1 |
|
2 | import { Readable } from 'stream';
|
3 | import { Queue } from './queue';
|
4 | import { Projector } from './projector';
|
5 |
|
6 |
|
7 |
|
8 | export interface IBundleResourceOptions {
|
9 | |
10 |
|
11 |
|
12 | atime?: null | Date;
|
13 | |
14 |
|
15 |
|
16 | atimeCopy?: null | boolean;
|
17 | |
18 |
|
19 |
|
20 | mtime?: null | Date;
|
21 | |
22 |
|
23 |
|
24 | mtimeCopy?: null | boolean;
|
25 | |
26 |
|
27 |
|
28 | executable?: null | boolean;
|
29 | |
30 |
|
31 |
|
32 | executableCopy?: null | boolean;
|
33 | |
34 |
|
35 |
|
36 | merge?: null | boolean;
|
37 | |
38 |
|
39 |
|
40 | noRecurse?: null | boolean;
|
41 | }
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 | export declare abstract class Bundle extends Object {
|
48 | |
49 |
|
50 |
|
51 | excludes: RegExp[];
|
52 | |
53 |
|
54 |
|
55 | readonly path: string;
|
56 | |
57 |
|
58 |
|
59 | abstract readonly projector: Projector;
|
60 | |
61 |
|
62 |
|
63 | protected _isOpen: boolean;
|
64 | |
65 |
|
66 |
|
67 | protected _closeQueue: Queue;
|
68 | constructor(path: string);
|
69 | /**
|
70 | * Check if output open.
|
71 | *
|
72 | * @returns Returns true if open, else false.
|
73 | */
|
74 | get isOpen(): boolean;
|
75 | /**
|
76 | * Check if name is excluded file.
|
77 | *
|
78 | * @param name File name.
|
79 | * @returns Returns true if excluded, else false.
|
80 | */
|
81 | isExcludedFile(name: string): boolean;
|
82 | /**
|
83 | * Open output with file.
|
84 | *
|
85 | * @param player Player path.
|
86 | * @param movieFile Movie file.
|
87 | */
|
88 | openFile(player: string, movieFile: string | null): Promise<void>;
|
89 | /**
|
90 | * Open output with data.
|
91 | *
|
92 | * @param player Player path.
|
93 | * @param movieData Movie data.
|
94 | */
|
95 | openData(player: string, movieData: Readonly<Buffer> | null): Promise<void>;
|
96 | /**
|
97 | * Close output.
|
98 | */
|
99 | close(): Promise<void>;
|
100 | /**
|
101 | * Write out projector with player and file.
|
102 | * Has a callback to write out the resources.
|
103 | *
|
104 | * @param player Player path.
|
105 | * @param movieFile Movie file.
|
106 | * @param func Async function.
|
107 | * @returns Return value of the async function.
|
108 | */
|
109 | withFile<T>(player: string, movieFile: string | null, func?: ((self: this) => Promise<T>) | null): Promise<T | null>;
|
110 | /**
|
111 | * Write out projector with player and data.
|
112 | * Has a callback to write out the resources.
|
113 | *
|
114 | * @param player Player path.
|
115 | * @param movieData Movie data.
|
116 | * @param func Async function.
|
117 | * @returns Return value of the async function.
|
118 | */
|
119 | withData<T>(player: string, movieData: Readonly<Buffer> | null, func?: ((self: this) => Promise<T>) | null): Promise<T | null>;
|
120 | /**
|
121 | * Get path for resource.
|
122 | *
|
123 | * @param destination Resource destination.
|
124 | * @returns Destination path.
|
125 | */
|
126 | resourcePath(destination: string): string;
|
127 | /**
|
128 | * Check if path for resource exists.
|
129 | *
|
130 | * @param destination Resource destination.
|
131 | * @returns True if destination exists, else false.
|
132 | */
|
133 | resourceExists(destination: string): Promise<boolean>;
|
134 | /**
|
135 | * Copy resource, detecting source type automatically.
|
136 | *
|
137 | * @param destination Resource destination.
|
138 | * @param source Source directory.
|
139 | * @param options Resource options.
|
140 | */
|
141 | copyResource(destination: string, source: string, options?: Readonly<IBundleResourceOptions> | null): Promise<void>;
|
142 | /**
|
143 | * Copy directory as resource, recursive copy.
|
144 | *
|
145 | * @param destination Resource destination.
|
146 | * @param source Source directory.
|
147 | * @param options Resource options.
|
148 | */
|
149 | copyResourceDirectory(destination: string, source: string, options?: Readonly<IBundleResourceOptions> | null): Promise<void>;
|
150 | /**
|
151 | * Copy file as resource.
|
152 | *
|
153 | * @param destination Resource destination.
|
154 | * @param source Source file.
|
155 | * @param options Resource options.
|
156 | */
|
157 | copyResourceFile(destination: string, source: string, options?: Readonly<IBundleResourceOptions> | null): Promise<void>;
|
158 | /**
|
159 | * Copy symlink as resource.
|
160 | *
|
161 | * @param destination Resource destination.
|
162 | * @param source Source symlink.
|
163 | * @param options Resource options.
|
164 | */
|
165 | copyResourceSymlink(destination: string, source: string, options?: Readonly<IBundleResourceOptions> | null): Promise<void>;
|
166 | /**
|
167 | * Create a resource directory.
|
168 | *
|
169 | * @param destination Resource destination.
|
170 | * @param options Resource options.
|
171 | */
|
172 | createResourceDirectory(destination: string, options?: Readonly<IBundleResourceOptions> | null): Promise<void>;
|
173 | /**
|
174 | * Create a resource file.
|
175 | *
|
176 | * @param destination Resource destination.
|
177 | * @param data Resource data.
|
178 | * @param options Resource options.
|
179 | */
|
180 | createResourceFile(destination: string, data: Readonly<Buffer> | string, options?: Readonly<IBundleResourceOptions> | null): Promise<void>;
|
181 | /**
|
182 | * Create a resource symlink.
|
183 | *
|
184 | * @param destination Resource destination.
|
185 | * @param target Symlink target.
|
186 | * @param options Resource options.
|
187 | */
|
188 | createResourceSymlink(destination: string, target: Readonly<Buffer> | string, options?: Readonly<IBundleResourceOptions> | null): Promise<void>;
|
189 | /**
|
190 | * Stream readable source to resource file.
|
191 | *
|
192 | * @param destination Resource destination.
|
193 | * @param data Resource stream.
|
194 | * @param options Resource options.
|
195 | */
|
196 | streamResourceFile(destination: string, data: Readable, options?: Readonly<IBundleResourceOptions> | null): Promise<void>;
|
197 | /**
|
198 | * Check that output path is valid, else throws.
|
199 | */
|
200 | protected _checkOutput(): Promise<void>;
|
201 | /**
|
202 | * Expand resource options copy properties with stat object from source.
|
203 | *
|
204 | * @param options Options object.
|
205 | * @param stat Stat function.
|
206 | * @returns Options copy with any values populated.
|
207 | */
|
208 | protected _expandResourceOptionsCopy(options: Readonly<IBundleResourceOptions>, stat: (() => Promise<{
|
209 | atime: Date;
|
210 | mtime: Date;
|
211 | mode: number;
|
212 | }>)): Promise<IBundleResourceOptions>;
|
213 | /**
|
214 | * Set resource attributes from options object.
|
215 | *
|
216 | * @param path File path.
|
217 | * @param options Options object.
|
218 | */
|
219 | protected _setResourceAttributes(path: string, options: Readonly<IBundleResourceOptions>): Promise<void>;
|
220 | /**
|
221 | * Get file mode executable.
|
222 | *
|
223 | * @param mode Current mode.
|
224 | * @returns Is executable.
|
225 | */
|
226 | protected _getResourceModeExecutable(mode: number): boolean;
|
227 | /**
|
228 | * Set file mode executable.
|
229 | *
|
230 | * @param mode Current mode.
|
231 | * @param executable Is executable.
|
232 | * @returns File mode.
|
233 | */
|
234 | protected _setResourceModeExecutable(mode: number, executable: boolean): number;
|
235 | /**
|
236 | * Open output with data.
|
237 | *
|
238 | * @param player Player path.
|
239 | * @param movieData Movie data.
|
240 | */
|
241 | protected _openData(player: string, movieData: Readonly<Buffer> | null): Promise<void>;
|
242 | /**
|
243 | * Close output.
|
244 | */
|
245 | protected _close(): Promise<void>;
|
246 | /**
|
247 | * Assert bundle is open.
|
248 | */
|
249 | protected _assertIsOpen(): void;
|
250 | /**
|
251 | * Assert resource does not exist, returning destination path.
|
252 | *
|
253 | * @param destination Resource destination.
|
254 | * @param ignoreDirectory Ignore directories.
|
255 | * @returns Destination path.
|
256 | */
|
257 | protected _assertNotResourceExists(destination: string, ignoreDirectory?: boolean): Promise<string>;
|
258 | /**
|
259 | * Main application file extension.
|
260 | *
|
261 | * @returns File extension.
|
262 | */
|
263 | abstract get extension(): string;
|
264 | /**
|
265 | * Create projector instance for the bundle.
|
266 | *
|
267 | * @returns Projector instance.
|
268 | */
|
269 | protected abstract _createProjector(): Projector;
|
270 | /**
|
271 | * Write the launcher file.
|
272 | */
|
273 | protected abstract _writeLauncher(): Promise<void>;
|
274 | }
|