korext 0.1.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 (517) hide show
  1. package/bin/korext.js +278 -0
  2. package/korext-cli-0.1.0.tgz +0 -0
  3. package/node_modules/ansi-regex/index.d.ts +37 -0
  4. package/node_modules/ansi-regex/index.js +10 -0
  5. package/node_modules/ansi-regex/license +9 -0
  6. package/node_modules/ansi-regex/package.json +55 -0
  7. package/node_modules/ansi-regex/readme.md +78 -0
  8. package/node_modules/ansi-styles/index.d.ts +345 -0
  9. package/node_modules/ansi-styles/index.js +163 -0
  10. package/node_modules/ansi-styles/license +9 -0
  11. package/node_modules/ansi-styles/package.json +56 -0
  12. package/node_modules/ansi-styles/readme.md +152 -0
  13. package/node_modules/balanced-match/LICENSE.md +23 -0
  14. package/node_modules/balanced-match/README.md +57 -0
  15. package/node_modules/balanced-match/dist/commonjs/index.d.ts +9 -0
  16. package/node_modules/balanced-match/dist/commonjs/index.d.ts.map +1 -0
  17. package/node_modules/balanced-match/dist/commonjs/index.js +59 -0
  18. package/node_modules/balanced-match/dist/commonjs/index.js.map +1 -0
  19. package/node_modules/balanced-match/dist/commonjs/package.json +3 -0
  20. package/node_modules/balanced-match/dist/esm/index.d.ts +9 -0
  21. package/node_modules/balanced-match/dist/esm/index.d.ts.map +1 -0
  22. package/node_modules/balanced-match/dist/esm/index.js +54 -0
  23. package/node_modules/balanced-match/dist/esm/index.js.map +1 -0
  24. package/node_modules/balanced-match/dist/esm/package.json +3 -0
  25. package/node_modules/balanced-match/package.json +68 -0
  26. package/node_modules/base64-js/LICENSE +21 -0
  27. package/node_modules/base64-js/README.md +34 -0
  28. package/node_modules/base64-js/base64js.min.js +1 -0
  29. package/node_modules/base64-js/index.d.ts +3 -0
  30. package/node_modules/base64-js/index.js +150 -0
  31. package/node_modules/base64-js/package.json +47 -0
  32. package/node_modules/bl/.travis.yml +17 -0
  33. package/node_modules/bl/BufferList.js +396 -0
  34. package/node_modules/bl/LICENSE.md +13 -0
  35. package/node_modules/bl/README.md +247 -0
  36. package/node_modules/bl/bl.js +84 -0
  37. package/node_modules/bl/package.json +37 -0
  38. package/node_modules/bl/test/convert.js +21 -0
  39. package/node_modules/bl/test/indexOf.js +492 -0
  40. package/node_modules/bl/test/isBufferList.js +32 -0
  41. package/node_modules/bl/test/test.js +869 -0
  42. package/node_modules/brace-expansion/LICENSE +23 -0
  43. package/node_modules/brace-expansion/README.md +94 -0
  44. package/node_modules/brace-expansion/dist/commonjs/index.d.ts +6 -0
  45. package/node_modules/brace-expansion/dist/commonjs/index.d.ts.map +1 -0
  46. package/node_modules/brace-expansion/dist/commonjs/index.js +199 -0
  47. package/node_modules/brace-expansion/dist/commonjs/index.js.map +1 -0
  48. package/node_modules/brace-expansion/dist/commonjs/package.json +3 -0
  49. package/node_modules/brace-expansion/dist/esm/index.d.ts +6 -0
  50. package/node_modules/brace-expansion/dist/esm/index.d.ts.map +1 -0
  51. package/node_modules/brace-expansion/dist/esm/index.js +195 -0
  52. package/node_modules/brace-expansion/dist/esm/index.js.map +1 -0
  53. package/node_modules/brace-expansion/dist/esm/package.json +3 -0
  54. package/node_modules/brace-expansion/package.json +64 -0
  55. package/node_modules/buffer/AUTHORS.md +70 -0
  56. package/node_modules/buffer/LICENSE +21 -0
  57. package/node_modules/buffer/README.md +410 -0
  58. package/node_modules/buffer/index.d.ts +186 -0
  59. package/node_modules/buffer/index.js +1817 -0
  60. package/node_modules/buffer/package.json +96 -0
  61. package/node_modules/chalk/index.d.ts +415 -0
  62. package/node_modules/chalk/license +9 -0
  63. package/node_modules/chalk/package.json +68 -0
  64. package/node_modules/chalk/readme.md +341 -0
  65. package/node_modules/chalk/source/index.js +229 -0
  66. package/node_modules/chalk/source/templates.js +134 -0
  67. package/node_modules/chalk/source/util.js +39 -0
  68. package/node_modules/cli-cursor/index.d.ts +45 -0
  69. package/node_modules/cli-cursor/index.js +35 -0
  70. package/node_modules/cli-cursor/license +9 -0
  71. package/node_modules/cli-cursor/package.json +46 -0
  72. package/node_modules/cli-cursor/readme.md +55 -0
  73. package/node_modules/cli-spinners/index.d.ts +128 -0
  74. package/node_modules/cli-spinners/index.js +15 -0
  75. package/node_modules/cli-spinners/license +9 -0
  76. package/node_modules/cli-spinners/package.json +50 -0
  77. package/node_modules/cli-spinners/readme.md +54 -0
  78. package/node_modules/cli-spinners/spinners.json +1622 -0
  79. package/node_modules/clone/.npmignore +4 -0
  80. package/node_modules/clone/LICENSE +18 -0
  81. package/node_modules/clone/README.md +126 -0
  82. package/node_modules/clone/clone.iml +10 -0
  83. package/node_modules/clone/clone.js +166 -0
  84. package/node_modules/clone/package.json +51 -0
  85. package/node_modules/color-convert/CHANGELOG.md +54 -0
  86. package/node_modules/color-convert/LICENSE +21 -0
  87. package/node_modules/color-convert/README.md +68 -0
  88. package/node_modules/color-convert/conversions.js +839 -0
  89. package/node_modules/color-convert/index.js +81 -0
  90. package/node_modules/color-convert/package.json +48 -0
  91. package/node_modules/color-convert/route.js +97 -0
  92. package/node_modules/color-name/LICENSE +8 -0
  93. package/node_modules/color-name/README.md +11 -0
  94. package/node_modules/color-name/index.js +152 -0
  95. package/node_modules/color-name/package.json +28 -0
  96. package/node_modules/commander/LICENSE +22 -0
  97. package/node_modules/commander/Readme.md +1176 -0
  98. package/node_modules/commander/esm.mjs +16 -0
  99. package/node_modules/commander/index.js +24 -0
  100. package/node_modules/commander/lib/argument.js +150 -0
  101. package/node_modules/commander/lib/command.js +2777 -0
  102. package/node_modules/commander/lib/error.js +39 -0
  103. package/node_modules/commander/lib/help.js +747 -0
  104. package/node_modules/commander/lib/option.js +380 -0
  105. package/node_modules/commander/lib/suggestSimilar.js +101 -0
  106. package/node_modules/commander/package-support.json +19 -0
  107. package/node_modules/commander/package.json +82 -0
  108. package/node_modules/commander/typings/esm.d.mts +3 -0
  109. package/node_modules/commander/typings/index.d.ts +1113 -0
  110. package/node_modules/data-uri-to-buffer/README.md +88 -0
  111. package/node_modules/data-uri-to-buffer/dist/index.d.ts +15 -0
  112. package/node_modules/data-uri-to-buffer/dist/index.js +53 -0
  113. package/node_modules/data-uri-to-buffer/dist/index.js.map +1 -0
  114. package/node_modules/data-uri-to-buffer/package.json +62 -0
  115. package/node_modules/data-uri-to-buffer/src/index.ts +68 -0
  116. package/node_modules/defaults/LICENSE +22 -0
  117. package/node_modules/defaults/README.md +39 -0
  118. package/node_modules/defaults/index.js +13 -0
  119. package/node_modules/defaults/package.json +33 -0
  120. package/node_modules/defaults/test.js +34 -0
  121. package/node_modules/fetch-blob/LICENSE +21 -0
  122. package/node_modules/fetch-blob/README.md +106 -0
  123. package/node_modules/fetch-blob/file.d.ts +2 -0
  124. package/node_modules/fetch-blob/file.js +49 -0
  125. package/node_modules/fetch-blob/from.d.ts +26 -0
  126. package/node_modules/fetch-blob/from.js +100 -0
  127. package/node_modules/fetch-blob/index.d.ts +3 -0
  128. package/node_modules/fetch-blob/index.js +250 -0
  129. package/node_modules/fetch-blob/package.json +56 -0
  130. package/node_modules/fetch-blob/streams.cjs +51 -0
  131. package/node_modules/formdata-polyfill/FormData.js +441 -0
  132. package/node_modules/formdata-polyfill/LICENSE +21 -0
  133. package/node_modules/formdata-polyfill/README.md +145 -0
  134. package/node_modules/formdata-polyfill/esm.min.d.ts +5 -0
  135. package/node_modules/formdata-polyfill/esm.min.js +40 -0
  136. package/node_modules/formdata-polyfill/formdata-to-blob.js +39 -0
  137. package/node_modules/formdata-polyfill/formdata.min.js +21 -0
  138. package/node_modules/formdata-polyfill/package.json +50 -0
  139. package/node_modules/glob/LICENSE.md +63 -0
  140. package/node_modules/glob/README.md +1203 -0
  141. package/node_modules/glob/dist/commonjs/glob.d.ts +396 -0
  142. package/node_modules/glob/dist/commonjs/glob.d.ts.map +1 -0
  143. package/node_modules/glob/dist/commonjs/glob.js +248 -0
  144. package/node_modules/glob/dist/commonjs/glob.js.map +1 -0
  145. package/node_modules/glob/dist/commonjs/has-magic.d.ts +14 -0
  146. package/node_modules/glob/dist/commonjs/has-magic.d.ts.map +1 -0
  147. package/node_modules/glob/dist/commonjs/has-magic.js +27 -0
  148. package/node_modules/glob/dist/commonjs/has-magic.js.map +1 -0
  149. package/node_modules/glob/dist/commonjs/ignore.d.ts +24 -0
  150. package/node_modules/glob/dist/commonjs/ignore.d.ts.map +1 -0
  151. package/node_modules/glob/dist/commonjs/ignore.js +119 -0
  152. package/node_modules/glob/dist/commonjs/ignore.js.map +1 -0
  153. package/node_modules/glob/dist/commonjs/index.d.ts +97 -0
  154. package/node_modules/glob/dist/commonjs/index.d.ts.map +1 -0
  155. package/node_modules/glob/dist/commonjs/index.js +68 -0
  156. package/node_modules/glob/dist/commonjs/index.js.map +1 -0
  157. package/node_modules/glob/dist/commonjs/index.min.js +4 -0
  158. package/node_modules/glob/dist/commonjs/index.min.js.map +7 -0
  159. package/node_modules/glob/dist/commonjs/package.json +3 -0
  160. package/node_modules/glob/dist/commonjs/pattern.d.ts +79 -0
  161. package/node_modules/glob/dist/commonjs/pattern.d.ts.map +1 -0
  162. package/node_modules/glob/dist/commonjs/pattern.js +223 -0
  163. package/node_modules/glob/dist/commonjs/pattern.js.map +1 -0
  164. package/node_modules/glob/dist/commonjs/processor.d.ts +59 -0
  165. package/node_modules/glob/dist/commonjs/processor.d.ts.map +1 -0
  166. package/node_modules/glob/dist/commonjs/processor.js +301 -0
  167. package/node_modules/glob/dist/commonjs/processor.js.map +1 -0
  168. package/node_modules/glob/dist/commonjs/walker.d.ts +97 -0
  169. package/node_modules/glob/dist/commonjs/walker.d.ts.map +1 -0
  170. package/node_modules/glob/dist/commonjs/walker.js +387 -0
  171. package/node_modules/glob/dist/commonjs/walker.js.map +1 -0
  172. package/node_modules/glob/dist/esm/glob.d.ts +396 -0
  173. package/node_modules/glob/dist/esm/glob.d.ts.map +1 -0
  174. package/node_modules/glob/dist/esm/glob.js +244 -0
  175. package/node_modules/glob/dist/esm/glob.js.map +1 -0
  176. package/node_modules/glob/dist/esm/has-magic.d.ts +14 -0
  177. package/node_modules/glob/dist/esm/has-magic.d.ts.map +1 -0
  178. package/node_modules/glob/dist/esm/has-magic.js +23 -0
  179. package/node_modules/glob/dist/esm/has-magic.js.map +1 -0
  180. package/node_modules/glob/dist/esm/ignore.d.ts +24 -0
  181. package/node_modules/glob/dist/esm/ignore.d.ts.map +1 -0
  182. package/node_modules/glob/dist/esm/ignore.js +115 -0
  183. package/node_modules/glob/dist/esm/ignore.js.map +1 -0
  184. package/node_modules/glob/dist/esm/index.d.ts +97 -0
  185. package/node_modules/glob/dist/esm/index.d.ts.map +1 -0
  186. package/node_modules/glob/dist/esm/index.js +55 -0
  187. package/node_modules/glob/dist/esm/index.js.map +1 -0
  188. package/node_modules/glob/dist/esm/index.min.js +4 -0
  189. package/node_modules/glob/dist/esm/index.min.js.map +7 -0
  190. package/node_modules/glob/dist/esm/package.json +3 -0
  191. package/node_modules/glob/dist/esm/pattern.d.ts +79 -0
  192. package/node_modules/glob/dist/esm/pattern.d.ts.map +1 -0
  193. package/node_modules/glob/dist/esm/pattern.js +219 -0
  194. package/node_modules/glob/dist/esm/pattern.js.map +1 -0
  195. package/node_modules/glob/dist/esm/processor.d.ts +59 -0
  196. package/node_modules/glob/dist/esm/processor.d.ts.map +1 -0
  197. package/node_modules/glob/dist/esm/processor.js +294 -0
  198. package/node_modules/glob/dist/esm/processor.js.map +1 -0
  199. package/node_modules/glob/dist/esm/walker.d.ts +97 -0
  200. package/node_modules/glob/dist/esm/walker.d.ts.map +1 -0
  201. package/node_modules/glob/dist/esm/walker.js +381 -0
  202. package/node_modules/glob/dist/esm/walker.js.map +1 -0
  203. package/node_modules/glob/package.json +98 -0
  204. package/node_modules/has-flag/index.d.ts +39 -0
  205. package/node_modules/has-flag/index.js +8 -0
  206. package/node_modules/has-flag/license +9 -0
  207. package/node_modules/has-flag/package.json +46 -0
  208. package/node_modules/has-flag/readme.md +89 -0
  209. package/node_modules/ieee754/LICENSE +11 -0
  210. package/node_modules/ieee754/README.md +51 -0
  211. package/node_modules/ieee754/index.d.ts +10 -0
  212. package/node_modules/ieee754/index.js +85 -0
  213. package/node_modules/ieee754/package.json +52 -0
  214. package/node_modules/inherits/LICENSE +16 -0
  215. package/node_modules/inherits/README.md +42 -0
  216. package/node_modules/inherits/inherits.js +9 -0
  217. package/node_modules/inherits/inherits_browser.js +27 -0
  218. package/node_modules/inherits/package.json +29 -0
  219. package/node_modules/is-interactive/index.d.ts +31 -0
  220. package/node_modules/is-interactive/index.js +9 -0
  221. package/node_modules/is-interactive/license +9 -0
  222. package/node_modules/is-interactive/package.json +38 -0
  223. package/node_modules/is-interactive/readme.md +51 -0
  224. package/node_modules/is-unicode-supported/index.d.ts +14 -0
  225. package/node_modules/is-unicode-supported/index.js +13 -0
  226. package/node_modules/is-unicode-supported/license +9 -0
  227. package/node_modules/is-unicode-supported/package.json +41 -0
  228. package/node_modules/is-unicode-supported/readme.md +35 -0
  229. package/node_modules/log-symbols/browser.js +8 -0
  230. package/node_modules/log-symbols/index.d.ts +25 -0
  231. package/node_modules/log-symbols/index.js +19 -0
  232. package/node_modules/log-symbols/license +9 -0
  233. package/node_modules/log-symbols/package.json +52 -0
  234. package/node_modules/log-symbols/readme.md +51 -0
  235. package/node_modules/lru-cache/LICENSE.md +55 -0
  236. package/node_modules/lru-cache/README.md +383 -0
  237. package/node_modules/lru-cache/dist/commonjs/index.d.ts +1323 -0
  238. package/node_modules/lru-cache/dist/commonjs/index.d.ts.map +1 -0
  239. package/node_modules/lru-cache/dist/commonjs/index.js +1595 -0
  240. package/node_modules/lru-cache/dist/commonjs/index.js.map +1 -0
  241. package/node_modules/lru-cache/dist/commonjs/index.min.js +2 -0
  242. package/node_modules/lru-cache/dist/commonjs/index.min.js.map +7 -0
  243. package/node_modules/lru-cache/dist/commonjs/package.json +3 -0
  244. package/node_modules/lru-cache/dist/esm/index.d.ts +1323 -0
  245. package/node_modules/lru-cache/dist/esm/index.d.ts.map +1 -0
  246. package/node_modules/lru-cache/dist/esm/index.js +1591 -0
  247. package/node_modules/lru-cache/dist/esm/index.js.map +1 -0
  248. package/node_modules/lru-cache/dist/esm/index.min.js +2 -0
  249. package/node_modules/lru-cache/dist/esm/index.min.js.map +7 -0
  250. package/node_modules/lru-cache/dist/esm/package.json +3 -0
  251. package/node_modules/lru-cache/package.json +93 -0
  252. package/node_modules/mimic-fn/index.d.ts +54 -0
  253. package/node_modules/mimic-fn/index.js +13 -0
  254. package/node_modules/mimic-fn/license +9 -0
  255. package/node_modules/mimic-fn/package.json +42 -0
  256. package/node_modules/mimic-fn/readme.md +69 -0
  257. package/node_modules/minimatch/LICENSE.md +55 -0
  258. package/node_modules/minimatch/README.md +528 -0
  259. package/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts +2 -0
  260. package/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts.map +1 -0
  261. package/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js +14 -0
  262. package/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js.map +1 -0
  263. package/node_modules/minimatch/dist/commonjs/ast.d.ts +22 -0
  264. package/node_modules/minimatch/dist/commonjs/ast.d.ts.map +1 -0
  265. package/node_modules/minimatch/dist/commonjs/ast.js +846 -0
  266. package/node_modules/minimatch/dist/commonjs/ast.js.map +1 -0
  267. package/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts +8 -0
  268. package/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts.map +1 -0
  269. package/node_modules/minimatch/dist/commonjs/brace-expressions.js +150 -0
  270. package/node_modules/minimatch/dist/commonjs/brace-expressions.js.map +1 -0
  271. package/node_modules/minimatch/dist/commonjs/escape.d.ts +15 -0
  272. package/node_modules/minimatch/dist/commonjs/escape.d.ts.map +1 -0
  273. package/node_modules/minimatch/dist/commonjs/escape.js +30 -0
  274. package/node_modules/minimatch/dist/commonjs/escape.js.map +1 -0
  275. package/node_modules/minimatch/dist/commonjs/index.d.ts +174 -0
  276. package/node_modules/minimatch/dist/commonjs/index.d.ts.map +1 -0
  277. package/node_modules/minimatch/dist/commonjs/index.js +1121 -0
  278. package/node_modules/minimatch/dist/commonjs/index.js.map +1 -0
  279. package/node_modules/minimatch/dist/commonjs/package.json +3 -0
  280. package/node_modules/minimatch/dist/commonjs/unescape.d.ts +22 -0
  281. package/node_modules/minimatch/dist/commonjs/unescape.d.ts.map +1 -0
  282. package/node_modules/minimatch/dist/commonjs/unescape.js +38 -0
  283. package/node_modules/minimatch/dist/commonjs/unescape.js.map +1 -0
  284. package/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts +2 -0
  285. package/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts.map +1 -0
  286. package/node_modules/minimatch/dist/esm/assert-valid-pattern.js +10 -0
  287. package/node_modules/minimatch/dist/esm/assert-valid-pattern.js.map +1 -0
  288. package/node_modules/minimatch/dist/esm/ast.d.ts +22 -0
  289. package/node_modules/minimatch/dist/esm/ast.d.ts.map +1 -0
  290. package/node_modules/minimatch/dist/esm/ast.js +842 -0
  291. package/node_modules/minimatch/dist/esm/ast.js.map +1 -0
  292. package/node_modules/minimatch/dist/esm/brace-expressions.d.ts +8 -0
  293. package/node_modules/minimatch/dist/esm/brace-expressions.d.ts.map +1 -0
  294. package/node_modules/minimatch/dist/esm/brace-expressions.js +146 -0
  295. package/node_modules/minimatch/dist/esm/brace-expressions.js.map +1 -0
  296. package/node_modules/minimatch/dist/esm/escape.d.ts +15 -0
  297. package/node_modules/minimatch/dist/esm/escape.d.ts.map +1 -0
  298. package/node_modules/minimatch/dist/esm/escape.js +26 -0
  299. package/node_modules/minimatch/dist/esm/escape.js.map +1 -0
  300. package/node_modules/minimatch/dist/esm/index.d.ts +174 -0
  301. package/node_modules/minimatch/dist/esm/index.d.ts.map +1 -0
  302. package/node_modules/minimatch/dist/esm/index.js +1108 -0
  303. package/node_modules/minimatch/dist/esm/index.js.map +1 -0
  304. package/node_modules/minimatch/dist/esm/package.json +3 -0
  305. package/node_modules/minimatch/dist/esm/unescape.d.ts +22 -0
  306. package/node_modules/minimatch/dist/esm/unescape.d.ts.map +1 -0
  307. package/node_modules/minimatch/dist/esm/unescape.js +34 -0
  308. package/node_modules/minimatch/dist/esm/unescape.js.map +1 -0
  309. package/node_modules/minimatch/package.json +67 -0
  310. package/node_modules/minipass/LICENSE.md +55 -0
  311. package/node_modules/minipass/README.md +825 -0
  312. package/node_modules/minipass/dist/commonjs/index.d.ts +545 -0
  313. package/node_modules/minipass/dist/commonjs/index.d.ts.map +1 -0
  314. package/node_modules/minipass/dist/commonjs/index.js +1038 -0
  315. package/node_modules/minipass/dist/commonjs/index.js.map +1 -0
  316. package/node_modules/minipass/dist/commonjs/package.json +3 -0
  317. package/node_modules/minipass/dist/esm/index.d.ts +545 -0
  318. package/node_modules/minipass/dist/esm/index.d.ts.map +1 -0
  319. package/node_modules/minipass/dist/esm/index.js +1020 -0
  320. package/node_modules/minipass/dist/esm/index.js.map +1 -0
  321. package/node_modules/minipass/dist/esm/package.json +3 -0
  322. package/node_modules/minipass/package.json +77 -0
  323. package/node_modules/node-domexception/.history/README_20210527203617.md +2 -0
  324. package/node_modules/node-domexception/.history/README_20210527212714.md +41 -0
  325. package/node_modules/node-domexception/.history/README_20210527213345.md +36 -0
  326. package/node_modules/node-domexception/.history/README_20210527213411.md +36 -0
  327. package/node_modules/node-domexception/.history/README_20210527213803.md +36 -0
  328. package/node_modules/node-domexception/.history/README_20210527214323.md +38 -0
  329. package/node_modules/node-domexception/.history/README_20210527214408.md +38 -0
  330. package/node_modules/node-domexception/.history/index_20210527203842.js +0 -0
  331. package/node_modules/node-domexception/.history/index_20210527203947.js +8 -0
  332. package/node_modules/node-domexception/.history/index_20210527204259.js +9 -0
  333. package/node_modules/node-domexception/.history/index_20210527204418.js +9 -0
  334. package/node_modules/node-domexception/.history/index_20210527204756.js +11 -0
  335. package/node_modules/node-domexception/.history/index_20210527204833.js +11 -0
  336. package/node_modules/node-domexception/.history/index_20210527211208.js +15 -0
  337. package/node_modules/node-domexception/.history/index_20210527211248.js +15 -0
  338. package/node_modules/node-domexception/.history/index_20210527212722.js +23 -0
  339. package/node_modules/node-domexception/.history/index_20210527212731.js +23 -0
  340. package/node_modules/node-domexception/.history/index_20210527212746.js +15 -0
  341. package/node_modules/node-domexception/.history/index_20210527212900.js +16 -0
  342. package/node_modules/node-domexception/.history/index_20210527213022.js +16 -0
  343. package/node_modules/node-domexception/.history/index_20210527213822.js +16 -0
  344. package/node_modules/node-domexception/.history/index_20210527213843.js +17 -0
  345. package/node_modules/node-domexception/.history/index_20210527213852.js +17 -0
  346. package/node_modules/node-domexception/.history/index_20210527213910.js +16 -0
  347. package/node_modules/node-domexception/.history/index_20210527214034.js +16 -0
  348. package/node_modules/node-domexception/.history/index_20210527214643.js +41 -0
  349. package/node_modules/node-domexception/.history/index_20210527214654.js +41 -0
  350. package/node_modules/node-domexception/.history/index_20210527214700.js +16 -0
  351. package/node_modules/node-domexception/.history/package_20210527203733.json +19 -0
  352. package/node_modules/node-domexception/.history/package_20210527203825.json +16 -0
  353. package/node_modules/node-domexception/.history/package_20210527204621.json +19 -0
  354. package/node_modules/node-domexception/.history/package_20210527204913.json +25 -0
  355. package/node_modules/node-domexception/.history/package_20210527204925.json +25 -0
  356. package/node_modules/node-domexception/.history/package_20210527205145.json +29 -0
  357. package/node_modules/node-domexception/.history/package_20210527205156.json +29 -0
  358. package/node_modules/node-domexception/.history/test_20210527205603.js +0 -0
  359. package/node_modules/node-domexception/.history/test_20210527205957.js +3 -0
  360. package/node_modules/node-domexception/.history/test_20210527210021.js +3 -0
  361. package/node_modules/node-domexception/LICENSE +21 -0
  362. package/node_modules/node-domexception/README.md +46 -0
  363. package/node_modules/node-domexception/index.js +16 -0
  364. package/node_modules/node-domexception/package.json +29 -0
  365. package/node_modules/node-fetch/@types/index.d.ts +219 -0
  366. package/node_modules/node-fetch/LICENSE.md +22 -0
  367. package/node_modules/node-fetch/README.md +872 -0
  368. package/node_modules/node-fetch/package.json +131 -0
  369. package/node_modules/node-fetch/src/body.js +397 -0
  370. package/node_modules/node-fetch/src/errors/abort-error.js +10 -0
  371. package/node_modules/node-fetch/src/errors/base.js +17 -0
  372. package/node_modules/node-fetch/src/errors/fetch-error.js +26 -0
  373. package/node_modules/node-fetch/src/headers.js +267 -0
  374. package/node_modules/node-fetch/src/index.js +417 -0
  375. package/node_modules/node-fetch/src/request.js +313 -0
  376. package/node_modules/node-fetch/src/response.js +160 -0
  377. package/node_modules/node-fetch/src/utils/get-search.js +9 -0
  378. package/node_modules/node-fetch/src/utils/is-redirect.js +11 -0
  379. package/node_modules/node-fetch/src/utils/is.js +87 -0
  380. package/node_modules/node-fetch/src/utils/multipart-parser.js +432 -0
  381. package/node_modules/node-fetch/src/utils/referrer.js +340 -0
  382. package/node_modules/onetime/index.d.ts +64 -0
  383. package/node_modules/onetime/index.js +44 -0
  384. package/node_modules/onetime/license +9 -0
  385. package/node_modules/onetime/package.json +43 -0
  386. package/node_modules/onetime/readme.md +94 -0
  387. package/node_modules/ora/index.d.ts +277 -0
  388. package/node_modules/ora/index.js +407 -0
  389. package/node_modules/ora/license +9 -0
  390. package/node_modules/ora/package.json +57 -0
  391. package/node_modules/ora/readme.md +264 -0
  392. package/node_modules/path-scurry/LICENSE.md +55 -0
  393. package/node_modules/path-scurry/README.md +636 -0
  394. package/node_modules/path-scurry/dist/commonjs/index.d.ts +1115 -0
  395. package/node_modules/path-scurry/dist/commonjs/index.d.ts.map +1 -0
  396. package/node_modules/path-scurry/dist/commonjs/index.js +2018 -0
  397. package/node_modules/path-scurry/dist/commonjs/index.js.map +1 -0
  398. package/node_modules/path-scurry/dist/commonjs/package.json +3 -0
  399. package/node_modules/path-scurry/dist/esm/index.d.ts +1115 -0
  400. package/node_modules/path-scurry/dist/esm/index.d.ts.map +1 -0
  401. package/node_modules/path-scurry/dist/esm/index.js +1983 -0
  402. package/node_modules/path-scurry/dist/esm/index.js.map +1 -0
  403. package/node_modules/path-scurry/dist/esm/package.json +3 -0
  404. package/node_modules/path-scurry/package.json +72 -0
  405. package/node_modules/readable-stream/CONTRIBUTING.md +38 -0
  406. package/node_modules/readable-stream/GOVERNANCE.md +136 -0
  407. package/node_modules/readable-stream/LICENSE +47 -0
  408. package/node_modules/readable-stream/README.md +106 -0
  409. package/node_modules/readable-stream/errors-browser.js +127 -0
  410. package/node_modules/readable-stream/errors.js +116 -0
  411. package/node_modules/readable-stream/experimentalWarning.js +17 -0
  412. package/node_modules/readable-stream/lib/_stream_duplex.js +126 -0
  413. package/node_modules/readable-stream/lib/_stream_passthrough.js +37 -0
  414. package/node_modules/readable-stream/lib/_stream_readable.js +1027 -0
  415. package/node_modules/readable-stream/lib/_stream_transform.js +190 -0
  416. package/node_modules/readable-stream/lib/_stream_writable.js +641 -0
  417. package/node_modules/readable-stream/lib/internal/streams/async_iterator.js +180 -0
  418. package/node_modules/readable-stream/lib/internal/streams/buffer_list.js +183 -0
  419. package/node_modules/readable-stream/lib/internal/streams/destroy.js +96 -0
  420. package/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +86 -0
  421. package/node_modules/readable-stream/lib/internal/streams/from-browser.js +3 -0
  422. package/node_modules/readable-stream/lib/internal/streams/from.js +52 -0
  423. package/node_modules/readable-stream/lib/internal/streams/pipeline.js +86 -0
  424. package/node_modules/readable-stream/lib/internal/streams/state.js +22 -0
  425. package/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
  426. package/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
  427. package/node_modules/readable-stream/package.json +68 -0
  428. package/node_modules/readable-stream/readable-browser.js +9 -0
  429. package/node_modules/readable-stream/readable.js +16 -0
  430. package/node_modules/restore-cursor/index.d.ts +13 -0
  431. package/node_modules/restore-cursor/index.js +9 -0
  432. package/node_modules/restore-cursor/license +9 -0
  433. package/node_modules/restore-cursor/package.json +52 -0
  434. package/node_modules/restore-cursor/readme.md +26 -0
  435. package/node_modules/safe-buffer/LICENSE +21 -0
  436. package/node_modules/safe-buffer/README.md +584 -0
  437. package/node_modules/safe-buffer/index.d.ts +187 -0
  438. package/node_modules/safe-buffer/index.js +65 -0
  439. package/node_modules/safe-buffer/package.json +51 -0
  440. package/node_modules/signal-exit/LICENSE.txt +16 -0
  441. package/node_modules/signal-exit/README.md +39 -0
  442. package/node_modules/signal-exit/index.js +202 -0
  443. package/node_modules/signal-exit/package.json +38 -0
  444. package/node_modules/signal-exit/signals.js +53 -0
  445. package/node_modules/string_decoder/LICENSE +48 -0
  446. package/node_modules/string_decoder/README.md +47 -0
  447. package/node_modules/string_decoder/lib/string_decoder.js +296 -0
  448. package/node_modules/string_decoder/package.json +34 -0
  449. package/node_modules/strip-ansi/index.d.ts +17 -0
  450. package/node_modules/strip-ansi/index.js +4 -0
  451. package/node_modules/strip-ansi/license +9 -0
  452. package/node_modules/strip-ansi/package.json +54 -0
  453. package/node_modules/strip-ansi/readme.md +46 -0
  454. package/node_modules/supports-color/browser.js +5 -0
  455. package/node_modules/supports-color/index.js +135 -0
  456. package/node_modules/supports-color/license +9 -0
  457. package/node_modules/supports-color/package.json +53 -0
  458. package/node_modules/supports-color/readme.md +76 -0
  459. package/node_modules/util-deprecate/History.md +16 -0
  460. package/node_modules/util-deprecate/LICENSE +24 -0
  461. package/node_modules/util-deprecate/README.md +53 -0
  462. package/node_modules/util-deprecate/browser.js +67 -0
  463. package/node_modules/util-deprecate/node.js +6 -0
  464. package/node_modules/util-deprecate/package.json +27 -0
  465. package/node_modules/wcwidth/.npmignore +1 -0
  466. package/node_modules/wcwidth/LICENSE +30 -0
  467. package/node_modules/wcwidth/Readme.md +33 -0
  468. package/node_modules/wcwidth/combining.js +50 -0
  469. package/node_modules/wcwidth/docs/index.md +65 -0
  470. package/node_modules/wcwidth/index.js +99 -0
  471. package/node_modules/wcwidth/package.json +42 -0
  472. package/node_modules/wcwidth/test/index.js +64 -0
  473. package/node_modules/web-streams-polyfill/LICENSE +22 -0
  474. package/node_modules/web-streams-polyfill/README.md +110 -0
  475. package/node_modules/web-streams-polyfill/dist/polyfill.es2018.js +4765 -0
  476. package/node_modules/web-streams-polyfill/dist/polyfill.es2018.js.map +1 -0
  477. package/node_modules/web-streams-polyfill/dist/polyfill.es2018.min.js +9 -0
  478. package/node_modules/web-streams-polyfill/dist/polyfill.es2018.min.js.map +1 -0
  479. package/node_modules/web-streams-polyfill/dist/polyfill.es2018.mjs +4745 -0
  480. package/node_modules/web-streams-polyfill/dist/polyfill.es2018.mjs.map +1 -0
  481. package/node_modules/web-streams-polyfill/dist/polyfill.es6.js +4838 -0
  482. package/node_modules/web-streams-polyfill/dist/polyfill.es6.js.map +1 -0
  483. package/node_modules/web-streams-polyfill/dist/polyfill.es6.min.js +9 -0
  484. package/node_modules/web-streams-polyfill/dist/polyfill.es6.min.js.map +1 -0
  485. package/node_modules/web-streams-polyfill/dist/polyfill.es6.mjs +4818 -0
  486. package/node_modules/web-streams-polyfill/dist/polyfill.es6.mjs.map +1 -0
  487. package/node_modules/web-streams-polyfill/dist/polyfill.js +5011 -0
  488. package/node_modules/web-streams-polyfill/dist/polyfill.js.map +1 -0
  489. package/node_modules/web-streams-polyfill/dist/polyfill.min.js +9 -0
  490. package/node_modules/web-streams-polyfill/dist/polyfill.min.js.map +1 -0
  491. package/node_modules/web-streams-polyfill/dist/polyfill.mjs +4991 -0
  492. package/node_modules/web-streams-polyfill/dist/polyfill.mjs.map +1 -0
  493. package/node_modules/web-streams-polyfill/dist/ponyfill.es2018.js +4737 -0
  494. package/node_modules/web-streams-polyfill/dist/ponyfill.es2018.js.map +1 -0
  495. package/node_modules/web-streams-polyfill/dist/ponyfill.es2018.mjs +4717 -0
  496. package/node_modules/web-streams-polyfill/dist/ponyfill.es2018.mjs.map +1 -0
  497. package/node_modules/web-streams-polyfill/dist/ponyfill.es6.js +4810 -0
  498. package/node_modules/web-streams-polyfill/dist/ponyfill.es6.js.map +1 -0
  499. package/node_modules/web-streams-polyfill/dist/ponyfill.es6.mjs +4790 -0
  500. package/node_modules/web-streams-polyfill/dist/ponyfill.es6.mjs.map +1 -0
  501. package/node_modules/web-streams-polyfill/dist/ponyfill.js +4983 -0
  502. package/node_modules/web-streams-polyfill/dist/ponyfill.js.map +1 -0
  503. package/node_modules/web-streams-polyfill/dist/ponyfill.mjs +4963 -0
  504. package/node_modules/web-streams-polyfill/dist/ponyfill.mjs.map +1 -0
  505. package/node_modules/web-streams-polyfill/dist/types/polyfill.d.ts +24 -0
  506. package/node_modules/web-streams-polyfill/dist/types/ponyfill.d.ts +780 -0
  507. package/node_modules/web-streams-polyfill/dist/types/ts3.6/polyfill.d.ts +28 -0
  508. package/node_modules/web-streams-polyfill/dist/types/ts3.6/ponyfill.d.ts +821 -0
  509. package/node_modules/web-streams-polyfill/dist/types/tsdoc-metadata.json +11 -0
  510. package/node_modules/web-streams-polyfill/es2018/package.json +14 -0
  511. package/node_modules/web-streams-polyfill/es6/package.json +14 -0
  512. package/node_modules/web-streams-polyfill/package.json +83 -0
  513. package/node_modules/web-streams-polyfill/ponyfill/es2018/package.json +13 -0
  514. package/node_modules/web-streams-polyfill/ponyfill/es6/package.json +13 -0
  515. package/node_modules/web-streams-polyfill/ponyfill/package.json +13 -0
  516. package/package.json +26 -0
  517. package/version.json +18 -0
