@intlayer/engine 9.2.0 → 9.3.1

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 (326) hide show
  1. package/README.md +24 -24
  2. package/dist/assets/initConfig/templates/cjs.txt +1 -1
  3. package/dist/assets/initConfig/templates/mjs.txt +1 -1
  4. package/dist/assets/initConfig/templates/ts.txt +1 -1
  5. package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -2
  6. package/dist/cjs/_virtual/_utils_asset.cjs +2 -1
  7. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs +14 -2
  8. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs.map +1 -1
  9. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +26 -5
  10. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -1
  11. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs +43 -6
  12. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs.map +1 -1
  13. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs +2 -1
  14. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs.map +1 -1
  15. package/dist/cjs/buildIntlayerDictionary/writeNestedDictionary.cjs +96 -0
  16. package/dist/cjs/buildIntlayerDictionary/writeNestedDictionary.cjs.map +1 -0
  17. package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs +4 -2
  18. package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs.map +1 -1
  19. package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs.map +1 -1
  20. package/dist/cjs/cleanOutputDir.cjs.map +1 -1
  21. package/dist/cjs/cleanRemovedContentDeclaration.cjs +7 -4
  22. package/dist/cjs/cleanRemovedContentDeclaration.cjs.map +1 -1
  23. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs +5 -3
  24. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs.map +1 -1
  25. package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs.map +1 -1
  26. package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs.map +1 -1
  27. package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs.map +1 -1
  28. package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs.map +1 -1
  29. package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs.map +1 -1
  30. package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs.map +1 -1
  31. package/dist/cjs/createType/createModuleAugmentation.cjs +2 -1
  32. package/dist/cjs/createType/createModuleAugmentation.cjs.map +1 -1
  33. package/dist/cjs/createType/createType.cjs.map +1 -1
  34. package/dist/cjs/detectFormatCommand.cjs.map +1 -1
  35. package/dist/cjs/docReview/alignBlocks.cjs +1 -1
  36. package/dist/cjs/docReview/alignBlocks.cjs.map +1 -1
  37. package/dist/cjs/docReview/computeSimilarity.cjs +0 -1
  38. package/dist/cjs/docReview/computeSimilarity.cjs.map +1 -1
  39. package/dist/cjs/docReview/mapChangedLinesToBlocks.cjs +0 -1
  40. package/dist/cjs/docReview/mapChangedLinesToBlocks.cjs.map +1 -1
  41. package/dist/cjs/docReview/normalizeBlock.cjs +0 -1
  42. package/dist/cjs/docReview/normalizeBlock.cjs.map +1 -1
  43. package/dist/cjs/docReview/planActions.cjs +0 -1
  44. package/dist/cjs/docReview/planActions.cjs.map +1 -1
  45. package/dist/cjs/docReview/rebuildDocument.cjs +0 -1
  46. package/dist/cjs/docReview/rebuildDocument.cjs.map +1 -1
  47. package/dist/cjs/docReview/reviewReport.cjs +2 -1
  48. package/dist/cjs/docReview/reviewReport.cjs.map +1 -1
  49. package/dist/cjs/docReview/segmentDocument.cjs +0 -1
  50. package/dist/cjs/docReview/segmentDocument.cjs.map +1 -1
  51. package/dist/cjs/fetchDistantDictionaries.cjs +107 -13
  52. package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
  53. package/dist/cjs/filterInvalidDictionaries.cjs.map +1 -1
  54. package/dist/cjs/formatDictionary.cjs.map +1 -1
  55. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -1
  56. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs +4 -2
  57. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs.map +1 -1
  58. package/dist/cjs/handleContentDeclarationFileChange.cjs +6 -2
  59. package/dist/cjs/handleContentDeclarationFileChange.cjs.map +1 -1
  60. package/dist/cjs/handleContentDeclarationFileMoved.cjs.map +1 -1
  61. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs +4 -2
  62. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs.map +1 -1
  63. package/dist/cjs/init/cms.cjs.map +1 -1
  64. package/dist/cjs/init/frameworkSetup/nextAppRouter/detect.cjs.map +1 -1
  65. package/dist/cjs/init/frameworkSetup/nextAppRouter/index.cjs +1 -3
  66. package/dist/cjs/init/frameworkSetup/nextAppRouter/index.cjs.map +1 -1
  67. package/dist/cjs/init/frameworkSetup/nextAppRouter/restructure.cjs +2 -1
  68. package/dist/cjs/init/frameworkSetup/nextAppRouter/restructure.cjs.map +1 -1
  69. package/dist/cjs/init/frameworkSetup/nextAppRouter/templates.cjs +0 -1
  70. package/dist/cjs/init/frameworkSetup/nextAppRouter/templates.cjs.map +1 -1
  71. package/dist/cjs/init/frameworkSetup/tanstackStart/detect.cjs.map +1 -1
  72. package/dist/cjs/init/frameworkSetup/tanstackStart/index.cjs +3 -5
  73. package/dist/cjs/init/frameworkSetup/tanstackStart/index.cjs.map +1 -1
  74. package/dist/cjs/init/frameworkSetup/tanstackStart/restructure.cjs +2 -1
  75. package/dist/cjs/init/frameworkSetup/tanstackStart/restructure.cjs.map +1 -1
  76. package/dist/cjs/init/frameworkSetup/tanstackStart/templates.cjs +18 -12
  77. package/dist/cjs/init/frameworkSetup/tanstackStart/templates.cjs.map +1 -1
  78. package/dist/cjs/init/frameworkSetup/tanstackStart/transforms.cjs +58 -15
  79. package/dist/cjs/init/frameworkSetup/tanstackStart/transforms.cjs.map +1 -1
  80. package/dist/cjs/init/index.cjs +66 -38
  81. package/dist/cjs/init/index.cjs.map +1 -1
  82. package/dist/cjs/init/utils/configManipulation.cjs.map +1 -1
  83. package/dist/cjs/init/utils/fileSystem.cjs +3 -1
  84. package/dist/cjs/init/utils/fileSystem.cjs.map +1 -1
  85. package/dist/cjs/init/utils/githubActions.cjs.map +1 -1
  86. package/dist/cjs/init/utils/jsonParser.cjs +0 -1
  87. package/dist/cjs/init/utils/jsonParser.cjs.map +1 -1
  88. package/dist/cjs/init/utils/nextCompilerBabel.cjs.map +1 -1
  89. package/dist/cjs/init/utils/packageManager.cjs +4 -2
  90. package/dist/cjs/init/utils/packageManager.cjs.map +1 -1
  91. package/dist/cjs/init/utils/tsConfig.cjs.map +1 -1
  92. package/dist/cjs/init/utils/version.cjs +0 -1
  93. package/dist/cjs/init/utils/version.cjs.map +1 -1
  94. package/dist/cjs/initConfig/index.cjs +12 -8
  95. package/dist/cjs/initConfig/index.cjs.map +1 -1
  96. package/dist/cjs/installSkills/index.cjs.map +1 -1
  97. package/dist/cjs/listDictionariesPath.cjs +6 -5
  98. package/dist/cjs/listDictionariesPath.cjs.map +1 -1
  99. package/dist/cjs/listGitFiles.cjs.map +1 -1
  100. package/dist/cjs/listProjects.cjs +2 -1
  101. package/dist/cjs/listProjects.cjs.map +1 -1
  102. package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs +2 -1
  103. package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs.map +1 -1
  104. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +8 -5
  105. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -1
  106. package/dist/cjs/loadDictionaries/loadDictionaries.cjs +4 -2
  107. package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
  108. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs.map +1 -1
  109. package/dist/cjs/loadDictionaries/loadMarkdownContentDeclaration.cjs.map +1 -1
  110. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +3 -2
  111. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
  112. package/dist/cjs/loadDictionaries/loadYamlContentDeclaration.cjs +2 -1
  113. package/dist/cjs/loadDictionaries/loadYamlContentDeclaration.cjs.map +1 -1
  114. package/dist/cjs/loadDictionaries/log.cjs +38 -11
  115. package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
  116. package/dist/cjs/loadDictionaries/logTypeScriptErrors.cjs.map +1 -1
  117. package/dist/cjs/logConfigDetails.cjs +4 -3
  118. package/dist/cjs/logConfigDetails.cjs.map +1 -1
  119. package/dist/cjs/prepareIntlayer.cjs +5 -3
  120. package/dist/cjs/prepareIntlayer.cjs.map +1 -1
  121. package/dist/cjs/reduceDictionaryContent/applyMask.cjs +0 -1
  122. package/dist/cjs/reduceDictionaryContent/applyMask.cjs.map +1 -1
  123. package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs +2 -1
  124. package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs.map +1 -1
  125. package/dist/cjs/scan/calculateScore.cjs +0 -1
  126. package/dist/cjs/scan/calculateScore.cjs.map +1 -1
  127. package/dist/cjs/scan/checks.cjs +1 -1
  128. package/dist/cjs/scan/checks.cjs.map +1 -1
  129. package/dist/cjs/scan/parseHtml.cjs +0 -1
  130. package/dist/cjs/scan/parseHtml.cjs.map +1 -1
  131. package/dist/cjs/scan/scanWebsite.cjs.map +1 -1
  132. package/dist/cjs/syncPluginKit/createFileAdapter.cjs +2 -1
  133. package/dist/cjs/syncPluginKit/createFileAdapter.cjs.map +1 -1
  134. package/dist/cjs/syncPluginKit/createSyncPlugin.cjs +4 -1
  135. package/dist/cjs/syncPluginKit/createSyncPlugin.cjs.map +1 -1
  136. package/dist/cjs/syncPluginKit/extractKeyAndLocaleFromPath.cjs +0 -1
  137. package/dist/cjs/syncPluginKit/extractKeyAndLocaleFromPath.cjs.map +1 -1
  138. package/dist/cjs/syncPluginKit/filePathPatternHelpers.cjs +0 -1
  139. package/dist/cjs/syncPluginKit/filePathPatternHelpers.cjs.map +1 -1
  140. package/dist/cjs/utils/autoDecorateContent.cjs.map +1 -1
  141. package/dist/cjs/utils/babelParser.cjs.map +1 -1
  142. package/dist/cjs/utils/buildComponentFilesList.cjs.map +1 -1
  143. package/dist/cjs/utils/buildFilesList.cjs.map +1 -1
  144. package/dist/cjs/utils/chunkArray.cjs +23 -0
  145. package/dist/cjs/utils/chunkArray.cjs.map +1 -0
  146. package/dist/cjs/utils/formatter.cjs.map +1 -1
  147. package/dist/cjs/utils/getContentExtension.cjs +1 -4
  148. package/dist/cjs/utils/getContentExtension.cjs.map +1 -1
  149. package/dist/cjs/utils/getFormatFromExtension.cjs +0 -1
  150. package/dist/cjs/utils/getFormatFromExtension.cjs.map +1 -1
  151. package/dist/cjs/utils/getPathHash.cjs +0 -1
  152. package/dist/cjs/utils/getPathHash.cjs.map +1 -1
  153. package/dist/cjs/utils/index.cjs +2 -0
  154. package/dist/cjs/utils/mergeChunks.cjs +0 -1
  155. package/dist/cjs/utils/mergeChunks.cjs.map +1 -1
  156. package/dist/cjs/utils/pLimit.cjs +0 -1
  157. package/dist/cjs/utils/pLimit.cjs.map +1 -1
  158. package/dist/cjs/utils/readDictionariesFromDisk.cjs.map +1 -1
  159. package/dist/cjs/utils/reduceObjectFormat.cjs +0 -1
  160. package/dist/cjs/utils/reduceObjectFormat.cjs.map +1 -1
  161. package/dist/cjs/utils/resolveObjectPromises.cjs +0 -1
  162. package/dist/cjs/utils/resolveObjectPromises.cjs.map +1 -1
  163. package/dist/cjs/utils/resolveRelativePath.cjs +4 -1
  164. package/dist/cjs/utils/resolveRelativePath.cjs.map +1 -1
  165. package/dist/cjs/utils/runOnce.cjs +2 -2
  166. package/dist/cjs/utils/runOnce.cjs.map +1 -1
  167. package/dist/cjs/utils/runParallel/bin.cjs.map +1 -1
  168. package/dist/cjs/utils/runParallel/bootstrap.cjs +0 -1
  169. package/dist/cjs/utils/runParallel/bootstrap.cjs.map +1 -1
  170. package/dist/cjs/utils/runParallel/index.cjs.map +1 -1
  171. package/dist/cjs/utils/runParallel/spawnPosix.cjs.map +1 -1
  172. package/dist/cjs/utils/runParallel/spawnWin32.cjs.map +1 -1
  173. package/dist/cjs/utils/sortAlphabetically.cjs +0 -1
  174. package/dist/cjs/utils/sortAlphabetically.cjs.map +1 -1
  175. package/dist/cjs/utils/splitTextByLine.cjs +0 -1
  176. package/dist/cjs/utils/splitTextByLine.cjs.map +1 -1
  177. package/dist/cjs/utils/verifyIdenticObjectFormat.cjs +0 -1
  178. package/dist/cjs/utils/verifyIdenticObjectFormat.cjs.map +1 -1
  179. package/dist/cjs/watcher.cjs +4 -2
  180. package/dist/cjs/watcher.cjs.map +1 -1
  181. package/dist/cjs/writeConfiguration/index.cjs +2 -1
  182. package/dist/cjs/writeConfiguration/index.cjs.map +1 -1
  183. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs +0 -1
  184. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs.map +1 -1
  185. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs.map +1 -1
  186. package/dist/cjs/writeContentDeclaration/transformJSFile.cjs +173 -109
  187. package/dist/cjs/writeContentDeclaration/transformJSFile.cjs.map +1 -1
  188. package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs +6 -5
  189. package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs.map +1 -1
  190. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +9 -3
  191. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
  192. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +2 -1
  193. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs.map +1 -1
  194. package/dist/cjs/writeContentDeclaration/writeMarkdownFile.cjs +2 -1
  195. package/dist/cjs/writeContentDeclaration/writeMarkdownFile.cjs.map +1 -1
  196. package/dist/cjs/writeContentDeclaration/writeYamlFile.cjs +4 -2
  197. package/dist/cjs/writeContentDeclaration/writeYamlFile.cjs.map +1 -1
  198. package/dist/cjs/writeFileIfChanged.cjs.map +1 -1
  199. package/dist/esm/_virtual/_utils_asset.mjs +2 -1
  200. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs +15 -3
  201. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs.map +1 -1
  202. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs +26 -5
  203. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs.map +1 -1
  204. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs +43 -6
  205. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs.map +1 -1
  206. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs +2 -1
  207. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs.map +1 -1
  208. package/dist/esm/buildIntlayerDictionary/writeNestedDictionary.mjs +92 -0
  209. package/dist/esm/buildIntlayerDictionary/writeNestedDictionary.mjs.map +1 -0
  210. package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs +4 -2
  211. package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs.map +1 -1
  212. package/dist/esm/cleanRemovedContentDeclaration.mjs +7 -4
  213. package/dist/esm/cleanRemovedContentDeclaration.mjs.map +1 -1
  214. package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs +5 -3
  215. package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs.map +1 -1
  216. package/dist/esm/createType/createModuleAugmentation.mjs +2 -1
  217. package/dist/esm/createType/createModuleAugmentation.mjs.map +1 -1
  218. package/dist/esm/docReview/alignBlocks.mjs +1 -1
  219. package/dist/esm/docReview/alignBlocks.mjs.map +1 -1
  220. package/dist/esm/docReview/reviewReport.mjs +2 -1
  221. package/dist/esm/docReview/reviewReport.mjs.map +1 -1
  222. package/dist/esm/fetchDistantDictionaries.mjs +107 -13
  223. package/dist/esm/fetchDistantDictionaries.mjs.map +1 -1
  224. package/dist/esm/handleAdditionalContentDeclarationFile.mjs +4 -2
  225. package/dist/esm/handleAdditionalContentDeclarationFile.mjs.map +1 -1
  226. package/dist/esm/handleContentDeclarationFileChange.mjs +6 -2
  227. package/dist/esm/handleContentDeclarationFileChange.mjs.map +1 -1
  228. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs +4 -2
  229. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs.map +1 -1
  230. package/dist/esm/init/frameworkSetup/nextAppRouter/index.mjs +1 -3
  231. package/dist/esm/init/frameworkSetup/nextAppRouter/index.mjs.map +1 -1
  232. package/dist/esm/init/frameworkSetup/nextAppRouter/restructure.mjs +2 -1
  233. package/dist/esm/init/frameworkSetup/nextAppRouter/restructure.mjs.map +1 -1
  234. package/dist/esm/init/frameworkSetup/tanstackStart/index.mjs +4 -6
  235. package/dist/esm/init/frameworkSetup/tanstackStart/index.mjs.map +1 -1
  236. package/dist/esm/init/frameworkSetup/tanstackStart/restructure.mjs +2 -1
  237. package/dist/esm/init/frameworkSetup/tanstackStart/restructure.mjs.map +1 -1
  238. package/dist/esm/init/frameworkSetup/tanstackStart/templates.mjs +17 -10
  239. package/dist/esm/init/frameworkSetup/tanstackStart/templates.mjs.map +1 -1
  240. package/dist/esm/init/frameworkSetup/tanstackStart/transforms.mjs +59 -16
  241. package/dist/esm/init/frameworkSetup/tanstackStart/transforms.mjs.map +1 -1
  242. package/dist/esm/init/index.mjs +66 -38
  243. package/dist/esm/init/index.mjs.map +1 -1
  244. package/dist/esm/init/utils/configManipulation.mjs.map +1 -1
  245. package/dist/esm/init/utils/fileSystem.mjs +3 -1
  246. package/dist/esm/init/utils/fileSystem.mjs.map +1 -1
  247. package/dist/esm/init/utils/packageManager.mjs +4 -2
  248. package/dist/esm/init/utils/packageManager.mjs.map +1 -1
  249. package/dist/esm/initConfig/index.mjs +12 -8
  250. package/dist/esm/initConfig/index.mjs.map +1 -1
  251. package/dist/esm/listDictionariesPath.mjs +6 -5
  252. package/dist/esm/listDictionariesPath.mjs.map +1 -1
  253. package/dist/esm/listProjects.mjs +2 -1
  254. package/dist/esm/listProjects.mjs.map +1 -1
  255. package/dist/esm/loadDictionaries/getIntlayerBundle.mjs +2 -1
  256. package/dist/esm/loadDictionaries/getIntlayerBundle.mjs.map +1 -1
  257. package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +8 -5
  258. package/dist/esm/loadDictionaries/loadContentDeclaration.mjs.map +1 -1
  259. package/dist/esm/loadDictionaries/loadDictionaries.mjs +4 -2
  260. package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
  261. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs +3 -2
  262. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -1
  263. package/dist/esm/loadDictionaries/loadYamlContentDeclaration.mjs +2 -1
  264. package/dist/esm/loadDictionaries/loadYamlContentDeclaration.mjs.map +1 -1
  265. package/dist/esm/loadDictionaries/log.mjs +38 -11
  266. package/dist/esm/loadDictionaries/log.mjs.map +1 -1
  267. package/dist/esm/logConfigDetails.mjs +4 -3
  268. package/dist/esm/logConfigDetails.mjs.map +1 -1
  269. package/dist/esm/prepareIntlayer.mjs +5 -3
  270. package/dist/esm/prepareIntlayer.mjs.map +1 -1
  271. package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs +2 -1
  272. package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs.map +1 -1
  273. package/dist/esm/scan/checks.mjs +1 -1
  274. package/dist/esm/scan/checks.mjs.map +1 -1
  275. package/dist/esm/syncPluginKit/createFileAdapter.mjs +2 -1
  276. package/dist/esm/syncPluginKit/createFileAdapter.mjs.map +1 -1
  277. package/dist/esm/syncPluginKit/createSyncPlugin.mjs +4 -1
  278. package/dist/esm/syncPluginKit/createSyncPlugin.mjs.map +1 -1
  279. package/dist/esm/utils/babelParser.mjs.map +1 -1
  280. package/dist/esm/utils/chunkArray.mjs +22 -0
  281. package/dist/esm/utils/chunkArray.mjs.map +1 -0
  282. package/dist/esm/utils/getContentExtension.mjs +1 -3
  283. package/dist/esm/utils/getContentExtension.mjs.map +1 -1
  284. package/dist/esm/utils/index.mjs +2 -1
  285. package/dist/esm/utils/resolveRelativePath.mjs +4 -1
  286. package/dist/esm/utils/resolveRelativePath.mjs.map +1 -1
  287. package/dist/esm/utils/runOnce.mjs +2 -2
  288. package/dist/esm/utils/runOnce.mjs.map +1 -1
  289. package/dist/esm/watcher.mjs +4 -2
  290. package/dist/esm/watcher.mjs.map +1 -1
  291. package/dist/esm/writeConfiguration/index.mjs +2 -1
  292. package/dist/esm/writeConfiguration/index.mjs.map +1 -1
  293. package/dist/esm/writeContentDeclaration/transformJSFile.mjs +173 -109
  294. package/dist/esm/writeContentDeclaration/transformJSFile.mjs.map +1 -1
  295. package/dist/esm/writeContentDeclaration/transformJSONFile.mjs +6 -5
  296. package/dist/esm/writeContentDeclaration/transformJSONFile.mjs.map +1 -1
  297. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +9 -3
  298. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
  299. package/dist/esm/writeContentDeclaration/writeJSFile.mjs +2 -1
  300. package/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -1
  301. package/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs +2 -1
  302. package/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs.map +1 -1
  303. package/dist/esm/writeContentDeclaration/writeYamlFile.mjs +4 -2
  304. package/dist/esm/writeContentDeclaration/writeYamlFile.mjs.map +1 -1
  305. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -1
  306. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +14 -2
  307. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -1
  308. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts +16 -2
  309. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -1
  310. package/dist/types/buildIntlayerDictionary/writeNestedDictionary.d.ts +54 -0
  311. package/dist/types/buildIntlayerDictionary/writeNestedDictionary.d.ts.map +1 -0
  312. package/dist/types/fetchDistantDictionaries.d.ts +26 -0
  313. package/dist/types/fetchDistantDictionaries.d.ts.map +1 -1
  314. package/dist/types/formatDictionary.d.ts +2 -0
  315. package/dist/types/formatDictionary.d.ts.map +1 -1
  316. package/dist/types/init/frameworkSetup/tanstackStart/templates.d.ts +9 -4
  317. package/dist/types/init/frameworkSetup/tanstackStart/templates.d.ts.map +1 -1
  318. package/dist/types/init/frameworkSetup/tanstackStart/transforms.d.ts +6 -2
  319. package/dist/types/init/frameworkSetup/tanstackStart/transforms.d.ts.map +1 -1
  320. package/dist/types/loadDictionaries/log.d.ts +16 -1
  321. package/dist/types/loadDictionaries/log.d.ts.map +1 -1
  322. package/dist/types/utils/chunkArray.d.ts +16 -0
  323. package/dist/types/utils/chunkArray.d.ts.map +1 -0
  324. package/dist/types/utils/index.d.ts +2 -1
  325. package/dist/types/writeContentDeclaration/transformJSFile.d.ts.map +1 -1
  326. package/package.json +11 -11
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
2
  //#region src/init/frameworkSetup/tanstackStart/templates.ts
