@opensumi/ide-components 1.1.4-next-1641353261.0

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 (409) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +65 -0
  3. package/dist/fonts/loading-dark.svg +52 -0
  4. package/dist/fonts/loading-hc.svg +52 -0
  5. package/dist/fonts/loading.svg +52 -0
  6. package/dist/index.css +1 -0
  7. package/dist/index.js +27789 -0
  8. package/lib/badge/index.d.ts +4 -0
  9. package/lib/badge/index.d.ts.map +1 -0
  10. package/lib/badge/index.js +13 -0
  11. package/lib/badge/index.js.map +1 -0
  12. package/lib/badge/styles.less +17 -0
  13. package/lib/button/index.d.ts +54 -0
  14. package/lib/button/index.d.ts.map +1 -0
  15. package/lib/button/index.js +67 -0
  16. package/lib/button/index.js.map +1 -0
  17. package/lib/button/style.less +251 -0
  18. package/lib/checkbox/index.d.ts +9 -0
  19. package/lib/checkbox/index.d.ts.map +1 -0
  20. package/lib/checkbox/index.js +27 -0
  21. package/lib/checkbox/index.js.map +1 -0
  22. package/lib/checkbox/style.less +80 -0
  23. package/lib/click-outside/index.d.ts +6 -0
  24. package/lib/click-outside/index.d.ts.map +1 -0
  25. package/lib/click-outside/index.js +27 -0
  26. package/lib/click-outside/index.js.map +1 -0
  27. package/lib/common.d.ts +7 -0
  28. package/lib/common.d.ts.map +1 -0
  29. package/lib/common.js +11 -0
  30. package/lib/common.js.map +1 -0
  31. package/lib/dialog/index.d.ts +26 -0
  32. package/lib/dialog/index.d.ts.map +1 -0
  33. package/lib/dialog/index.js +30 -0
  34. package/lib/dialog/index.js.map +1 -0
  35. package/lib/dialog/styles.less +85 -0
  36. package/lib/dropdown/dropdown.d.ts +48 -0
  37. package/lib/dropdown/dropdown.d.ts.map +1 -0
  38. package/lib/dropdown/dropdown.js +80 -0
  39. package/lib/dropdown/dropdown.js.map +1 -0
  40. package/lib/dropdown/index.d.ts +5 -0
  41. package/lib/dropdown/index.d.ts.map +1 -0
  42. package/lib/dropdown/index.js +8 -0
  43. package/lib/dropdown/index.js.map +1 -0
  44. package/lib/dropdown/style.less +254 -0
  45. package/lib/icon/icon.d.ts +33 -0
  46. package/lib/icon/icon.d.ts.map +1 -0
  47. package/lib/icon/icon.js +70 -0
  48. package/lib/icon/icon.js.map +1 -0
  49. package/lib/icon/iconfont/iconManager.d.ts +189 -0
  50. package/lib/icon/iconfont/iconManager.d.ts.map +1 -0
  51. package/lib/icon/iconfont/iconManager.js +67 -0
  52. package/lib/icon/iconfont/iconManager.js.map +1 -0
  53. package/lib/icon/iconfont/iconMap.d.ts +162 -0
  54. package/lib/icon/iconfont/iconMap.d.ts.map +1 -0
  55. package/lib/icon/iconfont/iconMap.js +167 -0
  56. package/lib/icon/iconfont/iconMap.js.map +1 -0
  57. package/lib/icon/iconfont/iconfont.css +654 -0
  58. package/lib/icon/iconfont/iconfont.eot +0 -0
  59. package/lib/icon/iconfont/iconfont.html +1549 -0
  60. package/lib/icon/iconfont/iconfont.svg +337 -0
  61. package/lib/icon/iconfont/iconfont.ttf +0 -0
  62. package/lib/icon/iconfont/iconfont.woff +0 -0
  63. package/lib/icon/iconfont/iconfont.woff2 +0 -0
  64. package/lib/icon/iconfont-cn.d.ts +15 -0
  65. package/lib/icon/iconfont-cn.d.ts.map +1 -0
  66. package/lib/icon/iconfont-cn.js +76 -0
  67. package/lib/icon/iconfont-cn.js.map +1 -0
  68. package/lib/icon/index.d.ts +4 -0
  69. package/lib/icon/index.d.ts.map +1 -0
  70. package/lib/icon/index.js +9 -0
  71. package/lib/icon/index.js.map +1 -0
  72. package/lib/icon/styles.less +115 -0
  73. package/lib/icon/util.d.ts +29 -0
  74. package/lib/icon/util.d.ts.map +1 -0
  75. package/lib/icon/util.js +53 -0
  76. package/lib/icon/util.js.map +1 -0
  77. package/lib/index.d.ts +22 -0
  78. package/lib/index.d.ts.map +1 -0
  79. package/lib/index.js +25 -0
  80. package/lib/index.js.map +1 -0
  81. package/lib/input/HistoryInputBox.d.ts +38 -0
  82. package/lib/input/HistoryInputBox.d.ts.map +1 -0
  83. package/lib/input/HistoryInputBox.js +108 -0
  84. package/lib/input/HistoryInputBox.js.map +1 -0
  85. package/lib/input/Input.d.ts +43 -0
  86. package/lib/input/Input.d.ts.map +1 -0
  87. package/lib/input/Input.js +122 -0
  88. package/lib/input/Input.js.map +1 -0
  89. package/lib/input/ProxiedInput.d.ts +8 -0
  90. package/lib/input/ProxiedInput.d.ts.map +1 -0
  91. package/lib/input/ProxiedInput.js +67 -0
  92. package/lib/input/ProxiedInput.js.map +1 -0
  93. package/lib/input/TextArea.d.ts +6 -0
  94. package/lib/input/TextArea.d.ts.map +1 -0
  95. package/lib/input/TextArea.js +9 -0
  96. package/lib/input/TextArea.js.map +1 -0
  97. package/lib/input/ValidateInput.d.ts +20 -0
  98. package/lib/input/ValidateInput.d.ts.map +1 -0
  99. package/lib/input/ValidateInput.js +59 -0
  100. package/lib/input/ValidateInput.js.map +1 -0
  101. package/lib/input/index.d.ts +5 -0
  102. package/lib/input/index.d.ts.map +1 -0
  103. package/lib/input/index.js +8 -0
  104. package/lib/input/index.js.map +1 -0
  105. package/lib/input/input.less +83 -0
  106. package/lib/input/validate-input.less +88 -0
  107. package/lib/loading/index.d.ts +2 -0
  108. package/lib/loading/index.d.ts.map +1 -0
  109. package/lib/loading/index.js +5 -0
  110. package/lib/loading/index.js.map +1 -0
  111. package/lib/loading/loading.less +14 -0
  112. package/lib/loading/loading.view.d.ts +4 -0
  113. package/lib/loading/loading.view.d.ts.map +1 -0
  114. package/lib/loading/loading.view.js +9 -0
  115. package/lib/loading/loading.view.js.map +1 -0
  116. package/lib/loading/media/loading-dark.svg +52 -0
  117. package/lib/loading/media/loading-hc.svg +52 -0
  118. package/lib/loading/media/loading.svg +52 -0
  119. package/lib/locale-context-provider.d.ts +16 -0
  120. package/lib/locale-context-provider.d.ts.map +1 -0
  121. package/lib/locale-context-provider.js +26 -0
  122. package/lib/locale-context-provider.js.map +1 -0
  123. package/lib/menu/MenuContext.d.ts +8 -0
  124. package/lib/menu/MenuContext.d.ts.map +1 -0
  125. package/lib/menu/MenuContext.js +8 -0
  126. package/lib/menu/MenuContext.js.map +1 -0
  127. package/lib/menu/MenuItem.d.ts +29 -0
  128. package/lib/menu/MenuItem.d.ts.map +1 -0
  129. package/lib/menu/MenuItem.js +32 -0
  130. package/lib/menu/MenuItem.js.map +1 -0
  131. package/lib/menu/SubMenu.d.ts +30 -0
  132. package/lib/menu/SubMenu.d.ts.map +1 -0
  133. package/lib/menu/SubMenu.js +28 -0
  134. package/lib/menu/SubMenu.js.map +1 -0
  135. package/lib/menu/index.d.ts +64 -0
  136. package/lib/menu/index.d.ts.map +1 -0
  137. package/lib/menu/index.js +201 -0
  138. package/lib/menu/index.js.map +1 -0
  139. package/lib/menu/style.less +502 -0
  140. package/lib/message/index.d.ts +10 -0
  141. package/lib/message/index.d.ts.map +1 -0
  142. package/lib/message/index.js +19 -0
  143. package/lib/message/index.js.map +1 -0
  144. package/lib/message/message.d.ts +42 -0
  145. package/lib/message/message.d.ts.map +1 -0
  146. package/lib/message/message.js +127 -0
  147. package/lib/message/message.js.map +1 -0
  148. package/lib/message/style.less +76 -0
  149. package/lib/modal/Modal.d.ts +127 -0
  150. package/lib/modal/Modal.d.ts.map +1 -0
  151. package/lib/modal/Modal.js +87 -0
  152. package/lib/modal/Modal.js.map +1 -0
  153. package/lib/modal/index.d.ts +5 -0
  154. package/lib/modal/index.d.ts.map +1 -0
  155. package/lib/modal/index.js +8 -0
  156. package/lib/modal/index.js.map +1 -0
  157. package/lib/modal/locale.d.ts +8 -0
  158. package/lib/modal/locale.d.ts.map +1 -0
  159. package/lib/modal/locale.js +23 -0
  160. package/lib/modal/locale.js.map +1 -0
  161. package/lib/modal/style.less +168 -0
  162. package/lib/notification/index.d.ts +8 -0
  163. package/lib/notification/index.d.ts.map +1 -0
  164. package/lib/notification/index.js +80 -0
  165. package/lib/notification/index.js.map +1 -0
  166. package/lib/notification/notification.d.ts +44 -0
  167. package/lib/notification/notification.d.ts.map +1 -0
  168. package/lib/notification/notification.js +156 -0
  169. package/lib/notification/notification.js.map +1 -0
  170. package/lib/notification/notification.less +232 -0
  171. package/lib/overlay/index.d.ts +19 -0
  172. package/lib/overlay/index.d.ts.map +1 -0
  173. package/lib/overlay/index.js +14 -0
  174. package/lib/overlay/index.js.map +1 -0
  175. package/lib/overlay/styles.less +43 -0
  176. package/lib/popover/index.d.ts +28 -0
  177. package/lib/popover/index.d.ts.map +1 -0
  178. package/lib/popover/index.js +127 -0
  179. package/lib/popover/index.js.map +1 -0
  180. package/lib/popover/styles.less +136 -0
  181. package/lib/recycle-list/RecycleList.d.ts +105 -0
  182. package/lib/recycle-list/RecycleList.d.ts.map +1 -0
  183. package/lib/recycle-list/RecycleList.js +253 -0
  184. package/lib/recycle-list/RecycleList.js.map +1 -0
  185. package/lib/recycle-list/index.d.ts +2 -0
  186. package/lib/recycle-list/index.d.ts.map +1 -0
  187. package/lib/recycle-list/index.js +5 -0
  188. package/lib/recycle-list/index.js.map +1 -0
  189. package/lib/recycle-tree/RecycleTree.d.ts +255 -0
  190. package/lib/recycle-tree/RecycleTree.d.ts.map +1 -0
  191. package/lib/recycle-tree/RecycleTree.js +627 -0
  192. package/lib/recycle-tree/RecycleTree.js.map +1 -0
  193. package/lib/recycle-tree/TreeNodeRendererWrap.d.ts +37 -0
  194. package/lib/recycle-tree/TreeNodeRendererWrap.d.ts.map +1 -0
  195. package/lib/recycle-tree/TreeNodeRendererWrap.js +18 -0
  196. package/lib/recycle-tree/TreeNodeRendererWrap.js.map +1 -0
  197. package/lib/recycle-tree/basic/index.d.ts +7 -0
  198. package/lib/recycle-tree/basic/index.d.ts.map +1 -0
  199. package/lib/recycle-tree/basic/index.js +167 -0
  200. package/lib/recycle-tree/basic/index.js.map +1 -0
  201. package/lib/recycle-tree/basic/menubar-item.d.ts +7 -0
  202. package/lib/recycle-tree/basic/menubar-item.d.ts.map +1 -0
  203. package/lib/recycle-tree/basic/menubar-item.js +25 -0
  204. package/lib/recycle-tree/basic/menubar-item.js.map +1 -0
  205. package/lib/recycle-tree/basic/placements.d.ts +12 -0
  206. package/lib/recycle-tree/basic/placements.d.ts.map +1 -0
  207. package/lib/recycle-tree/basic/placements.js +17 -0
  208. package/lib/recycle-tree/basic/placements.js.map +1 -0
  209. package/lib/recycle-tree/basic/styles.less +245 -0
  210. package/lib/recycle-tree/basic/tree-node.d.ts +8 -0
  211. package/lib/recycle-tree/basic/tree-node.d.ts.map +1 -0
  212. package/lib/recycle-tree/basic/tree-node.define.d.ts +31 -0
  213. package/lib/recycle-tree/basic/tree-node.define.d.ts.map +1 -0
  214. package/lib/recycle-tree/basic/tree-node.define.js +75 -0
  215. package/lib/recycle-tree/basic/tree-node.define.js.map +1 -0
  216. package/lib/recycle-tree/basic/tree-node.js +103 -0
  217. package/lib/recycle-tree/basic/tree-node.js.map +1 -0
  218. package/lib/recycle-tree/basic/tree-service.d.ts +38 -0
  219. package/lib/recycle-tree/basic/tree-service.d.ts.map +1 -0
  220. package/lib/recycle-tree/basic/tree-service.js +153 -0
  221. package/lib/recycle-tree/basic/tree-service.js.map +1 -0
  222. package/lib/recycle-tree/basic/types.d.ts +227 -0
  223. package/lib/recycle-tree/basic/types.d.ts.map +1 -0
  224. package/lib/recycle-tree/basic/types.js +15 -0
  225. package/lib/recycle-tree/basic/types.js.map +1 -0
  226. package/lib/recycle-tree/decorators/Adaptive/index.d.ts +10 -0
  227. package/lib/recycle-tree/decorators/Adaptive/index.d.ts.map +1 -0
  228. package/lib/recycle-tree/decorators/Adaptive/index.js +93 -0
  229. package/lib/recycle-tree/decorators/Adaptive/index.js.map +1 -0
  230. package/lib/recycle-tree/decorators/Filter/filter.less +11 -0
  231. package/lib/recycle-tree/decorators/Filter/index.d.ts +26 -0
  232. package/lib/recycle-tree/decorators/Filter/index.d.ts.map +1 -0
  233. package/lib/recycle-tree/decorators/Filter/index.js +54 -0
  234. package/lib/recycle-tree/decorators/Filter/index.js.map +1 -0
  235. package/lib/recycle-tree/decorators/index.d.ts +3 -0
  236. package/lib/recycle-tree/decorators/index.d.ts.map +1 -0
  237. package/lib/recycle-tree/decorators/index.js +6 -0
  238. package/lib/recycle-tree/decorators/index.js.map +1 -0
  239. package/lib/recycle-tree/index.d.ts +8 -0
  240. package/lib/recycle-tree/index.d.ts.map +1 -0
  241. package/lib/recycle-tree/index.js +11 -0
  242. package/lib/recycle-tree/index.js.map +1 -0
  243. package/lib/recycle-tree/prompt/NewPromptHandle.d.ts +12 -0
  244. package/lib/recycle-tree/prompt/NewPromptHandle.d.ts.map +1 -0
  245. package/lib/recycle-tree/prompt/NewPromptHandle.js +21 -0
  246. package/lib/recycle-tree/prompt/NewPromptHandle.js.map +1 -0
  247. package/lib/recycle-tree/prompt/PromptHandle.d.ts +59 -0
  248. package/lib/recycle-tree/prompt/PromptHandle.d.ts.map +1 -0
  249. package/lib/recycle-tree/prompt/PromptHandle.js +200 -0
  250. package/lib/recycle-tree/prompt/PromptHandle.js.map +1 -0
  251. package/lib/recycle-tree/prompt/RenamePromptHandle.d.ts +10 -0
  252. package/lib/recycle-tree/prompt/RenamePromptHandle.d.ts.map +1 -0
  253. package/lib/recycle-tree/prompt/RenamePromptHandle.js +21 -0
  254. package/lib/recycle-tree/prompt/RenamePromptHandle.js.map +1 -0
  255. package/lib/recycle-tree/prompt/index.d.ts +4 -0
  256. package/lib/recycle-tree/prompt/index.d.ts.map +1 -0
  257. package/lib/recycle-tree/prompt/index.js +7 -0
  258. package/lib/recycle-tree/prompt/index.js.map +1 -0
  259. package/lib/recycle-tree/tree/Tree.d.ts +20 -0
  260. package/lib/recycle-tree/tree/Tree.d.ts.map +1 -0
  261. package/lib/recycle-tree/tree/Tree.js +39 -0
  262. package/lib/recycle-tree/tree/Tree.js.map +1 -0
  263. package/lib/recycle-tree/tree/TreeNode.d.ts +222 -0
  264. package/lib/recycle-tree/tree/TreeNode.d.ts.map +1 -0
  265. package/lib/recycle-tree/tree/TreeNode.js +1103 -0
  266. package/lib/recycle-tree/tree/TreeNode.js.map +1 -0
  267. package/lib/recycle-tree/tree/decoration/CompositeDecoration.d.ts +60 -0
  268. package/lib/recycle-tree/tree/decoration/CompositeDecoration.d.ts.map +1 -0
  269. package/lib/recycle-tree/tree/decoration/CompositeDecoration.js +339 -0
  270. package/lib/recycle-tree/tree/decoration/CompositeDecoration.js.map +1 -0
  271. package/lib/recycle-tree/tree/decoration/Decoration.d.ts +79 -0
  272. package/lib/recycle-tree/tree/decoration/Decoration.d.ts.map +1 -0
  273. package/lib/recycle-tree/tree/decoration/Decoration.js +183 -0
  274. package/lib/recycle-tree/tree/decoration/Decoration.js.map +1 -0
  275. package/lib/recycle-tree/tree/decoration/DecorationManager.d.ts +34 -0
  276. package/lib/recycle-tree/tree/decoration/DecorationManager.d.ts.map +1 -0
  277. package/lib/recycle-tree/tree/decoration/DecorationManager.js +168 -0
  278. package/lib/recycle-tree/tree/decoration/DecorationManager.js.map +1 -0
  279. package/lib/recycle-tree/tree/decoration/index.d.ts +4 -0
  280. package/lib/recycle-tree/tree/decoration/index.d.ts.map +1 -0
  281. package/lib/recycle-tree/tree/decoration/index.js +7 -0
  282. package/lib/recycle-tree/tree/decoration/index.js.map +1 -0
  283. package/lib/recycle-tree/tree/index.d.ts +5 -0
  284. package/lib/recycle-tree/tree/index.d.ts.map +1 -0
  285. package/lib/recycle-tree/tree/index.js +8 -0
  286. package/lib/recycle-tree/tree/index.js.map +1 -0
  287. package/lib/recycle-tree/tree/model/TreeModel.d.ts +50 -0
  288. package/lib/recycle-tree/tree/model/TreeModel.d.ts.map +1 -0
  289. package/lib/recycle-tree/tree/model/TreeModel.js +81 -0
  290. package/lib/recycle-tree/tree/model/TreeModel.js.map +1 -0
  291. package/lib/recycle-tree/tree/model/index.d.ts +2 -0
  292. package/lib/recycle-tree/tree/model/index.d.ts.map +1 -0
  293. package/lib/recycle-tree/tree/model/index.js +5 -0
  294. package/lib/recycle-tree/tree/model/index.js.map +1 -0
  295. package/lib/recycle-tree/tree/model/treeState/TreeStateManager.d.ts +65 -0
  296. package/lib/recycle-tree/tree/model/treeState/TreeStateManager.d.ts.map +1 -0
  297. package/lib/recycle-tree/tree/model/treeState/TreeStateManager.js +189 -0
  298. package/lib/recycle-tree/tree/model/treeState/TreeStateManager.js.map +1 -0
  299. package/lib/recycle-tree/tree/model/treeState/TreeStateWatcher.d.ts +15 -0
  300. package/lib/recycle-tree/tree/model/treeState/TreeStateWatcher.d.ts.map +1 -0
  301. package/lib/recycle-tree/tree/model/treeState/TreeStateWatcher.js +104 -0
  302. package/lib/recycle-tree/tree/model/treeState/TreeStateWatcher.js.map +1 -0
  303. package/lib/recycle-tree/tree/model/treeState/index.d.ts +4 -0
  304. package/lib/recycle-tree/tree/model/treeState/index.d.ts.map +1 -0
  305. package/lib/recycle-tree/tree/model/treeState/index.js +8 -0
  306. package/lib/recycle-tree/tree/model/treeState/index.js.map +1 -0
  307. package/lib/recycle-tree/tree/model/treeState/types.d.ts +21 -0
  308. package/lib/recycle-tree/tree/model/treeState/types.d.ts.map +1 -0
  309. package/lib/recycle-tree/tree/model/treeState/types.js +18 -0
  310. package/lib/recycle-tree/tree/model/treeState/types.js.map +1 -0
  311. package/lib/recycle-tree/types/index.d.ts +4 -0
  312. package/lib/recycle-tree/types/index.d.ts.map +1 -0
  313. package/lib/recycle-tree/types/index.js +7 -0
  314. package/lib/recycle-tree/types/index.js.map +1 -0
  315. package/lib/recycle-tree/types/tree-node.d.ts +70 -0
  316. package/lib/recycle-tree/types/tree-node.d.ts.map +1 -0
  317. package/lib/recycle-tree/types/tree-node.js +11 -0
  318. package/lib/recycle-tree/types/tree-node.js.map +1 -0
  319. package/lib/recycle-tree/types/tree.d.ts +8 -0
  320. package/lib/recycle-tree/types/tree.d.ts.map +1 -0
  321. package/lib/recycle-tree/types/tree.js +3 -0
  322. package/lib/recycle-tree/types/tree.js.map +1 -0
  323. package/lib/recycle-tree/types/watcher.d.ts +114 -0
  324. package/lib/recycle-tree/types/watcher.d.ts.map +1 -0
  325. package/lib/recycle-tree/types/watcher.js +46 -0
  326. package/lib/recycle-tree/types/watcher.js.map +1 -0
  327. package/lib/scrollbars/index.d.ts +14 -0
  328. package/lib/scrollbars/index.d.ts.map +1 -0
  329. package/lib/scrollbars/index.js +54 -0
  330. package/lib/scrollbars/index.js.map +1 -0
  331. package/lib/scrollbars/styles.less +41 -0
  332. package/lib/select/index.d.ts +119 -0
  333. package/lib/select/index.d.ts.map +1 -0
  334. package/lib/select/index.js +325 -0
  335. package/lib/select/index.js.map +1 -0
  336. package/lib/select/style.less +228 -0
  337. package/lib/style/base.less +541 -0
  338. package/lib/style/index.less +14 -0
  339. package/lib/style/mixins.less +135 -0
  340. package/lib/style/motion/fade.less +31 -0
  341. package/lib/style/motion/move.less +120 -0
  342. package/lib/style/motion/other.less +45 -0
  343. package/lib/style/motion/slide.less +120 -0
  344. package/lib/style/motion/swing.less +34 -0
  345. package/lib/style/motion/zoom.less +162 -0
  346. package/lib/style/variable.less +203 -0
  347. package/lib/tabs/index.d.ts +12 -0
  348. package/lib/tabs/index.d.ts.map +1 -0
  349. package/lib/tabs/index.js +24 -0
  350. package/lib/tabs/index.js.map +1 -0
  351. package/lib/tabs/style.less +34 -0
  352. package/lib/tooltip/index.d.ts +7 -0
  353. package/lib/tooltip/index.d.ts.map +1 -0
  354. package/lib/tooltip/index.js +58 -0
  355. package/lib/tooltip/index.js.map +1 -0
  356. package/lib/tooltip/style.less +40 -0
  357. package/lib/utils/deprecated.d.ts +3 -0
  358. package/lib/utils/deprecated.d.ts.map +1 -0
  359. package/lib/utils/deprecated.js +18 -0
  360. package/lib/utils/deprecated.js.map +1 -0
  361. package/lib/utils/disposable.d.ts +37 -0
  362. package/lib/utils/disposable.d.ts.map +1 -0
  363. package/lib/utils/disposable.js +138 -0
  364. package/lib/utils/disposable.js.map +1 -0
  365. package/lib/utils/event.d.ts +189 -0
  366. package/lib/utils/event.d.ts.map +1 -0
  367. package/lib/utils/event.js +560 -0
  368. package/lib/utils/event.js.map +1 -0
  369. package/lib/utils/index.d.ts +10 -0
  370. package/lib/utils/index.d.ts.map +1 -0
  371. package/lib/utils/index.js +13 -0
  372. package/lib/utils/index.js.map +1 -0
  373. package/lib/utils/iterator.d.ts +14 -0
  374. package/lib/utils/iterator.d.ts.map +1 -0
  375. package/lib/utils/iterator.js +9 -0
  376. package/lib/utils/iterator.js.map +1 -0
  377. package/lib/utils/linkedList.d.ts +18 -0
  378. package/lib/utils/linkedList.d.ts.map +1 -0
  379. package/lib/utils/linkedList.js +139 -0
  380. package/lib/utils/linkedList.js.map +1 -0
  381. package/lib/utils/motion.d.ts +24 -0
  382. package/lib/utils/motion.d.ts.map +1 -0
  383. package/lib/utils/motion.js +17 -0
  384. package/lib/utils/motion.js.map +1 -0
  385. package/lib/utils/os.d.ts +4 -0
  386. package/lib/utils/os.d.ts.map +1 -0
  387. package/lib/utils/os.js +22 -0
  388. package/lib/utils/os.js.map +1 -0
  389. package/lib/utils/path.d.ts +92 -0
  390. package/lib/utils/path.d.ts.map +1 -0
  391. package/lib/utils/path.js +1696 -0
  392. package/lib/utils/path.js.map +1 -0
  393. package/lib/utils/process.d.ts +6 -0
  394. package/lib/utils/process.d.ts.map +1 -0
  395. package/lib/utils/process.js +23 -0
  396. package/lib/utils/process.js.map +1 -0
  397. package/lib/utils/raf.d.ts +10 -0
  398. package/lib/utils/raf.d.ts.map +1 -0
  399. package/lib/utils/raf.js +33 -0
  400. package/lib/utils/raf.js.map +1 -0
  401. package/lib/utils/type.d.ts +4 -0
  402. package/lib/utils/type.d.ts.map +1 -0
  403. package/lib/utils/type.js +9 -0
  404. package/lib/utils/type.js.map +1 -0
  405. package/lib/utils/warning.d.ts +8 -0
  406. package/lib/utils/warning.d.ts.map +1 -0
  407. package/lib/utils/warning.js +39 -0
  408. package/lib/utils/warning.js.map +1 -0
  409. package/package.json +38 -0