@@ -0,0 +1,1983 @@
1
+ import { LRUCache } from 'lru-cache';
2
+ import { posix, win32 } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { lstatSync, readdir as readdirCB, readdirSync, readlinkSync, realpathSync as rps, } from 'fs';
5
+ import * as actualFS from 'node:fs';
6
+ const realpathSync = rps.native;
7
+ // TODO: test perf of fs/promises realpath vs realpathCB,
8
+ // since the promises one uses realpath.native
9
+ import { lstat, readdir, readlink, realpath } from 'node:fs/promises';
10
+ import { Minipass } from 'minipass';
11
+ const defaultFS = {
12
+ lstatSync,
13
+ readdir: readdirCB,
14
+ readdirSync,
15
+ readlinkSync,
16
+ realpathSync,
17
+ promises: {
18
+ lstat,
19
+ readdir,
20
+ readlink,
21
+ realpath,
22
+ },
23
+ };
24
+ // if they just gave us require('fs') then use our default
25
+ const fsFromOption = (fsOption) => !fsOption || fsOption === defaultFS || fsOption === actualFS ?
26
+ defaultFS
27
+ : {
28
+ ...defaultFS,
29
+ ...fsOption,
30
+ promises: {
31
+ ...defaultFS.promises,
32
+ ...(fsOption.promises || {}),
33
+ },
34
+ };
35
+ // turn something like //?/c:/ into c:\
36
+ const uncDriveRegexp = /^\\\\\?\\([a-z]:)\\?$/i;
37
+ const uncToDrive = (rootPath) => rootPath.replace(/\//g, '\\').replace(uncDriveRegexp, '$1\\');
38
+ // windows paths are separated by either / or \
39
+ const eitherSep = /[\\\/]/;
40
+ const UNKNOWN = 0; // may not even exist, for all we know
41
+ const IFIFO = 0b0001;
42
+ const IFCHR = 0b0010;
43
+ const IFDIR = 0b0100;
44
+ const IFBLK = 0b0110;
45
+ const IFREG = 0b1000;
46
+ const IFLNK = 0b1010;
47
+ const IFSOCK = 0b1100;
48
+ const IFMT = 0b1111;
49
+ // mask to unset low 4 bits
50
+ const IFMT_UNKNOWN = ~IFMT;
51
+ // set after successfully calling readdir() and getting entries.
52
+ const READDIR_CALLED = 0b0000_0001_0000;
53
+ // set after a successful lstat()
54
+ const LSTAT_CALLED = 0b0000_0010_0000;
55
+ // set if an entry (or one of its parents) is definitely not a dir
56
+ const ENOTDIR = 0b0000_0100_0000;
57
+ // set if an entry (or one of its parents) does not exist
58
+ // (can also be set on lstat errors like EACCES or ENAMETOOLONG)
59
+ const ENOENT = 0b0000_1000_0000;
60
+ // cannot have child entries -- also verify &IFMT is either IFDIR or IFLNK
61
+ // set if we fail to readlink
62
+ const ENOREADLINK = 0b0001_0000_0000;
63
+ // set if we know realpath() will fail
64
+ const ENOREALPATH = 0b0010_0000_0000;
65
+ const ENOCHILD = ENOTDIR | ENOENT | ENOREALPATH;
66
+ const TYPEMASK = 0b0011_1111_1111;
67
+ const entToType = (s) => s.isFile() ? IFREG
68
+ : s.isDirectory() ? IFDIR
69
+ : s.isSymbolicLink() ? IFLNK
70
+ : s.isCharacterDevice() ? IFCHR
71
+ : s.isBlockDevice() ? IFBLK
72
+ : s.isSocket() ? IFSOCK
73
+ : s.isFIFO() ? IFIFO
74
+ : UNKNOWN;
75
+ // normalize unicode path names
76
+ const normalizeCache = new LRUCache({ max: 2 ** 12 });
77
+ const normalize = (s) => {
78
+ const c = normalizeCache.get(s);
79
+ if (c)
80
+ return c;
81
+ const n = s.normalize('NFKD');
82
+ normalizeCache.set(s, n);
83
+ return n;
84
+ };
85
+ const normalizeNocaseCache = new LRUCache({ max: 2 ** 12 });
86
+ const normalizeNocase = (s) => {
87
+ const c = normalizeNocaseCache.get(s);
88
+ if (c)
89
+ return c;
90
+ const n = normalize(s.toLowerCase());
91
+ normalizeNocaseCache.set(s, n);
92
+ return n;
93
+ };
94
+ /**
95
+ * An LRUCache for storing resolved path strings or Path objects.
96
+ * @internal
97
+ */
98
+ export class ResolveCache extends LRUCache {
99
+ constructor() {
100
+ super({ max: 256 });
101
+ }
102
+ }
103
+ // In order to prevent blowing out the js heap by allocating hundreds of
104
+ // thousands of Path entries when walking extremely large trees, the "children"
105
+ // in this tree are represented by storing an array of Path entries in an
106
+ // LRUCache, indexed by the parent. At any time, Path.children() may return an
107
+ // empty array, indicating that it doesn't know about any of its children, and
108
+ // thus has to rebuild that cache. This is fine, it just means that we don't
109
+ // benefit as much from having the cached entries, but huge directory walks
110
+ // don't blow out the stack, and smaller ones are still as fast as possible.
111
+ //
112
+ //It does impose some complexity when building up the readdir data, because we
113
+ //need to pass a reference to the children array that we started with.
114
+ /**
115
+ * an LRUCache for storing child entries.
116
+ * @internal
117
+ */
118
+ export class ChildrenCache extends LRUCache {
119
+ constructor(maxSize = 16 * 1024) {
120
+ super({
121
+ maxSize,
122
+ // parent + children
123
+ sizeCalculation: a => a.length + 1,
124
+ });
125
+ }
126
+ }
127
+ const setAsCwd = Symbol('PathScurry setAsCwd');
128
+ /**
129
+ * Path objects are sort of like a super-powered
130
+ * {@link https://nodejs.org/docs/latest/api/fs.html#class-fsdirent fs.Dirent}
131
+ *
132
+ * Each one represents a single filesystem entry on disk, which may or may not
133
+ * exist. It includes methods for reading various types of information via
134
+ * lstat, readlink, and readdir, and caches all information to the greatest
135
+ * degree possible.
136
+ *
137
+ * Note that fs operations that would normally throw will instead return an
138
+ * "empty" value. This is in order to prevent excessive overhead from error
139
+ * stack traces.
140
+ */
141
+ export class PathBase {
142
+ /**
143
+ * the basename of this path
144
+ *
145
+ * **Important**: *always* test the path name against any test string
146
+ * usingthe {@link isNamed} method, and not by directly comparing this
147
+ * string. Otherwise, unicode path strings that the system sees as identical
148
+ * will not be properly treated as the same path, leading to incorrect
149
+ * behavior and possible security issues.
150
+ */
151
+ name;
152
+ /**
153
+ * the Path entry corresponding to the path root.
154
+ *
155
+ * @internal
156
+ */
157
+ root;
158
+ /**
159
+ * All roots found within the current PathScurry family
160
+ *
161
+ * @internal
162
+ */
163
+ roots;
164
+ /**
165
+ * a reference to the parent path, or undefined in the case of root entries
166
+ *
167
+ * @internal
168
+ */
169
+ parent;
170
+ /**
171
+ * boolean indicating whether paths are compared case-insensitively
172
+ * @internal
173
+ */
174
+ nocase;
175
+ /**
176
+ * boolean indicating that this path is the current working directory
177
+ * of the PathScurry collection that contains it.
178
+ */
179
+ isCWD = false;
180
+ // potential default fs override
181
+ #fs;
182
+ // Stats fields
183
+ #dev;
184
+ get dev() {
185
+ return this.#dev;
186
+ }
187
+ #mode;
188
+ get mode() {
189
+ return this.#mode;
190
+ }
191
+ #nlink;
192
+ get nlink() {
193
+ return this.#nlink;
194
+ }
195
+ #uid;
196
+ get uid() {
197
+ return this.#uid;
198
+ }
199
+ #gid;
200
+ get gid() {
201
+ return this.#gid;
202
+ }
203
+ #rdev;
204
+ get rdev() {
205
+ return this.#rdev;
206
+ }
207
+ #blksize;
208
+ get blksize() {
209
+ return this.#blksize;
210
+ }
211
+ #ino;
212
+ get ino() {
213
+ return this.#ino;
214
+ }
215
+ #size;
216
+ get size() {
217
+ return this.#size;
218
+ }
219
+ #blocks;
220
+ get blocks() {
221
+ return this.#blocks;
222
+ }
223
+ #atimeMs;
224
+ get atimeMs() {
225
+ return this.#atimeMs;
226
+ }
227
+ #mtimeMs;
228
+ get mtimeMs() {
229
+ return this.#mtimeMs;
230
+ }
231
+ #ctimeMs;
232
+ get ctimeMs() {
233
+ return this.#ctimeMs;
234
+ }
235
+ #birthtimeMs;
236
+ get birthtimeMs() {
237
+ return this.#birthtimeMs;
238
+ }
239
+ #atime;
240
+ get atime() {
241
+ return this.#atime;
242
+ }
243
+ #mtime;
244
+ get mtime() {
245
+ return this.#mtime;
246
+ }
247
+ #ctime;
248
+ get ctime() {
249
+ return this.#ctime;
250
+ }
251
+ #birthtime;
252
+ get birthtime() {
253
+ return this.#birthtime;
254
+ }
255
+ #matchName;
256
+ #depth;
257
+ #fullpath;
258
+ #fullpathPosix;
259
+ #relative;
260
+ #relativePosix;
261
+ #type;
262
+ #children;
263
+ #linkTarget;
264
+ #realpath;
265
+ /**
266
+ * This property is for compatibility with the Dirent class as of
267
+ * Node v20, where Dirent['parentPath'] refers to the path of the
268
+ * directory that was passed to readdir. For root entries, it's the path
269
+ * to the entry itself.
270
+ */
271
+ get parentPath() {
272
+ return (this.parent || this).fullpath();
273
+ }
274
+ /* c8 ignore start */
275
+ /**
276
+ * Deprecated alias for Dirent['parentPath'] Somewhat counterintuitively,
277
+ * this property refers to the *parent* path, not the path object itself.
278
+ *
279
+ * @deprecated
280
+ */
281
+ get path() {
282
+ return this.parentPath;
283
+ }
284
+ /* c8 ignore stop */
285
+ /**
286
+ * Do not create new Path objects directly. They should always be accessed
287
+ * via the PathScurry class or other methods on the Path class.
288
+ *
289
+ * @internal
290
+ */
291
+ constructor(name, type = UNKNOWN, root, roots, nocase, children, opts) {
292
+ this.name = name;
293
+ this.#matchName = nocase ? normalizeNocase(name) : normalize(name);
294
+ this.#type = type & TYPEMASK;
295
+ this.nocase = nocase;
296
+ this.roots = roots;
297
+ this.root = root || this;
298
+ this.#children = children;
299
+ this.#fullpath = opts.fullpath;
300
+ this.#relative = opts.relative;
301
+ this.#relativePosix = opts.relativePosix;
302
+ this.parent = opts.parent;
303
+ if (this.parent) {
304
+ this.#fs = this.parent.#fs;
305
+ }
306
+ else {
307
+ this.#fs = fsFromOption(opts.fs);
308
+ }
309
+ }
310
+ /**
311
+ * Returns the depth of the Path object from its root.
312
+ *
313
+ * For example, a path at `/foo/bar` would have a depth of 2.
314
+ */
315
+ depth() {
316
+ if (this.#depth !== undefined)
317
+ return this.#depth;
318
+ if (!this.parent)
319
+ return (this.#depth = 0);
320
+ return (this.#depth = this.parent.depth() + 1);
321
+ }
322
+ /**
323
+ * @internal
324
+ */
325
+ childrenCache() {
326
+ return this.#children;
327
+ }
328
+ /**
329
+ * Get the Path object referenced by the string path, resolved from this Path
330
+ */
331
+ resolve(path) {
332
+ if (!path) {
333
+ return this;
334
+ }
335
+ const rootPath = this.getRootString(path);
336
+ const dir = path.substring(rootPath.length);
337
+ const dirParts = dir.split(this.splitSep);
338
+ const result = rootPath ?
339
+ this.getRoot(rootPath).#resolveParts(dirParts)
340
+ : this.#resolveParts(dirParts);
341
+ return result;
342
+ }
343
+ #resolveParts(dirParts) {
344
+ let p = this;
345
+ for (const part of dirParts) {
346
+ p = p.child(part);
347
+ }
348
+ return p;
349
+ }
350
+ /**
351
+ * Returns the cached children Path objects, if still available. If they
352
+ * have fallen out of the cache, then returns an empty array, and resets the
353
+ * READDIR_CALLED bit, so that future calls to readdir() will require an fs
354
+ * lookup.
355
+ *
356
+ * @internal
357
+ */
358
+ children() {
359
+ const cached = this.#children.get(this);
360
+ if (cached) {
361
+ return cached;
362
+ }
363
+ const children = Object.assign([], { provisional: 0 });
364
+ this.#children.set(this, children);
365
+ this.#type &= ~READDIR_CALLED;
366
+ return children;
367
+ }
368
+ /**
369
+ * Resolves a path portion and returns or creates the child Path.
370
+ *
371
+ * Returns `this` if pathPart is `''` or `'.'`, or `parent` if pathPart is
372
+ * `'..'`.
373
+ *
374
+ * This should not be called directly. If `pathPart` contains any path
375
+ * separators, it will lead to unsafe undefined behavior.
376
+ *
377
+ * Use `Path.resolve()` instead.
378
+ *
379
+ * @internal
380
+ */
381
+ child(pathPart, opts) {
382
+ if (pathPart === '' || pathPart === '.') {
383
+ return this;
384
+ }
385
+ if (pathPart === '..') {
386
+ return this.parent || this;
387
+ }
388
+ // find the child
389
+ const children = this.children();
390
+ const name = this.nocase ? normalizeNocase(pathPart) : normalize(pathPart);
391
+ for (const p of children) {
392
+ if (p.#matchName === name) {
393
+ return p;
394
+ }
395
+ }
396
+ // didn't find it, create provisional child, since it might not
397
+ // actually exist. If we know the parent isn't a dir, then
398
+ // in fact it CAN'T exist.
399
+ const s = this.parent ? this.sep : '';
400
+ const fullpath = this.#fullpath ? this.#fullpath + s + pathPart : undefined;
401
+ const pchild = this.newChild(pathPart, UNKNOWN, {
402
+ ...opts,
403
+ parent: this,
404
+ fullpath,
405
+ });
406
+ if (!this.canReaddir()) {
407
+ pchild.#type |= ENOENT;
408
+ }
409
+ // don't have to update provisional, because if we have real children,
410
+ // then provisional is set to children.length, otherwise a lower number
411
+ children.push(pchild);
412
+ return pchild;
413
+ }
414
+ /**
415
+ * The relative path from the cwd. If it does not share an ancestor with
416
+ * the cwd, then this ends up being equivalent to the fullpath()
417
+ */
418
+ relative() {
419
+ if (this.isCWD)
420
+ return '';
421
+ if (this.#relative !== undefined) {
422
+ return this.#relative;
423
+ }
424
+ const name = this.name;
425
+ const p = this.parent;
426
+ if (!p) {
427
+ return (this.#relative = this.name);
428
+ }
429
+ const pv = p.relative();
430
+ return pv + (!pv || !p.parent ? '' : this.sep) + name;
431
+ }
432
+ /**
433
+ * The relative path from the cwd, using / as the path separator.
434
+ * If it does not share an ancestor with
435
+ * the cwd, then this ends up being equivalent to the fullpathPosix()
436
+ * On posix systems, this is identical to relative().
437
+ */
438
+ relativePosix() {
439
+ if (this.sep === '/')
440
+ return this.relative();
441
+ if (this.isCWD)
442
+ return '';
443
+ if (this.#relativePosix !== undefined)
444
+ return this.#relativePosix;
445
+ const name = this.name;
446
+ const p = this.parent;
447
+ if (!p) {
448
+ return (this.#relativePosix = this.fullpathPosix());
449
+ }
450
+ const pv = p.relativePosix();
451
+ return pv + (!pv || !p.parent ? '' : '/') + name;
452
+ }
453
+ /**
454
+ * The fully resolved path string for this Path entry
455
+ */
456
+ fullpath() {
457
+ if (this.#fullpath !== undefined) {
458
+ return this.#fullpath;
459
+ }
460
+ const name = this.name;
461
+ const p = this.parent;
462
+ if (!p) {
463
+ return (this.#fullpath = this.name);
464
+ }
465
+ const pv = p.fullpath();
466
+ const fp = pv + (!p.parent ? '' : this.sep) + name;
467
+ return (this.#fullpath = fp);
468
+ }
469
+ /**
470
+ * On platforms other than windows, this is identical to fullpath.
471
+ *
472
+ * On windows, this is overridden to return the forward-slash form of the
473
+ * full UNC path.
474
+ */
475
+ fullpathPosix() {
476
+ if (this.#fullpathPosix !== undefined)
477
+ return this.#fullpathPosix;
478
+ if (this.sep === '/')
479
+ return (this.#fullpathPosix = this.fullpath());
480
+ if (!this.parent) {
481
+ const p = this.fullpath().replace(/\\/g, '/');
482
+ if (/^[a-z]:\//i.test(p)) {
483
+ return (this.#fullpathPosix = `//?/${p}`);
484
+ }
485
+ else {
486
+ return (this.#fullpathPosix = p);
487
+ }
488
+ }
489
+ const p = this.parent;
490
+ const pfpp = p.fullpathPosix();
491
+ const fpp = pfpp + (!pfpp || !p.parent ? '' : '/') + this.name;
492
+ return (this.#fullpathPosix = fpp);
493
+ }
494
+ /**
495
+ * Is the Path of an unknown type?
496
+ *
497
+ * Note that we might know *something* about it if there has been a previous
498
+ * filesystem operation, for example that it does not exist, or is not a
499
+ * link, or whether it has child entries.
500
+ */
501
+ isUnknown() {
502
+ return (this.#type & IFMT) === UNKNOWN;
503
+ }
504
+ isType(type) {
505
+ return this[`is${type}`]();
506
+ }
507
+ getType() {
508
+ return (this.isUnknown() ? 'Unknown'
509
+ : this.isDirectory() ? 'Directory'
510
+ : this.isFile() ? 'File'
511
+ : this.isSymbolicLink() ? 'SymbolicLink'
512
+ : this.isFIFO() ? 'FIFO'
513
+ : this.isCharacterDevice() ? 'CharacterDevice'
514
+ : this.isBlockDevice() ? 'BlockDevice'
515
+ : /* c8 ignore start */ this.isSocket() ? 'Socket'
516
+ : 'Unknown');
517
+ /* c8 ignore stop */
518
+ }
519
+ /**
520
+ * Is the Path a regular file?
521
+ */
522
+ isFile() {
523
+ return (this.#type & IFMT) === IFREG;
524
+ }
525
+ /**
526
+ * Is the Path a directory?
527
+ */
528
+ isDirectory() {
529
+ return (this.#type & IFMT) === IFDIR;
530
+ }
531
+ /**
532
+ * Is the path a character device?
533
+ */
534
+ isCharacterDevice() {
535
+ return (this.#type & IFMT) === IFCHR;
536
+ }
537
+ /**
538
+ * Is the path a block device?
539
+ */
540
+ isBlockDevice() {
541
+ return (this.#type & IFMT) === IFBLK;
542
+ }
543
+ /**
544
+ * Is the path a FIFO pipe?
545
+ */
546
+ isFIFO() {
547
+ return (this.#type & IFMT) === IFIFO;
548
+ }
549
+ /**
550
+ * Is the path a socket?
551
+ */
552
+ isSocket() {
553
+ return (this.#type & IFMT) === IFSOCK;
554
+ }
555
+ /**
556
+ * Is the path a symbolic link?
557
+ */
558
+ isSymbolicLink() {
559
+ return (this.#type & IFLNK) === IFLNK;
560
+ }
561
+ /**
562
+ * Return the entry if it has been subject of a successful lstat, or
563
+ * undefined otherwise.
564
+ *
565
+ * Does not read the filesystem, so an undefined result *could* simply
566
+ * mean that we haven't called lstat on it.
567
+ */
568
+ lstatCached() {
569
+ return this.#type & LSTAT_CALLED ? this : undefined;
570
+ }
571
+ /**
572
+ * Return the cached link target if the entry has been the subject of a
573
+ * successful readlink, or undefined otherwise.
574
+ *
575
+ * Does not read the filesystem, so an undefined result *could* just mean we
576
+ * don't have any cached data. Only use it if you are very sure that a
577
+ * readlink() has been called at some point.
578
+ */
579
+ readlinkCached() {
580
+ return this.#linkTarget;
581
+ }
582
+ /**
583
+ * Returns the cached realpath target if the entry has been the subject
584
+ * of a successful realpath, or undefined otherwise.
585
+ *
586
+ * Does not read the filesystem, so an undefined result *could* just mean we
587
+ * don't have any cached data. Only use it if you are very sure that a
588
+ * realpath() has been called at some point.
589
+ */
590
+ realpathCached() {
591
+ return this.#realpath;
592
+ }
593
+ /**
594
+ * Returns the cached child Path entries array if the entry has been the
595
+ * subject of a successful readdir(), or [] otherwise.
596
+ *
597
+ * Does not read the filesystem, so an empty array *could* just mean we
598
+ * don't have any cached data. Only use it if you are very sure that a
599
+ * readdir() has been called recently enough to still be valid.
600
+ */
601
+ readdirCached() {
602
+ const children = this.children();
603
+ return children.slice(0, children.provisional);
604
+ }
605
+ /**
606
+ * Return true if it's worth trying to readlink. Ie, we don't (yet) have
607
+ * any indication that readlink will definitely fail.
608
+ *
609
+ * Returns false if the path is known to not be a symlink, if a previous
610
+ * readlink failed, or if the entry does not exist.
611
+ */
612
+ canReadlink() {
613
+ if (this.#linkTarget)
614
+ return true;
615
+ if (!this.parent)
616
+ return false;
617
+ // cases where it cannot possibly succeed
618
+ const ifmt = this.#type & IFMT;
619
+ return !((ifmt !== UNKNOWN && ifmt !== IFLNK) ||
620
+ this.#type & ENOREADLINK ||
621
+ this.#type & ENOENT);
622
+ }
623
+ /**
624
+ * Return true if readdir has previously been successfully called on this
625
+ * path, indicating that cachedReaddir() is likely valid.
626
+ */
627
+ calledReaddir() {
628
+ return !!(this.#type & READDIR_CALLED);
629
+ }
630
+ /**
631
+ * Returns true if the path is known to not exist. That is, a previous lstat
632
+ * or readdir failed to verify its existence when that would have been
633
+ * expected, or a parent entry was marked either enoent or enotdir.
634
+ */
635
+ isENOENT() {
636
+ return !!(this.#type & ENOENT);
637
+ }
638
+ /**
639
+ * Return true if the path is a match for the given path name. This handles
640
+ * case sensitivity and unicode normalization.
641
+ *
642
+ * Note: even on case-sensitive systems, it is **not** safe to test the
643
+ * equality of the `.name` property to determine whether a given pathname
644
+ * matches, due to unicode normalization mismatches.
645
+ *
646
+ * Always use this method instead of testing the `path.name` property
647
+ * directly.
648
+ */
649
+ isNamed(n) {
650
+ return !this.nocase ?
651
+ this.#matchName === normalize(n)
652
+ : this.#matchName === normalizeNocase(n);
653
+ }
654
+ /**
655
+ * Return the Path object corresponding to the target of a symbolic link.
656
+ *
657
+ * If the Path is not a symbolic link, or if the readlink call fails for any
658
+ * reason, `undefined` is returned.
659
+ *
660
+ * Result is cached, and thus may be outdated if the filesystem is mutated.
661
+ */
662
+ async readlink() {
663
+ const target = this.#linkTarget;
664
+ if (target) {
665
+ return target;
666
+ }
667
+ if (!this.canReadlink()) {
668
+ return undefined;
669
+ }
670
+ /* c8 ignore start */
671
+ // already covered by the canReadlink test, here for ts grumples
672
+ if (!this.parent) {
673
+ return undefined;
674
+ }
675
+ /* c8 ignore stop */
676
+ try {
677
+ const read = await this.#fs.promises.readlink(this.fullpath());
678
+ const linkTarget = (await this.parent.realpath())?.resolve(read);
679
+ if (linkTarget) {
680
+ return (this.#linkTarget = linkTarget);
681
+ }
682
+ }
683
+ catch (er) {
684
+ this.#readlinkFail(er.code);
685
+ return undefined;
686
+ }
687
+ }
688
+ /**
689
+ * Synchronous {@link PathBase.readlink}
690
+ */
691
+ readlinkSync() {
692
+ const target = this.#linkTarget;
693
+ if (target) {
694
+ return target;
695
+ }
696
+ if (!this.canReadlink()) {
697
+ return undefined;
698
+ }
699
+ /* c8 ignore start */
700
+ // already covered by the canReadlink test, here for ts grumples
701
+ if (!this.parent) {
702
+ return undefined;
703
+ }
704
+ /* c8 ignore stop */
705
+ try {
706
+ const read = this.#fs.readlinkSync(this.fullpath());
707
+ const linkTarget = this.parent.realpathSync()?.resolve(read);
708
+ if (linkTarget) {
709
+ return (this.#linkTarget = linkTarget);
710
+ }
711
+ }
712
+ catch (er) {
713
+ this.#readlinkFail(er.code);
714
+ return undefined;
715
+ }
716
+ }
717
+ #readdirSuccess(children) {
718
+ // succeeded, mark readdir called bit
719
+ this.#type |= READDIR_CALLED;
720
+ // mark all remaining provisional children as ENOENT
721
+ for (let p = children.provisional; p < children.length; p++) {
722
+ const c = children[p];
723
+ if (c)
724
+ c.#markENOENT();
725
+ }
726
+ }
727
+ #markENOENT() {
728
+ // mark as UNKNOWN and ENOENT
729
+ if (this.#type & ENOENT)
730
+ return;
731
+ this.#type = (this.#type | ENOENT) & IFMT_UNKNOWN;
732
+ this.#markChildrenENOENT();
733
+ }
734
+ #markChildrenENOENT() {
735
+ // all children are provisional and do not exist
736
+ const children = this.children();
737
+ children.provisional = 0;
738
+ for (const p of children) {
739
+ p.#markENOENT();
740
+ }
741
+ }
742
+ #markENOREALPATH() {
743
+ this.#type |= ENOREALPATH;
744
+ this.#markENOTDIR();
745
+ }
746
+ // save the information when we know the entry is not a dir
747
+ #markENOTDIR() {
748
+ // entry is not a directory, so any children can't exist.
749
+ // this *should* be impossible, since any children created
750
+ // after it's been marked ENOTDIR should be marked ENOENT,
751
+ // so it won't even get to this point.
752
+ /* c8 ignore start */
753
+ if (this.#type & ENOTDIR)
754
+ return;
755
+ /* c8 ignore stop */
756
+ let t = this.#type;
757
+ // this could happen if we stat a dir, then delete it,
758
+ // then try to read it or one of its children.
759
+ if ((t & IFMT) === IFDIR)
760
+ t &= IFMT_UNKNOWN;
761
+ this.#type = t | ENOTDIR;
762
+ this.#markChildrenENOENT();
763
+ }
764
+ #readdirFail(code = '') {
765
+ // markENOTDIR and markENOENT also set provisional=0
766
+ if (code === 'ENOTDIR' || code === 'EPERM') {
767
+ this.#markENOTDIR();
768
+ }
769
+ else if (code === 'ENOENT') {
770
+ this.#markENOENT();
771
+ }
772
+ else {
773
+ this.children().provisional = 0;
774
+ }
775
+ }
776
+ #lstatFail(code = '') {
777
+ // Windows just raises ENOENT in this case, disable for win CI
778
+ /* c8 ignore start */
779
+ if (code === 'ENOTDIR') {
780
+ // already know it has a parent by this point
781
+ const p = this.parent;
782
+ p.#markENOTDIR();
783
+ }
784
+ else if (code === 'ENOENT') {
785
+ /* c8 ignore stop */
786
+ this.#markENOENT();
787
+ }
788
+ }
789
+ #readlinkFail(code = '') {
790
+ let ter = this.#type;
791
+ ter |= ENOREADLINK;
792
+ if (code === 'ENOENT')
793
+ ter |= ENOENT;
794
+ // windows gets a weird error when you try to readlink a file
795
+ if (code === 'EINVAL' || code === 'UNKNOWN') {
796
+ // exists, but not a symlink, we don't know WHAT it is, so remove
797
+ // all IFMT bits.
798
+ ter &= IFMT_UNKNOWN;
799
+ }
800
+ this.#type = ter;
801
+ // windows just gets ENOENT in this case. We do cover the case,
802
+ // just disabled because it's impossible on Windows CI
803
+ /* c8 ignore start */
804
+ if (code === 'ENOTDIR' && this.parent) {
805
+ this.parent.#markENOTDIR();
806
+ }
807
+ /* c8 ignore stop */
808
+ }
809
+ #readdirAddChild(e, c) {
810
+ return (this.#readdirMaybePromoteChild(e, c) ||
811
+ this.#readdirAddNewChild(e, c));
812
+ }
813
+ #readdirAddNewChild(e, c) {
814
+ // alloc new entry at head, so it's never provisional
815
+ const type = entToType(e);
816
+ const child = this.newChild(e.name, type, { parent: this });
817
+ const ifmt = child.#type & IFMT;
818
+ if (ifmt !== IFDIR && ifmt !== IFLNK && ifmt !== UNKNOWN) {
819
+ child.#type |= ENOTDIR;
820
+ }
821
+ c.unshift(child);
822
+ c.provisional++;
823
+ return child;
824
+ }
825
+ #readdirMaybePromoteChild(e, c) {
826
+ for (let p = c.provisional; p < c.length; p++) {
827
+ const pchild = c[p];
828
+ const name = this.nocase ? normalizeNocase(e.name) : normalize(e.name);
829
+ if (name !== pchild.#matchName) {
830
+ continue;
831
+ }
832
+ return this.#readdirPromoteChild(e, pchild, p, c);
833
+ }
834
+ }
835
+ #readdirPromoteChild(e, p, index, c) {
836
+ const v = p.name;
837
+ // retain any other flags, but set ifmt from dirent
838
+ p.#type = (p.#type & IFMT_UNKNOWN) | entToType(e);
839
+ // case sensitivity fixing when we learn the true name.
840
+ if (v !== e.name)
841
+ p.name = e.name;
842
+ // just advance provisional index (potentially off the list),
843
+ // otherwise we have to splice/pop it out and re-insert at head
844
+ if (index !== c.provisional) {
845
+ if (index === c.length - 1)
846
+ c.pop();
847
+ else
848
+ c.splice(index, 1);
849
+ c.unshift(p);
850
+ }
851
+ c.provisional++;
852
+ return p;
853
+ }
854
+ /**
855
+ * Call lstat() on this Path, and update all known information that can be
856
+ * determined.
857
+ *
858
+ * Note that unlike `fs.lstat()`, the returned value does not contain some
859
+ * information, such as `mode`, `dev`, `nlink`, and `ino`. If that
860
+ * information is required, you will need to call `fs.lstat` yourself.
861
+ *
862
+ * If the Path refers to a nonexistent file, or if the lstat call fails for
863
+ * any reason, `undefined` is returned. Otherwise the updated Path object is
864
+ * returned.
865
+ *
866
+ * Results are cached, and thus may be out of date if the filesystem is
867
+ * mutated.
868
+ */
869
+ async lstat() {
870
+ if ((this.#type & ENOENT) === 0) {
871
+ try {
872
+ this.#applyStat(await this.#fs.promises.lstat(this.fullpath()));
873
+ return this;
874
+ }
875
+ catch (er) {
876
+ this.#lstatFail(er.code);
877
+ }
878
+ }
879
+ }
880
+ /**
881
+ * synchronous {@link PathBase.lstat}
882
+ */
883
+ lstatSync() {
884
+ if ((this.#type & ENOENT) === 0) {
885
+ try {
886
+ this.#applyStat(this.#fs.lstatSync(this.fullpath()));
887
+ return this;
888
+ }
889
+ catch (er) {
890
+ this.#lstatFail(er.code);
891
+ }
892
+ }
893
+ }
894
+ #applyStat(st) {
895
+ const { atime, atimeMs, birthtime, birthtimeMs, blksize, blocks, ctime, ctimeMs, dev, gid, ino, mode, mtime, mtimeMs, nlink, rdev, size, uid, } = st;
896
+ this.#atime = atime;
897
+ this.#atimeMs = atimeMs;
898
+ this.#birthtime = birthtime;
899
+ this.#birthtimeMs = birthtimeMs;
900
+ this.#blksize = blksize;
901
+ this.#blocks = blocks;
902
+ this.#ctime = ctime;
903
+ this.#ctimeMs = ctimeMs;
904
+ this.#dev = dev;
905
+ this.#gid = gid;
906
+ this.#ino = ino;
907
+ this.#mode = mode;
908
+ this.#mtime = mtime;
909
+ this.#mtimeMs = mtimeMs;
910
+ this.#nlink = nlink;
911
+ this.#rdev = rdev;
912
+ this.#size = size;
913
+ this.#uid = uid;
914
+ const ifmt = entToType(st);
915
+ // retain any other flags, but set the ifmt
916
+ this.#type = (this.#type & IFMT_UNKNOWN) | ifmt | LSTAT_CALLED;
917
+ if (ifmt !== UNKNOWN && ifmt !== IFDIR && ifmt !== IFLNK) {
918
+ this.#type |= ENOTDIR;
919
+ }
920
+ }
921
+ #onReaddirCB = [];
922
+ #readdirCBInFlight = false;
923
+ #callOnReaddirCB(children) {
924
+ this.#readdirCBInFlight = false;
925
+ const cbs = this.#onReaddirCB.slice();
926
+ this.#onReaddirCB.length = 0;
927
+ cbs.forEach(cb => cb(null, children));
928
+ }
929
+ /**
930
+ * Standard node-style callback interface to get list of directory entries.
931
+ *
932
+ * If the Path cannot or does not contain any children, then an empty array
933
+ * is returned.
934
+ *
935
+ * Results are cached, and thus may be out of date if the filesystem is
936
+ * mutated.
937
+ *
938
+ * @param cb The callback called with (er, entries). Note that the `er`
939
+ * param is somewhat extraneous, as all readdir() errors are handled and
940
+ * simply result in an empty set of entries being returned.
941
+ * @param allowZalgo Boolean indicating that immediately known results should
942
+ * *not* be deferred with `queueMicrotask`. Defaults to `false`. Release
943
+ * zalgo at your peril, the dark pony lord is devious and unforgiving.
944
+ */
945
+ readdirCB(cb, allowZalgo = false) {
946
+ if (!this.canReaddir()) {
947
+ if (allowZalgo)
948
+ cb(null, []);
949
+ else
950
+ queueMicrotask(() => cb(null, []));
951
+ return;
952
+ }
953
+ const children = this.children();
954
+ if (this.calledReaddir()) {
955
+ const c = children.slice(0, children.provisional);
956
+ if (allowZalgo)
957
+ cb(null, c);
958
+ else
959
+ queueMicrotask(() => cb(null, c));
960
+ return;
961
+ }
962
+ // don't have to worry about zalgo at this point.
963
+ this.#onReaddirCB.push(cb);
964
+ if (this.#readdirCBInFlight) {
965
+ return;
966
+ }
967
+ this.#readdirCBInFlight = true;
968
+ // else read the directory, fill up children
969
+ // de-provisionalize any provisional children.
970
+ const fullpath = this.fullpath();
971
+ this.#fs.readdir(fullpath, { withFileTypes: true }, (er, entries) => {
972
+ if (er) {
973
+ this.#readdirFail(er.code);
974
+ children.provisional = 0;
975
+ }
976
+ else {
977
+ // if we didn't get an error, we always get entries.
978
+ //@ts-ignore
979
+ for (const e of entries) {
980
+ this.#readdirAddChild(e, children);
981
+ }
982
+ this.#readdirSuccess(children);
983
+ }
984
+ this.#callOnReaddirCB(children.slice(0, children.provisional));
985
+ return;
986
+ });
987
+ }
988
+ #asyncReaddirInFlight;
989
+ /**
990
+ * Return an array of known child entries.
991
+ *
992
+ * If the Path cannot or does not contain any children, then an empty array
993
+ * is returned.
994
+ *
995
+ * Results are cached, and thus may be out of date if the filesystem is
996
+ * mutated.
997
+ */
998
+ async readdir() {
999
+ if (!this.canReaddir()) {
1000
+ return [];
1001
+ }
1002
+ const children = this.children();
1003
+ if (this.calledReaddir()) {
1004
+ return children.slice(0, children.provisional);
1005
+ }
1006
+ // else read the directory, fill up children
1007
+ // de-provisionalize any provisional children.
1008
+ const fullpath = this.fullpath();
1009
+ if (this.#asyncReaddirInFlight) {
1010
+ await this.#asyncReaddirInFlight;
1011
+ }
1012
+ else {
1013
+ /* c8 ignore start */
1014
+ let resolve = () => { };
1015
+ /* c8 ignore stop */
1016
+ this.#asyncReaddirInFlight = new Promise(res => (resolve = res));
1017
+ try {
1018
+ for (const e of await this.#fs.promises.readdir(fullpath, {
1019
+ withFileTypes: true,
1020
+ })) {
1021
+ this.#readdirAddChild(e, children);
1022
+ }
1023
+ this.#readdirSuccess(children);
1024
+ }
1025
+ catch (er) {
1026
+ this.#readdirFail(er.code);
1027
+ children.provisional = 0;
1028
+ }
1029
+ this.#asyncReaddirInFlight = undefined;
1030
+ resolve();
1031
+ }
1032
+ return children.slice(0, children.provisional);
1033
+ }
1034
+ /**
1035
+ * synchronous {@link PathBase.readdir}
1036
+ */
1037
+ readdirSync() {
1038
+ if (!this.canReaddir()) {
1039
+ return [];
1040
+ }
1041
+ const children = this.children();
1042
+ if (this.calledReaddir()) {
1043
+ return children.slice(0, children.provisional);
1044
+ }
1045
+ // else read the directory, fill up children
1046
+ // de-provisionalize any provisional children.
1047
+ const fullpath = this.fullpath();
1048
+ try {
1049
+ for (const e of this.#fs.readdirSync(fullpath, {
1050
+ withFileTypes: true,
1051
+ })) {
1052
+ this.#readdirAddChild(e, children);
1053
+ }
1054
+ this.#readdirSuccess(children);
1055
+ }
1056
+ catch (er) {
1057
+ this.#readdirFail(er.code);
1058
+ children.provisional = 0;
1059
+ }
1060
+ return children.slice(0, children.provisional);
1061
+ }
1062
+ canReaddir() {
1063
+ if (this.#type & ENOCHILD)
1064
+ return false;
1065
+ const ifmt = IFMT & this.#type;
1066
+ // we always set ENOTDIR when setting IFMT, so should be impossible
1067
+ /* c8 ignore start */
1068
+ if (!(ifmt === UNKNOWN || ifmt === IFDIR || ifmt === IFLNK)) {
1069
+ return false;
1070
+ }
1071
+ /* c8 ignore stop */
1072
+ return true;
1073
+ }
1074
+ shouldWalk(dirs, walkFilter) {
1075
+ return ((this.#type & IFDIR) === IFDIR &&
1076
+ !(this.#type & ENOCHILD) &&
1077
+ !dirs.has(this) &&
1078
+ (!walkFilter || walkFilter(this)));
1079
+ }
1080
+ /**
1081
+ * Return the Path object corresponding to path as resolved
1082
+ * by realpath(3).
1083
+ *
1084
+ * If the realpath call fails for any reason, `undefined` is returned.
1085
+ *
1086
+ * Result is cached, and thus may be outdated if the filesystem is mutated.
1087
+ * On success, returns a Path object.
1088
+ */
1089
+ async realpath() {
1090
+ if (this.#realpath)
1091
+ return this.#realpath;
1092
+ if ((ENOREALPATH | ENOREADLINK | ENOENT) & this.#type)
1093
+ return undefined;
1094
+ try {
1095
+ const rp = await this.#fs.promises.realpath(this.fullpath());
1096
+ return (this.#realpath = this.resolve(rp));
1097
+ }
1098
+ catch (_) {
1099
+ this.#markENOREALPATH();
1100
+ }
1101
+ }
1102
+ /**
1103
+ * Synchronous {@link realpath}
1104
+ */
1105
+ realpathSync() {
1106
+ if (this.#realpath)
1107
+ return this.#realpath;
1108
+ if ((ENOREALPATH | ENOREADLINK | ENOENT) & this.#type)
1109
+ return undefined;
1110
+ try {
1111
+ const rp = this.#fs.realpathSync(this.fullpath());
1112
+ return (this.#realpath = this.resolve(rp));
1113
+ }
1114
+ catch (_) {
1115
+ this.#markENOREALPATH();
1116
+ }
1117
+ }
1118
+ /**
1119
+ * Internal method to mark this Path object as the scurry cwd,
1120
+ * called by {@link PathScurry#chdir}
1121
+ *
1122
+ * @internal
1123
+ */
1124
+ [setAsCwd](oldCwd) {
1125
+ if (oldCwd === this)
1126
+ return;
1127
+ oldCwd.isCWD = false;
1128
+ this.isCWD = true;
1129
+ const changed = new Set([]);
1130
+ let rp = [];
1131
+ let p = this;
1132
+ while (p && p.parent) {
1133
+ changed.add(p);
1134
+ p.#relative = rp.join(this.sep);
1135
+ p.#relativePosix = rp.join('/');
1136
+ p = p.parent;
1137
+ rp.push('..');
1138
+ }
1139
+ // now un-memoize parents of old cwd
1140
+ p = oldCwd;
1141
+ while (p && p.parent && !changed.has(p)) {
1142
+ p.#relative = undefined;
1143
+ p.#relativePosix = undefined;
1144
+ p = p.parent;
1145
+ }
1146
+ }
1147
+ }
1148
+ /**
1149
+ * Path class used on win32 systems
1150
+ *
1151
+ * Uses `'\\'` as the path separator for returned paths, either `'\\'` or `'/'`
1152
+ * as the path separator for parsing paths.
1153
+ */
1154
+ export class PathWin32 extends PathBase {
1155
+ /**
1156
+ * Separator for generating path strings.
1157
+ */
1158
+ sep = '\\';
1159
+ /**
1160
+ * Separator for parsing path strings.
1161
+ */
1162
+ splitSep = eitherSep;
1163
+ /**
1164
+ * Do not create new Path objects directly. They should always be accessed
1165
+ * via the PathScurry class or other methods on the Path class.
1166
+ *
1167
+ * @internal
1168
+ */
1169
+ constructor(name, type = UNKNOWN, root, roots, nocase, children, opts) {
1170
+ super(name, type, root, roots, nocase, children, opts);
1171
+ }
1172
+ /**
1173
+ * @internal
1174
+ */
1175
+ newChild(name, type = UNKNOWN, opts = {}) {
1176
+ return new PathWin32(name, type, this.root, this.roots, this.nocase, this.childrenCache(), opts);
1177
+ }
1178
+ /**
1179
+ * @internal
1180
+ */
1181
+ getRootString(path) {
1182
+ return win32.parse(path).root;
1183
+ }
1184
+ /**
1185
+ * @internal
1186
+ */
1187
+ getRoot(rootPath) {
1188
+ rootPath = uncToDrive(rootPath.toUpperCase());
1189
+ if (rootPath === this.root.name) {
1190
+ return this.root;
1191
+ }
1192
+ // ok, not that one, check if it matches another we know about
1193
+ for (const [compare, root] of Object.entries(this.roots)) {
1194
+ if (this.sameRoot(rootPath, compare)) {
1195
+ return (this.roots[rootPath] = root);
1196
+ }
1197
+ }
1198
+ // otherwise, have to create a new one.
1199
+ return (this.roots[rootPath] = new PathScurryWin32(rootPath, this).root);
1200
+ }
1201
+ /**
1202
+ * @internal
1203
+ */
1204
+ sameRoot(rootPath, compare = this.root.name) {
1205
+ // windows can (rarely) have case-sensitive filesystem, but
1206
+ // UNC and drive letters are always case-insensitive, and canonically
1207
+ // represented uppercase.
1208
+ rootPath = rootPath
1209
+ .toUpperCase()
1210
+ .replace(/\//g, '\\')
1211
+ .replace(uncDriveRegexp, '$1\\');
1212
+ return rootPath === compare;
1213
+ }
1214
+ }
1215
+ /**
1216
+ * Path class used on all posix systems.
1217
+ *
1218
+ * Uses `'/'` as the path separator.
1219
+ */
1220
+ export class PathPosix extends PathBase {
1221
+ /**
1222
+ * separator for parsing path strings
1223
+ */
1224
+ splitSep = '/';
1225
+ /**
1226
+ * separator for generating path strings
1227
+ */
1228
+ sep = '/';
1229
+ /**
1230
+ * Do not create new Path objects directly. They should always be accessed
1231
+ * via the PathScurry class or other methods on the Path class.
1232
+ *
1233
+ * @internal
1234
+ */
1235
+ constructor(name, type = UNKNOWN, root, roots, nocase, children, opts) {
1236
+ super(name, type, root, roots, nocase, children, opts);
1237
+ }
1238
+ /**
1239
+ * @internal
1240
+ */
1241
+ getRootString(path) {
1242
+ return path.startsWith('/') ? '/' : '';
1243
+ }
1244
+ /**
1245
+ * @internal
1246
+ */
1247
+ getRoot(_rootPath) {
1248
+ return this.root;
1249
+ }
1250
+ /**
1251
+ * @internal
1252
+ */
1253
+ newChild(name, type = UNKNOWN, opts = {}) {
1254
+ return new PathPosix(name, type, this.root, this.roots, this.nocase, this.childrenCache(), opts);
1255
+ }
1256
+ }
1257
+ /**
1258
+ * The base class for all PathScurry classes, providing the interface for path
1259
+ * resolution and filesystem operations.
1260
+ *
1261
+ * Typically, you should *not* instantiate this class directly, but rather one
1262
+ * of the platform-specific classes, or the exported {@link PathScurry} which
1263
+ * defaults to the current platform.
1264
+ */
1265
+ export class PathScurryBase {
1266
+ /**
1267
+ * The root Path entry for the current working directory of this Scurry
1268
+ */
1269
+ root;
1270
+ /**
1271
+ * The string path for the root of this Scurry's current working directory
1272
+ */
1273
+ rootPath;
1274
+ /**
1275
+ * A collection of all roots encountered, referenced by rootPath
1276
+ */
1277
+ roots;
1278
+ /**
1279
+ * The Path entry corresponding to this PathScurry's current working directory.
1280
+ */
1281
+ cwd;
1282
+ #resolveCache;
1283
+ #resolvePosixCache;
1284
+ #children;
1285
+ /**
1286
+ * Perform path comparisons case-insensitively.
1287
+ *
1288
+ * Defaults true on Darwin and Windows systems, false elsewhere.
1289
+ */
1290
+ nocase;
1291
+ #fs;
1292
+ /**
1293
+ * This class should not be instantiated directly.
1294
+ *
1295
+ * Use PathScurryWin32, PathScurryDarwin, PathScurryPosix, or PathScurry
1296
+ *
1297
+ * @internal
1298
+ */
1299
+ constructor(cwd = process.cwd(), pathImpl, sep, { nocase, childrenCacheSize = 16 * 1024, fs = defaultFS, } = {}) {
1300
+ this.#fs = fsFromOption(fs);
1301
+ if (cwd instanceof URL || cwd.startsWith('file://')) {
1302
+ cwd = fileURLToPath(cwd);
1303
+ }
1304
+ // resolve and split root, and then add to the store.
1305
+ // this is the only time we call path.resolve()
1306
+ const cwdPath = pathImpl.resolve(cwd);
1307
+ this.roots = Object.create(null);
1308
+ this.rootPath = this.parseRootPath(cwdPath);
1309
+ this.#resolveCache = new ResolveCache();
1310
+ this.#resolvePosixCache = new ResolveCache();
1311
+ this.#children = new ChildrenCache(childrenCacheSize);
1312
+ const split = cwdPath.substring(this.rootPath.length).split(sep);
1313
+ // resolve('/') leaves '', splits to [''], we don't want that.
1314
+ if (split.length === 1 && !split[0]) {
1315
+ split.pop();
1316
+ }
1317
+ /* c8 ignore start */
1318
+ if (nocase === undefined) {
1319
+ throw new TypeError('must provide nocase setting to PathScurryBase ctor');
1320
+ }
1321
+ /* c8 ignore stop */
1322
+ this.nocase = nocase;
1323
+ this.root = this.newRoot(this.#fs);
1324
+ this.roots[this.rootPath] = this.root;
1325
+ let prev = this.root;
1326
+ let len = split.length - 1;
1327
+ const joinSep = pathImpl.sep;
1328
+ let abs = this.rootPath;
1329
+ let sawFirst = false;
1330
+ for (const part of split) {
1331
+ const l = len--;
1332
+ prev = prev.child(part, {
1333
+ relative: new Array(l).fill('..').join(joinSep),
1334
+ relativePosix: new Array(l).fill('..').join('/'),
1335
+ fullpath: (abs += (sawFirst ? '' : joinSep) + part),
1336
+ });
1337
+ sawFirst = true;
1338
+ }
1339
+ this.cwd = prev;
1340
+ }
1341
+ /**
1342
+ * Get the depth of a provided path, string, or the cwd
1343
+ */
1344
+ depth(path = this.cwd) {
1345
+ if (typeof path === 'string') {
1346
+ path = this.cwd.resolve(path);
1347
+ }
1348
+ return path.depth();
1349
+ }
1350
+ /**
1351
+ * Return the cache of child entries. Exposed so subclasses can create
1352
+ * child Path objects in a platform-specific way.
1353
+ *
1354
+ * @internal
1355
+ */
1356
+ childrenCache() {
1357
+ return this.#children;
1358
+ }
1359
+ /**
1360
+ * Resolve one or more path strings to a resolved string
1361
+ *
1362
+ * Same interface as require('path').resolve.
1363
+ *
1364
+ * Much faster than path.resolve() when called multiple times for the same
1365
+ * path, because the resolved Path objects are cached. Much slower
1366
+ * otherwise.
1367
+ */
1368
+ resolve(...paths) {
1369
+ // first figure out the minimum number of paths we have to test
1370
+ // we always start at cwd, but any absolutes will bump the start
1371
+ let r = '';
1372
+ for (let i = paths.length - 1; i >= 0; i--) {
1373
+ const p = paths[i];
1374
+ if (!p || p === '.')
1375
+ continue;
1376
+ r = r ? `${p}/${r}` : p;
1377
+ if (this.isAbsolute(p)) {
1378
+ break;
1379
+ }
1380
+ }
1381
+ const cached = this.#resolveCache.get(r);
1382
+ if (cached !== undefined) {
1383
+ return cached;
1384
+ }
1385
+ const result = this.cwd.resolve(r).fullpath();
1386
+ this.#resolveCache.set(r, result);
1387
+ return result;
1388
+ }
1389
+ /**
1390
+ * Resolve one or more path strings to a resolved string, returning
1391
+ * the posix path. Identical to .resolve() on posix systems, but on
1392
+ * windows will return a forward-slash separated UNC path.
1393
+ *
1394
+ * Same interface as require('path').resolve.
1395
+ *
1396
+ * Much faster than path.resolve() when called multiple times for the same
1397
+ * path, because the resolved Path objects are cached. Much slower
1398
+ * otherwise.
1399
+ */
1400
+ resolvePosix(...paths) {
1401
+ // first figure out the minimum number of paths we have to test
1402
+ // we always start at cwd, but any absolutes will bump the start
1403
+ let r = '';
1404
+ for (let i = paths.length - 1; i >= 0; i--) {
1405
+ const p = paths[i];
1406
+ if (!p || p === '.')
1407
+ continue;
1408
+ r = r ? `${p}/${r}` : p;
1409
+ if (this.isAbsolute(p)) {
1410
+ break;
1411
+ }
1412
+ }
1413
+ const cached = this.#resolvePosixCache.get(r);
1414
+ if (cached !== undefined) {
1415
+ return cached;
1416
+ }
1417
+ const result = this.cwd.resolve(r).fullpathPosix();
1418
+ this.#resolvePosixCache.set(r, result);
1419
+ return result;
1420
+ }
1421
+ /**
1422
+ * find the relative path from the cwd to the supplied path string or entry
1423
+ */
1424
+ relative(entry = this.cwd) {
1425
+ if (typeof entry === 'string') {
1426
+ entry = this.cwd.resolve(entry);
1427
+ }
1428
+ return entry.relative();
1429
+ }
1430
+ /**
1431
+ * find the relative path from the cwd to the supplied path string or
1432
+ * entry, using / as the path delimiter, even on Windows.
1433
+ */
1434
+ relativePosix(entry = this.cwd) {
1435
+ if (typeof entry === 'string') {
1436
+ entry = this.cwd.resolve(entry);
1437
+ }
1438
+ return entry.relativePosix();
1439
+ }
1440
+ /**
1441
+ * Return the basename for the provided string or Path object
1442
+ */
1443
+ basename(entry = this.cwd) {
1444
+ if (typeof entry === 'string') {
1445
+ entry = this.cwd.resolve(entry);
1446
+ }
1447
+ return entry.name;
1448
+ }
1449
+ /**
1450
+ * Return the dirname for the provided string or Path object
1451
+ */
1452
+ dirname(entry = this.cwd) {
1453
+ if (typeof entry === 'string') {
1454
+ entry = this.cwd.resolve(entry);
1455
+ }
1456
+ return (entry.parent || entry).fullpath();
1457
+ }
1458
+ async readdir(entry = this.cwd, opts = {
1459
+ withFileTypes: true,
1460
+ }) {
1461
+ if (typeof entry === 'string') {
1462
+ entry = this.cwd.resolve(entry);
1463
+ }
1464
+ else if (!(entry instanceof PathBase)) {
1465
+ opts = entry;
1466
+ entry = this.cwd;
1467
+ }
1468
+ const { withFileTypes } = opts;
1469
+ if (!entry.canReaddir()) {
1470
+ return [];
1471
+ }
1472
+ else {
1473
+ const p = await entry.readdir();
1474
+ return withFileTypes ? p : p.map(e => e.name);
1475
+ }
1476
+ }
1477
+ readdirSync(entry = this.cwd, opts = {
1478
+ withFileTypes: true,
1479
+ }) {
1480
+ if (typeof entry === 'string') {
1481
+ entry = this.cwd.resolve(entry);
1482
+ }
1483
+ else if (!(entry instanceof PathBase)) {
1484
+ opts = entry;
1485
+ entry = this.cwd;
1486
+ }
1487
+ const { withFileTypes = true } = opts;
1488
+ if (!entry.canReaddir()) {
1489
+ return [];
1490
+ }
1491
+ else if (withFileTypes) {
1492
+ return entry.readdirSync();
1493
+ }
1494
+ else {
1495
+ return entry.readdirSync().map(e => e.name);
1496
+ }
1497
+ }
1498
+ /**
1499
+ * Call lstat() on the string or Path object, and update all known
1500
+ * information that can be determined.
1501
+ *
1502
+ * Note that unlike `fs.lstat()`, the returned value does not contain some
1503
+ * information, such as `mode`, `dev`, `nlink`, and `ino`. If that
1504
+ * information is required, you will need to call `fs.lstat` yourself.
1505
+ *
1506
+ * If the Path refers to a nonexistent file, or if the lstat call fails for
1507
+ * any reason, `undefined` is returned. Otherwise the updated Path object is
1508
+ * returned.
1509
+ *
1510
+ * Results are cached, and thus may be out of date if the filesystem is
1511
+ * mutated.
1512
+ */
1513
+ async lstat(entry = this.cwd) {
1514
+ if (typeof entry === 'string') {
1515
+ entry = this.cwd.resolve(entry);
1516
+ }
1517
+ return entry.lstat();
1518
+ }
1519
+ /**
1520
+ * synchronous {@link PathScurryBase.lstat}
1521
+ */
1522
+ lstatSync(entry = this.cwd) {
1523
+ if (typeof entry === 'string') {
1524
+ entry = this.cwd.resolve(entry);
1525
+ }
1526
+ return entry.lstatSync();
1527
+ }
1528
+ async readlink(entry = this.cwd, { withFileTypes } = {
1529
+ withFileTypes: false,
1530
+ }) {
1531
+ if (typeof entry === 'string') {
1532
+ entry = this.cwd.resolve(entry);
1533
+ }
1534
+ else if (!(entry instanceof PathBase)) {
1535
+ withFileTypes = entry.withFileTypes;
1536
+ entry = this.cwd;
1537
+ }
1538
+ const e = await entry.readlink();
1539
+ return withFileTypes ? e : e?.fullpath();
1540
+ }
1541
+ readlinkSync(entry = this.cwd, { withFileTypes } = {
1542
+ withFileTypes: false,
1543
+ }) {
1544
+ if (typeof entry === 'string') {
1545
+ entry = this.cwd.resolve(entry);
1546
+ }
1547
+ else if (!(entry instanceof PathBase)) {
1548
+ withFileTypes = entry.withFileTypes;
1549
+ entry = this.cwd;
1550
+ }
1551
+ const e = entry.readlinkSync();
1552
+ return withFileTypes ? e : e?.fullpath();
1553
+ }
1554
+ async realpath(entry = this.cwd, { withFileTypes } = {
1555
+ withFileTypes: false,
1556
+ }) {
1557
+ if (typeof entry === 'string') {
1558
+ entry = this.cwd.resolve(entry);
1559
+ }
1560
+ else if (!(entry instanceof PathBase)) {
1561
+ withFileTypes = entry.withFileTypes;
1562
+ entry = this.cwd;
1563
+ }
1564
+ const e = await entry.realpath();
1565
+ return withFileTypes ? e : e?.fullpath();
1566
+ }
1567
+ realpathSync(entry = this.cwd, { withFileTypes } = {
1568
+ withFileTypes: false,
1569
+ }) {
1570
+ if (typeof entry === 'string') {
1571
+ entry = this.cwd.resolve(entry);
1572
+ }
1573
+ else if (!(entry instanceof PathBase)) {
1574
+ withFileTypes = entry.withFileTypes;
1575
+ entry = this.cwd;
1576
+ }
1577
+ const e = entry.realpathSync();
1578
+ return withFileTypes ? e : e?.fullpath();
1579
+ }
1580
+ async walk(entry = this.cwd, opts = {}) {
1581
+ if (typeof entry === 'string') {
1582
+ entry = this.cwd.resolve(entry);
1583
+ }
1584
+ else if (!(entry instanceof PathBase)) {
1585
+ opts = entry;
1586
+ entry = this.cwd;
1587
+ }
1588
+ const { withFileTypes = true, follow = false, filter, walkFilter, } = opts;
1589
+ const results = [];
1590
+ if (!filter || filter(entry)) {
1591
+ results.push(withFileTypes ? entry : entry.fullpath());
1592
+ }
1593
+ const dirs = new Set();
1594
+ const walk = (dir, cb) => {
1595
+ dirs.add(dir);
1596
+ dir.readdirCB((er, entries) => {
1597
+ /* c8 ignore start */
1598
+ if (er) {
1599
+ return cb(er);
1600
+ }
1601
+ /* c8 ignore stop */
1602
+ let len = entries.length;
1603
+ if (!len)
1604
+ return cb();
1605
+ const next = () => {
1606
+ if (--len === 0) {
1607
+ cb();
1608
+ }
1609
+ };
1610
+ for (const e of entries) {
1611
+ if (!filter || filter(e)) {
1612
+ results.push(withFileTypes ? e : e.fullpath());
1613
+ }
1614
+ if (follow && e.isSymbolicLink()) {
1615
+ e.realpath()
1616
+ .then(r => (r?.isUnknown() ? r.lstat() : r))
1617
+ .then(r => r?.shouldWalk(dirs, walkFilter) ? walk(r, next) : next());
1618
+ }
1619
+ else {
1620
+ if (e.shouldWalk(dirs, walkFilter)) {
1621
+ walk(e, next);
1622
+ }
1623
+ else {
1624
+ next();
1625
+ }
1626
+ }
1627
+ }
1628
+ }, true); // zalgooooooo
1629
+ };
1630
+ const start = entry;
1631
+ return new Promise((res, rej) => {
1632
+ walk(start, er => {
1633
+ /* c8 ignore start */
1634
+ if (er)
1635
+ return rej(er);
1636
+ /* c8 ignore stop */
1637
+ res(results);
1638
+ });
1639
+ });
1640
+ }
1641
+ walkSync(entry = this.cwd, opts = {}) {
1642
+ if (typeof entry === 'string') {
1643
+ entry = this.cwd.resolve(entry);
1644
+ }
1645
+ else if (!(entry instanceof PathBase)) {
1646
+ opts = entry;
1647
+ entry = this.cwd;
1648
+ }
1649
+ const { withFileTypes = true, follow = false, filter, walkFilter, } = opts;
1650
+ const results = [];
1651
+ if (!filter || filter(entry)) {
1652
+ results.push(withFileTypes ? entry : entry.fullpath());
1653
+ }
1654
+ const dirs = new Set([entry]);
1655
+ for (const dir of dirs) {
1656
+ const entries = dir.readdirSync();
1657
+ for (const e of entries) {
1658
+ if (!filter || filter(e)) {
1659
+ results.push(withFileTypes ? e : e.fullpath());
1660
+ }
1661
+ let r = e;
1662
+ if (e.isSymbolicLink()) {
1663
+ if (!(follow && (r = e.realpathSync())))
1664
+ continue;
1665
+ if (r.isUnknown())
1666
+ r.lstatSync();
1667
+ }
1668
+ if (r.shouldWalk(dirs, walkFilter)) {
1669
+ dirs.add(r);
1670
+ }
1671
+ }
1672
+ }
1673
+ return results;
1674
+ }
1675
+ /**
1676
+ * Support for `for await`
1677
+ *
1678
+ * Alias for {@link PathScurryBase.iterate}
1679
+ *
1680
+ * Note: As of Node 19, this is very slow, compared to other methods of
1681
+ * walking. Consider using {@link PathScurryBase.stream} if memory overhead
1682
+ * and backpressure are concerns, or {@link PathScurryBase.walk} if not.
1683
+ */
1684
+ [Symbol.asyncIterator]() {
1685
+ return this.iterate();
1686
+ }
1687
+ iterate(entry = this.cwd, options = {}) {
1688
+ // iterating async over the stream is significantly more performant,
1689
+ // especially in the warm-cache scenario, because it buffers up directory
1690
+ // entries in the background instead of waiting for a yield for each one.
1691
+ if (typeof entry === 'string') {
1692
+ entry = this.cwd.resolve(entry);
1693
+ }
1694
+ else if (!(entry instanceof PathBase)) {
1695
+ options = entry;
1696
+ entry = this.cwd;
1697
+ }
1698
+ return this.stream(entry, options)[Symbol.asyncIterator]();
1699
+ }
1700
+ /**
1701
+ * Iterating over a PathScurry performs a synchronous walk.
1702
+ *
1703
+ * Alias for {@link PathScurryBase.iterateSync}
1704
+ */
1705
+ [Symbol.iterator]() {
1706
+ return this.iterateSync();
1707
+ }
1708
+ *iterateSync(entry = this.cwd, opts = {}) {
1709
+ if (typeof entry === 'string') {
1710
+ entry = this.cwd.resolve(entry);
1711
+ }
1712
+ else if (!(entry instanceof PathBase)) {
1713
+ opts = entry;
1714
+ entry = this.cwd;
1715
+ }
1716
+ const { withFileTypes = true, follow = false, filter, walkFilter, } = opts;
1717
+ if (!filter || filter(entry)) {
1718
+ yield withFileTypes ? entry : entry.fullpath();
1719
+ }
1720
+ const dirs = new Set([entry]);
1721
+ for (const dir of dirs) {
1722
+ const entries = dir.readdirSync();
1723
+ for (const e of entries) {
1724
+ if (!filter || filter(e)) {
1725
+ yield withFileTypes ? e : e.fullpath();
1726
+ }
1727
+ let r = e;
1728
+ if (e.isSymbolicLink()) {
1729
+ if (!(follow && (r = e.realpathSync())))
1730
+ continue;
1731
+ if (r.isUnknown())
1732
+ r.lstatSync();
1733
+ }
1734
+ if (r.shouldWalk(dirs, walkFilter)) {
1735
+ dirs.add(r);
1736
+ }
1737
+ }
1738
+ }
1739
+ }
1740
+ stream(entry = this.cwd, opts = {}) {
1741
+ if (typeof entry === 'string') {
1742
+ entry = this.cwd.resolve(entry);
1743
+ }
1744
+ else if (!(entry instanceof PathBase)) {
1745
+ opts = entry;
1746
+ entry = this.cwd;
1747
+ }
1748
+ const { withFileTypes = true, follow = false, filter, walkFilter, } = opts;
1749
+ const results = new Minipass({ objectMode: true });
1750
+ if (!filter || filter(entry)) {
1751
+ results.write(withFileTypes ? entry : entry.fullpath());
1752
+ }
1753
+ const dirs = new Set();
1754
+ const queue = [entry];
1755
+ let processing = 0;
1756
+ const process = () => {
1757
+ let paused = false;
1758
+ while (!paused) {
1759
+ const dir = queue.shift();
1760
+ if (!dir) {
1761
+ if (processing === 0)
1762
+ results.end();
1763
+ return;
1764
+ }
1765
+ processing++;
1766
+ dirs.add(dir);
1767
+ const onReaddir = (er, entries, didRealpaths = false) => {
1768
+ /* c8 ignore start */
1769
+ if (er)
1770
+ return results.emit('error', er);
1771
+ /* c8 ignore stop */
1772
+ if (follow && !didRealpaths) {
1773
+ const promises = [];
1774
+ for (const e of entries) {
1775
+ if (e.isSymbolicLink()) {
1776
+ promises.push(e
1777
+ .realpath()
1778
+ .then((r) => r?.isUnknown() ? r.lstat() : r));
1779
+ }
1780
+ }
1781
+ if (promises.length) {
1782
+ Promise.all(promises).then(() => onReaddir(null, entries, true));
1783
+ return;
1784
+ }
1785
+ }
1786
+ for (const e of entries) {
1787
+ if (e && (!filter || filter(e))) {
1788
+ if (!results.write(withFileTypes ? e : e.fullpath())) {
1789
+ paused = true;
1790
+ }
1791
+ }
1792
+ }
1793
+ processing--;
1794
+ for (const e of entries) {
1795
+ const r = e.realpathCached() || e;
1796
+ if (r.shouldWalk(dirs, walkFilter)) {
1797
+ queue.push(r);
1798
+ }
1799
+ }
1800
+ if (paused && !results.flowing) {
1801
+ results.once('drain', process);
1802
+ }
1803
+ else if (!sync) {
1804
+ process();
1805
+ }
1806
+ };
1807
+ // zalgo containment
1808
+ let sync = true;
1809
+ dir.readdirCB(onReaddir, true);
1810
+ sync = false;
1811
+ }
1812
+ };
1813
+ process();
1814
+ return results;
1815
+ }
1816
+ streamSync(entry = this.cwd, opts = {}) {
1817
+ if (typeof entry === 'string') {
1818
+ entry = this.cwd.resolve(entry);
1819
+ }
1820
+ else if (!(entry instanceof PathBase)) {
1821
+ opts = entry;
1822
+ entry = this.cwd;
1823
+ }
1824
+ const { withFileTypes = true, follow = false, filter, walkFilter, } = opts;
1825
+ const results = new Minipass({ objectMode: true });
1826
+ const dirs = new Set();
1827
+ if (!filter || filter(entry)) {
1828
+ results.write(withFileTypes ? entry : entry.fullpath());
1829
+ }
1830
+ const queue = [entry];
1831
+ let processing = 0;
1832
+ const process = () => {
1833
+ let paused = false;
1834
+ while (!paused) {
1835
+ const dir = queue.shift();
1836
+ if (!dir) {
1837
+ if (processing === 0)
1838
+ results.end();
1839
+ return;
1840
+ }
1841
+ processing++;
1842
+ dirs.add(dir);
1843
+ const entries = dir.readdirSync();
1844
+ for (const e of entries) {
1845
+ if (!filter || filter(e)) {
1846
+ if (!results.write(withFileTypes ? e : e.fullpath())) {
1847
+ paused = true;
1848
+ }
1849
+ }
1850
+ }
1851
+ processing--;
1852
+ for (const e of entries) {
1853
+ let r = e;
1854
+ if (e.isSymbolicLink()) {
1855
+ if (!(follow && (r = e.realpathSync())))
1856
+ continue;
1857
+ if (r.isUnknown())
1858
+ r.lstatSync();
1859
+ }
1860
+ if (r.shouldWalk(dirs, walkFilter)) {
1861
+ queue.push(r);
1862
+ }
1863
+ }
1864
+ }
1865
+ if (paused && !results.flowing)
1866
+ results.once('drain', process);
1867
+ };
1868
+ process();
1869
+ return results;
1870
+ }
1871
+ chdir(path = this.cwd) {
1872
+ const oldCwd = this.cwd;
1873
+ this.cwd = typeof path === 'string' ? this.cwd.resolve(path) : path;
1874
+ this.cwd[setAsCwd](oldCwd);
1875
+ }
1876
+ }
1877
+ /**
1878
+ * Windows implementation of {@link PathScurryBase}
1879
+ *
1880
+ * Defaults to case insensitve, uses `'\\'` to generate path strings. Uses
1881
+ * {@link PathWin32} for Path objects.
1882
+ */
1883
+ export class PathScurryWin32 extends PathScurryBase {
1884
+ /**
1885
+ * separator for generating path strings
1886
+ */
1887
+ sep = '\\';
1888
+ constructor(cwd = process.cwd(), opts = {}) {
1889
+ const { nocase = true } = opts;
1890
+ super(cwd, win32, '\\', { ...opts, nocase });
1891
+ this.nocase = nocase;
1892
+ for (let p = this.cwd; p; p = p.parent) {
1893
+ p.nocase = this.nocase;
1894
+ }
1895
+ }
1896
+ /**
1897
+ * @internal
1898
+ */
1899
+ parseRootPath(dir) {
1900
+ // if the path starts with a single separator, it's not a UNC, and we'll
1901
+ // just get separator as the root, and driveFromUNC will return \
1902
+ // In that case, mount \ on the root from the cwd.
1903
+ return win32.parse(dir).root.toUpperCase();
1904
+ }
1905
+ /**
1906
+ * @internal
1907
+ */
1908
+ newRoot(fs) {
1909
+ return new PathWin32(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs });
1910
+ }
1911
+ /**
1912
+ * Return true if the provided path string is an absolute path
1913
+ */
1914
+ isAbsolute(p) {
1915
+ return (p.startsWith('/') || p.startsWith('\\') || /^[a-z]:(\/|\\)/i.test(p));
1916
+ }
1917
+ }
1918
+ /**
1919
+ * {@link PathScurryBase} implementation for all posix systems other than Darwin.
1920
+ *
1921
+ * Defaults to case-sensitive matching, uses `'/'` to generate path strings.
1922
+ *
1923
+ * Uses {@link PathPosix} for Path objects.
1924
+ */
1925
+ export class PathScurryPosix extends PathScurryBase {
1926
+ /**
1927
+ * separator for generating path strings
1928
+ */
1929
+ sep = '/';
1930
+ constructor(cwd = process.cwd(), opts = {}) {
1931
+ const { nocase = false } = opts;
1932
+ super(cwd, posix, '/', { ...opts, nocase });
1933
+ this.nocase = nocase;
1934
+ }
1935
+ /**
1936
+ * @internal
1937
+ */
1938
+ parseRootPath(_dir) {
1939
+ return '/';
1940
+ }
1941
+ /**
1942
+ * @internal
1943
+ */
1944
+ newRoot(fs) {
1945
+ return new PathPosix(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs });
1946
+ }
1947
+ /**
1948
+ * Return true if the provided path string is an absolute path
1949
+ */
1950
+ isAbsolute(p) {
1951
+ return p.startsWith('/');
1952
+ }
1953
+ }
1954
+ /**
1955
+ * {@link PathScurryBase} implementation for Darwin (macOS) systems.
1956
+ *
1957
+ * Defaults to case-insensitive matching, uses `'/'` for generating path
1958
+ * strings.
1959
+ *
1960
+ * Uses {@link PathPosix} for Path objects.
1961
+ */
1962
+ export class PathScurryDarwin extends PathScurryPosix {
1963
+ constructor(cwd = process.cwd(), opts = {}) {
1964
+ const { nocase = true } = opts;
1965
+ super(cwd, { ...opts, nocase });
1966
+ }
1967
+ }
1968
+ /**
1969
+ * Default {@link PathBase} implementation for the current platform.
1970
+ *
1971
+ * {@link PathWin32} on Windows systems, {@link PathPosix} on all others.
1972
+ */
1973
+ export const Path = process.platform === 'win32' ? PathWin32 : PathPosix;
1974
+ /**
1975
+ * Default {@link PathScurryBase} implementation for the current platform.
1976
+ *
1977
+ * {@link PathScurryWin32} on Windows systems, {@link PathScurryDarwin} on
1978
+ * Darwin (macOS) systems, {@link PathScurryPosix} on all others.
1979
+ */
1980
+ export const PathScurry = process.platform === 'win32' ? PathScurryWin32
1981
+ : process.platform === 'darwin' ? PathScurryDarwin
1982
+ : PathScurryPosix;
1983
+ //# sourceMappingURL=index.js.map