@nocobase/plugin-multi-portal 2.2.0-alpha.10

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 (217) hide show
  1. package/LICENSE.txt +107 -0
  2. package/README.md +14 -0
  3. package/client-v2.d.ts +2 -0
  4. package/client-v2.js +1 -0
  5. package/client.d.ts +2 -0
  6. package/client.js +1 -0
  7. package/dist/client/index.d.ts +9 -0
  8. package/dist/client/index.js +10 -0
  9. package/dist/client/locale.d.ts +10 -0
  10. package/dist/client/models/index.d.ts +11 -0
  11. package/dist/client/plugin.d.ts +13 -0
  12. package/dist/client-v2/354.ead3e96143164cd5.js +10 -0
  13. package/dist/client-v2/499.ef2ff0c022687485.js +10 -0
  14. package/dist/client-v2/778.23ba409a924ee34a.js +10 -0
  15. package/dist/client-v2/845.f2b0ce44ae4be707.js +10 -0
  16. package/dist/client-v2/entryActions/PortalEntryActionModel.d.ts +52 -0
  17. package/dist/client-v2/entryActions/portalEntryActionStore.d.ts +36 -0
  18. package/dist/client-v2/entryActions/registerPortalEntryActions.d.ts +10 -0
  19. package/dist/client-v2/entryActions/types.d.ts +41 -0
  20. package/dist/client-v2/entryActions/url.d.ts +10 -0
  21. package/dist/client-v2/index.d.ts +9 -0
  22. package/dist/client-v2/index.js +10 -0
  23. package/dist/client-v2/layoutRegistration.d.ts +38 -0
  24. package/dist/client-v2/locale.d.ts +13 -0
  25. package/dist/client-v2/models/MultiPortalBlockModel.d.ts +13 -0
  26. package/dist/client-v2/models/MultiPortalMobilePageModels.d.ts +34 -0
  27. package/dist/client-v2/pages/MultiPortalsPage.d.ts +80 -0
  28. package/dist/client-v2/permissions/MultiPortalPermissionsTab.d.ts +21 -0
  29. package/dist/client-v2/permissions/multiPortalPermissions.d.ts +12 -0
  30. package/dist/client-v2/plugin.d.ts +13 -0
  31. package/dist/client-v2/routeRepositoryScope.d.ts +11 -0
  32. package/dist/client-v2/routeUrl.d.ts +18 -0
  33. package/dist/externalVersion.js +25 -0
  34. package/dist/index.d.ts +10 -0
  35. package/dist/index.js +48 -0
  36. package/dist/locale/en-US.json +82 -0
  37. package/dist/locale/zh-CN.json +82 -0
  38. package/dist/node_modules/tar/dist/commonjs/create.d.ts +3 -0
  39. package/dist/node_modules/tar/dist/commonjs/create.js +82 -0
  40. package/dist/node_modules/tar/dist/commonjs/cwd-error.d.ts +8 -0
  41. package/dist/node_modules/tar/dist/commonjs/cwd-error.js +18 -0
  42. package/dist/node_modules/tar/dist/commonjs/extract.d.ts +3 -0
  43. package/dist/node_modules/tar/dist/commonjs/extract.js +88 -0
  44. package/dist/node_modules/tar/dist/commonjs/get-write-flag.d.ts +2 -0
  45. package/dist/node_modules/tar/dist/commonjs/get-write-flag.js +32 -0
  46. package/dist/node_modules/tar/dist/commonjs/header.d.ts +53 -0
  47. package/dist/node_modules/tar/dist/commonjs/header.js +312 -0
  48. package/dist/node_modules/tar/dist/commonjs/index.d.ts +20 -0
  49. package/dist/node_modules/tar/dist/commonjs/index.js +64 -0
  50. package/dist/node_modules/tar/dist/commonjs/index.min.js +1 -0
  51. package/dist/node_modules/tar/dist/commonjs/large-numbers.d.ts +3 -0
  52. package/dist/node_modules/tar/dist/commonjs/large-numbers.js +99 -0
  53. package/dist/node_modules/tar/dist/commonjs/list.d.ts +7 -0
  54. package/dist/node_modules/tar/dist/commonjs/list.js +145 -0
  55. package/dist/node_modules/tar/dist/commonjs/make-command.d.ts +49 -0
  56. package/dist/node_modules/tar/dist/commonjs/make-command.js +52 -0
  57. package/dist/node_modules/tar/dist/commonjs/mkdir.d.ts +25 -0
  58. package/dist/node_modules/tar/dist/commonjs/mkdir.js +187 -0
  59. package/dist/node_modules/tar/dist/commonjs/mode-fix.d.ts +2 -0
  60. package/dist/node_modules/tar/dist/commonjs/mode-fix.js +29 -0
  61. package/dist/node_modules/tar/dist/commonjs/normalize-unicode.d.ts +2 -0
  62. package/dist/node_modules/tar/dist/commonjs/normalize-unicode.js +38 -0
  63. package/dist/node_modules/tar/dist/commonjs/normalize-windows-path.d.ts +2 -0
  64. package/dist/node_modules/tar/dist/commonjs/normalize-windows-path.js +12 -0
  65. package/dist/node_modules/tar/dist/commonjs/options.d.ts +596 -0
  66. package/dist/node_modules/tar/dist/commonjs/options.js +66 -0
  67. package/dist/node_modules/tar/dist/commonjs/pack.d.ts +105 -0
  68. package/dist/node_modules/tar/dist/commonjs/pack.js +545 -0
  69. package/dist/node_modules/tar/dist/commonjs/package.json +3 -0
  70. package/dist/node_modules/tar/dist/commonjs/parse.d.ts +85 -0
  71. package/dist/node_modules/tar/dist/commonjs/parse.js +610 -0
  72. package/dist/node_modules/tar/dist/commonjs/path-reservations.d.ts +11 -0
  73. package/dist/node_modules/tar/dist/commonjs/path-reservations.js +170 -0
  74. package/dist/node_modules/tar/dist/commonjs/pax.d.ts +26 -0
  75. package/dist/node_modules/tar/dist/commonjs/pax.js +158 -0
  76. package/dist/node_modules/tar/dist/commonjs/process-umask.d.ts +2 -0
  77. package/dist/node_modules/tar/dist/commonjs/process-umask.js +7 -0
  78. package/dist/node_modules/tar/dist/commonjs/read-entry.d.ts +36 -0
  79. package/dist/node_modules/tar/dist/commonjs/read-entry.js +136 -0
  80. package/dist/node_modules/tar/dist/commonjs/replace.d.ts +2 -0
  81. package/dist/node_modules/tar/dist/commonjs/replace.js +227 -0
  82. package/dist/node_modules/tar/dist/commonjs/strip-absolute-path.d.ts +2 -0
  83. package/dist/node_modules/tar/dist/commonjs/strip-absolute-path.js +29 -0
  84. package/dist/node_modules/tar/dist/commonjs/strip-trailing-slashes.d.ts +2 -0
  85. package/dist/node_modules/tar/dist/commonjs/strip-trailing-slashes.js +18 -0
  86. package/dist/node_modules/tar/dist/commonjs/symlink-error.d.ts +9 -0
  87. package/dist/node_modules/tar/dist/commonjs/symlink-error.js +19 -0
  88. package/dist/node_modules/tar/dist/commonjs/types.d.ts +7 -0
  89. package/dist/node_modules/tar/dist/commonjs/types.js +50 -0
  90. package/dist/node_modules/tar/dist/commonjs/unpack.d.ts +101 -0
  91. package/dist/node_modules/tar/dist/commonjs/unpack.js +932 -0
  92. package/dist/node_modules/tar/dist/commonjs/update.d.ts +2 -0
  93. package/dist/node_modules/tar/dist/commonjs/update.js +33 -0
  94. package/dist/node_modules/tar/dist/commonjs/warn-method.d.ts +24 -0
  95. package/dist/node_modules/tar/dist/commonjs/warn-method.js +31 -0
  96. package/dist/node_modules/tar/dist/commonjs/winchars.d.ts +3 -0
  97. package/dist/node_modules/tar/dist/commonjs/winchars.js +14 -0
  98. package/dist/node_modules/tar/dist/commonjs/write-entry.d.ts +129 -0
  99. package/dist/node_modules/tar/dist/commonjs/write-entry.js +698 -0
  100. package/dist/node_modules/tar/dist/esm/create.d.ts +3 -0
  101. package/dist/node_modules/tar/dist/esm/create.js +76 -0
  102. package/dist/node_modules/tar/dist/esm/cwd-error.d.ts +8 -0
  103. package/dist/node_modules/tar/dist/esm/cwd-error.js +14 -0
  104. package/dist/node_modules/tar/dist/esm/extract.d.ts +3 -0
  105. package/dist/node_modules/tar/dist/esm/extract.js +49 -0
  106. package/dist/node_modules/tar/dist/esm/get-write-flag.d.ts +2 -0
  107. package/dist/node_modules/tar/dist/esm/get-write-flag.js +26 -0
  108. package/dist/node_modules/tar/dist/esm/header.d.ts +53 -0
  109. package/dist/node_modules/tar/dist/esm/header.js +275 -0
  110. package/dist/node_modules/tar/dist/esm/index.d.ts +20 -0
  111. package/dist/node_modules/tar/dist/esm/index.js +20 -0
  112. package/dist/node_modules/tar/dist/esm/index.min.js +4 -0
  113. package/dist/node_modules/tar/dist/esm/large-numbers.d.ts +3 -0
  114. package/dist/node_modules/tar/dist/esm/large-numbers.js +94 -0
  115. package/dist/node_modules/tar/dist/esm/list.d.ts +7 -0
  116. package/dist/node_modules/tar/dist/esm/list.js +105 -0
  117. package/dist/node_modules/tar/dist/esm/make-command.d.ts +49 -0
  118. package/dist/node_modules/tar/dist/esm/make-command.js +48 -0
  119. package/dist/node_modules/tar/dist/esm/mkdir.d.ts +25 -0
  120. package/dist/node_modules/tar/dist/esm/mkdir.js +179 -0
  121. package/dist/node_modules/tar/dist/esm/mode-fix.d.ts +2 -0
  122. package/dist/node_modules/tar/dist/esm/mode-fix.js +25 -0
  123. package/dist/node_modules/tar/dist/esm/normalize-unicode.d.ts +2 -0
  124. package/dist/node_modules/tar/dist/esm/normalize-unicode.js +34 -0
  125. package/dist/node_modules/tar/dist/esm/normalize-windows-path.d.ts +2 -0
  126. package/dist/node_modules/tar/dist/esm/normalize-windows-path.js +9 -0
  127. package/dist/node_modules/tar/dist/esm/options.d.ts +596 -0
  128. package/dist/node_modules/tar/dist/esm/options.js +54 -0
  129. package/dist/node_modules/tar/dist/esm/pack.d.ts +105 -0
  130. package/dist/node_modules/tar/dist/esm/pack.js +503 -0
  131. package/dist/node_modules/tar/dist/esm/package.json +3 -0
  132. package/dist/node_modules/tar/dist/esm/parse.d.ts +85 -0
  133. package/dist/node_modules/tar/dist/esm/parse.js +606 -0
  134. package/dist/node_modules/tar/dist/esm/path-reservations.d.ts +11 -0
  135. package/dist/node_modules/tar/dist/esm/path-reservations.js +166 -0
  136. package/dist/node_modules/tar/dist/esm/pax.d.ts +26 -0
  137. package/dist/node_modules/tar/dist/esm/pax.js +154 -0
  138. package/dist/node_modules/tar/dist/esm/process-umask.d.ts +2 -0
  139. package/dist/node_modules/tar/dist/esm/process-umask.js +3 -0
  140. package/dist/node_modules/tar/dist/esm/read-entry.d.ts +36 -0
  141. package/dist/node_modules/tar/dist/esm/read-entry.js +132 -0
  142. package/dist/node_modules/tar/dist/esm/replace.d.ts +2 -0
  143. package/dist/node_modules/tar/dist/esm/replace.js +221 -0
  144. package/dist/node_modules/tar/dist/esm/strip-absolute-path.d.ts +2 -0
  145. package/dist/node_modules/tar/dist/esm/strip-absolute-path.js +25 -0
  146. package/dist/node_modules/tar/dist/esm/strip-trailing-slashes.d.ts +2 -0
  147. package/dist/node_modules/tar/dist/esm/strip-trailing-slashes.js +14 -0
  148. package/dist/node_modules/tar/dist/esm/symlink-error.d.ts +9 -0
  149. package/dist/node_modules/tar/dist/esm/symlink-error.js +15 -0
  150. package/dist/node_modules/tar/dist/esm/types.d.ts +7 -0
  151. package/dist/node_modules/tar/dist/esm/types.js +45 -0
  152. package/dist/node_modules/tar/dist/esm/unpack.d.ts +101 -0
  153. package/dist/node_modules/tar/dist/esm/unpack.js +891 -0
  154. package/dist/node_modules/tar/dist/esm/update.d.ts +2 -0
  155. package/dist/node_modules/tar/dist/esm/update.js +30 -0
  156. package/dist/node_modules/tar/dist/esm/warn-method.d.ts +24 -0
  157. package/dist/node_modules/tar/dist/esm/warn-method.js +27 -0
  158. package/dist/node_modules/tar/dist/esm/winchars.d.ts +3 -0
  159. package/dist/node_modules/tar/dist/esm/winchars.js +9 -0
  160. package/dist/node_modules/tar/dist/esm/write-entry.d.ts +129 -0
  161. package/dist/node_modules/tar/dist/esm/write-entry.js +656 -0
  162. package/dist/node_modules/tar/node_modules/chownr/dist/commonjs/index.d.ts +3 -0
  163. package/dist/node_modules/tar/node_modules/chownr/dist/commonjs/index.js +93 -0
  164. package/dist/node_modules/tar/node_modules/chownr/dist/commonjs/package.json +3 -0
  165. package/dist/node_modules/tar/node_modules/chownr/dist/esm/index.d.ts +3 -0
  166. package/dist/node_modules/tar/node_modules/chownr/dist/esm/index.js +85 -0
  167. package/dist/node_modules/tar/node_modules/chownr/dist/esm/package.json +3 -0
  168. package/dist/node_modules/tar/node_modules/chownr/package.json +69 -0
  169. package/dist/node_modules/tar/node_modules/minipass/dist/commonjs/index.d.ts +549 -0
  170. package/dist/node_modules/tar/node_modules/minipass/dist/commonjs/index.js +1028 -0
  171. package/dist/node_modules/tar/node_modules/minipass/dist/commonjs/package.json +3 -0
  172. package/dist/node_modules/tar/node_modules/minipass/dist/esm/index.d.ts +549 -0
  173. package/dist/node_modules/tar/node_modules/minipass/dist/esm/index.js +1018 -0
  174. package/dist/node_modules/tar/node_modules/minipass/dist/esm/package.json +3 -0
  175. package/dist/node_modules/tar/node_modules/minipass/package.json +82 -0
  176. package/dist/node_modules/tar/node_modules/minizlib/dist/commonjs/constants.d.ts +2 -0
  177. package/dist/node_modules/tar/node_modules/minizlib/dist/commonjs/constants.js +123 -0
  178. package/dist/node_modules/tar/node_modules/minizlib/dist/commonjs/index.d.ts +99 -0
  179. package/dist/node_modules/tar/node_modules/minizlib/dist/commonjs/index.js +416 -0
  180. package/dist/node_modules/tar/node_modules/minizlib/dist/commonjs/package.json +3 -0
  181. package/dist/node_modules/tar/node_modules/minizlib/dist/esm/constants.d.ts +2 -0
  182. package/dist/node_modules/tar/node_modules/minizlib/dist/esm/constants.js +117 -0
  183. package/dist/node_modules/tar/node_modules/minizlib/dist/esm/index.d.ts +99 -0
  184. package/dist/node_modules/tar/node_modules/minizlib/dist/esm/index.js +363 -0
  185. package/dist/node_modules/tar/node_modules/minizlib/dist/esm/package.json +3 -0
  186. package/dist/node_modules/tar/node_modules/minizlib/package.json +80 -0
  187. package/dist/node_modules/tar/node_modules/yallist/dist/commonjs/index.d.ts +39 -0
  188. package/dist/node_modules/tar/node_modules/yallist/dist/commonjs/index.js +384 -0
  189. package/dist/node_modules/tar/node_modules/yallist/dist/commonjs/package.json +3 -0
  190. package/dist/node_modules/tar/node_modules/yallist/dist/esm/index.d.ts +39 -0
  191. package/dist/node_modules/tar/node_modules/yallist/dist/esm/index.js +379 -0
  192. package/dist/node_modules/tar/node_modules/yallist/dist/esm/package.json +3 -0
  193. package/dist/node_modules/tar/node_modules/yallist/package.json +68 -0
  194. package/dist/node_modules/tar/package.json +1 -0
  195. package/dist/server/collections/desktopRoutes.d.ts +14 -0
  196. package/dist/server/collections/desktopRoutes.js +48 -0
  197. package/dist/server/collections/extendRoleField.d.ts +14 -0
  198. package/dist/server/collections/extendRoleField.js +51 -0
  199. package/dist/server/collections/multiPortals.d.ts +10 -0
  200. package/dist/server/collections/multiPortals.js +128 -0
  201. package/dist/server/collections/rolesMultiPortalDesktopRoutes.d.ts +10 -0
  202. package/dist/server/collections/rolesMultiPortalDesktopRoutes.js +76 -0
  203. package/dist/server/collections/rolesMultiPortalRoutePolicies.d.ts +10 -0
  204. package/dist/server/collections/rolesMultiPortalRoutePolicies.js +73 -0
  205. package/dist/server/collections/rolesMultiPortals.d.ts +10 -0
  206. package/dist/server/collections/rolesMultiPortals.js +68 -0
  207. package/dist/server/ensureDefaultRoleMultiPortalAccess.d.ts +11 -0
  208. package/dist/server/ensureDefaultRoleMultiPortalAccess.js +70 -0
  209. package/dist/server/index.d.ts +9 -0
  210. package/dist/server/index.js +42 -0
  211. package/dist/server/migrations/20260723105200-drop-ui-layout-foreign-key-constraint.d.ts +13 -0
  212. package/dist/server/migrations/20260723105200-drop-ui-layout-foreign-key-constraint.js +104 -0
  213. package/dist/server/plugin.d.ts +63 -0
  214. package/dist/server/plugin.js +2130 -0
  215. package/package.json +34 -0
  216. package/server.d.ts +2 -0
  217. package/server.js +1 -0
