@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,221 @@
1
+ // tar -r
2
+ import { WriteStream, WriteStreamSync } from '@isaacs/fs-minipass';
3
+ import fs from 'node:fs';
4
+ import path from 'node:path';
5
+ import { Header } from './header.js';
6
+ import { list } from './list.js';
7
+ import { makeCommand } from './make-command.js';
8
+ import { isFile } from './options.js';
9
+ import { Pack, PackSync } from './pack.js';
10
+ // starting at the head of the file, read a Header
11
+ // If the checksum is invalid, that's our position to start writing
12
+ // If it is, jump forward by the specified size (round up to 512)
13
+ // and try again.
14
+ // Write the new Pack stream starting there.
15
+ const replaceSync = (opt, files) => {
16
+ const p = new PackSync(opt);
17
+ let threw = true;
18
+ let fd;
19
+ let position;
20
+ try {
21
+ try {
22
+ fd = fs.openSync(opt.file, 'r+');
23
+ }
24
+ catch (er) {
25
+ if (er?.code === 'ENOENT') {
26
+ fd = fs.openSync(opt.file, 'w+');
27
+ }
28
+ else {
29
+ throw er;
30
+ }
31
+ }
32
+ const st = fs.fstatSync(fd);
33
+ const headBuf = Buffer.alloc(512);
34
+ POSITION: for (position = 0; position < st.size; position += 512) {
35
+ for (let bufPos = 0, bytes = 0; bufPos < 512; bufPos += bytes) {
36
+ bytes = fs.readSync(fd, headBuf, bufPos, headBuf.length - bufPos, position + bufPos);
37
+ if (position === 0 && headBuf[0] === 0x1f && headBuf[1] === 0x8b) {
38
+ throw new Error('cannot append to compressed archives');
39
+ }
40
+ if (!bytes) {
41
+ break POSITION;
42
+ }
43
+ }
44
+ const h = new Header(headBuf);
45
+ if (!h.cksumValid) {
46
+ break;
47
+ }
48
+ const entryBlockSize = 512 * Math.ceil((h.size || 0) / 512);
49
+ if (position + entryBlockSize + 512 > st.size) {
50
+ break;
51
+ }
52
+ // the 512 for the header we just parsed will be added as well
53
+ // also jump ahead all the blocks for the body
54
+ position += entryBlockSize;
55
+ if (opt.mtimeCache && h.mtime) {
56
+ opt.mtimeCache.set(String(h.path), h.mtime);
57
+ }
58
+ }
59
+ threw = false;
60
+ streamSync(opt, p, position, fd, files);
61
+ }
62
+ finally {
63
+ if (threw) {
64
+ try {
65
+ fs.closeSync(fd);
66
+ }
67
+ catch { }
68
+ }
69
+ }
70
+ };
71
+ const streamSync = (opt, p, position, fd, files) => {
72
+ const stream = new WriteStreamSync(opt.file, {
73
+ fd: fd,
74
+ start: position,
75
+ });
76
+ p.pipe(stream);
77
+ addFilesSync(p, files);
78
+ };
79
+ const replaceAsync = (opt, files) => {
80
+ files = Array.from(files);
81
+ const p = new Pack(opt);
82
+ const getPos = (fd, size, cb_) => {
83
+ const cb = (er, pos) => {
84
+ if (er) {
85
+ fs.close(fd, _ => cb_(er));
86
+ }
87
+ else {
88
+ cb_(null, pos);
89
+ }
90
+ };
91
+ let position = 0;
92
+ if (size === 0) {
93
+ return cb(null, 0);
94
+ }
95
+ let bufPos = 0;
96
+ const headBuf = Buffer.alloc(512);
97
+ const onread = (er, bytes) => {
98
+ if (er || bytes === undefined) {
99
+ return cb(er);
100
+ }
101
+ bufPos += bytes;
102
+ if (bufPos < 512 && bytes) {
103
+ return fs.read(fd, headBuf, bufPos, headBuf.length - bufPos, position + bufPos, onread);
104
+ }
105
+ if (position === 0 && headBuf[0] === 0x1f && headBuf[1] === 0x8b) {
106
+ return cb(new Error('cannot append to compressed archives'));
107
+ }
108
+ // truncated header
109
+ if (bufPos < 512) {
110
+ return cb(null, position);
111
+ }
112
+ const h = new Header(headBuf);
113
+ if (!h.cksumValid) {
114
+ return cb(null, position);
115
+ }
116
+ /* c8 ignore next */
117
+ const entryBlockSize = 512 * Math.ceil((h.size ?? 0) / 512);
118
+ if (position + entryBlockSize + 512 > size) {
119
+ return cb(null, position);
120
+ }
121
+ position += entryBlockSize + 512;
122
+ if (position >= size) {
123
+ return cb(null, position);
124
+ }
125
+ if (opt.mtimeCache && h.mtime) {
126
+ opt.mtimeCache.set(String(h.path), h.mtime);
127
+ }
128
+ bufPos = 0;
129
+ fs.read(fd, headBuf, 0, 512, position, onread);
130
+ };
131
+ fs.read(fd, headBuf, 0, 512, position, onread);
132
+ };
133
+ const promise = new Promise((resolve, reject) => {
134
+ p.on('error', reject);
135
+ let flag = 'r+';
136
+ const onopen = (er, fd) => {
137
+ if (er && er.code === 'ENOENT' && flag === 'r+') {
138
+ flag = 'w+';
139
+ return fs.open(opt.file, flag, onopen);
140
+ }
141
+ if (er || !fd) {
142
+ return reject(er);
143
+ }
144
+ fs.fstat(fd, (er, st) => {
145
+ if (er) {
146
+ return fs.close(fd, () => reject(er));
147
+ }
148
+ getPos(fd, st.size, (er, position) => {
149
+ if (er) {
150
+ return reject(er);
151
+ }
152
+ const stream = new WriteStream(opt.file, {
153
+ fd: fd,
154
+ start: position,
155
+ });
156
+ p.pipe(stream);
157
+ stream.on('error', reject);
158
+ stream.on('close', resolve);
159
+ addFilesAsync(p, files);
160
+ });
161
+ });
162
+ };
163
+ fs.open(opt.file, flag, onopen);
164
+ });
165
+ return promise;
166
+ };
167
+ const addFilesSync = (p, files) => {
168
+ files.forEach(file => {
169
+ if (file.charAt(0) === '@') {
170
+ list({
171
+ file: path.resolve(p.cwd, file.slice(1)),
172
+ sync: true,
173
+ noResume: true,
174
+ onReadEntry: entry => p.add(entry),
175
+ });
176
+ }
177
+ else {
178
+ p.add(file);
179
+ }
180
+ });
181
+ p.end();
182
+ };
183
+ const addFilesAsync = async (p, files) => {
184
+ for (const file of files) {
185
+ if (file.charAt(0) === '@') {
186
+ await list({
187
+ file: path.resolve(String(p.cwd), file.slice(1)),
188
+ noResume: true,
189
+ onReadEntry: entry => p.add(entry),
190
+ });
191
+ }
192
+ else {
193
+ p.add(file);
194
+ }
195
+ }
196
+ p.end();
197
+ };
198
+ export const replace = makeCommand(replaceSync, replaceAsync,
199
+ /* c8 ignore start */
200
+ () => {
201
+ throw new TypeError('file is required');
202
+ }, () => {
203
+ throw new TypeError('file is required');
204
+ },
205
+ /* c8 ignore stop */
206
+ (opt, entries) => {
207
+ if (!isFile(opt)) {
208
+ throw new TypeError('file is required');
209
+ }
210
+ if (opt.gzip ||
211
+ opt.brotli ||
212
+ opt.zstd ||
213
+ opt.file.endsWith('.br') ||
214
+ opt.file.endsWith('.tbr')) {
215
+ throw new TypeError('cannot append to compressed archives');
216
+ }
217
+ if (!entries?.length) {
218
+ throw new TypeError('no paths specified to add/replace');
219
+ }
220
+ });
221
+ //# sourceMappingURL=replace.js.map
@@ -0,0 +1,2 @@
1
+ export declare const stripAbsolutePath: (path: string) => [string, string];
2
+ //# sourceMappingURL=strip-absolute-path.d.ts.map
@@ -0,0 +1,25 @@
1
+ // unix absolute paths are also absolute on win32, so we use this for both
2
+ import { win32 } from 'node:path';
3
+ const { isAbsolute, parse } = win32;
4
+ // returns [root, stripped]
5
+ // Note that windows will think that //x/y/z/a has a "root" of //x/y, and in
6
+ // those cases, we want to sanitize it to x/y/z/a, not z/a, so we strip /
7
+ // explicitly if it's the first character.
8
+ // drive-specific relative paths on Windows get their root stripped off even
9
+ // though they are not absolute, so `c:../foo` becomes ['c:', '../foo']
10
+ export const stripAbsolutePath = (path) => {
11
+ let r = '';
12
+ let parsed = parse(path);
13
+ while (isAbsolute(path) || parsed.root) {
14
+ // windows will think that //x/y/z has a "root" of //x/y/
15
+ // but strip the //?/C:/ off of //?/C:/path
16
+ const root = path.charAt(0) === '/' && path.slice(0, 4) !== '//?/' ?
17
+ '/'
18
+ : parsed.root;
19
+ path = path.slice(root.length);
20
+ r += root;
21
+ parsed = parse(path);
22
+ }
23
+ return [r, path];
24
+ };
25
+ //# sourceMappingURL=strip-absolute-path.js.map
@@ -0,0 +1,2 @@
1
+ export declare const stripTrailingSlashes: (str: string) => string;
2
+ //# sourceMappingURL=strip-trailing-slashes.d.ts.map
@@ -0,0 +1,14 @@
1
+ // warning: extremely hot code path.
2
+ // This has been meticulously optimized for use
3
+ // within npm install on large package trees.
4
+ // Do not edit without careful benchmarking.
5
+ export const stripTrailingSlashes = (str) => {
6
+ let i = str.length - 1;
7
+ let slashesStart = -1;
8
+ while (i > -1 && str.charAt(i) === '/') {
9
+ slashesStart = i;
10
+ i--;
11
+ }
12
+ return slashesStart === -1 ? str : str.slice(0, slashesStart);
13
+ };
14
+ //# sourceMappingURL=strip-trailing-slashes.js.map
@@ -0,0 +1,9 @@
1
+ export declare class SymlinkError extends Error {
2
+ path: string;
3
+ symlink: string;
4
+ syscall: "symlink";
5
+ code: "TAR_SYMLINK_ERROR";
6
+ constructor(symlink: string, path: string);
7
+ get name(): string;
8
+ }
9
+ //# sourceMappingURL=symlink-error.d.ts.map
@@ -0,0 +1,15 @@
1
+ export class SymlinkError extends Error {
2
+ path;
3
+ symlink;
4
+ syscall = 'symlink';
5
+ code = 'TAR_SYMLINK_ERROR';
6
+ constructor(symlink, path) {
7
+ super('TAR_SYMLINK_ERROR: Cannot extract through symbolic link');
8
+ this.symlink = symlink;
9
+ this.path = path;
10
+ }
11
+ get name() {
12
+ return 'SymlinkError';
13
+ }
14
+ }
15
+ //# sourceMappingURL=symlink-error.js.map
@@ -0,0 +1,7 @@
1
+ export declare const isCode: (c: string) => c is EntryTypeCode;
2
+ export declare const isName: (c: string) => c is EntryTypeName;
3
+ export type EntryTypeCode = '0' | '' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | 'g' | 'x' | 'A' | 'D' | 'I' | 'K' | 'L' | 'M' | 'N' | 'S' | 'V' | 'X';
4
+ export type EntryTypeName = 'File' | 'OldFile' | 'Link' | 'SymbolicLink' | 'CharacterDevice' | 'BlockDevice' | 'Directory' | 'FIFO' | 'ContiguousFile' | 'GlobalExtendedHeader' | 'ExtendedHeader' | 'SolarisACL' | 'GNUDumpDir' | 'Inode' | 'NextFileHasLongLinkpath' | 'NextFileHasLongPath' | 'ContinuationFile' | 'OldGnuLongPath' | 'SparseFile' | 'TapeVolumeHeader' | 'OldExtendedHeader' | 'Unsupported';
5
+ export declare const name: Map<EntryTypeCode, EntryTypeName>;
6
+ export declare const code: Map<EntryTypeName, EntryTypeCode>;
7
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,45 @@
1
+ export const isCode = (c) => name.has(c);
2
+ export const isName = (c) => code.has(c);
3
+ // map types from key to human-friendly name
4
+ export const name = new Map([
5
+ ['0', 'File'],
6
+ // same as File
7
+ ['', 'OldFile'],
8
+ ['1', 'Link'],
9
+ ['2', 'SymbolicLink'],
10
+ // Devices and FIFOs aren't fully supported
11
+ // they are parsed, but skipped when unpacking
12
+ ['3', 'CharacterDevice'],
13
+ ['4', 'BlockDevice'],
14
+ ['5', 'Directory'],
15
+ ['6', 'FIFO'],
16
+ // same as File
17
+ ['7', 'ContiguousFile'],
18
+ // pax headers
19
+ ['g', 'GlobalExtendedHeader'],
20
+ ['x', 'ExtendedHeader'],
21
+ // vendor-specific stuff
22
+ // skip
23
+ ['A', 'SolarisACL'],
24
+ // like 5, but with data, which should be skipped
25
+ ['D', 'GNUDumpDir'],
26
+ // metadata only, skip
27
+ ['I', 'Inode'],
28
+ // data = link path of next file
29
+ ['K', 'NextFileHasLongLinkpath'],
30
+ // data = path of next file
31
+ ['L', 'NextFileHasLongPath'],
32
+ // skip
33
+ ['M', 'ContinuationFile'],
34
+ // like L
35
+ ['N', 'OldGnuLongPath'],
36
+ // skip
37
+ ['S', 'SparseFile'],
38
+ // skip
39
+ ['V', 'TapeVolumeHeader'],
40
+ // like x
41
+ ['X', 'OldExtendedHeader'],
42
+ ]);
43
+ // map the other direction
44
+ export const code = new Map(Array.from(name).map(kv => [kv[1], kv[0]]));
45
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,101 @@
1
+ import { type Stats } from 'node:fs';
2
+ import type { MkdirError } from './mkdir.js';
3
+ import { Parser } from './parse.js';
4
+ import type { TarOptions } from './options.js';
5
+ import { PathReservations } from './path-reservations.js';
6
+ import type { ReadEntry } from './read-entry.js';
7
+ import type { WarnData } from './warn-method.js';
8
+ import { SymlinkError } from './symlink-error.js';
9
+ declare const ONENTRY: unique symbol;
10
+ declare const CHECKFS: unique symbol;
11
+ declare const CHECKFS2: unique symbol;
12
+ declare const ISREUSABLE: unique symbol;
13
+ declare const MAKEFS: unique symbol;
14
+ declare const FILE: unique symbol;
15
+ declare const DIRECTORY: unique symbol;
16
+ declare const LINK: unique symbol;
17
+ declare const SYMLINK: unique symbol;
18
+ declare const HARDLINK: unique symbol;
19
+ declare const ENSURE_NO_SYMLINK: unique symbol;
20
+ declare const UNSUPPORTED: unique symbol;
21
+ declare const CHECKPATH: unique symbol;
22
+ declare const STRIPABSOLUTEPATH: unique symbol;
23
+ declare const MKDIR: unique symbol;
24
+ declare const ONERROR: unique symbol;
25
+ declare const PENDING: unique symbol;
26
+ declare const PEND: unique symbol;
27
+ declare const UNPEND: unique symbol;
28
+ declare const ENDED: unique symbol;
29
+ declare const MAYBECLOSE: unique symbol;
30
+ declare const SKIP: unique symbol;
31
+ declare const DOCHOWN: unique symbol;
32
+ declare const UID: unique symbol;
33
+ declare const GID: unique symbol;
34
+ declare const CHECKED_CWD: unique symbol;
35
+ export declare class Unpack extends Parser {
36
+ [ENDED]: boolean;
37
+ [CHECKED_CWD]: boolean;
38
+ [PENDING]: number;
39
+ reservations: PathReservations;
40
+ transform?: TarOptions['transform'];
41
+ writable: true;
42
+ readable: false;
43
+ uid?: number;
44
+ gid?: number;
45
+ setOwner: boolean;
46
+ preserveOwner: boolean;
47
+ processGid?: number;
48
+ processUid?: number;
49
+ maxDepth: number;
50
+ forceChown: boolean;
51
+ win32: boolean;
52
+ newer: boolean;
53
+ keep: boolean;
54
+ noMtime: boolean;
55
+ preservePaths: boolean;
56
+ unlink: boolean;
57
+ cwd: string;
58
+ strip: number;
59
+ processUmask: number;
60
+ umask: number;
61
+ dmode: number;
62
+ fmode: number;
63
+ chmod: boolean;
64
+ constructor(opt?: TarOptions);
65
+ warn(code: string, msg: string | Error, data?: WarnData): void;
66
+ [MAYBECLOSE](): void;
67
+ [STRIPABSOLUTEPATH](entry: ReadEntry, field: 'path' | 'linkpath'): boolean;
68
+ [CHECKPATH](entry: ReadEntry): boolean;
69
+ [ONENTRY](entry: ReadEntry): void;
70
+ [ONERROR](er: Error, entry: ReadEntry): void;
71
+ [MKDIR](dir: string, mode: number, cb: (er?: null | MkdirError, made?: string) => void): void;
72
+ [DOCHOWN](entry: ReadEntry): boolean;
73
+ [UID](entry: ReadEntry): number | undefined;
74
+ [GID](entry: ReadEntry): number | undefined;
75
+ [FILE](entry: ReadEntry, fullyDone: () => void): void;
76
+ [DIRECTORY](entry: ReadEntry, fullyDone: () => void): void;
77
+ [UNSUPPORTED](entry: ReadEntry): void;
78
+ [SYMLINK](entry: ReadEntry, done: () => void): void;
79
+ [HARDLINK](entry: ReadEntry, done: () => void): void;
80
+ [ENSURE_NO_SYMLINK](entry: ReadEntry, cwd: string, parts: string[], done: () => void, onError: (er: SymlinkError) => void): void;
81
+ [PEND](): void;
82
+ [UNPEND](): void;
83
+ [SKIP](entry: ReadEntry): void;
84
+ [ISREUSABLE](entry: ReadEntry, st: Stats): boolean;
85
+ [CHECKFS](entry: ReadEntry): void;
86
+ [CHECKFS2](entry: ReadEntry, fullyDone: (er?: Error) => void): void;
87
+ [MAKEFS](er: null | undefined | Error, entry: ReadEntry, done: () => void): void;
88
+ [LINK](entry: ReadEntry, linkpath: string, link: 'link' | 'symlink', done: () => void): void;
89
+ }
90
+ export declare class UnpackSync extends Unpack {
91
+ sync: true;
92
+ [MAKEFS](er: null | Error | undefined, entry: ReadEntry): void;
93
+ [CHECKFS](entry: ReadEntry): void;
94
+ [FILE](entry: ReadEntry, done: () => void): void;
95
+ [DIRECTORY](entry: ReadEntry, done: () => void): void;
96
+ [MKDIR](dir: string, mode: number): unknown;
97
+ [ENSURE_NO_SYMLINK](_entry: ReadEntry, cwd: string, parts: string[], done: () => void, onError: (er: SymlinkError) => void): void;
98
+ [LINK](entry: ReadEntry, linkpath: string, link: 'link' | 'symlink', done: () => void): void;
99
+ }
100
+ export {};
101
+ //# sourceMappingURL=unpack.d.ts.map