@intlayer/chokidar 8.4.4 → 8.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (497) hide show
  1. package/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -0
  2. package/dist/cjs/_virtual/_utils_asset.cjs +98 -0
  3. package/dist/cjs/build.cjs +58 -1
  4. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs +62 -1
  5. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs.map +1 -1
  6. package/dist/cjs/buildIntlayerDictionary/index.cjs +6 -1
  7. package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs +26 -1
  8. package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs.map +1 -1
  9. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +107 -5
  10. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -1
  11. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs +80 -3
  12. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs.map +1 -1
  13. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs +46 -1
  14. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs.map +1 -1
  15. package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs +50 -1
  16. package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs.map +1 -1
  17. package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs +59 -1
  18. package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs.map +1 -1
  19. package/dist/cjs/cleanOutputDir.cjs +30 -1
  20. package/dist/cjs/cleanOutputDir.cjs.map +1 -1
  21. package/dist/cjs/cleanRemovedContentDeclaration.cjs +97 -1
  22. package/dist/cjs/cleanRemovedContentDeclaration.cjs.map +1 -1
  23. package/dist/cjs/cli.cjs +35 -1
  24. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs +70 -1
  25. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs.map +1 -1
  26. package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs +42 -7
  27. package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs.map +1 -1
  28. package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs +23 -1
  29. package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs.map +1 -1
  30. package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs +24 -1
  31. package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs.map +1 -1
  32. package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs +24 -1
  33. package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs.map +1 -1
  34. package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs +23 -1
  35. package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs.map +1 -1
  36. package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs +23 -1
  37. package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs.map +1 -1
  38. package/dist/cjs/createDictionaryEntryPoint/index.cjs +16 -1
  39. package/dist/cjs/createType/createModuleAugmentation.cjs +112 -9
  40. package/dist/cjs/createType/createModuleAugmentation.cjs.map +1 -1
  41. package/dist/cjs/createType/createType.cjs +29 -1
  42. package/dist/cjs/createType/createType.cjs.map +1 -1
  43. package/dist/cjs/createType/index.cjs +8 -1
  44. package/dist/cjs/detectFormatCommand.cjs +32 -1
  45. package/dist/cjs/detectFormatCommand.cjs.map +1 -1
  46. package/dist/cjs/fetchDistantDictionaries.cjs +51 -1
  47. package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
  48. package/dist/cjs/filterInvalidDictionaries.cjs +52 -1
  49. package/dist/cjs/filterInvalidDictionaries.cjs.map +1 -1
  50. package/dist/cjs/formatDictionary.cjs +49 -1
  51. package/dist/cjs/formatDictionary.cjs.map +1 -1
  52. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +61 -7
  53. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -1
  54. package/dist/cjs/getContentDeclarationFileTemplate/index.cjs +4 -1
  55. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs +34 -1
  56. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs.map +1 -1
  57. package/dist/cjs/handleContentDeclarationFileChange.cjs +49 -1
  58. package/dist/cjs/handleContentDeclarationFileChange.cjs.map +1 -1
  59. package/dist/cjs/handleContentDeclarationFileMoved.cjs +24 -1
  60. package/dist/cjs/handleContentDeclarationFileMoved.cjs.map +1 -1
  61. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs +37 -1
  62. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs.map +1 -1
  63. package/dist/cjs/init/index.cjs +284 -1
  64. package/dist/cjs/init/index.cjs.map +1 -1
  65. package/dist/cjs/init/utils/configManipulation.cjs +111 -1
  66. package/dist/cjs/init/utils/configManipulation.cjs.map +1 -1
  67. package/dist/cjs/init/utils/fileSystem.cjs +39 -1
  68. package/dist/cjs/init/utils/fileSystem.cjs.map +1 -1
  69. package/dist/cjs/init/utils/index.cjs +14 -1
  70. package/dist/cjs/init/utils/jsonParser.cjs +42 -3
  71. package/dist/cjs/init/utils/jsonParser.cjs.map +1 -1
  72. package/dist/cjs/init/utils/tsConfig.cjs +18 -1
  73. package/dist/cjs/init/utils/tsConfig.cjs.map +1 -1
  74. package/dist/cjs/initConfig/index.cjs +39 -1
  75. package/dist/cjs/initConfig/index.cjs.map +1 -1
  76. package/dist/cjs/installMCP/installMCP.cjs +50 -1
  77. package/dist/cjs/installMCP/installMCP.cjs.map +1 -1
  78. package/dist/cjs/installSkills/index.cjs +303 -1
  79. package/dist/cjs/installSkills/index.cjs.map +1 -1
  80. package/dist/cjs/listDictionariesPath.cjs +42 -1
  81. package/dist/cjs/listDictionariesPath.cjs.map +1 -1
  82. package/dist/cjs/listGitFiles.cjs +105 -5
  83. package/dist/cjs/listGitFiles.cjs.map +1 -1
  84. package/dist/cjs/listProjects.cjs +47 -1
  85. package/dist/cjs/listProjects.cjs.map +1 -1
  86. package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs +68 -1
  87. package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs.map +1 -1
  88. package/dist/cjs/loadDictionaries/index.cjs +14 -1
  89. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +93 -2
  90. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -1
  91. package/dist/cjs/loadDictionaries/loadDictionaries.cjs +127 -1
  92. package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
  93. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs +27 -1
  94. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs.map +1 -1
  95. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +61 -1
  96. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
  97. package/dist/cjs/loadDictionaries/log.cjs +138 -3
  98. package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
  99. package/dist/cjs/loadDictionaries/logTypeScriptErrors.cjs +63 -2
  100. package/dist/cjs/loadDictionaries/logTypeScriptErrors.cjs.map +1 -1
  101. package/dist/cjs/logConfigDetails.cjs +39 -2
  102. package/dist/cjs/logConfigDetails.cjs.map +1 -1
  103. package/dist/cjs/prepareIntlayer.cjs +103 -1
  104. package/dist/cjs/prepareIntlayer.cjs.map +1 -1
  105. package/dist/cjs/reduceDictionaryContent/applyMask.cjs +30 -1
  106. package/dist/cjs/reduceDictionaryContent/applyMask.cjs.map +1 -1
  107. package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs +12 -1
  108. package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs.map +1 -1
  109. package/dist/cjs/utils/autoDecorateContent.cjs +89 -1
  110. package/dist/cjs/utils/autoDecorateContent.cjs.map +1 -1
  111. package/dist/cjs/utils/buildComponentFilesList.cjs +67 -1
  112. package/dist/cjs/utils/buildComponentFilesList.cjs.map +1 -1
  113. package/dist/cjs/utils/buildFilesList.cjs +83 -1
  114. package/dist/cjs/utils/buildFilesList.cjs.map +1 -1
  115. package/dist/cjs/utils/chunkJSON.cjs +336 -1
  116. package/dist/cjs/utils/chunkJSON.cjs.map +1 -1
  117. package/dist/cjs/utils/formatter.cjs +18 -1
  118. package/dist/cjs/utils/formatter.cjs.map +1 -1
  119. package/dist/cjs/utils/getChunk.cjs +34 -1
  120. package/dist/cjs/utils/getChunk.cjs.map +1 -1
  121. package/dist/cjs/utils/getContentExtension.cjs +29 -1
  122. package/dist/cjs/utils/getContentExtension.cjs.map +1 -1
  123. package/dist/cjs/utils/getFormatFromExtension.cjs +34 -1
  124. package/dist/cjs/utils/getFormatFromExtension.cjs.map +1 -1
  125. package/dist/cjs/utils/getPathHash.cjs +10 -1
  126. package/dist/cjs/utils/getPathHash.cjs.map +1 -1
  127. package/dist/cjs/utils/index.cjs +49 -1
  128. package/dist/cjs/utils/mergeChunks.cjs +28 -1
  129. package/dist/cjs/utils/mergeChunks.cjs.map +1 -1
  130. package/dist/cjs/utils/pLimit.cjs +128 -1
  131. package/dist/cjs/utils/pLimit.cjs.map +1 -1
  132. package/dist/cjs/utils/parallelize.cjs +11 -1
  133. package/dist/cjs/utils/parallelize.cjs.map +1 -1
  134. package/dist/cjs/utils/parallelizeGlobal.cjs +29 -1
  135. package/dist/cjs/utils/parallelizeGlobal.cjs.map +1 -1
  136. package/dist/cjs/utils/reduceObjectFormat.cjs +31 -1
  137. package/dist/cjs/utils/reduceObjectFormat.cjs.map +1 -1
  138. package/dist/cjs/utils/resolveObjectPromises.cjs +21 -1
  139. package/dist/cjs/utils/resolveObjectPromises.cjs.map +1 -1
  140. package/dist/cjs/utils/resolveRelativePath.cjs +21 -1
  141. package/dist/cjs/utils/resolveRelativePath.cjs.map +1 -1
  142. package/dist/cjs/utils/runOnce.cjs +95 -1
  143. package/dist/cjs/utils/runOnce.cjs.map +1 -1
  144. package/dist/cjs/utils/runParallel/bin.cjs +54 -1
  145. package/dist/cjs/utils/runParallel/bin.cjs.map +1 -1
  146. package/dist/cjs/utils/runParallel/bootstrap.cjs +24 -1
  147. package/dist/cjs/utils/runParallel/bootstrap.cjs.map +1 -1
  148. package/dist/cjs/utils/runParallel/index.cjs +115 -1
  149. package/dist/cjs/utils/runParallel/index.cjs.map +1 -1
  150. package/dist/cjs/utils/runParallel/pidTree.cjs +145 -1
  151. package/dist/cjs/utils/runParallel/pidTree.cjs.map +1 -1
  152. package/dist/cjs/utils/runParallel/ps.cjs +49 -1
  153. package/dist/cjs/utils/runParallel/ps.cjs.map +1 -1
  154. package/dist/cjs/utils/runParallel/runTask.cjs +154 -1
  155. package/dist/cjs/utils/runParallel/runTask.cjs.map +1 -1
  156. package/dist/cjs/utils/runParallel/spawnPosix.cjs +59 -1
  157. package/dist/cjs/utils/runParallel/spawnPosix.cjs.map +1 -1
  158. package/dist/cjs/utils/runParallel/spawnWin32.cjs +43 -1
  159. package/dist/cjs/utils/runParallel/spawnWin32.cjs.map +1 -1
  160. package/dist/cjs/utils/runParallel/wmic.cjs +52 -1
  161. package/dist/cjs/utils/runParallel/wmic.cjs.map +1 -1
  162. package/dist/cjs/utils/sortAlphabetically.cjs +7 -1
  163. package/dist/cjs/utils/sortAlphabetically.cjs.map +1 -1
  164. package/dist/cjs/utils/splitTextByLine.cjs +11 -1
  165. package/dist/cjs/utils/splitTextByLine.cjs.map +1 -1
  166. package/dist/cjs/utils/verifyIdenticObjectFormat.cjs +60 -1
  167. package/dist/cjs/utils/verifyIdenticObjectFormat.cjs.map +1 -1
  168. package/dist/cjs/watcher.cjs +120 -1
  169. package/dist/cjs/watcher.cjs.map +1 -1
  170. package/dist/cjs/writeConfiguration/index.cjs +42 -1
  171. package/dist/cjs/writeConfiguration/index.cjs.map +1 -1
  172. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs +28 -1
  173. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs.map +1 -1
  174. package/dist/cjs/writeContentDeclaration/index.cjs +10 -1
  175. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs +94 -1
  176. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs.map +1 -1
  177. package/dist/cjs/writeContentDeclaration/transformJSFile.cjs +412 -3
  178. package/dist/cjs/writeContentDeclaration/transformJSFile.cjs.map +1 -1
  179. package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs +127 -2
  180. package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs.map +1 -1
  181. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +148 -1
  182. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
  183. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +92 -1
  184. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs.map +1 -1
  185. package/dist/cjs/writeFileIfChanged.cjs +50 -1
  186. package/dist/cjs/writeFileIfChanged.cjs.map +1 -1
  187. package/dist/cjs/writeJsonIfChanged.cjs +17 -1
  188. package/dist/cjs/writeJsonIfChanged.cjs.map +1 -1
  189. package/dist/esm/_virtual/_rolldown/runtime.mjs +8 -0
  190. package/dist/esm/_virtual/_utils_asset.mjs +97 -0
  191. package/dist/esm/build.mjs +25 -1
  192. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs +60 -1
  193. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs.map +1 -1
  194. package/dist/esm/buildIntlayerDictionary/index.mjs +4 -1
  195. package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs +24 -1
  196. package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs.map +1 -1
  197. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs +102 -5
  198. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs.map +1 -1
  199. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs +76 -3
  200. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs.map +1 -1
  201. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs +44 -1
  202. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs.map +1 -1
  203. package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs +48 -1
  204. package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs.map +1 -1
  205. package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs +56 -1
  206. package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs.map +1 -1
  207. package/dist/esm/cleanOutputDir.mjs +28 -1
  208. package/dist/esm/cleanOutputDir.mjs.map +1 -1
  209. package/dist/esm/cleanRemovedContentDeclaration.mjs +94 -1
  210. package/dist/esm/cleanRemovedContentDeclaration.mjs.map +1 -1
  211. package/dist/esm/cli.mjs +15 -1
  212. package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs +68 -1
  213. package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs.map +1 -1
  214. package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs +40 -7
  215. package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs.map +1 -1
  216. package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs +20 -1
  217. package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs.map +1 -1
  218. package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs +21 -1
  219. package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs.map +1 -1
  220. package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs +21 -1
  221. package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs.map +1 -1
  222. package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs +20 -1
  223. package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs.map +1 -1
  224. package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs +20 -1
  225. package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs.map +1 -1
  226. package/dist/esm/createDictionaryEntryPoint/index.mjs +9 -1
  227. package/dist/esm/createType/createModuleAugmentation.mjs +108 -9
  228. package/dist/esm/createType/createModuleAugmentation.mjs.map +1 -1
  229. package/dist/esm/createType/createType.mjs +26 -1
  230. package/dist/esm/createType/createType.mjs.map +1 -1
  231. package/dist/esm/createType/index.mjs +4 -1
  232. package/dist/esm/detectFormatCommand.mjs +30 -1
  233. package/dist/esm/detectFormatCommand.mjs.map +1 -1
  234. package/dist/esm/fetchDistantDictionaries.mjs +49 -1
  235. package/dist/esm/fetchDistantDictionaries.mjs.map +1 -1
  236. package/dist/esm/filterInvalidDictionaries.mjs +48 -1
  237. package/dist/esm/filterInvalidDictionaries.mjs.map +1 -1
  238. package/dist/esm/formatDictionary.mjs +44 -1
  239. package/dist/esm/formatDictionary.mjs.map +1 -1
  240. package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs +59 -7
  241. package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs.map +1 -1
  242. package/dist/esm/getContentDeclarationFileTemplate/index.mjs +3 -1
  243. package/dist/esm/handleAdditionalContentDeclarationFile.mjs +32 -1
  244. package/dist/esm/handleAdditionalContentDeclarationFile.mjs.map +1 -1
  245. package/dist/esm/handleContentDeclarationFileChange.mjs +47 -1
  246. package/dist/esm/handleContentDeclarationFileChange.mjs.map +1 -1
  247. package/dist/esm/handleContentDeclarationFileMoved.mjs +22 -1
  248. package/dist/esm/handleContentDeclarationFileMoved.mjs.map +1 -1
  249. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs +35 -1
  250. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs.map +1 -1
  251. package/dist/esm/init/index.mjs +281 -1
  252. package/dist/esm/init/index.mjs.map +1 -1
  253. package/dist/esm/init/utils/configManipulation.mjs +108 -1
  254. package/dist/esm/init/utils/configManipulation.mjs.map +1 -1
  255. package/dist/esm/init/utils/fileSystem.mjs +34 -1
  256. package/dist/esm/init/utils/fileSystem.mjs.map +1 -1
  257. package/dist/esm/init/utils/index.mjs +6 -1
  258. package/dist/esm/init/utils/jsonParser.mjs +40 -3
  259. package/dist/esm/init/utils/jsonParser.mjs.map +1 -1
  260. package/dist/esm/init/utils/tsConfig.mjs +16 -1
  261. package/dist/esm/init/utils/tsConfig.mjs.map +1 -1
  262. package/dist/esm/initConfig/index.mjs +37 -1
  263. package/dist/esm/initConfig/index.mjs.map +1 -1
  264. package/dist/esm/installMCP/installMCP.mjs +46 -1
  265. package/dist/esm/installMCP/installMCP.mjs.map +1 -1
  266. package/dist/esm/installSkills/index.mjs +295 -1
  267. package/dist/esm/installSkills/index.mjs.map +1 -1
  268. package/dist/esm/listDictionariesPath.mjs +38 -1
  269. package/dist/esm/listDictionariesPath.mjs.map +1 -1
  270. package/dist/esm/listGitFiles.mjs +100 -5
  271. package/dist/esm/listGitFiles.mjs.map +1 -1
  272. package/dist/esm/listProjects.mjs +43 -1
  273. package/dist/esm/listProjects.mjs.map +1 -1
  274. package/dist/esm/loadDictionaries/getIntlayerBundle.mjs +67 -1
  275. package/dist/esm/loadDictionaries/getIntlayerBundle.mjs.map +1 -1
  276. package/dist/esm/loadDictionaries/index.mjs +6 -1
  277. package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +88 -2
  278. package/dist/esm/loadDictionaries/loadContentDeclaration.mjs.map +1 -1
  279. package/dist/esm/loadDictionaries/loadDictionaries.mjs +124 -1
  280. package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
  281. package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs +25 -1
  282. package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs.map +1 -1
  283. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs +58 -1
  284. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -1
  285. package/dist/esm/loadDictionaries/log.mjs +134 -3
  286. package/dist/esm/loadDictionaries/log.mjs.map +1 -1
  287. package/dist/esm/loadDictionaries/logTypeScriptErrors.mjs +61 -2
  288. package/dist/esm/loadDictionaries/logTypeScriptErrors.mjs.map +1 -1
  289. package/dist/esm/logConfigDetails.mjs +36 -2
  290. package/dist/esm/logConfigDetails.mjs.map +1 -1
  291. package/dist/esm/prepareIntlayer.mjs +99 -1
  292. package/dist/esm/prepareIntlayer.mjs.map +1 -1
  293. package/dist/esm/reduceDictionaryContent/applyMask.mjs +28 -1
  294. package/dist/esm/reduceDictionaryContent/applyMask.mjs.map +1 -1
  295. package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs +10 -1
  296. package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs.map +1 -1
  297. package/dist/esm/utils/autoDecorateContent.mjs +86 -1
  298. package/dist/esm/utils/autoDecorateContent.mjs.map +1 -1
  299. package/dist/esm/utils/buildComponentFilesList.mjs +64 -1
  300. package/dist/esm/utils/buildComponentFilesList.mjs.map +1 -1
  301. package/dist/esm/utils/buildFilesList.mjs +79 -1
  302. package/dist/esm/utils/buildFilesList.mjs.map +1 -1
  303. package/dist/esm/utils/chunkJSON.mjs +333 -1
  304. package/dist/esm/utils/chunkJSON.mjs.map +1 -1
  305. package/dist/esm/utils/formatter.mjs +13 -1
  306. package/dist/esm/utils/formatter.mjs.map +1 -1
  307. package/dist/esm/utils/getChunk.mjs +33 -1
  308. package/dist/esm/utils/getChunk.mjs.map +1 -1
  309. package/dist/esm/utils/getContentExtension.mjs +27 -1
  310. package/dist/esm/utils/getContentExtension.mjs.map +1 -1
  311. package/dist/esm/utils/getFormatFromExtension.mjs +31 -1
  312. package/dist/esm/utils/getFormatFromExtension.mjs.map +1 -1
  313. package/dist/esm/utils/getPathHash.mjs +7 -1
  314. package/dist/esm/utils/getPathHash.mjs.map +1 -1
  315. package/dist/esm/utils/index.mjs +22 -1
  316. package/dist/esm/utils/mergeChunks.mjs +26 -1
  317. package/dist/esm/utils/mergeChunks.mjs.map +1 -1
  318. package/dist/esm/utils/pLimit.mjs +125 -1
  319. package/dist/esm/utils/pLimit.mjs.map +1 -1
  320. package/dist/esm/utils/parallelize.mjs +10 -1
  321. package/dist/esm/utils/parallelize.mjs.map +1 -1
  322. package/dist/esm/utils/parallelizeGlobal.mjs +26 -1
  323. package/dist/esm/utils/parallelizeGlobal.mjs.map +1 -1
  324. package/dist/esm/utils/reduceObjectFormat.mjs +29 -1
  325. package/dist/esm/utils/reduceObjectFormat.mjs.map +1 -1
  326. package/dist/esm/utils/resolveObjectPromises.mjs +19 -1
  327. package/dist/esm/utils/resolveObjectPromises.mjs.map +1 -1
  328. package/dist/esm/utils/resolveRelativePath.mjs +19 -1
  329. package/dist/esm/utils/resolveRelativePath.mjs.map +1 -1
  330. package/dist/esm/utils/runOnce.mjs +92 -1
  331. package/dist/esm/utils/runOnce.mjs.map +1 -1
  332. package/dist/esm/utils/runParallel/bin.mjs +52 -1
  333. package/dist/esm/utils/runParallel/bin.mjs.map +1 -1
  334. package/dist/esm/utils/runParallel/bootstrap.mjs +22 -1
  335. package/dist/esm/utils/runParallel/bootstrap.mjs.map +1 -1
  336. package/dist/esm/utils/runParallel/index.mjs +113 -1
  337. package/dist/esm/utils/runParallel/index.mjs.map +1 -1
  338. package/dist/esm/utils/runParallel/pidTree.mjs +142 -1
  339. package/dist/esm/utils/runParallel/pidTree.mjs.map +1 -1
  340. package/dist/esm/utils/runParallel/ps.mjs +46 -1
  341. package/dist/esm/utils/runParallel/ps.mjs.map +1 -1
  342. package/dist/esm/utils/runParallel/runTask.mjs +152 -1
  343. package/dist/esm/utils/runParallel/runTask.mjs.map +1 -1
  344. package/dist/esm/utils/runParallel/spawnPosix.mjs +57 -1
  345. package/dist/esm/utils/runParallel/spawnPosix.mjs.map +1 -1
  346. package/dist/esm/utils/runParallel/spawnWin32.mjs +41 -1
  347. package/dist/esm/utils/runParallel/spawnWin32.mjs.map +1 -1
  348. package/dist/esm/utils/runParallel/wmic.mjs +49 -1
  349. package/dist/esm/utils/runParallel/wmic.mjs.map +1 -1
  350. package/dist/esm/utils/sortAlphabetically.mjs +5 -1
  351. package/dist/esm/utils/sortAlphabetically.mjs.map +1 -1
  352. package/dist/esm/utils/splitTextByLine.mjs +9 -1
  353. package/dist/esm/utils/splitTextByLine.mjs.map +1 -1
  354. package/dist/esm/utils/verifyIdenticObjectFormat.mjs +58 -1
  355. package/dist/esm/utils/verifyIdenticObjectFormat.mjs.map +1 -1
  356. package/dist/esm/watcher.mjs +117 -1
  357. package/dist/esm/watcher.mjs.map +1 -1
  358. package/dist/esm/writeConfiguration/index.mjs +39 -1
  359. package/dist/esm/writeConfiguration/index.mjs.map +1 -1
  360. package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs +26 -1
  361. package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs.map +1 -1
  362. package/dist/esm/writeContentDeclaration/index.mjs +6 -1
  363. package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs +91 -1
  364. package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs.map +1 -1
  365. package/dist/esm/writeContentDeclaration/transformJSFile.mjs +407 -3
  366. package/dist/esm/writeContentDeclaration/transformJSFile.mjs.map +1 -1
  367. package/dist/esm/writeContentDeclaration/transformJSONFile.mjs +124 -2
  368. package/dist/esm/writeContentDeclaration/transformJSONFile.mjs.map +1 -1
  369. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +146 -1
  370. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
  371. package/dist/esm/writeContentDeclaration/writeJSFile.mjs +90 -1
  372. package/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -1
  373. package/dist/esm/writeFileIfChanged.mjs +48 -1
  374. package/dist/esm/writeFileIfChanged.mjs.map +1 -1
  375. package/dist/esm/writeJsonIfChanged.mjs +16 -1
  376. package/dist/esm/writeJsonIfChanged.mjs.map +1 -1
  377. package/dist/types/build.d.ts +20 -20
  378. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +25 -2
  379. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -0
  380. package/dist/types/buildIntlayerDictionary/index.d.ts +2 -2
  381. package/dist/types/buildIntlayerDictionary/processContentDeclaration.d.ts +11 -2
  382. package/dist/types/buildIntlayerDictionary/processContentDeclaration.d.ts.map +1 -0
  383. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +49 -2
  384. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -0
  385. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts +1 -1
  386. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -1
  387. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +30 -2
  388. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts.map +1 -0
  389. package/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts +34 -2
  390. package/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts.map +1 -0
  391. package/dist/types/cli.d.ts +6 -6
  392. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +14 -2
  393. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts.map +1 -0
  394. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +10 -2
  395. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts.map +1 -0
  396. package/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts +10 -2
  397. package/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts.map +1 -0
  398. package/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts +10 -2
  399. package/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts.map +1 -0
  400. package/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts +10 -2
  401. package/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts.map +1 -0
  402. package/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts +10 -2
  403. package/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts.map +1 -0
  404. package/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts +10 -2
  405. package/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts.map +1 -0
  406. package/dist/types/createDictionaryEntryPoint/index.d.ts +7 -7
  407. package/dist/types/createType/createModuleAugmentation.d.ts +9 -2
  408. package/dist/types/createType/createModuleAugmentation.d.ts.map +1 -0
  409. package/dist/types/createType/createType.d.ts +12 -2
  410. package/dist/types/createType/createType.d.ts.map +1 -0
  411. package/dist/types/createType/index.d.ts +2 -2
  412. package/dist/types/fetchDistantDictionaries.d.ts +1 -1
  413. package/dist/types/fetchDistantDictionaries.d.ts.map +1 -1
  414. package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts +7 -2
  415. package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts.map +1 -0
  416. package/dist/types/getContentDeclarationFileTemplate/index.d.ts +1 -1
  417. package/dist/types/loadDictionaries/index.d.ts +4 -4
  418. package/dist/types/loadDictionaries/loadContentDeclaration.d.ts +12 -2
  419. package/dist/types/loadDictionaries/loadContentDeclaration.d.ts.map +1 -0
  420. package/dist/types/loadDictionaries/loadDictionaries.d.ts +23 -2
  421. package/dist/types/loadDictionaries/loadDictionaries.d.ts.map +1 -0
  422. package/dist/types/loadDictionaries/loadLocalDictionaries.d.ts +8 -2
  423. package/dist/types/loadDictionaries/loadLocalDictionaries.d.ts.map +1 -0
  424. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +15 -2
  425. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts.map +1 -0
  426. package/dist/types/loadDictionaries/log.d.ts +1 -1
  427. package/dist/types/utils/getFormatFromExtension.d.ts +8 -2
  428. package/dist/types/utils/getFormatFromExtension.d.ts.map +1 -0
  429. package/dist/types/utils/index.d.ts +1 -1
  430. package/dist/types/writeConfiguration/index.d.ts.map +1 -1
  431. package/dist/types/writeContentDeclaration/detectExportedComponentName.d.ts +12 -2
  432. package/dist/types/writeContentDeclaration/detectExportedComponentName.d.ts.map +1 -0
  433. package/dist/types/writeContentDeclaration/dictionaryStatus.d.ts +5 -2
  434. package/dist/types/writeContentDeclaration/dictionaryStatus.d.ts.map +1 -0
  435. package/dist/types/writeContentDeclaration/index.d.ts +5 -5
  436. package/dist/types/writeContentDeclaration/processContentDeclarationContent.d.ts.map +1 -1
  437. package/dist/types/writeContentDeclaration/transformJSFile.d.ts +11 -2
  438. package/dist/types/writeContentDeclaration/transformJSFile.d.ts.map +1 -0
  439. package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts +19 -2
  440. package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts.map +1 -0
  441. package/dist/types/writeContentDeclaration/writeJSFile.d.ts +14 -2
  442. package/dist/types/writeContentDeclaration/writeJSFile.d.ts.map +1 -0
  443. package/package.json +8 -8
  444. package/dist/cjs/_utils_asset-SJVy1xMD.cjs +0 -2
  445. package/dist/cjs/chunk-Bmb41Sf3.cjs +0 -1
  446. package/dist/esm/_utils_asset-4w8dPH9r.mjs +0 -2
  447. package/dist/esm/chunk-DDgYwkfe.mjs +0 -1
  448. package/dist/types/buildIntlayerDictionary-C-LWgPIL.d.ts +0 -25
  449. package/dist/types/buildIntlayerDictionary-C-LWgPIL.d.ts.map +0 -1
  450. package/dist/types/createDictionaryEntryPoint-Bc5lHSiY.d.ts +0 -14
  451. package/dist/types/createDictionaryEntryPoint-Bc5lHSiY.d.ts.map +0 -1
  452. package/dist/types/createModuleAugmentation-D1eIVnjg.d.ts +0 -9
  453. package/dist/types/createModuleAugmentation-D1eIVnjg.d.ts.map +0 -1
  454. package/dist/types/createType--rDwdg2t.d.ts +0 -12
  455. package/dist/types/createType--rDwdg2t.d.ts.map +0 -1
  456. package/dist/types/detectExportedComponentName-DVXsp_FG.d.ts +0 -12
  457. package/dist/types/detectExportedComponentName-DVXsp_FG.d.ts.map +0 -1
  458. package/dist/types/dictionaryStatus-DPVO37qe.d.ts +0 -5
  459. package/dist/types/dictionaryStatus-DPVO37qe.d.ts.map +0 -1
  460. package/dist/types/generateDictionaryListContent-DAtHG6SR.d.ts +0 -10
  461. package/dist/types/generateDictionaryListContent-DAtHG6SR.d.ts.map +0 -1
  462. package/dist/types/getBuiltDictionariesPath-C4it65a1.d.ts +0 -10
  463. package/dist/types/getBuiltDictionariesPath-C4it65a1.d.ts.map +0 -1
  464. package/dist/types/getBuiltDynamicDictionariesPath-Cj9EWnjT.d.ts +0 -10
  465. package/dist/types/getBuiltDynamicDictionariesPath-Cj9EWnjT.d.ts.map +0 -1
  466. package/dist/types/getBuiltFetchDictionariesPath-1JleRhT3.d.ts +0 -10
  467. package/dist/types/getBuiltFetchDictionariesPath-1JleRhT3.d.ts.map +0 -1
  468. package/dist/types/getBuiltRemoteDictionariesPath-DHOmqNCr.d.ts +0 -10
  469. package/dist/types/getBuiltRemoteDictionariesPath-DHOmqNCr.d.ts.map +0 -1
  470. package/dist/types/getBuiltUnmergedDictionariesPath-GUmmLxTB.d.ts +0 -10
  471. package/dist/types/getBuiltUnmergedDictionariesPath-GUmmLxTB.d.ts.map +0 -1
  472. package/dist/types/getContentDeclarationFileTemplate-Dz3rnFy9.d.ts +0 -7
  473. package/dist/types/getContentDeclarationFileTemplate-Dz3rnFy9.d.ts.map +0 -1
  474. package/dist/types/getFormatFromExtension-SdXYWfPx.d.ts +0 -8
  475. package/dist/types/getFormatFromExtension-SdXYWfPx.d.ts.map +0 -1
  476. package/dist/types/loadContentDeclaration-CBMS4vkA.d.ts +0 -12
  477. package/dist/types/loadContentDeclaration-CBMS4vkA.d.ts.map +0 -1
  478. package/dist/types/loadDictionaries-BIqHwtYE.d.ts +0 -23
  479. package/dist/types/loadDictionaries-BIqHwtYE.d.ts.map +0 -1
  480. package/dist/types/loadLocalDictionaries-CNmVaw0c.d.ts +0 -8
  481. package/dist/types/loadLocalDictionaries-CNmVaw0c.d.ts.map +0 -1
  482. package/dist/types/loadRemoteDictionaries-MoITTb7W.d.ts +0 -15
  483. package/dist/types/loadRemoteDictionaries-MoITTb7W.d.ts.map +0 -1
  484. package/dist/types/processContentDeclaration-CAvrHaIT.d.ts +0 -11
  485. package/dist/types/processContentDeclaration-CAvrHaIT.d.ts.map +0 -1
  486. package/dist/types/transformJSFile-Cg0LkeLb.d.ts +0 -11
  487. package/dist/types/transformJSFile-Cg0LkeLb.d.ts.map +0 -1
  488. package/dist/types/writeContentDeclaration-XdGxj0KP.d.ts +0 -19
  489. package/dist/types/writeContentDeclaration-XdGxj0KP.d.ts.map +0 -1
  490. package/dist/types/writeDynamicDictionary-BE0mF2zZ.d.ts +0 -49
  491. package/dist/types/writeDynamicDictionary-BE0mF2zZ.d.ts.map +0 -1
  492. package/dist/types/writeJSFile-kK95jzg_.d.ts +0 -14
  493. package/dist/types/writeJSFile-kK95jzg_.d.ts.map +0 -1
  494. package/dist/types/writeMergedDictionary-CMeghcRI.d.ts +0 -30
  495. package/dist/types/writeMergedDictionary-CMeghcRI.d.ts.map +0 -1
  496. package/dist/types/writeUnmergedDictionary-Cxx51isz.d.ts +0 -34
  497. package/dist/types/writeUnmergedDictionary-Cxx51isz.d.ts.map +0 -1
