@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 +1 @@
1
- {"version":3,"file":"verifyIdenticObjectFormat.cjs","names":[],"sources":["../../../src/utils/verifyIdenticObjectFormat.ts"],"sourcesContent":["type FlatType = string | number | boolean | object | null | undefined;\n\ntype RecursiveType =\n | FlatType\n | { [key: string]: RecursiveType }\n | Array<RecursiveType>;\n\ntype VerifyIdenticObjectFormatResult = {\n isIdentic: boolean;\n error?: string;\n};\n\n/**\n * Verifies that two objects have identical structure (same keys, array lengths, and types)\n * but not necessarily the same values.\n * Useful for validating translations maintain the same format as the original.\n *\n * @param object - The object to verify\n * @param expectedFormat - The expected format to compare against\n * @param path - Current path in the object tree (for error messages)\n * @returns true if structures match, throws error with details if they don't\n */\nexport const verifyIdenticObjectFormat = (\n object: RecursiveType,\n expectedFormat: RecursiveType,\n path: string = 'root'\n): VerifyIdenticObjectFormatResult => {\n // Check if both are null or undefined\n if (expectedFormat === null || expectedFormat === undefined) {\n if (expectedFormat !== object) {\n return {\n isIdentic: false,\n error: `Type mismatch at ${path}: expected ${expectedFormat === null ? 'null' : 'undefined'}, got ${object === null ? 'null' : typeof object}`,\n };\n }\n return {\n isIdentic: true,\n };\n }\n\n // Get the type of both values\n const expectedType = Array.isArray(expectedFormat)\n ? 'array'\n : typeof expectedFormat;\n const objectType = Array.isArray(object) ? 'array' : typeof object;\n\n // Check if types match\n if (expectedType !== objectType) {\n return {\n isIdentic: false,\n error: `Type mismatch at ${path}: expected ${expectedType}, got ${objectType}`,\n };\n }\n\n // Handle arrays\n if (Array.isArray(expectedFormat) && Array.isArray(object)) {\n if (expectedFormat.length !== object.length) {\n return {\n isIdentic: false,\n error: `Array length mismatch at ${path}: expected ${expectedFormat.length} elements, got ${object.length}`,\n };\n }\n\n // Recursively check each element\n for (let i = 0; i < expectedFormat.length; i++) {\n const result = verifyIdenticObjectFormat(\n object[i],\n expectedFormat[i],\n `${path}[${i}]`\n );\n if (!result.isIdentic) {\n return result;\n }\n }\n\n return {\n isIdentic: true,\n };\n }\n\n // Handle objects (excluding null and arrays)\n if (\n typeof expectedFormat === 'object' &&\n typeof object === 'object' &&\n expectedFormat !== null &&\n object !== null\n ) {\n const expectedKeys = Object.keys(expectedFormat);\n const objectKeys = Object.keys(object);\n\n // Check if number of keys match\n if (expectedKeys.length !== objectKeys.length) {\n return {\n isIdentic: false,\n error: `Object keys count mismatch at ${path}: expected ${expectedKeys.length} keys, got ${objectKeys.length}`,\n };\n }\n\n // Check if keys match and are in the same order\n for (let i = 0; i < expectedKeys.length; i++) {\n if (expectedKeys[i] !== objectKeys[i]) {\n return {\n isIdentic: false,\n error: `Object keys mismatch at ${path}: expected key \"${expectedKeys[i]}\" at position ${i}, got \"${objectKeys[i]}\"`,\n };\n }\n }\n\n // Recursively check each property\n for (const key of expectedKeys) {\n const result = verifyIdenticObjectFormat(\n (object as Record<string, RecursiveType>)[key],\n (expectedFormat as Record<string, RecursiveType>)[key],\n `${path}.${key}`\n );\n if (!result.isIdentic) {\n return result;\n }\n }\n\n return {\n isIdentic: true,\n };\n }\n\n // For primitive types (string, number, boolean), just verify they're the same type\n // We don't check the actual values as per requirements\n return {\n isIdentic: true,\n };\n};\n"],"mappings":"mEAsBA,MAAa,GACX,EACA,EACA,EAAe,SACqB,CAEpC,GAAI,GAAmB,KAOrB,OANI,IAAmB,EAMhB,CACL,UAAW,GACZ,CAPQ,CACL,UAAW,GACX,MAAO,oBAAoB,EAAK,aAAa,IAAmB,KAAO,OAAS,YAAY,QAAQ,IAAW,KAAO,OAAS,OAAO,IACvI,CAQL,IAAM,EAAe,MAAM,QAAQ,EAAe,CAC9C,QACA,OAAO,EACL,EAAa,MAAM,QAAQ,EAAO,CAAG,QAAU,OAAO,EAG5D,GAAI,IAAiB,EACnB,MAAO,CACL,UAAW,GACX,MAAO,oBAAoB,EAAK,aAAa,EAAa,QAAQ,IACnE,CAIH,GAAI,MAAM,QAAQ,EAAe,EAAI,MAAM,QAAQ,EAAO,CAAE,CAC1D,GAAI,EAAe,SAAW,EAAO,OACnC,MAAO,CACL,UAAW,GACX,MAAO,4BAA4B,EAAK,aAAa,EAAe,OAAO,iBAAiB,EAAO,SACpG,CAIH,IAAK,IAAI,EAAI,EAAG,EAAI,EAAe,OAAQ,IAAK,CAC9C,IAAM,EAAS,EACb,EAAO,GACP,EAAe,GACf,GAAG,EAAK,GAAG,EAAE,GACd,CACD,GAAI,CAAC,EAAO,UACV,OAAO,EAIX,MAAO,CACL,UAAW,GACZ,CAIH,GACE,OAAO,GAAmB,UAC1B,OAAO,GAAW,UAClB,IAAmB,MACnB,IAAW,KACX,CACA,IAAM,EAAe,OAAO,KAAK,EAAe,CAC1C,EAAa,OAAO,KAAK,EAAO,CAGtC,GAAI,EAAa,SAAW,EAAW,OACrC,MAAO,CACL,UAAW,GACX,MAAO,iCAAiC,EAAK,aAAa,EAAa,OAAO,aAAa,EAAW,SACvG,CAIH,IAAK,IAAI,EAAI,EAAG,EAAI,EAAa,OAAQ,IACvC,GAAI,EAAa,KAAO,EAAW,GACjC,MAAO,CACL,UAAW,GACX,MAAO,2BAA2B,EAAK,kBAAkB,EAAa,GAAG,gBAAgB,EAAE,SAAS,EAAW,GAAG,GACnH,CAKL,IAAK,IAAM,KAAO,EAAc,CAC9B,IAAM,EAAS,EACZ,EAAyC,GACzC,EAAiD,GAClD,GAAG,EAAK,GAAG,IACZ,CACD,GAAI,CAAC,EAAO,UACV,OAAO,EAIX,MAAO,CACL,UAAW,GACZ,CAKH,MAAO,CACL,UAAW,GACZ"}
1
+ {"version":3,"file":"verifyIdenticObjectFormat.cjs","names":[],"sources":["../../../src/utils/verifyIdenticObjectFormat.ts"],"sourcesContent":["type FlatType = string | number | boolean | object | null | undefined;\n\ntype RecursiveType =\n | FlatType\n | { [key: string]: RecursiveType }\n | Array<RecursiveType>;\n\ntype VerifyIdenticObjectFormatResult = {\n isIdentic: boolean;\n error?: string;\n};\n\n/**\n * Verifies that two objects have identical structure (same keys, array lengths, and types)\n * but not necessarily the same values.\n * Useful for validating translations maintain the same format as the original.\n *\n * @param object - The object to verify\n * @param expectedFormat - The expected format to compare against\n * @param path - Current path in the object tree (for error messages)\n * @returns true if structures match, throws error with details if they don't\n */\nexport const verifyIdenticObjectFormat = (\n object: RecursiveType,\n expectedFormat: RecursiveType,\n path: string = 'root'\n): VerifyIdenticObjectFormatResult => {\n // Check if both are null or undefined\n if (expectedFormat === null || expectedFormat === undefined) {\n if (expectedFormat !== object) {\n return {\n isIdentic: false,\n error: `Type mismatch at ${path}: expected ${expectedFormat === null ? 'null' : 'undefined'}, got ${object === null ? 'null' : typeof object}`,\n };\n }\n return {\n isIdentic: true,\n };\n }\n\n // Get the type of both values\n const expectedType = Array.isArray(expectedFormat)\n ? 'array'\n : typeof expectedFormat;\n const objectType = Array.isArray(object) ? 'array' : typeof object;\n\n // Check if types match\n if (expectedType !== objectType) {\n return {\n isIdentic: false,\n error: `Type mismatch at ${path}: expected ${expectedType}, got ${objectType}`,\n };\n }\n\n // Handle arrays\n if (Array.isArray(expectedFormat) && Array.isArray(object)) {\n if (expectedFormat.length !== object.length) {\n return {\n isIdentic: false,\n error: `Array length mismatch at ${path}: expected ${expectedFormat.length} elements, got ${object.length}`,\n };\n }\n\n // Recursively check each element\n for (let i = 0; i < expectedFormat.length; i++) {\n const result = verifyIdenticObjectFormat(\n object[i],\n expectedFormat[i],\n `${path}[${i}]`\n );\n if (!result.isIdentic) {\n return result;\n }\n }\n\n return {\n isIdentic: true,\n };\n }\n\n // Handle objects (excluding null and arrays)\n if (\n typeof expectedFormat === 'object' &&\n typeof object === 'object' &&\n expectedFormat !== null &&\n object !== null\n ) {\n const expectedKeys = Object.keys(expectedFormat);\n const objectKeys = Object.keys(object);\n\n // Check if number of keys match\n if (expectedKeys.length !== objectKeys.length) {\n return {\n isIdentic: false,\n error: `Object keys count mismatch at ${path}: expected ${expectedKeys.length} keys, got ${objectKeys.length}`,\n };\n }\n\n // Check if keys match and are in the same order\n for (let i = 0; i < expectedKeys.length; i++) {\n if (expectedKeys[i] !== objectKeys[i]) {\n return {\n isIdentic: false,\n error: `Object keys mismatch at ${path}: expected key \"${expectedKeys[i]}\" at position ${i}, got \"${objectKeys[i]}\"`,\n };\n }\n }\n\n // Recursively check each property\n for (const key of expectedKeys) {\n const result = verifyIdenticObjectFormat(\n (object as Record<string, RecursiveType>)[key],\n (expectedFormat as Record<string, RecursiveType>)[key],\n `${path}.${key}`\n );\n if (!result.isIdentic) {\n return result;\n }\n }\n\n return {\n isIdentic: true,\n };\n }\n\n // For primitive types (string, number, boolean), just verify they're the same type\n // We don't check the actual values as per requirements\n return {\n isIdentic: true,\n };\n};\n"],"mappings":";;;;;;;;;;;;;AAsBA,MAAa,6BACX,QACA,gBACA,OAAe,WACqB;AAEpC,KAAI,mBAAmB,QAAQ,mBAAmB,QAAW;AAC3D,MAAI,mBAAmB,OACrB,QAAO;GACL,WAAW;GACX,OAAO,oBAAoB,KAAK,aAAa,mBAAmB,OAAO,SAAS,YAAY,QAAQ,WAAW,OAAO,SAAS,OAAO;GACvI;AAEH,SAAO,EACL,WAAW,MACZ;;CAIH,MAAM,eAAe,MAAM,QAAQ,eAAe,GAC9C,UACA,OAAO;CACX,MAAM,aAAa,MAAM,QAAQ,OAAO,GAAG,UAAU,OAAO;AAG5D,KAAI,iBAAiB,WACnB,QAAO;EACL,WAAW;EACX,OAAO,oBAAoB,KAAK,aAAa,aAAa,QAAQ;EACnE;AAIH,KAAI,MAAM,QAAQ,eAAe,IAAI,MAAM,QAAQ,OAAO,EAAE;AAC1D,MAAI,eAAe,WAAW,OAAO,OACnC,QAAO;GACL,WAAW;GACX,OAAO,4BAA4B,KAAK,aAAa,eAAe,OAAO,iBAAiB,OAAO;GACpG;AAIH,OAAK,IAAI,IAAI,GAAG,IAAI,eAAe,QAAQ,KAAK;GAC9C,MAAM,SAAS,0BACb,OAAO,IACP,eAAe,IACf,GAAG,KAAK,GAAG,EAAE,GACd;AACD,OAAI,CAAC,OAAO,UACV,QAAO;;AAIX,SAAO,EACL,WAAW,MACZ;;AAIH,KACE,OAAO,mBAAmB,YAC1B,OAAO,WAAW,YAClB,mBAAmB,QACnB,WAAW,MACX;EACA,MAAM,eAAe,OAAO,KAAK,eAAe;EAChD,MAAM,aAAa,OAAO,KAAK,OAAO;AAGtC,MAAI,aAAa,WAAW,WAAW,OACrC,QAAO;GACL,WAAW;GACX,OAAO,iCAAiC,KAAK,aAAa,aAAa,OAAO,aAAa,WAAW;GACvG;AAIH,OAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,IACvC,KAAI,aAAa,OAAO,WAAW,GACjC,QAAO;GACL,WAAW;GACX,OAAO,2BAA2B,KAAK,kBAAkB,aAAa,GAAG,gBAAgB,EAAE,SAAS,WAAW,GAAG;GACnH;AAKL,OAAK,MAAM,OAAO,cAAc;GAC9B,MAAM,SAAS,0BACZ,OAAyC,MACzC,eAAiD,MAClD,GAAG,KAAK,GAAG,MACZ;AACD,OAAI,CAAC,OAAO,UACV,QAAO;;AAIX,SAAO,EACL,WAAW,MACZ;;AAKH,QAAO,EACL,WAAW,MACZ"}
@@ -1,2 +1,121 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./chunk-Bmb41Sf3.cjs`);const e=require(`./handleContentDeclarationFileChange.cjs`),t=require(`./handleContentDeclarationFileMoved.cjs`),n=require(`./handleAdditionalContentDeclarationFile.cjs`),r=require(`./handleUnlinkedContentDeclarationFile.cjs`),i=require(`./prepareIntlayer.cjs`),a=require(`./writeContentDeclaration/writeContentDeclaration.cjs`);require(`./writeContentDeclaration/index.cjs`);let o=require(`node:fs/promises`),s=require(`node:path`),c=require(`@intlayer/config/logger`),l=require(`@intlayer/config/node`),u=require(`@intlayer/config/utils`),d=require(`chokidar`);const f=new Map;let p=Promise.resolve();const m=e=>{p=p.then(async()=>{try{await e()}catch(e){console.error(e)}})},h=p=>{let h=(0,l.getConfigurationAndFilePath)(p?.configOptions),g=h.configurationFilePath,_=p?.configuration??h.configuration,v=(0,c.getAppLogger)(_),{watch:y,fileExtensions:b,contentDir:x}=_.content,S=[...b.flatMap(e=>x.map(t=>`${(0,u.normalizePath)(t)}/**/*${e}`.replace(`//`,`/`))),...g?[g]:[]];if(_.content.watch)return v(`Watching Intlayer content declarations`),(0,d.watch)(S,{persistent:y,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:1e3,pollInterval:100},ignored:[`**/node_modules/**`,`**/dist/**`,`**/build/**`,`**/.intlayer/**`],...p}).on(`add`,async e=>{let r=(0,s.basename)(e),i=!1,c;for(let[e]of f)if((0,s.basename)(e)===r){c=e;break}if(!c&&f.size===1&&(c=f.keys().next().value),c){let t=f.get(c);t&&(clearTimeout(t.timer),f.delete(c)),i=!0,v(`File moved from ${c} to ${e}`)}m(async()=>{if(i&&c)await t.handleContentDeclarationFileMoved(c,e,_);else{if(await(0,o.readFile)(e,`utf-8`)===``){let t=b.map(e=>e.replace(/\./g,`\\.`)).join(`|`);await a.writeContentDeclaration({key:r.replace(RegExp(`(${t})$`),``),content:{},filePath:e},_)}await n.handleAdditionalContentDeclarationFile(e,_)}})}).on(`change`,async t=>m(async()=>{if(g&&t===g){v(`Configuration file changed, repreparing Intlayer`),(0,u.clearModuleCache)(g),(0,u.clearAllCache)();let{configuration:e}=(0,l.getConfigurationAndFilePath)(p?.configOptions);_=p?.configuration??e,await i.prepareIntlayer(_,{clean:!1})}else await e.handleContentDeclarationFileChange(t,_)})).on(`unlink`,async e=>{let t=setTimeout(async()=>{f.delete(e),m(async()=>r.handleUnlinkedContentDeclarationFile(e,_))},200);f.set(e,{timer:t,oldPath:e})}).on(`error`,async e=>{v(`Watcher error: ${e}`,{level:`error`}),v(`Restarting watcher`),await i.prepareIntlayer(_)})},g=async e=>{let{skipPrepare:t,...n}=e??{},r=e?.configuration??(0,l.getConfiguration)(e?.configOptions);t||await i.prepareIntlayer(r,{forceRun:!0}),(r.content.watch||e?.persistent)&&h({...n,configuration:r})};exports.buildAndWatchIntlayer=g,exports.watch=h;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
+ const require_handleContentDeclarationFileChange = require('./handleContentDeclarationFileChange.cjs');
4
+ const require_handleContentDeclarationFileMoved = require('./handleContentDeclarationFileMoved.cjs');
5
+ const require_handleAdditionalContentDeclarationFile = require('./handleAdditionalContentDeclarationFile.cjs');
6
+ const require_handleUnlinkedContentDeclarationFile = require('./handleUnlinkedContentDeclarationFile.cjs');
7
+ const require_prepareIntlayer = require('./prepareIntlayer.cjs');
8
+ const require_writeContentDeclaration_writeContentDeclaration = require('./writeContentDeclaration/writeContentDeclaration.cjs');
9
+ let node_fs_promises = require("node:fs/promises");
10
+ let node_path = require("node:path");
11
+ let _intlayer_config_logger = require("@intlayer/config/logger");
12
+ let _intlayer_config_node = require("@intlayer/config/node");
13
+ let _intlayer_config_utils = require("@intlayer/config/utils");
14
+ let chokidar = require("chokidar");
15
+
16
+ //#region src/watcher.ts
17
+ /** @ts-ignore remove error Module '"chokidar"' has no exported member 'ChokidarOptions' */
18
+ const pendingUnlinks = /* @__PURE__ */ new Map();
19
+ let processingQueue = Promise.resolve();
20
+ const processEvent = (task) => {
21
+ processingQueue = processingQueue.then(async () => {
22
+ try {
23
+ await task();
24
+ } catch (error) {
25
+ console.error(error);
26
+ }
27
+ });
28
+ };
29
+ const watch = (options) => {
30
+ const configResult = (0, _intlayer_config_node.getConfigurationAndFilePath)(options?.configOptions);
31
+ const configurationFilePath = configResult.configurationFilePath;
32
+ let configuration = options?.configuration ?? configResult.configuration;
33
+ const appLogger = (0, _intlayer_config_logger.getAppLogger)(configuration);
34
+ const { watch: isWatchMode, fileExtensions, contentDir } = configuration.content;
35
+ const pathsToWatch = [...fileExtensions.flatMap((ext) => contentDir.map((dir) => `${(0, _intlayer_config_utils.normalizePath)(dir)}/**/*${ext}`.replace("//", "/"))), ...configurationFilePath ? [configurationFilePath] : []];
36
+ if (!configuration.content.watch) return;
37
+ appLogger("Watching Intlayer content declarations");
38
+ return (0, chokidar.watch)(pathsToWatch, {
39
+ persistent: isWatchMode,
40
+ ignoreInitial: true,
41
+ awaitWriteFinish: {
42
+ stabilityThreshold: 1e3,
43
+ pollInterval: 100
44
+ },
45
+ ignored: [
46
+ "**/node_modules/**",
47
+ "**/dist/**",
48
+ "**/build/**",
49
+ "**/.intlayer/**"
50
+ ],
51
+ ...options
52
+ }).on("add", async (filePath) => {
53
+ const fileName = (0, node_path.basename)(filePath);
54
+ let isMove = false;
55
+ let matchedOldPath;
56
+ for (const [oldPath] of pendingUnlinks) if ((0, node_path.basename)(oldPath) === fileName) {
57
+ matchedOldPath = oldPath;
58
+ break;
59
+ }
60
+ if (!matchedOldPath && pendingUnlinks.size === 1) matchedOldPath = pendingUnlinks.keys().next().value;
61
+ if (matchedOldPath) {
62
+ const pending = pendingUnlinks.get(matchedOldPath);
63
+ if (pending) {
64
+ clearTimeout(pending.timer);
65
+ pendingUnlinks.delete(matchedOldPath);
66
+ }
67
+ isMove = true;
68
+ appLogger(`File moved from ${matchedOldPath} to ${filePath}`);
69
+ }
70
+ processEvent(async () => {
71
+ if (isMove && matchedOldPath) await require_handleContentDeclarationFileMoved.handleContentDeclarationFileMoved(matchedOldPath, filePath, configuration);
72
+ else {
73
+ if (await (0, node_fs_promises.readFile)(filePath, "utf-8") === "") {
74
+ const extensionPattern = fileExtensions.map((ext) => ext.replace(/\./g, "\\.")).join("|");
75
+ await require_writeContentDeclaration_writeContentDeclaration.writeContentDeclaration({
76
+ key: fileName.replace(new RegExp(`(${extensionPattern})$`), ""),
77
+ content: {},
78
+ filePath
79
+ }, configuration);
80
+ }
81
+ await require_handleAdditionalContentDeclarationFile.handleAdditionalContentDeclarationFile(filePath, configuration);
82
+ }
83
+ });
84
+ }).on("change", async (filePath) => processEvent(async () => {
85
+ if (configurationFilePath && filePath === configurationFilePath) {
86
+ appLogger("Configuration file changed, repreparing Intlayer");
87
+ (0, _intlayer_config_utils.clearModuleCache)(configurationFilePath);
88
+ (0, _intlayer_config_utils.clearAllCache)();
89
+ const { configuration: newConfiguration } = (0, _intlayer_config_node.getConfigurationAndFilePath)(options?.configOptions);
90
+ configuration = options?.configuration ?? newConfiguration;
91
+ await require_prepareIntlayer.prepareIntlayer(configuration, { clean: false });
92
+ } else await require_handleContentDeclarationFileChange.handleContentDeclarationFileChange(filePath, configuration);
93
+ })).on("unlink", async (filePath) => {
94
+ const timer = setTimeout(async () => {
95
+ pendingUnlinks.delete(filePath);
96
+ processEvent(async () => require_handleUnlinkedContentDeclarationFile.handleUnlinkedContentDeclarationFile(filePath, configuration));
97
+ }, 200);
98
+ pendingUnlinks.set(filePath, {
99
+ timer,
100
+ oldPath: filePath
101
+ });
102
+ }).on("error", async (error) => {
103
+ appLogger(`Watcher error: ${error}`, { level: "error" });
104
+ appLogger("Restarting watcher");
105
+ await require_prepareIntlayer.prepareIntlayer(configuration);
106
+ });
107
+ };
108
+ const buildAndWatchIntlayer = async (options) => {
109
+ const { skipPrepare, ...rest } = options ?? {};
110
+ const configuration = options?.configuration ?? (0, _intlayer_config_node.getConfiguration)(options?.configOptions);
111
+ if (!skipPrepare) await require_prepareIntlayer.prepareIntlayer(configuration, { forceRun: true });
112
+ if (configuration.content.watch || options?.persistent) watch({
113
+ ...rest,
114
+ configuration
115
+ });
116
+ };
117
+
118
+ //#endregion
119
+ exports.buildAndWatchIntlayer = buildAndWatchIntlayer;
120
+ exports.watch = watch;
2
121
  //# sourceMappingURL=watcher.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"watcher.cjs","names":["handleContentDeclarationFileMoved","writeContentDeclaration","handleAdditionalContentDeclarationFile","prepareIntlayer","handleContentDeclarationFileChange","handleUnlinkedContentDeclarationFile"],"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.cjs","names":["handleContentDeclarationFileMoved","writeContentDeclaration","handleAdditionalContentDeclarationFile","prepareIntlayer","handleContentDeclarationFileChange","handleUnlinkedContentDeclarationFile"],"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,2 +1,43 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);const e=require(`../writeJsonIfChanged.cjs`);let t=require(`node:fs/promises`),n=require(`node:path`),r=require(`node:util`);const i=async e=>{let r=await(0,t.readFile)((0,n.join)(e.system.configDir,`configuration.json`),`utf8`);return JSON.parse(r)},a=async e=>{let t=o(e);return(0,r.isDeepStrictEqual)(await i(e),t)},o=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})),s=async r=>{let{system:i}=r,{configDir:a}=i;await(0,t.mkdir)(a,{recursive:!0}),await e.writeJsonIfChanged((0,n.join)(a,`configuration.json`),o(r))};exports.isCachedConfigurationUpToDate=a,exports.writeConfiguration=s;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_writeJsonIfChanged = require('../writeJsonIfChanged.cjs');