@@ -0,0 +1,1696 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.delimiter = exports.sep = exports.toNamespacedPath = exports.parse = exports.format = exports.extname = exports.basename = exports.dirname = exports.relative = exports.resolve = exports.join = exports.isAbsolute = exports.normalize = exports.posix = exports.win32 = exports.Path = void 0;
4
+ // Modify from @opensumi/ide-core-common/src/path.ts
5
+ const process_1 = require("./process");
6
+ const os_1 = require("./os");
7
+ const SystemPathSeparatorRegex = os_1.isWindows ? /\\/g : /\//g;
8
+ /**
9
+ * On POSIX:
10
+ * ┌──────────────────────┬────────────┐
11
+ * │ dir │ base │
12
+ * ├──────┬ ├──────┬─────┤
13
+ * │ root │ │ name │ ext │
14
+ * " / home/user/dir / file .txt "
15
+ * └──────┴───────────────┴──────┴─────┘
16
+ *
17
+ * On Windows:
18
+ * ┌──────────────────────┬────────────┐
19
+ * │ dir │ base │
20
+ * ├──────┬ ├──────┬─────┤
21
+ * │ root │ │ name │ ext │
22
+ * " /c: / home/user/dir / file .txt "
23
+ * └──────┴───────────────┴──────┴─────┘
24
+ */
25
+ class Path {
26
+ /**
27
+ * The raw should be normalized, meaning that only '/' is allowed as a path separator.
28
+ */
29
+ constructor(raw) {
30
+ raw = raw.replace(SystemPathSeparatorRegex, Path.separator);
31
+ this.raw = Path.normalizeDrive(raw);
32
+ const firstIndex = raw.indexOf(Path.separator);
33
+ const lastIndex = raw.lastIndexOf(Path.separator);
34
+ this.isAbsolute = firstIndex === 0;
35
+ this.base = lastIndex === -1 ? raw : raw.substr(lastIndex + 1);
36
+ this.isRoot = this.isAbsolute && firstIndex === lastIndex && (!this.base || Path.isDrive(this.base));
37
+ this.root = this.computeRoot();
38
+ const extIndex = this.base.lastIndexOf('.');
39
+ // 处理无后缀文件或者 dot 打头的无后缀文件
40
+ // file like 'a/b/c/test'
41
+ if (extIndex === -1) {
42
+ this.name = this.base;
43
+ this.ext = '';
44
+ }
45
+ else if (extIndex === 0) {
46
+ // dot file like `a/b/c/.eslintrc`
47
+ this.name = this.base;
48
+ this.ext = '';
49
+ }
50
+ else {
51
+ this.name = this.base.substr(0, extIndex);
52
+ this.ext = this.base.substr(extIndex);
53
+ }
54
+ }
55
+ static isDrive(segment) {
56
+ return segment.endsWith(':');
57
+ }
58
+ static splitPath(path) {
59
+ return path.split(Path.separator).filter((path) => !!path);
60
+ }
61
+ static isRelative(path) {
62
+ return !path.startsWith(Path.separator);
63
+ }
64
+ static pathDepth(path) {
65
+ return path.split(Path.separator).length;
66
+ }
67
+ /**
68
+ * vscode-uri always normalizes drive letters to lower case:
69
+ * https://github.com/Microsoft/vscode-uri/blob/b1d3221579f97f28a839b6f996d76fc45e9964d8/src/index.ts#L1025
70
+ * Theia path should be adjusted to this.
71
+ */
72
+ static normalizeDrive(path) {
73
+ // lower-case windows drive letters in /C:/fff or C:/fff
74
+ if (path.length >= 3 && path.charCodeAt(0) === 47 /* '/' */ && path.charCodeAt(2) === 58 /* ':' */) {
75
+ const code = path.charCodeAt(1);
76
+ if (code >= 65 /* A */ && code <= 90 /* Z */) {
77
+ path = `/${String.fromCharCode(code + 32)}:${path.substr(3)}`; // "/c:".length === 3
78
+ }
79
+ }
80
+ else if (path.length >= 2 && path.charCodeAt(1) === 58 /* ':' */) {
81
+ const code = path.charCodeAt(0);
82
+ if (code >= 65 /* A */ && code <= 90 /* Z */) {
83
+ path = `${String.fromCharCode(code + 32)}:${path.substr(2)}`; // "/c:".length === 3
84
+ }
85
+ }
86
+ return path;
87
+ }
88
+ computeRoot() {
89
+ // '/' -> '/'
90
+ // '/c:' -> '/c:'
91
+ if (this.isRoot) {
92
+ return this;
93
+ }
94
+ // 'foo/bar' -> `undefined`
95
+ if (!this.isAbsolute) {
96
+ return undefined;
97
+ }
98
+ const index = this.raw.indexOf(Path.separator, Path.separator.length);
99
+ if (index === -1) {
100
+ // '/foo/bar' -> '/'
101
+ return new Path(Path.separator);
102
+ }
103
+ // '/c:/foo/bar' -> '/c:'
104
+ // '/foo/bar' -> '/'
105
+ return new Path(this.raw.substr(0, index)).root;
106
+ }
107
+ get dir() {
108
+ if (this._dir === undefined) {
109
+ this._dir = this.computeDir();
110
+ }
111
+ return this._dir;
112
+ }
113
+ computeDir() {
114
+ if (this.isRoot) {
115
+ return this;
116
+ }
117
+ const lastIndex = this.raw.lastIndexOf(Path.separator);
118
+ if (lastIndex === -1) {
119
+ return this;
120
+ }
121
+ if (this.isAbsolute) {
122
+ const firstIndex = this.raw.indexOf(Path.separator);
123
+ if (firstIndex === lastIndex) {
124
+ return new Path(this.raw.substr(0, firstIndex + 1));
125
+ }
126
+ }
127
+ return new Path(this.raw.substr(0, lastIndex));
128
+ }
129
+ join(...paths) {
130
+ const code = this.raw.charCodeAt(0);
131
+ const isWindows = isWindowsDeviceRoot(code);
132
+ /**
133
+ * 只针对 IDE 后端运行在 Windows 的情况
134
+ * join('C:\\path\\to\\file', 'path/to/other') === 'C:\\path\\to\\file\\path\\to\\other'
135
+ */
136
+ if (isWindows) {
137
+ return new Path(exports.win32.join(this.raw, ...paths));
138
+ }
139
+ const relativePath = paths.filter((s) => !!s).join(Path.separator);
140
+ if (!relativePath) {
141
+ return this;
142
+ }
143
+ if (this.raw.endsWith(Path.separator)) {
144
+ return new Path(this.raw + relativePath);
145
+ }
146
+ return new Path(this.raw + Path.separator + relativePath);
147
+ }
148
+ toString() {
149
+ return this.raw;
150
+ }
151
+ relative(path) {
152
+ if (this.raw === path.raw) {
153
+ return new Path('');
154
+ }
155
+ if (!this.raw || !path.raw) {
156
+ return undefined;
157
+ }
158
+ const raw = this.base ? this.raw + Path.separator : this.raw;
159
+ if (!path.raw.startsWith(raw)) {
160
+ return undefined;
161
+ }
162
+ const relativePath = path.raw.substr(raw.length);
163
+ return new Path(relativePath);
164
+ }
165
+ isEqualOrParent(path) {
166
+ return !!this.relative(path);
167
+ }
168
+ isEqual(path) {
169
+ return this.raw === path.raw;
170
+ }
171
+ relativity(path) {
172
+ const relative = this.relative(path);
173
+ if (relative) {
174
+ const relativeStr = relative.toString();
175
+ if (relativeStr === '') {
176
+ return 0;
177
+ }
178
+ return relativeStr.split(Path.separator).length;
179
+ }
180
+ return -1;
181
+ }
182
+ }
183
+ exports.Path = Path;
184
+ Path.separator = '/';
185
+ const CHAR_UPPERCASE_A = 65; /* A */
186
+ const CHAR_LOWERCASE_A = 97; /* a */
187
+ const CHAR_UPPERCASE_Z = 90; /* Z */
188
+ const CHAR_LOWERCASE_Z = 122; /* z */
189
+ const CHAR_DOT = 46; /* . */
190
+ const CHAR_FORWARD_SLASH = 47; /* / */
191
+ const CHAR_BACKWARD_SLASH = 92; /* \ */
192
+ const CHAR_COLON = 58; /* : */
193
+ const CHAR_QUESTION_MARK = 63; /* ? */
194
+ class ErrorInvalidArgType extends Error {
195
+ constructor(name, expected, actual) {
196
+ // determiner: 'must be' or 'must not be'
197
+ let determiner;
198
+ if (typeof expected === 'string' && expected.indexOf('not ') === 0) {
199
+ determiner = 'must not be';
200
+ expected = expected.replace(/^not /, '');
201
+ }
202
+ else {
203
+ determiner = 'must be';
204
+ }
205
+ const type = name.indexOf('.') !== -1 ? 'property' : 'argument';
206
+ let msg = `The "${name}" ${type} ${determiner} of type ${expected}`;
207
+ msg += `. Received type ${typeof actual}`;
208
+ super(msg);
209
+ }
210
+ }
211
+ function validateString(value, name) {
212
+ if (typeof value !== 'string') {
213
+ throw new ErrorInvalidArgType(name, 'string', value);
214
+ }
215
+ }
216
+ function isPathSeparator(code) {
217
+ return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
218
+ }
219
+ function isPosixPathSeparator(code) {
220
+ return code === CHAR_FORWARD_SLASH;
221
+ }
222
+ function isWindowsDeviceRoot(code) {
223
+ return ((code >= CHAR_UPPERCASE_A && code <= CHAR_UPPERCASE_Z) || (code >= CHAR_LOWERCASE_A && code <= CHAR_LOWERCASE_Z));
224
+ }
225
+ // Resolves . and .. elements in a path with directory names
226
+ function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
227
+ let res = '';
228
+ let lastSegmentLength = 0;
229
+ let lastSlash = -1;
230
+ let dots = 0;
231
+ let code;
232
+ for (let i = 0; i <= path.length; ++i) {
233
+ if (i < path.length) {
234
+ code = path.charCodeAt(i);
235
+ }
236
+ else if (isPathSeparator(code)) {
237
+ break;
238
+ }
239
+ else {
240
+ code = CHAR_FORWARD_SLASH;
241
+ }
242
+ if (isPathSeparator(code)) {
243
+ if (lastSlash === i - 1 || dots === 1) {
244
+ // NOOP
245
+ }
246
+ else if (lastSlash !== i - 1 && dots === 2) {
247
+ if (res.length < 2 ||
248
+ lastSegmentLength !== 2 ||
249
+ res.charCodeAt(res.length - 1) !== CHAR_DOT ||
250
+ res.charCodeAt(res.length - 2) !== CHAR_DOT) {
251
+ if (res.length > 2) {
252
+ const lastSlashIndex = res.lastIndexOf(separator);
253
+ if (lastSlashIndex === -1) {
254
+ res = '';
255
+ lastSegmentLength = 0;
256
+ }
257
+ else {
258
+ res = res.slice(0, lastSlashIndex);
259
+ lastSegmentLength = res.length - 1 - res.lastIndexOf(separator);
260
+ }
261
+ lastSlash = i;
262
+ dots = 0;
263
+ continue;
264
+ }
265
+ else if (res.length === 2 || res.length === 1) {
266
+ res = '';
267
+ lastSegmentLength = 0;
268
+ lastSlash = i;
269
+ dots = 0;
270
+ continue;
271
+ }
272
+ }
273
+ if (allowAboveRoot) {
274
+ if (res.length > 0) {
275
+ res += `${separator}..`;
276
+ }
277
+ else {
278
+ res = '..';
279
+ }
280
+ lastSegmentLength = 2;
281
+ }
282
+ }
283
+ else {
284
+ if (res.length > 0) {
285
+ res += separator + path.slice(lastSlash + 1, i);
286
+ }
287
+ else {
288
+ res = path.slice(lastSlash + 1, i);
289
+ }
290
+ lastSegmentLength = i - lastSlash - 1;
291
+ }
292
+ lastSlash = i;
293
+ dots = 0;
294
+ }
295
+ else if (code === CHAR_DOT && dots !== -1) {
296
+ ++dots;
297
+ }
298
+ else {
299
+ dots = -1;
300
+ }
301
+ }
302
+ return res;
303
+ }
304
+ function _format(sep, pathObject) {
305
+ const dir = pathObject.dir || pathObject.root;
306
+ const base = pathObject.base || (pathObject.name || '') + (pathObject.ext || '');
307
+ if (!dir) {
308
+ return base;
309
+ }
310
+ if (dir === pathObject.root) {
311
+ return dir + base;
312
+ }
313
+ return dir + sep + base;
314
+ }
315
+ exports.win32 = {
316
+ // path.resolve([from ...], to)
317
+ resolve(...pathSegments) {
318
+ let resolvedDevice = '';
319
+ let resolvedTail = '';
320
+ let resolvedAbsolute = false;
321
+ for (let i = pathSegments.length - 1; i >= -1; i--) {
322
+ let path;
323
+ if (i >= 0) {
324
+ path = pathSegments[i];
325
+ }
326
+ else if (!resolvedDevice) {
327
+ path = process_1.Process.cwd();
328
+ }
329
+ else {
330
+ // Windows has the concept of drive-specific current working
331
+ // directories. If we've resolved a drive letter but not yet an
332
+ // absolute path, get cwd for that drive, or the process cwd if
333
+ // the drive cwd is not available. We're sure the device is not
334
+ // a UNC path at this points, because UNC paths are always absolute.
335
+ path = process_1.Process.env['=' + resolvedDevice] || process_1.Process.cwd();
336
+ // Verify that a cwd was found and that it actually points
337
+ // to our drive. If not, default to the drive's root.
338
+ if (path === undefined || path.slice(0, 3).toLowerCase() !== resolvedDevice.toLowerCase() + '\\') {
339
+ path = resolvedDevice + '\\';
340
+ }
341
+ }
342
+ validateString(path, 'path');
343
+ // Skip empty entries
344
+ if (path.length === 0) {
345
+ continue;
346
+ }
347
+ const len = path.length;
348
+ let rootEnd = 0;
349
+ let device = '';
350
+ let isAbsolute = false;
351
+ const code = path.charCodeAt(0);
352
+ // Try to match a root
353
+ if (len > 1) {
354
+ if (isPathSeparator(code)) {
355
+ // Possible UNC root
356
+ // If we started with a separator, we know we at least have an
357
+ // absolute path of some kind (UNC or otherwise)
358
+ isAbsolute = true;
359
+ if (isPathSeparator(path.charCodeAt(1))) {
360
+ // Matched double path separator at beginning
361
+ let j = 2;
362
+ let last = j;
363
+ // Match 1 or more non-path separators
364
+ for (; j < len; ++j) {
365
+ if (isPathSeparator(path.charCodeAt(j))) {
366
+ break;
367
+ }
368
+ }
369
+ if (j < len && j !== last) {
370
+ const firstPart = path.slice(last, j);
371
+ // Matched!
372
+ last = j;
373
+ // Match 1 or more path separators
374
+ for (; j < len; ++j) {
375
+ if (!isPathSeparator(path.charCodeAt(j))) {
376
+ break;
377
+ }
378
+ }
379
+ if (j < len && j !== last) {
380
+ // Matched!
381
+ last = j;
382
+ // Match 1 or more non-path separators
383
+ for (; j < len; ++j) {
384
+ if (isPathSeparator(path.charCodeAt(j))) {
385
+ break;
386
+ }
387
+ }
388
+ if (j === len) {
389
+ // We matched a UNC root only
390
+ device = '\\\\' + firstPart + '\\' + path.slice(last);
391
+ rootEnd = j;
392
+ }
393
+ else if (j !== last) {
394
+ // We matched a UNC root with leftovers
395
+ device = '\\\\' + firstPart + '\\' + path.slice(last, j);
396
+ rootEnd = j;
397
+ }
398
+ }
399
+ }
400
+ }
401
+ else {
402
+ rootEnd = 1;
403
+ }
404
+ }
405
+ else if (isWindowsDeviceRoot(code)) {
406
+ // Possible device root
407
+ if (path.charCodeAt(1) === CHAR_COLON) {
408
+ device = path.slice(0, 2);
409
+ rootEnd = 2;
410
+ if (len > 2) {
411
+ if (isPathSeparator(path.charCodeAt(2))) {
412
+ // Treat separator following drive name as an absolute path
413
+ // indicator
414
+ isAbsolute = true;
415
+ rootEnd = 3;
416
+ }
417
+ }
418
+ }
419
+ }
420
+ }
421
+ else if (isPathSeparator(code)) {
422
+ // `path` contains just a path separator
423
+ rootEnd = 1;
424
+ isAbsolute = true;
425
+ }
426
+ if (device.length > 0 && resolvedDevice.length > 0 && device.toLowerCase() !== resolvedDevice.toLowerCase()) {
427
+ // This path points to another device so it is not applicable
428
+ continue;
429
+ }
430
+ if (resolvedDevice.length === 0 && device.length > 0) {
431
+ resolvedDevice = device;
432
+ }
433
+ if (!resolvedAbsolute) {
434
+ resolvedTail = path.slice(rootEnd) + '\\' + resolvedTail;
435
+ resolvedAbsolute = isAbsolute;
436
+ }
437
+ if (resolvedDevice.length > 0 && resolvedAbsolute) {
438
+ break;
439
+ }
440
+ }
441
+ // At this point the path should be resolved to a full absolute path,
442
+ // but handle relative paths to be safe (might happen when Process.cwd()
443
+ // fails)
444
+ // Normalize the tail path
445
+ resolvedTail = normalizeString(resolvedTail, !resolvedAbsolute, '\\', isPathSeparator);
446
+ return resolvedDevice + (resolvedAbsolute ? '\\' : '') + resolvedTail || '.';
447
+ },
448
+ normalize(path) {
449
+ validateString(path, 'path');
450
+ const len = path.length;
451
+ if (len === 0) {
452
+ return '.';
453
+ }
454
+ let rootEnd = 0;
455
+ let device;
456
+ let isAbsolute = false;
457
+ const code = path.charCodeAt(0);
458
+ // Try to match a root
459
+ if (len > 1) {
460
+ if (isPathSeparator(code)) {
461
+ // Possible UNC root
462
+ // If we started with a separator, we know we at least have an absolute
463
+ // path of some kind (UNC or otherwise)
464
+ isAbsolute = true;
465
+ if (isPathSeparator(path.charCodeAt(1))) {
466
+ // Matched double path separator at beginning
467
+ let j = 2;
468
+ let last = j;
469
+ // Match 1 or more non-path separators
470
+ for (; j < len; ++j) {
471
+ if (isPathSeparator(path.charCodeAt(j))) {
472
+ break;
473
+ }
474
+ }
475
+ if (j < len && j !== last) {
476
+ const firstPart = path.slice(last, j);
477
+ // Matched!
478
+ last = j;
479
+ // Match 1 or more path separators
480
+ for (; j < len; ++j) {
481
+ if (!isPathSeparator(path.charCodeAt(j))) {
482
+ break;
483
+ }
484
+ }
485
+ if (j < len && j !== last) {
486
+ // Matched!
487
+ last = j;
488
+ // Match 1 or more non-path separators
489
+ for (; j < len; ++j) {
490
+ if (isPathSeparator(path.charCodeAt(j))) {
491
+ break;
492
+ }
493
+ }
494
+ if (j === len) {
495
+ // We matched a UNC root only
496
+ // Return the normalized version of the UNC root since there
497
+ // is nothing left to process
498
+ return '\\\\' + firstPart + '\\' + path.slice(last) + '\\';
499
+ }
500
+ else if (j !== last) {
501
+ // We matched a UNC root with leftovers
502
+ device = '\\\\' + firstPart + '\\' + path.slice(last, j);
503
+ rootEnd = j;
504
+ }
505
+ }
506
+ }
507
+ }
508
+ else {
509
+ rootEnd = 1;
510
+ }
511
+ }
512
+ else if (isWindowsDeviceRoot(code)) {
513
+ // Possible device root
514
+ if (path.charCodeAt(1) === CHAR_COLON) {
515
+ device = path.slice(0, 2);
516
+ rootEnd = 2;
517
+ if (len > 2) {
518
+ if (isPathSeparator(path.charCodeAt(2))) {
519
+ // Treat separator following drive name as an absolute path
520
+ // indicator
521
+ isAbsolute = true;
522
+ rootEnd = 3;
523
+ }
524
+ }
525
+ }
526
+ }
527
+ }
528
+ else if (isPathSeparator(code)) {
529
+ // `path` contains just a path separator, exit early to avoid unnecessary
530
+ // work
531
+ return '\\';
532
+ }
533
+ let tail;
534
+ if (rootEnd < len) {
535
+ tail = normalizeString(path.slice(rootEnd), !isAbsolute, '\\', isPathSeparator);
536
+ }
537
+ else {
538
+ tail = '';
539
+ }
540
+ if (tail.length === 0 && !isAbsolute) {
541
+ tail = '.';
542
+ }
543
+ if (tail.length > 0 && isPathSeparator(path.charCodeAt(len - 1))) {
544
+ tail += '\\';
545
+ }
546
+ if (device === undefined) {
547
+ if (isAbsolute) {
548
+ if (tail.length > 0) {
549
+ return '\\' + tail;
550
+ }
551
+ else {
552
+ return '\\';
553
+ }
554
+ }
555
+ else if (tail.length > 0) {
556
+ return tail;
557
+ }
558
+ else {
559
+ return '';
560
+ }
561
+ }
562
+ else if (isAbsolute) {
563
+ if (tail.length > 0) {
564
+ return device + '\\' + tail;
565
+ }
566
+ else {
567
+ return device + '\\';
568
+ }
569
+ }
570
+ else if (tail.length > 0) {
571
+ return device + tail;
572
+ }
573
+ else {
574
+ return device;
575
+ }
576
+ },
577
+ isAbsolute(path) {
578
+ validateString(path, 'path');
579
+ const len = path.length;
580
+ if (len === 0) {
581
+ return false;
582
+ }
583
+ const code = path.charCodeAt(0);
584
+ if (isPathSeparator(code)) {
585
+ return true;
586
+ }
587
+ else if (isWindowsDeviceRoot(code)) {
588
+ // Possible device root
589
+ if (len > 2 && path.charCodeAt(1) === CHAR_COLON) {
590
+ if (isPathSeparator(path.charCodeAt(2))) {
591
+ return true;
592
+ }
593
+ }
594
+ }
595
+ return false;
596
+ },
597
+ join(...paths) {
598
+ if (paths.length === 0) {
599
+ return '.';
600
+ }
601
+ let joined;
602
+ let firstPart;
603
+ // eslint-disable-next-line @typescript-eslint/prefer-for-of
604
+ for (let i = 0; i < paths.length; ++i) {
605
+ const arg = paths[i];
606
+ validateString(arg, 'path');
607
+ if (arg.length > 0) {
608
+ if (joined === undefined) {
609
+ joined = firstPart = arg;
610
+ }
611
+ else {
612
+ joined += '\\' + arg;
613
+ }
614
+ }
615
+ }
616
+ if (joined === undefined) {
617
+ return '.';
618
+ }
619
+ // Make sure that the joined path doesn't start with two slashes, because
620
+ // normalize() will mistake it for an UNC path then.
621
+ //
622
+ // This step is skipped when it is very clear that the user actually
623
+ // intended to point at an UNC path. This is assumed when the first
624
+ // non-empty string arguments starts with exactly two slashes followed by
625
+ // at least one more non-slash character.
626
+ //
627
+ // Note that for normalize() to treat a path as an UNC path it needs to
628
+ // have at least 2 components, so we don't filter for that here.
629
+ // This means that the user can use join to construct UNC paths from
630
+ // a server name and a share name; for example:
631
+ // path.join('//server', 'share') -> '\\\\server\\share\\')
632
+ let needsReplace = true;
633
+ let slashCount = 0;
634
+ if (typeof firstPart === 'string' && isPathSeparator(firstPart.charCodeAt(0))) {
635
+ ++slashCount;
636
+ const firstLen = firstPart.length;
637
+ if (firstLen > 1) {
638
+ if (isPathSeparator(firstPart.charCodeAt(1))) {
639
+ ++slashCount;
640
+ if (firstLen > 2) {
641
+ if (isPathSeparator(firstPart.charCodeAt(2))) {
642
+ ++slashCount;
643
+ }
644
+ else {
645
+ // We matched a UNC path in the first part
646
+ needsReplace = false;
647
+ }
648
+ }
649
+ }
650
+ }
651
+ }
652
+ if (needsReplace) {
653
+ // Find any more consecutive slashes we need to replace
654
+ for (; slashCount < joined.length; ++slashCount) {
655
+ if (!isPathSeparator(joined.charCodeAt(slashCount))) {
656
+ break;
657
+ }
658
+ }
659
+ // Replace the slashes if needed
660
+ if (slashCount >= 2) {
661
+ joined = '\\' + joined.slice(slashCount);
662
+ }
663
+ }
664
+ return exports.win32.normalize(joined);
665
+ },
666
+ // It will solve the relative path from `from` to `to`, for instance:
667
+ // from = 'C:\\orandea\\test\\aaa'
668
+ // to = 'C:\\orandea\\impl\\bbb'
669
+ // The output of the function should be: '..\\..\\impl\\bbb'
670
+ relative(from, to) {
671
+ validateString(from, 'from');
672
+ validateString(to, 'to');
673
+ if (from === to) {
674
+ return '';
675
+ }
676
+ const fromOrig = exports.win32.resolve(from);
677
+ const toOrig = exports.win32.resolve(to);
678
+ if (fromOrig === toOrig) {
679
+ return '';
680
+ }
681
+ from = fromOrig.toLowerCase();
682
+ to = toOrig.toLowerCase();
683
+ if (from === to) {
684
+ return '';
685
+ }
686
+ // Trim any leading backslashes
687
+ let fromStart = 0;
688
+ for (; fromStart < from.length; ++fromStart) {
689
+ if (from.charCodeAt(fromStart) !== CHAR_BACKWARD_SLASH) {
690
+ break;
691
+ }
692
+ }
693
+ // Trim trailing backslashes (applicable to UNC paths only)
694
+ let fromEnd = from.length;
695
+ for (; fromEnd - 1 > fromStart; --fromEnd) {
696
+ if (from.charCodeAt(fromEnd - 1) !== CHAR_BACKWARD_SLASH) {
697
+ break;
698
+ }
699
+ }
700
+ const fromLen = fromEnd - fromStart;
701
+ // Trim any leading backslashes
702
+ let toStart = 0;
703
+ for (; toStart < to.length; ++toStart) {
704
+ if (to.charCodeAt(toStart) !== CHAR_BACKWARD_SLASH) {
705
+ break;
706
+ }
707
+ }
708
+ // Trim trailing backslashes (applicable to UNC paths only)
709
+ let toEnd = to.length;
710
+ for (; toEnd - 1 > toStart; --toEnd) {
711
+ if (to.charCodeAt(toEnd - 1) !== CHAR_BACKWARD_SLASH) {
712
+ break;
713
+ }
714
+ }
715
+ const toLen = toEnd - toStart;
716
+ // Compare paths to find the longest common path from root
717
+ const length = fromLen < toLen ? fromLen : toLen;
718
+ let lastCommonSep = -1;
719
+ let i = 0;
720
+ for (; i <= length; ++i) {
721
+ if (i === length) {
722
+ if (toLen > length) {
723
+ if (to.charCodeAt(toStart + i) === CHAR_BACKWARD_SLASH) {
724
+ // We get here if `from` is the exact base path for `to`.
725
+ // For example: from='C:\\foo\\bar'; to='C:\\foo\\bar\\baz'
726
+ return toOrig.slice(toStart + i + 1);
727
+ }
728
+ else if (i === 2) {
729
+ // We get here if `from` is the device root.
730
+ // For example: from='C:\\'; to='C:\\foo'
731
+ return toOrig.slice(toStart + i);
732
+ }
733
+ }
734
+ if (fromLen > length) {
735
+ if (from.charCodeAt(fromStart + i) === CHAR_BACKWARD_SLASH) {
736
+ // We get here if `to` is the exact base path for `from`.
737
+ // For example: from='C:\\foo\\bar'; to='C:\\foo'
738
+ lastCommonSep = i;
739
+ }
740
+ else if (i === 2) {
741
+ // We get here if `to` is the device root.
742
+ // For example: from='C:\\foo\\bar'; to='C:\\'
743
+ lastCommonSep = 3;
744
+ }
745
+ }
746
+ break;
747
+ }
748
+ const fromCode = from.charCodeAt(fromStart + i);
749
+ const toCode = to.charCodeAt(toStart + i);
750
+ if (fromCode !== toCode) {
751
+ break;
752
+ }
753
+ else if (fromCode === CHAR_BACKWARD_SLASH) {
754
+ lastCommonSep = i;
755
+ }
756
+ }
757
+ // We found a mismatch before the first common path separator was seen, so
758
+ // return the original `to`.
759
+ if (i !== length && lastCommonSep === -1) {
760
+ return toOrig;
761
+ }
762
+ let out = '';
763
+ if (lastCommonSep === -1) {
764
+ lastCommonSep = 0;
765
+ }
766
+ // Generate the relative path based on the path difference between `to` and
767
+ // `from`
768
+ for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
769
+ if (i === fromEnd || from.charCodeAt(i) === CHAR_BACKWARD_SLASH) {
770
+ if (out.length === 0) {
771
+ out += '..';
772
+ }
773
+ else {
774
+ out += '\\..';
775
+ }
776
+ }
777
+ }
778
+ // Lastly, append the rest of the destination (`to`) path that comes after
779
+ // the common path parts
780
+ if (out.length > 0) {
781
+ return out + toOrig.slice(toStart + lastCommonSep, toEnd);
782
+ }
783
+ else {
784
+ toStart += lastCommonSep;
785
+ if (toOrig.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) {
786
+ ++toStart;
787
+ }
788
+ return toOrig.slice(toStart, toEnd);
789
+ }
790
+ },
791
+ toNamespacedPath(path) {
792
+ // Note: this will *probably* throw somewhere.
793
+ if (typeof path !== 'string') {
794
+ return path;
795
+ }
796
+ if (path.length === 0) {
797
+ return '';
798
+ }
799
+ const resolvedPath = exports.win32.resolve(path);
800
+ if (resolvedPath.length >= 3) {
801
+ if (resolvedPath.charCodeAt(0) === CHAR_BACKWARD_SLASH) {
802
+ // Possible UNC root
803
+ if (resolvedPath.charCodeAt(1) === CHAR_BACKWARD_SLASH) {
804
+ const code = resolvedPath.charCodeAt(2);
805
+ if (code !== CHAR_QUESTION_MARK && code !== CHAR_DOT) {
806
+ // Matched non-long UNC root, convert the path to a long UNC path
807
+ return '\\\\?\\UNC\\' + resolvedPath.slice(2);
808
+ }
809
+ }
810
+ }
811
+ else if (isWindowsDeviceRoot(resolvedPath.charCodeAt(0))) {
812
+ // Possible device root
813
+ if (resolvedPath.charCodeAt(1) === CHAR_COLON && resolvedPath.charCodeAt(2) === CHAR_BACKWARD_SLASH) {
814
+ // Matched device root, convert the path to a long UNC path
815
+ return '\\\\?\\' + resolvedPath;
816
+ }
817
+ }
818
+ }
819
+ return path;
820
+ },
821
+ dirname(path) {
822
+ validateString(path, 'path');
823
+ const len = path.length;
824
+ if (len === 0) {
825
+ return '.';
826
+ }
827
+ let rootEnd = -1;
828
+ let end = -1;
829
+ let matchedSlash = true;
830
+ let offset = 0;
831
+ const code = path.charCodeAt(0);
832
+ // Try to match a root
833
+ if (len > 1) {
834
+ if (isPathSeparator(code)) {
835
+ // Possible UNC root
836
+ rootEnd = offset = 1;
837
+ if (isPathSeparator(path.charCodeAt(1))) {
838
+ // Matched double path separator at beginning
839
+ let j = 2;
840
+ let last = j;
841
+ // Match 1 or more non-path separators
842
+ for (; j < len; ++j) {
843
+ if (isPathSeparator(path.charCodeAt(j))) {
844
+ break;
845
+ }
846
+ }
847
+ if (j < len && j !== last) {
848
+ // Matched!
849
+ last = j;
850
+ // Match 1 or more path separators
851
+ for (; j < len; ++j) {
852
+ if (!isPathSeparator(path.charCodeAt(j))) {
853
+ break;
854
+ }
855
+ }
856
+ if (j < len && j !== last) {
857
+ // Matched!
858
+ last = j;
859
+ // Match 1 or more non-path separators
860
+ for (; j < len; ++j) {
861
+ if (isPathSeparator(path.charCodeAt(j))) {
862
+ break;
863
+ }
864
+ }
865
+ if (j === len) {
866
+ // We matched a UNC root only
867
+ return path;
868
+ }
869
+ if (j !== last) {
870
+ // We matched a UNC root with leftovers
871
+ // Offset by 1 to include the separator after the UNC root to
872
+ // treat it as a "normal root" on top of a (UNC) root
873
+ rootEnd = offset = j + 1;
874
+ }
875
+ }
876
+ }
877
+ }
878
+ }
879
+ else if (isWindowsDeviceRoot(code)) {
880
+ // Possible device root
881
+ if (path.charCodeAt(1) === CHAR_COLON) {
882
+ rootEnd = offset = 2;
883
+ if (len > 2) {
884
+ if (isPathSeparator(path.charCodeAt(2))) {
885
+ rootEnd = offset = 3;
886
+ }
887
+ }
888
+ }
889
+ }
890
+ }
891
+ else if (isPathSeparator(code)) {
892
+ // `path` contains just a path separator, exit early to avoid
893
+ // unnecessary work
894
+ return path;
895
+ }
896
+ for (let i = len - 1; i >= offset; --i) {
897
+ if (isPathSeparator(path.charCodeAt(i))) {
898
+ if (!matchedSlash) {
899
+ end = i;
900
+ break;
901
+ }
902
+ }
903
+ else {
904
+ // We saw the first non-path separator
905
+ matchedSlash = false;
906
+ }
907
+ }
908
+ if (end === -1) {
909
+ if (rootEnd === -1) {
910
+ return '.';
911
+ }
912
+ else {
913
+ end = rootEnd;
914
+ }
915
+ }
916
+ return path.slice(0, end);
917
+ },
918
+ basename(path, ext) {
919
+ if (ext !== undefined) {
920
+ validateString(ext, 'ext');
921
+ }
922
+ validateString(path, 'path');
923
+ let start = 0;
924
+ let end = -1;
925
+ let matchedSlash = true;
926
+ let i;
927
+ // Check for a drive letter prefix so as not to mistake the following
928
+ // path separator as an extra separator at the end of the path that can be
929
+ // disregarded
930
+ if (path.length >= 2) {
931
+ const drive = path.charCodeAt(0);
932
+ if (isWindowsDeviceRoot(drive)) {
933
+ if (path.charCodeAt(1) === CHAR_COLON) {
934
+ start = 2;
935
+ }
936
+ }
937
+ }
938
+ if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
939
+ if (ext.length === path.length && ext === path) {
940
+ return '';
941
+ }
942
+ let extIdx = ext.length - 1;
943
+ let firstNonSlashEnd = -1;
944
+ for (i = path.length - 1; i >= start; --i) {
945
+ const code = path.charCodeAt(i);
946
+ if (isPathSeparator(code)) {
947
+ // If we reached a path separator that was not part of a set of path
948
+ // separators at the end of the string, stop now
949
+ if (!matchedSlash) {
950
+ start = i + 1;
951
+ break;
952
+ }
953
+ }
954
+ else {
955
+ if (firstNonSlashEnd === -1) {
956
+ // We saw the first non-path separator, remember this index in case
957
+ // we need it if the extension ends up not matching
958
+ matchedSlash = false;
959
+ firstNonSlashEnd = i + 1;
960
+ }
961
+ if (extIdx >= 0) {
962
+ // Try to match the explicit extension
963
+ if (code === ext.charCodeAt(extIdx)) {
964
+ if (--extIdx === -1) {
965
+ // We matched the extension, so mark this as the end of our path
966
+ // component
967
+ end = i;
968
+ }
969
+ }
970
+ else {
971
+ // Extension does not match, so our result is the entire path
972
+ // component
973
+ extIdx = -1;
974
+ end = firstNonSlashEnd;
975
+ }
976
+ }
977
+ }
978
+ }
979
+ if (start === end) {
980
+ end = firstNonSlashEnd;
981
+ }
982
+ else if (end === -1) {
983
+ end = path.length;
984
+ }
985
+ return path.slice(start, end);
986
+ }
987
+ else {
988
+ for (i = path.length - 1; i >= start; --i) {
989
+ if (isPathSeparator(path.charCodeAt(i))) {
990
+ // If we reached a path separator that was not part of a set of path
991
+ // separators at the end of the string, stop now
992
+ if (!matchedSlash) {
993
+ start = i + 1;
994
+ break;
995
+ }
996
+ }
997
+ else if (end === -1) {
998
+ // We saw the first non-path separator, mark this as the end of our
999
+ // path component
1000
+ matchedSlash = false;
1001
+ end = i + 1;
1002
+ }
1003
+ }
1004
+ if (end === -1) {
1005
+ return '';
1006
+ }
1007
+ return path.slice(start, end);
1008
+ }
1009
+ },
1010
+ extname(path) {
1011
+ validateString(path, 'path');
1012
+ let start = 0;
1013
+ let startDot = -1;
1014
+ let startPart = 0;
1015
+ let end = -1;
1016
+ let matchedSlash = true;
1017
+ // Track the state of characters (if any) we see before our first dot and
1018
+ // after any path separator we find
1019
+ let preDotState = 0;
1020
+ // Check for a drive letter prefix so as not to mistake the following
1021
+ // path separator as an extra separator at the end of the path that can be
1022
+ // disregarded
1023
+ if (path.length >= 2 && path.charCodeAt(1) === CHAR_COLON && isWindowsDeviceRoot(path.charCodeAt(0))) {
1024
+ start = startPart = 2;
1025
+ }
1026
+ for (let i = path.length - 1; i >= start; --i) {
1027
+ const code = path.charCodeAt(i);
1028
+ if (isPathSeparator(code)) {
1029
+ // If we reached a path separator that was not part of a set of path
1030
+ // separators at the end of the string, stop now
1031
+ if (!matchedSlash) {
1032
+ startPart = i + 1;
1033
+ break;
1034
+ }
1035
+ continue;
1036
+ }
1037
+ if (end === -1) {
1038
+ // We saw the first non-path separator, mark this as the end of our
1039
+ // extension
1040
+ matchedSlash = false;
1041
+ end = i + 1;
1042
+ }
1043
+ if (code === CHAR_DOT) {
1044
+ // If this is our first dot, mark it as the start of our extension
1045
+ if (startDot === -1) {
1046
+ startDot = i;
1047
+ }
1048
+ else if (preDotState !== 1) {
1049
+ preDotState = 1;
1050
+ }
1051
+ }
1052
+ else if (startDot !== -1) {
1053
+ // We saw a non-dot and non-path separator before our dot, so we should
1054
+ // have a good chance at having a non-empty extension
1055
+ preDotState = -1;
1056
+ }
1057
+ }
1058
+ if (startDot === -1 ||
1059
+ end === -1 ||
1060
+ // We saw a non-dot character immediately before the dot
1061
+ preDotState === 0 ||
1062
+ // The (right-most) trimmed path component is exactly '..'
1063
+ (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)) {
1064
+ return '';
1065
+ }
1066
+ return path.slice(startDot, end);
1067
+ },
1068
+ format(pathObject) {
1069
+ if (pathObject === null || typeof pathObject !== 'object') {
1070
+ throw new ErrorInvalidArgType('pathObject', 'Object', pathObject);
1071
+ }
1072
+ return _format('\\', pathObject);
1073
+ },
1074
+ parse(path) {
1075
+ validateString(path, 'path');
1076
+ const ret = { root: '', dir: '', base: '', ext: '', name: '' };
1077
+ if (path.length === 0) {
1078
+ return ret;
1079
+ }
1080
+ const len = path.length;
1081
+ let rootEnd = 0;
1082
+ let code = path.charCodeAt(0);
1083
+ // Try to match a root
1084
+ if (len > 1) {
1085
+ if (isPathSeparator(code)) {
1086
+ // Possible UNC root
1087
+ rootEnd = 1;
1088
+ if (isPathSeparator(path.charCodeAt(1))) {
1089
+ // Matched double path separator at beginning
1090
+ let j = 2;
1091
+ let last = j;
1092
+ // Match 1 or more non-path separators
1093
+ for (; j < len; ++j) {
1094
+ if (isPathSeparator(path.charCodeAt(j))) {
1095
+ break;
1096
+ }
1097
+ }
1098
+ if (j < len && j !== last) {
1099
+ // Matched!
1100
+ last = j;
1101
+ // Match 1 or more path separators
1102
+ for (; j < len; ++j) {
1103
+ if (!isPathSeparator(path.charCodeAt(j))) {
1104
+ break;
1105
+ }
1106
+ }
1107
+ if (j < len && j !== last) {
1108
+ // Matched!
1109
+ last = j;
1110
+ // Match 1 or more non-path separators
1111
+ for (; j < len; ++j) {
1112
+ if (isPathSeparator(path.charCodeAt(j))) {
1113
+ break;
1114
+ }
1115
+ }
1116
+ if (j === len) {
1117
+ // We matched a UNC root only
1118
+ rootEnd = j;
1119
+ }
1120
+ else if (j !== last) {
1121
+ // We matched a UNC root with leftovers
1122
+ rootEnd = j + 1;
1123
+ }
1124
+ }
1125
+ }
1126
+ }
1127
+ }
1128
+ else if (isWindowsDeviceRoot(code)) {
1129
+ // Possible device root
1130
+ if (path.charCodeAt(1) === CHAR_COLON) {
1131
+ rootEnd = 2;
1132
+ if (len > 2) {
1133
+ if (isPathSeparator(path.charCodeAt(2))) {
1134
+ if (len === 3) {
1135
+ // `path` contains just a drive root, exit early to avoid
1136
+ // unnecessary work
1137
+ ret.root = ret.dir = path;
1138
+ return ret;
1139
+ }
1140
+ rootEnd = 3;
1141
+ }
1142
+ }
1143
+ else {
1144
+ // `path` contains just a drive root, exit early to avoid
1145
+ // unnecessary work
1146
+ ret.root = ret.dir = path;
1147
+ return ret;
1148
+ }
1149
+ }
1150
+ }
1151
+ }
1152
+ else if (isPathSeparator(code)) {
1153
+ // `path` contains just a path separator, exit early to avoid
1154
+ // unnecessary work
1155
+ ret.root = ret.dir = path;
1156
+ return ret;
1157
+ }
1158
+ if (rootEnd > 0) {
1159
+ ret.root = path.slice(0, rootEnd);
1160
+ }
1161
+ let startDot = -1;
1162
+ let startPart = rootEnd;
1163
+ let end = -1;
1164
+ let matchedSlash = true;
1165
+ let i = path.length - 1;
1166
+ // Track the state of characters (if any) we see before our first dot and
1167
+ // after any path separator we find
1168
+ let preDotState = 0;
1169
+ // Get non-dir info
1170
+ for (; i >= rootEnd; --i) {
1171
+ code = path.charCodeAt(i);
1172
+ if (isPathSeparator(code)) {
1173
+ // If we reached a path separator that was not part of a set of path
1174
+ // separators at the end of the string, stop now
1175
+ if (!matchedSlash) {
1176
+ startPart = i + 1;
1177
+ break;
1178
+ }
1179
+ continue;
1180
+ }
1181
+ if (end === -1) {
1182
+ // We saw the first non-path separator, mark this as the end of our
1183
+ // extension
1184
+ matchedSlash = false;
1185
+ end = i + 1;
1186
+ }
1187
+ if (code === CHAR_DOT) {
1188
+ // If this is our first dot, mark it as the start of our extension
1189
+ if (startDot === -1) {
1190
+ startDot = i;
1191
+ }
1192
+ else if (preDotState !== 1) {
1193
+ preDotState = 1;
1194
+ }
1195
+ }
1196
+ else if (startDot !== -1) {
1197
+ // We saw a non-dot and non-path separator before our dot, so we should
1198
+ // have a good chance at having a non-empty extension
1199
+ preDotState = -1;
1200
+ }
1201
+ }
1202
+ if (startDot === -1 ||
1203
+ end === -1 ||
1204
+ // We saw a non-dot character immediately before the dot
1205
+ preDotState === 0 ||
1206
+ // The (right-most) trimmed path component is exactly '..'
1207
+ (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)) {
1208
+ if (end !== -1) {
1209
+ ret.base = ret.name = path.slice(startPart, end);
1210
+ }
1211
+ }
1212
+ else {
1213
+ ret.name = path.slice(startPart, startDot);
1214
+ ret.base = path.slice(startPart, end);
1215
+ ret.ext = path.slice(startDot, end);
1216
+ }
1217
+ // If the directory is the root, use the entire root as the `dir` including
1218
+ // the trailing slash if any (`C:\abc` -> `C:\`). Otherwise, strip out the
1219
+ // trailing slash (`C:\abc\def` -> `C:\abc`).
1220
+ if (startPart > 0 && startPart !== rootEnd) {
1221
+ ret.dir = path.slice(0, startPart - 1);
1222
+ }
1223
+ else {
1224
+ ret.dir = ret.root;
1225
+ }
1226
+ return ret;
1227
+ },
1228
+ sep: '\\',
1229
+ delimiter: ';',
1230
+ win32: null,
1231
+ posix: null,
1232
+ };
1233
+ exports.posix = {
1234
+ // path.resolve([from ...], to)
1235
+ resolve(...pathSegments) {
1236
+ let resolvedPath = '';
1237
+ let resolvedAbsolute = false;
1238
+ for (let i = pathSegments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
1239
+ let path;
1240
+ if (i >= 0) {
1241
+ path = pathSegments[i];
1242
+ }
1243
+ else {
1244
+ path = process_1.Process.cwd();
1245
+ }
1246
+ validateString(path, 'path');
1247
+ // Skip empty entries
1248
+ if (path.length === 0) {
1249
+ continue;
1250
+ }
1251
+ resolvedPath = path + '/' + resolvedPath;
1252
+ resolvedAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
1253
+ }
1254
+ // At this point the path should be resolved to a full absolute path, but
1255
+ // handle relative paths to be safe (might happen when Process.cwd() fails)
1256
+ // Normalize the path
1257
+ resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute, '/', isPosixPathSeparator);
1258
+ if (resolvedAbsolute) {
1259
+ if (resolvedPath.length > 0) {
1260
+ return '/' + resolvedPath;
1261
+ }
1262
+ else {
1263
+ return '/';
1264
+ }
1265
+ }
1266
+ else if (resolvedPath.length > 0) {
1267
+ return resolvedPath;
1268
+ }
1269
+ else {
1270
+ return '.';
1271
+ }
1272
+ },
1273
+ normalize(path) {
1274
+ validateString(path, 'path');
1275
+ if (path.length === 0) {
1276
+ return '.';
1277
+ }
1278
+ const isAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
1279
+ const trailingSeparator = path.charCodeAt(path.length - 1) === CHAR_FORWARD_SLASH;
1280
+ // Normalize the path
1281
+ path = normalizeString(path, !isAbsolute, '/', isPosixPathSeparator);
1282
+ if (path.length === 0 && !isAbsolute) {
1283
+ path = '.';
1284
+ }
1285
+ if (path.length > 0 && trailingSeparator) {
1286
+ path += '/';
1287
+ }
1288
+ if (isAbsolute) {
1289
+ return '/' + path;
1290
+ }
1291
+ return path;
1292
+ },
1293
+ isAbsolute(path) {
1294
+ validateString(path, 'path');
1295
+ return path.length > 0 && path.charCodeAt(0) === CHAR_FORWARD_SLASH;
1296
+ },
1297
+ join(...paths) {
1298
+ if (paths.length === 0) {
1299
+ return '.';
1300
+ }
1301
+ let joined;
1302
+ for (let i = 0; i < paths.length; ++i) {
1303
+ // eslint-disable-next-line prefer-rest-params
1304
+ const arg = arguments[i];
1305
+ validateString(arg, 'path');
1306
+ if (arg.length > 0) {
1307
+ if (joined === undefined) {
1308
+ joined = arg;
1309
+ }
1310
+ else {
1311
+ joined += '/' + arg;
1312
+ }
1313
+ }
1314
+ }
1315
+ if (joined === undefined) {
1316
+ return '.';
1317
+ }
1318
+ return exports.posix.normalize(joined);
1319
+ },
1320
+ relative(from, to) {
1321
+ validateString(from, 'from');
1322
+ validateString(to, 'to');
1323
+ if (from === to) {
1324
+ return '';
1325
+ }
1326
+ from = exports.posix.resolve(from);
1327
+ to = exports.posix.resolve(to);
1328
+ if (from === to) {
1329
+ return '';
1330
+ }
1331
+ // Trim any leading backslashes
1332
+ let fromStart = 1;
1333
+ for (; fromStart < from.length; ++fromStart) {
1334
+ if (from.charCodeAt(fromStart) !== CHAR_FORWARD_SLASH) {
1335
+ break;
1336
+ }
1337
+ }
1338
+ const fromEnd = from.length;
1339
+ const fromLen = fromEnd - fromStart;
1340
+ // Trim any leading backslashes
1341
+ let toStart = 1;
1342
+ for (; toStart < to.length; ++toStart) {
1343
+ if (to.charCodeAt(toStart) !== CHAR_FORWARD_SLASH) {
1344
+ break;
1345
+ }
1346
+ }
1347
+ const toEnd = to.length;
1348
+ const toLen = toEnd - toStart;
1349
+ // Compare paths to find the longest common path from root
1350
+ const length = fromLen < toLen ? fromLen : toLen;
1351
+ let lastCommonSep = -1;
1352
+ let i = 0;
1353
+ for (; i <= length; ++i) {
1354
+ if (i === length) {
1355
+ if (toLen > length) {
1356
+ if (to.charCodeAt(toStart + i) === CHAR_FORWARD_SLASH) {
1357
+ // We get here if `from` is the exact base path for `to`.
1358
+ // For example: from='/foo/bar'; to='/foo/bar/baz'
1359
+ return to.slice(toStart + i + 1);
1360
+ }
1361
+ else if (i === 0) {
1362
+ // We get here if `from` is the root
1363
+ // For example: from='/'; to='/foo'
1364
+ return to.slice(toStart + i);
1365
+ }
1366
+ }
1367
+ else if (fromLen > length) {
1368
+ if (from.charCodeAt(fromStart + i) === CHAR_FORWARD_SLASH) {
1369
+ // We get here if `to` is the exact base path for `from`.
1370
+ // For example: from='/foo/bar/baz'; to='/foo/bar'
1371
+ lastCommonSep = i;
1372
+ }
1373
+ else if (i === 0) {
1374
+ // We get here if `to` is the root.
1375
+ // For example: from='/foo'; to='/'
1376
+ lastCommonSep = 0;
1377
+ }
1378
+ }
1379
+ break;
1380
+ }
1381
+ const fromCode = from.charCodeAt(fromStart + i);
1382
+ const toCode = to.charCodeAt(toStart + i);
1383
+ if (fromCode !== toCode) {
1384
+ break;
1385
+ }
1386
+ else if (fromCode === CHAR_FORWARD_SLASH) {
1387
+ lastCommonSep = i;
1388
+ }
1389
+ }
1390
+ let out = '';
1391
+ // Generate the relative path based on the path difference between `to`
1392
+ // and `from`
1393
+ for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
1394
+ if (i === fromEnd || from.charCodeAt(i) === CHAR_FORWARD_SLASH) {
1395
+ if (out.length === 0) {
1396
+ out += '..';
1397
+ }
1398
+ else {
1399
+ out += '/..';
1400
+ }
1401
+ }
1402
+ }
1403
+ // Lastly, append the rest of the destination (`to`) path that comes after
1404
+ // the common path parts
1405
+ if (out.length > 0) {
1406
+ return out + to.slice(toStart + lastCommonSep);
1407
+ }
1408
+ else {
1409
+ toStart += lastCommonSep;
1410
+ if (to.charCodeAt(toStart) === CHAR_FORWARD_SLASH) {
1411
+ ++toStart;
1412
+ }
1413
+ return to.slice(toStart);
1414
+ }
1415
+ },
1416
+ toNamespacedPath(path) {
1417
+ // Non-op on posix systems
1418
+ return path;
1419
+ },
1420
+ dirname(path) {
1421
+ validateString(path, 'path');
1422
+ if (path.length === 0) {
1423
+ return '.';
1424
+ }
1425
+ const hasRoot = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
1426
+ let end = -1;
1427
+ let matchedSlash = true;
1428
+ for (let i = path.length - 1; i >= 1; --i) {
1429
+ if (path.charCodeAt(i) === CHAR_FORWARD_SLASH) {
1430
+ if (!matchedSlash) {
1431
+ end = i;
1432
+ break;
1433
+ }
1434
+ }
1435
+ else {
1436
+ // We saw the first non-path separator
1437
+ matchedSlash = false;
1438
+ }
1439
+ }
1440
+ if (end === -1) {
1441
+ return hasRoot ? '/' : '.';
1442
+ }
1443
+ if (hasRoot && end === 1) {
1444
+ return '//';
1445
+ }
1446
+ return path.slice(0, end);
1447
+ },
1448
+ basename(path, ext) {
1449
+ if (ext !== undefined) {
1450
+ validateString(ext, 'ext');
1451
+ }
1452
+ validateString(path, 'path');
1453
+ let start = 0;
1454
+ let end = -1;
1455
+ let matchedSlash = true;
1456
+ let i;
1457
+ if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
1458
+ if (ext.length === path.length && ext === path) {
1459
+ return '';
1460
+ }
1461
+ let extIdx = ext.length - 1;
1462
+ let firstNonSlashEnd = -1;
1463
+ for (i = path.length - 1; i >= 0; --i) {
1464
+ const code = path.charCodeAt(i);
1465
+ if (code === CHAR_FORWARD_SLASH) {
1466
+ // If we reached a path separator that was not part of a set of path
1467
+ // separators at the end of the string, stop now
1468
+ if (!matchedSlash) {
1469
+ start = i + 1;
1470
+ break;
1471
+ }
1472
+ }
1473
+ else {
1474
+ if (firstNonSlashEnd === -1) {
1475
+ // We saw the first non-path separator, remember this index in case
1476
+ // we need it if the extension ends up not matching
1477
+ matchedSlash = false;
1478
+ firstNonSlashEnd = i + 1;
1479
+ }
1480
+ if (extIdx >= 0) {
1481
+ // Try to match the explicit extension
1482
+ if (code === ext.charCodeAt(extIdx)) {
1483
+ if (--extIdx === -1) {
1484
+ // We matched the extension, so mark this as the end of our path
1485
+ // component
1486
+ end = i;
1487
+ }
1488
+ }
1489
+ else {
1490
+ // Extension does not match, so our result is the entire path
1491
+ // component
1492
+ extIdx = -1;
1493
+ end = firstNonSlashEnd;
1494
+ }
1495
+ }
1496
+ }
1497
+ }
1498
+ if (start === end) {
1499
+ end = firstNonSlashEnd;
1500
+ }
1501
+ else if (end === -1) {
1502
+ end = path.length;
1503
+ }
1504
+ return path.slice(start, end);
1505
+ }
1506
+ else {
1507
+ for (i = path.length - 1; i >= 0; --i) {
1508
+ if (path.charCodeAt(i) === CHAR_FORWARD_SLASH) {
1509
+ // If we reached a path separator that was not part of a set of path
1510
+ // separators at the end of the string, stop now
1511
+ if (!matchedSlash) {
1512
+ start = i + 1;
1513
+ break;
1514
+ }
1515
+ }
1516
+ else if (end === -1) {
1517
+ // We saw the first non-path separator, mark this as the end of our
1518
+ // path component
1519
+ matchedSlash = false;
1520
+ end = i + 1;
1521
+ }
1522
+ }
1523
+ if (end === -1) {
1524
+ return '';
1525
+ }
1526
+ return path.slice(start, end);
1527
+ }
1528
+ },
1529
+ extname(path) {
1530
+ validateString(path, 'path');
1531
+ let startDot = -1;
1532
+ let startPart = 0;
1533
+ let end = -1;
1534
+ let matchedSlash = true;
1535
+ // Track the state of characters (if any) we see before our first dot and
1536
+ // after any path separator we find
1537
+ let preDotState = 0;
1538
+ for (let i = path.length - 1; i >= 0; --i) {
1539
+ const code = path.charCodeAt(i);
1540
+ if (code === CHAR_FORWARD_SLASH) {
1541
+ // If we reached a path separator that was not part of a set of path
1542
+ // separators at the end of the string, stop now
1543
+ if (!matchedSlash) {
1544
+ startPart = i + 1;
1545
+ break;
1546
+ }
1547
+ continue;
1548
+ }
1549
+ if (end === -1) {
1550
+ // We saw the first non-path separator, mark this as the end of our
1551
+ // extension
1552
+ matchedSlash = false;
1553
+ end = i + 1;
1554
+ }
1555
+ if (code === CHAR_DOT) {
1556
+ // If this is our first dot, mark it as the start of our extension
1557
+ if (startDot === -1) {
1558
+ startDot = i;
1559
+ }
1560
+ else if (preDotState !== 1) {
1561
+ preDotState = 1;
1562
+ }
1563
+ }
1564
+ else if (startDot !== -1) {
1565
+ // We saw a non-dot and non-path separator before our dot, so we should
1566
+ // have a good chance at having a non-empty extension
1567
+ preDotState = -1;
1568
+ }
1569
+ }
1570
+ if (startDot === -1 ||
1571
+ end === -1 ||
1572
+ // We saw a non-dot character immediately before the dot
1573
+ preDotState === 0 ||
1574
+ // The (right-most) trimmed path component is exactly '..'
1575
+ (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)) {
1576
+ return '';
1577
+ }
1578
+ return path.slice(startDot, end);
1579
+ },
1580
+ format(pathObject) {
1581
+ if (pathObject === null || typeof pathObject !== 'object') {
1582
+ throw new ErrorInvalidArgType('pathObject', 'Object', pathObject);
1583
+ }
1584
+ return _format('/', pathObject);
1585
+ },
1586
+ parse(path) {
1587
+ validateString(path, 'path');
1588
+ const ret = { root: '', dir: '', base: '', ext: '', name: '' };
1589
+ if (path.length === 0) {
1590
+ return ret;
1591
+ }
1592
+ const isAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
1593
+ let start;
1594
+ if (isAbsolute) {
1595
+ ret.root = '/';
1596
+ start = 1;
1597
+ }
1598
+ else {
1599
+ start = 0;
1600
+ }
1601
+ let startDot = -1;
1602
+ let startPart = 0;
1603
+ let end = -1;
1604
+ let matchedSlash = true;
1605
+ let i = path.length - 1;
1606
+ // Track the state of characters (if any) we see before our first dot and
1607
+ // after any path separator we find
1608
+ let preDotState = 0;
1609
+ // Get non-dir info
1610
+ for (; i >= start; --i) {
1611
+ const code = path.charCodeAt(i);
1612
+ if (code === CHAR_FORWARD_SLASH) {
1613
+ // If we reached a path separator that was not part of a set of path
1614
+ // separators at the end of the string, stop now
1615
+ if (!matchedSlash) {
1616
+ startPart = i + 1;
1617
+ break;
1618
+ }
1619
+ continue;
1620
+ }
1621
+ if (end === -1) {
1622
+ // We saw the first non-path separator, mark this as the end of our
1623
+ // extension
1624
+ matchedSlash = false;
1625
+ end = i + 1;
1626
+ }
1627
+ if (code === CHAR_DOT) {
1628
+ // If this is our first dot, mark it as the start of our extension
1629
+ if (startDot === -1) {
1630
+ startDot = i;
1631
+ }
1632
+ else if (preDotState !== 1) {
1633
+ preDotState = 1;
1634
+ }
1635
+ }
1636
+ else if (startDot !== -1) {
1637
+ // We saw a non-dot and non-path separator before our dot, so we should
1638
+ // have a good chance at having a non-empty extension
1639
+ preDotState = -1;
1640
+ }
1641
+ }
1642
+ if (startDot === -1 ||
1643
+ end === -1 ||
1644
+ // We saw a non-dot character immediately before the dot
1645
+ preDotState === 0 ||
1646
+ // The (right-most) trimmed path component is exactly '..'
1647
+ (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)) {
1648
+ if (end !== -1) {
1649
+ if (startPart === 0 && isAbsolute) {
1650
+ ret.base = ret.name = path.slice(1, end);
1651
+ }
1652
+ else {
1653
+ ret.base = ret.name = path.slice(startPart, end);
1654
+ }
1655
+ }
1656
+ }
1657
+ else {
1658
+ if (startPart === 0 && isAbsolute) {
1659
+ ret.name = path.slice(1, startDot);
1660
+ ret.base = path.slice(1, end);
1661
+ }
1662
+ else {
1663
+ ret.name = path.slice(startPart, startDot);
1664
+ ret.base = path.slice(startPart, end);
1665
+ }
1666
+ ret.ext = path.slice(startDot, end);
1667
+ }
1668
+ if (startPart > 0) {
1669
+ ret.dir = path.slice(0, startPart - 1);
1670
+ }
1671
+ else if (isAbsolute) {
1672
+ ret.dir = '/';
1673
+ }
1674
+ return ret;
1675
+ },
1676
+ sep: '/',
1677
+ delimiter: ':',
1678
+ win32: null,
1679
+ posix: null,
1680
+ };
1681
+ exports.posix.win32 = exports.win32.win32 = exports.win32;
1682
+ exports.posix.posix = exports.win32.posix = exports.posix;
1683
+ exports.normalize = process_1.Process.platform === 'win32' ? exports.win32.normalize : exports.posix.normalize;
1684
+ exports.isAbsolute = process_1.Process.platform === 'win32' ? exports.win32.isAbsolute : exports.posix.isAbsolute;
1685
+ exports.join = process_1.Process.platform === 'win32' ? exports.win32.join : exports.posix.join;
1686
+ exports.resolve = process_1.Process.platform === 'win32' ? exports.win32.resolve : exports.posix.resolve;
1687
+ exports.relative = process_1.Process.platform === 'win32' ? exports.win32.relative : exports.posix.relative;
1688
+ exports.dirname = process_1.Process.platform === 'win32' ? exports.win32.dirname : exports.posix.dirname;
1689
+ exports.basename = process_1.Process.platform === 'win32' ? exports.win32.basename : exports.posix.basename;
1690
+ exports.extname = process_1.Process.platform === 'win32' ? exports.win32.extname : exports.posix.extname;
1691
+ exports.format = process_1.Process.platform === 'win32' ? exports.win32.format : exports.posix.format;
1692
+ exports.parse = process_1.Process.platform === 'win32' ? exports.win32.parse : exports.posix.parse;
1693
+ exports.toNamespacedPath = process_1.Process.platform === 'win32' ? exports.win32.toNamespacedPath : exports.posix.toNamespacedPath;
1694
+ exports.sep = process_1.Process.platform === 'win32' ? exports.win32.sep : exports.posix.sep;
1695
+ exports.delimiter = process_1.Process.platform === 'win32' ? exports.win32.delimiter : exports.posix.delimiter;
1696
+ //# sourceMappingURL=path.js.map