@intlayer/engine 9.0.0-canary.12

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 (833) hide show
  1. package/README.md +330 -0
  2. package/dist/assets/initConfig/templates/cjs.txt +140 -0
  3. package/dist/assets/initConfig/templates/json.txt +98 -0
  4. package/dist/assets/initConfig/templates/mjs.txt +140 -0
  5. package/dist/assets/initConfig/templates/ts.txt +139 -0
  6. package/dist/assets/installSkills/LICENCE.md +201 -0
  7. package/dist/assets/installSkills/skills/angular.md +159 -0
  8. package/dist/assets/installSkills/skills/astro.md +40 -0
  9. package/dist/assets/installSkills/skills/cli.md +68 -0
  10. package/dist/assets/installSkills/skills/compiler.md +32 -0
  11. package/dist/assets/installSkills/skills/config.md +63 -0
  12. package/dist/assets/installSkills/skills/content.md +377 -0
  13. package/dist/assets/installSkills/skills/next-js.md +130 -0
  14. package/dist/assets/installSkills/skills/preact.md +83 -0
  15. package/dist/assets/installSkills/skills/react.md +105 -0
  16. package/dist/assets/installSkills/skills/remote-content.md +31 -0
  17. package/dist/assets/installSkills/skills/solid.md +90 -0
  18. package/dist/assets/installSkills/skills/svelte.md +84 -0
  19. package/dist/assets/installSkills/skills/usage.md +44 -0
  20. package/dist/assets/installSkills/skills/vue.md +56 -0
  21. package/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -0
  22. package/dist/cjs/_virtual/_utils_asset.cjs +98 -0
  23. package/dist/cjs/build.cjs +60 -0
  24. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs +80 -0
  25. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs.map +1 -0
  26. package/dist/cjs/buildIntlayerDictionary/index.cjs +6 -0
  27. package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs +27 -0
  28. package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs.map +1 -0
  29. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +206 -0
  30. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -0
  31. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs +59 -0
  32. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs.map +1 -0
  33. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs +49 -0
  34. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs.map +1 -0
  35. package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs +51 -0
  36. package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs.map +1 -0
  37. package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs +62 -0
  38. package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs.map +1 -0
  39. package/dist/cjs/cleanOutputDir.cjs +31 -0
  40. package/dist/cjs/cleanOutputDir.cjs.map +1 -0
  41. package/dist/cjs/cleanRemovedContentDeclaration.cjs +97 -0
  42. package/dist/cjs/cleanRemovedContentDeclaration.cjs.map +1 -0
  43. package/dist/cjs/cli.cjs +48 -0
  44. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs +71 -0
  45. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs.map +1 -0
  46. package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs +43 -0
  47. package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs.map +1 -0
  48. package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs +25 -0
  49. package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs.map +1 -0
  50. package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs +26 -0
  51. package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs.map +1 -0
  52. package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs +26 -0
  53. package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs.map +1 -0
  54. package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs +25 -0
  55. package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs.map +1 -0
  56. package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs +25 -0
  57. package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs.map +1 -0
  58. package/dist/cjs/createDictionaryEntryPoint/index.cjs +16 -0
  59. package/dist/cjs/createType/createModuleAugmentation.cjs +126 -0
  60. package/dist/cjs/createType/createModuleAugmentation.cjs.map +1 -0
  61. package/dist/cjs/createType/createType.cjs +30 -0
  62. package/dist/cjs/createType/createType.cjs.map +1 -0
  63. package/dist/cjs/createType/index.cjs +8 -0
  64. package/dist/cjs/detectFormatCommand.cjs +33 -0
  65. package/dist/cjs/detectFormatCommand.cjs.map +1 -0
  66. package/dist/cjs/docReview/alignBlocks.cjs +79 -0
  67. package/dist/cjs/docReview/alignBlocks.cjs.map +1 -0
  68. package/dist/cjs/docReview/computeSimilarity.cjs +42 -0
  69. package/dist/cjs/docReview/computeSimilarity.cjs.map +1 -0
  70. package/dist/cjs/docReview/fingerprintBlock.cjs +35 -0
  71. package/dist/cjs/docReview/fingerprintBlock.cjs.map +1 -0
  72. package/dist/cjs/docReview/index.cjs +25 -0
  73. package/dist/cjs/docReview/mapChangedLinesToBlocks.cjs +27 -0
  74. package/dist/cjs/docReview/mapChangedLinesToBlocks.cjs.map +1 -0
  75. package/dist/cjs/docReview/normalizeBlock.cjs +34 -0
  76. package/dist/cjs/docReview/normalizeBlock.cjs.map +1 -0
  77. package/dist/cjs/docReview/pipeline.cjs +144 -0
  78. package/dist/cjs/docReview/pipeline.cjs.map +1 -0
  79. package/dist/cjs/docReview/planActions.cjs +58 -0
  80. package/dist/cjs/docReview/planActions.cjs.map +1 -0
  81. package/dist/cjs/docReview/rebuildDocument.cjs +65 -0
  82. package/dist/cjs/docReview/rebuildDocument.cjs.map +1 -0
  83. package/dist/cjs/docReview/reviewReport.cjs +200 -0
  84. package/dist/cjs/docReview/reviewReport.cjs.map +1 -0
  85. package/dist/cjs/docReview/segmentDocument.cjs +134 -0
  86. package/dist/cjs/docReview/segmentDocument.cjs.map +1 -0
  87. package/dist/cjs/docReview/types.cjs +0 -0
  88. package/dist/cjs/fetchDistantDictionaries.cjs +53 -0
  89. package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -0
  90. package/dist/cjs/filterInvalidDictionaries.cjs +57 -0
  91. package/dist/cjs/filterInvalidDictionaries.cjs.map +1 -0
  92. package/dist/cjs/formatDictionary.cjs +60 -0
  93. package/dist/cjs/formatDictionary.cjs.map +1 -0
  94. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +83 -0
  95. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -0
  96. package/dist/cjs/getContentDeclarationFileTemplate/index.cjs +4 -0
  97. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs +35 -0
  98. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs.map +1 -0
  99. package/dist/cjs/handleContentDeclarationFileChange.cjs +56 -0
  100. package/dist/cjs/handleContentDeclarationFileChange.cjs.map +1 -0
  101. package/dist/cjs/handleContentDeclarationFileMoved.cjs +25 -0
  102. package/dist/cjs/handleContentDeclarationFileMoved.cjs.map +1 -0
  103. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs +38 -0
  104. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs.map +1 -0
  105. package/dist/cjs/init/cms.cjs +140 -0
  106. package/dist/cjs/init/cms.cjs.map +1 -0
  107. package/dist/cjs/init/frameworkSetup/index.cjs +27 -0
  108. package/dist/cjs/init/frameworkSetup/index.cjs.map +1 -0
  109. package/dist/cjs/init/frameworkSetup/nextAppRouter/detect.cjs +56 -0
  110. package/dist/cjs/init/frameworkSetup/nextAppRouter/detect.cjs.map +1 -0
  111. package/dist/cjs/init/frameworkSetup/nextAppRouter/index.cjs +107 -0
  112. package/dist/cjs/init/frameworkSetup/nextAppRouter/index.cjs.map +1 -0
  113. package/dist/cjs/init/frameworkSetup/nextAppRouter/restructure.cjs +163 -0
  114. package/dist/cjs/init/frameworkSetup/nextAppRouter/restructure.cjs.map +1 -0
  115. package/dist/cjs/init/frameworkSetup/nextAppRouter/templates.cjs +122 -0
  116. package/dist/cjs/init/frameworkSetup/nextAppRouter/templates.cjs.map +1 -0
  117. package/dist/cjs/init/frameworkSetup/nextAppRouter/transforms.cjs +196 -0
  118. package/dist/cjs/init/frameworkSetup/nextAppRouter/transforms.cjs.map +1 -0
  119. package/dist/cjs/init/frameworkSetup/tanstackStart/detect.cjs +31 -0
  120. package/dist/cjs/init/frameworkSetup/tanstackStart/detect.cjs.map +1 -0
  121. package/dist/cjs/init/frameworkSetup/tanstackStart/index.cjs +76 -0
  122. package/dist/cjs/init/frameworkSetup/tanstackStart/index.cjs.map +1 -0
  123. package/dist/cjs/init/frameworkSetup/tanstackStart/restructure.cjs +116 -0
  124. package/dist/cjs/init/frameworkSetup/tanstackStart/restructure.cjs.map +1 -0
  125. package/dist/cjs/init/frameworkSetup/tanstackStart/templates.cjs +106 -0
  126. package/dist/cjs/init/frameworkSetup/tanstackStart/templates.cjs.map +1 -0
  127. package/dist/cjs/init/frameworkSetup/tanstackStart/transforms.cjs +141 -0
  128. package/dist/cjs/init/frameworkSetup/tanstackStart/transforms.cjs.map +1 -0
  129. package/dist/cjs/init/frameworkSetup/types.cjs +0 -0
  130. package/dist/cjs/init/index.cjs +521 -0
  131. package/dist/cjs/init/index.cjs.map +1 -0
  132. package/dist/cjs/init/utils/astImports.cjs +56 -0
  133. package/dist/cjs/init/utils/astImports.cjs.map +1 -0
  134. package/dist/cjs/init/utils/configManipulation.cjs +516 -0
  135. package/dist/cjs/init/utils/configManipulation.cjs.map +1 -0
  136. package/dist/cjs/init/utils/fileSystem.cjs +231 -0
  137. package/dist/cjs/init/utils/fileSystem.cjs.map +1 -0
  138. package/dist/cjs/init/utils/githubActions.cjs +159 -0
  139. package/dist/cjs/init/utils/githubActions.cjs.map +1 -0
  140. package/dist/cjs/init/utils/index.cjs +51 -0
  141. package/dist/cjs/init/utils/jsonParser.cjs +43 -0
  142. package/dist/cjs/init/utils/jsonParser.cjs.map +1 -0
  143. package/dist/cjs/init/utils/nextCompilerBabel.cjs +119 -0
  144. package/dist/cjs/init/utils/nextCompilerBabel.cjs.map +1 -0
  145. package/dist/cjs/init/utils/packageManager.cjs +303 -0
  146. package/dist/cjs/init/utils/packageManager.cjs.map +1 -0
  147. package/dist/cjs/init/utils/tsConfig.cjs +19 -0
  148. package/dist/cjs/init/utils/tsConfig.cjs.map +1 -0
  149. package/dist/cjs/initConfig/index.cjs +49 -0
  150. package/dist/cjs/initConfig/index.cjs.map +1 -0
  151. package/dist/cjs/installLSP.cjs +58 -0
  152. package/dist/cjs/installLSP.cjs.map +1 -0
  153. package/dist/cjs/installMCP/installMCP.cjs +51 -0
  154. package/dist/cjs/installMCP/installMCP.cjs.map +1 -0
  155. package/dist/cjs/installSkills/index.cjs +307 -0
  156. package/dist/cjs/installSkills/index.cjs.map +1 -0
  157. package/dist/cjs/listDictionariesPath.cjs +43 -0
  158. package/dist/cjs/listDictionariesPath.cjs.map +1 -0
  159. package/dist/cjs/listGitFiles.cjs +105 -0
  160. package/dist/cjs/listGitFiles.cjs.map +1 -0
  161. package/dist/cjs/listProjects.cjs +48 -0
  162. package/dist/cjs/listProjects.cjs.map +1 -0
  163. package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs +56 -0
  164. package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs.map +1 -0
  165. package/dist/cjs/loadDictionaries/index.cjs +14 -0
  166. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +133 -0
  167. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -0
  168. package/dist/cjs/loadDictionaries/loadDictionaries.cjs +128 -0
  169. package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -0
  170. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs +28 -0
  171. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs.map +1 -0
  172. package/dist/cjs/loadDictionaries/loadMarkdownContentDeclaration.cjs +45 -0
  173. package/dist/cjs/loadDictionaries/loadMarkdownContentDeclaration.cjs.map +1 -0
  174. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +63 -0
  175. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -0
  176. package/dist/cjs/loadDictionaries/loadYamlContentDeclaration.cjs +27 -0
  177. package/dist/cjs/loadDictionaries/loadYamlContentDeclaration.cjs.map +1 -0
  178. package/dist/cjs/loadDictionaries/log.cjs +138 -0
  179. package/dist/cjs/loadDictionaries/log.cjs.map +1 -0
  180. package/dist/cjs/loadDictionaries/logTypeScriptErrors.cjs +64 -0
  181. package/dist/cjs/loadDictionaries/logTypeScriptErrors.cjs.map +1 -0
  182. package/dist/cjs/logConfigDetails.cjs +40 -0
  183. package/dist/cjs/logConfigDetails.cjs.map +1 -0
  184. package/dist/cjs/prepareIntlayer.cjs +104 -0
  185. package/dist/cjs/prepareIntlayer.cjs.map +1 -0
  186. package/dist/cjs/reduceDictionaryContent/applyMask.cjs +31 -0
  187. package/dist/cjs/reduceDictionaryContent/applyMask.cjs.map +1 -0
  188. package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs +13 -0
  189. package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs.map +1 -0
  190. package/dist/cjs/scan/analyzeBundleContent.cjs +182 -0
  191. package/dist/cjs/scan/analyzeBundleContent.cjs.map +1 -0
  192. package/dist/cjs/scan/calculateScore.cjs +65 -0
  193. package/dist/cjs/scan/calculateScore.cjs.map +1 -0
  194. package/dist/cjs/scan/checks.cjs +274 -0
  195. package/dist/cjs/scan/checks.cjs.map +1 -0
  196. package/dist/cjs/scan/index.cjs +31 -0
  197. package/dist/cjs/scan/parseHtml.cjs +127 -0
  198. package/dist/cjs/scan/parseHtml.cjs.map +1 -0
  199. package/dist/cjs/scan/scanWebsite.cjs +205 -0
  200. package/dist/cjs/scan/scanWebsite.cjs.map +1 -0
  201. package/dist/cjs/scan/types.cjs +0 -0
  202. package/dist/cjs/utils/autoDecorateContent.cjs +90 -0
  203. package/dist/cjs/utils/autoDecorateContent.cjs.map +1 -0
  204. package/dist/cjs/utils/buildComponentFilesList.cjs +94 -0
  205. package/dist/cjs/utils/buildComponentFilesList.cjs.map +1 -0
  206. package/dist/cjs/utils/buildFilesList.cjs +84 -0
  207. package/dist/cjs/utils/buildFilesList.cjs.map +1 -0
  208. package/dist/cjs/utils/chunkJSON.cjs +337 -0
  209. package/dist/cjs/utils/chunkJSON.cjs.map +1 -0
  210. package/dist/cjs/utils/formatter.cjs +18 -0
  211. package/dist/cjs/utils/formatter.cjs.map +1 -0
  212. package/dist/cjs/utils/getChunk.cjs +35 -0
  213. package/dist/cjs/utils/getChunk.cjs.map +1 -0
  214. package/dist/cjs/utils/getContentExtension.cjs +30 -0
  215. package/dist/cjs/utils/getContentExtension.cjs.map +1 -0
  216. package/dist/cjs/utils/getFormatFromExtension.cjs +41 -0
  217. package/dist/cjs/utils/getFormatFromExtension.cjs.map +1 -0
  218. package/dist/cjs/utils/getPathHash.cjs +22 -0
  219. package/dist/cjs/utils/getPathHash.cjs.map +1 -0
  220. package/dist/cjs/utils/index.cjs +50 -0
  221. package/dist/cjs/utils/mergeChunks.cjs +29 -0
  222. package/dist/cjs/utils/mergeChunks.cjs.map +1 -0
  223. package/dist/cjs/utils/pLimit.cjs +134 -0
  224. package/dist/cjs/utils/pLimit.cjs.map +1 -0
  225. package/dist/cjs/utils/parallelize.cjs +12 -0
  226. package/dist/cjs/utils/parallelize.cjs.map +1 -0
  227. package/dist/cjs/utils/parallelizeGlobal.cjs +30 -0
  228. package/dist/cjs/utils/parallelizeGlobal.cjs.map +1 -0
  229. package/dist/cjs/utils/readDictionariesFromDisk.cjs +25 -0
  230. package/dist/cjs/utils/readDictionariesFromDisk.cjs.map +1 -0
  231. package/dist/cjs/utils/reduceObjectFormat.cjs +70 -0
  232. package/dist/cjs/utils/reduceObjectFormat.cjs.map +1 -0
  233. package/dist/cjs/utils/resolveObjectPromises.cjs +22 -0
  234. package/dist/cjs/utils/resolveObjectPromises.cjs.map +1 -0
  235. package/dist/cjs/utils/resolveRelativePath.cjs +22 -0
  236. package/dist/cjs/utils/resolveRelativePath.cjs.map +1 -0
  237. package/dist/cjs/utils/runOnce.cjs +96 -0
  238. package/dist/cjs/utils/runOnce.cjs.map +1 -0
  239. package/dist/cjs/utils/runParallel/bin.cjs +55 -0
  240. package/dist/cjs/utils/runParallel/bin.cjs.map +1 -0
  241. package/dist/cjs/utils/runParallel/bootstrap.cjs +25 -0
  242. package/dist/cjs/utils/runParallel/bootstrap.cjs.map +1 -0
  243. package/dist/cjs/utils/runParallel/index.cjs +102 -0
  244. package/dist/cjs/utils/runParallel/index.cjs.map +1 -0
  245. package/dist/cjs/utils/runParallel/pidTree.cjs +146 -0
  246. package/dist/cjs/utils/runParallel/pidTree.cjs.map +1 -0
  247. package/dist/cjs/utils/runParallel/ps.cjs +50 -0
  248. package/dist/cjs/utils/runParallel/ps.cjs.map +1 -0
  249. package/dist/cjs/utils/runParallel/runTask.cjs +155 -0
  250. package/dist/cjs/utils/runParallel/runTask.cjs.map +1 -0
  251. package/dist/cjs/utils/runParallel/spawnPosix.cjs +49 -0
  252. package/dist/cjs/utils/runParallel/spawnPosix.cjs.map +1 -0
  253. package/dist/cjs/utils/runParallel/spawnWin32.cjs +44 -0
  254. package/dist/cjs/utils/runParallel/spawnWin32.cjs.map +1 -0
  255. package/dist/cjs/utils/runParallel/wmic.cjs +53 -0
  256. package/dist/cjs/utils/runParallel/wmic.cjs.map +1 -0
  257. package/dist/cjs/utils/sortAlphabetically.cjs +8 -0
  258. package/dist/cjs/utils/sortAlphabetically.cjs.map +1 -0
  259. package/dist/cjs/utils/splitTextByLine.cjs +12 -0
  260. package/dist/cjs/utils/splitTextByLine.cjs.map +1 -0
  261. package/dist/cjs/utils/verifyIdenticObjectFormat.cjs +66 -0
  262. package/dist/cjs/utils/verifyIdenticObjectFormat.cjs.map +1 -0
  263. package/dist/cjs/watcher.cjs +230 -0
  264. package/dist/cjs/watcher.cjs.map +1 -0
  265. package/dist/cjs/writeConfiguration/generateConfigurationContent.cjs +35 -0
  266. package/dist/cjs/writeConfiguration/generateConfigurationContent.cjs.map +1 -0
  267. package/dist/cjs/writeConfiguration/index.cjs +25 -0
  268. package/dist/cjs/writeConfiguration/index.cjs.map +1 -0
  269. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs +29 -0
  270. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs.map +1 -0
  271. package/dist/cjs/writeContentDeclaration/dictionaryStatus.cjs +0 -0
  272. package/dist/cjs/writeContentDeclaration/index.cjs +10 -0
  273. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs +95 -0
  274. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs.map +1 -0
  275. package/dist/cjs/writeContentDeclaration/transformJSFile.cjs +417 -0
  276. package/dist/cjs/writeContentDeclaration/transformJSFile.cjs.map +1 -0
  277. package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs +128 -0
  278. package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs.map +1 -0
  279. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +164 -0
  280. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -0
  281. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +93 -0
  282. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs.map +1 -0
  283. package/dist/cjs/writeContentDeclaration/writeMarkdownFile.cjs +66 -0
  284. package/dist/cjs/writeContentDeclaration/writeMarkdownFile.cjs.map +1 -0
  285. package/dist/cjs/writeContentDeclaration/writeYamlFile.cjs +44 -0
  286. package/dist/cjs/writeContentDeclaration/writeYamlFile.cjs.map +1 -0
  287. package/dist/cjs/writeFileIfChanged.cjs +51 -0
  288. package/dist/cjs/writeFileIfChanged.cjs.map +1 -0
  289. package/dist/cjs/writeJsonIfChanged.cjs +18 -0
  290. package/dist/cjs/writeJsonIfChanged.cjs.map +1 -0
  291. package/dist/esm/_virtual/_rolldown/runtime.mjs +8 -0
  292. package/dist/esm/_virtual/_utils_asset.mjs +97 -0
  293. package/dist/esm/build.mjs +26 -0
  294. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs +78 -0
  295. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs.map +1 -0
  296. package/dist/esm/buildIntlayerDictionary/index.mjs +4 -0
  297. package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs +25 -0
  298. package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs.map +1 -0
  299. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs +201 -0
  300. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs.map +1 -0
  301. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs +56 -0
  302. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs.map +1 -0
  303. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs +47 -0
  304. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs.map +1 -0
  305. package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs +49 -0
  306. package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs.map +1 -0
  307. package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs +59 -0
  308. package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs.map +1 -0
  309. package/dist/esm/cleanOutputDir.mjs +29 -0
  310. package/dist/esm/cleanOutputDir.mjs.map +1 -0
  311. package/dist/esm/cleanRemovedContentDeclaration.mjs +94 -0
  312. package/dist/esm/cleanRemovedContentDeclaration.mjs.map +1 -0
  313. package/dist/esm/cli.mjs +20 -0
  314. package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs +69 -0
  315. package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs.map +1 -0
  316. package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs +41 -0
  317. package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs.map +1 -0
  318. package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs +22 -0
  319. package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs.map +1 -0
  320. package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs +23 -0
  321. package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs.map +1 -0
  322. package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs +23 -0
  323. package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs.map +1 -0
  324. package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs +22 -0
  325. package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs.map +1 -0
  326. package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs +22 -0
  327. package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs.map +1 -0
  328. package/dist/esm/createDictionaryEntryPoint/index.mjs +9 -0
  329. package/dist/esm/createType/createModuleAugmentation.mjs +122 -0
  330. package/dist/esm/createType/createModuleAugmentation.mjs.map +1 -0
  331. package/dist/esm/createType/createType.mjs +27 -0
  332. package/dist/esm/createType/createType.mjs.map +1 -0
  333. package/dist/esm/createType/index.mjs +4 -0
  334. package/dist/esm/detectFormatCommand.mjs +31 -0
  335. package/dist/esm/detectFormatCommand.mjs.map +1 -0
  336. package/dist/esm/docReview/alignBlocks.mjs +78 -0
  337. package/dist/esm/docReview/alignBlocks.mjs.map +1 -0
  338. package/dist/esm/docReview/computeSimilarity.mjs +39 -0
  339. package/dist/esm/docReview/computeSimilarity.mjs.map +1 -0
  340. package/dist/esm/docReview/fingerprintBlock.mjs +32 -0
  341. package/dist/esm/docReview/fingerprintBlock.mjs.map +1 -0
  342. package/dist/esm/docReview/index.mjs +12 -0
  343. package/dist/esm/docReview/mapChangedLinesToBlocks.mjs +25 -0
  344. package/dist/esm/docReview/mapChangedLinesToBlocks.mjs.map +1 -0
  345. package/dist/esm/docReview/normalizeBlock.mjs +32 -0
  346. package/dist/esm/docReview/normalizeBlock.mjs.map +1 -0
  347. package/dist/esm/docReview/pipeline.mjs +142 -0
  348. package/dist/esm/docReview/pipeline.mjs.map +1 -0
  349. package/dist/esm/docReview/planActions.mjs +56 -0
  350. package/dist/esm/docReview/planActions.mjs.map +1 -0
  351. package/dist/esm/docReview/rebuildDocument.mjs +62 -0
  352. package/dist/esm/docReview/rebuildDocument.mjs.map +1 -0
  353. package/dist/esm/docReview/reviewReport.mjs +196 -0
  354. package/dist/esm/docReview/reviewReport.mjs.map +1 -0
  355. package/dist/esm/docReview/segmentDocument.mjs +131 -0
  356. package/dist/esm/docReview/segmentDocument.mjs.map +1 -0
  357. package/dist/esm/docReview/types.mjs +0 -0
  358. package/dist/esm/fetchDistantDictionaries.mjs +51 -0
  359. package/dist/esm/fetchDistantDictionaries.mjs.map +1 -0
  360. package/dist/esm/filterInvalidDictionaries.mjs +53 -0
  361. package/dist/esm/filterInvalidDictionaries.mjs.map +1 -0
  362. package/dist/esm/formatDictionary.mjs +55 -0
  363. package/dist/esm/formatDictionary.mjs.map +1 -0
  364. package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs +81 -0
  365. package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs.map +1 -0
  366. package/dist/esm/getContentDeclarationFileTemplate/index.mjs +3 -0
  367. package/dist/esm/handleAdditionalContentDeclarationFile.mjs +33 -0
  368. package/dist/esm/handleAdditionalContentDeclarationFile.mjs.map +1 -0
  369. package/dist/esm/handleContentDeclarationFileChange.mjs +54 -0
  370. package/dist/esm/handleContentDeclarationFileChange.mjs.map +1 -0
  371. package/dist/esm/handleContentDeclarationFileMoved.mjs +23 -0
  372. package/dist/esm/handleContentDeclarationFileMoved.mjs.map +1 -0
  373. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs +36 -0
  374. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs.map +1 -0
  375. package/dist/esm/init/cms.mjs +131 -0
  376. package/dist/esm/init/cms.mjs.map +1 -0
  377. package/dist/esm/init/frameworkSetup/index.mjs +26 -0
  378. package/dist/esm/init/frameworkSetup/index.mjs.map +1 -0
  379. package/dist/esm/init/frameworkSetup/nextAppRouter/detect.mjs +52 -0
  380. package/dist/esm/init/frameworkSetup/nextAppRouter/detect.mjs.map +1 -0
  381. package/dist/esm/init/frameworkSetup/nextAppRouter/index.mjs +104 -0
  382. package/dist/esm/init/frameworkSetup/nextAppRouter/index.mjs.map +1 -0
  383. package/dist/esm/init/frameworkSetup/nextAppRouter/restructure.mjs +157 -0
  384. package/dist/esm/init/frameworkSetup/nextAppRouter/restructure.mjs.map +1 -0
  385. package/dist/esm/init/frameworkSetup/nextAppRouter/templates.mjs +113 -0
  386. package/dist/esm/init/frameworkSetup/nextAppRouter/templates.mjs.map +1 -0
  387. package/dist/esm/init/frameworkSetup/nextAppRouter/transforms.mjs +193 -0
  388. package/dist/esm/init/frameworkSetup/nextAppRouter/transforms.mjs.map +1 -0
  389. package/dist/esm/init/frameworkSetup/tanstackStart/detect.mjs +28 -0
  390. package/dist/esm/init/frameworkSetup/tanstackStart/detect.mjs.map +1 -0
  391. package/dist/esm/init/frameworkSetup/tanstackStart/index.mjs +73 -0
  392. package/dist/esm/init/frameworkSetup/tanstackStart/index.mjs.map +1 -0
  393. package/dist/esm/init/frameworkSetup/tanstackStart/restructure.mjs +108 -0
  394. package/dist/esm/init/frameworkSetup/tanstackStart/restructure.mjs.map +1 -0
  395. package/dist/esm/init/frameworkSetup/tanstackStart/templates.mjs +102 -0
  396. package/dist/esm/init/frameworkSetup/tanstackStart/templates.mjs.map +1 -0
  397. package/dist/esm/init/frameworkSetup/tanstackStart/transforms.mjs +139 -0
  398. package/dist/esm/init/frameworkSetup/tanstackStart/transforms.mjs.map +1 -0
  399. package/dist/esm/init/frameworkSetup/types.mjs +0 -0
  400. package/dist/esm/init/index.mjs +518 -0
  401. package/dist/esm/init/index.mjs.map +1 -0
  402. package/dist/esm/init/utils/astImports.mjs +51 -0
  403. package/dist/esm/init/utils/astImports.mjs.map +1 -0
  404. package/dist/esm/init/utils/configManipulation.mjs +499 -0
  405. package/dist/esm/init/utils/configManipulation.mjs.map +1 -0
  406. package/dist/esm/init/utils/fileSystem.mjs +222 -0
  407. package/dist/esm/init/utils/fileSystem.mjs.map +1 -0
  408. package/dist/esm/init/utils/githubActions.mjs +155 -0
  409. package/dist/esm/init/utils/githubActions.mjs.map +1 -0
  410. package/dist/esm/init/utils/index.mjs +10 -0
  411. package/dist/esm/init/utils/jsonParser.mjs +41 -0
  412. package/dist/esm/init/utils/jsonParser.mjs.map +1 -0
  413. package/dist/esm/init/utils/nextCompilerBabel.mjs +115 -0
  414. package/dist/esm/init/utils/nextCompilerBabel.mjs.map +1 -0
  415. package/dist/esm/init/utils/packageManager.mjs +294 -0
  416. package/dist/esm/init/utils/packageManager.mjs.map +1 -0
  417. package/dist/esm/init/utils/tsConfig.mjs +17 -0
  418. package/dist/esm/init/utils/tsConfig.mjs.map +1 -0
  419. package/dist/esm/initConfig/index.mjs +47 -0
  420. package/dist/esm/initConfig/index.mjs.map +1 -0
  421. package/dist/esm/installLSP.mjs +55 -0
  422. package/dist/esm/installLSP.mjs.map +1 -0
  423. package/dist/esm/installMCP/installMCP.mjs +47 -0
  424. package/dist/esm/installMCP/installMCP.mjs.map +1 -0
  425. package/dist/esm/installSkills/index.mjs +299 -0
  426. package/dist/esm/installSkills/index.mjs.map +1 -0
  427. package/dist/esm/listDictionariesPath.mjs +39 -0
  428. package/dist/esm/listDictionariesPath.mjs.map +1 -0
  429. package/dist/esm/listGitFiles.mjs +101 -0
  430. package/dist/esm/listGitFiles.mjs.map +1 -0
  431. package/dist/esm/listProjects.mjs +44 -0
  432. package/dist/esm/listProjects.mjs.map +1 -0
  433. package/dist/esm/loadDictionaries/getIntlayerBundle.mjs +54 -0
  434. package/dist/esm/loadDictionaries/getIntlayerBundle.mjs.map +1 -0
  435. package/dist/esm/loadDictionaries/index.mjs +6 -0
  436. package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +128 -0
  437. package/dist/esm/loadDictionaries/loadContentDeclaration.mjs.map +1 -0
  438. package/dist/esm/loadDictionaries/loadDictionaries.mjs +125 -0
  439. package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -0
  440. package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs +26 -0
  441. package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs.map +1 -0
  442. package/dist/esm/loadDictionaries/loadMarkdownContentDeclaration.mjs +43 -0
  443. package/dist/esm/loadDictionaries/loadMarkdownContentDeclaration.mjs.map +1 -0
  444. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs +60 -0
  445. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -0
  446. package/dist/esm/loadDictionaries/loadYamlContentDeclaration.mjs +25 -0
  447. package/dist/esm/loadDictionaries/loadYamlContentDeclaration.mjs.map +1 -0
  448. package/dist/esm/loadDictionaries/log.mjs +135 -0
  449. package/dist/esm/loadDictionaries/log.mjs.map +1 -0
  450. package/dist/esm/loadDictionaries/logTypeScriptErrors.mjs +62 -0
  451. package/dist/esm/loadDictionaries/logTypeScriptErrors.mjs.map +1 -0
  452. package/dist/esm/logConfigDetails.mjs +37 -0
  453. package/dist/esm/logConfigDetails.mjs.map +1 -0
  454. package/dist/esm/prepareIntlayer.mjs +100 -0
  455. package/dist/esm/prepareIntlayer.mjs.map +1 -0
  456. package/dist/esm/reduceDictionaryContent/applyMask.mjs +29 -0
  457. package/dist/esm/reduceDictionaryContent/applyMask.mjs.map +1 -0
  458. package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs +11 -0
  459. package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs.map +1 -0
  460. package/dist/esm/scan/analyzeBundleContent.mjs +180 -0
  461. package/dist/esm/scan/analyzeBundleContent.mjs.map +1 -0
  462. package/dist/esm/scan/calculateScore.mjs +61 -0
  463. package/dist/esm/scan/calculateScore.mjs.map +1 -0
  464. package/dist/esm/scan/checks.mjs +265 -0
  465. package/dist/esm/scan/checks.mjs.map +1 -0
  466. package/dist/esm/scan/index.mjs +7 -0
  467. package/dist/esm/scan/parseHtml.mjs +115 -0
  468. package/dist/esm/scan/parseHtml.mjs.map +1 -0
  469. package/dist/esm/scan/scanWebsite.mjs +203 -0
  470. package/dist/esm/scan/scanWebsite.mjs.map +1 -0
  471. package/dist/esm/scan/types.mjs +0 -0
  472. package/dist/esm/utils/autoDecorateContent.mjs +87 -0
  473. package/dist/esm/utils/autoDecorateContent.mjs.map +1 -0
  474. package/dist/esm/utils/buildComponentFilesList.mjs +91 -0
  475. package/dist/esm/utils/buildComponentFilesList.mjs.map +1 -0
  476. package/dist/esm/utils/buildFilesList.mjs +80 -0
  477. package/dist/esm/utils/buildFilesList.mjs.map +1 -0
  478. package/dist/esm/utils/chunkJSON.mjs +334 -0
  479. package/dist/esm/utils/chunkJSON.mjs.map +1 -0
  480. package/dist/esm/utils/formatter.mjs +14 -0
  481. package/dist/esm/utils/formatter.mjs.map +1 -0
  482. package/dist/esm/utils/getChunk.mjs +34 -0
  483. package/dist/esm/utils/getChunk.mjs.map +1 -0
  484. package/dist/esm/utils/getContentExtension.mjs +28 -0
  485. package/dist/esm/utils/getContentExtension.mjs.map +1 -0
  486. package/dist/esm/utils/getFormatFromExtension.mjs +38 -0
  487. package/dist/esm/utils/getFormatFromExtension.mjs.map +1 -0
  488. package/dist/esm/utils/getPathHash.mjs +20 -0
  489. package/dist/esm/utils/getPathHash.mjs.map +1 -0
  490. package/dist/esm/utils/index.mjs +22 -0
  491. package/dist/esm/utils/mergeChunks.mjs +27 -0
  492. package/dist/esm/utils/mergeChunks.mjs.map +1 -0
  493. package/dist/esm/utils/pLimit.mjs +131 -0
  494. package/dist/esm/utils/pLimit.mjs.map +1 -0
  495. package/dist/esm/utils/parallelize.mjs +11 -0
  496. package/dist/esm/utils/parallelize.mjs.map +1 -0
  497. package/dist/esm/utils/parallelizeGlobal.mjs +27 -0
  498. package/dist/esm/utils/parallelizeGlobal.mjs.map +1 -0
  499. package/dist/esm/utils/readDictionariesFromDisk.mjs +23 -0
  500. package/dist/esm/utils/readDictionariesFromDisk.mjs.map +1 -0
  501. package/dist/esm/utils/reduceObjectFormat.mjs +67 -0
  502. package/dist/esm/utils/reduceObjectFormat.mjs.map +1 -0
  503. package/dist/esm/utils/resolveObjectPromises.mjs +20 -0
  504. package/dist/esm/utils/resolveObjectPromises.mjs.map +1 -0
  505. package/dist/esm/utils/resolveRelativePath.mjs +20 -0
  506. package/dist/esm/utils/resolveRelativePath.mjs.map +1 -0
  507. package/dist/esm/utils/runOnce.mjs +93 -0
  508. package/dist/esm/utils/runOnce.mjs.map +1 -0
  509. package/dist/esm/utils/runParallel/bin.mjs +53 -0
  510. package/dist/esm/utils/runParallel/bin.mjs.map +1 -0
  511. package/dist/esm/utils/runParallel/bootstrap.mjs +23 -0
  512. package/dist/esm/utils/runParallel/bootstrap.mjs.map +1 -0
  513. package/dist/esm/utils/runParallel/index.mjs +100 -0
  514. package/dist/esm/utils/runParallel/index.mjs.map +1 -0
  515. package/dist/esm/utils/runParallel/pidTree.mjs +143 -0
  516. package/dist/esm/utils/runParallel/pidTree.mjs.map +1 -0
  517. package/dist/esm/utils/runParallel/ps.mjs +47 -0
  518. package/dist/esm/utils/runParallel/ps.mjs.map +1 -0
  519. package/dist/esm/utils/runParallel/runTask.mjs +153 -0
  520. package/dist/esm/utils/runParallel/runTask.mjs.map +1 -0
  521. package/dist/esm/utils/runParallel/spawnPosix.mjs +47 -0
  522. package/dist/esm/utils/runParallel/spawnPosix.mjs.map +1 -0
  523. package/dist/esm/utils/runParallel/spawnWin32.mjs +42 -0
  524. package/dist/esm/utils/runParallel/spawnWin32.mjs.map +1 -0
  525. package/dist/esm/utils/runParallel/wmic.mjs +50 -0
  526. package/dist/esm/utils/runParallel/wmic.mjs.map +1 -0
  527. package/dist/esm/utils/sortAlphabetically.mjs +6 -0
  528. package/dist/esm/utils/sortAlphabetically.mjs.map +1 -0
  529. package/dist/esm/utils/splitTextByLine.mjs +10 -0
  530. package/dist/esm/utils/splitTextByLine.mjs.map +1 -0
  531. package/dist/esm/utils/verifyIdenticObjectFormat.mjs +64 -0
  532. package/dist/esm/utils/verifyIdenticObjectFormat.mjs.map +1 -0
  533. package/dist/esm/watcher.mjs +226 -0
  534. package/dist/esm/watcher.mjs.map +1 -0
  535. package/dist/esm/writeConfiguration/generateConfigurationContent.mjs +33 -0
  536. package/dist/esm/writeConfiguration/generateConfigurationContent.mjs.map +1 -0
  537. package/dist/esm/writeConfiguration/index.mjs +22 -0
  538. package/dist/esm/writeConfiguration/index.mjs.map +1 -0
  539. package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs +27 -0
  540. package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs.map +1 -0
  541. package/dist/esm/writeContentDeclaration/dictionaryStatus.mjs +0 -0
  542. package/dist/esm/writeContentDeclaration/index.mjs +6 -0
  543. package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs +92 -0
  544. package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs.map +1 -0
  545. package/dist/esm/writeContentDeclaration/transformJSFile.mjs +412 -0
  546. package/dist/esm/writeContentDeclaration/transformJSFile.mjs.map +1 -0
  547. package/dist/esm/writeContentDeclaration/transformJSONFile.mjs +125 -0
  548. package/dist/esm/writeContentDeclaration/transformJSONFile.mjs.map +1 -0
  549. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +162 -0
  550. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -0
  551. package/dist/esm/writeContentDeclaration/writeJSFile.mjs +91 -0
  552. package/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -0
  553. package/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs +64 -0
  554. package/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs.map +1 -0
  555. package/dist/esm/writeContentDeclaration/writeYamlFile.mjs +42 -0
  556. package/dist/esm/writeContentDeclaration/writeYamlFile.mjs.map +1 -0
  557. package/dist/esm/writeFileIfChanged.mjs +49 -0
  558. package/dist/esm/writeFileIfChanged.mjs.map +1 -0
  559. package/dist/esm/writeJsonIfChanged.mjs +17 -0
  560. package/dist/esm/writeJsonIfChanged.mjs.map +1 -0
  561. package/dist/types/build.d.ts +26 -0
  562. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +25 -0
  563. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -0
  564. package/dist/types/buildIntlayerDictionary/index.d.ts +3 -0
  565. package/dist/types/buildIntlayerDictionary/processContentDeclaration.d.ts +11 -0
  566. package/dist/types/buildIntlayerDictionary/processContentDeclaration.d.ts.map +1 -0
  567. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +77 -0
  568. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -0
  569. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts +25 -0
  570. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -0
  571. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +40 -0
  572. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts.map +1 -0
  573. package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts +29 -0
  574. package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts.map +1 -0
  575. package/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts +34 -0
  576. package/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts.map +1 -0
  577. package/dist/types/cleanOutputDir.d.ts +7 -0
  578. package/dist/types/cleanOutputDir.d.ts.map +1 -0
  579. package/dist/types/cleanRemovedContentDeclaration.d.ts +11 -0
  580. package/dist/types/cleanRemovedContentDeclaration.d.ts.map +1 -0
  581. package/dist/types/cli.d.ts +21 -0
  582. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +14 -0
  583. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts.map +1 -0
  584. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +10 -0
  585. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts.map +1 -0
  586. package/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts +10 -0
  587. package/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts.map +1 -0
  588. package/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts +10 -0
  589. package/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts.map +1 -0
  590. package/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts +10 -0
  591. package/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts.map +1 -0
  592. package/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts +10 -0
  593. package/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts.map +1 -0
  594. package/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts +10 -0
  595. package/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts.map +1 -0
  596. package/dist/types/createDictionaryEntryPoint/index.d.ts +8 -0
  597. package/dist/types/createType/createModuleAugmentation.d.ts +9 -0
  598. package/dist/types/createType/createModuleAugmentation.d.ts.map +1 -0
  599. package/dist/types/createType/createType.d.ts +12 -0
  600. package/dist/types/createType/createType.d.ts.map +1 -0
  601. package/dist/types/createType/index.d.ts +3 -0
  602. package/dist/types/detectFormatCommand.d.ts +7 -0
  603. package/dist/types/detectFormatCommand.d.ts.map +1 -0
  604. package/dist/types/docReview/alignBlocks.d.ts +18 -0
  605. package/dist/types/docReview/alignBlocks.d.ts.map +1 -0
  606. package/dist/types/docReview/computeSimilarity.d.ts +22 -0
  607. package/dist/types/docReview/computeSimilarity.d.ts.map +1 -0
  608. package/dist/types/docReview/fingerprintBlock.d.ts +18 -0
  609. package/dist/types/docReview/fingerprintBlock.d.ts.map +1 -0
  610. package/dist/types/docReview/index.d.ts +12 -0
  611. package/dist/types/docReview/mapChangedLinesToBlocks.d.ts +15 -0
  612. package/dist/types/docReview/mapChangedLinesToBlocks.d.ts.map +1 -0
  613. package/dist/types/docReview/normalizeBlock.d.ts +18 -0
  614. package/dist/types/docReview/normalizeBlock.d.ts.map +1 -0
  615. package/dist/types/docReview/pipeline.d.ts +46 -0
  616. package/dist/types/docReview/pipeline.d.ts.map +1 -0
  617. package/dist/types/docReview/planActions.d.ts +18 -0
  618. package/dist/types/docReview/planActions.d.ts.map +1 -0
  619. package/dist/types/docReview/rebuildDocument.d.ts +46 -0
  620. package/dist/types/docReview/rebuildDocument.d.ts.map +1 -0
  621. package/dist/types/docReview/reviewReport.d.ts +82 -0
  622. package/dist/types/docReview/reviewReport.d.ts.map +1 -0
  623. package/dist/types/docReview/segmentDocument.d.ts +40 -0
  624. package/dist/types/docReview/segmentDocument.d.ts.map +1 -0
  625. package/dist/types/docReview/types.d.ts +73 -0
  626. package/dist/types/docReview/types.d.ts.map +1 -0
  627. package/dist/types/fetchDistantDictionaries.d.ts +16 -0
  628. package/dist/types/fetchDistantDictionaries.d.ts.map +1 -0
  629. package/dist/types/filterInvalidDictionaries.d.ts +12 -0
  630. package/dist/types/filterInvalidDictionaries.d.ts.map +1 -0
  631. package/dist/types/formatDictionary.d.ts +62 -0
  632. package/dist/types/formatDictionary.d.ts.map +1 -0
  633. package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts +7 -0
  634. package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts.map +1 -0
  635. package/dist/types/getContentDeclarationFileTemplate/index.d.ts +2 -0
  636. package/dist/types/handleAdditionalContentDeclarationFile.d.ts +7 -0
  637. package/dist/types/handleAdditionalContentDeclarationFile.d.ts.map +1 -0
  638. package/dist/types/handleContentDeclarationFileChange.d.ts +7 -0
  639. package/dist/types/handleContentDeclarationFileChange.d.ts.map +1 -0
  640. package/dist/types/handleContentDeclarationFileMoved.d.ts +7 -0
  641. package/dist/types/handleContentDeclarationFileMoved.d.ts.map +1 -0
  642. package/dist/types/handleUnlinkedContentDeclarationFile.d.ts +7 -0
  643. package/dist/types/handleUnlinkedContentDeclarationFile.d.ts.map +1 -0
  644. package/dist/types/init/cms.d.ts +51 -0
  645. package/dist/types/init/cms.d.ts.map +1 -0
  646. package/dist/types/init/frameworkSetup/index.d.ts +13 -0
  647. package/dist/types/init/frameworkSetup/index.d.ts.map +1 -0
  648. package/dist/types/init/frameworkSetup/nextAppRouter/detect.d.ts +25 -0
  649. package/dist/types/init/frameworkSetup/nextAppRouter/detect.d.ts.map +1 -0
  650. package/dist/types/init/frameworkSetup/nextAppRouter/index.d.ts +12 -0
  651. package/dist/types/init/frameworkSetup/nextAppRouter/index.d.ts.map +1 -0
  652. package/dist/types/init/frameworkSetup/nextAppRouter/restructure.d.ts +56 -0
  653. package/dist/types/init/frameworkSetup/nextAppRouter/restructure.d.ts.map +1 -0
  654. package/dist/types/init/frameworkSetup/nextAppRouter/templates.d.ts +26 -0
  655. package/dist/types/init/frameworkSetup/nextAppRouter/templates.d.ts.map +1 -0
  656. package/dist/types/init/frameworkSetup/nextAppRouter/transforms.d.ts +23 -0
  657. package/dist/types/init/frameworkSetup/nextAppRouter/transforms.d.ts.map +1 -0
  658. package/dist/types/init/frameworkSetup/tanstackStart/detect.d.ts +19 -0
  659. package/dist/types/init/frameworkSetup/tanstackStart/detect.d.ts.map +1 -0
  660. package/dist/types/init/frameworkSetup/tanstackStart/index.d.ts +13 -0
  661. package/dist/types/init/frameworkSetup/tanstackStart/index.d.ts.map +1 -0
  662. package/dist/types/init/frameworkSetup/tanstackStart/restructure.d.ts +68 -0
  663. package/dist/types/init/frameworkSetup/tanstackStart/restructure.d.ts.map +1 -0
  664. package/dist/types/init/frameworkSetup/tanstackStart/templates.d.ts +22 -0
  665. package/dist/types/init/frameworkSetup/tanstackStart/templates.d.ts.map +1 -0
  666. package/dist/types/init/frameworkSetup/tanstackStart/transforms.d.ts +17 -0
  667. package/dist/types/init/frameworkSetup/tanstackStart/transforms.d.ts.map +1 -0
  668. package/dist/types/init/frameworkSetup/types.d.ts +43 -0
  669. package/dist/types/init/frameworkSetup/types.d.ts.map +1 -0
  670. package/dist/types/init/index.d.ts +46 -0
  671. package/dist/types/init/index.d.ts.map +1 -0
  672. package/dist/types/init/utils/astImports.d.ts +29 -0
  673. package/dist/types/init/utils/astImports.d.ts.map +1 -0
  674. package/dist/types/init/utils/configManipulation.d.ts +99 -0
  675. package/dist/types/init/utils/configManipulation.d.ts.map +1 -0
  676. package/dist/types/init/utils/fileSystem.d.ts +111 -0
  677. package/dist/types/init/utils/fileSystem.d.ts.map +1 -0
  678. package/dist/types/init/utils/githubActions.d.ts +19 -0
  679. package/dist/types/init/utils/githubActions.d.ts.map +1 -0
  680. package/dist/types/init/utils/index.d.ts +9 -0
  681. package/dist/types/init/utils/jsonParser.d.ts +8 -0
  682. package/dist/types/init/utils/jsonParser.d.ts.map +1 -0
  683. package/dist/types/init/utils/nextCompilerBabel.d.ts +53 -0
  684. package/dist/types/init/utils/nextCompilerBabel.d.ts.map +1 -0
  685. package/dist/types/init/utils/packageManager.d.ts +149 -0
  686. package/dist/types/init/utils/packageManager.d.ts.map +1 -0
  687. package/dist/types/init/utils/tsConfig.d.ts +8 -0
  688. package/dist/types/init/utils/tsConfig.d.ts.map +1 -0
  689. package/dist/types/initConfig/index.d.ts +10 -0
  690. package/dist/types/initConfig/index.d.ts.map +1 -0
  691. package/dist/types/installLSP.d.ts +12 -0
  692. package/dist/types/installLSP.d.ts.map +1 -0
  693. package/dist/types/installMCP/installMCP.d.ts +11 -0
  694. package/dist/types/installMCP/installMCP.d.ts.map +1 -0
  695. package/dist/types/installSkills/index.d.ts +42 -0
  696. package/dist/types/installSkills/index.d.ts.map +1 -0
  697. package/dist/types/listDictionariesPath.d.ts +17 -0
  698. package/dist/types/listDictionariesPath.d.ts.map +1 -0
  699. package/dist/types/listGitFiles.d.ts +27 -0
  700. package/dist/types/listGitFiles.d.ts.map +1 -0
  701. package/dist/types/listProjects.d.ts +26 -0
  702. package/dist/types/listProjects.d.ts.map +1 -0
  703. package/dist/types/loadDictionaries/getIntlayerBundle.d.ts +7 -0
  704. package/dist/types/loadDictionaries/getIntlayerBundle.d.ts.map +1 -0
  705. package/dist/types/loadDictionaries/index.d.ts +5 -0
  706. package/dist/types/loadDictionaries/loadContentDeclaration.d.ts +15 -0
  707. package/dist/types/loadDictionaries/loadContentDeclaration.d.ts.map +1 -0
  708. package/dist/types/loadDictionaries/loadDictionaries.d.ts +23 -0
  709. package/dist/types/loadDictionaries/loadDictionaries.d.ts.map +1 -0
  710. package/dist/types/loadDictionaries/loadLocalDictionaries.d.ts +8 -0
  711. package/dist/types/loadDictionaries/loadLocalDictionaries.d.ts.map +1 -0
  712. package/dist/types/loadDictionaries/loadMarkdownContentDeclaration.d.ts +7 -0
  713. package/dist/types/loadDictionaries/loadMarkdownContentDeclaration.d.ts.map +1 -0
  714. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +15 -0
  715. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts.map +1 -0
  716. package/dist/types/loadDictionaries/loadYamlContentDeclaration.d.ts +7 -0
  717. package/dist/types/loadDictionaries/loadYamlContentDeclaration.d.ts.map +1 -0
  718. package/dist/types/loadDictionaries/log.d.ts +36 -0
  719. package/dist/types/loadDictionaries/log.d.ts.map +1 -0
  720. package/dist/types/loadDictionaries/logTypeScriptErrors.d.ts +7 -0
  721. package/dist/types/loadDictionaries/logTypeScriptErrors.d.ts.map +1 -0
  722. package/dist/types/logConfigDetails.d.ts +7 -0
  723. package/dist/types/logConfigDetails.d.ts.map +1 -0
  724. package/dist/types/prepareIntlayer.d.ts +15 -0
  725. package/dist/types/prepareIntlayer.d.ts.map +1 -0
  726. package/dist/types/reduceDictionaryContent/applyMask.d.ts +7 -0
  727. package/dist/types/reduceDictionaryContent/applyMask.d.ts.map +1 -0
  728. package/dist/types/reduceDictionaryContent/reduceDictionaryContent.d.ts +7 -0
  729. package/dist/types/reduceDictionaryContent/reduceDictionaryContent.d.ts.map +1 -0
  730. package/dist/types/scan/analyzeBundleContent.d.ts +16 -0
  731. package/dist/types/scan/analyzeBundleContent.d.ts.map +1 -0
  732. package/dist/types/scan/calculateScore.d.ts +65 -0
  733. package/dist/types/scan/calculateScore.d.ts.map +1 -0
  734. package/dist/types/scan/checks.d.ts +38 -0
  735. package/dist/types/scan/checks.d.ts.map +1 -0
  736. package/dist/types/scan/index.d.ts +7 -0
  737. package/dist/types/scan/parseHtml.d.ts +54 -0
  738. package/dist/types/scan/parseHtml.d.ts.map +1 -0
  739. package/dist/types/scan/scanWebsite.d.ts +18 -0
  740. package/dist/types/scan/scanWebsite.d.ts.map +1 -0
  741. package/dist/types/scan/types.d.ts +76 -0
  742. package/dist/types/scan/types.d.ts.map +1 -0
  743. package/dist/types/utils/autoDecorateContent.d.ts +13 -0
  744. package/dist/types/utils/autoDecorateContent.d.ts.map +1 -0
  745. package/dist/types/utils/buildComponentFilesList.d.ts +28 -0
  746. package/dist/types/utils/buildComponentFilesList.d.ts.map +1 -0
  747. package/dist/types/utils/buildFilesList.d.ts +62 -0
  748. package/dist/types/utils/buildFilesList.d.ts.map +1 -0
  749. package/dist/types/utils/chunkJSON.d.ts +56 -0
  750. package/dist/types/utils/chunkJSON.d.ts.map +1 -0
  751. package/dist/types/utils/formatter.d.ts +9 -0
  752. package/dist/types/utils/formatter.d.ts.map +1 -0
  753. package/dist/types/utils/getChunk.d.ts +11 -0
  754. package/dist/types/utils/getChunk.d.ts.map +1 -0
  755. package/dist/types/utils/getContentExtension.d.ts +15 -0
  756. package/dist/types/utils/getContentExtension.d.ts.map +1 -0
  757. package/dist/types/utils/getFormatFromExtension.d.ts +8 -0
  758. package/dist/types/utils/getFormatFromExtension.d.ts.map +1 -0
  759. package/dist/types/utils/getPathHash.d.ts +8 -0
  760. package/dist/types/utils/getPathHash.d.ts.map +1 -0
  761. package/dist/types/utils/index.d.ts +21 -0
  762. package/dist/types/utils/mergeChunks.d.ts +5 -0
  763. package/dist/types/utils/mergeChunks.d.ts.map +1 -0
  764. package/dist/types/utils/pLimit.d.ts +16 -0
  765. package/dist/types/utils/pLimit.d.ts.map +1 -0
  766. package/dist/types/utils/parallelize.d.ts +5 -0
  767. package/dist/types/utils/parallelize.d.ts.map +1 -0
  768. package/dist/types/utils/parallelizeGlobal.d.ts +20 -0
  769. package/dist/types/utils/parallelizeGlobal.d.ts.map +1 -0
  770. package/dist/types/utils/readDictionariesFromDisk.d.ts +9 -0
  771. package/dist/types/utils/readDictionariesFromDisk.d.ts.map +1 -0
  772. package/dist/types/utils/reduceObjectFormat.d.ts +30 -0
  773. package/dist/types/utils/reduceObjectFormat.d.ts.map +1 -0
  774. package/dist/types/utils/resolveObjectPromises.d.ts +9 -0
  775. package/dist/types/utils/resolveObjectPromises.d.ts.map +1 -0
  776. package/dist/types/utils/resolveRelativePath.d.ts +5 -0
  777. package/dist/types/utils/resolveRelativePath.d.ts.map +1 -0
  778. package/dist/types/utils/runOnce.d.ts +45 -0
  779. package/dist/types/utils/runOnce.d.ts.map +1 -0
  780. package/dist/types/utils/runParallel/bin.d.ts +15 -0
  781. package/dist/types/utils/runParallel/bin.d.ts.map +1 -0
  782. package/dist/types/utils/runParallel/bootstrap.d.ts +5 -0
  783. package/dist/types/utils/runParallel/bootstrap.d.ts.map +1 -0
  784. package/dist/types/utils/runParallel/index.d.ts +14 -0
  785. package/dist/types/utils/runParallel/index.d.ts.map +1 -0
  786. package/dist/types/utils/runParallel/pidTree.d.ts +24 -0
  787. package/dist/types/utils/runParallel/pidTree.d.ts.map +1 -0
  788. package/dist/types/utils/runParallel/ps.d.ts +11 -0
  789. package/dist/types/utils/runParallel/ps.d.ts.map +1 -0
  790. package/dist/types/utils/runParallel/runTask.d.ts +26 -0
  791. package/dist/types/utils/runParallel/runTask.d.ts.map +1 -0
  792. package/dist/types/utils/runParallel/spawnPosix.d.ts +20 -0
  793. package/dist/types/utils/runParallel/spawnPosix.d.ts.map +1 -0
  794. package/dist/types/utils/runParallel/spawnWin32.d.ts +20 -0
  795. package/dist/types/utils/runParallel/spawnWin32.d.ts.map +1 -0
  796. package/dist/types/utils/runParallel/wmic.d.ts +11 -0
  797. package/dist/types/utils/runParallel/wmic.d.ts.map +1 -0
  798. package/dist/types/utils/sortAlphabetically.d.ts +5 -0
  799. package/dist/types/utils/sortAlphabetically.d.ts.map +1 -0
  800. package/dist/types/utils/splitTextByLine.d.ts +5 -0
  801. package/dist/types/utils/splitTextByLine.d.ts.map +1 -0
  802. package/dist/types/utils/verifyIdenticObjectFormat.d.ts +23 -0
  803. package/dist/types/utils/verifyIdenticObjectFormat.d.ts.map +1 -0
  804. package/dist/types/watcher.d.ts +17 -0
  805. package/dist/types/watcher.d.ts.map +1 -0
  806. package/dist/types/writeConfiguration/generateConfigurationContent.d.ts +7 -0
  807. package/dist/types/writeConfiguration/generateConfigurationContent.d.ts.map +1 -0
  808. package/dist/types/writeConfiguration/index.d.ts +8 -0
  809. package/dist/types/writeConfiguration/index.d.ts.map +1 -0
  810. package/dist/types/writeContentDeclaration/detectExportedComponentName.d.ts +12 -0
  811. package/dist/types/writeContentDeclaration/detectExportedComponentName.d.ts.map +1 -0
  812. package/dist/types/writeContentDeclaration/dictionaryStatus.d.ts +5 -0
  813. package/dist/types/writeContentDeclaration/dictionaryStatus.d.ts.map +1 -0
  814. package/dist/types/writeContentDeclaration/index.d.ts +6 -0
  815. package/dist/types/writeContentDeclaration/processContentDeclarationContent.d.ts +14 -0
  816. package/dist/types/writeContentDeclaration/processContentDeclarationContent.d.ts.map +1 -0
  817. package/dist/types/writeContentDeclaration/transformJSFile.d.ts +11 -0
  818. package/dist/types/writeContentDeclaration/transformJSFile.d.ts.map +1 -0
  819. package/dist/types/writeContentDeclaration/transformJSONFile.d.ts +7 -0
  820. package/dist/types/writeContentDeclaration/transformJSONFile.d.ts.map +1 -0
  821. package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts +19 -0
  822. package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts.map +1 -0
  823. package/dist/types/writeContentDeclaration/writeJSFile.d.ts +14 -0
  824. package/dist/types/writeContentDeclaration/writeJSFile.d.ts.map +1 -0
  825. package/dist/types/writeContentDeclaration/writeMarkdownFile.d.ts +8 -0
  826. package/dist/types/writeContentDeclaration/writeMarkdownFile.d.ts.map +1 -0
  827. package/dist/types/writeContentDeclaration/writeYamlFile.d.ts +8 -0
  828. package/dist/types/writeContentDeclaration/writeYamlFile.d.ts.map +1 -0
  829. package/dist/types/writeFileIfChanged.d.ts +11 -0
  830. package/dist/types/writeFileIfChanged.d.ts.map +1 -0
  831. package/dist/types/writeJsonIfChanged.d.ts +9 -0
  832. package/dist/types/writeJsonIfChanged.d.ts.map +1 -0
  833. package/package.json +159 -0