4
+ let node_fs_promises = require("node:fs/promises");
5
+ let node_path = require("node:path");
6
+ let node_util = require("node:util");
7
+
8
+ //#region src/writeConfiguration/index.ts
9
+ const getCachedConfiguration = async (configuration) => {
10
+ const configurationContent = await (0, node_fs_promises.readFile)((0, node_path.join)(configuration.system.configDir, "configuration.json"), "utf8");
11
+ return JSON.parse(configurationContent);
12
+ };
13
+ const isCachedConfigurationUpToDate = async (configuration) => {
14
+ try {
15
+ const cleanedConfiguration = cleanConfiguration(configuration);
16
+ return (0, node_util.isDeepStrictEqual)(await getCachedConfiguration(configuration), cleanedConfiguration);
17
+ } catch {
18
+ return null;
19
+ }
20
+ };
21
+ const cleanConfiguration = (configuration) => {
22
+ return JSON.parse(JSON.stringify({
23
+ internationalization: {
24
+ locales: configuration.internationalization.locales,
25
+ defaultLocale: configuration.internationalization.defaultLocale
26
+ },
27
+ editor: configuration.editor,
28
+ log: configuration.log,
29
+ routing: configuration.routing,
30
+ metadata: configuration.metadata
31
+ }));
32
+ };
33
+ const writeConfiguration = async (configuration) => {
34
+ const { system } = configuration;
35
+ const { configDir } = system;
36
+ await (0, node_fs_promises.mkdir)(configDir, { recursive: true });
37
+ await require_writeJsonIfChanged.writeJsonIfChanged((0, node_path.join)(configDir, "configuration.json"), cleanConfiguration(configuration));
38
+ };
39
+
40
+ //#endregion
41
+ exports.isCachedConfigurationUpToDate = isCachedConfigurationUpToDate;
42
+ exports.writeConfiguration = writeConfiguration;
2
43
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["writeJsonIfChanged"],"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":"iOASA,MAAM,EAAyB,KAAO,IAAkC,CAMtE,IAAM,EAAuB,MAAA,EAAA,EAAA,WAAA,EAAA,EAAA,MAJ3B,EAAc,OAAO,UACrB,qBACD,CAE2D,OAAO,CACnE,OAAO,KAAK,MAAM,EAAqB,EAG5B,EAAgC,KAC3C,IAC4B,CAC5B,IAAM,EAAuB,EAAmB,EAAc,CAQ9D,OAAA,EAAA,EAAA,mBAP4B,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,MAAA,EAAA,EAAA,OAAY,EAAW,CAAE,UAAW,GAAM,CAAC,CAM3C,MAAMA,EAAAA,oBAAAA,EAAAA,EAAAA,MAJsB,EAAW,qBAAqB,CAE/B,EAAmB,EAAc,CAEA"}
1
+ {"version":3,"file":"index.cjs","names":["writeJsonIfChanged"],"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,yDAJ3B,cAAc,OAAO,WACrB,qBACD,EAE2D,OAAO;AACnE,QAAO,KAAK,MAAM,qBAAqB;;AAGzC,MAAa,gCAAgC,OAC3C,kBAC4B;AAC5B,KAAI;EACF,MAAM,uBAAuB,mBAAmB,cAAc;AAQ9D,0CAP4B,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,mCAAY,WAAW,EAAE,WAAW,MAAM,CAAC;AAM3C,OAAMA,kEAJsB,WAAW,qBAAqB,EAE/B,mBAAmB,cAAc,CAEA"}
@@ -1,2 +1,29 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});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};exports.detectExportedComponentName=e;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ //#region src/writeContentDeclaration/detectExportedComponentName.ts
4
+ /**
5
+ * Attempt to detect an exported React component name in the file text.
6
+ * Looks for patterns like:
7
+ * - export const MyComponent = ...
8
+ * - export function MyComponent(...)
9
+ * - export default function MyComponent(...)
10
+ */
11
+ const detectExportedComponentName = (fileText) => {
12
+ const defaultEsmFnRegex = /export\s+default\s+function\s+(\w+)/;
13
+ const defaultEsmVarRegex = /export\s+default\s+(\w+)/;
14
+ const cjsDefaultRegex = /module\.exports\s*=\s*(\w+)/;
15
+ const cjsDefaultVarRegex = /exports\.default\s*=\s*(\w+)/;
16
+ const namedExportRegex = /export\s+(?:const|function)\s+(\w+)/g;
17
+ const defaultEsmFnMatch = fileText.match(defaultEsmFnRegex);
18
+ if (defaultEsmFnMatch) return defaultEsmFnMatch[1];
19
+ const defaultEsmVarMatch = fileText.match(defaultEsmVarRegex);
20
+ if (defaultEsmVarMatch) return defaultEsmVarMatch[1];
21
+ const cjsDefaultMatch = fileText.match(cjsDefaultRegex) || fileText.match(cjsDefaultVarRegex);
22
+ if (cjsDefaultMatch) return cjsDefaultMatch[1];
23
+ for (const match of fileText.matchAll(namedExportRegex)) if (/^[A-Z]/.test(match[1])) return match[1];
24
+ return null;
25
+ };
26
+
27
+ //#endregion
28
+ exports.detectExportedComponentName = detectExportedComponentName;
2
29
  //# sourceMappingURL=detectExportedComponentName.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"detectExportedComponentName.cjs","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":"mEAOA,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.cjs","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,10 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./detectExportedComponentName.cjs`),t=require(`./transformJSFile.cjs`),n=require(`./writeJSFile.cjs`),r=require(`./writeContentDeclaration.cjs`);exports.detectExportedComponentName=e.detectExportedComponentName,exports.transformJSFile=t.transformJSFile,exports.writeContentDeclaration=r.writeContentDeclaration,exports.writeJSFile=n.writeJSFile;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_writeContentDeclaration_detectExportedComponentName = require('./detectExportedComponentName.cjs');
