@unbrained/pm-cli 2026.12.1 → 2026.12.2

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 (267) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/cli-bundle/bundle-manifest.json +1 -1
  3. package/dist/cli-bundle/chunks/{chunk-CWPR234D.js → chunk-7NAO7I75.js} +2 -2
  4. package/dist/cli-bundle/chunks/{chunk-4YQMQOUO.js → chunk-7V65VACG.js} +52 -52
  5. package/dist/cli-bundle/chunks/{chunk-NA6D75V5.js → chunk-G6TARHFK.js} +2 -2
  6. package/dist/cli-bundle/chunks/{chunk-YSVOXCYH.js → chunk-GOEQXVOI.js} +2 -2
  7. package/dist/cli-bundle/chunks/{chunk-OKEJ4U2I.js → chunk-ROTEELDL.js} +3 -3
  8. package/dist/cli-bundle/chunks/{chunk-U7RBJGLF.js → chunk-SDXCJZKB.js} +2 -2
  9. package/dist/cli-bundle/chunks/{chunk-XME6GIFQ.js → chunk-TKUG2X24.js} +2 -2
  10. package/dist/cli-bundle/chunks/{chunk-Q6GLSAJY.js → chunk-UNBW2LF3.js} +2 -2
  11. package/dist/cli-bundle/chunks/chunk-V2S4XAX3.js +2 -0
  12. package/dist/cli-bundle/chunks/{item-transaction-66RDV7PH.js → item-transaction-56J5OCHA.js} +2 -2
  13. package/dist/cli-bundle/chunks/{linked-resource-value-list-E2DX52LY.js → linked-resource-value-list-ZBIY4H23.js} +2 -2
  14. package/dist/cli-bundle/chunks/{register-mutation-2F6JUBST.js → register-mutation-EK6DVIQK.js} +2 -2
  15. package/dist/cli-bundle/chunks/{register-operations-ET3UKPYK.js → register-operations-6MURXE4V.js} +2 -2
  16. package/dist/cli-bundle/chunks/{register-setup-I63QTFCU.js → register-setup-RW26X3GJ.js} +2 -2
  17. package/dist/cli-bundle/focused-chunks/{chunk-SQ72CVUH.js → chunk-3COWDIPX.js} +54 -54
  18. package/dist/cli-bundle/focused-chunks/{chunk-PT7RT3T6.js → chunk-J72TRWR5.js} +3 -3
  19. package/dist/cli-bundle/focused-chunks/{item-transaction-2K4SFLJ7.js → item-transaction-LQLQLZE7.js} +2 -2
  20. package/dist/cli-bundle/main.js +3 -3
  21. package/dist/cli-bundle/sdk-core.js +1 -1
  22. package/dist/cli-bundle/sdk-governance.js +1 -1
  23. package/dist/cli-bundle/sdk-merge.js +1 -1
  24. package/dist/cli-bundle/sdk-runtime.js +1 -1
  25. package/dist/cli-bundle/sdk-testing.js +1 -1
  26. package/dist/cli-bundle/sdk.js +1 -1
  27. package/dist/sdk/extension/install-sources.d.ts +2 -2
  28. package/dist/sdk/extension/install-sources.js +5 -5
  29. package/marketplace.json +1 -1
  30. package/node_modules/tar/README.md +1792 -1147
  31. package/node_modules/tar/dist/commonjs/bytes.d.ts +21 -0
  32. package/node_modules/tar/dist/commonjs/bytes.js +83 -0
  33. package/node_modules/tar/dist/commonjs/codec.d.ts +53 -0
  34. package/node_modules/tar/dist/commonjs/codec.js +35 -0
  35. package/node_modules/tar/dist/commonjs/concat.d.ts +3 -0
  36. package/node_modules/tar/dist/commonjs/concat.js +20 -0
  37. package/node_modules/tar/dist/commonjs/create.d.ts +39 -2
  38. package/node_modules/tar/dist/commonjs/create.js +150 -64
  39. package/node_modules/tar/dist/commonjs/dealias.d.ts +79 -0
  40. package/node_modules/tar/dist/commonjs/dealias.js +50 -0
  41. package/node_modules/tar/dist/commonjs/delete.d.ts +19 -0
  42. package/node_modules/tar/dist/commonjs/delete.js +121 -0
  43. package/node_modules/tar/dist/commonjs/entries.d.ts +82 -0
  44. package/node_modules/tar/dist/commonjs/entries.js +398 -0
  45. package/node_modules/tar/dist/commonjs/extract.d.ts +14 -2
  46. package/node_modules/tar/dist/commonjs/extract.js +40 -81
  47. package/node_modules/tar/dist/commonjs/fs.d.ts +201 -0
  48. package/node_modules/tar/dist/commonjs/fs.js +5 -0
  49. package/node_modules/tar/dist/commonjs/header.d.ts +4 -4
  50. package/node_modules/tar/dist/commonjs/header.js +71 -53
  51. package/node_modules/tar/dist/commonjs/index.d.ts +25 -18
  52. package/node_modules/tar/dist/commonjs/index.js +46 -18
  53. package/node_modules/tar/dist/commonjs/index.min.js +2 -3
  54. package/node_modules/tar/dist/commonjs/large-numbers.d.ts +2 -2
  55. package/node_modules/tar/dist/commonjs/large-numbers.js +4 -4
  56. package/node_modules/tar/dist/commonjs/list.d.ts +23 -6
  57. package/node_modules/tar/dist/commonjs/list.js +99 -138
  58. package/node_modules/tar/dist/commonjs/mkdir.d.ts +16 -11
  59. package/node_modules/tar/dist/commonjs/mkdir.js +121 -159
  60. package/node_modules/tar/dist/commonjs/normalize-unicode.js +9 -0
  61. package/node_modules/tar/dist/commonjs/options.d.ts +284 -513
  62. package/node_modules/tar/dist/commonjs/options.js +20 -61
  63. package/node_modules/tar/dist/commonjs/pack.d.ts +150 -96
  64. package/node_modules/tar/dist/commonjs/pack.js +752 -445
  65. package/node_modules/tar/dist/commonjs/parser.d.ts +98 -0
  66. package/node_modules/tar/dist/commonjs/parser.js +452 -0
  67. package/node_modules/tar/dist/commonjs/path-reservations.d.ts +17 -7
  68. package/node_modules/tar/dist/commonjs/path-reservations.js +110 -140
  69. package/node_modules/tar/dist/commonjs/path.d.ts +19 -0
  70. package/node_modules/tar/dist/commonjs/path.js +90 -0
  71. package/node_modules/tar/dist/commonjs/pax.d.ts +3 -1
  72. package/node_modules/tar/dist/commonjs/pax.js +67 -36
  73. package/node_modules/tar/dist/commonjs/read-entry.d.ts +97 -11
  74. package/node_modules/tar/dist/commonjs/read-entry.js +251 -97
  75. package/node_modules/tar/dist/commonjs/read-file.d.ts +22 -0
  76. package/node_modules/tar/dist/commonjs/read-file.js +104 -0
  77. package/node_modules/tar/dist/commonjs/replace.d.ts +45 -1
  78. package/node_modules/tar/dist/commonjs/replace.js +164 -211
  79. package/node_modules/tar/dist/commonjs/server/codecs.d.ts +38 -0
  80. package/node_modules/tar/dist/commonjs/server/codecs.js +252 -0
  81. package/node_modules/tar/dist/commonjs/server/index.d.ts +115 -0
  82. package/node_modules/tar/dist/commonjs/server/index.js +166 -0
  83. package/node_modules/tar/dist/commonjs/server/index.min.js +3 -0
  84. package/node_modules/tar/dist/commonjs/strip-absolute-path.d.ts +8 -0
  85. package/node_modules/tar/dist/commonjs/strip-absolute-path.js +17 -20
  86. package/node_modules/tar/dist/commonjs/to-stream.d.ts +7 -0
  87. package/node_modules/tar/dist/commonjs/to-stream.js +22 -0
  88. package/node_modules/tar/dist/commonjs/types.d.ts +4 -3
  89. package/node_modules/tar/dist/commonjs/types.js +4 -3
  90. package/node_modules/tar/dist/commonjs/unpack.d.ts +143 -89
  91. package/node_modules/tar/dist/commonjs/unpack.js +780 -725
  92. package/node_modules/tar/dist/commonjs/update.d.ts +11 -1
  93. package/node_modules/tar/dist/commonjs/update.js +37 -28
  94. package/node_modules/tar/dist/commonjs/warn.d.ts +27 -0
  95. package/node_modules/tar/dist/commonjs/warn.js +36 -0
  96. package/node_modules/tar/dist/commonjs/win32-path.d.ts +16 -0
  97. package/node_modules/tar/dist/commonjs/win32-path.js +67 -0
  98. package/node_modules/tar/dist/commonjs/write-entry.d.ts +64 -111
  99. package/node_modules/tar/dist/commonjs/write-entry.js +108 -672
  100. package/node_modules/tar/dist/commonjs/write-flag.d.ts +18 -0
  101. package/node_modules/tar/dist/commonjs/write-flag.js +29 -0
  102. package/node_modules/tar/dist/esm/bytes.d.ts +21 -0
  103. package/node_modules/tar/dist/esm/bytes.js +72 -0
  104. package/node_modules/tar/dist/esm/codec.d.ts +53 -0
  105. package/node_modules/tar/dist/esm/codec.js +32 -0
  106. package/node_modules/tar/dist/esm/concat.d.ts +3 -0
  107. package/node_modules/tar/dist/esm/concat.js +16 -0
  108. package/node_modules/tar/dist/esm/create.d.ts +39 -2
  109. package/node_modules/tar/dist/esm/create.js +144 -61
  110. package/node_modules/tar/dist/esm/dealias.d.ts +79 -0
  111. package/node_modules/tar/dist/esm/dealias.js +46 -0
  112. package/node_modules/tar/dist/esm/delete.d.ts +19 -0
  113. package/node_modules/tar/dist/esm/delete.js +117 -0
  114. package/node_modules/tar/dist/esm/entries.d.ts +82 -0
  115. package/node_modules/tar/dist/esm/entries.js +388 -0
  116. package/node_modules/tar/dist/esm/extract.d.ts +14 -2
  117. package/node_modules/tar/dist/esm/extract.js +37 -44
  118. package/node_modules/tar/dist/esm/fs.d.ts +201 -0
  119. package/node_modules/tar/dist/esm/fs.js +4 -0
  120. package/node_modules/tar/dist/esm/header.d.ts +4 -4
  121. package/node_modules/tar/dist/esm/header.js +71 -53
  122. package/node_modules/tar/dist/esm/index.d.ts +25 -18
  123. package/node_modules/tar/dist/esm/index.js +23 -18
  124. package/node_modules/tar/dist/esm/index.min.js +2 -3
  125. package/node_modules/tar/dist/esm/large-numbers.d.ts +2 -2
  126. package/node_modules/tar/dist/esm/large-numbers.js +4 -4
  127. package/node_modules/tar/dist/esm/list.d.ts +23 -6
  128. package/node_modules/tar/dist/esm/list.js +96 -101
  129. package/node_modules/tar/dist/esm/mkdir.d.ts +16 -11
  130. package/node_modules/tar/dist/esm/mkdir.js +119 -154
  131. package/node_modules/tar/dist/esm/normalize-unicode.js +9 -0
  132. package/node_modules/tar/dist/esm/options.d.ts +284 -513
  133. package/node_modules/tar/dist/esm/options.js +17 -51
  134. package/node_modules/tar/dist/esm/pack.d.ts +150 -96
  135. package/node_modules/tar/dist/esm/pack.js +750 -441
  136. package/node_modules/tar/dist/esm/parser.d.ts +98 -0
  137. package/node_modules/tar/dist/esm/parser.js +448 -0
  138. package/node_modules/tar/dist/esm/path-reservations.d.ts +17 -7
  139. package/node_modules/tar/dist/esm/path-reservations.js +110 -140
  140. package/node_modules/tar/dist/esm/path.d.ts +19 -0
  141. package/node_modules/tar/dist/esm/path.js +80 -0
  142. package/node_modules/tar/dist/esm/pax.d.ts +3 -1
  143. package/node_modules/tar/dist/esm/pax.js +66 -35
  144. package/node_modules/tar/dist/esm/read-entry.d.ts +97 -11
  145. package/node_modules/tar/dist/esm/read-entry.js +248 -96
  146. package/node_modules/tar/dist/esm/read-file.d.ts +22 -0
  147. package/node_modules/tar/dist/esm/read-file.js +99 -0
  148. package/node_modules/tar/dist/esm/replace.d.ts +45 -1
  149. package/node_modules/tar/dist/esm/replace.js +160 -207
  150. package/node_modules/tar/dist/esm/server/codecs.d.ts +38 -0
  151. package/node_modules/tar/dist/esm/server/codecs.js +214 -0
  152. package/node_modules/tar/dist/esm/server/index.d.ts +115 -0
  153. package/node_modules/tar/dist/esm/server/index.js +102 -0
  154. package/node_modules/tar/dist/esm/server/index.min.js +3 -0
  155. package/node_modules/tar/dist/esm/strip-absolute-path.d.ts +8 -0
  156. package/node_modules/tar/dist/esm/strip-absolute-path.js +17 -20
  157. package/node_modules/tar/dist/esm/to-stream.d.ts +7 -0
  158. package/node_modules/tar/dist/esm/to-stream.js +18 -0
  159. package/node_modules/tar/dist/esm/types.d.ts +4 -3
  160. package/node_modules/tar/dist/esm/types.js +4 -3
  161. package/node_modules/tar/dist/esm/unpack.d.ts +143 -89
  162. package/node_modules/tar/dist/esm/unpack.js +776 -719
  163. package/node_modules/tar/dist/esm/update.d.ts +11 -1
  164. package/node_modules/tar/dist/esm/update.js +35 -28
  165. package/node_modules/tar/dist/esm/warn.d.ts +27 -0
  166. package/node_modules/tar/dist/esm/warn.js +31 -0
  167. package/node_modules/tar/dist/esm/win32-path.d.ts +16 -0
  168. package/node_modules/tar/dist/esm/win32-path.js +60 -0
  169. package/node_modules/tar/dist/esm/write-entry.d.ts +64 -111
  170. package/node_modules/tar/dist/esm/write-entry.js +107 -633
  171. package/node_modules/tar/dist/esm/write-flag.d.ts +18 -0
  172. package/node_modules/tar/dist/esm/write-flag.js +25 -0
  173. package/node_modules/tar/package.json +68 -224
  174. package/package.json +2 -2
  175. package/packages/pm-beads/package.json +1 -1
  176. package/packages/pm-calendar/package.json +1 -1
  177. package/packages/pm-command-kit/package.json +1 -1
  178. package/packages/pm-digital-twin/package.json +1 -1
  179. package/packages/pm-governance-audit/package.json +1 -1
  180. package/packages/pm-guide-shell/package.json +1 -1
  181. package/packages/pm-kanban/package.json +1 -1
  182. package/packages/pm-lifecycle-hooks/package.json +1 -1
  183. package/packages/pm-linked-test-adapters/package.json +1 -1
  184. package/packages/pm-search-advanced/package.json +1 -1
  185. package/packages/pm-templates/package.json +1 -1
  186. package/packages/pm-todos/package.json +1 -1
  187. package/packages/pm-vcs/package.json +1 -1
  188. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  189. package/plugins/pm-claude/package.json +1 -1
  190. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  191. package/plugins/pm-codex/package.json +1 -1
  192. package/plugins/pm-codex/plugin.json +1 -1
  193. package/runtime-dependencies.json +1 -1
  194. package/dist/cli-bundle/chunks/chunk-AJLU6KLW.js +0 -2
  195. package/node_modules/@isaacs/fs-minipass/LICENSE +0 -15
  196. package/node_modules/@isaacs/fs-minipass/README.md +0 -71
  197. package/node_modules/@isaacs/fs-minipass/dist/commonjs/index.d.ts +0 -118
  198. package/node_modules/@isaacs/fs-minipass/dist/commonjs/index.js +0 -430
  199. package/node_modules/@isaacs/fs-minipass/dist/commonjs/package.json +0 -3
  200. package/node_modules/@isaacs/fs-minipass/dist/esm/index.d.ts +0 -118
  201. package/node_modules/@isaacs/fs-minipass/dist/esm/index.js +0 -420
  202. package/node_modules/@isaacs/fs-minipass/dist/esm/package.json +0 -3
  203. package/node_modules/@isaacs/fs-minipass/package.json +0 -72
  204. package/node_modules/chownr/LICENSE.md +0 -63
  205. package/node_modules/chownr/README.md +0 -3
  206. package/node_modules/chownr/dist/commonjs/index.d.ts +0 -3
  207. package/node_modules/chownr/dist/commonjs/index.js +0 -93
  208. package/node_modules/chownr/dist/commonjs/package.json +0 -3
  209. package/node_modules/chownr/dist/esm/index.d.ts +0 -3
  210. package/node_modules/chownr/dist/esm/index.js +0 -85
  211. package/node_modules/chownr/dist/esm/package.json +0 -3
  212. package/node_modules/chownr/package.json +0 -69
  213. package/node_modules/minipass/LICENSE.md +0 -55
  214. package/node_modules/minipass/README.md +0 -825
  215. package/node_modules/minipass/dist/commonjs/index.d.ts +0 -545
  216. package/node_modules/minipass/dist/commonjs/index.js +0 -1038
  217. package/node_modules/minipass/dist/commonjs/package.json +0 -3
  218. package/node_modules/minipass/dist/esm/index.d.ts +0 -545
  219. package/node_modules/minipass/dist/esm/index.js +0 -1020
  220. package/node_modules/minipass/dist/esm/package.json +0 -3
  221. package/node_modules/minipass/package.json +0 -77
  222. package/node_modules/minizlib/LICENSE +0 -26
  223. package/node_modules/minizlib/README.md +0 -64
  224. package/node_modules/minizlib/dist/commonjs/constants.d.ts +0 -2
  225. package/node_modules/minizlib/dist/commonjs/constants.js +0 -123
  226. package/node_modules/minizlib/dist/commonjs/index.d.ts +0 -99
  227. package/node_modules/minizlib/dist/commonjs/index.js +0 -416
  228. package/node_modules/minizlib/dist/commonjs/package.json +0 -3
  229. package/node_modules/minizlib/dist/esm/constants.d.ts +0 -2
  230. package/node_modules/minizlib/dist/esm/constants.js +0 -117
  231. package/node_modules/minizlib/dist/esm/index.d.ts +0 -99
  232. package/node_modules/minizlib/dist/esm/index.js +0 -363
  233. package/node_modules/minizlib/dist/esm/package.json +0 -3
  234. package/node_modules/minizlib/package.json +0 -80
  235. package/node_modules/tar/dist/commonjs/get-write-flag.d.ts +0 -2
  236. package/node_modules/tar/dist/commonjs/get-write-flag.js +0 -32
  237. package/node_modules/tar/dist/commonjs/make-command.d.ts +0 -49
  238. package/node_modules/tar/dist/commonjs/make-command.js +0 -52
  239. package/node_modules/tar/dist/commonjs/normalize-windows-path.d.ts +0 -2
  240. package/node_modules/tar/dist/commonjs/normalize-windows-path.js +0 -12
  241. package/node_modules/tar/dist/commonjs/parse.d.ts +0 -92
  242. package/node_modules/tar/dist/commonjs/parse.js +0 -655
  243. package/node_modules/tar/dist/commonjs/process-umask.d.ts +0 -2
  244. package/node_modules/tar/dist/commonjs/process-umask.js +0 -7
  245. package/node_modules/tar/dist/commonjs/warn-method.d.ts +0 -24
  246. package/node_modules/tar/dist/commonjs/warn-method.js +0 -31
  247. package/node_modules/tar/dist/esm/get-write-flag.d.ts +0 -2
  248. package/node_modules/tar/dist/esm/get-write-flag.js +0 -26
  249. package/node_modules/tar/dist/esm/make-command.d.ts +0 -49
  250. package/node_modules/tar/dist/esm/make-command.js +0 -48
  251. package/node_modules/tar/dist/esm/normalize-windows-path.d.ts +0 -2
  252. package/node_modules/tar/dist/esm/normalize-windows-path.js +0 -9
  253. package/node_modules/tar/dist/esm/parse.d.ts +0 -92
  254. package/node_modules/tar/dist/esm/parse.js +0 -651
  255. package/node_modules/tar/dist/esm/process-umask.d.ts +0 -2
  256. package/node_modules/tar/dist/esm/process-umask.js +0 -3
  257. package/node_modules/tar/dist/esm/warn-method.d.ts +0 -24
  258. package/node_modules/tar/dist/esm/warn-method.js +0 -27
  259. package/node_modules/yallist/LICENSE.md +0 -63
  260. package/node_modules/yallist/README.md +0 -205
  261. package/node_modules/yallist/dist/commonjs/index.d.ts +0 -39
  262. package/node_modules/yallist/dist/commonjs/index.js +0 -384
  263. package/node_modules/yallist/dist/commonjs/package.json +0 -3
  264. package/node_modules/yallist/dist/esm/index.d.ts +0 -39
  265. package/node_modules/yallist/dist/esm/index.js +0 -379
  266. package/node_modules/yallist/dist/esm/package.json +0 -3
  267. package/node_modules/yallist/package.json +0 -68
