tar 7.5.24 → 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 -43
  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 -42
  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
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/server/index.ts", "../../../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", "../../../src/server/codecs.ts"],
4
+ "sourcesContent": ["// The entry point for Node.js, and for each runtime that has the\n// `node:` modules. It has all that the core entry point has. Each\n// command gets defaults for the options that the core cannot know:\n// the file system, the working directory, the platform, the user of\n// the process, and the codecs of `node:zlib`. It adds the sync\n// commands.\n\nimport * as nodeFs from 'node:fs'\nimport * as nodeFsPromises from 'node:fs/promises'\nimport { resolve } from 'node:path'\nimport type { BrotliOptions, ZlibOptions, ZstdOptions } from 'node:zlib'\nimport type { Codec } from '../codec.js'\nimport * as core from '../index.js'\nimport { createSync as coreCreateSync } from '../create.js'\nimport { deleteSync as coreDeleteSync } from '../delete.js'\nimport {\n dealias,\n type FileOption,\n type NoFileOption,\n type WithAliases,\n} from '../dealias.js'\nimport { entriesSync as coreEntriesSync } from '../entries.js'\nimport { extractSync as coreExtractSync } from '../extract.js'\nimport { listSync as coreListSync } from '../list.js'\nimport type { PackInput, PackInputSync } from '../pack.js'\nimport type { ReadEntry, ReadEntrySync } from '../read-entry.js'\nimport { replaceSync as coreReplaceSync } from '../replace.js'\nimport { updateSync as coreUpdateSync } from '../update.js'\nimport { zlibCodecs } from './codecs.js'\n\nexport * from '../index.js'\nexport { TarReaderSync } from '../entries.js'\nexport { PackSync } from '../pack.js'\nexport { ReadEntrySync } from '../read-entry.js'\nexport { UnpackSync } from '../unpack.js'\nexport { zlibCodecs, codecStream, type ZlibModule } from './codecs.js'\n\nconst fs: core.TarFS & core.ExtractFS & core.ReplaceFS & core.DeleteFS =\n nodeFsPromises\nconst fsSync: core.TarFSSync &\n core.ExtractFSSync &\n core.ReplaceFSSync &\n core.DeleteFSSync = nodeFs\nconst platform = process.platform === 'win32' ? 'win32' : 'posix'\nconst codecs = zlibCodecs()\n\n/** Each member of the option type `T`, with `fs` and `cwd` optional. */\nexport type Loose<T> =\n T extends unknown ?\n Omit<T, 'fs' | 'cwd'> &\n Partial<Pick<T, Extract<keyof T, 'fs' | 'cwd'>>>\n : never\n\n/** The compression options, with the option types of `node:zlib`. */\nexport type Zip = {\n /** Compress with gzip. An object is the options of `zlib.createGzip`. */\n gzip?: boolean | ZlibOptions\n /**\n * Compress with brotli. An object is the options of\n * `zlib.createBrotliCompress`.\n */\n brotli?: boolean | BrotliOptions\n /**\n * Compress with zstd. An object is the options of\n * `zlib.createZstdCompress`.\n */\n zstd?: boolean | ZstdOptions\n}\n/** `Loose<T>`, with the compression options of `Zip`. */\nexport type Packing<T> = Omit<Loose<T>, keyof Zip> & Zip\n\n/** The options of `entries`. */\nexport type ReadOptions = core.ReadOptions\n/** The options of `entriesSync`. */\nexport type ReadOptionsSync = core.ReadOptionsSync\n/** The options of `list`. Set `input` or `file`. */\nexport type ListOptions = Loose<core.ListOptions>\n/** The options of `listSync`. Set `input` or `file`. */\nexport type ListOptionsSync = Loose<core.ListOptionsSync>\n/** The options of `extract`. The default of `cwd` is `process.cwd()`. */\nexport type ExtractOptions = Loose<core.ExtractOptions>\n/** The options of `extractSync`. */\nexport type ExtractOptionsSync = Loose<core.ExtractOptionsSync>\n/** The options of `create`. The default of `cwd` is `process.cwd()`. */\nexport type CreateOptions = Packing<core.CreateOptions>\n/** The options of `createSync`. */\nexport type CreateOptionsSync = Packing<core.CreateOptionsSync>\n/** The options of `replace` and `update`. */\nexport type ReplaceOptions = Packing<core.ReplaceOptions>\n/** The options of `replaceSync` and `updateSync`. */\nexport type ReplaceOptionsSync = Packing<core.ReplaceOptionsSync>\n/** The options of `delete`. */\nexport type DeleteOptions = Loose<core.DeleteOptions>\n/** The options of `deleteSync`. */\nexport type DeleteOptionsSync = Loose<core.DeleteOptionsSync>\n\n// The options that get a default.\ntype Defaults = {\n fs?: unknown\n cwd?: string\n platform?: 'win32' | 'posix'\n chmod?: boolean\n processUid?: number\n processGid?: number\n processUname?: string\n processUmask?: number\n codecs?: Codec[]\n}\n\n// A copy of the options, with the name of the option in place of\n// each alias, and a default for each option that is not set. `T` is\n// the option type of the core command.\nconst fill = <T>(\n options: WithAliases<Defaults>,\n fs: unknown,\n paths: boolean,\n): T => {\n const opt = dealias<Defaults>(options)\n opt.fs ??= fs\n opt.platform ??= platform\n opt.codecs = [...(opt.codecs ?? []), ...codecs]\n // A command that reads an archive, and writes no file, does not\n // need the working directory or the user.\n if (paths) {\n // `resolve` adds `process.cwd()` to a relative path.\n opt.cwd = resolve(opt.cwd ?? '')\n opt.processUid ??= process.getuid?.()\n opt.processGid ??= process.getgid?.()\n opt.processUname ??= process.env.USER\n if (opt.chmod) opt.processUmask ??= process.umask()\n }\n return opt as T\n}\n\n/**\n * Read the entries of an archive. Gzip, brotli, and zstd input is\n * decompressed, if the runtime has the format.\n */\nexport const entries = (\n input: core.TarInput,\n opt: ReadOptions = {},\n): AsyncIterableIterator<ReadEntry, undefined> =>\n core.entries(input, fill(opt, fs, false))\n\n/** The sync form of `entries`. */\nexport const entriesSync = (\n input: core.TarInputSync,\n opt: ReadOptionsSync = {},\n): IterableIterator<ReadEntrySync, undefined> =>\n coreEntriesSync(input, fill(opt, fsSync, false))\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.\n */\nexport const list = (\n opt: WithAliases<ListOptions>,\n files?: string[],\n): Promise<void> => core.list(fill(opt, fs, false), files)\n\n/** The sync form of `list`. */\nexport const listSync = (\n opt: WithAliases<ListOptionsSync>,\n files?: string[],\n): void => coreListSync(fill(opt, fsSync, false), files)\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 */\nexport const extract = (\n opt: WithAliases<ExtractOptions>,\n files?: string[],\n): Promise<void> => core.extract(fill(opt, fs, true), files)\n\n/** The sync form of `extract`. */\nexport const extractSync = (\n opt: WithAliases<ExtractOptionsSync>,\n files?: string[],\n): void => coreExtractSync(fill(opt, fsSync, true), files)\n\n/**\n * Make an archive of the files. With `opt.file`, the archive is\n * written to that path. With no `opt.file`, the result is a stream\n * of the bytes of the archive.\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 opt: WithAliases<CreateOptions>,\n files: PackInput[],\n): Promise<void> | ReadableStream<Uint8Array> {\n return core.create(fill(opt, fs, true), files)\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.\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 opt: WithAliases<CreateOptionsSync>,\n files: PackInputSync[],\n): void | IterableIterator<Uint8Array, undefined> {\n return coreCreateSync(fill(opt, fsSync, true), files)\n}\n\n/** Add the files to the end of an archive file that is not compressed. */\nexport const replace = (\n opt: WithAliases<ReplaceOptions>,\n files: PackInput[],\n): Promise<void> => core.replace(fill(opt, fs, true), files)\n\n/** The sync form of `replace`. */\nexport const replaceSync = (\n opt: WithAliases<ReplaceOptionsSync>,\n files: PackInputSync[],\n): void => coreReplaceSync(fill(opt, fsSync, true), files)\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> => core.update(fill(opt, fs, true), files)\n\n/** The sync form of `update`. */\nexport const updateSync = (\n opt: WithAliases<ReplaceOptionsSync>,\n files: PackInputSync[],\n): void => coreUpdateSync(fill(opt, fsSync, true), files)\n\n/**\n * Remove entries from an archive file: each entry that `files` lists,\n * and each entry in a directory that it lists. With `opt.filter`,\n * only if the filter also returns true.\n */\nconst del = (\n opt: WithAliases<DeleteOptions>,\n files?: string[],\n): Promise<void> => core.delete(fill(opt, fs, false), files)\n\n/** The sync form of `delete`. */\nexport const deleteSync = (\n opt: WithAliases<DeleteOptionsSync>,\n files?: string[],\n): void => coreDeleteSync(fill(opt, fsSync, false), files)\n\nexport { del as delete }\nexport { create as c, extract as x, list as t, replace as r, update as u }\n", "// 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>,\n files: PackInputSync[],\n): void => replaceSync(newer(opt), files)\n", "import { constants } from 'node:buffer'\nimport type { Transform } from 'node:stream'\nimport * as nodeZlib from 'node:zlib'\nimport type { Codec, CodecStream } from '../codec.js'\n\n/**\n * The functions of `node:zlib` that the codecs use. A runtime can\n * have no brotli functions or no zstd functions.\n */\nexport type ZlibModule = Pick<\n typeof nodeZlib,\n 'createGzip' | 'createGunzip' | 'gzipSync' | 'gunzipSync'\n> &\n Partial<\n Pick<\n typeof nodeZlib,\n | 'createBrotliCompress'\n | 'createBrotliDecompress'\n | 'brotliCompressSync'\n | 'brotliDecompressSync'\n | 'createZstdCompress'\n | 'createZstdDecompress'\n | 'zstdCompressSync'\n | 'zstdDecompressSync'\n >\n >\n\ntype Options = Record<string, unknown>\n\n// The size of each chunk of decompressed output, and the size below\n// which chunks of input to compress are put together.\nconst CHUNK = 64 * 1024\n\n/**\n * Make the two web streams of a `node:zlib` stream, or of another\n * `Transform` stream of `node:stream`. The result fits the\n * `transform` option of `extract`.\n *\n * As with a `TransformStream`, a write is complete only when the\n * reader asks for more output than the stream has. The zlib stream\n * makes output only until its buffer is full. So the reader of an\n * archive can stop before more is decompressed.\n *\n * @param batch put small chunks of input together for one write.\n * Each write is a task for a thread.\n * @param first called with the first chunk of output\n */\nexport const codecStream = (\n stream: Transform,\n batch: boolean = false,\n first?: (chunk: Uint8Array) => void,\n): CodecStream => {\n let output!: ReadableStreamDefaultController<Uint8Array>\n let input!: WritableStreamDefaultController\n // True while the reader waits for output.\n let wanted = false\n // True when the zlib stream is closed.\n let done = false\n // settles the write or the close that waits for the zlib stream\n let settle: (() => void) | undefined\n // settles the write that waits for the reader\n let wake: (() => void) | undefined\n const held = batch ? new Uint8Array(CHUNK) : undefined\n let used = 0\n const write = (chunk: Uint8Array) =>\n new Promise<void>(res => {\n settle = res\n stream.write(chunk, () => res())\n })\n const flush = async (held: Uint8Array) => {\n if (used) await write(held.subarray(0, used))\n used = 0\n }\n // A write has no callback when the zlib stream fails or is\n // destroyed.\n const release = () => {\n done = true\n settle?.()\n wake?.()\n }\n const stop = () => {\n release()\n stream.destroy()\n }\n stream.pause()\n stream.on('data', (chunk: Uint8Array) => {\n first?.(chunk)\n first = undefined\n wanted = false\n stream.pause()\n output.enqueue(chunk)\n })\n // On Deno, a zlib stream that already has all its output emits\n // 'end' after it is destroyed. The output is then closed already.\n stream.on('end', () => {\n if (!done) output.close()\n })\n stream.on('error', er => {\n output.error(er)\n input.error(er)\n release()\n })\n stream.on('close', release)\n return {\n readable: new ReadableStream<Uint8Array>(\n {\n start: controller => {\n output = controller\n },\n pull: () => {\n wanted = true\n wake?.()\n stream.resume()\n },\n cancel: reason => {\n // Stop the source of the input also.\n input.error(reason)\n stop()\n },\n },\n { highWaterMark: 0 },\n ),\n writable: new WritableStream<Uint8Array>({\n start: controller => {\n input = controller\n // An abort does not wait for a write that waits.\n const { signal } = controller\n signal.addEventListener('abort', () => {\n output.error(signal.reason)\n stop()\n })\n },\n write: async chunk => {\n if (!held) await write(chunk)\n else {\n if (used + chunk.length > CHUNK) await flush(held)\n if (chunk.length > CHUNK) await write(chunk)\n else {\n held.set(chunk, used)\n used += chunk.length\n }\n }\n // As with a `TransformStream`, the write waits until the\n // reader wants output. Then a pipe from the source does not\n // start a write to a stream that the reader canceled.\n if (!wanted && !done) await new Promise<void>(res => (wake = res))\n },\n close: async () => {\n if (held) await flush(held)\n await new Promise<void>(res => {\n settle = res\n stream.end()\n })\n },\n }),\n }\n}\n\n// The option of the sync functions that limits the output. They\n// refuse a number that is not in the range of a buffer length.\nconst limit = (max: number) =>\n max >= constants.MAX_LENGTH ?\n {}\n : { maxOutputLength: Math.max(1, Math.floor(max)) }\n\nconst make = (\n base: Pick<Codec, 'name' | 'headLength' | 'detect' | 'extensions'>,\n compress: (options?: Options) => Transform,\n decompress: (options: Options) => Transform,\n compressSync: (data: Uint8Array, options?: Options) => Uint8Array,\n decompressSync: (data: Uint8Array, options: Options) => Uint8Array,\n): Codec => ({\n ...base,\n decompress: () => codecStream(decompress({ chunkSize: CHUNK })),\n compress: options => codecStream(compress(options), true),\n decompressSync: (data, { maxOutputLength }) => {\n try {\n return decompressSync(data, limit(maxOutputLength))\n } catch (er) {\n if ((er as { code?: string })?.code !== 'ERR_BUFFER_TOO_LARGE') {\n throw er\n }\n throw new Error(\n `max decompression ratio exceeded: the output is larger than ${maxOutputLength} bytes`,\n )\n }\n },\n compressSync,\n})\n\n// Byte 9 of a gzip stream names the system that made it. Set it to\n// 255, \"unknown\", so that each system makes the same bytes.\nconst portable = (chunk: Uint8Array) => {\n chunk[9] = 255\n}\n\n/**\n * The codecs of a `node:zlib` module: gzip, then brotli and zstd if\n * the module has their functions.\n *\n * The value of a `gzip`, `brotli`, or `zstd` option of `create` goes\n * to the zlib function as its options. A gzip codec reads the tar\n * option `portable` in its options: it makes output that does not\n * name the system.\n *\n * A brotli archive has no magic number. The readers use the brotli\n * codec for a file with a name that ends in `.tar.br` or `.tbr`, if\n * the file does not start with a tar header.\n */\nexport const zlibCodecs = (z: ZlibModule = nodeZlib): Codec[] => {\n const {\n createBrotliCompress,\n createBrotliDecompress,\n brotliCompressSync,\n brotliDecompressSync,\n createZstdCompress,\n createZstdDecompress,\n zstdCompressSync,\n zstdDecompressSync,\n } = z\n const gzip = make(\n {\n name: 'gzip',\n headLength: 2,\n detect: head => head[0] === 0x1f && head[1] === 0x8b,\n },\n z.createGzip,\n z.createGunzip,\n z.gzipSync,\n z.gunzipSync,\n )\n const codecs: Codec[] = [\n {\n ...gzip,\n compress: ({ portable: p, ...options }: Options = {}) =>\n codecStream(z.createGzip(options), true, p ? portable : undefined),\n compressSync: (data, { portable: p, ...options }: Options = {}) => {\n const out = z.gzipSync(data, options)\n if (p) portable(out)\n return out\n },\n },\n ]\n if (\n createBrotliCompress &&\n createBrotliDecompress &&\n brotliCompressSync &&\n brotliDecompressSync\n ) {\n codecs.push(\n make(\n {\n name: 'brotli',\n headLength: 0,\n detect: () => false,\n extensions: ['.tar.br', '.tbr'],\n },\n createBrotliCompress,\n createBrotliDecompress,\n brotliCompressSync,\n brotliDecompressSync,\n ),\n )\n }\n if (\n createZstdCompress &&\n createZstdDecompress &&\n zstdCompressSync &&\n zstdDecompressSync\n ) {\n codecs.push(\n make(\n {\n name: 'zstd',\n headLength: 4,\n detect: head =>\n head[0] === 0x28 &&\n head[1] === 0xb5 &&\n head[2] === 0x2f &&\n head[3] === 0xfd,\n },\n createZstdCompress,\n createZstdDecompress,\n zstdCompressSync,\n zstdDecompressSync,\n ),\n )\n }\n return codecs\n}\n"],
5
+ "mappings": "6FAOA,UAAYA,OAAY,UACxB,UAAYC,OAAoB,mBAChC,OAAS,WAAAC,OAAe,YCAjB,IAAMC,EAAgBC,GAC3B,YAAY,OAAOA,CAAC,GACnBA,EAAiB,OAAO,WAAW,IAAM,aAG/BC,GAAiBD,GAC5B,OAAO,UAAU,SAAS,KAAKA,CAAC,IAAM,uBAG3BE,EAAUF,GACrB,OAAQA,GAAwB,MAAS,UACzC,OAAQA,EAAW,QAAW,WAGnBG,GACXH,GAEA,OAAQA,GAAkC,WAAc,WAGpDI,GAAU,IAAI,YAAY,QAAS,CAAE,UAAW,EAAI,CAAE,EACtDC,GAAU,IAAI,YAGPC,EAAcC,GAAuB,CAChD,IAAIC,EAAMD,EAAI,OACd,QAASE,EAAI,EAAGA,EAAIF,EAAI,OAAQE,IAAK,CACnC,IAAMC,EAAIH,EAAI,WAAWE,CAAC,EACtBC,EAAI,MACJA,EAAI,KACNF,GAAO,EAEPE,GAAK,OACLA,GAAK,QACJH,EAAI,WAAWE,EAAI,CAAC,EAAI,SAAY,OAGrCD,GAAO,EACPC,KAEAD,GAAO,EAEX,CACA,OAAOA,CACT,EAGaG,EAAa,CACxBC,EACAC,EAAgB,EAChBC,EAAcF,EAAI,SACR,CAGV,IAAIL,EAAM,GACV,QAASE,EA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O,CAClBN,EACAO,IACuBD,GAAKT,EAAKG,EAAKV,EAAI,EAAK,EAAGiB,CAAK,EAG5CC,GAAW,CACtBR,EACAO,IACSC,GAAaX,EAAKG,EAAKR,GAAQ,EAAK,EAAGe,CAAK,EAO1CE,GAAU,CACrBT,EACAO,IACuBE,GAAQZ,EAAKG,EAAKV,EAAI,EAAI,EAAGiB,CAAK,EAG9CG,GAAc,CACzBV,EACAO,IACSG,GAAgBb,EAAKG,EAAKR,GAAQ,EAAI,EAAGe,CAAK,EAmBnD,SAAUI,GACdX,EACAO,EAAkB,CAElB,OAAYI,GAAOd,EAAKG,EAAKV,EAAI,EAAI,EAAGiB,CAAK,CAC/C,CAkBM,SAAUK,GACdZ,EACAO,EAAsB,CAEtB,OAAOK,GAAef,EAAKG,EAAKR,GAAQ,EAAI,EAAGe,CAAK,CACtD,CAGO,IAAMM,GAAU,CACrBb,EACAO,IACuBM,GAAQhB,EAAKG,EAAKV,EAAI,EAAI,EAAGiB,CAAK,EAG9CO,GAAc,CACzBd,EACAO,IACSO,GAAgBjB,EAAKG,EAAKR,GAAQ,EAAI,EAAGe,CAAK,EAO5CQ,GAAS,CACpBf,EACAO,IACuBQ,GAAOlB,EAAKG,EAAKV,EAAI,EAAI,EAAGiB,CAAK,EAG7CS,GAAa,CACxBhB,EACAO,IACSS,GAAenB,EAAKG,EAAKR,GAAQ,EAAI,EAAGe,CAAK,EAOlDU,GAAM,CACVjB,EACAO,IACuBU,GAAOpB,EAAKG,EAAKV,EAAI,EAAK,EAAGiB,CAAK,EAG9CW,GAAa,CACxBlB,EACAO,IACSW,GAAerB,EAAKG,EAAKR,GAAQ,EAAK,EAAGe,CAAK",
6
+ "names": ["nodeFs", "nodeFsPromises", "resolve", "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", "ReadEntrySync", "#body", "#iterate", "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", "chunksSync", "fd", "readFile", "readFileSync", "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", "TarReaderSync", "ReadEntrySync", "part", "decompressSync", "parts", "data", "out", "entries", "entriesSync", "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", "fillSync", "fs", "fd", "chunks", "isUint8Array", "isBlob", "isReadableStream", "reader", "res", "chunksSync", "count", "remain", "chunk", "padding", "bodyBlocks", "pad", "bodyBlocksSync", "Pack", "#out", "#planned", "#output", "#compress", "#run", "stream", "run", "failure", "toStream", "#start", "#path", "#entry", "n", "#stat", "planned", "st", "#load", "p", "follow", "noDirRecurse", "load", "length", "ok", "#read", "whole", "closed", "end", "PackSync", "concat", "jobs", "SMALL", "BATCH", "noop", "check", "opt", "files", "writeAll", "handle", "buf", "length", "position", "off", "writeChunks", "chunks", "batch", "used", "flush", "chunk", "writeChunksSync", "fs", "fd", "write", "createFile", "pack", "file", "mode", "ok", "closed", "packFiles", "strict", "onwarn", "codecs", "platform", "Pack", "item", "archive", "TarReader", "readFile", "packFilesSync", "PackSync", "TarReaderSync", "readFileSync", "create", "options", "dealias", "toStream", "er", "createSync", "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", "listSync", "readFileSync", "TarReaderSync", "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", "deleteSync", "fd", "createSync", "TarReaderSync", "readFileSync", "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", "mkdirSync", "ok", "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", "times", "owner", "handle", "#pipe", "atime", "mtime", "i", "next", "tx", "writing", "failed", "writer", "out", "stop", "feed", "done", "value", "UnpackSync", "TarReaderSync", "mkdirSync", "fd", "noInput", "extract", "options", "files", "opt", "dealias", "source", "readFile", "filter", "report", "filesFilter", "Unpack", "extractSync", "readFileSync", "UnpackSync", "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", "replaceSync", "packFilesSync", "fd", "writeChunksSync", "isNewer", "file", "archived", "a", "f", "newer", "opt", "filter", "mtimeCache", "path", "entry", "update", "files", "replace", "updateSync", "replaceSync", "constants", "nodeZlib", "CHUNK", "codecStream", "stream", "batch", "first", "output", "input", "wanted", "done", "settle", "wake", "held", "used", "write", "chunk", "res", "flush", "release", "stop", "er", "controller", "reason", "signal", "limit", "max", "make", "base", "compress", "decompress", "compressSync", "decompressSync", "options", "data", "maxOutputLength", "portable", "zlibCodecs", "z", "createBrotliCompress", "createBrotliDecompress", "brotliCompressSync", "brotliDecompressSync", "createZstdCompress", "createZstdDecompress", "zstdCompressSync", "zstdDecompressSync", "codecs", "head", "p", "out", "fs", "nodeFsPromises", "fsSync", "nodeFs", "platform", "codecs", "zlibCodecs", "fill", "options", "paths", "opt", "dealias", "resolve", "entries", "input", "entriesSync", "list", "files", "listSync", "extract", "extractSync", "create", "createSync", "replace", "replaceSync", "update", "updateSync", "del", "deleteSync"]
7
+ }