3
+ const require_writeContentDeclaration_transformJSFile = require('./transformJSFile.cjs');
4
+ const require_writeContentDeclaration_writeJSFile = require('./writeJSFile.cjs');
5
+ const require_writeContentDeclaration_writeContentDeclaration = require('./writeContentDeclaration.cjs');
6
+
7
+ exports.detectExportedComponentName = require_writeContentDeclaration_detectExportedComponentName.detectExportedComponentName;
8
+ exports.transformJSFile = require_writeContentDeclaration_transformJSFile.transformJSFile;
9
+ exports.writeContentDeclaration = require_writeContentDeclaration_writeContentDeclaration.writeContentDeclaration;
10
+ exports.writeJSFile = require_writeContentDeclaration_writeJSFile.writeJSFile;
@@ -1,2 +1,95 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);let e=require(`node:path`),t=require(`@intlayer/config/logger`),n=require(`node:fs`),r=require(`@intlayer/core/interpreter`),i=require(`@intlayer/types/nodeType`);const a={id:`write-file-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===i.NodeType.File,transform:r=>{let a=r.content,o=r.fixedPath;if(typeof a!=`string`)throw Error(`File content must be a string`);if(typeof o!=`string`)throw Error(`File path must be a string`);try{let t=(0,e.join)(process.cwd(),o),r=(0,e.dirname)(t);(0,n.existsSync)(r)||(0,n.mkdirSync)(r,{recursive:!0}),(0,n.writeFileSync)(t,a)}catch(e){throw Error(`${t.x} Error writing file to ${(0,t.colorizePath)(o)}: ${e}`)}return{nodeType:i.NodeType.File,[i.NodeType.File]:r.file}}},o={id:`markdown-file-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===i.NodeType.Markdown,transform:(e,t,n)=>({nodeType:i.NodeType.Markdown,[i.NodeType.Markdown]:n(e.markdown,t)})},s={id:`insertion-file-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===i.NodeType.Insertion,transform:(e,t,n)=>({nodeType:i.NodeType.Insertion,[i.NodeType.Insertion]:n(e.insertion,t)})},c={id:`html-file-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===i.NodeType.HTML,transform:(e,t,n)=>({nodeType:i.NodeType.HTML,[i.NodeType.HTML]:n(e.html,t)})},l=async e=>(0,r.deepTransformNode)(e,{dictionaryKey:e.key,keyPath:[],plugins:[a,o,s,c]});exports.processContentDeclarationContent=l;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let node_path = require("node:path");
4
+ let _intlayer_config_logger = require("@intlayer/config/logger");
5
+ let node_fs = require("node:fs");
6
+ let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
7
+ let _intlayer_types_nodeType = require("@intlayer/types/nodeType");
8
+ _intlayer_types_nodeType = require_runtime.__toESM(_intlayer_types_nodeType);
9
+
10
+ //#region src/writeContentDeclaration/processContentDeclarationContent.ts
11
+ /**
12
+ * Write file plugin
13
+ */
14
+ const writeFilePlugin = {
15
+ id: "write-file-plugin",
16
+ canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.FILE,
17
+ transform: (node) => {
18
+ const fileContent = node.content;
19
+ const filePath = node.fixedPath;
20
+ if (typeof fileContent !== "string") throw new Error("File content must be a string");
21
+ if (typeof filePath !== "string") throw new Error("File path must be a string");
22
+ try {
23
+ const absoluteFilePath = (0, node_path.join)(process.cwd(), filePath);
24
+ const fileDirectory = (0, node_path.dirname)(absoluteFilePath);
25
+ if (!(0, node_fs.existsSync)(fileDirectory)) (0, node_fs.mkdirSync)(fileDirectory, { recursive: true });
26
+ (0, node_fs.writeFileSync)(absoluteFilePath, fileContent);
27
+ } catch (error) {
28
+ throw new Error(`${_intlayer_config_logger.x} Error writing file to ${(0, _intlayer_config_logger.colorizePath)(filePath)}: ${error}`);
29
+ }
30
+ return {
31
+ nodeType: _intlayer_types_nodeType.FILE,
32
+ [_intlayer_types_nodeType.FILE]: node[_intlayer_types_nodeType.FILE]
33
+ };
34
+ }
35
+ };
36
+ /**
37
+ * Markdown file plugin
38
+ */
39
+ const markdownFilePlugin = {
40
+ id: "markdown-file-plugin",
41
+ canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.MARKDOWN,
42
+ transform: (node, props, deepTransformNode) => {
43
+ return {
44
+ nodeType: _intlayer_types_nodeType.MARKDOWN,
45
+ [_intlayer_types_nodeType.MARKDOWN]: deepTransformNode(node[_intlayer_types_nodeType.MARKDOWN], props)
46
+ };
47
+ }
48
+ };
49
+ /**
50
+ * Insertion file plugin
51
+ */
52
+ const insertionFilePlugin = {
53
+ id: "insertion-file-plugin",
54
+ canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.INSERTION,
55
+ transform: (node, props, deepTransformNode) => {
56
+ return {
57
+ nodeType: _intlayer_types_nodeType.INSERTION,
58
+ [_intlayer_types_nodeType.INSERTION]: deepTransformNode(node[_intlayer_types_nodeType.INSERTION], props)
59
+ };
60
+ }
61
+ };
62
+ /**
63
+ * HTML file plugin
64
+ */
65
+ const htmlFilePlugin = {
66
+ id: "html-file-plugin",
67
+ canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.HTML,
68
+ transform: (node, props, deepTransformNode) => {
69
+ return {
70
+ nodeType: _intlayer_types_nodeType.HTML,
71
+ [_intlayer_types_nodeType.HTML]: deepTransformNode(node[_intlayer_types_nodeType.HTML], props)
72
+ };
73
+ }
74
+ };
75
+ /**
76
+ * Process content declaration content
77
+ *
78
+ * It filter node that are autogenerated by intlayer to do not rewrite them in the content declaration file.
79
+ *
80
+ * And write external sources as file content if necessary.
81
+ */
82
+ const processContentDeclarationContent = async (dictionary) => (0, _intlayer_core_interpreter.deepTransformNode)(dictionary, {
83
+ dictionaryKey: dictionary.key,
84
+ keyPath: [],
85
+ plugins: [
86
+ writeFilePlugin,
87
+ markdownFilePlugin,
88
+ insertionFilePlugin,
89
+ htmlFilePlugin
90
+ ]
91
+ });
92
+
93
+ //#endregion
94
+ exports.processContentDeclarationContent = processContentDeclarationContent;
2
95
  //# sourceMappingURL=processContentDeclarationContent.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"processContentDeclarationContent.cjs","names":["NodeType","x"],"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":"uQAqBA,MAAM,EAA2B,CAC/B,GAAI,oBACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAaA,EAAAA,SAAS,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,GAAA,EAAA,EAAA,MAAwB,QAAQ,KAAK,CAAE,EAAS,CAGhD,GAAA,EAAA,EAAA,SAAwB,EAAiB,EAE3C,EAAA,EAAA,YAAY,EAAc,GAC5B,EAAA,EAAA,WAAU,EAAe,CAAE,UAAW,GAAM,CAAC,EAI/C,EAAA,EAAA,eAAc,EAAkB,EAAY,OACrC,EAAO,CACd,MAAU,MACR,GAAGC,EAAAA,EAAE,0BAAA,EAAA,EAAA,cAAsC,EAAS,CAAC,IAAI,IAC1D,CAQH,MALuD,CACrD,SAAUD,EAAAA,SAAS,MAClBA,EAAAA,SAAS,MAAO,EAAK,KACvB,EAIJ,CAMK,EAA8B,CAClC,GAAI,uBACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAaA,EAAAA,SAAS,SAC1D,WAAY,EAAuB,EAAO,KACmB,CACzD,SAAUA,EAAAA,SAAS,UAClBA,EAAAA,SAAS,UAAW,EAAkB,EAAK,SAAU,EAAM,CAC7D,EAIJ,CAMK,EAA+B,CACnC,GAAI,wBACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAaA,EAAAA,SAAS,UAC1D,WAAY,EAAwB,EAAO,KACoB,CAC3D,SAAUA,EAAAA,SAAS,WAClBA,EAAAA,SAAS,WAAY,EAAkB,EAAK,UAAW,EAAM,CAC/D,EAIJ,CAMK,EAA0B,CAC9B,GAAI,mBACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAaA,EAAAA,SAAS,KAC1D,WAAY,EAAmB,EAAO,KACe,CACjD,SAAUA,EAAAA,SAAS,MAClBA,EAAAA,SAAS,MAAO,EAAkB,EAAK,KAAM,EAAM,CACrD,EAIJ,CASY,EAAmC,KAC9C,KAAA,EAAA,EAAA,mBAEkB,EAAY,CAC5B,cAAe,EAAW,IAC1B,QAAS,EAAE,CACX,QAAS,CACP,EACA,EACA,EACA,EACD,CACF,CAAC"}