@@ -1,169 +1,139 @@
1
1
  "use strict";
2
- // A path exclusive reservation system
3
- // reserve([list, of, paths], fn)
4
- // When the fn is first in line for all its paths, it
5
- // is called with a cb that clears the reservation.
6
- //
7
- // Used by async unpack to avoid clobbering paths in use,
8
- // while still allowing maximal safe parallelization.
2
+ // The async extraction does several entries at one time. Two entries
3
+ // must not work on the same path at one time: a link needs its
4
+ // target, and an entry can replace an object of a different type.
9
5
  Object.defineProperty(exports, "__esModule", { value: true });
10
6
  exports.PathReservations = void 0;
11
- const node_path_1 = require("node:path");
12
7
  const normalize_unicode_js_1 = require("./normalize-unicode.js");
13
8
  const strip_trailing_slashes_js_1 = require("./strip-trailing-slashes.js");
14
- const platform = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
15
- const isWindows = platform === 'win32';
16
- // return a set of parent dirs for a given path
17
- // '/a/b/c/d' -> ['/', '/a', '/a/b', '/a/b/c', '/a/b/c/d']
18
- const getDirs = (path) => {
19
- const dirs = path
20
- .split('/')
21
- .slice(0, -1)
22
- .reduce((set, path) => {
23
- const s = set.at(-1);
24
- if (s !== undefined) {
25
- path = (0, node_path_1.join)(s, path);
26
- }
27
- set.push(path || '/');
28
- return set;
29
- }, []);
30
- return dirs;
31
- };
9
+ const path_js_1 = require("./path.js");
10
+ /**
11
+ * Gives each task the exclusive use of its paths, and the shared use
12
+ * of their parent directories. A task starts when each task before
13
+ * it that uses one of its paths, or a directory above or below one,
14
+ * is done.
15
+ *
16
+ * Paths that differ only in case or in Unicode form are the same
17
+ * path, because they can be the same file on disk.
18
+ */
32
19
  class PathReservations {
33
- // path => [function or Set]
34
- // A Set object means a directory reservation
35
- // A fn is a direct reservation on that path
36
- #queues = new Map();
37
- // fn => {paths:[path,...], dirs:[path, ...]}
20
+ #root = { queue: [], name: '' };
38
21
  #reservations = new Map();
39
- // functions currently running
40
22
  #running = new Set();
23
+ #win32;
24
+ /** @param win32 run one task at a time */
25
+ constructor(win32 = false) {
26
+ this.#win32 = win32;
27
+ }
28
+ /**
29
+ * Call `fn` when it is first in line for each of its paths. The
30
+ * paths are free again when the promise of `fn` settles. Returns a
31
+ * promise with the result of `fn`.
32
+ */
41
33
  reserve(paths, fn) {
42
- paths =
43
- isWindows ?
44
- ['win32 parallelization disabled']
45
- : paths.map(p => {
46
- // don't need normPath, because we skip this entirely for windows
47
- return (0, strip_trailing_slashes_js_1.stripTrailingSlashes)((0, node_path_1.join)((0, normalize_unicode_js_1.normalizeUnicode)(p)));
34
+ return new Promise((res, rej) => {
35
+ const handler = () => {
36
+ fn().then(() => {
37
+ this.#clear(handler);
38
+ res();
39
+ }, er => {
40
+ this.#clear(handler);
41
+ rej(er);
48
42
  });
49
- const dirs = new Set(paths.map(path => getDirs(path)).reduce((a, b) => a.concat(b)));
50
- this.#reservations.set(fn, { dirs, paths });
51
- for (const p of paths) {
52
- const q = this.#queues.get(p);
53
- if (!q) {
54
- this.#queues.set(p, [fn]);
55
- }
56
- else {
57
- q.push(fn);
58
- }
59
- }
60
- for (const dir of dirs) {
61
- const q = this.#queues.get(dir);
62
- if (!q) {
63
- this.#queues.set(dir, [new Set([fn])]);
64
- }
65
- else {
66
- const l = q.at(-1);
67
- if (l instanceof Set) {
68
- l.add(fn);
69
- }
70
- else {
71
- q.push(new Set([fn]));
72
- }
43
+ };
44
+ this.#add(paths, handler);
45
+ });
46
+ }
47
+ #add(names, fn) {
48
+ const root = this.#root;
49
+ const paths = new Set();
50
+ const dirs = new Set();
51
+ for (const name of this.#win32 ?
52
+ ['win32 parallelization disabled']
53
+ : names) {
54
+ const path = this.#win32 ? name : ((0, strip_trailing_slashes_js_1.stripTrailingSlashes)((0, path_js_1.join)((0, normalize_unicode_js_1.normalizeUnicode)(name))));
55
+ let node = root;
56
+ for (const part of path.split('/')) {
57
+ if (node !== root)
58
+ dirs.add(node);
59
+ const kids = (node.kids ??= new Map());
60
+ let kid = kids.get(part);
61
+ if (!kid)
62
+ kids.set(part, (kid = { queue: [], name: part, up: node }));
63
+ node = kid;
73
64
  }
65
+ paths.add(node);
74
66
  }
75
- return this.#run(fn);
76
- }
77
- // return the queues for each path the function cares about
78
- // fn => {paths, dirs}
79
- #getQueues(fn) {
80
- const res = this.#reservations.get(fn);
81
- /* c8 ignore start */
82
- if (!res) {
83
- throw new Error('function does not have any path reservations');
67
+ // A path of the task is exclusive, so it also covers the use of
68
+ // that path as a parent directory of another path.
69
+ for (const p of paths)
70
+ dirs.delete(p);
71
+ this.#reservations.set(fn, { dirs, paths });
72
+ for (const p of paths)
73
+ p.queue.push(fn);
74
+ for (const { queue } of dirs) {
75
+ const last = queue[queue.length - 1];
76
+ if (last instanceof Set)
77
+ last.add(fn);
78
+ else
79
+ queue.push(new Set([fn]));
84
80
  }
85
- /* c8 ignore stop */
86
- return {
87
- paths: res.paths.map((path) => this.#queues.get(path)),
88
- dirs: [...res.dirs].map(path => this.#queues.get(path)),
89
- };
90
- }
91
- // check if fn is first in line for all its paths, and is
92
- // included in the first set for all its dir queues
93
- check(fn) {
94
- const { paths, dirs } = this.#getQueues(fn);
95
- return (paths.every(q => q && q[0] === fn) &&
96
- dirs.every(q => q && q[0] instanceof Set && q[0].has(fn)));
81
+ this.#run(fn);
97
82
  }
98
- // run the function if it's first in line and not already running
83
+ // Start the task if it is first in line for each path, and in the
84
+ // first set for each directory. A task that waits is never first in
85
+ // line for each of them, so a task starts one time only.
99
86
  #run(fn) {
100
- if (this.#running.has(fn) || !this.check(fn)) {
101
- return false;
87
+ const { paths, dirs } = this.#reservations.get(fn);
88
+ for (const p of paths) {
89
+ if (p.queue[0] !== fn)
90
+ return;
91
+ }
92
+ for (const { queue } of dirs) {
93
+ const first = queue[0];
94
+ if (!(first instanceof Set) || !first.has(fn))
95
+ return;
102
96
  }
103
97
  this.#running.add(fn);
104
- fn(() => this.#clear(fn));
105
- return true;
98
+ fn();
106
99
  }
107
100
  #clear(fn) {
108
- if (!this.#running.has(fn)) {
109
- return false;
110
- }
111
- const res = this.#reservations.get(fn);
112
- /* c8 ignore start */
113
- if (!res) {
114
- throw new Error('invalid reservation');
115
- }
116
- /* c8 ignore stop */
117
- const { paths, dirs } = res;
101
+ const { paths, dirs } = this.#reservations.get(fn);
118
102
  const next = new Set();
119
- for (const path of paths) {
120
- const q = this.#queues.get(path);
121
- /* c8 ignore start */
122
- if (!q || q?.[0] !== fn) {
123
- continue;
124
- }
125
- /* c8 ignore stop */
126
- const q0 = q[1];
127
- if (!q0) {
128
- this.#queues.delete(path);
129
- continue;
130
- }
131
- q.shift();
132
- if (typeof q0 === 'function') {
133
- next.add(q0);
134
- }
135
- else {
136
- for (const f of q0) {
103
+ for (const { queue } of paths) {
104
+ // A running task is first in the queue of each of its paths.
105
+ queue.shift();
106
+ const after = queue[0];
107
+ if (typeof after === 'function')
108
+ next.add(after);
109
+ else if (after)
110
+ for (const f of after)
137
111
  next.add(f);
138
- }
139
- }
140
112
  }
141
- for (const dir of dirs) {
142
- const q = this.#queues.get(dir);
143
- const q0 = q?.[0];
144
- /* c8 ignore next - type safety only */
145
- if (!q || !(q0 instanceof Set))
146
- continue;
147
- if (q0.size === 1 && q.length === 1) {
148
- this.#queues.delete(dir);
149
- continue;
150
- }
151
- else if (q0.size === 1) {
152
- q.shift();
153
- // next one must be a function,
154
- // or else the Set would've been reused
155
- const n = q[0];
156
- if (typeof n === 'function') {
157
- next.add(n);
158
- }
159
- }
113
+ for (const { queue } of dirs) {
114
+ // A running task is in the first set of each of its directories.
115
+ const first = queue[0];
116
+ if (first.size > 1)
117
+ first.delete(fn);
160
118
  else {
161
- q0.delete(fn);
119
+ queue.shift();
120
+ // Two sets in a row would be one set, so this is a function.
121
+ if (queue.length)
122
+ next.add(queue[0]);
123
+ }
124
+ }
125
+ // Remove each node that no task uses. Each directory of the task
126
+ // is above one of its paths.
127
+ for (let node of paths) {
128
+ while (node.up && !node.queue.length && !node.kids?.size) {
129
+ node.up.kids?.delete(node.name);
130
+ node = node.up;
162
131
  }
163
132
  }
164
133
  this.#running.delete(fn);
165
- next.forEach(fn => this.#run(fn));
166
- return true;
134
+ this.#reservations.delete(fn);
135
+ for (const f of next)
136
+ this.#run(f);
167
137
  }
168
138
  }
169
139
  exports.PathReservations = PathReservations;
@@ -0,0 +1,19 @@
1
+ /** Resolve `.` and `..` parts, and remove repeated slashes. */
2
+ export declare const normalize: (path: string) => string;
3
+ /** Join the parts with a slash, then normalize the result. */
4
+ export declare const join: (...parts: string[]) => string;
5
+ /** The path without its last part. */
6
+ export declare const dirname: (path: string) => string;
7
+ /** The last part of the path. */
8
+ export declare const basename: (path: string) => string;
9
+ /** True if the path starts with a slash. */
10
+ export declare const isAbsolute: (path: string) => boolean;
11
+ /**
12
+ * Resolve the parts from right to left, up to the first absolute
13
+ * part. There is no working directory here: if no part is absolute,
14
+ * the result is a relative path.
15
+ */
16
+ export declare const resolve: (...parts: string[]) => string;
17
+ /** The relative path from `from` to `to`. */
18
+ export declare const relative: (from: string, to: string) => string;
19
+ //# sourceMappingURL=path.d.ts.map
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ // The POSIX path functions that tar paths need. Each one gives the
3
+ // same result as the function of the same name in `path.posix`.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.relative = exports.resolve = exports.isAbsolute = exports.basename = exports.dirname = exports.join = exports.normalize = void 0;
6
+ /** Resolve `.` and `..` parts, and remove repeated slashes. */
7
+ const normalize = (path) => {
8
+ const absolute = path.charCodeAt(0) === 47;
9
+ const out = [];
10
+ for (const part of path.split('/')) {
11
+ if (part === '' || part === '.')
12
+ continue;
13
+ if (part !== '..')
14
+ out.push(part);
15
+ else if (out.length && out[out.length - 1] !== '..')
16
+ out.pop();
17
+ else if (!absolute)
18
+ out.push(part);
19
+ }
20
+ const trail = out.length && path.charCodeAt(path.length - 1) === 47;
21
+ const res = out.join('/') + (trail ? '/' : '');
22
+ if (absolute)
23
+ return '/' + res;
24
+ return res || (path.endsWith('/') ? './' : '.');
25
+ };
26
+ exports.normalize = normalize;
27
+ /** Join the parts with a slash, then normalize the result. */
28
+ const join = (...parts) => (0, exports.normalize)(parts.filter(p => p).join('/'));
29
+ exports.join = join;
30
+ /** The path without its last part. */
31
+ const dirname = (path) => {
32
+ let end = path.length;
33
+ while (end > 1 && path.charCodeAt(end - 1) === 47)
34
+ end--;
35
+ const slash = path.lastIndexOf('/', end - 1);
36
+ if (slash === -1)
37
+ return '.';
38
+ if (slash === 0)
39
+ return '/';
40
+ if (slash === 1 && path.charCodeAt(0) === 47)
41
+ return '//';
42
+ return path.slice(0, slash);
43
+ };
44
+ exports.dirname = dirname;
45
+ /** The last part of the path. */
46
+ const basename = (path) => {
47
+ let end = path.length;
48
+ while (end > 0 && path.charCodeAt(end - 1) === 47)
49
+ end--;
50
+ return path.slice(path.lastIndexOf('/', end - 1) + 1, end);
51
+ };
52
+ exports.basename = basename;
53
+ /** True if the path starts with a slash. */
54
+ const isAbsolute = (path) => path.charCodeAt(0) === 47;
55
+ exports.isAbsolute = isAbsolute;
56
+ /**
57
+ * Resolve the parts from right to left, up to the first absolute
58
+ * part. There is no working directory here: if no part is absolute,
59
+ * the result is a relative path.
60
+ */
61
+ const resolve = (...parts) => {
62
+ let path = '';
63
+ for (let i = parts.length - 1; i >= 0 && !(0, exports.isAbsolute)(path); i--) {
64
+ const part = parts[i];
65
+ if (part)
66
+ path = path ? part + '/' + path : part;
67
+ }
68
+ const res = (0, exports.normalize)(path);
69
+ return res.length > 1 && res.endsWith('/') ? res.slice(0, -1) : res;
70
+ };
71
+ exports.resolve = resolve;
72
+ /** The relative path from `from` to `to`. */
73
+ const relative = (from, to) => {
74
+ const f = (0, exports.resolve)(from).split('/');
75
+ const t = (0, exports.resolve)(to).split('/');
76
+ // The root gives an empty last part.
77
+ if (!f[f.length - 1])
78
+ f.pop();
79
+ if (!t[t.length - 1])
80
+ t.pop();
81
+ let same = 0;
82
+ while (same < f.length && same < t.length && f[same] === t[same])
83
+ same++;
84
+ return [
85
+ ...Array.from({ length: f.length - same }, () => '..'),
86
+ ...t.slice(same),
87
+ ].join('/');
88
+ };
89
+ exports.relative = relative;
90
+ //# sourceMappingURL=path.js.map
@@ -18,9 +18,11 @@ export declare class Pax implements HeaderData {
18
18
  mode?: number;
19
19
  global: boolean;
20
20
  constructor(obj: HeaderData, global?: boolean);
21
- encode(): Buffer<ArrayBuffer>;
21
+ encode(): Uint8Array<ArrayBuffer>;
22
22
  encodeBody(): string;
23
23
  encodeField(field: keyof Pax): string;
24
24
  static parse(str: string, ex?: HeaderData, g?: boolean): Pax;
25
+ /** Parse the body of a PAX header entry. */
26
+ static parseBytes(buf: Uint8Array, ex?: HeaderData, g?: boolean): Pax;
25
27
  }
26
28
  //# sourceMappingURL=pax.d.ts.map
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Pax = void 0;
4
- const node_path_1 = require("node:path");
5
4
  const header_js_1 = require("./header.js");
5
+ const bytes_js_1 = require("./bytes.js");
6
+ const path_js_1 = require("./path.js");
7
+ const SIMPLE_NUMBER = /^\d+$/;
6
8
  class Pax {
7
9
  atime;
8
10
  mtime;
@@ -42,24 +44,18 @@ class Pax {
42
44
  encode() {
43
45
  const body = this.encodeBody();
44
46
  if (body === '') {
45
- return Buffer.allocUnsafe(0);
47
+ return new Uint8Array(0);
46
48
  }
47
- const bodyLen = Buffer.byteLength(body);
49
+ const bodyLen = (0, bytes_js_1.utf8Length)(body);
48
50
  // round up to 512 bytes
49
51
  // add 512 for header
50
52
  const bufLen = 512 * Math.ceil(1 + bodyLen / 512);
51
- const buf = Buffer.allocUnsafe(bufLen);
52
- // 0-fill the header section, it might not hit every field
53
- for (let i = 0; i < 512; i++) {
54
- buf[i] = 0;
55
- }
53
+ const buf = new Uint8Array(bufLen);
56
54
  new header_js_1.Header({
57
55
  // XXX split the path
58
56
  // then the path should be PaxHeader + basename, but less than 99,
59
57
  // prepend with the dirname
60
- /* c8 ignore start */
61
- path: ('PaxHeader/' + (0, node_path_1.basename)(this.path ?? '')).slice(0, 99),
62
- /* c8 ignore stop */
58
+ path: ('PaxHeader/' + (0, path_js_1.basename)(this.path ?? '')).slice(0, 99),
63
59
  mode: this.mode || 0o644,
64
60
  uid: this.uid,
65
61
  gid: this.gid,
@@ -74,11 +70,7 @@ class Pax {
74
70
  atime: this.atime,
75
71
  ctime: this.ctime,
76
72
  }).encode(buf);
77
- buf.write(body, 512, bodyLen, 'utf8');
78
- // null pad after the body
79
- for (let i = bodyLen + 512; i < buf.length; i++) {
80
- buf[i] = 0;
81
- }
73
+ (0, bytes_js_1.encodeUtf8Into)(body, buf, 512, bodyLen);
82
74
  return buf;
83
75
  }
84
76
  encodeBody() {
@@ -103,7 +95,7 @@ class Pax {
103
95
  return '';
104
96
  }
105
97
  const r = this[field];
106
- const v = r instanceof Date ? r.getTime() / 1000 : r;
98
+ const v = typeof r === 'object' ? r.getTime() / 1000 : r;
107
99
  const s = ' ' +
108
100
  (field === 'dev' || field === 'ino' || field === 'nlink' ?
109
101
  'SCHILY.'
@@ -112,7 +104,7 @@ class Pax {
112
104
  '=' +
113
105
  v +
114
106
  '\n';
115
- const byteLen = Buffer.byteLength(s);
107
+ const byteLen = (0, bytes_js_1.utf8Length)(s);
116
108
  // the digits includes the length of the digits in ascii base-10
117
109
  // so if it's 9 characters, then adding 1 for the 9 makes it 10
118
110
  // which makes it 11 chars.
@@ -124,30 +116,57 @@ class Pax {
124
116
  return len + s;
125
117
  }
126
118
  static parse(str, ex, g = false) {
127
- return new Pax(merge(parseKV(str), ex), g);
119
+ return Pax.parseBytes(new TextEncoder().encode(str), ex, g);
120
+ }
121
+ /** Parse the body of a PAX header entry. */
122
+ static parseBytes(buf, ex, g = false) {
123
+ return new Pax(merge(parseKV(buf), ex), g);
128
124
  }
129
125
  }
130
126
  exports.Pax = Pax;
131
127
  const merge = (a, b) => b ? Object.assign({}, b, a) : a;
132
- const parseKV = (str) => str
133
- .replace(/\n$/, '')
134
- .split('\n')
135
- .reduce(parseKVLine, Object.create(null));
136
- const parseKVLine = (set, line) => {
137
- const n = parseInt(line, 10);
138
- // XXX Values with \n in them will fail this.
139
- // Refactor to not be a naive line-by-line parse.
140
- if (n !== Buffer.byteLength(line) + 1) {
141
- return set;
128
+ // Each record is "<len> <key>=<value>\n". <len> is the byte length of
129
+ // the whole record. A value can contain a newline, so use the length
130
+ // to find the end of the record. A NUL where a record starts is the
131
+ // end of the records, as it is for GNU tar and Python. A record that
132
+ // is not valid is an error, because the records after it can set the
133
+ // size or the name of the entry.
134
+ const parseKV = (buf) => {
135
+ const set = Object.create(null);
136
+ let pos = 0;
137
+ while (pos < buf.length && buf[pos] !== 0) {
138
+ let sp = pos;
139
+ while (sp < buf.length &&
140
+ buf[sp] >= 0x30 &&
141
+ buf[sp] <= 0x39) {
142
+ sp++;
143
+ }
144
+ const end = pos + Number((0, bytes_js_1.decodeUtf8)(buf, pos, sp));
145
+ if (sp === pos ||
146
+ buf[sp] !== 0x20 ||
147
+ end <= sp + 1 ||
148
+ end > buf.length ||
149
+ buf[end - 1] !== 0x0a) {
150
+ throw new Error('invalid PAX record');
151
+ }
152
+ parseKVLine(set, (0, bytes_js_1.decodeUtf8)(buf, sp + 1, end - 1));
153
+ pos = end;
142
154
  }
143
- line = line.slice((n + ' ').length);
155
+ return set;
156
+ };
157
+ const parseKVLine = (set, line) => {
144
158
  const kv = line.split('=');
159
+ if (kv.length === 1)
160
+ throw new Error('invalid PAX record');
145
161
  const r = kv.shift();
146
162
  if (!r) {
147
163
  return set;
148
164
  }
149
165
  const k = r.replace(/^SCHILY\.(dev|ino|nlink)/, '$1');
150
- const v = kv.join('=').replace(/\0.*/, '');
166
+ // The value ends at the first NUL.
167
+ const joined = kv.join('=');
168
+ const nul = joined.indexOf('\0');
169
+ const v = nul === -1 ? joined : joined.slice(0, nul);
151
170
  switch (k) {
152
171
  case 'path':
153
172
  case 'linkpath':
@@ -161,12 +180,18 @@ const parseKVLine = (set, line) => {
161
180
  case 'ctime':
162
181
  case 'atime':
163
182
  case 'mtime':
164
- set[k] = new Date(Number(v) * 1000);
183
+ const d = new Date(Number(v) * 1000);
184
+ if (!isNaN(d.getTime()))
185
+ set[k] = d;
165
186
  break;
166
187
  case 'size':
167
- const s = +v;
168
- if (s >= 0)
169
- set[k] = s;
188
+ // The size sets where the next header is. Other tar programs
189
+ // read a value that is not only decimal digits in different
190
+ // ways, so it is an error.
191
+ if (!SIMPLE_NUMBER.test(joined) || !Number.isSafeInteger(+joined)) {
192
+ throw new Error('invalid PAX size');
193
+ }
194
+ set[k] = +joined;
170
195
  break;
171
196
  case 'gid':
172
197
  case 'uid':
@@ -174,7 +199,13 @@ const parseKVLine = (set, line) => {
174
199
  case 'ino':
175
200
  case 'nlink':
176
201
  case 'mode':
177
- set[k] = +v;
202
+ // value must be a string of decimal digits
203
+ if (!SIMPLE_NUMBER.test(v.trim()))
204
+ break;
205
+ const s = +v;
206
+ if (!Number.isSafeInteger(s))
207
+ break;
208
+ set[k] = s;
178
209
  break;
179
210
  }
180
211
  return set;