@@ -1,2 +1,96 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../chunk-Bmb41Sf3.cjs`);let t=require(`node:fs/promises`),n=require(`node:path`),r=require(`@intlayer/core/package.json`);r=e.t(r);const i={cacheTimeoutMs:60*1e3},a=async(e,i)=>{let a={version:r.default.version,timestamp:i};try{await(0,t.mkdir)((0,n.dirname)(e),{recursive:!0}),await(0,t.writeFile)(e,JSON.stringify(a),{flag:`wx`})}catch(r){if(r.code===`EEXIST`)return;if(r.code===`ENOENT`)try{await(0,t.mkdir)((0,n.dirname)(e),{recursive:!0}),await(0,t.writeFile)(e,JSON.stringify(a),{flag:`wx`});return}catch(e){if(e.code===`EEXIST`)return}throw r}},o=async(e,n,o)=>{let{onIsCached:s,cacheTimeoutMs:c,forceRun:l}={...i,...o??{}},u=Date.now();try{let n=u-(await(0,t.stat)(e)).mtime.getTime(),i=!!l||n>c;if(!i)try{let n=await(0,t.readFile)(e,`utf8`),a;try{a=JSON.parse(n).version}catch{a=void 0}(!a||a!==r.default.version)&&(i=!0)}catch{i=!0}if(i)try{await(0,t.unlink)(e)}catch{}else{await s?.();return}}catch(e){if(e.code!==`ENOENT`)throw e}await a(e,u);try{await n(),await a(e,u)}catch{try{await(0,t.unlink)(e)}catch{}}};exports.runOnce=o;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let node_fs_promises = require("node:fs/promises");
4
+ let node_path = require("node:path");
5
+ let _intlayer_core_package_json = require("@intlayer/core/package.json");
6
+ _intlayer_core_package_json = require_runtime.__toESM(_intlayer_core_package_json);
7
+
8
+ //#region src/utils/runOnce.ts
9
+ const DEFAULT_RUN_ONCE_OPTIONS = { cacheTimeoutMs: 60 * 1e3 };
10
+ const writeSentinelFile = async (sentinelFilePath, currentTimestamp) => {
11
+ const data = {
12
+ version: _intlayer_core_package_json.default.version,
13
+ timestamp: currentTimestamp
14
+ };
15
+ try {
16
+ await (0, node_fs_promises.mkdir)((0, node_path.dirname)(sentinelFilePath), { recursive: true });
17
+ await (0, node_fs_promises.writeFile)(sentinelFilePath, JSON.stringify(data), { flag: "wx" });
18
+ } catch (err) {
19
+ if (err.code === "EEXIST") return;
20
+ if (err.code === "ENOENT") try {
21
+ await (0, node_fs_promises.mkdir)((0, node_path.dirname)(sentinelFilePath), { recursive: true });
22
+ await (0, node_fs_promises.writeFile)(sentinelFilePath, JSON.stringify(data), { flag: "wx" });
23
+ return;
24
+ } catch (retryErr) {
25
+ if (retryErr.code === "EEXIST") return;
26
+ }
27
+ throw err;
28
+ }
29
+ };
30
+ /**
31
+ * Ensures a callback function runs only once within a specified time window across multiple processes.
32
+ * Uses a sentinel file to coordinate execution and prevent duplicate work.
33
+ *
34
+ * @param sentinelFilePath - Path to the sentinel file used for coordination
35
+ * @param callback - The function to execute (should be async)
36
+ * @param options - The options for the runOnce function
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * await runPrepareIntlayerOnce(
41
+ * '/tmp/intlayer-sentinel',
42
+ * async () => {
43
+ * // Your initialization logic here
44
+ * await prepareIntlayer();
45
+ * },
46
+ * 30 * 1000 // 30 seconds cache
47
+ * );
48
+ * ```
49
+ *
50
+ * @throws {Error} When there are unexpected filesystem errors
51
+ */
52
+ const runOnce = async (sentinelFilePath, callback, options) => {
53
+ const { onIsCached, cacheTimeoutMs, forceRun } = {
54
+ ...DEFAULT_RUN_ONCE_OPTIONS,
55
+ ...options ?? {}
56
+ };
57
+ const currentTimestamp = Date.now();
58
+ try {
59
+ const sentinelAge = currentTimestamp - (await (0, node_fs_promises.stat)(sentinelFilePath)).mtime.getTime();
60
+ let shouldRebuild = Boolean(forceRun) || sentinelAge > cacheTimeoutMs;
61
+ if (!shouldRebuild) try {
62
+ const raw = await (0, node_fs_promises.readFile)(sentinelFilePath, "utf8");
63
+ let cachedVersion;
64
+ try {
65
+ cachedVersion = JSON.parse(raw).version;
66
+ } catch {
67
+ cachedVersion = void 0;
68
+ }
69
+ if (!cachedVersion || cachedVersion !== _intlayer_core_package_json.default.version) shouldRebuild = true;
70
+ } catch {
71
+ shouldRebuild = true;
72
+ }
73
+ if (shouldRebuild) try {
74
+ await (0, node_fs_promises.unlink)(sentinelFilePath);
75
+ } catch {}
76
+ else {
77
+ await onIsCached?.();
78
+ return;
79
+ }
80
+ } catch (err) {
81
+ if (err.code === "ENOENT") {} else throw err;
82
+ }
83
+ await writeSentinelFile(sentinelFilePath, currentTimestamp);
84
+ try {
85
+ await callback();
86
+ await writeSentinelFile(sentinelFilePath, currentTimestamp);
87
+ } catch {
88
+ try {
89
+ await (0, node_fs_promises.unlink)(sentinelFilePath);
90
+ } catch {}
91
+ }
92
+ };
93
+
94
+ //#endregion
95
+ exports.runOnce = runOnce;
2
96
  //# sourceMappingURL=runOnce.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"runOnce.cjs","names":["packageJson"],"sources":["../../../src/utils/runOnce.ts"],"sourcesContent":["import { mkdir, readFile, stat, unlink, writeFile } from 'node:fs/promises';\nimport { dirname } from 'node:path';\nimport packageJson from '@intlayer/core/package.json' with { type: 'json' };\n\ntype RunOnceOptions = {\n /**\n * The function to execute when the sentinel is not found or is older than the cache timeout.\n */\n onIsCached?: () => void | Promise<void>;\n /**\n * The time window in milliseconds during which the sentinel is considered valid.\n *\n * @default 60000 = 1 minute\n */\n cacheTimeoutMs?: number;\n /**\n * If true, the callback will always run. If undefined, the callback will run only if the sentinel is older than the cache timeout.\n *\n * @default false\n */\n forceRun?: boolean;\n};\n\nconst DEFAULT_RUN_ONCE_OPTIONS = {\n cacheTimeoutMs: 60 * 1000, // 1 minute in milliseconds,\n} satisfies RunOnceOptions;\n\ntype SentinelData = {\n version: string;\n timestamp: number;\n};\n\nconst writeSentinelFile = async (\n sentinelFilePath: string,\n currentTimestamp: number\n) => {\n // O_EXCL ensures only the *first* process can create the file\n const data: SentinelData = {\n version: packageJson.version,\n timestamp: currentTimestamp,\n };\n\n try {\n // Ensure the directory exists before writing the file\n await mkdir(dirname(sentinelFilePath), { recursive: true });\n\n await writeFile(sentinelFilePath, JSON.stringify(data), { flag: 'wx' });\n } catch (err: any) {\n if (err.code === 'EEXIST') {\n // Another process already created it → we're done\n return;\n }\n // Optimization: If ENOENT occurs on write despite mkdir (race condition with external deletion), retry once.\n if (err.code === 'ENOENT') {\n try {\n await mkdir(dirname(sentinelFilePath), { recursive: true });\n await writeFile(sentinelFilePath, JSON.stringify(data), { flag: 'wx' });\n return;\n } catch (retryErr: any) {\n if (retryErr.code === 'EEXIST') return;\n }\n }\n throw err; // unexpected FS error\n }\n};\n\n/**\n * Ensures a callback function runs only once within a specified time window across multiple processes.\n * Uses a sentinel file to coordinate execution and prevent duplicate work.\n *\n * @param sentinelFilePath - Path to the sentinel file used for coordination\n * @param callback - The function to execute (should be async)\n * @param options - The options for the runOnce function\n *\n * @example\n * ```typescript\n * await runPrepareIntlayerOnce(\n * '/tmp/intlayer-sentinel',\n * async () => {\n * // Your initialization logic here\n * await prepareIntlayer();\n * },\n * 30 * 1000 // 30 seconds cache\n * );\n * ```\n *\n * @throws {Error} When there are unexpected filesystem errors\n */\nexport const runOnce = async (\n sentinelFilePath: string,\n callback: () => void | Promise<void>,\n options?: RunOnceOptions\n) => {\n const { onIsCached, cacheTimeoutMs, forceRun } = {\n ...DEFAULT_RUN_ONCE_OPTIONS,\n ...(options ?? {}),\n };\n const currentTimestamp = Date.now();\n\n try {\n // Check if sentinel file exists and get its stats\n const sentinelStats = await stat(sentinelFilePath);\n const sentinelAge = currentTimestamp - sentinelStats.mtime.getTime();\n\n // Determine if we should rebuild based on cache age, force flag, or version mismatch\n let shouldRebuild = Boolean(forceRun) || sentinelAge > cacheTimeoutMs!;\n\n if (!shouldRebuild) {\n try {\n const raw = await readFile(sentinelFilePath, 'utf8');\n let cachedVersion: string | undefined;\n try {\n const parsed = JSON.parse(raw) as Partial<SentinelData>;\n cachedVersion = parsed.version;\n } catch {\n // Legacy format (timestamp only). Force a rebuild once to write versioned sentinel.\n cachedVersion = undefined;\n }\n\n if (!cachedVersion || cachedVersion !== packageJson.version) {\n shouldRebuild = true;\n }\n } catch {\n // If we cannot read the file, err on the safe side and rebuild\n shouldRebuild = true;\n }\n }\n\n if (shouldRebuild) {\n try {\n await unlink(sentinelFilePath);\n } catch {}\n // Fall through to create new sentinel and rebuild\n } else {\n await onIsCached?.();\n // Sentinel is recent and versions match, no need to rebuild\n return;\n }\n } catch (err: any) {\n if (err.code === 'ENOENT') {\n // File doesn't exist, continue to create it\n } else {\n throw err; // unexpected FS error\n }\n }\n\n // Write sentinel file before to block parallel processes\n // Added await here\n await writeSentinelFile(sentinelFilePath, currentTimestamp);\n\n try {\n await callback();\n\n // Write sentinel file after to ensure the first one has not been removed with cleanOutputDir\n // Added await here\n await writeSentinelFile(sentinelFilePath, currentTimestamp);\n } catch {\n try {\n await unlink(sentinelFilePath); // Remove sentinel file if an error occurs\n } catch {}\n }\n};\n"],"mappings":"uNAuBA,MAAM,EAA2B,CAC/B,eAAgB,GAAK,IACtB,CAOK,EAAoB,MACxB,EACA,IACG,CAEH,IAAM,EAAqB,CACzB,QAASA,EAAAA,QAAY,QACrB,UAAW,EACZ,CAED,GAAI,CAEF,MAAA,EAAA,EAAA,QAAA,EAAA,EAAA,SAAoB,EAAiB,CAAE,CAAE,UAAW,GAAM,CAAC,CAE3D,MAAA,EAAA,EAAA,WAAgB,EAAkB,KAAK,UAAU,EAAK,CAAE,CAAE,KAAM,KAAM,CAAC,OAChE,EAAU,CACjB,GAAI,EAAI,OAAS,SAEf,OAGF,GAAI,EAAI,OAAS,SACf,GAAI,CACF,MAAA,EAAA,EAAA,QAAA,EAAA,EAAA,SAAoB,EAAiB,CAAE,CAAE,UAAW,GAAM,CAAC,CAC3D,MAAA,EAAA,EAAA,WAAgB,EAAkB,KAAK,UAAU,EAAK,CAAE,CAAE,KAAM,KAAM,CAAC,CACvE,aACO,EAAe,CACtB,GAAI,EAAS,OAAS,SAAU,OAGpC,MAAM,IA0BG,EAAU,MACrB,EACA,EACA,IACG,CACH,GAAM,CAAE,aAAY,iBAAgB,YAAa,CAC/C,GAAG,EACH,GAAI,GAAW,EAAE,CAClB,CACK,EAAmB,KAAK,KAAK,CAEnC,GAAI,CAGF,IAAM,EAAc,GADE,MAAA,EAAA,EAAA,MAAW,EAAiB,EACG,MAAM,SAAS,CAGhE,EAAgB,EAAQ,GAAa,EAAc,EAEvD,GAAI,CAAC,EACH,GAAI,CACF,IAAM,EAAM,MAAA,EAAA,EAAA,UAAe,EAAkB,OAAO,CAChD,EACJ,GAAI,CAEF,EADe,KAAK,MAAM,EAAI,CACP,aACjB,CAEN,EAAgB,IAAA,IAGd,CAAC,GAAiB,IAAkBA,EAAAA,QAAY,WAClD,EAAgB,SAEZ,CAEN,EAAgB,GAIpB,GAAI,EACF,GAAI,CACF,MAAA,EAAA,EAAA,QAAa,EAAiB,MACxB,MAEH,CACL,MAAM,KAAc,CAEpB,cAEK,EAAU,CACjB,GAAI,EAAI,OAAS,SAGf,MAAM,EAMV,MAAM,EAAkB,EAAkB,EAAiB,CAE3D,GAAI,CACF,MAAM,GAAU,CAIhB,MAAM,EAAkB,EAAkB,EAAiB,MACrD,CACN,GAAI,CACF,MAAA,EAAA,EAAA,QAAa,EAAiB,MACxB"}