4
3
  /**
5
4
  * File templates for a fresh TanStack Start integration. These are only written
@@ -35,25 +34,30 @@ export const Route = createFileRoute("/${localeSegment}")({
35
34
  `;
36
35
  /**
37
36
  * Root route document (`routes/__root.tsx`) providing `<html>` + the Intlayer
38
- * provider, with the locale read from the `{-$locale}` route param.
37
+ * provider, with the locale read from the locale segment route params.
38
+ *
39
+ * The route is reached through `getRouteApi(<route id>)` rather than by
40
+ * importing `<segment>/route`, so the root never imports a child route module —
41
+ * the recommended way to consume another route's typed hooks.
39
42
  */
40
- const ROOT_TEMPLATE_TS = `import {
43
+ const buildRootTemplateTs = (localeSegment) => `import {
41
44
  createRootRoute,
45
+ getRouteApi,
42
46
  HeadContent,
43
47
  Scripts,
44
- useParams,
45
48
  } from "@tanstack/react-router";
46
49
  import { defaultLocale, getHTMLTextDir } from "intlayer";
47
50
  import type { ReactNode } from "react";
48
51
  import { IntlayerProvider } from "react-intlayer";
49
52
 
53
+ const localeRoute = getRouteApi("/${localeSegment}");
54
+
50
55
  export const Route = createRootRoute({
51
56
  shellComponent: RootDocument,
52
57
  });
