@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,11 @@
1
+ export type Reservation = {
2
+ paths: string[];
3
+ dirs: Set<string>;
4
+ };
5
+ export type Handler = (clear: () => void) => void;
6
+ export declare class PathReservations {
7
+ #private;
8
+ reserve(paths: string[], fn: Handler): boolean;
9
+ check(fn: Handler): boolean;
10
+ }
11
+ //# sourceMappingURL=path-reservations.d.ts.map
@@ -0,0 +1,170 @@
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.
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.PathReservations = void 0;
11
+ const node_path_1 = require("node:path");
12
+ const normalize_unicode_js_1 = require("./normalize-unicode.js");
13
+ 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
+ };
32
+ 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, ...]}
38
+ #reservations = new Map();
39
+ // functions currently running
40
+ #running = new Set();
41
+ 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)));
48
+ });
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
+ }
73
+ }
74
+ }
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');
84
+ }
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)));
97
+ }
98
+ // run the function if it's first in line and not already running
99
+ #run(fn) {
100
+ if (this.#running.has(fn) || !this.check(fn)) {
101
+ return false;
102
+ }
103
+ this.#running.add(fn);
104
+ fn(() => this.#clear(fn));
105
+ return true;
106
+ }
107
+ #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;
118
+ 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) {
137
+ next.add(f);
138
+ }
139
+ }
140
+ }
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
+ }
160
+ else {
161
+ q0.delete(fn);
162
+ }
163
+ }
164
+ this.#running.delete(fn);
165
+ next.forEach(fn => this.#run(fn));
166
+ return true;
167
+ }
168
+ }
169
+ exports.PathReservations = PathReservations;
170
+ //# 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,158 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Pax = void 0;
4
+ const node_path_1 = require("node:path");
5
+ const header_js_1 = require("./header.js");
6
+ class Pax {
7
+ atime;
8
+ mtime;
9
+ ctime;
10
+ charset;
11
+ comment;
12
+ gid;
13
+ uid;
14
+ gname;
15
+ uname;
16
+ linkpath;
17
+ dev;
18
+ ino;
19
+ nlink;
20
+ path;
21
+ size;
22
+ mode;
23
+ global;
24
+ constructor(obj, global = false) {
25
+ this.atime = obj.atime;
26
+ this.charset = obj.charset;
27
+ this.comment = obj.comment;
28
+ this.ctime = obj.ctime;
29
+ this.dev = obj.dev;
30
+ this.gid = obj.gid;
31
+ this.global = global;
32
+ this.gname = obj.gname;
33
+ this.ino = obj.ino;
34
+ this.linkpath = obj.linkpath;
35
+ this.mtime = obj.mtime;
36
+ this.nlink = obj.nlink;
37
+ this.path = obj.path;
38
+ this.size = obj.size;
39
+ this.uid = obj.uid;
40
+ this.uname = obj.uname;
41
+ }
42
+ encode() {
43
+ const body = this.encodeBody();
44
+ if (body === '') {
45
+ return Buffer.allocUnsafe(0);
46
+ }
47
+ const bodyLen = Buffer.byteLength(body);
48
+ // round up to 512 bytes
49
+ // add 512 for header
50
+ 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
+ }
56
+ new header_js_1.Header({
57
+ // XXX split the path
58
+ // then the path should be PaxHeader + basename, but less than 99,
59
+ // 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 */
63
+ mode: this.mode || 0o644,
64
+ uid: this.uid,
65
+ gid: this.gid,
66
+ size: bodyLen,
67
+ mtime: this.mtime,
68
+ type: this.global ? 'GlobalExtendedHeader' : 'ExtendedHeader',
69
+ linkpath: '',
70
+ uname: this.uname || '',
71
+ gname: this.gname || '',
72
+ devmaj: 0,
73
+ devmin: 0,
74
+ atime: this.atime,
75
+ ctime: this.ctime,
76
+ }).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
+ }
82
+ return buf;
83
+ }
84
+ encodeBody() {
85
+ return (this.encodeField('path') +
86
+ this.encodeField('ctime') +
87
+ this.encodeField('atime') +
88
+ this.encodeField('dev') +
89
+ this.encodeField('ino') +
90
+ this.encodeField('nlink') +
91
+ this.encodeField('charset') +
92
+ this.encodeField('comment') +
93
+ this.encodeField('gid') +
94
+ this.encodeField('gname') +
95
+ this.encodeField('linkpath') +
96
+ this.encodeField('mtime') +
97
+ this.encodeField('size') +
98
+ this.encodeField('uid') +
99
+ this.encodeField('uname'));
100
+ }
101
+ encodeField(field) {
102
+ if (this[field] === undefined) {
103
+ return '';
104
+ }
105
+ const r = this[field];
106
+ const v = r instanceof Date ? r.getTime() / 1000 : r;
107
+ const s = ' ' +
108
+ (field === 'dev' || field === 'ino' || field === 'nlink' ?
109
+ 'SCHILY.'
110
+ : '') +
111
+ field +
112
+ '=' +
113
+ v +
114
+ '\n';
115
+ const byteLen = Buffer.byteLength(s);
116
+ // the digits includes the length of the digits in ascii base-10
117
+ // so if it's 9 characters, then adding 1 for the 9 makes it 10
118
+ // which makes it 11 chars.
119
+ let digits = Math.floor(Math.log(byteLen) / Math.log(10)) + 1;
120
+ if (byteLen + digits >= Math.pow(10, digits)) {
121
+ digits += 1;
122
+ }
123
+ const len = digits + byteLen;
124
+ return len + s;
125
+ }
126
+ static parse(str, ex, g = false) {
127
+ return new Pax(merge(parseKV(str), ex), g);
128
+ }
129
+ }
130
+ exports.Pax = Pax;
131
+ 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;
142
+ }
143
+ line = line.slice((n + ' ').length);
144
+ const kv = line.split('=');
145
+ const r = kv.shift();
146
+ if (!r) {
147
+ return set;
148
+ }
149
+ const k = r.replace(/^SCHILY\.(dev|ino|nlink)/, '$1');
150
+ const v = kv.join('=');
151
+ set[k] =
152
+ /^([A-Z]+\.)?([mac]|birth|creation)time$/.test(k) ?
153
+ new Date(Number(v) * 1000)
154
+ : /^[0-9]+$/.test(v) ? +v
155
+ : v;
156
+ return set;
157
+ };
158
+ //# sourceMappingURL=pax.js.map
@@ -0,0 +1,2 @@
1
+ export declare const umask: () => number;
2
+ //# sourceMappingURL=process-umask.d.ts.map
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.umask = void 0;
4
+ // separate file so I stop getting nagged in vim about deprecated API.
5
+ const umask = () => process.umask();
6
+ exports.umask = umask;
7
+ //# 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,136 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReadEntry = void 0;
4
+ const minipass_1 = require("minipass");
5
+ const normalize_windows_path_js_1 = require("./normalize-windows-path.js");
6
+ class ReadEntry extends minipass_1.Minipass {
7
+ extended;
8
+ globalExtended;
9
+ header;
10
+ startBlockSize;
11
+ blockRemain;
12
+ remain;
13
+ type;
14
+ meta = false;
15
+ ignore = false;
16
+ path;
17
+ mode;
18
+ uid;
19
+ gid;
20
+ uname;
21
+ gname;
22
+ size = 0;
23
+ mtime;
24
+ atime;
25
+ ctime;
26
+ linkpath;
27
+ dev;
28
+ ino;
29
+ nlink;
30
+ invalid = false;
31
+ absolute;
32
+ unsupported = false;
33
+ constructor(header, ex, gex) {
34
+ super({});
35
+ // read entries always start life paused. this is to avoid the
36
+ // situation where Minipass's auto-ending empty streams results
37
+ // in an entry ending before we're ready for it.
38
+ this.pause();
39
+ this.extended = ex;
40
+ this.globalExtended = gex;
41
+ this.header = header;
42
+ /* c8 ignore start */
43
+ this.remain = header.size ?? 0;
44
+ /* c8 ignore stop */
45
+ this.startBlockSize = 512 * Math.ceil(this.remain / 512);
46
+ this.blockRemain = this.startBlockSize;
47
+ this.type = header.type;
48
+ switch (this.type) {
49
+ case 'File':
50
+ case 'OldFile':
51
+ case 'Link':
52
+ case 'SymbolicLink':
53
+ case 'CharacterDevice':
54
+ case 'BlockDevice':
55
+ case 'Directory':
56
+ case 'FIFO':
57
+ case 'ContiguousFile':
58
+ case 'GNUDumpDir':
59
+ break;
60
+ case 'NextFileHasLongLinkpath':
61
+ case 'NextFileHasLongPath':
62
+ case 'OldGnuLongPath':
63
+ case 'GlobalExtendedHeader':
64
+ case 'ExtendedHeader':
65
+ case 'OldExtendedHeader':
66
+ this.meta = true;
67
+ break;
68
+ // NOTE: gnutar and bsdtar treat unrecognized types as 'File'
69
+ // it may be worth doing the same, but with a warning.
70
+ default:
71
+ this.ignore = true;
72
+ }
73
+ /* c8 ignore start */
74
+ if (!header.path) {
75
+ throw new Error('no path provided for tar.ReadEntry');
76
+ }
77
+ /* c8 ignore stop */
78
+ this.path = (0, normalize_windows_path_js_1.normalizeWindowsPath)(header.path);
79
+ this.mode = header.mode;
80
+ if (this.mode) {
81
+ this.mode = this.mode & 0o7777;
82
+ }
83
+ this.uid = header.uid;
84
+ this.gid = header.gid;
85
+ this.uname = header.uname;
86
+ this.gname = header.gname;
87
+ this.size = this.remain;
88
+ this.mtime = header.mtime;
89
+ this.atime = header.atime;
90
+ this.ctime = header.ctime;
91
+ /* c8 ignore start */
92
+ this.linkpath =
93
+ header.linkpath ? (0, normalize_windows_path_js_1.normalizeWindowsPath)(header.linkpath) : undefined;
94
+ /* c8 ignore stop */
95
+ this.uname = header.uname;
96
+ this.gname = header.gname;
97
+ if (ex) {
98
+ this.#slurp(ex);
99
+ }
100
+ if (gex) {
101
+ this.#slurp(gex, true);
102
+ }
103
+ }
104
+ write(data) {
105
+ const writeLen = data.length;
106
+ if (writeLen > this.blockRemain) {
107
+ throw new Error('writing more to entry than is appropriate');
108
+ }
109
+ const r = this.remain;
110
+ const br = this.blockRemain;
111
+ this.remain = Math.max(0, r - writeLen);
112
+ this.blockRemain = Math.max(0, br - writeLen);
113
+ if (this.ignore) {
114
+ return true;
115
+ }
116
+ if (r >= writeLen) {
117
+ return super.write(data);
118
+ }
119
+ // r < writeLen
120
+ return super.write(data.subarray(0, r));
121
+ }
122
+ #slurp(ex, gex = false) {
123
+ if (ex.path)
124
+ ex.path = (0, normalize_windows_path_js_1.normalizeWindowsPath)(ex.path);
125
+ if (ex.linkpath)
126
+ ex.linkpath = (0, normalize_windows_path_js_1.normalizeWindowsPath)(ex.linkpath);
127
+ Object.assign(this, Object.fromEntries(Object.entries(ex).filter(([k, v]) => {
128
+ // we slurp in everything except for the path attribute in
129
+ // a global extended header, because that's weird. Also, any
130
+ // null/undefined values are ignored.
131
+ return !(v === null || v === undefined || (k === 'path' && gex));
132
+ })));
133
+ }
134
+ }
135
+ exports.ReadEntry = ReadEntry;
136
+ //# 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