@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,105 @@
1
+ import { type Stats } from 'fs';
2
+ import { WriteEntry, WriteEntrySync, WriteEntryTar } from './write-entry.js';
3
+ export declare class PackJob {
4
+ path: string;
5
+ absolute: string;
6
+ entry?: WriteEntry | WriteEntryTar;
7
+ stat?: Stats;
8
+ readdir?: string[];
9
+ pending: boolean;
10
+ pendingLink: boolean;
11
+ ignore: boolean;
12
+ piped: boolean;
13
+ constructor(path: string, absolute: string);
14
+ }
15
+ import { Minipass } from 'minipass';
16
+ import * as zlib from 'minizlib';
17
+ import { Yallist } from 'yallist';
18
+ import { ReadEntry } from './read-entry.js';
19
+ import type { WarnEvent } from './warn-method.js';
20
+ import { type WarnData, type Warner } from './warn-method.js';
21
+ declare const ONSTAT: unique symbol;
22
+ declare const ENDED: unique symbol;
23
+ declare const QUEUE: unique symbol;
24
+ declare const PENDINGLINKS: unique symbol;
25
+ declare const CURRENT: unique symbol;
26
+ declare const PROCESS: unique symbol;
27
+ declare const PROCESSING: unique symbol;
28
+ declare const PROCESSJOB: unique symbol;
29
+ declare const JOBS: unique symbol;
30
+ declare const JOBDONE: unique symbol;
31
+ declare const ADDFSENTRY: unique symbol;
32
+ declare const ADDTARENTRY: unique symbol;
33
+ declare const STAT: unique symbol;
34
+ declare const READDIR: unique symbol;
35
+ declare const ONREADDIR: unique symbol;
36
+ declare const PIPE: unique symbol;
37
+ declare const ENTRY: unique symbol;
38
+ declare const ENTRYOPT: unique symbol;
39
+ declare const WRITEENTRYCLASS: unique symbol;
40
+ declare const WRITE: unique symbol;
41
+ declare const ONDRAIN: unique symbol;
42
+ import type { TarOptions } from './options.js';
43
+ export declare class Pack extends Minipass<Buffer, ReadEntry | string, WarnEvent<Buffer>> implements Warner {
44
+ sync: boolean;
45
+ opt: TarOptions;
46
+ cwd: string;
47
+ maxReadSize?: number;
48
+ preservePaths: boolean;
49
+ strict: boolean;
50
+ noPax: boolean;
51
+ prefix: string;
52
+ linkCache: Exclude<TarOptions['linkCache'], undefined>;
53
+ statCache: Exclude<TarOptions['statCache'], undefined>;
54
+ file: string;
55
+ portable: boolean;
56
+ zip?: zlib.BrotliCompress | zlib.Gzip | zlib.ZstdCompress;
57
+ readdirCache: Exclude<TarOptions['readdirCache'], undefined>;
58
+ noDirRecurse: boolean;
59
+ follow: boolean;
60
+ noMtime: boolean;
61
+ mtime?: Date;
62
+ filter: Exclude<TarOptions['filter'], undefined>;
63
+ jobs: number;
64
+ [WRITEENTRYCLASS]: typeof WriteEntry | typeof WriteEntrySync;
65
+ onWriteEntry?: (entry: WriteEntry) => void;
66
+ [QUEUE]: Yallist<PackJob>;
67
+ [PENDINGLINKS]: Map<`${number}:${number}`, PackJob[]>;
68
+ [JOBS]: number;
69
+ [PROCESSING]: boolean;
70
+ [ENDED]: boolean;
71
+ constructor(opt?: TarOptions);
72
+ [WRITE](chunk: Buffer): boolean;
73
+ add(path: string | ReadEntry): this;
74
+ end(cb?: () => void): this;
75
+ end(path: string | ReadEntry, cb?: () => void): this;
76
+ end(path: string | ReadEntry, encoding?: Minipass.Encoding, cb?: () => void): this;
77
+ write(path: string | ReadEntry): boolean;
78
+ [ADDTARENTRY](p: ReadEntry): void;
79
+ [ADDFSENTRY](p: string): void;
80
+ [STAT](job: PackJob): void;
81
+ [ONSTAT](job: PackJob, stat: Stats): void;
82
+ [READDIR](job: PackJob): void;
83
+ [ONREADDIR](job: PackJob, entries: string[]): void;
84
+ [PROCESS](): void;
85
+ get [CURRENT](): PackJob | undefined;
86
+ [JOBDONE](job: PackJob): void;
87
+ [PROCESSJOB](job: PackJob): void;
88
+ [ENTRYOPT](job: PackJob): TarOptions;
89
+ [ENTRY](job: PackJob): WriteEntry | undefined;
90
+ [ONDRAIN](): void;
91
+ [PIPE](job: PackJob): void;
92
+ pause(): void;
93
+ warn(code: string, message: string | Error, data?: WarnData): void;
94
+ }
95
+ export declare class PackSync extends Pack {
96
+ sync: true;
97
+ constructor(opt: TarOptions);
98
+ pause(): void;
99
+ resume(): void;
100
+ [STAT](job: PackJob): void;
101
+ [READDIR](job: PackJob): void;
102
+ [PIPE](job: PackJob): void;
103
+ }
104
+ export {};
105
+ //# sourceMappingURL=pack.d.ts.map
@@ -0,0 +1,503 @@
1
+ // A readable tar stream creator
2
+ // Technically, this is a transform stream that you write paths into,
3
+ // and tar format comes out of.
4
+ // The `add()` method is like `write()` but returns this,
5
+ // and end() return `this` as well, so you can
6
+ // do `new Pack(opt).add('files').add('dir').end().pipe(output)
7
+ // You could also do something like:
8
+ // streamOfPaths().pipe(new Pack()).pipe(new fs.WriteStream('out.tar'))
9
+ import fs from 'fs';
10
+ import { WriteEntry, WriteEntrySync, WriteEntryTar, } from './write-entry.js';
11
+ export class PackJob {
12
+ path;
13
+ absolute;
14
+ entry;
15
+ stat;
16
+ readdir;
17
+ pending = false;
18
+ pendingLink = false;
19
+ ignore = false;
20
+ piped = false;
21
+ constructor(path, absolute) {
22
+ this.path = path || './';
23
+ this.absolute = absolute;
24
+ }
25
+ }
26
+ import { Minipass } from 'minipass';
27
+ import * as zlib from 'minizlib';
28
+ import { Yallist } from 'yallist';
29
+ import { ReadEntry } from './read-entry.js';
30
+ import { warnMethod } from './warn-method.js';
31
+ const EOF = Buffer.alloc(1024);
32
+ const ONSTAT = Symbol('onStat');
33
+ const ENDED = Symbol('ended');
34
+ const QUEUE = Symbol('queue');
35
+ const PENDINGLINKS = Symbol('queue');
36
+ const CURRENT = Symbol('current');
37
+ const PROCESS = Symbol('process');
38
+ const PROCESSING = Symbol('processing');
39
+ const PROCESSJOB = Symbol('processJob');
40
+ const JOBS = Symbol('jobs');
41
+ const JOBDONE = Symbol('jobDone');
42
+ const ADDFSENTRY = Symbol('addFSEntry');
43
+ const ADDTARENTRY = Symbol('addTarEntry');
44
+ const STAT = Symbol('stat');
45
+ const READDIR = Symbol('readdir');
46
+ const ONREADDIR = Symbol('onreaddir');
47
+ const PIPE = Symbol('pipe');
48
+ const ENTRY = Symbol('entry');
49
+ const ENTRYOPT = Symbol('entryOpt');
50
+ const WRITEENTRYCLASS = Symbol('writeEntryClass');
51
+ const WRITE = Symbol('write');
52
+ const ONDRAIN = Symbol('ondrain');
53
+ import path from 'path';
54
+ import { normalizeWindowsPath } from './normalize-windows-path.js';
55
+ export class Pack extends Minipass {
56
+ sync = false;
57
+ opt;
58
+ cwd;
59
+ maxReadSize;
60
+ preservePaths;
61
+ strict;
62
+ noPax;
63
+ prefix;
64
+ linkCache;
65
+ statCache;
66
+ file;
67
+ portable;
68
+ zip;
69
+ readdirCache;
70
+ noDirRecurse;
71
+ follow;
72
+ noMtime;
73
+ mtime;
74
+ filter;
75
+ jobs;
76
+ [WRITEENTRYCLASS];
77
+ onWriteEntry;
78
+ // Note: we actually DO need a linked list here, because we
79
+ // shift() to update the head of the list where we start, but still
80
+ // while that happens, need to know what the next item in the queue
81
+ // will be. Since we do multiple jobs in parallel, it's not as simple
82
+ // as just an Array.shift(), since that would lose the information about
83
+ // the next job in the list. We could add a .next field on the PackJob
84
+ // class, but then we'd have to be tracking the tail of the queue the
85
+ // whole time, and Yallist just does that for us anyway.
86
+ [QUEUE];
87
+ [PENDINGLINKS] = new Map();
88
+ [JOBS] = 0;
89
+ [PROCESSING] = false;
90
+ [ENDED] = false;
91
+ constructor(opt = {}) {
92
+ super();
93
+ this.opt = opt;
94
+ this.file = opt.file || '';
95
+ this.cwd = opt.cwd || process.cwd();
96
+ this.maxReadSize = opt.maxReadSize;
97
+ this.preservePaths = !!opt.preservePaths;
98
+ this.strict = !!opt.strict;
99
+ this.noPax = !!opt.noPax;
100
+ this.prefix = normalizeWindowsPath(opt.prefix || '');
101
+ this.linkCache = opt.linkCache || new Map();
102
+ this.statCache = opt.statCache || new Map();
103
+ this.readdirCache = opt.readdirCache || new Map();
104
+ this.onWriteEntry = opt.onWriteEntry;
105
+ this[WRITEENTRYCLASS] = WriteEntry;
106
+ if (typeof opt.onwarn === 'function') {
107
+ this.on('warn', opt.onwarn);
108
+ }
109
+ this.portable = !!opt.portable;
110
+ if (opt.gzip || opt.brotli || opt.zstd) {
111
+ if ((opt.gzip ? 1 : 0) + (opt.brotli ? 1 : 0) + (opt.zstd ? 1 : 0) >
112
+ 1) {
113
+ throw new TypeError('gzip, brotli, zstd are mutually exclusive');
114
+ }
115
+ if (opt.gzip) {
116
+ if (typeof opt.gzip !== 'object') {
117
+ opt.gzip = {};
118
+ }
119
+ if (this.portable) {
120
+ opt.gzip.portable = true;
121
+ }
122
+ this.zip = new zlib.Gzip(opt.gzip);
123
+ }
124
+ if (opt.brotli) {
125
+ if (typeof opt.brotli !== 'object') {
126
+ opt.brotli = {};
127
+ }
128
+ this.zip = new zlib.BrotliCompress(opt.brotli);
129
+ }
130
+ if (opt.zstd) {
131
+ if (typeof opt.zstd !== 'object') {
132
+ opt.zstd = {};
133
+ }
134
+ this.zip = new zlib.ZstdCompress(opt.zstd);
135
+ }
136
+ /* c8 ignore next */
137
+ if (!this.zip)
138
+ throw new Error('impossible');
139
+ const zip = this.zip;
140
+ zip.on('data', chunk => super.write(chunk));
141
+ zip.on('end', () => super.end());
142
+ zip.on('drain', () => this[ONDRAIN]());
143
+ this.on('resume', () => zip.resume());
144
+ }
145
+ else {
146
+ this.on('drain', this[ONDRAIN]);
147
+ }
148
+ this.noDirRecurse = !!opt.noDirRecurse;
149
+ this.follow = !!opt.follow;
150
+ this.noMtime = !!opt.noMtime;
151
+ if (opt.mtime)
152
+ this.mtime = opt.mtime;
153
+ this.filter =
154
+ typeof opt.filter === 'function' ? opt.filter : () => true;
155
+ this[QUEUE] = new Yallist();
156
+ this[JOBS] = 0;
157
+ this.jobs = Number(opt.jobs) || 4;
158
+ this[PROCESSING] = false;
159
+ this[ENDED] = false;
160
+ }
161
+ [WRITE](chunk) {
162
+ return super.write(chunk);
163
+ }
164
+ add(path) {
165
+ this.write(path);
166
+ return this;
167
+ }
168
+ end(path, encoding, cb) {
169
+ /* c8 ignore start */
170
+ if (typeof path === 'function') {
171
+ cb = path;
172
+ path = undefined;
173
+ }
174
+ if (typeof encoding === 'function') {
175
+ cb = encoding;
176
+ encoding = undefined;
177
+ }
178
+ /* c8 ignore stop */
179
+ if (path) {
180
+ this.add(path);
181
+ }
182
+ this[ENDED] = true;
183
+ this[PROCESS]();
184
+ /* c8 ignore next */
185
+ if (cb)
186
+ cb();
187
+ return this;
188
+ }
189
+ write(path) {
190
+ if (this[ENDED]) {
191
+ throw new Error('write after end');
192
+ }
193
+ if (path instanceof ReadEntry) {
194
+ this[ADDTARENTRY](path);
195
+ }
196
+ else {
197
+ this[ADDFSENTRY](path);
198
+ }
199
+ return this.flowing;
200
+ }
201
+ [ADDTARENTRY](p) {
202
+ const absolute = normalizeWindowsPath(path.resolve(this.cwd, p.path));
203
+ // in this case, we don't have to wait for the stat
204
+ if (!this.filter(p.path, p)) {
205
+ p.resume();
206
+ }
207
+ else {
208
+ const job = new PackJob(p.path, absolute);
209
+ job.entry = new WriteEntryTar(p, this[ENTRYOPT](job));
210
+ job.entry.on('end', () => this[JOBDONE](job));
211
+ this[JOBS] += 1;
212
+ this[QUEUE].push(job);
213
+ }
214
+ this[PROCESS]();
215
+ }
216
+ [ADDFSENTRY](p) {
217
+ const absolute = normalizeWindowsPath(path.resolve(this.cwd, p));
218
+ this[QUEUE].push(new PackJob(p, absolute));
219
+ this[PROCESS]();
220
+ }
221
+ [STAT](job) {
222
+ job.pending = true;
223
+ this[JOBS] += 1;
224
+ const stat = this.follow ? 'stat' : 'lstat';
225
+ fs[stat](job.absolute, (er, stat) => {
226
+ job.pending = false;
227
+ this[JOBS] -= 1;
228
+ if (er) {
229
+ this.emit('error', er);
230
+ }
231
+ else {
232
+ this[ONSTAT](job, stat);
233
+ }
234
+ });
235
+ }
236
+ [ONSTAT](job, stat) {
237
+ this.statCache.set(job.absolute, stat);
238
+ job.stat = stat;
239
+ // now we have the stat, we can filter it.
240
+ if (!this.filter(job.path, stat)) {
241
+ job.ignore = true;
242
+ }
243
+ else if (stat.isFile() &&
244
+ stat.nlink > 1 &&
245
+ !this.linkCache.get(`${stat.dev}:${stat.ino}`) &&
246
+ !this.sync) {
247
+ // if it's not filtered, and it's a new File entry, and next anyway
248
+ // process right away in case any pending Link entries are about
249
+ // to try to link to it.
250
+ if (job === this[CURRENT]) {
251
+ this[PROCESSJOB](job);
252
+ }
253
+ else {
254
+ // if it's NOT the current entry, it needs to be deferred,
255
+ // so that the link target can be built first.
256
+ const key = `${stat.dev}:${stat.ino}`;
257
+ const pending = this[PENDINGLINKS].get(key);
258
+ if (pending)
259
+ pending.push(job);
260
+ else
261
+ this[PENDINGLINKS].set(key, [job]);
262
+ job.pendingLink = true;
263
+ job.pending = true;
264
+ }
265
+ }
266
+ this[PROCESS]();
267
+ }
268
+ [READDIR](job) {
269
+ job.pending = true;
270
+ this[JOBS] += 1;
271
+ fs.readdir(job.absolute, (er, entries) => {
272
+ job.pending = false;
273
+ this[JOBS] -= 1;
274
+ if (er) {
275
+ return this.emit('error', er);
276
+ }
277
+ this[ONREADDIR](job, entries);
278
+ });
279
+ }
280
+ [ONREADDIR](job, entries) {
281
+ this.readdirCache.set(job.absolute, entries);
282
+ job.readdir = entries;
283
+ this[PROCESS]();
284
+ }
285
+ [PROCESS]() {
286
+ if (this[PROCESSING]) {
287
+ return;
288
+ }
289
+ this[PROCESSING] = true;
290
+ for (let w = this[QUEUE].head; !!w && this[JOBS] < this.jobs; w = w.next) {
291
+ this[PROCESSJOB](w.value);
292
+ if (w.value.ignore) {
293
+ const p = w.next;
294
+ this[QUEUE].removeNode(w);
295
+ w.next = p;
296
+ }
297
+ }
298
+ this[PROCESSING] = false;
299
+ if (this[ENDED] && this[QUEUE].length === 0 && this[JOBS] === 0) {
300
+ if (this.zip) {
301
+ this.zip.end(EOF);
302
+ }
303
+ else {
304
+ super.write(EOF);
305
+ super.end();
306
+ }
307
+ }
308
+ }
309
+ get [CURRENT]() {
310
+ return this[QUEUE] && this[QUEUE].head && this[QUEUE].head.value;
311
+ }
312
+ [JOBDONE](job) {
313
+ this[QUEUE].shift();
314
+ this[JOBS] -= 1;
315
+ const { stat } = job;
316
+ if (stat && stat.isFile() && stat.nlink > 1) {
317
+ // might be a file with pending links
318
+ const key = `${stat.dev}:${stat.ino}`;
319
+ const pending = this[PENDINGLINKS].get(key);
320
+ if (pending) {
321
+ this[PENDINGLINKS].delete(key);
322
+ for (const job of pending) {
323
+ job.pending = false;
324
+ this[PROCESSJOB](job);
325
+ }
326
+ }
327
+ }
328
+ this[PROCESS]();
329
+ }
330
+ [PROCESSJOB](job) {
331
+ if (job.pending && job.pendingLink && job === this[CURRENT]) {
332
+ // At least one of the links to this file are not being included
333
+ // in the tarball, so we need to just proceed.
334
+ job.pending = false;
335
+ job.pendingLink = false;
336
+ }
337
+ if (job.pending) {
338
+ return;
339
+ }
340
+ if (job.entry) {
341
+ if (job === this[CURRENT] && !job.piped) {
342
+ this[PIPE](job);
343
+ }
344
+ return;
345
+ }
346
+ if (!job.stat) {
347
+ const sc = this.statCache.get(job.absolute);
348
+ if (sc) {
349
+ this[ONSTAT](job, sc);
350
+ }
351
+ else {
352
+ this[STAT](job);
353
+ }
354
+ }
355
+ if (!job.stat) {
356
+ return;
357
+ }
358
+ // filtered out!
359
+ if (job.ignore) {
360
+ return;
361
+ }
362
+ if (!this.noDirRecurse && job.stat.isDirectory() && !job.readdir) {
363
+ const rc = this.readdirCache.get(job.absolute);
364
+ if (rc) {
365
+ this[ONREADDIR](job, rc);
366
+ }
367
+ else {
368
+ this[READDIR](job);
369
+ }
370
+ if (!job.readdir) {
371
+ return;
372
+ }
373
+ }
374
+ // we know it doesn't have an entry, because that got checked above
375
+ job.entry = this[ENTRY](job);
376
+ if (!job.entry) {
377
+ job.ignore = true;
378
+ return;
379
+ }
380
+ if (job === this[CURRENT] && !job.piped) {
381
+ this[PIPE](job);
382
+ }
383
+ }
384
+ [ENTRYOPT](job) {
385
+ return {
386
+ onwarn: (code, msg, data) => this.warn(code, msg, data),
387
+ noPax: this.noPax,
388
+ cwd: this.cwd,
389
+ absolute: job.absolute,
390
+ preservePaths: this.preservePaths,
391
+ maxReadSize: this.maxReadSize,
392
+ strict: this.strict,
393
+ portable: this.portable,
394
+ linkCache: this.linkCache,
395
+ statCache: this.statCache,
396
+ noMtime: this.noMtime,
397
+ mtime: this.mtime,
398
+ prefix: this.prefix,
399
+ onWriteEntry: this.onWriteEntry,
400
+ };
401
+ }
402
+ [ENTRY](job) {
403
+ this[JOBS] += 1;
404
+ try {
405
+ const e = new this[WRITEENTRYCLASS](job.path, this[ENTRYOPT](job));
406
+ return e
407
+ .on('end', () => this[JOBDONE](job))
408
+ .on('error', er => this.emit('error', er));
409
+ }
410
+ catch (er) {
411
+ this.emit('error', er);
412
+ }
413
+ }
414
+ [ONDRAIN]() {
415
+ if (this[CURRENT] && this[CURRENT].entry) {
416
+ this[CURRENT].entry.resume();
417
+ }
418
+ }
419
+ // like .pipe() but using super, because our write() is special
420
+ [PIPE](job) {
421
+ job.piped = true;
422
+ if (job.readdir) {
423
+ job.readdir.forEach(entry => {
424
+ const p = job.path;
425
+ const base = p === './' ? '' : p.replace(/\/*$/, '/');
426
+ this[ADDFSENTRY](base + entry);
427
+ });
428
+ }
429
+ const source = job.entry;
430
+ const zip = this.zip;
431
+ /* c8 ignore start */
432
+ if (!source)
433
+ throw new Error('cannot pipe without source');
434
+ /* c8 ignore stop */
435
+ if (zip) {
436
+ source.on('data', chunk => {
437
+ if (!zip.write(chunk)) {
438
+ source.pause();
439
+ }
440
+ });
441
+ }
442
+ else {
443
+ source.on('data', chunk => {
444
+ if (!super.write(chunk)) {
445
+ source.pause();
446
+ }
447
+ });
448
+ }
449
+ }
450
+ pause() {
451
+ if (this.zip) {
452
+ this.zip.pause();
453
+ }
454
+ return super.pause();
455
+ }
456
+ warn(code, message, data = {}) {
457
+ warnMethod(this, code, message, data);
458
+ }
459
+ }
460
+ export class PackSync extends Pack {
461
+ sync = true;
462
+ constructor(opt) {
463
+ super(opt);
464
+ this[WRITEENTRYCLASS] = WriteEntrySync;
465
+ }
466
+ // pause/resume are no-ops in sync streams.
467
+ pause() { }
468
+ resume() { }
469
+ [STAT](job) {
470
+ const stat = this.follow ? 'statSync' : 'lstatSync';
471
+ this[ONSTAT](job, fs[stat](job.absolute));
472
+ }
473
+ [READDIR](job) {
474
+ this[ONREADDIR](job, fs.readdirSync(job.absolute));
475
+ }
476
+ // gotta get it all in this tick
477
+ [PIPE](job) {
478
+ const source = job.entry;
479
+ const zip = this.zip;
480
+ if (job.readdir) {
481
+ job.readdir.forEach(entry => {
482
+ const p = job.path;
483
+ const base = p === './' ? '' : p.replace(/\/*$/, '/');
484
+ this[ADDFSENTRY](base + entry);
485
+ });
486
+ }
487
+ /* c8 ignore start */
488
+ if (!source)
489
+ throw new Error('Cannot pipe without source');
490
+ /* c8 ignore stop */
491
+ if (zip) {
492
+ source.on('data', chunk => {
493
+ zip.write(chunk);
494
+ });
495
+ }
496
+ else {
497
+ source.on('data', chunk => {
498
+ super[WRITE](chunk);
499
+ });
500
+ }
501
+ }
502
+ }
503
+ //# sourceMappingURL=pack.js.map
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,85 @@
1
+ import { EventEmitter as EE } from 'events';
2
+ import { BrotliDecompress, Unzip, ZstdDecompress } from 'minizlib';
3
+ import type { TarOptions } from './options.js';
4
+ import { Pax } from './pax.js';
5
+ import { ReadEntry } from './read-entry.js';
6
+ import { type WarnData, type Warner } from './warn-method.js';
7
+ declare const STATE: unique symbol;
8
+ declare const WRITEENTRY: unique symbol;
9
+ declare const READENTRY: unique symbol;
10
+ declare const NEXTENTRY: unique symbol;
11
+ declare const PROCESSENTRY: unique symbol;
12
+ declare const EX: unique symbol;
13
+ declare const GEX: unique symbol;
14
+ declare const META: unique symbol;
15
+ declare const EMITMETA: unique symbol;
16
+ declare const BUFFER: unique symbol;
17
+ declare const QUEUE: unique symbol;
18
+ declare const ENDED: unique symbol;
19
+ declare const EMITTEDEND: unique symbol;
20
+ declare const EMIT: unique symbol;
21
+ declare const UNZIP: unique symbol;
22
+ declare const CONSUMECHUNK: unique symbol;
23
+ declare const CONSUMECHUNKSUB: unique symbol;
24
+ declare const CONSUMEBODY: unique symbol;
25
+ declare const CONSUMEMETA: unique symbol;
26
+ declare const CONSUMEHEADER: unique symbol;
27
+ declare const CONSUMING: unique symbol;
28
+ declare const BUFFERCONCAT: unique symbol;
29
+ declare const MAYBEEND: unique symbol;
30
+ declare const WRITING: unique symbol;
31
+ declare const ABORTED: unique symbol;
32
+ declare const SAW_VALID_ENTRY: unique symbol;
33
+ declare const SAW_NULL_BLOCK: unique symbol;
34
+ declare const SAW_EOF: unique symbol;
35
+ declare const CLOSESTREAM: unique symbol;
36
+ export type State = 'begin' | 'header' | 'ignore' | 'meta' | 'body';
37
+ export declare class Parser extends EE implements Warner {
38
+ file: string;
39
+ strict: boolean;
40
+ maxMetaEntrySize: number;
41
+ filter: Exclude<TarOptions['filter'], undefined>;
42
+ brotli?: TarOptions['brotli'];
43
+ zstd?: TarOptions['zstd'];
44
+ writable: true;
45
+ readable: false;
46
+ [QUEUE]: (ReadEntry | [string | symbol, unknown, unknown])[];
47
+ [BUFFER]?: Buffer;
48
+ [READENTRY]?: ReadEntry;
49
+ [WRITEENTRY]?: ReadEntry;
50
+ [STATE]: State;
51
+ [META]: string;
52
+ [EX]?: Pax;
53
+ [GEX]?: Pax;
54
+ [ENDED]: boolean;
55
+ [UNZIP]?: false | Unzip | BrotliDecompress | ZstdDecompress;
56
+ [ABORTED]: boolean;
57
+ [SAW_VALID_ENTRY]?: boolean;
58
+ [SAW_NULL_BLOCK]: boolean;
59
+ [SAW_EOF]: boolean;
60
+ [WRITING]: boolean;
61
+ [CONSUMING]: boolean;
62
+ [EMITTEDEND]: boolean;
63
+ constructor(opt?: TarOptions);
64
+ warn(code: string, message: string | Error, data?: WarnData): void;
65
+ [CONSUMEHEADER](chunk: Buffer, position: number): void;
66
+ [CLOSESTREAM](): void;
67
+ [PROCESSENTRY](entry?: ReadEntry | [string | symbol, unknown, unknown]): boolean;
68
+ [NEXTENTRY](): void;
69
+ [CONSUMEBODY](chunk: Buffer, position: number): number;
70
+ [CONSUMEMETA](chunk: Buffer, position: number): number;
71
+ [EMIT](ev: string | symbol, data?: unknown, extra?: unknown): void;
72
+ [EMITMETA](entry: ReadEntry): void;
73
+ abort(error: Error): void;
74
+ write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean;
75
+ write(str: string, encoding?: BufferEncoding, cb?: (err?: Error | null) => void): boolean;
76
+ [BUFFERCONCAT](c: Buffer): void;
77
+ [MAYBEEND](): void;
78
+ [CONSUMECHUNK](chunk?: Buffer): void;
79
+ [CONSUMECHUNKSUB](chunk: Buffer): void;
80
+ end(cb?: () => void): this;
81
+ end(data: string | Buffer, cb?: () => void): this;
82
+ end(str: string, encoding?: BufferEncoding, cb?: () => void): this;
83
+ }
84
+ export {};
85
+ //# sourceMappingURL=parse.d.ts.map