@@ -0,0 +1,166 @@
1
+ // A path exclusive reservation system
2
+ // reserve([list, of, paths], fn)
3
+ // When the fn is first in line for all its paths, it
4
+ // is called with a cb that clears the reservation.
5
+ //
6
+ // Used by async unpack to avoid clobbering paths in use,
7
+ // while still allowing maximal safe parallelization.
8
+ import { join } from 'node:path';
9
+ import { normalizeUnicode } from './normalize-unicode.js';
10
+ import { stripTrailingSlashes } from './strip-trailing-slashes.js';
11
+ const platform = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
12
+ const isWindows = platform === 'win32';
13
+ // return a set of parent dirs for a given path
14
+ // '/a/b/c/d' -> ['/', '/a', '/a/b', '/a/b/c', '/a/b/c/d']
15
+ const getDirs = (path) => {
16
+ const dirs = path
17
+ .split('/')
18
+ .slice(0, -1)
19
+ .reduce((set, path) => {
20
+ const s = set.at(-1);
21
+ if (s !== undefined) {
22
+ path = join(s, path);
23
+ }
24
+ set.push(path || '/');
25
+ return set;
26
+ }, []);
27
+ return dirs;
28
+ };
29
+ export class PathReservations {
30
+ // path => [function or Set]
31
+ // A Set object means a directory reservation
32
+ // A fn is a direct reservation on that path
33
+ #queues = new Map();
34
+ // fn => {paths:[path,...], dirs:[path, ...]}
35
+ #reservations = new Map();
36
+ // functions currently running
37
+ #running = new Set();
38
+ reserve(paths, fn) {
39
+ paths =
40
+ isWindows ?
41
+ ['win32 parallelization disabled']
42
+ : paths.map(p => {
43
+ // don't need normPath, because we skip this entirely for windows
44
+ return stripTrailingSlashes(join(normalizeUnicode(p)));
45
+ });
46
+ const dirs = new Set(paths.map(path => getDirs(path)).reduce((a, b) => a.concat(b)));
47
+ this.#reservations.set(fn, { dirs, paths });
48
+ for (const p of paths) {
49
+ const q = this.#queues.get(p);
50
+ if (!q) {
51
+ this.#queues.set(p, [fn]);
52
+ }
53
+ else {
54
+ q.push(fn);
55
+ }
56
+ }
57
+ for (const dir of dirs) {
58
+ const q = this.#queues.get(dir);
59
+ if (!q) {
60
+ this.#queues.set(dir, [new Set([fn])]);
61
+ }
62
+ else {
63
+ const l = q.at(-1);
64
+ if (l instanceof Set) {
65
+ l.add(fn);
66
+ }
67
+ else {
68
+ q.push(new Set([fn]));
69
+ }
70
+ }
71
+ }
72
+ return this.#run(fn);
73
+ }
74
+ // return the queues for each path the function cares about
75
+ // fn => {paths, dirs}
76
+ #getQueues(fn) {
77
+ const res = this.#reservations.get(fn);
78
+ /* c8 ignore start */
79
+ if (!res) {
80
+ throw new Error('function does not have any path reservations');
81
+ }
82
+ /* c8 ignore stop */
83
+ return {
84
+ paths: res.paths.map((path) => this.#queues.get(path)),
85
+ dirs: [...res.dirs].map(path => this.#queues.get(path)),
86
+ };
87
+ }
88
+ // check if fn is first in line for all its paths, and is
89
+ // included in the first set for all its dir queues
90
+ check(fn) {
91
+ const { paths, dirs } = this.#getQueues(fn);
92
+ return (paths.every(q => q && q[0] === fn) &&
93
+ dirs.every(q => q && q[0] instanceof Set && q[0].has(fn)));
94
+ }
95
+ // run the function if it's first in line and not already running
96
+ #run(fn) {
97
+ if (this.#running.has(fn) || !this.check(fn)) {
98
+ return false;
99
+ }
100
+ this.#running.add(fn);
101
+ fn(() => this.#clear(fn));
102
+ return true;
103
+ }
104
+ #clear(fn) {
105
+ if (!this.#running.has(fn)) {
106
+ return false;
107
+ }
108
+ const res = this.#reservations.get(fn);
109
+ /* c8 ignore start */
110
+ if (!res) {
111
+ throw new Error('invalid reservation');
112
+ }
113
+ /* c8 ignore stop */
114
+ const { paths, dirs } = res;
115
+ const next = new Set();
116
+ for (const path of paths) {
117
+ const q = this.#queues.get(path);
118
+ /* c8 ignore start */
119
+ if (!q || q?.[0] !== fn) {
120
+ continue;
121
+ }
122
+ /* c8 ignore stop */
123
+ const q0 = q[1];
124
+ if (!q0) {
125
+ this.#queues.delete(path);
126
+ continue;
127
+ }
128
+ q.shift();
129
+ if (typeof q0 === 'function') {
130
+ next.add(q0);
131
+ }
132
+ else {
133
+ for (const f of q0) {
134
+ next.add(f);
135
+ }
136
+ }
137
+ }
138
+ for (const dir of dirs) {
139
+ const q = this.#queues.get(dir);
140
+ const q0 = q?.[0];
141
+ /* c8 ignore next - type safety only */
142
+ if (!q || !(q0 instanceof Set))
143
+ continue;
144
+ if (q0.size === 1 && q.length === 1) {
145
+ this.#queues.delete(dir);
146
+ continue;
147
+ }
148
+ else if (q0.size === 1) {
149
+ q.shift();
150
+ // next one must be a function,
151
+ // or else the Set would've been reused
152
+ const n = q[0];
153
+ if (typeof n === 'function') {
154
+ next.add(n);
155
+ }
156
+ }
157
+ else {
158
+ q0.delete(fn);
159
+ }
160
+ }
161
+ this.#running.delete(fn);
162
+ next.forEach(fn => this.#run(fn));
163
+ return true;
164
+ }
165
+ }
166
+ //# sourceMappingURL=path-reservations.js.map
@@ -0,0 +1,26 @@
1
+ import type { HeaderData } from './header.js';
2
+ export declare class Pax implements HeaderData {
3
+ atime?: Date;
4
+ mtime?: Date;
5
+ ctime?: Date;
6
+ charset?: string;
7
+ comment?: string;
8
+ gid?: number;
9
+ uid?: number;
10
+ gname?: string;
11
+ uname?: string;
12
+ linkpath?: string;
13
+ dev?: number;
14
+ ino?: number;
15
+ nlink?: number;
16
+ path?: string;
17
+ size?: number;
18
+ mode?: number;
19
+ global: boolean;
20
+ constructor(obj: HeaderData, global?: boolean);
21
+ encode(): Buffer<ArrayBuffer>;
22
+ encodeBody(): string;
23
+ encodeField(field: keyof Pax): string;
24
+ static parse(str: string, ex?: HeaderData, g?: boolean): Pax;
25
+ }
26
+ //# sourceMappingURL=pax.d.ts.map
@@ -0,0 +1,154 @@
1
+ import { basename } from 'node:path';
2
+ import { Header } from './header.js';
3
+ export class Pax {
4
+ atime;
5
+ mtime;
6
+ ctime;
7
+ charset;
8
+ comment;
9
+ gid;
10
+ uid;
11
+ gname;
12
+ uname;
13
+ linkpath;
14
+ dev;
15
+ ino;
16
+ nlink;
17
+ path;
18
+ size;
19
+ mode;
20
+ global;
21
+ constructor(obj, global = false) {
22
+ this.atime = obj.atime;
23
+ this.charset = obj.charset;
24
+ this.comment = obj.comment;
25
+ this.ctime = obj.ctime;
26
+ this.dev = obj.dev;
27
+ this.gid = obj.gid;
28
+ this.global = global;
29
+ this.gname = obj.gname;
30
+ this.ino = obj.ino;
31
+ this.linkpath = obj.linkpath;
32
+ this.mtime = obj.mtime;
33
+ this.nlink = obj.nlink;
34
+ this.path = obj.path;
35
+ this.size = obj.size;
36
+ this.uid = obj.uid;
37
+ this.uname = obj.uname;
38
+ }
39
+ encode() {
40
+ const body = this.encodeBody();
41
+ if (body === '') {
42
+ return Buffer.allocUnsafe(0);
43
+ }
44
+ const bodyLen = Buffer.byteLength(body);
45
+ // round up to 512 bytes
46
+ // add 512 for header
47
+ const bufLen = 512 * Math.ceil(1 + bodyLen / 512);
48
+ const buf = Buffer.allocUnsafe(bufLen);
49
+ // 0-fill the header section, it might not hit every field
50
+ for (let i = 0; i < 512; i++) {
51
+ buf[i] = 0;
52
+ }
53
+ new Header({
54
+ // XXX split the path
55
+ // then the path should be PaxHeader + basename, but less than 99,
56
+ // prepend with the dirname
57
+ /* c8 ignore start */
58
+ path: ('PaxHeader/' + basename(this.path ?? '')).slice(0, 99),
59
+ /* c8 ignore stop */
60
+ mode: this.mode || 0o644,
61
+ uid: this.uid,
62
+ gid: this.gid,
63
+ size: bodyLen,
64
+ mtime: this.mtime,
65
+ type: this.global ? 'GlobalExtendedHeader' : 'ExtendedHeader',
66
+ linkpath: '',
67
+ uname: this.uname || '',
68
+ gname: this.gname || '',
69
+ devmaj: 0,
70
+ devmin: 0,
71
+ atime: this.atime,
72
+ ctime: this.ctime,
73
+ }).encode(buf);
74
+ buf.write(body, 512, bodyLen, 'utf8');
75
+ // null pad after the body
76
+ for (let i = bodyLen + 512; i < buf.length; i++) {
77
+ buf[i] = 0;
78
+ }
79
+ return buf;
80
+ }
81
+ encodeBody() {
82
+ return (this.encodeField('path') +
83
+ this.encodeField('ctime') +
84
+ this.encodeField('atime') +
85
+ this.encodeField('dev') +
86
+ this.encodeField('ino') +
87
+ this.encodeField('nlink') +
88
+ this.encodeField('charset') +
89
+ this.encodeField('comment') +
90
+ this.encodeField('gid') +
91
+ this.encodeField('gname') +
92
+ this.encodeField('linkpath') +
93
+ this.encodeField('mtime') +
94
+ this.encodeField('size') +
95
+ this.encodeField('uid') +
96
+ this.encodeField('uname'));
97
+ }
98
+ encodeField(field) {
99
+ if (this[field] === undefined) {
100
+ return '';
101
+ }
102
+ const r = this[field];
103
+ const v = r instanceof Date ? r.getTime() / 1000 : r;
104
+ const s = ' ' +
105
+ (field === 'dev' || field === 'ino' || field === 'nlink' ?
106
+ 'SCHILY.'
107
+ : '') +
108
+ field +
109
+ '=' +
110
+ v +
111
+ '\n';
112
+ const byteLen = Buffer.byteLength(s);
113
+ // the digits includes the length of the digits in ascii base-10
114
+ // so if it's 9 characters, then adding 1 for the 9 makes it 10
115
+ // which makes it 11 chars.
116
+ let digits = Math.floor(Math.log(byteLen) / Math.log(10)) + 1;
117
+ if (byteLen + digits >= Math.pow(10, digits)) {
118
+ digits += 1;
119
+ }
120
+ const len = digits + byteLen;
121
+ return len + s;
122
+ }
123
+ static parse(str, ex, g = false) {
124
+ return new Pax(merge(parseKV(str), ex), g);
125
+ }
126
+ }
127
+ const merge = (a, b) => b ? Object.assign({}, b, a) : a;
128
+ const parseKV = (str) => str
129
+ .replace(/\n$/, '')
130
+ .split('\n')
131
+ .reduce(parseKVLine, Object.create(null));
132
+ const parseKVLine = (set, line) => {
133
+ const n = parseInt(line, 10);
134
+ // XXX Values with \n in them will fail this.
135
+ // Refactor to not be a naive line-by-line parse.
136
+ if (n !== Buffer.byteLength(line) + 1) {
137
+ return set;
138
+ }
139
+ line = line.slice((n + ' ').length);
140
+ const kv = line.split('=');
141
+ const r = kv.shift();
142
+ if (!r) {
143
+ return set;
144
+ }
145
+ const k = r.replace(/^SCHILY\.(dev|ino|nlink)/, '$1');
146
+ const v = kv.join('=');
147
+ set[k] =
148
+ /^([A-Z]+\.)?([mac]|birth|creation)time$/.test(k) ?
149
+ new Date(Number(v) * 1000)
150
+ : /^[0-9]+$/.test(v) ? +v
151
+ : v;
152
+ return set;
153
+ };
154
+ //# sourceMappingURL=pax.js.map
@@ -0,0 +1,2 @@
1
+ export declare const umask: () => number;
2
+ //# sourceMappingURL=process-umask.d.ts.map
@@ -0,0 +1,3 @@
1
+ // separate file so I stop getting nagged in vim about deprecated API.
2
+ export const umask = () => process.umask();
3
+ //# sourceMappingURL=process-umask.js.map
@@ -0,0 +1,36 @@
1
+ import { Minipass } from 'minipass';
2
+ import type { Header } from './header.js';
3
+ import type { Pax } from './pax.js';
4
+ import type { EntryTypeName } from './types.js';
5
+ export declare class ReadEntry extends Minipass<Buffer, Buffer> {
6
+ #private;
7
+ extended?: Pax;
8
+ globalExtended?: Pax;
9
+ header: Header;
10
+ startBlockSize: number;
11
+ blockRemain: number;
12
+ remain: number;
13
+ type: EntryTypeName;
14
+ meta: boolean;
15
+ ignore: boolean;
16
+ path: string;
17
+ mode?: number;
18
+ uid?: number;
19
+ gid?: number;
20
+ uname?: string;
21
+ gname?: string;
22
+ size: number;
23
+ mtime?: Date;
24
+ atime?: Date;
25
+ ctime?: Date;
26
+ linkpath?: string;
27
+ dev?: number;
28
+ ino?: number;
29
+ nlink?: number;
30
+ invalid: boolean;
31
+ absolute?: string;
32
+ unsupported: boolean;
33
+ constructor(header: Header, ex?: Pax, gex?: Pax);
34
+ write(data: Buffer): boolean;
35
+ }
36
+ //# sourceMappingURL=read-entry.d.ts.map
@@ -0,0 +1,132 @@
1
+ import { Minipass } from 'minipass';
2
+ import { normalizeWindowsPath } from './normalize-windows-path.js';
3
+ export class ReadEntry extends Minipass {
4
+ extended;
5
+ globalExtended;
6
+ header;
7
+ startBlockSize;
8
+ blockRemain;
9
+ remain;
10
+ type;
11
+ meta = false;
12
+ ignore = false;
13
+ path;
14
+ mode;
15
+ uid;
16
+ gid;
17
+ uname;
18
+ gname;
19
+ size = 0;
20
+ mtime;
21
+ atime;
22
+ ctime;
23
+ linkpath;
24
+ dev;
25
+ ino;
26
+ nlink;
27
+ invalid = false;
28
+ absolute;
29
+ unsupported = false;
30
+ constructor(header, ex, gex) {
31
+ super({});
32
+ // read entries always start life paused. this is to avoid the
33
+ // situation where Minipass's auto-ending empty streams results
34
+ // in an entry ending before we're ready for it.
35
+ this.pause();
36
+ this.extended = ex;
37
+ this.globalExtended = gex;
38
+ this.header = header;
39
+ /* c8 ignore start */
40
+ this.remain = header.size ?? 0;
41
+ /* c8 ignore stop */
42
+ this.startBlockSize = 512 * Math.ceil(this.remain / 512);
43
+ this.blockRemain = this.startBlockSize;
44
+ this.type = header.type;
45
+ switch (this.type) {
46
+ case 'File':
47
+ case 'OldFile':
48
+ case 'Link':
49
+ case 'SymbolicLink':
50
+ case 'CharacterDevice':
51
+ case 'BlockDevice':
52
+ case 'Directory':
53
+ case 'FIFO':
54
+ case 'ContiguousFile':
55
+ case 'GNUDumpDir':
56
+ break;
57
+ case 'NextFileHasLongLinkpath':
58
+ case 'NextFileHasLongPath':
59
+ case 'OldGnuLongPath':
60
+ case 'GlobalExtendedHeader':
61
+ case 'ExtendedHeader':
62
+ case 'OldExtendedHeader':
63
+ this.meta = true;
64
+ break;
65
+ // NOTE: gnutar and bsdtar treat unrecognized types as 'File'
66
+ // it may be worth doing the same, but with a warning.
67
+ default:
68
+ this.ignore = true;
69
+ }
70
+ /* c8 ignore start */
71
+ if (!header.path) {
72
+ throw new Error('no path provided for tar.ReadEntry');
73
+ }
74
+ /* c8 ignore stop */
75
+ this.path = normalizeWindowsPath(header.path);
76
+ this.mode = header.mode;
77
+ if (this.mode) {
78
+ this.mode = this.mode & 0o7777;
79
+ }
80
+ this.uid = header.uid;
81
+ this.gid = header.gid;
82
+ this.uname = header.uname;
83
+ this.gname = header.gname;
84
+ this.size = this.remain;
85
+ this.mtime = header.mtime;
86
+ this.atime = header.atime;
87
+ this.ctime = header.ctime;
88
+ /* c8 ignore start */
89
+ this.linkpath =
90
+ header.linkpath ? normalizeWindowsPath(header.linkpath) : undefined;
91
+ /* c8 ignore stop */
92
+ this.uname = header.uname;
93
+ this.gname = header.gname;
94
+ if (ex) {
95
+ this.#slurp(ex);
96
+ }
97
+ if (gex) {
98
+ this.#slurp(gex, true);
99
+ }
100
+ }
101
+ write(data) {
102
+ const writeLen = data.length;
103
+ if (writeLen > this.blockRemain) {
104
+ throw new Error('writing more to entry than is appropriate');
105
+ }
106
+ const r = this.remain;
107
+ const br = this.blockRemain;
108
+ this.remain = Math.max(0, r - writeLen);
109
+ this.blockRemain = Math.max(0, br - writeLen);
110
+ if (this.ignore) {
111
+ return true;
112
+ }
113
+ if (r >= writeLen) {
114
+ return super.write(data);
115
+ }
116
+ // r < writeLen
117
+ return super.write(data.subarray(0, r));
118
+ }
119
+ #slurp(ex, gex = false) {
120
+ if (ex.path)
121
+ ex.path = normalizeWindowsPath(ex.path);
122
+ if (ex.linkpath)
123
+ ex.linkpath = normalizeWindowsPath(ex.linkpath);
124
+ Object.assign(this, Object.fromEntries(Object.entries(ex).filter(([k, v]) => {
125
+ // we slurp in everything except for the path attribute in
126
+ // a global extended header, because that's weird. Also, any
127
+ // null/undefined values are ignored.
128
+ return !(v === null || v === undefined || (k === 'path' && gex));
129
+ })));
130
+ }
131
+ }
132
+ //# sourceMappingURL=read-entry.js.map
@@ -0,0 +1,2 @@
1
+ export declare const replace: import("./make-command.js").TarCommand<never, never>;
2
+ //# sourceMappingURL=replace.d.ts.map