@intlayer/chokidar 8.4.4 → 8.4.6

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 (497) hide show
  1. package/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -0
  2. package/dist/cjs/_virtual/_utils_asset.cjs +98 -0
  3. package/dist/cjs/build.cjs +58 -1
  4. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs +62 -1
  5. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs.map +1 -1
  6. package/dist/cjs/buildIntlayerDictionary/index.cjs +6 -1
  7. package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs +26 -1
  8. package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs.map +1 -1
  9. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +107 -5
  10. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -1
  11. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs +80 -3
  12. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs.map +1 -1
  13. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs +46 -1
  14. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs.map +1 -1
  15. package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs +50 -1
  16. package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs.map +1 -1
  17. package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs +59 -1
  18. package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs.map +1 -1
  19. package/dist/cjs/cleanOutputDir.cjs +30 -1
  20. package/dist/cjs/cleanOutputDir.cjs.map +1 -1
  21. package/dist/cjs/cleanRemovedContentDeclaration.cjs +97 -1
  22. package/dist/cjs/cleanRemovedContentDeclaration.cjs.map +1 -1
  23. package/dist/cjs/cli.cjs +35 -1
  24. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs +70 -1
  25. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs.map +1 -1
  26. package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs +42 -7
  27. package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs.map +1 -1
  28. package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs +23 -1
  29. package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs.map +1 -1
  30. package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs +24 -1
  31. package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs.map +1 -1
  32. package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs +24 -1
  33. package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs.map +1 -1
  34. package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs +23 -1
  35. package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs.map +1 -1
  36. package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs +23 -1
  37. package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs.map +1 -1
  38. package/dist/cjs/createDictionaryEntryPoint/index.cjs +16 -1
  39. package/dist/cjs/createType/createModuleAugmentation.cjs +112 -9
  40. package/dist/cjs/createType/createModuleAugmentation.cjs.map +1 -1
  41. package/dist/cjs/createType/createType.cjs +29 -1
  42. package/dist/cjs/createType/createType.cjs.map +1 -1
  43. package/dist/cjs/createType/index.cjs +8 -1
  44. package/dist/cjs/detectFormatCommand.cjs +32 -1
  45. package/dist/cjs/detectFormatCommand.cjs.map +1 -1
  46. package/dist/cjs/fetchDistantDictionaries.cjs +51 -1
  47. package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
  48. package/dist/cjs/filterInvalidDictionaries.cjs +52 -1
  49. package/dist/cjs/filterInvalidDictionaries.cjs.map +1 -1
  50. package/dist/cjs/formatDictionary.cjs +49 -1
  51. package/dist/cjs/formatDictionary.cjs.map +1 -1
  52. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +61 -7
  53. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -1
  54. package/dist/cjs/getContentDeclarationFileTemplate/index.cjs +4 -1
  55. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs +34 -1
  56. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs.map +1 -1
  57. package/dist/cjs/handleContentDeclarationFileChange.cjs +49 -1
  58. package/dist/cjs/handleContentDeclarationFileChange.cjs.map +1 -1
  59. package/dist/cjs/handleContentDeclarationFileMoved.cjs +24 -1
  60. package/dist/cjs/handleContentDeclarationFileMoved.cjs.map +1 -1
  61. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs +37 -1
  62. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs.map +1 -1
  63. package/dist/cjs/init/index.cjs +284 -1
  64. package/dist/cjs/init/index.cjs.map +1 -1
  65. package/dist/cjs/init/utils/configManipulation.cjs +111 -1
  66. package/dist/cjs/init/utils/configManipulation.cjs.map +1 -1
  67. package/dist/cjs/init/utils/fileSystem.cjs +39 -1
  68. package/dist/cjs/init/utils/fileSystem.cjs.map +1 -1
  69. package/dist/cjs/init/utils/index.cjs +14 -1
  70. package/dist/cjs/init/utils/jsonParser.cjs +42 -3
  71. package/dist/cjs/init/utils/jsonParser.cjs.map +1 -1
  72. package/dist/cjs/init/utils/tsConfig.cjs +18 -1
  73. package/dist/cjs/init/utils/tsConfig.cjs.map +1 -1
  74. package/dist/cjs/initConfig/index.cjs +39 -1
  75. package/dist/cjs/initConfig/index.cjs.map +1 -1
  76. package/dist/cjs/installMCP/installMCP.cjs +50 -1
  77. package/dist/cjs/installMCP/installMCP.cjs.map +1 -1
  78. package/dist/cjs/installSkills/index.cjs +303 -1
  79. package/dist/cjs/installSkills/index.cjs.map +1 -1
  80. package/dist/cjs/listDictionariesPath.cjs +42 -1
  81. package/dist/cjs/listDictionariesPath.cjs.map +1 -1
  82. package/dist/cjs/listGitFiles.cjs +105 -5
  83. package/dist/cjs/listGitFiles.cjs.map +1 -1
  84. package/dist/cjs/listProjects.cjs +47 -1
  85. package/dist/cjs/listProjects.cjs.map +1 -1
  86. package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs +68 -1
  87. package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs.map +1 -1
  88. package/dist/cjs/loadDictionaries/index.cjs +14 -1
  89. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +93 -2
  90. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -1
  91. package/dist/cjs/loadDictionaries/loadDictionaries.cjs +127 -1
  92. package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
  93. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs +27 -1
  94. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs.map +1 -1
  95. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +61 -1
  96. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
  97. package/dist/cjs/loadDictionaries/log.cjs +138 -3
  98. package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
  99. package/dist/cjs/loadDictionaries/logTypeScriptErrors.cjs +63 -2
  100. package/dist/cjs/loadDictionaries/logTypeScriptErrors.cjs.map +1 -1
  101. package/dist/cjs/logConfigDetails.cjs +39 -2
  102. package/dist/cjs/logConfigDetails.cjs.map +1 -1
  103. package/dist/cjs/prepareIntlayer.cjs +103 -1
  104. package/dist/cjs/prepareIntlayer.cjs.map +1 -1
  105. package/dist/cjs/reduceDictionaryContent/applyMask.cjs +30 -1
  106. package/dist/cjs/reduceDictionaryContent/applyMask.cjs.map +1 -1
  107. package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs +12 -1
  108. package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs.map +1 -1
  109. package/dist/cjs/utils/autoDecorateContent.cjs +89 -1
  110. package/dist/cjs/utils/autoDecorateContent.cjs.map +1 -1
  111. package/dist/cjs/utils/buildComponentFilesList.cjs +67 -1
  112. package/dist/cjs/utils/buildComponentFilesList.cjs.map +1 -1
  113. package/dist/cjs/utils/buildFilesList.cjs +83 -1
  114. package/dist/cjs/utils/buildFilesList.cjs.map +1 -1
  115. package/dist/cjs/utils/chunkJSON.cjs +336 -1
  116. package/dist/cjs/utils/chunkJSON.cjs.map +1 -1
  117. package/dist/cjs/utils/formatter.cjs +18 -1
  118. package/dist/cjs/utils/formatter.cjs.map +1 -1
  119. package/dist/cjs/utils/getChunk.cjs +34 -1
  120. package/dist/cjs/utils/getChunk.cjs.map +1 -1
  121. package/dist/cjs/utils/getContentExtension.cjs +29 -1
  122. package/dist/cjs/utils/getContentExtension.cjs.map +1 -1
  123. package/dist/cjs/utils/getFormatFromExtension.cjs +34 -1
  124. package/dist/cjs/utils/getFormatFromExtension.cjs.map +1 -1
  125. package/dist/cjs/utils/getPathHash.cjs +10 -1
  126. package/dist/cjs/utils/getPathHash.cjs.map +1 -1
  127. package/dist/cjs/utils/index.cjs +49 -1
  128. package/dist/cjs/utils/mergeChunks.cjs +28 -1
  129. package/dist/cjs/utils/mergeChunks.cjs.map +1 -1
  130. package/dist/cjs/utils/pLimit.cjs +128 -1
  131. package/dist/cjs/utils/pLimit.cjs.map +1 -1
  132. package/dist/cjs/utils/parallelize.cjs +11 -1
  133. package/dist/cjs/utils/parallelize.cjs.map +1 -1
  134. package/dist/cjs/utils/parallelizeGlobal.cjs +29 -1
  135. package/dist/cjs/utils/parallelizeGlobal.cjs.map +1 -1
  136. package/dist/cjs/utils/reduceObjectFormat.cjs +31 -1
  137. package/dist/cjs/utils/reduceObjectFormat.cjs.map +1 -1
  138. package/dist/cjs/utils/resolveObjectPromises.cjs +21 -1
  139. package/dist/cjs/utils/resolveObjectPromises.cjs.map +1 -1
  140. package/dist/cjs/utils/resolveRelativePath.cjs +21 -1
  141. package/dist/cjs/utils/resolveRelativePath.cjs.map +1 -1
  142. package/dist/cjs/utils/runOnce.cjs +95 -1
  143. package/dist/cjs/utils/runOnce.cjs.map +1 -1
  144. package/dist/cjs/utils/runParallel/bin.cjs +54 -1
  145. package/dist/cjs/utils/runParallel/bin.cjs.map +1 -1
  146. package/dist/cjs/utils/runParallel/bootstrap.cjs +24 -1
  147. package/dist/cjs/utils/runParallel/bootstrap.cjs.map +1 -1
  148. package/dist/cjs/utils/runParallel/index.cjs +115 -1
  149. package/dist/cjs/utils/runParallel/index.cjs.map +1 -1
  150. package/dist/cjs/utils/runParallel/pidTree.cjs +145 -1
  151. package/dist/cjs/utils/runParallel/pidTree.cjs.map +1 -1
  152. package/dist/cjs/utils/runParallel/ps.cjs +49 -1
  153. package/dist/cjs/utils/runParallel/ps.cjs.map +1 -1
  154. package/dist/cjs/utils/runParallel/runTask.cjs +154 -1
  155. package/dist/cjs/utils/runParallel/runTask.cjs.map +1 -1
  156. package/dist/cjs/utils/runParallel/spawnPosix.cjs +59 -1
  157. package/dist/cjs/utils/runParallel/spawnPosix.cjs.map +1 -1
  158. package/dist/cjs/utils/runParallel/spawnWin32.cjs +43 -1
  159. package/dist/cjs/utils/runParallel/spawnWin32.cjs.map +1 -1
  160. package/dist/cjs/utils/runParallel/wmic.cjs +52 -1
  161. package/dist/cjs/utils/runParallel/wmic.cjs.map +1 -1
  162. package/dist/cjs/utils/sortAlphabetically.cjs +7 -1
  163. package/dist/cjs/utils/sortAlphabetically.cjs.map +1 -1
  164. package/dist/cjs/utils/splitTextByLine.cjs +11 -1
  165. package/dist/cjs/utils/splitTextByLine.cjs.map +1 -1
  166. package/dist/cjs/utils/verifyIdenticObjectFormat.cjs +60 -1
  167. package/dist/cjs/utils/verifyIdenticObjectFormat.cjs.map +1 -1
  168. package/dist/cjs/watcher.cjs +120 -1
  169. package/dist/cjs/watcher.cjs.map +1 -1
  170. package/dist/cjs/writeConfiguration/index.cjs +42 -1
  171. package/dist/cjs/writeConfiguration/index.cjs.map +1 -1
  172. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs +28 -1
  173. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs.map +1 -1
  174. package/dist/cjs/writeContentDeclaration/index.cjs +10 -1
  175. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs +94 -1
  176. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs.map +1 -1
  177. package/dist/cjs/writeContentDeclaration/transformJSFile.cjs +412 -3
  178. package/dist/cjs/writeContentDeclaration/transformJSFile.cjs.map +1 -1
  179. package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs +127 -2
  180. package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs.map +1 -1
  181. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +148 -1
  182. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
  183. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +92 -1
  184. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs.map +1 -1
  185. package/dist/cjs/writeFileIfChanged.cjs +50 -1
  186. package/dist/cjs/writeFileIfChanged.cjs.map +1 -1
  187. package/dist/cjs/writeJsonIfChanged.cjs +17 -1
  188. package/dist/cjs/writeJsonIfChanged.cjs.map +1 -1
  189. package/dist/esm/_virtual/_rolldown/runtime.mjs +8 -0
  190. package/dist/esm/_virtual/_utils_asset.mjs +97 -0
  191. package/dist/esm/build.mjs +25 -1
  192. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs +60 -1
  193. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs.map +1 -1
  194. package/dist/esm/buildIntlayerDictionary/index.mjs +4 -1
  195. package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs +24 -1
  196. package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs.map +1 -1
  197. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs +102 -5
  198. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs.map +1 -1
  199. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs +76 -3
  200. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs.map +1 -1
  201. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs +44 -1
  202. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs.map +1 -1
  203. package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs +48 -1
  204. package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs.map +1 -1
  205. package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs +56 -1
  206. package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs.map +1 -1
  207. package/dist/esm/cleanOutputDir.mjs +28 -1
  208. package/dist/esm/cleanOutputDir.mjs.map +1 -1
  209. package/dist/esm/cleanRemovedContentDeclaration.mjs +94 -1
  210. package/dist/esm/cleanRemovedContentDeclaration.mjs.map +1 -1
  211. package/dist/esm/cli.mjs +15 -1
  212. package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs +68 -1
  213. package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs.map +1 -1
  214. package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs +40 -7
  215. package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs.map +1 -1
  216. package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs +20 -1
  217. package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs.map +1 -1
  218. package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs +21 -1
  219. package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs.map +1 -1
  220. package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs +21 -1
  221. package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs.map +1 -1
  222. package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs +20 -1
  223. package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs.map +1 -1
  224. package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs +20 -1
  225. package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs.map +1 -1
  226. package/dist/esm/createDictionaryEntryPoint/index.mjs +9 -1
  227. package/dist/esm/createType/createModuleAugmentation.mjs +108 -9
  228. package/dist/esm/createType/createModuleAugmentation.mjs.map +1 -1
  229. package/dist/esm/createType/createType.mjs +26 -1
  230. package/dist/esm/createType/createType.mjs.map +1 -1
  231. package/dist/esm/createType/index.mjs +4 -1
  232. package/dist/esm/detectFormatCommand.mjs +30 -1
  233. package/dist/esm/detectFormatCommand.mjs.map +1 -1
  234. package/dist/esm/fetchDistantDictionaries.mjs +49 -1
  235. package/dist/esm/fetchDistantDictionaries.mjs.map +1 -1
  236. package/dist/esm/filterInvalidDictionaries.mjs +48 -1
  237. package/dist/esm/filterInvalidDictionaries.mjs.map +1 -1
  238. package/dist/esm/formatDictionary.mjs +44 -1
  239. package/dist/esm/formatDictionary.mjs.map +1 -1
  240. package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs +59 -7
  241. package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs.map +1 -1
  242. package/dist/esm/getContentDeclarationFileTemplate/index.mjs +3 -1
  243. package/dist/esm/handleAdditionalContentDeclarationFile.mjs +32 -1
  244. package/dist/esm/handleAdditionalContentDeclarationFile.mjs.map +1 -1
  245. package/dist/esm/handleContentDeclarationFileChange.mjs +47 -1
  246. package/dist/esm/handleContentDeclarationFileChange.mjs.map +1 -1
  247. package/dist/esm/handleContentDeclarationFileMoved.mjs +22 -1
  248. package/dist/esm/handleContentDeclarationFileMoved.mjs.map +1 -1
  249. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs +35 -1
  250. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs.map +1 -1
  251. package/dist/esm/init/index.mjs +281 -1
  252. package/dist/esm/init/index.mjs.map +1 -1
  253. package/dist/esm/init/utils/configManipulation.mjs +108 -1
  254. package/dist/esm/init/utils/configManipulation.mjs.map +1 -1
  255. package/dist/esm/init/utils/fileSystem.mjs +34 -1
  256. package/dist/esm/init/utils/fileSystem.mjs.map +1 -1
  257. package/dist/esm/init/utils/index.mjs +6 -1
  258. package/dist/esm/init/utils/jsonParser.mjs +40 -3
  259. package/dist/esm/init/utils/jsonParser.mjs.map +1 -1
  260. package/dist/esm/init/utils/tsConfig.mjs +16 -1
  261. package/dist/esm/init/utils/tsConfig.mjs.map +1 -1
  262. package/dist/esm/initConfig/index.mjs +37 -1
  263. package/dist/esm/initConfig/index.mjs.map +1 -1
  264. package/dist/esm/installMCP/installMCP.mjs +46 -1
  265. package/dist/esm/installMCP/installMCP.mjs.map +1 -1
  266. package/dist/esm/installSkills/index.mjs +295 -1
  267. package/dist/esm/installSkills/index.mjs.map +1 -1
  268. package/dist/esm/listDictionariesPath.mjs +38 -1
  269. package/dist/esm/listDictionariesPath.mjs.map +1 -1
  270. package/dist/esm/listGitFiles.mjs +100 -5
  271. package/dist/esm/listGitFiles.mjs.map +1 -1
  272. package/dist/esm/listProjects.mjs +43 -1
  273. package/dist/esm/listProjects.mjs.map +1 -1
  274. package/dist/esm/loadDictionaries/getIntlayerBundle.mjs +67 -1
  275. package/dist/esm/loadDictionaries/getIntlayerBundle.mjs.map +1 -1
  276. package/dist/esm/loadDictionaries/index.mjs +6 -1
  277. package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +88 -2
  278. package/dist/esm/loadDictionaries/loadContentDeclaration.mjs.map +1 -1
  279. package/dist/esm/loadDictionaries/loadDictionaries.mjs +124 -1
  280. package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
  281. package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs +25 -1
  282. package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs.map +1 -1
  283. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs +58 -1
  284. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -1
  285. package/dist/esm/loadDictionaries/log.mjs +134 -3
  286. package/dist/esm/loadDictionaries/log.mjs.map +1 -1
  287. package/dist/esm/loadDictionaries/logTypeScriptErrors.mjs +61 -2
  288. package/dist/esm/loadDictionaries/logTypeScriptErrors.mjs.map +1 -1
  289. package/dist/esm/logConfigDetails.mjs +36 -2
  290. package/dist/esm/logConfigDetails.mjs.map +1 -1
  291. package/dist/esm/prepareIntlayer.mjs +99 -1
  292. package/dist/esm/prepareIntlayer.mjs.map +1 -1
  293. package/dist/esm/reduceDictionaryContent/applyMask.mjs +28 -1
  294. package/dist/esm/reduceDictionaryContent/applyMask.mjs.map +1 -1
  295. package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs +10 -1
  296. package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs.map +1 -1
  297. package/dist/esm/utils/autoDecorateContent.mjs +86 -1
  298. package/dist/esm/utils/autoDecorateContent.mjs.map +1 -1
  299. package/dist/esm/utils/buildComponentFilesList.mjs +64 -1
  300. package/dist/esm/utils/buildComponentFilesList.mjs.map +1 -1
  301. package/dist/esm/utils/buildFilesList.mjs +79 -1
  302. package/dist/esm/utils/buildFilesList.mjs.map +1 -1
  303. package/dist/esm/utils/chunkJSON.mjs +333 -1
  304. package/dist/esm/utils/chunkJSON.mjs.map +1 -1
  305. package/dist/esm/utils/formatter.mjs +13 -1
  306. package/dist/esm/utils/formatter.mjs.map +1 -1
  307. package/dist/esm/utils/getChunk.mjs +33 -1
  308. package/dist/esm/utils/getChunk.mjs.map +1 -1
  309. package/dist/esm/utils/getContentExtension.mjs +27 -1
  310. package/dist/esm/utils/getContentExtension.mjs.map +1 -1
  311. package/dist/esm/utils/getFormatFromExtension.mjs +31 -1
  312. package/dist/esm/utils/getFormatFromExtension.mjs.map +1 -1
  313. package/dist/esm/utils/getPathHash.mjs +7 -1
  314. package/dist/esm/utils/getPathHash.mjs.map +1 -1
  315. package/dist/esm/utils/index.mjs +22 -1
  316. package/dist/esm/utils/mergeChunks.mjs +26 -1
  317. package/dist/esm/utils/mergeChunks.mjs.map +1 -1
  318. package/dist/esm/utils/pLimit.mjs +125 -1
  319. package/dist/esm/utils/pLimit.mjs.map +1 -1
  320. package/dist/esm/utils/parallelize.mjs +10 -1
  321. package/dist/esm/utils/parallelize.mjs.map +1 -1
  322. package/dist/esm/utils/parallelizeGlobal.mjs +26 -1
  323. package/dist/esm/utils/parallelizeGlobal.mjs.map +1 -1
  324. package/dist/esm/utils/reduceObjectFormat.mjs +29 -1
  325. package/dist/esm/utils/reduceObjectFormat.mjs.map +1 -1
  326. package/dist/esm/utils/resolveObjectPromises.mjs +19 -1
  327. package/dist/esm/utils/resolveObjectPromises.mjs.map +1 -1
  328. package/dist/esm/utils/resolveRelativePath.mjs +19 -1
  329. package/dist/esm/utils/resolveRelativePath.mjs.map +1 -1
  330. package/dist/esm/utils/runOnce.mjs +92 -1
  331. package/dist/esm/utils/runOnce.mjs.map +1 -1
  332. package/dist/esm/utils/runParallel/bin.mjs +52 -1
  333. package/dist/esm/utils/runParallel/bin.mjs.map +1 -1
  334. package/dist/esm/utils/runParallel/bootstrap.mjs +22 -1
  335. package/dist/esm/utils/runParallel/bootstrap.mjs.map +1 -1
  336. package/dist/esm/utils/runParallel/index.mjs +113 -1
  337. package/dist/esm/utils/runParallel/index.mjs.map +1 -1
  338. package/dist/esm/utils/runParallel/pidTree.mjs +142 -1
  339. package/dist/esm/utils/runParallel/pidTree.mjs.map +1 -1
  340. package/dist/esm/utils/runParallel/ps.mjs +46 -1
  341. package/dist/esm/utils/runParallel/ps.mjs.map +1 -1
  342. package/dist/esm/utils/runParallel/runTask.mjs +152 -1
  343. package/dist/esm/utils/runParallel/runTask.mjs.map +1 -1
  344. package/dist/esm/utils/runParallel/spawnPosix.mjs +57 -1
  345. package/dist/esm/utils/runParallel/spawnPosix.mjs.map +1 -1
  346. package/dist/esm/utils/runParallel/spawnWin32.mjs +41 -1
  347. package/dist/esm/utils/runParallel/spawnWin32.mjs.map +1 -1
  348. package/dist/esm/utils/runParallel/wmic.mjs +49 -1
  349. package/dist/esm/utils/runParallel/wmic.mjs.map +1 -1
  350. package/dist/esm/utils/sortAlphabetically.mjs +5 -1
  351. package/dist/esm/utils/sortAlphabetically.mjs.map +1 -1
  352. package/dist/esm/utils/splitTextByLine.mjs +9 -1
  353. package/dist/esm/utils/splitTextByLine.mjs.map +1 -1
  354. package/dist/esm/utils/verifyIdenticObjectFormat.mjs +58 -1
  355. package/dist/esm/utils/verifyIdenticObjectFormat.mjs.map +1 -1
  356. package/dist/esm/watcher.mjs +117 -1
  357. package/dist/esm/watcher.mjs.map +1 -1
  358. package/dist/esm/writeConfiguration/index.mjs +39 -1
  359. package/dist/esm/writeConfiguration/index.mjs.map +1 -1
  360. package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs +26 -1
  361. package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs.map +1 -1
  362. package/dist/esm/writeContentDeclaration/index.mjs +6 -1
  363. package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs +91 -1
  364. package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs.map +1 -1
  365. package/dist/esm/writeContentDeclaration/transformJSFile.mjs +407 -3
  366. package/dist/esm/writeContentDeclaration/transformJSFile.mjs.map +1 -1
  367. package/dist/esm/writeContentDeclaration/transformJSONFile.mjs +124 -2
  368. package/dist/esm/writeContentDeclaration/transformJSONFile.mjs.map +1 -1
  369. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +146 -1
  370. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
  371. package/dist/esm/writeContentDeclaration/writeJSFile.mjs +90 -1
  372. package/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -1
  373. package/dist/esm/writeFileIfChanged.mjs +48 -1
  374. package/dist/esm/writeFileIfChanged.mjs.map +1 -1
  375. package/dist/esm/writeJsonIfChanged.mjs +16 -1
  376. package/dist/esm/writeJsonIfChanged.mjs.map +1 -1
  377. package/dist/types/build.d.ts +20 -20
  378. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +25 -2
  379. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -0
  380. package/dist/types/buildIntlayerDictionary/index.d.ts +2 -2
  381. package/dist/types/buildIntlayerDictionary/processContentDeclaration.d.ts +11 -2
  382. package/dist/types/buildIntlayerDictionary/processContentDeclaration.d.ts.map +1 -0
  383. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +49 -2
  384. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -0
  385. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts +1 -1
  386. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -1
  387. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +30 -2
  388. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts.map +1 -0
  389. package/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts +34 -2
  390. package/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts.map +1 -0
  391. package/dist/types/cli.d.ts +6 -6
  392. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +14 -2
  393. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts.map +1 -0
  394. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +10 -2
  395. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts.map +1 -0
  396. package/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts +10 -2
  397. package/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts.map +1 -0
  398. package/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts +10 -2
  399. package/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts.map +1 -0
  400. package/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts +10 -2
  401. package/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts.map +1 -0
  402. package/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts +10 -2
  403. package/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts.map +1 -0
  404. package/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts +10 -2
  405. package/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts.map +1 -0
  406. package/dist/types/createDictionaryEntryPoint/index.d.ts +7 -7
  407. package/dist/types/createType/createModuleAugmentation.d.ts +9 -2
  408. package/dist/types/createType/createModuleAugmentation.d.ts.map +1 -0
  409. package/dist/types/createType/createType.d.ts +12 -2
  410. package/dist/types/createType/createType.d.ts.map +1 -0
  411. package/dist/types/createType/index.d.ts +2 -2
  412. package/dist/types/fetchDistantDictionaries.d.ts +1 -1
  413. package/dist/types/fetchDistantDictionaries.d.ts.map +1 -1
  414. package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts +7 -2
  415. package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts.map +1 -0
  416. package/dist/types/getContentDeclarationFileTemplate/index.d.ts +1 -1
  417. package/dist/types/loadDictionaries/index.d.ts +4 -4
  418. package/dist/types/loadDictionaries/loadContentDeclaration.d.ts +12 -2
  419. package/dist/types/loadDictionaries/loadContentDeclaration.d.ts.map +1 -0
  420. package/dist/types/loadDictionaries/loadDictionaries.d.ts +23 -2
  421. package/dist/types/loadDictionaries/loadDictionaries.d.ts.map +1 -0
  422. package/dist/types/loadDictionaries/loadLocalDictionaries.d.ts +8 -2
  423. package/dist/types/loadDictionaries/loadLocalDictionaries.d.ts.map +1 -0
  424. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +15 -2
  425. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts.map +1 -0
  426. package/dist/types/loadDictionaries/log.d.ts +1 -1
  427. package/dist/types/utils/getFormatFromExtension.d.ts +8 -2
  428. package/dist/types/utils/getFormatFromExtension.d.ts.map +1 -0
  429. package/dist/types/utils/index.d.ts +1 -1
  430. package/dist/types/writeConfiguration/index.d.ts.map +1 -1
  431. package/dist/types/writeContentDeclaration/detectExportedComponentName.d.ts +12 -2
  432. package/dist/types/writeContentDeclaration/detectExportedComponentName.d.ts.map +1 -0
  433. package/dist/types/writeContentDeclaration/dictionaryStatus.d.ts +5 -2
  434. package/dist/types/writeContentDeclaration/dictionaryStatus.d.ts.map +1 -0
  435. package/dist/types/writeContentDeclaration/index.d.ts +5 -5
  436. package/dist/types/writeContentDeclaration/processContentDeclarationContent.d.ts.map +1 -1
  437. package/dist/types/writeContentDeclaration/transformJSFile.d.ts +11 -2
  438. package/dist/types/writeContentDeclaration/transformJSFile.d.ts.map +1 -0
  439. package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts +19 -2
  440. package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts.map +1 -0
  441. package/dist/types/writeContentDeclaration/writeJSFile.d.ts +14 -2
  442. package/dist/types/writeContentDeclaration/writeJSFile.d.ts.map +1 -0
  443. package/package.json +8 -8
  444. package/dist/cjs/_utils_asset-SJVy1xMD.cjs +0 -2
  445. package/dist/cjs/chunk-Bmb41Sf3.cjs +0 -1
  446. package/dist/esm/_utils_asset-4w8dPH9r.mjs +0 -2
  447. package/dist/esm/chunk-DDgYwkfe.mjs +0 -1
  448. package/dist/types/buildIntlayerDictionary-C-LWgPIL.d.ts +0 -25
  449. package/dist/types/buildIntlayerDictionary-C-LWgPIL.d.ts.map +0 -1
  450. package/dist/types/createDictionaryEntryPoint-Bc5lHSiY.d.ts +0 -14
  451. package/dist/types/createDictionaryEntryPoint-Bc5lHSiY.d.ts.map +0 -1
  452. package/dist/types/createModuleAugmentation-D1eIVnjg.d.ts +0 -9
  453. package/dist/types/createModuleAugmentation-D1eIVnjg.d.ts.map +0 -1
  454. package/dist/types/createType--rDwdg2t.d.ts +0 -12
  455. package/dist/types/createType--rDwdg2t.d.ts.map +0 -1
  456. package/dist/types/detectExportedComponentName-DVXsp_FG.d.ts +0 -12
  457. package/dist/types/detectExportedComponentName-DVXsp_FG.d.ts.map +0 -1
  458. package/dist/types/dictionaryStatus-DPVO37qe.d.ts +0 -5
  459. package/dist/types/dictionaryStatus-DPVO37qe.d.ts.map +0 -1
  460. package/dist/types/generateDictionaryListContent-DAtHG6SR.d.ts +0 -10
  461. package/dist/types/generateDictionaryListContent-DAtHG6SR.d.ts.map +0 -1
  462. package/dist/types/getBuiltDictionariesPath-C4it65a1.d.ts +0 -10
  463. package/dist/types/getBuiltDictionariesPath-C4it65a1.d.ts.map +0 -1
  464. package/dist/types/getBuiltDynamicDictionariesPath-Cj9EWnjT.d.ts +0 -10
  465. package/dist/types/getBuiltDynamicDictionariesPath-Cj9EWnjT.d.ts.map +0 -1
  466. package/dist/types/getBuiltFetchDictionariesPath-1JleRhT3.d.ts +0 -10
  467. package/dist/types/getBuiltFetchDictionariesPath-1JleRhT3.d.ts.map +0 -1
  468. package/dist/types/getBuiltRemoteDictionariesPath-DHOmqNCr.d.ts +0 -10
  469. package/dist/types/getBuiltRemoteDictionariesPath-DHOmqNCr.d.ts.map +0 -1
  470. package/dist/types/getBuiltUnmergedDictionariesPath-GUmmLxTB.d.ts +0 -10
  471. package/dist/types/getBuiltUnmergedDictionariesPath-GUmmLxTB.d.ts.map +0 -1
  472. package/dist/types/getContentDeclarationFileTemplate-Dz3rnFy9.d.ts +0 -7
  473. package/dist/types/getContentDeclarationFileTemplate-Dz3rnFy9.d.ts.map +0 -1
  474. package/dist/types/getFormatFromExtension-SdXYWfPx.d.ts +0 -8
  475. package/dist/types/getFormatFromExtension-SdXYWfPx.d.ts.map +0 -1
  476. package/dist/types/loadContentDeclaration-CBMS4vkA.d.ts +0 -12
  477. package/dist/types/loadContentDeclaration-CBMS4vkA.d.ts.map +0 -1
  478. package/dist/types/loadDictionaries-BIqHwtYE.d.ts +0 -23
  479. package/dist/types/loadDictionaries-BIqHwtYE.d.ts.map +0 -1
  480. package/dist/types/loadLocalDictionaries-CNmVaw0c.d.ts +0 -8
  481. package/dist/types/loadLocalDictionaries-CNmVaw0c.d.ts.map +0 -1
  482. package/dist/types/loadRemoteDictionaries-MoITTb7W.d.ts +0 -15
  483. package/dist/types/loadRemoteDictionaries-MoITTb7W.d.ts.map +0 -1
  484. package/dist/types/processContentDeclaration-CAvrHaIT.d.ts +0 -11
  485. package/dist/types/processContentDeclaration-CAvrHaIT.d.ts.map +0 -1
  486. package/dist/types/transformJSFile-Cg0LkeLb.d.ts +0 -11
  487. package/dist/types/transformJSFile-Cg0LkeLb.d.ts.map +0 -1
  488. package/dist/types/writeContentDeclaration-XdGxj0KP.d.ts +0 -19
  489. package/dist/types/writeContentDeclaration-XdGxj0KP.d.ts.map +0 -1
  490. package/dist/types/writeDynamicDictionary-BE0mF2zZ.d.ts +0 -49
  491. package/dist/types/writeDynamicDictionary-BE0mF2zZ.d.ts.map +0 -1
  492. package/dist/types/writeJSFile-kK95jzg_.d.ts +0 -14
  493. package/dist/types/writeJSFile-kK95jzg_.d.ts.map +0 -1
  494. package/dist/types/writeMergedDictionary-CMeghcRI.d.ts +0 -30
  495. package/dist/types/writeMergedDictionary-CMeghcRI.d.ts.map +0 -1
  496. package/dist/types/writeUnmergedDictionary-Cxx51isz.d.ts +0 -34
  497. package/dist/types/writeUnmergedDictionary-Cxx51isz.d.ts.map +0 -1