@@ -0,0 +1,412 @@
1
+ import { getNodeType } from "@intlayer/core/dictionaryManipulator";
2
+ import * as NodeTypes from "@intlayer/types/nodeType";
3
+ import * as recast from "recast";
4
+ import * as babelTsParser from "recast/parsers/babel-ts.js";
5
+
6
+ //#region src/writeContentDeclaration/transformJSFile.ts
7
+ const b = recast.types.builders;
8
+ const n = recast.types.namedTypes;
9
+ /**
10
+ * Unwraps TypeScript/Babel expression wrappers (satisfies, as, !, <Type>).
11
+ * Uses string fallbacks to bypass outdated ast-types definitions.
12
+ */
13
+ const unwrap = (node) => {
14
+ while (node && (n.TSSatisfiesExpression?.check(node) || n.TSAsExpression?.check(node) || n.TSTypeAssertion?.check(node) || n.TSNonNullExpression?.check(node) || [
15
+ "TSSatisfiesExpression",
16
+ "TSAsExpression",
17
+ "TSTypeAssertion",
18
+ "TSNonNullExpression"
19
+ ].includes(node.type))) node = node.expression;
20
+ return node;
21
+ };
22
+ /**
23
+ * Robustly finds a property in a recast ObjectExpression.
24
+ * Handles quoted ("key") or unquoted (key) properties.
25
+ */
26
+ const getMatchingProperty = (node, key) => {
27
+ return node.properties.find((prop) => {
28
+ if (n.Property.check(prop) || n.ObjectProperty.check(prop)) {
29
+ if (n.Identifier.check(prop.key) && prop.key.name === key) return true;
30
+ if (n.StringLiteral.check(prop.key) && prop.key.value === key) return true;
31
+ if (n.Literal.check(prop.key) && prop.key.value === key) return true;
32
+ }
33
+ return false;
34
+ });
35
+ };
36
+ /**
37
+ * Synchronizes numeric suffixes across locales.
38
+ * E.g. "Hello 1" -> "Hello 3" updates "Bonjour 1" to "Bonjour 3".
39
+ */
40
+ const syncNumericSuffixAcrossLocales = (existingNode, fallbackLocaleCode, newFallbackValue) => {
41
+ const trailingNumberMatch = newFallbackValue.match(/\d+(?!.*\d)/);
42
+ if (!trailingNumberMatch) return;
43
+ const newTrailingNumber = trailingNumberMatch[0];
44
+ if (n.ObjectExpression.check(existingNode)) {
45
+ for (const prop of existingNode.properties) if (n.Property.check(prop) || n.ObjectProperty.check(prop)) {
46
+ let propName = "";
47
+ if (n.Identifier.check(prop.key)) propName = prop.key.name;
48
+ else if (n.Literal.check(prop.key) && typeof prop.key.value === "string") propName = prop.key.value;
49
+ else if (n.StringLiteral.check(prop.key)) propName = prop.key.value;
50
+ if (propName && propName !== fallbackLocaleCode) {
51
+ if (n.Literal.check(prop.value) && typeof prop.value.value === "string") {
52
+ const currentValue = prop.value.value;
53
+ if (currentValue.match(/\d+(?!.*\d)/)) prop.value = b.literal(currentValue.replace(/(\d+)(?!.*\d)/, newTrailingNumber));
54
+ } else if (n.StringLiteral.check(prop.value)) {
55
+ const currentValue = prop.value.value;
56
+ if (currentValue.match(/\d+(?!.*\d)/)) prop.value = b.stringLiteral(currentValue.replace(/(\d+)(?!.*\d)/, newTrailingNumber));
57
+ }
58
+ }
59
+ }
60
+ }
61
+ };
62
+ /**
63
+ * Checks if a value represents a multilingual Intlayer node.
64
+ * A node is multilingual if it is a Translation node, or if it is a specialized node
65
+ * (Markdown, HTML, etc.) that contains a Translation node.
66
+ */
67
+ const isMultilingualNode = (val) => {
68
+ if (typeof val !== "object" || val === null || Array.isArray(val)) return false;
69
+ const nodeType = getNodeType(val);
70
+ if (nodeType === NodeTypes.TRANSLATION) return true;
71
+ if (nodeType === NodeTypes.MARKDOWN || nodeType === NodeTypes.HTML || nodeType === NodeTypes.INSERTION) return isMultilingualNode(val[nodeType]);
72
+ if (nodeType === NodeTypes.ENUMERATION || nodeType === NodeTypes.PLURAL || nodeType === NodeTypes.CONDITION || nodeType === NodeTypes.GENDER) {
73
+ const data = val[nodeType];
74
+ if (data && typeof data === "object") return Object.values(data).some((v) => isMultilingualNode(v));
75
+ }
76
+ return false;
77
+ };
78
+ /**
79
+ * Recursively builds or updates an AST node for a given dictionary value.
80
+ */
81
+ const buildNodeForValue = (val, existingNode, fallbackLocale, requiredImports) => {
82
+ const unwrappedExisting = unwrap(existingNode);
83
+ if (unwrappedExisting) {
84
+ if (!(n.Literal.check(unwrappedExisting) || n.StringLiteral.check(unwrappedExisting) || n.NumericLiteral.check(unwrappedExisting) || n.BooleanLiteral.check(unwrappedExisting) || n.TemplateLiteral.check(unwrappedExisting) || n.ObjectExpression.check(unwrappedExisting) || n.ArrayExpression.check(unwrappedExisting) || n.CallExpression.check(unwrappedExisting) && n.Identifier.check(unwrappedExisting.callee) && [
85
+ "t",
86
+ "enu",
87
+ "plural",
88
+ "cond",
89
+ "gender",
90
+ "insert",
91
+ "md",
92
+ "html",
93
+ "file",
94
+ "nest"
95
+ ].includes(unwrappedExisting.callee.name))) return existingNode;
96
+ }
97
+ if (fallbackLocale && !existingNode && !isMultilingualNode(val)) {
98
+ if (val === null) return b.literal(null);
99
+ if (typeof val === "string" || typeof val === "number" || typeof val === "boolean") {
100
+ if (typeof val === "string" && val.includes("\n")) return b.templateLiteral([b.templateElement({
101
+ raw: val,
102
+ cooked: val
103
+ }, true)], []);
104
+ return b.literal(val);
105
+ }
106
+ }
107
+ if (fallbackLocale && existingNode && !isMultilingualNode(val)) {
108
+ if (n.CallExpression.check(existingNode) && n.Identifier.check(existingNode.callee) && existingNode.callee.name === "t") {
109
+ const arg = unwrap(existingNode.arguments[0]);
110
+ if (n.ObjectExpression.check(arg)) {
111
+ if (typeof val === "string") syncNumericSuffixAcrossLocales(arg, fallbackLocale, val);
112
+ updateObjectLiteral(arg, { [fallbackLocale]: val }, fallbackLocale, requiredImports);
113
+ if (!fallbackLocale) requiredImports.add("t");
114
+ return existingNode;
115
+ }
116
+ }
117
+ if ((!val || typeof val !== "object") && n.CallExpression.check(existingNode) && n.Identifier.check(existingNode.callee) && existingNode.callee.name === "md") {
118
+ const innerArg = existingNode.arguments[0];
119
+ if (n.CallExpression.check(innerArg) && n.Identifier.check(innerArg.callee) && innerArg.callee.name === "t") {
120
+ const tArg = unwrap(innerArg.arguments[0]);
121
+ if (n.ObjectExpression.check(tArg)) {
122
+ if (typeof val === "string") syncNumericSuffixAcrossLocales(tArg, fallbackLocale, val);
123
+ updateObjectLiteral(tArg, { [fallbackLocale]: val }, fallbackLocale, requiredImports);
124
+ requiredImports.add("md");
125
+ requiredImports.add("t");
126
+ return existingNode;
127
+ }
128
+ }
129
+ }
130
+ }
131
+ if (val === null) return b.literal(null);
132
+ if (typeof val === "string" || typeof val === "number" || typeof val === "boolean") {
133
+ if (unwrappedExisting) {
134
+ if (n.TemplateLiteral.check(unwrappedExisting) && unwrappedExisting.expressions.length === 0) {
135
+ unwrappedExisting.quasis[0].value.raw = String(val);
136
+ unwrappedExisting.quasis[0].value.cooked = String(val);
137
+ return existingNode;
138
+ }
139
+ if (n.Literal.check(unwrappedExisting) || n.StringLiteral.check(unwrappedExisting)) {
140
+ unwrappedExisting.value = val;
141
+ return existingNode;
142
+ }
143
+ }
144
+ if (typeof val === "string" && val.includes("\n")) return b.templateLiteral([b.templateElement({
145
+ raw: val,
146
+ cooked: val
147
+ }, true)], []);
148
+ return b.literal(val);
149
+ }
150
+ if (Array.isArray(val)) if (unwrappedExisting && n.ArrayExpression.check(unwrappedExisting)) {
151
+ const elements = [...unwrappedExisting.elements];
152
+ val.forEach((item, i) => {
153
+ elements[i] = buildNodeForValue(item, elements[i], fallbackLocale, requiredImports);
154
+ });
155
+ if (elements.length > val.length) elements.length = val.length;
156
+ unwrappedExisting.elements = elements;
157
+ return existingNode;
158
+ } else return b.arrayExpression(val.map((item) => buildNodeForValue(item, null, fallbackLocale, requiredImports)));
159
+ const nodeType = val && typeof val === "object" && !Array.isArray(val) ? getNodeType(val) : null;
160
+ if (nodeType && [
161
+ NodeTypes.TRANSLATION,
162
+ NodeTypes.ENUMERATION,
163
+ NodeTypes.PLURAL,
164
+ NodeTypes.CONDITION,
165
+ NodeTypes.GENDER,
166
+ NodeTypes.INSERTION,
167
+ NodeTypes.MARKDOWN,
168
+ NodeTypes.HTML,
169
+ NodeTypes.FILE,
170
+ NodeTypes.NESTED,
171
+ NodeTypes.ARRAY,
172
+ NodeTypes.OBJECT,
173
+ NodeTypes.REACT_NODE,
174
+ NodeTypes.NUMBER,
175
+ NodeTypes.BOOLEAN,
176
+ NodeTypes.NULL,
177
+ NodeTypes.UNKNOWN
178
+ ].includes(nodeType) && nodeType !== NodeTypes.TEXT) {
179
+ const nodeData = val[nodeType];
180
+ let calleeName = "";
181
+ if (nodeType === NodeTypes.TRANSLATION) calleeName = "t";
182
+ else if (nodeType === NodeTypes.ENUMERATION) calleeName = "enu";
183
+ else if (nodeType === NodeTypes.PLURAL) calleeName = "plural";
184
+ else if (nodeType === NodeTypes.CONDITION) calleeName = "cond";
185
+ else if (nodeType === NodeTypes.GENDER) calleeName = "gender";
186
+ else if (nodeType === NodeTypes.INSERTION) calleeName = "insert";
187
+ else if (nodeType === NodeTypes.MARKDOWN) calleeName = "md";
188
+ else if (nodeType === NodeTypes.HTML) calleeName = "html";
189
+ else if (nodeType === NodeTypes.FILE) calleeName = "file";
190
+ else if (nodeType === NodeTypes.NESTED) calleeName = "nest";
191
+ if (calleeName) requiredImports.add(calleeName);
192
+ const isMatchingCall = existingNode && n.CallExpression.check(existingNode) && n.Identifier.check(existingNode.callee) && existingNode.callee.name === calleeName;
193
+ if ([
194
+ "t",
195
+ "enu",
196
+ "plural",
197
+ "cond",
198
+ "gender"
199
+ ].includes(calleeName)) {
200
+ let objArg = null;
201
+ if (isMatchingCall && existingNode.arguments.length > 0 && n.ObjectExpression.check(existingNode.arguments[0])) objArg = existingNode.arguments[0];
202
+ else objArg = b.objectExpression([]);
203
+ updateObjectLiteral(objArg, nodeData, fallbackLocale, requiredImports);
204
+ return isMatchingCall ? existingNode : b.callExpression(b.identifier(calleeName), [objArg]);
205
+ }
206
+ if ([
207
+ "md",
208
+ "html",
209
+ "insert",
210
+ "file"
211
+ ].includes(calleeName)) {
212
+ const argNode = buildNodeForValue(nodeData, isMatchingCall && existingNode.arguments.length > 0 ? existingNode.arguments[0] : null, fallbackLocale, requiredImports);
213
+ if (isMatchingCall) {
214
+ existingNode.arguments[0] = argNode;
215
+ return existingNode;
216
+ }
217
+ return b.callExpression(b.identifier(calleeName), [argNode]);
218
+ }
219
+ if (calleeName === "nest") {
220
+ const args = [b.literal(nodeData.dictionaryKey)];
221
+ if (nodeData.path) args.push(b.literal(nodeData.path));
222
+ if (isMatchingCall) {
223
+ existingNode.arguments = args;
224
+ return existingNode;
225
+ }
226
+ return b.callExpression(b.identifier("nest"), args);
227
+ }
228
+ }
229
+ const objNode = unwrappedExisting && n.ObjectExpression.check(unwrappedExisting) ? unwrappedExisting : b.objectExpression([]);
230
+ updateObjectLiteral(objNode, val, fallbackLocale, requiredImports);
231
+ return existingNode && unwrappedExisting === existingNode ? objNode : existingNode || objNode;
232
+ };
233
+ /**
234
+ * Recursively updates the AST object literal properties.
235
+ */
236
+ const updateObjectLiteral = (node, data, fallbackLocale, requiredImports) => {
237
+ for (const [key, val] of Object.entries(data)) {
238
+ if (val === void 0) continue;
239
+ const existingProp = getMatchingProperty(node, key);
240
+ if (existingProp) existingProp.value = buildNodeForValue(val, existingProp.value, fallbackLocale, requiredImports);
241
+ else {
242
+ const keyNode = /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? b.identifier(key) : b.literal(key);
243
+ const valueNode = buildNodeForValue(val, null, fallbackLocale, requiredImports);
244
+ node.properties.push(b.property("init", keyNode, valueNode));
245
+ }
246
+ }
247
+ };
248
+ /**
249
+ * Modifies the AST's top-level imports to inject dynamically needed helper utilities seamlessly.
250
+ */
251
+ const addImports = (ast, requiredImports, isESM) => {
252
+ if (requiredImports.size === 0) return;
253
+ const existingCoreImports = /* @__PURE__ */ new Set();
254
+ let coreImportPath = null;
255
+ recast.visit(ast, {
256
+ visitImportDeclaration(path) {
257
+ if (path.node.source.value === "intlayer") {
258
+ coreImportPath = path;
259
+ path.node.specifiers?.forEach((spec) => {
260
+ if (n.ImportSpecifier.check(spec) && typeof spec.imported.name === "string") existingCoreImports.add(spec.imported.name);
261
+ });
262
+ }
263
+ return false;
264
+ },
265
+ visitVariableDeclaration(path) {
266
+ path.node.declarations.forEach((decl) => {
267
+ if (n.VariableDeclarator.check(decl) && n.CallExpression.check(decl.init) && n.Identifier.check(decl.init.callee) && decl.init.callee.name === "require") {
268
+ const arg = decl.init.arguments[0];
269
+ if (n.Literal.check(arg)) {
270
+ if (arg.value === "intlayer") {
271
+ if (n.ObjectPattern.check(decl.id)) decl.id.properties.forEach((prop) => {
272
+ if (n.Property.check(prop) && (n.Identifier.check(prop.key) || n.Identifier.check(prop.value))) {
273
+ const name = n.Identifier.check(prop.key) ? prop.key.name : prop.value.name;
274
+ existingCoreImports.add(name);
275
+ }
276
+ });
277
+ else if (n.Identifier.check(decl.id)) existingCoreImports.add(decl.id.name);
278
+ }
279
+ }
280
+ }
281
+ });
282
+ return false;
283
+ }
284
+ });
285
+ const missingCore = Array.from(requiredImports).filter((imp) => !existingCoreImports.has(imp));
286
+ if (missingCore.length === 0) return;
287
+ if (isESM) if (coreImportPath) {
288
+ missingCore.forEach((imp) => {
289
+ coreImportPath.node.specifiers.push(b.importSpecifier(b.identifier(imp)));
290
+ });
291
+ coreImportPath.node.specifiers.sort((a, b) => a.imported.name.localeCompare(b.imported.name));
292
+ } else {
293
+ const specifiers = missingCore.sort().map((imp) => b.importSpecifier(b.identifier(imp)));
294
+ const newImport = b.importDeclaration(specifiers, b.literal("intlayer"));
295
+ ast.program.body.unshift(newImport);
296
+ }
297
+ else {
298
+ let insertIndex = 0;
299
+ if (ast.program.body.length > 0 && n.ExpressionStatement.check(ast.program.body[0]) && n.Literal.check(ast.program.body[0].expression)) insertIndex = 1;
300
+ const cjsLines = [];
301
+ const properties = missingCore.sort().map((imp) => {
302
+ const prop = b.property("init", b.identifier(imp), b.identifier(imp));
303
+ prop.shorthand = true;
304
+ return prop;
305
+ });
306
+ cjsLines.push(b.variableDeclaration("const", [b.variableDeclarator(b.objectPattern(properties), b.callExpression(b.identifier("require"), [b.literal("intlayer")]))]));
307
+ ast.program.body.splice(insertIndex, 0, ...cjsLines);
308
+ }
309
+ };
310
+ /**
311
+ * Updates a JS/TS file seamlessly to map new localization keys, arrays, complex nodes and nested dictionaries gracefully using AST updates via Recast parser.
312
+ */
313
+ const transformJSFile = async (fileContent, dictionary, fallbackLocale, noMetadata) => {
314
+ if (!dictionary || typeof dictionary !== "object") return fileContent;
315
+ let ast;
316
+ try {
317
+ ast = recast.parse(fileContent, { parser: babelTsParser });
318
+ } catch (error) {
319
+ console.error({ error });
320
+ return fileContent;
321
+ }
322
+ let rootObject = null;
323
+ let isESM = false;
324
+ recast.visit(ast, {
325
+ visitExportDefaultDeclaration() {
326
+ isESM = true;
327
+ return false;
328
+ },
329
+ visitImportDeclaration() {
330
+ isESM = true;
331
+ return false;
332
+ }
333
+ });
334
+ recast.visit(ast, {
335
+ visitExportDefaultDeclaration(path) {
336
+ const decl = path.node.declaration;
337
+ const unwrappedDecl = unwrap(decl);
338
+ if (n.ObjectExpression.check(unwrappedDecl)) rootObject = unwrappedDecl;
339
+ else if (n.Identifier.check(unwrappedDecl)) {
340
+ const varName = unwrappedDecl.name;
341
+ recast.visit(ast, { visitVariableDeclarator(vp) {
342
+ const unwrappedInit = unwrap(vp.node.init);
343
+ if (n.Identifier.check(vp.node.id) && vp.node.id.name === varName && n.ObjectExpression.check(unwrappedInit)) rootObject = unwrappedInit;
344
+ return false;
345
+ } });
346
+ }
347
+ return false;
348
+ },
349
+ visitAssignmentExpression(path) {
350
+ const left = path.node.left;
351
+ if (n.MemberExpression.check(left)) {
352
+ if (n.Identifier.check(left.object) && left.object.name === "module" && n.Identifier.check(left.property) && left.property.name === "exports") {
353
+ const unwrappedRight = unwrap(path.node.right);
354
+ if (n.ObjectExpression.check(unwrappedRight)) rootObject = unwrappedRight;
355
+ }
356
+ if (n.Identifier.check(left.object) && left.object.name === "exports" && n.Identifier.check(left.property) && left.property.name === "default") {
357
+ const unwrappedRight = unwrap(path.node.right);
358
+ if (n.ObjectExpression.check(unwrappedRight)) rootObject = unwrappedRight;
359
+ }
360
+ }
361
+ this.traverse(path);
362
+ }
363
+ });
364
+ if (!rootObject) recast.visit(ast, { visitVariableDeclarator(path) {
365
+ const unwrappedInit = unwrap(path.node.init);
366
+ if (!rootObject && n.ObjectExpression.check(unwrappedInit)) rootObject = unwrappedInit;
367
+ return false;
368
+ } });
369
+ if (!rootObject) return fileContent;
370
+ const requiredImports = /* @__PURE__ */ new Set();
371
+ const effectiveFallbackLocale = fallbackLocale ?? "en";
372
+ const metadataProperties = [
373
+ "id",
374
+ "locale",
375
+ "filled",
376
+ "fill",
377
+ "title",
378
+ "description",
379
+ "tags",
380
+ "version",
381
+ "priority",
382
+ "contentAutoTransformation"
383
+ ];
384
+ if (noMetadata) {
385
+ rootObject.properties = rootObject.properties.filter((prop) => {
386
+ if (n.Property.check(prop) || n.ObjectProperty.check(prop)) {
387
+ let propName = "";
388
+ if (n.Identifier.check(prop.key)) propName = prop.key.name;
389
+ else if (n.StringLiteral.check(prop.key)) propName = prop.key.value;
390
+ else if (n.Literal.check(prop.key)) propName = String(prop.key.value);
391
+ return ![
392
+ "key",
393
+ "content",
394
+ ...metadataProperties
395
+ ].includes(propName);
396
+ }
397
+ return true;
398
+ });
399
+ recast.visit(ast, { visitNode(path) {
400
+ const node = path.node;
401
+ if ((n.TSSatisfiesExpression?.check(node) || node.type === "TSSatisfiesExpression") && node.typeAnnotation && n.TSTypeReference.check(node.typeAnnotation) && n.Identifier.check(node.typeAnnotation.typeName) && node.typeAnnotation.typeName.name === "Dictionary") node.typeAnnotation = b.tsIndexedAccessType(b.tsTypeReference(b.identifier("Dictionary")), b.tsLiteralType(b.stringLiteral("content")));
402
+ this.traverse(path);
403
+ } });
404
+ } else for (const prop of metadataProperties) if (dictionary[prop] !== void 0) updateObjectLiteral(rootObject, { [prop]: dictionary[prop] }, void 0, requiredImports);
405
+ if (dictionary.content !== void 0) updateObjectLiteral(rootObject, noMetadata ? dictionary.content : { content: dictionary.content }, effectiveFallbackLocale, requiredImports);
406
+ addImports(ast, requiredImports, isESM);
407
+ return recast.print(ast).code;
408
+ };
409
+
410
+ //#endregion
411
+ export { transformJSFile };
412
+ //# sourceMappingURL=transformJSFile.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformJSFile.mjs","names":[],"sources":["../../../src/writeContentDeclaration/transformJSFile.ts"],"sourcesContent":["import { getNodeType } from '@intlayer/core/dictionaryManipulator';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { ContentNode, Dictionary } from '@intlayer/types/dictionary';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport * as recast from 'recast';\nimport * as babelTsParser from 'recast/parsers/babel-ts.js';\n\nconst b = recast.types.builders;\nconst n = recast.types.namedTypes;\n\n/**\n * Unwraps TypeScript/Babel expression wrappers (satisfies, as, !, <Type>).\n * Uses string fallbacks to bypass outdated ast-types definitions.\n */\nconst unwrap = (node: any) => {\n while (\n node &&\n (n.TSSatisfiesExpression?.check(node) ||\n n.TSAsExpression?.check(node) ||\n n.TSTypeAssertion?.check(node) ||\n n.TSNonNullExpression?.check(node) ||\n [\n 'TSSatisfiesExpression',\n 'TSAsExpression',\n 'TSTypeAssertion',\n 'TSNonNullExpression',\n ].includes(node.type))\n ) {\n node = node.expression;\n }\n return node;\n};\n\n/**\n * Robustly finds a property in a recast ObjectExpression.\n * Handles quoted (\"key\") or unquoted (key) properties.\n */\nconst getMatchingProperty = (node: any, key: string) => {\n return node.properties.find((prop: any) => {\n if (n.Property.check(prop) || n.ObjectProperty.check(prop)) {\n if (n.Identifier.check(prop.key) && prop.key.name === key) return true;\n\n if (n.StringLiteral.check(prop.key) && prop.key.value === key)\n return true;\n\n if (n.Literal.check(prop.key) && prop.key.value === key) return true;\n }\n\n return false;\n });\n};\n\n/**\n * Synchronizes numeric suffixes across locales.\n * E.g. \"Hello 1\" -> \"Hello 3\" updates \"Bonjour 1\" to \"Bonjour 3\".\n */\nconst syncNumericSuffixAcrossLocales = (\n existingNode: any,\n fallbackLocaleCode: string,\n newFallbackValue: string\n) => {\n const trailingNumberMatch = newFallbackValue.match(/\\d+(?!.*\\d)/);\n if (!trailingNumberMatch) return;\n const newTrailingNumber = trailingNumberMatch[0];\n\n if (n.ObjectExpression.check(existingNode)) {\n for (const prop of existingNode.properties) {\n if (n.Property.check(prop) || n.ObjectProperty.check(prop)) {\n let propName = '';\n\n if (n.Identifier.check(prop.key)) propName = prop.key.name;\n else if (\n n.Literal.check(prop.key) &&\n typeof prop.key.value === 'string'\n )\n propName = prop.key.value;\n else if (n.StringLiteral.check(prop.key)) propName = prop.key.value;\n\n if (propName && propName !== fallbackLocaleCode) {\n if (\n n.Literal.check(prop.value) &&\n typeof prop.value.value === 'string'\n ) {\n const currentValue = prop.value.value;\n const currentTrailingNumberMatch =\n currentValue.match(/\\d+(?!.*\\d)/);\n\n if (currentTrailingNumberMatch) {\n prop.value = b.literal(\n currentValue.replace(/(\\d+)(?!.*\\d)/, newTrailingNumber)\n );\n }\n } else if (n.StringLiteral.check(prop.value)) {\n const currentValue = prop.value.value;\n const currentTrailingNumberMatch =\n currentValue.match(/\\d+(?!.*\\d)/);\n\n if (currentTrailingNumberMatch) {\n prop.value = b.stringLiteral(\n currentValue.replace(/(\\d+)(?!.*\\d)/, newTrailingNumber)\n );\n }\n }\n }\n }\n }\n }\n};\n\n/**\n * Checks if a value represents a multilingual Intlayer node.\n * A node is multilingual if it is a Translation node, or if it is a specialized node\n * (Markdown, HTML, etc.) that contains a Translation node.\n */\nconst isMultilingualNode = (val: any): boolean => {\n if (typeof val !== 'object' || val === null || Array.isArray(val)) {\n return false;\n }\n\n const nodeType = getNodeType(val as ContentNode);\n\n if (nodeType === NodeTypes.TRANSLATION) {\n return true;\n }\n\n if (\n nodeType === NodeTypes.MARKDOWN ||\n nodeType === NodeTypes.HTML ||\n nodeType === NodeTypes.INSERTION\n ) {\n return isMultilingualNode((val as any)[nodeType]);\n }\n\n if (\n nodeType === NodeTypes.ENUMERATION ||\n nodeType === NodeTypes.PLURAL ||\n nodeType === NodeTypes.CONDITION ||\n nodeType === NodeTypes.GENDER\n ) {\n const data = (val as any)[nodeType];\n\n if (data && typeof data === 'object') {\n return Object.values(data).some((v) => isMultilingualNode(v));\n }\n }\n\n return false;\n};\n\n/**\n * Recursively builds or updates an AST node for a given dictionary value.\n */\nconst buildNodeForValue = (\n val: any,\n existingNode: any,\n fallbackLocale: string | undefined, // In per-locale mode, this is the locale of the file\n requiredImports: Set<string>\n): any => {\n const unwrappedExisting = unwrap(existingNode);\n\n // --- CRITICAL GUARD: STRICT AST PRESERVATION ---\n // If the existing node is code (JSX, Variables, standard functions), leave it alone.\n // Only allow updates to literals, plain objects, arrays, and Intlayer helpers.\n if (unwrappedExisting) {\n const isUpdatableNode =\n n.Literal.check(unwrappedExisting) ||\n n.StringLiteral.check(unwrappedExisting) ||\n n.NumericLiteral.check(unwrappedExisting) ||\n n.BooleanLiteral.check(unwrappedExisting) ||\n n.TemplateLiteral.check(unwrappedExisting) ||\n n.ObjectExpression.check(unwrappedExisting) ||\n n.ArrayExpression.check(unwrappedExisting) ||\n (n.CallExpression.check(unwrappedExisting) &&\n n.Identifier.check(unwrappedExisting.callee) &&\n [\n 't',\n 'enu',\n 'plural',\n 'cond',\n 'gender',\n 'insert',\n 'md',\n 'html',\n 'file',\n 'nest',\n ].includes(unwrappedExisting.callee.name));\n\n if (!isUpdatableNode) {\n return existingNode;\n }\n }\n\n // If we are in per-locale mode (fallbackLocale is set)\n // and the value is not already a complex translation node,\n // we want to store it as a simple literal, NOT wrapped in t().\n if (fallbackLocale && !existingNode && !isMultilingualNode(val)) {\n if (val === null) return b.literal(null);\n if (\n typeof val === 'string' ||\n typeof val === 'number' ||\n typeof val === 'boolean'\n ) {\n if (typeof val === 'string' && val.includes('\\n')) {\n return b.templateLiteral(\n [b.templateElement({ raw: val, cooked: val }, true)],\n []\n );\n }\n return b.literal(val);\n }\n }\n\n if (fallbackLocale && existingNode && !isMultilingualNode(val)) {\n if (\n n.CallExpression.check(existingNode) &&\n n.Identifier.check(existingNode.callee) &&\n existingNode.callee.name === 't'\n ) {\n const arg = unwrap(existingNode.arguments[0]);\n\n if (n.ObjectExpression.check(arg)) {\n if (typeof val === 'string') {\n syncNumericSuffixAcrossLocales(arg, fallbackLocale, val);\n }\n updateObjectLiteral(\n arg,\n { [fallbackLocale]: val },\n fallbackLocale,\n requiredImports\n );\n\n if (!fallbackLocale) {\n requiredImports.add('t');\n }\n\n return existingNode;\n }\n }\n\n if (\n (!val || typeof val !== 'object') &&\n n.CallExpression.check(existingNode) &&\n n.Identifier.check(existingNode.callee) &&\n existingNode.callee.name === 'md'\n ) {\n const innerArg = existingNode.arguments[0];\n\n if (\n n.CallExpression.check(innerArg) &&\n n.Identifier.check(innerArg.callee) &&\n innerArg.callee.name === 't'\n ) {\n const tArg = unwrap(innerArg.arguments[0]);\n\n if (n.ObjectExpression.check(tArg)) {\n if (typeof val === 'string') {\n syncNumericSuffixAcrossLocales(tArg, fallbackLocale, val);\n }\n updateObjectLiteral(\n tArg,\n { [fallbackLocale]: val },\n fallbackLocale,\n requiredImports\n );\n requiredImports.add('md');\n requiredImports.add('t');\n\n return existingNode;\n }\n }\n }\n }\n\n // 1. Primitives\n if (val === null) return b.literal(null);\n if (\n typeof val === 'string' ||\n typeof val === 'number' ||\n typeof val === 'boolean'\n ) {\n if (unwrappedExisting) {\n // Preserve existing template literals (backticks)\n if (\n n.TemplateLiteral.check(unwrappedExisting) &&\n unwrappedExisting.expressions.length === 0\n ) {\n unwrappedExisting.quasis[0].value.raw = String(val);\n unwrappedExisting.quasis[0].value.cooked = String(val);\n return existingNode;\n }\n // Preserve existing standard literals (keeps quote styling)\n if (\n n.Literal.check(unwrappedExisting) ||\n n.StringLiteral.check(unwrappedExisting)\n ) {\n unwrappedExisting.value = val;\n return existingNode;\n }\n }\n\n // Force multiline strings to use Template Literals\n if (typeof val === 'string' && val.includes('\\n')) {\n return b.templateLiteral(\n [b.templateElement({ raw: val, cooked: val }, true)],\n []\n );\n }\n return b.literal(val);\n }\n\n // 2. Arrays\n if (Array.isArray(val)) {\n if (unwrappedExisting && n.ArrayExpression.check(unwrappedExisting)) {\n const elements = [...unwrappedExisting.elements];\n val.forEach((item, i) => {\n elements[i] = buildNodeForValue(\n item,\n elements[i],\n fallbackLocale,\n requiredImports\n );\n });\n\n if (elements.length > val.length) elements.length = val.length;\n unwrappedExisting.elements = elements as any;\n\n return existingNode;\n } else {\n return b.arrayExpression(\n val.map((item) =>\n buildNodeForValue(item, null, fallbackLocale, requiredImports)\n )\n );\n }\n }\n\n // 3. Intlayer Specialized Nodes\n const nodeType =\n val && typeof val === 'object' && !Array.isArray(val)\n ? getNodeType(val as ContentNode)\n : null;\n\n if (\n nodeType &&\n [\n NodeTypes.TRANSLATION,\n NodeTypes.ENUMERATION,\n NodeTypes.PLURAL,\n NodeTypes.CONDITION,\n NodeTypes.GENDER,\n NodeTypes.INSERTION,\n NodeTypes.MARKDOWN,\n NodeTypes.HTML,\n NodeTypes.FILE,\n NodeTypes.NESTED,\n NodeTypes.ARRAY,\n NodeTypes.OBJECT,\n NodeTypes.REACT_NODE,\n NodeTypes.NUMBER,\n NodeTypes.BOOLEAN,\n NodeTypes.NULL,\n NodeTypes.UNKNOWN,\n ].includes(nodeType as any) &&\n nodeType !== NodeTypes.TEXT\n ) {\n const nodeData = (val as any)[nodeType];\n let calleeName = '';\n\n if (nodeType === NodeTypes.TRANSLATION) calleeName = 't';\n else if (nodeType === NodeTypes.ENUMERATION) calleeName = 'enu';\n else if (nodeType === NodeTypes.PLURAL) calleeName = 'plural';\n else if (nodeType === NodeTypes.CONDITION) calleeName = 'cond';\n else if (nodeType === NodeTypes.GENDER) calleeName = 'gender';\n else if (nodeType === NodeTypes.INSERTION) calleeName = 'insert';\n else if (nodeType === NodeTypes.MARKDOWN) calleeName = 'md';\n else if (nodeType === NodeTypes.HTML) calleeName = 'html';\n else if (nodeType === NodeTypes.FILE) calleeName = 'file';\n else if (nodeType === NodeTypes.NESTED) calleeName = 'nest';\n\n if (calleeName) requiredImports.add(calleeName);\n\n const isMatchingCall =\n existingNode &&\n n.CallExpression.check(existingNode) &&\n n.Identifier.check(existingNode.callee) &&\n existingNode.callee.name === calleeName;\n\n if (['t', 'enu', 'plural', 'cond', 'gender'].includes(calleeName)) {\n let objArg: any = null;\n\n if (\n isMatchingCall &&\n existingNode.arguments.length > 0 &&\n n.ObjectExpression.check(existingNode.arguments[0])\n ) {\n objArg = existingNode.arguments[0];\n } else {\n objArg = b.objectExpression([]);\n }\n updateObjectLiteral(objArg, nodeData, fallbackLocale, requiredImports);\n\n return isMatchingCall\n ? existingNode\n : b.callExpression(b.identifier(calleeName), [objArg]);\n }\n\n if (['md', 'html', 'insert', 'file'].includes(calleeName)) {\n const argNode = buildNodeForValue(\n nodeData,\n isMatchingCall && existingNode.arguments.length > 0\n ? existingNode.arguments[0]\n : null,\n fallbackLocale,\n requiredImports\n );\n\n if (isMatchingCall) {\n existingNode.arguments[0] = argNode;\n\n return existingNode;\n }\n\n return b.callExpression(b.identifier(calleeName), [argNode]);\n }\n\n if (calleeName === 'nest') {\n const args = [b.literal(nodeData.dictionaryKey)];\n\n if (nodeData.path) args.push(b.literal(nodeData.path));\n\n if (isMatchingCall) {\n existingNode.arguments = args;\n\n return existingNode;\n }\n\n return b.callExpression(b.identifier('nest'), args);\n }\n }\n\n // 4. Plain Object\n const objNode =\n unwrappedExisting && n.ObjectExpression.check(unwrappedExisting)\n ? unwrappedExisting\n : b.objectExpression([]);\n\n updateObjectLiteral(objNode, val, fallbackLocale, requiredImports);\n\n return existingNode && unwrappedExisting === existingNode\n ? objNode\n : existingNode || objNode;\n};\n\n/**\n * Recursively updates the AST object literal properties.\n */\nconst updateObjectLiteral = (\n node: recast.types.namedTypes.ObjectExpression,\n data: Record<string, any>,\n fallbackLocale: string | undefined,\n requiredImports: Set<string>\n) => {\n for (const [key, val] of Object.entries(data)) {\n if (val === undefined) continue;\n\n const existingProp = getMatchingProperty(node, key);\n\n if (existingProp) {\n existingProp.value = buildNodeForValue(\n val,\n existingProp.value,\n fallbackLocale,\n requiredImports\n );\n } else {\n const isValidId = /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key);\n const keyNode = isValidId ? b.identifier(key) : b.literal(key);\n const valueNode = buildNodeForValue(\n val,\n null,\n fallbackLocale,\n requiredImports\n );\n node.properties.push(b.property('init', keyNode, valueNode));\n }\n }\n};\n\n/**\n * Modifies the AST's top-level imports to inject dynamically needed helper utilities seamlessly.\n */\nconst addImports = (ast: any, requiredImports: Set<string>, isESM: boolean) => {\n if (requiredImports.size === 0) return;\n\n const existingCoreImports = new Set<string>();\n let coreImportPath: any = null;\n\n recast.visit(ast, {\n visitImportDeclaration(path) {\n const source = path.node.source.value;\n\n if (source === 'intlayer') {\n coreImportPath = path;\n path.node.specifiers?.forEach((spec) => {\n if (\n n.ImportSpecifier.check(spec) &&\n typeof spec.imported.name === 'string'\n ) {\n existingCoreImports.add(spec.imported.name);\n }\n });\n }\n\n return false;\n },\n visitVariableDeclaration(path) {\n path.node.declarations.forEach((decl) => {\n if (\n n.VariableDeclarator.check(decl) &&\n n.CallExpression.check(decl.init) &&\n n.Identifier.check(decl.init.callee) &&\n decl.init.callee.name === 'require'\n ) {\n const arg = decl.init.arguments[0];\n\n if (n.Literal.check(arg)) {\n if (arg.value === 'intlayer') {\n if (n.ObjectPattern.check(decl.id)) {\n decl.id.properties.forEach((prop) => {\n if (\n n.Property.check(prop) &&\n (n.Identifier.check(prop.key) ||\n n.Identifier.check(prop.value))\n ) {\n const name = n.Identifier.check(prop.key)\n ? prop.key.name\n : (prop.value as any).name;\n existingCoreImports.add(name);\n }\n });\n } else if (n.Identifier.check(decl.id)) {\n // Handle const intlayer = require('intlayer')\n existingCoreImports.add(decl.id.name);\n }\n }\n }\n }\n });\n\n return false;\n },\n });\n\n const missingCore = Array.from(requiredImports).filter(\n (imp) => !existingCoreImports.has(imp)\n );\n\n if (missingCore.length === 0) return;\n\n if (isESM) {\n if (coreImportPath) {\n missingCore.forEach((imp) => {\n coreImportPath.node.specifiers.push(\n b.importSpecifier(b.identifier(imp))\n );\n });\n coreImportPath.node.specifiers.sort((a: any, b: any) =>\n a.imported.name.localeCompare(b.imported.name)\n );\n } else {\n const specifiers = missingCore\n .sort()\n .map((imp) => b.importSpecifier(b.identifier(imp)));\n const newImport = b.importDeclaration(specifiers, b.literal('intlayer'));\n ast.program.body.unshift(newImport);\n }\n } else {\n let insertIndex = 0;\n\n if (\n ast.program.body.length > 0 &&\n n.ExpressionStatement.check(ast.program.body[0]) &&\n n.Literal.check(ast.program.body[0].expression)\n ) {\n insertIndex = 1; // Insert after 'use strict'\n }\n const cjsLines: any[] = [];\n\n const properties = missingCore.sort().map((imp) => {\n const prop = b.property('init', b.identifier(imp), b.identifier(imp));\n prop.shorthand = true;\n\n return prop;\n });\n cjsLines.push(\n b.variableDeclaration('const', [\n b.variableDeclarator(\n b.objectPattern(properties),\n b.callExpression(b.identifier('require'), [b.literal('intlayer')])\n ),\n ])\n );\n\n ast.program.body.splice(insertIndex, 0, ...cjsLines);\n }\n};\n\n/**\n * Updates a JS/TS file seamlessly to map new localization keys, arrays, complex nodes and nested dictionaries gracefully using AST updates via Recast parser.\n */\nexport const transformJSFile = async (\n fileContent: string,\n dictionary: Dictionary,\n fallbackLocale?: Locale,\n noMetadata?: boolean\n): Promise<string> => {\n if (!dictionary || typeof dictionary !== 'object') return fileContent;\n\n let ast: any;\n try {\n ast = recast.parse(fileContent, {\n parser: babelTsParser,\n });\n } catch (error) {\n console.error({ error });\n return fileContent;\n }\n\n let rootObject: any = null;\n let isESM = false;\n\n recast.visit(ast, {\n visitExportDefaultDeclaration() {\n isESM = true;\n\n return false;\n },\n visitImportDeclaration() {\n isESM = true;\n\n return false;\n },\n });\n\n recast.visit(ast, {\n visitExportDefaultDeclaration(path) {\n const decl = path.node.declaration;\n const unwrappedDecl = unwrap(decl);\n\n if (n.ObjectExpression.check(unwrappedDecl)) {\n rootObject = unwrappedDecl;\n } else if (n.Identifier.check(unwrappedDecl)) {\n const varName = unwrappedDecl.name;\n recast.visit(ast, {\n visitVariableDeclarator(vp) {\n const unwrappedInit = unwrap(vp.node.init);\n\n if (\n n.Identifier.check(vp.node.id) &&\n vp.node.id.name === varName &&\n n.ObjectExpression.check(unwrappedInit)\n ) {\n rootObject = unwrappedInit;\n }\n\n return false;\n },\n });\n }\n\n return false;\n },\n visitAssignmentExpression(path) {\n const left = path.node.left;\n\n if (n.MemberExpression.check(left)) {\n if (\n n.Identifier.check(left.object) &&\n left.object.name === 'module' &&\n n.Identifier.check(left.property) &&\n left.property.name === 'exports'\n ) {\n const unwrappedRight = unwrap(path.node.right);\n\n if (n.ObjectExpression.check(unwrappedRight)) {\n rootObject = unwrappedRight;\n }\n }\n\n if (\n n.Identifier.check(left.object) &&\n left.object.name === 'exports' &&\n n.Identifier.check(left.property) &&\n left.property.name === 'default'\n ) {\n const unwrappedRight = unwrap(path.node.right);\n\n if (n.ObjectExpression.check(unwrappedRight)) {\n rootObject = unwrappedRight;\n }\n }\n }\n this.traverse(path);\n },\n });\n\n if (!rootObject) {\n recast.visit(ast, {\n visitVariableDeclarator(path) {\n const unwrappedInit = unwrap(path.node.init);\n\n if (!rootObject && n.ObjectExpression.check(unwrappedInit)) {\n rootObject = unwrappedInit;\n }\n\n return false;\n },\n });\n }\n\n if (!rootObject) return fileContent;\n\n const requiredImports = new Set<string>();\n const effectiveFallbackLocale = (fallbackLocale as string) ?? 'en';\n\n const metadataProperties = [\n 'id',\n 'locale',\n 'filled',\n 'fill',\n 'title',\n 'description',\n 'tags',\n 'version',\n 'priority',\n 'contentAutoTransformation',\n ];\n\n if (noMetadata) {\n // Remove key, content and metadata properties if they exist\n rootObject.properties = rootObject.properties.filter((prop: any) => {\n if (n.Property.check(prop) || n.ObjectProperty.check(prop)) {\n let propName = '';\n if (n.Identifier.check(prop.key)) propName = prop.key.name;\n else if (n.StringLiteral.check(prop.key)) propName = prop.key.value;\n else if (n.Literal.check(prop.key)) propName = String(prop.key.value);\n\n return !['key', 'content', ...metadataProperties].includes(propName);\n }\n return true;\n });\n\n // Update satisfies type if exists\n recast.visit(ast, {\n visitNode(path) {\n const node = path.node;\n if (\n (n.TSSatisfiesExpression?.check(node) ||\n node.type === 'TSSatisfiesExpression') &&\n (node as any).typeAnnotation &&\n n.TSTypeReference.check((node as any).typeAnnotation) &&\n n.Identifier.check((node as any).typeAnnotation.typeName) &&\n (node as any).typeAnnotation.typeName.name === 'Dictionary'\n ) {\n (node as any).typeAnnotation = b.tsIndexedAccessType(\n b.tsTypeReference(b.identifier('Dictionary')),\n b.tsLiteralType(b.stringLiteral('content'))\n );\n }\n this.traverse(path);\n },\n });\n } else {\n for (const prop of metadataProperties) {\n if ((dictionary as any)[prop] !== undefined) {\n updateObjectLiteral(\n rootObject,\n { [prop]: (dictionary as any)[prop] },\n undefined,\n requiredImports\n );\n }\n }\n }\n\n if (dictionary.content !== undefined) {\n updateObjectLiteral(\n rootObject,\n noMetadata\n ? (dictionary.content as Record<string, any>)\n : { content: dictionary.content },\n effectiveFallbackLocale,\n requiredImports\n );\n }\n\n addImports(ast, requiredImports, isESM);\n\n return recast.print(ast).code;\n};\n"],"mappings":";;;;;;AAOA,MAAM,IAAI,OAAO,MAAM;AACvB,MAAM,IAAI,OAAO,MAAM;;;;;AAMvB,MAAM,UAAU,SAAc;AAC5B,QACE,SACC,EAAE,uBAAuB,MAAM,KAAK,IACnC,EAAE,gBAAgB,MAAM,KAAK,IAC7B,EAAE,iBAAiB,MAAM,KAAK,IAC9B,EAAE,qBAAqB,MAAM,KAAK,IAClC;EACE;EACA;EACA;EACA;EACD,CAAC,SAAS,KAAK,KAAK,EAEvB,QAAO,KAAK;AAEd,QAAO;;;;;;AAOT,MAAM,uBAAuB,MAAW,QAAgB;AACtD,QAAO,KAAK,WAAW,MAAM,SAAc;AACzC,MAAI,EAAE,SAAS,MAAM,KAAK,IAAI,EAAE,eAAe,MAAM,KAAK,EAAE;AAC1D,OAAI,EAAE,WAAW,MAAM,KAAK,IAAI,IAAI,KAAK,IAAI,SAAS,IAAK,QAAO;AAElE,OAAI,EAAE,cAAc,MAAM,KAAK,IAAI,IAAI,KAAK,IAAI,UAAU,IACxD,QAAO;AAET,OAAI,EAAE,QAAQ,MAAM,KAAK,IAAI,IAAI,KAAK,IAAI,UAAU,IAAK,QAAO;;AAGlE,SAAO;GACP;;;;;;AAOJ,MAAM,kCACJ,cACA,oBACA,qBACG;CACH,MAAM,sBAAsB,iBAAiB,MAAM,cAAc;AACjE,KAAI,CAAC,oBAAqB;C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,MAAM;AAErE,WAAO,CAAC;KAAC;KAAO;KAAW,GAAG;KAAmB,CAAC,SAAS,SAAS;;AAEtE,UAAO;IACP;AAGF,SAAO,MAAM,KAAK,EAChB,UAAU,MAAM;GACd,MAAM,OAAO,KAAK;AAClB,QACG,EAAE,uBAAuB,MAAM,KAAK,IACnC,KAAK,SAAS,4BACf,KAAa,kBACd,EAAE,gBAAgB,MAAO,KAAa,eAAe,IACrD,EAAE,WAAW,MAAO,KAAa,eAAe,SAAS,IACxD,KAAa,eAAe,SAAS,SAAS,aAE/C,CAAC,KAAa,iBAAiB,EAAE,oBAC/B,EAAE,gBAAgB,EAAE,WAAW,aAAa,CAAC,EAC7C,EAAE,cAAc,EAAE,cAAc,UAAU,CAAC,CAC5C;AAEH,QAAK,SAAS,KAAK;KAEtB,CAAC;OAEF,MAAK,MAAM,QAAQ,mBACjB,KAAK,WAAmB,UAAU,OAChC,qBACE,YACA,GAAG,OAAQ,WAAmB,OAAO,EACrC,QACA,gBACD;AAKP,KAAI,WAAW,YAAY,OACzB,qBACE,YACA,aACK,WAAW,UACZ,EAAE,SAAS,WAAW,SAAS,EACnC,yBACA,gBACD;AAGH,YAAW,KAAK,iBAAiB,MAAM;AAEvC,QAAO,OAAO,MAAM,IAAI,CAAC"}
@@ -0,0 +1,125 @@
1
+ import * as recast from "recast";
2
+
3
+ //#region src/writeContentDeclaration/transformJSONFile.ts
4
+ const b = recast.types.builders;
5
+ const n = recast.types.namedTypes;
6
+ /**
7
+ * Checks if a value is a plain object (and not null/array)
8
+ */
9
+ const isPlainObject = (value) => {
10
+ return typeof value === "object" && value !== null && !Array.isArray(value);
11
+ };
12
+ /**
13
+ * Checks if a recast AST node value matches the incoming primitive value.
14
+ */
15
+ const isPrimitiveEqual = (astNode, val) => {
16
+ if (val === null) return n.Literal.check(astNode) && astNode.value === null;
17
+ if (typeof val === "string" || typeof val === "number" || typeof val === "boolean") return (n.Literal.check(astNode) || n.StringLiteral.check(astNode) || n.NumericLiteral.check(astNode) || n.BooleanLiteral.check(astNode)) && astNode.value === val;
18
+ return false;
19
+ };
20
+ /**
21
+ * Robustly finds a property in a recast ObjectExpression.
22
+ * Handles quoted ("key") or unquoted (key) properties.
23
+ */
24
+ const getMatchingProperty = (node, key) => {
25
+ return node.properties.find((prop) => {
26
+ if (n.Property.check(prop) || n.ObjectProperty.check(prop)) {
27
+ if (n.Identifier.check(prop.key) && prop.key.name === key) return true;
28
+ if (n.StringLiteral.check(prop.key) && prop.key.value === key) return true;
29
+ if (n.Literal.check(prop.key) && prop.key.value === key) return true;
30
+ }
31
+ return false;
32
+ });
33
+ };
34
+ /**
35
+ * Recursively builds a clean recast AST node from a plain JS value.
36
+ * Because these nodes lack `loc` tracking, recast is forced to pretty-print them.
37
+ */
38
+ const buildASTNode = (val) => {
39
+ if (val === null) return b.literal(null);
40
+ if (typeof val === "string" || typeof val === "number" || typeof val === "boolean") return b.literal(val);
41
+ if (Array.isArray(val)) return b.arrayExpression(val.map((item) => buildASTNode(item)));
42
+ if (isPlainObject(val)) return b.objectExpression(Object.entries(val).filter(([, v]) => v !== void 0).map(([k, v]) => b.property("init", b.stringLiteral(k), buildASTNode(v))));
43
+ return b.literal(null);
44
+ };
45
+ /**
46
+ * Recursively updates the AST object literal with new data.
47
+ */
48
+ const updateObjectLiteral = (node, data) => {
49
+ for (const [key, val] of Object.entries(data)) {
50
+ if (val === void 0) continue;
51
+ const existingProp = getMatchingProperty(node, key);
52
+ if (existingProp?.comments) existingProp.comments.forEach((c) => {
53
+ if ((c.type === "Line" || c.type === "CommentLine") && c.trailing) {
54
+ c.type = c.type === "Line" ? "Block" : "CommentBlock";
55
+ c.value = `__INLINE_LINE__${c.value}`;
56
+ c.leading = false;
57
+ c.trailing = true;
58
+ }
59
+ });
60
+ if (isPlainObject(val)) if (existingProp && n.ObjectExpression.check(existingProp.value)) updateObjectLiteral(existingProp.value, val);
61
+ else if (existingProp) {
62
+ if (!(n.Literal.check(existingProp.value) && existingProp.value.value === val)) existingProp.value = buildASTNode(val);
63
+ } else node.properties.push(b.property("init", b.stringLiteral(key), buildASTNode(val)));
64
+ else if (existingProp) {
65
+ if (!isPrimitiveEqual(existingProp.value, val)) existingProp.value = buildASTNode(val);
66
+ } else node.properties.push(b.property("init", b.stringLiteral(key), buildASTNode(val)));
67
+ }
68
+ };
69
+ const transformJSONFile = (fileContent, dictionary, noMetadata) => {
70
+ const wrappedContent = `const _config = ${fileContent.trim() || "{}"};`;
71
+ let ast;
72
+ try {
73
+ ast = recast.parse(wrappedContent);
74
+ } catch {
75
+ return JSON.stringify(noMetadata ? dictionary.content : dictionary, null, 2);
76
+ }
77
+ const declaration = ast.program.body[0];
78
+ let objectLiteral;
79
+ if (n.VariableDeclaration.check(declaration) && declaration.declarations.length > 0 && n.VariableDeclarator.check(declaration.declarations[0]) && n.ObjectExpression.check(declaration.declarations[0].init)) objectLiteral = declaration.declarations[0].init;
80
+ if (noMetadata) {
81
+ const metadataProperties = [
82
+ "id",
83
+ "locale",
84
+ "filled",
85
+ "fill",
86
+ "title",
87
+ "description",
88
+ "tags",
89
+ "version",
90
+ "priority",
91
+ "contentAutoTransformation",
92
+ "$schema"
93
+ ];
94
+ for (let i = objectLiteral.properties.length - 1; i >= 0; i--) {
95
+ const prop = objectLiteral.properties[i];
96
+ if (n.Property.check(prop) || n.ObjectProperty.check(prop)) {
97
+ let propName = "";
98
+ if (n.Identifier.check(prop.key)) propName = prop.key.name;
99
+ else if (n.StringLiteral.check(prop.key)) propName = prop.key.value;
100
+ else if (n.Literal.check(prop.key)) propName = String(prop.key.value);
101
+ if ([
102
+ "key",
103
+ "content",
104
+ ...metadataProperties
105
+ ].includes(propName)) objectLiteral.properties.splice(i, 1);
106
+ }
107
+ }
108
+ }
109
+ updateObjectLiteral(objectLiteral, noMetadata ? dictionary.content : dictionary);
110
+ const printedCode = recast.print(ast, {
111
+ tabWidth: 2,
112
+ quote: "double",
113
+ trailingComma: false
114
+ }).code;
115
+ const startIndex = printedCode.indexOf("{");
116
+ const endIndex = printedCode.lastIndexOf("}");
117
+ let finalOutput = printedCode.substring(startIndex, endIndex + 1);
118
+ finalOutput = finalOutput.replace(/\s*\/\*__INLINE_LINE__(.*?)\*\/(\s*,?)/g, "$2 //$1");
119
+ finalOutput = finalOutput.replace(/\n[ \t]*\n/g, "\n");
120
+ return finalOutput;
121
+ };
122
+
123
+ //#endregion
124
+ export { transformJSONFile };
125
+ //# sourceMappingURL=transformJSONFile.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformJSONFile.mjs","names":[],"sources":["../../../src/writeContentDeclaration/transformJSONFile.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport * as recast from 'recast';\n\nconst b = recast.types.builders;\nconst n = recast.types.namedTypes;\n\n/**\n * Checks if a value is a plain object (and not null/array)\n */\nconst isPlainObject = (value: unknown): value is Record<string, unknown> => {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n};\n\n/**\n * Checks if a recast AST node value matches the incoming primitive value.\n */\nconst isPrimitiveEqual = (astNode: any, val: unknown): boolean => {\n if (val === null) {\n return n.Literal.check(astNode) && astNode.value === null;\n }\n if (\n typeof val === 'string' ||\n typeof val === 'number' ||\n typeof val === 'boolean'\n ) {\n return (\n (n.Literal.check(astNode) ||\n n.StringLiteral.check(astNode) ||\n n.NumericLiteral.check(astNode) ||\n n.BooleanLiteral.check(astNode)) &&\n astNode.value === val\n );\n }\n return false;\n};\n\n/**\n * Robustly finds a property in a recast ObjectExpression.\n * Handles quoted (\"key\") or unquoted (key) properties.\n */\nconst getMatchingProperty = (node: any, key: string) => {\n return node.properties.find((prop: any) => {\n if (n.Property.check(prop) || n.ObjectProperty.check(prop)) {\n if (n.Identifier.check(prop.key) && prop.key.name === key) return true;\n if (n.StringLiteral.check(prop.key) && prop.key.value === key)\n return true;\n if (n.Literal.check(prop.key) && prop.key.value === key) return true;\n }\n return false;\n });\n};\n\n/**\n * Recursively builds a clean recast AST node from a plain JS value.\n * Because these nodes lack `loc` tracking, recast is forced to pretty-print them.\n */\nconst buildASTNode = (val: unknown): any => {\n if (val === null) return b.literal(null);\n\n if (\n typeof val === 'string' ||\n typeof val === 'number' ||\n typeof val === 'boolean'\n ) {\n return b.literal(val);\n }\n\n if (Array.isArray(val)) {\n return b.arrayExpression(val.map((item) => buildASTNode(item)));\n }\n\n if (isPlainObject(val)) {\n return b.objectExpression(\n Object.entries(val)\n .filter(([, v]) => v !== undefined)\n .map(([k, v]) =>\n b.property('init', b.stringLiteral(k), buildASTNode(v))\n )\n );\n }\n\n return b.literal(null); // Fallback\n};\n\n/**\n * Recursively updates the AST object literal with new data.\n */\nconst updateObjectLiteral = (node: any, data: Record<string, any>) => {\n for (const [key, val] of Object.entries(data)) {\n if (val === undefined) {\n continue;\n }\n\n const existingProp = getMatchingProperty(node, key);\n\n if (existingProp?.comments) {\n existingProp.comments.forEach((c: any) => {\n if ((c.type === 'Line' || c.type === 'CommentLine') && c.trailing) {\n // Convert to block comment and tag it to force Recast to print it inline\n c.type = c.type === 'Line' ? 'Block' : 'CommentBlock';\n c.value = `__INLINE_LINE__${c.value}`;\n c.leading = false;\n c.trailing = true;\n }\n });\n }\n\n if (isPlainObject(val)) {\n if (existingProp && n.ObjectExpression.check(existingProp.value)) {\n updateObjectLiteral(existingProp.value, val);\n } else {\n if (existingProp) {\n // Prevent AST invalidation if the primitive value is identical\n const isIdentical =\n n.Literal.check(existingProp.value) &&\n existingProp.value.value === val;\n\n if (!isIdentical) {\n existingProp.value = buildASTNode(val);\n }\n } else {\n node.properties.push(\n b.property('init', b.stringLiteral(key), buildASTNode(val))\n );\n }\n }\n } else {\n // Handle primitives and arrays\n if (existingProp) {\n // Skip assignment if the primitive value is identical\n if (!isPrimitiveEqual(existingProp.value, val)) {\n existingProp.value = buildASTNode(val);\n }\n } else {\n node.properties.push(\n b.property('init', b.stringLiteral(key), buildASTNode(val))\n );\n }\n }\n }\n};\n\nexport const transformJSONFile = (\n fileContent: string,\n dictionary: Dictionary,\n noMetadata?: boolean\n): string => {\n // Wrap content to create valid syntax for the parser\n const wrappedContent = `const _config = ${fileContent.trim() || '{}'};`;\n\n let ast: ReturnType<typeof recast.parse>;\n try {\n ast = recast.parse(wrappedContent);\n } catch {\n // Fallback if parsing failed\n return JSON.stringify(\n noMetadata ? dictionary.content : dictionary,\n null,\n 2\n );\n }\n\n // Navigate the AST to locate the object literal initialized to `_config`\n const declaration = ast.program.body[0];\n let objectLiteral: any;\n\n if (\n n.VariableDeclaration.check(declaration) &&\n declaration.declarations.length > 0 &&\n n.VariableDeclarator.check(declaration.declarations[0]) &&\n n.ObjectExpression.check(declaration.declarations[0].init)\n ) {\n objectLiteral = declaration.declarations[0].init;\n }\n\n if (noMetadata) {\n const metadataProperties = [\n 'id',\n 'locale',\n 'filled',\n 'fill',\n 'title',\n 'description',\n 'tags',\n 'version',\n 'priority',\n 'contentAutoTransformation',\n '$schema',\n ];\n\n // Mutate the array backwards instead of using .filter() to prevent layout invalidation\n for (let i = objectLiteral.properties.length - 1; i >= 0; i--) {\n const prop = objectLiteral.properties[i];\n if (n.Property.check(prop) || n.ObjectProperty.check(prop)) {\n let propName = '';\n if (n.Identifier.check(prop.key)) propName = prop.key.name;\n else if (n.StringLiteral.check(prop.key)) propName = prop.key.value;\n else if (n.Literal.check(prop.key)) propName = String(prop.key.value);\n\n if (['key', 'content', ...metadataProperties].includes(propName)) {\n objectLiteral.properties.splice(i, 1);\n }\n }\n }\n }\n\n // Update the AST in place\n updateObjectLiteral(\n objectLiteral,\n noMetadata ? (dictionary.content as Record<string, any>) : dictionary\n );\n\n // Print the full AST to utilize the global token stream for inline comments\n const printedCode = recast.print(ast, {\n tabWidth: 2,\n quote: 'double',\n trailingComma: false,\n }).code;\n\n // Extract the target object literal cleanly\n const startIndex = printedCode.indexOf('{');\n const endIndex = printedCode.lastIndexOf('}');\n let finalOutput = printedCode.substring(startIndex, endIndex + 1);\n\n // Revert the tagged block comment back to an inline line comment and fix comma placement\n finalOutput = finalOutput.replace(\n /\\s*\\/\\*__INLINE_LINE__(.*?)\\*\\/(\\s*,?)/g,\n '$2 //$1'\n );\n\n // Collapse empty lines injected by Recast around commented properties\n finalOutput = finalOutput.replace(/\\n[ \\t]*\\n/g, '\\n');\n\n return finalOutput;\n};\n"],"mappings":";;;AAGA,MAAM,IAAI,OAAO,MAAM;AACvB,MAAM,IAAI,OAAO,MAAM;;;;AAKvB,MAAM,iBAAiB,UAAqD;AAC1E,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,MAAM;;;;;AAM7E,MAAM,oBAAoB,SAAc,QAA0B;AAChE,KAAI,QAAQ,KACV,QAAO,EAAE,QAAQ,MAAM,QAAQ,IAAI,QAAQ,UAAU;AAEvD,KACE,OAAO,QAAQ,YACf,OAAO,QAAQ,YACf,OAAO,QAAQ,UAEf,SACG,EAAE,QAAQ,MAAM,QAAQ,IACvB,EAAE,cAAc,MAAM,QAAQ,IAC9B,EAAE,eAAe,MAAM,QAAQ,IAC/B,EAAE,eAAe,MAAM,QAAQ,KACjC,QAAQ,UAAU;AAGtB,QAAO;;;;;;AAOT,MAAM,uBAAuB,MAAW,QAAgB;AACtD,QAAO,KAAK,WAAW,MAAM,SAAc;AACzC,MAAI,EAAE,SAAS,MAAM,KAAK,IAAI,EAAE,eAAe,MAAM,KAAK,EAAE;AAC1D,OAAI,EAAE,WAAW,MAAM,KAAK,IAAI,IAAI,KAAK,IAAI,SAAS,IAAK,QAAO;AAClE,OAAI,EAAE,cAAc,MAAM,KAAK,IAAI,IAAI,KAAK,IAAI,UAAU,IACxD,QAAO;AACT,OAAI,EAAE,QAAQ,MAAM,KAAK,IAAI,IAAI,KAAK,IAAI,UAAU,IAAK,QAAO;;AAElE,SAAO;GACP;;;;;;AAOJ,MAAM,gBAAgB,QAAsB;AAC1C,KAAI,QAAQ,KAAM,QAAO,EAAE,QAAQ,KAAK;AAExC,KACE,OAAO,QAAQ,YACf,OAAO,QAAQ,YACf,OAAO,QAAQ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