@opensumi/ide-core-common 2.12.1-next-079c1930

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