53
58
 
54
59
  function RootDocument({ children }: { children: ReactNode }) {
55
- const params = useParams({ strict: false });
56
- const locale = params.locale ?? defaultLocale;
60
+ const { locale = defaultLocale } = localeRoute.useParams();
57
61
 
58
62
  return (
59
63
  <html dir={getHTMLTextDir(locale)} lang={locale}>
@@ -68,22 +72,24 @@ function RootDocument({ children }: { children: ReactNode }) {
68
72
  );
69
73
  }
70
74
  `;
71
- const ROOT_TEMPLATE_JS = `import {
75
+ /** JavaScript counterpart of {@link buildRootTemplateTs}. */
76
+ const buildRootTemplateJs = (localeSegment) => `import {
72
77
  createRootRoute,
78
+ getRouteApi,
73
79
  HeadContent,
74
80
  Scripts,
75
- useParams,
76
81
  } from "@tanstack/react-router";
77
82
  import { defaultLocale, getHTMLTextDir } from "intlayer";
78
83
  import { IntlayerProvider } from "react-intlayer";
79
84
 
85
+ const localeRoute = getRouteApi("/${localeSegment}");
86
+
80
87
  export const Route = createRootRoute({
81
88
  shellComponent: RootDocument,
82
89
  });
83
90
 
84
91
  function RootDocument({ children }) {
85
- const params = useParams({ strict: false });
86
- const locale = params.locale ?? defaultLocale;
92
+ const { locale = defaultLocale } = localeRoute.useParams();
87
93
 
88
94
  return (
89
95
  <html dir={getHTMLTextDir(locale)} lang={locale}>
@@ -100,7 +106,7 @@ function RootDocument({ children }) {
100
106
  `;
101
107
 
102
108
  //#endregion
103
- exports.ROOT_TEMPLATE_JS = ROOT_TEMPLATE_JS;
104
- exports.ROOT_TEMPLATE_TS = ROOT_TEMPLATE_TS;
105
109
  exports.buildLocaleRouteTemplate = buildLocaleRouteTemplate;
110
+ exports.buildRootTemplateJs = buildRootTemplateJs;
111
+ exports.buildRootTemplateTs = buildRootTemplateTs;
106
112
  //# sourceMappingURL=templates.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"templates.cjs","names":[],"sources":["../../../../../src/init/frameworkSetup/tanstackStart/templates.ts"],"sourcesContent":["/**\n * File templates for a fresh TanStack Start integration. These are only written\n * when the target file does not exist — they never overwrite user code.\n */\n\n/**\n * Builds the locale segment route (`routes/<localeSegment>/route.tsx`) for the\n * given segment. The optional `{-$locale}` param makes the default locale\n * prefix-free, while the required `$locale` param (`prefix-all`) prefixes every\n * locale; in both cases `validatePrefix` redirects unknown prefixes to a valid\n * one. Identical for TypeScript and JavaScript projects.\n */\nexport const buildLocaleRouteTemplate = (\n localeSegment: string\n): string => `import { createFileRoute, Outlet, redirect } from \"@tanstack/react-router\";\nimport { validatePrefix } from \"intlayer\";\n\nexport const Route = createFileRoute(\"/${localeSegment}\")({\n beforeLoad: ({ params }) => {\n // beforeLoad runs on both client and server, so resolve the locale from the\n // route params rather than from request headers.\n const { isValid, localePrefix } = validatePrefix(params.locale);\n\n // A valid (or absent, i.e. default) locale prefix is fine as-is.\n if (isValid) return;\n\n // Otherwise redirect to the same route with a valid locale prefix.\n throw redirect({\n params: { locale: localePrefix },\n to: \"/${localeSegment}\",\n });\n },\n component: Outlet,\n});\n`;\n\n/**\n * Root route document (`routes/__root.tsx`) providing `<html>` + the Intlayer\n * provider, with the locale read from the `{-$locale}` route param.\n */\nexport const ROOT_TEMPLATE_TS = `import {\n createRootRoute,\n HeadContent,\n Scripts,\n useParams,\n} from \"@tanstack/react-router\";\nimport { defaultLocale, getHTMLTextDir } from \"intlayer\";\nimport type { ReactNode } from \"react\";\nimport { IntlayerProvider } from \"react-intlayer\";\n\nexport const Route = createRootRoute({\n shellComponent: RootDocument,\n});\n\nfunction RootDocument({ children }: { children: ReactNode }) {\n const params = useParams({ strict: false });\n const locale = params.locale ?? defaultLocale;\n\n return (\n <html dir={getHTMLTextDir(locale)} lang={locale}>\n <head>\n <HeadContent />\n </head>\n <body>\n <IntlayerProvider locale={locale}>{children}</IntlayerProvider>\n <Scripts />\n </body>\n </html>\n );\n}\n`;\n\nexport const ROOT_TEMPLATE_JS = `import {\n createRootRoute,\n HeadContent,\n Scripts,\n useParams,\n} from \"@tanstack/react-router\";\nimport { defaultLocale, getHTMLTextDir } from \"intlayer\";\nimport { IntlayerProvider } from \"react-intlayer\";\n\nexport const Route = createRootRoute({\n shellComponent: RootDocument,\n});\n\nfunction RootDocument({ children }) {\n const params = useParams({ strict: false });\n const locale = params.locale ?? defaultLocale;\n\n return (\n <html dir={getHTMLTextDir(locale)} lang={locale}>\n <head>\n <HeadContent />\n </head>\n <body>\n <IntlayerProvider locale={locale}>{children}</IntlayerProvider>\n <Scripts />\n </body>\n </html>\n );\n}\n`;\n"],"mappings":";;;;;;;;;;;;;;AAYA,MAAa,4BACX,kBACW;;;yCAG4B,cAAc;;;;;;;;;;;;cAYzC,cAAc;;;;;;;;;;AAW5B,MAAa,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgChC,MAAa,mBAAmB"}
1
+ {"version":3,"file":"templates.cjs","names":[],"sources":["../../../../../src/init/frameworkSetup/tanstackStart/templates.ts"],"sourcesContent":["/**\n * File templates for a fresh TanStack Start integration. These are only written\n * when the target file does not exist — they never overwrite user code.\n */\n\n/**\n * Builds the locale segment route (`routes/<localeSegment>/route.tsx`) for the\n * given segment. The optional `{-$locale}` param makes the default locale\n * prefix-free, while the required `$locale` param (`prefix-all`) prefixes every\n * locale; in both cases `validatePrefix` redirects unknown prefixes to a valid\n * one. Identical for TypeScript and JavaScript projects.\n */\nexport const buildLocaleRouteTemplate = (\n localeSegment: string\n): string => `import { createFileRoute, Outlet, redirect } from \"@tanstack/react-router\";\nimport { validatePrefix } from \"intlayer\";\n\nexport const Route = createFileRoute(\"/${localeSegment}\")({\n beforeLoad: ({ params }) => {\n // beforeLoad runs on both client and server, so resolve the locale from the\n // route params rather than from request headers.\n const { isValid, localePrefix } = validatePrefix(params.locale);\n\n // A valid (or absent, i.e. default) locale prefix is fine as-is.\n if (isValid) return;\n\n // Otherwise redirect to the same route with a valid locale prefix.\n throw redirect({\n params: { locale: localePrefix },\n to: \"/${localeSegment}\",\n });\n },\n component: Outlet,\n});\n`;\n\n/**\n * Root route document (`routes/__root.tsx`) providing `<html>` + the Intlayer\n * provider, with the locale read from the locale segment route params.\n *\n * The route is reached through `getRouteApi(<route id>)` rather than by\n * importing `<segment>/route`, so the root never imports a child route module —\n * the recommended way to consume another route's typed hooks.\n */\nexport const buildRootTemplateTs = (localeSegment: string): string => `import {\n createRootRoute,\n getRouteApi,\n HeadContent,\n Scripts,\n} from \"@tanstack/react-router\";\nimport { defaultLocale, getHTMLTextDir } from \"intlayer\";\nimport type { ReactNode } from \"react\";\nimport { IntlayerProvider } from \"react-intlayer\";\n\nconst localeRoute = getRouteApi(\"/${localeSegment}\");\n\nexport const Route = createRootRoute({\n shellComponent: RootDocument,\n});\n\nfunction RootDocument({ children }: { children: ReactNode }) {\n const { locale = defaultLocale } = localeRoute.useParams();\n\n return (\n <html dir={getHTMLTextDir(locale)} lang={locale}>\n <head>\n <HeadContent />\n </head>\n <body>\n <IntlayerProvider locale={locale}>{children}</IntlayerProvider>\n <Scripts />\n </body>\n </html>\n );\n}\n`;\n\n/** JavaScript counterpart of {@link buildRootTemplateTs}. */\nexport const buildRootTemplateJs = (localeSegment: string): string => `import {\n createRootRoute,\n getRouteApi,\n HeadContent,\n Scripts,\n} from \"@tanstack/react-router\";\nimport { defaultLocale, getHTMLTextDir } from \"intlayer\";\nimport { IntlayerProvider } from \"react-intlayer\";\n\nconst localeRoute = getRouteApi(\"/${localeSegment}\");\n\nexport const Route = createRootRoute({\n shellComponent: RootDocument,\n});\n\nfunction RootDocument({ children }) {\n const { locale = defaultLocale } = localeRoute.useParams();\n\n return (\n <html dir={getHTMLTextDir(locale)} lang={locale}>\n <head>\n <HeadContent />\n </head>\n <body>\n <IntlayerProvider locale={locale}>{children}</IntlayerProvider>\n <Scripts />\n </body>\n </html>\n );\n}\n`;\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAa,4BACX,kBACW;;;yCAG4B,cAAc;;;;;;;;;;;;cAYzC,cAAc;;;;;;;;;;;;;;AAe5B,MAAa,uBAAuB,kBAAkC;;;;;;;;;;oCAUlC,cAAc;;;;;;;;;;;;;;;;;;;;;;;AAwBlD,MAAa,uBAAuB,kBAAkC;;;;;;;;;oCASlC,cAAc"}
@@ -7,6 +7,8 @@ recast = require_runtime.__toESM(recast);
7
7
 
8
8
  //#region src/init/frameworkSetup/tanstackStart/transforms.ts
9
9
  const { builders: b, namedTypes: n } = recast.types;
10
+ /** Module-scope identifier bound to the locale route's typed API. */
11
+ const LOCALE_ROUTE_API_VARIABLE = "localeRoute";
10
12
  /** babel-ts parser handles TypeScript *and* JSX. */
11
13
  const parseTsx = (code) => recast.parse(code, { parser: require_utils_babelParser.babelTsParser });
12
14
  /**
@@ -51,27 +53,59 @@ const patternBindsName = (node, name) => {
51
53
  }
52
54
  };
53
55
  /**
54
- * Inserts `const locale = …` once, at the top of the function body. A single
55
- * self-contained statement is used (rather than an intermediate `params` const)
56
- * so it can never collide with a `params` variable the document already
57
- * declares. Expression-bodied arrow functions are first converted to a block so
58
- * the declaration has somewhere to live.
56
+ * Inserts `const { locale = defaultLocale } = localeRoute.useParams();` once, at
57
+ * the top of the function body. The destructuring form binds only `locale`, so
58
+ * it can never collide with a `params` variable the document already declares.
59
+ * Expression-bodied arrow functions are first converted to a block so the
60
+ * declaration has somewhere to live.
59
61
  *
60
62
  * No-ops when `locale` is already bound in the function — whether as a simple
61
63
  * identifier, through a destructuring pattern (e.g.
62
- * `const { locale = defaultLocale } = useLoaderData()`), or as a function
64
+ * `const { locale = defaultLocale } = Route.useLoaderData()`), or as a function
63
65
  * parameter — so the injected declaration never collides with one the document
64
66
  * already provides (which would produce an
65
67
  * `Identifier 'locale' has already been declared` parse error).
68
+ *
69
+ * @returns `true` when the declaration was injected, `false` when the document
70
+ * already binds `locale` itself. Callers use this to skip the imports and the
71
+ * route API declaration the injected statement would have needed.
66
72
  */
67
73
  const ensureLocaleFromParams = (funcNode) => {
68
74
  if (funcNode.body?.type !== "BlockStatement") funcNode.body = b.blockStatement([b.returnStatement(funcNode.body)]);
69
75
  const declaredInBody = funcNode.body.body.some((stmt) => stmt.type === "VariableDeclaration" && stmt.declarations.some((d) => patternBindsName(d.id, "locale")));
70
76
  const declaredInParams = (funcNode.params ?? []).some((param) => patternBindsName(param, "locale"));
71
- if (declaredInBody || declaredInParams) return;
72
- const statement = parseTsx("const locale = useParams({ strict: false }).locale ?? defaultLocale;").program.body[0];
77
+ if (declaredInBody || declaredInParams) return false;
78
+ const statement = parseTsx(`const { locale = defaultLocale } = ${LOCALE_ROUTE_API_VARIABLE}.useParams();`).program.body[0];
73
79
  funcNode.body.body.unshift(statement);
80
+ return true;
74
81
  };
82
+ /**
83
+ * Ensures the module-scope `const localeRoute = getRouteApi("/<segment>");`
84
+ * declaration the injected locale statement reads from, inserted right after the
85
+ * import block.
86
+ *
87
+ * Referencing the locale route by id keeps the root document free of an import
88
+ * of `<segment>/route` — importing a child route module from `__root` is
89
+ * discouraged, since the generated route tree already imports the root.
90
+ *
91
+ * No-ops when `localeRoute` is already bound at module scope, reusing that
92
+ * binding rather than redeclaring it (which would be a parse error).
93
+ *
94
+ * @returns `true` when the declaration was inserted, `false` when an existing
95
+ * binding was reused.
96
+ */
97
+ const ensureLocaleRouteApi = (ast, localeSegment) => {
98
+ if (require_init_utils_astImports.isModuleScopeBinding(ast, LOCALE_ROUTE_API_VARIABLE)) return false;
99
+ const declaration = parseTsx(`const ${LOCALE_ROUTE_API_VARIABLE} = getRouteApi("/${localeSegment}");`).program.body[0];
100
+ ast.program.body.splice(require_init_utils_astImports.firstInsertIndex(ast), 0, declaration);
101
+ return true;
102
+ };
103
+ /**
104
+ * Puts a blank line between the import block and the inserted route API
105
+ * declaration — recast prints a spliced statement flush against the preceding
106
+ * line, which reads as part of the imports.
107
+ */
108
+ const separateRouteApiDeclaration = (printedCode) => printedCode.replace(new RegExp(`([^\\n])\\n(const ${LOCALE_ROUTE_API_VARIABLE} = getRouteApi\\()`), "$1\n\n$2");
75
109
  /** Sets `lang={locale}` and `dir={getHTMLTextDir(locale)}` on the first `<html>` element. */
76
110
  const setHtmlLangAndDir = (ast) => {
77
111
  recast.visit(ast, { visitJSXOpeningElement(path) {
@@ -83,7 +117,7 @@ const setHtmlLangAndDir = (ast) => {
83
117
  const upsertAttribute = (name, value) => {
84
118
  const existing = node.attributes?.find((attr) => attr.type === "JSXAttribute" && attr.name?.name === name);
85
119
  if (existing) existing.value = value;
86
- else node.attributes.push(b.jsxAttribute(b.jsxIdentifier(name), value));
120
+ else node.attributes?.push(b.jsxAttribute(b.jsxIdentifier(name), value));
87
121
  };
88
122
  upsertAttribute("lang", b.jsxExpressionContainer(b.identifier("locale")));
89
123
  upsertAttribute("dir", b.jsxExpressionContainer(b.callExpression(b.identifier("getHTMLTextDir"), [b.identifier("locale")])));
@@ -92,12 +126,16 @@ const setHtmlLangAndDir = (ast) => {
92
126
  };
93
127
  /**
94
128
  * Wraps the `{children}` of a TanStack Start root document with
95
- * `IntlayerProvider`, deriving the locale from the `{-$locale}` route param.
129
+ * `IntlayerProvider`, deriving the locale from the locale segment route params.
96
130
  * Safe and idempotent: bails (returns the original code) when the provider is
97
131
  * already present, when no `<html>` document function is found, or when there is
98
132
  * no `{children}` placeholder to wrap.
133
+ *
134
+ * @param code Source of the project's `__root` document.
135
+ * @param localeSegment Locale segment directory in use — `{-$locale}` for every
136
+ * routing mode but `prefix-all`, which uses the required `$locale`.
99
137
  */
100
- const wrapRootWithProvider = (code) => {
138
+ const wrapRootWithProvider = (code, localeSegment) => {
101
139
  const ast = parseTsx(code);
102
140
  if (code.includes("IntlayerProvider")) return {
103
141
  code,
@@ -125,14 +163,19 @@ const wrapRootWithProvider = (code) => {
125
163
  code,
126
164
  status: "skipped"
127
165
  };
166
+ const injectedLocaleDeclaration = ensureLocaleFromParams(funcNode);
128
167
  require_init_utils_astImports.ensureNamedImport(ast, "IntlayerProvider", "react-intlayer");
129
- require_init_utils_astImports.ensureNamedImport(ast, "useParams", "@tanstack/react-router");
130
- require_init_utils_astImports.ensureNamedImport(ast, "defaultLocale", "intlayer");
168
+ let insertedRouteApi = false;
169
+ if (injectedLocaleDeclaration) {
170
+ require_init_utils_astImports.ensureNamedImport(ast, "getRouteApi", "@tanstack/react-router");
171
+ require_init_utils_astImports.ensureNamedImport(ast, "defaultLocale", "intlayer");
172
+ insertedRouteApi = ensureLocaleRouteApi(ast, localeSegment);
173
+ }
131
174
  require_init_utils_astImports.ensureNamedImport(ast, "getHTMLTextDir", "intlayer");
132
- ensureLocaleFromParams(funcNode);
133
175
  setHtmlLangAndDir(ast);
176
+ const printedCode = recast.print(ast).code;
134
177
  return {
135
- code: recast.print(ast).code,
178
+ code: insertedRouteApi ? separateRouteApiDeclaration(printedCode) : printedCode,
136
179
  status: "wrapped"
137
180
  };
138
181
  };
@@ -1 +1 @@
1
- {"version":3,"file":"transforms.cjs","names":["babelTsParser"],"sources":["../../../../../src/init/frameworkSetup/tanstackStart/transforms.ts"],"sourcesContent":["import * as recast from 'recast';\nimport { babelTsParser } from '../../../utils/babelParser';\nimport { ensureNamedImport } from '../../utils/astImports';\n\nconst { builders: b, namedTypes: n } = recast.types;\n\n/** babel-ts parser handles TypeScript *and* JSX. */\nconst parseTsx = (code: string): any =>\n recast.parse(code, { parser: babelTsParser });\n\n/** Result of a source transform. `code` is unchanged for any non-`wrapped` status. */\nexport type TransformResult = {\n code: string;\n status: 'wrapped' | 'already' | 'skipped';\n};\n\n/**\n * Finds the single function that returns the `<html>` document element. Returns\n * `null` when there is no such function, or more than one (ambiguous).\n */\nconst findHtmlDocumentFunction = (ast: any): any => {\n const found = new Set<any>();\n\n recast.visit(ast, {\n visitJSXOpeningElement(path) {\n const node = path.node;\n if (node.name?.type === 'JSXIdentifier' && node.name.name === 'html') {\n // Walk up to the nearest enclosing function node.\n let current = path.parentPath;\n while (current) {\n const value = current.value;\n if (\n value &&\n (n.FunctionDeclaration.check(value) ||\n n.FunctionExpression.check(value) ||\n n.ArrowFunctionExpression.check(value))\n ) {\n found.add(value);\n break;\n }\n current = current.parentPath;\n }\n }\n this.traverse(path);\n },\n });\n\n return found.size === 1 ? [...found][0] : null;\n};\n\n/**\n * Whether the binding pattern `node` introduces a variable named `name`.\n * Recurses through destructuring patterns so all of `const locale`,\n * `const { locale } = …`, `const { locale = fallback } = …`,\n * `const { foo: locale } = …`, `const [locale] = …` and `...locale` are\n * detected — not just a bare identifier.\n */\nconst patternBindsName = (node: any, name: string): boolean => {\n if (!node) return false;\n switch (node.type) {\n case 'Identifier':\n return node.name === name;\n case 'AssignmentPattern':\n // `locale = fallback`\n return patternBindsName(node.left, name);\n case 'RestElement':\n // `...locale`\n return patternBindsName(node.argument, name);\n case 'ArrayPattern':\n return node.elements.some((element: any) =>\n patternBindsName(element, name)\n );\n case 'ObjectPattern':\n return node.properties.some((property: any) =>\n property.type === 'RestElement'\n ? patternBindsName(property.argument, name)\n : // The *value* is the binding target (`{ foo: locale }` binds `locale`).\n patternBindsName(property.value, name)\n );\n default:\n return false;\n }\n};\n\n/**\n * Inserts `const locale = …` once, at the top of the function body. A single\n * self-contained statement is used (rather than an intermediate `params` const)\n * so it can never collide with a `params` variable the document already\n * declares. Expression-bodied arrow functions are first converted to a block so\n * the declaration has somewhere to live.\n *\n * No-ops when `locale` is already bound in the function — whether as a simple\n * identifier, through a destructuring pattern (e.g.\n * `const { locale = defaultLocale } = useLoaderData()`), or as a function\n * parameter — so the injected declaration never collides with one the document\n * already provides (which would produce an\n * `Identifier 'locale' has already been declared` parse error).\n */\nconst ensureLocaleFromParams = (funcNode: any): void => {\n if (funcNode.body?.type !== 'BlockStatement') {\n funcNode.body = b.blockStatement([b.returnStatement(funcNode.body)]);\n }\n\n const declaredInBody = funcNode.body.body.some(\n (stmt: any) =>\n stmt.type === 'VariableDeclaration' &&\n stmt.declarations.some((d: any) => patternBindsName(d.id, 'locale'))\n );\n const declaredInParams = (funcNode.params ?? []).some((param: any) =>\n patternBindsName(param, 'locale')\n );\n if (declaredInBody || declaredInParams) return;\n\n const statement = parseTsx(\n 'const locale = useParams({ strict: false }).locale ?? defaultLocale;'\n ).program.body[0];\n funcNode.body.body.unshift(statement);\n};\n\n/** Sets `lang={locale}` and `dir={getHTMLTextDir(locale)}` on the first `<html>` element. */\nconst setHtmlLangAndDir = (ast: any): void => {\n recast.visit(ast, {\n visitJSXOpeningElement(path) {\n const node = path.node;\n if (node.name?.type !== 'JSXIdentifier' || node.name.name !== 'html') {\n this.traverse(path);\n return;\n }\n\n const upsertAttribute = (name: string, value: any): void => {\n const existing = node.attributes?.find(\n (attr: any) =>\n attr.type === 'JSXAttribute' && attr.name?.name === name\n ) as any;\n if (existing) {\n existing.value = value;\n } else {\n node.attributes.push(b.jsxAttribute(b.jsxIdentifier(name), value));\n }\n };\n\n upsertAttribute('lang', b.jsxExpressionContainer(b.identifier('locale')));\n upsertAttribute(\n 'dir',\n b.jsxExpressionContainer(\n b.callExpression(b.identifier('getHTMLTextDir'), [\n b.identifier('locale'),\n ])\n )\n );\n return false;\n },\n });\n};\n\n/**\n * Wraps the `{children}` of a TanStack Start root document with\n * `IntlayerProvider`, deriving the locale from the `{-$locale}` route param.\n * Safe and idempotent: bails (returns the original code) when the provider is\n * already present, when no `<html>` document function is found, or when there is\n * no `{children}` placeholder to wrap.\n */\nexport const wrapRootWithProvider = (code: string): TransformResult => {\n const ast = parseTsx(code);\n\n if (code.includes('IntlayerProvider')) return { code, status: 'already' };\n\n const funcNode = findHtmlDocumentFunction(ast);\n if (!funcNode) return { code, status: 'skipped' };\n\n let wrapped = false;\n recast.visit(funcNode, {\n visitJSXExpressionContainer(path) {\n if (wrapped) return false;\n const expression = path.node.expression;\n if (expression?.type === 'Identifier' && expression.name === 'children') {\n const template = parseTsx(\n 'const __wrap = <IntlayerProvider locale={locale}>{__child__}</IntlayerProvider>;'\n );\n const providerElement = template.program.body[0].declarations[0].init;\n providerElement.children = [path.node];\n path.replace(providerElement);\n wrapped = true;\n return false;\n }\n this.traverse(path);\n },\n });\n\n if (!wrapped) return { code, status: 'skipped' };\n\n ensureNamedImport(ast, 'IntlayerProvider', 'react-intlayer');\n ensureNamedImport(ast, 'useParams', '@tanstack/react-router');\n ensureNamedImport(ast, 'defaultLocale', 'intlayer');\n ensureNamedImport(ast, 'getHTMLTextDir', 'intlayer');\n ensureLocaleFromParams(funcNode);\n setHtmlLangAndDir(ast);\n\n return { code: recast.print(ast).code, status: 'wrapped' };\n};\n"],"mappings":";;;;;;;;AAIA,MAAM,EAAE,UAAU,GAAG,YAAY,MAAM,OAAO;;AAG9C,MAAM,YAAY,SAChB,OAAO,MAAM,MAAM,EAAE,QAAQA,wCAAc,CAAC;;;;;AAY9C,MAAM,4BAA4B,QAAkB;CAClD,MAAM,wBAAQ,IAAI,IAAS;CAE3B,OAAO,MAAM,KAAK,EAChB,uBAAuB,MAAM;EAC3B,MAAM,OAAO,KAAK;EAClB,IAAI,KAAK,MAAM,SAAS,mBAAmB,KAAK,KAAK,SAAS,QAAQ;GAEpE,IAAI,UAAU,KAAK;GACnB,OAAO,SAAS;IACd,MAAM,QAAQ,QAAQ;IACtB,IACE,UACC,EAAE,oBAAoB,MAAM,KAAK,KAChC,EAAE,mBAAmB,MAAM,KAAK,KAChC,EAAE,wBAAwB,MAAM,KAAK,IACvC;KACA,MAAM,IAAI,KAAK;KACf;IACF;IACA,UAAU,QAAQ;GACpB;EACF;EACA,KAAK,SAAS,IAAI;CACpB,EAC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AAU;CAClD,gDAAkB,KAAK,kBAAkB,UAAU;CACnD,uBAAuB,QAAQ;CAC/B,kBAAkB,GAAG;CAErB,OAAO;EAAE,MAAM,OAAO,MAAM,GAAG,CAAC,CAAC;EAAM,QAAQ;CAAU;AAC3D"}
1
+ {"version":3,"file":"transforms.cjs","names":["babelTsParser","isModuleScopeBinding","firstInsertIndex"],"sources":["../../../../../src/init/frameworkSetup/tanstackStart/transforms.ts"],"sourcesContent":["import * as recast from 'recast';\nimport { babelTsParser } from '../../../utils/babelParser';\nimport {\n ensureNamedImport,\n firstInsertIndex,\n isModuleScopeBinding,\n} from '../../utils/astImports';\n\nconst { builders: b, namedTypes: n } = recast.types;\n\n/** Module-scope identifier bound to the locale route's typed API. */\nconst LOCALE_ROUTE_API_VARIABLE = 'localeRoute';\n\n/** babel-ts parser handles TypeScript *and* JSX. */\nconst parseTsx = (code: string): any =>\n recast.parse(code, { parser: babelTsParser });\n\n/** Result of a source transform. `code` is unchanged for any non-`wrapped` status. */\nexport type TransformResult = {\n code: string;\n status: 'wrapped' | 'already' | 'skipped';\n};\n\n/**\n * Finds the single function that returns the `<html>` document element. Returns\n * `null` when there is no such function, or more than one (ambiguous).\n */\nconst findHtmlDocumentFunction = (ast: any): any => {\n const found = new Set<any>();\n\n recast.visit(ast, {\n visitJSXOpeningElement(path) {\n const node = path.node;\n if (node.name?.type === 'JSXIdentifier' && node.name.name === 'html') {\n // Walk up to the nearest enclosing function node.\n let current = path.parentPath;\n while (current) {\n const value = current.value;\n if (\n value &&\n (n.FunctionDeclaration.check(value) ||\n n.FunctionExpression.check(value) ||\n n.ArrowFunctionExpression.check(value))\n ) {\n found.add(value);\n break;\n }\n current = current.parentPath;\n }\n }\n this.traverse(path);\n },\n });\n\n return found.size === 1 ? [...found][0] : null;\n};\n\n/**\n * Whether the binding pattern `node` introduces a variable named `name`.\n * Recurses through destructuring patterns so all of `const locale`,\n * `const { locale } = …`, `const { locale = fallback } = …`,\n * `const { foo: locale } = …`, `const [locale] = …` and `...locale` are\n * detected — not just a bare identifier.\n */\nconst patternBindsName = (node: any, name: string): boolean => {\n if (!node) return false;\n switch (node.type) {\n case 'Identifier':\n return node.name === name;\n case 'AssignmentPattern':\n // `locale = fallback`\n return patternBindsName(node.left, name);\n case 'RestElement':\n // `...locale`\n return patternBindsName(node.argument, name);\n case 'ArrayPattern':\n return node.elements.some((element: any) =>\n patternBindsName(element, name)\n );\n case 'ObjectPattern':\n return node.properties.some((property: any) =>\n property.type === 'RestElement'\n ? patternBindsName(property.argument, name)\n : // The *value* is the binding target (`{ foo: locale }` binds `locale`).\n patternBindsName(property.value, name)\n );\n default:\n return false;\n }\n};\n\n/**\n * Inserts `const { locale = defaultLocale } = localeRoute.useParams();` once, at\n * the top of the function body. The destructuring form binds only `locale`, so\n * it can never collide with a `params` variable the document already declares.\n * Expression-bodied arrow functions are first converted to a block so the\n * declaration has somewhere to live.\n *\n * No-ops when `locale` is already bound in the function — whether as a simple\n * identifier, through a destructuring pattern (e.g.\n * `const { locale = defaultLocale } = Route.useLoaderData()`), or as a function\n * parameter — so the injected declaration never collides with one the document\n * already provides (which would produce an\n * `Identifier 'locale' has already been declared` parse error).\n *\n * @returns `true` when the declaration was injected, `false` when the document\n * already binds `locale` itself. Callers use this to skip the imports and the\n * route API declaration the injected statement would have needed.\n */\nconst ensureLocaleFromParams = (funcNode: any): boolean => {\n if (funcNode.body?.type !== 'BlockStatement') {\n funcNode.body = b.blockStatement([b.returnStatement(funcNode.body)]);\n }\n\n const declaredInBody = funcNode.body.body.some(\n (stmt: any) =>\n stmt.type === 'VariableDeclaration' &&\n stmt.declarations.some((d: any) => patternBindsName(d.id, 'locale'))\n );\n const declaredInParams = (funcNode.params ?? []).some((param: any) =>\n patternBindsName(param, 'locale')\n );\n if (declaredInBody || declaredInParams) return false;\n\n const statement = parseTsx(\n `const { locale = defaultLocale } = ${LOCALE_ROUTE_API_VARIABLE}.useParams();`\n ).program.body[0];\n funcNode.body.body.unshift(statement);\n return true;\n};\n\n/**\n * Ensures the module-scope `const localeRoute = getRouteApi(\"/<segment>\");`\n * declaration the injected locale statement reads from, inserted right after the\n * import block.\n *\n * Referencing the locale route by id keeps the root document free of an import\n * of `<segment>/route` — importing a child route module from `__root` is\n * discouraged, since the generated route tree already imports the root.\n *\n * No-ops when `localeRoute` is already bound at module scope, reusing that\n * binding rather than redeclaring it (which would be a parse error).\n *\n * @returns `true` when the declaration was inserted, `false` when an existing\n * binding was reused.\n */\nconst ensureLocaleRouteApi = (ast: any, localeSegment: string): boolean => {\n if (isModuleScopeBinding(ast, LOCALE_ROUTE_API_VARIABLE)) return false;\n\n const declaration = parseTsx(\n `const ${LOCALE_ROUTE_API_VARIABLE} = getRouteApi(\"/${localeSegment}\");`\n ).program.body[0];\n ast.program.body.splice(firstInsertIndex(ast), 0, declaration);\n return true;\n};\n\n/**\n * Puts a blank line between the import block and the inserted route API\n * declaration — recast prints a spliced statement flush against the preceding\n * line, which reads as part of the imports.\n */\nconst separateRouteApiDeclaration = (printedCode: string): string =>\n printedCode.replace(\n new RegExp(\n `([^\\\\n])\\\\n(const ${LOCALE_ROUTE_API_VARIABLE} = getRouteApi\\\\()`\n ),\n '$1\\n\\n$2'\n );\n\n/** Sets `lang={locale}` and `dir={getHTMLTextDir(locale)}` on the first `<html>` element. */\nconst setHtmlLangAndDir = (ast: any): void => {\n recast.visit(ast, {\n visitJSXOpeningElement(path) {\n const node = path.node;\n if (node.name?.type !== 'JSXIdentifier' || node.name.name !== 'html') {\n this.traverse(path);\n return;\n }\n\n const upsertAttribute = (name: string, value: any): void => {\n const existing = node.attributes?.find(\n (attr: any) =>\n attr.type === 'JSXAttribute' && attr.name?.name === name\n ) as any;\n if (existing) {\n existing.value = value;\n } else {\n node.attributes?.push(b.jsxAttribute(b.jsxIdentifier(name), value));\n }\n };\n\n upsertAttribute('lang', b.jsxExpressionContainer(b.identifier('locale')));\n upsertAttribute(\n 'dir',\n b.jsxExpressionContainer(\n b.callExpression(b.identifier('getHTMLTextDir'), [\n b.identifier('locale'),\n ])\n )\n );\n return false;\n },\n });\n};\n\n/**\n * Wraps the `{children}` of a TanStack Start root document with\n * `IntlayerProvider`, deriving the locale from the locale segment route params.\n * Safe and idempotent: bails (returns the original code) when the provider is\n * already present, when no `<html>` document function is found, or when there is\n * no `{children}` placeholder to wrap.\n *\n * @param code Source of the project's `__root` document.\n * @param localeSegment Locale segment directory in use — `{-$locale}` for every\n * routing mode but `prefix-all`, which uses the required `$locale`.\n */\nexport const wrapRootWithProvider = (\n code: string,\n localeSegment: string\n): TransformResult => {\n const ast = parseTsx(code);\n\n if (code.includes('IntlayerProvider')) return { code, status: 'already' };\n\n const funcNode = findHtmlDocumentFunction(ast);\n if (!funcNode) return { code, status: 'skipped' };\n\n let wrapped = false;\n recast.visit(funcNode, {\n visitJSXExpressionContainer(path) {\n if (wrapped) return false;\n const expression = path.node.expression;\n if (expression?.type === 'Identifier' && expression.name === 'children') {\n const template = parseTsx(\n 'const __wrap = <IntlayerProvider locale={locale}>{__child__}</IntlayerProvider>;'\n );\n const providerElement = template.program.body[0].declarations[0].init;\n providerElement.children = [path.node];\n path.replace(providerElement);\n wrapped = true;\n return false;\n }\n this.traverse(path);\n },\n });\n\n if (!wrapped) return { code, status: 'skipped' };\n\n const injectedLocaleDeclaration = ensureLocaleFromParams(funcNode);\n\n ensureNamedImport(ast, 'IntlayerProvider', 'react-intlayer');\n // Only needed by the injected declaration: a document that already derives its\n // own `locale` must not be given unused imports or a stray route API const.\n let insertedRouteApi = false;\n if (injectedLocaleDeclaration) {\n ensureNamedImport(ast, 'getRouteApi', '@tanstack/react-router');\n ensureNamedImport(ast, 'defaultLocale', 'intlayer');\n insertedRouteApi = ensureLocaleRouteApi(ast, localeSegment);\n }\n ensureNamedImport(ast, 'getHTMLTextDir', 'intlayer');\n setHtmlLangAndDir(ast);\n\n const printedCode = recast.print(ast).code;\n\n return {\n code: insertedRouteApi\n ? separateRouteApiDeclaration(printedCode)\n : printedCode,\n status: 'wrap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AG;CAErB,MAAM,cAAc,OAAO,MAAM,GAAG,CAAC,CAAC;CAEtC,OAAO;EACL,MAAM,mBACF,4BAA4B,WAAW,IACvC;EACJ,QAAQ;CACV;AACF"}
@@ -35,14 +35,14 @@ const DocumentationRouter = {
35
35
  ViteAndSolid: "https://intlayer.org/doc/environment/vite-and-solid.md",
36
36
  ViteAndSvelte: "https://intlayer.org/doc/environment/vite-and-svelte.md",
37
37
  ViteAndPreact: "https://intlayer.org/doc/environment/vite-and-preact.md",
38
- TanStackRouter: "https://intlayer.org/doc/environment/tanstack.md",
38
+ TanStackRouter: "https://intlayer.org/doc/environment/tanstack-start.md",
39
39
  NuxtAndVue: "https://intlayer.org/doc/environment/nuxt-and-vue.md",
40
40
  Angular: "https://intlayer.org/doc/environment/angular.md",
41
41
  SvelteKit: "https://intlayer.org/doc/environment/sveltekit.md",
42
42
  ReactNativeAndExpo: "https://intlayer.org/doc/environment/react-native-and-expo.md",
43
43
  Lynx: "https://intlayer.org/doc/environment/lynx-and-react.md",
44
44
  Express: "https://intlayer.org/doc/environment/express.md",
45
- NestJS: "https://intlayer.org/doc/environment/nestjs.md",
45
+ NestJS: "https://intlayer.org/doc/environment/nest.md",
46
46
  Fastify: "https://intlayer.org/doc/environment/fastify.md",
47
47
  Default: "https://intlayer.org/doc/get-started",
48
48
  LSP: "https://intlayer.org/doc/lsp.md",
@@ -151,7 +151,8 @@ const initIntlayer = async (rootDir, options) => {
151
151
  const linguiPresent = Boolean(effectiveAllDeps["@lingui/core"] || effectiveAllDeps["@lingui/react"] || effectiveAllDeps["@intlayer/lingui"]);
152
152
  const linguiCatalog = linguiPresent ? await require_init_utils_fileSystem.detectLinguiCatalogPattern(rootDir) : null;
153
153
  const hintLinguiJson = Boolean(options?.hintDependencies?.["__lingui_json__"]);
154
- const { packagesToInstall, devPackagesToInstall, compatSyncConfig, compatVitePluginConfig } = require_init_utils_packageManager.detectMissingIntlayerPackages(effectiveAllDeps, { linguiCatalogFormat: linguiCatalog?.format ?? (linguiPresent ? hintLinguiJson ? "json" : "po" : null) });
154
+ const linguiCatalogFormat = linguiCatalog?.format ?? (linguiPresent ? hintLinguiJson ? "json" : "po" : null);
155
+ const { packagesToInstall, devPackagesToInstall, compatSyncConfig, compatVitePluginConfig } = require_init_utils_packageManager.detectMissingIntlayerPackages(effectiveAllDeps, { linguiCatalogFormat });
155
156
  const wantsJsonNamespaces = options?.contentStrategy === "json-namespaces" && !compatSyncConfig;
156
157
  if (wantsJsonNamespaces && !effectiveAllDeps["@intlayer/sync-json-plugin"] && !devPackagesToInstall.includes("@intlayer/sync-json-plugin")) devPackagesToInstall.push("@intlayer/sync-json-plugin");
157
158
  if (!options?.noInstallPackages) {
@@ -194,7 +195,8 @@ const initIntlayer = async (rootDir, options) => {
194
195
  if (!options?.noGitignore && await require_init_utils_fileSystem.exists(rootDir, gitignorePath)) {
195
196
  const gitignoreContent = await require_init_utils_fileSystem.readFileFromRoot(rootDir, gitignorePath);
196
197
  if (!gitignoreContent.includes("intlayer")) {
197
- await require_init_utils_fileSystem.writeFileToRoot(rootDir, gitignorePath, `${gitignoreContent}\n# Intlayer\n.intlayer\n`);
198
+ const newContent = `${gitignoreContent}\n# Intlayer\n.intlayer\n`;
199
+ await require_init_utils_fileSystem.writeFileToRoot(rootDir, gitignorePath, newContent);
198
200
  (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} Added ${(0, _intlayer_config_logger.colorizePath)(".intlayer")} to ${(0, _intlayer_config_logger.colorizePath)(gitignorePath)}`);
199
201
  } else (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} ${(0, _intlayer_config_logger.colorizePath)(gitignorePath)} already includes .intlayer`);
200
202
  }
@@ -220,8 +222,10 @@ const initIntlayer = async (rootDir, options) => {
220
222
  const extensionId = "intlayer.intlayer-vs-code-extension";
221
223
  if (!options?.noVscodeExtension) try {
222
224
  let extensionsConfig = { recommendations: [] };
223
- if (await require_init_utils_fileSystem.exists(rootDir, extensionsJsonPath)) extensionsConfig = require_init_utils_jsonParser.parseJSONWithComments(await require_init_utils_fileSystem.readFileFromRoot(rootDir, extensionsJsonPath));
224
- else await require_init_utils_fileSystem.ensureDirectory(rootDir, vscodeDir);
225
+ if (await require_init_utils_fileSystem.exists(rootDir, extensionsJsonPath)) {
226
+ const content = await require_init_utils_fileSystem.readFileFromRoot(rootDir, extensionsJsonPath);
227
+ extensionsConfig = require_init_utils_jsonParser.parseJSONWithComments(content);
228
+ } else await require_init_utils_fileSystem.ensureDirectory(rootDir, vscodeDir);
225
229
  if (!extensionsConfig.recommendations) extensionsConfig.recommendations = [];
226
230
  if (!extensionsConfig.recommendations.includes(extensionId)) {
227
231
  extensionsConfig.recommendations.push(extensionId);
@@ -234,8 +238,10 @@ const initIntlayer = async (rootDir, options) => {
234
238
  const settingsJsonPath = (0, node_path.join)(vscodeDir, "settings.json");
235
239
  if (!options?.noLsp) try {
236
240
  let settingsConfig = {};
237
- if (await require_init_utils_fileSystem.exists(rootDir, settingsJsonPath)) settingsConfig = require_init_utils_jsonParser.parseJSONWithComments(await require_init_utils_fileSystem.readFileFromRoot(rootDir, settingsJsonPath));
238
- else await require_init_utils_fileSystem.ensureDirectory(rootDir, vscodeDir);
241
+ if (await require_init_utils_fileSystem.exists(rootDir, settingsJsonPath)) {
242
+ const content = await require_init_utils_fileSystem.readFileFromRoot(rootDir, settingsJsonPath);
243
+ settingsConfig = require_init_utils_jsonParser.parseJSONWithComments(content);
244
+ } else await require_init_utils_fileSystem.ensureDirectory(rootDir, vscodeDir);
239
245
  let settingsUpdated = false;
240
246
  if (!settingsConfig["intlayer.languageServer.command"]) {
241
247
  settingsConfig["intlayer.languageServer.command"] = "npx";
@@ -257,7 +263,8 @@ const initIntlayer = async (rootDir, options) => {
257
263
  for (const fileName of tsConfigFiles) if (await require_init_utils_fileSystem.exists(rootDir, fileName)) {
258
264
  hasTsConfig = true;
259
265
  try {
260
- const config = require_init_utils_jsonParser.parseJSONWithComments(await require_init_utils_fileSystem.readFileFromRoot(rootDir, fileName));
266
+ const fileContent = await require_init_utils_fileSystem.readFileFromRoot(rootDir, fileName);
267
+ const config = require_init_utils_jsonParser.parseJSONWithComments(fileContent);
261
268
  const typeDefinition = "./.intlayer/**/*.ts";
262
269
  let updated = false;
263
270
  if (!config.include) {} else if (Array.isArray(config.include) && !config.include.some((pattern) => pattern.includes(".intlayer"))) {
@@ -301,7 +308,9 @@ const initIntlayer = async (rootDir, options) => {
301
308
  ]) if (await require_init_utils_fileSystem.exists(rootDir, configFile)) {
302
309
  const configContent = await require_init_utils_fileSystem.readFileFromRoot(rootDir, configFile);
303
310
  if (!configContent.includes(syncPluginPackage)) {
304
- await require_init_utils_fileSystem.writeFileToRoot(rootDir, configFile, require_init_utils_configManipulation.updateIntlayerConfigWithSyncPlugin(configContent, configFile.split(".").pop(), resolvedSyncConfig));
311
+ const extension = configFile.split(".").pop();
312
+ const updatedConfigContent = require_init_utils_configManipulation.updateIntlayerConfigWithSyncPlugin(configContent, extension, resolvedSyncConfig);
313
+ await require_init_utils_fileSystem.writeFileToRoot(rootDir, configFile, updatedConfigContent);
305
314
  (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} Updated ${(0, _intlayer_config_logger.colorizePath)(configFile)} with ${syncPluginName} compat plugin`);
306
315
  } else (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} ${(0, _intlayer_config_logger.colorizePath)(configFile)} already includes ${syncPluginName} plugin`);
307
316
  break;
@@ -321,15 +330,18 @@ const initIntlayer = async (rootDir, options) => {
321
330
  const { replacesVitePlugin } = compatVitePluginConfig;
322
331
  if (content.includes(compatVitePluginConfig.pluginPackageSource)) (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} ${(0, _intlayer_config_logger.colorizePath)(file)} already includes ${compatVitePluginConfig.pluginPackageSource}`);
323
332
  else if (replacesVitePlugin && content.includes(replacesVitePlugin.fromPackageSource)) {
324
- await require_init_utils_fileSystem.writeFileToRoot(rootDir, file, require_init_utils_configManipulation.replaceViteConfigPluginImportSource(content, replacesVitePlugin.importName, replacesVitePlugin.fromPackageSource, compatVitePluginConfig.pluginPackageSource));
333
+ const updatedContent = require_init_utils_configManipulation.replaceViteConfigPluginImportSource(content, replacesVitePlugin.importName, replacesVitePlugin.fromPackageSource, compatVitePluginConfig.pluginPackageSource);
334
+ await require_init_utils_fileSystem.writeFileToRoot(rootDir, file, updatedContent);
325
335
  (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} Updated ${(0, _intlayer_config_logger.colorizePath)(file)} to import ${replacesVitePlugin.importName} from ${compatVitePluginConfig.pluginPackageSource}`);
326
336
  } else {
327
- await require_init_utils_fileSystem.writeFileToRoot(rootDir, file, require_init_utils_configManipulation.updateViteConfigForCompatPlugin(content, extension, compatVitePluginConfig));
337
+ const updatedContent = require_init_utils_configManipulation.updateViteConfigForCompatPlugin(content, extension, compatVitePluginConfig);
338
+ await require_init_utils_fileSystem.writeFileToRoot(rootDir, file, updatedContent);
328
339
  (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} Updated ${(0, _intlayer_config_logger.colorizePath)(file)} to include ${compatVitePluginConfig.pluginFunctionName} compat plugin`);
329
340
  }
330
341
  } else if (require_init_utils_configManipulation.hasIntlayerVitePlugin(content)) (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} ${(0, _intlayer_config_logger.colorizePath)(file)} already includes an Intlayer plugin`);
331
342
  else {
332
- await require_init_utils_fileSystem.writeFileToRoot(rootDir, file, require_init_utils_configManipulation.updateViteConfig(content, extension));
343
+ const updatedContent = require_init_utils_configManipulation.updateViteConfig(content, extension);
344
+ await require_init_utils_fileSystem.writeFileToRoot(rootDir, file, updatedContent);
333
345
  (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} Updated ${(0, _intlayer_config_logger.colorizePath)(file)} to include Intlayer plugin`);
334
346
  }
335
347
  break;
@@ -345,20 +357,27 @@ const initIntlayer = async (rootDir, options) => {
345
357
  hasAliasConfiguration = true;
346
358
  const content = await require_init_utils_fileSystem.readFileFromRoot(rootDir, file);
347
359
  const extension = file.split(".").pop();
348
- if (allDeps["next-i18next"]) if (!content.includes("@intlayer/next-i18next")) {
349
- await require_init_utils_fileSystem.writeFileToRoot(rootDir, file, require_init_utils_configManipulation.updateNextConfigForNextI18next(content, extension));
350
- (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} Updated ${(0, _intlayer_config_logger.colorizePath)(file)} to include Intlayer next-i18next compat plugin`);
351
- } else (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} ${(0, _intlayer_config_logger.colorizePath)(file)} already includes @intlayer/next-i18next`);
352
- else if (allDeps["next-intl"]) if (!content.includes("@intlayer/next-intl/plugin")) {
353
- await require_init_utils_fileSystem.writeFileToRoot(rootDir, file, require_init_utils_configManipulation.updateNextConfigForNextIntl(content, extension));
354
- (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} Updated ${(0, _intlayer_config_logger.colorizePath)(file)} to include Intlayer next-intl compat plugin`);
355
- } else (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} ${(0, _intlayer_config_logger.colorizePath)(file)} already includes @intlayer/next-intl/plugin`);
356
- else if (allDeps["next-translate"]) if (!content.includes("@intlayer/next-translate")) {
357
- await require_init_utils_fileSystem.writeFileToRoot(rootDir, file, require_init_utils_configManipulation.updateNextConfigForNextTranslate(content, extension));
358
- (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} Updated ${(0, _intlayer_config_logger.colorizePath)(file)} to include Intlayer next-translate compat plugin`);
359
- } else (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} ${(0, _intlayer_config_logger.colorizePath)(file)} already includes @intlayer/next-translate`);
360
- else if (!content.includes("next-intlayer")) {
361
- await require_init_utils_fileSystem.writeFileToRoot(rootDir, file, require_init_utils_configManipulation.updateNextConfig(content, extension));
360
+ if (allDeps["next-i18next"]) {
361
+ if (!content.includes("@intlayer/next-i18next")) {
362
+ const updatedContent = require_init_utils_configManipulation.updateNextConfigForNextI18next(content, extension);
363
+ await require_init_utils_fileSystem.writeFileToRoot(rootDir, file, updatedContent);
364
+ (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} Updated ${(0, _intlayer_config_logger.colorizePath)(file)} to include Intlayer next-i18next compat plugin`);
365
+ } else (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} ${(0, _intlayer_config_logger.colorizePath)(file)} already includes @intlayer/next-i18next`);
366
+ } else if (allDeps["next-intl"]) {
367
+ if (!content.includes("@intlayer/next-intl/plugin")) {
368
+ const updatedContent = require_init_utils_configManipulation.updateNextConfigForNextIntl(content, extension);
369
+ await require_init_utils_fileSystem.writeFileToRoot(rootDir, file, updatedContent);
370
+ (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} Updated ${(0, _intlayer_config_logger.colorizePath)(file)} to include Intlayer next-intl compat plugin`);
371
+ } else (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} ${(0, _intlayer_config_logger.colorizePath)(file)} already includes @intlayer/next-intl/plugin`);
372
+ } else if (allDeps["next-translate"]) {
373
+ if (!content.includes("@intlayer/next-translate")) {
374
+ const updatedContent = require_init_utils_configManipulation.updateNextConfigForNextTranslate(content, extension);
375
+ await require_init_utils_fileSystem.writeFileToRoot(rootDir, file, updatedContent);
376
+ (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} Updated ${(0, _intlayer_config_logger.colorizePath)(file)} to include Intlayer next-translate compat plugin`);
377
+ } else (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} ${(0, _intlayer_config_logger.colorizePath)(file)} already includes @intlayer/next-translate`);
378
+ } else if (!content.includes("next-intlayer")) {
379
+ const updatedContent = require_init_utils_configManipulation.updateNextConfig(content, extension);
380
+ await require_init_utils_fileSystem.writeFileToRoot(rootDir, file, updatedContent);
362
381
  (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} Updated ${(0, _intlayer_config_logger.colorizePath)(file)} to include Intlayer plugin`);
363
382
  }
364
383
  break;
@@ -379,7 +398,9 @@ const initIntlayer = async (rootDir, options) => {
379
398
  if (file.startsWith("astro.config.")) {
380
399
  const content = await require_init_utils_fileSystem.readFileFromRoot(rootDir, file);
381
400
  if (!content.includes("astro-intlayer")) {
382
- await require_init_utils_fileSystem.writeFileToRoot(rootDir, file, require_init_utils_configManipulation.updateAstroConfig(content, file.split(".").pop()));
401
+ const extension = file.split(".").pop();
402
+ const updatedContent = require_init_utils_configManipulation.updateAstroConfig(content, extension);
403
+ await require_init_utils_fileSystem.writeFileToRoot(rootDir, file, updatedContent);
383
404
  (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} Updated ${(0, _intlayer_config_logger.colorizePath)(file)} to include Intlayer integration`);
384
405
  }
385
406
  }
@@ -388,12 +409,15 @@ const initIntlayer = async (rootDir, options) => {
388
409
  for (const file of ["nuxt.config.js", "nuxt.config.ts"]) if (await require_init_utils_fileSystem.exists(rootDir, file)) {
389
410
  hasAliasConfiguration = true;
390
411
  const content = await require_init_utils_fileSystem.readFileFromRoot(rootDir, file);
391
- if (allDeps["@nuxtjs/i18n"]) if (!content.includes("@intlayer/nuxtjs-i18n")) {
392
- await require_init_utils_fileSystem.writeFileToRoot(rootDir, file, require_init_utils_configManipulation.updateNuxtConfigForNuxtjsI18n(content));
393
- (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} Updated ${(0, _intlayer_config_logger.colorizePath)(file)} to include @intlayer/nuxtjs-i18n module`);
394
- } else (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} ${(0, _intlayer_config_logger.colorizePath)(file)} already includes @intlayer/nuxtjs-i18n`);
395
- else if (!content.includes("nuxt-intlayer")) {
396
- await require_init_utils_fileSystem.writeFileToRoot(rootDir, file, require_init_utils_configManipulation.updateNuxtConfig(content));
412
+ if (allDeps["@nuxtjs/i18n"]) {
413
+ if (!content.includes("@intlayer/nuxtjs-i18n")) {
414
+ const updatedContent = require_init_utils_configManipulation.updateNuxtConfigForNuxtjsI18n(content);
415
+ await require_init_utils_fileSystem.writeFileToRoot(rootDir, file, updatedContent);
416
+ (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} Updated ${(0, _intlayer_config_logger.colorizePath)(file)} to include @intlayer/nuxtjs-i18n module`);
417
+ } else (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} ${(0, _intlayer_config_logger.colorizePath)(file)} already includes @intlayer/nuxtjs-i18n`);
418
+ } else if (!content.includes("nuxt-intlayer")) {
419
+ const updatedContent = require_init_utils_configManipulation.updateNuxtConfig(content);
420
+ await require_init_utils_fileSystem.writeFileToRoot(rootDir, file, updatedContent);
397
421
  (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} Updated ${(0, _intlayer_config_logger.colorizePath)(file)} to include Intlayer module`);
398
422
  }
399
423
  break;
@@ -415,7 +439,8 @@ const initIntlayer = async (rootDir, options) => {
415
439
  const content = await require_init_utils_fileSystem.readFileFromRoot(rootDir, metroConfigFile);
416
440
  if (content.includes("react-native-intlayer")) (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} ${(0, _intlayer_config_logger.colorizePath)(metroConfigFile)} already includes the Intlayer Metro plugin`);
417
441
  else {
418
- const updatedContent = require_init_utils_configManipulation.updateMetroConfig(content, metroConfigFile.split(".").pop());
442
+ const extension = metroConfigFile.split(".").pop();
443
+ const updatedContent = require_init_utils_configManipulation.updateMetroConfig(content, extension);
419
444
  if (updatedContent !== content) {
420
445
  await require_init_utils_fileSystem.writeFileToRoot(rootDir, metroConfigFile, updatedContent);
421
446
  (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} Updated ${(0, _intlayer_config_logger.colorizePath)(metroConfigFile)} to include the Intlayer Metro plugin`);
@@ -459,11 +484,13 @@ const initIntlayer = async (rootDir, options) => {
459
484
  ...backendIntlayerPackages
460
485
  ].some((pkg) => allDeps[pkg])) hasAliasConfiguration = true;
461
486
  if (!hasAliasConfiguration) {
462
- const aliases = (0, _intlayer_config_utils.getAlias)({ configuration: (0, _intlayer_config_node.getConfiguration)({ baseDir: rootDir }) });
487
+ const configuration = (0, _intlayer_config_node.getConfiguration)({ baseDir: rootDir });
488
+ const aliases = (0, _intlayer_config_utils.getAlias)({ configuration });
463
489
  if (hasTsConfig && tsConfigFiles.length > 0) {
464
490
  const tsConfigPath = tsConfigFiles.find((file) => file === "tsconfig.json") || tsConfigFiles[0];
465
491
  if (tsConfigPath) {
466
- const config = require_init_utils_jsonParser.parseJSONWithComments(await require_init_utils_fileSystem.readFileFromRoot(rootDir, tsConfigPath));
492
+ const tsConfigContent = await require_init_utils_fileSystem.readFileFromRoot(rootDir, tsConfigPath);
493
+ const config = require_init_utils_jsonParser.parseJSONWithComments(tsConfigContent);
467
494
  config.compilerOptions ??= {};
468
495
  config.compilerOptions.paths ??= {};
469
496
  let updated = false;
@@ -481,7 +508,8 @@ const initIntlayer = async (rootDir, options) => {
481
508
  } else {
482
509
  const jsConfigPath = "jsconfig.json";
483
510
  if (await require_init_utils_fileSystem.exists(rootDir, jsConfigPath)) {
484
- const config = require_init_utils_jsonParser.parseJSONWithComments(await require_init_utils_fileSystem.readFileFromRoot(rootDir, jsConfigPath));
511
+ const jsConfigContent = await require_init_utils_fileSystem.readFileFromRoot(rootDir, jsConfigPath);
512
+ const config = require_init_utils_jsonParser.parseJSONWithComments(jsConfigContent);
485
513
  config.compilerOptions ??= {};
486
514
  config.compilerOptions.paths ??= {};
487
515
  let updated = false;