tar 7.5.23 → 8.0.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 (330) hide show
  1. package/README.md +1705 -1147
  2. package/dist/commonjs/bytes.d.ts +21 -0
  3. package/dist/commonjs/bytes.d.ts.map +1 -0
  4. package/dist/commonjs/bytes.js +83 -0
  5. package/dist/commonjs/bytes.js.map +1 -0
  6. package/dist/commonjs/codec.d.ts +53 -0
  7. package/dist/commonjs/codec.d.ts.map +1 -0
  8. package/dist/commonjs/codec.js +35 -0
  9. package/dist/commonjs/codec.js.map +1 -0
  10. package/dist/commonjs/concat.d.ts +3 -0
  11. package/dist/commonjs/concat.d.ts.map +1 -0
  12. package/dist/commonjs/concat.js +20 -0
  13. package/dist/commonjs/concat.js.map +1 -0
  14. package/dist/commonjs/create.d.ts +39 -2
  15. package/dist/commonjs/create.d.ts.map +1 -1
  16. package/dist/commonjs/create.js +150 -64
  17. package/dist/commonjs/create.js.map +1 -1
  18. package/dist/commonjs/dealias.d.ts +79 -0
  19. package/dist/commonjs/dealias.d.ts.map +1 -0
  20. package/dist/commonjs/dealias.js +50 -0
  21. package/dist/commonjs/dealias.js.map +1 -0
  22. package/dist/commonjs/delete.d.ts +19 -0
  23. package/dist/commonjs/delete.d.ts.map +1 -0
  24. package/dist/commonjs/delete.js +121 -0
  25. package/dist/commonjs/delete.js.map +1 -0
  26. package/dist/commonjs/entries.d.ts +82 -0
  27. package/dist/commonjs/entries.d.ts.map +1 -0
  28. package/dist/commonjs/entries.js +398 -0
  29. package/dist/commonjs/entries.js.map +1 -0
  30. package/dist/commonjs/extract.d.ts +14 -2
  31. package/dist/commonjs/extract.d.ts.map +1 -1
  32. package/dist/commonjs/extract.js +40 -81
  33. package/dist/commonjs/extract.js.map +1 -1
  34. package/dist/commonjs/fs.d.ts +201 -0
  35. package/dist/commonjs/fs.d.ts.map +1 -0
  36. package/dist/commonjs/fs.js +5 -0
  37. package/dist/commonjs/fs.js.map +1 -0
  38. package/dist/commonjs/header.d.ts +4 -4
  39. package/dist/commonjs/header.d.ts.map +1 -1
  40. package/dist/commonjs/header.js +38 -42
  41. package/dist/commonjs/header.js.map +1 -1
  42. package/dist/commonjs/index.d.ts +25 -18
  43. package/dist/commonjs/index.d.ts.map +1 -1
  44. package/dist/commonjs/index.js +46 -18
  45. package/dist/commonjs/index.js.map +1 -1
  46. package/dist/commonjs/index.min.js +2 -3
  47. package/dist/commonjs/index.min.js.map +4 -4
  48. package/dist/commonjs/large-numbers.d.ts +2 -2
  49. package/dist/commonjs/large-numbers.d.ts.map +1 -1
  50. package/dist/commonjs/large-numbers.js +4 -4
  51. package/dist/commonjs/large-numbers.js.map +1 -1
  52. package/dist/commonjs/list.d.ts +23 -6
  53. package/dist/commonjs/list.d.ts.map +1 -1
  54. package/dist/commonjs/list.js +99 -138
  55. package/dist/commonjs/list.js.map +1 -1
  56. package/dist/commonjs/mkdir.d.ts +16 -11
  57. package/dist/commonjs/mkdir.d.ts.map +1 -1
  58. package/dist/commonjs/mkdir.js +121 -159
  59. package/dist/commonjs/mkdir.js.map +1 -1
  60. package/dist/commonjs/options.d.ts +284 -513
  61. package/dist/commonjs/options.d.ts.map +1 -1
  62. package/dist/commonjs/options.js +20 -61
  63. package/dist/commonjs/options.js.map +1 -1
  64. package/dist/commonjs/pack.d.ts +150 -96
  65. package/dist/commonjs/pack.d.ts.map +1 -1
  66. package/dist/commonjs/pack.js +752 -445
  67. package/dist/commonjs/pack.js.map +1 -1
  68. package/dist/commonjs/parser.d.ts +94 -0
  69. package/dist/commonjs/parser.d.ts.map +1 -0
  70. package/dist/commonjs/parser.js +381 -0
  71. package/dist/commonjs/parser.js.map +1 -0
  72. package/dist/commonjs/path-reservations.d.ts +17 -7
  73. package/dist/commonjs/path-reservations.d.ts.map +1 -1
  74. package/dist/commonjs/path-reservations.js +96 -119
  75. package/dist/commonjs/path-reservations.js.map +1 -1
  76. package/dist/commonjs/path.d.ts +19 -0
  77. package/dist/commonjs/path.d.ts.map +1 -0
  78. package/dist/commonjs/path.js +90 -0
  79. package/dist/commonjs/path.js.map +1 -0
  80. package/dist/commonjs/pax.d.ts +3 -1
  81. package/dist/commonjs/pax.d.ts.map +1 -1
  82. package/dist/commonjs/pax.js +53 -37
  83. package/dist/commonjs/pax.js.map +1 -1
  84. package/dist/commonjs/read-entry.d.ts +97 -11
  85. package/dist/commonjs/read-entry.d.ts.map +1 -1
  86. package/dist/commonjs/read-entry.js +248 -97
  87. package/dist/commonjs/read-entry.js.map +1 -1
  88. package/dist/commonjs/read-file.d.ts +22 -0
  89. package/dist/commonjs/read-file.d.ts.map +1 -0
  90. package/dist/commonjs/read-file.js +104 -0
  91. package/dist/commonjs/read-file.js.map +1 -0
  92. package/dist/commonjs/replace.d.ts +45 -1
  93. package/dist/commonjs/replace.d.ts.map +1 -1
  94. package/dist/commonjs/replace.js +165 -211
  95. package/dist/commonjs/replace.js.map +1 -1
  96. package/dist/commonjs/server/codecs.d.ts +38 -0
  97. package/dist/commonjs/server/codecs.d.ts.map +1 -0
  98. package/dist/commonjs/server/codecs.js +252 -0
  99. package/dist/commonjs/server/codecs.js.map +1 -0
  100. package/dist/commonjs/server/index.d.ts +115 -0
  101. package/dist/commonjs/server/index.d.ts.map +1 -0
  102. package/dist/commonjs/server/index.js +166 -0
  103. package/dist/commonjs/server/index.js.map +1 -0
  104. package/dist/commonjs/server/index.min.js +3 -0
  105. package/dist/commonjs/server/index.min.js.map +7 -0
  106. package/dist/commonjs/strip-absolute-path.d.ts +8 -0
  107. package/dist/commonjs/strip-absolute-path.d.ts.map +1 -1
  108. package/dist/commonjs/strip-absolute-path.js +17 -20
  109. package/dist/commonjs/strip-absolute-path.js.map +1 -1
  110. package/dist/commonjs/to-stream.d.ts +7 -0
  111. package/dist/commonjs/to-stream.d.ts.map +1 -0
  112. package/dist/commonjs/to-stream.js +22 -0
  113. package/dist/commonjs/to-stream.js.map +1 -0
  114. package/dist/commonjs/types.d.ts +4 -3
  115. package/dist/commonjs/types.d.ts.map +1 -1
  116. package/dist/commonjs/types.js +4 -3
  117. package/dist/commonjs/types.js.map +1 -1
  118. package/dist/commonjs/unpack.d.ts +135 -89
  119. package/dist/commonjs/unpack.d.ts.map +1 -1
  120. package/dist/commonjs/unpack.js +760 -727
  121. package/dist/commonjs/unpack.js.map +1 -1
  122. package/dist/commonjs/update.d.ts +11 -1
  123. package/dist/commonjs/update.d.ts.map +1 -1
  124. package/dist/commonjs/update.js +37 -28
  125. package/dist/commonjs/update.js.map +1 -1
  126. package/dist/commonjs/warn.d.ts +27 -0
  127. package/dist/commonjs/warn.d.ts.map +1 -0
  128. package/dist/commonjs/warn.js +36 -0
  129. package/dist/commonjs/warn.js.map +1 -0
  130. package/dist/commonjs/win32-path.d.ts +16 -0
  131. package/dist/commonjs/win32-path.d.ts.map +1 -0
  132. package/dist/commonjs/win32-path.js +67 -0
  133. package/dist/commonjs/win32-path.js.map +1 -0
  134. package/dist/commonjs/write-entry.d.ts +64 -111
  135. package/dist/commonjs/write-entry.d.ts.map +1 -1
  136. package/dist/commonjs/write-entry.js +108 -672
  137. package/dist/commonjs/write-entry.js.map +1 -1
  138. package/dist/commonjs/write-flag.d.ts +18 -0
  139. package/dist/commonjs/write-flag.d.ts.map +1 -0
  140. package/dist/commonjs/write-flag.js +29 -0
  141. package/dist/commonjs/write-flag.js.map +1 -0
  142. package/dist/esm/bytes.d.ts +21 -0
  143. package/dist/esm/bytes.d.ts.map +1 -0
  144. package/dist/esm/bytes.js +72 -0
  145. package/dist/esm/bytes.js.map +1 -0
  146. package/dist/esm/codec.d.ts +53 -0
  147. package/dist/esm/codec.d.ts.map +1 -0
  148. package/dist/esm/codec.js +32 -0
  149. package/dist/esm/codec.js.map +1 -0
  150. package/dist/esm/concat.d.ts +3 -0
  151. package/dist/esm/concat.d.ts.map +1 -0
  152. package/dist/esm/concat.js +16 -0
  153. package/dist/esm/concat.js.map +1 -0
  154. package/dist/esm/create.d.ts +39 -2
  155. package/dist/esm/create.d.ts.map +1 -1
  156. package/dist/esm/create.js +144 -61
  157. package/dist/esm/create.js.map +1 -1
  158. package/dist/esm/dealias.d.ts +79 -0
  159. package/dist/esm/dealias.d.ts.map +1 -0
  160. package/dist/esm/dealias.js +46 -0
  161. package/dist/esm/dealias.js.map +1 -0
  162. package/dist/esm/delete.d.ts +19 -0
  163. package/dist/esm/delete.d.ts.map +1 -0
  164. package/dist/esm/delete.js +117 -0
  165. package/dist/esm/delete.js.map +1 -0
  166. package/dist/esm/entries.d.ts +82 -0
  167. package/dist/esm/entries.d.ts.map +1 -0
  168. package/dist/esm/entries.js +388 -0
  169. package/dist/esm/entries.js.map +1 -0
  170. package/dist/esm/extract.d.ts +14 -2
  171. package/dist/esm/extract.d.ts.map +1 -1
  172. package/dist/esm/extract.js +37 -44
  173. package/dist/esm/extract.js.map +1 -1
  174. package/dist/esm/fs.d.ts +201 -0
  175. package/dist/esm/fs.d.ts.map +1 -0
  176. package/dist/esm/fs.js +4 -0
  177. package/dist/esm/fs.js.map +1 -0
  178. package/dist/esm/header.d.ts +4 -4
  179. package/dist/esm/header.d.ts.map +1 -1
  180. package/dist/esm/header.js +38 -42
  181. package/dist/esm/header.js.map +1 -1
  182. package/dist/esm/index.d.ts +25 -18
  183. package/dist/esm/index.d.ts.map +1 -1
  184. package/dist/esm/index.js +23 -18
  185. package/dist/esm/index.js.map +1 -1
  186. package/dist/esm/index.min.js +2 -3
  187. package/dist/esm/index.min.js.map +4 -4
  188. package/dist/esm/large-numbers.d.ts +2 -2
  189. package/dist/esm/large-numbers.d.ts.map +1 -1
  190. package/dist/esm/large-numbers.js +4 -4
  191. package/dist/esm/large-numbers.js.map +1 -1
  192. package/dist/esm/list.d.ts +23 -6
  193. package/dist/esm/list.d.ts.map +1 -1
  194. package/dist/esm/list.js +96 -101
  195. package/dist/esm/list.js.map +1 -1
  196. package/dist/esm/mkdir.d.ts +16 -11
  197. package/dist/esm/mkdir.d.ts.map +1 -1
  198. package/dist/esm/mkdir.js +119 -154
  199. package/dist/esm/mkdir.js.map +1 -1
  200. package/dist/esm/options.d.ts +284 -513
  201. package/dist/esm/options.d.ts.map +1 -1
  202. package/dist/esm/options.js +17 -51
  203. package/dist/esm/options.js.map +1 -1
  204. package/dist/esm/pack.d.ts +150 -96
  205. package/dist/esm/pack.d.ts.map +1 -1
  206. package/dist/esm/pack.js +750 -441
  207. package/dist/esm/pack.js.map +1 -1
  208. package/dist/esm/parser.d.ts +94 -0
  209. package/dist/esm/parser.d.ts.map +1 -0
  210. package/dist/esm/parser.js +377 -0
  211. package/dist/esm/parser.js.map +1 -0
  212. package/dist/esm/path-reservations.d.ts +17 -7
  213. package/dist/esm/path-reservations.d.ts.map +1 -1
  214. package/dist/esm/path-reservations.js +96 -119
  215. package/dist/esm/path-reservations.js.map +1 -1
  216. package/dist/esm/path.d.ts +19 -0
  217. package/dist/esm/path.d.ts.map +1 -0
  218. package/dist/esm/path.js +80 -0
  219. package/dist/esm/path.js.map +1 -0
  220. package/dist/esm/pax.d.ts +3 -1
  221. package/dist/esm/pax.d.ts.map +1 -1
  222. package/dist/esm/pax.js +52 -36
  223. package/dist/esm/pax.js.map +1 -1
  224. package/dist/esm/read-entry.d.ts +97 -11
  225. package/dist/esm/read-entry.d.ts.map +1 -1
  226. package/dist/esm/read-entry.js +245 -96
  227. package/dist/esm/read-entry.js.map +1 -1
  228. package/dist/esm/read-file.d.ts +22 -0
  229. package/dist/esm/read-file.d.ts.map +1 -0
  230. package/dist/esm/read-file.js +99 -0
  231. package/dist/esm/read-file.js.map +1 -0
  232. package/dist/esm/replace.d.ts +45 -1
  233. package/dist/esm/replace.d.ts.map +1 -1
  234. package/dist/esm/replace.js +161 -207
  235. package/dist/esm/replace.js.map +1 -1
  236. package/dist/esm/server/codecs.d.ts +38 -0
  237. package/dist/esm/server/codecs.d.ts.map +1 -0
  238. package/dist/esm/server/codecs.js +214 -0
  239. package/dist/esm/server/codecs.js.map +1 -0
  240. package/dist/esm/server/index.d.ts +115 -0
  241. package/dist/esm/server/index.d.ts.map +1 -0
  242. package/dist/esm/server/index.js +102 -0
  243. package/dist/esm/server/index.js.map +1 -0
  244. package/dist/esm/server/index.min.js +3 -0
  245. package/dist/esm/server/index.min.js.map +7 -0
  246. package/dist/esm/strip-absolute-path.d.ts +8 -0
  247. package/dist/esm/strip-absolute-path.d.ts.map +1 -1
  248. package/dist/esm/strip-absolute-path.js +17 -20
  249. package/dist/esm/strip-absolute-path.js.map +1 -1
  250. package/dist/esm/to-stream.d.ts +7 -0
  251. package/dist/esm/to-stream.d.ts.map +1 -0
  252. package/dist/esm/to-stream.js +18 -0
  253. package/dist/esm/to-stream.js.map +1 -0
  254. package/dist/esm/types.d.ts +4 -3
  255. package/dist/esm/types.d.ts.map +1 -1
  256. package/dist/esm/types.js +4 -3
  257. package/dist/esm/types.js.map +1 -1
  258. package/dist/esm/unpack.d.ts +135 -89
  259. package/dist/esm/unpack.d.ts.map +1 -1
  260. package/dist/esm/unpack.js +756 -721
  261. package/dist/esm/unpack.js.map +1 -1
  262. package/dist/esm/update.d.ts +11 -1
  263. package/dist/esm/update.d.ts.map +1 -1
  264. package/dist/esm/update.js +35 -28
  265. package/dist/esm/update.js.map +1 -1
  266. package/dist/esm/warn.d.ts +27 -0
  267. package/dist/esm/warn.d.ts.map +1 -0
  268. package/dist/esm/warn.js +31 -0
  269. package/dist/esm/warn.js.map +1 -0
  270. package/dist/esm/win32-path.d.ts +16 -0
  271. package/dist/esm/win32-path.d.ts.map +1 -0
  272. package/dist/esm/win32-path.js +60 -0
  273. package/dist/esm/win32-path.js.map +1 -0
  274. package/dist/esm/write-entry.d.ts +64 -111
  275. package/dist/esm/write-entry.d.ts.map +1 -1
  276. package/dist/esm/write-entry.js +107 -633
  277. package/dist/esm/write-entry.js.map +1 -1
  278. package/dist/esm/write-flag.d.ts +18 -0
  279. package/dist/esm/write-flag.d.ts.map +1 -0
  280. package/dist/esm/write-flag.js +25 -0
  281. package/dist/esm/write-flag.js.map +1 -0
  282. package/package.json +68 -224
  283. package/dist/commonjs/get-write-flag.d.ts +0 -2
  284. package/dist/commonjs/get-write-flag.d.ts.map +0 -1
  285. package/dist/commonjs/get-write-flag.js +0 -32
  286. package/dist/commonjs/get-write-flag.js.map +0 -1
  287. package/dist/commonjs/make-command.d.ts +0 -49
  288. package/dist/commonjs/make-command.d.ts.map +0 -1
  289. package/dist/commonjs/make-command.js +0 -52
  290. package/dist/commonjs/make-command.js.map +0 -1
  291. package/dist/commonjs/normalize-windows-path.d.ts +0 -2
  292. package/dist/commonjs/normalize-windows-path.d.ts.map +0 -1
  293. package/dist/commonjs/normalize-windows-path.js +0 -12
  294. package/dist/commonjs/normalize-windows-path.js.map +0 -1
  295. package/dist/commonjs/parse.d.ts +0 -92
  296. package/dist/commonjs/parse.d.ts.map +0 -1
  297. package/dist/commonjs/parse.js +0 -655
  298. package/dist/commonjs/parse.js.map +0 -1
  299. package/dist/commonjs/process-umask.d.ts +0 -2
  300. package/dist/commonjs/process-umask.d.ts.map +0 -1
  301. package/dist/commonjs/process-umask.js +0 -7
  302. package/dist/commonjs/process-umask.js.map +0 -1
  303. package/dist/commonjs/warn-method.d.ts +0 -24
  304. package/dist/commonjs/warn-method.d.ts.map +0 -1
  305. package/dist/commonjs/warn-method.js +0 -31
  306. package/dist/commonjs/warn-method.js.map +0 -1
  307. package/dist/esm/get-write-flag.d.ts +0 -2
  308. package/dist/esm/get-write-flag.d.ts.map +0 -1
  309. package/dist/esm/get-write-flag.js +0 -26
  310. package/dist/esm/get-write-flag.js.map +0 -1
  311. package/dist/esm/make-command.d.ts +0 -49
  312. package/dist/esm/make-command.d.ts.map +0 -1
  313. package/dist/esm/make-command.js +0 -48
  314. package/dist/esm/make-command.js.map +0 -1
  315. package/dist/esm/normalize-windows-path.d.ts +0 -2
  316. package/dist/esm/normalize-windows-path.d.ts.map +0 -1
  317. package/dist/esm/normalize-windows-path.js +0 -9
  318. package/dist/esm/normalize-windows-path.js.map +0 -1
  319. package/dist/esm/parse.d.ts +0 -92
  320. package/dist/esm/parse.d.ts.map +0 -1
  321. package/dist/esm/parse.js +0 -651
  322. package/dist/esm/parse.js.map +0 -1
  323. package/dist/esm/process-umask.d.ts +0 -2
  324. package/dist/esm/process-umask.d.ts.map +0 -1
  325. package/dist/esm/process-umask.js +0 -3
  326. package/dist/esm/process-umask.js.map +0 -1
  327. package/dist/esm/warn-method.d.ts +0 -24
  328. package/dist/esm/warn-method.d.ts.map +0 -1
  329. package/dist/esm/warn-method.js +0 -27
  330. package/dist/esm/warn-method.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../node_modules/@isaacs/fs-minipass/src/index.ts", "../../node_modules/minipass/src/index.ts", "../../src/create.ts", "../../src/list.ts", "../../src/options.ts", "../../src/make-command.ts", "../../src/parse.ts", "../../node_modules/minizlib/src/index.ts", "../../node_modules/minizlib/src/constants.ts", "../../src/header.ts", "../../src/large-numbers.ts", "../../src/types.ts", "../../src/pax.ts", "../../src/normalize-windows-path.ts", "../../src/read-entry.ts", "../../src/warn-method.ts", "../../src/strip-trailing-slashes.ts", "../../src/pack.ts", "../../src/write-entry.ts", "../../src/mode-fix.ts", "../../src/strip-absolute-path.ts", "../../src/winchars.ts", "../../node_modules/yallist/src/index.ts", "../../src/extract.ts", "../../src/unpack.ts", "../../src/get-write-flag.ts", "../../node_modules/chownr/src/index.ts", "../../src/mkdir.ts", "../../src/cwd-error.ts", "../../src/symlink-error.ts", "../../src/path-reservations.ts", "../../src/normalize-unicode.ts", "../../src/process-umask.ts", "../../src/replace.ts", "../../src/update.ts"],
4
- "sourcesContent": ["import EE from 'events'\nimport fs from 'fs'\nimport { Minipass } from 'minipass'\n\nconst writev = fs.writev\n\nconst _autoClose = Symbol('_autoClose')\nconst _close = Symbol('_close')\nconst _ended = Symbol('_ended')\nconst _fd = Symbol('_fd')\nconst _finished = Symbol('_finished')\nconst _flags = Symbol('_flags')\nconst _flush = Symbol('_flush')\nconst _handleChunk = Symbol('_handleChunk')\nconst _makeBuf = Symbol('_makeBuf')\nconst _mode = Symbol('_mode')\nconst _needDrain = Symbol('_needDrain')\nconst _onerror = Symbol('_onerror')\nconst _onopen = Symbol('_onopen')\nconst _onread = Symbol('_onread')\nconst _onwrite = Symbol('_onwrite')\nconst _open = Symbol('_open')\nconst _path = Symbol('_path')\nconst _pos = Symbol('_pos')\nconst _queue = Symbol('_queue')\nconst _read = Symbol('_read')\nconst _readSize = Symbol('_readSize')\nconst _reading = Symbol('_reading')\nconst _remain = Symbol('_remain')\nconst _size = Symbol('_size')\nconst _write = Symbol('_write')\nconst _writing = Symbol('_writing')\nconst _defaultFlag = Symbol('_defaultFlag')\nconst _errored = Symbol('_errored')\n\nexport type ReadStreamOptions =\n Minipass.Options<Minipass.ContiguousData> & {\n fd?: number\n readSize?: number\n size?: number\n autoClose?: boolean\n }\n\nexport type ReadStreamEvents = Minipass.Events<Minipass.ContiguousData> & {\n open: [fd: number]\n}\n\nexport class ReadStream extends Minipass<\n Minipass.ContiguousData,\n Buffer,\n ReadStreamEvents\n> {\n [_errored]: boolean = false;\n [_fd]?: number;\n [_path]: string;\n [_readSize]: number;\n [_reading]: boolean = false;\n [_size]: number;\n [_remain]: number;\n [_autoClose]: boolean\n\n constructor(path: string, opt: ReadStreamOptions) {\n opt = opt || {}\n super(opt)\n\n this.readable = true\n this.writable = false\n\n if (typeof path !== 'string') {\n throw new TypeError('path must be a string')\n }\n\n this[_errored] = false\n this[_fd] = typeof opt.fd === 'number' ? opt.fd : undefined\n this[_path] = path\n this[_readSize] = opt.readSize || 16 * 1024 * 1024\n this[_reading] = false\n this[_size] = typeof opt.size === 'number' ? opt.size : Infinity\n this[_remain] = this[_size]\n this[_autoClose] =\n typeof opt.autoClose === 'boolean' ? opt.autoClose : true\n\n if (typeof this[_fd] === 'number') {\n this[_read]()\n } else {\n this[_open]()\n }\n }\n\n get fd() {\n return this[_fd]\n }\n\n get path() {\n return this[_path]\n }\n\n //@ts-ignore\n write() {\n throw new TypeError('this is a readable stream')\n }\n\n //@ts-ignore\n end() {\n throw new TypeError('this is a readable stream')\n }\n\n [_open]() {\n fs.open(this[_path], 'r', (er, fd) => this[_onopen](er, fd))\n }\n\n [_onopen](er?: NodeJS.ErrnoException | null, fd?: number) {\n if (er) {\n this[_onerror](er)\n } else {\n this[_fd] = fd\n this.emit('open', fd as number)\n this[_read]()\n }\n }\n\n [_makeBuf]() {\n return Buffer.allocUnsafe(Math.min(this[_readSize], this[_remain]))\n }\n\n [_read]() {\n if (!this[_reading]) {\n this[_reading] = true\n const buf = this[_makeBuf]()\n /* c8 ignore start */\n if (buf.length === 0) {\n return process.nextTick(() => this[_onread](null, 0, buf))\n }\n /* c8 ignore stop */\n fs.read(this[_fd] as number, buf, 0, buf.length, null, (er, br, b) =>\n this[_onread](er, br, b),\n )\n }\n }\n\n [_onread](er?: NodeJS.ErrnoException | null, br?: number, buf?: Buffer) {\n this[_reading] = false\n if (er) {\n this[_onerror](er)\n } else if (this[_handleChunk](br as number, buf as Buffer)) {\n this[_read]()\n }\n }\n\n [_close]() {\n if (this[_autoClose] && typeof this[_fd] === 'number') {\n const fd = this[_fd]\n this[_fd] = undefined\n fs.close(fd, er =>\n er ? this.emit('error', er) : this.emit('close'),\n )\n }\n }\n\n [_onerror](er: NodeJS.ErrnoException) {\n this[_reading] = true\n this[_close]()\n this.emit('error', er)\n }\n\n [_handleChunk](br: number, buf: Buffer) {\n let ret = false\n // no effect if infinite\n this[_remain] -= br\n if (br > 0) {\n ret = super.write(br < buf.length ? buf.subarray(0, br) : buf)\n }\n\n if (br === 0 || this[_remain] <= 0) {\n ret = false\n this[_close]()\n super.end()\n }\n\n return ret\n }\n\n emit<Event extends keyof ReadStreamEvents>(\n ev: Event,\n ...args: ReadStreamEvents[Event]\n ): boolean {\n switch (ev) {\n case 'prefinish':\n case 'finish':\n return false\n\n case 'drain':\n if (typeof this[_fd] === 'number') {\n this[_read]()\n }\n return false\n\n case 'error':\n if (this[_errored]) {\n return false\n }\n this[_errored] = true\n return super.emit(ev, ...args)\n\n default:\n return super.emit(ev, ...args)\n }\n }\n}\n\nexport class ReadStreamSync extends ReadStream {\n [_open]() {\n let threw = true\n try {\n this[_onopen](null, fs.openSync(this[_path], 'r'))\n threw = false\n } finally {\n if (threw) {\n this[_close]()\n }\n }\n }\n\n [_read]() {\n let threw = true\n try {\n if (!this[_reading]) {\n this[_reading] = true\n do {\n const buf = this[_makeBuf]()\n /* c8 ignore start */\n const br =\n buf.length === 0\n ? 0\n : fs.readSync(this[_fd] as number, buf, 0, buf.length, null)\n /* c8 ignore stop */\n if (!this[_handleChunk](br, buf)) {\n break\n }\n } while (true)\n this[_reading] = false\n }\n threw = false\n } finally {\n if (threw) {\n this[_close]()\n }\n }\n }\n\n [_close]() {\n if (this[_autoClose] && typeof this[_fd] === 'number') {\n const fd = this[_fd]\n this[_fd] = undefined\n fs.closeSync(fd)\n this.emit('close')\n }\n }\n}\n\nexport type WriteStreamOptions = {\n fd?: number\n autoClose?: boolean\n mode?: number\n captureRejections?: boolean\n start?: number\n flags?: string\n}\n\nexport class WriteStream extends EE {\n readable: false = false\n writable: boolean = true;\n [_errored]: boolean = false;\n [_writing]: boolean = false;\n [_ended]: boolean = false;\n [_queue]: Buffer[] = [];\n [_needDrain]: boolean = false;\n [_path]: string;\n [_mode]: number;\n [_autoClose]: boolean;\n [_fd]?: number;\n [_defaultFlag]: boolean;\n [_flags]: string;\n [_finished]: boolean = false;\n [_pos]?: number\n\n constructor(path: string, opt: WriteStreamOptions) {\n opt = opt || {}\n super(opt)\n this[_path] = path\n this[_fd] = typeof opt.fd === 'number' ? opt.fd : undefined\n this[_mode] = opt.mode === undefined ? 0o666 : opt.mode\n this[_pos] = typeof opt.start === 'number' ? opt.start : undefined\n this[_autoClose] =\n typeof opt.autoClose === 'boolean' ? opt.autoClose : true\n\n // truncating makes no sense when writing into the middle\n const defaultFlag = this[_pos] !== undefined ? 'r+' : 'w'\n this[_defaultFlag] = opt.flags === undefined\n this[_flags] = opt.flags === undefined ? defaultFlag : opt.flags\n\n if (this[_fd] === undefined) {\n this[_open]()\n }\n }\n\n emit(ev: string, ...args: any[]) {\n if (ev === 'error') {\n if (this[_errored]) {\n return false\n }\n this[_errored] = true\n }\n return super.emit(ev, ...args)\n }\n\n get fd() {\n return this[_fd]\n }\n\n get path() {\n return this[_path]\n }\n\n [_onerror](er: NodeJS.ErrnoException) {\n this[_close]()\n this[_writing] = true\n this.emit('error', er)\n }\n\n [_open]() {\n fs.open(this[_path], this[_flags], this[_mode], (er, fd) =>\n this[_onopen](er, fd),\n )\n }\n\n [_onopen](er?: null | NodeJS.ErrnoException, fd?: number) {\n if (\n this[_defaultFlag] &&\n this[_flags] === 'r+' &&\n er &&\n er.code === 'ENOENT'\n ) {\n this[_flags] = 'w'\n this[_open]()\n } else if (er) {\n this[_onerror](er)\n } else {\n this[_fd] = fd\n this.emit('open', fd)\n if (!this[_writing]) {\n this[_flush]()\n }\n }\n }\n\n end(buf: string, enc?: BufferEncoding): this\n end(buf?: Buffer, enc?: undefined): this\n end(buf?: Buffer | string, enc?: BufferEncoding): this {\n if (buf) {\n //@ts-ignore\n this.write(buf, enc)\n }\n\n this[_ended] = true\n\n // synthetic after-write logic, where drain/finish live\n if (\n !this[_writing] &&\n !this[_queue].length &&\n typeof this[_fd] === 'number'\n ) {\n this[_onwrite](null, 0)\n }\n return this\n }\n\n write(buf: string, enc?: BufferEncoding): boolean\n write(buf: Buffer, enc?: undefined): boolean\n write(buf: Buffer | string, enc?: BufferEncoding): boolean {\n if (typeof buf === 'string') {\n buf = Buffer.from(buf, enc)\n }\n\n if (this[_ended]) {\n this.emit('error', new Error('write() after end()'))\n return false\n }\n\n if (this[_fd] === undefined || this[_writing] || this[_queue].length) {\n this[_queue].push(buf)\n this[_needDrain] = true\n return false\n }\n\n this[_writing] = true\n this[_write](buf)\n return true\n }\n\n [_write](buf: Buffer) {\n fs.write(\n this[_fd] as number,\n buf,\n 0,\n buf.length,\n this[_pos],\n (er, bw) => this[_onwrite](er, bw),\n )\n }\n\n [_onwrite](er?: null | NodeJS.ErrnoException, bw?: number) {\n if (er) {\n this[_onerror](er)\n } else {\n if (this[_pos] !== undefined && typeof bw === 'number') {\n this[_pos] += bw\n }\n if (this[_queue].length) {\n this[_flush]()\n } else {\n this[_writing] = false\n\n if (this[_ended] && !this[_finished]) {\n this[_finished] = true\n this[_close]()\n this.emit('finish')\n } else if (this[_needDrain]) {\n this[_needDrain] = false\n this.emit('drain')\n }\n }\n }\n }\n\n [_flush]() {\n if (this[_queue].length === 0) {\n if (this[_ended]) {\n this[_onwrite](null, 0)\n }\n } else if (this[_queue].length === 1) {\n this[_write](this[_queue].pop() as Buffer)\n } else {\n const iovec = this[_queue]\n this[_queue] = []\n writev(this[_fd] as number, iovec, this[_pos] as number, (er, bw) =>\n this[_onwrite](er, bw),\n )\n }\n }\n\n [_close]() {\n if (this[_autoClose] && typeof this[_fd] === 'number') {\n const fd = this[_fd]\n this[_fd] = undefined\n fs.close(fd, er =>\n er ? this.emit('error', er) : this.emit('close'),\n )\n }\n }\n}\n\nexport class WriteStreamSync extends WriteStream {\n [_open](): void {\n let fd\n // only wrap in a try{} block if we know we'll retry, to avoid\n // the rethrow obscuring the error's source frame in most cases.\n if (this[_defaultFlag] && this[_flags] === 'r+') {\n try {\n fd = fs.openSync(this[_path], this[_flags], this[_mode])\n } catch (er) {\n if ((er as NodeJS.ErrnoException)?.code === 'ENOENT') {\n this[_flags] = 'w'\n return this[_open]()\n } else {\n throw er\n }\n }\n } else {\n fd = fs.openSync(this[_path], this[_flags], this[_mode])\n }\n\n this[_onopen](null, fd)\n }\n\n [_close]() {\n if (this[_autoClose] && typeof this[_fd] === 'number') {\n const fd = this[_fd]\n this[_fd] = undefined\n fs.closeSync(fd)\n this.emit('close')\n }\n }\n\n [_write](buf: Buffer) {\n // throw the original, but try to close if it fails\n let threw = true\n try {\n this[_onwrite](\n null,\n fs.writeSync(this[_fd] as number, buf, 0, buf.length, this[_pos]),\n )\n threw = false\n } finally {\n if (threw) {\n try {\n this[_close]()\n } catch {\n // ok error\n }\n }\n }\n }\n}\n", "const proc =\n typeof process === 'object' && process\n ? process\n : {\n stdout: null,\n stderr: null,\n }\nimport { EventEmitter } from 'node:events'\nimport Stream from 'node:stream'\nimport { StringDecoder } from 'node:string_decoder'\n\n/**\n * Same as StringDecoder, but exposing the `lastNeed` flag on the type\n */\ntype SD = StringDecoder & { lastNeed: boolean }\n\nexport type { SD, Pipe, PipeProxyErrors }\n\n/**\n * Return true if the argument is a Minipass stream, Node stream, or something\n * else that Minipass can interact with.\n */\nexport const isStream = (\n s: any\n): s is Minipass.Readable | Minipass.Writable =>\n !!s &&\n typeof s === 'object' &&\n (s instanceof Minipass ||\n s instanceof Stream ||\n isReadable(s) ||\n isWritable(s))\n\n/**\n * Return true if the argument is a valid {@link Minipass.Readable}\n */\nexport const isReadable = (s: any): s is Minipass.Readable =>\n !!s &&\n typeof s === 'object' &&\n s instanceof EventEmitter &&\n typeof (s as Minipass.Readable).pipe === 'function' &&\n // node core Writable streams have a pipe() method, but it throws\n (s as Minipass.Readable).pipe !== Stream.Writable.prototype.pipe\n\n/**\n * Return true if the argument is a valid {@link Minipass.Writable}\n */\nexport const isWritable = (s: any): s is Minipass.Readable =>\n !!s &&\n typeof s === 'object' &&\n s instanceof EventEmitter &&\n typeof (s as Minipass.Writable).write === 'function' &&\n typeof (s as Minipass.Writable).end === 'function'\n\nconst EOF = Symbol('EOF')\nconst MAYBE_EMIT_END = Symbol('maybeEmitEnd')\nconst EMITTED_END = Symbol('emittedEnd')\nconst EMITTING_END = Symbol('emittingEnd')\nconst EMITTED_ERROR = Symbol('emittedError')\nconst CLOSED = Symbol('closed')\nconst READ = Symbol('read')\nconst FLUSH = Symbol('flush')\nconst FLUSHCHUNK = Symbol('flushChunk')\nconst ENCODING = Symbol('encoding')\nconst DECODER = Symbol('decoder')\nconst FLOWING = Symbol('flowing')\nconst PAUSED = Symbol('paused')\nconst RESUME = Symbol('resume')\nconst BUFFER = Symbol('buffer')\nconst PIPES = Symbol('pipes')\nconst BUFFERLENGTH = Symbol('bufferLength')\nconst BUFFERPUSH = Symbol('bufferPush')\nconst BUFFERSHIFT = Symbol('bufferShift')\nconst OBJECTMODE = Symbol('objectMode')\n// internal event when stream is destroyed\nconst DESTROYED = Symbol('destroyed')\n// internal event when stream has an error\nconst ERROR = Symbol('error')\nconst EMITDATA = Symbol('emitData')\nconst EMITEND = Symbol('emitEnd')\nconst EMITEND2 = Symbol('emitEnd2')\nconst ASYNC = Symbol('async')\nconst ABORT = Symbol('abort')\nconst ABORTED = Symbol('aborted')\nconst SIGNAL = Symbol('signal')\nconst DATALISTENERS = Symbol('dataListeners')\nconst DISCARDED = Symbol('discarded')\n\nconst defer = (fn: (...a: any[]) => any) => Promise.resolve().then(fn)\nconst nodefer = (fn: (...a: any[]) => any) => fn()\n\n// events that mean 'the stream is over'\n// these are treated specially, and re-emitted\n// if they are listened for after emitting.\ntype EndishEvent = 'end' | 'finish' | 'prefinish'\nconst isEndish = (ev: any): ev is EndishEvent =>\n ev === 'end' || ev === 'finish' || ev === 'prefinish'\n\nconst isArrayBufferLike = (b: any): b is ArrayBufferLike =>\n b instanceof ArrayBuffer ||\n (!!b &&\n typeof b === 'object' &&\n b.constructor &&\n b.constructor.name === 'ArrayBuffer' &&\n b.byteLength >= 0)\n\nconst isArrayBufferView = (b: any): b is ArrayBufferView =>\n !Buffer.isBuffer(b) && ArrayBuffer.isView(b)\n\n/**\n * Options that may be passed to stream.pipe()\n */\nexport interface PipeOptions {\n /**\n * end the destination stream when the source stream ends\n */\n end?: boolean\n /**\n * proxy errors from the source stream to the destination stream\n */\n proxyErrors?: boolean\n}\n\n/**\n * Internal class representing a pipe to a destination stream.\n *\n * @internal\n */\nclass Pipe<T extends unknown> {\n src: Minipass<T>\n dest: Minipass<any, T>\n opts: PipeOptions\n ondrain: () => any\n constructor(\n src: Minipass<T>,\n dest: Minipass.Writable,\n opts: PipeOptions\n ) {\n this.src = src\n this.dest = dest as Minipass<any, T>\n this.opts = opts\n this.ondrain = () => src[RESUME]()\n this.dest.on('drain', this.ondrain)\n }\n unpipe() {\n this.dest.removeListener('drain', this.ondrain)\n }\n // only here for the prototype\n /* c8 ignore start */\n proxyErrors(_er: any) {}\n /* c8 ignore stop */\n end() {\n this.unpipe()\n if (this.opts.end) this.dest.end()\n }\n}\n\n/**\n * Internal class representing a pipe to a destination stream where\n * errors are proxied.\n *\n * @internal\n */\nclass PipeProxyErrors<T> extends Pipe<T> {\n unpipe() {\n this.src.removeListener('error', this.proxyErrors)\n super.unpipe()\n }\n constructor(\n src: Minipass<T>,\n dest: Minipass.Writable,\n opts: PipeOptions\n ) {\n super(src, dest, opts)\n this.proxyErrors = (er: Error) => this.dest.emit('error', er)\n src.on('error', this.proxyErrors)\n }\n}\n\nexport namespace Minipass {\n /**\n * Encoding used to create a stream that outputs strings rather than\n * Buffer objects.\n */\n export type Encoding = BufferEncoding | 'buffer' | null\n\n /**\n * Any stream that Minipass can pipe into\n */\n export type Writable =\n | Minipass<any, any, any>\n | NodeJS.WriteStream\n | (NodeJS.WriteStream & { fd: number })\n | (EventEmitter & {\n end(): any\n write(chunk: any, ...args: any[]): any\n })\n\n /**\n * Any stream that can be read from\n */\n export type Readable =\n | Minipass<any, any, any>\n | NodeJS.ReadStream\n | (NodeJS.ReadStream & { fd: number })\n | (EventEmitter & {\n pause(): any\n resume(): any\n pipe(...destArgs: any[]): any\n })\n\n /**\n * Utility type that can be iterated sync or async\n */\n export type DualIterable<T> = Iterable<T> & AsyncIterable<T>\n\n type EventArguments = Record<string | symbol, unknown[]>\n\n /**\n * The listing of events that a Minipass class can emit.\n * Extend this when extending the Minipass class, and pass as\n * the third template argument. The key is the name of the event,\n * and the value is the argument list.\n *\n * Any undeclared events will still be allowed, but the handler will get\n * arguments as `unknown[]`.\n */\n export interface Events<RType extends any = Buffer>\n extends EventArguments {\n readable: []\n data: [chunk: RType]\n error: [er: unknown]\n abort: [reason: unknown]\n drain: []\n resume: []\n end: []\n finish: []\n prefinish: []\n close: []\n [DESTROYED]: [er?: unknown]\n [ERROR]: [er: unknown]\n }\n\n /**\n * String or buffer-like data that can be joined and sliced\n */\n export type ContiguousData =\n | Buffer\n | ArrayBufferLike\n | ArrayBufferView\n | string\n export type BufferOrString = Buffer | string\n\n /**\n * Options passed to the Minipass constructor.\n */\n export type SharedOptions = {\n /**\n * Defer all data emission and other events until the end of the\n * current tick, similar to Node core streams\n */\n async?: boolean\n /**\n * A signal which will abort the stream\n */\n signal?: AbortSignal\n /**\n * Output string encoding. Set to `null` or `'buffer'` (or omit) to\n * emit Buffer objects rather than strings.\n *\n * Conflicts with `objectMode`\n */\n encoding?: BufferEncoding | null | 'buffer'\n /**\n * Output data exactly as it was written, supporting non-buffer/string\n * data (such as arbitrary objects, falsey values, etc.)\n *\n * Conflicts with `encoding`\n */\n objectMode?: boolean\n }\n\n /**\n * Options for a string encoded output\n */\n export type EncodingOptions = SharedOptions & {\n encoding: BufferEncoding\n objectMode?: false\n }\n\n /**\n * Options for contiguous data buffer output\n */\n export type BufferOptions = SharedOptions & {\n encoding?: null | 'buffer'\n objectMode?: false\n }\n\n /**\n * Options for objectMode arbitrary output\n */\n export type ObjectModeOptions = SharedOptions & {\n objectMode: true\n encoding?: null\n }\n\n /**\n * Utility type to determine allowed options based on read type\n */\n export type Options<T> =\n | ObjectModeOptions\n | (T extends string\n ? EncodingOptions\n : T extends Buffer\n ? BufferOptions\n : SharedOptions)\n}\n\nconst isObjectModeOptions = (\n o: Minipass.SharedOptions\n): o is Minipass.ObjectModeOptions => !!o.objectMode\n\nconst isEncodingOptions = (\n o: Minipass.SharedOptions\n): o is Minipass.EncodingOptions =>\n !o.objectMode && !!o.encoding && o.encoding !== 'buffer'\n\n/**\n * Main export, the Minipass class\n *\n * `RType` is the type of data emitted, defaults to Buffer\n *\n * `WType` is the type of data to be written, if RType is buffer or string,\n * then any {@link Minipass.ContiguousData} is allowed.\n *\n * `Events` is the set of event handler signatures that this object\n * will emit, see {@link Minipass.Events}\n */\nexport class Minipass<\n RType extends unknown = Buffer,\n WType extends unknown = RType extends Minipass.BufferOrString\n ? Minipass.ContiguousData\n : RType,\n Events extends Minipass.Events<RType> = Minipass.Events<RType>\n >\n extends EventEmitter\n implements Minipass.DualIterable<RType>\n{\n [FLOWING]: boolean = false;\n [PAUSED]: boolean = false;\n [PIPES]: Pipe<RType>[] = [];\n [BUFFER]: RType[] = [];\n [OBJECTMODE]: boolean;\n [ENCODING]: BufferEncoding | null;\n [ASYNC]: boolean;\n [DECODER]: SD | null;\n [EOF]: boolean = false;\n [EMITTED_END]: boolean = false;\n [EMITTING_END]: boolean = false;\n [CLOSED]: boolean = false;\n [EMITTED_ERROR]: unknown = null;\n [BUFFERLENGTH]: number = 0;\n [DESTROYED]: boolean = false;\n [SIGNAL]?: AbortSignal;\n [ABORTED]: boolean = false;\n [DATALISTENERS]: number = 0;\n [DISCARDED]: boolean = false\n\n /**\n * true if the stream can be written\n */\n writable: boolean = true\n /**\n * true if the stream can be read\n */\n readable: boolean = true\n\n /**\n * If `RType` is Buffer, then options do not need to be provided.\n * Otherwise, an options object must be provided to specify either\n * {@link Minipass.SharedOptions.objectMode} or\n * {@link Minipass.SharedOptions.encoding}, as appropriate.\n */\n constructor(\n ...args:\n | [Minipass.ObjectModeOptions]\n | (RType extends Buffer\n ? [] | [Minipass.Options<RType>]\n : [Minipass.Options<RType>])\n ) {\n const options: Minipass.Options<RType> = (args[0] ||\n {}) as Minipass.Options<RType>\n super()\n if (options.objectMode && typeof options.encoding === 'string') {\n throw new TypeError(\n 'Encoding and objectMode may not be used together'\n )\n }\n if (isObjectModeOptions(options)) {\n this[OBJECTMODE] = true\n this[ENCODING] = null\n } else if (isEncodingOptions(options)) {\n this[ENCODING] = options.encoding\n this[OBJECTMODE] = false\n } else {\n this[OBJECTMODE] = false\n this[ENCODING] = null\n }\n this[ASYNC] = !!options.async\n this[DECODER] = this[ENCODING]\n ? (new StringDecoder(this[ENCODING]) as SD)\n : null\n\n //@ts-ignore - private option for debugging and testing\n if (options && options.debugExposeBuffer === true) {\n Object.defineProperty(this, 'buffer', { get: () => this[BUFFER] })\n }\n //@ts-ignore - private option for debugging and testing\n if (options && options.debugExposePipes === true) {\n Object.defineProperty(this, 'pipes', { get: () => this[PIPES] })\n }\n\n const { signal } = options\n if (signal) {\n this[SIGNAL] = signal\n if (signal.aborted) {\n this[ABORT]()\n } else {\n signal.addEventListener('abort', () => this[ABORT]())\n }\n }\n }\n\n /**\n * The amount of data stored in the buffer waiting to be read.\n *\n * For Buffer strings, this will be the total byte length.\n * For string encoding streams, this will be the string character length,\n * according to JavaScript's `string.length` logic.\n * For objectMode streams, this is a count of the items waiting to be\n * emitted.\n */\n get bufferLength() {\n return this[BUFFERLENGTH]\n }\n\n /**\n * The `BufferEncoding` currently in use, or `null`\n */\n get encoding() {\n return this[ENCODING]\n }\n\n /**\n * @deprecated - This is a read only property\n */\n set encoding(_enc) {\n throw new Error('Encoding must be set at instantiation time')\n }\n\n /**\n * @deprecated - Encoding may only be set at instantiation time\n */\n setEncoding(_enc: Minipass.Encoding) {\n throw new Error('Encoding must be set at instantiation time')\n }\n\n /**\n * True if this is an objectMode stream\n */\n get objectMode() {\n return this[OBJECTMODE]\n }\n\n /**\n * @deprecated - This is a read-only property\n */\n set objectMode(_om) {\n throw new Error('objectMode must be set at instantiation time')\n }\n\n /**\n * true if this is an async stream\n */\n get ['async'](): boolean {\n return this[ASYNC]\n }\n /**\n * Set to true to make this stream async.\n *\n * Once set, it cannot be unset, as this would potentially cause incorrect\n * behavior. Ie, a sync stream can be made async, but an async stream\n * cannot be safely made sync.\n */\n set ['async'](a: boolean) {\n this[ASYNC] = this[ASYNC] || !!a\n }\n\n // drop everything and get out of the flow completely\n [ABORT]() {\n this[ABORTED] = true\n this.emit('abort', this[SIGNAL]?.reason)\n this.destroy(this[SIGNAL]?.reason)\n }\n\n /**\n * True if the stream has been aborted.\n */\n get aborted() {\n return this[ABORTED]\n }\n /**\n * No-op setter. Stream aborted status is set via the AbortSignal provided\n * in the constructor options.\n */\n set aborted(_) {}\n\n /**\n * Write data into the stream\n *\n * If the chunk written is a string, and encoding is not specified, then\n * `utf8` will be assumed. If the stream encoding matches the encoding of\n * a written string, and the state of the string decoder allows it, then\n * the string will be passed through to either the output or the internal\n * buffer without any processing. Otherwise, it will be turned into a\n * Buffer object for processing into the desired encoding.\n *\n * If provided, `cb` function is called immediately before return for\n * sync streams, or on next tick for async streams, because for this\n * base class, a chunk is considered \"processed\" once it is accepted\n * and either emitted or buffered. That is, the callback does not indicate\n * that the chunk has been eventually emitted, though of course child\n * classes can override this function to do whatever processing is required\n * and call `super.write(...)` only once processing is completed.\n */\n write(chunk: WType, cb?: () => void): boolean\n write(\n chunk: WType,\n encoding?: Minipass.Encoding,\n cb?: () => void\n ): boolean\n write(\n chunk: WType,\n encoding?: Minipass.Encoding | (() => void),\n cb?: () => void\n ): boolean {\n if (this[ABORTED]) return false\n if (this[EOF]) throw new Error('write after end')\n\n if (this[DESTROYED]) {\n this.emit(\n 'error',\n Object.assign(\n new Error('Cannot call write after a stream was destroyed'),\n { code: 'ERR_STREAM_DESTROYED' }\n )\n )\n return true\n }\n\n if (typeof encoding === 'function') {\n cb = encoding\n encoding = 'utf8'\n }\n\n if (!encoding) encoding = 'utf8'\n\n const fn = this[ASYNC] ? defer : nodefer\n\n // convert array buffers and typed array views into buffers\n // at some point in the future, we may want to do the opposite!\n // leave strings and buffers as-is\n // anything is only allowed if in object mode, so throw\n if (!this[OBJECTMODE] && !Buffer.isBuffer(chunk)) {\n if (isArrayBufferView(chunk)) {\n //@ts-ignore - sinful unsafe type changing\n chunk = Buffer.from(\n chunk.buffer,\n chunk.byteOffset,\n chunk.byteLength\n )\n } else if (isArrayBufferLike(chunk)) {\n //@ts-ignore - sinful unsafe type changing\n chunk = Buffer.from(chunk)\n } else if (typeof chunk !== 'string') {\n throw new Error(\n 'Non-contiguous data written to non-objectMode stream'\n )\n }\n }\n\n // handle object mode up front, since it's simpler\n // this yields better performance, fewer checks later.\n if (this[OBJECTMODE]) {\n // maybe impossible?\n /* c8 ignore start */\n if (this[FLOWING] && this[BUFFERLENGTH] !== 0) this[FLUSH](true)\n /* c8 ignore stop */\n\n if (this[FLOWING]) this.emit('data', chunk as unknown as RType)\n else this[BUFFERPUSH](chunk as unknown as RType)\n\n if (this[BUFFERLENGTH] !== 0) this.emit('readable')\n\n if (cb) fn(cb)\n\n return this[FLOWING]\n }\n\n // at this point the chunk is a buffer or string\n // don't buffer it up or send it to the decoder\n if (!(chunk as Minipass.BufferOrString).length) {\n if (this[BUFFERLENGTH] !== 0) this.emit('readable')\n if (cb) fn(cb)\n return this[FLOWING]\n }\n\n // fast-path writing strings of same encoding to a stream with\n // an empty buffer, skipping the buffer/decoder dance\n if (\n typeof chunk === 'string' &&\n // unless it is a string already ready for us to use\n !(encoding === this[ENCODING] && !this[DECODER]?.lastNeed)\n ) {\n //@ts-ignore - sinful unsafe type change\n chunk = Buffer.from(chunk, encoding)\n }\n\n if (Buffer.isBuffer(chunk) && this[ENCODING]) {\n //@ts-ignore - sinful unsafe type change\n chunk = this[DECODER].write(chunk)\n }\n\n // Note: flushing CAN potentially switch us into not-flowing mode\n if (this[FLOWING] && this[BUFFERLENGTH] !== 0) this[FLUSH](true)\n\n if (this[FLOWING]) this.emit('data', chunk as unknown as RType)\n else this[BUFFERPUSH](chunk as unknown as RType)\n\n if (this[BUFFERLENGTH] !== 0) this.emit('readable')\n\n if (cb) fn(cb)\n\n return this[FLOWING]\n }\n\n /**\n * Low-level explicit read method.\n *\n * In objectMode, the argument is ignored, and one item is returned if\n * available.\n *\n * `n` is the number of bytes (or in the case of encoding streams,\n * characters) to consume. If `n` is not provided, then the entire buffer\n * is returned, or `null` is returned if no data is available.\n *\n * If `n` is greater that the amount of data in the internal buffer,\n * then `null` is returned.\n */\n read(n?: number | null): RType | null {\n if (this[DESTROYED]) return null\n this[DISCARDED] = false\n\n if (\n this[BUFFERLENGTH] === 0 ||\n n === 0 ||\n (n && n > this[BUFFERLENGTH])\n ) {\n this[MAYBE_EMIT_END]()\n return null\n }\n\n if (this[OBJECTMODE]) n = null\n\n if (this[BUFFER].length > 1 && !this[OBJECTMODE]) {\n // not object mode, so if we have an encoding, then RType is string\n // otherwise, must be Buffer\n this[BUFFER] = [\n (this[ENCODING]\n ? this[BUFFER].join('')\n : Buffer.concat(\n this[BUFFER] as Buffer[],\n this[BUFFERLENGTH]\n )) as RType,\n ]\n }\n\n const ret = this[READ](n || null, this[BUFFER][0] as RType)\n this[MAYBE_EMIT_END]()\n return ret\n }\n\n [READ](n: number | null, chunk: RType) {\n if (this[OBJECTMODE]) this[BUFFERSHIFT]()\n else {\n const c = chunk as Minipass.BufferOrString\n if (n === c.length || n === null) this[BUFFERSHIFT]()\n else if (typeof c === 'string') {\n this[BUFFER][0] = c.slice(n) as RType\n chunk = c.slice(0, n) as RType\n this[BUFFERLENGTH] -= n\n } else {\n this[BUFFER][0] = c.subarray(n) as RType\n chunk = c.subarray(0, n) as RType\n this[BUFFERLENGTH] -= n\n }\n }\n\n this.emit('data', chunk)\n\n if (!this[BUFFER].length && !this[EOF]) this.emit('drain')\n\n return chunk\n }\n\n /**\n * End the stream, optionally providing a final write.\n *\n * See {@link Minipass#write} for argument descriptions\n */\n end(cb?: () => void): this\n end(chunk: WType, cb?: () => void): this\n end(chunk: WType, encoding?: Minipass.Encoding, cb?: () => void): this\n end(\n chunk?: WType | (() => void),\n encoding?: Minipass.Encoding | (() => void),\n cb?: () => void\n ): this {\n if (typeof chunk === 'function') {\n cb = chunk as () => void\n chunk = undefined\n }\n if (typeof encoding === 'function') {\n cb = encoding\n encoding = 'utf8'\n }\n if (chunk !== undefined) this.write(chunk, encoding)\n if (cb) this.once('end', cb)\n this[EOF] = true\n this.writable = false\n\n // if we haven't written anything, then go ahead and emit,\n // even if we're not reading.\n // we'll re-emit if a new 'end' listener is added anyway.\n // This makes MP more suitable to write-only use cases.\n if (this[FLOWING] || !this[PAUSED]) this[MAYBE_EMIT_END]()\n return this\n }\n\n // don't let the internal resume be overwritten\n [RESUME]() {\n if (this[DESTROYED]) return\n\n if (!this[DATALISTENERS] && !this[PIPES].length) {\n this[DISCARDED] = true\n }\n this[PAUSED] = false\n this[FLOWING] = true\n this.emit('resume')\n if (this[BUFFER].length) this[FLUSH]()\n else if (this[EOF]) this[MAYBE_EMIT_END]()\n else this.emit('drain')\n }\n\n /**\n * Resume the stream if it is currently in a paused state\n *\n * If called when there are no pipe destinations or `data` event listeners,\n * this will place the stream in a \"discarded\" state, where all data will\n * be thrown away. The discarded state is removed if a pipe destination or\n * data handler is added, if pause() is called, or if any synchronous or\n * asynchronous iteration is started.\n */\n resume() {\n return this[RESUME]()\n }\n\n /**\n * Pause the stream\n */\n pause() {\n this[FLOWING] = false\n this[PAUSED] = true\n this[DISCARDED] = false\n }\n\n /**\n * true if the stream has been forcibly destroyed\n */\n get destroyed() {\n return this[DESTROYED]\n }\n\n /**\n * true if the stream is currently in a flowing state, meaning that\n * any writes will be immediately emitted.\n */\n get flowing() {\n return this[FLOWING]\n }\n\n /**\n * true if the stream is currently in a paused state\n */\n get paused() {\n return this[PAUSED]\n }\n\n [BUFFERPUSH](chunk: RType) {\n if (this[OBJECTMODE]) this[BUFFERLENGTH] += 1\n else this[BUFFERLENGTH] += (chunk as Minipass.BufferOrString).length\n this[BUFFER].push(chunk)\n }\n\n [BUFFERSHIFT](): RType {\n if (this[OBJECTMODE]) this[BUFFERLENGTH] -= 1\n else\n this[BUFFERLENGTH] -= (\n this[BUFFER][0] as Minipass.BufferOrString\n ).length\n return this[BUFFER].shift() as RType\n }\n\n [FLUSH](noDrain: boolean = false) {\n do {} while (\n this[FLUSHCHUNK](this[BUFFERSHIFT]()) &&\n this[BUFFER].length\n )\n\n if (!noDrain && !this[BUFFER].length && !this[EOF]) this.emit('drain')\n }\n\n [FLUSHCHUNK](chunk: RType) {\n this.emit('data', chunk)\n return this[FLOWING]\n }\n\n /**\n * Pipe all data emitted by this stream into the destination provided.\n *\n * Triggers the flow of data.\n */\n pipe<W extends Minipass.Writable>(dest: W, opts?: PipeOptions): W {\n if (this[DESTROYED]) return dest\n this[DISCARDED] = false\n\n const ended = this[EMITTED_END]\n opts = opts || {}\n if (dest === proc.stdout || dest === proc.stderr) opts.end = false\n else opts.end = opts.end !== false\n opts.proxyErrors = !!opts.proxyErrors\n\n // piping an ended stream ends immediately\n if (ended) {\n if (opts.end) dest.end()\n } else {\n // \"as\" here just ignores the WType, which pipes don't care about,\n // since they're only consuming from us, and writing to the dest\n this[PIPES].push(\n !opts.proxyErrors\n ? new Pipe<RType>(this as Minipass<RType>, dest, opts)\n : new PipeProxyErrors<RType>(this as Minipass<RType>, dest, opts)\n )\n if (this[ASYNC]) defer(() => this[RESUME]())\n else this[RESUME]()\n }\n\n return dest\n }\n\n /**\n * Fully unhook a piped destination stream.\n *\n * If the destination stream was the only consumer of this stream (ie,\n * there are no other piped destinations or `'data'` event listeners)\n * then the flow of data will stop until there is another consumer or\n * {@link Minipass#resume} is explicitly called.\n */\n unpipe<W extends Minipass.Writable>(dest: W) {\n const p = this[PIPES].find(p => p.dest === dest)\n if (p) {\n if (this[PIPES].length === 1) {\n if (this[FLOWING] && this[DATALISTENERS] === 0) {\n this[FLOWING] = false\n }\n this[PIPES] = []\n } else this[PIPES].splice(this[PIPES].indexOf(p), 1)\n p.unpipe()\n }\n }\n\n /**\n * Alias for {@link Minipass#on}\n */\n addListener<Event extends keyof Events>(\n ev: Event,\n handler: (...args: Events[Event]) => any\n ): this {\n return this.on(ev, handler)\n }\n\n /**\n * Mostly identical to `EventEmitter.on`, with the following\n * behavior differences to prevent data loss and unnecessary hangs:\n *\n * - Adding a 'data' event handler will trigger the flow of data\n *\n * - Adding a 'readable' event handler when there is data waiting to be read\n * will cause 'readable' to be emitted immediately.\n *\n * - Adding an 'endish' event handler ('end', 'finish', etc.) which has\n * already passed will cause the event to be emitted immediately and all\n * handlers removed.\n *\n * - Adding an 'error' event handler after an error has been emitted will\n * cause the event to be re-emitted immediately with the error previously\n * raised.\n */\n on<Event extends keyof Events>(\n ev: Event,\n handler: (...args: Events[Event]) => any\n ): this {\n const ret = super.on(\n ev as string | symbol,\n handler as (...a: any[]) => any\n )\n if (ev === 'data') {\n this[DISCARDED] = false\n this[DATALISTENERS]++\n if (!this[PIPES].length && !this[FLOWING]) {\n this[RESUME]()\n }\n } else if (ev === 'readable' && this[BUFFERLENGTH] !== 0) {\n super.emit('readable')\n } else if (isEndish(ev) && this[EMITTED_END]) {\n super.emit(ev)\n this.removeAllListeners(ev)\n } else if (ev === 'error' && this[EMITTED_ERROR]) {\n const h = handler as (...a: Events['error']) => any\n if (this[ASYNC]) defer(() => h.call(this, this[EMITTED_ERROR]))\n else h.call(this, this[EMITTED_ERROR])\n }\n return ret\n }\n\n /**\n * Alias for {@link Minipass#off}\n */\n removeListener<Event extends keyof Events>(\n ev: Event,\n handler: (...args: Events[Event]) => any\n ) {\n return this.off(ev, handler)\n }\n\n /**\n * Mostly identical to `EventEmitter.off`\n *\n * If a 'data' event handler is removed, and it was the last consumer\n * (ie, there are no pipe destinations or other 'data' event listeners),\n * then the flow of data will stop until there is another consumer or\n * {@link Minipass#resume} is explicitly called.\n */\n off<Event extends keyof Events>(\n ev: Event,\n handler: (...args: Events[Event]) => any\n ) {\n const ret = super.off(\n ev as string | symbol,\n handler as (...a: any[]) => any\n )\n // if we previously had listeners, and now we don't, and we don't\n // have any pipes, then stop the flow, unless it's been explicitly\n // put in a discarded flowing state via stream.resume().\n if (ev === 'data') {\n this[DATALISTENERS] = this.listeners('data').length\n if (\n this[DATALISTENERS] === 0 &&\n !this[DISCARDED] &&\n !this[PIPES].length\n ) {\n this[FLOWING] = false\n }\n }\n return ret\n }\n\n /**\n * Mostly identical to `EventEmitter.removeAllListeners`\n *\n * If all 'data' event handlers are removed, and they were the last consumer\n * (ie, there are no pipe destinations), then the flow of data will stop\n * until there is another consumer or {@link Minipass#resume} is explicitly\n * called.\n */\n removeAllListeners<Event extends keyof Events>(ev?: Event) {\n const ret = super.removeAllListeners(ev as string | symbol | undefined)\n if (ev === 'data' || ev === undefined) {\n this[DATALISTENERS] = 0\n if (!this[DISCARDED] && !this[PIPES].length) {\n this[FLOWING] = false\n }\n }\n return ret\n }\n\n /**\n * true if the 'end' event has been emitted\n */\n get emittedEnd() {\n return this[EMITTED_END]\n }\n\n [MAYBE_EMIT_END]() {\n if (\n !this[EMITTING_END] &&\n !this[EMITTED_END] &&\n !this[DESTROYED] &&\n this[BUFFER].length === 0 &&\n this[EOF]\n ) {\n this[EMITTING_END] = true\n this.emit('end')\n this.emit('prefinish')\n this.emit('finish')\n if (this[CLOSED]) this.emit('close')\n this[EMITTING_END] = false\n }\n }\n\n /**\n * Mostly identical to `EventEmitter.emit`, with the following\n * behavior differences to prevent data loss and unnecessary hangs:\n *\n * If the stream has been destroyed, and the event is something other\n * than 'close' or 'error', then `false` is returned and no handlers\n * are called.\n *\n * If the event is 'end', and has already been emitted, then the event\n * is ignored. If the stream is in a paused or non-flowing state, then\n * the event will be deferred until data flow resumes. If the stream is\n * async, then handlers will be called on the next tick rather than\n * immediately.\n *\n * If the event is 'close', and 'end' has not yet been emitted, then\n * the event will be deferred until after 'end' is emitted.\n *\n * If the event is 'error', and an AbortSignal was provided for the stream,\n * and there are no listeners, then the event is ignored, matching the\n * behavior of node core streams in the presense of an AbortSignal.\n *\n * If the event is 'finish' or 'prefinish', then all listeners will be\n * removed after emitting the event, to prevent double-firing.\n */\n emit<Event extends keyof Events>(\n ev: Event,\n ...args: Events[Event]\n ): boolean {\n const data = args[0]\n // error and close are only events allowed after calling destroy()\n if (\n ev !== 'error' &&\n ev !== 'close' &&\n ev !== DESTROYED &&\n this[DESTROYED]\n ) {\n return false\n } else if (ev === 'data') {\n return !this[OBJECTMODE] && !data\n ? false\n : this[ASYNC]\n ? (defer(() => this[EMITDATA](data as RType)), true)\n : this[EMITDATA](data as RType)\n } else if (ev === 'end') {\n return this[EMITEND]()\n } else if (ev === 'close') {\n this[CLOSED] = true\n // don't emit close before 'end' and 'finish'\n if (!this[EMITTED_END] && !this[DESTROYED]) return false\n const ret = super.emit('close')\n this.removeAllListeners('close')\n return ret\n } else if (ev === 'error') {\n this[EMITTED_ERROR] = data\n super.emit(ERROR, data)\n const ret =\n !this[SIGNAL] || this.listeners('error').length\n ? super.emit('error', data)\n : false\n this[MAYBE_EMIT_END]()\n return ret\n } else if (ev === 'resume') {\n const ret = super.emit('resume')\n this[MAYBE_EMIT_END]()\n return ret\n } else if (ev === 'finish' || ev === 'prefinish') {\n const ret = super.emit(ev)\n this.removeAllListeners(ev)\n return ret\n }\n\n // Some other unknown event\n const ret = super.emit(ev as string, ...args)\n this[MAYBE_EMIT_END]()\n return ret\n }\n\n [EMITDATA](data: RType) {\n for (const p of this[PIPES]) {\n if (p.dest.write(data as RType) === false) this.pause()\n }\n const ret = this[DISCARDED] ? false : super.emit('data', data)\n this[MAYBE_EMIT_END]()\n return ret\n }\n\n [EMITEND]() {\n if (this[EMITTED_END]) return false\n\n this[EMITTED_END] = true\n this.readable = false\n return this[ASYNC]\n ? (defer(() => this[EMITEND2]()), true)\n : this[EMITEND2]()\n }\n\n [EMITEND2]() {\n if (this[DECODER]) {\n const data = this[DECODER].end()\n if (data) {\n for (const p of this[PIPES]) {\n p.dest.write(data as RType)\n }\n if (!this[DISCARDED]) super.emit('data', data)\n }\n }\n\n for (const p of this[PIPES]) {\n p.end()\n }\n const ret = super.emit('end')\n this.removeAllListeners('end')\n return ret\n }\n\n /**\n * Return a Promise that resolves to an array of all emitted data once\n * the stream ends.\n */\n async collect(): Promise<RType[] & { dataLength: number }> {\n const buf: RType[] & { dataLength: number } = Object.assign([], {\n dataLength: 0,\n })\n if (!this[OBJECTMODE]) buf.dataLength = 0\n // set the promise first, in case an error is raised\n // by triggering the flow here.\n const p = this.promise()\n this.on('data', c => {\n buf.push(c)\n if (!this[OBJECTMODE])\n buf.dataLength += (c as Minipass.BufferOrString).length\n })\n await p\n return buf\n }\n\n /**\n * Return a Promise that resolves to the concatenation of all emitted data\n * once the stream ends.\n *\n * Not allowed on objectMode streams.\n */\n async concat(): Promise<RType> {\n if (this[OBJECTMODE]) {\n throw new Error('cannot concat in objectMode')\n }\n const buf = await this.collect()\n return (\n this[ENCODING]\n ? buf.join('')\n : Buffer.concat(buf as Buffer[], buf.dataLength)\n ) as RType\n }\n\n /**\n * Return a void Promise that resolves once the stream ends.\n */\n async promise(): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n this.on(DESTROYED, () => reject(new Error('stream destroyed')))\n this.on('error', er => reject(er))\n this.on('end', () => resolve())\n })\n }\n\n /**\n * Asynchronous `for await of` iteration.\n *\n * This will continue emitting all chunks until the stream terminates.\n */\n [Symbol.asyncIterator](): AsyncGenerator<RType, void, void> {\n // set this up front, in case the consumer doesn't call next()\n // right away.\n this[DISCARDED] = false\n let stopped = false\n const stop = async (): Promise<IteratorReturnResult<void>> => {\n this.pause()\n stopped = true\n return { value: undefined, done: true }\n }\n const next = (): Promise<IteratorResult<RType, void>> => {\n if (stopped) return stop()\n const res = this.read()\n if (res !== null) return Promise.resolve({ done: false, value: res })\n\n if (this[EOF]) return stop()\n\n let resolve!: (res: IteratorResult<RType>) => void\n let reject!: (er: unknown) => void\n const onerr = (er: unknown) => {\n this.off('data', ondata)\n this.off('end', onend)\n this.off(DESTROYED, ondestroy)\n stop()\n reject(er)\n }\n const ondata = (value: RType) => {\n this.off('error', onerr)\n this.off('end', onend)\n this.off(DESTROYED, ondestroy)\n this.pause()\n resolve({ value, done: !!this[EOF] })\n }\n const onend = () => {\n this.off('error', onerr)\n this.off('data', ondata)\n this.off(DESTROYED, ondestroy)\n stop()\n resolve({ done: true, value: undefined })\n }\n const ondestroy = () => onerr(new Error('stream destroyed'))\n return new Promise<IteratorResult<RType>>((res, rej) => {\n reject = rej\n resolve = res\n this.once(DESTROYED, ondestroy)\n this.once('error', onerr)\n this.once('end', onend)\n this.once('data', ondata)\n })\n }\n\n return {\n next,\n throw: stop,\n return: stop,\n [Symbol.asyncIterator]() {\n return this\n },\n [Symbol.asyncDispose]: async () => {},\n }\n }\n\n /**\n * Synchronous `for of` iteration.\n *\n * The iteration will terminate when the internal buffer runs out, even\n * if the stream has not yet terminated.\n */\n [Symbol.iterator](): Generator<RType, void, void> {\n // set this up front, in case the consumer doesn't call next()\n // right away.\n this[DISCARDED] = false\n let stopped = false\n const stop = (): IteratorReturnResult<void> => {\n this.pause()\n this.off(ERROR, stop)\n this.off(DESTROYED, stop)\n this.off('end', stop)\n stopped = true\n return { done: true, value: undefined }\n }\n\n const next = (): IteratorResult<RType, void> => {\n if (stopped) return stop()\n const value = this.read()\n return value === null ? stop() : { done: false, value }\n }\n\n this.once('end', stop)\n this.once(ERROR, stop)\n this.once(DESTROYED, stop)\n\n return {\n next,\n throw: stop,\n return: stop,\n [Symbol.iterator]() {\n return this\n },\n [Symbol.dispose]: () => {},\n }\n }\n\n /**\n * Destroy a stream, preventing it from being used for any further purpose.\n *\n * If the stream has a `close()` method, then it will be called on\n * destruction.\n *\n * After destruction, any attempt to write data, read data, or emit most\n * events will be ignored.\n *\n * If an error argument is provided, then it will be emitted in an\n * 'error' event.\n */\n destroy(er?: unknown) {\n if (this[DESTROYED]) {\n if (er) this.emit('error', er)\n else this.emit(DESTROYED)\n return this\n }\n\n this[DESTROYED] = true\n this[DISCARDED] = true\n\n // throw away all buffered data, it's never coming out\n this[BUFFER].length = 0\n this[BUFFERLENGTH] = 0\n\n const wc = this as Minipass<RType, WType, Events> & {\n close?: () => void\n }\n if (typeof wc.close === 'function' && !this[CLOSED]) wc.close()\n\n if (er) this.emit('error', er)\n // if no error to emit, still reject pending promises\n else this.emit(DESTROYED)\n\n return this\n }\n\n /**\n * Alias for {@link isStream}\n *\n * Former export location, maintained for backwards compatibility.\n *\n * @deprecated\n */\n static get isStream() {\n return isStream\n }\n}\n", "import { WriteStream, WriteStreamSync } from '@isaacs/fs-minipass'\nimport type { Minipass } from 'minipass'\nimport path from 'node:path'\nimport { list } from './list.js'\nimport { makeCommand } from './make-command.js'\nimport type {\n TarOptions,\n TarOptionsFile,\n TarOptionsSync,\n TarOptionsSyncFile,\n} from './options.js'\nimport { Pack, PackSync } from './pack.js'\n\nconst createFileSync = (opt: TarOptionsSyncFile, files: string[]) => {\n const p = new PackSync(opt)\n const stream = new WriteStreamSync(opt.file, {\n mode: opt.mode || 0o666,\n })\n p.pipe(stream as unknown as Minipass.Writable)\n addFilesSync(p, files)\n}\n\nconst createFile = (opt: TarOptionsFile, files: string[]) => {\n const p = new Pack(opt)\n const stream = new WriteStream(opt.file, {\n mode: opt.mode || 0o666,\n })\n p.pipe(stream as unknown as Minipass.Writable)\n\n const promise = new Promise<void>((res, rej) => {\n stream.on('error', rej)\n stream.on('close', res)\n p.on('error', rej)\n })\n\n addFilesAsync(p, files).catch(er => p.emit('error', er))\n\n return promise\n}\n\nconst addFilesSync = (p: PackSync, files: string[]) => {\n files.forEach(file => {\n if (file.charAt(0) === '@') {\n list({\n file: path.resolve(p.cwd, file.slice(1)),\n sync: true,\n noResume: true,\n onReadEntry: entry => p.add(entry),\n })\n } else {\n p.add(file)\n }\n })\n p.end()\n}\n\nconst addFilesAsync = async (p: Pack, files: string[]): Promise<void> => {\n for (const file of files) {\n if (file.charAt(0) === '@') {\n await list({\n file: path.resolve(String(p.cwd), file.slice(1)),\n noResume: true,\n onReadEntry: entry => {\n p.add(entry)\n },\n })\n } else {\n p.add(file)\n }\n }\n p.end()\n}\n\nconst createSync = (opt: TarOptionsSync, files: string[]) => {\n const p = new PackSync(opt)\n addFilesSync(p, files)\n return p\n}\n\nconst createAsync = (opt: TarOptions, files: string[]) => {\n const p = new Pack(opt)\n addFilesAsync(p, files).catch(er => p.emit('error', er))\n return p\n}\n\nexport const create = makeCommand(\n createFileSync,\n createFile,\n createSync,\n createAsync,\n (_opt, files) => {\n if (!files?.length) {\n throw new TypeError('no paths specified to add to archive')\n }\n },\n)\n", "// tar -t\nimport * as fsm from '@isaacs/fs-minipass'\nimport fs from 'node:fs'\nimport { dirname, parse } from 'path'\nimport { makeCommand } from './make-command.js'\nimport type {\n TarOptions,\n TarOptionsFile,\n TarOptionsSyncFile,\n} from './options.js'\nimport { Parser } from './parse.js'\nimport { stripTrailingSlashes } from './strip-trailing-slashes.js'\n\nconst onReadEntryFunction = (opt: TarOptions) => {\n const onReadEntry = opt.onReadEntry\n opt.onReadEntry =\n onReadEntry ?\n e => {\n onReadEntry(e)\n e.resume()\n }\n : e => e.resume()\n}\n\n// construct a filter that limits the file entries listed\n// include child entries if a dir is included\nexport const filesFilter = (opt: TarOptions, files: string[]) => {\n const map = new Map<string, boolean>(\n files.map(f => [stripTrailingSlashes(f), true]),\n )\n const filter = opt.filter\n\n // limit recursion to 100 levels\n const MAX = 100\n const mapHas = (file: string, r: string = '', depth = 0): boolean => {\n /* c8 ignore start - excessive caution */\n if (depth >= MAX) {\n map.set(file, false)\n return false\n }\n /* c8 ignore stop */\n const root = r || parse(file).root || '.'\n let ret: boolean\n if (file === root) ret = false\n else {\n const m = map.get(file)\n ret = m !== undefined ? m : mapHas(dirname(file), root, depth + 1)\n }\n\n map.set(file, ret)\n return ret\n }\n\n opt.filter =\n filter ?\n (file, entry) =>\n filter(file, entry) && mapHas(stripTrailingSlashes(file))\n : file => mapHas(stripTrailingSlashes(file))\n}\n\nconst listFileSync = (opt: TarOptionsSyncFile) => {\n const p = new Parser(opt)\n const file = opt.file\n let fd: number | undefined\n try {\n fd = fs.openSync(file, 'r')\n const stat: fs.Stats = fs.fstatSync(fd)\n const readSize: number = opt.maxReadSize || 16 * 1024 * 1024\n if (stat.size < readSize) {\n const buf = Buffer.allocUnsafe(stat.size)\n const read = fs.readSync(fd, buf, 0, stat.size, 0)\n p.end(read === buf.byteLength ? buf : buf.subarray(0, read))\n } else {\n let pos = 0\n const buf = Buffer.allocUnsafe(readSize)\n while (pos < stat.size) {\n const bytesRead = fs.readSync(fd, buf, 0, readSize, pos)\n if (bytesRead === 0) break\n pos += bytesRead\n p.write(buf.subarray(0, bytesRead))\n }\n p.end()\n }\n } finally {\n if (typeof fd === 'number') {\n try {\n fs.closeSync(fd)\n /* c8 ignore next */\n } catch {}\n }\n }\n}\n\nconst listFile = (\n opt: TarOptionsFile,\n _files: string[],\n): Promise<void> => {\n const parse = new Parser(opt)\n const readSize = opt.maxReadSize || 16 * 1024 * 1024\n\n const file = opt.file\n const p = new Promise<void>((resolve, reject) => {\n parse.on('error', reject)\n parse.on('end', resolve)\n\n fs.stat(file, (er, stat) => {\n if (er) {\n reject(er)\n } else {\n const stream = new fsm.ReadStream(file, {\n readSize: readSize,\n size: stat.size,\n })\n stream.on('error', reject)\n stream.pipe(parse)\n }\n })\n })\n return p\n}\n\nexport const list = makeCommand(\n listFileSync,\n listFile,\n opt => new Parser(opt) as Parser & { sync: true },\n opt => new Parser(opt),\n (opt, files) => {\n if (files?.length) filesFilter(opt, files)\n if (!opt.noResume) onReadEntryFunction(opt)\n },\n)\n", "// turn tar(1) style args like `C` into the more verbose things like `cwd`\n\nimport { type GzipOptions, type ZlibOptions } from 'minizlib'\nimport { type Stats } from 'node:fs'\nimport { type ReadEntry } from './read-entry.js'\nimport { type WarnData } from './warn-method.js'\nimport type { WriteEntry } from './write-entry.js'\n\nconst argmap = new Map<keyof TarOptionsWithAliases, keyof TarOptions>([\n ['C', 'cwd'],\n ['f', 'file'],\n ['z', 'gzip'],\n ['P', 'preservePaths'],\n ['U', 'unlink'],\n ['strip-components', 'strip'],\n ['stripComponents', 'strip'],\n ['keep-newer', 'newer'],\n ['keepNewer', 'newer'],\n ['keep-newer-files', 'newer'],\n ['keepNewerFiles', 'newer'],\n ['k', 'keep'],\n ['keep-existing', 'keep'],\n ['keepExisting', 'keep'],\n ['m', 'noMtime'],\n ['no-mtime', 'noMtime'],\n ['p', 'preserveOwner'],\n ['L', 'follow'],\n ['h', 'follow'],\n ['onentry', 'onReadEntry'],\n])\n\n/**\n * The options that can be provided to tar commands.\n *\n * Note that some of these are only relevant for certain commands, since\n * they are specific to reading or writing.\n *\n * Aliases are provided in the {@link TarOptionsWithAliases} type.\n */\nexport interface TarOptions {\n //////////////////////////\n // shared options\n\n /**\n * Perform all I/O operations synchronously. If the stream is ended\n * immediately, then it will be processed entirely synchronously.\n */\n sync?: boolean\n\n /**\n * The tar file to be read and/or written. When this is set, a stream\n * is not returned. Asynchronous commands will return a promise indicating\n * when the operation is completed, and synchronous commands will return\n * immediately.\n */\n file?: string\n\n /**\n * Treat warnings as crash-worthy errors. Defaults false.\n */\n strict?: boolean\n\n /**\n * The effective current working directory for this tar command\n */\n cwd?: string\n\n /**\n * When creating a tar archive, this can be used to compress it as well.\n * Set to `true` to use the default gzip options, or customize them as\n * needed.\n *\n * When reading, if this is unset, then the compression status will be\n * inferred from the archive data. This is generally best, unless you are\n * sure of the compression settings in use to create the archive, and want to\n * fail if the archive doesn't match expectations.\n */\n gzip?: boolean | GzipOptions\n\n /**\n * When creating archives, preserve absolute and `..` paths in the archive,\n * rather than sanitizing them under the cwd.\n *\n * When extracting, allow absolute paths, paths containing `..`, and\n * extracting through symbolic links. By default, the root `/` is stripped\n * from absolute paths (eg, turning `/x/y/z` into `x/y/z`), paths containing\n * `..` are not extracted, and any file whose location would be modified by a\n * symbolic link is not extracted.\n *\n * **WARNING** This is almost always unsafe, and must NEVER be used on\n * archives from untrusted sources, such as user input, and every entry must\n * be validated to ensure it is safe to write. Even if the input is not\n * malicious, mistakes can cause a lot of damage!\n */\n preservePaths?: boolean\n\n /**\n * When extracting, do not set the `mtime` value for extracted entries to\n * match the `mtime` in the archive.\n *\n * When creating archives, do not store the `mtime` value in the entry. Note\n * that this prevents properly using other mtime-based features (such as\n * `tar.update` or the `newer` option) with the resulting archive.\n */\n noMtime?: boolean\n\n /**\n * Set to `true` or an object with settings for `zlib.BrotliCompress()` to\n * create a brotli-compressed archive\n *\n * When extracting, this will cause the archive to be treated as a\n * brotli-compressed file if set to `true` or a ZlibOptions object.\n *\n * If set `false`, then brotli options will not be used.\n *\n * If this, the `gzip`, and `zstd` options are left `undefined`, then tar\n * will attempt to infer the brotli compression status, but can only do so\n * based on the filename. If the filename ends in `.tbr` or `.tar.br`, and\n * the first 512 bytes are not a valid tar header, then brotli decompression\n * will be attempted.\n */\n brotli?: boolean | ZlibOptions\n\n /**\n * Set to `true` or an object with settings for `zstd.compress()` to\n * create a zstd-compressed archive\n *\n * When extracting, this will cause the archive to be treated as a\n * zstd-compressed file if set to `true` or a ZlibOptions object.\n *\n * If set `false`, then zstd options will not be used.\n *\n * If this, the `gzip`, and `brotli` options are left `undefined`, then tar\n * will attempt to infer the zstd compression status, but can only do so\n * based on the filename. If the filename ends in `.tzst` or `.tar.zst`, and\n * the first 512 bytes are not a valid tar header, then zstd decompression\n * will be attempted.\n */\n zstd?: boolean | ZlibOptions\n\n /**\n * A function that is called with `(path, stat)` when creating an archive, or\n * `(path, entry)` when extracting. Return true to process the file/entry, or\n * false to exclude it.\n */\n filter?: (path: string, entry: Stats | ReadEntry) => boolean\n\n /**\n * A function that gets called for any warning encountered.\n *\n * Note: if `strict` is set, then the warning will throw, and this method\n * will not be called.\n */\n onwarn?: (code: string, message: string, data: WarnData) => unknown\n\n /**\n * The maximum allowed ratio of decompressed bytes to compressed bytes when\n * reading gzip, brotli, or zstd-compressed archives.\n *\n * This defaults to `1000` and aborts extraction or parsing when exceeded.\n * Set to `Infinity` to disable the limit.\n */\n maxDecompressionRatio?: number\n\n //////////////////////////\n // extraction options\n\n /**\n * When extracting, unlink files before creating them. Without this option,\n * tar overwrites existing files, which preserves existing hardlinks. With\n * this option, existing hardlinks will be broken, as will any symlink that\n * would affect the location of an extracted file.\n */\n unlink?: boolean\n\n /**\n * When extracting, strip the specified number of path portions from the\n * entry path. For example, with `{strip: 2}`, the entry `a/b/c/d` would be\n * extracted to `{cwd}/c/d`.\n *\n * Any entry whose entire path is stripped will be excluded.\n */\n strip?: number\n\n /**\n * When extracting, keep the existing file on disk if it's newer than the\n * file in the archive.\n */\n newer?: boolean\n\n /**\n * When extracting, do not overwrite existing files at all.\n */\n keep?: boolean\n\n /**\n * When extracting, set the `uid` and `gid` of extracted entries to the `uid`\n * and `gid` fields in the archive. Defaults to true when run as root, and\n * false otherwise.\n *\n * If false, then files and directories will be set with the owner and group\n * of the user running the process. This is similar to `-p` in `tar(1)`, but\n * ACLs and other system-specific data is never unpacked in this\n * implementation, and modes are set by default already.\n */\n preserveOwner?: boolean\n\n /**\n * The maximum depth of subfolders to extract into. This defaults to 1024.\n * Anything deeper than the limit will raise a warning and skip the entry.\n * Set to `Infinity` to remove the limitation.\n */\n maxDepth?: number\n\n /**\n * When extracting, force all created files and directories, and all\n * implicitly created directories, to be owned by the specified user id,\n * regardless of the `uid` field in the archive.\n *\n * Cannot be used along with `preserveOwner`. Requires also setting the `gid`\n * option.\n */\n uid?: number\n\n /**\n * When extracting, force all created files and directories, and all\n * implicitly created directories, to be owned by the specified group id,\n * regardless of the `gid` field in the archive.\n *\n * Cannot be used along with `preserveOwner`. Requires also setting the `uid`\n * option.\n */\n gid?: number\n\n /**\n * When extracting, provide a function that takes an `entry` object, and\n * returns a stream, or any falsey value. If a stream is provided, then that\n * stream's data will be written instead of the contents of the archive\n * entry. If a falsey value is provided, then the entry is written to disk as\n * normal.\n *\n * To exclude items from extraction, use the `filter` option.\n *\n * Note that using an asynchronous stream type with the `transform` option\n * will cause undefined behavior in synchronous extractions.\n * [MiniPass](http://npm.im/minipass)-based streams are designed for this use\n * case.\n */\n transform?: (\n entry: ReadEntry,\n ) => ReadEntry | null | undefined | false | 0 | ''\n\n /**\n * Call `chmod()` to ensure that extracted files match the entry's mode\n * field. Without this field set, all mode fields in archive entries are a\n * best effort attempt only.\n *\n * Setting this necessitates a call to the deprecated `process.umask()`\n * method to determine the default umask value, unless a `processUmask`\n * config is provided as well.\n *\n * If not set, tar will attempt to create file system entries with whatever\n * mode is provided, and let the implicit process `umask` apply normally, but\n * if a file already exists to be written to, then its existing mode will not\n * be modified.\n *\n * When setting `chmod: true`, it is highly recommend to set the\n * {@link TarOptions#processUmask} option as well, to avoid the call to the\n * deprecated (and thread-unsafe) `process.umask()` method.\n */\n chmod?: boolean\n\n /**\n * When setting the {@link TarOptions#chmod} option to `true`, you may\n * provide a value here to avoid having to call the deprecated and\n * thread-unsafe `process.umask()` method.\n *\n * This has no effect with `chmod` is not set to true, as mode values are not\n * set explicitly anyway. If `chmod` is set to `true`, and a value is not\n * provided here, then `process.umask()` must be called, which will result in\n * deprecation warnings.\n *\n * The most common values for this are `0o22` (resulting in directories\n * created with mode `0o755` and files with `0o644` by default) and `0o2`\n * (resulting in directores created with mode `0o775` and files `0o664`, so\n * they are group-writable).\n */\n processUmask?: number\n\n //////////////////////////\n // archive creation options\n\n /**\n * When parsing/listing archives, `entry` streams are by default resumed\n * (set into \"flowing\" mode) immediately after the call to `onReadEntry()`.\n * Set `noResume: true` to suppress this behavior.\n *\n * Note that when this is set, the stream will never complete until the\n * data is consumed somehow.\n *\n * Set automatically in extract operations, since the entry is piped to\n * a file system entry right away. Only relevant when parsing.\n */\n noResume?: boolean\n\n /**\n * When creating, updating, or replacing within archives, this method will\n * be called with each WriteEntry that is created.\n */\n onWriteEntry?: (entry: WriteEntry) => unknown\n\n /**\n * When extracting or listing archives, this method will be called with\n * each entry that is not excluded by a `filter`.\n *\n * Important when listing archives synchronously from a file, because there\n * is otherwise no way to interact with the data!\n */\n onReadEntry?: (entry: ReadEntry) => unknown\n\n /**\n * Pack the targets of symbolic links rather than the link itself.\n */\n follow?: boolean\n\n /**\n * When creating archives, omit any metadata that is system-specific:\n * `ctime`, `atime`, `uid`, `gid`, `uname`, `gname`, `dev`, `ino`, and\n * `nlink`. Note that `mtime` is still included, because this is necessary\n * for other time-based operations such as `tar.update`. Additionally, `mode`\n * is set to a \"reasonable default\" for mose unix systems, based on an\n * effective `umask` of `0o22`.\n *\n * This also defaults the `portable` option in the gzip configs when creating\n * a compressed archive, in order to produce deterministic archives that are\n * not operating-system specific.\n */\n portable?: boolean\n\n /**\n * When creating archives, do not recursively archive the contents of\n * directories. By default, archiving a directory archives all of its\n * contents as well.\n */\n noDirRecurse?: boolean\n\n /**\n * Suppress Pax extended headers when creating archives. Note that this means\n * long paths and linkpaths will be truncated, and large or negative numeric\n * values may be interpreted incorrectly.\n */\n noPax?: boolean\n\n /**\n * Set to a `Date` object to force a specific `mtime` value for everything\n * written to an archive.\n *\n * This is useful when creating archives that are intended to be\n * deterministic based on their contents, irrespective of the file's last\n * modification time.\n *\n * Overridden by `noMtime`.\n */\n mtime?: Date\n\n /**\n * A path portion to prefix onto the entries added to an archive.\n */\n prefix?: string\n\n /**\n * The mode to set on any created file archive, defaults to 0o666\n * masked by the process umask, often resulting in 0o644.\n *\n * This does *not* affect the mode fields of individual entries, or the\n * mode status of extracted entries on the filesystem.\n */\n mode?: number\n\n //////////////////////////\n // internal options\n\n /**\n * A cache of mtime values, to avoid having to stat the same file repeatedly.\n *\n * @internal\n */\n mtimeCache?: Map<string, Date>\n\n /**\n * maximum buffer size for `fs.read()` operations.\n *\n * @internal\n */\n maxReadSize?: number\n\n /**\n * Filter modes of entries being unpacked, like `process.umask()`\n *\n * @internal\n */\n umask?: number\n\n /**\n * Default mode for directories. Used for all implicitly created directories,\n * and any directories in the archive that do not have a mode field.\n *\n * @internal\n */\n dmode?: number\n\n /**\n * default mode for files\n *\n * @internal\n */\n fmode?: number\n\n /**\n * Map that tracks which directories already exist, for extraction\n *\n * @internal\n */\n dirCache?: Map<string, boolean>\n /**\n * maximum supported size of meta entries. Defaults to 1MB\n *\n * @internal\n */\n maxMetaEntrySize?: number\n\n /**\n * A Map object containing the device and inode value for any file whose\n * `nlink` value is greater than 1, to identify hard links when creating\n * archives.\n *\n * @internal\n */\n linkCache?: Map<LinkCacheKey, string>\n\n /**\n * A map object containing the results of `fs.readdir()` calls.\n *\n * @internal\n */\n readdirCache?: Map<string, string[]>\n\n /**\n * A cache of all `lstat` results, for use in creating archives.\n *\n * @internal\n */\n statCache?: Map<string, Stats>\n\n /**\n * Number of concurrent jobs to run when creating archives.\n *\n * Defaults to 4.\n *\n * @internal\n */\n jobs?: number\n\n /**\n * Automatically set to true on Windows systems.\n *\n * When extracting, causes behavior where filenames containing `<|>?:`\n * characters are converted to windows-compatible escape sequences in the\n * created filesystem entries.\n *\n * When packing, causes behavior where paths replace `\\` with `/`, and\n * filenames containing the windows-compatible escaped forms of `<|>?:` are\n * converted to actual `<|>?:` characters in the archive.\n *\n * @internal\n */\n win32?: boolean\n\n /**\n * For `WriteEntry` objects, the absolute path to the entry on the\n * filesystem. By default, this is `resolve(cwd, entry.path)`, but it can be\n * overridden explicitly.\n *\n * @internal\n */\n absolute?: string\n\n /**\n * Used with Parser stream interface, to attach and take over when the\n * stream is completely parsed. If this is set, then the prefinish,\n * finish, and end events will not fire, and are the responsibility of\n * the ondone method to emit properly.\n *\n * @internal\n */\n ondone?: () => void\n\n /**\n * Mostly for testing, but potentially useful in some cases.\n * Forcibly trigger a chown on every entry, no matter what.\n */\n forceChown?: boolean\n\n /**\n * ambiguous deprecated name for {@link onReadEntry}\n *\n * @deprecated\n */\n onentry?: (entry: ReadEntry) => unknown\n}\n\nexport type TarOptionsSync = TarOptions & { sync: true }\nexport type TarOptionsAsync = TarOptions & { sync?: false }\nexport type TarOptionsFile = TarOptions & { file: string }\nexport type TarOptionsNoFile = TarOptions & { file?: undefined }\nexport type TarOptionsSyncFile = TarOptionsSync & TarOptionsFile\nexport type TarOptionsAsyncFile = TarOptionsAsync & TarOptionsFile\nexport type TarOptionsSyncNoFile = TarOptionsSync & TarOptionsNoFile\nexport type TarOptionsAsyncNoFile = TarOptionsAsync & TarOptionsNoFile\n\nexport type LinkCacheKey = `${number}:${number}`\n\nexport interface TarOptionsWithAliases extends TarOptions {\n /**\n * The effective current working directory for this tar command\n */\n C?: TarOptions['cwd']\n /**\n * The tar file to be read and/or written. When this is set, a stream\n * is not returned. Asynchronous commands will return a promise indicating\n * when the operation is completed, and synchronous commands will return\n * immediately.\n */\n f?: TarOptions['file']\n /**\n * When creating a tar archive, this can be used to compress it as well.\n * Set to `true` to use the default gzip options, or customize them as\n * needed.\n *\n * When reading, if this is unset, then the compression status will be\n * inferred from the archive data. This is generally best, unless you are\n * sure of the compression settings in use to create the archive, and want to\n * fail if the archive doesn't match expectations.\n */\n z?: TarOptions['gzip']\n /**\n * When creating archives, preserve absolute and `..` paths in the archive,\n * rather than sanitizing them under the cwd.\n *\n * When extracting, allow absolute paths, paths containing `..`, and\n * extracting through symbolic links. By default, the root `/` is stripped\n * from absolute paths (eg, turning `/x/y/z` into `x/y/z`), paths containing\n * `..` are not extracted, and any file whose location would be modified by a\n * symbolic link is not extracted.\n *\n * **WARNING** This is almost always unsafe, and must NEVER be used on\n * archives from untrusted sources, such as user input, and every entry must\n * be validated to ensure it is safe to write. Even if the input is not\n * malicious, mistakes can cause a lot of damage!\n */\n P?: TarOptions['preservePaths']\n /**\n * When extracting, unlink files before creating them. Without this option,\n * tar overwrites existing files, which preserves existing hardlinks. With\n * this option, existing hardlinks will be broken, as will any symlink that\n * would affect the location of an extracted file.\n */\n U?: TarOptions['unlink']\n /**\n * When extracting, strip the specified number of path portions from the\n * entry path. For example, with `{strip: 2}`, the entry `a/b/c/d` would be\n * extracted to `{cwd}/c/d`.\n */\n 'strip-components'?: TarOptions['strip']\n /**\n * When extracting, strip the specified number of path portions from the\n * entry path. For example, with `{strip: 2}`, the entry `a/b/c/d` would be\n * extracted to `{cwd}/c/d`.\n */\n stripComponents?: TarOptions['strip']\n /**\n * When extracting, keep the existing file on disk if it's newer than the\n * file in the archive.\n */\n 'keep-newer'?: TarOptions['newer']\n /**\n * When extracting, keep the existing file on disk if it's newer than the\n * file in the archive.\n */\n keepNewer?: TarOptions['newer']\n /**\n * When extracting, keep the existing file on disk if it's newer than the\n * file in the archive.\n */\n 'keep-newer-files'?: TarOptions['newer']\n /**\n * When extracting, keep the existing file on disk if it's newer than the\n * file in the archive.\n */\n keepNewerFiles?: TarOptions['newer']\n /**\n * When extracting, do not overwrite existing files at all.\n */\n k?: TarOptions['keep']\n /**\n * When extracting, do not overwrite existing files at all.\n */\n 'keep-existing'?: TarOptions['keep']\n /**\n * When extracting, do not overwrite existing files at all.\n */\n keepExisting?: TarOptions['keep']\n /**\n * When extracting, do not set the `mtime` value for extracted entries to\n * match the `mtime` in the archive.\n *\n * When creating archives, do not store the `mtime` value in the entry. Note\n * that this prevents properly using other mtime-based features (such as\n * `tar.update` or the `newer` option) with the resulting archive.\n */\n m?: TarOptions['noMtime']\n /**\n * When extracting, do not set the `mtime` value for extracted entries to\n * match the `mtime` in the archive.\n *\n * When creating archives, do not store the `mtime` value in the entry. Note\n * that this prevents properly using other mtime-based features (such as\n * `tar.update` or the `newer` option) with the resulting archive.\n */\n 'no-mtime'?: TarOptions['noMtime']\n /**\n * When extracting, set the `uid` and `gid` of extracted entries to the `uid`\n * and `gid` fields in the archive. Defaults to true when run as root, and\n * false otherwise.\n *\n * If false, then files and directories will be set with the owner and group\n * of the user running the process. This is similar to `-p` in `tar(1)`, but\n * ACLs and other system-specific data is never unpacked in this\n * implementation, and modes are set by default already.\n */\n p?: TarOptions['preserveOwner']\n /**\n * Pack the targets of symbolic links rather than the link itself.\n */\n L?: TarOptions['follow']\n /**\n * Pack the targets of symbolic links rather than the link itself.\n */\n h?: TarOptions['follow']\n\n /**\n * Deprecated option. Set explicitly false to set `chmod: true`. Ignored\n * if {@link TarOptions#chmod} is set to any boolean value.\n *\n * @deprecated\n */\n noChmod?: boolean\n}\n\nexport type TarOptionsWithAliasesSync = TarOptionsWithAliases & {\n sync: true\n}\nexport type TarOptionsWithAliasesAsync = TarOptionsWithAliases & {\n sync?: false\n}\nexport type TarOptionsWithAliasesFile =\n | (TarOptionsWithAliases & {\n file: string\n })\n | (TarOptionsWithAliases & { f: string })\nexport type TarOptionsWithAliasesSyncFile = TarOptionsWithAliasesSync &\n TarOptionsWithAliasesFile\nexport type TarOptionsWithAliasesAsyncFile = TarOptionsWithAliasesAsync &\n TarOptionsWithAliasesFile\n\nexport type TarOptionsWithAliasesNoFile = TarOptionsWithAliases & {\n f?: undefined\n file?: undefined\n}\n\nexport type TarOptionsWithAliasesSyncNoFile = TarOptionsWithAliasesSync &\n TarOptionsWithAliasesNoFile\nexport type TarOptionsWithAliasesAsyncNoFile = TarOptionsWithAliasesAsync &\n TarOptionsWithAliasesNoFile\n\nexport const isSyncFile = <O extends TarOptions>(\n o: O,\n): o is O & TarOptionsSyncFile => !!o.sync && !!o.file\nexport const isAsyncFile = <O extends TarOptions>(\n o: O,\n): o is O & TarOptionsAsyncFile => !o.sync && !!o.file\nexport const isSyncNoFile = <O extends TarOptions>(\n o: O,\n): o is O & TarOptionsSyncNoFile => !!o.sync && !o.file\nexport const isAsyncNoFile = <O extends TarOptions>(\n o: O,\n): o is O & TarOptionsAsyncNoFile => !o.sync && !o.file\nexport const isSync = <O extends TarOptions>(\n o: O,\n): o is O & TarOptionsSync => !!o.sync\nexport const isAsync = <O extends TarOptions>(\n o: O,\n): o is O & TarOptionsAsync => !o.sync\nexport const isFile = <O extends TarOptions>(\n o: O,\n): o is O & TarOptionsFile => !!o.file\nexport const isNoFile = <O extends TarOptions>(\n o: O,\n): o is O & TarOptionsNoFile => !o.file\n\nconst dealiasKey = (k: keyof TarOptionsWithAliases): keyof TarOptions => {\n const d = argmap.get(k)\n if (d) return d\n return k as keyof TarOptions\n}\n\nexport const dealias = (opt: TarOptionsWithAliases = {}): TarOptions => {\n if (!opt) return {}\n const result: Record<string, unknown> = {}\n for (const [key, v] of Object.entries(opt) as [\n keyof TarOptionsWithAliases,\n unknown,\n ][]) {\n // TS doesn't know that aliases are going to always be the same type\n const k = dealiasKey(key)\n result[k] = v\n }\n // affordance for deprecated noChmod -> chmod\n if (result.chmod === undefined && result.noChmod === false) {\n result.chmod = true\n }\n delete result.noChmod\n return result as TarOptions\n}\n", "import type {\n TarOptions,\n TarOptionsAsyncFile,\n TarOptionsAsyncNoFile,\n TarOptionsSyncFile,\n TarOptionsSyncNoFile,\n TarOptionsWithAliases,\n TarOptionsWithAliasesAsync,\n TarOptionsWithAliasesAsyncFile,\n TarOptionsWithAliasesAsyncNoFile,\n TarOptionsWithAliasesFile,\n TarOptionsWithAliasesNoFile,\n TarOptionsWithAliasesSync,\n TarOptionsWithAliasesSyncFile,\n TarOptionsWithAliasesSyncNoFile,\n} from './options.js'\nimport {\n dealias,\n isAsyncFile,\n isAsyncNoFile,\n isSyncFile,\n isSyncNoFile,\n} from './options.js'\n\nexport type CB = (er?: Error) => unknown\n\nexport type TarCommand<AsyncClass, SyncClass extends { sync: true }> = {\n // async and no file specified\n (): AsyncClass\n (opt: TarOptionsWithAliasesAsyncNoFile): AsyncClass\n (entries: string[]): AsyncClass\n (opt: TarOptionsWithAliasesAsyncNoFile, entries: string[]): AsyncClass\n} & {\n // sync and no file\n (opt: TarOptionsWithAliasesSyncNoFile): SyncClass\n (opt: TarOptionsWithAliasesSyncNoFile, entries: string[]): SyncClass\n} & {\n // async and file\n (opt: TarOptionsWithAliasesAsyncFile): Promise<void>\n (opt: TarOptionsWithAliasesAsyncFile, entries: string[]): Promise<void>\n (opt: TarOptionsWithAliasesAsyncFile, cb: CB): Promise<void>\n (\n opt: TarOptionsWithAliasesAsyncFile,\n entries: string[],\n cb: CB,\n ): Promise<void>\n} & {\n // sync and file\n (opt: TarOptionsWithAliasesSyncFile): void\n (opt: TarOptionsWithAliasesSyncFile, entries: string[]): void\n} & {\n // sync, maybe file\n (opt: TarOptionsWithAliasesSync): typeof opt extends (\n TarOptionsWithAliasesFile\n ) ?\n void\n : typeof opt extends TarOptionsWithAliasesNoFile ? SyncClass\n : void | SyncClass\n (\n opt: TarOptionsWithAliasesSync,\n entries: string[],\n ): typeof opt extends TarOptionsWithAliasesFile ? void\n : typeof opt extends TarOptionsWithAliasesNoFile ? SyncClass\n : void | SyncClass\n} & {\n // async, maybe file\n (opt: TarOptionsWithAliasesAsync): typeof opt extends (\n TarOptionsWithAliasesFile\n ) ?\n Promise<void>\n : typeof opt extends TarOptionsWithAliasesNoFile ? AsyncClass\n : Promise<void> | AsyncClass\n (\n opt: TarOptionsWithAliasesAsync,\n entries: string[],\n ): typeof opt extends TarOptionsWithAliasesFile ? Promise<void>\n : typeof opt extends TarOptionsWithAliasesNoFile ? AsyncClass\n : Promise<void> | AsyncClass\n (opt: TarOptionsWithAliasesAsync, cb: CB): Promise<void>\n (\n opt: TarOptionsWithAliasesAsync,\n entries: string[],\n cb: CB,\n ): typeof opt extends TarOptionsWithAliasesFile ? Promise<void>\n : typeof opt extends TarOptionsWithAliasesNoFile ? never\n : Promise<void>\n} & {\n // maybe sync, file\n (opt: TarOptionsWithAliasesFile): Promise<void> | void\n (\n opt: TarOptionsWithAliasesFile,\n entries: string[],\n ): typeof opt extends TarOptionsWithAliasesSync ? void\n : typeof opt extends TarOptionsWithAliasesAsync ? Promise<void>\n : Promise<void> | void\n (opt: TarOptionsWithAliasesFile, cb: CB): Promise<void>\n (\n opt: TarOptionsWithAliasesFile,\n entries: string[],\n cb: CB,\n ): typeof opt extends TarOptionsWithAliasesSync ? never\n : typeof opt extends TarOptionsWithAliasesAsync ? Promise<void>\n : Promise<void>\n} & {\n // maybe sync, no file\n (opt: TarOptionsWithAliasesNoFile): typeof opt extends (\n TarOptionsWithAliasesSync\n ) ?\n SyncClass\n : typeof opt extends TarOptionsWithAliasesAsync ? AsyncClass\n : SyncClass | AsyncClass\n (\n opt: TarOptionsWithAliasesNoFile,\n entries: string[],\n ): typeof opt extends TarOptionsWithAliasesSync ? SyncClass\n : typeof opt extends TarOptionsWithAliasesAsync ? AsyncClass\n : SyncClass | AsyncClass\n} & {\n // maybe sync, maybe file\n (opt: TarOptionsWithAliases): typeof opt extends (\n TarOptionsWithAliasesFile\n ) ?\n typeof opt extends TarOptionsWithAliasesSync ? void\n : typeof opt extends TarOptionsWithAliasesAsync ? Promise<void>\n : void | Promise<void>\n : typeof opt extends TarOptionsWithAliasesNoFile ?\n typeof opt extends TarOptionsWithAliasesSync ? SyncClass\n : typeof opt extends TarOptionsWithAliasesAsync ? AsyncClass\n : SyncClass | AsyncClass\n : typeof opt extends TarOptionsWithAliasesSync ? SyncClass | void\n : typeof opt extends TarOptionsWithAliasesAsync ?\n AsyncClass | Promise<void>\n : SyncClass | void | AsyncClass | Promise<void>\n} & {\n // extras\n syncFile: (opt: TarOptionsSyncFile, entries: string[]) => void\n asyncFile: (\n opt: TarOptionsAsyncFile,\n entries: string[],\n cb?: CB,\n ) => Promise<void>\n syncNoFile: (opt: TarOptionsSyncNoFile, entries: string[]) => SyncClass\n asyncNoFile: (\n opt: TarOptionsAsyncNoFile,\n entries: string[],\n ) => AsyncClass\n validate?: (opt: TarOptions, entries?: string[]) => void\n}\n\nexport const makeCommand = <AsyncClass, SyncClass extends { sync: true }>(\n syncFile: (opt: TarOptionsSyncFile, entries: string[]) => void,\n asyncFile: (\n opt: TarOptionsAsyncFile,\n entries: string[],\n cb?: CB,\n ) => Promise<void>,\n syncNoFile: (opt: TarOptionsSyncNoFile, entries: string[]) => SyncClass,\n asyncNoFile: (\n opt: TarOptionsAsyncNoFile,\n entries: string[],\n ) => AsyncClass,\n validate?: (opt: TarOptions, entries?: string[]) => void,\n): TarCommand<AsyncClass, SyncClass> => {\n return Object.assign(\n (\n opt_: TarOptionsWithAliases | string[] = [],\n entries?: string[] | CB,\n cb?: CB,\n ) => {\n if (Array.isArray(opt_)) {\n entries = opt_\n opt_ = {}\n }\n\n if (typeof entries === 'function') {\n cb = entries\n entries = undefined\n }\n\n entries = !entries ? [] : Array.from(entries)\n\n const opt = dealias(opt_)\n\n validate?.(opt, entries)\n\n if (isSyncFile(opt)) {\n if (typeof cb === 'function') {\n throw new TypeError(\n 'callback not supported for sync tar functions',\n )\n }\n return syncFile(opt, entries)\n } else if (isAsyncFile(opt)) {\n const p = asyncFile(opt, entries)\n return cb ? p.then(() => cb(), cb) : p\n } else if (isSyncNoFile(opt)) {\n if (typeof cb === 'function') {\n throw new TypeError(\n 'callback not supported for sync tar functions',\n )\n }\n return syncNoFile(opt, entries)\n } else if (isAsyncNoFile(opt)) {\n if (typeof cb === 'function') {\n throw new TypeError('callback only supported with file option')\n }\n return asyncNoFile(opt, entries)\n /* c8 ignore start */\n }\n throw new Error('impossible options??')\n\n /* c8 ignore stop */\n },\n {\n syncFile,\n asyncFile,\n syncNoFile,\n asyncNoFile,\n validate,\n },\n ) as TarCommand<AsyncClass, SyncClass>\n}\n", "// this[BUFFER] is the remainder of a chunk if we're waiting for\n// the full 512 bytes of a header to come in. We will Buffer.concat()\n// it to the next write(), which is a mem copy, but a small one.\n//\n// this[QUEUE] is a list of entries that haven't been emitted\n// yet this can only get filled up if the user keeps write()ing after\n// a write() returns false, or does a write() with more than one entry\n//\n// We don't buffer chunks, we always parse them and either create an\n// entry, or push it into the active entry. The ReadEntry class knows\n// to throw data away if .ignore=true\n//\n// Shift entry off the buffer when it emits 'end', and emit 'entry' for\n// the next one in the list.\n//\n// At any time, we're pushing body chunks into the entry at WRITEENTRY,\n// and waiting for 'end' on the entry at READENTRY\n//\n// ignored entries get .resume() called on them straight away\n\nimport { EventEmitter as EE } from 'events'\nimport { BrotliDecompress, Unzip, ZstdDecompress } from 'minizlib'\nimport { Header } from './header.js'\nimport type { TarOptions } from './options.js'\nimport { Pax } from './pax.js'\nimport { ReadEntry } from './read-entry.js'\nimport { warnMethod, type WarnData, type Warner } from './warn-method.js'\n\nconst maxMetaEntrySize = 1024 * 1024\nconst gzipHeader = Buffer.from([0x1f, 0x8b])\nconst zstdHeader = Buffer.from([0x28, 0xb5, 0x2f, 0xfd])\nconst ZIP_HEADER_LEN = Math.max(gzipHeader.length, zstdHeader.length)\n\nconst STATE = Symbol('state')\nconst WRITEENTRY = Symbol('writeEntry')\nconst READENTRY = Symbol('readEntry')\nconst NEXTENTRY = Symbol('nextEntry')\nconst PROCESSENTRY = Symbol('processEntry')\nconst EX = Symbol('extendedHeader')\nconst GEX = Symbol('globalExtendedHeader')\nconst META = Symbol('meta')\nconst EMITMETA = Symbol('emitMeta')\nconst BUFFER = Symbol('buffer')\nconst QUEUE = Symbol('queue')\nconst ENDED = Symbol('ended')\nconst EMITTEDEND = Symbol('emittedEnd')\nconst EMIT = Symbol('emit')\nconst UNZIP = Symbol('unzip')\nconst CONSUMECHUNK = Symbol('consumeChunk')\nconst CONSUMECHUNKSUB = Symbol('consumeChunkSub')\nconst CONSUMEBODY = Symbol('consumeBody')\nconst CONSUMEMETA = Symbol('consumeMeta')\nconst CONSUMEHEADER = Symbol('consumeHeader')\nconst CONSUMING = Symbol('consuming')\nconst BUFFERCONCAT = Symbol('bufferConcat')\nconst MAYBEEND = Symbol('maybeEnd')\nconst WRITING = Symbol('writing')\nconst ABORTED = Symbol('aborted')\nconst DONE = Symbol('onDone')\nconst SAW_VALID_ENTRY = Symbol('sawValidEntry')\nconst SAW_NULL_BLOCK = Symbol('sawNullBlock')\nconst SAW_EOF = Symbol('sawEOF')\nconst CLOSESTREAM = Symbol('closeStream')\nconst MAX_DECOMPRESSION_RATIO = 1000\nconst COMPRESSEDBYTESREAD = Symbol('compressedBytesRead')\nconst DECOMPRESSEDBYTESREAD = Symbol('decompressedBytesRead')\nconst CHECKDECOMPRESSIONRATIO = Symbol('checkDecompressionRatio')\n\nconst noop = () => true\n\nexport type State = 'begin' | 'header' | 'ignore' | 'meta' | 'body'\n\nexport class Parser extends EE implements Warner {\n file: string\n strict: boolean\n maxMetaEntrySize: number\n filter: Exclude<TarOptions['filter'], undefined>\n brotli?: TarOptions['brotli']\n zstd?: TarOptions['zstd']\n maxDecompressionRatio: number\n\n writable: true = true\n readable: false = false;\n\n [QUEUE]: (ReadEntry | [string | symbol, unknown, unknown])[] = [];\n [BUFFER]?: Buffer;\n [READENTRY]?: ReadEntry;\n [WRITEENTRY]?: ReadEntry;\n [STATE]: State = 'begin';\n [META]: string = '';\n [EX]?: Pax;\n [GEX]?: Pax;\n [ENDED]: boolean = false;\n [UNZIP]?: false | Unzip | BrotliDecompress | ZstdDecompress;\n [ABORTED]: boolean = false;\n [SAW_VALID_ENTRY]?: boolean;\n [SAW_NULL_BLOCK]: boolean = false;\n [SAW_EOF]: boolean = false;\n [WRITING]: boolean = false;\n [CONSUMING]: boolean = false;\n [EMITTEDEND]: boolean = false;\n [COMPRESSEDBYTESREAD]: number = 0;\n [DECOMPRESSEDBYTESREAD]: number = 0\n\n constructor(opt: TarOptions = {}) {\n super()\n\n this.file = opt.file || ''\n\n // these BADARCHIVE errors can't be detected early. listen on DONE.\n this.on(DONE, () => {\n if (this[STATE] === 'begin' || this[SAW_VALID_ENTRY] === false) {\n // either less than 1 block of data, or all entries were invalid.\n // Either way, probably not even a tarball.\n this.warn('TAR_BAD_ARCHIVE', 'Unrecognized archive format')\n }\n })\n\n if (opt.ondone) {\n this.on(DONE, opt.ondone)\n } else {\n this.on(DONE, () => {\n this.emit('prefinish')\n this.emit('finish')\n this.emit('end')\n })\n }\n\n this.strict = !!opt.strict\n this.maxDecompressionRatio =\n typeof opt.maxDecompressionRatio === 'number' ?\n opt.maxDecompressionRatio\n : MAX_DECOMPRESSION_RATIO\n this.maxMetaEntrySize = opt.maxMetaEntrySize || maxMetaEntrySize\n this.filter = typeof opt.filter === 'function' ? opt.filter : noop\n // Unlike gzip, brotli doesn't have any magic bytes to identify it\n // Users need to explicitly tell us they're extracting a brotli file\n // Or we infer from the file extension\n const isTBR =\n opt.file &&\n (opt.file.endsWith('.tar.br') || opt.file.endsWith('.tbr'))\n // if it's a tbr file it MIGHT be brotli, but we don't know until\n // we look at it and verify it's not a valid tar file.\n this.brotli =\n !(opt.gzip || opt.zstd) && opt.brotli !== undefined ? opt.brotli\n : isTBR ? undefined\n : false\n\n // zstd has magic bytes to identify it, but we also support explicit options\n // and file extension detection\n const isTZST =\n opt.file &&\n (opt.file.endsWith('.tar.zst') || opt.file.endsWith('.tzst'))\n this.zstd =\n !(opt.gzip || opt.brotli) && opt.zstd !== undefined ? opt.zstd\n : isTZST ? true\n : undefined\n\n // have to set this so that streams are ok piping into it\n this.on('end', () => this[CLOSESTREAM]())\n\n if (typeof opt.onwarn === 'function') {\n this.on('warn', opt.onwarn)\n }\n if (typeof opt.onReadEntry === 'function') {\n this.on('entry', opt.onReadEntry)\n }\n }\n\n warn(code: string, message: string | Error, data: WarnData = {}): void {\n warnMethod(this, code, message, data)\n }\n\n [CONSUMEHEADER](chunk: Buffer, position: number) {\n if (this[SAW_VALID_ENTRY] === undefined) {\n this[SAW_VALID_ENTRY] = false\n }\n let header\n try {\n header = new Header(chunk, position, this[EX], this[GEX])\n } catch (er) {\n return this.warn('TAR_ENTRY_INVALID', er as Error)\n }\n\n if (header.nullBlock) {\n if (this[SAW_NULL_BLOCK]) {\n this[SAW_EOF] = true\n // ending an archive with no entries. pointless, but legal.\n if (this[STATE] === 'begin') {\n this[STATE] = 'header'\n }\n this[EMIT]('eof')\n } else {\n this[SAW_NULL_BLOCK] = true\n this[EMIT]('nullBlock')\n }\n } else {\n this[SAW_NULL_BLOCK] = false\n if (!header.cksumValid) {\n this.warn('TAR_ENTRY_INVALID', 'checksum failure', { header })\n } else if (!header.path) {\n this.warn('TAR_ENTRY_INVALID', 'path is required', { header })\n } else {\n const type = header.type\n if (/^(Symbolic)?Link$/.test(type) && !header.linkpath) {\n this.warn('TAR_ENTRY_INVALID', 'linkpath required', {\n header,\n })\n } else if (\n !/^(Symbolic)?Link$/.test(type) &&\n !/^(Global)?ExtendedHeader$/.test(type) &&\n header.linkpath\n ) {\n this.warn('TAR_ENTRY_INVALID', 'linkpath forbidden', {\n header,\n })\n } else {\n const entry = (this[WRITEENTRY] = new ReadEntry(\n header,\n this[EX],\n this[GEX],\n ))\n\n // we do this for meta & ignored entries as well, because they\n // are still valid tar, or else we wouldn't know to ignore them\n if (!this[SAW_VALID_ENTRY]) {\n if (entry.remain) {\n // this might be the one!\n const onend = () => {\n if (!entry.invalid) {\n this[SAW_VALID_ENTRY] = true\n }\n }\n entry.on('end', onend)\n } else {\n this[SAW_VALID_ENTRY] = true\n }\n }\n\n if (entry.meta) {\n if (entry.size > this.maxMetaEntrySize) {\n entry.ignore = true\n this[EMIT]('ignoredEntry', entry)\n this[STATE] = 'ignore'\n entry.resume()\n } else if (entry.size > 0) {\n this[META] = ''\n entry.on('data', c => (this[META] += c))\n this[STATE] = 'meta'\n }\n } else {\n this[EX] = undefined\n entry.ignore = entry.ignore || !this.filter(entry.path, entry)\n\n if (entry.ignore) {\n // probably valid, just not something we care about\n this[EMIT]('ignoredEntry', entry)\n this[STATE] = entry.remain ? 'ignore' : 'header'\n entry.resume()\n } else {\n if (entry.remain) {\n this[STATE] = 'body'\n } else {\n this[STATE] = 'header'\n entry.end()\n }\n\n if (!this[READENTRY]) {\n this[QUEUE].push(entry)\n this[NEXTENTRY]()\n } else {\n this[QUEUE].push(entry)\n }\n }\n }\n }\n }\n }\n }\n\n [CLOSESTREAM]() {\n queueMicrotask(() => this.emit('close'))\n }\n\n [PROCESSENTRY](entry?: ReadEntry | [string | symbol, unknown, unknown]) {\n let go = true\n\n if (!entry) {\n this[READENTRY] = undefined\n go = false\n } else if (Array.isArray(entry)) {\n const [ev, ...args]: [string | symbol, unknown, unknown] = entry\n this.emit(ev, ...args)\n } else {\n this[READENTRY] = entry\n this.emit('entry', entry)\n if (!entry.emittedEnd) {\n entry.on('end', () => this[NEXTENTRY]())\n go = false\n }\n }\n\n return go\n }\n\n [NEXTENTRY]() {\n do {} while (this[PROCESSENTRY](this[QUEUE].shift()))\n\n if (this[QUEUE].length === 0) {\n // At this point, there's nothing in the queue, but we may have an\n // entry which is being consumed (readEntry).\n // If we don't, then we definitely can handle more data.\n // If we do, and either it's flowing, or it has never had any data\n // written to it, then it needs more.\n // The only other possibility is that it has returned false from a\n // write() call, so we wait for the next drain to continue.\n const re = this[READENTRY]\n const drainNow = !re || re.flowing || re.size === re.remain\n if (drainNow) {\n if (!this[WRITING]) {\n this.emit('drain')\n }\n } else {\n re.once('drain', () => this.emit('drain'))\n }\n }\n }\n\n [CONSUMEBODY](chunk: Buffer, position: number) {\n // write up to but no more than writeEntry.blockRemain\n const entry = this[WRITEENTRY]\n /* c8 ignore start */\n if (!entry) {\n throw new Error('attempt to consume body without entry??')\n }\n const br = entry.blockRemain ?? 0\n /* c8 ignore stop */\n const c =\n br >= chunk.length && position === 0 ?\n chunk\n : chunk.subarray(position, position + br)\n\n entry.write(c)\n\n if (!entry.blockRemain) {\n this[STATE] = 'header'\n this[WRITEENTRY] = undefined\n entry.end()\n }\n\n return c.length\n }\n\n [CONSUMEMETA](chunk: Buffer, position: number) {\n const entry = this[WRITEENTRY]\n const ret = this[CONSUMEBODY](chunk, position)\n\n // if we finished, then the entry is reset\n if (!this[WRITEENTRY] && entry) {\n this[EMITMETA](entry)\n }\n\n return ret\n }\n\n [EMIT](ev: string | symbol, data?: unknown, extra?: unknown) {\n if (this[QUEUE].length === 0 && !this[READENTRY]) {\n this.emit(ev, data, extra)\n } else {\n this[QUEUE].push([ev, data, extra])\n }\n }\n\n [EMITMETA](entry: ReadEntry) {\n this[EMIT]('meta', this[META])\n switch (entry.type) {\n case 'ExtendedHeader':\n case 'OldExtendedHeader':\n this[EX] = Pax.parse(this[META], this[EX], false)\n break\n\n case 'GlobalExtendedHeader':\n this[GEX] = Pax.parse(this[META], this[GEX], true)\n break\n\n case 'NextFileHasLongPath':\n case 'OldGnuLongPath': {\n const ex: Pax = this[EX] ?? Object.create(null)\n this[EX] = ex\n ex.path = this[META].replace(/\\0.*/, '')\n break\n }\n\n case 'NextFileHasLongLinkpath': {\n const ex: Pax = this[EX] || Object.create(null)\n this[EX] = ex\n ex.linkpath = this[META].replace(/\\0.*/, '')\n break\n }\n\n /* c8 ignore start */\n default:\n throw new Error('unknown meta: ' + entry.type)\n /* c8 ignore stop */\n }\n }\n\n abort(error: Error) {\n if (this[ABORTED]) {\n return\n }\n if (this[UNZIP]) {\n // fully nerf the decompressor and close its underlying binding\n const u = this[UNZIP]\n /* c8 ignore start */\n u.write = () => true\n u.end = () => u\n u.emit = () => false\n /* c8 ignore stop */\n u.destroy?.()\n }\n this[ABORTED] = true\n this.emit('abort', error)\n // always throws, even in non-strict mode\n this.warn('TAR_ABORT', error, { recoverable: false })\n }\n\n [CHECKDECOMPRESSIONRATIO](chunk: Buffer) {\n this[DECOMPRESSEDBYTESREAD] += chunk.length\n const ratio = this[DECOMPRESSEDBYTESREAD] / this[COMPRESSEDBYTESREAD]\n if (ratio > this.maxDecompressionRatio) {\n this.abort(\n new Error(\n `max decompression ratio exceeded: ${ratio.toFixed(2)} > ${\n this.maxDecompressionRatio\n }`,\n ),\n )\n return false\n }\n return true\n }\n\n write(\n buffer: Uint8Array | string,\n cb?: (err?: Error | null) => void,\n ): boolean\n write(\n str: string,\n encoding?: BufferEncoding,\n cb?: (err?: Error | null) => void,\n ): boolean\n write(\n chunk: Buffer | string,\n encoding?: BufferEncoding | (() => unknown),\n cb?: () => unknown,\n ): boolean {\n if (typeof encoding === 'function') {\n cb = encoding\n encoding = undefined\n }\n if (typeof chunk === 'string') {\n chunk = Buffer.from(\n chunk,\n /* c8 ignore next */\n typeof encoding === 'string' ? encoding : 'utf8',\n )\n }\n if (this[ABORTED]) {\n /* c8 ignore next */\n cb?.()\n return false\n }\n\n // first write, might be gzipped, zstd, or brotli compressed\n const needSniff =\n this[UNZIP] === undefined ||\n (this.brotli === undefined && this[UNZIP] === false)\n if (needSniff && chunk) {\n if (this[BUFFER]) {\n chunk = Buffer.concat([this[BUFFER], chunk])\n this[BUFFER] = undefined\n }\n if (chunk.length < ZIP_HEADER_LEN) {\n this[BUFFER] = chunk\n /* c8 ignore next */\n cb?.()\n return true\n }\n\n // look for gzip header\n for (\n let i = 0;\n this[UNZIP] === undefined && i < gzipHeader.length;\n i++\n ) {\n if (chunk[i] !== gzipHeader[i]) {\n this[UNZIP] = false\n }\n }\n\n // look for zstd header if gzip header not found\n let isZstd = false\n if (this[UNZIP] === false && this.zstd !== false) {\n isZstd = true\n for (let i = 0; i < zstdHeader.length; i++) {\n if (chunk[i] !== zstdHeader[i]) {\n isZstd = false\n break\n }\n }\n }\n\n const maybeBrotli = this.brotli === undefined && !isZstd\n if (this[UNZIP] === false && maybeBrotli) {\n // read the first header to see if it's a valid tar file. If so,\n // we can safely assume that it's not actually brotli, despite the\n // .tbr or .tar.br file extension.\n // if we ended before getting a full chunk, yes, def brotli\n if (chunk.length < 512) {\n if (this[ENDED]) {\n this.brotli = true\n } else {\n this[BUFFER] = chunk\n /* c8 ignore next */\n cb?.()\n return true\n }\n } else {\n // if it's tar, it's pretty reliably not brotli, chances of\n // that happening are astronomical.\n try {\n new Header(chunk.subarray(0, 512))\n this.brotli = false\n } catch (_) {\n this.brotli = true\n }\n }\n }\n\n if (\n this[UNZIP] === undefined ||\n (this[UNZIP] === false && (this.brotli || isZstd))\n ) {\n const ended = this[ENDED]\n this[ENDED] = false\n this[UNZIP] =\n this[UNZIP] === undefined ? new Unzip({})\n : isZstd ? new ZstdDecompress({})\n : new BrotliDecompress({})\n this[UNZIP].on('data', chunk => {\n if (this[CHECKDECOMPRESSIONRATIO](chunk)) {\n this[CONSUMECHUNK](chunk)\n }\n })\n this[UNZIP].on('error', er => {\n if (!this[ABORTED]) {\n this.abort(er as Error)\n }\n })\n this[UNZIP].on('end', () => {\n this[ENDED] = true\n this[CONSUMECHUNK]()\n })\n this[WRITING] = true\n this[COMPRESSEDBYTESREAD] += chunk.length\n const ret = !!this[UNZIP][ended ? 'end' : 'write'](chunk)\n this[WRITING] = false\n cb?.()\n return ret\n }\n }\n\n this[WRITING] = true\n if (this[UNZIP]) {\n this[COMPRESSEDBYTESREAD] += chunk.length\n this[UNZIP].write(chunk)\n } else {\n this[CONSUMECHUNK](chunk)\n }\n this[WRITING] = false\n\n // return false if there's a queue, or if the current entry isn't flowing\n const ret =\n this[QUEUE].length > 0 ? false\n : this[READENTRY] ? this[READENTRY].flowing\n : true\n\n // if we have no queue, then that means a clogged READENTRY\n if (!ret && this[QUEUE].length === 0) {\n this[READENTRY]?.once('drain', () => this.emit('drain'))\n }\n\n /* c8 ignore next */\n cb?.()\n return ret\n }\n\n [BUFFERCONCAT](c: Buffer) {\n if (c && !this[ABORTED]) {\n this[BUFFER] = this[BUFFER] ? Buffer.concat([this[BUFFER], c]) : c\n }\n }\n\n [MAYBEEND]() {\n if (\n this[ENDED] &&\n !this[EMITTEDEND] &&\n !this[ABORTED] &&\n !this[CONSUMING]\n ) {\n this[EMITTEDEND] = true\n const entry = this[WRITEENTRY]\n if (entry?.blockRemain) {\n // truncated, likely a damaged file\n const have = this[BUFFER] ? this[BUFFER].length : 0\n this.warn(\n 'TAR_BAD_ARCHIVE',\n `Truncated input (needed ${entry.blockRemain} more bytes, only ${have} available)`,\n { entry },\n )\n if (this[BUFFER]) {\n entry.write(this[BUFFER])\n }\n entry.end()\n }\n this[EMIT](DONE)\n }\n }\n\n [CONSUMECHUNK](chunk?: Buffer) {\n if (this[CONSUMING] && chunk) {\n this[BUFFERCONCAT](chunk)\n } else if (!chunk && !this[BUFFER]) {\n this[MAYBEEND]()\n } else if (chunk) {\n this[CONSUMING] = true\n if (this[BUFFER]) {\n this[BUFFERCONCAT](chunk)\n const c = this[BUFFER]\n this[BUFFER] = undefined\n this[CONSUMECHUNKSUB](c)\n } else {\n this[CONSUMECHUNKSUB](chunk)\n }\n\n while (\n this[BUFFER] &&\n (this[BUFFER] as Buffer)?.length >= 512 &&\n !this[ABORTED] &&\n !this[SAW_EOF]\n ) {\n const c = this[BUFFER]\n this[BUFFER] = undefined\n this[CONSUMECHUNKSUB](c)\n }\n this[CONSUMING] = false\n }\n\n if (!this[BUFFER] || this[ENDED]) {\n this[MAYBEEND]()\n }\n }\n\n [CONSUMECHUNKSUB](chunk: Buffer) {\n // we know that we are in CONSUMING mode, so anything written goes into\n // the buffer. Advance the position and put any remainder in the buffer.\n let position = 0\n const length = chunk.length\n while (position + 512 <= length && !this[ABORTED] && !this[SAW_EOF]) {\n switch (this[STATE]) {\n case 'begin':\n case 'header':\n this[CONSUMEHEADER](chunk, position)\n position += 512\n break\n\n case 'ignore':\n case 'body':\n position += this[CONSUMEBODY](chunk, position)\n break\n\n case 'meta':\n position += this[CONSUMEMETA](chunk, position)\n break\n\n /* c8 ignore start */\n default:\n throw new Error('invalid state: ' + this[STATE])\n /* c8 ignore stop */\n }\n }\n\n if (position < length) {\n this[BUFFER] =\n this[BUFFER] ?\n Buffer.concat([chunk.subarray(position), this[BUFFER]])\n : chunk.subarray(position)\n }\n }\n\n end(cb?: () => void): this\n end(data: string | Buffer, cb?: () => void): this\n end(str: string, encoding?: BufferEncoding, cb?: () => void): this\n end(\n chunk?: string | Buffer | (() => void),\n encoding?: BufferEncoding | (() => void),\n cb?: () => void,\n ) {\n if (typeof chunk === 'function') {\n cb = chunk\n encoding = undefined\n chunk = undefined\n }\n if (typeof encoding === 'function') {\n cb = encoding\n encoding = undefined\n }\n if (typeof chunk === 'string') {\n chunk = Buffer.from(chunk, encoding)\n }\n if (cb) this.once('finish', cb)\n if (!this[ABORTED]) {\n if (this[UNZIP]) {\n /* c8 ignore start */\n if (chunk) {\n this[COMPRESSEDBYTESREAD] += chunk.length\n this[UNZIP].write(chunk)\n }\n /* c8 ignore stop */\n this[UNZIP].end()\n } else {\n this[ENDED] = true\n if (this.brotli === undefined || this.zstd === undefined)\n chunk = chunk || Buffer.alloc(0)\n if (chunk) this.write(chunk)\n this[MAYBEEND]()\n }\n }\n return this\n }\n}\n", "import assert from 'assert'\nimport { Buffer } from 'buffer'\nimport { Minipass } from 'minipass'\nimport * as realZlib from 'zlib'\nimport { constants } from './constants.js'\nexport { constants } from './constants.js'\n\nconst OriginalBufferConcat = Buffer.concat\nconst desc = Object.getOwnPropertyDescriptor(Buffer, 'concat')\nconst noop = (args: Buffer[]) => args as unknown as Buffer\nconst passthroughBufferConcat =\n desc?.writable === true || desc?.set !== undefined\n ? (makeNoOp: boolean) => {\n Buffer.concat = makeNoOp ? noop : OriginalBufferConcat\n }\n : (_: boolean) => {}\n\nconst _superWrite = Symbol('_superWrite')\n\nexport class ZlibError extends Error {\n code?: string\n errno?: number\n constructor(err: NodeJS.ErrnoException | Error, origin?: Function) {\n super('zlib: ' + err.message, { cause: err })\n this.code = (err as NodeJS.ErrnoException).code\n this.errno = (err as NodeJS.ErrnoException).errno\n /* c8 ignore next */\n if (!this.code) this.code = 'ZLIB_ERROR'\n\n this.message = 'zlib: ' + err.message\n Error.captureStackTrace(this, origin ?? this.constructor)\n }\n\n get name() {\n return 'ZlibError'\n }\n}\n\n// the Zlib class they all inherit from\n// This thing manages the queue of requests, and returns\n// true or false if there is anything in the queue when\n// you call the .write() method.\nconst _flushFlag = Symbol('flushFlag')\n\nexport type ChunkWithFlushFlag = Minipass.ContiguousData & {\n [_flushFlag]?: number\n}\n\nexport type ZlibBaseOptions = Minipass.Options<Minipass.ContiguousData> & {\n flush?: number\n finishFlush?: number\n fullFlushFlag?: number\n}\n\nexport type ZlibHandle =\n | realZlib.Gzip\n | realZlib.Gunzip\n | realZlib.Deflate\n | realZlib.Inflate\n | realZlib.DeflateRaw\n | realZlib.InflateRaw\n | realZlib.BrotliCompress\n | realZlib.BrotliDecompress\n | realZlib.ZstdCompress\n | realZlib.ZstdDecompress\nexport type ZlibMode =\n | 'Gzip'\n | 'Gunzip'\n | 'Deflate'\n | 'Inflate'\n | 'DeflateRaw'\n | 'InflateRaw'\n | 'Unzip'\nexport type BrotliMode = 'BrotliCompress' | 'BrotliDecompress'\nexport type ZstdMode = 'ZstdCompress' | 'ZstdDecompress'\n\nabstract class ZlibBase extends Minipass<Buffer, ChunkWithFlushFlag> {\n #sawError: boolean = false\n #ended: boolean = false\n #flushFlag: number\n #finishFlushFlag: number\n #fullFlushFlag: number\n #handle?: ZlibHandle\n #onError: (err: ZlibError) => any\n\n get sawError() {\n return this.#sawError\n }\n get handle() {\n return this.#handle\n }\n /* c8 ignore start */\n get flushFlag() {\n return this.#flushFlag\n }\n /* c8 ignore stop */\n\n constructor(opts: ZlibBaseOptions, mode: ZlibMode | BrotliMode | ZstdMode) {\n if (!opts || typeof opts !== 'object')\n throw new TypeError('invalid options for ZlibBase constructor')\n\n //@ts-ignore\n super(opts)\n\n /* c8 ignore start */\n this.#flushFlag = opts.flush ?? 0\n this.#finishFlushFlag = opts.finishFlush ?? 0\n this.#fullFlushFlag = opts.fullFlushFlag ?? 0\n /* c8 ignore stop */\n\n //@ts-ignore\n if (typeof realZlib[mode] !== 'function') {\n throw new TypeError('Compression method not supported: ' + mode)\n }\n\n // this will throw if any options are invalid for the class selected\n try {\n // @types/node doesn't know that it exports the classes, but they're there\n //@ts-ignore\n this.#handle = new realZlib[mode](opts)\n } catch (er) {\n // make sure that all errors get decorated properly\n throw new ZlibError(er as NodeJS.ErrnoException, this.constructor)\n }\n\n this.#onError = err => {\n // no sense raising multiple errors, since we abort on the first one.\n if (this.#sawError) return\n\n this.#sawError = true\n\n // there is no way to cleanly recover.\n // continuing only obscures problems.\n this.close()\n this.emit('error', err)\n }\n\n this.#handle?.on('error', er => this.#onError(new ZlibError(er)))\n this.once('end', () => this.close)\n }\n\n close() {\n if (this.#handle) {\n this.#handle.close()\n this.#handle = undefined\n this.emit('close')\n }\n }\n\n reset() {\n if (!this.#sawError) {\n assert(this.#handle, 'zlib binding closed')\n //@ts-ignore\n return this.#handle.reset?.()\n }\n }\n\n flush(flushFlag?: number) {\n if (this.ended) return\n\n if (typeof flushFlag !== 'number') flushFlag = this.#fullFlushFlag\n\n this.write(Object.assign(Buffer.alloc(0), { [_flushFlag]: flushFlag }))\n }\n\n end(cb?: () => void): this\n end(chunk: ChunkWithFlushFlag, cb?: () => void): this\n end(\n chunk: ChunkWithFlushFlag,\n encoding?: Minipass.Encoding,\n cb?: () => void,\n ): this\n end(\n chunk?: ChunkWithFlushFlag | (() => void),\n encoding?: Minipass.Encoding | (() => void),\n cb?: () => void,\n ) {\n /* c8 ignore start */\n if (typeof chunk === 'function') {\n cb = chunk\n encoding = undefined\n chunk = undefined\n }\n if (typeof encoding === 'function') {\n cb = encoding\n encoding = undefined\n }\n /* c8 ignore stop */\n if (chunk) {\n if (encoding) this.write(chunk, encoding)\n else this.write(chunk)\n }\n this.flush(this.#finishFlushFlag)\n this.#ended = true\n return super.end(cb)\n }\n\n get ended() {\n return this.#ended\n }\n\n // overridden in the gzip classes to do portable writes\n [_superWrite](data: Buffer & { [_flushFlag]?: number }) {\n return super.write(data)\n }\n\n write(chunk: ChunkWithFlushFlag, cb?: () => void): boolean\n write(\n chunk: ChunkWithFlushFlag,\n encoding?: Minipass.Encoding,\n cb?: () => void,\n ): boolean\n write(\n chunk: ChunkWithFlushFlag,\n encoding?: Minipass.Encoding | (() => void),\n cb?: () => void,\n ) {\n // process the chunk using the sync process\n // then super.write() all the outputted chunks\n if (typeof encoding === 'function')\n (cb = encoding), (encoding = 'utf8')\n\n if (typeof chunk === 'string')\n chunk = Buffer.from(chunk as string, encoding as BufferEncoding)\n\n if (this.#sawError) return\n assert(this.#handle, 'zlib binding closed')\n\n // _processChunk tries to .close() the native handle after it's done, so we\n // intercept that by temporarily making it a no-op.\n // diving into the node:zlib internals a bit here\n const nativeHandle = (this.#handle as unknown as { _handle: any })\n ._handle\n const originalNativeClose = nativeHandle.close\n nativeHandle.close = () => {}\n const originalClose = this.#handle.close\n this.#handle.close = () => {}\n // It also calls `Buffer.concat()` at the end, which may be convenient\n // for some, but which we are not interested in as it slows us down.\n passthroughBufferConcat(true)\n let result: undefined | Buffer | Buffer[] = undefined\n try {\n const flushFlag =\n typeof chunk[_flushFlag] === 'number'\n ? chunk[_flushFlag]\n : this.#flushFlag\n result = (\n this.#handle as unknown as {\n _processChunk: (chunk: Buffer, flushFlag: number) => Buffer[]\n }\n )._processChunk(chunk as Buffer, flushFlag)\n // if we don't throw, reset it back how it was\n passthroughBufferConcat(false)\n } catch (err) {\n // or if we do, put Buffer.concat() back before we emit error\n // Error events call into user code, which may call Buffer.concat()\n passthroughBufferConcat(false)\n this.#onError(new ZlibError(err as NodeJS.ErrnoException, this.write))\n } finally {\n if (this.#handle) {\n // Core zlib resets `_handle` to null after attempting to close the\n // native handle. Our no-op handler prevented actual closure, but we\n // need to restore the `._handle` property.\n ;(this.#handle as unknown as { _handle: any })._handle =\n nativeHandle\n nativeHandle.close = originalNativeClose\n this.#handle.close = originalClose\n // `_processChunk()` adds an 'error' listener. If we don't remove it\n // after each call, these handlers start piling up.\n this.#handle.removeAllListeners('error')\n // make sure OUR error listener is still attached tho\n }\n }\n\n if (this.#handle)\n this.#handle.on('error', er => this.#onError(new ZlibError(er, this.write)))\n\n let writeReturn\n if (result) {\n if (Array.isArray(result) && result.length > 0) {\n const r = result[0]\n // The first buffer is always `handle._outBuffer`, which would be\n // re-used for later invocations; so, we always have to copy that one.\n writeReturn = this[_superWrite](Buffer.from(r as Buffer))\n for (let i = 1; i < result.length; i++) {\n writeReturn = this[_superWrite](result[i] as Buffer)\n }\n } else {\n // either a single Buffer or an empty array\n writeReturn = this[_superWrite](Buffer.from(result as Buffer | []))\n }\n }\n\n if (cb) cb()\n return writeReturn\n }\n}\n\nexport type ZlibOptions = ZlibBaseOptions & {\n level?: number\n strategy?: number\n}\n\nexport class Zlib extends ZlibBase {\n #level?: number\n #strategy?: number\n\n constructor(opts: ZlibOptions, mode: ZlibMode) {\n opts = opts || {}\n\n opts.flush = opts.flush || constants.Z_NO_FLUSH\n opts.finishFlush = opts.finishFlush || constants.Z_FINISH\n opts.fullFlushFlag = constants.Z_FULL_FLUSH\n super(opts, mode)\n\n this.#level = opts.level\n this.#strategy = opts.strategy\n }\n\n params(level: number, strategy: number) {\n if (this.sawError) return\n\n if (!this.handle)\n throw new Error('cannot switch params when binding is closed')\n\n // no way to test this without also not supporting params at all\n /* c8 ignore start */\n if (!(this.handle as { params?: any }).params)\n throw new Error('not supported in this implementation')\n /* c8 ignore stop */\n\n if (this.#level !== level || this.#strategy !== strategy) {\n this.flush(constants.Z_SYNC_FLUSH)\n assert(this.handle, 'zlib binding closed')\n // .params() calls .flush(), but the latter is always async in the\n // core zlib. We override .flush() temporarily to intercept that and\n // flush synchronously.\n const origFlush = this.handle.flush\n this.handle.flush = (\n flushFlag?: (() => void) | number,\n cb?: () => void,\n ) => {\n /* c8 ignore start */\n if (typeof flushFlag === 'function') {\n cb = flushFlag\n flushFlag = this.flushFlag\n }\n /* c8 ignore stop */\n this.flush(flushFlag)\n cb?.()\n }\n try {\n ;(\n this.handle as unknown as {\n params: (level?: number, strategy?: number) => void\n }\n ).params(level, strategy)\n } finally {\n this.handle.flush = origFlush\n }\n /* c8 ignore start */\n if (this.handle) {\n this.#level = level\n this.#strategy = strategy\n }\n /* c8 ignore stop */\n }\n }\n}\n\n// minimal 2-byte header\nexport class Deflate extends Zlib {\n constructor(opts: ZlibOptions) {\n super(opts, 'Deflate')\n }\n}\n\nexport class Inflate extends Zlib {\n constructor(opts: ZlibOptions) {\n super(opts, 'Inflate')\n }\n}\n\n// gzip - bigger header, same deflate compression\nexport type GzipOptions = ZlibOptions & { portable?: boolean }\nexport class Gzip extends Zlib {\n #portable: boolean\n constructor(opts: GzipOptions) {\n super(opts, 'Gzip')\n this.#portable = opts && !!opts.portable\n }\n\n [_superWrite](data: Buffer & { [_flushFlag]?: number }) {\n if (!this.#portable) return super[_superWrite](data)\n\n // we'll always get the header emitted in one first chunk\n // overwrite the OS indicator byte with 0xFF\n this.#portable = false\n data[9] = 255\n return super[_superWrite](data)\n }\n}\n\nexport class Gunzip extends Zlib {\n constructor(opts: ZlibOptions) {\n super(opts, 'Gunzip')\n }\n}\n\n// raw - no header\nexport class DeflateRaw extends Zlib {\n constructor(opts: ZlibOptions) {\n super(opts, 'DeflateRaw')\n }\n}\n\nexport class InflateRaw extends Zlib {\n constructor(opts: ZlibOptions) {\n super(opts, 'InflateRaw')\n }\n}\n\n// auto-detect header.\nexport class Unzip extends Zlib {\n constructor(opts: ZlibOptions) {\n super(opts, 'Unzip')\n }\n}\n\nclass Brotli extends ZlibBase {\n constructor(opts: ZlibOptions, mode: BrotliMode) {\n opts = opts || {}\n\n opts.flush = opts.flush || constants.BROTLI_OPERATION_PROCESS\n opts.finishFlush =\n opts.finishFlush || constants.BROTLI_OPERATION_FINISH\n opts.fullFlushFlag = constants.BROTLI_OPERATION_FLUSH\n super(opts, mode)\n }\n}\n\nexport class BrotliCompress extends Brotli {\n constructor(opts: ZlibOptions) {\n super(opts, 'BrotliCompress')\n }\n}\n\nexport class BrotliDecompress extends Brotli {\n constructor(opts: ZlibOptions) {\n super(opts, 'BrotliDecompress')\n }\n}\n\nclass Zstd extends ZlibBase {\n constructor(opts: ZlibOptions, mode: ZstdMode) {\n opts = opts || {}\n\n opts.flush = opts.flush || constants.ZSTD_e_continue\n opts.finishFlush = opts.finishFlush || constants.ZSTD_e_end\n opts.fullFlushFlag = constants.ZSTD_e_flush\n super(opts, mode)\n }\n}\n\nexport class ZstdCompress extends Zstd {\n constructor(opts: ZlibOptions) {\n super(opts, 'ZstdCompress')\n }\n}\n\nexport class ZstdDecompress extends Zstd {\n constructor(opts: ZlibOptions) {\n super(opts, 'ZstdDecompress')\n }\n}\n", "// Update with any zlib constants that are added or changed in the future.\n// Node v6 didn't export this, so we just hard code the version and rely\n// on all the other hard-coded values from zlib v4736. When node v6\n// support drops, we can just export the realZlibConstants object.\nimport realZlib from 'zlib'\n/* c8 ignore start */\nconst realZlibConstants = realZlib.constants || { ZLIB_VERNUM: 4736 }\n/* c8 ignore stop */\n\nexport const constants = Object.freeze(\n Object.assign(\n Object.create(null),\n {\n Z_NO_FLUSH: 0,\n Z_PARTIAL_FLUSH: 1,\n Z_SYNC_FLUSH: 2,\n Z_FULL_FLUSH: 3,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_OK: 0,\n Z_STREAM_END: 1,\n Z_NEED_DICT: 2,\n Z_ERRNO: -1,\n Z_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n Z_VERSION_ERROR: -6,\n Z_NO_COMPRESSION: 0,\n Z_BEST_SPEED: 1,\n Z_BEST_COMPRESSION: 9,\n Z_DEFAULT_COMPRESSION: -1,\n Z_FILTERED: 1,\n Z_HUFFMAN_ONLY: 2,\n Z_RLE: 3,\n Z_FIXED: 4,\n Z_DEFAULT_STRATEGY: 0,\n DEFLATE: 1,\n INFLATE: 2,\n GZIP: 3,\n GUNZIP: 4,\n DEFLATERAW: 5,\n INFLATERAW: 6,\n UNZIP: 7,\n BROTLI_DECODE: 8,\n BROTLI_ENCODE: 9,\n Z_MIN_WINDOWBITS: 8,\n Z_MAX_WINDOWBITS: 15,\n Z_DEFAULT_WINDOWBITS: 15,\n Z_MIN_CHUNK: 64,\n Z_MAX_CHUNK: Infinity,\n Z_DEFAULT_CHUNK: 16384,\n Z_MIN_MEMLEVEL: 1,\n Z_MAX_MEMLEVEL: 9,\n Z_DEFAULT_MEMLEVEL: 8,\n Z_MIN_LEVEL: -1,\n Z_MAX_LEVEL: 9,\n Z_DEFAULT_LEVEL: -1,\n BROTLI_OPERATION_PROCESS: 0,\n BROTLI_OPERATION_FLUSH: 1,\n BROTLI_OPERATION_FINISH: 2,\n BROTLI_OPERATION_EMIT_METADATA: 3,\n BROTLI_MODE_GENERIC: 0,\n BROTLI_MODE_TEXT: 1,\n BROTLI_MODE_FONT: 2,\n BROTLI_DEFAULT_MODE: 0,\n BROTLI_MIN_QUALITY: 0,\n BROTLI_MAX_QUALITY: 11,\n BROTLI_DEFAULT_QUALITY: 11,\n BROTLI_MIN_WINDOW_BITS: 10,\n BROTLI_MAX_WINDOW_BITS: 24,\n BROTLI_LARGE_MAX_WINDOW_BITS: 30,\n BROTLI_DEFAULT_WINDOW: 22,\n BROTLI_MIN_INPUT_BLOCK_BITS: 16,\n BROTLI_MAX_INPUT_BLOCK_BITS: 24,\n BROTLI_PARAM_MODE: 0,\n BROTLI_PARAM_QUALITY: 1,\n BROTLI_PARAM_LGWIN: 2,\n BROTLI_PARAM_LGBLOCK: 3,\n BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING: 4,\n BROTLI_PARAM_SIZE_HINT: 5,\n BROTLI_PARAM_LARGE_WINDOW: 6,\n BROTLI_PARAM_NPOSTFIX: 7,\n BROTLI_PARAM_NDIRECT: 8,\n BROTLI_DECODER_RESULT_ERROR: 0,\n BROTLI_DECODER_RESULT_SUCCESS: 1,\n BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT: 2,\n BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT: 3,\n BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION: 0,\n BROTLI_DECODER_PARAM_LARGE_WINDOW: 1,\n BROTLI_DECODER_NO_ERROR: 0,\n BROTLI_DECODER_SUCCESS: 1,\n BROTLI_DECODER_NEEDS_MORE_INPUT: 2,\n BROTLI_DECODER_NEEDS_MORE_OUTPUT: 3,\n BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE: -1,\n BROTLI_DECODER_ERROR_FORMAT_RESERVED: -2,\n BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE: -3,\n BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET: -4,\n BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME: -5,\n BROTLI_DECODER_ERROR_FORMAT_CL_SPACE: -6,\n BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE: -7,\n BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT: -8,\n BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1: -9,\n BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2: -10,\n BROTLI_DECODER_ERROR_FORMAT_TRANSFORM: -11,\n BROTLI_DECODER_ERROR_FORMAT_DICTIONARY: -12,\n BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS: -13,\n BROTLI_DECODER_ERROR_FORMAT_PADDING_1: -14,\n BROTLI_DECODER_ERROR_FORMAT_PADDING_2: -15,\n BROTLI_DECODER_ERROR_FORMAT_DISTANCE: -16,\n BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET: -19,\n BROTLI_DECODER_ERROR_INVALID_ARGUMENTS: -20,\n BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES: -21,\n BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS: -22,\n BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP: -25,\n BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1: -26,\n BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2: -27,\n BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES: -30,\n BROTLI_DECODER_ERROR_UNREACHABLE: -31,\n },\n realZlibConstants,\n ),\n)\n", "// parse a 512-byte header block to a data object, or vice-versa\n// encode returns `true` if a pax extended header is needed, because\n// the data could not be faithfully encoded in a simple header.\n// (Also, check header.needPax to see if it needs a pax header.)\n\nimport { posix as pathModule } from 'node:path'\nimport * as large from './large-numbers.js'\nimport type { EntryTypeCode, EntryTypeName } from './types.js'\nimport * as types from './types.js'\n\nconst notNegative = (n?: number): number | undefined =>\n n === undefined || n < 0 ? undefined : n\n\nexport type HeaderData = {\n path?: string\n mode?: number\n uid?: number\n gid?: number\n size?: number\n cksum?: number\n type?: EntryTypeName | 'Unsupported'\n linkpath?: string\n uname?: string\n gname?: string\n devmaj?: number\n devmin?: number\n atime?: Date\n ctime?: Date\n mtime?: Date\n\n // fields that are common in extended PAX headers, but not in the\n // \"standard\" tar header block\n charset?: string\n comment?: string\n dev?: number\n ino?: number\n nlink?: number\n}\n\nexport class Header implements HeaderData {\n cksumValid: boolean = false\n needPax: boolean = false\n nullBlock: boolean = false\n\n block?: Buffer\n path?: string\n mode?: number\n uid?: number\n gid?: number\n size?: number\n cksum?: number\n #type: EntryTypeCode | 'Unsupported' = 'Unsupported'\n linkpath?: string\n uname?: string\n gname?: string\n devmaj: number = 0\n devmin: number = 0\n atime?: Date\n ctime?: Date\n mtime?: Date\n\n charset?: string\n comment?: string\n\n constructor(\n data?: Buffer | HeaderData,\n off: number = 0,\n ex?: HeaderData,\n gex?: HeaderData,\n ) {\n if (Buffer.isBuffer(data)) {\n this.decode(data, off || 0, ex, gex)\n } else if (data) {\n this.#slurp(data)\n }\n }\n\n decode(buf: Buffer, off: number, ex?: HeaderData, gex?: HeaderData) {\n if (!off) {\n off = 0\n }\n\n if (!buf || !(buf.length >= off + 512)) {\n throw new Error('need 512 bytes for header')\n }\n\n // Decode the typeflag (independent of any pending PAX/GNU extended header)\n // up front so we can tell whether THIS block is itself an intermediary\n // extension header (PAX `x`/`g`, GNU long-name `L`, GNU long-link `K`).\n // Per POSIX pax, a PAX extended header describes the *next file entry*, not\n // the extension headers that may sit between it and that file. Applying the\n // pending PAX overrides (notably `size`) to an intervening `L`/`K`/`x`/`g`\n // header desynchronizes the stream relative to other tar implementations\n // and enables tar interpretation-conflict / file-smuggling attacks.\n const t = decString(buf, off + 156, 1)\n const isNormalFS = types.normalFsTypes.has(t as EntryTypeCode)\n const exForFields = isNormalFS ? ex : undefined\n const gexForFields = isNormalFS ? gex : undefined\n\n this.path = exForFields?.path ?? decString(buf, off, 100)\n this.mode =\n exForFields?.mode ??\n gexForFields?.mode ??\n decNumber(buf, off + 100, 8)\n this.uid =\n exForFields?.uid ?? gexForFields?.uid ?? decNumber(buf, off + 108, 8)\n this.gid =\n exForFields?.gid ?? gexForFields?.gid ?? decNumber(buf, off + 116, 8)\n\n this.size = notNegative(\n exForFields?.size ??\n gexForFields?.size ??\n decNumber(buf, off + 124, 12),\n )\n this.mtime =\n exForFields?.mtime ??\n gexForFields?.mtime ??\n decDate(buf, off + 136, 12)\n this.cksum = decNumber(buf, off + 148, 12)\n\n // if we have extended or global extended headers, apply them now\n // See https://github.com/npm/node-tar/pull/187\n // Apply global before local, so it overrides. Never slurp the pending\n // extended-header fields onto an intermediary extension header.\n if (gexForFields) this.#slurp(gexForFields, true)\n if (exForFields) this.#slurp(exForFields)\n\n // old tar versions marked dirs as a file with a trailing /\n if (types.isCode(t)) {\n this.#type = t || '0'\n }\n if (this.#type === '0' && this.path.slice(-1) === '/') {\n this.#type = '5'\n }\n\n // tar implementations sometimes incorrectly put the stat(dir).size\n // as the size in the tarball, even though Directory entries are\n // not able to have any body at all. In the very rare chance that\n // it actually DOES have a body, we weren't going to do anything with\n // it anyway, and it'll just be a warning about an invalid header.\n if (this.#type === '5') {\n this.size = 0\n }\n\n this.linkpath = decString(buf, off + 157, 100)\n if (\n buf.subarray(off + 257, off + 265).toString() === 'ustar\\u000000'\n ) {\n /* c8 ignore start */\n this.uname =\n exForFields?.uname ??\n gexForFields?.uname ??\n decString(buf, off + 265, 32)\n this.gname =\n exForFields?.gname ??\n gexForFields?.gname ??\n decString(buf, off + 297, 32)\n this.devmaj =\n exForFields?.devmaj ??\n gexForFields?.devmaj ??\n decNumber(buf, off + 329, 8) ??\n 0\n this.devmin =\n exForFields?.devmin ??\n gexForFields?.devmin ??\n decNumber(buf, off + 337, 8) ??\n 0\n /* c8 ignore stop */\n if (buf[off + 475] !== 0) {\n // definitely a prefix, definitely >130 chars.\n const prefix = decString(buf, off + 345, 155)\n this.path = prefix + '/' + this.path\n } else {\n const prefix = decString(buf, off + 345, 130)\n if (prefix) {\n this.path = prefix + '/' + this.path\n }\n /* c8 ignore start */\n this.atime = ex?.atime ?? gex?.atime ?? decDate(buf, off + 476, 12)\n this.ctime = ex?.ctime ?? gex?.ctime ?? decDate(buf, off + 488, 12)\n /* c8 ignore stop */\n }\n }\n\n let sum = 8 * 0x20\n for (let i = off; i < off + 148; i++) {\n sum += buf[i] as number\n }\n\n for (let i = off + 156; i < off + 512; i++) {\n sum += buf[i] as number\n }\n\n this.cksumValid = sum === this.cksum\n if (this.cksum === undefined && sum === 8 * 0x20) {\n this.nullBlock = true\n }\n }\n\n #slurp(ex: HeaderData, gex: boolean = false) {\n Object.assign(\n this,\n Object.fromEntries(\n Object.entries(ex).filter(([k, v]) => {\n // we slurp in everything except for the path attribute in\n // a global extended header, because that's weird. Also, any\n // null/undefined values are ignored.\n return !(\n v === null ||\n v === undefined ||\n (k === 'size' && Number(v) < 0) ||\n (k === 'path' && gex) ||\n (k === 'linkpath' && gex) ||\n k === 'global'\n )\n }),\n ),\n )\n }\n\n encode(buf?: Buffer, off: number = 0) {\n if (!buf) {\n buf = this.block = Buffer.alloc(512)\n }\n\n if (this.#type === 'Unsupported') {\n this.#type = '0'\n }\n\n if (!(buf.length >= off + 512)) {\n throw new Error('need 512 bytes for header')\n }\n\n const prefixSize = this.ctime || this.atime ? 130 : 155\n const split = splitPrefix(this.path || '', prefixSize)\n const path = split[0]\n const prefix = split[1]\n this.needPax = !!split[2]\n\n this.needPax = encString(buf, off, 100, path) || this.needPax\n this.needPax = encNumber(buf, off + 100, 8, this.mode) || this.needPax\n this.needPax = encNumber(buf, off + 108, 8, this.uid) || this.needPax\n this.needPax = encNumber(buf, off + 116, 8, this.gid) || this.needPax\n this.needPax = encNumber(buf, off + 124, 12, this.size) || this.needPax\n this.needPax = encDate(buf, off + 136, 12, this.mtime) || this.needPax\n buf[off + 156] = Number(this.#type.codePointAt(0))\n this.needPax =\n encString(buf, off + 157, 100, this.linkpath) || this.needPax\n buf.write('ustar\\u000000', off + 257, 8)\n this.needPax =\n encString(buf, off + 265, 32, this.uname) || this.needPax\n this.needPax =\n encString(buf, off + 297, 32, this.gname) || this.needPax\n this.needPax =\n encNumber(buf, off + 329, 8, this.devmaj) || this.needPax\n this.needPax =\n encNumber(buf, off + 337, 8, this.devmin) || this.needPax\n this.needPax =\n encString(buf, off + 345, prefixSize, prefix) || this.needPax\n if (buf[off + 475] !== 0) {\n this.needPax = encString(buf, off + 345, 155, prefix) || this.needPax\n } else {\n this.needPax = encString(buf, off + 345, 130, prefix) || this.needPax\n this.needPax =\n encDate(buf, off + 476, 12, this.atime) || this.needPax\n this.needPax =\n encDate(buf, off + 488, 12, this.ctime) || this.needPax\n }\n\n let sum = 8 * 0x20\n for (let i = off; i < off + 148; i++) {\n sum += buf[i] as number\n }\n\n for (let i = off + 156; i < off + 512; i++) {\n sum += buf[i] as number\n }\n\n this.cksum = sum\n encNumber(buf, off + 148, 8, this.cksum)\n this.cksumValid = true\n\n return this.needPax\n }\n\n get type(): EntryTypeName {\n return (\n this.#type === 'Unsupported' ?\n this.#type\n : types.name.get(this.#type)) as EntryTypeName\n }\n\n get typeKey(): EntryTypeCode | 'Unsupported' {\n return this.#type\n }\n\n set type(type: EntryTypeCode | EntryTypeName | 'Unsupported') {\n const c = String(types.code.get(type as EntryTypeName))\n if (types.isCode(c) || c === 'Unsupported') {\n this.#type = c\n } else if (types.isCode(type)) {\n this.#type = type\n } else {\n throw new TypeError('invalid entry type: ' + type)\n }\n }\n}\n\nconst splitPrefix = (\n p: string,\n prefixSize: number,\n): [string, string, boolean] => {\n const pathSize = 100\n let pp = p\n let prefix = ''\n let ret: undefined | [string, string, boolean] = undefined\n const root = pathModule.parse(p).root || '.'\n\n if (Buffer.byteLength(pp) < pathSize) {\n ret = [pp, prefix, false]\n } else {\n // first set prefix to the dir, and path to the base\n prefix = pathModule.dirname(pp)\n pp = pathModule.basename(pp)\n\n do {\n if (\n Buffer.byteLength(pp) <= pathSize &&\n Buffer.byteLength(prefix) <= prefixSize\n ) {\n // both fit!\n ret = [pp, prefix, false]\n } else if (\n Buffer.byteLength(pp) > pathSize &&\n Buffer.byteLength(prefix) <= prefixSize\n ) {\n // prefix fits in prefix, but path doesn't fit in path\n ret = [pp.slice(0, pathSize - 1), prefix, true]\n } else {\n // make path take a bit from prefix\n pp = pathModule.join(pathModule.basename(prefix), pp)\n prefix = pathModule.dirname(prefix)\n }\n } while (prefix !== root && ret === undefined)\n\n // at this point, found no resolution, just truncate\n if (!ret) {\n ret = [p.slice(0, pathSize - 1), '', true]\n }\n }\n return ret\n}\n\nconst decString = (buf: Buffer, off: number, size: number) =>\n buf\n .subarray(off, off + size)\n .toString('utf8')\n .replace(/\\0.*/, '')\n\nconst decDate = (buf: Buffer, off: number, size: number) =>\n numToDate(decNumber(buf, off, size))\n\nconst numToDate = (num?: number) =>\n num === undefined ? undefined : new Date(num * 1000)\n\nconst decNumber = (buf: Buffer, off: number, size: number) =>\n Number(buf[off]) & 0x80 ?\n large.parse(buf.subarray(off, off + size))\n : decSmallNumber(buf, off, size)\n\nconst nanUndef = (value: number) => (isNaN(value) ? undefined : value)\n\nconst decSmallNumber = (buf: Buffer, off: number, size: number) =>\n nanUndef(\n parseInt(\n buf\n .subarray(off, off + size)\n .toString('utf8')\n .replace(/\\0.*$/, '')\n .trim(),\n 8,\n ),\n )\n\n// the maximum encodable as a null-terminated octal, by field size\nconst MAXNUM = {\n 12: 0o77777777777,\n 8: 0o7777777,\n}\n\nconst encNumber = (\n buf: Buffer,\n off: number,\n size: 12 | 8,\n num?: number,\n) =>\n num === undefined ? false\n : num > MAXNUM[size] || num < 0 ?\n (large.encode(num, buf.subarray(off, off + size)), true)\n : (encSmallNumber(buf, off, size, num), false)\n\nconst encSmallNumber = (\n buf: Buffer,\n off: number,\n size: number,\n num: number,\n) => buf.write(octalString(num, size), off, size, 'ascii')\n\nconst octalString = (num: number, size: number) =>\n padOctal(Math.floor(num).toString(8), size)\n\nconst padOctal = (str: string, size: number) =>\n (str.length === size - 1 ?\n str\n : new Array(size - str.length - 1).join('0') + str + ' ') + '\\0'\n\nconst encDate = (buf: Buffer, off: number, size: 8 | 12, date?: Date) =>\n date === undefined ? false : (\n encNumber(buf, off, size, date.getTime() / 1000)\n )\n\n// enough to fill the longest string we've got\nconst NULLS = new Array(156).join('\\0')\n// pad with nulls, return true if it's longer or non-ascii\nconst encString = (\n buf: Buffer,\n off: number,\n size: number,\n str?: string,\n) =>\n str === undefined ? false : (\n (buf.write(str + NULLS, off, size, 'utf8'),\n str.length !== Buffer.byteLength(str) || str.length > size)\n )\n", "// Tar can encode large and negative numbers using a leading byte of\n// 0xff for negative, and 0x80 for positive.\n\nexport const encode = (num: number, buf: Buffer) => {\n if (!Number.isSafeInteger(num)) {\n // The number is so large that javascript cannot represent it with integer\n // precision.\n throw Error(\n 'cannot encode number outside of javascript safe integer range',\n )\n } else if (num < 0) {\n encodeNegative(num, buf)\n } else {\n encodePositive(num, buf)\n }\n return buf\n}\n\nconst encodePositive = (num: number, buf: Buffer) => {\n buf[0] = 0x80\n\n for (var i = buf.length; i > 1; i--) {\n buf[i - 1] = num & 0xff\n num = Math.floor(num / 0x100)\n }\n}\n\nconst encodeNegative = (num: number, buf: Buffer) => {\n buf[0] = 0xff\n var flipped = false\n num = num * -1\n for (var i = buf.length; i > 1; i--) {\n var byte = num & 0xff\n num = Math.floor(num / 0x100)\n if (flipped) {\n buf[i - 1] = onesComp(byte)\n } else if (byte === 0) {\n buf[i - 1] = 0\n } else {\n flipped = true\n buf[i - 1] = twosComp(byte)\n }\n }\n}\n\nexport const parse = (buf: Buffer) => {\n const pre = buf[0]\n const value =\n pre === 0x80 ? pos(buf.subarray(1, buf.length))\n : pre === 0xff ? twos(buf)\n : null\n if (value === null) {\n throw Error('invalid base256 encoding')\n }\n\n if (!Number.isSafeInteger(value)) {\n // The number is so large that javascript cannot represent it with integer\n // precision.\n throw Error('parsed number outside of javascript safe integer range')\n }\n\n return value\n}\n\nconst twos = (buf: Buffer) => {\n var len = buf.length\n var sum = 0\n var flipped = false\n for (var i = len - 1; i > -1; i--) {\n var byte = Number(buf[i])\n var f\n if (flipped) {\n f = onesComp(byte)\n } else if (byte === 0) {\n f = byte\n } else {\n flipped = true\n f = twosComp(byte)\n }\n if (f !== 0) {\n sum -= f * Math.pow(256, len - i - 1)\n }\n }\n return sum\n}\n\nconst pos = (buf: Buffer) => {\n var len = buf.length\n var sum = 0\n for (var i = len - 1; i > -1; i--) {\n var byte = Number(buf[i])\n if (byte !== 0) {\n sum += byte * Math.pow(256, len - i - 1)\n }\n }\n return sum\n}\n\nconst onesComp = (byte: number) => (0xff ^ byte) & 0xff\n\nconst twosComp = (byte: number) => ((0xff ^ byte) + 1) & 0xff\n", "export const isCode = (c: string): c is EntryTypeCode =>\n name.has(c as EntryTypeCode)\n\nexport const isName = (c: string): c is EntryTypeName =>\n code.has(c as EntryTypeName)\n\nexport type EntryTypeCode =\n | '0'\n | ''\n | '1'\n | '2'\n | '3'\n | '4'\n | '5'\n | '6'\n | '7'\n | 'g'\n | 'x'\n | 'A'\n | 'D'\n | 'I'\n | 'K'\n | 'L'\n | 'M'\n | 'N'\n | 'S'\n | 'V'\n | 'X'\n\nexport type EntryTypeName =\n | 'File'\n | 'OldFile'\n | 'Link'\n | 'SymbolicLink'\n | 'CharacterDevice'\n | 'BlockDevice'\n | 'Directory'\n | 'FIFO'\n | 'ContiguousFile'\n | 'GlobalExtendedHeader'\n | 'ExtendedHeader'\n | 'SolarisACL'\n | 'GNUDumpDir'\n | 'Inode'\n | 'NextFileHasLongLinkpath'\n | 'NextFileHasLongPath'\n | 'ContinuationFile'\n | 'OldGnuLongPath'\n | 'SparseFile'\n | 'TapeVolumeHeader'\n | 'OldExtendedHeader'\n | 'Unsupported'\n\n/**\n * types that are a normal file system entry, not metadata.\n *\n * These can be the subject of extended/globalExtended headers, long path\n * names, long linkpath names, etc.\n *\n * Any other types are meta, and cannot be targetted by extended PAX headers.\n */\nexport const normalFsTypes = new Set<EntryTypeCode>([\n '0',\n '',\n '1',\n '2',\n '3',\n '4',\n '5',\n '6',\n '7',\n 'D',\n])\n\n// map types from key to human-friendly name\nexport const name = new Map<EntryTypeCode, EntryTypeName>([\n ['0', 'File'],\n // same as File\n ['', 'OldFile'],\n ['1', 'Link'],\n ['2', 'SymbolicLink'],\n // Devices and FIFOs aren't fully supported\n // they are parsed, but skipped when unpacking\n ['3', 'CharacterDevice'],\n ['4', 'BlockDevice'],\n ['5', 'Directory'],\n ['6', 'FIFO'],\n // same as File\n ['7', 'ContiguousFile'],\n // pax headers\n ['g', 'GlobalExtendedHeader'],\n ['x', 'ExtendedHeader'],\n // vendor-specific stuff\n // skip\n ['A', 'SolarisACL'],\n // like 5, but with data, which should be skipped\n ['D', 'GNUDumpDir'],\n // metadata only, skip\n ['I', 'Inode'],\n // data = link path of next file\n ['K', 'NextFileHasLongLinkpath'],\n // data = path of next file\n ['L', 'NextFileHasLongPath'],\n // skip\n ['M', 'ContinuationFile'],\n // like L\n ['N', 'OldGnuLongPath'],\n // skip\n ['S', 'SparseFile'],\n // skip\n ['V', 'TapeVolumeHeader'],\n // like x\n ['X', 'OldExtendedHeader'],\n])\n\n// map the other direction\nexport const code = new Map<EntryTypeName, EntryTypeCode>(\n Array.from(name).map(kv => [kv[1], kv[0]]),\n)\n", "import { basename } from 'node:path'\nimport type { HeaderData } from './header.js'\nimport { Header } from './header.js'\n\nexport class Pax implements HeaderData {\n atime?: Date\n mtime?: Date\n ctime?: Date\n\n charset?: string\n comment?: string\n\n gid?: number\n uid?: number\n\n gname?: string\n uname?: string\n linkpath?: string\n dev?: number\n ino?: number\n nlink?: number\n path?: string\n size?: number\n mode?: number\n\n global: boolean\n\n constructor(obj: HeaderData, global: boolean = false) {\n this.atime = obj.atime\n this.charset = obj.charset\n this.comment = obj.comment\n this.ctime = obj.ctime\n this.dev = obj.dev\n this.gid = obj.gid\n this.global = global\n this.gname = obj.gname\n this.ino = obj.ino\n this.linkpath = obj.linkpath\n this.mtime = obj.mtime\n this.nlink = obj.nlink\n this.path = obj.path\n this.size = obj.size\n this.uid = obj.uid\n this.uname = obj.uname\n }\n\n encode() {\n const body = this.encodeBody()\n if (body === '') {\n return Buffer.allocUnsafe(0)\n }\n\n const bodyLen = Buffer.byteLength(body)\n // round up to 512 bytes\n // add 512 for header\n const bufLen = 512 * Math.ceil(1 + bodyLen / 512)\n const buf = Buffer.allocUnsafe(bufLen)\n\n // 0-fill the header section, it might not hit every field\n for (let i = 0; i < 512; i++) {\n buf[i] = 0\n }\n\n new Header({\n // XXX split the path\n // then the path should be PaxHeader + basename, but less than 99,\n // prepend with the dirname\n /* c8 ignore start */\n path: ('PaxHeader/' + basename(this.path ?? '')).slice(0, 99),\n /* c8 ignore stop */\n mode: this.mode || 0o644,\n uid: this.uid,\n gid: this.gid,\n size: bodyLen,\n mtime: this.mtime,\n type: this.global ? 'GlobalExtendedHeader' : 'ExtendedHeader',\n linkpath: '',\n uname: this.uname || '',\n gname: this.gname || '',\n devmaj: 0,\n devmin: 0,\n atime: this.atime,\n ctime: this.ctime,\n }).encode(buf)\n\n buf.write(body, 512, bodyLen, 'utf8')\n\n // null pad after the body\n for (let i = bodyLen + 512; i < buf.length; i++) {\n buf[i] = 0\n }\n\n return buf\n }\n\n encodeBody() {\n return (\n this.encodeField('path') +\n this.encodeField('ctime') +\n this.encodeField('atime') +\n this.encodeField('dev') +\n this.encodeField('ino') +\n this.encodeField('nlink') +\n this.encodeField('charset') +\n this.encodeField('comment') +\n this.encodeField('gid') +\n this.encodeField('gname') +\n this.encodeField('linkpath') +\n this.encodeField('mtime') +\n this.encodeField('size') +\n this.encodeField('uid') +\n this.encodeField('uname')\n )\n }\n\n encodeField(field: keyof Pax): string {\n if (this[field] === undefined) {\n return ''\n }\n const r = this[field]\n const v = r instanceof Date ? r.getTime() / 1000 : r\n const s =\n ' ' +\n (field === 'dev' || field === 'ino' || field === 'nlink' ?\n 'SCHILY.'\n : '') +\n field +\n '=' +\n v +\n '\\n'\n const byteLen = Buffer.byteLength(s)\n // the digits includes the length of the digits in ascii base-10\n // so if it's 9 characters, then adding 1 for the 9 makes it 10\n // which makes it 11 chars.\n let digits = Math.floor(Math.log(byteLen) / Math.log(10)) + 1\n if (byteLen + digits >= Math.pow(10, digits)) {\n digits += 1\n }\n const len = digits + byteLen\n return len + s\n }\n\n static parse(str: string, ex?: HeaderData, g: boolean = false) {\n return new Pax(merge(parseKV(str), ex), g)\n }\n}\n\nconst merge = (a: HeaderData, b?: HeaderData) =>\n b ? Object.assign({}, b, a) : a\n\nconst parseKV = (str: string) =>\n str\n .replace(/\\n$/, '')\n .split('\\n')\n .reduce(parseKVLine, Object.create(null))\n\nconst parseKVLine = (\n set: Record<string, string | number | Date>,\n line: string,\n) => {\n const n = parseInt(line, 10)\n\n // XXX Values with \\n in them will fail this.\n // Refactor to not be a naive line-by-line parse.\n if (n !== Buffer.byteLength(line) + 1) {\n return set\n }\n\n line = line.slice((n + ' ').length)\n const kv = line.split('=')\n const r = kv.shift()\n\n if (!r) {\n return set\n }\n\n const k = r.replace(/^SCHILY\\.(dev|ino|nlink)/, '$1')\n\n const v = kv.join('=').replace(/\\0.*/, '')\n switch (k) {\n case 'path':\n case 'linkpath':\n case 'type':\n case 'charset':\n case 'comment':\n case 'gname':\n case 'uname':\n set[k] = v\n break\n case 'ctime':\n case 'atime':\n case 'mtime':\n set[k] = new Date(Number(v) * 1000)\n break\n case 'size':\n const s = +v\n if (s >= 0) set[k] = s\n break\n case 'gid':\n case 'uid':\n case 'dev':\n case 'ino':\n case 'nlink':\n case 'mode':\n set[k] = +v\n break\n }\n return set\n}\n", "// on windows, either \\ or / are valid directory separators.\n// on unix, \\ is a valid character in filenames.\n// so, on windows, and only on windows, we replace all \\ chars with /,\n// so that we can use / as our one and only directory separator char.\n\nconst platform = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform\n\nexport const normalizeWindowsPath: (p: unknown) => string =\n platform !== 'win32' ?\n (p: unknown) => String(p)\n : (p: unknown) => String(p).replaceAll(/\\\\/g, '/')\n", "import { Minipass } from 'minipass'\nimport type { Header } from './header.js'\nimport { normalizeWindowsPath } from './normalize-windows-path.js'\nimport type { Pax } from './pax.js'\nimport type { EntryTypeName } from './types.js'\n\nexport class ReadEntry extends Minipass<Buffer, Buffer> {\n extended?: Pax\n globalExtended?: Pax\n header: Header\n startBlockSize: number\n blockRemain: number\n remain: number\n type: EntryTypeName\n meta: boolean = false\n ignore: boolean = false\n path: string\n mode?: number\n uid?: number\n gid?: number\n uname?: string\n gname?: string\n size: number = 0\n mtime?: Date\n atime?: Date\n ctime?: Date\n linkpath?: string\n\n dev?: number\n ino?: number\n nlink?: number\n invalid: boolean = false\n absolute?: string\n unsupported: boolean = false\n\n constructor(header: Header, ex?: Pax, gex?: Pax) {\n super({})\n // read entries always start life paused. this is to avoid the\n // situation where Minipass's auto-ending empty streams results\n // in an entry ending before we're ready for it.\n this.pause()\n this.extended = ex\n this.globalExtended = gex\n this.header = header\n /* c8 ignore start */\n this.remain = header.size ?? 0\n /* c8 ignore stop */\n this.startBlockSize = 512 * Math.ceil(this.remain / 512)\n this.blockRemain = this.startBlockSize\n this.type = header.type\n switch (this.type) {\n case 'File':\n case 'OldFile':\n case 'Link':\n case 'SymbolicLink':\n case 'CharacterDevice':\n case 'BlockDevice':\n case 'Directory':\n case 'FIFO':\n case 'ContiguousFile':\n case 'GNUDumpDir':\n break\n\n case 'NextFileHasLongLinkpath':\n case 'NextFileHasLongPath':\n case 'OldGnuLongPath':\n case 'GlobalExtendedHeader':\n case 'ExtendedHeader':\n case 'OldExtendedHeader':\n this.meta = true\n break\n\n // NOTE: gnutar and bsdtar treat unrecognized types as 'File'\n // it may be worth doing the same, but with a warning.\n default:\n this.ignore = true\n }\n\n /* c8 ignore start */\n if (!header.path) {\n throw new Error('no path provided for tar.ReadEntry')\n }\n /* c8 ignore stop */\n\n this.path = normalizeWindowsPath(header.path) as string\n this.mode = header.mode\n if (this.mode) {\n this.mode = this.mode & 0o7777\n }\n this.uid = header.uid\n this.gid = header.gid\n this.uname = header.uname\n this.gname = header.gname\n this.size = this.remain\n this.mtime = header.mtime\n this.atime = header.atime\n this.ctime = header.ctime\n /* c8 ignore start */\n this.linkpath =\n header.linkpath ? normalizeWindowsPath(header.linkpath) : undefined\n /* c8 ignore stop */\n this.uname = header.uname\n this.gname = header.gname\n\n if (ex) {\n this.#slurp(ex)\n }\n if (gex) {\n this.#slurp(gex, true)\n }\n }\n\n write(data: Buffer) {\n const writeLen = data.length\n if (writeLen > this.blockRemain) {\n throw new Error('writing more to entry than is appropriate')\n }\n\n const r = this.remain\n const br = this.blockRemain\n this.remain = Math.max(0, r - writeLen)\n this.blockRemain = Math.max(0, br - writeLen)\n if (this.ignore) {\n return true\n }\n\n if (r >= writeLen) {\n return super.write(data)\n }\n\n // r < writeLen\n return super.write(data.subarray(0, r))\n }\n\n #slurp(ex: Pax, gex: boolean = false) {\n if (ex.path) ex.path = normalizeWindowsPath(ex.path)\n if (ex.linkpath) ex.linkpath = normalizeWindowsPath(ex.linkpath)\n Object.assign(\n this,\n Object.fromEntries(\n Object.entries(ex).filter(([k, v]) => {\n // we slurp in everything except for the path attribute in\n // a global extended header, because that's weird. Also, any\n // null/undefined values are ignored.\n return !(v === null || v === undefined || (k === 'path' && gex))\n }),\n ),\n )\n }\n}\n", "import { type Minipass } from 'minipass'\n\n/** has a warn method */\nexport type Warner = {\n warn(code: string, message: string | Error, data: unknown): void\n file?: string\n cwd?: string\n strict?: boolean\n\n emit(event: 'warn', code: string, message: string, data?: WarnData): void\n emit(event: 'error', error: TarError): void\n}\n\nexport type WarnEvent<T = Buffer> = Minipass.Events<T> & {\n warn: [code: string, message: string, data: WarnData]\n}\n\nexport type WarnData = {\n file?: string\n cwd?: string\n code?: string\n tarCode?: string\n recoverable?: boolean\n [k: string]: unknown\n}\n\nexport type TarError = Error & WarnData\n\nexport const warnMethod = (\n self: Warner,\n code: string,\n message: string | Error,\n data: WarnData = {},\n) => {\n if (self.file) {\n data.file = self.file\n }\n if (self.cwd) {\n data.cwd = self.cwd\n }\n data.code =\n (message instanceof Error &&\n (message as NodeJS.ErrnoException).code) ||\n code\n data.tarCode = code\n if (!self.strict && data.recoverable !== false) {\n if (message instanceof Error) {\n data = Object.assign(message, data)\n message = message.message\n }\n self.emit('warn', code, message, data)\n } else if (message instanceof Error) {\n self.emit('error', Object.assign(message, data))\n } else {\n self.emit(\n 'error',\n Object.assign(new Error(`${code}: ${message}`), data),\n )\n }\n}\n", "// warning: extremely hot code path.\n// This has been meticulously optimized for use\n// within npm install on large package trees.\n// Do not edit without careful benchmarking.\nexport const stripTrailingSlashes = (str: string) => {\n let i = str.length - 1\n let slashesStart = -1\n while (i > -1 && str.charAt(i) === '/') {\n slashesStart = i\n i--\n }\n return slashesStart === -1 ? str : str.slice(0, slashesStart)\n}\n", "// A readable tar stream creator\n// Technically, this is a transform stream that you write paths into,\n// and tar format comes out of.\n// The `add()` method is like `write()` but returns this,\n// and end() return `this` as well, so you can\n// do `new Pack(opt).add('files').add('dir').end().pipe(output)\n// You could also do something like:\n// streamOfPaths().pipe(new Pack()).pipe(new fs.WriteStream('out.tar'))\n\nimport fs, { type Stats } from 'fs'\nimport {\n WriteEntry,\n WriteEntrySync,\n WriteEntryTar,\n} from './write-entry.js'\n\nexport class PackJob {\n path: string\n absolute: string\n entry?: WriteEntry | WriteEntryTar\n stat?: Stats\n readdir?: string[]\n pending: boolean = false\n pendingLink: boolean = false\n ignore: boolean = false\n piped: boolean = false\n constructor(path: string, absolute: string) {\n this.path = path || './'\n this.absolute = absolute\n }\n}\n\nimport { Minipass } from 'minipass'\nimport * as zlib from 'minizlib'\nimport { Yallist } from 'yallist'\nimport type { ReadEntry } from './read-entry.js'\nimport type { WarnEvent } from './warn-method.js'\nimport { warnMethod, type WarnData, type Warner } from './warn-method.js'\n\nconst EOF = Buffer.alloc(1024)\nconst ONSTAT = Symbol('onStat')\nconst ENDED = Symbol('ended')\nconst QUEUE = Symbol('queue')\nconst PENDINGLINKS = Symbol('pendingLinks')\nconst CURRENT = Symbol('current')\nconst PROCESS = Symbol('process')\nconst PROCESSING = Symbol('processing')\nconst PROCESSJOB = Symbol('processJob')\nconst JOBS = Symbol('jobs')\nconst JOBDONE = Symbol('jobDone')\nconst ADDFSENTRY = Symbol('addFSEntry')\nconst ADDTARENTRY = Symbol('addTarEntry')\nconst STAT = Symbol('stat')\nconst READDIR = Symbol('readdir')\nconst ONREADDIR = Symbol('onreaddir')\nconst PIPE = Symbol('pipe')\nconst ENTRY = Symbol('entry')\nconst ENTRYOPT = Symbol('entryOpt')\nconst WRITEENTRYCLASS = Symbol('writeEntryClass')\nconst WRITE = Symbol('write')\nconst ONDRAIN = Symbol('ondrain')\n\nimport path from 'path'\nimport { normalizeWindowsPath } from './normalize-windows-path.js'\nimport type { LinkCacheKey, TarOptions } from './options.js'\n\nexport class Pack\n extends Minipass<Buffer, ReadEntry | string, WarnEvent<Buffer>>\n implements Warner\n{\n sync: boolean = false\n opt: TarOptions\n cwd: string\n maxReadSize?: number\n preservePaths: boolean\n strict: boolean\n noPax: boolean\n prefix: string\n linkCache: Exclude<TarOptions['linkCache'], undefined>\n statCache: Exclude<TarOptions['statCache'], undefined>\n file: string\n portable: boolean\n zip?: zlib.BrotliCompress | zlib.Gzip | zlib.ZstdCompress\n readdirCache: Exclude<TarOptions['readdirCache'], undefined>\n noDirRecurse: boolean\n follow: boolean\n noMtime: boolean\n mtime?: Date\n filter: Exclude<TarOptions['filter'], undefined>\n jobs: number;\n\n [WRITEENTRYCLASS]: typeof WriteEntry | typeof WriteEntrySync\n onWriteEntry?: (entry: WriteEntry) => void;\n // Note: we actually DO need a linked list here, because we\n // shift() to update the head of the list where we start, but still\n // while that happens, need to know what the next item in the queue\n // will be. Since we do multiple jobs in parallel, it's not as simple\n // as just an Array.shift(), since that would lose the information about\n // the next job in the list. We could add a .next field on the PackJob\n // class, but then we'd have to be tracking the tail of the queue the\n // whole time, and Yallist just does that for us anyway.\n [QUEUE]: Yallist<PackJob>;\n [PENDINGLINKS] = new Map<LinkCacheKey, PackJob[]>();\n [JOBS]: number = 0;\n [PROCESSING]: boolean = false;\n [ENDED]: boolean = false\n\n constructor(opt: TarOptions = {}) {\n super()\n this.opt = opt\n this.file = opt.file || ''\n this.cwd = opt.cwd || process.cwd()\n this.maxReadSize = opt.maxReadSize\n this.preservePaths = !!opt.preservePaths\n this.strict = !!opt.strict\n this.noPax = !!opt.noPax\n this.prefix = normalizeWindowsPath(opt.prefix || '')\n this.linkCache = opt.linkCache || new Map()\n this.statCache = opt.statCache || new Map()\n this.readdirCache = opt.readdirCache || new Map()\n this.onWriteEntry = opt.onWriteEntry\n\n this[WRITEENTRYCLASS] = WriteEntry\n if (typeof opt.onwarn === 'function') {\n this.on('warn', opt.onwarn)\n }\n\n this.portable = !!opt.portable\n\n if (opt.gzip || opt.brotli || opt.zstd) {\n if (\n (opt.gzip ? 1 : 0) + (opt.brotli ? 1 : 0) + (opt.zstd ? 1 : 0) >\n 1\n ) {\n throw new TypeError('gzip, brotli, zstd are mutually exclusive')\n }\n if (opt.gzip) {\n if (typeof opt.gzip !== 'object') {\n opt.gzip = {}\n }\n if (this.portable) {\n opt.gzip.portable = true\n }\n this.zip = new zlib.Gzip(opt.gzip)\n }\n if (opt.brotli) {\n if (typeof opt.brotli !== 'object') {\n opt.brotli = {}\n }\n this.zip = new zlib.BrotliCompress(opt.brotli)\n }\n if (opt.zstd) {\n if (typeof opt.zstd !== 'object') {\n opt.zstd = {}\n }\n this.zip = new zlib.ZstdCompress(opt.zstd)\n }\n /* c8 ignore next */\n if (!this.zip) throw new Error('impossible')\n const zip = this.zip\n zip.on('data', chunk => super.write(chunk as unknown as string))\n zip.on('end', () => super.end())\n zip.on('drain', () => this[ONDRAIN]())\n this.on('resume', () => zip.resume())\n } else {\n this.on('drain', this[ONDRAIN])\n }\n\n this.noDirRecurse = !!opt.noDirRecurse\n this.follow = !!opt.follow\n this.noMtime = !!opt.noMtime\n if (opt.mtime) this.mtime = opt.mtime\n\n this.filter =\n typeof opt.filter === 'function' ? opt.filter : () => true\n\n this[QUEUE] = new Yallist<PackJob>()\n this[JOBS] = 0\n this.jobs = Number(opt.jobs) || 4\n this[PROCESSING] = false\n this[ENDED] = false\n }\n\n [WRITE](chunk: Buffer) {\n return super.write(chunk as unknown as string)\n }\n\n add(path: string | ReadEntry) {\n this.write(path)\n return this\n }\n\n end(cb?: () => void): this\n end(path: string | ReadEntry, cb?: () => void): this\n end(\n path: string | ReadEntry,\n encoding?: Minipass.Encoding,\n cb?: () => void,\n ): this\n end(\n path?: string | ReadEntry | (() => void),\n encoding?: Minipass.Encoding | (() => void),\n cb?: () => void,\n ) {\n /* c8 ignore start */\n if (typeof path === 'function') {\n cb = path\n path = undefined\n }\n if (typeof encoding === 'function') {\n cb = encoding\n encoding = undefined\n }\n /* c8 ignore stop */\n if (path) {\n this.add(path)\n }\n this[ENDED] = true\n this[PROCESS]()\n /* c8 ignore next */\n if (cb) cb()\n return this\n }\n\n write(path: string | ReadEntry) {\n if (this[ENDED]) {\n throw new Error('write after end')\n }\n\n if (typeof path === 'string') {\n this[ADDFSENTRY](path)\n } else {\n this[ADDTARENTRY](path)\n }\n return this.flowing\n }\n\n [ADDTARENTRY](p: ReadEntry) {\n const absolute = normalizeWindowsPath(path.resolve(this.cwd, p.path))\n // in this case, we don't have to wait for the stat\n if (!this.filter(p.path, p)) {\n p.resume()\n } else {\n const job = new PackJob(p.path, absolute)\n job.entry = new WriteEntryTar(p, this[ENTRYOPT](job))\n job.entry.on('end', () => this[JOBDONE](job))\n this[JOBS] += 1\n this[QUEUE].push(job)\n }\n\n this[PROCESS]()\n }\n\n [ADDFSENTRY](p: string) {\n const absolute = normalizeWindowsPath(path.resolve(this.cwd, p))\n this[QUEUE].push(new PackJob(p, absolute))\n this[PROCESS]()\n }\n\n [STAT](job: PackJob) {\n job.pending = true\n this[JOBS] += 1\n const stat = this.follow ? 'stat' : 'lstat'\n fs[stat](job.absolute, (er, stat) => {\n job.pending = false\n this[JOBS] -= 1\n if (er) {\n this.emit('error', er)\n } else {\n this[ONSTAT](job, stat)\n }\n })\n }\n\n [ONSTAT](job: PackJob, stat: Stats) {\n this.statCache.set(job.absolute, stat)\n job.stat = stat\n\n // now we have the stat, we can filter it.\n if (!this.filter(job.path, stat)) {\n job.ignore = true\n } else if (\n stat.isFile() &&\n stat.nlink > 1 &&\n !this.linkCache.get(`${stat.dev}:${stat.ino}`) &&\n !this.sync\n ) {\n // if it's not filtered, and it's a new File entry, and next anyway\n // process right away in case any pending Link entries are about\n // to try to link to it.\n if (job === this[CURRENT]) {\n this[PROCESSJOB](job)\n } else {\n // if it's NOT the current entry, it needs to be deferred,\n // so that the link target can be built first.\n const key: LinkCacheKey = `${stat.dev}:${stat.ino}`\n const pending = this[PENDINGLINKS].get(key)\n if (pending) pending.push(job)\n else this[PENDINGLINKS].set(key, [job])\n job.pendingLink = true\n job.pending = true\n }\n }\n\n this[PROCESS]()\n }\n\n [READDIR](job: PackJob) {\n job.pending = true\n this[JOBS] += 1\n fs.readdir(job.absolute, (er, entries) => {\n job.pending = false\n this[JOBS] -= 1\n if (er) {\n return this.emit('error', er)\n }\n this[ONREADDIR](job, entries)\n })\n }\n\n [ONREADDIR](job: PackJob, entries: string[]) {\n this.readdirCache.set(job.absolute, entries)\n job.readdir = entries\n this[PROCESS]()\n }\n\n [PROCESS]() {\n if (this[PROCESSING]) {\n return\n }\n\n this[PROCESSING] = true\n for (\n let w = this[QUEUE].head;\n !!w && this[JOBS] < this.jobs;\n w = w.next\n ) {\n this[PROCESSJOB](w.value)\n if (w.value.ignore) {\n const p = w.next\n this[QUEUE].removeNode(w)\n w.next = p\n }\n }\n\n this[PROCESSING] = false\n\n if (this[ENDED] && this[QUEUE].length === 0 && this[JOBS] === 0) {\n if (this.zip) {\n this.zip.end(EOF)\n } else {\n super.write(EOF as unknown as string)\n super.end()\n }\n }\n }\n\n get [CURRENT]() {\n return this[QUEUE] && this[QUEUE].head && this[QUEUE].head.value\n }\n\n [JOBDONE](job: PackJob) {\n this[QUEUE].shift()\n this[JOBS] -= 1\n const { stat } = job\n if (stat && stat.isFile() && stat.nlink > 1) {\n // might be a file with pending links\n const key: LinkCacheKey = `${stat.dev}:${stat.ino}`\n const pending = this[PENDINGLINKS].get(key)\n if (pending) {\n this[PENDINGLINKS].delete(key)\n for (const job of pending) {\n job.pending = false\n this[PROCESSJOB](job)\n }\n }\n }\n this[PROCESS]()\n }\n\n [PROCESSJOB](job: PackJob) {\n if (job.pending && job.pendingLink && job === this[CURRENT]) {\n // At least one of the links to this file are not being included\n // in the tarball, so we need to just proceed.\n job.pending = false\n job.pendingLink = false\n }\n if (job.pending) {\n return\n }\n\n if (job.entry) {\n if (job === this[CURRENT] && !job.piped) {\n this[PIPE](job)\n }\n return\n }\n\n if (!job.stat) {\n const sc = this.statCache.get(job.absolute)\n if (sc) {\n this[ONSTAT](job, sc)\n } else {\n this[STAT](job)\n }\n }\n if (!job.stat) {\n return\n }\n\n // filtered out!\n if (job.ignore) {\n return\n }\n\n if (!this.noDirRecurse && job.stat.isDirectory() && !job.readdir) {\n const rc = this.readdirCache.get(job.absolute)\n if (rc) {\n this[ONREADDIR](job, rc)\n } else {\n this[READDIR](job)\n }\n if (!job.readdir) {\n return\n }\n }\n\n // we know it doesn't have an entry, because that got checked above\n job.entry = this[ENTRY](job)\n if (!job.entry) {\n job.ignore = true\n return\n }\n\n if (job === this[CURRENT] && !job.piped) {\n this[PIPE](job)\n }\n }\n\n [ENTRYOPT](job: PackJob): TarOptions {\n return {\n onwarn: (code, msg, data) => this.warn(code, msg, data),\n noPax: this.noPax,\n cwd: this.cwd,\n absolute: job.absolute,\n preservePaths: this.preservePaths,\n maxReadSize: this.maxReadSize,\n strict: this.strict,\n portable: this.portable,\n linkCache: this.linkCache,\n statCache: this.statCache,\n noMtime: this.noMtime,\n mtime: this.mtime,\n prefix: this.prefix,\n onWriteEntry: this.onWriteEntry,\n }\n }\n\n [ENTRY](job: PackJob) {\n this[JOBS] += 1\n try {\n const e = new this[WRITEENTRYCLASS](job.path, this[ENTRYOPT](job))\n return e\n .on('end', () => this[JOBDONE](job))\n .on('error', er => this.emit('error', er))\n } catch (er) {\n this.emit('error', er)\n }\n }\n\n [ONDRAIN]() {\n if (this[CURRENT] && this[CURRENT].entry) {\n this[CURRENT].entry.resume()\n }\n }\n\n // like .pipe() but using super, because our write() is special\n [PIPE](job: PackJob) {\n job.piped = true\n\n if (job.readdir) {\n job.readdir.forEach(entry => {\n const p = job.path\n const base = p === './' ? '' : p.replace(/\\/*$/, '/')\n this[ADDFSENTRY](base + entry)\n })\n }\n\n const source = job.entry\n const zip = this.zip\n /* c8 ignore start */\n if (!source) throw new Error('cannot pipe without source')\n /* c8 ignore stop */\n\n if (zip) {\n source.on('data', chunk => {\n if (!zip.write(chunk)) {\n source.pause()\n }\n })\n } else {\n source.on('data', chunk => {\n if (!super.write(chunk as unknown as string)) {\n source.pause()\n }\n })\n }\n }\n\n pause() {\n if (this.zip) {\n this.zip.pause()\n }\n return super.pause()\n }\n warn(code: string, message: string | Error, data: WarnData = {}): void {\n warnMethod(this, code, message, data)\n }\n}\n\nexport class PackSync extends Pack {\n sync: true = true\n constructor(opt: TarOptions) {\n super(opt)\n this[WRITEENTRYCLASS] = WriteEntrySync\n }\n\n // pause/resume are no-ops in sync streams.\n pause() {}\n resume() {}\n\n [STAT](job: PackJob) {\n const stat = this.follow ? 'statSync' : 'lstatSync'\n this[ONSTAT](job, fs[stat](job.absolute))\n }\n\n [READDIR](job: PackJob) {\n this[ONREADDIR](job, fs.readdirSync(job.absolute))\n }\n\n // gotta get it all in this tick\n [PIPE](job: PackJob) {\n const source = job.entry\n const zip = this.zip\n\n if (job.readdir) {\n job.readdir.forEach(entry => {\n const p = job.path\n const base = p === './' ? '' : p.replace(/\\/*$/, '/')\n this[ADDFSENTRY](base + entry)\n })\n }\n\n /* c8 ignore start */\n if (!source) throw new Error('Cannot pipe without source')\n /* c8 ignore stop */\n\n if (zip) {\n source.on('data', chunk => {\n zip.write(chunk)\n })\n } else {\n source.on('data', chunk => {\n super[WRITE](chunk)\n })\n }\n }\n}\n", "import fs, { type Stats } from 'fs'\nimport { Minipass } from 'minipass'\nimport path from 'path'\nimport { Header } from './header.js'\nimport { modeFix } from './mode-fix.js'\nimport { normalizeWindowsPath } from './normalize-windows-path.js'\nimport type {\n LinkCacheKey,\n TarOptions,\n TarOptionsWithAliases,\n} from './options.js'\nimport { dealias } from './options.js'\nimport { Pax } from './pax.js'\nimport type { ReadEntry } from './read-entry.js'\nimport { stripAbsolutePath } from './strip-absolute-path.js'\nimport { stripTrailingSlashes } from './strip-trailing-slashes.js'\nimport type { EntryTypeName } from './types.js'\nimport type { WarnData, Warner, WarnEvent } from './warn-method.js'\nimport { warnMethod } from './warn-method.js'\nimport * as winchars from './winchars.js'\n\nconst prefixPath = (path: string, prefix?: string) => {\n if (!prefix) {\n return normalizeWindowsPath(path)\n }\n path = normalizeWindowsPath(path).replace(/^\\.(\\/|$)/, '')\n return stripTrailingSlashes(prefix) + '/' + path\n}\n\nconst maxReadSize = 16 * 1024 * 1024\n\nconst PROCESS = Symbol('process')\nconst FILE = Symbol('file')\nconst DIRECTORY = Symbol('directory')\nconst SYMLINK = Symbol('symlink')\nconst HARDLINK = Symbol('hardlink')\nconst HEADER = Symbol('header')\nconst READ = Symbol('read')\nconst LSTAT = Symbol('lstat')\nconst ONLSTAT = Symbol('onlstat')\nconst ONREAD = Symbol('onread')\nconst ONREADLINK = Symbol('onreadlink')\nconst OPENFILE = Symbol('openfile')\nconst ONOPENFILE = Symbol('onopenfile')\nconst CLOSE = Symbol('close')\nconst MODE = Symbol('mode')\nconst AWAITDRAIN = Symbol('awaitDrain')\nconst ONDRAIN = Symbol('ondrain')\nconst PREFIX = Symbol('prefix')\n\nexport class WriteEntry\n extends Minipass<Buffer, Minipass.ContiguousData, WarnEvent>\n implements Warner\n{\n path: string\n portable: boolean\n myuid: number = (process.getuid && process.getuid()) || 0\n // until node has builtin pwnam functions, this'll have to do\n myuser: string = process.env.USER || ''\n maxReadSize: number\n linkCache: Exclude<TarOptions['linkCache'], undefined>\n statCache: Exclude<TarOptions['statCache'], undefined>\n preservePaths: boolean\n cwd: string\n strict: boolean\n mtime?: Date\n noPax: boolean\n noMtime: boolean\n prefix?: string\n fd?: number\n\n blockLen: number = 0\n blockRemain: number = 0\n buf?: Buffer\n pos: number = 0\n remain: number = 0\n length: number = 0\n offset: number = 0\n\n win32: boolean\n absolute: string\n\n header?: Header\n type?: EntryTypeName | 'Unsupported'\n linkpath?: string\n stat?: Stats\n onWriteEntry?: (entry: WriteEntry) => unknown\n\n #hadError: boolean = false\n\n constructor(p: string, opt_: TarOptionsWithAliases = {}) {\n const opt = dealias(opt_)\n super()\n this.path = normalizeWindowsPath(p)\n // suppress atime, ctime, uid, gid, uname, gname\n this.portable = !!opt.portable\n this.maxReadSize = opt.maxReadSize || maxReadSize\n this.linkCache = opt.linkCache || new Map()\n this.statCache = opt.statCache || new Map()\n this.preservePaths = !!opt.preservePaths\n this.cwd = normalizeWindowsPath(opt.cwd || process.cwd())\n this.strict = !!opt.strict\n this.noPax = !!opt.noPax\n this.noMtime = !!opt.noMtime\n this.mtime = opt.mtime\n this.prefix = opt.prefix ? normalizeWindowsPath(opt.prefix) : undefined\n this.onWriteEntry = opt.onWriteEntry\n\n if (typeof opt.onwarn === 'function') {\n this.on('warn', opt.onwarn)\n }\n\n let pathWarn: string | boolean = false\n if (!this.preservePaths) {\n const [root, stripped] = stripAbsolutePath(this.path)\n if (root && typeof stripped === 'string') {\n this.path = stripped\n pathWarn = root\n }\n }\n\n this.win32 = !!opt.win32 || process.platform === 'win32'\n if (this.win32) {\n // force the \\ to / normalization, since we might not *actually*\n // be on windows, but want \\ to be considered a path separator.\n this.path = winchars.decode(this.path.replaceAll(/\\\\/g, '/'))\n p = p.replaceAll(/\\\\/g, '/')\n }\n\n this.absolute = normalizeWindowsPath(\n opt.absolute || path.resolve(this.cwd, p),\n )\n\n if (this.path === '') {\n this.path = './'\n }\n\n if (pathWarn) {\n this.warn(\n 'TAR_ENTRY_INFO',\n `stripping ${pathWarn} from absolute path`,\n {\n entry: this,\n path: pathWarn + this.path,\n },\n )\n }\n\n const cs = this.statCache.get(this.absolute)\n if (cs) {\n this[ONLSTAT](cs)\n } else {\n this[LSTAT]()\n }\n }\n\n warn(code: string, message: string | Error, data: WarnData = {}) {\n return warnMethod(this, code, message, data)\n }\n\n emit(ev: keyof WarnEvent, ...data: unknown[]) {\n if (ev === 'error') {\n this.#hadError = true\n }\n return super.emit(ev, ...data)\n }\n\n [LSTAT]() {\n fs.lstat(this.absolute, (er, stat) => {\n if (er) {\n return this.emit('error', er)\n }\n this[ONLSTAT](stat)\n })\n }\n\n [ONLSTAT](stat: Stats) {\n this.statCache.set(this.absolute, stat)\n this.stat = stat\n if (!stat.isFile()) {\n stat.size = 0\n }\n this.type = getType(stat)\n this.emit('stat', stat)\n this[PROCESS]()\n }\n\n [PROCESS]() {\n switch (this.type) {\n case 'File':\n return this[FILE]()\n case 'Directory':\n return this[DIRECTORY]()\n case 'SymbolicLink':\n return this[SYMLINK]()\n // unsupported types are ignored.\n default:\n return this.end()\n }\n }\n\n [MODE](mode: number) {\n return modeFix(mode, this.type === 'Directory', this.portable)\n }\n\n [PREFIX](path: string) {\n return prefixPath(path, this.prefix)\n }\n\n [HEADER]() {\n /* c8 ignore start */\n if (!this.stat) {\n throw new Error('cannot write header before stat')\n }\n /* c8 ignore stop */\n\n if (this.type === 'Directory' && this.portable) {\n this.noMtime = true\n }\n\n this.onWriteEntry?.(this)\n this.header = new Header({\n path: this[PREFIX](this.path),\n // only apply the prefix to hard links.\n linkpath:\n this.type === 'Link' && this.linkpath !== undefined ?\n this[PREFIX](this.linkpath)\n : this.linkpath,\n // only the permissions and setuid/setgid/sticky bitflags\n // not the higher-order bits that specify file type\n mode: this[MODE](this.stat.mode),\n uid: this.portable ? undefined : this.stat.uid,\n gid: this.portable ? undefined : this.stat.gid,\n size: this.stat.size,\n mtime: this.noMtime ? undefined : this.mtime || this.stat.mtime,\n /* c8 ignore next */\n type: this.type === 'Unsupported' ? undefined : this.type,\n uname:\n this.portable ? undefined\n : this.stat.uid === this.myuid ? this.myuser\n : '',\n atime: this.portable ? undefined : this.stat.atime,\n ctime: this.portable ? undefined : this.stat.ctime,\n })\n\n if (this.header.encode() && !this.noPax) {\n super.write(\n new Pax({\n atime: this.portable ? undefined : this.header.atime,\n ctime: this.portable ? undefined : this.header.ctime,\n gid: this.portable ? undefined : this.header.gid,\n mtime:\n this.noMtime ? undefined : this.mtime || this.header.mtime,\n path: this[PREFIX](this.path),\n linkpath:\n this.type === 'Link' && this.linkpath !== undefined ?\n this[PREFIX](this.linkpath)\n : this.linkpath,\n size: this.header.size,\n uid: this.portable ? undefined : this.header.uid,\n uname: this.portable ? undefined : this.header.uname,\n dev: this.portable ? undefined : this.stat.dev,\n ino: this.portable ? undefined : this.stat.ino,\n nlink: this.portable ? undefined : this.stat.nlink,\n }).encode(),\n )\n }\n const block = this.header?.block\n /* c8 ignore start */\n if (!block) {\n throw new Error('failed to encode header')\n }\n /* c8 ignore stop */\n super.write(block)\n }\n\n [DIRECTORY]() {\n /* c8 ignore start */\n if (!this.stat) {\n throw new Error('cannot create directory entry without stat')\n }\n /* c8 ignore stop */\n if (this.path.slice(-1) !== '/') {\n this.path += '/'\n }\n this.stat.size = 0\n this[HEADER]()\n this.end()\n }\n\n [SYMLINK]() {\n fs.readlink(this.absolute, (er, linkpath) => {\n if (er) {\n return this.emit('error', er)\n }\n this[ONREADLINK](linkpath)\n })\n }\n\n [ONREADLINK](linkpath: string) {\n this.linkpath = normalizeWindowsPath(linkpath)\n this[HEADER]()\n this.end()\n }\n\n [HARDLINK](linkpath: string) {\n /* c8 ignore start */\n if (!this.stat) {\n throw new Error('cannot create link entry without stat')\n }\n /* c8 ignore stop */\n this.type = 'Link'\n this.linkpath = normalizeWindowsPath(path.relative(this.cwd, linkpath))\n this.stat.size = 0\n this[HEADER]()\n this.end()\n }\n\n [FILE]() {\n /* c8 ignore start */\n if (!this.stat) {\n throw new Error('cannot create file entry without stat')\n }\n /* c8 ignore stop */\n if (this.stat.nlink > 1) {\n const linkKey = `${this.stat.dev}:${this.stat.ino}` as LinkCacheKey\n const linkpath = this.linkCache.get(linkKey)\n if (linkpath?.indexOf(this.cwd) === 0) {\n return this[HARDLINK](linkpath)\n }\n this.linkCache.set(linkKey, this.absolute)\n }\n\n this[HEADER]()\n if (this.stat.size === 0) {\n return this.end()\n }\n\n this[OPENFILE]()\n }\n\n [OPENFILE]() {\n fs.open(this.absolute, 'r', (er, fd) => {\n if (er) {\n return this.emit('error', er)\n }\n this[ONOPENFILE](fd)\n })\n }\n\n [ONOPENFILE](fd: number) {\n this.fd = fd\n if (this.#hadError) {\n return this[CLOSE]()\n }\n /* c8 ignore start */\n if (!this.stat) {\n throw new Error('should stat before calling onopenfile')\n }\n /* c8 ignore start */\n\n this.blockLen = 512 * Math.ceil(this.stat.size / 512)\n this.blockRemain = this.blockLen\n const bufLen = Math.min(this.blockLen, this.maxReadSize)\n this.buf = Buffer.allocUnsafe(bufLen)\n this.offset = 0\n this.pos = 0\n this.remain = this.stat.size\n this.length = this.buf.length\n this[READ]()\n }\n\n [READ]() {\n const { fd, buf, offset, length, pos } = this\n if (fd === undefined || buf === undefined) {\n throw new Error('cannot read file without first opening')\n }\n fs.read(fd, buf, offset, length, pos, (er, bytesRead) => {\n if (er) {\n // ignoring the error from close(2) is a bad practice, but at\n // this point we already have an error, don't need another one\n return this[CLOSE](() => this.emit('error', er))\n }\n this[ONREAD](bytesRead)\n })\n }\n\n /* c8 ignore start */\n [CLOSE](\n cb: (er?: null | Error | NodeJS.ErrnoException) => unknown = () => {},\n ) {\n /* c8 ignore stop */\n if (this.fd !== undefined) fs.close(this.fd, cb)\n }\n\n [ONREAD](bytesRead: number) {\n if (bytesRead <= 0 && this.remain > 0) {\n const er = Object.assign(new Error('encountered unexpected EOF'), {\n path: this.absolute,\n syscall: 'read',\n code: 'EOF',\n })\n return this[CLOSE](() => this.emit('error', er))\n }\n\n if (bytesRead > this.remain) {\n const er = Object.assign(\n new Error('did not encounter expected EOF'),\n {\n path: this.absolute,\n syscall: 'read',\n code: 'EOF',\n },\n )\n return this[CLOSE](() => this.emit('error', er))\n }\n\n /* c8 ignore start */\n if (!this.buf) {\n throw new Error('should have created buffer prior to reading')\n }\n /* c8 ignore stop */\n\n // null out the rest of the buffer, if we could fit the block padding\n // at the end of this loop, we've incremented bytesRead and this.remain\n // to be incremented up to the blockRemain level, as if we had expected\n // to get a null-padded file, and read it until the end. then we will\n // decrement both remain and blockRemain by bytesRead, and know that we\n // reached the expected EOF, without any null buffer to append.\n if (bytesRead === this.remain) {\n for (\n let i = bytesRead;\n i < this.length && bytesRead < this.blockRemain;\n i++\n ) {\n this.buf[i + this.offset] = 0\n bytesRead++\n this.remain++\n }\n }\n\n const chunk =\n this.offset === 0 && bytesRead === this.buf.length ?\n this.buf\n : this.buf.subarray(this.offset, this.offset + bytesRead)\n\n const flushed = this.write(chunk)\n if (!flushed) {\n this[AWAITDRAIN](() => this[ONDRAIN]())\n } else {\n this[ONDRAIN]()\n }\n }\n\n [AWAITDRAIN](cb: () => unknown) {\n this.once('drain', cb)\n }\n\n write(buffer: Buffer | string, cb?: () => void): boolean\n write(\n str: Buffer | string,\n encoding?: BufferEncoding | null,\n cb?: () => void,\n ): boolean\n write(\n chunk: Buffer | string,\n encoding?: BufferEncoding | (() => unknown) | null,\n cb?: () => unknown,\n ): boolean {\n /* c8 ignore start - just junk to comply with NodeJS.WritableStream */\n if (typeof encoding === 'function') {\n cb = encoding\n encoding = undefined\n }\n if (typeof chunk === 'string') {\n chunk = Buffer.from(\n chunk,\n typeof encoding === 'string' ? encoding : 'utf8',\n )\n }\n /* c8 ignore stop */\n\n if (this.blockRemain < chunk.length) {\n const er = Object.assign(\n new Error('writing more data than expected'),\n {\n path: this.absolute,\n },\n )\n return this.emit('error', er)\n }\n this.remain -= chunk.length\n this.blockRemain -= chunk.length\n this.pos += chunk.length\n this.offset += chunk.length\n return super.write(chunk, null, cb)\n }\n\n [ONDRAIN]() {\n if (!this.remain) {\n if (this.blockRemain) {\n super.write(Buffer.alloc(this.blockRemain))\n }\n return this[CLOSE](er => (er ? this.emit('error', er) : this.end()))\n }\n\n /* c8 ignore start */\n if (!this.buf) {\n throw new Error('buffer lost somehow in ONDRAIN')\n }\n /* c8 ignore stop */\n\n if (this.offset >= this.length) {\n // if we only have a smaller bit left to read, alloc a smaller buffer\n // otherwise, keep it the same length it was before.\n this.buf = Buffer.allocUnsafe(\n Math.min(this.blockRemain, this.buf.length),\n )\n this.offset = 0\n }\n this.length = this.buf.length - this.offset\n this[READ]()\n }\n}\n\nexport class WriteEntrySync extends WriteEntry implements Warner {\n sync: true = true;\n\n [LSTAT]() {\n this[ONLSTAT](fs.lstatSync(this.absolute))\n }\n\n [SYMLINK]() {\n this[ONREADLINK](fs.readlinkSync(this.absolute))\n }\n\n [OPENFILE]() {\n this[ONOPENFILE](fs.openSync(this.absolute, 'r'))\n }\n\n [READ]() {\n let threw = true\n try {\n const { fd, buf, offset, length, pos } = this\n /* c8 ignore start */\n if (fd === undefined || buf === undefined) {\n throw new Error('fd and buf must be set in READ method')\n }\n /* c8 ignore stop */\n const bytesRead = fs.readSync(fd, buf, offset, length, pos)\n this[ONREAD](bytesRead)\n threw = false\n } finally {\n // ignoring the error from close(2) is a bad practice, but at\n // this point we already have an error, don't need another one\n if (threw) {\n try {\n this[CLOSE](() => {})\n } catch {}\n }\n }\n }\n\n [AWAITDRAIN](cb: () => unknown) {\n cb()\n }\n\n /* c8 ignore start */\n [CLOSE](\n cb: (er?: null | Error | NodeJS.ErrnoException) => unknown = () => {},\n ) {\n /* c8 ignore stop */\n if (this.fd !== undefined) fs.closeSync(this.fd)\n cb()\n }\n}\n\nexport class WriteEntryTar\n extends Minipass<Buffer, Buffer | string, WarnEvent>\n implements Warner\n{\n blockLen: number = 0\n blockRemain: number = 0\n buf: number = 0\n pos: number = 0\n remain: number = 0\n length: number = 0\n preservePaths: boolean\n portable: boolean\n strict: boolean\n noPax: boolean\n noMtime: boolean\n readEntry: ReadEntry\n type: EntryTypeName\n prefix?: string\n path: string\n mode?: number\n uid?: number\n gid?: number\n uname?: string\n gname?: string\n header?: Header\n mtime?: Date\n atime?: Date\n ctime?: Date\n linkpath?: string\n size: number\n onWriteEntry?: (entry: WriteEntry) => unknown\n\n warn(code: string, message: string | Error, data: WarnData = {}) {\n return warnMethod(this, code, message, data)\n }\n\n constructor(readEntry: ReadEntry, opt_: TarOptionsWithAliases = {}) {\n const opt = dealias(opt_)\n super()\n this.preservePaths = !!opt.preservePaths\n this.portable = !!opt.portable\n this.strict = !!opt.strict\n this.noPax = !!opt.noPax\n this.noMtime = !!opt.noMtime\n this.onWriteEntry = opt.onWriteEntry\n\n this.readEntry = readEntry\n const { type } = readEntry\n /* c8 ignore start */\n if (type === 'Unsupported') {\n throw new Error('writing entry that should be ignored')\n }\n /* c8 ignore stop */\n this.type = type\n if (this.type === 'Directory' && this.portable) {\n this.noMtime = true\n }\n\n this.prefix = opt.prefix\n\n this.path = normalizeWindowsPath(readEntry.path)\n this.mode =\n readEntry.mode !== undefined ? this[MODE](readEntry.mode) : undefined\n this.uid = this.portable ? undefined : readEntry.uid\n this.gid = this.portable ? undefined : readEntry.gid\n this.uname = this.portable ? undefined : readEntry.uname\n this.gname = this.portable ? undefined : readEntry.gname\n this.size = readEntry.size\n this.mtime = this.noMtime ? undefined : opt.mtime || readEntry.mtime\n this.atime = this.portable ? undefined : readEntry.atime\n this.ctime = this.portable ? undefined : readEntry.ctime\n this.linkpath =\n readEntry.linkpath !== undefined ?\n normalizeWindowsPath(readEntry.linkpath)\n : undefined\n\n if (typeof opt.onwarn === 'function') {\n this.on('warn', opt.onwarn)\n }\n\n let pathWarn: false | string = false\n if (!this.preservePaths) {\n const [root, stripped] = stripAbsolutePath(this.path)\n if (root && typeof stripped === 'string') {\n this.path = stripped\n pathWarn = root\n }\n }\n\n this.remain = readEntry.size\n this.blockRemain = readEntry.startBlockSize\n\n this.onWriteEntry?.(this as unknown as WriteEntry)\n this.header = new Header({\n path: this[PREFIX](this.path),\n linkpath:\n this.type === 'Link' && this.linkpath !== undefined ?\n this[PREFIX](this.linkpath)\n : this.linkpath,\n // only the permissions and setuid/setgid/sticky bitflags\n // not the higher-order bits that specify file type\n mode: this.mode,\n uid: this.portable ? undefined : this.uid,\n gid: this.portable ? undefined : this.gid,\n size: this.size,\n mtime: this.noMtime ? undefined : this.mtime,\n type: this.type,\n uname: this.portable ? undefined : this.uname,\n atime: this.portable ? undefined : this.atime,\n ctime: this.portable ? undefined : this.ctime,\n })\n\n if (pathWarn) {\n this.warn(\n 'TAR_ENTRY_INFO',\n `stripping ${pathWarn} from absolute path`,\n {\n entry: this,\n path: pathWarn + this.path,\n },\n )\n }\n\n if (this.header.encode() && !this.noPax) {\n super.write(\n new Pax({\n atime: this.portable ? undefined : this.atime,\n ctime: this.portable ? undefined : this.ctime,\n gid: this.portable ? undefined : this.gid,\n mtime: this.noMtime ? undefined : this.mtime,\n path: this[PREFIX](this.path),\n linkpath:\n this.type === 'Link' && this.linkpath !== undefined ?\n this[PREFIX](this.linkpath)\n : this.linkpath,\n size: this.size,\n uid: this.portable ? undefined : this.uid,\n uname: this.portable ? undefined : this.uname,\n dev: this.portable ? undefined : this.readEntry.dev,\n ino: this.portable ? undefined : this.readEntry.ino,\n nlink: this.portable ? undefined : this.readEntry.nlink,\n }).encode(),\n )\n }\n\n const b = this.header?.block\n /* c8 ignore start */\n if (!b) throw new Error('failed to encode header')\n /* c8 ignore stop */\n super.write(b)\n readEntry.pipe(this)\n }\n\n [PREFIX](path: string) {\n return prefixPath(path, this.prefix)\n }\n\n [MODE](mode: number) {\n return modeFix(mode, this.type === 'Directory', this.portable)\n }\n\n write(buffer: Buffer | string, cb?: () => void): boolean\n write(\n str: Buffer | string,\n encoding?: BufferEncoding | null,\n cb?: () => void,\n ): boolean\n write(\n chunk: Buffer | string,\n encoding?: BufferEncoding | (() => unknown) | null,\n cb?: () => unknown,\n ): boolean {\n /* c8 ignore start - just junk to comply with NodeJS.WritableStream */\n if (typeof encoding === 'function') {\n cb = encoding\n encoding = undefined\n }\n if (typeof chunk === 'string') {\n chunk = Buffer.from(\n chunk,\n typeof encoding === 'string' ? encoding : 'utf8',\n )\n }\n /* c8 ignore stop */\n const writeLen = chunk.length\n if (writeLen > this.blockRemain) {\n throw new Error('writing more to entry than is appropriate')\n }\n this.blockRemain -= writeLen\n return super.write(chunk, cb)\n }\n\n end(cb?: () => void): this\n end(chunk: Buffer | string, cb?: () => void): this\n end(\n chunk: Buffer | string,\n encoding?: BufferEncoding,\n cb?: () => void,\n ): this\n end(\n chunk?: Buffer | string | (() => void),\n encoding?: BufferEncoding | (() => void),\n cb?: () => void,\n ): this {\n if (this.blockRemain) {\n super.write(Buffer.alloc(this.blockRemain))\n }\n /* c8 ignore start - just junk to comply with NodeJS.WritableStream */\n if (typeof chunk === 'function') {\n cb = chunk\n encoding = undefined\n chunk = undefined\n }\n if (typeof encoding === 'function') {\n cb = encoding\n encoding = undefined\n }\n if (typeof chunk === 'string') {\n chunk = Buffer.from(chunk, encoding ?? 'utf8')\n }\n if (cb) this.once('finish', cb)\n if (chunk) super.end(chunk, cb)\n else super.end(cb)\n /* c8 ignore stop */\n return this\n }\n}\n\nconst getType = (stat: Stats): EntryTypeName | 'Unsupported' =>\n stat.isFile() ? 'File'\n : stat.isDirectory() ? 'Directory'\n : stat.isSymbolicLink() ? 'SymbolicLink'\n : 'Unsupported'\n", "export const modeFix = (\n mode: number,\n isDir: boolean,\n portable: boolean,\n) => {\n mode &= 0o7777\n\n // in portable mode, use the minimum reasonable umask\n // if this system creates files with 0o664 by default\n // (as some linux distros do), then we'll write the\n // archive with 0o644 instead. Also, don't ever create\n // a file that is not readable/writable by the owner.\n if (portable) {\n mode = (mode | 0o600) & ~0o22\n }\n\n // if dirs are readable, then they should be listable\n if (isDir) {\n if (mode & 0o400) {\n mode |= 0o100\n }\n if (mode & 0o40) {\n mode |= 0o10\n }\n if (mode & 0o4) {\n mode |= 0o1\n }\n }\n return mode\n}\n", "// unix absolute paths are also absolute on win32, so we use this for both\nimport { win32 } from 'node:path'\nconst { isAbsolute, parse } = win32\n\n// returns [root, stripped]\n// Note that windows will think that //x/y/z/a has a \"root\" of //x/y, and in\n// those cases, we want to sanitize it to x/y/z/a, not z/a, so we strip /\n// explicitly if it's the first character.\n// drive-specific relative paths on Windows get their root stripped off even\n// though they are not absolute, so `c:../foo` becomes ['c:', '../foo']\nexport const stripAbsolutePath = (path: string): [string, string] => {\n let r = ''\n\n let parsed = parse(path)\n while (isAbsolute(path) || parsed.root) {\n // windows will think that //x/y/z has a \"root\" of //x/y/\n // but strip the //?/C:/ off of //?/C:/path\n const root =\n path.charAt(0) === '/' && path.slice(0, 4) !== '//?/' ?\n '/'\n : parsed.root\n path = path.slice(root.length)\n r += root\n parsed = parse(path)\n }\n return [r, path]\n}\n", "// When writing files on Windows, translate the characters to their\n// 0xf000 higher-encoded versions.\n\nconst raw = ['|', '<', '>', '?', ':']\n\nconst win = raw.map(char =>\n String.fromCodePoint(0xf000 + Number(char.codePointAt(0))),\n)\n\nconst toWin = new Map(raw.map((char, i) => [char, win[i]]))\nconst toRaw = new Map(win.map((char, i) => [char, raw[i]]))\n\nexport const encode = (s: string) =>\n raw.reduce((s, c) => s.split(c).join(toWin.get(c)), s)\nexport const decode = (s: string) =>\n win.reduce((s, c) => s.split(c).join(toRaw.get(c)), s)\n", "export class Yallist<T = unknown> {\n tail?: Node<T>\n head?: Node<T>\n length: number = 0\n\n static create<T = unknown>(list: Iterable<T> = []) {\n return new Yallist(list)\n }\n\n constructor(list: Iterable<T> = []) {\n for (const item of list) {\n this.push(item)\n }\n }\n\n *[Symbol.iterator]() {\n for (let walker = this.head; walker; walker = walker.next) {\n yield walker.value\n }\n }\n\n removeNode(node: Node<T>) {\n if (node.list !== this) {\n throw new Error(\n 'removing node which does not belong to this list',\n )\n }\n\n const next = node.next\n const prev = node.prev\n\n if (next) {\n next.prev = prev\n }\n\n if (prev) {\n prev.next = next\n }\n\n if (node === this.head) {\n this.head = next\n }\n if (node === this.tail) {\n this.tail = prev\n }\n\n this.length--\n node.next = undefined\n node.prev = undefined\n node.list = undefined\n\n return next\n }\n\n unshiftNode(node: Node<T>) {\n if (node === this.head) {\n return\n }\n\n if (node.list) {\n node.list.removeNode(node)\n }\n\n const head = this.head\n node.list = this\n node.next = head\n if (head) {\n head.prev = node\n }\n\n this.head = node\n if (!this.tail) {\n this.tail = node\n }\n this.length++\n }\n\n pushNode(node: Node<T>) {\n if (node === this.tail) {\n return\n }\n\n if (node.list) {\n node.list.removeNode(node)\n }\n\n const tail = this.tail\n node.list = this\n node.prev = tail\n if (tail) {\n tail.next = node\n }\n\n this.tail = node\n if (!this.head) {\n this.head = node\n }\n this.length++\n }\n\n push(...args: T[]) {\n for (let i = 0, l = args.length; i < l; i++) {\n push(this, args[i])\n }\n return this.length\n }\n\n unshift(...args: T[]) {\n for (var i = 0, l = args.length; i < l; i++) {\n unshift(this, args[i])\n }\n return this.length\n }\n\n pop() {\n if (!this.tail) {\n return undefined\n }\n\n const res = this.tail.value\n const t = this.tail\n this.tail = this.tail.prev\n if (this.tail) {\n this.tail.next = undefined\n } else {\n this.head = undefined\n }\n t.list = undefined\n this.length--\n return res\n }\n\n shift() {\n if (!this.head) {\n return undefined\n }\n\n const res = this.head.value\n const h = this.head\n this.head = this.head.next\n if (this.head) {\n this.head.prev = undefined\n } else {\n this.tail = undefined\n }\n h.list = undefined\n this.length--\n return res\n }\n\n forEach(\n fn: (value: T, i: number, list: Yallist<T>) => any,\n thisp?: any,\n ) {\n thisp = thisp || this\n for (let walker = this.head, i = 0; !!walker; i++) {\n fn.call(thisp, walker.value, i, this)\n walker = walker.next\n }\n }\n\n forEachReverse(\n fn: (value: T, i: number, list: Yallist<T>) => any,\n thisp?: any,\n ) {\n thisp = thisp || this\n for (let walker = this.tail, i = this.length - 1; !!walker; i--) {\n fn.call(thisp, walker.value, i, this)\n walker = walker.prev\n }\n }\n\n get(n: number) {\n let i = 0\n let walker = this.head\n for (; !!walker && i < n; i++) {\n walker = walker.next\n }\n if (i === n && !!walker) {\n return walker.value\n }\n }\n\n getReverse(n: number) {\n let i = 0\n let walker = this.tail\n for (; !!walker && i < n; i++) {\n // abort out of the list early if we hit a cycle\n walker = walker.prev\n }\n if (i === n && !!walker) {\n return walker.value\n }\n }\n\n map<R = any>(\n fn: (value: T, list: Yallist<T>) => R,\n thisp?: any,\n ): Yallist<R> {\n thisp = thisp || this\n const res = new Yallist<R>()\n for (let walker = this.head; !!walker; ) {\n res.push(fn.call(thisp, walker.value, this))\n walker = walker.next\n }\n return res\n }\n\n mapReverse<R = any>(\n fn: (value: T, list: Yallist<T>) => R,\n thisp?: any,\n ): Yallist<R> {\n thisp = thisp || this\n var res = new Yallist<R>()\n for (let walker = this.tail; !!walker; ) {\n res.push(fn.call(thisp, walker.value, this))\n walker = walker.prev\n }\n return res\n }\n\n reduce(fn: (left: T, right: T, i: number) => T): T\n reduce<R = any>(\n fn: (acc: R, next: T, i: number) => R,\n initial: R,\n ): R\n reduce<R = any>(\n fn: (acc: R, next: T, i: number) => R,\n initial?: R,\n ): R {\n let acc: R | T\n let walker = this.head\n if (arguments.length > 1) {\n acc = initial as R\n } else if (this.head) {\n walker = this.head.next\n acc = this.head.value\n } else {\n throw new TypeError(\n 'Reduce of empty list with no initial value',\n )\n }\n\n for (var i = 0; !!walker; i++) {\n acc = fn(acc as R, walker.value, i)\n walker = walker.next\n }\n\n return acc as R\n }\n\n reduceReverse(fn: (left: T, right: T, i: number) => T): T\n reduceReverse<R = any>(\n fn: (acc: R, next: T, i: number) => R,\n initial: R,\n ): R\n reduceReverse<R = any>(\n fn: (acc: R, next: T, i: number) => R,\n initial?: R,\n ): R {\n let acc: R | T\n let walker = this.tail\n if (arguments.length > 1) {\n acc = initial as R\n } else if (this.tail) {\n walker = this.tail.prev\n acc = this.tail.value\n } else {\n throw new TypeError(\n 'Reduce of empty list with no initial value',\n )\n }\n\n for (let i = this.length - 1; !!walker; i--) {\n acc = fn(acc as R, walker.value, i)\n walker = walker.prev\n }\n\n return acc as R\n }\n\n toArray() {\n const arr = new Array(this.length)\n for (let i = 0, walker = this.head; !!walker; i++) {\n arr[i] = walker.value\n walker = walker.next\n }\n return arr\n }\n\n toArrayReverse() {\n const arr = new Array(this.length)\n for (let i = 0, walker = this.tail; !!walker; i++) {\n arr[i] = walker.value\n walker = walker.prev\n }\n return arr\n }\n\n slice(from: number = 0, to: number = this.length) {\n if (to < 0) {\n to += this.length\n }\n if (from < 0) {\n from += this.length\n }\n const ret = new Yallist()\n if (to < from || to < 0) {\n return ret\n }\n if (from < 0) {\n from = 0\n }\n if (to > this.length) {\n to = this.length\n }\n let walker = this.head\n let i = 0\n for (i = 0; !!walker && i < from; i++) {\n walker = walker.next\n }\n for (; !!walker && i < to; i++, walker = walker.next) {\n ret.push(walker.value)\n }\n return ret\n }\n\n sliceReverse(from: number = 0, to: number = this.length) {\n if (to < 0) {\n to += this.length\n }\n if (from < 0) {\n from += this.length\n }\n const ret = new Yallist()\n if (to < from || to < 0) {\n return ret\n }\n if (from < 0) {\n from = 0\n }\n if (to > this.length) {\n to = this.length\n }\n let i = this.length\n let walker = this.tail\n for (; !!walker && i > to; i--) {\n walker = walker.prev\n }\n for (; !!walker && i > from; i--, walker = walker.prev) {\n ret.push(walker.value)\n }\n return ret\n }\n\n splice(start: number, deleteCount: number = 0, ...nodes: T[]) {\n if (start > this.length) {\n start = this.length - 1\n }\n if (start < 0) {\n start = this.length + start\n }\n\n let walker = this.head\n\n for (let i = 0; !!walker && i < start; i++) {\n walker = walker.next\n }\n\n const ret: T[] = []\n for (let i = 0; !!walker && i < deleteCount; i++) {\n ret.push(walker.value)\n walker = this.removeNode(walker)\n }\n if (!walker) {\n walker = this.tail\n } else if (walker !== this.tail) {\n walker = walker.prev\n }\n\n for (const v of nodes) {\n walker = insertAfter<T>(this, walker, v)\n }\n\n return ret\n }\n\n reverse() {\n const head = this.head\n const tail = this.tail\n for (let walker = head; !!walker; walker = walker.prev) {\n const p = walker.prev\n walker.prev = walker.next\n walker.next = p\n }\n this.head = tail\n this.tail = head\n return this\n }\n}\n\n// insertAfter undefined means \"make the node the new head of list\"\nfunction insertAfter<T>(\n self: Yallist<T>,\n node: Node<T> | undefined,\n value: T,\n) {\n const prev = node\n const next = node ? node.next : self.head\n const inserted = new Node<T>(value, prev, next, self)\n\n if (inserted.next === undefined) {\n self.tail = inserted\n }\n if (inserted.prev === undefined) {\n self.head = inserted\n }\n\n self.length++\n\n return inserted\n}\n\nfunction push<T>(self: Yallist<T>, item: T) {\n self.tail = new Node<T>(item, self.tail, undefined, self)\n if (!self.head) {\n self.head = self.tail\n }\n self.length++\n}\n\nfunction unshift<T>(self: Yallist<T>, item: T) {\n self.head = new Node<T>(item, undefined, self.head, self)\n if (!self.tail) {\n self.tail = self.head\n }\n self.length++\n}\n\nexport class Node<T = unknown> {\n list?: Yallist<T>\n next?: Node<T>\n prev?: Node<T>\n value: T\n\n constructor(\n value: T,\n prev?: Node<T> | undefined,\n next?: Node<T> | undefined,\n list?: Yallist<T> | undefined,\n ) {\n this.list = list\n this.value = value\n\n if (prev) {\n prev.next = this\n this.prev = prev\n } else {\n this.prev = undefined\n }\n\n if (next) {\n next.prev = this\n this.next = next\n } else {\n this.next = undefined\n }\n }\n}\n", "// tar -x\nimport * as fsm from '@isaacs/fs-minipass'\nimport fs from 'node:fs'\nimport { filesFilter } from './list.js'\nimport { makeCommand } from './make-command.js'\nimport type { TarOptionsFile, TarOptionsSyncFile } from './options.js'\nimport { Unpack, UnpackSync } from './unpack.js'\n\nconst extractFileSync = (opt: TarOptionsSyncFile) => {\n const u = new UnpackSync(opt)\n const file = opt.file\n const stat = fs.statSync(file)\n // This trades a zero-byte read() syscall for a stat\n // However, it will usually result in less memory allocation\n const readSize = opt.maxReadSize || 16 * 1024 * 1024\n const stream = new fsm.ReadStreamSync(file, {\n readSize: readSize,\n size: stat.size,\n })\n stream.pipe(u)\n}\n\nconst extractFile = (opt: TarOptionsFile, _?: string[]) => {\n const u = new Unpack(opt)\n const readSize = opt.maxReadSize || 16 * 1024 * 1024\n\n const file = opt.file\n const p = new Promise<void>((resolve, reject) => {\n u.on('error', reject)\n u.on('close', resolve)\n\n // This trades a zero-byte read() syscall for a stat\n // However, it will usually result in less memory allocation\n fs.stat(file, (er, stat) => {\n if (er) {\n reject(er)\n } else {\n const stream = new fsm.ReadStream(file, {\n readSize: readSize,\n size: stat.size,\n })\n stream.on('error', reject)\n stream.pipe(u)\n }\n })\n })\n return p\n}\n\nexport const extract = makeCommand<Unpack, UnpackSync>(\n extractFileSync,\n extractFile,\n opt => new UnpackSync(opt),\n opt => new Unpack(opt),\n (opt, files) => {\n if (files?.length) filesFilter(opt, files)\n },\n)\n", "// the PEND/UNPEND stuff tracks whether we're ready to emit end/close yet.\n// but the path reservations are required to avoid race conditions where\n// parallelized unpack ops may mess with one another, due to dependencies\n// (like a Link depending on its target) or destructive operations (like\n// clobbering an fs object to create one of a different type.)\n\nimport * as fsm from '@isaacs/fs-minipass'\nimport assert from 'node:assert'\nimport { randomBytes } from 'node:crypto'\nimport fs, { type Stats } from 'node:fs'\nimport path from 'node:path'\nimport { getWriteFlag } from './get-write-flag.js'\nimport type { MkdirError } from './mkdir.js'\nimport { mkdir, mkdirSync } from './mkdir.js'\nimport { normalizeWindowsPath } from './normalize-windows-path.js'\nimport { Parser } from './parse.js'\nimport { stripAbsolutePath } from './strip-absolute-path.js'\nimport * as wc from './winchars.js'\n\nimport type { TarOptions } from './options.js'\nimport { PathReservations } from './path-reservations.js'\nimport type { ReadEntry } from './read-entry.js'\nimport type { WarnData } from './warn-method.js'\nimport { SymlinkError } from './symlink-error.js'\nimport { umask } from './process-umask.js'\n\nconst ONENTRY = Symbol('onEntry')\nconst CHECKFS = Symbol('checkFs')\nconst CHECKFS2 = Symbol('checkFs2')\nconst ISREUSABLE = Symbol('isReusable')\nconst MAKEFS = Symbol('makeFs')\nconst FILE = Symbol('file')\nconst DIRECTORY = Symbol('directory')\nconst LINK = Symbol('link')\nconst SYMLINK = Symbol('symlink')\nconst HARDLINK = Symbol('hardlink')\nconst ENSURE_NO_SYMLINK = Symbol('ensureNoSymlink')\nconst UNSUPPORTED = Symbol('unsupported')\nconst CHECKPATH = Symbol('checkPath')\nconst STRIPABSOLUTEPATH = Symbol('stripAbsolutePath')\nconst MKDIR = Symbol('mkdir')\nconst ONERROR = Symbol('onError')\nconst PENDING = Symbol('pending')\nconst PEND = Symbol('pend')\nconst UNPEND = Symbol('unpend')\nconst ENDED = Symbol('ended')\nconst MAYBECLOSE = Symbol('maybeClose')\nconst SKIP = Symbol('skip')\nconst DOCHOWN = Symbol('doChown')\nconst UID = Symbol('uid')\nconst GID = Symbol('gid')\nconst CHECKED_CWD = Symbol('checkedCwd')\nconst platform = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform\nconst isWindows = platform === 'win32'\nconst DEFAULT_MAX_DEPTH = 1024\n\n// Unlinks on Windows are not atomic.\n//\n// This means that if you have a file entry, followed by another\n// file entry with an identical name, and you cannot re-use the file\n// (because it's a hardlink, or because unlink:true is set, or it's\n// Windows, which does not have useful nlink values), then the unlink\n// will be committed to the disk AFTER the new file has been written\n// over the old one, deleting the new file.\n//\n// To work around this, on Windows systems, we rename the file and then\n// delete the renamed file. It's a sloppy kludge, but frankly, I do not\n// know of a better way to do this, given windows' non-atomic unlink\n// semantics.\n//\n// See: https://github.com/npm/node-tar/issues/183\n/* c8 ignore start */\nconst unlinkFile = (path: string, cb: (er?: Error | null) => void) => {\n if (!isWindows) {\n return fs.unlink(path, cb)\n }\n\n const name = path + '.DELETE.' + randomBytes(16).toString('hex')\n fs.rename(path, name, er => {\n if (er) {\n return cb(er)\n }\n fs.unlink(name, cb)\n })\n}\n/* c8 ignore stop */\n\n/* c8 ignore start */\nconst unlinkFileSync = (path: string) => {\n if (!isWindows) {\n return fs.unlinkSync(path)\n }\n\n const name = path + '.DELETE.' + randomBytes(16).toString('hex')\n fs.renameSync(path, name)\n fs.unlinkSync(name)\n}\n/* c8 ignore stop */\n\n// this.gid, entry.gid, this.processUid\nconst uint32 = (\n a: number | undefined,\n b: number | undefined,\n c: number | undefined,\n) =>\n a !== undefined && a === a >>> 0 ? a\n : b !== undefined && b === b >>> 0 ? b\n : c\n\nexport class Unpack extends Parser {\n [ENDED]: boolean = false;\n [CHECKED_CWD]: boolean = false;\n [PENDING]: number = 0\n\n reservations: PathReservations = new PathReservations()\n transform?: TarOptions['transform']\n writable: true = true\n readable: false = false\n uid?: number\n gid?: number\n setOwner: boolean\n preserveOwner: boolean\n processGid?: number\n processUid?: number\n maxDepth: number\n forceChown: boolean\n win32: boolean\n newer: boolean\n keep: boolean\n noMtime: boolean\n preservePaths: boolean\n unlink: boolean\n cwd: string\n strip: number\n processUmask: number\n umask: number\n dmode: number\n fmode: number\n chmod: boolean\n\n constructor(opt: TarOptions = {}) {\n opt.ondone = () => {\n this[ENDED] = true\n this[MAYBECLOSE]()\n }\n\n super(opt)\n\n this.transform = opt.transform\n\n this.chmod = !!opt.chmod\n\n if (typeof opt.uid === 'number' || typeof opt.gid === 'number') {\n // need both or neither\n if (typeof opt.uid !== 'number' || typeof opt.gid !== 'number') {\n throw new TypeError('cannot set owner without number uid and gid')\n }\n if (opt.preserveOwner) {\n throw new TypeError(\n 'cannot preserve owner in archive and also set owner explicitly',\n )\n }\n this.uid = opt.uid\n this.gid = opt.gid\n this.setOwner = true\n } else {\n this.uid = undefined\n this.gid = undefined\n this.setOwner = false\n }\n\n // default true for root\n this.preserveOwner =\n opt.preserveOwner === undefined && typeof opt.uid !== 'number' ?\n !!(process.getuid?.() === 0)\n : !!opt.preserveOwner\n\n this.processUid =\n (this.preserveOwner || this.setOwner) && process.getuid ?\n process.getuid()\n : undefined\n this.processGid =\n (this.preserveOwner || this.setOwner) && process.getgid ?\n process.getgid()\n : undefined\n\n // prevent excessively deep nesting of subfolders\n // set to `Infinity` to remove this restriction\n this.maxDepth =\n typeof opt.maxDepth === 'number' ? opt.maxDepth : DEFAULT_MAX_DEPTH\n\n // mostly just for testing, but useful in some cases.\n // Forcibly trigger a chown on every entry, no matter what\n this.forceChown = opt.forceChown === true\n\n // turn ><?| in filenames into 0xf000-higher encoded forms\n this.win32 = !!opt.win32 || isWindows\n\n // do not unpack over files that are newer than what's in the archive\n this.newer = !!opt.newer\n\n // do not unpack over ANY files\n this.keep = !!opt.keep\n\n // do not set mtime/atime of extracted entries\n this.noMtime = !!opt.noMtime\n\n // allow .., absolute path entries, and unpacking through symlinks\n // without this, warn and skip .., relativize absolutes, and error\n // on symlinks in extraction path\n this.preservePaths = !!opt.preservePaths\n\n // unlink files and links before writing. This breaks existing hard\n // links, and removes symlink directories rather than erroring\n this.unlink = !!opt.unlink\n\n this.cwd = normalizeWindowsPath(path.resolve(opt.cwd || process.cwd()))\n this.strip = Number(opt.strip) || 0\n // if we're not chmodding, then we don't need the process umask\n this.processUmask =\n !this.chmod ? 0\n : typeof opt.processUmask === 'number' ? opt.processUmask\n : umask()\n this.umask =\n typeof opt.umask === 'number' ? opt.umask : this.processUmask\n\n // default mode for dirs created as parents\n this.dmode = opt.dmode || 0o0777 & ~this.umask\n this.fmode = opt.fmode || 0o0666 & ~this.umask\n\n this.on('entry', entry => this[ONENTRY](entry))\n }\n\n // a bad or damaged archive is a warning for Parser, but an error\n // when extracting. Mark those errors as unrecoverable, because\n // the Unpack contract cannot be met.\n warn(code: string, msg: string | Error, data: WarnData = {}) {\n if (code === 'TAR_BAD_ARCHIVE' || code === 'TAR_ABORT') {\n data.recoverable = false\n }\n return super.warn(code, msg, data)\n }\n\n [MAYBECLOSE]() {\n if (this[ENDED] && this[PENDING] === 0) {\n this.emit('prefinish')\n this.emit('finish')\n this.emit('end')\n }\n }\n\n // return false if we need to skip this file\n // return true if the field was successfully sanitized\n [STRIPABSOLUTEPATH](\n entry: ReadEntry,\n field: 'path' | 'linkpath',\n ): boolean {\n const p = entry[field]\n const { type } = entry\n if (!p || this.preservePaths) return true\n\n // strip off the root\n const [root, stripped] = stripAbsolutePath(p)\n const parts = stripped.replaceAll(/\\\\/g, '/').split('/')\n\n if (\n parts.includes('..') ||\n /* c8 ignore next */\n (isWindows && /^[a-z]:\\.\\.$/i.test(parts[0] ?? ''))\n ) {\n // For linkpath, check if the resolved path escapes cwd rather than\n // just rejecting any path with '..' - relative symlinks like\n // '../sibling/file' are valid if they resolve within the cwd.\n // For paths, they just simply may not ever use .. at all.\n if (field === 'path' || type === 'Link') {\n this.warn('TAR_ENTRY_ERROR', `${field} contains '..'`, {\n entry,\n [field]: p,\n })\n // not ok!\n return false\n }\n // Resolve linkpath relative to the entry's directory.\n // `path.posix` is safe to use because we're operating on\n // tar paths, not a filesystem.\n const entryDir = path.posix.dirname(entry.path)\n const resolved = path.posix.normalize(\n path.posix.join(entryDir, parts.join('/')),\n )\n // If the resolved path escapes (starts with ..), reject it\n if (resolved.startsWith('../') || resolved === '..') {\n this.warn(\n 'TAR_ENTRY_ERROR',\n `${field} escapes extraction directory`,\n {\n entry,\n [field]: p,\n },\n )\n return false\n }\n }\n\n if (root) {\n // ok, but triggers warning about stripping root\n entry[field] = String(stripped)\n this.warn(\n 'TAR_ENTRY_INFO',\n `stripping ${root} from absolute ${field}`,\n {\n entry,\n [field]: p,\n },\n )\n }\n return true\n }\n\n // no IO, just string checking for absolute indicators\n [CHECKPATH](entry: ReadEntry) {\n const p = normalizeWindowsPath(entry.path)\n const parts = p.split('/')\n\n if (this.strip) {\n if (parts.length < this.strip) {\n return false\n }\n if (entry.type === 'Link') {\n const linkparts = normalizeWindowsPath(\n String(entry.linkpath),\n ).split('/')\n if (linkparts.length >= this.strip) {\n entry.linkpath = linkparts.slice(this.strip).join('/')\n } else {\n return false\n }\n }\n parts.splice(0, this.strip)\n entry.path = parts.join('/')\n }\n\n if (isFinite(this.maxDepth) && parts.length > this.maxDepth) {\n this.warn('TAR_ENTRY_ERROR', 'path excessively deep', {\n entry,\n path: p,\n depth: parts.length,\n maxDepth: this.maxDepth,\n })\n return false\n }\n\n if (\n !this[STRIPABSOLUTEPATH](entry, 'path') ||\n !this[STRIPABSOLUTEPATH](entry, 'linkpath')\n ) {\n return false\n }\n\n entry.absolute =\n path.isAbsolute(entry.path) ?\n normalizeWindowsPath(path.resolve(entry.path))\n : normalizeWindowsPath(path.resolve(this.cwd, entry.path))\n\n // if we somehow ended up with a path that escapes the cwd, and we are\n // not in preservePaths mode, then something is fishy! This should have\n // been prevented above, so ignore this for coverage.\n /* c8 ignore start - defense in depth */\n if (\n !this.preservePaths &&\n typeof entry.absolute === 'string' &&\n entry.absolute.indexOf(this.cwd + '/') !== 0 &&\n entry.absolute !== this.cwd\n ) {\n this.warn('TAR_ENTRY_ERROR', 'path escaped extraction target', {\n entry,\n path: normalizeWindowsPath(entry.path),\n resolvedPath: entry.absolute,\n cwd: this.cwd,\n })\n return false\n }\n /* c8 ignore stop */\n\n // an archive can set properties on the extraction directory, but it\n // may not replace the cwd with a different kind of thing entirely.\n if (\n entry.absolute === this.cwd &&\n entry.type !== 'Directory' &&\n entry.type !== 'GNUDumpDir'\n ) {\n return false\n }\n\n // only encode : chars that aren't drive letter indicators\n if (this.win32) {\n const { root: aRoot } = path.win32.parse(String(entry.absolute))\n entry.absolute =\n aRoot + wc.encode(String(entry.absolute).slice(aRoot.length))\n const { root: pRoot } = path.win32.parse(entry.path)\n entry.path = pRoot + wc.encode(entry.path.slice(pRoot.length))\n }\n\n return true\n }\n\n [ONENTRY](entry: ReadEntry) {\n if (!this[CHECKPATH](entry)) {\n return entry.resume()\n }\n\n assert.equal(typeof entry.absolute, 'string')\n\n switch (entry.type) {\n case 'Directory':\n case 'GNUDumpDir':\n if (entry.mode) {\n entry.mode = entry.mode | 0o700\n }\n\n // eslint-disable-next-line no-fallthrough\n case 'File':\n case 'OldFile':\n case 'ContiguousFile':\n case 'Link':\n case 'SymbolicLink':\n return this[CHECKFS](entry)\n\n case 'CharacterDevice':\n case 'BlockDevice':\n case 'FIFO':\n default:\n return this[UNSUPPORTED](entry)\n }\n }\n\n [ONERROR](er: Error, entry: ReadEntry) {\n // Cwd has to exist, or else nothing works. That's serious.\n // Other errors are warnings, which raise the error in strict\n // mode, but otherwise continue on.\n if (er.name === 'CwdError') {\n this.emit('error', er)\n } else {\n this.warn('TAR_ENTRY_ERROR', er, { entry })\n this[UNPEND]()\n entry.resume()\n }\n }\n\n [MKDIR](\n dir: string,\n mode: number,\n cb: (er?: null | MkdirError, made?: string) => void,\n ) {\n void mkdir(\n normalizeWindowsPath(dir),\n {\n uid: this.uid,\n gid: this.gid,\n processUid: this.processUid,\n processGid: this.processGid,\n umask: this.processUmask,\n preserve: this.preservePaths,\n unlink: this.unlink,\n cwd: this.cwd,\n mode: mode,\n },\n cb,\n )\n }\n\n [DOCHOWN](entry: ReadEntry) {\n // in preserve owner mode, chown if the entry doesn't match process\n // in set owner mode, chown if setting doesn't match process\n return (\n this.forceChown ||\n (this.preserveOwner &&\n ((typeof entry.uid === 'number' &&\n entry.uid !== this.processUid) ||\n (typeof entry.gid === 'number' &&\n entry.gid !== this.processGid))) ||\n (typeof this.uid === 'number' && this.uid !== this.processUid) ||\n (typeof this.gid === 'number' && this.gid !== this.processGid)\n )\n }\n\n [UID](entry: ReadEntry) {\n return uint32(this.uid, entry.uid, this.processUid)\n }\n\n [GID](entry: ReadEntry) {\n return uint32(this.gid, entry.gid, this.processGid)\n }\n\n [FILE](entry: ReadEntry, fullyDone: () => void) {\n const mode =\n typeof entry.mode === 'number' ? entry.mode & 0o7777 : this.fmode\n const stream = new fsm.WriteStream(String(entry.absolute), {\n // slight lie, but it can be numeric flags\n flags: getWriteFlag(entry.size) as string,\n mode: mode,\n autoClose: false,\n })\n stream.on('error', (er: Error) => {\n if (stream.fd) {\n fs.close(stream.fd, () => {})\n }\n\n // flush all the data out so that we aren't left hanging\n // if the error wasn't actually fatal. otherwise the parse\n // is blocked, and we never proceed.\n stream.write = () => true\n this[ONERROR](er, entry)\n fullyDone()\n })\n\n let actions = 1\n const done = (er?: null | Error) => {\n if (er) {\n /* c8 ignore start - we should always have a fd by now */\n if (stream.fd) {\n fs.close(stream.fd, () => {})\n }\n /* c8 ignore stop */\n\n this[ONERROR](er, entry)\n fullyDone()\n return\n }\n\n if (--actions === 0) {\n if (stream.fd !== undefined) {\n fs.close(stream.fd, er => {\n if (er) {\n this[ONERROR](er, entry)\n } else {\n this[UNPEND]()\n }\n fullyDone()\n })\n }\n }\n }\n\n stream.on('finish', () => {\n // if futimes fails, try utimes\n // if utimes fails, fail with the original error\n // same for fchown/chown\n const abs = String(entry.absolute)\n const fd = stream.fd\n\n if (typeof fd === 'number' && entry.mtime && !this.noMtime) {\n actions++\n const atime = entry.atime || new Date()\n const mtime = entry.mtime\n fs.futimes(fd, atime, mtime, er =>\n er ?\n fs.utimes(abs, atime, mtime, er2 => done(er2 && er))\n : done(),\n )\n }\n\n if (typeof fd === 'number' && this[DOCHOWN](entry)) {\n actions++\n const uid = this[UID](entry)\n const gid = this[GID](entry)\n if (typeof uid === 'number' && typeof gid === 'number') {\n fs.fchown(fd, uid, gid, er =>\n er ? fs.chown(abs, uid, gid, er2 => done(er2 && er)) : done(),\n )\n }\n }\n\n done()\n })\n\n const tx = this.transform ? this.transform(entry) || entry : entry\n if (tx !== entry) {\n tx.on('error', er => {\n this[ONERROR](er as Error, entry)\n fullyDone()\n })\n entry.pipe(tx)\n }\n tx.pipe(stream)\n }\n\n [DIRECTORY](entry: ReadEntry, fullyDone: () => void) {\n const mode =\n typeof entry.mode === 'number' ? entry.mode & 0o7777 : this.dmode\n this[MKDIR](String(entry.absolute), mode, er => {\n if (er) {\n this[ONERROR](er, entry)\n fullyDone()\n return\n }\n\n let actions = 1\n const done = () => {\n if (--actions === 0) {\n fullyDone()\n this[UNPEND]()\n entry.resume()\n }\n }\n\n if (entry.mtime && !this.noMtime) {\n actions++\n fs.utimes(\n String(entry.absolute),\n entry.atime || new Date(),\n entry.mtime,\n done,\n )\n }\n\n if (this[DOCHOWN](entry)) {\n actions++\n fs.chown(\n String(entry.absolute),\n Number(this[UID](entry)),\n Number(this[GID](entry)),\n done,\n )\n }\n\n done()\n })\n }\n\n [UNSUPPORTED](entry: ReadEntry) {\n entry.unsupported = true\n this.warn(\n 'TAR_ENTRY_UNSUPPORTED',\n `unsupported entry type: ${entry.type}`,\n { entry },\n )\n entry.resume()\n }\n\n [SYMLINK](entry: ReadEntry, done: () => void) {\n const parts = normalizeWindowsPath(\n path.relative(\n this.cwd,\n path.resolve(\n path.dirname(String(entry.absolute)),\n String(entry.linkpath),\n ),\n ),\n ).split('/')\n this[ENSURE_NO_SYMLINK](\n entry,\n this.cwd,\n parts,\n () => this[LINK](entry, String(entry.linkpath), 'symlink', done),\n er => {\n this[ONERROR](er, entry)\n done()\n },\n )\n }\n\n [HARDLINK](entry: ReadEntry, done: () => void) {\n const linkpath = normalizeWindowsPath(\n path.resolve(this.cwd, String(entry.linkpath)),\n )\n const parts = normalizeWindowsPath(String(entry.linkpath)).split('/')\n this[ENSURE_NO_SYMLINK](\n entry,\n this.cwd,\n parts,\n () => this[LINK](entry, linkpath, 'link', done),\n er => {\n this[ONERROR](er, entry)\n done()\n },\n )\n }\n\n [ENSURE_NO_SYMLINK](\n entry: ReadEntry,\n cwd: string,\n parts: string[],\n done: () => void,\n onError: (er: SymlinkError) => void,\n ) {\n const p = parts.shift()\n if (this.preservePaths || p === undefined) return done()\n const t = path.resolve(cwd, p)\n fs.lstat(t, (er, st) => {\n if (er) return done()\n if (st?.isSymbolicLink()) {\n return onError(\n new SymlinkError(t, path.resolve(t, parts.join('/'))),\n )\n }\n this[ENSURE_NO_SYMLINK](entry, t, parts, done, onError)\n })\n }\n\n [PEND]() {\n this[PENDING]++\n }\n\n [UNPEND]() {\n this[PENDING]--\n this[MAYBECLOSE]()\n }\n\n [SKIP](entry: ReadEntry) {\n this[UNPEND]()\n entry.resume()\n }\n\n // Check if we can reuse an existing filesystem entry safely and\n // overwrite it, rather than unlinking and recreating\n // Windows doesn't report a useful nlink, so we just never reuse entries\n [ISREUSABLE](entry: ReadEntry, st: Stats) {\n return (\n entry.type === 'File' &&\n !this.unlink &&\n st.isFile() &&\n st.nlink <= 1 &&\n !isWindows\n )\n }\n\n // check if a thing is there, and if so, try to clobber it\n [CHECKFS](entry: ReadEntry) {\n this[PEND]()\n const paths = [entry.path]\n if (entry.linkpath) {\n paths.push(entry.linkpath)\n }\n this.reservations.reserve(paths, done => this[CHECKFS2](entry, done))\n }\n\n [CHECKFS2](entry: ReadEntry, fullyDone: (er?: Error) => void) {\n const done = (er?: Error) => {\n fullyDone(er)\n }\n\n const checkCwd = () => {\n this[MKDIR](this.cwd, this.dmode, er => {\n if (er) {\n this[ONERROR](er, entry)\n done()\n return\n }\n this[CHECKED_CWD] = true\n start()\n })\n }\n\n const start = () => {\n if (entry.absolute !== this.cwd) {\n const parent = normalizeWindowsPath(\n path.dirname(String(entry.absolute)),\n )\n if (parent !== this.cwd) {\n return this[MKDIR](parent, this.dmode, er => {\n if (er) {\n this[ONERROR](er, entry)\n done()\n return\n }\n afterMakeParent()\n })\n }\n }\n afterMakeParent()\n }\n\n const afterMakeParent = () => {\n fs.lstat(String(entry.absolute), (lstatEr, st) => {\n if (\n st &&\n (this.keep ||\n /* c8 ignore next */\n (this.newer && st.mtime > (entry.mtime ?? st.mtime)))\n ) {\n this[SKIP](entry)\n done()\n return\n }\n if (lstatEr || this[ISREUSABLE](entry, st)) {\n return this[MAKEFS](null, entry, done)\n }\n\n if (st.isDirectory()) {\n if (entry.type === 'Directory') {\n const needChmod =\n this.chmod && entry.mode && (st.mode & 0o7777) !== entry.mode\n const afterChmod = (er?: Error | null | undefined) =>\n this[MAKEFS](er ?? null, entry, done)\n if (!needChmod) {\n return afterChmod()\n }\n return fs.chmod(\n String(entry.absolute),\n Number(entry.mode),\n afterChmod,\n )\n }\n // Not a dir entry, have to remove it.\n // NB: the only way to end up with an entry that is the cwd\n // itself, in such a way that == does not detect, is a\n // tricky windows absolute path with UNC or 8.3 parts (and\n // preservePaths:true, or else it will have been stripped).\n // In that case, the user has opted out of path protections\n // explicitly, so if they blow away the cwd, c'est la vie.\n if (entry.absolute !== this.cwd) {\n return fs.rmdir(String(entry.absolute), (er?: null | Error) =>\n this[MAKEFS](er ?? null, entry, done),\n )\n }\n }\n\n // not a dir, and not reusable\n // don't remove if the cwd, we want that error\n if (entry.absolute === this.cwd) {\n return this[MAKEFS](null, entry, done)\n }\n\n unlinkFile(String(entry.absolute), er =>\n this[MAKEFS](er ?? null, entry, done),\n )\n })\n }\n\n if (this[CHECKED_CWD]) {\n start()\n } else {\n checkCwd()\n }\n }\n\n [MAKEFS](\n er: null | undefined | Error,\n entry: ReadEntry,\n done: () => void,\n ) {\n if (er) {\n this[ONERROR](er, entry)\n done()\n return\n }\n\n switch (entry.type) {\n case 'File':\n case 'OldFile':\n case 'ContiguousFile':\n return this[FILE](entry, done)\n\n case 'Link':\n return this[HARDLINK](entry, done)\n\n case 'SymbolicLink':\n return this[SYMLINK](entry, done)\n\n case 'Directory':\n case 'GNUDumpDir':\n return this[DIRECTORY](entry, done)\n }\n }\n\n [LINK](\n entry: ReadEntry,\n linkpath: string,\n link: 'link' | 'symlink',\n done: () => void,\n ) {\n fs[link](linkpath, String(entry.absolute), er => {\n if (er) {\n this[ONERROR](er, entry)\n } else {\n this[UNPEND]()\n entry.resume()\n }\n done()\n })\n }\n}\n\nconst callSync = <T>(\n fn: () => T,\n): [null, T] | [NodeJS.ErrnoException, null] => {\n try {\n return [null, fn()]\n } catch (er) {\n return [er as NodeJS.ErrnoException, null]\n }\n}\n\nexport class UnpackSync extends Unpack {\n sync: true = true;\n\n [MAKEFS](er: null | Error | undefined, entry: ReadEntry) {\n return super[MAKEFS](er, entry, () => {})\n }\n\n [CHECKFS](entry: ReadEntry) {\n if (!this[CHECKED_CWD]) {\n const er = this[MKDIR](this.cwd, this.dmode)\n if (er) {\n return this[ONERROR](er as Error, entry)\n }\n this[CHECKED_CWD] = true\n }\n\n // don't bother to make the parent if the current entry is the cwd,\n // we've already checked it.\n if (entry.absolute !== this.cwd) {\n const parent = normalizeWindowsPath(\n path.dirname(String(entry.absolute)),\n )\n if (parent !== this.cwd) {\n const mkParent = this[MKDIR](parent, this.dmode)\n if (mkParent) {\n return this[ONERROR](mkParent as Error, entry)\n }\n }\n }\n\n const [lstatEr, st] = callSync(() =>\n fs.lstatSync(String(entry.absolute)),\n )\n if (\n st &&\n (this.keep ||\n /* c8 ignore next */\n (this.newer && st.mtime > (entry.mtime ?? st.mtime)))\n ) {\n return this[SKIP](entry)\n }\n\n if (lstatEr || this[ISREUSABLE](entry, st)) {\n return this[MAKEFS](null, entry)\n }\n\n if (st.isDirectory()) {\n if (entry.type === 'Directory') {\n const needChmod =\n this.chmod && entry.mode && (st.mode & 0o7777) !== entry.mode\n const [er] =\n needChmod ?\n callSync(() => {\n fs.chmodSync(String(entry.absolute), Number(entry.mode))\n })\n : []\n return this[MAKEFS](er, entry)\n }\n // not a dir entry, have to remove it\n const [er] = callSync(() => fs.rmdirSync(String(entry.absolute)))\n this[MAKEFS](er, entry)\n }\n\n // not a dir, and not reusable.\n // don't remove if it's the cwd, since we want that error.\n const [er] =\n entry.absolute === this.cwd ?\n []\n : callSync(() => unlinkFileSync(String(entry.absolute)))\n this[MAKEFS](er, entry)\n }\n\n [FILE](entry: ReadEntry, done: () => void) {\n const mode =\n typeof entry.mode === 'number' ? entry.mode & 0o7777 : this.fmode\n\n const oner = (er?: null | Error | undefined) => {\n let closeError\n try {\n fs.closeSync(fd)\n } catch (e) {\n closeError = e\n }\n if (er || closeError) {\n this[ONERROR]((er as Error) || closeError, entry)\n }\n done()\n }\n\n let fd: number\n try {\n fd = fs.openSync(\n String(entry.absolute),\n getWriteFlag(entry.size),\n mode,\n )\n /* c8 ignore start - This is only a problem if the file was successfully\n * statted, BUT failed to open. Testing this is annoying, and we\n * already have ample testint for other uses of oner() methods.\n */\n } catch (er) {\n return oner(er as Error)\n }\n /* c8 ignore stop */\n const tx = this.transform ? this.transform(entry) || entry : entry\n if (tx !== entry) {\n tx.on('error', er => this[ONERROR](er as Error, entry))\n entry.pipe(tx)\n }\n\n tx.on('data', (chunk: Buffer) => {\n try {\n fs.writeSync(fd, chunk, 0, chunk.length)\n } catch (er) {\n oner(er as Error)\n }\n })\n\n tx.on('end', () => {\n let er = null\n // try both, falling futimes back to utimes\n // if either fails, handle the first error\n if (entry.mtime && !this.noMtime) {\n const atime = entry.atime || new Date()\n const mtime = entry.mtime\n try {\n fs.futimesSync(fd, atime, mtime)\n } catch (futimeser) {\n try {\n fs.utimesSync(String(entry.absolute), atime, mtime)\n } catch {\n er = futimeser\n }\n }\n }\n\n if (this[DOCHOWN](entry)) {\n const uid = this[UID](entry)\n const gid = this[GID](entry)\n\n try {\n fs.fchownSync(fd, Number(uid), Number(gid))\n } catch (fchowner) {\n try {\n fs.chownSync(String(entry.absolute), Number(uid), Number(gid))\n } catch {\n er = er || fchowner\n }\n }\n }\n\n oner(er as Error)\n })\n }\n\n [DIRECTORY](entry: ReadEntry, done: () => void) {\n const mode =\n typeof entry.mode === 'number' ? entry.mode & 0o7777 : this.dmode\n const er = this[MKDIR](String(entry.absolute), mode)\n if (er) {\n this[ONERROR](er as Error, entry)\n done()\n return\n }\n if (entry.mtime && !this.noMtime) {\n try {\n fs.utimesSync(\n String(entry.absolute),\n entry.atime || new Date(),\n entry.mtime,\n )\n /* c8 ignore next */\n } catch {}\n }\n if (this[DOCHOWN](entry)) {\n try {\n fs.chownSync(\n String(entry.absolute),\n Number(this[UID](entry)),\n Number(this[GID](entry)),\n )\n } catch {}\n }\n done()\n entry.resume()\n }\n\n [MKDIR](dir: string, mode: number) {\n try {\n return mkdirSync(normalizeWindowsPath(dir), {\n uid: this.uid,\n gid: this.gid,\n processUid: this.processUid,\n processGid: this.processGid,\n umask: this.processUmask,\n preserve: this.preservePaths,\n unlink: this.unlink,\n cwd: this.cwd,\n mode: mode,\n })\n } catch (er) {\n return er\n }\n }\n\n [ENSURE_NO_SYMLINK](\n _entry: ReadEntry,\n cwd: string,\n parts: string[],\n done: () => void,\n onError: (er: SymlinkError) => void,\n ) {\n if (this.preservePaths || parts.length === 0) return done()\n let t = cwd\n for (const p of parts) {\n t = path.resolve(t, p)\n const [er, st] = callSync(() => fs.lstatSync(t))\n if (er) return done()\n if (st.isSymbolicLink()) {\n return onError(\n new SymlinkError(t, path.resolve(cwd, parts.join('/'))),\n )\n }\n }\n done()\n }\n\n [LINK](\n entry: ReadEntry,\n linkpath: string,\n link: 'link' | 'symlink',\n done: () => void,\n ) {\n const linkSync: `${typeof link}Sync` = `${link}Sync`\n try {\n fs[linkSync](linkpath, String(entry.absolute))\n done()\n entry.resume()\n } catch (er) {\n return this[ONERROR](er as Error, entry)\n }\n }\n}\n", "// Get the appropriate flag to use for creating files\n// We use fmap on Windows platforms for files less than\n// 512kb. This is a fairly low limit, but avoids making\n// things slower in some cases. Since most of what this\n// library is used for is extracting tarballs of many\n// relatively small files in npm packages and the like,\n// it can be a big boost on Windows platforms.\n\nimport fs from 'fs'\n\nconst platform = process.env.__FAKE_PLATFORM__ || process.platform\nconst isWindows = platform === 'win32'\n\n/* c8 ignore start */\nconst { O_CREAT, O_NOFOLLOW, O_TRUNC, O_WRONLY } = fs.constants\nconst UV_FS_O_FILEMAP =\n Number(process.env.__FAKE_FS_O_FILENAME__) ||\n fs.constants.UV_FS_O_FILEMAP ||\n 0\n/* c8 ignore stop */\n\nconst fMapEnabled = isWindows && !!UV_FS_O_FILEMAP\nconst fMapLimit = 512 * 1024\nconst fMapFlag = UV_FS_O_FILEMAP | O_TRUNC | O_CREAT | O_WRONLY\nconst noFollowFlag =\n !isWindows && typeof O_NOFOLLOW === 'number' ?\n O_NOFOLLOW | O_TRUNC | O_CREAT | O_WRONLY\n : null\nexport const getWriteFlag =\n noFollowFlag !== null ? () => noFollowFlag\n : !fMapEnabled ? () => 'w'\n : (size: number) => (size < fMapLimit ? fMapFlag : 'w')\n", "import fs, { type Dirent } from 'node:fs'\nimport path from 'node:path'\n\nconst lchownSync = (path: string, uid: number, gid: number) => {\n try {\n return fs.lchownSync(path, uid, gid)\n } catch (er) {\n if ((er as NodeJS.ErrnoException)?.code !== 'ENOENT') throw er\n }\n}\n\nconst chown = (\n cpath: string,\n uid: number,\n gid: number,\n cb: (er?: unknown) => any,\n) => {\n fs.lchown(cpath, uid, gid, er => {\n // Skip ENOENT error\n cb(er && (er as NodeJS.ErrnoException)?.code !== 'ENOENT' ? er : null)\n })\n}\n\nconst chownrKid = (\n p: string,\n child: Dirent,\n uid: number,\n gid: number,\n cb: (er?: unknown) => any,\n) => {\n if (child.isDirectory()) {\n chownr(path.resolve(p, child.name), uid, gid, (er: unknown) => {\n if (er) return cb(er)\n const cpath = path.resolve(p, child.name)\n chown(cpath, uid, gid, cb)\n })\n } else {\n const cpath = path.resolve(p, child.name)\n chown(cpath, uid, gid, cb)\n }\n}\n\nexport const chownr = (\n p: string,\n uid: number,\n gid: number,\n cb: (er?: unknown) => any,\n) => {\n fs.readdir(p, { withFileTypes: true }, (er, children) => {\n // any error other than ENOTDIR or ENOTSUP means it's not readable,\n // or doesn't exist. give up.\n if (er) {\n if (er.code === 'ENOENT') return cb()\n else if (er.code !== 'ENOTDIR' && er.code !== 'ENOTSUP')\n return cb(er)\n }\n if (er || !children.length) return chown(p, uid, gid, cb)\n\n let len = children.length\n let errState: null | NodeJS.ErrnoException = null\n const then = (er?: unknown) => {\n /* c8 ignore start */\n if (errState) return\n /* c8 ignore stop */\n if (er) return cb((errState = er as NodeJS.ErrnoException))\n if (--len === 0) return chown(p, uid, gid, cb)\n }\n\n for (const child of children) {\n chownrKid(p, child, uid, gid, then)\n }\n })\n}\n\nconst chownrKidSync = (\n p: string,\n child: Dirent,\n uid: number,\n gid: number,\n) => {\n if (child.isDirectory())\n chownrSync(path.resolve(p, child.name), uid, gid)\n\n lchownSync(path.resolve(p, child.name), uid, gid)\n}\n\nexport const chownrSync = (p: string, uid: number, gid: number) => {\n let children: Dirent[]\n try {\n children = fs.readdirSync(p, { withFileTypes: true })\n } catch (er) {\n const e = er as NodeJS.ErrnoException\n if (e?.code === 'ENOENT') return\n else if (e?.code === 'ENOTDIR' || e?.code === 'ENOTSUP')\n return lchownSync(p, uid, gid)\n else throw e\n }\n\n for (const child of children) {\n chownrKidSync(p, child, uid, gid)\n }\n\n return lchownSync(p, uid, gid)\n}\n", "import { chownr, chownrSync } from 'chownr'\nimport fs from 'node:fs'\nimport fsp from 'node:fs/promises'\nimport path from 'node:path'\nimport { CwdError } from './cwd-error.js'\nimport { normalizeWindowsPath } from './normalize-windows-path.js'\nimport { SymlinkError } from './symlink-error.js'\n\nexport type MkdirOptions = {\n uid?: number\n gid?: number\n processUid?: number\n processGid?: number\n umask?: number\n preserve: boolean\n unlink: boolean\n cwd: string\n mode: number\n}\n\nexport type MkdirError = NodeJS.ErrnoException | CwdError | SymlinkError\n\nconst checkCwd = (\n dir: string,\n cb: (er?: null | MkdirError) => unknown,\n) => {\n fs.stat(dir, (er, st) => {\n if (er || !st.isDirectory()) {\n er = new CwdError(\n dir,\n (er as NodeJS.ErrnoException)?.code || 'ENOTDIR',\n )\n }\n cb(er)\n })\n}\n\n/**\n * Wrapper around fs/promises.mkdir for tar's needs.\n *\n * The main purpose is to avoid creating directories if we know that\n * they already exist (and track which ones exist for this purpose),\n * and prevent entries from being extracted into symlinked folders,\n * if `preservePaths` is not set.\n */\nexport const mkdir = (\n dir: string,\n opt: MkdirOptions,\n cb: (er?: null | MkdirError, made?: string) => void,\n) => {\n dir = normalizeWindowsPath(dir)\n\n // if there's any overlap between mask and mode,\n // then we'll need an explicit chmod\n /* c8 ignore next */\n const umask = opt.umask ?? 0o22\n const mode = opt.mode | 0o0700\n const needChmod = (mode & umask) !== 0\n\n const uid = opt.uid\n const gid = opt.gid\n const doChown =\n typeof uid === 'number' &&\n typeof gid === 'number' &&\n (uid !== opt.processUid || gid !== opt.processGid)\n\n const preserve = opt.preserve\n const unlink = opt.unlink\n const cwd = normalizeWindowsPath(opt.cwd)\n\n const done = (er?: null | MkdirError, created?: string) => {\n if (er) {\n cb(er)\n } else {\n if (created && doChown) {\n chownr(created, uid, gid, er => done(er as NodeJS.ErrnoException))\n } else if (needChmod) {\n fs.chmod(dir, mode, cb)\n } else {\n cb()\n }\n }\n }\n\n if (dir === cwd) {\n return checkCwd(dir, done)\n }\n\n if (preserve) {\n return fsp.mkdir(dir, { mode, recursive: true }).then(\n made => done(null, made ?? undefined), // oh, ts\n done,\n )\n }\n\n const sub = normalizeWindowsPath(path.relative(cwd, dir))\n const parts = sub.split('/')\n mkdir_(cwd, parts, mode, unlink, cwd, undefined, done)\n}\n\nconst mkdir_ = (\n base: string,\n parts: string[],\n mode: number,\n unlink: boolean,\n cwd: string,\n created: string | undefined,\n cb: (er?: null | MkdirError, made?: string) => void,\n): void => {\n if (parts.length === 0) {\n return cb(null, created)\n }\n const p = parts.shift()\n const part = normalizeWindowsPath(path.resolve(base + '/' + p))\n fs.mkdir(\n part,\n mode,\n onmkdir(part, parts, mode, unlink, cwd, created, cb),\n )\n}\n\nconst onmkdir =\n (\n part: string,\n parts: string[],\n mode: number,\n unlink: boolean,\n cwd: string,\n created: string | undefined,\n cb: (er?: null | MkdirError, made?: string) => void,\n ) =>\n (er?: null | NodeJS.ErrnoException) => {\n if (er) {\n fs.lstat(part, (statEr, st) => {\n if (statEr) {\n statEr.path = statEr.path && normalizeWindowsPath(statEr.path)\n cb(statEr)\n } else if (st.isDirectory()) {\n mkdir_(part, parts, mode, unlink, cwd, created, cb)\n } else if (unlink) {\n fs.unlink(part, er => {\n if (er) {\n return cb(er)\n }\n fs.mkdir(\n part,\n mode,\n onmkdir(part, parts, mode, unlink, cwd, created, cb),\n )\n })\n } else if (st.isSymbolicLink()) {\n return cb(new SymlinkError(part, part + '/' + parts.join('/')))\n } else {\n cb(er)\n }\n })\n } else {\n created = created || part\n mkdir_(part, parts, mode, unlink, cwd, created, cb)\n }\n }\n\nconst checkCwdSync = (dir: string) => {\n let ok = false\n let code\n try {\n ok = fs.statSync(dir).isDirectory()\n } catch (er) {\n code = (er as NodeJS.ErrnoException)?.code\n } finally {\n if (!ok) {\n throw new CwdError(dir, code ?? 'ENOTDIR')\n }\n }\n}\n\nexport const mkdirSync = (dir: string, opt: MkdirOptions) => {\n dir = normalizeWindowsPath(dir)\n // if there's any overlap between mask and mode,\n // then we'll need an explicit chmod\n /* c8 ignore next */\n const umask = opt.umask ?? 0o22\n const mode = opt.mode | 0o700\n const needChmod = (mode & umask) !== 0\n\n const uid = opt.uid\n const gid = opt.gid\n const doChown =\n typeof uid === 'number' &&\n typeof gid === 'number' &&\n (uid !== opt.processUid || gid !== opt.processGid)\n\n const preserve = opt.preserve\n const unlink = opt.unlink\n const cwd = normalizeWindowsPath(opt.cwd)\n\n const done = (created?: string | undefined) => {\n if (created && doChown) {\n chownrSync(created, uid, gid)\n }\n if (needChmod) {\n fs.chmodSync(dir, mode)\n }\n }\n\n if (dir === cwd) {\n checkCwdSync(cwd)\n return done()\n }\n\n if (preserve) {\n return done(fs.mkdirSync(dir, { mode, recursive: true }) ?? undefined)\n }\n\n const sub = normalizeWindowsPath(path.relative(cwd, dir))\n const parts = sub.split('/')\n let created\n for (\n let p = parts.shift(), part = cwd;\n p && (part += '/' + p);\n p = parts.shift()\n ) {\n part = normalizeWindowsPath(path.resolve(part))\n\n try {\n fs.mkdirSync(part, mode)\n created = created || part\n } catch {\n const st = fs.lstatSync(part)\n if (st.isDirectory()) {\n continue\n } else if (unlink) {\n fs.unlinkSync(part)\n fs.mkdirSync(part, mode)\n created = created || part\n continue\n } else if (st.isSymbolicLink()) {\n return new SymlinkError(part, part + '/' + parts.join('/'))\n }\n }\n }\n\n return done(created)\n}\n", "export class CwdError extends Error {\n path: string\n code: string\n syscall = 'chdir' as const\n\n constructor(path: string, code: string) {\n super(`${code}: Cannot cd into '${path}'`)\n this.path = path\n this.code = code\n }\n\n get name() {\n return 'CwdError'\n }\n}\n", "export class SymlinkError extends Error {\n path: string\n symlink: string\n syscall = 'symlink' as const\n code = 'TAR_SYMLINK_ERROR' as const\n constructor(symlink: string, path: string) {\n super('TAR_SYMLINK_ERROR: Cannot extract through symbolic link')\n this.symlink = symlink\n this.path = path\n }\n get name() {\n return 'SymlinkError'\n }\n}\n", "// A path exclusive reservation system\n// reserve([list, of, paths], fn)\n// When the fn is first in line for all its paths, it\n// is called with a cb that clears the reservation.\n//\n// Used by async unpack to avoid clobbering paths in use,\n// while still allowing maximal safe parallelization.\n\nimport { join } from 'node:path'\nimport { normalizeUnicode } from './normalize-unicode.js'\nimport { stripTrailingSlashes } from './strip-trailing-slashes.js'\n\nconst platform = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform\nconst isWindows = platform === 'win32'\n\nexport type Reservation = {\n paths: string[]\n dirs: Set<string>\n}\n\nexport type Handler = (clear: () => void) => void\n\n// return a set of parent dirs for a given path\n// '/a/b/c/d' -> ['/', '/a', '/a/b', '/a/b/c', '/a/b/c/d']\nconst getDirs = (path: string) => {\n const dirs = path\n .split('/')\n .slice(0, -1)\n .reduce((set: string[], path) => {\n const s = set.at(-1)\n if (s !== undefined) {\n path = join(s, path)\n }\n set.push(path || '/')\n return set\n }, [])\n return dirs\n}\n\nexport class PathReservations {\n // path => [function or Set]\n // A Set object means a directory reservation\n // A fn is a direct reservation on that path\n #queues = new Map<string, (Handler | Set<Handler>)[]>()\n\n // fn => {paths:[path,...], dirs:[path, ...]}\n #reservations = new Map<Handler, Reservation>()\n\n // functions currently running\n #running = new Set<Handler>()\n\n reserve(paths: string[], fn: Handler) {\n paths =\n isWindows ?\n ['win32 parallelization disabled']\n : paths.map(p => {\n // don't need normPath, because we skip this entirely for windows\n return stripTrailingSlashes(join(normalizeUnicode(p)))\n })\n\n const dirs = new Set<string>(\n paths.map(path => getDirs(path)).reduce((a, b) => a.concat(b)),\n )\n this.#reservations.set(fn, { dirs, paths })\n for (const p of paths) {\n const q = this.#queues.get(p)\n if (!q) {\n this.#queues.set(p, [fn])\n } else {\n q.push(fn)\n }\n }\n for (const dir of dirs) {\n const q = this.#queues.get(dir)\n if (!q) {\n this.#queues.set(dir, [new Set([fn])])\n } else {\n const l = q.at(-1)\n if (l instanceof Set) {\n l.add(fn)\n } else {\n q.push(new Set([fn]))\n }\n }\n }\n return this.#run(fn)\n }\n\n // return the queues for each path the function cares about\n // fn => {paths, dirs}\n #getQueues(fn: Handler): {\n paths: Handler[][]\n dirs: (Handler | Set<Handler>)[][]\n } {\n const res = this.#reservations.get(fn)\n /* c8 ignore start */\n if (!res) {\n throw new Error('function does not have any path reservations')\n }\n /* c8 ignore stop */\n return {\n paths: res.paths.map((path: string) =>\n this.#queues.get(path),\n ) as Handler[][],\n dirs: [...res.dirs].map(path => this.#queues.get(path)) as (\n | Handler\n | Set<Handler>\n )[][],\n }\n }\n\n // check if fn is first in line for all its paths, and is\n // included in the first set for all its dir queues\n check(fn: Handler) {\n const { paths, dirs } = this.#getQueues(fn)\n return (\n paths.every(q => q && q[0] === fn) &&\n dirs.every(q => q && q[0] instanceof Set && q[0].has(fn))\n )\n }\n\n // run the function if it's first in line and not already running\n #run(fn: Handler) {\n if (this.#running.has(fn) || !this.check(fn)) {\n return false\n }\n this.#running.add(fn)\n fn(() => this.#clear(fn))\n return true\n }\n\n #clear(fn: Handler) {\n if (!this.#running.has(fn)) {\n return false\n }\n const res = this.#reservations.get(fn)\n /* c8 ignore start */\n if (!res) {\n throw new Error('invalid reservation')\n }\n /* c8 ignore stop */\n const { paths, dirs } = res\n\n const next = new Set<Handler>()\n for (const path of paths) {\n const q = this.#queues.get(path)\n /* c8 ignore start */\n if (!q || q?.[0] !== fn) {\n continue\n }\n /* c8 ignore stop */\n const q0 = q[1]\n if (!q0) {\n this.#queues.delete(path)\n continue\n }\n q.shift()\n if (typeof q0 === 'function') {\n next.add(q0)\n } else {\n for (const f of q0) {\n next.add(f)\n }\n }\n }\n\n for (const dir of dirs) {\n const q = this.#queues.get(dir)\n const q0 = q?.[0]\n /* c8 ignore next - type safety only */\n if (!q || !(q0 instanceof Set)) continue\n if (q0.size === 1 && q.length === 1) {\n this.#queues.delete(dir)\n continue\n } else if (q0.size === 1) {\n q.shift()\n // next one must be a function,\n // or else the Set would've been reused\n const n = q[0]\n if (typeof n === 'function') {\n next.add(n)\n }\n } else {\n q0.delete(fn)\n }\n }\n\n this.#running.delete(fn)\n next.forEach(fn => this.#run(fn))\n return true\n }\n}\n", "// warning: extremely hot code path.\n// This has been meticulously optimized for use\n// within npm install on large package trees.\n// Do not edit without careful benchmarking.\nconst normalizeCache: Record<string, string> = Object.create(null)\n\n// Limit the size of this. Very low-sophistication LRU cache\nconst MAX = 10000\nconst cache = new Set<string>()\nexport const normalizeUnicode = (s: string): string => {\n if (!cache.has(s)) {\n // shake out identical accents and ligatures\n normalizeCache[s] = s\n .normalize('NFD')\n .toLocaleLowerCase('en')\n .toLocaleUpperCase('en')\n } else {\n cache.delete(s)\n }\n cache.add(s)\n\n const ret = normalizeCache[s] as string\n\n let i = cache.size - MAX\n // only prune when we're 10% over the max\n if (i > MAX / 10) {\n for (const s of cache) {\n cache.delete(s)\n delete normalizeCache[s]\n if (--i <= 0) break\n }\n }\n\n return ret\n}\n", "// separate file so I stop getting nagged in vim about deprecated API.\nexport const umask = () => process.umask()\n", "// tar -r\nimport { WriteStream, WriteStreamSync } from '@isaacs/fs-minipass'\nimport type { Minipass } from 'minipass'\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport { Header } from './header.js'\nimport { list } from './list.js'\nimport { makeCommand } from './make-command.js'\nimport type { TarOptionsFile, TarOptionsSyncFile } from './options.js'\nimport { isFile } from './options.js'\nimport { Pack, PackSync } from './pack.js'\n\n// starting at the head of the file, read a Header\n// If the checksum is invalid, that's our position to start writing\n// If it is, jump forward by the specified size (round up to 512)\n// and try again.\n// Write the new Pack stream starting there.\n\nconst replaceSync = (opt: TarOptionsSyncFile, files: string[]) => {\n const p = new PackSync(opt)\n\n let threw = true\n let fd\n let position\n\n try {\n try {\n fd = fs.openSync(opt.file, 'r+')\n } catch (er) {\n if ((er as NodeJS.ErrnoException)?.code === 'ENOENT') {\n fd = fs.openSync(opt.file, 'w+')\n } else {\n throw er\n }\n }\n\n const st = fs.fstatSync(fd)\n const headBuf = Buffer.alloc(512)\n\n POSITION: for (position = 0; position < st.size; position += 512) {\n for (let bufPos = 0, bytes = 0; bufPos < 512; bufPos += bytes) {\n bytes = fs.readSync(\n fd,\n headBuf,\n bufPos,\n headBuf.length - bufPos,\n position + bufPos,\n )\n\n if (position === 0 && headBuf[0] === 0x1f && headBuf[1] === 0x8b) {\n throw new Error('cannot append to compressed archives')\n }\n\n if (!bytes) {\n break POSITION\n }\n }\n\n const h = new Header(headBuf)\n if (!h.cksumValid) {\n break\n }\n const entryBlockSize = 512 * Math.ceil((h.size || 0) / 512)\n if (position + entryBlockSize + 512 > st.size) {\n break\n }\n // the 512 for the header we just parsed will be added as well\n // also jump ahead all the blocks for the body\n position += entryBlockSize\n if (opt.mtimeCache && h.mtime) {\n opt.mtimeCache.set(String(h.path), h.mtime)\n }\n }\n threw = false\n\n streamSync(opt, p, position, fd, files)\n } finally {\n if (threw) {\n try {\n fs.closeSync(fd as number)\n } catch {}\n }\n }\n}\n\nconst streamSync = (\n opt: TarOptionsSyncFile,\n p: Pack,\n position: number,\n fd: number,\n files: string[],\n) => {\n const stream = new WriteStreamSync(opt.file, {\n fd: fd,\n start: position,\n })\n p.pipe(stream as unknown as Minipass.Writable)\n addFilesSync(p, files)\n}\n\nconst replaceAsync = (\n opt: TarOptionsFile,\n files: string[],\n): Promise<void> => {\n files = Array.from(files)\n const p = new Pack(opt)\n\n const getPos = (\n fd: number,\n size: number,\n cb_: (er?: null | Error, pos?: number) => void,\n ) => {\n const cb = (er?: Error | null, pos?: number) => {\n if (er) {\n fs.close(fd, _ => cb_(er))\n } else {\n cb_(null, pos)\n }\n }\n\n let position = 0\n if (size === 0) {\n return cb(null, 0)\n }\n\n let bufPos = 0\n const headBuf = Buffer.alloc(512)\n const onread = (er?: null | Error, bytes?: number): void => {\n if (er || bytes === undefined) {\n return cb(er)\n }\n bufPos += bytes\n if (bufPos < 512 && bytes) {\n return fs.read(\n fd,\n headBuf,\n bufPos,\n headBuf.length - bufPos,\n position + bufPos,\n onread,\n )\n }\n\n if (position === 0 && headBuf[0] === 0x1f && headBuf[1] === 0x8b) {\n return cb(new Error('cannot append to compressed archives'))\n }\n\n // truncated header\n if (bufPos < 512) {\n return cb(null, position)\n }\n\n const h = new Header(headBuf)\n if (!h.cksumValid) {\n return cb(null, position)\n }\n\n /* c8 ignore next */\n const entryBlockSize = 512 * Math.ceil((h.size ?? 0) / 512)\n if (position + entryBlockSize + 512 > size) {\n return cb(null, position)\n }\n\n position += entryBlockSize + 512\n if (position >= size) {\n return cb(null, position)\n }\n\n if (opt.mtimeCache && h.mtime) {\n opt.mtimeCache.set(String(h.path), h.mtime)\n }\n bufPos = 0\n fs.read(fd, headBuf, 0, 512, position, onread)\n }\n fs.read(fd, headBuf, 0, 512, position, onread)\n }\n\n const promise = new Promise<void>((resolve, reject) => {\n p.on('error', reject)\n let flag = 'r+'\n const onopen = (er?: NodeJS.ErrnoException | null, fd?: number) => {\n if (er && er.code === 'ENOENT' && flag === 'r+') {\n flag = 'w+'\n return fs.open(opt.file, flag, onopen)\n }\n\n if (er || !fd) {\n return reject(er)\n }\n\n fs.fstat(fd, (er, st) => {\n if (er) {\n return fs.close(fd, () => reject(er))\n }\n\n getPos(fd, st.size, (er, position) => {\n if (er) {\n return reject(er)\n }\n const stream = new WriteStream(opt.file, {\n fd: fd,\n start: position,\n })\n p.pipe(stream as unknown as Minipass.Writable)\n stream.on('error', reject)\n stream.on('close', resolve)\n addFilesAsync(p, files)\n })\n })\n }\n fs.open(opt.file, flag, onopen)\n })\n\n return promise\n}\n\nconst addFilesSync = (p: Pack, files: string[]) => {\n files.forEach(file => {\n if (file.charAt(0) === '@') {\n list({\n file: path.resolve(p.cwd, file.slice(1)),\n sync: true,\n noResume: true,\n onReadEntry: entry => p.add(entry),\n })\n } else {\n p.add(file)\n }\n })\n p.end()\n}\n\nconst addFilesAsync = async (p: Pack, files: string[]): Promise<void> => {\n for (const file of files) {\n if (file.charAt(0) === '@') {\n await list({\n file: path.resolve(String(p.cwd), file.slice(1)),\n noResume: true,\n onReadEntry: entry => p.add(entry),\n })\n } else {\n p.add(file)\n }\n }\n p.end()\n}\n\nexport const replace = makeCommand(\n replaceSync,\n replaceAsync,\n /* c8 ignore start */\n (): never => {\n throw new TypeError('file is required')\n },\n (): never => {\n throw new TypeError('file is required')\n },\n /* c8 ignore stop */\n (opt, entries) => {\n if (!isFile(opt)) {\n throw new TypeError('file is required')\n }\n\n if (\n opt.gzip ||\n opt.brotli ||\n opt.zstd ||\n opt.file.endsWith('.br') ||\n opt.file.endsWith('.tbr')\n ) {\n throw new TypeError('cannot append to compressed archives')\n }\n\n if (!entries?.length) {\n throw new TypeError('no paths specified to add/replace')\n }\n },\n)\n", "// tar -u\n\nimport { makeCommand } from './make-command.js'\nimport { type TarOptionsWithAliases } from './options.js'\n\nimport { replace as r } from './replace.js'\n\n// just call tar.r with the filter and mtimeCache\nexport const update = makeCommand(\n r.syncFile,\n r.asyncFile,\n r.syncNoFile,\n r.asyncNoFile,\n (opt, entries = []) => {\n r.validate?.(opt, entries)\n mtimeFilter(opt)\n },\n)\n\nconst mtimeFilter = (opt: TarOptionsWithAliases) => {\n const filter = opt.filter\n\n if (!opt.mtimeCache) {\n opt.mtimeCache = new Map()\n }\n\n opt.filter =\n filter ?\n (path, stat) =>\n filter(path, stat) &&\n !(\n /* c8 ignore start */\n (\n (opt.mtimeCache?.get(path) ?? stat.mtime ?? 0) >\n (stat.mtime ?? 0)\n )\n /* c8 ignore stop */\n )\n : (path, stat) =>\n !(\n /* c8 ignore start */\n (\n (opt.mtimeCache?.get(path) ?? stat.mtime ?? 0) >\n (stat.mtime ?? 0)\n )\n /* c8 ignore stop */\n )\n}\n"],
5
- "mappings": "6FAAA,OAAOA,OAAQ,SACf,OAAOC,MAAQ,KCMf,OAAS,gBAAAC,OAAoB,cAC7B,OAAOC,OAAY,cACnB,OAAS,iBAAAC,OAAqB,sBAT9B,IAAMC,GACJ,OAAO,SAAY,UAAY,QAC3B,QACA,CACE,OAAQ,KACR,OAAQ,MAiBHC,GACX,GAEA,CAAC,CAAC,GACF,OAAO,GAAM,WACZ,aAAaC,GACZ,aAAaJ,IACbK,GAAW,CAAC,GACZC,GAAW,CAAC,GAKHD,GAAc,GACzB,CAAC,CAAC,GACF,OAAO,GAAM,UACb,aAAaN,IACb,OAAQ,EAAwB,MAAS,YAExC,EAAwB,OAASC,GAAO,SAAS,UAAU,KAKjDM,GAAc,GACzB,CAAC,CAAC,GACF,OAAO,GAAM,UACb,aAAaP,IACb,OAAQ,EAAwB,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Stream", "Minipass", "isReadable", "isWritable", "EOF", "MAYBE_EMIT_END", "EMITTED_END", "EMITTING_END", "EMITTED_ERROR", "CLOSED", "READ", "FLUSH", "FLUSHCHUNK", "ENCODING", "DECODER", "FLOWING", "PAUSED", "RESUME", "BUFFER", "PIPES", "BUFFERLENGTH", "BUFFERPUSH", "BUFFERSHIFT", "OBJECTMODE", "DESTROYED", "ERROR", "EMITDATA", "EMITEND", "EMITEND2", "ASYNC", "ABORT", "ABORTED", "SIGNAL", "DATALISTENERS", "DISCARDED", "defer", "fn", "nodefer", "isEndish", "ev", "isArrayBufferLike", "b", "isArrayBufferView", "Pipe", "src", "dest", "opts", "_er", "PipeProxyErrors", "er", "isObjectModeOptions", "o", "isEncodingOptions", "args", "options", "signal", "_enc", "_om", "a", "_", "chunk", "encoding", "cb", "n", "ret", "c", "noDrain", "ended", "p", "handler", "h", "data", "buf", "resolve", "reject", "stopped", "stop", "res", "onerr", "ondata", "onend", "ondestroy", "value", "rej", "next", "wc", "writev", "fs", "_autoClose", "_close", "_ended", "_fd", "_finished", "_flags", "_flush", "_handleChunk", "_makeBuf", "_mode", "_needDrain", "_onerror", "_onopen", "_onread", "_onwrite", "_open", "_path", "_pos", "_queue", "_read", "_readSize", "_reading", "_remain", "_size", "_write", "_writing", "_defaultFlag", "_errored", "ReadStream", "Minipass", "path", "opt", "er", "fd", "buf", "br", "b", "ret", "ev", "args", "ReadStreamSync", "threw", "WriteStream", "EE", "defaultFlag", "enc", "bw", "iovec", "WriteStreamSync", "path", "fs", "dirname", "parse", "argmap", "isSyncFile", "o", "isAsyncFile", "isSyncNoFile", "isAsyncNoFile", "isFile", "o", "dealiasKey", "k", "d", "argmap", "dealias", "opt", "result", "key", "v", "makeCommand", "syncFile", "asyncFile", "syncNoFile", "asyncNoFile", "validate", "opt_", "entries", "cb", "opt", "dealias", "isSyncFile", "isAsyncFile", "p", "isSyncNoFile", "isAsyncNoFile", "EE", "assert", "Buffer", "realZlib", "realZlib", "realZlibConstants", "constants", "OriginalBufferConcat", "Buffer", "desc", "noop", "args", "passthroughBufferConcat", "makeNoOp", "_", "_superWrite", "ZlibError", "err", "origin", "_flushFlag", "ZlibBase", "Minipass", "#sawError", "#ended", "#flushFlag", "#finishFlushFlag", "#fullFlushFlag", "#handle", "#onError", "opts", "mode", "realZlib", "er", "assert", "flushFlag", "chunk", "encoding", "cb", "data", "nativeHandle", "originalNativeClose", "originalClose", "result", "writeReturn", "r", "i", "Zlib", "#level", "#strategy", "constants", "level", "strategy", "origFlush", "Gzip", "Zlib", "#portable", "opts", "_superWrite", "data", "Unzip", "Zlib", "opts", "Brotli", "ZlibBase", "mode", "constants", "BrotliCompress", "BrotliDecompress", "Zstd", "ZstdCompress", "ZstdDecompress", "pathModule", "encode", "num", "buf", "encodeNegative", "encodePositive", "i", "flipped", "byte", "onesComp", "twosComp", "parse", "pre", "value", "pos", "twos", "len", "sum", "f", "types_exports", "__export", "code", "isCode", "isName", "name", "normalFsTypes", "c", "kv", "notNegative", "n", "Header", "#type", "data", "off", "ex", "gex", "#slurp", "buf", "t", "decString", "isNormalFS", "normalFsTypes", "exForFields", "gexForFields", "decNumber", "decDate", "isCode", "prefix", "sum", "i", "k", "v", "prefixSize", "split", "splitPrefix", "path", "encString", "encNumber", "encDate", "name", "type", "c", "code", "p", "pp", "ret", "root", "pathModule", "size", "numToDate", "num", "parse", "decSmallNumber", "nanUndef", "value", "MAXNUM", "encode", "encSmallNumber", "octalString", "padOctal", "str", "date", "NULLS", "basename", "Pax", "_Pax", "obj", "global", "body", "bodyLen", "bufLen", "buf", "i", "Header", "basename", "field", "r", "v", "s", "byteLen", "digits", "str", "ex", "g", "merge", "parseKV", "a", "b", "parseKVLine", "set", "line", "n", "kv", "k", "platform", "normalizeWindowsPath", "p", "ReadEntry", "Minipass", "header", "ex", "gex", "normalizeWindowsPath", "#slurp", "data", "writeLen", "r", "br", "k", "v", "warnMethod", "self", "code", "message", "data", "maxMetaEntrySize", "gzipHeader", "zstdHeader", "ZIP_HEADER_LEN", "STATE", "WRITEENTRY", "READENTRY", "NEXTENTRY", "PROCESSENTRY", "EX", "GEX", "META", "EMITMETA", "BUFFER", "QUEUE", "ENDED", "EMITTEDEND", "EMIT", "UNZIP", "CONSUMECHUNK", "CONSUMECHUNKSUB", "CONSUMEBODY", "CONSUMEMETA", "CONSUMEHEADER", "CONSUMING", "BUFFERCONCAT", "MAYBEEND", "WRITING", "ABORTED", "DONE", "SAW_VALID_ENTRY", "SAW_NULL_BLOCK", "SAW_EOF", "CLOSESTREAM", "MAX_DECOMPRESSION_RATIO", "COMPRESSEDBYTESREAD", "DECOMPRESSEDBYTESREAD", "CHECKDECOMPRESSIONRATIO", "noop", "Parser", "EE", "opt", "isTBR", "isTZST", "code", "message", "data", "warnMethod", "chunk", "position", "header", "Header", "er", "type", "entry", "ReadEntry", "onend", "c", "go", "ev", "args", "re", "br", "ret", "extra", "Pax", "ex", "error", "u", "ratio", "encoding", "cb", "i", "isZstd", "maybeBrotli", "ended", "Unzip", "ZstdDecompress", "BrotliDecompress", "have", "length", "stripTrailingSlashes", "str", "i", "slashesStart", "onReadEntryFunction", "opt", "onReadEntry", "filesFilter", "files", "map", "f", "stripTrailingSlashes", "filter", "MAX", "mapHas", "file", "r", "depth", "root", "parse", "ret", "m", "dirname", "entry", "listFileSync", "p", "Parser", "fd", "fs", "stat", "readSize", "buf", "read", "pos", "bytesRead", "listFile", "_files", "resolve", "reject", "er", "stream", "ReadStream", "list", "makeCommand", "fs", "fs", "path", "modeFix", "mode", "isDir", "portable", "win32", "isAbsolute", "parse", "stripAbsolutePath", "path", "r", "parsed", "root", "raw", "win", "char", "toWin", "i", "toRaw", "encode", "s", "c", "decode", "prefixPath", "path", "prefix", "normalizeWindowsPath", "stripTrailingSlashes", "maxReadSize", "PROCESS", "FILE", "DIRECTORY", "SYMLINK", "HARDLINK", "HEADER", "READ", "LSTAT", "ONLSTAT", "ONREAD", "ONREADLINK", "OPENFILE", "ONOPENFILE", "CLOSE", "MODE", "AWAITDRAIN", "ONDRAIN", "PREFIX", "WriteEntry", "Minipass", "#hadError", "p", "opt_", "opt", "dealias", "pathWarn", "root", "stripped", "stripAbsolutePath", "decode", "cs", "code", "message", "data", "warnMethod", "ev", "fs", "er", "stat", "getType", "mode", "modeFix", "Header", "Pax", "block", "linkpath", "linkKey", "fd", "bufLen", "buf", "offset", "length", "pos", "bytesRead", "cb", "i", "chunk", "encoding", "WriteEntrySync", "threw", "WriteEntryTar", "readEntry", "type", "b", "writeLen", "Yallist", "_Yallist", "list", "item", "walker", "node", "next", "prev", "head", "tail", "args", "i", "l", "push", "unshift", "res", "t", "h", "fn", "thisp", "n", "initial", "acc", "arr", "from", "to", "ret", "start", "deleteCount", "nodes", "v", "insertAfter", "p", "self", "value", "inserted", "Node", "path", "PackJob", "path", "absolute", "EOF", "ONSTAT", "ENDED", "QUEUE", "PENDINGLINKS", "CURRENT", "PROCESS", "PROCESSING", "PROCESSJOB", "JOBS", "JOBDONE", "ADDFSENTRY", "ADDTARENTRY", "STAT", "READDIR", "ONREADDIR", "PIPE", "ENTRY", "ENTRYOPT", "WRITEENTRYCLASS", "WRITE", "ONDRAIN", "Pack", "Minipass", "opt", "normalizeWindowsPath", "WriteEntry", "Gzip", "BrotliCompress", "ZstdCompress", "zip", "chunk", "Yallist", "encoding", "cb", "p", "job", "WriteEntryTar", "stat", "fs", "er", "key", "pending", "entries", "w", "sc", "rc", "code", "msg", "data", "entry", "base", "source", "message", "warnMethod", "PackSync", "WriteEntrySync", "createFileSync", "opt", "files", "p", "PackSync", "stream", "WriteStreamSync", "addFilesSync", "createFile", "Pack", "WriteStream", "promise", "res", "rej", "addFilesAsync", "er", "file", "list", "path", "entry", "createSync", "createAsync", "create", "makeCommand", "_opt", "fs", "assert", "randomBytes", "fs", "path", "fs", "platform", "isWindows", "O_CREAT", "O_NOFOLLOW", "O_TRUNC", "O_WRONLY", "UV_FS_O_FILEMAP", "fMapEnabled", "fMapLimit", "fMapFlag", "noFollowFlag", "getWriteFlag", "size", "fs", "path", "lchownSync", "uid", "gid", "er", "chown", "cpath", "cb", "chownrKid", "p", "child", "chownr", "children", "len", "errState", "then", "chownrKidSync", "chownrSync", "e", "fs", "fsp", "path", "CwdError", "path", "code", "SymlinkError", "symlink", "path", "checkCwd", "dir", "cb", "fs", "er", "st", "CwdError", "mkdir", "opt", "normalizeWindowsPath", "umask", "mode", "needChmod", "uid", "gid", "doChown", "preserve", "unlink", "cwd", "done", "created", "chownr", "fsp", "made", "parts", "path", "mkdir_", "base", "p", "part", "onmkdir", "statEr", "SymlinkError", "checkCwdSync", "ok", "code", "mkdirSync", "chownrSync", "join", "normalizeCache", "MAX", "cache", "normalizeUnicode", "ret", "i", "s", "platform", "isWindows", "getDirs", "path", "set", "s", "join", "PathReservations", "#queues", "#reservations", "#running", "paths", "fn", "p", "stripTrailingSlashes", "normalizeUnicode", "dirs", "a", "b", "q", "dir", "l", "#run", "#getQueues", "res", "#clear", "next", "q0", "f", "n", "umask", "ONENTRY", "CHECKFS", "CHECKFS2", "ISREUSABLE", "MAKEFS", "FILE", "DIRECTORY", "LINK", "SYMLINK", "HARDLINK", "ENSURE_NO_SYMLINK", "UNSUPPORTED", "CHECKPATH", "STRIPABSOLUTEPATH", "MKDIR", "ONERROR", "PENDING", "PEND", "UNPEND", "ENDED", "MAYBECLOSE", "SKIP", "DOCHOWN", "UID", "GID", "CHECKED_CWD", "platform", "isWindows", "DEFAULT_MAX_DEPTH", "unlinkFile", "path", "cb", "fs", "name", "randomBytes", "er", "unlinkFileSync", "uint32", "a", "b", "c", "Unpack", "Parser", "PathReservations", "opt", "normalizeWindowsPath", "umask", "entry", "code", "msg", "data", "field", "p", "type", "root", "stripped", "stripAbsolutePath", "parts", "entryDir", "resolved", "linkparts", "aRoot", "encode", "pRoot", "assert", "dir", "mode", "mkdir", "fullyDone", "stream", "WriteStream", "getWriteFlag", "actions", "done", "abs", "fd", "atime", "mtime", "er2", "uid", "gid", "tx", "linkpath", "cwd", "onError", "t", "st", "SymlinkError", "paths", "checkCwd", "start", "parent", "afterMakeParent", "lstatEr", "needChmod", "afterChmod", "link", "callSync", "fn", "UnpackSync", "mkParent", "oner", "closeError", "e", "chunk", "futimeser", "fchowner", "mkdirSync", "_entry", "linkSync", "extractFileSync", "opt", "u", "UnpackSync", "file", "stat", "fs", "readSize", "ReadStreamSync", "extractFile", "_", "Unpack", "resolve", "reject", "er", "stream", "ReadStream", "extract", "makeCommand", "files", "filesFilter", "fs", "path", "replaceSync", "opt", "files", "p", "PackSync", "threw", "fd", "position", "fs", "er", "st", "headBuf", "POSITION", "bufPos", "bytes", "h", "Header", "entryBlockSize", "streamSync", "stream", "WriteStreamSync", "addFilesSync", "replaceAsync", "Pack", "getPos", "size", "cb_", "cb", "pos", "_", "onread", "resolve", "reject", "flag", "onopen", "WriteStream", "addFilesAsync", "file", "list", "path", "entry", "replace", "makeCommand", "entries", "isFile", "update", "makeCommand", "replace", "opt", "entries", "mtimeFilter", "filter", "path", "stat"]
3
+ "sources": ["../../src/bytes.ts", "../../src/large-numbers.ts", "../../src/path.ts", "../../src/types.ts", "../../src/header.ts", "../../src/pax.ts", "../../src/codec.ts", "../../src/dealias.ts", "../../src/concat.ts", "../../src/options.ts", "../../src/read-entry.ts", "../../src/warn.ts", "../../src/parser.ts", "../../src/read-file.ts", "../../src/entries.ts", "../../src/mode-fix.ts", "../../src/winchars.ts", "../../src/win32-path.ts", "../../src/strip-absolute-path.ts", "../../src/to-stream.ts", "../../src/strip-trailing-slashes.ts", "../../src/write-entry.ts", "../../src/pack.ts", "../../src/create.ts", "../../src/list.ts", "../../src/delete.ts", "../../src/cwd-error.ts", "../../src/symlink-error.ts", "../../src/mkdir.ts", "../../src/normalize-unicode.ts", "../../src/path-reservations.ts", "../../src/write-flag.ts", "../../src/unpack.ts", "../../src/extract.ts", "../../src/replace.ts", "../../src/update.ts"],
4
+ "sourcesContent": ["// Text and byte helpers that work on a plain Uint8Array in any\n// JavaScript runtime, and type checks for the input of a caller.\n//\n// A check with `instanceof` is false for an object that a different\n// realm made, such as a Node.js `Buffer` in a `node:vm` context, or a\n// `Blob` of a different window. These checks are true for an object\n// of each realm.\n\n/** True for a `Uint8Array`, and for a subclass such as `Buffer`. */\nexport const isUint8Array = (x: unknown): x is Uint8Array =>\n ArrayBuffer.isView(x) &&\n (x as Uint8Array)[Symbol.toStringTag] === 'Uint8Array'\n\n/** True for an `ArrayBuffer`. */\nexport const isArrayBuffer = (x: unknown): x is ArrayBuffer =>\n Object.prototype.toString.call(x) === '[object ArrayBuffer]'\n\n/** True for an object that has the size and the stream of a `Blob`. */\nexport const isBlob = (x: unknown): x is Blob =>\n typeof (x as Blob | undefined)?.size === 'number' &&\n typeof (x as Blob).stream === 'function'\n\n/** True for an object that has the reader of a `ReadableStream`. */\nexport const isReadableStream = (\n x: unknown,\n): x is ReadableStream<Uint8Array> =>\n typeof (x as ReadableStream | undefined)?.getReader === 'function'\n\n// A name can start with U+FEFF. The decoder must keep it.\nconst decoder = new TextDecoder('utf-8', { ignoreBOM: true })\nconst encoder = new TextEncoder()\n\n/** The number of bytes in the UTF-8 form of the string. */\nexport const utf8Length = (str: string): number => {\n let len = str.length\n for (let i = 0; i < str.length; i++) {\n const c = str.charCodeAt(i)\n if (c < 0x80) continue\n if (c < 0x800) {\n len += 1\n } else if (\n c >= 0xd800 &&\n c <= 0xdbff &&\n (str.charCodeAt(i + 1) & 0xfc00) === 0xdc00\n ) {\n // A surrogate pair is 2 code units, and 4 bytes.\n len += 2\n i++\n } else {\n len += 2\n }\n }\n return len\n}\n\n/** Decode the bytes from `start` to `end` as UTF-8. */\nexport const decodeUtf8 = (\n buf: Uint8Array,\n start: number = 0,\n end: number = buf.length,\n): string => {\n // Most names in an archive are short ASCII. That case needs no\n // decoder call.\n let str = ''\n for (let i = start; i < end; i++) {\n const c = buf[i] as number\n if (c >= 0x80) return decoder.decode(buf.subarray(start, end))\n str += String.fromCharCode(c)\n }\n return str\n}\n\n/**\n * Write the string as UTF-8 into `size` bytes at `off`. Fill the bytes\n * that are left with zeros. A character that does not fit completely\n * is not written.\n */\nexport const encodeUtf8Into = (\n str: string,\n buf: Uint8Array,\n off: number,\n size: number,\n): void => {\n const { written } = encoder.encodeInto(\n str,\n buf.subarray(off, off + size),\n )\n buf.fill(0, off + written, off + size)\n}\n\n/** Write a string of ASCII characters at `off`. */\nexport const writeAscii = (\n str: string,\n buf: Uint8Array,\n off: number,\n): void => {\n for (let i = 0; i < str.length; i++) {\n buf[off + i] = str.charCodeAt(i)\n }\n}\n", "// Tar can encode large and negative numbers using a leading byte of\n// 0xff for negative, and 0x80 for positive.\n\nexport const encode = (num: number, buf: Uint8Array) => {\n if (!Number.isSafeInteger(num)) {\n // The number is so large that javascript cannot represent it with\n // integer precision.\n throw Error(\n 'cannot encode number outside of javascript safe integer range',\n )\n } else if (num < 0) {\n encodeNegative(num, buf)\n } else {\n encodePositive(num, buf)\n }\n return buf\n}\n\nconst encodePositive = (num: number, buf: Uint8Array) => {\n buf[0] = 0x80\n\n for (var i = buf.length; i > 1; i--) {\n buf[i - 1] = num & 0xff\n num = Math.floor(num / 0x100)\n }\n}\n\nconst encodeNegative = (num: number, buf: Uint8Array) => {\n buf[0] = 0xff\n var flipped = false\n num = num * -1\n for (var i = buf.length; i > 1; i--) {\n var byte = num & 0xff\n num = Math.floor(num / 0x100)\n if (flipped) {\n buf[i - 1] = onesComp(byte)\n } else if (byte === 0) {\n buf[i - 1] = 0\n } else {\n flipped = true\n buf[i - 1] = twosComp(byte)\n }\n }\n}\n\nexport const parse = (buf: Uint8Array) => {\n const pre = buf[0]\n const value =\n pre === 0x80 ? pos(buf.subarray(1, buf.length))\n : pre === 0xff ? twos(buf)\n : null\n if (value === null) {\n throw Error('invalid base256 encoding')\n }\n\n if (!Number.isSafeInteger(value)) {\n // The number is so large that javascript cannot represent it with\n // integer precision.\n throw Error('parsed number outside of javascript safe integer range')\n }\n\n return value\n}\n\nconst twos = (buf: Uint8Array) => {\n var len = buf.length\n var sum = 0\n var flipped = false\n for (var i = len - 1; i > -1; i--) {\n var byte = Number(buf[i])\n var f\n if (flipped) {\n f = onesComp(byte)\n } else if (byte === 0) {\n f = byte\n } else {\n flipped = true\n f = twosComp(byte)\n }\n if (f !== 0) {\n sum -= f * Math.pow(256, len - i - 1)\n }\n }\n return sum\n}\n\nconst pos = (buf: Uint8Array) => {\n var len = buf.length\n var sum = 0\n for (var i = len - 1; i > -1; i--) {\n var byte = Number(buf[i])\n if (byte !== 0) {\n sum += byte * Math.pow(256, len - i - 1)\n }\n }\n return sum\n}\n\nconst onesComp = (byte: number) => (0xff ^ byte) & 0xff\n\nconst twosComp = (byte: number) => ((0xff ^ byte) + 1) & 0xff\n", "// The POSIX path functions that tar paths need. Each one gives the\n// same result as the function of the same name in `path.posix`.\n\n/** Resolve `.` and `..` parts, and remove repeated slashes. */\nexport const normalize = (path: string): string => {\n const absolute = path.charCodeAt(0) === 47\n const out: string[] = []\n for (const part of path.split('/')) {\n if (part === '' || part === '.') continue\n if (part !== '..') out.push(part)\n else if (out.length && out[out.length - 1] !== '..') out.pop()\n else if (!absolute) out.push(part)\n }\n const trail = out.length && path.charCodeAt(path.length - 1) === 47\n const res = out.join('/') + (trail ? '/' : '')\n if (absolute) return '/' + res\n return res || (path.endsWith('/') ? './' : '.')\n}\n\n/** Join the parts with a slash, then normalize the result. */\nexport const join = (...parts: string[]): string =>\n normalize(parts.filter(p => p).join('/'))\n\n/** The path without its last part. */\nexport const dirname = (path: string): string => {\n let end = path.length\n while (end > 1 && path.charCodeAt(end - 1) === 47) end--\n const slash = path.lastIndexOf('/', end - 1)\n if (slash === -1) return '.'\n if (slash === 0) return '/'\n if (slash === 1 && path.charCodeAt(0) === 47) return '//'\n return path.slice(0, slash)\n}\n\n/** The last part of the path. */\nexport const basename = (path: string): string => {\n let end = path.length\n while (end > 0 && path.charCodeAt(end - 1) === 47) end--\n return path.slice(path.lastIndexOf('/', end - 1) + 1, end)\n}\n\n/** True if the path starts with a slash. */\nexport const isAbsolute = (path: string): boolean =>\n path.charCodeAt(0) === 47\n\n/**\n * Resolve the parts from right to left, up to the first absolute\n * part. There is no working directory here: if no part is absolute,\n * the result is a relative path.\n */\nexport const resolve = (...parts: string[]): string => {\n let path = ''\n for (let i = parts.length - 1; i >= 0 && !isAbsolute(path); i--) {\n const part = parts[i]\n if (part) path = path ? part + '/' + path : part\n }\n const res = normalize(path)\n return res.length > 1 && res.endsWith('/') ? res.slice(0, -1) : res\n}\n\n/** The relative path from `from` to `to`. */\nexport const relative = (from: string, to: string): string => {\n const f = resolve(from).split('/')\n const t = resolve(to).split('/')\n // The root gives an empty last part.\n if (!f[f.length - 1]) f.pop()\n if (!t[t.length - 1]) t.pop()\n let same = 0\n while (same < f.length && same < t.length && f[same] === t[same]) same++\n return [\n ...Array.from({ length: f.length - same }, () => '..'),\n ...t.slice(same),\n ].join('/')\n}\n", "export const isCode = (c: string): c is EntryTypeCode =>\n name.has(c as EntryTypeCode)\n\nexport const isName = (c: string): c is EntryTypeName =>\n code.has(c as EntryTypeName)\n\nexport type EntryTypeCode =\n | '0'\n | ''\n | '1'\n | '2'\n | '3'\n | '4'\n | '5'\n | '6'\n | '7'\n | 'g'\n | 'x'\n | 'A'\n | 'D'\n | 'I'\n | 'K'\n | 'L'\n | 'M'\n | 'N'\n | 'S'\n | 'V'\n | 'X'\n\nexport type EntryTypeName =\n | 'File'\n | 'OldFile'\n | 'Link'\n | 'SymbolicLink'\n | 'CharacterDevice'\n | 'BlockDevice'\n | 'Directory'\n | 'FIFO'\n | 'ContiguousFile'\n | 'GlobalExtendedHeader'\n | 'ExtendedHeader'\n | 'SolarisACL'\n | 'GNUDumpDir'\n | 'Inode'\n | 'NextFileHasLongLinkpath'\n | 'NextFileHasLongPath'\n | 'ContinuationFile'\n | 'OldGnuLongPath'\n | 'SparseFile'\n | 'TapeVolumeHeader'\n | 'OldExtendedHeader'\n | 'Unsupported'\n\n/**\n * types that are a normal file system entry, not metadata.\n *\n * These can be the subject of extended/globalExtended headers, long\n * path names, long linkpath names, etc.\n *\n * Any other types are meta, and cannot be targeted by extended PAX\n * headers.\n */\nexport const normalFsTypes = new Set<EntryTypeCode>([\n '0',\n '',\n '1',\n '2',\n '3',\n '4',\n '5',\n '6',\n '7',\n 'D',\n])\n\n// map types from key to human-friendly name\nexport const name = new Map<EntryTypeCode, EntryTypeName>([\n ['0', 'File'],\n // same as File\n ['', 'OldFile'],\n ['1', 'Link'],\n ['2', 'SymbolicLink'],\n // Devices and FIFOs aren't fully supported\n // they are parsed, but skipped when unpacking\n ['3', 'CharacterDevice'],\n ['4', 'BlockDevice'],\n ['5', 'Directory'],\n ['6', 'FIFO'],\n // same as File\n ['7', 'ContiguousFile'],\n // pax headers\n ['g', 'GlobalExtendedHeader'],\n ['x', 'ExtendedHeader'],\n // vendor-specific stuff\n // skip\n ['A', 'SolarisACL'],\n // like 5, but with data, which should be skipped\n ['D', 'GNUDumpDir'],\n // metadata only, skip\n ['I', 'Inode'],\n // data = link path of next file\n ['K', 'NextFileHasLongLinkpath'],\n // data = path of next file\n ['L', 'NextFileHasLongPath'],\n // skip\n ['M', 'ContinuationFile'],\n // like L\n ['N', 'OldGnuLongPath'],\n // skip\n ['S', 'SparseFile'],\n // skip\n ['V', 'TapeVolumeHeader'],\n // like x\n ['X', 'OldExtendedHeader'],\n])\n\n// map the other direction\nexport const code = new Map<EntryTypeName, EntryTypeCode>(\n Array.from(name).map(kv => [kv[1], kv[0]]),\n)\n", "// parse a 512-byte header block to a data object, or vice-versa\n// encode returns `true` if a pax extended header is needed, because\n// the data could not be faithfully encoded in a simple header.\n// (Also, check header.needPax to see if it needs a pax header.)\n\nimport {\n decodeUtf8,\n encodeUtf8Into,\n isUint8Array,\n utf8Length,\n writeAscii,\n} from './bytes.js'\nimport * as large from './large-numbers.js'\nimport { basename, dirname, join } from './path.js'\nimport type { EntryTypeCode, EntryTypeName } from './types.js'\nimport * as types from './types.js'\n\nconst notNegative = (n?: number): number | undefined =>\n n === undefined || n < 0 ? undefined : n\n\nexport type HeaderData = {\n path?: string\n mode?: number\n uid?: number\n gid?: number\n size?: number\n cksum?: number\n type?: EntryTypeName | 'Unsupported'\n linkpath?: string\n uname?: string\n gname?: string\n devmaj?: number\n devmin?: number\n atime?: Date\n ctime?: Date\n mtime?: Date\n\n // fields that are common in extended PAX headers, but not in the\n // \"standard\" tar header block\n charset?: string\n comment?: string\n dev?: number\n ino?: number\n nlink?: number\n}\n\nexport class Header implements HeaderData {\n cksumValid: boolean = false\n needPax: boolean = false\n nullBlock: boolean = false\n\n block?: Uint8Array\n path?: string\n mode?: number\n uid?: number\n gid?: number\n size?: number\n cksum?: number\n #type: EntryTypeCode | 'Unsupported' = 'Unsupported'\n linkpath?: string\n uname?: string\n gname?: string\n devmaj: number = 0\n devmin: number = 0\n atime?: Date\n ctime?: Date\n mtime?: Date\n\n charset?: string\n comment?: string\n\n constructor(\n data?: Uint8Array | HeaderData,\n off: number = 0,\n ex?: HeaderData,\n gex?: HeaderData,\n ) {\n if (isUint8Array(data)) {\n this.decode(data, off || 0, ex, gex)\n } else if (data) {\n this.#slurp(data)\n }\n }\n\n decode(buf: Uint8Array, off: number, ex?: HeaderData, gex?: HeaderData) {\n if (!off) {\n off = 0\n }\n\n if (!buf || !(buf.length >= off + 512)) {\n throw new Error('need 512 bytes for header')\n }\n\n // Decode the typeflag (independent of any pending PAX/GNU extended\n // header) up front so we can tell whether THIS block is itself an\n // intermediary extension header (PAX `x`/`g`, GNU long-name `L`,\n // GNU long-link `K`). Per POSIX pax, a PAX extended header\n // describes the *next file entry*, not the extension headers that\n // may sit between it and that file. Applying the pending PAX\n // overrides (notably `size`) to an intervening `L`/`K`/`x`/`g`\n // header desynchronizes the stream relative to other tar\n // implementations and enables tar interpretation-conflict /\n // file-smuggling attacks.\n const t = decString(buf, off + 156, 1)\n const isNormalFS = types.normalFsTypes.has(t as EntryTypeCode)\n const exForFields = isNormalFS ? ex : undefined\n const gexForFields = isNormalFS ? gex : undefined\n\n this.path = exForFields?.path ?? decString(buf, off, 100)\n this.mode =\n exForFields?.mode ??\n gexForFields?.mode ??\n decNumber(buf, off + 100, 8)\n this.uid =\n exForFields?.uid ?? gexForFields?.uid ?? decNumber(buf, off + 108, 8)\n this.gid =\n exForFields?.gid ?? gexForFields?.gid ?? decNumber(buf, off + 116, 8)\n\n this.size = notNegative(\n exForFields?.size ??\n gexForFields?.size ??\n decNumber(buf, off + 124, 12),\n )\n this.mtime =\n exForFields?.mtime ??\n gexForFields?.mtime ??\n decDate(buf, off + 136, 12)\n this.cksum = decNumber(buf, off + 148, 12)\n\n // if we have extended or global extended headers, apply them now\n // See https://github.com/npm/node-tar/pull/187\n // Apply global before local, so it overrides. Never slurp the pending\n // extended-header fields onto an intermediary extension header.\n if (gexForFields) this.#slurp(gexForFields, true)\n if (exForFields) this.#slurp(exForFields)\n\n // old tar versions marked dirs as a file with a trailing /\n if (types.isCode(t)) {\n this.#type = t || '0'\n }\n if (this.#type === '0' && this.path.slice(-1) === '/') {\n this.#type = '5'\n }\n\n // tar implementations sometimes incorrectly put the stat(dir).size\n // as the size in the tarball, even though Directory entries are\n // not able to have any body at all. In the very rare chance that\n // it actually DOES have a body, we weren't going to do anything with\n // it anyway, and it'll just be a warning about an invalid header.\n if (this.#type === '5') {\n this.size = 0\n }\n\n this.linkpath = decString(buf, off + 157, 100)\n if (decodeUtf8(buf, off + 257, off + 265) === 'ustar\\u000000') {\n this.uname =\n exForFields?.uname ??\n gexForFields?.uname ??\n decString(buf, off + 265, 32)\n this.gname =\n exForFields?.gname ??\n gexForFields?.gname ??\n decString(buf, off + 297, 32)\n this.devmaj =\n exForFields?.devmaj ??\n gexForFields?.devmaj ??\n decNumber(buf, off + 329, 8) ??\n 0\n this.devmin =\n exForFields?.devmin ??\n gexForFields?.devmin ??\n decNumber(buf, off + 337, 8) ??\n 0\n if (buf[off + 475] !== 0) {\n // definitely a prefix, definitely >130 chars.\n const prefix = decString(buf, off + 345, 155)\n this.path = prefix + '/' + this.path\n } else {\n const prefix = decString(buf, off + 345, 130)\n if (prefix) {\n this.path = prefix + '/' + this.path\n }\n this.atime = ex?.atime ?? gex?.atime ?? decDate(buf, off + 476, 12)\n this.ctime = ex?.ctime ?? gex?.ctime ?? decDate(buf, off + 488, 12)\n }\n }\n\n let sum = 8 * 0x20\n for (let i = off; i < off + 148; i++) {\n sum += buf[i] as number\n }\n\n for (let i = off + 156; i < off + 512; i++) {\n sum += buf[i] as number\n }\n\n this.cksumValid = sum === this.cksum\n if (this.cksum === undefined && sum === 8 * 0x20) {\n this.nullBlock = true\n }\n }\n\n #slurp(ex: HeaderData, gex: boolean = false) {\n Object.assign(\n this,\n Object.fromEntries(\n Object.entries(ex).filter(([k, v]) => {\n // we slurp in everything except for the path attribute in\n // a global extended header, because that's weird. Also, any\n // null/undefined values are ignored.\n return !(\n v === null ||\n v === undefined ||\n (k === 'size' && Number(v) < 0) ||\n (k === 'path' && gex) ||\n (k === 'linkpath' && gex) ||\n k === 'global'\n )\n }),\n ),\n )\n }\n\n encode(buf?: Uint8Array, off: number = 0) {\n if (!buf) {\n buf = this.block = new Uint8Array(512)\n }\n\n if (this.#type === 'Unsupported') {\n this.#type = '0'\n }\n\n if (!(buf.length >= off + 512)) {\n throw new Error('need 512 bytes for header')\n }\n\n const prefixSize = this.ctime || this.atime ? 130 : 155\n const split = splitPrefix(this.path || '', prefixSize)\n const path = split[0]\n const prefix = split[1]\n this.needPax = !!split[2]\n\n this.needPax = encString(buf, off, 100, path) || this.needPax\n this.needPax = encNumber(buf, off + 100, 8, this.mode) || this.needPax\n this.needPax = encNumber(buf, off + 108, 8, this.uid) || this.needPax\n this.needPax = encNumber(buf, off + 116, 8, this.gid) || this.needPax\n this.needPax = encNumber(buf, off + 124, 12, this.size) || this.needPax\n this.needPax = encDate(buf, off + 136, 12, this.mtime) || this.needPax\n buf[off + 156] = Number(this.#type.codePointAt(0))\n this.needPax =\n encString(buf, off + 157, 100, this.linkpath) || this.needPax\n writeAscii('ustar\\u000000', buf, off + 257)\n this.needPax =\n encString(buf, off + 265, 32, this.uname) || this.needPax\n this.needPax =\n encString(buf, off + 297, 32, this.gname) || this.needPax\n this.needPax =\n encNumber(buf, off + 329, 8, this.devmaj) || this.needPax\n this.needPax =\n encNumber(buf, off + 337, 8, this.devmin) || this.needPax\n this.needPax =\n encString(buf, off + 345, prefixSize, prefix) || this.needPax\n if (buf[off + 475] !== 0) {\n this.needPax = encString(buf, off + 345, 155, prefix) || this.needPax\n } else {\n this.needPax = encString(buf, off + 345, 130, prefix) || this.needPax\n this.needPax =\n encDate(buf, off + 476, 12, this.atime) || this.needPax\n this.needPax =\n encDate(buf, off + 488, 12, this.ctime) || this.needPax\n }\n\n let sum = 8 * 0x20\n for (let i = off; i < off + 148; i++) {\n sum += buf[i] as number\n }\n\n for (let i = off + 156; i < off + 512; i++) {\n sum += buf[i] as number\n }\n\n this.cksum = sum\n encNumber(buf, off + 148, 8, this.cksum)\n this.cksumValid = true\n\n return this.needPax\n }\n\n get type(): EntryTypeName {\n return (\n this.#type === 'Unsupported' ?\n this.#type\n : types.name.get(this.#type)) as EntryTypeName\n }\n\n get typeKey(): EntryTypeCode | 'Unsupported' {\n return this.#type\n }\n\n set type(type: EntryTypeCode | EntryTypeName | 'Unsupported') {\n const c = String(types.code.get(type as EntryTypeName))\n if (types.isCode(c) || c === 'Unsupported') {\n this.#type = c\n } else if (types.isCode(type)) {\n this.#type = type\n } else {\n throw new TypeError('invalid entry type: ' + type)\n }\n }\n}\n\nconst splitPrefix = (\n p: string,\n prefixSize: number,\n): [string, string, boolean] => {\n const pathSize = 100\n let pp = p\n let prefix = ''\n let ret: undefined | [string, string, boolean] = undefined\n const root = p.charAt(0) === '/' ? '/' : '.'\n\n if (utf8Length(pp) < pathSize) {\n ret = [pp, prefix, false]\n } else {\n // first set prefix to the dir, and path to the base\n prefix = dirname(pp)\n pp = basename(pp)\n\n do {\n if (utf8Length(pp) <= pathSize && utf8Length(prefix) <= prefixSize) {\n // both fit!\n ret = [pp, prefix, false]\n } else if (\n utf8Length(pp) > pathSize &&\n utf8Length(prefix) <= prefixSize\n ) {\n // prefix fits in prefix, but path doesn't fit in path\n ret = [pp.slice(0, pathSize - 1), prefix, true]\n } else {\n // make path take a bit from prefix\n pp = join(basename(prefix), pp)\n prefix = dirname(prefix)\n }\n } while (prefix !== root && ret === undefined)\n\n // at this point, found no resolution, just truncate\n if (!ret) {\n ret = [p.slice(0, pathSize - 1), '', true]\n }\n }\n return ret\n}\n\n// The string ends at the first NUL, or at the end of the field.\nconst decString = (buf: Uint8Array, off: number, size: number) => {\n let end = off\n const max = Math.min(off + size, buf.length)\n while (end < max && buf[end] !== 0) end++\n return decodeUtf8(buf, off, end)\n}\n\nconst decDate = (buf: Uint8Array, off: number, size: number) =>\n numToDate(decNumber(buf, off, size))\n\nconst numToDate = (num?: number) =>\n num === undefined ? undefined : new Date(num * 1000)\n\nconst decNumber = (buf: Uint8Array, off: number, size: number) =>\n Number(buf[off]) & 0x80 ?\n large.parse(buf.subarray(off, off + size))\n : decSmallNumber(buf, off, size)\n\nconst nanUndef = (value: number) => (isNaN(value) ? undefined : value)\n\nconst decSmallNumber = (buf: Uint8Array, off: number, size: number) =>\n nanUndef(parseInt(decString(buf, off, size).trim(), 8))\n\n// the maximum encodable as a null-terminated octal, by field size\nconst MAXNUM = {\n 12: 0o77777777777,\n 8: 0o7777777,\n}\n\nconst encNumber = (\n buf: Uint8Array,\n off: number,\n size: 12 | 8,\n num?: number,\n) =>\n num === undefined ? false\n : num > MAXNUM[size] || num < 0 ?\n (large.encode(num, buf.subarray(off, off + size)), true)\n : (encSmallNumber(buf, off, size, num), false)\n\nconst encSmallNumber = (\n buf: Uint8Array,\n off: number,\n size: number,\n num: number,\n) => writeAscii(octalString(num, size), buf, off)\n\nconst octalString = (num: number, size: number) =>\n padOctal(Math.floor(num).toString(8), size)\n\nconst padOctal = (str: string, size: number) =>\n (str.length === size - 1 ?\n str\n : '0'.repeat(size - str.length - 2) + str + ' ') + '\\0'\n\nconst encDate = (\n buf: Uint8Array,\n off: number,\n size: 8 | 12,\n date?: Date,\n) =>\n date === undefined ? false : (\n encNumber(buf, off, size, date.getTime() / 1000)\n )\n\n// pad with nulls, return true if it's longer or non-ascii\nconst encString = (\n buf: Uint8Array,\n off: number,\n size: number,\n str?: string,\n) =>\n str === undefined ? false : (\n (encodeUtf8Into(str, buf, off, size),\n str.length !== utf8Length(str) || str.length > size)\n )\n", "import type { HeaderData } from './header.js'\nimport { Header } from './header.js'\nimport { decodeUtf8, encodeUtf8Into, utf8Length } from './bytes.js'\nimport { basename } from './path.js'\n\nconst SIMPLE_NUMBER = /^\\d+$/\n\nexport class Pax implements HeaderData {\n atime?: Date\n mtime?: Date\n ctime?: Date\n\n charset?: string\n comment?: string\n\n gid?: number\n uid?: number\n\n gname?: string\n uname?: string\n linkpath?: string\n dev?: number\n ino?: number\n nlink?: number\n path?: string\n size?: number\n mode?: number\n\n global: boolean\n\n constructor(obj: HeaderData, global: boolean = false) {\n this.atime = obj.atime\n this.charset = obj.charset\n this.comment = obj.comment\n this.ctime = obj.ctime\n this.dev = obj.dev\n this.gid = obj.gid\n this.global = global\n this.gname = obj.gname\n this.ino = obj.ino\n this.linkpath = obj.linkpath\n this.mtime = obj.mtime\n this.nlink = obj.nlink\n this.path = obj.path\n this.size = obj.size\n this.uid = obj.uid\n this.uname = obj.uname\n }\n\n encode() {\n const body = this.encodeBody()\n if (body === '') {\n return new Uint8Array(0)\n }\n\n const bodyLen = utf8Length(body)\n // round up to 512 bytes\n // add 512 for header\n const bufLen = 512 * Math.ceil(1 + bodyLen / 512)\n const buf = new Uint8Array(bufLen)\n\n new Header({\n // XXX split the path\n // then the path should be PaxHeader + basename, but less than 99,\n // prepend with the dirname\n path: ('PaxHeader/' + basename(this.path ?? '')).slice(0, 99),\n mode: this.mode || 0o644,\n uid: this.uid,\n gid: this.gid,\n size: bodyLen,\n mtime: this.mtime,\n type: this.global ? 'GlobalExtendedHeader' : 'ExtendedHeader',\n linkpath: '',\n uname: this.uname || '',\n gname: this.gname || '',\n devmaj: 0,\n devmin: 0,\n atime: this.atime,\n ctime: this.ctime,\n }).encode(buf)\n\n encodeUtf8Into(body, buf, 512, bodyLen)\n\n return buf\n }\n\n encodeBody() {\n return (\n this.encodeField('path') +\n this.encodeField('ctime') +\n this.encodeField('atime') +\n this.encodeField('dev') +\n this.encodeField('ino') +\n this.encodeField('nlink') +\n this.encodeField('charset') +\n this.encodeField('comment') +\n this.encodeField('gid') +\n this.encodeField('gname') +\n this.encodeField('linkpath') +\n this.encodeField('mtime') +\n this.encodeField('size') +\n this.encodeField('uid') +\n this.encodeField('uname')\n )\n }\n\n encodeField(field: keyof Pax): string {\n if (this[field] === undefined) {\n return ''\n }\n const r = this[field]\n const v = typeof r === 'object' ? r.getTime() / 1000 : r\n const s =\n ' ' +\n (field === 'dev' || field === 'ino' || field === 'nlink' ?\n 'SCHILY.'\n : '') +\n field +\n '=' +\n v +\n '\\n'\n const byteLen = utf8Length(s)\n // the digits includes the length of the digits in ascii base-10\n // so if it's 9 characters, then adding 1 for the 9 makes it 10\n // which makes it 11 chars.\n let digits = Math.floor(Math.log(byteLen) / Math.log(10)) + 1\n if (byteLen + digits >= Math.pow(10, digits)) {\n digits += 1\n }\n const len = digits + byteLen\n return len + s\n }\n\n static parse(str: string, ex?: HeaderData, g: boolean = false) {\n return Pax.parseBytes(new TextEncoder().encode(str), ex, g)\n }\n\n /** Parse the body of a PAX header entry. */\n static parseBytes(buf: Uint8Array, ex?: HeaderData, g: boolean = false) {\n return new Pax(merge(parseKV(buf), ex), g)\n }\n}\n\nconst merge = (a: HeaderData, b?: HeaderData) =>\n b ? Object.assign({}, b, a) : a\n\n// Each record is \"<len> <key>=<value>\\n\". <len> is the byte length of\n// the whole record. A value can contain a newline, so use the length\n// to find the end of the record. Stop at the first malformed record.\nconst parseKV = (buf: Uint8Array) => {\n const set: Record<string, string | number | Date> = Object.create(null)\n let pos = 0\n while (pos < buf.length) {\n let sp = pos\n while (\n sp < buf.length &&\n (buf[sp] as number) >= 0x30 &&\n (buf[sp] as number) <= 0x39\n ) {\n sp++\n }\n if (sp === pos || buf[sp] !== 0x20) break\n const n = Number(decodeUtf8(buf, pos, sp))\n const end = pos + n\n if (end <= sp + 1 || end > buf.length || buf[end - 1] !== 0x0a) break\n parseKVLine(set, decodeUtf8(buf, sp + 1, end - 1))\n pos = end\n }\n return set\n}\n\nconst parseKVLine = (\n set: Record<string, string | number | Date>,\n line: string,\n) => {\n const kv = line.split('=')\n const r = kv.shift()\n\n if (!r) {\n return set\n }\n\n const k = r.replace(/^SCHILY\\.(dev|ino|nlink)/, '$1')\n\n // The value ends at the first NUL.\n const joined = kv.join('=')\n const nul = joined.indexOf('\\0')\n const v = nul === -1 ? joined : joined.slice(0, nul)\n switch (k) {\n case 'path':\n case 'linkpath':\n case 'type':\n case 'charset':\n case 'comment':\n case 'gname':\n case 'uname':\n set[k] = v\n break\n case 'ctime':\n case 'atime':\n case 'mtime':\n const d = new Date(Number(v) * 1000)\n if (!isNaN(d.getTime())) set[k] = d\n break\n case 'size':\n case 'gid':\n case 'uid':\n case 'dev':\n case 'ino':\n case 'nlink':\n case 'mode':\n // value must be a string of decimal digits\n if (!SIMPLE_NUMBER.test(v.trim())) break\n const s = +v\n if (!Number.isSafeInteger(s)) break\n set[k] = s\n break\n }\n return set\n}\n", "/** The two ends of a stream that changes data, as a `TransformStream`. */\nexport type CodecStream = {\n readable: ReadableStream<Uint8Array>\n writable: WritableStream<Uint8Array>\n}\n\n/**\n * One compression format. Pass codecs in the `codecs` option to add\n * a format, or to replace the gzip support of the runtime.\n *\n * The readers use the first codec for which `detect` returns true.\n * If there is none, and the archive has a file name, and the input\n * does not start with a tar header, they use the first codec that\n * has an ending of the file name in `extensions`.\n *\n * The readers enforce `maxDecompressionRatio` for each codec.\n */\nexport type Codec = {\n name: string\n /** The number of bytes that `detect` needs. */\n headLength: number\n /**\n * True if the input is in this format. `head` is the start of the\n * input: `headLength` bytes or more, or all of a shorter input.\n */\n detect(head: Uint8Array): boolean\n /**\n * File name endings, such as `.tar.br`, for a format that `detect`\n * cannot identify.\n */\n extensions?: string[]\n /** Make a stream that decompresses. */\n decompress(): CodecStream\n /** Make a stream that compresses. */\n compress?(options?: Record<string, unknown>): CodecStream\n /**\n * Decompress all of `data`. The sync readers need it. It must throw\n * before it makes more than `limit.maxOutputLength` bytes. That\n * number is `Infinity` when the caller sets no ratio limit.\n */\n decompressSync?(\n data: Uint8Array,\n limit: { maxOutputLength: number },\n ): Uint8Array\n /** Compress all of `data`. */\n compressSync?(\n data: Uint8Array,\n options?: Record<string, unknown>,\n ): Uint8Array\n}\n\n/**\n * Gzip with the `DecompressionStream` and `CompressionStream` of the\n * runtime. The async readers always have it, after `opt.codecs`.\n * The option `portable` of `compress` makes output that does not\n * name the system.\n */\nexport const gzip: Codec = {\n name: 'gzip',\n headLength: 2,\n detect: head => head[0] === 0x1f && head[1] === 0x8b,\n decompress: () => new DecompressionStream('gzip') as CodecStream,\n compress: options => {\n const stream = new CompressionStream('gzip') as CodecStream\n if (!options?.portable) return stream\n // Byte 9 of a gzip stream names the system that made it. Set it\n // to 255, \"unknown\", so that each system makes the same bytes.\n let pos = 0\n return {\n writable: stream.writable,\n readable: stream.readable.pipeThrough(\n new TransformStream<Uint8Array, Uint8Array>({\n transform: (chunk, controller) => {\n if (pos <= 9 && pos + chunk.length > 9) chunk[9 - pos] = 255\n pos += chunk.length\n controller.enqueue(chunk)\n },\n }),\n ),\n }\n },\n}\n", "/**\n * The option aliases of the commands: the short names of the tar\n * program, and the long names of version 7. Each alias has the name\n * of its option.\n */\nexport const aliases = {\n C: 'cwd',\n f: 'file',\n z: 'gzip',\n P: 'preservePaths',\n U: 'unlink',\n 'strip-components': 'strip',\n stripComponents: 'strip',\n 'keep-newer': 'newer',\n keepNewer: 'newer',\n 'keep-newer-files': 'newer',\n keepNewerFiles: 'newer',\n k: 'keep',\n 'keep-existing': 'keep',\n keepExisting: 'keep',\n m: 'noMtime',\n 'no-mtime': 'noMtime',\n p: 'preserveOwner',\n L: 'follow',\n h: 'follow',\n onentry: 'onEntry',\n onReadEntry: 'onEntry',\n} as const\n\n/** The alias names, and the name of the option of each one. */\nexport type Aliases = typeof aliases\n\n/** The names of the options that have an alias. */\nexport type Aliased = Aliases[keyof Aliases]\n\n/** The alias names of the option `K`. */\nexport type AliasOf<K> = {\n [A in keyof Aliases]: Aliases[A] extends K ? A : never\n}[keyof Aliases]\n\n/**\n * For each option `K` of `T`, an object type that requires the option\n * or one of its aliases.\n */\nexport type RequiredOption<T, K extends keyof T> =\n [K] extends [never] ? unknown\n : // A function type for each option, to make an intersection.\n (\n K extends unknown ?\n (x: {\n // A union: one object type for each name of the option.\n v: { [N in K | AliasOf<K>]: { [P in N]: T[K] } }[K | AliasOf<K>]\n }) => void\n : never\n ) extends (x: infer I extends { v: unknown }) => void ?\n I['v']\n : never\n\n/**\n * The option type `T` of a command, and the aliases of its options.\n * An alias has the type of its option. An option that `T` requires\n * can be given with its name or with an alias.\n */\nexport type WithAliases<T> =\n T extends unknown ?\n Omit<T, Aliased> &\n Partial<Pick<T, keyof T & Aliased>> & {\n [A in keyof Aliases as Aliases[A] extends keyof T ? A\n : never]?: T[Aliases[A] & keyof T]\n } & ('chmod' extends keyof T ?\n {\n /** `noChmod: false` is `chmod: true`, if `chmod` is not set. */\n noChmod?: boolean\n }\n : unknown) &\n RequiredOption<\n T,\n // The options that `T` must have.\n {\n [K in keyof T]-?: object extends Pick<T, K> ? never : K\n }[keyof T] &\n Aliased\n >\n : never\n\n/** The `file` option, with its name or with its alias. */\nexport type FileOption = RequiredOption<{ file: string }, 'file'>\n\n/** No `file` option. */\nexport type NoFileOption = { [N in 'file' | AliasOf<'file'>]?: undefined }\n\n/**\n * A copy of the options, with no prototype, that has the name of the\n * option in place of each alias. An option that is set wins over its\n * aliases.\n */\nexport const dealias = <T extends object>(options: WithAliases<T>): T => {\n const opt: Record<string, unknown> = Object.assign(\n Object.create(null),\n options,\n )\n for (const [alias, name] of Object.entries(aliases)) {\n if (opt[alias] !== undefined) opt[name] ??= opt[alias]\n delete opt[alias]\n }\n if (opt.noChmod === false) opt.chmod ??= true\n delete opt.noChmod\n return opt as T\n}\n", "/** Copy the parts into one new array. */\nexport const concat = (parts: Uint8Array[]): Uint8Array<ArrayBuffer> => {\n if (parts.length === 1) return (parts[0] as Uint8Array).slice()\n let length = 0\n for (const part of parts) length += part.length\n const out = new Uint8Array(length)\n let pos = 0\n for (const part of parts) {\n out.set(part, pos)\n pos += part.length\n }\n return out\n}\n", "import type { Codec } from './codec.js'\nimport type { EntryData, ReadEntry, ReadEntrySync } from './read-entry.js'\nimport type { ExtractFS, ExtractFSSync, TarFS, TarFSSync } from './fs.js'\nimport type { WarnOptions } from './warn.js'\nimport type {\n CreateFS,\n CreateFSSync,\n CreateStats,\n DeleteFS,\n DeleteFSSync,\n ReplaceFS,\n ReplaceFSSync,\n} from './fs.js'\nimport type { WriteEntry } from './write-entry.js'\n\n/**\n * A copy of the options with no prototype, so that an option that is\n * not set cannot get a value from a changed `Object.prototype`.\n */\nexport const ownOptions = <T extends object>(\n opt: T,\n more?: Partial<T>,\n): T => Object.assign(Object.create(null) as T, opt, more)\n\n/**\n * The value of an option that is a count, such as `jobs`: the\n * default if the option is not set or is 0, and a `TypeError` if the\n * value is not a positive integer or `Infinity`.\n */\nexport const countOption = (\n name: string,\n value: unknown,\n def: number,\n): number => {\n if (value === undefined || value === null || value === 0) return def\n if (\n value === Infinity ||\n (Number.isInteger(value) && Number(value) > 0)\n ) {\n return value as number\n }\n throw new TypeError(`${name} must be a positive integer`)\n}\n\n/** The options of a `Parser`. */\nexport type ParserOptions<E extends EntryData = EntryData> =\n WarnOptions & {\n /**\n * Called with each entry that is an object of the file system.\n * If it returns false, the entry is ignored.\n */\n filter?: (path: string, entry: E) => boolean\n /**\n * The largest PAX or GNU long name entry to read, in bytes. A\n * larger one is skipped. Default 1 MiB.\n */\n maxMetaEntrySize?: number\n /** With `'win32'`, each `\\` in a path is changed to `/`. */\n platform?: 'win32' | 'posix'\n }\n\n/** The options of the readers. */\nexport type ReadOptions<E extends EntryData = ReadEntry> =\n ParserOptions<E> & {\n /**\n * Stop with an error when the decompressed size is more than this\n * many times the compressed size. Default 1000.\n */\n maxDecompressionRatio?: number\n /**\n * Compression formats, tried in order before the gzip support of\n * the runtime.\n */\n codecs?: Codec[]\n }\n\n/** The options of `entriesSync`. */\nexport type ReadOptionsSync = ReadOptions<ReadEntrySync>\n\n/** The archive data that `entries` reads. */\nexport type TarInput =\n | Uint8Array\n | ArrayBuffer\n | Blob\n | ReadableStream<Uint8Array>\n | AsyncIterable<Uint8Array>\n | Iterable<Uint8Array>\n\n/** The archive data that `entriesSync` reads. */\nexport type TarInputSync = Uint8Array | ArrayBuffer | Iterable<Uint8Array>\n\n/** The options of `list`. Set `input`, or `file` and `fs`. */\nexport type ListOptions = ReadOptions & {\n input?: TarInput\n /** The path of the archive file. */\n file?: string\n fs?: TarFS\n /**\n * The most bytes to read from the file at one time. Default, and\n * with 0, 16 MiB. A positive integer, or `Infinity`.\n */\n maxReadSize?: number\n /**\n * Called with each entry. A promise is awaited before the next\n * entry.\n */\n onEntry?: (entry: ReadEntry) => unknown\n}\n\n/** The options of `listSync`. Set `input`, or `file` and `fs`. */\nexport type ListOptionsSync = ReadOptionsSync & {\n input?: TarInputSync\n /** The path of the archive file. */\n file?: string\n fs?: TarFSSync\n /**\n * The most bytes to read from the file at one time. Default, and\n * with 0, 16 MiB. A positive integer, or `Infinity`.\n */\n maxReadSize?: number\n /** Called with each entry. */\n onEntry?: (entry: ReadEntrySync) => unknown\n}\n\n/**\n * The options of the extraction that are not about the archive data\n * or the file system functions.\n */\nexport type UnpackOptions = {\n /** The absolute path of the directory to extract into. */\n cwd: string\n /**\n * With `'win32'`: the path rules of Windows, the characters `<|>?:`\n * in a name are changed to private-use characters, a file is\n * renamed before it is removed, and one entry is extracted at a\n * time.\n */\n platform?: 'win32' | 'posix'\n /** Remove this number of leading parts from each path. */\n strip?: number\n /**\n * Permit absolute paths, `..` in paths, and extraction through\n * symbolic links. This is not safe with an archive that is not\n * trusted.\n */\n preservePaths?: boolean\n /**\n * Remove a file before the entry is written, in place of a write\n * into the existing file. Also remove a symbolic link in the path\n * to an entry.\n */\n unlink?: boolean\n /** Do not write over an existing file. */\n keep?: boolean\n /** Do not write over a file that is newer than the entry. */\n newer?: boolean\n /** Do not set the times of the entries. */\n noMtime?: boolean\n /**\n * Set the owner of each entry to the `uid` and `gid` in the\n * archive. Default: true if `processUid` is 0 and `uid` is not set.\n */\n preserveOwner?: boolean\n /** Set the owner of each entry to this user. Needs `gid`. */\n uid?: number\n /** Set the owner of each entry to this group. Needs `uid`. */\n gid?: number\n /** Set the owner of each entry, also when it is the process owner. */\n forceChown?: boolean\n /**\n * Set the mode of each directory with `chmod`, so that the umask of\n * the process does not change it.\n */\n chmod?: boolean\n /**\n * The umask of the process. Only used with `chmod`. Default 0o22.\n */\n processUmask?: number\n /** The user ID of the process. */\n processUid?: number\n /** The group ID of the process. */\n processGid?: number\n /** Sets the default of `dmode` and `fmode`. Default: `processUmask`. */\n umask?: number\n /** The mode of a directory that has no mode in the archive. */\n dmode?: number\n /** The mode of a file that has no mode in the archive. */\n fmode?: number\n /**\n * The most parts that a path or a link target can have. Default\n * 1024. `Infinity` removes the limit.\n */\n maxDepth?: number\n}\n\n/**\n * The options of `extract`. Set `input`, or `file`. With `file`, the\n * `fs` must also have the functions of `TarFS`.\n */\nexport type ExtractOptions = ReadOptions &\n UnpackOptions & {\n /**\n * The most bytes to read from the file at one time. Default, and\n * with 0, 16 MiB. A positive integer, or `Infinity`.\n */\n maxReadSize?: number\n /**\n * Called with each entry before it is extracted. A promise is\n * awaited before the entry is extracted.\n */\n onEntry?: (entry: ReadEntry) => unknown\n /**\n * Return a stream that changes the content of a file entry, or\n * `undefined` to write the content as it is.\n */\n transform?: (\n entry: ReadEntry,\n ) => TransformStream<Uint8Array, Uint8Array> | undefined\n /**\n * The most entries to extract at one time. Default, and with 0,\n * 16. A positive integer, or `Infinity`.\n */\n jobs?: number\n } & (\n | {\n /**\n * The archive data. A chunk must not change after the source\n * gives it.\n */\n input: TarInput\n /** The name of the archive, for warnings. */\n file?: string\n fs: ExtractFS\n }\n | {\n input?: undefined\n /** The path of the archive file. */\n file: string\n fs: ExtractFS & TarFS\n }\n )\n\n/** The options of `extractSync`. Set `input`, or `file`. */\nexport type ExtractOptionsSync = ReadOptionsSync &\n UnpackOptions & {\n /**\n * The most bytes to read from the file at one time. Default, and\n * with 0, 16 MiB. A positive integer, or `Infinity`.\n */\n maxReadSize?: number\n /** Called with each entry before it is extracted. */\n onEntry?: (entry: ReadEntrySync) => unknown\n /**\n * Return a function that changes each chunk of the content of a\n * file entry, or `undefined` to write the content as it is.\n */\n transform?: (\n entry: ReadEntrySync,\n ) => ((chunk: Uint8Array) => Uint8Array) | undefined\n } & (\n | {\n input: TarInputSync\n /** The name of the archive, for warnings. */\n file?: string\n fs: ExtractFSSync\n }\n | {\n input?: undefined\n /** The path of the archive file. */\n file: string\n fs: ExtractFSSync & TarFSSync\n }\n )\n\n/** The options that `Pack` and `PackSync` share. */\nexport type PackOptionsBase<E extends EntryData> = WarnOptions & {\n /**\n * The absolute path of the directory that the paths to add are\n * relative to. A pack needs it, and `fs`, to add a path. A path\n * that is not absolute is a `TypeError`.\n */\n cwd?: string\n /** A directory to put before the path of each entry. */\n prefix?: string\n /**\n * Leave out the data that is specific to one system: `uid`, `gid`,\n * `uname`, `gname`, `atime`, `ctime`, `dev`, `ino`, `nlink`, and\n * the `mtime` of a directory. Remove the write permission of the\n * group and of others.\n */\n portable?: boolean\n /** Write no PAX header for a field that does not fit the header. */\n noPax?: boolean\n /** Add the target of a symbolic link, not the link. */\n follow?: boolean\n /** Add a directory without the entries in it. */\n noDirRecurse?: boolean\n /** Write no `mtime`. */\n noMtime?: boolean\n /** The `mtime` of each entry. */\n mtime?: Date\n /** Keep a root at the start of a path, such as `/`. */\n preservePaths?: boolean\n /**\n * Called with each path and its `lstat` result (its `stat` result\n * with `follow`), and with each entry of another archive. If it\n * returns false, the path or the entry is not added.\n */\n filter?: (path: string, entry: CreateStats | E) => boolean\n /**\n * The most bytes to read from a file at one time. Default, and\n * with 0, 16 MiB. A positive integer, or `Infinity`. A larger file\n * is not read before the pack comes to it.\n */\n maxReadSize?: number\n /**\n * With `'win32'`, each `\\` in a path is changed to `/`, and the\n * characters that `winchars` encodes are decoded.\n */\n platform?: 'win32' | 'posix'\n /** The user ID of the process. */\n processUid?: number\n /** The `uname` of each file that `processUid` owns. */\n processUname?: string\n /**\n * Called with each entry before its header is written. It can\n * change the fields of the entry.\n */\n onWriteEntry?: (entry: WriteEntry) => unknown\n /**\n * Compression formats, before the gzip support of the runtime. The\n * options `gzip`, `brotli`, and `zstd` select the first codec that\n * has that name.\n */\n codecs?: Codec[]\n /** Compress with the codec named `gzip`. */\n gzip?: boolean | Record<string, unknown>\n /** Compress with the codec named `brotli` in `codecs`. */\n brotli?: boolean | Record<string, unknown>\n /** Compress with the codec named `zstd` in `codecs`. */\n zstd?: boolean | Record<string, unknown>\n /**\n * Compress with this codec. It does not need to be in `codecs`.\n * With a pair, the second item is given to the `compress` function\n * of the codec.\n */\n compress?: Codec | [codec: Codec, options: Record<string, unknown>]\n}\n\n/** The options of `Pack`. */\nexport type PackOptions = PackOptionsBase<ReadEntry> & {\n fs?: CreateFS\n /**\n * The number of paths at the start of the queue that are read\n * before the pack writes them. Default, and with 0, 4. A positive\n * integer, or `Infinity`.\n */\n jobs?: number\n}\n\n/** The options of `PackSync`. */\nexport type PackOptionsSync = PackOptionsBase<ReadEntrySync> & {\n fs?: CreateFSSync\n}\n\n/**\n * The options of `create`. With `file`, the archive is written to\n * that path through `fs`.\n */\nexport type CreateOptions = PackOptions & {\n /** The mode of the archive file. Default 0o666. */\n mode?: number\n}\n\n/** The options of `createSync`. */\nexport type CreateOptionsSync = PackOptionsSync & {\n /** The mode of the archive file. Default 0o666. */\n mode?: number\n}\n\n/** The options of `replace` and `update`. */\nexport type ReplaceOptions = CreateOptions & {\n /** The path of the archive file. It is made if it does not exist. */\n file: string\n fs: ReplaceFS\n /**\n * Gets the path and the `mtime` of each entry that the archive\n * has. `update` adds a path only if it is newer than the `mtime`\n * here.\n */\n mtimeCache?: Map<string, Date>\n}\n\n/** The options of `replaceSync` and `updateSync`. */\nexport type ReplaceOptionsSync = CreateOptionsSync & {\n /** The path of the archive file. It is made if it does not exist. */\n file: string\n fs: ReplaceFSSync\n /**\n * Gets the path and the `mtime` of each entry that the archive\n * has. `updateSync` adds a path only if it is newer than the\n * `mtime` here.\n */\n mtimeCache?: Map<string, Date>\n}\n\n/** The options of `delete`. */\nexport type DeleteOptions = Omit<ReadOptions, 'filter'> & {\n /** The path of the archive file. */\n file: string\n fs: DeleteFS\n /**\n * Return true to remove the entry. With a list of paths, an entry\n * is removed only if the list also has it.\n */\n filter?: (path: string, entry: ReadEntry) => boolean\n /**\n * The most bytes to read from the file at one time. Default, and\n * with 0, 16 MiB. A positive integer, or `Infinity`.\n */\n maxReadSize?: number\n}\n\n/** The options of `deleteSync`. */\nexport type DeleteOptionsSync = Omit<ReadOptionsSync, 'filter'> & {\n /** The path of the archive file. */\n file: string\n fs: DeleteFSSync\n /**\n * Return true to remove the entry. With a list of paths, an entry\n * is removed only if the list also has it.\n */\n filter?: (path: string, entry: ReadEntrySync) => boolean\n /**\n * The most bytes to read from the file at one time. Default, and\n * with 0, 16 MiB. A positive integer, or `Infinity`.\n */\n maxReadSize?: number\n}\n", "import type { Header } from './header.js'\nimport type { Pax } from './pax.js'\nimport type { EntryTypeName } from './types.js'\nimport { concat } from './concat.js'\n\n// The types that are an object of the file system.\nconst fsTypes = new Set<EntryTypeName>([\n 'File',\n 'OldFile',\n 'Link',\n 'SymbolicLink',\n 'CharacterDevice',\n 'BlockDevice',\n 'Directory',\n 'FIFO',\n 'ContiguousFile',\n 'GNUDumpDir',\n])\n\nconst winPath = (path: string) => path.replaceAll('\\\\', '/')\n\n/**\n * The metadata of one archive entry: the header fields, with the\n * values of the PAX and GNU extended headers applied.\n */\nexport class EntryData {\n /** The header block of the entry. */\n header: Header\n /** The PAX header that applies to this entry only. */\n extended?: Pax\n /** The global PAX header in effect. */\n globalExtended?: Pax\n type: EntryTypeName\n path: string\n /** The permission bits only. */\n mode?: number\n uid?: number\n gid?: number\n uname?: string\n gname?: string\n /** The number of bytes in the body. */\n size: number\n mtime?: Date\n atime?: Date\n ctime?: Date\n linkpath?: string\n devmaj: number\n devmin: number\n dev?: number\n ino?: number\n nlink?: number\n /** The absolute path of the entry, when a consumer resolves it. */\n absolute?: string\n /**\n * The body is skipped. Set for a type that is not an object of the\n * file system, and for an entry that the filter refuses.\n */\n ignore: boolean\n /** A consumer sets this when it refuses the entry. */\n invalid: boolean = false\n /** A consumer sets this when it does not support the type. */\n unsupported: boolean = false\n\n /**\n * @param win32 change each `\\` in `path` and `linkpath` to `/`\n */\n constructor(\n header: Header,\n ex?: Pax,\n gex?: Pax,\n win32: boolean = false,\n ) {\n if (!header.path) {\n throw new Error('no path provided for tar.ReadEntry')\n }\n this.header = header\n this.extended = ex\n this.globalExtended = gex\n this.type = header.type\n this.ignore = !fsTypes.has(this.type)\n this.path = win32 ? winPath(header.path) : header.path\n this.mode = header.mode && header.mode & 0o7777\n this.uid = header.uid\n this.gid = header.gid\n this.uname = header.uname\n this.gname = header.gname\n this.size = header.size ?? 0\n this.mtime = header.mtime\n this.atime = header.atime\n this.ctime = header.ctime\n this.linkpath =\n header.linkpath ?\n win32 ? winPath(header.linkpath)\n : header.linkpath\n : undefined\n this.devmaj = header.devmaj\n this.devmin = header.devmin\n\n // Apply the global values first, so that the local values win.\n // The header already has the size.\n if (gex) this.#apply(gex)\n if (ex) {\n this.#apply(ex)\n // A global header does not set a path or a linkpath.\n if (ex.path != null) this.path = win32 ? winPath(ex.path) : ex.path\n if (ex.linkpath != null) {\n this.linkpath = win32 ? winPath(ex.linkpath) : ex.linkpath\n }\n }\n }\n\n #apply(ex: Pax) {\n if (ex.uid != null) this.uid = ex.uid\n if (ex.gid != null) this.gid = ex.gid\n if (ex.uname != null) this.uname = ex.uname\n if (ex.gname != null) this.gname = ex.gname\n if (ex.mtime != null) this.mtime = ex.mtime\n if (ex.atime != null) this.atime = ex.atime\n if (ex.ctime != null) this.ctime = ex.ctime\n if (ex.dev != null) this.dev = ex.dev\n if (ex.ino != null) this.ino = ex.ino\n if (ex.nlink != null) this.nlink = ex.nlink\n }\n}\n\n/** Where a `ReadEntry` gets its body. */\nexport type BodySource = {\n /**\n * The next part of the body of `entry`. `null` at the end of the\n * body. `undefined` if more input is needed: then await `fill()`\n * and call this again. Throws if the source moved to a later entry.\n */\n readBody(entry: ReadEntry): Uint8Array | null | undefined\n /** Read more input. */\n fill(): Promise<void>\n}\n\n/** Where a `ReadEntrySync` gets its body. */\nexport type BodySourceSync = {\n /**\n * The next part of the body of `entry`, or `null` at the end of the\n * body. Throws if the source moved to a later entry.\n */\n readBody(entry: ReadEntrySync): Uint8Array | null\n}\n\n// As `Response.text()` does, this decoder removes a byte order mark\n// at the start of the body.\nconst decoder = new TextDecoder()\nconst decode = (parts: Uint8Array[]) => {\n let text = ''\n for (const part of parts) text += decoder.decode(part, { stream: true })\n return text + decoder.decode()\n}\n\nconst usedError = () => new TypeError('Body has already been consumed')\n\n/**\n * An archive entry with its body, in the shape of a `Response`. The\n * body can be consumed one time, in one way. It must be consumed\n * before the next entry is read: after that, the rest of it is gone.\n */\nexport class ReadEntry extends EntryData {\n #source?: BodySource\n #used: boolean = false\n #stream?: ReadableStream<Uint8Array>\n\n constructor(\n header: Header,\n ex?: Pax,\n gex?: Pax,\n win32?: boolean,\n source?: BodySource,\n ) {\n super(header, ex, gex, win32)\n this.#source = source\n }\n\n /** True when the body started to be consumed. */\n get bodyUsed(): boolean {\n return this.#used\n }\n\n /**\n * The body as a stream. Each chunk is a view into the input, not a\n * copy. Input is read only when the stream is read.\n */\n get body(): ReadableStream<Uint8Array> {\n if (this.#stream) return this.#stream\n let started = false\n return (this.#stream = new ReadableStream<Uint8Array>(\n {\n pull: async controller => {\n if (!started) {\n this.#claim()\n started = true\n }\n const [part] = await this.#read(1)\n if (part) controller.enqueue(part)\n else controller.close()\n },\n },\n { highWaterMark: 0 },\n ))\n }\n\n #claim() {\n if (this.#used) throw usedError()\n this.#used = true\n }\n\n // Add the parts of the body that are in memory to `parts`, up to\n // `max` parts. False if the body has more parts that need input.\n #collect(parts: Uint8Array[], max: number = Infinity): boolean {\n const source = this.#source\n while (source && parts.length < max) {\n const part = source.readBody(this)\n if (part === null) break\n if (part === undefined) return false\n parts.push(part)\n }\n return true\n }\n\n // Read all the parts of the body that are left, or `max` of them.\n async #read(max?: number): Promise<Uint8Array[]> {\n const parts: Uint8Array[] = []\n while (!this.#collect(parts, max)) await this.#source?.fill()\n return parts\n }\n\n /** The body in a new `Uint8Array`. */\n async bytes(): Promise<Uint8Array<ArrayBuffer>> {\n this.#claim()\n const parts: Uint8Array[] = []\n while (!this.#collect(parts)) await this.#source?.fill()\n return concat(parts)\n }\n\n /** The body in a new `ArrayBuffer`. */\n async arrayBuffer(): Promise<ArrayBuffer> {\n return (await this.bytes()).buffer\n }\n\n /**\n * The body, decoded as UTF-8. As with `Response.text()`, a byte\n * order mark at the start is not in the text.\n */\n async text(): Promise<string> {\n this.#claim()\n return decode(await this.#read())\n }\n\n /** The body in a new `Blob`. */\n async blob(): Promise<Blob> {\n this.#claim()\n return new Blob((await this.#read()) as Uint8Array<ArrayBuffer>[])\n }\n}\n\n/**\n * An archive entry with its body, for sync code. The body can be\n * consumed one time, in one way. It must be consumed before the next\n * entry is read: after that, the rest of it is gone.\n */\nexport class ReadEntrySync extends EntryData {\n #source?: BodySourceSync\n #used: boolean = false\n #body?: IterableIterator<Uint8Array>\n\n constructor(\n header: Header,\n ex?: Pax,\n gex?: Pax,\n win32?: boolean,\n source?: BodySourceSync,\n ) {\n super(header, ex, gex, win32)\n this.#source = source\n }\n\n /** True when the body started to be consumed. */\n get bodyUsed(): boolean {\n return this.#used\n }\n\n /**\n * The parts of the body. Each one is a view into the input, not a\n * copy. Input is read only when the iterator is read.\n */\n get body(): IterableIterator<Uint8Array> {\n return (this.#body ??= this.#iterate())\n }\n\n *#iterate(): IterableIterator<Uint8Array> {\n this.#claim()\n for (let part; (part = this.#source?.readBody(this)); ) yield part\n }\n\n #claim() {\n if (this.#used) throw usedError()\n this.#used = true\n }\n\n #read(): Uint8Array[] {\n this.#claim()\n const parts: Uint8Array[] = []\n for (let part; (part = this.#source?.readBody(this)); )\n parts.push(part)\n return parts\n }\n\n /** The body in a new `Uint8Array`. */\n bytes(): Uint8Array<ArrayBuffer> {\n return concat(this.#read())\n }\n\n /** The body in a new `ArrayBuffer`. */\n arrayBuffer(): ArrayBuffer {\n return this.bytes().buffer\n }\n\n /**\n * The body, decoded as UTF-8. A byte order mark at the start is not\n * in the text.\n */\n text(): string {\n return decode(this.#read())\n }\n}\n", "/** Data that a warning or an error of this package carries. */\nexport type WarnData = {\n file?: string\n code?: string\n tarCode?: string\n recoverable?: boolean\n [k: string]: unknown\n}\n\n/** An error with the data of the warning that caused it. */\nexport type TarError = Error & WarnData\n\n/** The options that `warn` reads. */\nexport type WarnOptions = {\n /** Throw each warning as an error. */\n strict?: boolean\n /** Called for each warning when `strict` is not set. */\n onwarn?: (code: string, message: string, data: WarnData) => unknown\n /** The archive file. Each warning has it as `data.file`. */\n file?: string\n}\n\n// A message that is not a string is an error. The test is not\n// `instanceof Error`, which is false for an error of a different\n// realm, such as an error of `node:fs` in a `node:vm` context.\n\nconst fill = (\n opt: WarnOptions,\n code: string,\n message: string | Error,\n data: WarnData,\n) => {\n if (opt.file) data.file = opt.file\n data.code =\n (typeof message === 'object' && (message as TarError).code) || code\n data.tarCode = code\n return data\n}\n\n/** Make the error for a problem that is not recoverable. */\nexport const tarError = (\n opt: WarnOptions,\n code: string,\n message: string | Error,\n data: WarnData = {},\n): TarError =>\n Object.assign(\n typeof message === 'object' ? message : (\n new Error(`${code}: ${message}`)\n ),\n fill(opt, code, message, data),\n )\n\n/**\n * Report a problem. Call `opt.onwarn(code, message, data)`, or throw\n * the error if `opt.strict` is set or `data.recoverable` is false.\n */\nexport const warn = (\n opt: WarnOptions,\n code: string,\n message: string | Error,\n data: WarnData = {},\n): void => {\n // The value of a changed `Object.prototype` does not count.\n const fatal =\n Object.hasOwn(data, 'recoverable') && data.recoverable === false\n if (opt.strict || fatal) {\n throw tarError(opt, code, message, data)\n }\n fill(opt, code, message, data)\n if (typeof message === 'object') {\n data = Object.assign(message, data)\n message = message.message\n }\n opt.onwarn?.(code, message, data)\n}\n", "import { decodeUtf8 } from './bytes.js'\nimport { Header } from './header.js'\nimport { Pax } from './pax.js'\nimport type { EntryTypeName } from './types.js'\nimport { ownOptions, type ParserOptions } from './options.js'\nimport { EntryData } from './read-entry.js'\nimport { warn, type WarnData, type WarnOptions } from './warn.js'\n\n/** What `Parser.next()` returns. */\nexport type ParseEvent<E extends EntryData = EntryData> =\n /**\n * An entry that is not a PAX or GNU meta entry. If `entry.ignore`\n * is set, the parser skips the body, and no other event follows\n * for this entry.\n */\n | { type: 'entry'; entry: E }\n /** A part of the body of the entry. A view into the input. */\n | { type: 'body'; data: Uint8Array }\n /** The end of the body of the entry. */\n | { type: 'entryEnd' }\n /** The end of the archive. No event follows. */\n | { type: 'end' }\n\n/** Makes the entry object for a header. */\nexport type CreateEntry<E extends EntryData> = (\n header: Header,\n ex: Pax | undefined,\n gex: Pax | undefined,\n) => E\n\nconst BEGIN = 0\nconst HEADER = 1\nconst BODY = 2\nconst IGNORE = 3\nconst META = 4\n\nconst ENTRY_END = { type: 'entryEnd' } as const\nconst END = { type: 'end' } as const\n\nconst metaTypes = new Set<EntryTypeName>([\n 'ExtendedHeader',\n 'OldExtendedHeader',\n 'GlobalExtendedHeader',\n 'NextFileHasLongPath',\n 'OldGnuLongPath',\n 'NextFileHasLongLinkpath',\n])\n\n// The text up to the first NUL.\nconst cstring = (buf: Uint8Array) => {\n const nul = buf.indexOf(0)\n return decodeUtf8(buf, 0, nul === -1 ? buf.length : nul)\n}\n\n/**\n * A tar parser that the caller pulls. Give it input with `push()`,\n * and call `next()` for each event until it returns `undefined`.\n * Then give it more input, or call `end()` and call `next()` again.\n *\n * It does not decompress. It calls no code of the caller but\n * `filter`, `onwarn`, and the function that makes the entry objects.\n *\n * With `strict`, `next()` throws at each problem. The parser stays\n * usable: the next call continues after the block with the problem.\n */\nexport class Parser<E extends EntryData = EntryData> {\n maxMetaEntrySize: number\n /**\n * The number of input bytes up to the end of the last complete\n * entry that is not a meta entry.\n */\n position: number = 0\n /**\n * The number of input bytes that are parsed: the header blocks and\n * the body blocks. At an `entry` event, it is the place of the body\n * of the entry in the input.\n */\n offset: number = 0\n\n #opt: WarnOptions\n #filter?: (path: string, entry: E) => boolean\n #create: CreateEntry<E>\n #queue: Uint8Array[] = []\n #chunk?: Uint8Array\n #pos: number = 0\n // a header block that is in more than one chunk\n #block?: Uint8Array\n #blockLen: number = 0\n #state: number = BEGIN\n // the entry of the body that is read or skipped now\n #entry?: E\n #header?: Header\n #meta?: Uint8Array\n #metaLen: number = 0\n // body bytes to come, without and with the padding\n #remain: number = 0\n #blockRemain: number = 0\n #ex?: Pax\n // the names of the GNU long name headers for the next entry\n #longPath?: string\n #longLinkpath?: string\n #gex?: Pax\n #ended: boolean = false\n #sawValid?: boolean\n #entryEnd: boolean = false\n // 0: reading, 1: the end is found, 2: the end event is returned\n #done: number = 0\n\n /**\n * @param createEntry makes the object for each entry event. It is\n * required if `E` is not `EntryData`.\n */\n constructor(opt: ParserOptions<E> = {}, createEntry?: CreateEntry<E>) {\n opt = this.#opt = ownOptions(opt)\n this.maxMetaEntrySize = opt.maxMetaEntrySize || 1024 * 1024\n this.#filter = opt.filter\n const win32 = opt.platform === 'win32'\n this.#create =\n createEntry ??\n ((header, ex, gex) => new EntryData(header, ex, gex, win32) as E)\n }\n\n /**\n * Report a problem to `onwarn`. Throws if `strict` is set, or if\n * `data.recoverable` is false.\n */\n warn(code: string, message: string | Error, data?: WarnData): void {\n warn(this.#opt, code, message, data)\n }\n\n /**\n * Add input. The parser keeps the chunk until `next()` returns\n * `undefined`, and each body event is a view into it. Input after\n * `end()`, or after the end of the archive, is dropped.\n */\n push(chunk: Uint8Array): void {\n if (!this.#ended) this.#queue.push(chunk)\n }\n\n /** Tell the parser that the input is complete. */\n end(): void {\n this.#ended = true\n }\n\n /**\n * The number of bytes of the body of the current entry, with its\n * padding, that are after the input given so far. The caller can\n * skip them in its input, and call `skipBody()`. It is 0 if the\n * parser has input that it did not parse, and in a PAX or GNU\n * header, because the parser reads that body.\n */\n get bodyRemain(): number {\n const chunk = this.#chunk\n const state = this.#state\n return (\n (state !== BODY && state !== IGNORE) ||\n this.#queue.length ||\n (chunk && this.#pos < chunk.length)\n ) ?\n 0\n : this.#blockRemain\n }\n\n /**\n * Count the `bodyRemain` bytes as parsed. The next input is the\n * header after the body.\n */\n skipBody(): void {\n this.#entryEnd = this.#state === BODY\n this.offset += this.#blockRemain\n this.#remain = this.#blockRemain = 0\n this.#endBody()\n }\n\n /**\n * The next event. `undefined` means that the parser needs more\n * input, or after the `end` event, that it is done.\n */\n next(): ParseEvent<E> | undefined {\n if (this.#entryEnd) {\n this.#entryEnd = false\n return ENTRY_END\n }\n for (;;) {\n let chunk = this.#chunk\n let pos = this.#pos\n if (!chunk || pos === chunk.length) {\n chunk = this.#chunk = this.#queue.shift()\n pos = this.#pos = 0\n if (!chunk) {\n if (!this.#ended || this.#done === 2) return undefined\n const ev = this.#finish()\n if (ev) return ev\n }\n continue\n }\n const avail = chunk.length - pos\n const state = this.#state\n\n if (state <= HEADER) {\n let ev: ParseEvent<E> | undefined\n if (this.#blockLen === 0 && avail >= 512) {\n this.#pos = pos + 512\n ev = this.#consumeHeader(chunk, pos)\n } else {\n const block = (this.#block ??= new Uint8Array(512))\n const n = Math.min(512 - this.#blockLen, avail)\n block.set(chunk.subarray(pos, pos + n), this.#blockLen)\n this.#pos = pos + n\n this.#blockLen += n\n if (this.#blockLen < 512) continue\n this.#blockLen = 0\n ev = this.#consumeHeader(block, 0)\n }\n if (ev) return ev\n continue\n }\n\n const blockRemain = this.#blockRemain\n const n = avail < blockRemain ? avail : blockRemain\n const remain = this.#remain\n const len = n < remain ? n : remain\n this.#pos = pos + n\n this.offset += n\n this.#blockRemain = blockRemain - n\n this.#remain = remain - len\n const last = n === blockRemain\n\n if (state === META) {\n const meta = this.#meta as Uint8Array\n meta.set(chunk.subarray(pos, pos + len), this.#metaLen)\n this.#metaLen += len\n if (last) {\n this.#endBody()\n this.#applyMeta(meta)\n }\n continue\n }\n if (last) this.#endBody()\n if (state === IGNORE) continue\n if (len === 0) {\n if (last) return ENTRY_END\n continue\n }\n this.#entryEnd = last\n return {\n type: 'body',\n data:\n len === chunk.length ? chunk : chunk.subarray(pos, pos + len),\n }\n }\n }\n\n #endBody() {\n const entry = this.#entry\n if (entry) {\n this.position = this.offset\n this.#entry = undefined\n }\n if (!entry?.invalid) this.#sawValid = true\n this.#state = HEADER\n }\n\n // The input is complete, and all of it is read.\n #finish(): ParseEvent<E> | undefined {\n const state = this.#state\n if (state > HEADER) {\n // The body of the last entry is not complete.\n const entry = this.#entry\n // The bytes of the last block of the input, which is not\n // complete, and the bytes from the start of that block to the\n // end of the body. The chunks of the input do not change them.\n const held = (512 - (this.#blockRemain % 512)) % 512\n const need = this.#blockRemain + held\n this.#entry = undefined\n this.#meta = undefined\n this.#state = HEADER\n if (!entry?.invalid) this.#sawValid = true\n this.#entryEnd = state === BODY\n this.warn(\n 'TAR_BAD_ARCHIVE',\n `Truncated input (needed ${need} more bytes, only ${held} available)`,\n { entry, header: this.#header },\n )\n return undefined\n }\n if (this.#entryEnd) {\n this.#entryEnd = false\n return ENTRY_END\n }\n if (this.#done === 0) {\n this.#done = 1\n if (state === BEGIN || this.#sawValid === false) {\n // Less than one block of data, or no valid entry.\n this.warn('TAR_BAD_ARCHIVE', 'Unrecognized archive format')\n }\n }\n this.#done = 2\n return END\n }\n\n #consumeHeader(buf: Uint8Array, off: number): ParseEvent<E> | undefined {\n this.offset += 512\n if (this.#sawValid === undefined) this.#sawValid = false\n // A PAX name wins over a GNU long name. The header does not use\n // these values if it is a PAX or GNU header itself.\n let ex = this.#ex\n const longPath = this.#longPath\n const longLinkpath = this.#longLinkpath\n if (longPath !== undefined || longLinkpath !== undefined) {\n ex = Object.assign(Object.create(null) as Pax, ex)\n ex.path ??= longPath\n ex.linkpath ??= longLinkpath\n }\n let header: Header\n try {\n header = new Header(buf, off, ex, this.#gex)\n } catch (er) {\n this.warn('TAR_ENTRY_INVALID', er as Error)\n return\n }\n\n if (header.nullBlock) {\n // A null block is the end of the archive, as it is for bsdtar.\n // A second null block normally comes after it. All the data\n // after the first one is dropped, so an entry there is not\n // read.\n this.#ended = true\n this.#chunk = undefined\n this.#queue.length = 0\n this.#blockLen = 0\n // The input is not shorter than one block. An archive with no\n // valid entry still gets the warning of `#finish`.\n this.#state = HEADER\n return\n }\n\n if (!header.cksumValid) {\n this.warn('TAR_ENTRY_INVALID', 'checksum failure', { header })\n return\n }\n if (!header.path) {\n this.warn('TAR_ENTRY_INVALID', 'path is required', { header })\n return\n }\n const type = header.type\n const link = type === 'Link' || type === 'SymbolicLink'\n if (link && !header.linkpath) {\n this.warn('TAR_ENTRY_INVALID', 'linkpath required', { header })\n return\n }\n if (\n !link &&\n header.linkpath &&\n type !== 'ExtendedHeader' &&\n type !== 'GlobalExtendedHeader'\n ) {\n this.warn('TAR_ENTRY_INVALID', 'linkpath forbidden', { header })\n return\n }\n\n const size = header.size ?? 0\n this.#header = header\n this.#remain = size\n this.#blockRemain = 512 * Math.ceil(size / 512)\n // A meta entry or an ignored entry is valid tar also.\n if (!size) this.#sawValid = true\n\n if (metaTypes.has(type)) {\n if (size > this.maxMetaEntrySize) {\n this.#state = IGNORE\n } else if (size > 0) {\n this.#meta = new Uint8Array(size)\n this.#metaLen = 0\n this.#state = META\n }\n return\n }\n\n this.#ex = this.#longPath = this.#longLinkpath = undefined\n const entry = this.#create(header, ex, this.#gex)\n if (\n !entry.ignore &&\n this.#filter &&\n !this.#filter(entry.path, entry)\n ) {\n entry.ignore = true\n }\n if (size) {\n this.#entry = entry\n this.#state = entry.ignore ? IGNORE : BODY\n } else {\n this.#state = HEADER\n this.position = this.offset\n this.#entryEnd = !entry.ignore\n }\n return { type: 'entry', entry }\n }\n\n #applyMeta(meta: Uint8Array) {\n switch ((this.#header as Header).type) {\n case 'ExtendedHeader':\n case 'OldExtendedHeader':\n this.#ex = Pax.parseBytes(meta, this.#ex, false)\n break\n case 'GlobalExtendedHeader':\n this.#gex = Pax.parseBytes(meta, this.#gex, true)\n break\n // The last GNU long name of each kind is the one to use.\n case 'NextFileHasLongPath':\n case 'OldGnuLongPath':\n this.#longPath = cstring(meta)\n break\n // NextFileHasLongLinkpath\n default:\n this.#longLinkpath = cstring(meta)\n }\n }\n}\n", "import type { TarFS, TarFSSync } from './fs.js'\nimport { countOption } from './options.js'\n\nconst MAX_READ = 16 * 1024 * 1024\n// The size of the first read, and of the read after a skip.\nconst FIRST_READ = 64 * 1024\n// A skip of fewer bytes than this is slower than a read of them.\nconst MIN_SKIP = 1024 * 1024\n\n/**\n * The key of the method of a chunk source that skips input. A\n * `TarReader` calls it with the number of bytes of a body that are\n * after the chunks given so far, when no consumer reads that body.\n * If it returns true, the next chunk starts after those bytes.\n */\nexport const SKIP: unique symbol = Symbol.for('tar.readFile.skip')\n\n/** A chunk source that can skip input. */\nexport type Skip = { [SKIP](n: number): boolean }\n\n// The place and the size of the next read of a file.\nclass Plan {\n pos: number = 0\n /** The size of the file. 0 before the file is open. */\n size: number = 0\n #max: number\n #want: number = FIRST_READ\n\n constructor(maxReadSize: number | undefined) {\n this.#max = countOption('maxReadSize', maxReadSize, MAX_READ)\n }\n\n // The number of bytes to read at `pos`. 0 at the end of the file.\n // Each read is two times the size of the read before it, so that\n // an archive of small entries is read in few reads.\n next(): number {\n const n = Math.min(this.#want, this.#max, this.size - this.pos)\n this.#want *= 2\n return n\n }\n\n // Skip only inside the file: the parser must see where a truncated\n // file ends. The read after a skip is small, because a header\n // comes next, and the body after it can be skipped also.\n skip(n: number): boolean {\n if (n < MIN_SKIP || this.pos + n > this.size) return false\n this.pos += n\n this.#want = FIRST_READ\n return true\n }\n}\n\nasync function* chunks(\n fs: TarFS,\n file: string,\n plan: Plan,\n): AsyncGenerator<Uint8Array, void, void> {\n const handle = await fs.open(file, 'r')\n try {\n plan.size = (await handle.stat()).size\n for (let n; (n = plan.next()); ) {\n const buf = new Uint8Array(n)\n const { bytesRead } = await handle.read(buf, 0, n, plan.pos)\n if (!bytesRead) break\n plan.pos += bytesRead\n yield bytesRead < n ? buf.subarray(0, bytesRead) : buf\n }\n } finally {\n await handle.close().catch(() => {})\n }\n}\n\nfunction* chunksSync(\n fs: TarFSSync,\n file: string,\n plan: Plan,\n): Generator<Uint8Array, void, void> {\n const fd = fs.openSync(file, 'r')\n try {\n plan.size = fs.fstatSync(fd).size\n for (let n; (n = plan.next()); ) {\n const buf = new Uint8Array(n)\n const bytesRead = fs.readSync(fd, buf, 0, n, plan.pos)\n if (!bytesRead) break\n plan.pos += bytesRead\n yield bytesRead < n ? buf.subarray(0, bytesRead) : buf\n }\n } finally {\n try {\n fs.closeSync(fd)\n } catch {}\n }\n}\n\n/**\n * Read a file in chunks of `maxReadSize` bytes at most. The default,\n * and the value for 0, is 16 MiB. Each chunk is a new array. The\n * first chunk is small, and the chunks grow. A reader can skip a\n * large part of the file.\n */\nexport const readFile = (\n fs: TarFS,\n file: string,\n maxReadSize?: number,\n): AsyncGenerator<Uint8Array, void, void> & Skip => {\n const plan = new Plan(maxReadSize)\n return Object.assign(chunks(fs, file, plan), {\n [SKIP]: (n: number) => plan.skip(n),\n })\n}\n\n/** The sync form of `readFile`. */\nexport const readFileSync = (\n fs: TarFSSync,\n file: string,\n maxReadSize?: number,\n): Generator<Uint8Array, void, void> & Skip => {\n const plan = new Plan(maxReadSize)\n return Object.assign(chunksSync(fs, file, plan), {\n [SKIP]: (n: number) => plan.skip(n),\n })\n}\n", "import {\n isArrayBuffer,\n isBlob,\n isReadableStream,\n isUint8Array,\n} from './bytes.js'\nimport { Header } from './header.js'\nimport { gzip, type Codec } from './codec.js'\nimport { concat } from './concat.js'\nimport {\n ownOptions,\n type ReadOptions,\n type ReadOptionsSync,\n type TarInput,\n type TarInputSync,\n} from './options.js'\nimport { Parser } from './parser.js'\nimport {\n ReadEntry,\n ReadEntrySync,\n type BodySource,\n type BodySourceSync,\n type EntryData,\n} from './read-entry.js'\nimport { SKIP, type Skip } from './read-file.js'\nimport { tarError } from './warn.js'\n\nconst noop = () => {}\n\n// A source of input chunks: an iterator, or the reader of a stream.\ntype Source = Partial<Skip> & {\n next():\n | IteratorResult<Uint8Array, unknown>\n | Promise<IteratorResult<Uint8Array, unknown>>\n return?(): unknown\n}\ntype SourceSync = Iterator<Uint8Array, unknown> & Partial<Skip>\n\n// The number of bytes to read before the choice of a codec.\nexport const headLength = (codecs: Codec[]) =>\n Math.max(512, ...codecs.map(c => c.headLength))\n\nconst isTar = (head: Uint8Array) => {\n try {\n const header = new Header(head)\n return header.cksumValid || header.nullBlock\n } catch {\n return false\n }\n}\n\nexport const findCodec = (\n codecs: Codec[],\n head: Uint8Array,\n file: string = '',\n): Codec | undefined =>\n codecs.find(c => c.detect(head)) ??\n (isTar(head) ? undefined : (\n codecs.find(c => c.extensions?.some(x => file.endsWith(x)))\n ))\n\nconst maxRatio = (opt: ReadOptions<never>) =>\n typeof opt.maxDecompressionRatio === 'number' ?\n opt.maxDecompressionRatio\n : 1000\n\nconst abort = (opt: ReadOptions<never>, er: Error) =>\n tarError(opt, 'TAR_ABORT', er, { recoverable: false })\n\nconst ratioError = (opt: ReadOptions<never>, ratio: number, max: number) =>\n abort(\n opt,\n new Error(\n `max decompression ratio exceeded: ${ratio.toFixed(2)} > ${max}`,\n ),\n )\n\nconst notCurrent = () =>\n new TypeError('The body of an entry cannot be read after a later entry')\n\n/**\n * Gets entries and the parts of their bodies from a `Parser`. The\n * readers use it. It does not read input.\n */\nexport class EntryCursor<E extends EntryData> {\n parser: Parser<E>\n /** The entry that has a body to read now. */\n current?: E\n /** True after the end of the archive. */\n ended: boolean = false\n\n constructor(parser: Parser<E>) {\n this.parser = parser\n }\n\n /**\n * The next entry that is not ignored. `null` at the end of the\n * archive. `undefined` if the parser needs more input. The rest of\n * the body of the entry before it is skipped.\n */\n entry(): E | null | undefined {\n this.current = undefined\n if (this.ended) return null\n for (let ev; (ev = this.parser.next()); ) {\n if (ev.type === 'end') {\n this.ended = true\n return null\n }\n if (ev.type === 'entry' && !ev.entry.ignore) {\n return (this.current = ev.entry)\n }\n }\n }\n\n /**\n * The next part of the body of `entry`. `null` at the end of the\n * body. `undefined` if the parser needs more input.\n */\n body(entry: E): Uint8Array | null | undefined {\n if (entry !== this.current) throw notCurrent()\n const ev = this.parser.next()\n if (!ev) return undefined\n if (ev.type === 'body') return ev.data\n this.current = undefined\n return null\n }\n}\n\n// Skip the rest of a body that no consumer reads, if it is after the\n// input that the parser has, and the source can skip it. The source\n// must be the input of the reader: decompressed data has no place in\n// the input.\nconst skipBody = <E extends EntryData>(\n cursor: EntryCursor<E>,\n source: Partial<Skip>,\n) => {\n if (cursor.current) return\n const n = cursor.parser.bodyRemain\n if (n && source[SKIP]?.(n)) cursor.parser.skipBody()\n}\n\nconst toSource = (input: TarInput): Source => {\n if (isUint8Array(input)) return [input].values()\n if (isArrayBuffer(input)) return [new Uint8Array(input)].values()\n if (isBlob(input)) input = input.stream()\n if (isReadableStream(input)) {\n const reader = input.getReader()\n return { next: () => reader.read(), return: () => reader.cancel() }\n }\n return Symbol.asyncIterator in input ?\n input[Symbol.asyncIterator]()\n : input[Symbol.iterator]()\n}\n\n/**\n * Reads the entries of an archive from async input. It is the\n * iterator that `entries()` returns.\n *\n * Input is read only when the consumer asks for the next entry or\n * for more of a body. `poll()` and `fill()` do the same work as\n * `next()`, with no promise for an entry that is in memory.\n */\nexport class TarReader\n implements AsyncIterableIterator<ReadEntry, undefined>, BodySource\n{\n parser: Parser<ReadEntry>\n #cursor: EntryCursor<ReadEntry>\n #opt: ReadOptions\n #input: Source\n #source?: Source\n // the first bytes of input that is not compressed\n #head?: Uint8Array\n #filling?: Promise<void>\n #done: boolean = false\n\n constructor(input: TarInput, opt: ReadOptions = {}) {\n opt = ownOptions(opt)\n const win32 = opt.platform === 'win32'\n this.parser = new Parser<ReadEntry>(\n opt,\n (header, ex, gex) => new ReadEntry(header, ex, gex, win32, this),\n )\n this.#cursor = new EntryCursor(this.parser)\n this.#opt = opt\n this.#input = toSource(input)\n }\n\n /**\n * The next entry, if it is in memory. `null` at the end of the\n * archive. `undefined` if more input is needed: then await `fill()`\n * and call this again.\n */\n poll(): ReadEntry | null | undefined {\n return this.#done ? null : this.#cursor.entry()\n }\n\n readBody(entry: ReadEntry): Uint8Array | null | undefined {\n return this.#cursor.body(entry)\n }\n\n /** Read one chunk of input, and give it to the parser. */\n fill(): Promise<void> {\n return (this.#filling ??= this.#fill())\n }\n\n async #fill() {\n try {\n const source = (this.#source ??= await this.#open(this.#input))\n const head = this.#head\n this.#head = undefined\n if (source === this.#input) skipBody(this.#cursor, source)\n const res = head ? { value: head, done: false } : await source.next()\n if (res.done) this.parser.end()\n else this.parser.push(res.value)\n } finally {\n this.#filling = undefined\n }\n }\n\n // Read the first bytes, and add the decompression if they need it.\n async #open(input: Source): Promise<Source> {\n const opt = this.#opt\n const codecs = [...(opt.codecs ?? []), gzip]\n const need = headLength(codecs)\n let head: Uint8Array | undefined\n while (!head || head.length < need) {\n const res = await input.next()\n if (res.done) break\n head = head ? concat([head, res.value]) : res.value\n }\n const codec = head && findCodec(codecs, head, opt.file)\n if (!codec) {\n this.#head = head\n return input\n }\n let compressed = 0\n let decompressed = 0\n const { readable, writable } = codec.decompress()\n const writer = writable.getWriter()\n const reader = readable.getReader()\n let stopped = false\n // Give the input to the codec, as fast as the codec takes it. This\n // loop holds each promise of the writer, so that a write that\n // fails after the consumer stops is not an unhandled rejection.\n const feed = async () => {\n try {\n for (;;) {\n await writer.ready\n if (stopped) return\n const res =\n head ? { value: head, done: false } : await input.next()\n head = undefined\n if (stopped) return\n if (res.done) return await writer.close()\n compressed += res.value.length\n await writer.write(res.value)\n }\n } catch (er) {\n // An error of the input goes to the reader of the output. An\n // error of the codec is there already.\n if (!stopped) await writer.abort(er).catch(noop)\n }\n }\n void feed()\n const max = maxRatio(opt)\n return {\n next: async () => {\n const res = await reader.read().catch(er => {\n throw abort(opt, er as Error)\n })\n if (!res.done) {\n decompressed += res.value.length\n const ratio = decompressed / compressed\n if (ratio > max) throw ratioError(opt, ratio, max)\n }\n return res\n },\n return: async () => {\n stopped = true\n await reader.cancel().catch(noop)\n await writer.abort().catch(noop)\n await input.return?.()\n return { value: undefined, done: true }\n },\n }\n }\n\n async next(): Promise<IteratorResult<ReadEntry, undefined>> {\n try {\n for (;;) {\n const entry = this.poll()\n if (entry) return { value: entry, done: false }\n if (entry === null) break\n await this.fill()\n }\n } catch (er) {\n await this.return()\n throw er\n }\n return this.return()\n }\n\n /** Stop reading, and release the input. */\n async return(): Promise<IteratorResult<ReadEntry, undefined>> {\n if (!this.#done) {\n this.#done = true\n this.#cursor.current = undefined\n await (this.#source ?? this.#input).return?.()\n }\n return { value: undefined, done: true }\n }\n\n [Symbol.asyncIterator](): this {\n return this\n }\n}\n\n/**\n * Reads the entries of an archive from sync input. It is the\n * iterator that `entriesSync()` returns.\n */\nexport class TarReaderSync\n implements IterableIterator<ReadEntrySync, undefined>, BodySourceSync\n{\n parser: Parser<ReadEntrySync>\n #cursor: EntryCursor<ReadEntrySync>\n #opt: ReadOptionsSync\n #input: SourceSync\n #source?: SourceSync\n // the first bytes of input that is not compressed\n #head?: Uint8Array\n #done: boolean = false\n\n constructor(input: TarInputSync, opt: ReadOptionsSync = {}) {\n opt = ownOptions(opt)\n const win32 = opt.platform === 'win32'\n this.parser = new Parser<ReadEntrySync>(\n opt,\n (header, ex, gex) => new ReadEntrySync(header, ex, gex, win32, this),\n )\n this.#cursor = new EntryCursor(this.parser)\n this.#opt = opt\n this.#input =\n isUint8Array(input) ? [input].values()\n : isArrayBuffer(input) ? [new Uint8Array(input)].values()\n : input[Symbol.iterator]()\n }\n\n readBody(entry: ReadEntrySync): Uint8Array | null {\n for (;;) {\n const part = this.#cursor.body(entry)\n if (part !== undefined) return part\n this.#fill()\n }\n }\n\n #fill() {\n const source = (this.#source ??= this.#open(this.#input))\n const head = this.#head\n this.#head = undefined\n if (source === this.#input) skipBody(this.#cursor, source)\n const res = head ? { value: head, done: false } : source.next()\n if (res.done) this.parser.end()\n else this.parser.push(res.value)\n }\n\n // Read the first bytes. If they are compressed, read and decompress\n // all the input.\n #open(input: SourceSync): SourceSync {\n const opt = this.#opt\n const codecs = [...(opt.codecs ?? []), gzip]\n const need = headLength(codecs)\n let head: Uint8Array | undefined\n let res: IteratorResult<Uint8Array, unknown>\n while ((!head || head.length < need) && !(res = input.next()).done) {\n head = head ? concat([head, res.value]) : res.value\n }\n const codec = head && findCodec(codecs, head, opt.file)\n if (!head || !codec) {\n this.#head = head\n return input\n }\n const { decompressSync } = codec\n if (!decompressSync) {\n throw abort(\n opt,\n new Error(\n `the ${codec.name} codec has no decompressSync function`,\n ),\n )\n }\n const parts = [head]\n while (!(res = input.next()).done) parts.push(res.value)\n const data = concat(parts)\n const max = maxRatio(opt)\n let out: Uint8Array\n try {\n out = decompressSync(data, { maxOutputLength: data.length * max })\n } catch (er) {\n throw abort(opt, er as Error)\n }\n const ratio = out.length / data.length\n if (ratio > max) throw ratioError(opt, ratio, max)\n return [out].values()\n }\n\n next(): IteratorResult<ReadEntrySync, undefined> {\n try {\n for (;;) {\n const entry = this.#done ? null : this.#cursor.entry()\n if (entry) return { value: entry, done: false }\n if (entry === null) break\n this.#fill()\n }\n } catch (er) {\n this.return()\n throw er\n }\n return this.return()\n }\n\n /** Stop reading, and release the input. */\n return(): IteratorResult<ReadEntrySync, undefined> {\n if (!this.#done) {\n this.#done = true\n this.#cursor.current = undefined\n ;(this.#source ?? this.#input).return?.()\n }\n return { value: undefined, done: true }\n }\n\n [Symbol.iterator](): this {\n return this\n }\n}\n\n/**\n * Read the entries of an archive. Gzip input is decompressed.\n *\n * Read the body of an entry before the next entry: when the iterator\n * moves on, the rest of the body is skipped.\n */\nexport const entries = (\n input: TarInput,\n opt?: ReadOptions,\n): AsyncIterableIterator<ReadEntry, undefined> => new TarReader(input, opt)\n\n/**\n * Read the entries of an archive with no promises. Compressed input\n * needs a codec with a `decompressSync` function in `opt.codecs`.\n */\nexport const entriesSync = (\n input: TarInputSync,\n opt?: ReadOptionsSync,\n): IterableIterator<ReadEntrySync, undefined> =>\n new TarReaderSync(input, opt)\n", "export const modeFix = (\n mode: number,\n isDir: boolean,\n portable: boolean,\n) => {\n mode &= 0o7777\n\n // in portable mode, use the minimum reasonable umask\n // if this system creates files with 0o664 by default\n // (as some linux distros do), then we'll write the\n // archive with 0o644 instead. Also, don't ever create\n // a file that is not readable/writable by the owner.\n if (portable) {\n mode = (mode | 0o600) & ~0o22\n }\n\n // if dirs are readable, then they should be listable\n if (isDir) {\n if (mode & 0o400) {\n mode |= 0o100\n }\n if (mode & 0o40) {\n mode |= 0o10\n }\n if (mode & 0o4) {\n mode |= 0o1\n }\n }\n return mode\n}\n", "// When writing files on Windows, translate the characters to their\n// 0xf000 higher-encoded versions.\n\nconst raw = ['|', '<', '>', '?', ':']\n\nconst win = raw.map(char =>\n String.fromCodePoint(0xf000 + Number(char.codePointAt(0))),\n)\n\nconst toWin = new Map(raw.map((char, i) => [char, win[i]]))\nconst toRaw = new Map(win.map((char, i) => [char, raw[i]]))\n\nexport const encode = (s: string) =>\n raw.reduce((s, c) => s.split(c).join(toWin.get(c)), s)\nexport const decode = (s: string) =>\n win.reduce((s, c) => s.split(c).join(toRaw.get(c)), s)\n", "// The path rules of Windows that the extraction needs. Each function\n// takes a path with `/` or `\\` separators.\n\nimport { dirname, resolve } from './path.js'\n\nconst isSep = (code: number) => code === 47 || code === 92\n\nconst isDrive = (code: number) =>\n (code >= 65 && code <= 90) || (code >= 97 && code <= 122)\n\n/**\n * The root of a path: a slash, a drive such as `c:` or `c:/`, or a\n * UNC root such as `//host/share/`. The same result as the `root` of\n * `path.win32.parse`.\n */\nexport const win32Root = (path: string): string => {\n const len = path.length\n let end = 0\n if (isSep(path.charCodeAt(0))) {\n end = 1\n if (isSep(path.charCodeAt(1))) {\n // `//host/share` and what follows it\n let j = 2\n let last = j\n while (j < len && !isSep(path.charCodeAt(j))) j++\n if (j < len && j !== last) {\n last = j\n while (j < len && isSep(path.charCodeAt(j))) j++\n if (j < len && j !== last) {\n last = j\n while (j < len && !isSep(path.charCodeAt(j))) j++\n if (j === len) end = j\n else if (j !== last) end = j + 1\n }\n }\n }\n } else if (isDrive(path.charCodeAt(0)) && path.charCodeAt(1) === 58) {\n end = isSep(path.charCodeAt(2)) ? 3 : 2\n }\n return path.slice(0, end)\n}\n\n/** True for a path with a root that is not relative to a drive. */\nexport const win32IsAbsolute = (path: string): boolean =>\n isSep(path.charCodeAt(0)) || win32Root(path).length === 3\n\n/**\n * Resolve `path` from the absolute path `base`. Both have `/`\n * separators.\n */\nexport const win32Resolve = (base: string, path: string): string => {\n const full = win32IsAbsolute(path) ? path : base + '/' + path\n const root = win32Root(full)\n return root + resolve('/', full.slice(root.length)).slice(1)\n}\n\n/** The parent directory of an absolute path with `/` separators. */\nexport const win32Dirname = (path: string): string => {\n const root = win32Root(path)\n const dir = dirname(path.slice(root.length))\n return dir === '.' ? root : root + dir\n}\n", "import { win32Root } from './win32-path.js'\n\n/**\n * Remove each root from the start of a path. Returns the roots and\n * the rest of the path.\n *\n * A POSIX absolute path is also absolute on Windows, so the rules of\n * Windows are used on each platform. A path that is relative to a\n * drive loses the drive: `c:../foo` gives `['c:', '../foo']`.\n */\nexport const stripAbsolutePath = (path: string): [string, string] => {\n let roots = ''\n for (let root; (root = win32Root(path)); ) {\n // Windows reads `//x/y/` as the root of `//x/y/z`. Remove only the\n // first slash, but remove all of `//?/c:/`.\n if (path.charAt(0) === '/' && path.slice(0, 4) !== '//?/') root = '/'\n path = path.slice(root.length)\n roots += root\n }\n return [roots, path]\n}\n", "/**\n * Make a stream of the chunks of an iterator. It asks the iterator\n * for a chunk only when a consumer reads the stream. A cancel of the\n * stream calls `return()` of the iterator.\n */\nexport const toStream = (\n chunks: AsyncIterator<Uint8Array, unknown>,\n): ReadableStream<Uint8Array> =>\n new ReadableStream<Uint8Array>(\n {\n pull: async controller => {\n const res = await chunks.next()\n if (res.done) controller.close()\n else controller.enqueue(res.value)\n },\n cancel: async () => {\n await chunks.return?.()\n },\n },\n { highWaterMark: 0 },\n )\n", "// warning: extremely hot code path.\n// This has been meticulously optimized for use\n// within npm install on large package trees.\n// Do not edit without careful benchmarking.\nexport const stripTrailingSlashes = (str: string) => {\n let i = str.length - 1\n let slashesStart = -1\n while (i > -1 && str.charAt(i) === '/') {\n slashesStart = i\n i--\n }\n return slashesStart === -1 ? str : str.slice(0, slashesStart)\n}\n", "import { isBlob, isUint8Array } from './bytes.js'\nimport { Header } from './header.js'\nimport { ownOptions } from './options.js'\nimport { Pax } from './pax.js'\nimport { stripTrailingSlashes } from './strip-trailing-slashes.js'\nimport type { EntryTypeName } from './types.js'\n\n/**\n * The content of a `WriteEntry`. `PackSync` takes only a string, a\n * `Uint8Array`, or a sync iterable.\n */\nexport type WriteBody =\n | string\n | Uint8Array\n | Blob\n | ReadableStream<Uint8Array>\n | AsyncIterable<Uint8Array>\n | Iterable<Uint8Array>\n\n/** The metadata of a `WriteEntry`. A `ReadEntry` fits this type. */\nexport type WriteEntryData = {\n path: string\n /** Default `'File'`. */\n type?: EntryTypeName\n mode?: number\n uid?: number\n gid?: number\n uname?: string\n gname?: string\n /**\n * The number of bytes in the body. Default: the length of a body\n * that is a string, a `Uint8Array`, or a `Blob`.\n */\n size?: number\n mtime?: Date\n atime?: Date\n ctime?: Date\n linkpath?: string\n dev?: number\n ino?: number\n nlink?: number\n}\n\n/** The options of `WriteEntry.encode`. */\nexport type EncodeOptions = {\n /** A directory to put before the path, and before a hard link target. */\n prefix?: string\n /** Write no PAX header for a field that does not fit the header. */\n noPax?: boolean\n}\n\nconst encoder = new TextEncoder()\n\nconst prefixPath = (path: string, prefix?: string) =>\n prefix ?\n stripTrailingSlashes(prefix) + '/' + path.replace(/^\\.(\\/|$)/, '')\n : path\n\n/**\n * An entry to write to an archive, in the shape of a `Request`: the\n * metadata is in the fields, and the content is `body`.\n *\n * A pack makes one for each path that it reads from the file system\n * and for each entry that it copies from another archive. Make one\n * with content from memory, and give it to `Pack.add()`.\n *\n * `onWriteEntry` gets the entry before its header is written, and can\n * change each field.\n */\nexport class WriteEntry {\n path: string\n type: EntryTypeName\n /** The permission bits only. */\n mode?: number\n uid?: number\n gid?: number\n uname?: string\n gname?: string\n /** The number of bytes in the body. The body must have this many. */\n size: number\n mtime?: Date\n atime?: Date\n ctime?: Date\n linkpath?: string\n dev?: number\n ino?: number\n nlink?: number\n /** The content. A string is kept as its UTF-8 bytes. */\n body?: Exclude<WriteBody, string>\n /** The path of the file, for an entry that a pack read from a path. */\n absolute?: string\n /** The header block, after `encode()`. */\n header?: Header\n\n constructor(data: WriteEntryData, body?: WriteBody) {\n if ((data.type as string) === 'Unsupported') {\n throw new Error('writing entry that should be ignored')\n }\n if (typeof body === 'string') body = encoder.encode(body)\n this.path = data.path\n this.type = data.type ?? 'File'\n this.mode = data.mode\n this.uid = data.uid\n this.gid = data.gid\n this.uname = data.uname\n this.gname = data.gname\n if (\n data.size === undefined &&\n body !== undefined &&\n !isUint8Array(body) &&\n !isBlob(body)\n ) {\n // The header comes before the content, and it has the size.\n throw new TypeError('a stream body needs the size option')\n }\n this.size =\n data.size ??\n (isUint8Array(body) ? body.length\n : isBlob(body) ? body.size\n : 0)\n this.mtime = data.mtime\n this.atime = data.atime\n this.ctime = data.ctime\n this.linkpath = data.linkpath\n this.dev = data.dev\n this.ino = data.ino\n this.nlink = data.nlink\n this.body = body\n }\n\n /**\n * Make the header from the fields, and write it to the first 512\n * bytes of `block`, which must be zeros. Returns the blocks to\n * write before the body: `block`, and before it a PAX header entry\n * if a field does not fit the header.\n */\n encode(\n opt: EncodeOptions = {},\n block: Uint8Array = new Uint8Array(512),\n ): Uint8Array[] {\n opt = ownOptions(opt)\n const path = prefixPath(this.path, opt.prefix)\n // The target of a symbolic link is not a path in the archive.\n const linkpath =\n this.type === 'Link' && this.linkpath !== undefined ?\n prefixPath(this.linkpath, opt.prefix)\n : this.linkpath\n const { uid, gid, uname, gname, size, mtime, atime, ctime } = this\n this.header = new Header({\n path,\n linkpath,\n mode: this.mode,\n uid,\n gid,\n size,\n mtime,\n type: this.type,\n uname,\n gname,\n atime,\n ctime,\n })\n if (!this.header.encode(block) || opt.noPax) return [block]\n const { dev, ino, nlink } = this\n return [\n new Pax({\n atime,\n ctime,\n gid,\n gname,\n mtime,\n path,\n linkpath,\n size,\n uid,\n uname,\n dev,\n ino,\n nlink,\n }).encode(),\n block,\n ]\n }\n}\n", "import { isBlob, isReadableStream, isUint8Array } from './bytes.js'\nimport { modeFix } from './mode-fix.js'\nimport type { EntryTypeName } from './types.js'\nimport * as winchars from './winchars.js'\nimport { gzip, type Codec, type CodecStream } from './codec.js'\nimport { concat } from './concat.js'\nimport type {\n CreateFileHandle,\n CreateFS,\n CreateFSSync,\n CreateStats,\n FileId,\n} from './fs.js'\nimport {\n countOption,\n ownOptions,\n type PackOptions,\n type PackOptionsBase,\n type PackOptionsSync,\n} from './options.js'\nimport { isAbsolute, relative, resolve } from './path.js'\nimport type { ReadEntry, ReadEntrySync } from './read-entry.js'\nimport { stripAbsolutePath } from './strip-absolute-path.js'\nimport { toStream } from './to-stream.js'\nimport { warn } from './warn.js'\nimport { win32IsAbsolute, win32Resolve } from './win32-path.js'\nimport { WriteEntry, type EncodeOptions } from './write-entry.js'\n\nconst MAX_READ = 16 * 1024 * 1024\nconst noop = () => {}\n\nconst blockLength = (size: number) => 512 * Math.ceil(size / 512)\nconst slashes = (path: string) => path.replaceAll('\\\\', '/')\n// The identity of a file: a key for a `Map`, and a value to compare.\n// The key of two `bigint` values is the key of the same two numbers.\nconst idOf = (id: FileId) => `${id.dev}:${id.ino}`\nconst BIG = { bigint: true } as const\n// Node.js gives `dev` and `ino` as numbers. A value that is not a\n// safe integer can be the value of more than one file. On NTFS, most\n// `ino` values are not safe integers.\nconst lossy = ({ dev, ino }: { dev: number; ino: number }) =>\n !Number.isSafeInteger(dev) || !Number.isSafeInteger(ino)\n// True if the path is still the object of its stat. The numbers are\n// enough here: one object always gives the same numbers, so numbers\n// that are not exact give no false alarm, and need no second stat.\nconst same = (\n a: { dev: number; ino: number },\n b: { dev: number; ino: number },\n) => a.dev === b.dev && a.ino === b.ino\n\nconst eof = (message: string, path: string) =>\n Object.assign(new Error(message), { path, syscall: 'read', code: 'EOF' })\n// The file does not have the number of bytes that its stat gave.\nconst fewer = (path: string, size: number) =>\n eof(\n `encountered unexpected EOF: ${path} has fewer than the ${size} bytes of its stat`,\n path,\n )\nconst more = (path: string, size: number) =>\n eof(\n `did not encounter expected EOF: ${path} has more than the ${size} bytes of its stat`,\n path,\n )\nconst pathOf = (entry: WriteEntry) => entry.absolute ?? entry.path\nconst tooLong = (entry: WriteEntry) =>\n Object.assign(new Error('writing more data than expected'), {\n path: pathOf(entry),\n })\n\n// The package has more than one copy of each class: the entry points\n// `tar` and `tar/core` are separate bundles, and each has an ESM and\n// a CommonJS build. `instanceof` is false for an entry of a different\n// copy, so these checks use the shape of the item. A `PackJob` is\n// always of this copy, because only the pack makes it.\n\n// A source of entries is an iterable. An entry is not.\nconst isSource = (\n item: object,\n): item is AsyncIterable<unknown> | Iterable<unknown> =>\n Symbol.asyncIterator in item || Symbol.iterator in item\n\n// A `WriteEntry` can encode its header. An entry of an archive\n// cannot.\nconst isWriteEntry = (item: object): item is WriteEntry =>\n typeof (item as WriteEntry).encode === 'function'\n\n/** A directory above a path, when a pack follows symbolic links. */\nexport type Ancestor = { key: string; up?: Ancestor }\n\n/** What `Pack` reads for a path before it writes the entry. */\nexport type PackLoad = {\n stat: CreateStats\n /** The identity of the object: the stat, or exact `dev` and `ino`. */\n id: FileId\n type: EntryTypeName\n /** The target of a symbolic link. */\n linkpath?: string\n /** The names in a directory. */\n names?: string[]\n /** A file of `maxReadSize` bytes or less, after 512 bytes of zeros. */\n buf?: Uint8Array\n /** A larger file. */\n handle?: CreateFileHandle\n /** The path is a different object now. The pack skips it. */\n changed?: boolean\n}\n\n/** A path in the queue of a pack. */\nexport class PackJob {\n path: string\n absolute: string\n /** The directories above it, when the pack follows symbolic links. */\n up?: Ancestor\n /** The target, when the pack writes the file as a hard link. */\n linkpath?: string\n /** Set when `Pack` starts to read the path. */\n ready?: Promise<PackLoad | undefined>\n\n constructor(path: string, absolute: string) {\n this.path = path\n this.absolute = absolute\n }\n}\n\n/** One item of the queue of a pack, and the item after it. */\nexport type QueueNode<T> = { item: T; next?: QueueNode<T> }\n\n/**\n * The parts of `Pack` and `PackSync` that are the same: the options,\n * the queue, and the rules that make an entry from a path or from an\n * entry of another archive.\n */\nexport abstract class PackBase<\n FS,\n E extends ReadEntry | ReadEntrySync,\n S extends object,\n> {\n opt: PackOptionsBase<E>\n fs?: FS\n /** The normalized form of `opt.cwd`. */\n cwd?: string\n win32: boolean\n maxReadSize: number\n /** The options of `WriteEntry.encode`. */\n header: EncodeOptions\n /** The compression of the output. */\n codec?: Codec\n codecOptions?: Record<string, unknown>\n /** True after `end()`. */\n ended: boolean = false\n protected head?: QueueNode<PackJob | WriteEntry | E | S>\n protected tail?: QueueNode<PackJob | WriteEntry | E | S>\n protected wake?: () => void\n // The first path of each file that has more than one link.\n #links = new Map<string, string>()\n\n constructor(\n opt: PackOptionsBase<E> & { fs?: FS },\n compress: 'compress' | 'compressSync',\n ) {\n opt = this.opt = ownOptions(opt)\n this.fs = opt.fs\n this.win32 = opt.platform === 'win32'\n this.maxReadSize = countOption(\n 'maxReadSize',\n opt.maxReadSize,\n MAX_READ,\n )\n const { prefix, noPax } = opt\n this.header = {\n prefix: prefix && this.win32 ? slashes(prefix) : prefix,\n noPax,\n }\n const cwd = opt.cwd && (this.win32 ? slashes(opt.cwd) : opt.cwd)\n // This code has no working directory to make a path absolute.\n if (cwd && !(this.win32 ? win32IsAbsolute : isAbsolute)(cwd)) {\n throw new TypeError('cwd must be an absolute path')\n }\n this.cwd = cwd && this.#resolve(cwd, '')\n\n const set = opt as Record<string, unknown>\n const names = ['gzip', 'brotli', 'zstd', 'compress'].filter(\n name => set[name],\n )\n if (names.length > 1) {\n throw new TypeError(`${names.join(', ')} are mutually exclusive`)\n }\n const [name] = names\n if (name) {\n const custom = opt.compress\n // The named options use a codec of `codecs`, or the gzip of\n // the runtime. The `compress` option has its own codec.\n const [codec, value] =\n !custom ?\n [\n [...(opt.codecs ?? []), gzip].find(c => c.name === name),\n set[name],\n ]\n : Array.isArray(custom) ? custom\n : [custom]\n if (!codec?.[compress]) {\n throw new TypeError(\n `no codec named ${codec?.name ?? name} has a ${compress} function`,\n )\n }\n this.codec = codec\n this.codecOptions = {\n ...(typeof value === 'object' ? value : undefined),\n ...(codec.name === 'gzip' && opt.portable ?\n { portable: true }\n : undefined),\n }\n }\n }\n\n #resolve(cwd: string, path: string) {\n return this.win32 ? win32Resolve(cwd, path) : resolve(cwd, path)\n }\n\n /** The absolute form of a path that is relative to `cwd`. */\n resolve(path: string): string {\n if (!this.cwd || !this.fs) {\n throw new TypeError('a path needs the cwd and fs options')\n }\n return this.#resolve(this.cwd, this.win32 ? slashes(path) : path)\n }\n\n /**\n * Put a path, an entry, or a source of entries at the end of the\n * queue. A directory is added with all that is in it.\n */\n add(item: string | WriteEntry | E | S): this {\n if (this.ended) throw new Error('write after end')\n if (typeof item !== 'string') this.push(item)\n else {\n const path = this.win32 ? slashes(item) : item\n this.push(new PackJob(path || './', this.resolve(path)))\n }\n return this\n }\n\n /** Add no more. The archive ends after the last item of the queue. */\n end(): this {\n this.ended = true\n this.wake?.()\n return this\n }\n\n protected push(item: PackJob | WriteEntry | E | S): void {\n const node = { item }\n if (this.tail) this.tail.next = node\n else this.head = node\n this.tail = node\n this.wake?.()\n }\n\n protected shift(): void {\n this.head = this.head?.next\n if (!this.head) this.tail = undefined\n }\n\n /**\n * True if the pack must read the exact `dev` and `ino` of the\n * object with the `bigint` option: the numbers are not exact, and a\n * wrong match loses data. That is a file with more than one link,\n * which a wrong match makes a hard link to a different file, and\n * with `follow` a directory, which a wrong match skips as a\n * directory in itself. Each other object gets no second stat.\n */\n protected needsExact(stat: CreateStats): boolean {\n return (\n lossy(stat) &&\n (stat.isDirectory() ?\n !!this.opt.follow\n : stat.isFile() && stat.nlink > 1)\n )\n }\n\n /**\n * The type of the entry to write for a path, or `undefined` to\n * write no entry. The pack calls it one time for each path, in the\n * order of the queue. `id` is the stat, or the exact `dev` and `ino`\n * of the object.\n */\n protected plan(\n job: PackJob,\n stat: CreateStats,\n id: FileId,\n ): EntryTypeName | undefined {\n const { filter } = this.opt\n if (filter && !filter(job.path, stat)) return\n if (stat.isDirectory()) {\n for (let a = job.up; a; a = a.up) {\n if (a.key !== idOf(id)) continue\n warn(\n this.opt,\n 'TAR_ENTRY_ERROR',\n 'directory is its own ancestor',\n {\n path: job.path,\n absolute: job.absolute,\n },\n )\n return\n }\n return 'Directory'\n }\n if (stat.isSymbolicLink()) return 'SymbolicLink'\n if (!stat.isFile()) {\n // A socket, a FIFO, or a device.\n warn(this.opt, 'TAR_ENTRY_UNSUPPORTED', 'unsupported file type', {\n path: job.path,\n absolute: job.absolute,\n })\n return\n }\n if (stat.nlink > 1) {\n const key = idOf(id)\n const target = this.#links.get(key)\n const cwd = this.cwd as string\n // A link is only made to a path in the cwd. A directory beside\n // the cwd can have a name that starts with the name of the cwd.\n // A path that is added two times is a file each time: a link to\n // itself cannot be extracted.\n if (\n target !== job.absolute &&\n target?.startsWith(cwd.endsWith('/') ? cwd : cwd + '/')\n ) {\n job.linkpath = relative(cwd, target)\n return 'Link'\n }\n this.#links.set(key, job.absolute)\n }\n return 'File'\n }\n\n /** The jobs for the names in the directory of `job`. */\n protected children(\n job: PackJob,\n names: string[],\n id: FileId,\n ): PackJob[] {\n const base = job.path === './' ? '' : job.path.replace(/\\/*$/, '/')\n const dir =\n job.absolute.endsWith('/') ? job.absolute : job.absolute + '/'\n // Only a pack that follows symbolic links can find a directory\n // in itself.\n const up = this.opt.follow ? { key: idOf(id), up: job.up } : undefined\n // Node.js sorts the names of a directory. Bun does not. Sort\n // them, so that each runtime makes the same archive.\n return [...names].sort().map(name => {\n const child = new PackJob(base + name, dir + name)\n child.up = up\n return child\n })\n }\n\n /**\n * Report a path that does not exist, and skip it. Each other error\n * of the stat is thrown.\n */\n protected missing(job: PackJob, er: unknown): undefined {\n if ((er as { code?: unknown })?.code !== 'ENOENT') throw er\n warn(this.opt, 'TAR_ENTRY_ERROR', er as Error, {\n path: job.path,\n absolute: job.absolute,\n })\n }\n\n /** Report a path that is a different object after its `lstat`. */\n protected changed(job: PackJob, type: EntryTypeName): void {\n warn(\n this.opt,\n 'TAR_ENTRY_ERROR',\n type === 'Directory' ?\n 'directory changed between lstat and readdir'\n : 'file changed between lstat and open',\n { path: job.path, absolute: job.absolute },\n )\n }\n\n /** Make the entry for a path. */\n protected pathEntry(\n job: PackJob,\n stat: CreateStats,\n type: EntryTypeName,\n linkpath: string | undefined,\n body: WriteEntry['body'],\n ): WriteEntry {\n const { processUid, processUname = '' } = this.opt\n const entry = new WriteEntry(\n {\n path: job.path,\n type,\n mode: stat.mode,\n uid: stat.uid,\n gid: stat.gid,\n uname: stat.uid === processUid ? processUname : '',\n size: type === 'File' ? stat.size : 0,\n mtime: stat.mtime,\n atime: stat.atime,\n ctime: stat.ctime,\n linkpath: linkpath && this.win32 ? slashes(linkpath) : linkpath,\n dev: stat.dev,\n ino: stat.ino,\n nlink: stat.nlink,\n },\n body,\n )\n entry.absolute = job.absolute\n return this.#finish(entry, true)\n }\n\n /**\n * Make the entry to write for an entry that the caller added.\n * `undefined` if the filter refuses an entry of another archive.\n */\n protected addedEntry(item: WriteEntry | E): WriteEntry | undefined {\n if (isWriteEntry(item)) return this.#finish(item, false)\n const { filter } = this.opt\n if (filter && !filter(item.path, item)) return\n return this.#finish(new WriteEntry(item, item.body), false)\n }\n\n // Apply the options to the fields of the entry.\n #finish(entry: WriteEntry, fromPath: boolean): WriteEntry {\n const { opt, win32 } = this\n const dir = entry.type === 'Directory'\n if (win32 && !fromPath) {\n entry.path = slashes(entry.path)\n if (entry.linkpath) entry.linkpath = slashes(entry.linkpath)\n }\n const [root, stripped] =\n opt.preservePaths ? ['', entry.path] : stripAbsolutePath(entry.path)\n entry.path = stripped\n if (fromPath) {\n if (win32) entry.path = winchars.decode(entry.path)\n if (entry.path === '') entry.path = './'\n }\n if (root) {\n warn(opt, 'TAR_ENTRY_INFO', `stripping ${root} from absolute path`, {\n entry,\n path: root + entry.path,\n })\n }\n if (fromPath && dir && !entry.path.endsWith('/')) entry.path += '/'\n\n if (opt.portable) {\n entry.uid =\n entry.gid =\n entry.dev =\n entry.ino =\n entry.nlink =\n undefined\n entry.uname = entry.gname = undefined\n entry.atime = entry.ctime = undefined\n }\n if (entry.mode !== undefined) {\n entry.mode = modeFix(entry.mode, dir, !!opt.portable)\n }\n entry.mtime =\n opt.noMtime || (opt.portable && dir) ?\n undefined\n : opt.mtime || entry.mtime\n return entry\n }\n}\n\n// Read from the handle into `buf` at `off`, until the buffer is full\n// or the file has no more bytes. `pos` is the place in the file.\n// Returns the new place.\nconst fill = async (\n handle: CreateFileHandle,\n buf: Uint8Array,\n off: number,\n pos: number,\n size: number,\n path: string,\n): Promise<number> => {\n while (off < buf.length && pos < size) {\n const { bytesRead } = await handle.read(\n buf,\n off,\n buf.length - off,\n pos,\n )\n if (bytesRead <= 0) throw fewer(path, size)\n if (bytesRead > size - pos) throw more(path, size)\n off += bytesRead\n pos += bytesRead\n }\n return pos\n}\n\nconst fillSync = (\n fs: CreateFSSync,\n fd: number,\n buf: Uint8Array,\n off: number,\n pos: number,\n size: number,\n path: string,\n): number => {\n while (off < buf.length && pos < size) {\n const bytesRead = fs.readSync(fd, buf, off, buf.length - off, pos)\n if (bytesRead <= 0) throw fewer(path, size)\n if (bytesRead > size - pos) throw more(path, size)\n off += bytesRead\n pos += bytesRead\n }\n return pos\n}\n\n// The chunks of a body, from each kind of content.\nasync function* chunks(\n body: WriteEntry['body'],\n): AsyncGenerator<Uint8Array, void, void> {\n if (isUint8Array(body)) yield body\n else if (isBlob(body) || isReadableStream(body)) {\n const reader = (isBlob(body) ? body.stream() : body).getReader()\n try {\n for (;;) {\n const res = await reader.read()\n if (res.done) break\n yield res.value\n }\n } finally {\n await reader.cancel().catch(noop)\n }\n } else if (body) yield* body\n}\n\nfunction* chunksSync(\n body: WriteEntry['body'],\n): Generator<Uint8Array, void, void> {\n if (isUint8Array(body)) yield body\n else if (body && Symbol.iterator in body) yield* body\n else if (body) {\n throw new TypeError(\n 'PackSync needs a body that is a string, a Uint8Array, or an iterable',\n )\n }\n}\n\n// Count the bytes of a body part. Returns the bytes that are left.\nconst count = (entry: WriteEntry, remain: number, chunk: Uint8Array) => {\n if (chunk.length > remain) throw tooLong(entry)\n return remain - chunk.length\n}\n\n// The zeros after a body, or an error if the body was too short.\nconst padding = (entry: WriteEntry, remain: number) => {\n if (remain) throw eof('encountered unexpected EOF', pathOf(entry))\n return new Uint8Array(blockLength(entry.size) - entry.size)\n}\n\n// The body of the entry, with the zeros that fill its last block.\nasync function* bodyBlocks(\n entry: WriteEntry,\n): AsyncGenerator<Uint8Array, void, void> {\n if (!entry.size) return\n let remain = entry.size\n for await (const chunk of chunks(entry.body)) {\n remain = count(entry, remain, chunk)\n yield chunk\n }\n const pad = padding(entry, remain)\n if (pad.length) yield pad\n}\n\nfunction* bodyBlocksSync(\n entry: WriteEntry,\n): Generator<Uint8Array, void, void> {\n if (!entry.size) return\n let remain = entry.size\n for (const chunk of chunksSync(entry.body)) {\n remain = count(entry, remain, chunk)\n yield chunk\n }\n const pad = padding(entry, remain)\n if (pad.length) yield pad\n}\n\n/** What `Pack.add()` takes. */\nexport type PackInput =\n | string\n | WriteEntry\n | ReadEntry\n | AsyncIterable<WriteEntry | ReadEntry>\n | Iterable<WriteEntry | ReadEntry>\n\n/** What `PackSync.add()` takes. */\nexport type PackInputSync =\n | string\n | WriteEntry\n | ReadEntrySync\n | Iterable<WriteEntry | ReadEntrySync>\n\n/**\n * Makes an archive. `add()` paths and entries, then `end()`. The\n * pack is the async iterator of the bytes of the archive, compressed\n * if an option selects a codec.\n *\n * It reads the file system only when the consumer asks for bytes.\n * Then it reads the first `jobs` paths of the queue at the same\n * time, and writes them in the order of the queue. The entries of a\n * directory go to the end of the queue.\n *\n * `return()` closes each file that is open.\n */\nexport class Pack\n extends PackBase<\n CreateFS,\n ReadEntry,\n | AsyncIterable<WriteEntry | ReadEntry>\n | Iterable<WriteEntry | ReadEntry>\n >\n implements AsyncIterableIterator<Uint8Array, undefined>\n{\n jobs: number\n #out?: AsyncGenerator<Uint8Array, void, void>\n // Settles when the pack called `plan()` for each path that it\n // started to read. It keeps the calls in the order of the queue.\n #planned: Promise<unknown> = Promise.resolve()\n\n constructor(opt: PackOptions = {}) {\n super(opt, 'compress')\n this.jobs = countOption('jobs', (this.opt as PackOptions).jobs, 4)\n }\n\n async next(): Promise<IteratorResult<Uint8Array, undefined>> {\n const res = await (this.#out ??= this.#output()).next()\n return res.done ? { value: undefined, done: true } : res\n }\n\n /** Stop, and close each file that is open. */\n async return(): Promise<IteratorResult<Uint8Array, undefined>> {\n this.end()\n await this.#out?.return()\n return { value: undefined, done: true }\n }\n\n [Symbol.asyncIterator](): this {\n return this\n }\n\n #output(): AsyncGenerator<Uint8Array, void, void> {\n const { codec } = this\n return codec?.compress ?\n this.#compress(codec.compress(this.codecOptions))\n : this.#run()\n }\n\n async *#compress(\n stream: CodecStream,\n ): AsyncGenerator<Uint8Array, void, void> {\n const run = this.#run()\n // An error of the pack goes to the consumer, also when the codec\n // does not pass it on: then the cancel ends the read.\n let failure: { er: unknown } | undefined\n const reader = toStream({\n next: () =>\n run.next().catch(er => {\n failure = { er }\n void reader.cancel().catch(noop)\n throw er\n }),\n })\n .pipeThrough(stream)\n .getReader()\n try {\n for (;;) {\n const res = await reader.read()\n if (failure) throw failure.er\n if (res.done) break\n yield res.value\n }\n } finally {\n await reader.cancel().catch(noop)\n await run.return()\n }\n }\n\n async *#run(): AsyncGenerator<Uint8Array, void, void> {\n try {\n for (;;) {\n const node = this.head\n if (!node) {\n if (this.ended) break\n await new Promise<void>(res => (this.wake = res))\n continue\n }\n this.#start()\n const { item } = node\n if (item instanceof PackJob) yield* this.#path(item)\n else if (!isSource(item)) yield* this.#entry(item)\n else for await (const entry of item) yield* this.#entry(entry)\n this.shift()\n }\n yield new Uint8Array(1024)\n } finally {\n // Close the files of the paths that the pack did not write.\n for (let node = this.head; node; node = node.next) {\n const { item } = node\n if (!(item instanceof PackJob) || !item.ready) break\n const load = await item.ready.catch(noop)\n await load?.handle?.close().catch(noop)\n }\n }\n }\n\n // Start to read the paths at the start of the queue.\n #start() {\n const fs = this.fs as CreateFS\n let node = this.head\n for (let n = 0; node && n < this.jobs; n++, node = node.next) {\n const job = node.item\n // An entry can change what the filter does with a later path.\n if (!(job instanceof PackJob)) break\n if (job.ready) continue\n const stat = this.#stat(fs, job.absolute)\n stat.catch(noop)\n const planned = this.#planned\n .then(() => stat)\n .then(\n ([st, id]) => {\n const type = this.plan(job, st, id)\n return type && { load: this.#load(fs, job, st, id, type) }\n },\n er => this.missing(job, er),\n )\n this.#planned = planned.catch(noop)\n job.ready = planned.then(p => p?.load)\n job.ready.catch(noop)\n }\n }\n\n // The stat of a path, and the identity of the object.\n async #stat(fs: CreateFS, path: string): Promise<[CreateStats, FileId]> {\n const { follow } = this.opt\n const stat = await (follow ? fs.stat(path) : fs.lstat(path))\n const id =\n !this.needsExact(stat) ?\n stat\n : await (follow ? fs.stat(path, BIG) : fs.lstat(path, BIG))\n return [stat, id]\n }\n\n async #load(\n fs: CreateFS,\n job: PackJob,\n stat: CreateStats,\n id: FileId,\n type: EntryTypeName,\n ): Promise<PackLoad> {\n const { absolute } = job\n const { follow, noDirRecurse } = this.opt\n const load: PackLoad = { stat, id, type }\n if (type === 'SymbolicLink') {\n load.linkpath = await fs.readlink(absolute)\n } else if (type === 'Directory' && !noDirRecurse) {\n load.names = await fs.readdir(absolute)\n load.changed = !follow && !same(stat, await fs.lstat(absolute))\n } else if (type === 'File' && stat.size) {\n const handle = await fs.open(absolute, 'r')\n try {\n const { size } = stat\n const length = blockLength(size)\n if (!follow && !same(stat, await handle.stat())) {\n load.changed = true\n } else if (length > this.maxReadSize) load.handle = handle\n else {\n load.buf = new Uint8Array(512 + length)\n await fill(handle, load.buf, 512, 0, size, absolute)\n }\n } catch (er) {\n await handle.close().catch(noop)\n throw er\n }\n if (!load.handle) await handle.close()\n }\n return load\n }\n\n async *#path(job: PackJob): AsyncGenerator<Uint8Array, void, void> {\n const load = await job.ready\n if (!load) return\n const { stat, id, type, names, buf, handle } = load\n if (load.changed) return this.changed(job, type)\n let ok = false\n try {\n const body =\n buf ?\n buf.subarray(512, 512 + stat.size)\n : handle && this.#read(handle, stat.size, job.absolute)\n const entry = this.pathEntry(\n job,\n stat,\n type,\n load.linkpath ?? job.linkpath,\n body,\n )\n if (names) {\n for (const child of this.children(job, names, id)) {\n this.push(child)\n }\n }\n await this.opt.onWriteEntry?.(entry)\n // The header goes in the space before a body that is in `buf`.\n const whole = buf && entry.body === body && entry.size === stat.size\n yield* entry.encode(this.header, whole ? buf : undefined)\n if (!whole) yield* bodyBlocks(entry)\n ok = true\n } finally {\n if (handle) {\n load.handle = undefined\n const closed = handle.close()\n await (ok ? closed : closed.catch(noop))\n }\n }\n }\n\n // The chunks of a file that is larger than `maxReadSize`.\n async *#read(\n handle: CreateFileHandle,\n size: number,\n path: string,\n ): AsyncGenerator<Uint8Array, void, void> {\n const length = blockLength(size)\n for (let pos = 0; pos < size; ) {\n // Ask for the bytes of the last block also, to find a file that\n // is larger now.\n const buf = new Uint8Array(Math.min(length - pos, this.maxReadSize))\n const end = await fill(handle, buf, 0, pos, size, path)\n yield buf.subarray(0, end - pos)\n pos = end\n }\n }\n\n async *#entry(\n item: WriteEntry | ReadEntry,\n ): AsyncGenerator<Uint8Array, void, void> {\n const entry = this.addedEntry(item)\n if (!entry) return\n await this.opt.onWriteEntry?.(entry)\n yield* entry.encode(this.header)\n yield* bodyBlocks(entry)\n }\n}\n\n/**\n * Makes an archive with no promise. `add()` paths and entries. The\n * pack is the iterator of the bytes of the archive. It reads the\n * file system only when the consumer asks for bytes, one path at a\n * time. The entries of a directory come before the next item that\n * the caller added.\n *\n * The pack ends when the iterator comes to the end of the queue.\n * With compression, the iterator gives all the archive in one chunk.\n */\nexport class PackSync\n extends PackBase<\n CreateFSSync,\n ReadEntrySync,\n Iterable<WriteEntry | ReadEntrySync>\n >\n implements IterableIterator<Uint8Array, undefined>\n{\n #out?: Generator<Uint8Array, void, void>\n\n constructor(opt: PackOptionsSync = {}) {\n super(opt, 'compressSync')\n }\n\n next(): IteratorResult<Uint8Array, undefined> {\n const res = (this.#out ??= this.#output()).next()\n return res.done ? { value: undefined, done: true } : res\n }\n\n /** Stop, and close the file that is open. */\n return(): IteratorResult<Uint8Array, undefined> {\n this.ended = true\n this.#out?.return()\n return { value: undefined, done: true }\n }\n\n [Symbol.iterator](): this {\n return this\n }\n\n *#output(): Generator<Uint8Array, void, void> {\n const { codec } = this\n if (!codec?.compressSync) return yield* this.#run()\n yield codec.compressSync(concat([...this.#run()]), this.codecOptions)\n }\n\n *#run(): Generator<Uint8Array, void, void> {\n for (let node; (node = this.head); this.shift()) {\n const { item } = node\n if (item instanceof PackJob) {\n const jobs = [item]\n for (const job of jobs) yield* this.#path(job, jobs)\n } else if (!isSource(item)) yield* this.#entry(item)\n else for (const entry of item) yield* this.#entry(entry)\n }\n this.ended = true\n yield new Uint8Array(1024)\n }\n\n *#path(\n job: PackJob,\n jobs: PackJob[],\n ): Generator<Uint8Array, void, void> {\n const fs = this.fs as CreateFSSync\n const { absolute } = job\n const { follow, noDirRecurse } = this.opt\n let stat: CreateStats\n try {\n stat = follow ? fs.statSync(absolute) : fs.lstatSync(absolute)\n } catch (er) {\n return this.missing(job, er)\n }\n const id: FileId =\n !this.needsExact(stat) ? stat\n : follow ? fs.statSync(absolute, BIG)\n : fs.lstatSync(absolute, BIG)\n const type = this.plan(job, stat, id)\n if (!type) return\n let { linkpath } = job\n let buf: Uint8Array | undefined\n let body: WriteEntry['body']\n let fd: number | undefined\n let ok = false\n try {\n if (type === 'SymbolicLink') linkpath = fs.readlinkSync(absolute)\n else if (type === 'Directory' && !noDirRecurse) {\n const names = fs.readdirSync(absolute)\n if (!follow && !same(stat, fs.lstatSync(absolute))) {\n return this.changed(job, type)\n }\n jobs.push(...this.children(job, names, id))\n } else if (type === 'File' && stat.size) {\n const { size } = stat\n const length = blockLength(size)\n fd = fs.openSync(absolute, 'r')\n if (!follow && !same(stat, fs.fstatSync(fd))) {\n return this.changed(job, type)\n }\n if (length > this.maxReadSize) {\n body = this.#read(fs, fd, size, absolute)\n } else {\n buf = new Uint8Array(512 + length)\n fillSync(fs, fd, buf, 512, 0, size, absolute)\n body = buf.subarray(512, 512 + size)\n }\n }\n const entry = this.pathEntry(job, stat, type, linkpath, body)\n this.opt.onWriteEntry?.(entry)\n // The header goes in the space before a body that is in `buf`.\n const whole = buf && entry.body === body && entry.size === stat.size\n yield* entry.encode(this.header, whole ? buf : undefined)\n if (!whole) yield* bodyBlocksSync(entry)\n ok = true\n } finally {\n // An error of close must not hide the first error.\n if (fd !== undefined && !ok) {\n try {\n fs.closeSync(fd)\n } catch {}\n }\n }\n if (fd !== undefined) fs.closeSync(fd)\n }\n\n // The chunks of a file that is larger than `maxReadSize`.\n *#read(\n fs: CreateFSSync,\n fd: number,\n size: number,\n path: string,\n ): Generator<Uint8Array, void, void> {\n const length = blockLength(size)\n for (let pos = 0; pos < size; ) {\n const buf = new Uint8Array(Math.min(length - pos, this.maxReadSize))\n const end = fillSync(fs, fd, buf, 0, pos, size, path)\n yield buf.subarray(0, end - pos)\n pos = end\n }\n }\n\n *#entry(\n item: WriteEntry | ReadEntrySync,\n ): Generator<Uint8Array, void, void> {\n const entry = this.addedEntry(item)\n if (!entry) return\n this.opt.onWriteEntry?.(entry)\n yield* entry.encode(this.header)\n yield* bodyBlocksSync(entry)\n }\n}\n", "import {\n dealias,\n type FileOption,\n type NoFileOption,\n type WithAliases,\n} from './dealias.js'\nimport { TarReader, TarReaderSync } from './entries.js'\nimport type { CreateFileHandle, CreateFS, CreateFSSync } from './fs.js'\nimport type { CreateOptions, CreateOptionsSync } from './options.js'\nimport {\n Pack,\n PackSync,\n type PackInput,\n type PackInputSync,\n} from './pack.js'\nimport { readFile, readFileSync } from './read-file.js'\nimport { toStream } from './to-stream.js'\n\n// Chunks that are smaller than this are put together for one write.\nconst SMALL = 64 * 1024\nconst BATCH = 4 * SMALL\nconst noop = () => {}\n\nconst check = (opt: { file?: string; fs?: unknown }, files: unknown[]) => {\n if (!files?.length) {\n throw new TypeError('no paths specified to add to archive')\n }\n if (opt.file && !opt.fs) {\n throw new TypeError('the file option needs the fs option')\n }\n}\n\nconst writeAll = async (\n handle: CreateFileHandle,\n buf: Uint8Array,\n length: number,\n position: number,\n) => {\n for (let off = 0; off < length; ) {\n off += (await handle.write(buf, off, length - off, position + off))\n .bytesWritten\n }\n}\n\n/**\n * Write the chunks to the file, from `position`. Chunks that are\n * smaller than 64 KiB are put together for one write.\n */\nexport const writeChunks = async (\n handle: CreateFileHandle,\n chunks: AsyncIterable<Uint8Array>,\n position: number,\n): Promise<void> => {\n const batch = new Uint8Array(BATCH)\n let used = 0\n const flush = async () => {\n await writeAll(handle, batch, used, position)\n position += used\n used = 0\n }\n for await (const chunk of chunks) {\n if (used + chunk.length > BATCH || chunk.length >= SMALL) await flush()\n if (chunk.length >= SMALL) {\n await writeAll(handle, chunk, chunk.length, position)\n position += chunk.length\n } else {\n batch.set(chunk, used)\n used += chunk.length\n }\n }\n await flush()\n}\n\n/** The sync form of `writeChunks`. */\nexport const writeChunksSync = (\n fs: CreateFSSync,\n fd: number,\n chunks: Iterable<Uint8Array>,\n position: number,\n): void => {\n const batch = new Uint8Array(BATCH)\n let used = 0\n const write = (buf: Uint8Array, length: number) => {\n for (let off = 0; off < length; ) {\n off += fs.writeSync(fd, buf, off, length - off, position + off)\n }\n position += length\n }\n for (const chunk of chunks) {\n if (used + chunk.length > BATCH || chunk.length >= SMALL) {\n write(batch, used)\n used = 0\n }\n if (chunk.length >= SMALL) write(chunk, chunk.length)\n else {\n batch.set(chunk, used)\n used += chunk.length\n }\n }\n write(batch, used)\n}\n\nconst createFile = async (\n pack: Pack,\n fs: CreateFS,\n file: string,\n mode: number,\n): Promise<void> => {\n const handle = await fs.open(file, 'w', mode)\n let ok = false\n try {\n await writeChunks(handle, pack, 0)\n ok = true\n } finally {\n const closed = handle.close()\n await (ok ? closed : closed.catch(noop))\n }\n}\n\n/**\n * Make the pack for the files of a command. A name that starts with\n * `@` is the path of an archive: the pack gets its entries.\n */\nexport const packFiles = (\n opt: CreateOptions,\n files: PackInput[],\n): Pack => {\n const { fs, strict, onwarn, codecs, platform } = opt\n const pack = new Pack(opt)\n for (const item of files) {\n if (typeof item !== 'string' || item.charAt(0) !== '@') pack.add(item)\n else {\n const archive = pack.resolve(item.slice(1))\n pack.add(\n new TarReader(readFile(fs as CreateFS, archive, opt.maxReadSize), {\n strict,\n onwarn,\n codecs,\n platform,\n file: archive,\n }),\n )\n }\n }\n return pack.end()\n}\n\n/** The sync form of `packFiles`. */\nexport const packFilesSync = (\n opt: CreateOptionsSync,\n files: PackInputSync[],\n): PackSync => {\n const { strict, onwarn, codecs, platform } = opt\n const pack = new PackSync(opt)\n for (const item of files) {\n if (typeof item !== 'string' || item.charAt(0) !== '@') pack.add(item)\n else {\n const archive = pack.resolve(item.slice(1))\n pack.add(\n new TarReaderSync(\n readFileSync(opt.fs as CreateFSSync, archive, opt.maxReadSize),\n { strict, onwarn, codecs, platform, file: archive },\n ),\n )\n }\n }\n return pack\n}\n\n/**\n * Make an archive of the files. A directory is added with all that\n * is in it. A name that starts with `@` is the path of an archive:\n * its entries are added. A file can also be an entry, or a source of\n * entries, as in `Pack.add()`.\n *\n * With `opt.file`, the archive is written to that path through\n * `opt.fs`. With no `opt.file`, the result is a stream of the bytes\n * of the archive. Files are read only when the stream is read.\n */\nexport function create(\n opt: WithAliases<CreateOptions> & FileOption,\n files: PackInput[],\n): Promise<void>\nexport function create(\n opt: WithAliases<CreateOptions> & NoFileOption,\n files: PackInput[],\n): ReadableStream<Uint8Array>\nexport function create(\n opt: WithAliases<CreateOptions>,\n files: PackInput[],\n): Promise<void> | ReadableStream<Uint8Array>\nexport function create(\n options: WithAliases<CreateOptions>,\n files: PackInput[],\n): Promise<void> | ReadableStream<Uint8Array> {\n const opt = dealias<CreateOptions>(options)\n if (!opt.file) {\n check(opt, files)\n return toStream(packFiles(opt, files))\n }\n // The file form returns a promise, so a bad argument rejects it.\n try {\n check(opt, files)\n return createFile(\n packFiles(opt, files),\n opt.fs as CreateFS,\n opt.file,\n opt.mode || 0o666,\n )\n } catch (er) {\n return Promise.reject(er)\n }\n}\n\n/**\n * The sync form of `create`. With no `opt.file`, the result is an\n * iterator of the bytes of the archive. Files are read only when the\n * iterator is read.\n */\nexport function createSync(\n opt: WithAliases<CreateOptionsSync> & FileOption,\n files: PackInputSync[],\n): void\nexport function createSync(\n opt: WithAliases<CreateOptionsSync> & NoFileOption,\n files: PackInputSync[],\n): IterableIterator<Uint8Array, undefined>\nexport function createSync(\n opt: WithAliases<CreateOptionsSync>,\n files: PackInputSync[],\n): void | IterableIterator<Uint8Array, undefined>\nexport function createSync(\n options: WithAliases<CreateOptionsSync>,\n files: PackInputSync[],\n): void | IterableIterator<Uint8Array, undefined> {\n const opt = dealias<CreateOptionsSync>(options)\n check(opt, files)\n const { file } = opt\n const fs = opt.fs as CreateFSSync\n const pack = packFilesSync(opt, files)\n if (!file) return pack\n const fd = fs.openSync(file, 'w', opt.mode || 0o666)\n try {\n writeChunksSync(fs, fd, pack, 0)\n } catch (er) {\n try {\n fs.closeSync(fd)\n } catch {}\n throw er\n }\n fs.closeSync(fd)\n}\n", "import { stripTrailingSlashes } from './strip-trailing-slashes.js'\nimport { dealias, type WithAliases } from './dealias.js'\nimport { TarReader, TarReaderSync } from './entries.js'\nimport type { ListOptions, ListOptionsSync } from './options.js'\nimport { readFile, readFileSync } from './read-file.js'\nimport { warn, type WarnOptions } from './warn.js'\n\n/**\n * Make a filter that passes the entries that `files` lists. An entry\n * passes if `filter` accepts it, and it is in the list or one of its\n * parent directories is. Trailing slashes are ignored.\n *\n * The second item of the result reports each listed path that no\n * entry of the archive matched, as a `TAR_ENTRY_ERROR` warning. An\n * entry that `filter` refuses also matches. Call it when the archive\n * ends.\n */\nexport const filesFilter = <E>(\n files: string[],\n filter?: (path: string, entry: E) => boolean,\n): [\n filter: (path: string, entry: E) => boolean,\n report: (opt: WarnOptions) => void,\n] => {\n const set = new Set(files.map(f => stripTrailingSlashes(f)))\n // The listed paths that no entry matched yet.\n const missing = new Set(set)\n let max = 0\n for (const f of set) max = Math.max(max, f.length)\n const listed = (path: string) => {\n const p = stripTrailingSlashes(path)\n const root = p.charAt(0) === '/' ? '/' : '.'\n let found = false\n // Look at the path, and then at each parent directory. One that\n // is longer than each listed path is not looked up, so the work\n // for a very long path stays small.\n for (let end = p.length; end > 0; end = p.lastIndexOf('/', end - 1)) {\n if (end > max) continue\n const dir = p.slice(0, end)\n if (dir === root || !set.has(dir)) continue\n found = true\n missing.delete(dir)\n // A parent directory can also be in the list.\n if (!missing.size) break\n }\n return found\n }\n return [\n (path, entry) => {\n // The filter of the caller gets each entry.\n const ok = !filter || filter(path, entry)\n return listed(path) && ok\n },\n opt => {\n for (const path of missing) {\n warn(opt, 'TAR_ENTRY_ERROR', `${path}: not found in archive`, {\n path,\n })\n }\n },\n ]\n}\n\nconst noInput = () => new TypeError('list needs input, or file and fs')\n\n/**\n * Call `opt.onEntry` with each entry of an archive. If `files` is\n * set, only with the entries that it lists, and the entries in the\n * directories that it lists. A listed path that no entry matches is\n * a warning when the archive ends.\n */\nexport const list = async (\n options: WithAliases<ListOptions>,\n files?: string[],\n): Promise<void> => {\n const opt = dealias<ListOptions>(options)\n const { input, file, fs, onEntry } = opt\n const source =\n input ?? (file && fs ? readFile(fs, file, opt.maxReadSize) : undefined)\n if (!source) throw noInput()\n const [filter, report] =\n files?.length ? filesFilter(files, opt.filter) : []\n if (filter) opt.filter = filter\n const reader = new TarReader(source, opt)\n try {\n for (;;) {\n const entry = reader.poll()\n if (entry === null) break\n if (entry === undefined) await reader.fill()\n else if (onEntry) await onEntry(entry)\n }\n } finally {\n await reader.return()\n }\n report?.(opt)\n}\n\n/** The sync form of `list`. */\nexport const listSync = (\n options: WithAliases<ListOptionsSync>,\n files?: string[],\n): void => {\n const opt = dealias<ListOptionsSync>(options)\n const { input, file, fs, onEntry } = opt\n const source =\n input ??\n (file && fs ? readFileSync(fs, file, opt.maxReadSize) : undefined)\n if (!source) throw noInput()\n const [filter, report] =\n files?.length ? filesFilter(files, opt.filter) : []\n if (filter) opt.filter = filter\n const reader = new TarReaderSync(source, opt)\n for (const entry of reader) onEntry?.(entry)\n report?.(opt)\n}\n", "import { gzip, type Codec } from './codec.js'\nimport { create, createSync } from './create.js'\nimport { dealias, type WithAliases } from './dealias.js'\nimport {\n findCodec,\n headLength,\n TarReader,\n TarReaderSync,\n} from './entries.js'\nimport { filesFilter } from './list.js'\nimport type { DeleteOptions, DeleteOptionsSync } from './options.js'\nimport { readFile, readFileSync } from './read-file.js'\n\nconst noop = () => {}\n\ntype Filter<E> = (path: string, entry: E) => boolean\n\n// The codecs to look for, and the filter and the report of the paths\n// to delete.\nconst plan = <E>(\n opt: {\n file?: string\n fs?: unknown\n codecs?: Codec[]\n filter?: Filter<E>\n },\n files: string[] | undefined,\n): [\n codecs: Codec[],\n remove: Filter<E>,\n report?: ReturnType<typeof filesFilter>[1],\n] => {\n if (!opt.file) throw new TypeError('file is required')\n if (!opt.fs) throw new TypeError('the file option needs the fs option')\n const codecs = [...(opt.codecs ?? []), gzip]\n if (files?.length) return [codecs, ...filesFilter(files, opt.filter)]\n if (opt.filter) return [codecs, opt.filter]\n throw new TypeError('no paths specified to delete')\n}\n\n// The path of the new archive, until it gets the path of the old one.\nconst tmpName = (file: string) =>\n `${file}.${Math.random().toString(36).slice(2)}.tmp`\n\n/**\n * Remove entries from an archive file. An entry is removed if\n * `files` lists its path or one of its parent directories. With\n * `opt.filter`, only if the filter also returns true. With no\n * `files`, each entry that the filter accepts is removed. A listed\n * path that no entry matches is a warning.\n *\n * The other entries are written to a new file next to the archive,\n * with the compression and the mode of the archive. The new file\n * then gets the path of the archive. The archive does not change if\n * the command fails.\n */\nconst del = async (\n options: WithAliases<DeleteOptions>,\n files?: string[],\n): Promise<void> => {\n const opt = dealias<DeleteOptions>(options)\n const [codecs, remove, report] = plan(opt, files)\n const { fs, file, filter: _, maxReadSize, ...read } = opt\n const head = new Uint8Array(headLength(codecs))\n let length = 0\n const handle = await fs.open(file, 'r')\n try {\n for (let n = 1; n > 0 && length < head.length; length += n) {\n n = (await handle.read(head, length, head.length - length, length))\n .bytesRead\n }\n } finally {\n await handle.close()\n }\n const { mode } = await fs.stat(file)\n const tmp = tmpName(file)\n try {\n await create(\n {\n ...read,\n fs,\n file: tmp,\n mode: mode & 0o777,\n compress: findCodec(codecs, head.subarray(0, length), file),\n preservePaths: true,\n filter: (path, entry) => !remove(path, entry as never),\n },\n [new TarReader(readFile(fs, file, maxReadSize), { ...read, file })],\n )\n report?.(opt)\n await fs.rename(tmp, file)\n } catch (er) {\n await fs.unlink(tmp).catch(noop)\n throw er\n }\n}\n\n/** The sync form of `delete`. */\nexport const deleteSync = (\n options: WithAliases<DeleteOptionsSync>,\n files?: string[],\n): void => {\n const opt = dealias<DeleteOptionsSync>(options)\n const [codecs, remove, report] = plan(opt, files)\n const { fs, file, filter: _, maxReadSize, ...read } = opt\n const head = new Uint8Array(headLength(codecs))\n let length = 0\n const fd = fs.openSync(file, 'r')\n try {\n for (let n = 1; n > 0 && length < head.length; length += n) {\n n = fs.readSync(fd, head, length, head.length - length, length)\n }\n } finally {\n fs.closeSync(fd)\n }\n const { mode } = fs.statSync(file)\n const tmp = tmpName(file)\n try {\n createSync(\n {\n ...read,\n fs,\n file: tmp,\n mode: mode & 0o777,\n compress: findCodec(codecs, head.subarray(0, length), file),\n preservePaths: true,\n filter: (path, entry) => !remove(path, entry as never),\n },\n [\n new TarReaderSync(readFileSync(fs, file, maxReadSize), {\n ...read,\n file,\n }),\n ],\n )\n report?.(opt)\n fs.renameSync(tmp, file)\n } catch (er) {\n try {\n fs.unlinkSync(tmp)\n } catch {}\n throw er\n }\n}\n\nexport { del as delete }\n", "export class CwdError extends Error {\n path: string\n code: string\n syscall = 'chdir' as const\n\n constructor(path: string, code: string) {\n super(`${code}: Cannot cd into '${path}'`)\n this.path = path\n this.code = code\n }\n\n get name() {\n return 'CwdError'\n }\n}\n", "export class SymlinkError extends Error {\n path: string\n symlink: string\n syscall = 'symlink' as const\n code = 'TAR_SYMLINK_ERROR' as const\n constructor(symlink: string, path: string) {\n super('TAR_SYMLINK_ERROR: Cannot extract through symbolic link')\n this.symlink = symlink\n this.path = path\n }\n get name() {\n return 'SymlinkError'\n }\n}\n", "import { CwdError } from './cwd-error.js'\nimport { SymlinkError } from './symlink-error.js'\nimport type { ExtractFS, ExtractFSSync } from './fs.js'\nimport { relative } from './path.js'\n\n/** The options of `mkdir`. Each path has `/` separators. */\nexport type MkdirOptions = {\n /** The owner of each directory that is made, if it has `gid` also. */\n uid?: number\n gid?: number\n processUid?: number\n processGid?: number\n /** If the mode has a bit of this mask, `chmod` sets the mode. */\n umask: number\n /** Permit a symbolic link in the path. */\n preserve: boolean\n /** Remove an object in the path that is not a directory. */\n unlink: boolean\n /** The absolute path of the extraction directory. */\n cwd: string\n mode: number\n}\n\ntype ErrorWithCode = Error & { code?: string }\n\n// The parts of the mkdir options that do not need the file system.\nconst plan = (opt: MkdirOptions) => {\n const mode = opt.mode | 0o700\n const { uid, gid } = opt\n return {\n mode,\n // The umask removes bits when the system makes the directory.\n needChmod: (mode & opt.umask) !== 0,\n owner:\n (\n typeof uid === 'number' &&\n typeof gid === 'number' &&\n (uid !== opt.processUid || gid !== opt.processGid)\n ) ?\n { uid, gid }\n : undefined,\n }\n}\n\nconst child = (dir: string, name: string) =>\n dir.endsWith('/') ? dir + name : dir + '/' + name\n\n// The directories that a recursive mkdir made: `dir`, and its parents\n// up to `first`, the one that was made first. On Windows, Node.js\n// gives `first` with `\\` separators, after the prefix `\\\\?\\`. So\n// `first` is the parent that it ends with. If it ends with none of\n// them, only `dir` is known.\nconst chain = (first: string, dir: string) => {\n const end = first.replaceAll('\\\\', '/')\n const made = [dir]\n for (let i = dir.length; !end.endsWith(dir.slice(0, i)); ) {\n i = dir.lastIndexOf('/', i - 1)\n if (i <= 0) return [dir]\n made.push(dir.slice(0, i))\n }\n return made\n}\n\n/**\n * Make the directory `dir` and its parents, below `opt.cwd`.\n *\n * If `opt.preserve` is not set, a symbolic link in the path is an\n * error, so that no entry is extracted through a link. The\n * extraction directory itself is never made: it must be a directory,\n * or the error is a `CwdError`.\n */\nexport const mkdir = async (\n fs: ExtractFS,\n dir: string,\n opt: MkdirOptions,\n): Promise<void> => {\n const { mode, needChmod, owner } = plan(opt)\n const { cwd } = opt\n let made: string[] = []\n if (dir === cwd) {\n let code: string | undefined = 'ENOTDIR'\n const ok = await fs.stat(dir).then(\n st => st.isDirectory(),\n (er: ErrorWithCode) => {\n code = er?.code || code\n return false\n },\n )\n if (!ok) throw new CwdError(dir, code)\n } else if (opt.preserve) {\n const first = await fs.mkdir(dir, { mode, recursive: true })\n if (first) made = chain(first, dir)\n } else {\n const parts = relative(cwd, dir).split('/')\n let part = cwd\n for (let i = 0; i < parts.length; i++) {\n part = child(part, parts[i] as string)\n try {\n await fs.mkdir(part, { mode })\n } catch (er) {\n const st = await fs.lstat(part)\n if (st.isDirectory()) continue\n if (!opt.unlink) {\n throw st.isSymbolicLink() ?\n new SymlinkError(\n part,\n part + '/' + parts.slice(i + 1).join('/'),\n )\n : er\n }\n await fs.unlink(part)\n await fs.mkdir(part, { mode })\n }\n made.push(part)\n }\n }\n if (owner) {\n for (const d of made) await fs.lchown(d, owner.uid, owner.gid)\n }\n if (needChmod) await fs.chmod(dir, mode)\n}\n\n/** The sync form of `mkdir`. */\nexport const mkdirSync = (\n fs: ExtractFSSync,\n dir: string,\n opt: MkdirOptions,\n): void => {\n const { mode, needChmod, owner } = plan(opt)\n const { cwd } = opt\n let made: string[] = []\n if (dir === cwd) {\n let code: string | undefined = 'ENOTDIR'\n let ok = false\n try {\n ok = fs.statSync(dir).isDirectory()\n } catch (er) {\n code = (er as ErrorWithCode)?.code || code\n }\n if (!ok) throw new CwdError(dir, code)\n } else if (opt.preserve) {\n const first = fs.mkdirSync(dir, { mode, recursive: true })\n if (first) made = chain(first, dir)\n } else {\n const parts = relative(cwd, dir).split('/')\n let part = cwd\n for (let i = 0; i < parts.length; i++) {\n part = child(part, parts[i] as string)\n try {\n fs.mkdirSync(part, { mode })\n } catch (er) {\n const st = fs.lstatSync(part)\n if (st.isDirectory()) continue\n if (!opt.unlink) {\n throw st.isSymbolicLink() ?\n new SymlinkError(\n part,\n part + '/' + parts.slice(i + 1).join('/'),\n )\n : er\n }\n fs.unlinkSync(part)\n fs.mkdirSync(part, { mode })\n }\n made.push(part)\n }\n }\n if (owner) {\n for (const d of made) fs.lchownSync(d, owner.uid, owner.gid)\n }\n if (needChmod) fs.chmodSync(dir, mode)\n}\n", "// warning: extremely hot code path.\n// This has been meticulously optimized for use\n// within npm install on large package trees.\n// Do not edit without careful benchmarking.\nconst normalizeCache: Record<string, string> = Object.create(null)\n\n// Limit the size of this. Very low-sophistication LRU cache\nconst MAX = 10000\nconst cache = new Set<string>()\nexport const normalizeUnicode = (s: string): string => {\n if (!cache.has(s)) {\n // shake out identical accents and ligatures\n normalizeCache[s] = s\n .normalize('NFD')\n .toLocaleLowerCase('en')\n .toLocaleUpperCase('en')\n } else {\n cache.delete(s)\n }\n cache.add(s)\n\n const ret = normalizeCache[s] as string\n\n let i = cache.size - MAX\n // only prune when we're 10% over the max\n if (i > MAX / 10) {\n for (const s of cache) {\n cache.delete(s)\n delete normalizeCache[s]\n if (--i <= 0) break\n }\n }\n\n return ret\n}\n", "// The async extraction does several entries at one time. Two entries\n// must not work on the same path at one time: a link needs its\n// target, and an entry can replace an object of a different type.\n\nimport { normalizeUnicode } from './normalize-unicode.js'\nimport { stripTrailingSlashes } from './strip-trailing-slashes.js'\nimport { join } from './path.js'\n\ntype Handler = () => void\ntype Queue = (Handler | Set<Handler>)[]\ntype Reservation = { paths: string[]; dirs: Set<string> }\n\n// The parent directories of a normalized path.\n// '/a/b/c' gives ['/', '/a', '/a/b'].\nconst getDirs = (path: string) => {\n const dirs: string[] = []\n for (let i = path.indexOf('/'); i !== -1; i = path.indexOf('/', i + 1)) {\n dirs.push(path.slice(0, i) || '/')\n }\n return dirs\n}\n\n/**\n * Gives each task the exclusive use of its paths, and the shared use\n * of their parent directories. A task starts when each task before\n * it that uses one of its paths, or a directory above or below one,\n * is done.\n *\n * Paths that differ only in case or in Unicode form are the same\n * path, because they can be the same file on disk.\n */\nexport class PathReservations {\n // For each path: the tasks that wait for it, in order. A function\n // has the path for itself. A Set of functions shares the path as a\n // parent directory.\n #queues = new Map<string, Queue>()\n #reservations = new Map<Handler, Reservation>()\n #running = new Set<Handler>()\n #win32: boolean\n\n /** @param win32 run one task at a time */\n constructor(win32: boolean = false) {\n this.#win32 = win32\n }\n\n /**\n * Call `fn` when it is first in line for each of its paths. The\n * paths are free again when the promise of `fn` settles. Returns a\n * promise with the result of `fn`.\n */\n reserve(paths: string[], fn: () => Promise<void>): Promise<void> {\n return new Promise<void>((res, rej) => {\n const handler: Handler = () => {\n fn().then(\n () => {\n this.#clear(handler)\n res()\n },\n er => {\n this.#clear(handler)\n rej(er)\n },\n )\n }\n this.#add(paths, handler)\n })\n }\n\n #add(paths: string[], fn: Handler) {\n paths =\n this.#win32 ?\n ['win32 parallelization disabled']\n : [\n ...new Set(\n paths.map(p =>\n stripTrailingSlashes(join(normalizeUnicode(p))),\n ),\n ),\n ]\n const dirs = new Set<string>(paths.flatMap(getDirs))\n // A path of the task is exclusive, so it also covers the use of\n // that path as a parent directory of another path.\n for (const p of paths) dirs.delete(p)\n this.#reservations.set(fn, { dirs, paths })\n for (const p of paths) {\n const q = this.#queues.get(p)\n if (!q) this.#queues.set(p, [fn])\n else q.push(fn)\n }\n for (const dir of dirs) {\n const q = this.#queues.get(dir)\n const last = q?.[q.length - 1]\n if (!q) this.#queues.set(dir, [new Set([fn])])\n else if (last instanceof Set) last.add(fn)\n else q.push(new Set([fn]))\n }\n this.#run(fn)\n }\n\n // Start the task if it is first in line for each path, and in the\n // first set for each directory. A task that waits is never first in\n // line for each of them, so a task starts one time only.\n #run(fn: Handler) {\n const { paths, dirs } = this.#reservations.get(fn) as Reservation\n for (const p of paths) {\n if (this.#queues.get(p)?.[0] !== fn) return\n }\n for (const dir of dirs) {\n const first = this.#queues.get(dir)?.[0]\n if (!(first instanceof Set) || !first.has(fn)) return\n }\n this.#running.add(fn)\n fn()\n }\n\n #clear(fn: Handler) {\n const { paths, dirs } = this.#reservations.get(fn) as Reservation\n const next = new Set<Handler>()\n for (const path of paths) {\n // A running task is first in the queue of each of its paths.\n const q = this.#queues.get(path) as Queue\n const after = q[1]\n if (!after) {\n this.#queues.delete(path)\n continue\n }\n q.shift()\n if (typeof after === 'function') next.add(after)\n else for (const f of after) next.add(f)\n }\n for (const dir of dirs) {\n // A running task is in the first set of each of its directories.\n const q = this.#queues.get(dir) as Queue\n const first = q[0] as Set<Handler>\n if (first.size > 1) first.delete(fn)\n else if (q.length === 1) this.#queues.delete(dir)\n else {\n q.shift()\n // Two sets in a row would be one set, so this is a function.\n next.add(q[0] as Handler)\n }\n }\n this.#running.delete(fn)\n this.#reservations.delete(fn)\n for (const f of next) this.#run(f)\n }\n}\n", "/** The flag values of `fs.constants` that the extraction uses. */\nexport type OpenConstants = {\n O_CREAT: number\n O_TRUNC: number\n O_WRONLY: number\n O_NOFOLLOW?: number\n UV_FS_O_FILEMAP?: number\n}\n\n// Windows writes a small file faster through a file mapping.\nconst FMAP_LIMIT = 512 * 1024\n\n/**\n * Make the function that gives the `open` flag for a new file of a\n * given size.\n *\n * With `O_NOFOLLOW`, `open` fails if the path is a symbolic link.\n * Windows does not have it. If `constants` is not set, the flag is\n * `'w'`.\n */\nexport const writeFlags = (\n constants: OpenConstants | undefined,\n win32: boolean,\n): ((size: number) => string | number) => {\n if (!constants) return () => 'w'\n const { O_CREAT, O_TRUNC, O_WRONLY, O_NOFOLLOW, UV_FS_O_FILEMAP } =\n constants\n const write = O_TRUNC | O_CREAT | O_WRONLY\n if (!win32) {\n const flag = typeof O_NOFOLLOW === 'number' ? O_NOFOLLOW | write : 'w'\n return () => flag\n }\n if (!UV_FS_O_FILEMAP) return () => 'w'\n const fmap = UV_FS_O_FILEMAP | write\n return size => (size < FMAP_LIMIT ? fmap : 'w')\n}\n", "import { SymlinkError } from './symlink-error.js'\nimport type { EntryTypeName } from './types.js'\nimport * as wc from './winchars.js'\nimport { TarReader, TarReaderSync } from './entries.js'\nimport type { ExtractFS, ExtractFSSync, ExtractStats } from './fs.js'\nimport { mkdir, mkdirSync, type MkdirOptions } from './mkdir.js'\nimport {\n countOption,\n ownOptions,\n type ExtractOptions,\n type ExtractOptionsSync,\n type ReadOptions,\n type TarInput,\n type TarInputSync,\n type UnpackOptions,\n} from './options.js'\nimport { PathReservations } from './path-reservations.js'\nimport {\n dirname,\n isAbsolute,\n join,\n normalize,\n relative,\n resolve,\n} from './path.js'\nimport type { EntryData, ReadEntry, ReadEntrySync } from './read-entry.js'\nimport { stripAbsolutePath } from './strip-absolute-path.js'\nimport { warn, type WarnData } from './warn.js'\nimport {\n win32Dirname,\n win32IsAbsolute,\n win32Resolve,\n win32Root,\n} from './win32-path.js'\nimport { writeFlags, type OpenConstants } from './write-flag.js'\n\nconst DEFAULT_MAX_DEPTH = 1024\n// Longer than any path that a supported platform can create.\nconst MAX_PATH_LENGTH = 32768\nconst DEFAULT_JOBS = 16\n\nconst fileTypes = new Set<EntryTypeName>([\n 'File',\n 'OldFile',\n 'ContiguousFile',\n])\nconst dirTypes = new Set<EntryTypeName>(['Directory', 'GNUDumpDir'])\nconst linkTypes = new Set<EntryTypeName>(['Link', 'SymbolicLink'])\n\n// The first of the values that is an unsigned 32-bit integer, or the\n// last value.\nconst uint32 = (\n a: number | undefined,\n b: number | undefined,\n c: number | undefined,\n) =>\n a !== undefined ? a\n : b !== undefined && b === b >>> 0 ? b\n : c\n\n/** The options that `UnpackBase` reads. */\nexport type UnpackBaseOptions<E extends EntryData> = ReadOptions<E> &\n UnpackOptions & { fs: { constants?: OpenConstants } }\n\n/**\n * The parts of the extraction that do not use the file system: the\n * options, the checks of each entry, and the warnings. `Unpack` and\n * `UnpackSync` add the file system work.\n */\nexport class UnpackBase<\n E extends EntryData,\n O extends UnpackBaseOptions<E> = UnpackBaseOptions<E>,\n> {\n /** The options, with no prototype. */\n opt: O\n /** The absolute path of the extraction directory. */\n cwd: string\n win32: boolean\n strip: number\n maxDepth: number\n preservePaths: boolean\n unlink: boolean\n keep: boolean\n newer: boolean\n noMtime: boolean\n chmod: boolean\n uid?: number\n gid?: number\n preserveOwner: boolean\n forceChown: boolean\n processUid?: number\n processGid?: number\n processUmask: number\n umask: number\n dmode: number\n fmode: number\n /** Gives the `open` flag for a new file of a given size. */\n writeFlag: (size: number) => string | number\n /** Resolve a path from an absolute path. */\n resolve: (base: string, path: string) => string\n /** The parent directory of an absolute path. */\n dirname: (path: string) => string\n /** Set when an error stops the extraction. */\n fatal?: { error: unknown }\n\n constructor(options: O) {\n const opt = (this.opt = ownOptions(options))\n const win32 = (this.win32 = opt.platform === 'win32')\n this.resolve = win32 ? win32Resolve : resolve\n this.dirname = win32 ? win32Dirname : dirname\n\n if (typeof opt.cwd !== 'string') {\n throw new TypeError('cwd is required')\n }\n const cwd = win32 ? opt.cwd.replaceAll('\\\\', '/') : opt.cwd\n if (!(win32 ? win32IsAbsolute : isAbsolute)(cwd)) {\n throw new TypeError('cwd must be an absolute path')\n }\n this.cwd = this.resolve(cwd, '')\n\n if (typeof opt.uid === 'number' || typeof opt.gid === 'number') {\n // need both or neither\n if (typeof opt.uid !== 'number' || typeof opt.gid !== 'number') {\n throw new TypeError('cannot set owner without number uid and gid')\n }\n // A value that is not valid must not fall back to the owner\n // in the archive.\n if (opt.uid !== opt.uid >>> 0 || opt.gid !== opt.gid >>> 0) {\n throw new TypeError('uid and gid must be unsigned 32-bit integers')\n }\n if (opt.preserveOwner) {\n throw new TypeError(\n 'cannot preserve owner in archive and also set owner explicitly',\n )\n }\n this.uid = opt.uid\n this.gid = opt.gid\n }\n this.processUid = opt.processUid\n this.processGid = opt.processGid\n this.preserveOwner =\n opt.preserveOwner === undefined && typeof opt.uid !== 'number' ?\n opt.processUid === 0\n : !!opt.preserveOwner\n this.forceChown = opt.forceChown === true\n\n this.maxDepth =\n typeof opt.maxDepth === 'number' ? opt.maxDepth : DEFAULT_MAX_DEPTH\n this.strip = Number(opt.strip) || 0\n this.preservePaths = !!opt.preservePaths\n this.unlink = !!opt.unlink\n this.keep = !!opt.keep\n this.newer = !!opt.newer\n this.noMtime = !!opt.noMtime\n this.chmod = !!opt.chmod\n\n // Without chmod, the umask of the process is not needed.\n this.processUmask =\n !this.chmod ? 0\n : typeof opt.processUmask === 'number' ? opt.processUmask\n : 0o22\n this.umask =\n typeof opt.umask === 'number' ? opt.umask : this.processUmask\n this.dmode = opt.dmode || 0o777 & ~this.umask\n this.fmode = opt.fmode || 0o666 & ~this.umask\n\n this.writeFlag = writeFlags(opt.fs.constants, win32)\n }\n\n /**\n * Report a problem to `onwarn`, or throw it if `strict` is set. A\n * damaged archive is always an error here, because the extraction\n * cannot be complete.\n */\n warn(code: string, message: string | Error, data: WarnData = {}): void {\n if (code === 'TAR_BAD_ARCHIVE' || code === 'TAR_ABORT') {\n data.recoverable = false\n }\n data.cwd = this.cwd\n warn(this.opt, code, message, data)\n }\n\n /** The options for the reader. Its warnings go to `warn()`. */\n readerOptions(): ReadOptions<E> {\n return ownOptions<ReadOptions<E>>(this.opt, {\n strict: false,\n onwarn: (code, message, data) =>\n data instanceof Error ?\n this.warn(code, data)\n : this.warn(code, message, data),\n })\n }\n\n /**\n * Report the failure of one entry as a `TAR_ENTRY_ERROR` warning.\n * Throws the error if it stops the extraction: the extraction\n * directory is not usable, the archive cannot be read, or `strict`\n * is set.\n */\n entryError(er: unknown, entry: E): void {\n if (this.fatal?.error === er || (er as Error)?.name === 'CwdError') {\n throw er\n }\n this.warn('TAR_ENTRY_ERROR', er as Error, { entry })\n }\n\n /** Record the error that stops the extraction. Returns it. */\n fail(error: unknown): unknown {\n this.fatal ??= { error }\n return error\n }\n\n // Remove the root of an absolute path, and refuse a path that can\n // leave the extraction directory. False if the entry is refused.\n #stripAbsolutePath(entry: E, field: 'path' | 'linkpath'): boolean {\n const p = entry[field]\n if (!p || this.preservePaths) return true\n\n const [root, stripped] = stripAbsolutePath(p)\n const parts = stripped.replaceAll('\\\\', '/').split('/')\n\n if (parts.includes('..')) {\n // A path, and the target of a hard link, cannot have '..' at\n // all. The target of a symbolic link is relative to the\n // directory of the link, so '../sibling/file' can be valid.\n if (field === 'path' || entry.type === 'Link') {\n this.warn('TAR_ENTRY_ERROR', `${field} contains '..'`, {\n entry,\n [field]: p,\n })\n return false\n }\n // A '..' is only safe at the start of the target. Any named\n // part before it can be a symlink, and then the '..' goes to\n // the parent of the target of that symlink.\n const firstName = parts.findIndex(\n part => part !== '..' && part !== '.' && part !== '',\n )\n if (firstName !== -1 && parts.includes('..', firstName)) {\n this.warn(\n 'TAR_ENTRY_ERROR',\n `${field} contains '..' after a path portion`,\n { entry, [field]: p },\n )\n return false\n }\n // Normalize the path, so that the directory is the one where\n // the link is created. The path 'x/.' creates the link 'x'.\n const entryDir = dirname(normalize(entry.path))\n const resolved = normalize(join(entryDir, parts.join('/')))\n if (resolved.startsWith('../') || resolved === '..') {\n this.warn(\n 'TAR_ENTRY_ERROR',\n `${field} escapes extraction directory`,\n { entry, [field]: p },\n )\n return false\n }\n }\n\n if (root) {\n ;(entry as EntryData)[field] = stripped\n this.warn(\n 'TAR_ENTRY_INFO',\n `stripping ${root} from absolute ${field}`,\n { entry, [field]: p },\n )\n }\n return true\n }\n\n /**\n * Check the entry, with no use of the file system. Set its\n * `absolute` path, and change its `path`, `linkpath`, and `mode` to\n * the values to extract. False if the entry must not be extracted.\n */\n check(entry: E): boolean {\n const p = entry.path\n const parts = p.split('/')\n\n if (this.strip) {\n if (parts.length < this.strip) return false\n if (entry.type === 'Link') {\n const linkparts = String(entry.linkpath).split('/')\n if (linkparts.length < this.strip) return false\n entry.linkpath = linkparts.slice(this.strip).join('/')\n }\n parts.splice(0, this.strip)\n // No part of the path is left, as for the top directory of a\n // package. The entry must not change the extraction directory.\n if (parts.every(part => part === '')) return false\n entry.path = parts.join('/')\n }\n\n const { maxDepth } = this\n if (isFinite(maxDepth) && parts.length > maxDepth) {\n this.warn('TAR_ENTRY_ERROR', 'path excessively deep', {\n entry,\n path: p,\n depth: parts.length,\n maxDepth,\n })\n return false\n }\n // The path reservations do work for each parent directory of the\n // path and of the linkpath.\n const { linkpath } = entry\n if (\n linkpath &&\n isFinite(maxDepth) &&\n linkpath.split('/').length > maxDepth\n ) {\n this.warn('TAR_ENTRY_ERROR', 'linkpath excessively deep', {\n entry,\n path: p,\n linkpath,\n maxDepth,\n })\n return false\n }\n for (const field of ['path', 'linkpath'] as const) {\n const { length } = entry[field] ?? ''\n if (length > MAX_PATH_LENGTH) {\n this.warn('TAR_ENTRY_ERROR', `${field} excessively long`, {\n entry,\n path: p,\n length,\n maxLength: MAX_PATH_LENGTH,\n })\n return false\n }\n }\n\n if (\n !this.#stripAbsolutePath(entry, 'path') ||\n !this.#stripAbsolutePath(entry, 'linkpath')\n ) {\n return false\n }\n\n const { cwd } = this\n let absolute = this.resolve(cwd, entry.path)\n\n // The checks above refuse a path that leaves the extraction\n // directory. This check is defense in depth.\n if (\n !this.preservePaths &&\n absolute !== cwd &&\n // A root, such as `/` or `c:/`, ends with a slash.\n !absolute.startsWith(cwd.endsWith('/') ? cwd : cwd + '/')\n ) {\n this.warn('TAR_ENTRY_ERROR', 'path escaped extraction target', {\n entry,\n path: entry.path,\n resolvedPath: absolute,\n cwd,\n })\n return false\n }\n\n // An archive can set properties of the extraction directory, but\n // it cannot replace it with a different kind of thing.\n if (absolute === cwd && !dirTypes.has(entry.type)) return false\n\n // Do not change the ':' of a drive letter.\n if (this.win32) {\n const aRoot = win32Root(absolute)\n absolute = aRoot + wc.encode(absolute.slice(aRoot.length))\n const pRoot = win32Root(entry.path)\n entry.path = pRoot + wc.encode(entry.path.slice(pRoot.length))\n }\n entry.absolute = absolute\n\n // Never set the setuid, setgid, or sticky bit from an archive.\n if (typeof entry.mode === 'number') entry.mode &= 0o777\n\n if (dirTypes.has(entry.type)) {\n if (entry.mode) entry.mode |= 0o700\n } else if (!fileTypes.has(entry.type) && !linkTypes.has(entry.type)) {\n // A device or a FIFO is never made.\n entry.unsupported = true\n this.warn(\n 'TAR_ENTRY_UNSUPPORTED',\n `unsupported entry type: ${entry.type}`,\n { entry },\n )\n return false\n }\n return true\n }\n\n /**\n * The paths that the entry must have for itself while it is made.\n * A link also reserves its target, so that an entry that makes the\n * target, and an entry that goes through the link, do not run at\n * the same time as the link.\n */\n reservedPaths(entry: E): string[] {\n const { path, linkpath } = entry\n if (!linkpath) return [path]\n // The target of a symlink is relative to the directory of the\n // link. The target of a hard link is relative to the cwd.\n return [\n path,\n entry.type === 'SymbolicLink' && !isAbsolute(linkpath) ?\n join(dirname(path), linkpath)\n : linkpath,\n ]\n }\n\n /** The options to make a directory with a mode. */\n mkdirOptions(mode: number): MkdirOptions {\n return {\n uid: this.uid,\n gid: this.gid,\n processUid: this.processUid,\n processGid: this.processGid,\n umask: this.processUmask,\n preserve: this.preservePaths,\n unlink: this.unlink,\n cwd: this.cwd,\n mode,\n }\n }\n\n /**\n * The owner to set on the entry, if it needs one: with\n * `preserveOwner`, when the owner in the archive is not the process\n * owner, and with `uid` and `gid`, when they are not the process\n * owner.\n */\n owner(entry: E): { uid: number; gid: number } | undefined {\n const doChown =\n this.forceChown ||\n (this.preserveOwner &&\n ((typeof entry.uid === 'number' &&\n entry.uid !== this.processUid) ||\n (typeof entry.gid === 'number' &&\n entry.gid !== this.processGid))) ||\n (typeof this.uid === 'number' && this.uid !== this.processUid) ||\n (typeof this.gid === 'number' && this.gid !== this.processGid)\n const uid = uint32(this.uid, entry.uid, this.processUid)\n const gid = uint32(this.gid, entry.gid, this.processGid)\n return doChown && typeof uid === 'number' && typeof gid === 'number' ?\n { uid, gid }\n : undefined\n }\n\n /** The times to set on the entry, if it needs them. */\n times(entry: E): { atime: Date; mtime: Date } | undefined {\n return entry.mtime && !this.noMtime ?\n { atime: entry.atime || new Date(), mtime: entry.mtime }\n : undefined\n }\n\n /** True if the object on disk at the path of the entry must stay. */\n skip(entry: E, st: ExtractStats): boolean {\n return (\n this.keep || (this.newer && st.mtime > (entry.mtime ?? st.mtime))\n )\n }\n\n /**\n * True if the entry can be written into the file that is on disk.\n * A file with more than one link is not used, because the write\n * would change the other links. Windows does not report a useful\n * link count.\n */\n isReusable(entry: E, st: ExtractStats): boolean {\n return (\n entry.type === 'File' &&\n !this.unlink &&\n st.isFile() &&\n st.nlink <= 1 &&\n !this.win32\n )\n }\n\n /**\n * The parts of the path from the extraction directory to the\n * target of a link entry. None of them can be a symbolic link.\n */\n linkParts(entry: E, absolute: string): string[] {\n const linkpath = String(entry.linkpath)\n return entry.type === 'Link' ?\n linkpath.split('/')\n : relative(\n this.cwd,\n this.resolve(this.dirname(absolute), linkpath),\n ).split('/')\n }\n\n /** The error for a link target that goes through a symbolic link. */\n symlinkError(symlink: string, parts: string[]): SymlinkError {\n return new SymlinkError(\n symlink,\n this.resolve(this.cwd, parts.join('/')),\n )\n }\n}\n\n// Unlinks on Windows are not atomic. A file that is made at the path\n// of a file that was just removed can be removed with it. So rename\n// the file first, and then remove it under the new name.\nconst deleteName = (path: string) =>\n path +\n '.DELETE.' +\n Array.from(crypto.getRandomValues(new Uint8Array(16)), b =>\n b.toString(16).padStart(2, '0'),\n ).join('')\n\n/**\n * Extracts the entries of an archive with async file system\n * functions.\n *\n * Several entries are extracted at one time. Entries that use the\n * same path, or a path and a directory above it, are extracted in\n * the order of the archive.\n */\nexport class Unpack extends UnpackBase<ReadEntry, ExtractOptions> {\n #fs: ExtractFS\n #reservations: PathReservations\n #jobs: number\n // the number of entries that are in work\n #active: number = 0\n #wake?: () => void\n #checkedCwd: boolean = false\n #cwdCheck?: Promise<void>\n\n constructor(opt: ExtractOptions) {\n super(opt)\n this.#fs = this.opt.fs\n this.#reservations = new PathReservations(this.win32)\n this.#jobs = countOption('jobs', this.opt.jobs, DEFAULT_JOBS)\n }\n\n /**\n * Extract the archive. The promise settles when all the file\n * system work is done. It rejects with the first error that stops\n * the extraction.\n */\n async extract(input: TarInput): Promise<void> {\n const reader = new TarReader(input, this.readerOptions())\n const { onEntry } = this.opt\n const stream = !!this.opt.transform\n try {\n while (!this.fatal) {\n const entry = reader.poll()\n if (entry === null) break\n if (entry === undefined) {\n await reader.fill()\n continue\n }\n if (onEntry) await onEntry(entry)\n // The caller took the content, so there is nothing to write.\n if (entry.bodyUsed) continue\n if (!this.check(entry)) continue\n\n // A file whose content is all in memory is written while the\n // next entries are read. Other files are written as their\n // content arrives.\n const body: Uint8Array[] = []\n let inMemory = !stream\n if (inMemory && fileTypes.has(entry.type)) {\n for (;;) {\n const part = reader.readBody(entry)\n if (part === null) break\n if (part === undefined) {\n inMemory = false\n break\n }\n body.push(part)\n }\n }\n const work = this.#start(\n entry,\n body,\n inMemory ? undefined : reader,\n )\n if (!inMemory) await work\n while (this.#active >= this.#jobs) await this.#idle()\n }\n } catch (er) {\n this.fail(er)\n }\n await reader.return().catch(er => this.fail(er))\n while (this.#active > 0) await this.#idle()\n if (this.fatal) {\n const { error } = this.fatal\n if (error && typeof error === 'object' && 'tarCode' in error) {\n Object.assign(error, { cwd: this.cwd })\n }\n throw error\n }\n }\n\n // Resolves when an entry that is in work is done.\n #idle(): Promise<void> {\n return new Promise<void>(res => {\n this.#wake = res\n })\n }\n\n // Extract the entry when its paths are free. The promise never\n // rejects: a failure is a warning, or it sets `fatal`.\n #start(\n entry: ReadEntry,\n body: Uint8Array[],\n reader: TarReader | undefined,\n ): Promise<void> {\n this.#active++\n return this.#reservations.reserve(\n this.reservedPaths(entry),\n async () => {\n try {\n if (!this.fatal) await this.#extract(entry, body, reader)\n } catch (er) {\n try {\n this.entryError(er, entry)\n } catch (fatal) {\n this.fail(fatal)\n }\n }\n this.#active--\n this.#wake?.()\n },\n )\n }\n\n #mkdir(dir: string, mode: number): Promise<void> {\n return mkdir(this.#fs, dir, this.mkdirOptions(mode))\n }\n\n // The extraction directory must exist. Entries that start at the\n // same time share one check.\n #checkCwd(): Promise<void> {\n return (this.#cwdCheck ??= this.#mkdir(this.cwd, this.dmode).then(\n () => {\n this.#checkedCwd = true\n },\n er => {\n this.#cwdCheck = undefined\n throw er\n },\n ))\n }\n\n async #extract(\n entry: ReadEntry,\n body: Uint8Array[],\n reader: TarReader | undefined,\n ): Promise<void> {\n const fs = this.#fs\n const absolute = entry.absolute as string\n const { cwd } = this\n if (!this.#checkedCwd) await this.#checkCwd()\n if (absolute !== cwd) {\n const parent = this.dirname(absolute)\n if (parent !== cwd) await this.#mkdir(parent, this.dmode)\n }\n\n // Remove what is at the path, if the entry cannot use it.\n const st = await fs.lstat(absolute).catch(() => undefined)\n if (st && this.skip(entry, st)) return\n if (st && !this.isReusable(entry, st)) {\n if (st.isDirectory() && dirTypes.has(entry.type)) {\n if (\n this.chmod &&\n entry.mode &&\n (st.mode & 0o7777) !== entry.mode\n ) {\n await fs.chmod(absolute, entry.mode)\n }\n } else if (absolute !== cwd) {\n if (st.isDirectory()) await fs.rmdir(absolute)\n else await this.#unlink(absolute)\n }\n }\n\n if (fileTypes.has(entry.type)) {\n return this.#file(entry, absolute, body, reader)\n }\n if (dirTypes.has(entry.type)) return this.#directory(entry, absolute)\n await this.#ensureNoSymlink(this.linkParts(entry, absolute))\n const linkpath = String(entry.linkpath)\n if (entry.type === 'Link') {\n await fs.link(this.resolve(cwd, linkpath), absolute)\n } else {\n await fs.symlink(linkpath, absolute)\n }\n }\n\n async #unlink(path: string): Promise<void> {\n const fs = this.#fs\n if (!this.win32) return fs.unlink(path)\n const name = deleteName(path)\n await fs.rename(path, name)\n await fs.unlink(name)\n }\n\n async #ensureNoSymlink(parts: string[]): Promise<void> {\n if (this.preservePaths) return\n let t = this.cwd\n for (const p of parts) {\n t = this.resolve(t, p)\n const st = await this.#fs.lstat(t).catch(() => undefined)\n if (!st) return\n if (st.isSymbolicLink()) throw this.symlinkError(t, parts)\n }\n }\n\n async #directory(entry: ReadEntry, absolute: string): Promise<void> {\n const fs = this.#fs\n await this.#mkdir(absolute, entry.mode ?? this.dmode)\n // These do not follow a symbolic link that replaced the\n // directory. A failure is not an error of the entry.\n const times = this.times(entry)\n if (times) {\n await fs.lutimes(absolute, times.atime, times.mtime).catch(() => {})\n }\n const owner = this.owner(entry)\n if (owner) {\n await fs.lchown(absolute, owner.uid, owner.gid).catch(() => {})\n }\n }\n\n async #file(\n entry: ReadEntry,\n absolute: string,\n body: Uint8Array[],\n reader: TarReader | undefined,\n ): Promise<void> {\n const fs = this.#fs\n const handle = await fs.open(\n absolute,\n this.writeFlag(entry.size),\n entry.mode ?? this.fmode,\n )\n try {\n if (reader) await this.#pipe(entry, body, reader, handle)\n else for (const part of body) await handle.write(part)\n\n // Use the open file, so that a symbolic link that replaced the\n // path is not followed. If that fails, use the path.\n const times = this.times(entry)\n if (times) {\n const { atime, mtime } = times\n await handle.utimes(atime, mtime).catch(async er => {\n await fs.utimes(absolute, atime, mtime).catch(() => {\n throw er\n })\n })\n }\n const owner = this.owner(entry)\n if (owner) {\n const { uid, gid } = owner\n await handle.chown(uid, gid).catch(async er => {\n await fs.chown(absolute, uid, gid).catch(() => {\n throw er\n })\n })\n }\n } catch (er) {\n await handle.close().catch(() => {})\n throw er\n }\n await handle.close()\n }\n\n // Write the content of the entry as it arrives, through the\n // transform stream if there is one.\n async #pipe(\n entry: ReadEntry,\n body: Uint8Array[],\n reader: TarReader,\n handle: { write(data: Uint8Array): Promise<unknown> },\n ): Promise<void> {\n let i = 0\n const next = async (): Promise<Uint8Array | null> => {\n if (i < body.length) return body[i++] as Uint8Array\n try {\n for (;;) {\n const part = reader.readBody(entry)\n if (part !== undefined) return part\n await reader.fill()\n }\n } catch (er) {\n // The archive cannot be read.\n throw this.fail(er)\n }\n }\n\n const tx = this.opt.transform?.(entry)\n if (!tx) {\n // Write one part while the next part is read.\n let writing: Promise<void> | undefined\n let failed: { error: unknown } | undefined\n try {\n for (let part; (part = await next()); ) {\n await writing\n if (failed) break\n writing = handle.write(part).then(\n () => {},\n error => {\n failed = { error }\n },\n )\n }\n } finally {\n await writing\n }\n if (failed) throw failed.error\n return\n }\n\n const writer = tx.writable.getWriter()\n const out = tx.readable.getReader()\n let failed: { error: unknown } | undefined\n // Stop the two streams. A read that waits gets the end of the\n // stream, and a write that waits fails.\n const stop = async (error: unknown) => {\n failed ??= { error }\n await out.cancel(error).catch(() => {})\n await writer.abort(error).catch(() => {})\n }\n const feed = (async () => {\n try {\n for (let part; (part = await next()); ) await writer.write(part)\n await writer.close()\n } catch (er) {\n await stop(er)\n }\n })()\n try {\n for (;;) {\n const { done, value } = await out.read()\n if (done) break\n await handle.write(value)\n }\n } catch (er) {\n await stop(er)\n }\n // The feed reads the archive, so it must end before the next\n // entry is read.\n await feed\n if (failed) throw failed.error\n }\n}\n\n/**\n * Extracts the entries of an archive with sync file system\n * functions, one entry at a time.\n */\nexport class UnpackSync extends UnpackBase<\n ReadEntrySync,\n ExtractOptionsSync\n> {\n #fs: ExtractFSSync\n #checkedCwd: boolean = false\n\n constructor(opt: ExtractOptionsSync) {\n super(opt)\n this.#fs = this.opt.fs\n }\n\n /** Extract the archive. Throws the first error that stops it. */\n extract(input: TarInputSync): void {\n const reader = new TarReaderSync(input, this.readerOptions())\n const { onEntry } = this.opt\n try {\n for (const entry of reader) {\n onEntry?.(entry)\n if (entry.bodyUsed) continue\n if (!this.check(entry)) continue\n try {\n this.#extract(entry, reader)\n } catch (er) {\n this.entryError(er, entry)\n }\n }\n } catch (error) {\n if (error && typeof error === 'object' && 'tarCode' in error) {\n Object.assign(error, { cwd: this.cwd })\n }\n throw error\n }\n }\n\n #mkdir(dir: string, mode: number): void {\n mkdirSync(this.#fs, dir, this.mkdirOptions(mode))\n }\n\n #extract(entry: ReadEntrySync, reader: TarReaderSync): void {\n const fs = this.#fs\n const absolute = entry.absolute as string\n const { cwd } = this\n if (!this.#checkedCwd) {\n this.#mkdir(cwd, this.dmode)\n this.#checkedCwd = true\n }\n if (absolute !== cwd) {\n const parent = this.dirname(absolute)\n if (parent !== cwd) this.#mkdir(parent, this.dmode)\n }\n\n // Remove what is at the path, if the entry cannot use it.\n let st: ExtractStats | undefined\n try {\n st = fs.lstatSync(absolute)\n } catch {}\n if (st && this.skip(entry, st)) return\n if (st && !this.isReusable(entry, st)) {\n if (st.isDirectory() && dirTypes.has(entry.type)) {\n if (\n this.chmod &&\n entry.mode &&\n (st.mode & 0o7777) !== entry.mode\n ) {\n fs.chmodSync(absolute, entry.mode)\n }\n } else if (absolute !== cwd) {\n if (st.isDirectory()) fs.rmdirSync(absolute)\n else this.#unlink(absolute)\n }\n }\n\n if (fileTypes.has(entry.type)) {\n return this.#file(entry, absolute, reader)\n }\n if (dirTypes.has(entry.type)) return this.#directory(entry, absolute)\n this.#ensureNoSymlink(this.linkParts(entry, absolute))\n const linkpath = String(entry.linkpath)\n if (entry.type === 'Link') {\n fs.linkSync(this.resolve(cwd, linkpath), absolute)\n } else {\n fs.symlinkSync(linkpath, absolute)\n }\n }\n\n #unlink(path: string): void {\n const fs = this.#fs\n if (!this.win32) return fs.unlinkSync(path)\n const name = deleteName(path)\n fs.renameSync(path, name)\n fs.unlinkSync(name)\n }\n\n #ensureNoSymlink(parts: string[]): void {\n if (this.preservePaths) return\n let t = this.cwd\n for (const p of parts) {\n t = this.resolve(t, p)\n let st: ExtractStats\n try {\n st = this.#fs.lstatSync(t)\n } catch {\n return\n }\n if (st.isSymbolicLink()) throw this.symlinkError(t, parts)\n }\n }\n\n #directory(entry: ReadEntrySync, absolute: string): void {\n const fs = this.#fs\n this.#mkdir(absolute, entry.mode ?? this.dmode)\n // These do not follow a symbolic link that replaced the\n // directory. A failure is not an error of the entry.\n const times = this.times(entry)\n if (times) {\n try {\n fs.lutimesSync(absolute, times.atime, times.mtime)\n } catch {}\n }\n const owner = this.owner(entry)\n if (owner) {\n try {\n fs.lchownSync(absolute, owner.uid, owner.gid)\n } catch {}\n }\n }\n\n #file(\n entry: ReadEntrySync,\n absolute: string,\n reader: TarReaderSync,\n ): void {\n const fs = this.#fs\n const fd = fs.openSync(\n absolute,\n this.writeFlag(entry.size),\n entry.mode ?? this.fmode,\n )\n try {\n const tx = this.opt.transform?.(entry)\n for (;;) {\n let part: Uint8Array | null\n try {\n part = reader.readBody(entry)\n } catch (er) {\n // The archive cannot be read.\n throw this.fail(er)\n }\n if (!part) break\n fs.writeSync(fd, tx ? tx(part) : part)\n }\n\n // Use the open file, so that a symbolic link that replaced the\n // path is not followed. If that fails, use the path.\n const times = this.times(entry)\n if (times) {\n const { atime, mtime } = times\n try {\n fs.futimesSync(fd, atime, mtime)\n } catch (er) {\n try {\n fs.utimesSync(absolute, atime, mtime)\n } catch {\n throw er\n }\n }\n }\n const owner = this.owner(entry)\n if (owner) {\n const { uid, gid } = owner\n try {\n fs.fchownSync(fd, uid, gid)\n } catch (er) {\n try {\n fs.chownSync(absolute, uid, gid)\n } catch {\n throw er\n }\n }\n }\n } catch (er) {\n // Close the file one time, and do not use the descriptor again:\n // the system can give its number to a different file.\n try {\n fs.closeSync(fd)\n } catch {}\n throw er\n }\n fs.closeSync(fd)\n }\n}\n", "import { dealias, type WithAliases } from './dealias.js'\nimport { filesFilter } from './list.js'\nimport type { ExtractOptions, ExtractOptionsSync } from './options.js'\nimport { readFile, readFileSync } from './read-file.js'\nimport { Unpack, UnpackSync } from './unpack.js'\n\nconst noInput = () => new TypeError('extract needs input or file')\n\n/**\n * Extract the entries of an archive into the directory `opt.cwd`.\n * If `files` is set, only the entries that it lists, and the entries\n * in the directories that it lists.\n *\n * A problem with one entry is a warning for `opt.onwarn`, and the\n * extraction continues. A listed path that no entry matches is a\n * warning when the archive ends. With `opt.strict`, each is an error.\n */\nexport const extract = async (\n options: WithAliases<ExtractOptions>,\n files?: string[],\n): Promise<void> => {\n const opt = dealias<ExtractOptions>(options)\n const source =\n opt.input ??\n (opt.file ? readFile(opt.fs, opt.file, opt.maxReadSize) : undefined)\n if (!source) throw noInput()\n const [filter, report] =\n files?.length ? filesFilter(files, opt.filter) : []\n if (filter) opt.filter = filter\n await new Unpack(opt).extract(source)\n report?.(opt)\n}\n\n/** The sync form of `extract`. */\nexport const extractSync = (\n options: WithAliases<ExtractOptionsSync>,\n files?: string[],\n): void => {\n const opt = dealias<ExtractOptionsSync>(options)\n const source =\n opt.input ??\n (opt.file ?\n readFileSync(opt.fs, opt.file, opt.maxReadSize)\n : undefined)\n if (!source) throw noInput()\n const [filter, report] =\n files?.length ? filesFilter(files, opt.filter) : []\n if (filter) opt.filter = filter\n new UnpackSync(opt).extract(source)\n report?.(opt)\n}\n", "import { gzip, type Codec } from './codec.js'\nimport { dealias, type WithAliases } from './dealias.js'\nimport {\n packFiles,\n packFilesSync,\n writeChunks,\n writeChunksSync,\n} from './create.js'\nimport type { ReplaceOptions, ReplaceOptionsSync } from './options.js'\nimport type { PackInput, PackInputSync } from './pack.js'\nimport { Parser } from './parser.js'\n\n// The most bytes to read from the archive at one time.\nconst CHUNK = 64 * 1024\n// Thrown in the parser to stop at the first block that is not valid.\nconst STOP = {}\nconst noop = () => {}\n\nconst compressed = () => new Error('cannot append to compressed archives')\n\nconst check = (\n opt: ReplaceOptions | ReplaceOptionsSync,\n files: unknown[],\n) => {\n const { file } = opt\n if (!file) throw new TypeError('file is required')\n if (\n opt.gzip ||\n opt.brotli ||\n opt.zstd ||\n file.endsWith('.br') ||\n file.endsWith('.tbr')\n ) {\n throw new TypeError(compressed().message)\n }\n if (!files?.length) {\n throw new TypeError('no paths specified to add/replace')\n }\n}\n\n/**\n * Finds the place in an archive file where new entries go: the end\n * of the last complete entry before the first block that is not a\n * valid header. A PAX or GNU header with no entry after it is not a\n * complete entry.\n *\n * Read the file into `buf` at `pos`, and call `push()`, until it\n * returns false. The bodies of the entries are not read.\n */\nexport class AppendScan {\n buf: Uint8Array = new Uint8Array(CHUNK)\n /** The place in the file of the next read. */\n pos: number = 0\n #size: number\n #parser: Parser\n #codecs: Codec[]\n #mtimes?: Map<string, Date>\n\n /**\n * @param size the size of the file\n * @param mtimes gets the path and the `mtime` of each complete entry\n */\n constructor(\n size: number,\n codecs: Codec[] = [],\n mtimes?: Map<string, Date>,\n ) {\n this.#size = size\n this.#codecs = [...codecs, gzip]\n this.#mtimes = mtimes\n this.#parser = new Parser({\n // The parser must not give the bodies.\n filter: () => false,\n onwarn: (_code, _message, data) => {\n // An error of the header code goes to the caller.\n throw data instanceof Error ? data : STOP\n },\n })\n }\n\n /** The place in the file where new entries go. */\n get position(): number {\n return this.#parser.position\n }\n\n /** The number of bytes to read into `buf` at `pos`. */\n get want(): number {\n return Math.min(CHUNK, this.#size - this.pos)\n }\n\n /**\n * Parse the first `length` bytes of `buf`. False if the place is\n * found. Throws if the file is compressed.\n */\n push(length: number): boolean {\n const chunk = this.buf.subarray(0, length)\n if (this.pos === 0 && this.#codecs.some(c => c.detect(chunk))) {\n throw compressed()\n }\n const parser = this.#parser\n this.pos += length\n // the end of the body of the last entry in the chunk\n let end = 0\n parser.push(chunk)\n try {\n for (let ev; (ev = parser.next()); ) {\n if (ev.type !== 'entry') return false\n const { entry } = ev\n end = parser.offset + 512 * Math.ceil(entry.size / 512)\n if (end > this.#size) return false\n if (entry.mtime) this.#mtimes?.set(entry.path, entry.mtime)\n }\n // The rest of the body of the last entry is not read.\n if (this.pos < end) {\n parser.skipBody()\n this.pos = end\n }\n } catch (er) {\n if (er !== STOP) throw er\n return false\n }\n return length > 0 && this.pos < this.#size\n }\n}\n\n/**\n * Add the files to the end of an archive file that is not\n * compressed. The files are the same as for `create`. If the archive\n * does not exist, it is made.\n *\n * The new entries go after the last complete entry of the archive.\n * A reader of the archive gets the old entry and then the new entry\n * of a path that is in it two times.\n */\nexport const replace = async (\n options: WithAliases<ReplaceOptions>,\n files: PackInput[],\n): Promise<void> => {\n const opt = dealias<ReplaceOptions>(options)\n check(opt, files)\n const { fs, file } = opt\n const pack = packFiles(opt, files)\n if (pack.codec) throw new TypeError(compressed().message)\n const handle = await fs.open(file, 'r+').catch(er => {\n if ((er as { code?: string })?.code !== 'ENOENT') throw er\n return fs.open(file, 'w+', opt.mode || 0o666)\n })\n let ok = false\n try {\n const { size } = await handle.stat()\n const scan = new AppendScan(size, opt.codecs, opt.mtimeCache)\n while (\n scan.push(\n (await handle.read(scan.buf, 0, scan.want, scan.pos)).bytesRead,\n )\n );\n await writeChunks(handle, pack, scan.position)\n ok = true\n } finally {\n const closed = handle.close()\n await (ok ? closed : closed.catch(noop))\n }\n}\n\n/** The sync form of `replace`. */\nexport const replaceSync = (\n options: WithAliases<ReplaceOptionsSync>,\n files: PackInputSync[],\n): void => {\n const opt = dealias<ReplaceOptionsSync>(options)\n check(opt, files)\n const { fs, file } = opt\n const pack = packFilesSync(opt, files)\n if (pack.codec) throw new TypeError(compressed().message)\n let fd: number\n try {\n fd = fs.openSync(file, 'r+')\n } catch (er) {\n if ((er as { code?: string })?.code !== 'ENOENT') throw er\n fd = fs.openSync(file, 'w+', opt.mode || 0o666)\n }\n try {\n const { size } = fs.fstatSync(fd)\n const scan = new AppendScan(size, opt.codecs, opt.mtimeCache)\n while (scan.push(fs.readSync(fd, scan.buf, 0, scan.want, scan.pos)));\n writeChunksSync(fs, fd, pack, scan.position)\n } catch (er) {\n try {\n fs.closeSync(fd)\n } catch {}\n throw er\n }\n fs.closeSync(fd)\n}\n", "import type { WithAliases } from './dealias.js'\nimport type { CreateStats } from './fs.js'\nimport type { ReplaceOptions, ReplaceOptionsSync } from './options.js'\nimport type { PackInput, PackInputSync } from './pack.js'\nimport type { EntryData } from './read-entry.js'\nimport { replace, replaceSync } from './replace.js'\n\n// Add a filter that refuses a path that is not newer than the entry\n// of the same path in the archive. The filter accepts each directory\n// of the file system: a file in a directory can be newer than the\n// directory, and the pack reads a directory only if it adds it.\n\n// A ustar header has the time in whole seconds. A file is not newer\n// than such an entry if only the part below one second differs.\nconst isNewer = (file: Date, archived: Date) => {\n const a = archived.getTime()\n const f = file.getTime()\n return (a % 1000 === 0 ? f - (f % 1000) : f) > a\n}\n\nconst newer = <\n E extends EntryData,\n O extends { mtimeCache?: Map<string, Date> },\n>(\n opt: O & { filter?: (path: string, entry: CreateStats | E) => boolean },\n): O => {\n const { filter } = opt\n const mtimeCache = opt.mtimeCache ?? new Map<string, Date>()\n return {\n ...opt,\n mtimeCache,\n filter: (path: string, entry: CreateStats | E) => {\n if (filter && !filter(path, entry)) return false\n if ('isDirectory' in entry && entry.isDirectory()) return true\n const archived = mtimeCache.get(path)\n return !archived || !entry.mtime || isNewer(entry.mtime, archived)\n },\n }\n}\n\n/**\n * The same as `replace`, but a file is added only if it is newer than\n * the last entry of the archive that has its path. A directory is\n * always added, and each path in it is checked.\n */\nexport const update = (\n opt: WithAliases<ReplaceOptions>,\n files: PackInput[],\n): Promise<void> => replace(newer(opt), files)\n\n/** The sync form of `update`. */\nexport const updateSync = (\n opt: WithAliases<ReplaceOptionsSync>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MAAK,EAC3B,MAAOC,EAAKG,EAASA,EAAO,MAAMrC,EAAI,EACxC,CACF,ECpJA,IAAMsC,GAAU,CAACC,EAAYC,IAAkB,CAC7C,IAAMC,EAAID,EAAS,QAAO,EACpBE,EAAIH,EAAK,QAAO,EACtB,OAAQE,EAAI,MAAS,EAAIC,EAAKA,EAAI,IAAQA,GAAKD,CACjD,EAEME,GAIJC,GACK,CACL,GAAM,CAAE,OAAAC,CAAM,EAAKD,EACbE,EAAaF,EAAI,YAAc,IAAI,IACzC,MAAO,CACL,GAAGA,EACH,WAAAE,EACA,OAAQ,CAACC,EAAcC,IAA0B,CAC/C,GAAIH,GAAU,CAACA,EAAOE,EAAMC,CAAK,EAAG,MAAO,GAC3C,GAAI,gBAAiBA,GAASA,EAAM,YAAW,EAAI,MAAO,GAC1D,IAAMR,EAAWM,EAAW,IAAIC,CAAI,EACpC,MAAO,CAACP,GAAY,CAACQ,EAAM,OAASV,GAAQU,EAAM,MAAOR,CAAQ,CACnE,EAEJ,EAOaS,GAAS,CACpBL,EACAM,IACkBC,GAAQR,GAAMC,CAAG,EAAGM,CAAK",
6
+ "names": ["isUint8Array", "x", "isArrayBuffer", "isBlob", "isReadableStream", "decoder", "encoder", "utf8Length", "str", "len", "i", "c", "decodeUtf8", "buf", "start", "end", "encodeUtf8Into", "off", "size", "written", "writeAscii", "encode", "num", "buf", "encodeNegative", "encodePositive", "i", "flipped", "byte", "onesComp", "twosComp", "parse", "pre", "value", "pos", "twos", "len", "sum", "f", "normalize", "path", "absolute", "out", "part", "trail", "res", "join", "parts", "p", "dirname", "end", "slash", "basename", "isAbsolute", "resolve", "i", "relative", "from", "to", "f", "t", "same", "types_exports", "__export", "code", "isCode", "isName", "name", "normalFsTypes", "c", "kv", "notNegative", "n", "Header", "#type", "data", "off", "ex", "gex", "isUint8Array", "#slurp", "buf", "t", "decString", "isNormalFS", "normalFsTypes", "exForFields", "gexForFields", "decNumber", "decDate", "isCode", "decodeUtf8", "prefix", "sum", "i", "k", "v", "prefixSize", "split", "splitPrefix", "path", "encString", "encNumber", "encDate", "writeAscii", "name", "type", "c", "code", "p", "pp", "ret", "root", "utf8Length", "dirname", "basename", "join", "size", "end", "max", "numToDate", "num", "parse", "decSmallNumber", "nanUndef", "value", "MAXNUM", "encode", "encSmallNumber", "octalString", "padOctal", "str", "date", "encodeUtf8Into", "SIMPLE_NUMBER", "Pax", "_Pax", "obj", "global", "body", "bodyLen", "utf8Length", "bufLen", "buf", "Header", "basename", "encodeUtf8Into", "field", "r", "v", "s", "byteLen", "digits", "str", "ex", "g", "merge", "parseKV", "a", "b", "set", "pos", "sp", "decodeUtf8", "end", "parseKVLine", "line", "kv", "k", "joined", "nul", "d", "gzip", "head", "options", "stream", "pos", "chunk", "controller", "aliases", "dealias", "options", "opt", "alias", "name", "concat", "parts", "length", "part", "out", "pos", "ownOptions", "opt", "more", "countOption", "name", "value", "def", "fsTypes", "winPath", "path", "EntryData", "header", "ex", "gex", "win32", "#apply", "decoder", "decode", "parts", "text", "part", "usedError", "ReadEntry", "#source", "#used", "#stream", "source", "started", "controller", "#claim", "#read", "#collect", "max", "concat", "fill", "opt", "code", "message", "data", "tarError", "warn", "fatal", "BEGIN", "HEADER", "BODY", "IGNORE", "META", "ENTRY_END", "END", "metaTypes", "cstring", "buf", "nul", "decodeUtf8", "Parser", "#opt", "#filter", "#create", "#queue", "#chunk", "#pos", "#block", "#blockLen", "#state", "#entry", "#header", "#meta", "#metaLen", "#remain", "#blockRemain", "#ex", "#longPath", "#longLinkpath", "#gex", "#ended", "#sawValid", "#entryEnd", "#done", "opt", "createEntry", "ownOptions", "win32", "header", "ex", "gex", "EntryData", "code", "message", "data", "warn", "chunk", "state", "#endBody", "pos", "ev", "#finish", "avail", "#consumeHeader", "block", "n", "blockRemain", "remain", "len", "last", "meta", "#applyMeta", "entry", "held", "need", "off", "longPath", "longLinkpath", "Header", "er", "type", "link", "size", "Pax", "MAX_READ", "FIRST_READ", "MIN_SKIP", "SKIP", "Plan", "#max", "#want", "maxReadSize", "countOption", "n", "chunks", "fs", "file", "plan", "handle", "buf", "bytesRead", "readFile", "fs", "file", "maxReadSize", "plan", "Plan", "chunks", "SKIP", "noop", "headLength", "codecs", "c", "isTar", "head", "header", "Header", "findCodec", "file", "x", "maxRatio", "opt", "abort", "er", "tarError", "ratioError", "ratio", "max", "notCurrent", "EntryCursor", "parser", "ev", "entry", "skipBody", "cursor", "source", "n", "SKIP", "toSource", "input", "isUint8Array", "isArrayBuffer", "isBlob", "isReadableStream", "reader", "TarReader", "#cursor", "#opt", "#input", "#source", "#head", "#filling", "#done", "ownOptions", "win32", "Parser", "ex", "gex", "ReadEntry", "#fill", "#open", "res", "gzip", "need", "concat", "codec", "compressed", "decompressed", "readable", "writable", "writer", "stopped", "entries", "input", "opt", "TarReader", "modeFix", "mode", "isDir", "portable", "raw", "win", "char", "toWin", "i", "toRaw", "encode", "s", "c", "decode", "isSep", "code", "isDrive", "win32Root", "path", "len", "end", "j", "last", "win32IsAbsolute", "win32Resolve", "base", "full", "root", "resolve", "win32Dirname", "dir", "dirname", "stripAbsolutePath", "path", "roots", "root", "win32Root", "toStream", "chunks", "controller", "res", "stripTrailingSlashes", "str", "i", "slashesStart", "encoder", "prefixPath", "path", "prefix", "stripTrailingSlashes", "WriteEntry", "data", "body", "isUint8Array", "isBlob", "opt", "block", "ownOptions", "linkpath", "uid", "gid", "uname", "gname", "size", "mtime", "atime", "ctime", "Header", "dev", "ino", "nlink", "Pax", "MAX_READ", "noop", "blockLength", "size", "slashes", "path", "idOf", "id", "BIG", "lossy", "dev", "ino", "same", "a", "b", "eof", "message", "fewer", "more", "pathOf", "entry", "tooLong", "isSource", "item", "isWriteEntry", "PackJob", "absolute", "PackBase", "#links", "opt", "compress", "ownOptions", "countOption", "prefix", "noPax", "cwd", "win32IsAbsolute", "isAbsolute", "#resolve", "set", "names", "name", "custom", "codec", "value", "gzip", "c", "win32Resolve", "resolve", "node", "stat", "job", "filter", "warn", "key", "target", "relative", "base", "dir", "up", "child", "er", "type", "linkpath", "body", "processUid", "processUname", "WriteEntry", "#finish", "fromPath", "win32", "root", "stripped", "stripAbsolutePath", "decode", "modeFix", "fill", "handle", "buf", "off", "pos", "bytesRead", "chunks", "body", "isUint8Array", "isBlob", "isReadableStream", "reader", "res", "noop", "count", "entry", "remain", "chunk", "tooLong", "padding", "eof", "pathOf", "blockLength", "bodyBlocks", "chunks", "pad", "Pack", "PackBase", "#out", "#planned", "opt", "countOption", "res", "#output", "codec", "#compress", "#run", "stream", "run", "failure", "reader", "toStream", "er", "noop", "node", "#start", "item", "PackJob", "#path", "isSource", "#entry", "entry", "fs", "n", "job", "stat", "#stat", "planned", "st", "id", "type", "#load", "p", "path", "follow", "BIG", "absolute", "noDirRecurse", "load", "same", "handle", "size", "length", "blockLength", "fill", "names", "buf", "ok", "body", "#read", "child", "whole", "bodyBlocks", "closed", "pos", "end", "SMALL", "BATCH", "noop", "check", "opt", "files", "writeAll", "handle", "buf", "length", "position", "off", "writeChunks", "chunks", "batch", "used", "flush", "chunk", "createFile", "pack", "fs", "file", "mode", "handle", "ok", "writeChunks", "closed", "noop", "packFiles", "opt", "files", "strict", "onwarn", "codecs", "platform", "Pack", "item", "archive", "TarReader", "readFile", "create", "options", "files", "opt", "dealias", "check", "toStream", "packFiles", "createFile", "er", "filesFilter", "files", "filter", "set", "f", "stripTrailingSlashes", "missing", "max", "listed", "path", "p", "root", "found", "end", "dir", "entry", "ok", "opt", "warn", "noInput", "list", "options", "dealias", "input", "file", "fs", "onEntry", "source", "readFile", "report", "reader", "TarReader", "noop", "plan", "opt", "files", "codecs", "gzip", "filesFilter", "tmpName", "file", "del", "options", "dealias", "remove", "report", "fs", "_", "maxReadSize", "read", "head", "headLength", "length", "handle", "n", "mode", "tmp", "create", "findCodec", "path", "entry", "TarReader", "readFile", "er", "CwdError", "path", "code", "SymlinkError", "symlink", "path", "plan", "opt", "mode", "uid", "gid", "child", "dir", "name", "chain", "first", "end", "made", "i", "mkdir", "fs", "needChmod", "owner", "cwd", "code", "st", "er", "CwdError", "parts", "relative", "part", "SymlinkError", "d", "normalizeCache", "MAX", "cache", "normalizeUnicode", "s", "ret", "i", "getDirs", "path", "dirs", "i", "PathReservations", "#queues", "#reservations", "#running", "#win32", "win32", "paths", "fn", "res", "rej", "handler", "#clear", "er", "#add", "p", "stripTrailingSlashes", "join", "normalizeUnicode", "q", "dir", "last", "#run", "first", "next", "after", "f", "writeFlags", "constants", "win32", "O_CREAT", "O_TRUNC", "O_WRONLY", "O_NOFOLLOW", "UV_FS_O_FILEMAP", "write", "flag", "fmap", "size", "DEFAULT_MAX_DEPTH", "MAX_PATH_LENGTH", "DEFAULT_JOBS", "fileTypes", "dirTypes", "linkTypes", "uint32", "a", "b", "c", "UnpackBase", "options", "opt", "ownOptions", "win32", "win32Resolve", "resolve", "win32Dirname", "dirname", "cwd", "win32IsAbsolute", "isAbsolute", "writeFlags", "code", "message", "data", "warn", "er", "entry", "error", "#stripAbsolutePath", "field", "p", "root", "stripped", "stripAbsolutePath", "parts", "firstName", "part", "entryDir", "normalize", "resolved", "join", "linkparts", "maxDepth", "linkpath", "length", "absolute", "aRoot", "win32Root", "encode", "pRoot", "path", "mode", "doChown", "uid", "gid", "st", "relative", "symlink", "SymlinkError", "deleteName", "Unpack", "#fs", "#reservations", "#jobs", "#active", "#wake", "#checkedCwd", "#cwdCheck", "PathReservations", "countOption", "input", "reader", "TarReader", "onEntry", "stream", "body", "inMemory", "work", "#start", "#idle", "res", "#extract", "fatal", "#mkdir", "dir", "mkdir", "#checkCwd", "fs", "parent", "#unlink", "#file", "#directory", "#ensureNoSymlink", "name", "t", "times", "owner", "handle", "#pipe", "atime", "mtime", "i", "next", "tx", "writing", "failed", "writer", "out", "stop", "feed", "done", "value", "noInput", "extract", "options", "files", "opt", "dealias", "source", "readFile", "filter", "report", "filesFilter", "Unpack", "CHUNK", "STOP", "noop", "compressed", "check", "opt", "files", "file", "AppendScan", "#size", "#parser", "#codecs", "#mtimes", "size", "codecs", "mtimes", "gzip", "Parser", "_code", "_message", "data", "length", "chunk", "c", "parser", "end", "ev", "entry", "er", "replace", "options", "dealias", "fs", "pack", "packFiles", "handle", "ok", "scan", "writeChunks", "closed", "isNewer", "file", "archived", "a", "f", "newer", "opt", "filter", "mtimeCache", "path", "entry", "update", "files", "replace"]
7
7
  }