@@ -1,2 +1,118 @@
1
- import{handleContentDeclarationFileChange as e}from"./handleContentDeclarationFileChange.mjs";import{handleContentDeclarationFileMoved as t}from"./handleContentDeclarationFileMoved.mjs";import{handleAdditionalContentDeclarationFile as n}from"./handleAdditionalContentDeclarationFile.mjs";import{handleUnlinkedContentDeclarationFile as r}from"./handleUnlinkedContentDeclarationFile.mjs";import{prepareIntlayer as i}from"./prepareIntlayer.mjs";import{writeContentDeclaration as a}from"./writeContentDeclaration/writeContentDeclaration.mjs";import"./writeContentDeclaration/index.mjs";import{readFile as o}from"node:fs/promises";import{basename as s}from"node:path";import{getAppLogger as c}from"@intlayer/config/logger";import{getConfiguration as l,getConfigurationAndFilePath as u}from"@intlayer/config/node";import{clearAllCache as d,clearModuleCache as f,normalizePath as p}from"@intlayer/config/utils";import{watch as m}from"chokidar";const h=new Map;let g=Promise.resolve();const _=e=>{g=g.then(async()=>{try{await e()}catch(e){console.error(e)}})},v=l=>{let g=u(l?.configOptions),v=g.configurationFilePath,y=l?.configuration??g.configuration,b=c(y),{watch:x,fileExtensions:S,contentDir:C}=y.content,w=[...S.flatMap(e=>C.map(t=>`${p(t)}/**/*${e}`.replace(`//`,`/`))),...v?[v]:[]];if(y.content.watch)return b(`Watching Intlayer content declarations`),m(w,{persistent:x,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:1e3,pollInterval:100},ignored:[`**/node_modules/**`,`**/dist/**`,`**/build/**`,`**/.intlayer/**`],...l}).on(`add`,async e=>{let r=s(e),i=!1,c;for(let[e]of h)if(s(e)===r){c=e;break}if(!c&&h.size===1&&(c=h.keys().next().value),c){let t=h.get(c);t&&(clearTimeout(t.timer),h.delete(c)),i=!0,b(`File moved from ${c} to ${e}`)}_(async()=>{if(i&&c)await t(c,e,y);else{if(await o(e,`utf-8`)===``){let t=S.map(e=>e.replace(/\./g,`\\.`)).join(`|`);await a({key:r.replace(RegExp(`(${t})$`),``),content:{},filePath:e},y)}await n(e,y)}})}).on(`change`,async t=>_(async()=>{if(v&&t===v){b(`Configuration file changed, repreparing Intlayer`),f(v),d();let{configuration:e}=u(l?.configOptions);y=l?.configuration??e,await i(y,{clean:!1})}else await e(t,y)})).on(`unlink`,async e=>{let t=setTimeout(async()=>{h.delete(e),_(async()=>r(e,y))},200);h.set(e,{timer:t,oldPath:e})}).on(`error`,async e=>{b(`Watcher error: ${e}`,{level:`error`}),b(`Restarting watcher`),await i(y)})},y=async e=>{let{skipPrepare:t,...n}=e??{},r=e?.configuration??l(e?.configOptions);t||await i(r,{forceRun:!0}),(r.content.watch||e?.persistent)&&v({...n,configuration:r})};export{y as buildAndWatchIntlayer,v as watch};
1
+ import { handleContentDeclarationFileChange } from "./handleContentDeclarationFileChange.mjs";
2
+ import { handleContentDeclarationFileMoved } from "./handleContentDeclarationFileMoved.mjs";
3
+ import { handleAdditionalContentDeclarationFile } from "./handleAdditionalContentDeclarationFile.mjs";
4
+ import { handleUnlinkedContentDeclarationFile } from "./handleUnlinkedContentDeclarationFile.mjs";
5
+ import { prepareIntlayer } from "./prepareIntlayer.mjs";
6
+ import { writeContentDeclaration } from "./writeContentDeclaration/writeContentDeclaration.mjs";
7
+ import { readFile } from "node:fs/promises";
8
+ import { basename } from "node:path";
9
+ import { getAppLogger } from "@intlayer/config/logger";
10
+ import { getConfiguration, getConfigurationAndFilePath } from "@intlayer/config/node";
11
+ import { clearAllCache, clearModuleCache, normalizePath } from "@intlayer/config/utils";
12
+ import { watch as watch$1 } from "chokidar";
13
+
14
+ //#region src/watcher.ts
15
+ /** @ts-ignore remove error Module '"chokidar"' has no exported member 'ChokidarOptions' */
16
+ const pendingUnlinks = /* @__PURE__ */ new Map();
17
+ let processingQueue = Promise.resolve();
18
+ const processEvent = (task) => {
19
+ processingQueue = processingQueue.then(async () => {
20
+ try {
21
+ await task();
22
+ } catch (error) {
23
+ console.error(error);
24
+ }
25
+ });
26
+ };
27
+ const watch = (options) => {
28
+ const configResult = getConfigurationAndFilePath(options?.configOptions);
29
+ const configurationFilePath = configResult.configurationFilePath;
30
+ let configuration = options?.configuration ?? configResult.configuration;
31
+ const appLogger = getAppLogger(configuration);
32
+ const { watch: isWatchMode, fileExtensions, contentDir } = configuration.content;
33
+ const pathsToWatch = [...fileExtensions.flatMap((ext) => contentDir.map((dir) => `${normalizePath(dir)}/**/*${ext}`.replace("//", "/"))), ...configurationFilePath ? [configurationFilePath] : []];
34
+ if (!configuration.content.watch) return;
35
+ appLogger("Watching Intlayer content declarations");
36
+ return watch$1(pathsToWatch, {
37
+ persistent: isWatchMode,
38
+ ignoreInitial: true,
39
+ awaitWriteFinish: {
40
+ stabilityThreshold: 1e3,
41
+ pollInterval: 100
42
+ },
43
+ ignored: [
44
+ "**/node_modules/**",
45
+ "**/dist/**",
46
+ "**/build/**",
47
+ "**/.intlayer/**"
48
+ ],
49
+ ...options
50
+ }).on("add", async (filePath) => {
51
+ const fileName = basename(filePath);
52
+ let isMove = false;
53
+ let matchedOldPath;
54
+ for (const [oldPath] of pendingUnlinks) if (basename(oldPath) === fileName) {
55
+ matchedOldPath = oldPath;
56
+ break;
57
+ }
58
+ if (!matchedOldPath && pendingUnlinks.size === 1) matchedOldPath = pendingUnlinks.keys().next().value;
59
+ if (matchedOldPath) {
60
+ const pending = pendingUnlinks.get(matchedOldPath);
61
+ if (pending) {
62
+ clearTimeout(pending.timer);
63
+ pendingUnlinks.delete(matchedOldPath);
64
+ }
65
+ isMove = true;
66
+ appLogger(`File moved from ${matchedOldPath} to ${filePath}`);
67
+ }
68
+ processEvent(async () => {
69
+ if (isMove && matchedOldPath) await handleContentDeclarationFileMoved(matchedOldPath, filePath, configuration);
70
+ else {
71
+ if (await readFile(filePath, "utf-8") === "") {
72
+ const extensionPattern = fileExtensions.map((ext) => ext.replace(/\./g, "\\.")).join("|");
73
+ await writeContentDeclaration({
74
+ key: fileName.replace(new RegExp(`(${extensionPattern})$`), ""),
75
+ content: {},
76
+ filePath
77
+ }, configuration);
78
+ }
79
+ await handleAdditionalContentDeclarationFile(filePath, configuration);
80
+ }
81
+ });
82
+ }).on("change", async (filePath) => processEvent(async () => {
83
+ if (configurationFilePath && filePath === configurationFilePath) {
84
+ appLogger("Configuration file changed, repreparing Intlayer");
85
+ clearModuleCache(configurationFilePath);
86
+ clearAllCache();
87
+ const { configuration: newConfiguration } = getConfigurationAndFilePath(options?.configOptions);
88
+ configuration = options?.configuration ?? newConfiguration;
89
+ await prepareIntlayer(configuration, { clean: false });
90
+ } else await handleContentDeclarationFileChange(filePath, configuration);
91
+ })).on("unlink", async (filePath) => {
92
+ const timer = setTimeout(async () => {
93
+ pendingUnlinks.delete(filePath);
94
+ processEvent(async () => handleUnlinkedContentDeclarationFile(filePath, configuration));
95
+ }, 200);
96
+ pendingUnlinks.set(filePath, {
97
+ timer,
98
+ oldPath: filePath
99
+ });
100
+ }).on("error", async (error) => {
101
+ appLogger(`Watcher error: ${error}`, { level: "error" });
102
+ appLogger("Restarting watcher");
103
+ await prepareIntlayer(configuration);
104
+ });
105
+ };
106
+ const buildAndWatchIntlayer = async (options) => {
107
+ const { skipPrepare, ...rest } = options ?? {};
108
+ const configuration = options?.configuration ?? getConfiguration(options?.configOptions);
109
+ if (!skipPrepare) await prepareIntlayer(configuration, { forceRun: true });
110
+ if (configuration.content.watch || options?.persistent) watch({
111
+ ...rest,
112
+ configuration
113
+ });
114
+ };
115
+
116
+ //#endregion
117
+ export { buildAndWatchIntlayer, watch };
2
118
  //# sourceMappingURL=watcher.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"watcher.mjs","names":["chokidarWatch"],"sources":["../../src/watcher.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { basename } from 'node:path';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n getConfigurationAndFilePath,\n} from '@intlayer/config/node';\nimport {\n clearAllCache,\n clearModuleCache,\n normalizePath,\n} from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n/** @ts-ignore remove error Module '\"chokidar\"' has no exported member 'ChokidarOptions' */\nimport { type ChokidarOptions, watch as chokidarWatch } from 'chokidar';\nimport { handleAdditionalContentDeclarationFile } from './handleAdditionalContentDeclarationFile';\nimport { handleContentDeclarationFileChange } from './handleContentDeclarationFileChange';\nimport { handleContentDeclarationFileMoved } from './handleContentDeclarationFileMoved';\nimport { handleUnlinkedContentDeclarationFile } from './handleUnlinkedContentDeclarationFile';\nimport { prepareIntlayer } from './prepareIntlayer';\nimport { writeContentDeclaration } from './writeContentDeclaration';\n\n// Map to track files that were recently unlinked: oldPath -> { timer, timestamp }\nconst pendingUnlinks = new Map<\n string,\n { timer: NodeJS.Timeout; oldPath: string }\n>();\n\n// Task queue to ensure sequential processing of file events\nlet processingQueue = Promise.resolve();\nconst processEvent = (task: () => Promise<void>) => {\n processingQueue = processingQueue.then(async () => {\n try {\n await task();\n } catch (error) {\n console.error(error);\n }\n });\n};\n\ntype WatchOptions = ChokidarOptions & {\n configuration?: IntlayerConfig;\n configOptions?: GetConfigurationOptions;\n skipPrepare?: boolean;\n};\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: WatchOptions) => {\n const configResult = getConfigurationAndFilePath(options?.configOptions);\n const configurationFilePath = configResult.configurationFilePath;\n let configuration: IntlayerConfig =\n options?.configuration ?? configResult.configuration;\n const appLogger = getAppLogger(configuration);\n\n const {\n watch: isWatchMode,\n fileExtensions,\n contentDir,\n } = configuration.content;\n\n const watchedFilesPatternWithPath = fileExtensions.flatMap((ext) =>\n contentDir.map((dir) =>\n `${normalizePath(dir)}/**/*${ext}`.replace('//', '/')\n )\n );\n\n const pathsToWatch = [\n ...watchedFilesPatternWithPath,\n ...(configurationFilePath ? [configurationFilePath] : []),\n ];\n\n if (!configuration.content.watch) return;\n\n appLogger('Watching Intlayer content declarations');\n\n return chokidarWatch(pathsToWatch, {\n persistent: isWatchMode, // Make the watcher persistent\n ignoreInitial: true, // Process existing files\n awaitWriteFinish: {\n stabilityThreshold: 1000,\n pollInterval: 100,\n },\n ignored: [\n '**/node_modules/**',\n '**/dist/**',\n '**/build/**',\n '**/.intlayer/**',\n ],\n ...options,\n })\n .on('add', async (filePath) => {\n const fileName = basename(filePath);\n let isMove = false;\n\n // Check if this Add corresponds to a pending Unlink (Move/Rename detection)\n // Heuristic:\n // - Priority A: Exact basename match (Moved to different folder)\n // - Priority B: Single entry in pendingUnlinks (Renamed file)\n let matchedOldPath: string | undefined;\n\n // Search for basename match\n for (const [oldPath] of pendingUnlinks) {\n if (basename(oldPath) === fileName) {\n matchedOldPath = oldPath;\n break;\n }\n }\n\n // If no basename match, but exactly one file was recently unlinked, assume it's a rename\n if (!matchedOldPath && pendingUnlinks.size === 1) {\n matchedOldPath = pendingUnlinks.keys().next().value;\n }\n\n if (matchedOldPath) {\n // It is a move! Cancel the unlink handler\n const pending = pendingUnlinks.get(matchedOldPath);\n if (pending) {\n clearTimeout(pending.timer);\n pendingUnlinks.delete(matchedOldPath);\n }\n\n isMove = true;\n appLogger(`File moved from ${matchedOldPath} to ${filePath}`);\n }\n\n processEvent(async () => {\n if (isMove && matchedOldPath) {\n await handleContentDeclarationFileMoved(\n matchedOldPath,\n filePath,\n configuration\n );\n } else {\n const fileContent = await readFile(filePath, 'utf-8');\n const isEmpty = fileContent === '';\n\n // Fill template content declaration file if it is empty\n if (isEmpty) {\n const extensionPattern = fileExtensions\n .map((ext) => ext.replace(/\\./g, '\\\\.'))\n .join('|');\n const name = fileName.replace(\n new RegExp(`(${extensionPattern})$`),\n ''\n );\n\n await writeContentDeclaration(\n {\n key: name,\n content: {},\n filePath,\n },\n configuration\n );\n }\n\n await handleAdditionalContentDeclarationFile(filePath, configuration);\n }\n });\n })\n .on('change', async (filePath) =>\n processEvent(async () => {\n if (configurationFilePath && filePath === configurationFilePath) {\n appLogger('Configuration file changed, repreparing Intlayer');\n\n clearModuleCache(configurationFilePath);\n clearAllCache();\n\n const { configuration: newConfiguration } =\n getConfigurationAndFilePath(options?.configOptions);\n\n configuration = options?.configuration ?? newConfiguration;\n\n await prepareIntlayer(configuration, { clean: false });\n } else {\n await handleContentDeclarationFileChange(filePath, configuration);\n }\n })\n )\n .on('unlink', async (filePath) => {\n // Delay unlink processing to see if an 'add' event occurs (indicating a move)\n const timer = setTimeout(async () => {\n // If timer fires, the file was genuinely removed\n pendingUnlinks.delete(filePath);\n processEvent(async () =>\n handleUnlinkedContentDeclarationFile(filePath, configuration)\n );\n }, 200); // 200ms window to catch the 'add' event\n\n pendingUnlinks.set(filePath, { timer, oldPath: filePath });\n })\n .on('error', async (error) => {\n appLogger(`Watcher error: ${error}`, {\n level: 'error',\n });\n\n appLogger('Restarting watcher');\n\n await prepareIntlayer(configuration);\n });\n};\n\nexport const buildAndWatchIntlayer = async (options?: WatchOptions) => {\n const { skipPrepare, ...rest } = options ?? {};\n const configuration =\n options?.configuration ?? getConfiguration(options?.configOptions);\n\n if (!skipPrepare) {\n await prepareIntlayer(configuration, { forceRun: true });\n }\n\n if (configuration.content.watch || options?.persistent) {\n watch({ ...rest, configuration });\n }\n};\n"],"mappings":"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"}