1
+ {"version":3,"file":"runOnce.cjs","names":["packageJson"],"sources":["../../../src/utils/runOnce.ts"],"sourcesContent":["import { mkdir, readFile, stat, unlink, writeFile } from 'node:fs/promises';\nimport { dirname } from 'node:path';\nimport packageJson from '@intlayer/core/package.json' with { type: 'json' };\n\ntype RunOnceOptions = {\n /**\n * The function to execute when the sentinel is not found or is older than the cache timeout.\n */\n onIsCached?: () => void | Promise<void>;\n /**\n * The time window in milliseconds during which the sentinel is considered valid.\n *\n * @default 60000 = 1 minute\n */\n cacheTimeoutMs?: number;\n /**\n * If true, the callback will always run. If undefined, the callback will run only if the sentinel is older than the cache timeout.\n *\n * @default false\n */\n forceRun?: boolean;\n};\n\nconst DEFAULT_RUN_ONCE_OPTIONS = {\n cacheTimeoutMs: 60 * 1000, // 1 minute in milliseconds,\n} satisfies RunOnceOptions;\n\ntype SentinelData = {\n version: string;\n timestamp: number;\n};\n\nconst writeSentinelFile = async (\n sentinelFilePath: string,\n currentTimestamp: number\n) => {\n // O_EXCL ensures only the *first* process can create the file\n const data: SentinelData = {\n version: packageJson.version,\n timestamp: currentTimestamp,\n };\n\n try {\n // Ensure the directory exists before writing the file\n await mkdir(dirname(sentinelFilePath), { recursive: true });\n\n await writeFile(sentinelFilePath, JSON.stringify(data), { flag: 'wx' });\n } catch (err: any) {\n if (err.code === 'EEXIST') {\n // Another process already created it → we're done\n return;\n }\n // Optimization: If ENOENT occurs on write despite mkdir (race condition with external deletion), retry once.\n if (err.code === 'ENOENT') {\n try {\n await mkdir(dirname(sentinelFilePath), { recursive: true });\n await writeFile(sentinelFilePath, JSON.stringify(data), { flag: 'wx' });\n return;\n } catch (retryErr: any) {\n if (retryErr.code === 'EEXIST') return;\n }\n }\n throw err; // unexpected FS error\n }\n};\n\n/**\n * Ensures a callback function runs only once within a specified time window across multiple processes.\n * Uses a sentinel file to coordinate execution and prevent duplicate work.\n *\n * @param sentinelFilePath - Path to the sentinel file used for coordination\n * @param callback - The function to execute (should be async)\n * @param options - The options for the runOnce function\n *\n * @example\n * ```typescript\n * await runPrepareIntlayerOnce(\n * '/tmp/intlayer-sentinel',\n * async () => {\n * // Your initialization logic here\n * await prepareIntlayer();\n * },\n * 30 * 1000 // 30 seconds cache\n * );\n * ```\n *\n * @throws {Error} When there are unexpected filesystem errors\n */\nexport const runOnce = async (\n sentinelFilePath: string,\n callback: () => void | Promise<void>,\n options?: RunOnceOptions\n) => {\n const { onIsCached, cacheTimeoutMs, forceRun } = {\n ...DEFAULT_RUN_ONCE_OPTIONS,\n ...(options ?? {}),\n };\n const currentTimestamp = Date.now();\n\n try {\n // Check if sentinel file exists and get its stats\n const sentinelStats = await stat(sentinelFilePath);\n const sentinelAge = currentTimestamp - sentinelStats.mtime.getTime();\n\n // Determine if we should rebuild based on cache age, force flag, or version mismatch\n let shouldRebuild = Boolean(forceRun) || sentinelAge > cacheTimeoutMs!;\n\n if (!shouldRebuild) {\n try {\n const raw = await readFile(sentinelFilePath, 'utf8');\n let cachedVersion: string | undefined;\n try {\n const parsed = JSON.parse(raw) as Partial<SentinelData>;\n cachedVersion = parsed.version;\n } catch {\n // Legacy format (timestamp only). Force a rebuild once to write versioned sentinel.\n cachedVersion = undefined;\n }\n\n if (!cachedVersion || cachedVersion !== packageJson.version) {\n shouldRebuild = true;\n }\n } catch {\n // If we cannot read the file, err on the safe side and rebuild\n shouldRebuild = true;\n }\n }\n\n if (shouldRebuild) {\n try {\n await unlink(sentinelFilePath);\n } catch {}\n // Fall through to create new sentinel and rebuild\n } else {\n await onIsCached?.();\n // Sentinel is recent and versions match, no need to rebuild\n return;\n }\n } catch (err: any) {\n if (err.code === 'ENOENT') {\n // File doesn't exist, continue to create it\n } else {\n throw err; // unexpected FS error\n }\n }\n\n // Write sentinel file before to block parallel processes\n // Added await here\n await writeSentinelFile(sentinelFilePath, currentTimestamp);\n\n try {\n await callback();\n\n // Write sentinel file after to ensure the first one has not been removed with cleanOutputDir\n // Added await here\n await writeSentinelFile(sentinelFilePath, currentTimestamp);\n } catch {\n try {\n await unlink(sentinelFilePath); // Remove sentinel file if an error occurs\n } catch {}\n }\n};\n"],"mappings":";;;;;;;;AAuBA,MAAM,2BAA2B,EAC/B,gBAAgB,KAAK,KACtB;AAOD,MAAM,oBAAoB,OACxB,kBACA,qBACG;CAEH,MAAM,OAAqB;EACzB,SAASA,oCAAY;EACrB,WAAW;EACZ;AAED,KAAI;AAEF,2DAAoB,iBAAiB,EAAE,EAAE,WAAW,MAAM,CAAC;AAE3D,wCAAgB,kBAAkB,KAAK,UAAU,KAAK,EAAE,EAAE,MAAM,MAAM,CAAC;UAChE,KAAU;AACjB,MAAI,IAAI,SAAS,SAEf;AAGF,MAAI,IAAI,SAAS,SACf,KAAI;AACF,4DAAoB,iBAAiB,EAAE,EAAE,WAAW,MAAM,CAAC;AAC3D,yCAAgB,kBAAkB,KAAK,UAAU,KAAK,EAAE,EAAE,MAAM,MAAM,CAAC;AACvE;WACO,UAAe;AACtB,OAAI,SAAS,SAAS,SAAU;;AAGpC,QAAM;;;;;;;;;;;;;;;;;;;;;;;;;AA0BV,MAAa,UAAU,OACrB,kBACA,UACA,YACG;CACH,MAAM,EAAE,YAAY,gBAAgB,aAAa;EAC/C,GAAG;EACH,GAAI,WAAW,EAAE;EAClB;CACD,MAAM,mBAAmB,KAAK,KAAK;AAEnC,KAAI;EAGF,MAAM,cAAc,oBADE,iCAAW,iBAAiB,EACG,MAAM,SAAS;EAGpE,IAAI,gBAAgB,QAAQ,SAAS,IAAI,cAAc;AAEvD,MAAI,CAAC,cACH,KAAI;GACF,MAAM,MAAM,qCAAe,kBAAkB,OAAO;GACpD,IAAI;AACJ,OAAI;AAEF,oBADe,KAAK,MAAM,IAAI,CACP;WACjB;AAEN,oBAAgB;;AAGlB,OAAI,CAAC,iBAAiB,kBAAkBA,oCAAY,QAClD,iBAAgB;UAEZ;AAEN,mBAAgB;;AAIpB,MAAI,cACF,KAAI;AACF,sCAAa,iBAAiB;UACxB;OAEH;AACL,SAAM,cAAc;AAEpB;;UAEK,KAAU;AACjB,MAAI,IAAI,SAAS,UAAU,OAGzB,OAAM;;AAMV,OAAM,kBAAkB,kBAAkB,iBAAiB;AAE3D,KAAI;AACF,QAAM,UAAU;AAIhB,QAAM,kBAAkB,kBAAkB,iBAAiB;SACrD;AACN,MAAI;AACF,sCAAa,iBAAiB;UACxB"}
@@ -1,2 +1,55 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../chunk-Bmb41Sf3.cjs`);let e=require(`node:child_process`);const t=e=>{if(!e)return;let t=e.trim();return t=t.replace(/your \d+x\d+ screen size is bogus\. expect trouble/gi,``),t.trim()||void 0},n=(n,r,i,a)=>{let o,s;typeof i==`function`?(s=i,o=void 0):(s=a,o=i);let c=!1,l=(0,e.spawn)(n,r,o??{}),u=``,d=``;l.stdout&&l.stdout.on(`data`,e=>{u+=e.toString()}),l.stderr&&l.stderr.on(`data`,e=>{d+=e.toString()}),l.on(`error`,e=>{c||(c=!0,s(Error(String(e))))}),l.on(`close`,e=>{if(c)return;c=!0;let n=t(d);if(n)return s(Error(n));s(null,u,e??void 0)})};exports.run=n;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
+ let node_child_process = require("node:child_process");
4
+
5
+ //#region src/utils/runParallel/bin.ts
6
+ const stripStderr = (stderr) => {
7
+ if (!stderr) return;
8
+ let cleaned = stderr.trim();
9
+ cleaned = cleaned.replace(/your \d+x\d+ screen size is bogus\. expect trouble/gi, "");
10
+ return cleaned.trim() || void 0;
11
+ };
12
+ /**
13
+ * Spawn a binary and read its stdout.
14
+ * @param cmd The name of the binary to spawn.
15
+ * @param args The arguments for the binary.
16
+ * @param options Optional option for the spawn function.
17
+ * @param done Callback function.
18
+ */
19
+ const run = (cmd, args, options, done) => {
20
+ let normalizedOptions;
21
+ let normalizedDone;
22
+ if (typeof options === "function") {
23
+ normalizedDone = options;
24
+ normalizedOptions = void 0;
25
+ } else {
26
+ normalizedDone = done;
27
+ normalizedOptions = options;
28
+ }
29
+ let executed = false;
30
+ const ch = (0, node_child_process.spawn)(cmd, args, normalizedOptions ?? {});
31
+ let stdout = "";
32
+ let stderr = "";
33
+ if (ch.stdout) ch.stdout.on("data", (d) => {
34
+ stdout += d.toString();
35
+ });
36
+ if (ch.stderr) ch.stderr.on("data", (d) => {
37
+ stderr += d.toString();
38
+ });
39
+ ch.on("error", (err) => {
40
+ if (executed) return;
41
+ executed = true;
42
+ normalizedDone(new Error(String(err)));
43
+ });
44
+ ch.on("close", (code) => {
45
+ if (executed) return;
46
+ executed = true;
47
+ const cleanedStderr = stripStderr(stderr);
48
+ if (cleanedStderr) return normalizedDone(new Error(cleanedStderr));
49
+ normalizedDone(null, stdout, code ?? void 0);
50
+ });
51
+ };
52
+
53
+ //#endregion
54
+ exports.run = run;
2
55
  //# sourceMappingURL=bin.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"bin.cjs","names":[],"sources":["../../../../src/utils/runParallel/bin.ts"],"sourcesContent":["import type { ChildProcess } from 'node:child_process';\nimport { type SpawnOptions, spawn } from 'node:child_process';\n\ntype BinCallback = (err: Error | null, stdout?: string, code?: number) => void;\n\nconst stripStderr = (stderr: string | undefined): string | undefined => {\n if (!stderr) return;\n let cleaned = stderr.trim();\n // Strip bogus screen size error.\n // See https://github.com/microsoft/vscode/issues/98590\n const regex = /your \\d+x\\d+ screen size is bogus\\. expect trouble/gi;\n cleaned = cleaned.replace(regex, '');\n\n return cleaned.trim() || undefined;\n};\n\n/**\n * Spawn a binary and read its stdout.\n * @param cmd The name of the binary to spawn.\n * @param args The arguments for the binary.\n * @param options Optional option for the spawn function.\n * @param done Callback function.\n */\nexport const run = (\n cmd: string,\n args: string[],\n options: SpawnOptions | BinCallback | undefined,\n done?: BinCallback\n): void => {\n let normalizedOptions: SpawnOptions | undefined;\n let normalizedDone: BinCallback;\n\n if (typeof options === 'function') {\n normalizedDone = options;\n normalizedOptions = undefined;\n } else {\n normalizedDone = done!;\n normalizedOptions = options;\n }\n\n let executed = false;\n const ch: ChildProcess = spawn(cmd, args, normalizedOptions ?? {});\n let stdout = '';\n let stderr = '';\n\n if (ch.stdout) {\n ch.stdout.on('data', (d: Buffer) => {\n stdout += d.toString();\n });\n }\n\n if (ch.stderr) {\n ch.stderr.on('data', (d: Buffer) => {\n stderr += d.toString();\n });\n }\n\n ch.on('error', (err: Error) => {\n if (executed) return;\n executed = true;\n normalizedDone(new Error(String(err)));\n });\n\n ch.on('close', (code: number | null) => {\n if (executed) return;\n executed = true;\n\n const cleanedStderr = stripStderr(stderr);\n if (cleanedStderr) {\n return normalizedDone(new Error(cleanedStderr));\n }\n\n normalizedDone(null, stdout, code ?? undefined);\n });\n};\n"],"mappings":"2IAKA,MAAM,EAAe,GAAmD,CACtE,GAAI,CAAC,EAAQ,OACb,IAAI,EAAU,EAAO,MAAM,CAM3B,MAFA,GAAU,EAAQ,QADJ,uDACmB,GAAG,CAE7B,EAAQ,MAAM,EAAI,IAAA,IAUd,GACX,EACA,EACA,EACA,IACS,CACT,IAAI,EACA,EAEA,OAAO,GAAY,YACrB,EAAiB,EACjB,EAAoB,IAAA,KAEpB,EAAiB,EACjB,EAAoB,GAGtB,IAAI,EAAW,GACT,GAAA,EAAA,EAAA,OAAyB,EAAK,EAAM,GAAqB,EAAE,CAAC,CAC9D,EAAS,GACT,EAAS,GAET,EAAG,QACL,EAAG,OAAO,GAAG,OAAS,GAAc,CAClC,GAAU,EAAE,UAAU,EACtB,CAGA,EAAG,QACL,EAAG,OAAO,GAAG,OAAS,GAAc,CAClC,GAAU,EAAE,UAAU,EACtB,CAGJ,EAAG,GAAG,QAAU,GAAe,CACzB,IACJ,EAAW,GACX,EAAmB,MAAM,OAAO,EAAI,CAAC,CAAC,GACtC,CAEF,EAAG,GAAG,QAAU,GAAwB,CACtC,GAAI,EAAU,OACd,EAAW,GAEX,IAAM,EAAgB,EAAY,EAAO,CACzC,GAAI,EACF,OAAO,EAAmB,MAAM,EAAc,CAAC,CAGjD,EAAe,KAAM,EAAQ,GAAQ,IAAA,GAAU,EAC/C"}
1
+ {"version":3,"file":"bin.cjs","names":[],"sources":["../../../../src/utils/runParallel/bin.ts"],"sourcesContent":["import type { ChildProcess } from 'node:child_process';\nimport { type SpawnOptions, spawn } from 'node:child_process';\n\ntype BinCallback = (err: Error | null, stdout?: string, code?: number) => void;\n\nconst stripStderr = (stderr: string | undefined): string | undefined => {\n if (!stderr) return;\n let cleaned = stderr.trim();\n // Strip bogus screen size error.\n // See https://github.com/microsoft/vscode/issues/98590\n const regex = /your \\d+x\\d+ screen size is bogus\\. expect trouble/gi;\n cleaned = cleaned.replace(regex, '');\n\n return cleaned.trim() || undefined;\n};\n\n/**\n * Spawn a binary and read its stdout.\n * @param cmd The name of the binary to spawn.\n * @param args The arguments for the binary.\n * @param options Optional option for the spawn function.\n * @param done Callback function.\n */\nexport const run = (\n cmd: string,\n args: string[],\n options: SpawnOptions | BinCallback | undefined,\n done?: BinCallback\n): void => {\n let normalizedOptions: SpawnOptions | undefined;\n let normalizedDone: BinCallback;\n\n if (typeof options === 'function') {\n normalizedDone = options;\n normalizedOptions = undefined;\n } else {\n normalizedDone = done!;\n normalizedOptions = options;\n }\n\n let executed = false;\n const ch: ChildProcess = spawn(cmd, args, normalizedOptions ?? {});\n let stdout = '';\n let stderr = '';\n\n if (ch.stdout) {\n ch.stdout.on('data', (d: Buffer) => {\n stdout += d.toString();\n });\n }\n\n if (ch.stderr) {\n ch.stderr.on('data', (d: Buffer) => {\n stderr += d.toString();\n });\n }\n\n ch.on('error', (err: Error) => {\n if (executed) return;\n executed = true;\n normalizedDone(new Error(String(err)));\n });\n\n ch.on('close', (code: number | null) => {\n if (executed) return;\n executed = true;\n\n const cleanedStderr = stripStderr(stderr);\n if (cleanedStderr) {\n return normalizedDone(new Error(cleanedStderr));\n }\n\n normalizedDone(null, stdout, code ?? undefined);\n });\n};\n"],"mappings":";;;;;AAKA,MAAM,eAAe,WAAmD;AACtE,KAAI,CAAC,OAAQ;CACb,IAAI,UAAU,OAAO,MAAM;AAI3B,WAAU,QAAQ,QADJ,wDACmB,GAAG;AAEpC,QAAO,QAAQ,MAAM,IAAI;;;;;;;;;AAU3B,MAAa,OACX,KACA,MACA,SACA,SACS;CACT,IAAI;CACJ,IAAI;AAEJ,KAAI,OAAO,YAAY,YAAY;AACjC,mBAAiB;AACjB,sBAAoB;QACf;AACL,mBAAiB;AACjB,sBAAoB;;CAGtB,IAAI,WAAW;CACf,MAAM,mCAAyB,KAAK,MAAM,qBAAqB,EAAE,CAAC;CAClE,IAAI,SAAS;CACb,IAAI,SAAS;AAEb,KAAI,GAAG,OACL,IAAG,OAAO,GAAG,SAAS,MAAc;AAClC,YAAU,EAAE,UAAU;GACtB;AAGJ,KAAI,GAAG,OACL,IAAG,OAAO,GAAG,SAAS,MAAc;AAClC,YAAU,EAAE,UAAU;GACtB;AAGJ,IAAG,GAAG,UAAU,QAAe;AAC7B,MAAI,SAAU;AACd,aAAW;AACX,iBAAe,IAAI,MAAM,OAAO,IAAI,CAAC,CAAC;GACtC;AAEF,IAAG,GAAG,UAAU,SAAwB;AACtC,MAAI,SAAU;AACd,aAAW;EAEX,MAAM,gBAAgB,YAAY,OAAO;AACzC,MAAI,cACF,QAAO,eAAe,IAAI,MAAM,cAAc,CAAC;AAGjD,iBAAe,MAAM,QAAQ,QAAQ,OAAU;GAC/C"}
@@ -1,2 +1,25 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=e=>{switch(process.argv.slice(2)[0]){case void 0:case`-h`:case`--help`:console.log(`Help not implemented`);return;case`-v`:case`--version`:console.log(`Version not implemented`);return;default:process.stdout.setMaxListeners(0),process.stderr.setMaxListeners(0),process.stdin.setMaxListeners(0);return}};exports.bootstrap=e;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ //#region src/utils/runParallel/bootstrap.ts
4
+ const bootstrap = (_name) => {
5
+ switch (process.argv.slice(2)[0]) {
6
+ case void 0:
7
+ case "-h":
8
+ case "--help":
9
+ console.log("Help not implemented");
10
+ return;
11
+ case "-v":
12
+ case "--version":
13
+ console.log("Version not implemented");
14
+ return;
15
+ default:
16
+ process.stdout.setMaxListeners(0);
17
+ process.stderr.setMaxListeners(0);
18
+ process.stdin.setMaxListeners(0);
19
+ return;
20
+ }
21
+ };
22
+
23
+ //#endregion
24
+ exports.bootstrap = bootstrap;
2
25
  //# sourceMappingURL=bootstrap.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.cjs","names":[],"sources":["../../../../src/utils/runParallel/bootstrap.ts"],"sourcesContent":["//------------------------------------------------------------------------------\n// Public Interface\n//------------------------------------------------------------------------------\n\nexport const bootstrap = (_name: string): void | Promise<void> => {\n const argv = process.argv.slice(2);\n\n switch (argv[0]) {\n case undefined:\n case '-h':\n case '--help':\n // Not needed for our use case\n console.log('Help not implemented');\n return;\n\n case '-v':\n case '--version':\n // Not needed for our use case\n console.log('Version not implemented');\n return;\n\n default:\n // https://github.com/mysticatea/npm-run-all/issues/105\n // Avoid MaxListenersExceededWarnings.\n process.stdout.setMaxListeners(0);\n process.stderr.setMaxListeners(0);\n process.stdin.setMaxListeners(0);\n return;\n }\n};\n"],"mappings":"mEAIA,MAAa,EAAa,GAAwC,CAGhE,OAFa,QAAQ,KAAK,MAAM,EAAE,CAErB,GAAb,CACE,KAAK,IAAA,GACL,IAAK,KACL,IAAK,SAEH,QAAQ,IAAI,uBAAuB,CACnC,OAEF,IAAK,KACL,IAAK,YAEH,QAAQ,IAAI,0BAA0B,CACtC,OAEF,QAGE,QAAQ,OAAO,gBAAgB,EAAE,CACjC,QAAQ,OAAO,gBAAgB,EAAE,CACjC,QAAQ,MAAM,gBAAgB,EAAE,CAChC"}
1
+ {"version":3,"file":"bootstrap.cjs","names":[],"sources":["../../../../src/utils/runParallel/bootstrap.ts"],"sourcesContent":["//------------------------------------------------------------------------------\n// Public Interface\n//------------------------------------------------------------------------------\n\nexport const bootstrap = (_name: string): void | Promise<void> => {\n const argv = process.argv.slice(2);\n\n switch (argv[0]) {\n case undefined:\n case '-h':\n case '--help':\n // Not needed for our use case\n console.log('Help not implemented');\n return;\n\n case '-v':\n case '--version':\n // Not needed for our use case\n console.log('Version not implemented');\n return;\n\n default:\n // https://github.com/mysticatea/npm-run-all/issues/105\n // Avoid MaxListenersExceededWarnings.\n process.stdout.setMaxListeners(0);\n process.stderr.setMaxListeners(0);\n process.stdin.setMaxListeners(0);\n return;\n }\n};\n"],"mappings":";;;AAIA,MAAa,aAAa,UAAwC;AAGhE,SAFa,QAAQ,KAAK,MAAM,EAAE,CAErB,IAAb;EACE,KAAK;EACL,KAAK;EACL,KAAK;AAEH,WAAQ,IAAI,uBAAuB;AACnC;EAEF,KAAK;EACL,KAAK;AAEH,WAAQ,IAAI,0BAA0B;AACtC;EAEF;AAGE,WAAQ,OAAO,gBAAgB,EAAE;AACjC,WAAQ,OAAO,gBAAgB,EAAE;AACjC,WAAQ,MAAM,gBAAgB,EAAE;AAChC"}
@@ -1,2 +1,116 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../chunk-Bmb41Sf3.cjs`);const e=require(`./spawnPosix.cjs`),t=require(`./spawnWin32.cjs`);let n=require(`node:path`);const r=r=>{if(!r||Array.isArray(r)&&r.length===0)throw Error(`Invalid command`);let i=Array.isArray(r)?r.join(` `):r,a=Array.isArray(r),o=a?r[0]:i,s=a?r.slice(1):[],c=(0,n.join)(process.cwd(),`node_modules`,`.bin`),l=Object.keys(process.env).find(e=>e.toLowerCase()===`path`)??`PATH`,u=[c,process.env[l]??``].filter(Boolean).join(n.delimiter),d={...process.env,[l]:u},f=process.platform===`win32`,p=f?t.spawnWin32:e.spawnPosix,m={cwd:process.cwd(),stdio:`inherit`,env:d,shell:f},h=a?s.length===0&&/\s/.test(o)?f?p(process.env.ComSpec??`cmd.exe`,[`/d`,`/s`,`/c`,o],m):p(process.env.SHELL??`/bin/sh`,[`-c`,o],m):p(o,s,m):f?p(process.env.ComSpec??`cmd.exe`,[`/d`,`/s`,`/c`,i],m):p(process.env.SHELL??`/bin/sh`,[`-c`,i],m),g=new Promise((e,t)=>{h.on(`error`,e=>{try{console.error(`[runParallel] Failed to start: ${e?.message??String(e)}`)}catch{}y(),t(e)}),h.on(`exit`,(n,r)=>{y(),n===0||new Set([129,130,131,143]).has(n??-1)||r&&[`SIGINT`,`SIGTERM`,`SIGQUIT`,`SIGHUP`].includes(r)?e():t(Object.assign(Error(`Parallel process failed`),{code:n,signal:r}))})}),_=()=>{try{h.kill(`SIGTERM`)}catch{}},v=[{event:`SIGINT`,handler:_},{event:`SIGTERM`,handler:_},{event:`SIGQUIT`,handler:_},{event:`SIGHUP`,handler:_}];v.forEach(({event:e,handler:t})=>{process.on(e,t)});let y=()=>{v.forEach(({event:e,handler:t})=>{process.off(e,t)})};return{kill:()=>{try{h.kill(`SIGTERM`)}catch{}},result:g,commandText:i}};exports.runParallel=r;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
+ const require_utils_runParallel_spawnPosix = require('./spawnPosix.cjs');
4
+ const require_utils_runParallel_spawnWin32 = require('./spawnWin32.cjs');
5
+ let node_path = require("node:path");
6
+
7
+ //#region src/utils/runParallel/index.ts
8
+ /**
9
+ * Start a cross-platform parallel process using npm-run-all approach.
10
+ * Accepts either a single string (e.g., 'next start') or an array of tokens (e.g., ['next', 'start']).
11
+ */
12
+ const runParallel = (proc) => {
13
+ if (!proc || Array.isArray(proc) && proc.length === 0) throw new Error("Invalid command");
14
+ const commandText = Array.isArray(proc) ? proc.join(" ") : proc;
15
+ const isArray = Array.isArray(proc);
16
+ const command = isArray ? proc[0] : commandText;
17
+ const args = isArray ? proc.slice(1) : [];
18
+ const cwdBin = (0, node_path.join)(process.cwd(), "node_modules", ".bin");
19
+ const PATH_KEY = Object.keys(process.env).find((key) => key.toLowerCase() === "path") ?? "PATH";
20
+ const extendedPath = [cwdBin, process.env[PATH_KEY] ?? ""].filter(Boolean).join(node_path.delimiter);
21
+ const childEnv = {
22
+ ...process.env,
23
+ [PATH_KEY]: extendedPath
24
+ };
25
+ const isWin = process.platform === "win32";
26
+ const spawnFunc = isWin ? require_utils_runParallel_spawnWin32.spawnWin32 : require_utils_runParallel_spawnPosix.spawnPosix;
27
+ const spawnOptions = {
28
+ cwd: process.cwd(),
29
+ stdio: "inherit",
30
+ env: childEnv,
31
+ shell: isWin
32
+ };
33
+ const child = isArray ? args.length === 0 && /\s/.test(command) ? isWin ? spawnFunc(process.env.ComSpec ?? "cmd.exe", [
34
+ "/d",
35
+ "/s",
36
+ "/c",
37
+ command
38
+ ], spawnOptions) : spawnFunc(process.env.SHELL ?? "/bin/sh", ["-c", command], spawnOptions) : spawnFunc(command, args, spawnOptions) : isWin ? spawnFunc(process.env.ComSpec ?? "cmd.exe", [
39
+ "/d",
40
+ "/s",
41
+ "/c",
42
+ commandText
43
+ ], spawnOptions) : spawnFunc(process.env.SHELL ?? "/bin/sh", ["-c", commandText], spawnOptions);
44
+ const result = new Promise((resolve, reject) => {
45
+ child.on("error", (err) => {
46
+ try {
47
+ console.error(`[runParallel] Failed to start: ${err?.message ?? String(err)}`);
48
+ } catch {}
49
+ cleanupHandlers();
50
+ reject(err);
51
+ });
52
+ child.on("exit", (code, signal) => {
53
+ cleanupHandlers();
54
+ if (code === 0 || new Set([
55
+ 129,
56
+ 130,
57
+ 131,
58
+ 143
59
+ ]).has(code ?? -1) || signal && [
60
+ "SIGINT",
61
+ "SIGTERM",
62
+ "SIGQUIT",
63
+ "SIGHUP"
64
+ ].includes(signal)) resolve();
65
+ else reject(Object.assign(/* @__PURE__ */ new Error("Parallel process failed"), {
66
+ code,
67
+ signal
68
+ }));
69
+ });
70
+ });
71
+ const cleanup = () => {
72
+ try {
73
+ child.kill("SIGTERM");
74
+ } catch {}
75
+ };
76
+ const signalHandlers = [
77
+ {
78
+ event: "SIGINT",
79
+ handler: cleanup
80
+ },
81
+ {
82
+ event: "SIGTERM",
83
+ handler: cleanup
84
+ },
85
+ {
86
+ event: "SIGQUIT",
87
+ handler: cleanup
88
+ },
89
+ {
90
+ event: "SIGHUP",
91
+ handler: cleanup
92
+ }
93
+ ];
94
+ signalHandlers.forEach(({ event, handler }) => {
95
+ process.on(event, handler);
96
+ });
97
+ const cleanupHandlers = () => {
98
+ signalHandlers.forEach(({ event, handler }) => {
99
+ process.off(event, handler);
100
+ });
101
+ };
102
+ const kill = () => {
103
+ try {
104
+ child.kill("SIGTERM");
105
+ } catch {}
106
+ };
107
+ return {
108
+ kill,
109
+ result,
110
+ commandText
111
+ };
112
+ };
113
+
114
+ //#endregion
115
+ exports.runParallel = runParallel;
2
116
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["delimiter","spawnWin32","spawnPosix"],"sources":["../../../../src/utils/runParallel/index.ts"],"sourcesContent":["import { delimiter, join } from 'node:path';\nimport { spawnPosix } from './spawnPosix';\nimport { spawnWin32 } from './spawnWin32';\n\nexport type ParallelHandle = {\n kill: () => void;\n result: Promise<any>;\n commandText: string;\n};\n\n/**\n * Start a cross-platform parallel process using npm-run-all approach.\n * Accepts either a single string (e.g., 'next start') or an array of tokens (e.g., ['next', 'start']).\n */\nexport const runParallel = (proc?: string | string[]): ParallelHandle => {\n if (!proc || (Array.isArray(proc) && proc.length === 0))\n throw new Error('Invalid command');\n\n const commandText = Array.isArray(proc) ? proc.join(' ') : proc;\n\n const isArray = Array.isArray(proc);\n const command = isArray ? (proc as string[])[0] : commandText;\n const args = isArray ? (proc as string[]).slice(1) : [];\n\n // Ensure local binaries (node_modules/.bin) are resolvable\n const cwdBin = join(process.cwd(), 'node_modules', '.bin');\n const PATH_KEY =\n Object.keys(process.env).find((key) => key.toLowerCase() === 'path') ??\n 'PATH';\n\n const extendedPath = [cwdBin, process.env[PATH_KEY] ?? '']\n .filter(Boolean)\n .join(delimiter);\n\n const childEnv = {\n ...process.env,\n [PATH_KEY]: extendedPath,\n } as NodeJS.ProcessEnv;\n\n const isWin = process.platform === 'win32';\n const spawnFunc = isWin ? spawnWin32 : spawnPosix;\n\n // Spawn options\n const spawnOptions = {\n cwd: process.cwd(),\n stdio: 'inherit' as const,\n env: childEnv,\n shell: isWin,\n };\n\n // Spawn the child process\n const child = isArray\n ? // If provided as a single string element that includes spaces, treat it like a shell command\n args.length === 0 && /\\s/.test(command)\n ? isWin\n ? spawnFunc(\n process.env.ComSpec ?? 'cmd.exe',\n ['/d', '/s', '/c', command],\n spawnOptions\n )\n : spawnFunc(\n process.env.SHELL ?? '/bin/sh',\n ['-c', command],\n spawnOptions\n )\n : spawnFunc(command, args, spawnOptions)\n : isWin\n ? spawnFunc(\n process.env.ComSpec ?? 'cmd.exe',\n ['/d', '/s', '/c', commandText],\n spawnOptions\n )\n : spawnFunc(\n process.env.SHELL ?? '/bin/sh',\n ['-c', commandText],\n spawnOptions\n );\n\n const result = new Promise<void>((resolve, reject) => {\n child.on('error', (err) => {\n try {\n console.error(\n `[runParallel] Failed to start: ${err?.message ?? String(err)}`\n );\n } catch {}\n cleanupHandlers();\n reject(err);\n });\n\n child.on('exit', (code, signal) => {\n cleanupHandlers();\n\n // Treat common termination signals as graceful exits, not failures\n const gracefulSignals = ['SIGINT', 'SIGTERM', 'SIGQUIT', 'SIGHUP'];\n // Also treat shell-convention exit codes (128 + signal number) as graceful:\n // 129 = SIGHUP, 130 = SIGINT, 131 = SIGQUIT, 143 = SIGTERM\n const gracefulSignalCodes = new Set([129, 130, 131, 143]);\n if (\n code === 0 ||\n gracefulSignalCodes.has(code ?? -1) ||\n (signal && gracefulSignals.includes(signal))\n ) {\n resolve();\n } else {\n reject(\n Object.assign(new Error('Parallel process failed'), { code, signal })\n );\n }\n });\n });\n\n const cleanup = () => {\n try {\n child.kill('SIGTERM');\n } catch {\n // Best effort\n }\n };\n\n const signalHandlers: { event: string; handler: (...args: any[]) => void }[] =\n [\n { event: 'SIGINT', handler: cleanup },\n { event: 'SIGTERM', handler: cleanup },\n { event: 'SIGQUIT', handler: cleanup },\n { event: 'SIGHUP', handler: cleanup },\n ];\n\n // Register signal handlers\n signalHandlers.forEach(({ event, handler }) => {\n process.on(event as any, handler as any);\n });\n\n const cleanupHandlers = () => {\n signalHandlers.forEach(({ event, handler }) => {\n process.off(event as any, handler as any);\n });\n };\n\n const kill = () => {\n try {\n child.kill('SIGTERM');\n } catch {\n // Best effort\n }\n };\n\n return { kill, result, commandText };\n};\n"],"mappings":"oMAcA,MAAa,EAAe,GAA6C,CACvE,GAAI,CAAC,GAAS,MAAM,QAAQ,EAAK,EAAI,EAAK,SAAW,EACnD,MAAU,MAAM,kBAAkB,CAEpC,IAAM,EAAc,MAAM,QAAQ,EAAK,CAAG,EAAK,KAAK,IAAI,CAAG,EAErD,EAAU,MAAM,QAAQ,EAAK,CAC7B,EAAU,EAAW,EAAkB,GAAK,EAC5C,EAAO,EAAW,EAAkB,MAAM,EAAE,CAAG,EAAE,CAGjD,GAAA,EAAA,EAAA,MAAc,QAAQ,KAAK,CAAE,eAAgB,OAAO,CACpD,EACJ,OAAO,KAAK,QAAQ,IAAI,CAAC,KAAM,GAAQ,EAAI,aAAa,GAAK,OAAO,EACpE,OAEI,EAAe,CAAC,EAAQ,QAAQ,IAAI,IAAa,GAAG,CACvD,OAAO,QAAQ,CACf,KAAKA,EAAAA,UAAU,CAEZ,EAAW,CACf,GAAG,QAAQ,KACV,GAAW,EACb,CAEK,EAAQ,QAAQ,WAAa,QAC7B,EAAY,EAAQC,EAAAA,WAAaC,EAAAA,WAGjC,EAAe,CACnB,IAAK,QAAQ,KAAK,CAClB,MAAO,UACP,IAAK,EACL,MAAO,EACR,CAGK,EAAQ,EAEV,EAAK,SAAW,GAAK,KAAK,KAAK,EAAQ,CACrC,EACE,EACE,QAAQ,IAAI,SAAW,UACvB,CAAC,KAAM,KAAM,KAAM,EAAQ,CAC3B,EACD,CACD,EACE,QAAQ,IAAI,OAAS,UACrB,CAAC,KAAM,EAAQ,CACf,EACD,CACH,EAAU,EAAS,EAAM,EAAa,CACxC,EACE,EACE,QAAQ,IAAI,SAAW,UACvB,CAAC,KAAM,KAAM,KAAM,EAAY,CAC/B,EACD,CACD,EACE,QAAQ,IAAI,OAAS,UACrB,CAAC,KAAM,EAAY,CACnB,EACD,CAED,EAAS,IAAI,SAAe,EAAS,IAAW,CACpD,EAAM,GAAG,QAAU,GAAQ,CACzB,GAAI,CACF,QAAQ,MACN,kCAAkC,GAAK,SAAW,OAAO,EAAI,GAC9D,MACK,EACR,GAAiB,CACjB,EAAO,EAAI,EACX,CAEF,EAAM,GAAG,QAAS,EAAM,IAAW,CACjC,GAAiB,CAQf,IAAS,GAFiB,IAAI,IAAI,CAAC,IAAK,IAAK,IAAK,IAAI,CAAC,CAGnC,IAAI,GAAQ,GAAG,EAClC,GAPqB,CAAC,SAAU,UAAW,UAAW,SAAS,CAOrC,SAAS,EAAO,CAE3C,GAAS,CAET,EACE,OAAO,OAAW,MAAM,0BAA0B,CAAE,CAAE,OAAM,SAAQ,CAAC,CACtE,EAEH,EACF,CAEI,MAAgB,CACpB,GAAI,CACF,EAAM,KAAK,UAAU,MACf,IAKJ,EACJ,CACE,CAAE,MAAO,SAAU,QAAS,EAAS,CACrC,CAAE,MAAO,UAAW,QAAS,EAAS,CACtC,CAAE,MAAO,UAAW,QAAS,EAAS,CACtC,CAAE,MAAO,SAAU,QAAS,EAAS,CACtC,CAGH,EAAe,SAAS,CAAE,QAAO,aAAc,CAC7C,QAAQ,GAAG,EAAc,EAAe,EACxC,CAEF,IAAM,MAAwB,CAC5B,EAAe,SAAS,CAAE,QAAO,aAAc,CAC7C,QAAQ,IAAI,EAAc,EAAe,EACzC,EAWJ,MAAO,CAAE,SARU,CACjB,GAAI,CACF,EAAM,KAAK,UAAU,MACf,IAKK,SAAQ,cAAa"}
1
+ {"version":3,"file":"index.cjs","names":["delimiter","spawnWin32","spawnPosix"],"sources":["../../../../src/utils/runParallel/index.ts"],"sourcesContent":["import { delimiter, join } from 'node:path';\nimport { spawnPosix } from './spawnPosix';\nimport { spawnWin32 } from './spawnWin32';\n\nexport type ParallelHandle = {\n kill: () => void;\n result: Promise<any>;\n commandText: string;\n};\n\n/**\n * Start a cross-platform parallel process using npm-run-all approach.\n * Accepts either a single string (e.g., 'next start') or an array of tokens (e.g., ['next', 'start']).\n */\nexport const runParallel = (proc?: string | string[]): ParallelHandle => {\n if (!proc || (Array.isArray(proc) && proc.length === 0))\n throw new Error('Invalid command');\n\n const commandText = Array.isArray(proc) ? proc.join(' ') : proc;\n\n const isArray = Array.isArray(proc);\n const command = isArray ? (proc as string[])[0] : commandText;\n const args = isArray ? (proc as string[]).slice(1) : [];\n\n // Ensure local binaries (node_modules/.bin) are resolvable\n const cwdBin = join(process.cwd(), 'node_modules', '.bin');\n const PATH_KEY =\n Object.keys(process.env).find((key) => key.toLowerCase() === 'path') ??\n 'PATH';\n\n const extendedPath = [cwdBin, process.env[PATH_KEY] ?? '']\n .filter(Boolean)\n .join(delimiter);\n\n const childEnv = {\n ...process.env,\n [PATH_KEY]: extendedPath,\n } as NodeJS.ProcessEnv;\n\n const isWin = process.platform === 'win32';\n const spawnFunc = isWin ? spawnWin32 : spawnPosix;\n\n // Spawn options\n const spawnOptions = {\n cwd: process.cwd(),\n stdio: 'inherit' as const,\n env: childEnv,\n shell: isWin,\n };\n\n // Spawn the child process\n const child = isArray\n ? // If provided as a single string element that includes spaces, treat it like a shell command\n args.length === 0 && /\\s/.test(command)\n ? isWin\n ? spawnFunc(\n process.env.ComSpec ?? 'cmd.exe',\n ['/d', '/s', '/c', command],\n spawnOptions\n )\n : spawnFunc(\n process.env.SHELL ?? '/bin/sh',\n ['-c', command],\n spawnOptions\n )\n : spawnFunc(command, args, spawnOptions)\n : isWin\n ? spawnFunc(\n process.env.ComSpec ?? 'cmd.exe',\n ['/d', '/s', '/c', commandText],\n spawnOptions\n )\n : spawnFunc(\n process.env.SHELL ?? '/bin/sh',\n ['-c', commandText],\n spawnOptions\n );\n\n const result = new Promise<void>((resolve, reject) => {\n child.on('error', (err) => {\n try {\n console.error(\n `[runParallel] Failed to start: ${err?.message ?? String(err)}`\n );\n } catch {}\n cleanupHandlers();\n reject(err);\n });\n\n child.on('exit', (code, signal) => {\n cleanupHandlers();\n\n // Treat common termination signals as graceful exits, not failures\n const gracefulSignals = ['SIGINT', 'SIGTERM', 'SIGQUIT', 'SIGHUP'];\n // Also treat shell-convention exit codes (128 + signal number) as graceful:\n // 129 = SIGHUP, 130 = SIGINT, 131 = SIGQUIT, 143 = SIGTERM\n const gracefulSignalCodes = new Set([129, 130, 131, 143]);\n if (\n code === 0 ||\n gracefulSignalCodes.has(code ?? -1) ||\n (signal && gracefulSignals.includes(signal))\n ) {\n resolve();\n } else {\n reject(\n Object.assign(new Error('Parallel process failed'), { code, signal })\n );\n }\n });\n });\n\n const cleanup = () => {\n try {\n child.kill('SIGTERM');\n } catch {\n // Best effort\n }\n };\n\n const signalHandlers: { event: string; handler: (...args: any[]) => void }[] =\n [\n { event: 'SIGINT', handler: cleanup },\n { event: 'SIGTERM', handler: cleanup },\n { event: 'SIGQUIT', handler: cleanup },\n { event: 'SIGHUP', handler: cleanup },\n ];\n\n // Register signal handlers\n signalHandlers.forEach(({ event, handler }) => {\n process.on(event as any, handler as any);\n });\n\n const cleanupHandlers = () => {\n signalHandlers.forEach(({ event, handler }) => {\n process.off(event as any, handler as any);\n });\n };\n\n const kill = () => {\n try {\n child.kill('SIGTERM');\n } catch {\n // Best effort\n }\n };\n\n return { kill, result, commandText };\n};\n"],"mappings":";;;;;;;;;;;AAcA,MAAa,eAAe,SAA6C;AACvE,KAAI,CAAC,QAAS,MAAM,QAAQ,KAAK,IAAI,KAAK,WAAW,EACnD,OAAM,IAAI,MAAM,kBAAkB;CAEpC,MAAM,cAAc,MAAM,QAAQ,KAAK,GAAG,KAAK,KAAK,IAAI,GAAG;CAE3D,MAAM,UAAU,MAAM,QAAQ,KAAK;CACnC,MAAM,UAAU,UAAW,KAAkB,KAAK;CAClD,MAAM,OAAO,UAAW,KAAkB,MAAM,EAAE,GAAG,EAAE;CAGvD,MAAM,6BAAc,QAAQ,KAAK,EAAE,gBAAgB,OAAO;CAC1D,MAAM,WACJ,OAAO,KAAK,QAAQ,IAAI,CAAC,MAAM,QAAQ,IAAI,aAAa,KAAK,OAAO,IACpE;CAEF,MAAM,eAAe,CAAC,QAAQ,QAAQ,IAAI,aAAa,GAAG,CACvD,OAAO,QAAQ,CACf,KAAKA,oBAAU;CAElB,MAAM,WAAW;EACf,GAAG,QAAQ;GACV,WAAW;EACb;CAED,MAAM,QAAQ,QAAQ,aAAa;CACnC,MAAM,YAAY,QAAQC,kDAAaC;CAGvC,MAAM,eAAe;EACnB,KAAK,QAAQ,KAAK;EAClB,OAAO;EACP,KAAK;EACL,OAAO;EACR;CAGD,MAAM,QAAQ,UAEV,KAAK,WAAW,KAAK,KAAK,KAAK,QAAQ,GACrC,QACE,UACE,QAAQ,IAAI,WAAW,WACvB;EAAC;EAAM;EAAM;EAAM;EAAQ,EAC3B,aACD,GACD,UACE,QAAQ,IAAI,SAAS,WACrB,CAAC,MAAM,QAAQ,EACf,aACD,GACH,UAAU,SAAS,MAAM,aAAa,GACxC,QACE,UACE,QAAQ,IAAI,WAAW,WACvB;EAAC;EAAM;EAAM;EAAM;EAAY,EAC/B,aACD,GACD,UACE,QAAQ,IAAI,SAAS,WACrB,CAAC,MAAM,YAAY,EACnB,aACD;CAEP,MAAM,SAAS,IAAI,SAAe,SAAS,WAAW;AACpD,QAAM,GAAG,UAAU,QAAQ;AACzB,OAAI;AACF,YAAQ,MACN,kCAAkC,KAAK,WAAW,OAAO,IAAI,GAC9D;WACK;AACR,oBAAiB;AACjB,UAAO,IAAI;IACX;AAEF,QAAM,GAAG,SAAS,MAAM,WAAW;AACjC,oBAAiB;AAOjB,OACE,SAAS,KAFiB,IAAI,IAAI;IAAC;IAAK;IAAK;IAAK;IAAI,CAAC,CAGnC,IAAI,QAAQ,GAAG,IAClC,UAPqB;IAAC;IAAU;IAAW;IAAW;IAAS,CAOrC,SAAS,OAAO,CAE3C,UAAS;OAET,QACE,OAAO,uBAAO,IAAI,MAAM,0BAA0B,EAAE;IAAE;IAAM;IAAQ,CAAC,CACtE;IAEH;GACF;CAEF,MAAM,gBAAgB;AACpB,MAAI;AACF,SAAM,KAAK,UAAU;UACf;;CAKV,MAAM,iBACJ;EACE;GAAE,OAAO;GAAU,SAAS;GAAS;EACrC;GAAE,OAAO;GAAW,SAAS;GAAS;EACtC;GAAE,OAAO;GAAW,SAAS;GAAS;EACtC;GAAE,OAAO;GAAU,SAAS;GAAS;EACtC;AAGH,gBAAe,SAAS,EAAE,OAAO,cAAc;AAC7C,UAAQ,GAAG,OAAc,QAAe;GACxC;CAEF,MAAM,wBAAwB;AAC5B,iBAAe,SAAS,EAAE,OAAO,cAAc;AAC7C,WAAQ,IAAI,OAAc,QAAe;IACzC;;CAGJ,MAAM,aAAa;AACjB,MAAI;AACF,SAAM,KAAK,UAAU;UACf;;AAKV,QAAO;EAAE;EAAM;EAAQ;EAAa"}
@@ -1,2 +1,146 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../chunk-Bmb41Sf3.cjs`),t=require(`./ps.cjs`),n=require(`./wmic.cjs`);let r=require(`node:os`);r=e.t(r);const i={darwin:`ps`,sunos:`ps`,freebsd:`ps`,netbsd:`ps`,win:`wmic`,linux:`ps`,aix:`ps`},a={ps:t.ps,wmic:n.wmic};let o=r.platform();o.startsWith(`win`)&&(o=`win`);const s=i[o],c=e=>{if(s===void 0){e(Error(r.platform()+` is not supported yet, please open an issue (https://github.com/simonepri/pidtree)`),void 0);return}let t=a[s];t(e)},l=(e,t,n)=>{let r,i;typeof t==`function`?(i=t,r={}):(i=n,r=typeof t==`object`?t:{});let a=parseInt(String(e),10);if(Number.isNaN(a)||a<-1){i(TypeError(`The pid provided is invalid`),void 0);return}c((e,t)=>{if(e){i(e,void 0);return}if(!t){i(Error(`Failed to get process list`),void 0);return}if(a===-1){let e=t.map(([e,t])=>r.advanced?{ppid:e,pid:t}:t);i(null,e);return}let n;for(let e=0;e<t.length;e++){if(t[e][1]===a){n=r.advanced?{ppid:t[e][0],pid:a}:a;break}t[e][0]===a&&(n=r.advanced?{pid:a}:a)}if(n===void 0){i(Error(`No matching pid found`),void 0);return}let o={},s=[...t];for(;s.length>0;){let e=s.pop();o[e[0]]?o[e[0]].push(e[1]):o[e[0]]=[e[1]]}let c=0,l=[n];for(;c<l.length;){let e=r.advanced?l[c++].pid:l[c++];if(!o[e])continue;let t=o[e].length;for(let n=0;n<t;n++)l.push(r.advanced?{ppid:e,pid:o[e][n]}:o[e][n]);delete o[e]}r.root||l.shift(),i(null,l)})},u=(e,t,n)=>new Promise((r,i)=>{e(t,n,(e,t)=>{if(e)return i(e);if(t===void 0)return i(Error(`No data returned`));r(t)})});String.prototype.startsWith||(String.prototype.startsWith=function(e){return this.substring(0,e.length)===e});const d=(e,t,n)=>{if(typeof t==`function`){l(e,void 0,t);return}if(typeof n==`function`){l(e,t,n);return}return u(l,e,t)};exports.list=d;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
+ const require_utils_runParallel_ps = require('./ps.cjs');
4
+ const require_utils_runParallel_wmic = require('./wmic.cjs');
5
+ let node_os = require("node:os");
6
+ node_os = require_runtime.__toESM(node_os);
7
+
8
+ //#region src/utils/runParallel/pidTree.ts
9
+ const platformToMethod = {
10
+ darwin: "ps",
11
+ sunos: "ps",
12
+ freebsd: "ps",
13
+ netbsd: "ps",
14
+ win: "wmic",
15
+ linux: "ps",
16
+ aix: "ps"
17
+ };
18
+ const methodToFn = {
19
+ ps: require_utils_runParallel_ps.ps,
20
+ wmic: require_utils_runParallel_wmic.wmic
21
+ };
22
+ let platform = node_os.platform();
23
+ if (platform.startsWith("win")) platform = "win";
24
+ const method = platformToMethod[platform];
25
+ /**
26
+ * Gets the list of all the pids of the system.
27
+ */
28
+ const getAll = (callback) => {
29
+ if (method === void 0) {
30
+ callback(/* @__PURE__ */ new Error(node_os.platform() + " is not supported yet, please open an issue (https://github.com/simonepri/pidtree)"), void 0);
31
+ return;
32
+ }
33
+ const listFn = methodToFn[method];
34
+ listFn(callback);
35
+ };
36
+ /**
37
+ * Get the list of children and grandchildren pids of the given PID.
38
+ * @param PID A PID. If -1 will return all the pids.
39
+ * @param options Optional options object.
40
+ * @param callback Called when the list is ready.
41
+ */
42
+ const pidtree = (PID, options, callback) => {
43
+ let normalizedOptions;
44
+ let normalizedCallback;
45
+ if (typeof options === "function") {
46
+ normalizedCallback = options;
47
+ normalizedOptions = {};
48
+ } else {
49
+ normalizedCallback = callback;
50
+ normalizedOptions = typeof options === "object" ? options : {};
51
+ }
52
+ const parsedPID = parseInt(String(PID), 10);
53
+ if (Number.isNaN(parsedPID) || parsedPID < -1) {
54
+ normalizedCallback(/* @__PURE__ */ new TypeError("The pid provided is invalid"), void 0);
55
+ return;
56
+ }
57
+ getAll((err, processList) => {
58
+ if (err) {
59
+ normalizedCallback(err, void 0);
60
+ return;
61
+ }
62
+ if (!processList) {
63
+ normalizedCallback(/* @__PURE__ */ new Error("Failed to get process list"), void 0);
64
+ return;
65
+ }
66
+ if (parsedPID === -1) {
67
+ const result = processList.map(([ppid, pid]) => normalizedOptions.advanced ? {
68
+ ppid,
69
+ pid
70
+ } : pid);
71
+ normalizedCallback(null, result);
72
+ return;
73
+ }
74
+ let root;
75
+ for (let l = 0; l < processList.length; l++) {
76
+ if (processList[l][1] === parsedPID) {
77
+ root = normalizedOptions.advanced ? {
78
+ ppid: processList[l][0],
79
+ pid: parsedPID
80
+ } : parsedPID;
81
+ break;
82
+ }
83
+ if (processList[l][0] === parsedPID) root = normalizedOptions.advanced ? { pid: parsedPID } : parsedPID;
84
+ }
85
+ if (root === void 0) {
86
+ normalizedCallback(/* @__PURE__ */ new Error("No matching pid found"), void 0);
87
+ return;
88
+ }
89
+ const tree = {};
90
+ const listCopy = [...processList];
91
+ while (listCopy.length > 0) {
92
+ const element = listCopy.pop();
93
+ if (tree[element[0]]) tree[element[0]].push(element[1]);
94
+ else tree[element[0]] = [element[1]];
95
+ }
96
+ let idx = 0;
97
+ const pids = [root];
98
+ while (idx < pids.length) {
99
+ const curpid = normalizedOptions.advanced ? pids[idx++].pid : pids[idx++];
100
+ if (!tree[curpid]) continue;
101
+ const length = tree[curpid].length;
102
+ for (let j = 0; j < length; j++) pids.push(normalizedOptions.advanced ? {
103
+ ppid: curpid,
104
+ pid: tree[curpid][j]
105
+ } : tree[curpid][j]);
106
+ delete tree[curpid];
107
+ }
108
+ if (!normalizedOptions.root) pids.shift();
109
+ normalizedCallback(null, pids);
110
+ });
111
+ };
112
+ const pify = (fn, arg1, arg2) => {
113
+ return new Promise((resolve, reject) => {
114
+ fn(arg1, arg2, (err, data) => {
115
+ if (err) return reject(err);
116
+ if (data === void 0) return reject(/* @__PURE__ */ new Error("No data returned"));
117
+ resolve(data);
118
+ });
119
+ });
120
+ };
121
+ /* istanbul ignore if */
122
+ if (!String.prototype.startsWith) String.prototype.startsWith = function(suffix) {
123
+ return this.substring(0, suffix.length) === suffix;
124
+ };
125
+ /**
126
+ * Get the list of children pids of the given pid.
127
+ * @param pid A PID. If -1 will return all the pids.
128
+ * @param options Optional options object.
129
+ * @param callback Called when the list is ready. If not provided a promise is returned instead.
130
+ * @returns Only when the callback is not provided.
131
+ */
132
+ const list = (pid, options, callback) => {
133
+ if (typeof options === "function") {
134
+ pidtree(pid, void 0, options);
135
+ return;
136
+ }
137
+ if (typeof callback === "function") {
138
+ pidtree(pid, options, callback);
139
+ return;
140
+ }
141
+ return pify(pidtree, pid, options);
142
+ };
143
+
144
+ //#endregion
145
+ exports.list = list;
2
146
  //# sourceMappingURL=pidTree.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"pidTree.cjs","names":["os"],"sources":["../../../../src/utils/runParallel/pidTree.ts"],"sourcesContent":["import * as os from 'node:os';\nimport { ps } from './ps';\nimport { wmic } from './wmic';\n\ntype Platform =\n | 'darwin'\n | 'sunos'\n | 'freebsd'\n | 'netbsd'\n | 'win'\n | 'linux'\n | 'aix';\ntype Method = 'ps' | 'wmic';\n\ntype ProcessList = [number, number][]; // [PPID, PID][]\n\ninterface ListOptions {\n root?: boolean;\n advanced?: boolean;\n}\n\ntype ProcessInfo = { pid: number; ppid?: number };\ntype ResultType<T extends ListOptions | undefined> = T extends {\n advanced: true;\n}\n ? ProcessInfo[]\n : number[];\n\ntype ProcessListCallback = (err: Error | null, list?: ProcessList) => void;\ntype ListCallback<T extends ListOptions | undefined> = (\n err: Error | null,\n list?: ResultType<T>\n) => void;\n\ntype ProcessListFn = (callback: ProcessListCallback) => void;\n\nconst platformToMethod: Record<Platform, Method> = {\n darwin: 'ps',\n sunos: 'ps',\n freebsd: 'ps',\n netbsd: 'ps',\n win: 'wmic',\n linux: 'ps',\n aix: 'ps',\n};\n\nconst methodToFn: Record<Method, ProcessListFn> = {\n ps,\n wmic,\n};\n\nlet platform: string = os.platform();\nif (platform.startsWith('win')) {\n platform = 'win';\n}\n\nconst method: Method | undefined = platformToMethod[platform as Platform];\n\n/**\n * Gets the list of all the pids of the system.\n */\nconst getAll = (callback: ProcessListCallback): void => {\n if (method === undefined) {\n callback(\n new Error(\n os.platform() +\n ' is not supported yet, please open an issue (https://github.com/simonepri/pidtree)'\n ),\n undefined\n );\n return;\n }\n\n const listFn = methodToFn[method];\n listFn(callback);\n};\n\n/**\n * Get the list of children and grandchildren pids of the given PID.\n * @param PID A PID. If -1 will return all the pids.\n * @param options Optional options object.\n * @param callback Called when the list is ready.\n */\nconst pidtree = <T extends ListOptions | undefined>(\n PID: number | string,\n options: T | ListCallback<T> | undefined,\n callback?: ListCallback<T>\n): void => {\n let normalizedOptions: ListOptions;\n let normalizedCallback: ListCallback<T>;\n\n if (typeof options === 'function') {\n normalizedCallback = options;\n normalizedOptions = {};\n } else {\n normalizedCallback = callback!;\n normalizedOptions = typeof options === 'object' ? options : {};\n }\n\n const parsedPID = parseInt(String(PID), 10);\n if (Number.isNaN(parsedPID) || parsedPID < -1) {\n normalizedCallback(\n new TypeError('The pid provided is invalid') as Error,\n undefined\n );\n return;\n }\n\n getAll((err, processList) => {\n if (err) {\n normalizedCallback(err, undefined);\n return;\n }\n\n if (!processList) {\n normalizedCallback(new Error('Failed to get process list'), undefined);\n return;\n }\n\n // If the user wants the whole list just return it\n if (parsedPID === -1) {\n const result = processList.map(([ppid, pid]) =>\n normalizedOptions.advanced ? { ppid, pid } : pid\n ) as ResultType<T>;\n\n normalizedCallback(null, result);\n return;\n }\n\n let root: ProcessInfo | number | undefined;\n for (let l = 0; l < processList.length; l++) {\n if (processList[l][1] === parsedPID) {\n root = normalizedOptions.advanced\n ? { ppid: processList[l][0], pid: parsedPID }\n : parsedPID;\n break;\n }\n\n if (processList[l][0] === parsedPID) {\n root = normalizedOptions.advanced ? { pid: parsedPID } : parsedPID; // Special pids like 0 on *nix\n }\n }\n\n if (root === undefined) {\n normalizedCallback(new Error('No matching pid found'), undefined);\n return;\n }\n\n // Build the adjacency Hash Map (pid -> [children of pid])\n const tree: Record<number, number[]> = {};\n const listCopy = [...processList];\n while (listCopy.length > 0) {\n const element = listCopy.pop()!;\n if (tree[element[0]]) {\n tree[element[0]].push(element[1]);\n } else {\n tree[element[0]] = [element[1]];\n }\n }\n\n // Starting by the PID provided by the user, traverse the tree using the\n // adjacency Hash Map until the whole subtree is visited.\n // Each pid encountered while visiting is added to the pids array.\n let idx = 0;\n const pids: (ProcessInfo | number)[] = [root];\n while (idx < pids.length) {\n const curpid = normalizedOptions.advanced\n ? (pids[idx++] as ProcessInfo).pid\n : (pids[idx++] as number);\n if (!tree[curpid]) continue;\n const length = tree[curpid].length;\n for (let j = 0; j < length; j++) {\n pids.push(\n normalizedOptions.advanced\n ? { ppid: curpid, pid: tree[curpid][j] }\n : tree[curpid][j]\n );\n }\n\n delete tree[curpid];\n }\n\n if (!normalizedOptions.root) {\n pids.shift(); // Remove root\n }\n\n normalizedCallback(null, pids as ResultType<T>);\n });\n};\n\nconst pify = <T extends ListOptions | undefined>(\n fn: typeof pidtree,\n arg1: number | string,\n arg2: T | undefined\n): Promise<ResultType<T>> => {\n return new Promise((resolve, reject) => {\n fn(arg1, arg2, (err, data) => {\n if (err) return reject(err);\n if (data === undefined) {\n return reject(new Error('No data returned'));\n }\n resolve(data);\n });\n });\n};\n\n// Node versions prior to 4.0.0 do not define have `startsWith`.\n/* istanbul ignore if */\nif (!String.prototype.startsWith) {\n String.prototype.startsWith = function (suffix: string): boolean {\n return this.substring(0, suffix.length) === suffix;\n };\n}\n\n/**\n * Get the list of children pids of the given pid.\n * @param pid A PID. If -1 will return all the pids.\n * @param options Optional options object.\n * @param callback Called when the list is ready. If not provided a promise is returned instead.\n * @returns Only when the callback is not provided.\n */\nexport const list = <T extends ListOptions | undefined>(\n pid: number | string,\n options?: T | ListCallback<T>,\n callback?: ListCallback<T>\n): Promise<ResultType<T>> | undefined => {\n if (typeof options === 'function') {\n pidtree(pid, undefined, options);\n return;\n }\n\n if (typeof callback === 'function') {\n pidtree(pid, options, callback);\n return;\n }\n\n return pify(pidtree, pid, options);\n};\n"],"mappings":"+LAoCA,MAAM,EAA6C,CACjD,OAAQ,KACR,MAAO,KACP,QAAS,KACT,OAAQ,KACR,IAAK,OACL,MAAO,KACP,IAAK,KACN,CAEK,EAA4C,CAChD,GAAA,EAAA,GACA,KAAA,EAAA,KACD,CAED,IAAI,EAAmBA,EAAG,UAAU,CAChC,EAAS,WAAW,MAAM,GAC5B,EAAW,OAGb,MAAM,EAA6B,EAAiB,GAK9C,EAAU,GAAwC,CACtD,GAAI,IAAW,IAAA,GAAW,CACxB,EACM,MACFA,EAAG,UAAU,CACX,qFACH,CACD,IAAA,GACD,CACD,OAGF,IAAM,EAAS,EAAW,GAC1B,EAAO,EAAS,EASZ,GACJ,EACA,EACA,IACS,CACT,IAAI,EACA,EAEA,OAAO,GAAY,YACrB,EAAqB,EACrB,EAAoB,EAAE,GAEtB,EAAqB,EACrB,EAAoB,OAAO,GAAY,SAAW,EAAU,EAAE,EAGhE,IAAM,EAAY,SAAS,OAAO,EAAI,CAAE,GAAG,CAC3C,GAAI,OAAO,MAAM,EAAU,EAAI,EAAY,GAAI,CAC7C,EACM,UAAU,8BAA8B,CAC5C,IAAA,GACD,CACD,OAGF,GAAQ,EAAK,IAAgB,CAC3B,GAAI,EAAK,CACP,EAAmB,EAAK,IAAA,GAAU,CAClC,OAGF,GAAI,CAAC,EAAa,CAChB,EAAuB,MAAM,6BAA6B,CAAE,IAAA,GAAU,CACtE,OAIF,GAAI,IAAc,GAAI,CACpB,IAAM,EAAS,EAAY,KAAK,CAAC,EAAM,KACrC,EAAkB,SAAW,CAAE,OAAM,MAAK,CAAG,EAC9C,CAED,EAAmB,KAAM,EAAO,CAChC,OAGF,IAAI,EACJ,IAAK,IAAI,EAAI,EAAG,EAAI,EAAY,OAAQ,IAAK,CAC3C,GAAI,EAAY,GAAG,KAAO,EAAW,CACnC,EAAO,EAAkB,SACrB,CAAE,KAAM,EAAY,GAAG,GAAI,IAAK,EAAW,CAC3C,EACJ,MAGE,EAAY,GAAG,KAAO,IACxB,EAAO,EAAkB,SAAW,CAAE,IAAK,EAAW,CAAG,GAI7D,GAAI,IAAS,IAAA,GAAW,CACtB,EAAuB,MAAM,wBAAwB,CAAE,IAAA,GAAU,CACjE,OAIF,IAAM,EAAiC,EAAE,CACnC,EAAW,CAAC,GAAG,EAAY,CACjC,KAAO,EAAS,OAAS,GAAG,CAC1B,IAAM,EAAU,EAAS,KAAK,CAC1B,EAAK,EAAQ,IACf,EAAK,EAAQ,IAAI,KAAK,EAAQ,GAAG,CAEjC,EAAK,EAAQ,IAAM,CAAC,EAAQ,GAAG,CAOnC,IAAI,EAAM,EACJ,EAAiC,CAAC,EAAK,CAC7C,KAAO,EAAM,EAAK,QAAQ,CACxB,IAAM,EAAS,EAAkB,SAC5B,EAAK,KAAuB,IAC5B,EAAK,KACV,GAAI,CAAC,EAAK,GAAS,SACnB,IAAM,EAAS,EAAK,GAAQ,OAC5B,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,IAC1B,EAAK,KACH,EAAkB,SACd,CAAE,KAAM,EAAQ,IAAK,EAAK,GAAQ,GAAI,CACtC,EAAK,GAAQ,GAClB,CAGH,OAAO,EAAK,GAGT,EAAkB,MACrB,EAAK,OAAO,CAGd,EAAmB,KAAM,EAAsB,EAC/C,EAGE,GACJ,EACA,EACA,IAEO,IAAI,SAAS,EAAS,IAAW,CACtC,EAAG,EAAM,GAAO,EAAK,IAAS,CAC5B,GAAI,EAAK,OAAO,EAAO,EAAI,CAC3B,GAAI,IAAS,IAAA,GACX,OAAO,EAAW,MAAM,mBAAmB,CAAC,CAE9C,EAAQ,EAAK,EACb,EACF,CAKC,OAAO,UAAU,aACpB,OAAO,UAAU,WAAa,SAAU,EAAyB,CAC/D,OAAO,KAAK,UAAU,EAAG,EAAO,OAAO,GAAK,IAWhD,MAAa,GACX,EACA,EACA,IACuC,CACvC,GAAI,OAAO,GAAY,WAAY,CACjC,EAAQ,EAAK,IAAA,GAAW,EAAQ,CAChC,OAGF,GAAI,OAAO,GAAa,WAAY,CAClC,EAAQ,EAAK,EAAS,EAAS,CAC/B,OAGF,OAAO,EAAK,EAAS,EAAK,EAAQ"}
1
+ {"version":3,"file":"pidTree.cjs","names":["os"],"sources":["../../../../src/utils/runParallel/pidTree.ts"],"sourcesContent":["import * as os from 'node:os';\nimport { ps } from './ps';\nimport { wmic } from './wmic';\n\ntype Platform =\n | 'darwin'\n | 'sunos'\n | 'freebsd'\n | 'netbsd'\n | 'win'\n | 'linux'\n | 'aix';\ntype Method = 'ps' | 'wmic';\n\ntype ProcessList = [number, number][]; // [PPID, PID][]\n\ninterface ListOptions {\n root?: boolean;\n advanced?: boolean;\n}\n\ntype ProcessInfo = { pid: number; ppid?: number };\ntype ResultType<T extends ListOptions | undefined> = T extends {\n advanced: true;\n}\n ? ProcessInfo[]\n : number[];\n\ntype ProcessListCallback = (err: Error | null, list?: ProcessList) => void;\ntype ListCallback<T extends ListOptions | undefined> = (\n err: Error | null,\n list?: ResultType<T>\n) => void;\n\ntype ProcessListFn = (callback: ProcessListCallback) => void;\n\nconst platformToMethod: Record<Platform, Method> = {\n darwin: 'ps',\n sunos: 'ps',\n freebsd: 'ps',\n netbsd: 'ps',\n win: 'wmic',\n linux: 'ps',\n aix: 'ps',\n};\n\nconst methodToFn: Record<Method, ProcessListFn> = {\n ps,\n wmic,\n};\n\nlet platform: string = os.platform();\nif (platform.startsWith('win')) {\n platform = 'win';\n}\n\nconst method: Method | undefined = platformToMethod[platform as Platform];\n\n/**\n * Gets the list of all the pids of the system.\n */\nconst getAll = (callback: ProcessListCallback): void => {\n if (method === undefined) {\n callback(\n new Error(\n os.platform() +\n ' is not supported yet, please open an issue (https://github.com/simonepri/pidtree)'\n ),\n undefined\n );\n return;\n }\n\n const listFn = methodToFn[method];\n listFn(callback);\n};\n\n/**\n * Get the list of children and grandchildren pids of the given PID.\n * @param PID A PID. If -1 will return all the pids.\n * @param options Optional options object.\n * @param callback Called when the list is ready.\n */\nconst pidtree = <T extends ListOptions | undefined>(\n PID: number | string,\n options: T | ListCallback<T> | undefined,\n callback?: ListCallback<T>\n): void => {\n let normalizedOptions: ListOptions;\n let normalizedCallback: ListCallback<T>;\n\n if (typeof options === 'function') {\n normalizedCallback = options;\n normalizedOptions = {};\n } else {\n normalizedCallback = callback!;\n normalizedOptions = typeof options === 'object' ? options : {};\n }\n\n const parsedPID = parseInt(String(PID), 10);\n if (Number.isNaN(parsedPID) || parsedPID < -1) {\n normalizedCallback(\n new TypeError('The pid provided is invalid') as Error,\n undefined\n );\n return;\n }\n\n getAll((err, processList) => {\n if (err) {\n normalizedCallback(err, undefined);\n return;\n }\n\n if (!processList) {\n normalizedCallback(new Error('Failed to get process list'), undefined);\n return;\n }\n\n // If the user wants the whole list just return it\n if (parsedPID === -1) {\n const result = processList.map(([ppid, pid]) =>\n normalizedOptions.advanced ? { ppid, pid } : pid\n ) as ResultType<T>;\n\n normalizedCallback(null, result);\n return;\n }\n\n let root: ProcessInfo | number | undefined;\n for (let l = 0; l < processList.length; l++) {\n if (processList[l][1] === parsedPID) {\n root = normalizedOptions.advanced\n ? { ppid: processList[l][0], pid: parsedPID }\n : parsedPID;\n break;\n }\n\n if (processList[l][0] === parsedPID) {\n root = normalizedOptions.advanced ? { pid: parsedPID } : parsedPID; // Special pids like 0 on *nix\n }\n }\n\n if (root === undefined) {\n normalizedCallback(new Error('No matching pid found'), undefined);\n return;\n }\n\n // Build the adjacency Hash Map (pid -> [children of pid])\n const tree: Record<number, number[]> = {};\n const listCopy = [...processList];\n while (listCopy.length > 0) {\n const element = listCopy.pop()!;\n if (tree[element[0]]) {\n tree[element[0]].push(element[1]);\n } else {\n tree[element[0]] = [element[1]];\n }\n }\n\n // Starting by the PID provided by the user, traverse the tree using the\n // adjacency Hash Map until the whole subtree is visited.\n // Each pid encountered while visiting is added to the pids array.\n let idx = 0;\n const pids: (ProcessInfo | number)[] = [root];\n while (idx < pids.length) {\n const curpid = normalizedOptions.advanced\n ? (pids[idx++] as ProcessInfo).pid\n : (pids[idx++] as number);\n if (!tree[curpid]) continue;\n const length = tree[curpid].length;\n for (let j = 0; j < length; j++) {\n pids.push(\n normalizedOptions.advanced\n ? { ppid: curpid, pid: tree[curpid][j] }\n : tree[curpid][j]\n );\n }\n\n delete tree[curpid];\n }\n\n if (!normalizedOptions.root) {\n pids.shift(); // Remove root\n }\n\n normalizedCallback(null, pids as ResultType<T>);\n });\n};\n\nconst pify = <T extends ListOptions | undefined>(\n fn: typeof pidtree,\n arg1: number | string,\n arg2: T | undefined\n): Promise<ResultType<T>> => {\n return new Promise((resolve, reject) => {\n fn(arg1, arg2, (err, data) => {\n if (err) return reject(err);\n if (data === undefined) {\n return reject(new Error('No data returned'));\n }\n resolve(data);\n });\n });\n};\n\n// Node versions prior to 4.0.0 do not define have `startsWith`.\n/* istanbul ignore if */\nif (!String.prototype.startsWith) {\n String.prototype.startsWith = function (suffix: string): boolean {\n return this.substring(0, suffix.length) === suffix;\n };\n}\n\n/**\n * Get the list of children pids of the given pid.\n * @param pid A PID. If -1 will return all the pids.\n * @param options Optional options object.\n * @param callback Called when the list is ready. If not provided a promise is returned instead.\n * @returns Only when the callback is not provided.\n */\nexport const list = <T extends ListOptions | undefined>(\n pid: number | string,\n options?: T | ListCallback<T>,\n callback?: ListCallback<T>\n): Promise<ResultType<T>> | undefined => {\n if (typeof options === 'function') {\n pidtree(pid, undefined, options);\n return;\n }\n\n if (typeof callback === 'function') {\n pidtree(pid, options, callback);\n return;\n }\n\n return pify(pidtree, pid, options);\n};\n"],"mappings":"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"}