1
+ {"version":3,"file":"processContentDeclarationContent.cjs","names":["NodeTypes","x"],"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,aAAaA,yBAAU;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,uCAAwB,QAAQ,KAAK,EAAE,SAAS;GAGtD,MAAM,uCAAwB,iBAAiB;AAE/C,OAAI,yBAAY,cAAc,CAC5B,wBAAU,eAAe,EAAE,WAAW,MAAM,CAAC;AAI/C,8BAAc,kBAAkB,YAAY;WACrC,OAAO;AACd,SAAM,IAAI,MACR,GAAGC,0BAAE,mEAAsC,SAAS,CAAC,IAAI,QAC1D;;AAQH,SALuD;GACrD,UAAUD,yBAAU;IACnBA,yBAAU,OAAO,KAAKA,yBAAU;GAClC;;CAIJ;;;;AAMD,MAAM,qBAA8B;CAClC,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAaA,yBAAU;CAC3D,YAAY,MAAuB,OAAO,sBAAsB;AAM9D,SAL2D;GACzD,UAAUA,yBAAU;IACnBA,yBAAU,WAAW,kBAAkB,KAAKA,yBAAU,WAAW,MAAM;GACzE;;CAIJ;;;;AAMD,MAAM,sBAA+B;CACnC,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAaA,yBAAU;CAC3D,YAAY,MAAwB,OAAO,sBAAsB;AAS/D,SAR6D;GAC3D,UAAUA,yBAAU;IACnBA,yBAAU,YAAY,kBACrB,KAAKA,yBAAU,YACf,MACD;GACF;;CAIJ;;;;AAMD,MAAM,iBAA0B;CAC9B,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAaA,yBAAU;CAC3D,YAAY,MAAmB,OAAO,sBAAsB;AAM1D,SALmD;GACjD,UAAUA,yBAAU;IACnBA,yBAAU,OAAO,kBAAkB,KAAKA,yBAAU,OAAO,MAAM;GACjE;;CAIJ;;;;;;;;AASD,MAAa,mCAAmC,OAC9C,iEAEkB,YAAY;CAC5B,eAAe,WAAW;CAC1B,SAAS,EAAE;CACX,SAAS;EACP;EACA;EACA;EACA;EACD;CACF,CAAC"}