1
+ {"version":3,"file":"watcher.mjs","names":["chokidarWatch"],"sources":["../../src/watcher.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { basename } from 'node:path';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n getConfigurationAndFilePath,\n} from '@intlayer/config/node';\nimport {\n clearAllCache,\n clearModuleCache,\n normalizePath,\n} from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n/** @ts-ignore remove error Module '\"chokidar\"' has no exported member 'ChokidarOptions' */\nimport { type ChokidarOptions, watch as chokidarWatch } from 'chokidar';\nimport { handleAdditionalContentDeclarationFile } from './handleAdditionalContentDeclarationFile';\nimport { handleContentDeclarationFileChange } from './handleContentDeclarationFileChange';\nimport { handleContentDeclarationFileMoved } from './handleContentDeclarationFileMoved';\nimport { handleUnlinkedContentDeclarationFile } from './handleUnlinkedContentDeclarationFile';\nimport { prepareIntlayer } from './prepareIntlayer';\nimport { writeContentDeclaration } from './writeContentDeclaration';\n\n// Map to track files that were recently unlinked: oldPath -> { timer, timestamp }\nconst pendingUnlinks = new Map<\n string,\n { timer: NodeJS.Timeout; oldPath: string }\n>();\n\n// Task queue to ensure sequential processing of file events\nlet processingQueue = Promise.resolve();\nconst processEvent = (task: () => Promise<void>) => {\n processingQueue = processingQueue.then(async () => {\n try {\n await task();\n } catch (error) {\n console.error(error);\n }\n });\n};\n\ntype WatchOptions = ChokidarOptions & {\n configuration?: IntlayerConfig;\n configOptions?: GetConfigurationOptions;\n skipPrepare?: boolean;\n};\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: WatchOptions) => {\n const configResult = getConfigurationAndFilePath(options?.configOptions);\n const configurationFilePath = configResult.configurationFilePath;\n let configuration: IntlayerConfig =\n options?.configuration ?? configResult.configuration;\n const appLogger = getAppLogger(configuration);\n\n const {\n watch: isWatchMode,\n fileExtensions,\n contentDir,\n } = configuration.content;\n\n const watchedFilesPatternWithPath = fileExtensions.flatMap((ext) =>\n contentDir.map((dir) =>\n `${normalizePath(dir)}/**/*${ext}`.replace('//', '/')\n )\n );\n\n const pathsToWatch = [\n ...watchedFilesPatternWithPath,\n ...(configurationFilePath ? [configurationFilePath] : []),\n ];\n\n if (!configuration.content.watch) return;\n\n appLogger('Watching Intlayer content declarations');\n\n return chokidarWatch(pathsToWatch, {\n persistent: isWatchMode, // Make the watcher persistent\n ignoreInitial: true, // Process existing files\n awaitWriteFinish: {\n stabilityThreshold: 1000,\n pollInterval: 100,\n },\n ignored: [\n '**/node_modules/**',\n '**/dist/**',\n '**/build/**',\n '**/.intlayer/**',\n ],\n ...options,\n })\n .on('add', async (filePath) => {\n const fileName = basename(filePath);\n let isMove = false;\n\n // Check if this Add corresponds to a pending Unlink (Move/Rename detection)\n // Heuristic:\n // - Priority A: Exact basename match (Moved to different folder)\n // - Priority B: Single entry in pendingUnlinks (Renamed file)\n let matchedOldPath: string | undefined;\n\n // Search for basename match\n for (const [oldPath] of pendingUnlinks) {\n if (basename(oldPath) === fileName) {\n matchedOldPath = oldPath;\n break;\n }\n }\n\n // If no basename match, but exactly one file was recently unlinked, assume it's a rename\n if (!matchedOldPath && pendingUnlinks.size === 1) {\n matchedOldPath = pendingUnlinks.keys().next().value;\n }\n\n if (matchedOldPath) {\n // It is a move! Cancel the unlink handler\n const pending = pendingUnlinks.get(matchedOldPath);\n if (pending) {\n clearTimeout(pending.timer);\n pendingUnlinks.delete(matchedOldPath);\n }\n\n isMove = true;\n appLogger(`File moved from ${matchedOldPath} to ${filePath}`);\n }\n\n processEvent(async () => {\n if (isMove && matchedOldPath) {\n await handleContentDeclarationFileMoved(\n matchedOldPath,\n filePath,\n configuration\n );\n } else {\n const fileContent = await readFile(filePath, 'utf-8');\n const isEmpty = fileContent === '';\n\n // Fill template content declaration file if it is empty\n if (isEmpty) {\n const extensionPattern = fileExtensions\n .map((ext) => ext.replace(/\\./g, '\\\\.'))\n .join('|');\n const name = fileName.replace(\n new RegExp(`(${extensionPattern})$`),\n ''\n );\n\n await writeContentDeclaration(\n {\n key: name,\n content: {},\n filePath,\n },\n configuration\n );\n }\n\n await handleAdditionalContentDeclarationFile(filePath, configuration);\n }\n });\n })\n .on('change', async (filePath) =>\n processEvent(async () => {\n if (configurationFilePath && filePath === configurationFilePath) {\n appLogger('Configuration file changed, repreparing Intlayer');\n\n clearModuleCache(configurationFilePath);\n clearAllCache();\n\n const { configuration: newConfiguration } =\n getConfigurationAndFilePath(options?.configOptions);\n\n configuration = options?.configuration ?? newConfiguration;\n\n await prepareIntlayer(configuration, { clean: false });\n } else {\n await handleContentDeclarationFileChange(filePath, configuration);\n }\n })\n )\n .on('unlink', async (filePath) => {\n // Delay unlink processing to see if an 'add' event occurs (indicating a move)\n const timer = setTimeout(async () => {\n // If timer fires, the file was genuinely removed\n pendingUnlinks.delete(filePath);\n processEvent(async () =>\n handleUnlinkedContentDeclarationFile(filePath, configuration)\n );\n }, 200); // 200ms window to catch the 'add' event\n\n pendingUnlinks.set(filePath, { timer, oldPath: filePath });\n })\n .on('error', async (error) => {\n appLogger(`Watcher error: ${error}`, {\n level: 'error',\n });\n\n appLogger('Restarting watcher');\n\n await prepareIntlayer(configuration);\n });\n};\n\nexport const buildAndWatchIntlayer = async (options?: WatchOptions) => {\n const { skipPrepare, ...rest } = options ?? {};\n const configuration =\n options?.configuration ?? getConfiguration(options?.configOptions);\n\n if (!skipPrepare) {\n await prepareIntlayer(configuration, { forceRun: true });\n }\n\n if (configuration.content.watch || options?.persistent) {\n watch({ ...rest, configuration });\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;AAwBA,MAAM,iCAAiB,IAAI,KAGxB;AAGH,IAAI,kBAAkB,QAAQ,SAAS;AACvC,MAAM,gBAAgB,SAA8B;AAClD,mBAAkB,gBAAgB,KAAK,YAAY;AACjD,MAAI;AACF,SAAM,MAAM;WACL,OAAO;AACd,WAAQ,MAAM,MAAM;;GAEtB;;AAUJ,MAAa,SAAS,YAA2B;CAC/C,MAAM,eAAe,4BAA4B,SAAS,cAAc;CACxE,MAAM,wBAAwB,aAAa;CAC3C,IAAI,gBACF,SAAS,iBAAiB,aAAa;CACzC,MAAM,YAAY,aAAa,cAAc;CAE7C,MAAM,EACJ,OAAO,aACP,gBACA,eACE,cAAc;CAQlB,MAAM,eAAe,CACnB,GAPkC,eAAe,SAAS,QAC1D,WAAW,KAAK,QACd,GAAG,cAAc,IAAI,CAAC,OAAO,MAAM,QAAQ,MAAM,IAAI,CACtD,CACF,EAIC,GAAI,wBAAwB,CAAC,sBAAsB,GAAG,EAAE,CACzD;AAED,KAAI,CAAC,cAAc,QAAQ,MAAO;AAElC,WAAU,yCAAyC;AAEnD,QAAOA,QAAc,cAAc;EACjC,YAAY;EACZ,eAAe;EACf,kBAAkB;GAChB,oBAAoB;GACpB,cAAc;GACf;EACD,SAAS;GACP;GACA;GACA;GACA;GACD;EACD,GAAG;EACJ,CAAC,CACC,GAAG,OAAO,OAAO,aAAa;EAC7B,MAAM,WAAW,SAAS,SAAS;EACnC,IAAI,SAAS;EAMb,IAAI;AAGJ,OAAK,MAAM,CAAC,YAAY,eACtB,KAAI,SAAS,QAAQ,KAAK,UAAU;AAClC,oBAAiB;AACjB;;AAKJ,MAAI,CAAC,kBAAkB,eAAe,SAAS,EAC7C,kBAAiB,eAAe,MAAM,CAAC,MAAM,CAAC;AAGhD,MAAI,gBAAgB;GAElB,MAAM,UAAU,eAAe,IAAI,eAAe;AAClD,OAAI,SAAS;AACX,iBAAa,QAAQ,MAAM;AAC3B,mBAAe,OAAO,eAAe;;AAGvC,YAAS;AACT,aAAU,mBAAmB,eAAe,MAAM,WAAW;;AAG/D,eAAa,YAAY;AACvB,OAAI,UAAU,eACZ,OAAM,kCACJ,gBACA,UACA,cACD;QACI;AAKL,QAJoB,MAAM,SAAS,UAAU,QAAQ,KACrB,IAGnB;KACX,MAAM,mBAAmB,eACtB,KAAK,QAAQ,IAAI,QAAQ,OAAO,MAAM,CAAC,CACvC,KAAK,IAAI;AAMZ,WAAM,wBACJ;MACE,KAPS,SAAS,QACpB,IAAI,OAAO,IAAI,iBAAiB,IAAI,EACpC,GACD;MAKG,SAAS,EAAE;MACX;MACD,EACD,cACD;;AAGH,UAAM,uCAAuC,UAAU,cAAc;;IAEvE;GACF,CACD,GAAG,UAAU,OAAO,aACnB,aAAa,YAAY;AACvB,MAAI,yBAAyB,aAAa,uBAAuB;AAC/D,aAAU,mDAAmD;AAE7D,oBAAiB,sBAAsB;AACvC,kBAAe;GAEf,MAAM,EAAE,eAAe,qBACrB,4BAA4B,SAAS,cAAc;AAErD,mBAAgB,SAAS,iBAAiB;AAE1C,SAAM,gBAAgB,eAAe,EAAE,OAAO,OAAO,CAAC;QAEtD,OAAM,mCAAmC,UAAU,cAAc;GAEnE,CACH,CACA,GAAG,UAAU,OAAO,aAAa;EAEhC,MAAM,QAAQ,WAAW,YAAY;AAEnC,kBAAe,OAAO,SAAS;AAC/B,gBAAa,YACX,qCAAqC,UAAU,cAAc,CAC9D;KACA,IAAI;AAEP,iBAAe,IAAI,UAAU;GAAE;GAAO,SAAS;GAAU,CAAC;GAC1D,CACD,GAAG,SAAS,OAAO,UAAU;AAC5B,YAAU,kBAAkB,SAAS,EACnC,OAAO,SACR,CAAC;AAEF,YAAU,qBAAqB;AAE/B,QAAM,gBAAgB,cAAc;GACpC;;AAGN,MAAa,wBAAwB,OAAO,YAA2B;CACrE,MAAM,EAAE,aAAa,GAAG,SAAS,WAAW,EAAE;CAC9C,MAAM,gBACJ,SAAS,iBAAiB,iBAAiB,SAAS,cAAc;AAEpE,KAAI,CAAC,YACH,OAAM,gBAAgB,eAAe,EAAE,UAAU,MAAM,CAAC;AAG1D,KAAI,cAAc,QAAQ,SAAS,SAAS,WAC1C,OAAM;EAAE,GAAG;EAAM;EAAe,CAAC"}
@@ -1,2 +1,40 @@
1
- import{writeJsonIfChanged as e}from"../writeJsonIfChanged.mjs";import{mkdir as t,readFile as n}from"node:fs/promises";import{join as r}from"node:path";import{isDeepStrictEqual as i}from"node:util";const a=async e=>{let t=await n(r(e.system.configDir,`configuration.json`),`utf8`);return JSON.parse(t)},o=async e=>{let t=s(e);return i(await a(e),t)},s=e=>JSON.parse(JSON.stringify({internationalization:{locales:e.internationalization.locales,defaultLocale:e.internationalization.defaultLocale},editor:e.editor,log:e.log,routing:e.routing,metadata:e.metadata})),c=async n=>{let{system:i}=n,{configDir:a}=i;await t(a,{recursive:!0}),await e(r(a,`configuration.json`),s(n))};export{o as isCachedConfigurationUpToDate,c as writeConfiguration};
1
+ import { writeJsonIfChanged } from "../writeJsonIfChanged.mjs";
2
+ import { mkdir, readFile } from "node:fs/promises";
3
+ import { join } from "node:path";
4
+ import { isDeepStrictEqual } from "node:util";
5
+
6
+ //#region src/writeConfiguration/index.ts
7
+ const getCachedConfiguration = async (configuration) => {
8
+ const configurationContent = await readFile(join(configuration.system.configDir, "configuration.json"), "utf8");
9
+ return JSON.parse(configurationContent);
10
+ };
11
+ const isCachedConfigurationUpToDate = async (configuration) => {
12
+ try {
13
+ const cleanedConfiguration = cleanConfiguration(configuration);
14
+ return isDeepStrictEqual(await getCachedConfiguration(configuration), cleanedConfiguration);
15
+ } catch {
16
+ return null;
17
+ }
18
+ };
19
+ const cleanConfiguration = (configuration) => {
20
+ return JSON.parse(JSON.stringify({
21
+ internationalization: {
22
+ locales: configuration.internationalization.locales,
23
+ defaultLocale: configuration.internationalization.defaultLocale
24
+ },
25
+ editor: configuration.editor,
26
+ log: configuration.log,
27
+ routing: configuration.routing,
28
+ metadata: configuration.metadata
29
+ }));
30
+ };
31
+ const writeConfiguration = async (configuration) => {
32
+ const { system } = configuration;
33
+ const { configDir } = system;
34
+ await mkdir(configDir, { recursive: true });
35
+ await writeJsonIfChanged(join(configDir, "configuration.json"), cleanConfiguration(configuration));
36
+ };
37
+
38
+ //#endregion
39
+ export { isCachedConfigurationUpToDate, writeConfiguration };
2
40
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/writeConfiguration/index.ts"],"sourcesContent":["import { mkdir, readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { isDeepStrictEqual } from 'node:util';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n} from '@intlayer/types/config';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\n\nconst getCachedConfiguration = async (configuration: IntlayerConfig) => {\n const configFilePath = join(\n configuration.system.configDir,\n 'configuration.json'\n );\n\n const configurationContent = await readFile(configFilePath, 'utf8');\n return JSON.parse(configurationContent);\n};\n\nexport const isCachedConfigurationUpToDate = async (\n configuration: IntlayerConfig\n): Promise<boolean | null> => {\n const cleanedConfiguration = cleanConfiguration(configuration);\n const cachedConfiguration = await getCachedConfiguration(configuration);\n\n const isSimilar = isDeepStrictEqual(\n cachedConfiguration,\n cleanedConfiguration\n );\n\n return isSimilar;\n};\n\nconst cleanConfiguration = (configuration: IntlayerConfig): IntlayerConfig => {\n const parsedConfiguration = JSON.parse(\n JSON.stringify({\n internationalization: {\n locales: configuration.internationalization.locales,\n defaultLocale: configuration.internationalization.defaultLocale,\n },\n editor: configuration.editor,\n log: configuration.log,\n routing: configuration.routing,\n metadata: configuration.metadata,\n } as CustomIntlayerConfig)\n );\n\n return parsedConfiguration;\n};\n\nexport const writeConfiguration = async (configuration: IntlayerConfig) => {\n const { system } = configuration;\n const { configDir } = system;\n\n // Ensure target directory exists\n // configDir is expected to be the directory where configuration.json will live\n await mkdir(configDir, { recursive: true });\n\n const configFilePath = join(configDir, 'configuration.json');\n\n const cleanedConfiguration = cleanConfiguration(configuration);\n\n await writeJsonIfChanged(configFilePath, cleanedConfiguration);\n};\n"],"mappings":"qMASA,MAAM,EAAyB,KAAO,IAAkC,CAMtE,IAAM,EAAuB,MAAM,EALZ,EACrB,EAAc,OAAO,UACrB,qBACD,CAE2D,OAAO,CACnE,OAAO,KAAK,MAAM,EAAqB,EAG5B,EAAgC,KAC3C,IAC4B,CAC5B,IAAM,EAAuB,EAAmB,EAAc,CAQ9D,OALkB,EAFU,MAAM,EAAuB,EAAc,CAIrE,EACD,EAKG,EAAsB,GACE,KAAK,MAC/B,KAAK,UAAU,CACb,qBAAsB,CACpB,QAAS,EAAc,qBAAqB,QAC5C,cAAe,EAAc,qBAAqB,cACnD,CACD,OAAQ,EAAc,OACtB,IAAK,EAAc,IACnB,QAAS,EAAc,QACvB,SAAU,EAAc,SACzB,CAAyB,CAC3B,CAKU,EAAqB,KAAO,IAAkC,CACzE,GAAM,CAAE,UAAW,EACb,CAAE,aAAc,EAItB,MAAM,EAAM,EAAW,CAAE,UAAW,GAAM,CAAC,CAM3C,MAAM,EAJiB,EAAK,EAAW,qBAAqB,CAE/B,EAAmB,EAAc,CAEA"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/writeConfiguration/index.ts"],"sourcesContent":["import { mkdir, readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { isDeepStrictEqual } from 'node:util';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n} from '@intlayer/types/config';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\n\nconst getCachedConfiguration = async (configuration: IntlayerConfig) => {\n const configFilePath = join(\n configuration.system.configDir,\n 'configuration.json'\n );\n\n const configurationContent = await readFile(configFilePath, 'utf8');\n return JSON.parse(configurationContent);\n};\n\nexport const isCachedConfigurationUpToDate = async (\n configuration: IntlayerConfig\n): Promise<boolean | null> => {\n try {\n const cleanedConfiguration = cleanConfiguration(configuration);\n const cachedConfiguration = await getCachedConfiguration(configuration);\n\n const isSimilar = isDeepStrictEqual(\n cachedConfiguration,\n cleanedConfiguration\n );\n\n return isSimilar;\n } catch {\n return null; // Can crash if await readFile(configFilePath, 'utf8'); and config is not defined\n }\n};\n\nconst cleanConfiguration = (configuration: IntlayerConfig): IntlayerConfig => {\n const parsedConfiguration = JSON.parse(\n JSON.stringify({\n internationalization: {\n locales: configuration.internationalization.locales,\n defaultLocale: configuration.internationalization.defaultLocale,\n },\n editor: configuration.editor,\n log: configuration.log,\n routing: configuration.routing,\n metadata: configuration.metadata,\n } as CustomIntlayerConfig)\n );\n\n return parsedConfiguration;\n};\n\nexport const writeConfiguration = async (configuration: IntlayerConfig) => {\n const { system } = configuration;\n const { configDir } = system;\n\n // Ensure target directory exists\n // configDir is expected to be the directory where configuration.json will live\n await mkdir(configDir, { recursive: true });\n\n const configFilePath = join(configDir, 'configuration.json');\n\n const cleanedConfiguration = cleanConfiguration(configuration);\n\n await writeJsonIfChanged(configFilePath, cleanedConfiguration);\n};\n"],"mappings":";;;;;;AASA,MAAM,yBAAyB,OAAO,kBAAkC;CAMtE,MAAM,uBAAuB,MAAM,SALZ,KACrB,cAAc,OAAO,WACrB,qBACD,EAE2D,OAAO;AACnE,QAAO,KAAK,MAAM,qBAAqB;;AAGzC,MAAa,gCAAgC,OAC3C,kBAC4B;AAC5B,KAAI;EACF,MAAM,uBAAuB,mBAAmB,cAAc;AAQ9D,SALkB,kBAFU,MAAM,uBAAuB,cAAc,EAIrE,qBACD;SAGK;AACN,SAAO;;;AAIX,MAAM,sBAAsB,kBAAkD;AAc5E,QAb4B,KAAK,MAC/B,KAAK,UAAU;EACb,sBAAsB;GACpB,SAAS,cAAc,qBAAqB;GAC5C,eAAe,cAAc,qBAAqB;GACnD;EACD,QAAQ,cAAc;EACtB,KAAK,cAAc;EACnB,SAAS,cAAc;EACvB,UAAU,cAAc;EACzB,CAAyB,CAC3B;;AAKH,MAAa,qBAAqB,OAAO,kBAAkC;CACzE,MAAM,EAAE,WAAW;CACnB,MAAM,EAAE,cAAc;AAItB,OAAM,MAAM,WAAW,EAAE,WAAW,MAAM,CAAC;AAM3C,OAAM,mBAJiB,KAAK,WAAW,qBAAqB,EAE/B,mBAAmB,cAAc,CAEA"}
@@ -1,2 +1,27 @@
1
- const e=e=>{let t=/export\s+default\s+function\s+(\w+)/,n=/export\s+default\s+(\w+)/,r=/module\.exports\s*=\s*(\w+)/,i=/exports\.default\s*=\s*(\w+)/,a=/export\s+(?:const|function)\s+(\w+)/g,o=e.match(t);if(o)return o[1];let s=e.match(n);if(s)return s[1];let c=e.match(r)||e.match(i);if(c)return c[1];for(let t of e.matchAll(a))if(/^[A-Z]/.test(t[1]))return t[1];return null};export{e as detectExportedComponentName};
1
+ //#region src/writeContentDeclaration/detectExportedComponentName.ts
2
+ /**
3
+ * Attempt to detect an exported React component name in the file text.
4
+ * Looks for patterns like:
5
+ * - export const MyComponent = ...
6
+ * - export function MyComponent(...)
7
+ * - export default function MyComponent(...)
8
+ */
9
+ const detectExportedComponentName = (fileText) => {
10
+ const defaultEsmFnRegex = /export\s+default\s+function\s+(\w+)/;
11
+ const defaultEsmVarRegex = /export\s+default\s+(\w+)/;
12
+ const cjsDefaultRegex = /module\.exports\s*=\s*(\w+)/;
13
+ const cjsDefaultVarRegex = /exports\.default\s*=\s*(\w+)/;
14
+ const namedExportRegex = /export\s+(?:const|function)\s+(\w+)/g;
15
+ const defaultEsmFnMatch = fileText.match(defaultEsmFnRegex);
16
+ if (defaultEsmFnMatch) return defaultEsmFnMatch[1];
17
+ const defaultEsmVarMatch = fileText.match(defaultEsmVarRegex);
18
+ if (defaultEsmVarMatch) return defaultEsmVarMatch[1];
19
+ const cjsDefaultMatch = fileText.match(cjsDefaultRegex) || fileText.match(cjsDefaultVarRegex);
20
+ if (cjsDefaultMatch) return cjsDefaultMatch[1];
21
+ for (const match of fileText.matchAll(namedExportRegex)) if (/^[A-Z]/.test(match[1])) return match[1];
22
+ return null;
23
+ };
24
+
25
+ //#endregion
26
+ export { detectExportedComponentName };
2
27
  //# sourceMappingURL=detectExportedComponentName.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"detectExportedComponentName.mjs","names":[],"sources":["../../../src/writeContentDeclaration/detectExportedComponentName.ts"],"sourcesContent":["/**\n * Attempt to detect an exported React component name in the file text.\n * Looks for patterns like:\n * - export const MyComponent = ...\n * - export function MyComponent(...)\n * - export default function MyComponent(...)\n */\nexport const detectExportedComponentName = (\n fileText: string\n): string | null => {\n // Added regexes for default ESM, default CJS, and named exports\n const defaultEsmFnRegex = /export\\s+default\\s+function\\s+(\\w+)/;\n const defaultEsmVarRegex = /export\\s+default\\s+(\\w+)/;\n const cjsDefaultRegex = /module\\.exports\\s*=\\s*(\\w+)/;\n const cjsDefaultVarRegex = /exports\\.default\\s*=\\s*(\\w+)/;\n const namedExportRegex = /export\\s+(?:const|function)\\s+(\\w+)/g;\n\n // Check for default ESM function or variable\n const defaultEsmFnMatch = fileText.match(defaultEsmFnRegex);\n if (defaultEsmFnMatch) {\n return defaultEsmFnMatch[1];\n }\n\n const defaultEsmVarMatch = fileText.match(defaultEsmVarRegex);\n if (defaultEsmVarMatch) {\n return defaultEsmVarMatch[1];\n }\n\n // Check for default CJS\n const cjsDefaultMatch =\n fileText.match(cjsDefaultRegex) || fileText.match(cjsDefaultVarRegex);\n\n if (cjsDefaultMatch) return cjsDefaultMatch[1];\n\n // Otherwise, look for capitalized named exports\n for (const match of fileText.matchAll(namedExportRegex)) {\n if (/^[A-Z]/.test(match[1])) return match[1];\n }\n\n // If we can’t find it, return null\n return null;\n};\n"],"mappings":"AAOA,MAAa,EACX,GACkB,CAElB,IAAM,EAAoB,sCACpB,EAAqB,2BACrB,EAAkB,8BAClB,EAAqB,+BACrB,EAAmB,uCAGnB,EAAoB,EAAS,MAAM,EAAkB,CAC3D,GAAI,EACF,OAAO,EAAkB,GAG3B,IAAM,EAAqB,EAAS,MAAM,EAAmB,CAC7D,GAAI,EACF,OAAO,EAAmB,GAI5B,IAAM,EACJ,EAAS,MAAM,EAAgB,EAAI,EAAS,MAAM,EAAmB,CAEvE,GAAI,EAAiB,OAAO,EAAgB,GAG5C,IAAK,IAAM,KAAS,EAAS,SAAS,EAAiB,CACrD,GAAI,SAAS,KAAK,EAAM,GAAG,CAAE,OAAO,EAAM,GAI5C,OAAO"}
1
+ {"version":3,"file":"detectExportedComponentName.mjs","names":[],"sources":["../../../src/writeContentDeclaration/detectExportedComponentName.ts"],"sourcesContent":["/**\n * Attempt to detect an exported React component name in the file text.\n * Looks for patterns like:\n * - export const MyComponent = ...\n * - export function MyComponent(...)\n * - export default function MyComponent(...)\n */\nexport const detectExportedComponentName = (\n fileText: string\n): string | null => {\n // Added regexes for default ESM, default CJS, and named exports\n const defaultEsmFnRegex = /export\\s+default\\s+function\\s+(\\w+)/;\n const defaultEsmVarRegex = /export\\s+default\\s+(\\w+)/;\n const cjsDefaultRegex = /module\\.exports\\s*=\\s*(\\w+)/;\n const cjsDefaultVarRegex = /exports\\.default\\s*=\\s*(\\w+)/;\n const namedExportRegex = /export\\s+(?:const|function)\\s+(\\w+)/g;\n\n // Check for default ESM function or variable\n const defaultEsmFnMatch = fileText.match(defaultEsmFnRegex);\n if (defaultEsmFnMatch) {\n return defaultEsmFnMatch[1];\n }\n\n const defaultEsmVarMatch = fileText.match(defaultEsmVarRegex);\n if (defaultEsmVarMatch) {\n return defaultEsmVarMatch[1];\n }\n\n // Check for default CJS\n const cjsDefaultMatch =\n fileText.match(cjsDefaultRegex) || fileText.match(cjsDefaultVarRegex);\n\n if (cjsDefaultMatch) return cjsDefaultMatch[1];\n\n // Otherwise, look for capitalized named exports\n for (const match of fileText.matchAll(namedExportRegex)) {\n if (/^[A-Z]/.test(match[1])) return match[1];\n }\n\n // If we can’t find it, return null\n return null;\n};\n"],"mappings":";;;;;;;;AAOA,MAAa,+BACX,aACkB;CAElB,MAAM,oBAAoB;CAC1B,MAAM,qBAAqB;CAC3B,MAAM,kBAAkB;CACxB,MAAM,qBAAqB;CAC3B,MAAM,mBAAmB;CAGzB,MAAM,oBAAoB,SAAS,MAAM,kBAAkB;AAC3D,KAAI,kBACF,QAAO,kBAAkB;CAG3B,MAAM,qBAAqB,SAAS,MAAM,mBAAmB;AAC7D,KAAI,mBACF,QAAO,mBAAmB;CAI5B,MAAM,kBACJ,SAAS,MAAM,gBAAgB,IAAI,SAAS,MAAM,mBAAmB;AAEvE,KAAI,gBAAiB,QAAO,gBAAgB;AAG5C,MAAK,MAAM,SAAS,SAAS,SAAS,iBAAiB,CACrD,KAAI,SAAS,KAAK,MAAM,GAAG,CAAE,QAAO,MAAM;AAI5C,QAAO"}
@@ -1 +1,6 @@
1
- import{detectExportedComponentName as e}from"./detectExportedComponentName.mjs";import{transformJSFile as t}from"./transformJSFile.mjs";import{writeJSFile as n}from"./writeJSFile.mjs";import{writeContentDeclaration as r}from"./writeContentDeclaration.mjs";export{e as detectExportedComponentName,t as transformJSFile,r as writeContentDeclaration,n as writeJSFile};
1
+ import { detectExportedComponentName } from "./detectExportedComponentName.mjs";
2
+ import { transformJSFile } from "./transformJSFile.mjs";
3
+ import { writeJSFile } from "./writeJSFile.mjs";
4
+ import { writeContentDeclaration } from "./writeContentDeclaration.mjs";
5
+
6
+ export { detectExportedComponentName, transformJSFile, writeContentDeclaration, writeJSFile };
@@ -1,2 +1,92 @@
1
- import{dirname as e,join as t}from"node:path";import{colorizePath as n,x as r}from"@intlayer/config/logger";import{existsSync as i,mkdirSync as a,writeFileSync as o}from"node:fs";import{deepTransformNode as s}from"@intlayer/core/interpreter";import{NodeType as c}from"@intlayer/types/nodeType";const l={id:`write-file-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===c.File,transform:s=>{let l=s.content,u=s.fixedPath;if(typeof l!=`string`)throw Error(`File content must be a string`);if(typeof u!=`string`)throw Error(`File path must be a string`);try{let n=t(process.cwd(),u),r=e(n);i(r)||a(r,{recursive:!0}),o(n,l)}catch(e){throw Error(`${r} Error writing file to ${n(u)}: ${e}`)}return{nodeType:c.File,[c.File]:s.file}}},u={id:`markdown-file-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===c.Markdown,transform:(e,t,n)=>({nodeType:c.Markdown,[c.Markdown]:n(e.markdown,t)})},d={id:`insertion-file-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===c.Insertion,transform:(e,t,n)=>({nodeType:c.Insertion,[c.Insertion]:n(e.insertion,t)})},f={id:`html-file-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===c.HTML,transform:(e,t,n)=>({nodeType:c.HTML,[c.HTML]:n(e.html,t)})},p=async e=>s(e,{dictionaryKey:e.key,keyPath:[],plugins:[l,u,d,f]});export{p as processContentDeclarationContent};
1
+ import { dirname, join } from "node:path";
2
+ import { colorizePath, x } from "@intlayer/config/logger";
3
+ import { existsSync, mkdirSync, writeFileSync } from "node:fs";
4
+ import { deepTransformNode } from "@intlayer/core/interpreter";
5
+ import * as NodeTypes from "@intlayer/types/nodeType";
6
+
7
+ //#region src/writeContentDeclaration/processContentDeclarationContent.ts
8
+ /**
9
+ * Write file plugin
10
+ */
11
+ const writeFilePlugin = {
12
+ id: "write-file-plugin",
13
+ canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.FILE,
14
+ transform: (node) => {
15
+ const fileContent = node.content;
16
+ const filePath = node.fixedPath;
17
+ if (typeof fileContent !== "string") throw new Error("File content must be a string");
18
+ if (typeof filePath !== "string") throw new Error("File path must be a string");
19
+ try {
20
+ const absoluteFilePath = join(process.cwd(), filePath);
21
+ const fileDirectory = dirname(absoluteFilePath);
22
+ if (!existsSync(fileDirectory)) mkdirSync(fileDirectory, { recursive: true });
23
+ writeFileSync(absoluteFilePath, fileContent);
24
+ } catch (error) {
25
+ throw new Error(`${x} Error writing file to ${colorizePath(filePath)}: ${error}`);
26
+ }
27
+ return {
28
+ nodeType: NodeTypes.FILE,
29
+ [NodeTypes.FILE]: node[NodeTypes.FILE]
30
+ };
31
+ }
32
+ };
33
+ /**
34
+ * Markdown file plugin
35
+ */
36
+ const markdownFilePlugin = {
37
+ id: "markdown-file-plugin",
38
+ canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.MARKDOWN,
39
+ transform: (node, props, deepTransformNode) => {
40
+ return {
41
+ nodeType: NodeTypes.MARKDOWN,
42
+ [NodeTypes.MARKDOWN]: deepTransformNode(node[NodeTypes.MARKDOWN], props)
43
+ };
44
+ }
45
+ };
46
+ /**
47
+ * Insertion file plugin
48
+ */
49
+ const insertionFilePlugin = {
50
+ id: "insertion-file-plugin",
51
+ canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.INSERTION,
52
+ transform: (node, props, deepTransformNode) => {
53
+ return {
54
+ nodeType: NodeTypes.INSERTION,
55
+ [NodeTypes.INSERTION]: deepTransformNode(node[NodeTypes.INSERTION], props)
56
+ };
57
+ }
58
+ };
59
+ /**
60
+ * HTML file plugin
61
+ */
62
+ const htmlFilePlugin = {
63
+ id: "html-file-plugin",
64
+ canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.HTML,
65
+ transform: (node, props, deepTransformNode) => {
66
+ return {
67
+ nodeType: NodeTypes.HTML,
68
+ [NodeTypes.HTML]: deepTransformNode(node[NodeTypes.HTML], props)
69
+ };
70
+ }
71
+ };
72
+ /**
73
+ * Process content declaration content
74
+ *
75
+ * It filter node that are autogenerated by intlayer to do not rewrite them in the content declaration file.
76
+ *
77
+ * And write external sources as file content if necessary.
78
+ */
79
+ const processContentDeclarationContent = async (dictionary) => deepTransformNode(dictionary, {
80
+ dictionaryKey: dictionary.key,
81
+ keyPath: [],
82
+ plugins: [
83
+ writeFilePlugin,
84
+ markdownFilePlugin,
85
+ insertionFilePlugin,
86
+ htmlFilePlugin
87
+ ]
88
+ });
89
+
90
+ //#endregion
91
+ export { processContentDeclarationContent };
2
92
  //# sourceMappingURL=processContentDeclarationContent.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"processContentDeclarationContent.mjs","names":[],"sources":["../../../src/writeContentDeclaration/processContentDeclarationContent.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { colorizePath, x } from '@intlayer/config/logger';\nimport { deepTransformNode, type Plugins } from '@intlayer/core/interpreter';\nimport type {\n FileContent,\n FileContentConstructor,\n HTMLContent,\n HTMLContentConstructor,\n InsertionContent,\n InsertionContentConstructor,\n MarkdownContent,\n MarkdownContentConstructor,\n} from '@intlayer/core/transpiler';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { NodeType } from '@intlayer/types/nodeType';\n\n/**\n * Write file plugin\n */\n\nconst writeFilePlugin: Plugins = {\n id: 'write-file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.File,\n transform: (node: FileContent) => {\n const fileContent = node.content;\n const filePath = node.fixedPath;\n\n if (typeof fileContent !== 'string') {\n throw new Error('File content must be a string');\n }\n\n if (typeof filePath !== 'string') {\n throw new Error('File path must be a string');\n }\n\n // Write the file to the file system\n try {\n const absoluteFilePath = join(process.cwd(), filePath);\n\n // Create the file directory if it doesn't exist\n const fileDirectory = dirname(absoluteFilePath);\n\n if (!existsSync(fileDirectory)) {\n mkdirSync(fileDirectory, { recursive: true });\n }\n\n // Write the file\n writeFileSync(absoluteFilePath, fileContent);\n } catch (error) {\n throw new Error(\n `${x} Error writing file to ${colorizePath(filePath)}: ${error}`\n );\n }\n\n const transformedFileContent: FileContentConstructor = {\n nodeType: NodeType.File,\n [NodeType.File]: node.file,\n };\n\n return transformedFileContent;\n },\n};\n\n/**\n * Markdown file plugin\n */\n\nconst markdownFilePlugin: Plugins = {\n id: 'markdown-file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const simplifiedMarkdownNode: MarkdownContentConstructor = {\n nodeType: NodeType.Markdown,\n [NodeType.Markdown]: deepTransformNode(node.markdown, props),\n };\n\n return simplifiedMarkdownNode;\n },\n};\n\n/**\n * Insertion file plugin\n */\n\nconst insertionFilePlugin: Plugins = {\n id: 'insertion-file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Insertion,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const simplifiedInsertionNode: InsertionContentConstructor = {\n nodeType: NodeType.Insertion,\n [NodeType.Insertion]: deepTransformNode(node.insertion, props),\n };\n\n return simplifiedInsertionNode;\n },\n};\n\n/**\n * HTML file plugin\n */\n\nconst htmlFilePlugin: Plugins = {\n id: 'html-file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.HTML,\n transform: (node: HTMLContent, props, deepTransformNode) => {\n const simplifiedHTMLNode: HTMLContentConstructor = {\n nodeType: NodeType.HTML,\n [NodeType.HTML]: deepTransformNode(node.html, props),\n };\n\n return simplifiedHTMLNode;\n },\n};\n\n/**\n * Process content declaration content\n *\n * It filter node that are autogenerated by intlayer to do not rewrite them in the content declaration file.\n *\n * And write external sources as file content if necessary.\n */\nexport const processContentDeclarationContent = async (\n dictionary: Dictionary\n) =>\n deepTransformNode(dictionary, {\n dictionaryKey: dictionary.key,\n keyPath: [],\n plugins: [\n writeFilePlugin,\n markdownFilePlugin,\n insertionFilePlugin,\n htmlFilePlugin,\n ],\n });\n"],"mappings":"sSAqBA,MAAM,EAA2B,CAC/B,GAAI,oBACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAa,EAAS,KAC1D,UAAY,GAAsB,CAChC,IAAM,EAAc,EAAK,QACnB,EAAW,EAAK,UAEtB,GAAI,OAAO,GAAgB,SACzB,MAAU,MAAM,gCAAgC,CAGlD,GAAI,OAAO,GAAa,SACtB,MAAU,MAAM,6BAA6B,CAI/C,GAAI,CACF,IAAM,EAAmB,EAAK,QAAQ,KAAK,CAAE,EAAS,CAGhD,EAAgB,EAAQ,EAAiB,CAE1C,EAAW,EAAc,EAC5B,EAAU,EAAe,CAAE,UAAW,GAAM,CAAC,CAI/C,EAAc,EAAkB,EAAY,OACrC,EAAO,CACd,MAAU,MACR,GAAG,EAAE,yBAAyB,EAAa,EAAS,CAAC,IAAI,IAC1D,CAQH,MALuD,CACrD,SAAU,EAAS,MAClB,EAAS,MAAO,EAAK,KACvB,EAIJ,CAMK,EAA8B,CAClC,GAAI,uBACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAa,EAAS,SAC1D,WAAY,EAAuB,EAAO,KACmB,CACzD,SAAU,EAAS,UAClB,EAAS,UAAW,EAAkB,EAAK,SAAU,EAAM,CAC7D,EAIJ,CAMK,EAA+B,CACnC,GAAI,wBACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAa,EAAS,UAC1D,WAAY,EAAwB,EAAO,KACoB,CAC3D,SAAU,EAAS,WAClB,EAAS,WAAY,EAAkB,EAAK,UAAW,EAAM,CAC/D,EAIJ,CAMK,EAA0B,CAC9B,GAAI,mBACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAa,EAAS,KAC1D,WAAY,EAAmB,EAAO,KACe,CACjD,SAAU,EAAS,MAClB,EAAS,MAAO,EAAkB,EAAK,KAAM,EAAM,CACrD,EAIJ,CASY,EAAmC,KAC9C,IAEA,EAAkB,EAAY,CAC5B,cAAe,EAAW,IAC1B,QAAS,EAAE,CACX,QAAS,CACP,EACA,EACA,EACA,EACD,CACF,CAAC"}
1
+ {"version":3,"file":"processContentDeclarationContent.mjs","names":[],"sources":["../../../src/writeContentDeclaration/processContentDeclarationContent.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { colorizePath, x } from '@intlayer/config/logger';\nimport { deepTransformNode, type Plugins } from '@intlayer/core/interpreter';\nimport type {\n FileContent,\n FileContentConstructor,\n HTMLContent,\n HTMLContentConstructor,\n InsertionContent,\n InsertionContentConstructor,\n MarkdownContent,\n MarkdownContentConstructor,\n} from '@intlayer/core/transpiler';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport * as NodeTypes from '@intlayer/types/nodeType';\n\n/**\n * Write file plugin\n */\n\nconst writeFilePlugin: Plugins = {\n id: 'write-file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.FILE,\n transform: (node: FileContent) => {\n const fileContent = node.content;\n const filePath = node.fixedPath;\n\n if (typeof fileContent !== 'string') {\n throw new Error('File content must be a string');\n }\n\n if (typeof filePath !== 'string') {\n throw new Error('File path must be a string');\n }\n\n // Write the file to the file system\n try {\n const absoluteFilePath = join(process.cwd(), filePath);\n\n // Create the file directory if it doesn't exist\n const fileDirectory = dirname(absoluteFilePath);\n\n if (!existsSync(fileDirectory)) {\n mkdirSync(fileDirectory, { recursive: true });\n }\n\n // Write the file\n writeFileSync(absoluteFilePath, fileContent);\n } catch (error) {\n throw new Error(\n `${x} Error writing file to ${colorizePath(filePath)}: ${error}`\n );\n }\n\n const transformedFileContent: FileContentConstructor = {\n nodeType: NodeTypes.FILE,\n [NodeTypes.FILE]: node[NodeTypes.FILE],\n };\n\n return transformedFileContent;\n },\n};\n\n/**\n * Markdown file plugin\n */\n\nconst markdownFilePlugin: Plugins = {\n id: 'markdown-file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.MARKDOWN,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const simplifiedMarkdownNode: MarkdownContentConstructor = {\n nodeType: NodeTypes.MARKDOWN,\n [NodeTypes.MARKDOWN]: deepTransformNode(node[NodeTypes.MARKDOWN], props),\n };\n\n return simplifiedMarkdownNode;\n },\n};\n\n/**\n * Insertion file plugin\n */\n\nconst insertionFilePlugin: Plugins = {\n id: 'insertion-file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const simplifiedInsertionNode: InsertionContentConstructor = {\n nodeType: NodeTypes.INSERTION,\n [NodeTypes.INSERTION]: deepTransformNode(\n node[NodeTypes.INSERTION],\n props\n ),\n };\n\n return simplifiedInsertionNode;\n },\n};\n\n/**\n * HTML file plugin\n */\n\nconst htmlFilePlugin: Plugins = {\n id: 'html-file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.HTML,\n transform: (node: HTMLContent, props, deepTransformNode) => {\n const simplifiedHTMLNode: HTMLContentConstructor = {\n nodeType: NodeTypes.HTML,\n [NodeTypes.HTML]: deepTransformNode(node[NodeTypes.HTML], props),\n };\n\n return simplifiedHTMLNode;\n },\n};\n\n/**\n * Process content declaration content\n *\n * It filter node that are autogenerated by intlayer to do not rewrite them in the content declaration file.\n *\n * And write external sources as file content if necessary.\n */\nexport const processContentDeclarationContent = async (\n dictionary: Dictionary\n) =>\n deepTransformNode(dictionary, {\n dictionaryKey: dictionary.key,\n keyPath: [],\n plugins: [\n writeFilePlugin,\n markdownFilePlugin,\n insertionFilePlugin,\n htmlFilePlugin,\n ],\n });\n"],"mappings":";;;;;;;;;;AAqBA,MAAM,kBAA2B;CAC/B,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC3D,YAAY,SAAsB;EAChC,MAAM,cAAc,KAAK;EACzB,MAAM,WAAW,KAAK;AAEtB,MAAI,OAAO,gBAAgB,SACzB,OAAM,IAAI,MAAM,gCAAgC;AAGlD,MAAI,OAAO,aAAa,SACtB,OAAM,IAAI,MAAM,6BAA6B;AAI/C,MAAI;GACF,MAAM,mBAAmB,KAAK,QAAQ,KAAK,EAAE,SAAS;GAGtD,MAAM,gBAAgB,QAAQ,iBAAiB;AAE/C,OAAI,CAAC,WAAW,cAAc,CAC5B,WAAU,eAAe,EAAE,WAAW,MAAM,CAAC;AAI/C,iBAAc,kBAAkB,YAAY;WACrC,OAAO;AACd,SAAM,IAAI,MACR,GAAG,EAAE,yBAAyB,aAAa,SAAS,CAAC,IAAI,QAC1D;;AAQH,SALuD;GACrD,UAAU,UAAU;IACnB,UAAU,OAAO,KAAK,UAAU;GAClC;;CAIJ;;;;AAMD,MAAM,qBAA8B;CAClC,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC3D,YAAY,MAAuB,OAAO,sBAAsB;AAM9D,SAL2D;GACzD,UAAU,UAAU;IACnB,UAAU,WAAW,kBAAkB,KAAK,UAAU,WAAW,MAAM;GACzE;;CAIJ;;;;AAMD,MAAM,sBAA+B;CACnC,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC3D,YAAY,MAAwB,OAAO,sBAAsB;AAS/D,SAR6D;GAC3D,UAAU,UAAU;IACnB,UAAU,YAAY,kBACrB,KAAK,UAAU,YACf,MACD;GACF;;CAIJ;;;;AAMD,MAAM,iBAA0B;CAC9B,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC3D,YAAY,MAAmB,OAAO,sBAAsB;AAM1D,SALmD;GACjD,UAAU,UAAU;IACnB,UAAU,OAAO,kBAAkB,KAAK,UAAU,OAAO,MAAM;GACjE;;CAIJ;;;;;;;;AASD,MAAa,mCAAmC,OAC9C,eAEA,kBAAkB,YAAY;CAC5B,eAAe,WAAW;CAC1B,SAAS,EAAE;CACX,SAAS;EACP;EACA;EACA;EACA;EACD;CACF,CAAC"}