@remotion/renderer 4.0.461 → 4.0.463
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.
- package/dist/browser/BrowserFetcher.js +2 -5
- package/dist/browser/extract-zip-archive.d.ts +1 -0
- package/dist/browser/extract-zip-archive.js +144 -0
- package/dist/esm/index.mjs +1905 -355
- package/package.json +13 -15
- package/vendor/yauzl-patched/LICENSE +21 -0
- package/vendor/yauzl-patched/buffer-crc32.js +111 -0
- package/vendor/yauzl-patched/fd-slicer.js +326 -0
- package/vendor/yauzl-patched/index.d.ts +23 -0
- package/vendor/yauzl-patched/index.js +969 -0
- package/vendor/yauzl-patched/pend.js +55 -0
- package/dist/options/experimental-visual-mode.d.ts +0 -16
- package/dist/options/experimental-visual-mode.js +0 -30
package/dist/esm/index.mjs
CHANGED
|
@@ -1,16 +1,669 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
4
|
+
var __returnValue = (v) => v;
|
|
5
|
+
function __exportSetter(name, newValue) {
|
|
6
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
7
|
+
}
|
|
3
8
|
var __export = (target, all) => {
|
|
4
9
|
for (var name in all)
|
|
5
10
|
__defProp(target, name, {
|
|
6
11
|
get: all[name],
|
|
7
12
|
enumerable: true,
|
|
8
13
|
configurable: true,
|
|
9
|
-
set: (
|
|
14
|
+
set: __exportSetter.bind(all, name)
|
|
10
15
|
});
|
|
11
16
|
};
|
|
12
17
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
13
18
|
|
|
19
|
+
// vendor/yauzl-patched/pend.js
|
|
20
|
+
var require_pend = __commonJS((exports, module) => {
|
|
21
|
+
module.exports = Pend;
|
|
22
|
+
function Pend() {
|
|
23
|
+
this.pending = 0;
|
|
24
|
+
this.max = Infinity;
|
|
25
|
+
this.listeners = [];
|
|
26
|
+
this.waiting = [];
|
|
27
|
+
this.error = null;
|
|
28
|
+
}
|
|
29
|
+
Pend.prototype.go = function(fn) {
|
|
30
|
+
if (this.pending < this.max) {
|
|
31
|
+
pendGo(this, fn);
|
|
32
|
+
} else {
|
|
33
|
+
this.waiting.push(fn);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
Pend.prototype.wait = function(cb) {
|
|
37
|
+
if (this.pending === 0) {
|
|
38
|
+
cb(this.error);
|
|
39
|
+
} else {
|
|
40
|
+
this.listeners.push(cb);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
Pend.prototype.hold = function() {
|
|
44
|
+
return pendHold(this);
|
|
45
|
+
};
|
|
46
|
+
function pendHold(self) {
|
|
47
|
+
self.pending += 1;
|
|
48
|
+
var called = false;
|
|
49
|
+
return onCb;
|
|
50
|
+
function onCb(err) {
|
|
51
|
+
if (called)
|
|
52
|
+
throw new Error("callback called twice");
|
|
53
|
+
called = true;
|
|
54
|
+
self.error = self.error || err;
|
|
55
|
+
self.pending -= 1;
|
|
56
|
+
if (self.waiting.length > 0 && self.pending < self.max) {
|
|
57
|
+
pendGo(self, self.waiting.shift());
|
|
58
|
+
} else if (self.pending === 0) {
|
|
59
|
+
var listeners = self.listeners;
|
|
60
|
+
self.listeners = [];
|
|
61
|
+
listeners.forEach(cbListener);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function cbListener(listener) {
|
|
65
|
+
listener(self.error);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function pendGo(self, fn) {
|
|
69
|
+
fn(pendHold(self));
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// vendor/yauzl-patched/fd-slicer.js
|
|
74
|
+
var require_fd_slicer = __commonJS((exports) => {
|
|
75
|
+
var fs5 = __require("fs");
|
|
76
|
+
var util = __require("util");
|
|
77
|
+
var stream = __require("stream");
|
|
78
|
+
var Readable = stream.Readable;
|
|
79
|
+
var Writable = stream.Writable;
|
|
80
|
+
var PassThrough = stream.PassThrough;
|
|
81
|
+
var Pend = require_pend();
|
|
82
|
+
var EventEmitter2 = __require("events").EventEmitter;
|
|
83
|
+
exports.createFromBuffer = createFromBuffer;
|
|
84
|
+
exports.createFromFd = createFromFd;
|
|
85
|
+
exports.BufferSlicer = BufferSlicer;
|
|
86
|
+
exports.FdSlicer = FdSlicer;
|
|
87
|
+
util.inherits(FdSlicer, EventEmitter2);
|
|
88
|
+
function FdSlicer(fd, options2) {
|
|
89
|
+
options2 = options2 || {};
|
|
90
|
+
EventEmitter2.call(this);
|
|
91
|
+
this.fd = fd;
|
|
92
|
+
this.pend = new Pend;
|
|
93
|
+
this.pend.max = 1;
|
|
94
|
+
this.refCount = 0;
|
|
95
|
+
this.autoClose = !!options2.autoClose;
|
|
96
|
+
}
|
|
97
|
+
FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
|
|
98
|
+
var self = this;
|
|
99
|
+
self.pend.go(function(cb) {
|
|
100
|
+
fs5.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer2) {
|
|
101
|
+
cb();
|
|
102
|
+
callback(err, bytesRead, buffer2);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
FdSlicer.prototype.write = function(buffer, offset, length, position, callback) {
|
|
107
|
+
var self = this;
|
|
108
|
+
self.pend.go(function(cb) {
|
|
109
|
+
fs5.write(self.fd, buffer, offset, length, position, function(err, written, buffer2) {
|
|
110
|
+
cb();
|
|
111
|
+
callback(err, written, buffer2);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
FdSlicer.prototype.createReadStream = function(options2) {
|
|
116
|
+
return new ReadStream(this, options2);
|
|
117
|
+
};
|
|
118
|
+
FdSlicer.prototype.createWriteStream = function(options2) {
|
|
119
|
+
return new WriteStream(this, options2);
|
|
120
|
+
};
|
|
121
|
+
FdSlicer.prototype.ref = function() {
|
|
122
|
+
this.refCount += 1;
|
|
123
|
+
};
|
|
124
|
+
FdSlicer.prototype.unref = function() {
|
|
125
|
+
var self = this;
|
|
126
|
+
self.refCount -= 1;
|
|
127
|
+
if (self.refCount > 0)
|
|
128
|
+
return;
|
|
129
|
+
if (self.refCount < 0)
|
|
130
|
+
throw new Error("invalid unref");
|
|
131
|
+
if (self.autoClose) {
|
|
132
|
+
fs5.close(self.fd, onCloseDone);
|
|
133
|
+
}
|
|
134
|
+
function onCloseDone(err) {
|
|
135
|
+
if (err) {
|
|
136
|
+
self.emit("error", err);
|
|
137
|
+
} else {
|
|
138
|
+
self.emit("close");
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
util.inherits(ReadStream, Readable);
|
|
143
|
+
function ReadStream(context, options2) {
|
|
144
|
+
options2 = options2 || {};
|
|
145
|
+
Readable.call(this, options2);
|
|
146
|
+
this.context = context;
|
|
147
|
+
this.context.ref();
|
|
148
|
+
this.start = options2.start || 0;
|
|
149
|
+
this.endOffset = options2.end;
|
|
150
|
+
this.pos = this.start;
|
|
151
|
+
this._destroyed = false;
|
|
152
|
+
}
|
|
153
|
+
ReadStream.prototype._read = function(n) {
|
|
154
|
+
var self = this;
|
|
155
|
+
if (self._destroyed)
|
|
156
|
+
return;
|
|
157
|
+
var toRead = Math.min(self._readableState.highWaterMark, n);
|
|
158
|
+
if (self.endOffset != null) {
|
|
159
|
+
toRead = Math.min(toRead, self.endOffset - self.pos);
|
|
160
|
+
}
|
|
161
|
+
if (toRead <= 0) {
|
|
162
|
+
self._destroyed = true;
|
|
163
|
+
self.push(null);
|
|
164
|
+
self.context.unref();
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
self.context.pend.go(function(cb) {
|
|
168
|
+
if (self._destroyed)
|
|
169
|
+
return cb();
|
|
170
|
+
var buffer = Buffer.allocUnsafe(toRead);
|
|
171
|
+
fs5.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
|
|
172
|
+
if (self._destroyed)
|
|
173
|
+
return cb();
|
|
174
|
+
if (err) {
|
|
175
|
+
self.destroy(err);
|
|
176
|
+
} else if (bytesRead === 0) {
|
|
177
|
+
self._destroyed = true;
|
|
178
|
+
self.push(null);
|
|
179
|
+
self.context.unref();
|
|
180
|
+
} else {
|
|
181
|
+
self.pos += bytesRead;
|
|
182
|
+
self.push(buffer.slice(0, bytesRead));
|
|
183
|
+
}
|
|
184
|
+
cb();
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
ReadStream.prototype.destroy = function(err) {
|
|
189
|
+
if (err == null && !this.readableEnded) {
|
|
190
|
+
err = new Error("stream _destroyed");
|
|
191
|
+
}
|
|
192
|
+
return Readable.prototype.destroy.call(this, err);
|
|
193
|
+
};
|
|
194
|
+
ReadStream.prototype._destroy = function(err, cb) {
|
|
195
|
+
if (!this._destroyed) {
|
|
196
|
+
this._destroyed = true;
|
|
197
|
+
this.context.unref();
|
|
198
|
+
}
|
|
199
|
+
cb(err);
|
|
200
|
+
};
|
|
201
|
+
util.inherits(WriteStream, Writable);
|
|
202
|
+
function WriteStream(context, options2) {
|
|
203
|
+
options2 = options2 || {};
|
|
204
|
+
Writable.call(this, options2);
|
|
205
|
+
this.context = context;
|
|
206
|
+
this.context.ref();
|
|
207
|
+
this.start = options2.start || 0;
|
|
208
|
+
this.endOffset = options2.end == null ? Infinity : +options2.end;
|
|
209
|
+
this.bytesWritten = 0;
|
|
210
|
+
this.pos = this.start;
|
|
211
|
+
this._destroyed = false;
|
|
212
|
+
this.on("finish", this.destroy.bind(this));
|
|
213
|
+
}
|
|
214
|
+
WriteStream.prototype._write = function(buffer, encoding, callback) {
|
|
215
|
+
var self = this;
|
|
216
|
+
if (self._destroyed)
|
|
217
|
+
return;
|
|
218
|
+
if (self.pos + buffer.length > self.endOffset) {
|
|
219
|
+
var err = new Error("maximum file length exceeded");
|
|
220
|
+
err.code = "ETOOBIG";
|
|
221
|
+
self.destroy();
|
|
222
|
+
callback(err);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
self.context.pend.go(function(cb) {
|
|
226
|
+
if (self._destroyed)
|
|
227
|
+
return cb();
|
|
228
|
+
fs5.write(self.context.fd, buffer, 0, buffer.length, self.pos, function(err2, bytes) {
|
|
229
|
+
if (err2) {
|
|
230
|
+
self.destroy();
|
|
231
|
+
cb();
|
|
232
|
+
callback(err2);
|
|
233
|
+
} else {
|
|
234
|
+
self.bytesWritten += bytes;
|
|
235
|
+
self.pos += bytes;
|
|
236
|
+
self.emit("progress");
|
|
237
|
+
cb();
|
|
238
|
+
callback();
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
};
|
|
243
|
+
WriteStream.prototype._destroy = function(err, cb) {
|
|
244
|
+
if (!this._destroyed) {
|
|
245
|
+
this._destroyed = true;
|
|
246
|
+
this.context.unref();
|
|
247
|
+
}
|
|
248
|
+
cb(err);
|
|
249
|
+
};
|
|
250
|
+
util.inherits(BufferSlicer, EventEmitter2);
|
|
251
|
+
function BufferSlicer(buffer, options2) {
|
|
252
|
+
EventEmitter2.call(this);
|
|
253
|
+
options2 = options2 || {};
|
|
254
|
+
this.refCount = 0;
|
|
255
|
+
this.buffer = buffer;
|
|
256
|
+
this.maxChunkSize = options2.maxChunkSize || Number.MAX_SAFE_INTEGER;
|
|
257
|
+
}
|
|
258
|
+
BufferSlicer.prototype.read = function(buffer, offset, length, position, callback) {
|
|
259
|
+
if (!(0 <= offset && offset <= buffer.length))
|
|
260
|
+
throw new RangeError("offset outside buffer: 0 <= " + offset + " <= " + buffer.length);
|
|
261
|
+
if (position < 0)
|
|
262
|
+
throw new RangeError("position is negative: " + position);
|
|
263
|
+
if (offset + length > buffer.length) {
|
|
264
|
+
length = buffer.length - offset;
|
|
265
|
+
}
|
|
266
|
+
if (position + length > this.buffer.length) {
|
|
267
|
+
length = this.buffer.length - position;
|
|
268
|
+
}
|
|
269
|
+
if (length <= 0) {
|
|
270
|
+
setImmediate(function() {
|
|
271
|
+
callback(null, 0);
|
|
272
|
+
});
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
this.buffer.copy(buffer, offset, position, position + length);
|
|
276
|
+
setImmediate(function() {
|
|
277
|
+
callback(null, length);
|
|
278
|
+
});
|
|
279
|
+
};
|
|
280
|
+
BufferSlicer.prototype.write = function(buffer, offset, length, position, callback) {
|
|
281
|
+
buffer.copy(this.buffer, position, offset, offset + length);
|
|
282
|
+
setImmediate(function() {
|
|
283
|
+
callback(null, length, buffer);
|
|
284
|
+
});
|
|
285
|
+
};
|
|
286
|
+
BufferSlicer.prototype.createReadStream = function(options2) {
|
|
287
|
+
options2 = options2 || {};
|
|
288
|
+
var readStream = new PassThrough(options2);
|
|
289
|
+
readStream._destroyed = false;
|
|
290
|
+
readStream.start = options2.start || 0;
|
|
291
|
+
readStream.endOffset = options2.end;
|
|
292
|
+
readStream.pos = readStream.endOffset || this.buffer.length;
|
|
293
|
+
var entireSlice = this.buffer.slice(readStream.start, readStream.pos);
|
|
294
|
+
var offset = 0;
|
|
295
|
+
while (true) {
|
|
296
|
+
var nextOffset = offset + this.maxChunkSize;
|
|
297
|
+
if (nextOffset >= entireSlice.length) {
|
|
298
|
+
if (offset < entireSlice.length) {
|
|
299
|
+
readStream.write(entireSlice.slice(offset, entireSlice.length));
|
|
300
|
+
}
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
readStream.write(entireSlice.slice(offset, nextOffset));
|
|
304
|
+
offset = nextOffset;
|
|
305
|
+
}
|
|
306
|
+
readStream.end();
|
|
307
|
+
readStream._destroy = function(err, cb) {
|
|
308
|
+
readStream._destroyed = true;
|
|
309
|
+
PassThrough.prototype._destroy.call(readStream, err, cb);
|
|
310
|
+
};
|
|
311
|
+
return readStream;
|
|
312
|
+
};
|
|
313
|
+
BufferSlicer.prototype.createWriteStream = function(options2) {
|
|
314
|
+
var bufferSlicer = this;
|
|
315
|
+
options2 = options2 || {};
|
|
316
|
+
var writeStream = new Writable(options2);
|
|
317
|
+
writeStream.start = options2.start || 0;
|
|
318
|
+
writeStream.endOffset = options2.end == null ? this.buffer.length : +options2.end;
|
|
319
|
+
writeStream.bytesWritten = 0;
|
|
320
|
+
writeStream.pos = writeStream.start;
|
|
321
|
+
writeStream._destroyed = false;
|
|
322
|
+
writeStream._write = function(buffer, encoding, callback) {
|
|
323
|
+
if (writeStream._destroyed)
|
|
324
|
+
return;
|
|
325
|
+
var end = writeStream.pos + buffer.length;
|
|
326
|
+
if (end > writeStream.endOffset) {
|
|
327
|
+
var err = new Error("maximum file length exceeded");
|
|
328
|
+
err.code = "ETOOBIG";
|
|
329
|
+
writeStream._destroyed = true;
|
|
330
|
+
callback(err);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
buffer.copy(bufferSlicer.buffer, writeStream.pos, 0, buffer.length);
|
|
334
|
+
writeStream.bytesWritten += buffer.length;
|
|
335
|
+
writeStream.pos = end;
|
|
336
|
+
writeStream.emit("progress");
|
|
337
|
+
callback();
|
|
338
|
+
};
|
|
339
|
+
writeStream._destroy = function(err, cb) {
|
|
340
|
+
writeStream._destroyed = true;
|
|
341
|
+
cb(err);
|
|
342
|
+
};
|
|
343
|
+
return writeStream;
|
|
344
|
+
};
|
|
345
|
+
BufferSlicer.prototype.ref = function() {
|
|
346
|
+
this.refCount += 1;
|
|
347
|
+
};
|
|
348
|
+
BufferSlicer.prototype.unref = function() {
|
|
349
|
+
this.refCount -= 1;
|
|
350
|
+
if (this.refCount < 0) {
|
|
351
|
+
throw new Error("invalid unref");
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
function createFromBuffer(buffer, options2) {
|
|
355
|
+
return new BufferSlicer(buffer, options2);
|
|
356
|
+
}
|
|
357
|
+
function createFromFd(fd, options2) {
|
|
358
|
+
return new FdSlicer(fd, options2);
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
// vendor/yauzl-patched/buffer-crc32.js
|
|
363
|
+
var require_buffer_crc32 = __commonJS((exports, module) => {
|
|
364
|
+
var Buffer2 = __require("buffer").Buffer;
|
|
365
|
+
var CRC_TABLE = [
|
|
366
|
+
0,
|
|
367
|
+
1996959894,
|
|
368
|
+
3993919788,
|
|
369
|
+
2567524794,
|
|
370
|
+
124634137,
|
|
371
|
+
1886057615,
|
|
372
|
+
3915621685,
|
|
373
|
+
2657392035,
|
|
374
|
+
249268274,
|
|
375
|
+
2044508324,
|
|
376
|
+
3772115230,
|
|
377
|
+
2547177864,
|
|
378
|
+
162941995,
|
|
379
|
+
2125561021,
|
|
380
|
+
3887607047,
|
|
381
|
+
2428444049,
|
|
382
|
+
498536548,
|
|
383
|
+
1789927666,
|
|
384
|
+
4089016648,
|
|
385
|
+
2227061214,
|
|
386
|
+
450548861,
|
|
387
|
+
1843258603,
|
|
388
|
+
4107580753,
|
|
389
|
+
2211677639,
|
|
390
|
+
325883990,
|
|
391
|
+
1684777152,
|
|
392
|
+
4251122042,
|
|
393
|
+
2321926636,
|
|
394
|
+
335633487,
|
|
395
|
+
1661365465,
|
|
396
|
+
4195302755,
|
|
397
|
+
2366115317,
|
|
398
|
+
997073096,
|
|
399
|
+
1281953886,
|
|
400
|
+
3579855332,
|
|
401
|
+
2724688242,
|
|
402
|
+
1006888145,
|
|
403
|
+
1258607687,
|
|
404
|
+
3524101629,
|
|
405
|
+
2768942443,
|
|
406
|
+
901097722,
|
|
407
|
+
1119000684,
|
|
408
|
+
3686517206,
|
|
409
|
+
2898065728,
|
|
410
|
+
853044451,
|
|
411
|
+
1172266101,
|
|
412
|
+
3705015759,
|
|
413
|
+
2882616665,
|
|
414
|
+
651767980,
|
|
415
|
+
1373503546,
|
|
416
|
+
3369554304,
|
|
417
|
+
3218104598,
|
|
418
|
+
565507253,
|
|
419
|
+
1454621731,
|
|
420
|
+
3485111705,
|
|
421
|
+
3099436303,
|
|
422
|
+
671266974,
|
|
423
|
+
1594198024,
|
|
424
|
+
3322730930,
|
|
425
|
+
2970347812,
|
|
426
|
+
795835527,
|
|
427
|
+
1483230225,
|
|
428
|
+
3244367275,
|
|
429
|
+
3060149565,
|
|
430
|
+
1994146192,
|
|
431
|
+
31158534,
|
|
432
|
+
2563907772,
|
|
433
|
+
4023717930,
|
|
434
|
+
1907459465,
|
|
435
|
+
112637215,
|
|
436
|
+
2680153253,
|
|
437
|
+
3904427059,
|
|
438
|
+
2013776290,
|
|
439
|
+
251722036,
|
|
440
|
+
2517215374,
|
|
441
|
+
3775830040,
|
|
442
|
+
2137656763,
|
|
443
|
+
141376813,
|
|
444
|
+
2439277719,
|
|
445
|
+
3865271297,
|
|
446
|
+
1802195444,
|
|
447
|
+
476864866,
|
|
448
|
+
2238001368,
|
|
449
|
+
4066508878,
|
|
450
|
+
1812370925,
|
|
451
|
+
453092731,
|
|
452
|
+
2181625025,
|
|
453
|
+
4111451223,
|
|
454
|
+
1706088902,
|
|
455
|
+
314042704,
|
|
456
|
+
2344532202,
|
|
457
|
+
4240017532,
|
|
458
|
+
1658658271,
|
|
459
|
+
366619977,
|
|
460
|
+
2362670323,
|
|
461
|
+
4224994405,
|
|
462
|
+
1303535960,
|
|
463
|
+
984961486,
|
|
464
|
+
2747007092,
|
|
465
|
+
3569037538,
|
|
466
|
+
1256170817,
|
|
467
|
+
1037604311,
|
|
468
|
+
2765210733,
|
|
469
|
+
3554079995,
|
|
470
|
+
1131014506,
|
|
471
|
+
879679996,
|
|
472
|
+
2909243462,
|
|
473
|
+
3663771856,
|
|
474
|
+
1141124467,
|
|
475
|
+
855842277,
|
|
476
|
+
2852801631,
|
|
477
|
+
3708648649,
|
|
478
|
+
1342533948,
|
|
479
|
+
654459306,
|
|
480
|
+
3188396048,
|
|
481
|
+
3373015174,
|
|
482
|
+
1466479909,
|
|
483
|
+
544179635,
|
|
484
|
+
3110523913,
|
|
485
|
+
3462522015,
|
|
486
|
+
1591671054,
|
|
487
|
+
702138776,
|
|
488
|
+
2966460450,
|
|
489
|
+
3352799412,
|
|
490
|
+
1504918807,
|
|
491
|
+
783551873,
|
|
492
|
+
3082640443,
|
|
493
|
+
3233442989,
|
|
494
|
+
3988292384,
|
|
495
|
+
2596254646,
|
|
496
|
+
62317068,
|
|
497
|
+
1957810842,
|
|
498
|
+
3939845945,
|
|
499
|
+
2647816111,
|
|
500
|
+
81470997,
|
|
501
|
+
1943803523,
|
|
502
|
+
3814918930,
|
|
503
|
+
2489596804,
|
|
504
|
+
225274430,
|
|
505
|
+
2053790376,
|
|
506
|
+
3826175755,
|
|
507
|
+
2466906013,
|
|
508
|
+
167816743,
|
|
509
|
+
2097651377,
|
|
510
|
+
4027552580,
|
|
511
|
+
2265490386,
|
|
512
|
+
503444072,
|
|
513
|
+
1762050814,
|
|
514
|
+
4150417245,
|
|
515
|
+
2154129355,
|
|
516
|
+
426522225,
|
|
517
|
+
1852507879,
|
|
518
|
+
4275313526,
|
|
519
|
+
2312317920,
|
|
520
|
+
282753626,
|
|
521
|
+
1742555852,
|
|
522
|
+
4189708143,
|
|
523
|
+
2394877945,
|
|
524
|
+
397917763,
|
|
525
|
+
1622183637,
|
|
526
|
+
3604390888,
|
|
527
|
+
2714866558,
|
|
528
|
+
953729732,
|
|
529
|
+
1340076626,
|
|
530
|
+
3518719985,
|
|
531
|
+
2797360999,
|
|
532
|
+
1068828381,
|
|
533
|
+
1219638859,
|
|
534
|
+
3624741850,
|
|
535
|
+
2936675148,
|
|
536
|
+
906185462,
|
|
537
|
+
1090812512,
|
|
538
|
+
3747672003,
|
|
539
|
+
2825379669,
|
|
540
|
+
829329135,
|
|
541
|
+
1181335161,
|
|
542
|
+
3412177804,
|
|
543
|
+
3160834842,
|
|
544
|
+
628085408,
|
|
545
|
+
1382605366,
|
|
546
|
+
3423369109,
|
|
547
|
+
3138078467,
|
|
548
|
+
570562233,
|
|
549
|
+
1426400815,
|
|
550
|
+
3317316542,
|
|
551
|
+
2998733608,
|
|
552
|
+
733239954,
|
|
553
|
+
1555261956,
|
|
554
|
+
3268935591,
|
|
555
|
+
3050360625,
|
|
556
|
+
752459403,
|
|
557
|
+
1541320221,
|
|
558
|
+
2607071920,
|
|
559
|
+
3965973030,
|
|
560
|
+
1969922972,
|
|
561
|
+
40735498,
|
|
562
|
+
2617837225,
|
|
563
|
+
3943577151,
|
|
564
|
+
1913087877,
|
|
565
|
+
83908371,
|
|
566
|
+
2512341634,
|
|
567
|
+
3803740692,
|
|
568
|
+
2075208622,
|
|
569
|
+
213261112,
|
|
570
|
+
2463272603,
|
|
571
|
+
3855990285,
|
|
572
|
+
2094854071,
|
|
573
|
+
198958881,
|
|
574
|
+
2262029012,
|
|
575
|
+
4057260610,
|
|
576
|
+
1759359992,
|
|
577
|
+
534414190,
|
|
578
|
+
2176718541,
|
|
579
|
+
4139329115,
|
|
580
|
+
1873836001,
|
|
581
|
+
414664567,
|
|
582
|
+
2282248934,
|
|
583
|
+
4279200368,
|
|
584
|
+
1711684554,
|
|
585
|
+
285281116,
|
|
586
|
+
2405801727,
|
|
587
|
+
4167216745,
|
|
588
|
+
1634467795,
|
|
589
|
+
376229701,
|
|
590
|
+
2685067896,
|
|
591
|
+
3608007406,
|
|
592
|
+
1308918612,
|
|
593
|
+
956543938,
|
|
594
|
+
2808555105,
|
|
595
|
+
3495958263,
|
|
596
|
+
1231636301,
|
|
597
|
+
1047427035,
|
|
598
|
+
2932959818,
|
|
599
|
+
3654703836,
|
|
600
|
+
1088359270,
|
|
601
|
+
936918000,
|
|
602
|
+
2847714899,
|
|
603
|
+
3736837829,
|
|
604
|
+
1202900863,
|
|
605
|
+
817233897,
|
|
606
|
+
3183342108,
|
|
607
|
+
3401237130,
|
|
608
|
+
1404277552,
|
|
609
|
+
615818150,
|
|
610
|
+
3134207493,
|
|
611
|
+
3453421203,
|
|
612
|
+
1423857449,
|
|
613
|
+
601450431,
|
|
614
|
+
3009837614,
|
|
615
|
+
3294710456,
|
|
616
|
+
1567103746,
|
|
617
|
+
711928724,
|
|
618
|
+
3020668471,
|
|
619
|
+
3272380065,
|
|
620
|
+
1510334235,
|
|
621
|
+
755167117
|
|
622
|
+
];
|
|
623
|
+
if (typeof Int32Array !== "undefined") {
|
|
624
|
+
CRC_TABLE = new Int32Array(CRC_TABLE);
|
|
625
|
+
}
|
|
626
|
+
function ensureBuffer(input) {
|
|
627
|
+
if (Buffer2.isBuffer(input)) {
|
|
628
|
+
return input;
|
|
629
|
+
}
|
|
630
|
+
var hasNewBufferAPI = typeof Buffer2.alloc === "function" && typeof Buffer2.from === "function";
|
|
631
|
+
if (typeof input === "number") {
|
|
632
|
+
return hasNewBufferAPI ? Buffer2.alloc(input) : new Buffer2(input);
|
|
633
|
+
} else if (typeof input === "string") {
|
|
634
|
+
return hasNewBufferAPI ? Buffer2.from(input) : new Buffer2(input);
|
|
635
|
+
} else {
|
|
636
|
+
throw new Error("input must be buffer, number, or string, received " + typeof input);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
function bufferizeInt(num) {
|
|
640
|
+
var tmp = ensureBuffer(4);
|
|
641
|
+
tmp.writeInt32BE(num, 0);
|
|
642
|
+
return tmp;
|
|
643
|
+
}
|
|
644
|
+
function _crc32(buf, previous) {
|
|
645
|
+
buf = ensureBuffer(buf);
|
|
646
|
+
if (Buffer2.isBuffer(previous)) {
|
|
647
|
+
previous = previous.readUInt32BE(0);
|
|
648
|
+
}
|
|
649
|
+
var crc = ~~previous ^ -1;
|
|
650
|
+
for (var n = 0;n < buf.length; n++) {
|
|
651
|
+
crc = CRC_TABLE[(crc ^ buf[n]) & 255] ^ crc >>> 8;
|
|
652
|
+
}
|
|
653
|
+
return crc ^ -1;
|
|
654
|
+
}
|
|
655
|
+
function crc32() {
|
|
656
|
+
return bufferizeInt(_crc32.apply(null, arguments));
|
|
657
|
+
}
|
|
658
|
+
crc32.signed = function() {
|
|
659
|
+
return _crc32.apply(null, arguments);
|
|
660
|
+
};
|
|
661
|
+
crc32.unsigned = function() {
|
|
662
|
+
return _crc32.apply(null, arguments) >>> 0;
|
|
663
|
+
};
|
|
664
|
+
module.exports = crc32;
|
|
665
|
+
});
|
|
666
|
+
|
|
14
667
|
// src/index.ts
|
|
15
668
|
import execa2 from "execa";
|
|
16
669
|
|
|
@@ -383,10 +1036,10 @@ var verboseTag = (str) => {
|
|
|
383
1036
|
return isColorSupported() ? chalk.bgBlack(` ${str} `) : `[${str}]`;
|
|
384
1037
|
};
|
|
385
1038
|
var Log = {
|
|
386
|
-
formatLogs: (logLevel,
|
|
1039
|
+
formatLogs: (logLevel, options2, args) => {
|
|
387
1040
|
return [
|
|
388
|
-
|
|
389
|
-
|
|
1041
|
+
options2.indent ? INDENT_TOKEN : null,
|
|
1042
|
+
options2.tag ? verboseTag(options2.tag) : null
|
|
390
1043
|
].filter(truthy).concat(args.map((a) => {
|
|
391
1044
|
if (logLevel === "warn") {
|
|
392
1045
|
return chalk.yellow(a);
|
|
@@ -400,54 +1053,54 @@ var Log = {
|
|
|
400
1053
|
return a;
|
|
401
1054
|
}));
|
|
402
1055
|
},
|
|
403
|
-
trace: (
|
|
1056
|
+
trace: (options2, ...args) => {
|
|
404
1057
|
writeInRepro("trace", ...args);
|
|
405
|
-
if (isEqualOrBelowLogLevel(
|
|
1058
|
+
if (isEqualOrBelowLogLevel(options2.logLevel, "trace")) {
|
|
406
1059
|
if (args.length === 0) {
|
|
407
1060
|
return process.stdout.write(`
|
|
408
1061
|
`);
|
|
409
1062
|
}
|
|
410
|
-
return console.log(...Log.formatLogs("trace",
|
|
1063
|
+
return console.log(...Log.formatLogs("trace", options2, args));
|
|
411
1064
|
}
|
|
412
1065
|
},
|
|
413
|
-
verbose: (
|
|
1066
|
+
verbose: (options2, ...args) => {
|
|
414
1067
|
writeInRepro("verbose", ...args);
|
|
415
|
-
if (isEqualOrBelowLogLevel(
|
|
1068
|
+
if (isEqualOrBelowLogLevel(options2.logLevel, "verbose")) {
|
|
416
1069
|
if (args.length === 0) {
|
|
417
1070
|
return process.stdout.write(`
|
|
418
1071
|
`);
|
|
419
1072
|
}
|
|
420
|
-
return console.log(...Log.formatLogs("verbose",
|
|
1073
|
+
return console.log(...Log.formatLogs("verbose", options2, args));
|
|
421
1074
|
}
|
|
422
1075
|
},
|
|
423
|
-
info: (
|
|
1076
|
+
info: (options2, ...args) => {
|
|
424
1077
|
writeInRepro("info", ...args);
|
|
425
|
-
if (isEqualOrBelowLogLevel(
|
|
1078
|
+
if (isEqualOrBelowLogLevel(options2.logLevel, "info")) {
|
|
426
1079
|
if (args.length === 0) {
|
|
427
1080
|
return process.stdout.write(`
|
|
428
1081
|
`);
|
|
429
1082
|
}
|
|
430
|
-
return console.log(...Log.formatLogs("info",
|
|
1083
|
+
return console.log(...Log.formatLogs("info", options2, args));
|
|
431
1084
|
}
|
|
432
1085
|
},
|
|
433
|
-
warn: (
|
|
1086
|
+
warn: (options2, ...args) => {
|
|
434
1087
|
writeInRepro("warn", ...args);
|
|
435
|
-
if (isEqualOrBelowLogLevel(
|
|
1088
|
+
if (isEqualOrBelowLogLevel(options2.logLevel, "warn")) {
|
|
436
1089
|
if (args.length === 0) {
|
|
437
1090
|
return process.stdout.write(`
|
|
438
1091
|
`);
|
|
439
1092
|
}
|
|
440
|
-
return console.warn(...Log.formatLogs("warn",
|
|
1093
|
+
return console.warn(...Log.formatLogs("warn", options2, args));
|
|
441
1094
|
}
|
|
442
1095
|
},
|
|
443
|
-
error: (
|
|
1096
|
+
error: (options2, ...args) => {
|
|
444
1097
|
writeInRepro("error", ...args);
|
|
445
|
-
if (isEqualOrBelowLogLevel(
|
|
1098
|
+
if (isEqualOrBelowLogLevel(options2.logLevel, "error")) {
|
|
446
1099
|
if (args.length === 0) {
|
|
447
1100
|
return process.stdout.write(`
|
|
448
1101
|
`);
|
|
449
1102
|
}
|
|
450
|
-
return console.error(...Log.formatLogs("error",
|
|
1103
|
+
return console.error(...Log.formatLogs("error", options2, args));
|
|
451
1104
|
}
|
|
452
1105
|
}
|
|
453
1106
|
};
|
|
@@ -655,9 +1308,9 @@ var downloadFileWithoutRetries = ({
|
|
|
655
1308
|
});
|
|
656
1309
|
});
|
|
657
1310
|
};
|
|
658
|
-
var downloadFile = async (
|
|
1311
|
+
var downloadFile = async (options2, retries = 2, attempt = 1) => {
|
|
659
1312
|
try {
|
|
660
|
-
const res = await downloadFileWithoutRetries(
|
|
1313
|
+
const res = await downloadFileWithoutRetries(options2);
|
|
661
1314
|
return res;
|
|
662
1315
|
} catch (err) {
|
|
663
1316
|
const { message } = err;
|
|
@@ -668,12 +1321,12 @@ var downloadFile = async (options, retries = 2, attempt = 1) => {
|
|
|
668
1321
|
if (retries === 0) {
|
|
669
1322
|
throw err;
|
|
670
1323
|
}
|
|
671
|
-
Log.warn({ indent:
|
|
1324
|
+
Log.warn({ indent: options2.indent, logLevel: options2.logLevel }, `Downloading ${options2.url} failed (will retry): ${message}`);
|
|
672
1325
|
const backoffInSeconds = (attempt + 1) ** 2;
|
|
673
1326
|
await new Promise((resolve) => {
|
|
674
1327
|
setTimeout(() => resolve(), backoffInSeconds * 1000);
|
|
675
1328
|
});
|
|
676
|
-
return downloadFile(
|
|
1329
|
+
return downloadFile(options2, retries - 1, attempt + 1);
|
|
677
1330
|
}
|
|
678
1331
|
throw err;
|
|
679
1332
|
}
|
|
@@ -1445,30 +2098,30 @@ class WaitTask {
|
|
|
1445
2098
|
#terminated = false;
|
|
1446
2099
|
#browser;
|
|
1447
2100
|
promise;
|
|
1448
|
-
constructor(
|
|
2101
|
+
constructor(options2) {
|
|
1449
2102
|
function getPredicateBody(predicateBody) {
|
|
1450
2103
|
if (isString(predicateBody)) {
|
|
1451
2104
|
return `return (${predicateBody});`;
|
|
1452
2105
|
}
|
|
1453
2106
|
return `return (${predicateBody})(...args);`;
|
|
1454
2107
|
}
|
|
1455
|
-
this.#domWorld =
|
|
1456
|
-
this.#timeout =
|
|
1457
|
-
this.#predicateBody = getPredicateBody(
|
|
1458
|
-
this.#args =
|
|
2108
|
+
this.#domWorld = options2.domWorld;
|
|
2109
|
+
this.#timeout = options2.timeout;
|
|
2110
|
+
this.#predicateBody = getPredicateBody(options2.predicateBody);
|
|
2111
|
+
this.#args = options2.args;
|
|
1459
2112
|
this.#runCount = 0;
|
|
1460
2113
|
this.#domWorld._waitTasks.add(this);
|
|
1461
2114
|
this.promise = new Promise((resolve, reject) => {
|
|
1462
2115
|
this.#resolve = resolve;
|
|
1463
2116
|
this.#reject = reject;
|
|
1464
2117
|
});
|
|
1465
|
-
if (
|
|
1466
|
-
const timeoutError = new TimeoutError(`waiting for ${
|
|
2118
|
+
if (options2.timeout) {
|
|
2119
|
+
const timeoutError = new TimeoutError(`waiting for ${options2.title} failed: timeout ${options2.timeout}ms exceeded`);
|
|
1467
2120
|
this.#timeoutTimer = setTimeout(() => {
|
|
1468
2121
|
return this.#reject(timeoutError);
|
|
1469
|
-
},
|
|
2122
|
+
}, options2.timeout);
|
|
1470
2123
|
}
|
|
1471
|
-
this.#browser =
|
|
2124
|
+
this.#browser = options2.browser;
|
|
1472
2125
|
this.#browser.on("closed" /* Closed */, this.onBrowserClose);
|
|
1473
2126
|
this.#browser.on("closed-silent" /* ClosedSilent */, this.onBrowserCloseSilent);
|
|
1474
2127
|
this.rerun();
|
|
@@ -2352,8 +3005,8 @@ class FrameManager extends EventEmitter {
|
|
|
2352
3005
|
networkManager() {
|
|
2353
3006
|
return this.#networkManager;
|
|
2354
3007
|
}
|
|
2355
|
-
async navigateFrame(frame, url, timeout,
|
|
2356
|
-
const { referer = undefined, waitUntil = "load" } =
|
|
3008
|
+
async navigateFrame(frame, url, timeout, options2 = {}) {
|
|
3009
|
+
const { referer = undefined, waitUntil = "load" } = options2;
|
|
2357
3010
|
const watcher = new LifecycleWatcher(this, frame, waitUntil, timeout);
|
|
2358
3011
|
let error = await Promise.race([
|
|
2359
3012
|
navigate(this.#client, url, referer, frame._id),
|
|
@@ -2630,8 +3283,8 @@ class Frame {
|
|
|
2630
3283
|
isOOPFrame() {
|
|
2631
3284
|
return this.#client !== this._frameManager._client;
|
|
2632
3285
|
}
|
|
2633
|
-
goto(url, timeout,
|
|
2634
|
-
return this._frameManager.navigateFrame(this, url, timeout,
|
|
3286
|
+
goto(url, timeout, options2 = {}) {
|
|
3287
|
+
return this._frameManager.navigateFrame(this, url, timeout, options2);
|
|
2635
3288
|
}
|
|
2636
3289
|
_client() {
|
|
2637
3290
|
return this.#client;
|
|
@@ -3065,9 +3718,9 @@ class Page extends EventEmitter {
|
|
|
3065
3718
|
goto({
|
|
3066
3719
|
url,
|
|
3067
3720
|
timeout,
|
|
3068
|
-
options = {}
|
|
3721
|
+
options: options2 = {}
|
|
3069
3722
|
}) {
|
|
3070
|
-
return this.#frameManager.mainFrame().goto(url, timeout,
|
|
3723
|
+
return this.#frameManager.mainFrame().goto(url, timeout, options2);
|
|
3071
3724
|
}
|
|
3072
3725
|
async bringToFront() {
|
|
3073
3726
|
await this.#client.send("Page.bringToFront");
|
|
@@ -3093,12 +3746,12 @@ class Page extends EventEmitter {
|
|
|
3093
3746
|
source
|
|
3094
3747
|
});
|
|
3095
3748
|
}
|
|
3096
|
-
async close(
|
|
3749
|
+
async close(options2 = { runBeforeUnload: undefined }) {
|
|
3097
3750
|
const connection = this.#client.connection();
|
|
3098
3751
|
if (!connection) {
|
|
3099
3752
|
return;
|
|
3100
3753
|
}
|
|
3101
|
-
const runBeforeUnload = Boolean(
|
|
3754
|
+
const runBeforeUnload = Boolean(options2.runBeforeUnload);
|
|
3102
3755
|
if (runBeforeUnload) {
|
|
3103
3756
|
await this.#client.send("Page.close");
|
|
3104
3757
|
} else {
|
|
@@ -3809,8 +4462,8 @@ class HeadlessBrowser extends EventEmitter {
|
|
|
3809
4462
|
return target._isInitialized;
|
|
3810
4463
|
});
|
|
3811
4464
|
}
|
|
3812
|
-
async waitForTarget(predicate,
|
|
3813
|
-
const { timeout = 30000 } =
|
|
4465
|
+
async waitForTarget(predicate, options2 = {}) {
|
|
4466
|
+
const { timeout = 30000 } = options2;
|
|
3814
4467
|
let resolve;
|
|
3815
4468
|
let isResolved = false;
|
|
3816
4469
|
const targetPromise = new Promise((x) => {
|
|
@@ -3868,10 +4521,10 @@ class BrowserContext extends EventEmitter {
|
|
|
3868
4521
|
return target.browserContext() === this;
|
|
3869
4522
|
});
|
|
3870
4523
|
}
|
|
3871
|
-
waitForTarget(predicate,
|
|
4524
|
+
waitForTarget(predicate, options2 = {}) {
|
|
3872
4525
|
return this.#browser.waitForTarget((target) => {
|
|
3873
4526
|
return target.browserContext() === this && predicate(target);
|
|
3874
|
-
},
|
|
4527
|
+
}, options2);
|
|
3875
4528
|
}
|
|
3876
4529
|
async pages() {
|
|
3877
4530
|
const pages = await Promise.all(this.targets().filter((target) => target.type() === "page").map((target) => target.expectPage()));
|
|
@@ -4047,7 +4700,7 @@ var callFf = ({
|
|
|
4047
4700
|
bin,
|
|
4048
4701
|
indent,
|
|
4049
4702
|
logLevel,
|
|
4050
|
-
options,
|
|
4703
|
+
options: options2,
|
|
4051
4704
|
binariesDirectory,
|
|
4052
4705
|
cancelSignal
|
|
4053
4706
|
}) => {
|
|
@@ -4062,7 +4715,7 @@ var callFf = ({
|
|
|
4062
4715
|
const task = execa(executablePath, args.filter(truthy), {
|
|
4063
4716
|
cwd,
|
|
4064
4717
|
env: getExplicitEnv(cwd),
|
|
4065
|
-
...
|
|
4718
|
+
...options2
|
|
4066
4719
|
});
|
|
4067
4720
|
cancelSignal?.(() => {
|
|
4068
4721
|
task.kill();
|
|
@@ -4074,7 +4727,7 @@ var callFfNative = ({
|
|
|
4074
4727
|
bin,
|
|
4075
4728
|
indent,
|
|
4076
4729
|
logLevel,
|
|
4077
|
-
options,
|
|
4730
|
+
options: options2,
|
|
4078
4731
|
binariesDirectory,
|
|
4079
4732
|
cancelSignal
|
|
4080
4733
|
}) => {
|
|
@@ -4089,7 +4742,7 @@ var callFfNative = ({
|
|
|
4089
4742
|
const task = spawn2(executablePath, args.filter(truthy), {
|
|
4090
4743
|
cwd,
|
|
4091
4744
|
env: getExplicitEnv(cwd),
|
|
4092
|
-
...
|
|
4745
|
+
...options2
|
|
4093
4746
|
});
|
|
4094
4747
|
cancelSignal?.(() => {
|
|
4095
4748
|
task.kill();
|
|
@@ -4791,9 +5444,9 @@ var defaultOnLog = ({ logLevel, tag, previewString }) => {
|
|
|
4791
5444
|
};
|
|
4792
5445
|
|
|
4793
5446
|
// src/open-browser.ts
|
|
4794
|
-
import
|
|
5447
|
+
import fs11 from "node:fs";
|
|
4795
5448
|
import os6 from "node:os";
|
|
4796
|
-
import
|
|
5449
|
+
import path10 from "node:path";
|
|
4797
5450
|
|
|
4798
5451
|
// src/browser/Launcher.ts
|
|
4799
5452
|
var launchChrome = async ({
|
|
@@ -4826,17 +5479,909 @@ var launchChrome = async ({
|
|
|
4826
5479
|
};
|
|
4827
5480
|
|
|
4828
5481
|
// src/ensure-browser.ts
|
|
4829
|
-
import
|
|
5482
|
+
import fs9 from "fs";
|
|
4830
5483
|
|
|
4831
5484
|
// src/browser/BrowserFetcher.ts
|
|
4832
|
-
import * as
|
|
5485
|
+
import * as fs8 from "node:fs";
|
|
4833
5486
|
import * as os4 from "node:os";
|
|
4834
|
-
import * as
|
|
5487
|
+
import * as path9 from "node:path";
|
|
5488
|
+
import { promisify as promisify2 } from "node:util";
|
|
5489
|
+
|
|
5490
|
+
// src/browser/extract-zip-archive.ts
|
|
5491
|
+
import { createWriteStream as createWriteStream2 } from "node:fs";
|
|
5492
|
+
import { mkdir, realpath, symlink } from "node:fs/promises";
|
|
5493
|
+
import * as path7 from "node:path";
|
|
5494
|
+
import { buffer } from "node:stream/consumers";
|
|
5495
|
+
import { pipeline } from "node:stream/promises";
|
|
4835
5496
|
import { promisify } from "node:util";
|
|
4836
|
-
|
|
5497
|
+
|
|
5498
|
+
// vendor/yauzl-patched/index.js
|
|
5499
|
+
var fs5 = __require("fs");
|
|
5500
|
+
var zlib = __require("zlib");
|
|
5501
|
+
var fd_slicer = require_fd_slicer();
|
|
5502
|
+
var crc32 = require_buffer_crc32();
|
|
5503
|
+
var util = __require("util");
|
|
5504
|
+
var EventEmitter2 = __require("events").EventEmitter;
|
|
5505
|
+
var Transform = __require("stream").Transform;
|
|
5506
|
+
var PassThrough = __require("stream").PassThrough;
|
|
5507
|
+
var Writable = __require("stream").Writable;
|
|
5508
|
+
var $open = open;
|
|
5509
|
+
function open(path7, options2, callback) {
|
|
5510
|
+
if (typeof options2 === "function") {
|
|
5511
|
+
callback = options2;
|
|
5512
|
+
options2 = null;
|
|
5513
|
+
}
|
|
5514
|
+
if (options2 == null)
|
|
5515
|
+
options2 = {};
|
|
5516
|
+
if (options2.autoClose == null)
|
|
5517
|
+
options2.autoClose = true;
|
|
5518
|
+
if (options2.lazyEntries == null)
|
|
5519
|
+
options2.lazyEntries = false;
|
|
5520
|
+
if (options2.decodeStrings == null)
|
|
5521
|
+
options2.decodeStrings = true;
|
|
5522
|
+
if (options2.validateEntrySizes == null)
|
|
5523
|
+
options2.validateEntrySizes = true;
|
|
5524
|
+
if (options2.strictFileNames == null)
|
|
5525
|
+
options2.strictFileNames = false;
|
|
5526
|
+
if (callback == null)
|
|
5527
|
+
callback = defaultCallback;
|
|
5528
|
+
fs5.open(path7, "r", function(err, fd) {
|
|
5529
|
+
if (err)
|
|
5530
|
+
return callback(err);
|
|
5531
|
+
fromFd(fd, options2, function(err2, zipfile) {
|
|
5532
|
+
if (err2)
|
|
5533
|
+
fs5.close(fd, defaultCallback);
|
|
5534
|
+
callback(err2, zipfile);
|
|
5535
|
+
});
|
|
5536
|
+
});
|
|
5537
|
+
}
|
|
5538
|
+
function fromFd(fd, options2, callback) {
|
|
5539
|
+
if (typeof options2 === "function") {
|
|
5540
|
+
callback = options2;
|
|
5541
|
+
options2 = null;
|
|
5542
|
+
}
|
|
5543
|
+
if (options2 == null)
|
|
5544
|
+
options2 = {};
|
|
5545
|
+
if (options2.autoClose == null)
|
|
5546
|
+
options2.autoClose = false;
|
|
5547
|
+
if (options2.lazyEntries == null)
|
|
5548
|
+
options2.lazyEntries = false;
|
|
5549
|
+
if (options2.decodeStrings == null)
|
|
5550
|
+
options2.decodeStrings = true;
|
|
5551
|
+
if (options2.validateEntrySizes == null)
|
|
5552
|
+
options2.validateEntrySizes = true;
|
|
5553
|
+
if (options2.strictFileNames == null)
|
|
5554
|
+
options2.strictFileNames = false;
|
|
5555
|
+
if (callback == null)
|
|
5556
|
+
callback = defaultCallback;
|
|
5557
|
+
fs5.fstat(fd, function(err, stats) {
|
|
5558
|
+
if (err)
|
|
5559
|
+
return callback(err);
|
|
5560
|
+
var reader = fd_slicer.createFromFd(fd, { autoClose: true });
|
|
5561
|
+
fromRandomAccessReader(reader, stats.size, options2, callback);
|
|
5562
|
+
});
|
|
5563
|
+
}
|
|
5564
|
+
function fromRandomAccessReader(reader, totalSize, options2, callback) {
|
|
5565
|
+
if (typeof options2 === "function") {
|
|
5566
|
+
callback = options2;
|
|
5567
|
+
options2 = null;
|
|
5568
|
+
}
|
|
5569
|
+
if (options2 == null)
|
|
5570
|
+
options2 = {};
|
|
5571
|
+
if (options2.autoClose == null)
|
|
5572
|
+
options2.autoClose = true;
|
|
5573
|
+
if (options2.lazyEntries == null)
|
|
5574
|
+
options2.lazyEntries = false;
|
|
5575
|
+
if (options2.decodeStrings == null)
|
|
5576
|
+
options2.decodeStrings = true;
|
|
5577
|
+
var decodeStrings = !!options2.decodeStrings;
|
|
5578
|
+
if (options2.validateEntrySizes == null)
|
|
5579
|
+
options2.validateEntrySizes = true;
|
|
5580
|
+
if (options2.strictFileNames == null)
|
|
5581
|
+
options2.strictFileNames = false;
|
|
5582
|
+
if (callback == null)
|
|
5583
|
+
callback = defaultCallback;
|
|
5584
|
+
if (typeof totalSize !== "number")
|
|
5585
|
+
throw new Error("expected totalSize parameter to be a number");
|
|
5586
|
+
if (totalSize > Number.MAX_SAFE_INTEGER) {
|
|
5587
|
+
throw new Error("zip file too large. only file sizes up to 2^52 are supported due to JavaScript's Number type being an IEEE 754 double.");
|
|
5588
|
+
}
|
|
5589
|
+
reader.ref();
|
|
5590
|
+
var eocdrWithoutCommentSize = 22;
|
|
5591
|
+
var zip64EocdlSize = 20;
|
|
5592
|
+
var maxCommentSize = 65535;
|
|
5593
|
+
var bufferSize = Math.min(zip64EocdlSize + eocdrWithoutCommentSize + maxCommentSize, totalSize);
|
|
5594
|
+
var buffer = newBuffer(bufferSize);
|
|
5595
|
+
var bufferReadStart = totalSize - buffer.length;
|
|
5596
|
+
readAndAssertNoEof(reader, buffer, 0, bufferSize, bufferReadStart, function(err) {
|
|
5597
|
+
if (err)
|
|
5598
|
+
return callback(err);
|
|
5599
|
+
for (var i = bufferSize - eocdrWithoutCommentSize;i >= 0; i -= 1) {
|
|
5600
|
+
if (buffer.readUInt32LE(i) !== 101010256)
|
|
5601
|
+
continue;
|
|
5602
|
+
var eocdrBuffer = buffer.subarray(i);
|
|
5603
|
+
var diskNumber = eocdrBuffer.readUInt16LE(4);
|
|
5604
|
+
var entryCount = eocdrBuffer.readUInt16LE(10);
|
|
5605
|
+
var centralDirectoryOffset = eocdrBuffer.readUInt32LE(16);
|
|
5606
|
+
var commentLength = eocdrBuffer.readUInt16LE(20);
|
|
5607
|
+
var expectedCommentLength = eocdrBuffer.length - eocdrWithoutCommentSize;
|
|
5608
|
+
if (commentLength !== expectedCommentLength) {
|
|
5609
|
+
return callback(new Error("Invalid comment length. Expected: " + expectedCommentLength + ". Found: " + commentLength + ". Are there extra bytes at the end of the file? Or is the end of central dir signature `PK☺☻` in the comment?"));
|
|
5610
|
+
}
|
|
5611
|
+
var comment = decodeStrings ? decodeBuffer(eocdrBuffer.subarray(22), false) : eocdrBuffer.subarray(22);
|
|
5612
|
+
if (i - zip64EocdlSize >= 0 && buffer.readUInt32LE(i - zip64EocdlSize) === 117853008) {
|
|
5613
|
+
var zip64EocdlBuffer = buffer.subarray(i - zip64EocdlSize, i - zip64EocdlSize + zip64EocdlSize);
|
|
5614
|
+
var zip64EocdrOffset = readUInt64LE(zip64EocdlBuffer, 8);
|
|
5615
|
+
var zip64EocdrBuffer = newBuffer(56);
|
|
5616
|
+
return readAndAssertNoEof(reader, zip64EocdrBuffer, 0, zip64EocdrBuffer.length, zip64EocdrOffset, function(err2) {
|
|
5617
|
+
if (err2)
|
|
5618
|
+
return callback(err2);
|
|
5619
|
+
if (zip64EocdrBuffer.readUInt32LE(0) !== 101075792) {
|
|
5620
|
+
return callback(new Error("invalid zip64 end of central directory record signature"));
|
|
5621
|
+
}
|
|
5622
|
+
diskNumber = zip64EocdrBuffer.readUInt32LE(16);
|
|
5623
|
+
if (diskNumber !== 0) {
|
|
5624
|
+
return callback(new Error("multi-disk zip files are not supported: found disk number: " + diskNumber));
|
|
5625
|
+
}
|
|
5626
|
+
entryCount = readUInt64LE(zip64EocdrBuffer, 32);
|
|
5627
|
+
centralDirectoryOffset = readUInt64LE(zip64EocdrBuffer, 48);
|
|
5628
|
+
return callback(null, new ZipFile(reader, centralDirectoryOffset, totalSize, entryCount, comment, options2.autoClose, options2.lazyEntries, decodeStrings, options2.validateEntrySizes, options2.strictFileNames));
|
|
5629
|
+
});
|
|
5630
|
+
}
|
|
5631
|
+
if (diskNumber !== 0) {
|
|
5632
|
+
return callback(new Error("multi-disk zip files are not supported: found disk number: " + diskNumber));
|
|
5633
|
+
}
|
|
5634
|
+
return callback(null, new ZipFile(reader, centralDirectoryOffset, totalSize, entryCount, comment, options2.autoClose, options2.lazyEntries, decodeStrings, options2.validateEntrySizes, options2.strictFileNames));
|
|
5635
|
+
}
|
|
5636
|
+
callback(new Error("End of central directory record signature not found. Either not a zip file, or file is truncated."));
|
|
5637
|
+
});
|
|
5638
|
+
}
|
|
5639
|
+
util.inherits(ZipFile, EventEmitter2);
|
|
5640
|
+
function ZipFile(reader, centralDirectoryOffset, fileSize, entryCount, comment, autoClose, lazyEntries, decodeStrings, validateEntrySizes, strictFileNames) {
|
|
5641
|
+
var self = this;
|
|
5642
|
+
EventEmitter2.call(self);
|
|
5643
|
+
self.reader = reader;
|
|
5644
|
+
self.reader.on("error", function(err) {
|
|
5645
|
+
emitError(self, err);
|
|
5646
|
+
});
|
|
5647
|
+
self.reader.once("close", function() {
|
|
5648
|
+
self.emit("close");
|
|
5649
|
+
});
|
|
5650
|
+
self.readEntryCursor = centralDirectoryOffset;
|
|
5651
|
+
self.fileSize = fileSize;
|
|
5652
|
+
self.entryCount = entryCount;
|
|
5653
|
+
self.comment = comment;
|
|
5654
|
+
self.entriesRead = 0;
|
|
5655
|
+
self.autoClose = !!autoClose;
|
|
5656
|
+
self.lazyEntries = !!lazyEntries;
|
|
5657
|
+
self.decodeStrings = !!decodeStrings;
|
|
5658
|
+
self.validateEntrySizes = !!validateEntrySizes;
|
|
5659
|
+
self.strictFileNames = !!strictFileNames;
|
|
5660
|
+
self.isOpen = true;
|
|
5661
|
+
self.emittedError = false;
|
|
5662
|
+
if (!self.lazyEntries)
|
|
5663
|
+
self._readEntry();
|
|
5664
|
+
}
|
|
5665
|
+
ZipFile.prototype.close = function() {
|
|
5666
|
+
if (!this.isOpen)
|
|
5667
|
+
return;
|
|
5668
|
+
this.isOpen = false;
|
|
5669
|
+
this.reader.unref();
|
|
5670
|
+
};
|
|
5671
|
+
function emitErrorAndAutoClose(self, err) {
|
|
5672
|
+
if (self.autoClose)
|
|
5673
|
+
self.close();
|
|
5674
|
+
emitError(self, err);
|
|
5675
|
+
}
|
|
5676
|
+
function emitError(self, err) {
|
|
5677
|
+
if (self.emittedError)
|
|
5678
|
+
return;
|
|
5679
|
+
self.emittedError = true;
|
|
5680
|
+
self.emit("error", err);
|
|
5681
|
+
}
|
|
5682
|
+
ZipFile.prototype.readEntry = function() {
|
|
5683
|
+
if (!this.lazyEntries)
|
|
5684
|
+
throw new Error("readEntry() called without lazyEntries:true");
|
|
5685
|
+
this._readEntry();
|
|
5686
|
+
};
|
|
5687
|
+
ZipFile.prototype._readEntry = function() {
|
|
5688
|
+
var self = this;
|
|
5689
|
+
if (self.entryCount === self.entriesRead) {
|
|
5690
|
+
setImmediate(function() {
|
|
5691
|
+
if (self.autoClose)
|
|
5692
|
+
self.close();
|
|
5693
|
+
if (self.emittedError)
|
|
5694
|
+
return;
|
|
5695
|
+
self.emit("end");
|
|
5696
|
+
});
|
|
5697
|
+
return;
|
|
5698
|
+
}
|
|
5699
|
+
if (self.emittedError)
|
|
5700
|
+
return;
|
|
5701
|
+
var buffer = newBuffer(46);
|
|
5702
|
+
readAndAssertNoEof(self.reader, buffer, 0, buffer.length, self.readEntryCursor, function(err) {
|
|
5703
|
+
if (err)
|
|
5704
|
+
return emitErrorAndAutoClose(self, err);
|
|
5705
|
+
if (self.emittedError)
|
|
5706
|
+
return;
|
|
5707
|
+
var entry = new Entry;
|
|
5708
|
+
var signature = buffer.readUInt32LE(0);
|
|
5709
|
+
if (signature !== 33639248)
|
|
5710
|
+
return emitErrorAndAutoClose(self, new Error("invalid central directory file header signature: 0x" + signature.toString(16)));
|
|
5711
|
+
entry.versionMadeBy = buffer.readUInt16LE(4);
|
|
5712
|
+
entry.versionNeededToExtract = buffer.readUInt16LE(6);
|
|
5713
|
+
entry.generalPurposeBitFlag = buffer.readUInt16LE(8);
|
|
5714
|
+
entry.compressionMethod = buffer.readUInt16LE(10);
|
|
5715
|
+
entry.lastModFileTime = buffer.readUInt16LE(12);
|
|
5716
|
+
entry.lastModFileDate = buffer.readUInt16LE(14);
|
|
5717
|
+
entry.crc32 = buffer.readUInt32LE(16);
|
|
5718
|
+
entry.compressedSize = buffer.readUInt32LE(20);
|
|
5719
|
+
entry.uncompressedSize = buffer.readUInt32LE(24);
|
|
5720
|
+
entry.fileNameLength = buffer.readUInt16LE(28);
|
|
5721
|
+
entry.extraFieldLength = buffer.readUInt16LE(30);
|
|
5722
|
+
entry.fileCommentLength = buffer.readUInt16LE(32);
|
|
5723
|
+
entry.internalFileAttributes = buffer.readUInt16LE(36);
|
|
5724
|
+
entry.externalFileAttributes = buffer.readUInt32LE(38);
|
|
5725
|
+
entry.relativeOffsetOfLocalHeader = buffer.readUInt32LE(42);
|
|
5726
|
+
if (entry.generalPurposeBitFlag & 64)
|
|
5727
|
+
return emitErrorAndAutoClose(self, new Error("strong encryption is not supported"));
|
|
5728
|
+
self.readEntryCursor += 46;
|
|
5729
|
+
buffer = newBuffer(entry.fileNameLength + entry.extraFieldLength + entry.fileCommentLength);
|
|
5730
|
+
readAndAssertNoEof(self.reader, buffer, 0, buffer.length, self.readEntryCursor, function(err2) {
|
|
5731
|
+
if (err2)
|
|
5732
|
+
return emitErrorAndAutoClose(self, err2);
|
|
5733
|
+
if (self.emittedError)
|
|
5734
|
+
return;
|
|
5735
|
+
entry.fileNameRaw = buffer.subarray(0, entry.fileNameLength);
|
|
5736
|
+
var fileCommentStart = entry.fileNameLength + entry.extraFieldLength;
|
|
5737
|
+
entry.extraFieldRaw = buffer.subarray(entry.fileNameLength, fileCommentStart);
|
|
5738
|
+
entry.fileCommentRaw = buffer.subarray(fileCommentStart, fileCommentStart + entry.fileCommentLength);
|
|
5739
|
+
try {
|
|
5740
|
+
entry.extraFields = parseExtraFields(entry.extraFieldRaw);
|
|
5741
|
+
} catch (err3) {
|
|
5742
|
+
return emitErrorAndAutoClose(self, err3);
|
|
5743
|
+
}
|
|
5744
|
+
if (self.decodeStrings) {
|
|
5745
|
+
var isUtf8 = (entry.generalPurposeBitFlag & 2048) !== 0;
|
|
5746
|
+
entry.fileComment = decodeBuffer(entry.fileCommentRaw, isUtf8);
|
|
5747
|
+
entry.fileName = getFileNameLowLevel(entry.generalPurposeBitFlag, entry.fileNameRaw, entry.extraFields, self.strictFileNames);
|
|
5748
|
+
var errorMessage = validateFileName(entry.fileName);
|
|
5749
|
+
if (errorMessage != null)
|
|
5750
|
+
return emitErrorAndAutoClose(self, new Error(errorMessage));
|
|
5751
|
+
} else {
|
|
5752
|
+
entry.fileComment = entry.fileCommentRaw;
|
|
5753
|
+
entry.fileName = entry.fileNameRaw;
|
|
5754
|
+
}
|
|
5755
|
+
entry.comment = entry.fileComment;
|
|
5756
|
+
self.readEntryCursor += buffer.length;
|
|
5757
|
+
self.entriesRead += 1;
|
|
5758
|
+
for (var i = 0;i < entry.extraFields.length; i++) {
|
|
5759
|
+
var extraField = entry.extraFields[i];
|
|
5760
|
+
if (extraField.id !== 1)
|
|
5761
|
+
continue;
|
|
5762
|
+
var zip64EiefBuffer = extraField.data;
|
|
5763
|
+
var index = 0;
|
|
5764
|
+
if (entry.uncompressedSize === 4294967295) {
|
|
5765
|
+
if (index + 8 > zip64EiefBuffer.length) {
|
|
5766
|
+
return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include uncompressed size"));
|
|
5767
|
+
}
|
|
5768
|
+
entry.uncompressedSize = readUInt64LE(zip64EiefBuffer, index);
|
|
5769
|
+
index += 8;
|
|
5770
|
+
}
|
|
5771
|
+
if (entry.compressedSize === 4294967295) {
|
|
5772
|
+
if (index + 8 > zip64EiefBuffer.length) {
|
|
5773
|
+
return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include compressed size"));
|
|
5774
|
+
}
|
|
5775
|
+
entry.compressedSize = readUInt64LE(zip64EiefBuffer, index);
|
|
5776
|
+
index += 8;
|
|
5777
|
+
}
|
|
5778
|
+
if (entry.relativeOffsetOfLocalHeader === 4294967295) {
|
|
5779
|
+
if (index + 8 > zip64EiefBuffer.length) {
|
|
5780
|
+
return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include relative header offset"));
|
|
5781
|
+
}
|
|
5782
|
+
entry.relativeOffsetOfLocalHeader = readUInt64LE(zip64EiefBuffer, index);
|
|
5783
|
+
index += 8;
|
|
5784
|
+
}
|
|
5785
|
+
break;
|
|
5786
|
+
}
|
|
5787
|
+
if (self.validateEntrySizes && entry.compressionMethod === 0) {
|
|
5788
|
+
var expectedCompressedSize = entry.uncompressedSize;
|
|
5789
|
+
if (entry.isEncrypted()) {
|
|
5790
|
+
expectedCompressedSize += 12;
|
|
5791
|
+
}
|
|
5792
|
+
if (entry.compressedSize !== expectedCompressedSize) {
|
|
5793
|
+
var msg = "compressed/uncompressed size mismatch for stored file: " + entry.compressedSize + " != " + entry.uncompressedSize;
|
|
5794
|
+
return emitErrorAndAutoClose(self, new Error(msg));
|
|
5795
|
+
}
|
|
5796
|
+
}
|
|
5797
|
+
self.emit("entry", entry);
|
|
5798
|
+
if (!self.lazyEntries)
|
|
5799
|
+
self._readEntry();
|
|
5800
|
+
});
|
|
5801
|
+
});
|
|
5802
|
+
};
|
|
5803
|
+
ZipFile.prototype.openReadStream = function(entry, options2, callback) {
|
|
5804
|
+
var self = this;
|
|
5805
|
+
var relativeStart = 0;
|
|
5806
|
+
var relativeEnd = entry.compressedSize;
|
|
5807
|
+
if (callback == null) {
|
|
5808
|
+
callback = options2;
|
|
5809
|
+
options2 = null;
|
|
5810
|
+
}
|
|
5811
|
+
if (options2 == null) {
|
|
5812
|
+
options2 = {};
|
|
5813
|
+
} else {
|
|
5814
|
+
if (options2.decodeFileData === false) {
|
|
5815
|
+
if (options2.decrypt != null) {
|
|
5816
|
+
throw new Error("cannot use options.decrypt when options.decodeFileData === false");
|
|
5817
|
+
}
|
|
5818
|
+
if (options2.decompress != null) {
|
|
5819
|
+
throw new Error("cannot use options.decompress when options.decodeFileData === false");
|
|
5820
|
+
}
|
|
5821
|
+
} else {
|
|
5822
|
+
if (options2.decrypt != null) {
|
|
5823
|
+
if (!entry.isEncrypted()) {
|
|
5824
|
+
throw new Error("options.decrypt can only be specified for encrypted entries. See also option decodeFileData.");
|
|
5825
|
+
}
|
|
5826
|
+
if (options2.decrypt !== false)
|
|
5827
|
+
throw new Error("invalid options.decrypt value: " + options2.decrypt);
|
|
5828
|
+
if (entry.isCompressed()) {
|
|
5829
|
+
if (options2.decompress !== false)
|
|
5830
|
+
throw new Error("entry is encrypted and compressed, and options.decompress !== false. See also option decodeFileData.");
|
|
5831
|
+
}
|
|
5832
|
+
}
|
|
5833
|
+
if (options2.decompress != null) {
|
|
5834
|
+
if (!entry.isCompressed()) {
|
|
5835
|
+
throw new Error("options.decompress can only be specified for compressed entries. See also option decodeFileData.");
|
|
5836
|
+
}
|
|
5837
|
+
if (!(options2.decompress === false || options2.decompress === true)) {
|
|
5838
|
+
throw new Error("invalid options.decompress value: " + options2.decompress);
|
|
5839
|
+
}
|
|
5840
|
+
decompress = options2.decompress;
|
|
5841
|
+
}
|
|
5842
|
+
}
|
|
5843
|
+
if (options2.start != null) {
|
|
5844
|
+
relativeStart = options2.start;
|
|
5845
|
+
if (relativeStart < 0)
|
|
5846
|
+
throw new Error("options.start < 0");
|
|
5847
|
+
if (relativeStart > entry.compressedSize)
|
|
5848
|
+
throw new Error("options.start > entry.compressedSize");
|
|
5849
|
+
}
|
|
5850
|
+
if (options2.end != null) {
|
|
5851
|
+
relativeEnd = options2.end;
|
|
5852
|
+
if (relativeEnd < 0)
|
|
5853
|
+
throw new Error("options.end < 0");
|
|
5854
|
+
if (relativeEnd > entry.compressedSize)
|
|
5855
|
+
throw new Error("options.end > entry.compressedSize");
|
|
5856
|
+
if (relativeEnd < relativeStart)
|
|
5857
|
+
throw new Error("options.end < options.start");
|
|
5858
|
+
}
|
|
5859
|
+
}
|
|
5860
|
+
var rawMode = options2.decodeFileData === false || (entry.compressionMethod === 0 || entry.compressionMethod === 8 && options2.decompress === false) && (!entry.isEncrypted() || options2.decrypt === false);
|
|
5861
|
+
if (options2.start != null || options2.end != null) {
|
|
5862
|
+
if (!rawMode)
|
|
5863
|
+
throw new Error("start/end range require options.decodeFileData === false for non-trivial encoded entries.");
|
|
5864
|
+
}
|
|
5865
|
+
if (!self.isOpen)
|
|
5866
|
+
return callback(new Error("closed"));
|
|
5867
|
+
if (entry.isEncrypted() && !rawMode) {
|
|
5868
|
+
if (options2.decrypt !== false)
|
|
5869
|
+
return callback(new Error("entry is encrypted, and options.decodeFileData !== false"));
|
|
5870
|
+
}
|
|
5871
|
+
var decompress;
|
|
5872
|
+
if (rawMode) {
|
|
5873
|
+
decompress = false;
|
|
5874
|
+
} else if (entry.compressionMethod === 8) {
|
|
5875
|
+
decompress = options2.decodeFileData !== true;
|
|
5876
|
+
} else {
|
|
5877
|
+
return callback(new Error("unsupported compression method: " + entry.compressionMethod));
|
|
5878
|
+
}
|
|
5879
|
+
self.readLocalFileHeader(entry, { minimal: true }, function(err, localFileHeader) {
|
|
5880
|
+
if (err)
|
|
5881
|
+
return callback(err);
|
|
5882
|
+
self.openReadStreamLowLevel(localFileHeader.fileDataStart, entry.compressedSize, relativeStart, relativeEnd, decompress, entry.uncompressedSize, callback);
|
|
5883
|
+
});
|
|
5884
|
+
};
|
|
5885
|
+
ZipFile.prototype.openReadStreamLowLevel = function(fileDataStart, compressedSize, relativeStart, relativeEnd, decompress, uncompressedSize, callback) {
|
|
5886
|
+
var self = this;
|
|
5887
|
+
var fileDataEnd = fileDataStart + compressedSize;
|
|
5888
|
+
var readStream = self.reader.createReadStream({
|
|
5889
|
+
start: fileDataStart + relativeStart,
|
|
5890
|
+
end: fileDataStart + relativeEnd
|
|
5891
|
+
});
|
|
5892
|
+
var endpointStream = readStream;
|
|
5893
|
+
if (decompress) {
|
|
5894
|
+
var destroyed = false;
|
|
5895
|
+
var inflateFilter = zlib.createInflateRaw();
|
|
5896
|
+
readStream.on("error", function(err) {
|
|
5897
|
+
setImmediate(function() {
|
|
5898
|
+
if (!destroyed)
|
|
5899
|
+
inflateFilter.emit("error", err);
|
|
5900
|
+
});
|
|
5901
|
+
});
|
|
5902
|
+
readStream.pipe(inflateFilter);
|
|
5903
|
+
if (self.validateEntrySizes) {
|
|
5904
|
+
endpointStream = new AssertByteCountStream(uncompressedSize);
|
|
5905
|
+
inflateFilter.on("error", function(err) {
|
|
5906
|
+
setImmediate(function() {
|
|
5907
|
+
if (!destroyed)
|
|
5908
|
+
endpointStream.emit("error", err);
|
|
5909
|
+
});
|
|
5910
|
+
});
|
|
5911
|
+
inflateFilter.pipe(endpointStream);
|
|
5912
|
+
} else {
|
|
5913
|
+
endpointStream = inflateFilter;
|
|
5914
|
+
}
|
|
5915
|
+
installDestroyFn(endpointStream, function() {
|
|
5916
|
+
destroyed = true;
|
|
5917
|
+
if (inflateFilter !== endpointStream)
|
|
5918
|
+
inflateFilter.unpipe(endpointStream);
|
|
5919
|
+
readStream.unpipe(inflateFilter);
|
|
5920
|
+
readStream.destroy();
|
|
5921
|
+
});
|
|
5922
|
+
}
|
|
5923
|
+
callback(null, endpointStream);
|
|
5924
|
+
};
|
|
5925
|
+
ZipFile.prototype.readLocalFileHeader = function(entry, options2, callback) {
|
|
5926
|
+
var self = this;
|
|
5927
|
+
if (callback == null) {
|
|
5928
|
+
callback = options2;
|
|
5929
|
+
options2 = null;
|
|
5930
|
+
}
|
|
5931
|
+
if (options2 == null)
|
|
5932
|
+
options2 = {};
|
|
5933
|
+
self.reader.ref();
|
|
5934
|
+
var buffer = newBuffer(30);
|
|
5935
|
+
readAndAssertNoEof(self.reader, buffer, 0, buffer.length, entry.relativeOffsetOfLocalHeader, function(err) {
|
|
5936
|
+
try {
|
|
5937
|
+
if (err)
|
|
5938
|
+
return callback(err);
|
|
5939
|
+
var signature = buffer.readUInt32LE(0);
|
|
5940
|
+
if (signature !== 67324752) {
|
|
5941
|
+
return callback(new Error("invalid local file header signature: 0x" + signature.toString(16)));
|
|
5942
|
+
}
|
|
5943
|
+
var fileNameLength = buffer.readUInt16LE(26);
|
|
5944
|
+
var extraFieldLength = buffer.readUInt16LE(28);
|
|
5945
|
+
var fileDataStart = entry.relativeOffsetOfLocalHeader + 30 + fileNameLength + extraFieldLength;
|
|
5946
|
+
if (fileDataStart + entry.compressedSize > self.fileSize) {
|
|
5947
|
+
return callback(new Error("file data overflows file bounds: " + fileDataStart + " + " + entry.compressedSize + " > " + self.fileSize));
|
|
5948
|
+
}
|
|
5949
|
+
if (options2.minimal) {
|
|
5950
|
+
return callback(null, { fileDataStart });
|
|
5951
|
+
}
|
|
5952
|
+
var localFileHeader = new LocalFileHeader;
|
|
5953
|
+
localFileHeader.fileDataStart = fileDataStart;
|
|
5954
|
+
localFileHeader.versionNeededToExtract = buffer.readUInt16LE(4);
|
|
5955
|
+
localFileHeader.generalPurposeBitFlag = buffer.readUInt16LE(6);
|
|
5956
|
+
localFileHeader.compressionMethod = buffer.readUInt16LE(8);
|
|
5957
|
+
localFileHeader.lastModFileTime = buffer.readUInt16LE(10);
|
|
5958
|
+
localFileHeader.lastModFileDate = buffer.readUInt16LE(12);
|
|
5959
|
+
localFileHeader.crc32 = buffer.readUInt32LE(14);
|
|
5960
|
+
localFileHeader.compressedSize = buffer.readUInt32LE(18);
|
|
5961
|
+
localFileHeader.uncompressedSize = buffer.readUInt32LE(22);
|
|
5962
|
+
localFileHeader.fileNameLength = fileNameLength;
|
|
5963
|
+
localFileHeader.extraFieldLength = extraFieldLength;
|
|
5964
|
+
buffer = newBuffer(fileNameLength + extraFieldLength);
|
|
5965
|
+
self.reader.ref();
|
|
5966
|
+
readAndAssertNoEof(self.reader, buffer, 0, buffer.length, entry.relativeOffsetOfLocalHeader + 30, function(err2) {
|
|
5967
|
+
try {
|
|
5968
|
+
if (err2)
|
|
5969
|
+
return callback(err2);
|
|
5970
|
+
localFileHeader.fileName = buffer.subarray(0, fileNameLength);
|
|
5971
|
+
localFileHeader.extraField = buffer.subarray(fileNameLength);
|
|
5972
|
+
return callback(null, localFileHeader);
|
|
5973
|
+
} finally {
|
|
5974
|
+
self.reader.unref();
|
|
5975
|
+
}
|
|
5976
|
+
});
|
|
5977
|
+
} finally {
|
|
5978
|
+
self.reader.unref();
|
|
5979
|
+
}
|
|
5980
|
+
});
|
|
5981
|
+
};
|
|
5982
|
+
function Entry() {}
|
|
5983
|
+
Entry.prototype.getLastModDate = function(options2) {
|
|
5984
|
+
if (options2 == null)
|
|
5985
|
+
options2 = {};
|
|
5986
|
+
if (!options2.forceDosFormat) {
|
|
5987
|
+
for (var i = 0;i < this.extraFields.length; i++) {
|
|
5988
|
+
var extraField = this.extraFields[i];
|
|
5989
|
+
if (extraField.id === 21589) {
|
|
5990
|
+
var data = extraField.data;
|
|
5991
|
+
if (data.length < 5)
|
|
5992
|
+
continue;
|
|
5993
|
+
var flags = data[0];
|
|
5994
|
+
var HAS_MTIME = 1;
|
|
5995
|
+
if (!(flags & HAS_MTIME))
|
|
5996
|
+
continue;
|
|
5997
|
+
var posixTimestamp = data.readInt32LE(1);
|
|
5998
|
+
return new Date(posixTimestamp * 1000);
|
|
5999
|
+
} else if (extraField.id === 10) {
|
|
6000
|
+
var data = extraField.data;
|
|
6001
|
+
if (data.length !== 32)
|
|
6002
|
+
continue;
|
|
6003
|
+
if (data.readUInt16LE(4) !== 1)
|
|
6004
|
+
continue;
|
|
6005
|
+
if (data.readUInt16LE(6) !== 24)
|
|
6006
|
+
continue;
|
|
6007
|
+
var hundredNanoSecondsSince1601 = data.readUInt32LE(8) + 4294967296 * data.readInt32LE(12);
|
|
6008
|
+
var millisecondsSince1970 = hundredNanoSecondsSince1601 / 1e4 - 11644473600000;
|
|
6009
|
+
return new Date(millisecondsSince1970);
|
|
6010
|
+
}
|
|
6011
|
+
}
|
|
6012
|
+
}
|
|
6013
|
+
return dosDateTimeToDate(this.lastModFileDate, this.lastModFileTime, options2.timezone);
|
|
6014
|
+
};
|
|
6015
|
+
Entry.prototype.canDecodeFileData = function() {
|
|
6016
|
+
return !this.isEncrypted() && (this.compressionMethod === 0 || this.compressionMethod === 8);
|
|
6017
|
+
};
|
|
6018
|
+
Entry.prototype.isEncrypted = function() {
|
|
6019
|
+
return (this.generalPurposeBitFlag & 1) !== 0;
|
|
6020
|
+
};
|
|
6021
|
+
Entry.prototype.isCompressed = function() {
|
|
6022
|
+
return this.compressionMethod === 8;
|
|
6023
|
+
};
|
|
6024
|
+
function LocalFileHeader() {}
|
|
6025
|
+
function dosDateTimeToDate(date, time, timezone) {
|
|
6026
|
+
var day = date & 31;
|
|
6027
|
+
var month = (date >> 5 & 15) - 1;
|
|
6028
|
+
var year = (date >> 9 & 127) + 1980;
|
|
6029
|
+
var millisecond = 0;
|
|
6030
|
+
var second = (time & 31) * 2;
|
|
6031
|
+
var minute = time >> 5 & 63;
|
|
6032
|
+
var hour = time >> 11 & 31;
|
|
6033
|
+
if (timezone == null || timezone === "local") {
|
|
6034
|
+
return new Date(year, month, day, hour, minute, second, millisecond);
|
|
6035
|
+
} else if (timezone === "UTC") {
|
|
6036
|
+
return new Date(Date.UTC(year, month, day, hour, minute, second, millisecond));
|
|
6037
|
+
} else {
|
|
6038
|
+
throw new Error("unrecognized options.timezone: " + options.timezone);
|
|
6039
|
+
}
|
|
6040
|
+
}
|
|
6041
|
+
function getFileNameLowLevel(generalPurposeBitFlag, fileNameBuffer, extraFields, strictFileNames) {
|
|
6042
|
+
var fileName = null;
|
|
6043
|
+
for (var i = 0;i < extraFields.length; i++) {
|
|
6044
|
+
var extraField = extraFields[i];
|
|
6045
|
+
if (extraField.id === 28789) {
|
|
6046
|
+
if (extraField.data.length < 6) {
|
|
6047
|
+
continue;
|
|
6048
|
+
}
|
|
6049
|
+
if (extraField.data.readUInt8(0) !== 1) {
|
|
6050
|
+
continue;
|
|
6051
|
+
}
|
|
6052
|
+
var oldNameCrc32 = extraField.data.readUInt32LE(1);
|
|
6053
|
+
if (crc32.unsigned(fileNameBuffer) !== oldNameCrc32) {
|
|
6054
|
+
continue;
|
|
6055
|
+
}
|
|
6056
|
+
fileName = decodeBuffer(extraField.data.subarray(5), true);
|
|
6057
|
+
break;
|
|
6058
|
+
}
|
|
6059
|
+
}
|
|
6060
|
+
if (fileName == null) {
|
|
6061
|
+
var isUtf8 = (generalPurposeBitFlag & 2048) !== 0;
|
|
6062
|
+
fileName = decodeBuffer(fileNameBuffer, isUtf8);
|
|
6063
|
+
}
|
|
6064
|
+
if (!strictFileNames) {
|
|
6065
|
+
fileName = fileName.replace(/\\/g, "/");
|
|
6066
|
+
}
|
|
6067
|
+
return fileName;
|
|
6068
|
+
}
|
|
6069
|
+
function validateFileName(fileName) {
|
|
6070
|
+
if (fileName.indexOf("\\") !== -1) {
|
|
6071
|
+
return "invalid characters in fileName: " + fileName;
|
|
6072
|
+
}
|
|
6073
|
+
if (/^[a-zA-Z]:/.test(fileName) || /^\//.test(fileName)) {
|
|
6074
|
+
return "absolute path: " + fileName;
|
|
6075
|
+
}
|
|
6076
|
+
if (fileName.split("/").indexOf("..") !== -1) {
|
|
6077
|
+
return "invalid relative path: " + fileName;
|
|
6078
|
+
}
|
|
6079
|
+
return null;
|
|
6080
|
+
}
|
|
6081
|
+
function parseExtraFields(extraFieldBuffer) {
|
|
6082
|
+
var extraFields = [];
|
|
6083
|
+
var i = 0;
|
|
6084
|
+
while (i < extraFieldBuffer.length - 3) {
|
|
6085
|
+
var headerId = extraFieldBuffer.readUInt16LE(i + 0);
|
|
6086
|
+
var dataSize = extraFieldBuffer.readUInt16LE(i + 2);
|
|
6087
|
+
var dataStart = i + 4;
|
|
6088
|
+
var dataEnd = dataStart + dataSize;
|
|
6089
|
+
if (dataEnd > extraFieldBuffer.length)
|
|
6090
|
+
throw new Error("extra field length exceeds extra field buffer size");
|
|
6091
|
+
var dataBuffer = extraFieldBuffer.subarray(dataStart, dataEnd);
|
|
6092
|
+
extraFields.push({
|
|
6093
|
+
id: headerId,
|
|
6094
|
+
data: dataBuffer
|
|
6095
|
+
});
|
|
6096
|
+
i = dataEnd;
|
|
6097
|
+
}
|
|
6098
|
+
return extraFields;
|
|
6099
|
+
}
|
|
6100
|
+
function readAndAssertNoEof(reader, buffer, offset, length, position, callback) {
|
|
6101
|
+
if (length === 0) {
|
|
6102
|
+
return setImmediate(function() {
|
|
6103
|
+
callback(null, newBuffer(0));
|
|
6104
|
+
});
|
|
6105
|
+
}
|
|
6106
|
+
reader.read(buffer, offset, length, position, function(err, bytesRead) {
|
|
6107
|
+
if (err)
|
|
6108
|
+
return callback(err);
|
|
6109
|
+
if (bytesRead < length) {
|
|
6110
|
+
return callback(new Error("unexpected EOF"));
|
|
6111
|
+
}
|
|
6112
|
+
callback();
|
|
6113
|
+
});
|
|
6114
|
+
}
|
|
6115
|
+
util.inherits(AssertByteCountStream, Transform);
|
|
6116
|
+
function AssertByteCountStream(byteCount) {
|
|
6117
|
+
Transform.call(this);
|
|
6118
|
+
this.actualByteCount = 0;
|
|
6119
|
+
this.expectedByteCount = byteCount;
|
|
6120
|
+
}
|
|
6121
|
+
AssertByteCountStream.prototype._transform = function(chunk, encoding, cb) {
|
|
6122
|
+
this.actualByteCount += chunk.length;
|
|
6123
|
+
if (this.actualByteCount > this.expectedByteCount) {
|
|
6124
|
+
var msg = "too many bytes in the stream. expected " + this.expectedByteCount + ". got at least " + this.actualByteCount;
|
|
6125
|
+
return cb(new Error(msg));
|
|
6126
|
+
}
|
|
6127
|
+
cb(null, chunk);
|
|
6128
|
+
};
|
|
6129
|
+
AssertByteCountStream.prototype._flush = function(cb) {
|
|
6130
|
+
if (this.actualByteCount < this.expectedByteCount) {
|
|
6131
|
+
var msg = "not enough bytes in the stream. expected " + this.expectedByteCount + ". got only " + this.actualByteCount;
|
|
6132
|
+
return cb(new Error(msg));
|
|
6133
|
+
}
|
|
6134
|
+
cb();
|
|
6135
|
+
};
|
|
6136
|
+
util.inherits(RandomAccessReader, EventEmitter2);
|
|
6137
|
+
function RandomAccessReader() {
|
|
6138
|
+
EventEmitter2.call(this);
|
|
6139
|
+
this.refCount = 0;
|
|
6140
|
+
}
|
|
6141
|
+
RandomAccessReader.prototype.ref = function() {
|
|
6142
|
+
this.refCount += 1;
|
|
6143
|
+
};
|
|
6144
|
+
RandomAccessReader.prototype.unref = function() {
|
|
6145
|
+
var self = this;
|
|
6146
|
+
self.refCount -= 1;
|
|
6147
|
+
if (self.refCount > 0)
|
|
6148
|
+
return;
|
|
6149
|
+
if (self.refCount < 0)
|
|
6150
|
+
throw new Error("invalid unref");
|
|
6151
|
+
self.close(onCloseDone);
|
|
6152
|
+
function onCloseDone(err) {
|
|
6153
|
+
if (err)
|
|
6154
|
+
return self.emit("error", err);
|
|
6155
|
+
self.emit("close");
|
|
6156
|
+
}
|
|
6157
|
+
};
|
|
6158
|
+
RandomAccessReader.prototype.createReadStream = function(options2) {
|
|
6159
|
+
if (options2 == null)
|
|
6160
|
+
options2 = {};
|
|
6161
|
+
var start = options2.start;
|
|
6162
|
+
var end = options2.end;
|
|
6163
|
+
if (start === end) {
|
|
6164
|
+
var emptyStream = new PassThrough;
|
|
6165
|
+
setImmediate(function() {
|
|
6166
|
+
emptyStream.end();
|
|
6167
|
+
});
|
|
6168
|
+
return emptyStream;
|
|
6169
|
+
}
|
|
6170
|
+
var stream = this._readStreamForRange(start, end);
|
|
6171
|
+
var destroyed = false;
|
|
6172
|
+
var refUnrefFilter = new RefUnrefFilter(this);
|
|
6173
|
+
stream.on("error", function(err) {
|
|
6174
|
+
setImmediate(function() {
|
|
6175
|
+
if (!destroyed)
|
|
6176
|
+
refUnrefFilter.emit("error", err);
|
|
6177
|
+
});
|
|
6178
|
+
});
|
|
6179
|
+
installDestroyFn(refUnrefFilter, function() {
|
|
6180
|
+
stream.unpipe(refUnrefFilter);
|
|
6181
|
+
refUnrefFilter.unref();
|
|
6182
|
+
stream.destroy();
|
|
6183
|
+
});
|
|
6184
|
+
var byteCounter = new AssertByteCountStream(end - start);
|
|
6185
|
+
refUnrefFilter.on("error", function(err) {
|
|
6186
|
+
setImmediate(function() {
|
|
6187
|
+
if (!destroyed)
|
|
6188
|
+
byteCounter.emit("error", err);
|
|
6189
|
+
});
|
|
6190
|
+
});
|
|
6191
|
+
installDestroyFn(byteCounter, function() {
|
|
6192
|
+
destroyed = true;
|
|
6193
|
+
refUnrefFilter.unpipe(byteCounter);
|
|
6194
|
+
refUnrefFilter.destroy();
|
|
6195
|
+
});
|
|
6196
|
+
return stream.pipe(refUnrefFilter).pipe(byteCounter);
|
|
6197
|
+
};
|
|
6198
|
+
RandomAccessReader.prototype._readStreamForRange = function(start, end) {
|
|
6199
|
+
throw new Error("not implemented");
|
|
6200
|
+
};
|
|
6201
|
+
RandomAccessReader.prototype.read = function(buffer, offset, length, position, callback) {
|
|
6202
|
+
var readStream = this.createReadStream({ start: position, end: position + length });
|
|
6203
|
+
var writeStream = new Writable;
|
|
6204
|
+
var written = 0;
|
|
6205
|
+
writeStream._write = function(chunk, encoding, cb) {
|
|
6206
|
+
chunk.copy(buffer, offset + written, 0, chunk.length);
|
|
6207
|
+
written += chunk.length;
|
|
6208
|
+
cb();
|
|
6209
|
+
};
|
|
6210
|
+
writeStream.on("finish", callback);
|
|
6211
|
+
readStream.on("error", function(error) {
|
|
6212
|
+
callback(error);
|
|
6213
|
+
});
|
|
6214
|
+
readStream.pipe(writeStream);
|
|
6215
|
+
};
|
|
6216
|
+
RandomAccessReader.prototype.close = function(callback) {
|
|
6217
|
+
setImmediate(callback);
|
|
6218
|
+
};
|
|
6219
|
+
util.inherits(RefUnrefFilter, PassThrough);
|
|
6220
|
+
function RefUnrefFilter(context) {
|
|
6221
|
+
PassThrough.call(this);
|
|
6222
|
+
this.context = context;
|
|
6223
|
+
this.context.ref();
|
|
6224
|
+
this.unreffedYet = false;
|
|
6225
|
+
}
|
|
6226
|
+
RefUnrefFilter.prototype._flush = function(cb) {
|
|
6227
|
+
this.unref();
|
|
6228
|
+
cb();
|
|
6229
|
+
};
|
|
6230
|
+
RefUnrefFilter.prototype.unref = function(cb) {
|
|
6231
|
+
if (this.unreffedYet)
|
|
6232
|
+
return;
|
|
6233
|
+
this.unreffedYet = true;
|
|
6234
|
+
this.context.unref();
|
|
6235
|
+
};
|
|
6236
|
+
var cp437 = "\x00☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ";
|
|
6237
|
+
function decodeBuffer(buffer, isUtf8) {
|
|
6238
|
+
if (isUtf8) {
|
|
6239
|
+
return buffer.toString("utf8");
|
|
6240
|
+
} else {
|
|
6241
|
+
var result = "";
|
|
6242
|
+
for (var i = 0;i < buffer.length; i++) {
|
|
6243
|
+
result += cp437[buffer[i]];
|
|
6244
|
+
}
|
|
6245
|
+
return result;
|
|
6246
|
+
}
|
|
6247
|
+
}
|
|
6248
|
+
function readUInt64LE(buffer, offset) {
|
|
6249
|
+
var lower32 = buffer.readUInt32LE(offset);
|
|
6250
|
+
var upper32 = buffer.readUInt32LE(offset + 4);
|
|
6251
|
+
return upper32 * 4294967296 + lower32;
|
|
6252
|
+
}
|
|
6253
|
+
var newBuffer;
|
|
6254
|
+
if (typeof Buffer.allocUnsafe === "function") {
|
|
6255
|
+
newBuffer = function(len) {
|
|
6256
|
+
return Buffer.allocUnsafe(len);
|
|
6257
|
+
};
|
|
6258
|
+
} else {
|
|
6259
|
+
newBuffer = function(len) {
|
|
6260
|
+
return new Buffer(len);
|
|
6261
|
+
};
|
|
6262
|
+
}
|
|
6263
|
+
function installDestroyFn(stream, fn) {
|
|
6264
|
+
if (typeof stream.destroy === "function") {
|
|
6265
|
+
stream._destroy = function(err, cb) {
|
|
6266
|
+
fn();
|
|
6267
|
+
if (cb != null)
|
|
6268
|
+
cb(err);
|
|
6269
|
+
};
|
|
6270
|
+
} else {
|
|
6271
|
+
stream.destroy = fn;
|
|
6272
|
+
}
|
|
6273
|
+
}
|
|
6274
|
+
function defaultCallback(err) {
|
|
6275
|
+
if (err)
|
|
6276
|
+
throw err;
|
|
6277
|
+
}
|
|
6278
|
+
|
|
6279
|
+
// src/browser/extract-zip-archive.ts
|
|
6280
|
+
var openZip = promisify($open);
|
|
6281
|
+
var openReadStream = (zipfile, entry) => {
|
|
6282
|
+
return new Promise((resolve, reject) => {
|
|
6283
|
+
zipfile.openReadStream(entry, (err, readStream) => {
|
|
6284
|
+
if (err) {
|
|
6285
|
+
reject(err);
|
|
6286
|
+
return;
|
|
6287
|
+
}
|
|
6288
|
+
if (!readStream) {
|
|
6289
|
+
reject(new Error("Failed to open zip read stream"));
|
|
6290
|
+
return;
|
|
6291
|
+
}
|
|
6292
|
+
resolve(readStream);
|
|
6293
|
+
});
|
|
6294
|
+
});
|
|
6295
|
+
};
|
|
6296
|
+
var getExtractedMode = (entryMode, isDir) => {
|
|
6297
|
+
if (entryMode !== 0) {
|
|
6298
|
+
return entryMode;
|
|
6299
|
+
}
|
|
6300
|
+
return isDir ? 493 : 420;
|
|
6301
|
+
};
|
|
6302
|
+
var extractEntry = async ({
|
|
6303
|
+
entry,
|
|
6304
|
+
zipfile,
|
|
6305
|
+
dir
|
|
6306
|
+
}) => {
|
|
6307
|
+
if (entry.fileName.startsWith("__MACOSX/")) {
|
|
6308
|
+
return;
|
|
6309
|
+
}
|
|
6310
|
+
const dest = path7.join(dir, entry.fileName);
|
|
6311
|
+
const destDir = path7.dirname(dest);
|
|
6312
|
+
await mkdir(destDir, { recursive: true });
|
|
6313
|
+
const canonicalDestDir = await realpath(destDir);
|
|
6314
|
+
const relativeDestDir = path7.relative(dir, canonicalDestDir);
|
|
6315
|
+
if (relativeDestDir.split(path7.sep).includes("..")) {
|
|
6316
|
+
throw new Error(`Out of bound path "${canonicalDestDir}" found while processing file ${entry.fileName}`);
|
|
6317
|
+
}
|
|
6318
|
+
const mode = entry.externalFileAttributes >> 16 & 65535;
|
|
6319
|
+
const IFMT = 61440;
|
|
6320
|
+
const IFDIR = 16384;
|
|
6321
|
+
const IFLNK = 40960;
|
|
6322
|
+
const symlinkEntry = (mode & IFMT) === IFLNK;
|
|
6323
|
+
let isDir = (mode & IFMT) === IFDIR;
|
|
6324
|
+
if (!isDir && entry.fileName.endsWith("/")) {
|
|
6325
|
+
isDir = true;
|
|
6326
|
+
}
|
|
6327
|
+
const madeBy = entry.versionMadeBy >> 8;
|
|
6328
|
+
if (!isDir && madeBy === 0 && entry.externalFileAttributes === 16) {
|
|
6329
|
+
isDir = true;
|
|
6330
|
+
}
|
|
6331
|
+
const procMode = getExtractedMode(mode, isDir) & 511;
|
|
6332
|
+
const destDirectory = isDir ? dest : path7.dirname(dest);
|
|
6333
|
+
await mkdir(destDirectory, {
|
|
6334
|
+
recursive: true,
|
|
6335
|
+
mode: isDir ? procMode : undefined
|
|
6336
|
+
});
|
|
6337
|
+
if (isDir) {
|
|
6338
|
+
return;
|
|
6339
|
+
}
|
|
6340
|
+
const readStream = await openReadStream(zipfile, entry);
|
|
6341
|
+
if (symlinkEntry) {
|
|
6342
|
+
const link = (await buffer(readStream)).toString();
|
|
6343
|
+
await symlink(link, dest);
|
|
6344
|
+
return;
|
|
6345
|
+
}
|
|
6346
|
+
await pipeline(readStream, createWriteStream2(dest, { mode: procMode }));
|
|
6347
|
+
};
|
|
6348
|
+
var extractZipArchive = async (archivePath, dir) => {
|
|
6349
|
+
if (!path7.isAbsolute(dir)) {
|
|
6350
|
+
throw new Error("Target directory is expected to be absolute");
|
|
6351
|
+
}
|
|
6352
|
+
await mkdir(dir, { recursive: true });
|
|
6353
|
+
const resolvedDir = await realpath(dir);
|
|
6354
|
+
const zipfile = await openZip(archivePath, { lazyEntries: true });
|
|
6355
|
+
return new Promise((resolve, reject) => {
|
|
6356
|
+
let canceled = false;
|
|
6357
|
+
const cancel = (err) => {
|
|
6358
|
+
if (canceled) {
|
|
6359
|
+
return;
|
|
6360
|
+
}
|
|
6361
|
+
canceled = true;
|
|
6362
|
+
zipfile.close();
|
|
6363
|
+
reject(err);
|
|
6364
|
+
};
|
|
6365
|
+
zipfile.on("error", cancel);
|
|
6366
|
+
zipfile.on("close", () => {
|
|
6367
|
+
if (!canceled) {
|
|
6368
|
+
resolve();
|
|
6369
|
+
}
|
|
6370
|
+
});
|
|
6371
|
+
zipfile.on("entry", (entry) => {
|
|
6372
|
+
if (canceled) {
|
|
6373
|
+
return;
|
|
6374
|
+
}
|
|
6375
|
+
extractEntry({ entry, zipfile, dir: resolvedDir }).then(() => {
|
|
6376
|
+
zipfile.readEntry();
|
|
6377
|
+
}).catch(cancel);
|
|
6378
|
+
});
|
|
6379
|
+
zipfile.readEntry();
|
|
6380
|
+
});
|
|
6381
|
+
};
|
|
4837
6382
|
|
|
4838
6383
|
// src/browser/get-chrome-download-url.ts
|
|
4839
|
-
import * as
|
|
6384
|
+
import * as fs6 from "node:fs";
|
|
4840
6385
|
import * as os3 from "node:os";
|
|
4841
6386
|
var TESTED_VERSION = "149.0.7790.0";
|
|
4842
6387
|
var PLAYWRIGHT_VERSION = "1421";
|
|
@@ -4845,7 +6390,7 @@ var isAmazonLinux2023 = () => {
|
|
|
4845
6390
|
return false;
|
|
4846
6391
|
}
|
|
4847
6392
|
try {
|
|
4848
|
-
const osRelease =
|
|
6393
|
+
const osRelease = fs6.readFileSync("/etc/os-release", "utf-8");
|
|
4849
6394
|
return osRelease.includes("Amazon Linux") && osRelease.includes('VERSION="2023"');
|
|
4850
6395
|
} catch {
|
|
4851
6396
|
return false;
|
|
@@ -4938,18 +6483,18 @@ var logDownloadUrl = ({
|
|
|
4938
6483
|
};
|
|
4939
6484
|
|
|
4940
6485
|
// src/browser/get-download-destination.ts
|
|
4941
|
-
import
|
|
4942
|
-
import
|
|
6486
|
+
import fs7 from "node:fs";
|
|
6487
|
+
import path8 from "node:path";
|
|
4943
6488
|
var getDownloadsCacheDir = () => {
|
|
4944
6489
|
const cwd = process.cwd();
|
|
4945
6490
|
let dir = cwd;
|
|
4946
6491
|
for (;; ) {
|
|
4947
6492
|
try {
|
|
4948
|
-
if (
|
|
6493
|
+
if (fs7.statSync(path8.join(dir, "package.json")).isFile()) {
|
|
4949
6494
|
break;
|
|
4950
6495
|
}
|
|
4951
6496
|
} catch (e) {}
|
|
4952
|
-
const parent =
|
|
6497
|
+
const parent = path8.dirname(dir);
|
|
4953
6498
|
if (dir === parent) {
|
|
4954
6499
|
dir = undefined;
|
|
4955
6500
|
break;
|
|
@@ -4957,23 +6502,23 @@ var getDownloadsCacheDir = () => {
|
|
|
4957
6502
|
dir = parent;
|
|
4958
6503
|
}
|
|
4959
6504
|
if (!dir) {
|
|
4960
|
-
return
|
|
6505
|
+
return path8.resolve(cwd, ".remotion");
|
|
4961
6506
|
}
|
|
4962
6507
|
if (process.versions.pnp === "1") {
|
|
4963
|
-
return
|
|
6508
|
+
return path8.resolve(dir, ".pnp/.remotion");
|
|
4964
6509
|
}
|
|
4965
6510
|
if (process.versions.pnp === "3") {
|
|
4966
|
-
return
|
|
6511
|
+
return path8.resolve(dir, ".yarn/.remotion");
|
|
4967
6512
|
}
|
|
4968
|
-
return
|
|
6513
|
+
return path8.resolve(dir, "node_modules/.remotion");
|
|
4969
6514
|
};
|
|
4970
6515
|
|
|
4971
6516
|
// src/browser/BrowserFetcher.ts
|
|
4972
|
-
var mkdirAsync =
|
|
4973
|
-
var unlinkAsync =
|
|
6517
|
+
var mkdirAsync = fs8.promises.mkdir;
|
|
6518
|
+
var unlinkAsync = promisify2(fs8.unlink.bind(fs8));
|
|
4974
6519
|
function existsAsync(filePath) {
|
|
4975
6520
|
return new Promise((resolve2) => {
|
|
4976
|
-
|
|
6521
|
+
fs8.access(filePath, (err) => {
|
|
4977
6522
|
return resolve2(!err);
|
|
4978
6523
|
});
|
|
4979
6524
|
});
|
|
@@ -4993,11 +6538,11 @@ var getPlatform = () => {
|
|
|
4993
6538
|
};
|
|
4994
6539
|
var getDownloadsFolder = (chromeMode) => {
|
|
4995
6540
|
const destination = chromeMode === "headless-shell" ? "chrome-headless-shell" : "chrome-for-testing";
|
|
4996
|
-
return
|
|
6541
|
+
return path9.join(getDownloadsCacheDir(), destination);
|
|
4997
6542
|
};
|
|
4998
6543
|
var getVersionFilePath = (chromeMode) => {
|
|
4999
6544
|
const downloadsFolder = getDownloadsFolder(chromeMode);
|
|
5000
|
-
return
|
|
6545
|
+
return path9.join(downloadsFolder, "VERSION");
|
|
5001
6546
|
};
|
|
5002
6547
|
var getExpectedVersion = (version, _chromeMode) => {
|
|
5003
6548
|
if (version) {
|
|
@@ -5008,14 +6553,14 @@ var getExpectedVersion = (version, _chromeMode) => {
|
|
|
5008
6553
|
var readVersionFile = (chromeMode) => {
|
|
5009
6554
|
const versionFilePath = getVersionFilePath(chromeMode);
|
|
5010
6555
|
try {
|
|
5011
|
-
return
|
|
6556
|
+
return fs8.readFileSync(versionFilePath, "utf-8").trim();
|
|
5012
6557
|
} catch {
|
|
5013
6558
|
return null;
|
|
5014
6559
|
}
|
|
5015
6560
|
};
|
|
5016
6561
|
var writeVersionFile = (chromeMode, version) => {
|
|
5017
6562
|
const versionFilePath = getVersionFilePath(chromeMode);
|
|
5018
|
-
|
|
6563
|
+
fs8.writeFileSync(versionFilePath, version);
|
|
5019
6564
|
};
|
|
5020
6565
|
var downloadBrowser = async ({
|
|
5021
6566
|
logLevel,
|
|
@@ -5031,7 +6576,7 @@ var downloadBrowser = async ({
|
|
|
5031
6576
|
throw new Error(`A malformed download URL was found: ${downloadURL}.`);
|
|
5032
6577
|
}
|
|
5033
6578
|
const downloadsFolder = getDownloadsFolder(chromeMode);
|
|
5034
|
-
const archivePath =
|
|
6579
|
+
const archivePath = path9.join(downloadsFolder, fileName);
|
|
5035
6580
|
const outputPath = getFolderPath(downloadsFolder, platform3);
|
|
5036
6581
|
const expectedVersion = getExpectedVersion(version, chromeMode);
|
|
5037
6582
|
if (await existsAsync(outputPath)) {
|
|
@@ -5039,7 +6584,7 @@ var downloadBrowser = async ({
|
|
|
5039
6584
|
if (installedVersion === expectedVersion) {
|
|
5040
6585
|
return getRevisionInfo(chromeMode);
|
|
5041
6586
|
}
|
|
5042
|
-
|
|
6587
|
+
fs8.rmSync(outputPath, { recursive: true, force: true });
|
|
5043
6588
|
}
|
|
5044
6589
|
if (!await existsAsync(downloadsFolder)) {
|
|
5045
6590
|
await mkdirAsync(downloadsFolder, {
|
|
@@ -5072,7 +6617,7 @@ var downloadBrowser = async ({
|
|
|
5072
6617
|
logLevel,
|
|
5073
6618
|
abortSignal: new AbortController().signal
|
|
5074
6619
|
});
|
|
5075
|
-
await
|
|
6620
|
+
await extractZipArchive(archivePath, outputPath);
|
|
5076
6621
|
const possibleSubdirs = [
|
|
5077
6622
|
"chrome-linux",
|
|
5078
6623
|
"chrome-headless-shell-linux64",
|
|
@@ -5080,16 +6625,16 @@ var downloadBrowser = async ({
|
|
|
5080
6625
|
"chromium-headless-shell-amazon-linux2023-x64"
|
|
5081
6626
|
];
|
|
5082
6627
|
for (const subdir of possibleSubdirs) {
|
|
5083
|
-
const chromeLinuxFolder =
|
|
5084
|
-
const chromePath =
|
|
5085
|
-
if (
|
|
5086
|
-
const chromeHeadlessShellPath =
|
|
5087
|
-
|
|
6628
|
+
const chromeLinuxFolder = path9.join(outputPath, subdir);
|
|
6629
|
+
const chromePath = path9.join(chromeLinuxFolder, "chrome");
|
|
6630
|
+
if (fs8.existsSync(chromePath)) {
|
|
6631
|
+
const chromeHeadlessShellPath = path9.join(chromeLinuxFolder, "chrome-headless-shell");
|
|
6632
|
+
fs8.renameSync(chromePath, chromeHeadlessShellPath);
|
|
5088
6633
|
}
|
|
5089
|
-
if (
|
|
5090
|
-
const targetFolder =
|
|
6634
|
+
if (fs8.existsSync(chromeLinuxFolder)) {
|
|
6635
|
+
const targetFolder = path9.join(outputPath, "chrome-headless-shell-" + platform3);
|
|
5091
6636
|
if (chromeLinuxFolder !== targetFolder) {
|
|
5092
|
-
|
|
6637
|
+
fs8.renameSync(chromeLinuxFolder, targetFolder);
|
|
5093
6638
|
}
|
|
5094
6639
|
}
|
|
5095
6640
|
}
|
|
@@ -5106,7 +6651,7 @@ var downloadBrowser = async ({
|
|
|
5106
6651
|
return revisionInfo;
|
|
5107
6652
|
};
|
|
5108
6653
|
var getFolderPath = (downloadsFolder, platform3) => {
|
|
5109
|
-
return
|
|
6654
|
+
return path9.resolve(downloadsFolder, platform3);
|
|
5110
6655
|
};
|
|
5111
6656
|
var getExecutablePath2 = (chromeMode) => {
|
|
5112
6657
|
const downloadsFolder = getDownloadsFolder(chromeMode);
|
|
@@ -5114,18 +6659,18 @@ var getExecutablePath2 = (chromeMode) => {
|
|
|
5114
6659
|
const folderPath = getFolderPath(downloadsFolder, platform3);
|
|
5115
6660
|
if (chromeMode === "chrome-for-testing") {
|
|
5116
6661
|
if (platform3 === "mac-arm64" || platform3 === "mac-x64") {
|
|
5117
|
-
return
|
|
6662
|
+
return path9.join(folderPath, `chrome-${platform3}`, "Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing");
|
|
5118
6663
|
}
|
|
5119
6664
|
if (platform3 === "win64") {
|
|
5120
|
-
return
|
|
6665
|
+
return path9.join(folderPath, "chrome-win64", "chrome.exe");
|
|
5121
6666
|
}
|
|
5122
6667
|
if (platform3 === "linux64" || platform3 === "linux-arm64") {
|
|
5123
|
-
return
|
|
6668
|
+
return path9.join(folderPath, "chrome-linux64", "chrome");
|
|
5124
6669
|
}
|
|
5125
6670
|
throw new Error("unsupported platform" + platform3);
|
|
5126
6671
|
}
|
|
5127
6672
|
if (chromeMode === "headless-shell") {
|
|
5128
|
-
return
|
|
6673
|
+
return path9.join(folderPath, `chrome-headless-shell-${platform3}`, platform3 === "win64" ? "chrome-headless-shell.exe" : platform3 === "linux-arm64" || isAmazonLinux2023() ? "headless_shell" : "chrome-headless-shell");
|
|
5129
6674
|
}
|
|
5130
6675
|
throw new Error("unsupported chrome mode" + chromeMode);
|
|
5131
6676
|
};
|
|
@@ -5135,7 +6680,7 @@ var getRevisionInfo = (chromeMode) => {
|
|
|
5135
6680
|
const platform3 = getPlatform();
|
|
5136
6681
|
const folderPath = getFolderPath(downloadsFolder, platform3);
|
|
5137
6682
|
const url = getChromeDownloadUrl({ platform: platform3, version: null, chromeMode });
|
|
5138
|
-
const local =
|
|
6683
|
+
const local = fs8.existsSync(folderPath);
|
|
5139
6684
|
return {
|
|
5140
6685
|
executablePath,
|
|
5141
6686
|
folderPath,
|
|
@@ -5165,8 +6710,8 @@ var internalEnsureBrowserUncapped = async ({
|
|
|
5165
6710
|
const newStatus = getBrowserStatus({ browserExecutable, chromeMode });
|
|
5166
6711
|
return newStatus;
|
|
5167
6712
|
};
|
|
5168
|
-
var internalEnsureBrowser = (
|
|
5169
|
-
currentEnsureBrowserOperation = currentEnsureBrowserOperation.then(() => internalEnsureBrowserUncapped(
|
|
6713
|
+
var internalEnsureBrowser = (options2) => {
|
|
6714
|
+
currentEnsureBrowserOperation = currentEnsureBrowserOperation.then(() => internalEnsureBrowserUncapped(options2));
|
|
5170
6715
|
return currentEnsureBrowserOperation;
|
|
5171
6716
|
};
|
|
5172
6717
|
var getBrowserStatus = ({
|
|
@@ -5174,13 +6719,13 @@ var getBrowserStatus = ({
|
|
|
5174
6719
|
chromeMode
|
|
5175
6720
|
}) => {
|
|
5176
6721
|
if (browserExecutable) {
|
|
5177
|
-
if (!
|
|
6722
|
+
if (!fs9.existsSync(browserExecutable)) {
|
|
5178
6723
|
throw new Error(`"browserExecutable" was specified as '${browserExecutable}' but the path doesn't exist. Pass "null" for "browserExecutable" to download a browser automatically.`);
|
|
5179
6724
|
}
|
|
5180
6725
|
return { path: browserExecutable, type: "user-defined-path" };
|
|
5181
6726
|
}
|
|
5182
6727
|
const revision = getRevisionInfo(chromeMode);
|
|
5183
|
-
if (revision.local &&
|
|
6728
|
+
if (revision.local && fs9.existsSync(revision.executablePath)) {
|
|
5184
6729
|
const actualVersion = readVersionFile(chromeMode);
|
|
5185
6730
|
if (actualVersion === TESTED_VERSION) {
|
|
5186
6731
|
return { path: revision.executablePath, type: "local-puppeteer-browser" };
|
|
@@ -5189,24 +6734,24 @@ var getBrowserStatus = ({
|
|
|
5189
6734
|
}
|
|
5190
6735
|
return { type: "no-browser" };
|
|
5191
6736
|
};
|
|
5192
|
-
var ensureBrowser = (
|
|
6737
|
+
var ensureBrowser = (options2) => {
|
|
5193
6738
|
const indent = false;
|
|
5194
|
-
const logLevel =
|
|
6739
|
+
const logLevel = options2?.logLevel ?? "info";
|
|
5195
6740
|
return internalEnsureBrowser({
|
|
5196
|
-
browserExecutable:
|
|
6741
|
+
browserExecutable: options2?.browserExecutable ?? null,
|
|
5197
6742
|
indent,
|
|
5198
|
-
logLevel:
|
|
5199
|
-
onBrowserDownload:
|
|
6743
|
+
logLevel: options2?.logLevel ?? "info",
|
|
6744
|
+
onBrowserDownload: options2?.onBrowserDownload ?? defaultBrowserDownloadProgress({
|
|
5200
6745
|
api: "ensureBrowser()",
|
|
5201
6746
|
indent: false,
|
|
5202
6747
|
logLevel
|
|
5203
6748
|
}),
|
|
5204
|
-
chromeMode:
|
|
6749
|
+
chromeMode: options2?.chromeMode ?? "headless-shell"
|
|
5205
6750
|
});
|
|
5206
6751
|
};
|
|
5207
6752
|
|
|
5208
6753
|
// src/get-local-browser-executable.ts
|
|
5209
|
-
import
|
|
6754
|
+
import fs10 from "node:fs";
|
|
5210
6755
|
var getBrowserStatus2 = ({
|
|
5211
6756
|
browserExecutablePath,
|
|
5212
6757
|
indent,
|
|
@@ -5214,13 +6759,13 @@ var getBrowserStatus2 = ({
|
|
|
5214
6759
|
chromeMode
|
|
5215
6760
|
}) => {
|
|
5216
6761
|
if (browserExecutablePath) {
|
|
5217
|
-
if (!
|
|
6762
|
+
if (!fs10.existsSync(browserExecutablePath)) {
|
|
5218
6763
|
Log.warn({ indent, logLevel }, `Browser executable was specified as '${browserExecutablePath}' but the path doesn't exist.`);
|
|
5219
6764
|
}
|
|
5220
6765
|
return { path: browserExecutablePath, type: "user-defined-path" };
|
|
5221
6766
|
}
|
|
5222
6767
|
const revision = getRevisionInfo(chromeMode);
|
|
5223
|
-
if (revision.local &&
|
|
6768
|
+
if (revision.local && fs10.existsSync(revision.executablePath)) {
|
|
5224
6769
|
return { path: revision.executablePath, type: "local-puppeteer-browser" };
|
|
5225
6770
|
}
|
|
5226
6771
|
return { type: "no-browser" };
|
|
@@ -5518,7 +7063,7 @@ var internalOpenBrowser = async ({
|
|
|
5518
7063
|
if (chromiumOptions.userAgent) {
|
|
5519
7064
|
Log.verbose({ indent, logLevel, tag: "openBrowser()" }, `Using custom user agent: ${chromiumOptions.userAgent}`);
|
|
5520
7065
|
}
|
|
5521
|
-
const userDataDir = await
|
|
7066
|
+
const userDataDir = await fs11.promises.mkdtemp(path10.join(os6.tmpdir(), "puppeteer_dev_chrome_profile-"));
|
|
5522
7067
|
const browserInstance = await launchChrome({
|
|
5523
7068
|
executablePath,
|
|
5524
7069
|
logLevel,
|
|
@@ -5597,10 +7142,10 @@ var internalOpenBrowser = async ({
|
|
|
5597
7142
|
await pages[0]?.close();
|
|
5598
7143
|
return browserInstance;
|
|
5599
7144
|
};
|
|
5600
|
-
var openBrowser = (browser,
|
|
5601
|
-
const { browserExecutable, chromiumOptions, forceDeviceScaleFactor } =
|
|
7145
|
+
var openBrowser = (browser, options2) => {
|
|
7146
|
+
const { browserExecutable, chromiumOptions, forceDeviceScaleFactor } = options2 ?? {};
|
|
5602
7147
|
const indent = false;
|
|
5603
|
-
const logLevel =
|
|
7148
|
+
const logLevel = options2?.logLevel ?? (options2?.shouldDumpIo ? "verbose" : "info");
|
|
5604
7149
|
return internalOpenBrowser({
|
|
5605
7150
|
browser,
|
|
5606
7151
|
browserExecutable: browserExecutable ?? null,
|
|
@@ -5614,7 +7159,7 @@ var openBrowser = (browser, options) => {
|
|
|
5614
7159
|
logLevel,
|
|
5615
7160
|
api: "openBrowser()"
|
|
5616
7161
|
}),
|
|
5617
|
-
chromeMode:
|
|
7162
|
+
chromeMode: options2?.chromeMode ?? "headless-shell"
|
|
5618
7163
|
});
|
|
5619
7164
|
};
|
|
5620
7165
|
|
|
@@ -5691,12 +7236,12 @@ var DEFAULT_RENDER_FRAMES_OFFTHREAD_VIDEO_THREADS = 2;
|
|
|
5691
7236
|
|
|
5692
7237
|
// src/prepare-server.ts
|
|
5693
7238
|
import { existsSync as existsSync4 } from "node:fs";
|
|
5694
|
-
import
|
|
7239
|
+
import path20 from "node:path";
|
|
5695
7240
|
import { NoReactInternals as NoReactInternals7 } from "remotion/no-react";
|
|
5696
7241
|
|
|
5697
7242
|
// src/assets/download-and-map-assets-to-file.ts
|
|
5698
|
-
import
|
|
5699
|
-
import
|
|
7243
|
+
import fs12 from "node:fs";
|
|
7244
|
+
import path12, { extname as extname2 } from "node:path";
|
|
5700
7245
|
import { random } from "remotion/no-react";
|
|
5701
7246
|
|
|
5702
7247
|
// src/compress-assets.ts
|
|
@@ -14362,11 +15907,11 @@ populateMaps(extensions, {});
|
|
|
14362
15907
|
var getExt = (contentType) => {
|
|
14363
15908
|
return mimeDb[contentType.toLowerCase()]?.extensions?.[0] ?? null;
|
|
14364
15909
|
};
|
|
14365
|
-
function mimeLookup(
|
|
14366
|
-
if (!
|
|
15910
|
+
function mimeLookup(path11) {
|
|
15911
|
+
if (!path11 || typeof path11 !== "string") {
|
|
14367
15912
|
return false;
|
|
14368
15913
|
}
|
|
14369
|
-
const ext = extname("." +
|
|
15914
|
+
const ext = extname("." + path11).toLowerCase().substr(1);
|
|
14370
15915
|
if (!ext) {
|
|
14371
15916
|
return false;
|
|
14372
15917
|
}
|
|
@@ -14565,7 +16110,7 @@ var getAudioChannelsAndDuration = ({
|
|
|
14565
16110
|
};
|
|
14566
16111
|
|
|
14567
16112
|
// src/assets/sanitize-filepath.ts
|
|
14568
|
-
import
|
|
16113
|
+
import path11 from "node:path";
|
|
14569
16114
|
|
|
14570
16115
|
// src/assets/truncate-utf8-bytes.ts
|
|
14571
16116
|
function isHighSurrogate(codePoint) {
|
|
@@ -14626,7 +16171,7 @@ var sanitizeFilename = (input) => {
|
|
|
14626
16171
|
// src/assets/sanitize-filepath.ts
|
|
14627
16172
|
var pathSeparators = /[/\\]/;
|
|
14628
16173
|
var sanitizeFilePath = (pathToSanitize) => {
|
|
14629
|
-
return pathToSanitize.split(pathSeparators).map((s) => sanitizeFilename(s)).join(
|
|
16174
|
+
return pathToSanitize.split(pathSeparators).map((s) => sanitizeFilename(s)).join(path11.sep);
|
|
14630
16175
|
};
|
|
14631
16176
|
|
|
14632
16177
|
// src/assets/download-and-map-assets-to-file.ts
|
|
@@ -14731,7 +16276,7 @@ var downloadAsset = async ({
|
|
|
14731
16276
|
const { downloadDir } = downloadMap;
|
|
14732
16277
|
if (downloadMap.hasBeenDownloadedMap[src]?.[downloadDir]) {
|
|
14733
16278
|
const claimedDownloadLocation = downloadMap.hasBeenDownloadedMap[src]?.[downloadDir];
|
|
14734
|
-
if (
|
|
16279
|
+
if (fs12.existsSync(claimedDownloadLocation)) {
|
|
14735
16280
|
return claimedDownloadLocation;
|
|
14736
16281
|
}
|
|
14737
16282
|
downloadMap.hasBeenDownloadedMap[src][downloadDir] = null;
|
|
@@ -14770,7 +16315,7 @@ var downloadAsset = async ({
|
|
|
14770
16315
|
});
|
|
14771
16316
|
ensureOutputDirectory(output);
|
|
14772
16317
|
const buff = Buffer.from(assetData, encoding);
|
|
14773
|
-
await
|
|
16318
|
+
await fs12.promises.writeFile(output, buff);
|
|
14774
16319
|
notifyAssetIsDownloaded({ src, downloadMap, downloadDir, to: output });
|
|
14775
16320
|
return output;
|
|
14776
16321
|
}
|
|
@@ -14858,7 +16403,7 @@ var getSanitizedFilenameForAssetUrl = ({
|
|
|
14858
16403
|
const fileExtension = split.length > 1 && split[split.length - 1] ? `.${split[split.length - 1]}` : "";
|
|
14859
16404
|
const hashedFileName = String(random(`${src}${pathname}${search}`)).replace("0.", "");
|
|
14860
16405
|
const filename = hashedFileName + fileExtension;
|
|
14861
|
-
return
|
|
16406
|
+
return path12.join(downloadDir, sanitizeFilePath(filename));
|
|
14862
16407
|
};
|
|
14863
16408
|
var downloadAndMapAssetsToFileUrl = async ({
|
|
14864
16409
|
renderAsset,
|
|
@@ -14927,7 +16472,7 @@ var attachDownloadListenerToEmitter = (downloadMap, onDownload) => {
|
|
|
14927
16472
|
|
|
14928
16473
|
// src/assets/download-map.ts
|
|
14929
16474
|
import { mkdirSync as mkdirSync2 } from "node:fs";
|
|
14930
|
-
import
|
|
16475
|
+
import path16 from "node:path";
|
|
14931
16476
|
import { VERSION as VERSION2 } from "remotion/version";
|
|
14932
16477
|
|
|
14933
16478
|
// src/offthread-video-server.ts
|
|
@@ -14935,7 +16480,7 @@ import { URLSearchParams } from "node:url";
|
|
|
14935
16480
|
|
|
14936
16481
|
// src/compositor/compositor.ts
|
|
14937
16482
|
import { spawn as spawn3 } from "node:child_process";
|
|
14938
|
-
import
|
|
16483
|
+
import path13 from "node:path";
|
|
14939
16484
|
import { makeStreamer } from "@remotion/streaming";
|
|
14940
16485
|
|
|
14941
16486
|
// src/compositor/make-nonce.ts
|
|
@@ -14989,7 +16534,7 @@ var startCompositor = ({
|
|
|
14989
16534
|
});
|
|
14990
16535
|
makeFileExecutableIfItIsNot(bin);
|
|
14991
16536
|
const fullCommand = serializeCommand(type, payload);
|
|
14992
|
-
const cwd =
|
|
16537
|
+
const cwd = path13.dirname(bin);
|
|
14993
16538
|
const jsonArg = JSON.stringify(fullCommand);
|
|
14994
16539
|
const launch = wrapExecutableWithSetprivIfAvailable({
|
|
14995
16540
|
executablePath: bin,
|
|
@@ -15356,9 +16901,9 @@ class OffthreadVideoServerEmitter {
|
|
|
15356
16901
|
}
|
|
15357
16902
|
|
|
15358
16903
|
// src/tmp-dir.ts
|
|
15359
|
-
import
|
|
16904
|
+
import fs13, { mkdirSync } from "node:fs";
|
|
15360
16905
|
import os7 from "node:os";
|
|
15361
|
-
import
|
|
16906
|
+
import path14 from "node:path";
|
|
15362
16907
|
var alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
15363
16908
|
var randomHash = () => {
|
|
15364
16909
|
return new Array(10).fill(1).map(() => {
|
|
@@ -15366,9 +16911,9 @@ var randomHash = () => {
|
|
|
15366
16911
|
}).join("");
|
|
15367
16912
|
};
|
|
15368
16913
|
var tmpDir = (str) => {
|
|
15369
|
-
const newDir =
|
|
15370
|
-
if (
|
|
15371
|
-
|
|
16914
|
+
const newDir = path14.join(os7.tmpdir(), str + randomHash());
|
|
16915
|
+
if (fs13.existsSync(newDir)) {
|
|
16916
|
+
fs13.rmSync(newDir, {
|
|
15372
16917
|
recursive: true,
|
|
15373
16918
|
force: true
|
|
15374
16919
|
});
|
|
@@ -15378,8 +16923,8 @@ var tmpDir = (str) => {
|
|
|
15378
16923
|
};
|
|
15379
16924
|
|
|
15380
16925
|
// src/assets/inline-audio-mixing.ts
|
|
15381
|
-
import
|
|
15382
|
-
import
|
|
16926
|
+
import fs14, { writeSync } from "node:fs";
|
|
16927
|
+
import path15 from "node:path";
|
|
15383
16928
|
|
|
15384
16929
|
// src/assets/apply-tone-frequency.ts
|
|
15385
16930
|
var applyToneFrequencyUsingFfmpeg = async ({
|
|
@@ -15449,7 +16994,7 @@ var makeInlineAudioMixing = (dir, sampleRate) => {
|
|
|
15449
16994
|
const cleanup = () => {
|
|
15450
16995
|
for (const fileName of Object.keys(openFiles)) {
|
|
15451
16996
|
try {
|
|
15452
|
-
|
|
16997
|
+
fs14.closeSync(openFiles[fileName]);
|
|
15453
16998
|
delete openFiles[fileName];
|
|
15454
16999
|
} catch {}
|
|
15455
17000
|
}
|
|
@@ -15459,7 +17004,7 @@ var makeInlineAudioMixing = (dir, sampleRate) => {
|
|
|
15459
17004
|
return Object.keys(openFiles);
|
|
15460
17005
|
};
|
|
15461
17006
|
const getFilePath = (asset) => {
|
|
15462
|
-
return
|
|
17007
|
+
return path15.join(folderToAdd, `${asset.id}.wav`);
|
|
15463
17008
|
};
|
|
15464
17009
|
const ensureAsset = ({
|
|
15465
17010
|
asset,
|
|
@@ -15470,7 +17015,7 @@ var makeInlineAudioMixing = (dir, sampleRate) => {
|
|
|
15470
17015
|
}) => {
|
|
15471
17016
|
const filePath = getFilePath(asset);
|
|
15472
17017
|
if (!openFiles[filePath]) {
|
|
15473
|
-
openFiles[filePath] =
|
|
17018
|
+
openFiles[filePath] = fs14.openSync(filePath, "w");
|
|
15474
17019
|
}
|
|
15475
17020
|
if (writtenHeaders[filePath]) {
|
|
15476
17021
|
return;
|
|
@@ -15517,9 +17062,9 @@ var makeInlineAudioMixing = (dir, sampleRate) => {
|
|
|
15517
17062
|
sampleRate: finishSampleRate
|
|
15518
17063
|
});
|
|
15519
17064
|
try {
|
|
15520
|
-
|
|
17065
|
+
fs14.closeSync(openFiles[fileName]);
|
|
15521
17066
|
} catch {}
|
|
15522
|
-
|
|
17067
|
+
fs14.renameSync(tmpFile, fileName);
|
|
15523
17068
|
}
|
|
15524
17069
|
};
|
|
15525
17070
|
const addAsset = ({
|
|
@@ -15568,7 +17113,7 @@ var makeInlineAudioMixing = (dir, sampleRate) => {
|
|
|
15568
17113
|
|
|
15569
17114
|
// src/assets/download-map.ts
|
|
15570
17115
|
var makeAndReturn = (dir, name) => {
|
|
15571
|
-
const p =
|
|
17116
|
+
const p = path16.join(dir, name);
|
|
15572
17117
|
mkdirSync2(p);
|
|
15573
17118
|
return p;
|
|
15574
17119
|
};
|
|
@@ -15617,7 +17162,7 @@ var cleanDownloadMap = (downloadMap) => {
|
|
|
15617
17162
|
};
|
|
15618
17163
|
|
|
15619
17164
|
// src/get-bundle-url-from-serve-url.ts
|
|
15620
|
-
import
|
|
17165
|
+
import path17 from "path";
|
|
15621
17166
|
import { NoReactInternals as NoReactInternals6 } from "remotion/no-react";
|
|
15622
17167
|
var map = (webpackBundleOrServeUrl, suffix) => {
|
|
15623
17168
|
if (isServeUrl(webpackBundleOrServeUrl)) {
|
|
@@ -15628,7 +17173,7 @@ var map = (webpackBundleOrServeUrl, suffix) => {
|
|
|
15628
17173
|
}
|
|
15629
17174
|
return parsed.origin + parsed.pathname.substring(0, idx + 1) + suffix;
|
|
15630
17175
|
}
|
|
15631
|
-
const index = webpackBundleOrServeUrl.lastIndexOf(
|
|
17176
|
+
const index = webpackBundleOrServeUrl.lastIndexOf(path17.sep);
|
|
15632
17177
|
const url = webpackBundleOrServeUrl.substring(0, index + 1) + suffix;
|
|
15633
17178
|
return url;
|
|
15634
17179
|
};
|
|
@@ -15877,10 +17422,10 @@ var hasIpv4LoopbackAddress = (flattened) => {
|
|
|
15877
17422
|
|
|
15878
17423
|
// src/serve-handler/index.ts
|
|
15879
17424
|
import { createReadStream, promises as promises2 } from "node:fs";
|
|
15880
|
-
import
|
|
17425
|
+
import path19 from "node:path";
|
|
15881
17426
|
|
|
15882
17427
|
// src/serve-handler/is-path-inside.ts
|
|
15883
|
-
import
|
|
17428
|
+
import path18 from "node:path";
|
|
15884
17429
|
var isPathInside = function(thePath, potentialParent) {
|
|
15885
17430
|
thePath = stripTrailingSep(thePath);
|
|
15886
17431
|
potentialParent = stripTrailingSep(potentialParent);
|
|
@@ -15888,10 +17433,10 @@ var isPathInside = function(thePath, potentialParent) {
|
|
|
15888
17433
|
thePath = thePath.toLowerCase();
|
|
15889
17434
|
potentialParent = potentialParent.toLowerCase();
|
|
15890
17435
|
}
|
|
15891
|
-
return thePath.lastIndexOf(potentialParent, 0) === 0 && (thePath[potentialParent.length] ===
|
|
17436
|
+
return thePath.lastIndexOf(potentialParent, 0) === 0 && (thePath[potentialParent.length] === path18.sep || thePath[potentialParent.length] === undefined);
|
|
15892
17437
|
};
|
|
15893
17438
|
function stripTrailingSep(thePath) {
|
|
15894
|
-
if (thePath[thePath.length - 1] ===
|
|
17439
|
+
if (thePath[thePath.length - 1] === path18.sep) {
|
|
15895
17440
|
return thePath.slice(0, -1);
|
|
15896
17441
|
}
|
|
15897
17442
|
return thePath;
|
|
@@ -15944,7 +17489,7 @@ var rangeParser = (size, str) => {
|
|
|
15944
17489
|
|
|
15945
17490
|
// src/serve-handler/index.ts
|
|
15946
17491
|
var getHeaders = (absolutePath, stats) => {
|
|
15947
|
-
const { base } =
|
|
17492
|
+
const { base } = path19.parse(absolutePath);
|
|
15948
17493
|
let defaultHeaders = {};
|
|
15949
17494
|
if (stats) {
|
|
15950
17495
|
defaultHeaders = {
|
|
@@ -15960,15 +17505,15 @@ var getHeaders = (absolutePath, stats) => {
|
|
|
15960
17505
|
return defaultHeaders;
|
|
15961
17506
|
};
|
|
15962
17507
|
var getPossiblePaths = (relativePath, extension) => [
|
|
15963
|
-
|
|
17508
|
+
path19.join(relativePath, `index${extension}`),
|
|
15964
17509
|
relativePath.endsWith("/") ? relativePath.replace(/\/$/g, extension) : relativePath + extension
|
|
15965
|
-
].filter((item) =>
|
|
17510
|
+
].filter((item) => path19.basename(item) !== extension);
|
|
15966
17511
|
var findRelated = async (current, relativePath) => {
|
|
15967
17512
|
const possible = getPossiblePaths(relativePath, ".html");
|
|
15968
17513
|
let stats = null;
|
|
15969
17514
|
for (let index = 0;index < possible.length; index++) {
|
|
15970
17515
|
const related = possible[index];
|
|
15971
|
-
const absolutePath =
|
|
17516
|
+
const absolutePath = path19.join(current, related);
|
|
15972
17517
|
try {
|
|
15973
17518
|
stats = await promises2.lstat(absolutePath);
|
|
15974
17519
|
} catch (err) {
|
|
@@ -16003,7 +17548,7 @@ var internalError = (absolutePath, response) => {
|
|
|
16003
17548
|
};
|
|
16004
17549
|
var serveHandler = async (request, response, config) => {
|
|
16005
17550
|
const cwd = process.cwd();
|
|
16006
|
-
const current =
|
|
17551
|
+
const current = path19.resolve(cwd, config.public);
|
|
16007
17552
|
let relativePath = null;
|
|
16008
17553
|
try {
|
|
16009
17554
|
const parsedUrl = new URL(request.url, `http://${request.headers.host}`);
|
|
@@ -16015,7 +17560,7 @@ var serveHandler = async (request, response, config) => {
|
|
|
16015
17560
|
message: "Bad Request"
|
|
16016
17561
|
});
|
|
16017
17562
|
}
|
|
16018
|
-
let absolutePath =
|
|
17563
|
+
let absolutePath = path19.join(current, relativePath);
|
|
16019
17564
|
if (!isPathInside(absolutePath, current)) {
|
|
16020
17565
|
return sendError(absolutePath, response, {
|
|
16021
17566
|
statusCode: 400,
|
|
@@ -16024,7 +17569,7 @@ var serveHandler = async (request, response, config) => {
|
|
|
16024
17569
|
});
|
|
16025
17570
|
}
|
|
16026
17571
|
let stats = null;
|
|
16027
|
-
if (
|
|
17572
|
+
if (path19.extname(relativePath) !== "") {
|
|
16028
17573
|
try {
|
|
16029
17574
|
stats = await promises2.lstat(absolutePath);
|
|
16030
17575
|
} catch (err) {
|
|
@@ -16107,31 +17652,31 @@ var serveHandler = async (request, response, config) => {
|
|
|
16107
17652
|
};
|
|
16108
17653
|
|
|
16109
17654
|
// src/serve-static.ts
|
|
16110
|
-
var serveStatic = async (
|
|
17655
|
+
var serveStatic = async (path20, options2) => {
|
|
16111
17656
|
const {
|
|
16112
17657
|
listener: offthreadRequest,
|
|
16113
17658
|
close: closeCompositor,
|
|
16114
17659
|
compositor
|
|
16115
17660
|
} = startOffthreadVideoServer({
|
|
16116
|
-
downloadMap:
|
|
16117
|
-
offthreadVideoThreads:
|
|
16118
|
-
logLevel:
|
|
16119
|
-
indent:
|
|
16120
|
-
offthreadVideoCacheSizeInBytes:
|
|
16121
|
-
binariesDirectory:
|
|
17661
|
+
downloadMap: options2.downloadMap,
|
|
17662
|
+
offthreadVideoThreads: options2.offthreadVideoThreads,
|
|
17663
|
+
logLevel: options2.logLevel,
|
|
17664
|
+
indent: options2.indent,
|
|
17665
|
+
offthreadVideoCacheSizeInBytes: options2.offthreadVideoCacheSizeInBytes,
|
|
17666
|
+
binariesDirectory: options2.binariesDirectory
|
|
16122
17667
|
});
|
|
16123
17668
|
const connections = {};
|
|
16124
17669
|
const server = http2.createServer((request, response) => {
|
|
16125
17670
|
if (request.url?.startsWith("/proxy")) {
|
|
16126
17671
|
return offthreadRequest(request, response);
|
|
16127
17672
|
}
|
|
16128
|
-
if (
|
|
17673
|
+
if (path20 === null) {
|
|
16129
17674
|
response.writeHead(404);
|
|
16130
17675
|
response.end("Server only supports /proxy");
|
|
16131
17676
|
return;
|
|
16132
17677
|
}
|
|
16133
17678
|
serveHandler(request, response, {
|
|
16134
|
-
public:
|
|
17679
|
+
public: path20
|
|
16135
17680
|
}).catch(() => {
|
|
16136
17681
|
if (!response.headersSent) {
|
|
16137
17682
|
response.writeHead(500);
|
|
@@ -16153,13 +17698,13 @@ var serveStatic = async (path19, options) => {
|
|
|
16153
17698
|
});
|
|
16154
17699
|
let selectedPort = null;
|
|
16155
17700
|
const maxTries = 10;
|
|
16156
|
-
const portConfig = getPortConfig(
|
|
17701
|
+
const portConfig = getPortConfig(options2.forceIPv4);
|
|
16157
17702
|
for (let i = 0;i < maxTries; i++) {
|
|
16158
17703
|
let unlock = () => {};
|
|
16159
17704
|
try {
|
|
16160
17705
|
selectedPort = await new Promise((resolve2, reject) => {
|
|
16161
17706
|
getDesiredPort({
|
|
16162
|
-
desiredPort:
|
|
17707
|
+
desiredPort: options2?.port ?? undefined,
|
|
16163
17708
|
from: 3000,
|
|
16164
17709
|
to: 3100,
|
|
16165
17710
|
hostsToTry: portConfig.hostsToTry
|
|
@@ -16283,13 +17828,13 @@ var prepareServer = async ({
|
|
|
16283
17828
|
downloadMap
|
|
16284
17829
|
});
|
|
16285
17830
|
}
|
|
16286
|
-
const indexFile =
|
|
17831
|
+
const indexFile = path20.join(webpackConfigOrServeUrl, "index.html");
|
|
16287
17832
|
const exists = existsSync4(indexFile);
|
|
16288
17833
|
if (!exists) {
|
|
16289
17834
|
throw new Error(`Tried to serve the Webpack bundle on a HTTP server, but the file ${indexFile} does not exist. Is this a valid path to a Webpack bundle?`);
|
|
16290
17835
|
}
|
|
16291
17836
|
let localSourceMap = null;
|
|
16292
|
-
getSourceMapFromLocalFile(
|
|
17837
|
+
getSourceMapFromLocalFile(path20.join(webpackConfigOrServeUrl, NoReactInternals7.bundleName)).then((s) => {
|
|
16293
17838
|
localSourceMap = s;
|
|
16294
17839
|
}).catch((err) => {
|
|
16295
17840
|
Log.verbose({ indent, logLevel }, "Could not fetch sourcemap for ", webpackConfigOrServeUrl, err);
|
|
@@ -17361,21 +18906,21 @@ var defaultCodecsForFileExtension = {
|
|
|
17361
18906
|
// src/path-normalize.ts
|
|
17362
18907
|
var SLASH = 47;
|
|
17363
18908
|
var DOT = 46;
|
|
17364
|
-
var assertPath = (
|
|
17365
|
-
const t = typeof
|
|
18909
|
+
var assertPath = (path21) => {
|
|
18910
|
+
const t = typeof path21;
|
|
17366
18911
|
if (t !== "string") {
|
|
17367
18912
|
throw new TypeError(`Expected a string, got a ${t}`);
|
|
17368
18913
|
}
|
|
17369
18914
|
};
|
|
17370
|
-
var posixNormalize = (
|
|
18915
|
+
var posixNormalize = (path21, allowAboveRoot) => {
|
|
17371
18916
|
let res = "";
|
|
17372
18917
|
let lastSegmentLength = 0;
|
|
17373
18918
|
let lastSlash = -1;
|
|
17374
18919
|
let dots = 0;
|
|
17375
18920
|
let code;
|
|
17376
|
-
for (let i = 0;i <=
|
|
17377
|
-
if (i <
|
|
17378
|
-
code =
|
|
18921
|
+
for (let i = 0;i <= path21.length; ++i) {
|
|
18922
|
+
if (i < path21.length) {
|
|
18923
|
+
code = path21.charCodeAt(i);
|
|
17379
18924
|
} else if (code === SLASH) {
|
|
17380
18925
|
break;
|
|
17381
18926
|
} else {
|
|
@@ -17416,9 +18961,9 @@ var posixNormalize = (path20, allowAboveRoot) => {
|
|
|
17416
18961
|
}
|
|
17417
18962
|
} else {
|
|
17418
18963
|
if (res.length > 0) {
|
|
17419
|
-
res += "/" +
|
|
18964
|
+
res += "/" + path21.slice(lastSlash + 1, i);
|
|
17420
18965
|
} else {
|
|
17421
|
-
res =
|
|
18966
|
+
res = path21.slice(lastSlash + 1, i);
|
|
17422
18967
|
}
|
|
17423
18968
|
lastSegmentLength = i - lastSlash - 1;
|
|
17424
18969
|
}
|
|
@@ -17441,24 +18986,24 @@ var decode = (s) => {
|
|
|
17441
18986
|
};
|
|
17442
18987
|
var pathNormalize = (p) => {
|
|
17443
18988
|
assertPath(p);
|
|
17444
|
-
let
|
|
17445
|
-
if (
|
|
18989
|
+
let path21 = p;
|
|
18990
|
+
if (path21.length === 0) {
|
|
17446
18991
|
return ".";
|
|
17447
18992
|
}
|
|
17448
|
-
const
|
|
17449
|
-
const trailingSeparator =
|
|
17450
|
-
|
|
17451
|
-
|
|
17452
|
-
if (
|
|
17453
|
-
|
|
18993
|
+
const isAbsolute2 = path21.charCodeAt(0) === SLASH;
|
|
18994
|
+
const trailingSeparator = path21.charCodeAt(path21.length - 1) === SLASH;
|
|
18995
|
+
path21 = decode(path21);
|
|
18996
|
+
path21 = posixNormalize(path21, !isAbsolute2);
|
|
18997
|
+
if (path21.length === 0 && !isAbsolute2) {
|
|
18998
|
+
path21 = ".";
|
|
17454
18999
|
}
|
|
17455
|
-
if (
|
|
17456
|
-
|
|
19000
|
+
if (path21.length > 0 && trailingSeparator) {
|
|
19001
|
+
path21 += "/";
|
|
17457
19002
|
}
|
|
17458
|
-
if (
|
|
17459
|
-
return "/" +
|
|
19003
|
+
if (isAbsolute2) {
|
|
19004
|
+
return "/" + path21;
|
|
17460
19005
|
}
|
|
17461
|
-
return
|
|
19006
|
+
return path21;
|
|
17462
19007
|
};
|
|
17463
19008
|
|
|
17464
19009
|
// src/get-extension-of-filename.ts
|
|
@@ -17615,8 +19160,8 @@ var validateSelectedPixelFormatAndCodecCombination = (pixelFormat, codec) => {
|
|
|
17615
19160
|
};
|
|
17616
19161
|
|
|
17617
19162
|
// src/render-frames.ts
|
|
17618
|
-
import
|
|
17619
|
-
import
|
|
19163
|
+
import fs16 from "node:fs";
|
|
19164
|
+
import path22 from "node:path";
|
|
17620
19165
|
import { NoReactInternals as NoReactInternals12 } from "remotion/no-react";
|
|
17621
19166
|
|
|
17622
19167
|
// src/cycle-browser-tabs.ts
|
|
@@ -17668,7 +19213,7 @@ var cycleBrowserTabs = ({
|
|
|
17668
19213
|
|
|
17669
19214
|
// src/combine-audio.ts
|
|
17670
19215
|
import { rmSync as rmSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
17671
|
-
import { join as
|
|
19216
|
+
import { join as join4 } from "path";
|
|
17672
19217
|
import { VERSION as VERSION4 } from "remotion/version";
|
|
17673
19218
|
|
|
17674
19219
|
// src/options/separate-audio.tsx
|
|
@@ -17925,7 +19470,7 @@ var encodeAudio = async ({
|
|
|
17925
19470
|
}) => {
|
|
17926
19471
|
const fileList = files.map((p) => `file '${p}'`).join(`
|
|
17927
19472
|
`);
|
|
17928
|
-
const fileListTxt =
|
|
19473
|
+
const fileListTxt = join4(filelistDir, "audio-files.txt");
|
|
17929
19474
|
writeFileSync2(fileListTxt, fileList);
|
|
17930
19475
|
const startCombining = Date.now();
|
|
17931
19476
|
const command = [
|
|
@@ -18007,7 +19552,7 @@ var combineAudioSeamlessly = async ({
|
|
|
18007
19552
|
`);
|
|
18008
19553
|
}).join(`
|
|
18009
19554
|
`);
|
|
18010
|
-
const fileListTxt =
|
|
19555
|
+
const fileListTxt = join4(filelistDir, "audio-files.txt");
|
|
18011
19556
|
writeFileSync2(fileListTxt, fileList);
|
|
18012
19557
|
const command = [
|
|
18013
19558
|
"-hide_banner",
|
|
@@ -18469,7 +20014,7 @@ var getRetriesLeftFromError = (error) => {
|
|
|
18469
20014
|
};
|
|
18470
20015
|
|
|
18471
20016
|
// src/render-frame-with-option-to-reject.ts
|
|
18472
|
-
import
|
|
20017
|
+
import path21 from "path";
|
|
18473
20018
|
|
|
18474
20019
|
// src/collect-assets.ts
|
|
18475
20020
|
var collectAssets = async ({
|
|
@@ -18548,14 +20093,14 @@ var onlyInlineAudio = (assets) => {
|
|
|
18548
20093
|
import * as assert2 from "node:assert";
|
|
18549
20094
|
|
|
18550
20095
|
// src/screenshot-task.ts
|
|
18551
|
-
import
|
|
20096
|
+
import fs15 from "node:fs";
|
|
18552
20097
|
var screenshotTask = async ({
|
|
18553
20098
|
format: format2,
|
|
18554
20099
|
height,
|
|
18555
20100
|
omitBackground,
|
|
18556
20101
|
page,
|
|
18557
20102
|
width,
|
|
18558
|
-
path:
|
|
20103
|
+
path: path21,
|
|
18559
20104
|
jpegQuality,
|
|
18560
20105
|
scale
|
|
18561
20106
|
}) => {
|
|
@@ -18607,11 +20152,11 @@ var screenshotTask = async ({
|
|
|
18607
20152
|
if (omitBackground) {
|
|
18608
20153
|
await client.send("Emulation.setDefaultBackgroundColorOverride");
|
|
18609
20154
|
}
|
|
18610
|
-
const
|
|
18611
|
-
if (
|
|
18612
|
-
await
|
|
20155
|
+
const buffer2 = Buffer.from(result.data, "base64");
|
|
20156
|
+
if (path21) {
|
|
20157
|
+
await fs15.promises.writeFile(path21, buffer2);
|
|
18613
20158
|
}
|
|
18614
|
-
return
|
|
20159
|
+
return buffer2;
|
|
18615
20160
|
} catch (err) {
|
|
18616
20161
|
if (err.message.includes("Unable to capture screenshot")) {
|
|
18617
20162
|
const errMessage = [
|
|
@@ -18625,21 +20170,21 @@ var screenshotTask = async ({
|
|
|
18625
20170
|
};
|
|
18626
20171
|
|
|
18627
20172
|
// src/puppeteer-screenshot.ts
|
|
18628
|
-
var screenshot = (
|
|
18629
|
-
if (
|
|
18630
|
-
assert2.ok(typeof
|
|
18631
|
-
assert2.ok(Number.isInteger(
|
|
18632
|
-
assert2.ok(
|
|
18633
|
-
}
|
|
18634
|
-
return
|
|
18635
|
-
page:
|
|
18636
|
-
format:
|
|
18637
|
-
height:
|
|
18638
|
-
width:
|
|
18639
|
-
omitBackground:
|
|
18640
|
-
path:
|
|
18641
|
-
jpegQuality:
|
|
18642
|
-
scale:
|
|
20173
|
+
var screenshot = (options2) => {
|
|
20174
|
+
if (options2.jpegQuality) {
|
|
20175
|
+
assert2.ok(typeof options2.jpegQuality === "number", "Expected options.quality to be a number but found " + typeof options2.jpegQuality);
|
|
20176
|
+
assert2.ok(Number.isInteger(options2.jpegQuality), "Expected options.quality to be an integer");
|
|
20177
|
+
assert2.ok(options2.jpegQuality >= 0 && options2.jpegQuality <= 100, "Expected options.quality to be between 0 and 100 (inclusive), got " + options2.jpegQuality);
|
|
20178
|
+
}
|
|
20179
|
+
return options2.page.screenshotTaskQueue.postTask(() => screenshotTask({
|
|
20180
|
+
page: options2.page,
|
|
20181
|
+
format: options2.type,
|
|
20182
|
+
height: options2.height,
|
|
20183
|
+
width: options2.width,
|
|
20184
|
+
omitBackground: options2.omitBackground,
|
|
20185
|
+
path: options2.path,
|
|
20186
|
+
jpegQuality: options2.type === "jpeg" ? options2.jpegQuality : undefined,
|
|
20187
|
+
scale: options2.scale
|
|
18643
20188
|
}));
|
|
18644
20189
|
};
|
|
18645
20190
|
|
|
@@ -18764,12 +20309,12 @@ var renderFrameWithOptionToReject = async ({
|
|
|
18764
20309
|
if (outputDir && onFrameBuffer && imageFormat !== "none") {
|
|
18765
20310
|
throw new Error("Pass either `outputDir` or `onFrameBuffer` to renderFrames(), not both.");
|
|
18766
20311
|
}
|
|
18767
|
-
const [
|
|
20312
|
+
const [buffer2, collectedAssets] = await Promise.all([
|
|
18768
20313
|
takeFrame({
|
|
18769
20314
|
freePage: page,
|
|
18770
20315
|
height,
|
|
18771
20316
|
imageFormat: assetsOnly ? "none" : imageFormat,
|
|
18772
|
-
output: index === null ? null :
|
|
20317
|
+
output: index === null ? null : path21.join(frameDir, getFrameOutputFileName({
|
|
18773
20318
|
frame,
|
|
18774
20319
|
imageFormat,
|
|
18775
20320
|
index,
|
|
@@ -18791,10 +20336,10 @@ var renderFrameWithOptionToReject = async ({
|
|
|
18791
20336
|
})
|
|
18792
20337
|
]);
|
|
18793
20338
|
if (onFrameBuffer && !assetsOnly) {
|
|
18794
|
-
if (!
|
|
20339
|
+
if (!buffer2) {
|
|
18795
20340
|
throw new Error("unexpected null buffer");
|
|
18796
20341
|
}
|
|
18797
|
-
onFrameBuffer(
|
|
20342
|
+
onFrameBuffer(buffer2, frame);
|
|
18798
20343
|
}
|
|
18799
20344
|
const onlyAvailableAssets = assets.filter(truthy);
|
|
18800
20345
|
const previousAudioRenderAssets = onlyAvailableAssets.map((a) => a.audioAndVideoAssets).flat(2);
|
|
@@ -18802,7 +20347,7 @@ var renderFrameWithOptionToReject = async ({
|
|
|
18802
20347
|
const audioAndVideoAssets = onlyAudioAndVideoAssets(collectedAssets);
|
|
18803
20348
|
const artifactAssets = onlyArtifact({
|
|
18804
20349
|
assets: collectedAssets,
|
|
18805
|
-
frameBuffer:
|
|
20350
|
+
frameBuffer: buffer2
|
|
18806
20351
|
});
|
|
18807
20352
|
for (const artifact of artifactAssets) {
|
|
18808
20353
|
for (const previousArtifact of previousArtifactAssets) {
|
|
@@ -19248,8 +20793,8 @@ var innerRenderFrames = async ({
|
|
|
19248
20793
|
sampleRate
|
|
19249
20794
|
}) => {
|
|
19250
20795
|
if (outputDir) {
|
|
19251
|
-
if (!
|
|
19252
|
-
|
|
20796
|
+
if (!fs16.existsSync(outputDir)) {
|
|
20797
|
+
fs16.mkdirSync(outputDir, {
|
|
19253
20798
|
recursive: true
|
|
19254
20799
|
});
|
|
19255
20800
|
}
|
|
@@ -19390,7 +20935,7 @@ var innerRenderFrames = async ({
|
|
|
19390
20935
|
assets: assets.sort((a, b) => {
|
|
19391
20936
|
return a.frame - b.frame;
|
|
19392
20937
|
}),
|
|
19393
|
-
imageSequenceName:
|
|
20938
|
+
imageSequenceName: path22.join(frameDir, imageSequenceName),
|
|
19394
20939
|
firstFrameIndex,
|
|
19395
20940
|
downloadMap,
|
|
19396
20941
|
trimLeftOffset,
|
|
@@ -19583,7 +21128,7 @@ var internalRenderFramesRaw = ({
|
|
|
19583
21128
|
});
|
|
19584
21129
|
};
|
|
19585
21130
|
var internalRenderFrames = wrapWithErrorHandling(internalRenderFramesRaw);
|
|
19586
|
-
var renderFrames = (
|
|
21131
|
+
var renderFrames = (options2) => {
|
|
19587
21132
|
const {
|
|
19588
21133
|
composition,
|
|
19589
21134
|
inputProps,
|
|
@@ -19621,7 +21166,7 @@ var renderFrames = (options) => {
|
|
|
19621
21166
|
imageSequencePattern,
|
|
19622
21167
|
mediaCacheSizeInBytes,
|
|
19623
21168
|
sampleRate
|
|
19624
|
-
} =
|
|
21169
|
+
} = options2;
|
|
19625
21170
|
if (!composition) {
|
|
19626
21171
|
throw new Error("No `composition` option has been specified for renderFrames()");
|
|
19627
21172
|
}
|
|
@@ -19686,9 +21231,9 @@ var renderFrames = (options) => {
|
|
|
19686
21231
|
};
|
|
19687
21232
|
|
|
19688
21233
|
// src/render-media.ts
|
|
19689
|
-
import
|
|
21234
|
+
import fs18 from "node:fs";
|
|
19690
21235
|
import os9 from "node:os";
|
|
19691
|
-
import
|
|
21236
|
+
import path27 from "node:path";
|
|
19692
21237
|
import { LicensingInternals } from "@remotion/licensing";
|
|
19693
21238
|
import { NoReactInternals as NoReactInternals15 } from "remotion/no-react";
|
|
19694
21239
|
|
|
@@ -20184,77 +21729,77 @@ var validateEvenDimensionsWithCodec = ({
|
|
|
20184
21729
|
};
|
|
20185
21730
|
|
|
20186
21731
|
// src/prespawn-ffmpeg.ts
|
|
20187
|
-
var prespawnFfmpeg = (
|
|
20188
|
-
validateDimension(
|
|
20189
|
-
validateDimension(
|
|
20190
|
-
const codec =
|
|
20191
|
-
validateFps(
|
|
21732
|
+
var prespawnFfmpeg = (options2) => {
|
|
21733
|
+
validateDimension(options2.height, "height", "passed to `stitchFramesToVideo()`");
|
|
21734
|
+
validateDimension(options2.width, "width", "passed to `stitchFramesToVideo()`");
|
|
21735
|
+
const codec = options2.codec ?? DEFAULT_CODEC;
|
|
21736
|
+
validateFps(options2.fps, "in `stitchFramesToVideo()`", codec === "gif");
|
|
20192
21737
|
validateEvenDimensionsWithCodec({
|
|
20193
|
-
width:
|
|
20194
|
-
height:
|
|
21738
|
+
width: options2.width,
|
|
21739
|
+
height: options2.height,
|
|
20195
21740
|
codec,
|
|
20196
21741
|
scale: 1,
|
|
20197
21742
|
wantsImageSequence: false,
|
|
20198
|
-
indent:
|
|
20199
|
-
logLevel:
|
|
21743
|
+
indent: options2.indent,
|
|
21744
|
+
logLevel: options2.logLevel
|
|
20200
21745
|
});
|
|
20201
|
-
const pixelFormat =
|
|
20202
|
-
const proResProfileName = getProResProfileName(codec,
|
|
21746
|
+
const pixelFormat = options2.pixelFormat ?? DEFAULT_PIXEL_FORMAT;
|
|
21747
|
+
const proResProfileName = getProResProfileName(codec, options2.proResProfile);
|
|
20203
21748
|
validateSelectedPixelFormatAndCodecCombination(pixelFormat, codec);
|
|
20204
21749
|
const ffmpegArgs = [
|
|
20205
|
-
["-r",
|
|
21750
|
+
["-r", options2.fps],
|
|
20206
21751
|
...[
|
|
20207
21752
|
["-f", "image2pipe"],
|
|
20208
|
-
["-s", `${
|
|
20209
|
-
["-vcodec",
|
|
21753
|
+
["-s", `${options2.width}x${options2.height}`],
|
|
21754
|
+
["-vcodec", options2.imageFormat === "jpeg" ? "mjpeg" : "png"],
|
|
20210
21755
|
["-i", "-"]
|
|
20211
21756
|
],
|
|
20212
21757
|
...generateFfmpegArgs({
|
|
20213
21758
|
hasPreencoded: false,
|
|
20214
21759
|
proResProfileName,
|
|
20215
21760
|
pixelFormat,
|
|
20216
|
-
x264Preset:
|
|
21761
|
+
x264Preset: options2.x264Preset,
|
|
20217
21762
|
codec,
|
|
20218
|
-
crf:
|
|
20219
|
-
videoBitrate:
|
|
20220
|
-
encodingMaxRate:
|
|
20221
|
-
encodingBufferSize:
|
|
20222
|
-
colorSpace:
|
|
20223
|
-
hardwareAcceleration:
|
|
20224
|
-
indent:
|
|
20225
|
-
logLevel:
|
|
21763
|
+
crf: options2.crf,
|
|
21764
|
+
videoBitrate: options2.videoBitrate,
|
|
21765
|
+
encodingMaxRate: options2.encodingMaxRate,
|
|
21766
|
+
encodingBufferSize: options2.encodingBufferSize,
|
|
21767
|
+
colorSpace: options2.colorSpace,
|
|
21768
|
+
hardwareAcceleration: options2.hardwareAcceleration,
|
|
21769
|
+
indent: options2.indent,
|
|
21770
|
+
logLevel: options2.logLevel
|
|
20226
21771
|
}),
|
|
20227
21772
|
"-y",
|
|
20228
|
-
|
|
21773
|
+
options2.outputLocation
|
|
20229
21774
|
];
|
|
20230
21775
|
Log.verbose({
|
|
20231
|
-
indent:
|
|
20232
|
-
logLevel:
|
|
21776
|
+
indent: options2.indent,
|
|
21777
|
+
logLevel: options2.logLevel,
|
|
20233
21778
|
tag: "prespawnFfmpeg()"
|
|
20234
21779
|
}, "Generated FFMPEG command:");
|
|
20235
21780
|
Log.verbose({
|
|
20236
|
-
indent:
|
|
20237
|
-
logLevel:
|
|
21781
|
+
indent: options2.indent,
|
|
21782
|
+
logLevel: options2.logLevel,
|
|
20238
21783
|
tag: "prespawnFfmpeg()"
|
|
20239
21784
|
}, ffmpegArgs.join(" "));
|
|
20240
21785
|
const ffmpegString = ffmpegArgs.flat(2).filter(Boolean);
|
|
20241
|
-
const finalFfmpegString =
|
|
21786
|
+
const finalFfmpegString = options2.ffmpegOverride ? options2.ffmpegOverride({ type: "pre-stitcher", args: ffmpegString }) : ffmpegString;
|
|
20242
21787
|
const task = callFf({
|
|
20243
21788
|
bin: "ffmpeg",
|
|
20244
21789
|
args: finalFfmpegString,
|
|
20245
|
-
indent:
|
|
20246
|
-
logLevel:
|
|
20247
|
-
binariesDirectory:
|
|
20248
|
-
cancelSignal:
|
|
21790
|
+
indent: options2.indent,
|
|
21791
|
+
logLevel: options2.logLevel,
|
|
21792
|
+
binariesDirectory: options2.binariesDirectory,
|
|
21793
|
+
cancelSignal: options2.signal
|
|
20249
21794
|
});
|
|
20250
21795
|
let ffmpegOutput = "";
|
|
20251
21796
|
task.stderr?.on("data", (data) => {
|
|
20252
21797
|
const str = data.toString();
|
|
20253
21798
|
ffmpegOutput += str;
|
|
20254
|
-
if (
|
|
20255
|
-
const parsed = parseFfmpegProgress(str,
|
|
21799
|
+
if (options2.onProgress) {
|
|
21800
|
+
const parsed = parseFfmpegProgress(str, options2.fps);
|
|
20256
21801
|
if (parsed !== undefined) {
|
|
20257
|
-
|
|
21802
|
+
options2.onProgress(parsed);
|
|
20258
21803
|
}
|
|
20259
21804
|
}
|
|
20260
21805
|
});
|
|
@@ -20322,7 +21867,7 @@ var validateSelectedCodecAndProResCombination = ({
|
|
|
20322
21867
|
|
|
20323
21868
|
// src/stitch-frames-to-video.ts
|
|
20324
21869
|
import { cpSync as cpSync2, promises as promises3, rmSync as rmSync4 } from "node:fs";
|
|
20325
|
-
import
|
|
21870
|
+
import path26 from "node:path";
|
|
20326
21871
|
|
|
20327
21872
|
// src/convert-number-of-gif-loops-to-ffmpeg.ts
|
|
20328
21873
|
var convertNumberOfGifLoopsToFfmpegSyntax = (loops) => {
|
|
@@ -20336,7 +21881,7 @@ var convertNumberOfGifLoopsToFfmpegSyntax = (loops) => {
|
|
|
20336
21881
|
};
|
|
20337
21882
|
|
|
20338
21883
|
// src/create-audio.ts
|
|
20339
|
-
import
|
|
21884
|
+
import path25 from "path";
|
|
20340
21885
|
|
|
20341
21886
|
// src/resolve-asset-src.ts
|
|
20342
21887
|
import url from "node:url";
|
|
@@ -20537,7 +22082,7 @@ var compressAudio = async ({
|
|
|
20537
22082
|
};
|
|
20538
22083
|
|
|
20539
22084
|
// src/merge-audio-track.ts
|
|
20540
|
-
import
|
|
22085
|
+
import path24 from "node:path";
|
|
20541
22086
|
|
|
20542
22087
|
// src/chunk.ts
|
|
20543
22088
|
var chunk2 = (input, size) => {
|
|
@@ -20568,8 +22113,8 @@ var createFfmpegMergeFilter = ({
|
|
|
20568
22113
|
};
|
|
20569
22114
|
|
|
20570
22115
|
// src/ffmpeg-filter-file.ts
|
|
20571
|
-
import
|
|
20572
|
-
import
|
|
22116
|
+
import fs17, { existsSync as existsSync5 } from "node:fs";
|
|
22117
|
+
import path23 from "node:path";
|
|
20573
22118
|
var makeFfmpegFilterFile = (complexFilter, downloadMap) => {
|
|
20574
22119
|
if (complexFilter.filter === null) {
|
|
20575
22120
|
return {
|
|
@@ -20583,15 +22128,15 @@ var makeFfmpegFilterFile = (complexFilter, downloadMap) => {
|
|
|
20583
22128
|
};
|
|
20584
22129
|
var makeFfmpegFilterFileStr = async (complexFilter, downloadMap) => {
|
|
20585
22130
|
const random2 = Math.random().toString().replace(".", "");
|
|
20586
|
-
const filterFile =
|
|
22131
|
+
const filterFile = path23.join(downloadMap.complexFilter, "complex-filter-" + random2 + ".txt");
|
|
20587
22132
|
if (!existsSync5(downloadMap.complexFilter)) {
|
|
20588
|
-
|
|
22133
|
+
fs17.mkdirSync(downloadMap.complexFilter, { recursive: true });
|
|
20589
22134
|
}
|
|
20590
|
-
await
|
|
22135
|
+
await fs17.promises.writeFile(filterFile, complexFilter);
|
|
20591
22136
|
return {
|
|
20592
22137
|
file: filterFile,
|
|
20593
22138
|
cleanup: () => {
|
|
20594
|
-
|
|
22139
|
+
fs17.unlinkSync(filterFile);
|
|
20595
22140
|
}
|
|
20596
22141
|
};
|
|
20597
22142
|
};
|
|
@@ -20693,7 +22238,7 @@ var mergeAudioTrackUnlimited = async ({
|
|
|
20693
22238
|
onProgress(combinedProgress);
|
|
20694
22239
|
};
|
|
20695
22240
|
const chunkNames = await Promise.all(chunked.map(async (chunkFiles, i) => {
|
|
20696
|
-
const chunkOutname =
|
|
22241
|
+
const chunkOutname = path24.join(tempPath, `chunk-${i}.wav`);
|
|
20697
22242
|
await mergeAudioTrack({
|
|
20698
22243
|
files: chunkFiles,
|
|
20699
22244
|
chunkLengthInSeconds,
|
|
@@ -20778,8 +22323,8 @@ var mergeAudioTrackUnlimited = async ({
|
|
|
20778
22323
|
cleanup();
|
|
20779
22324
|
};
|
|
20780
22325
|
var limit2 = pLimit(3);
|
|
20781
|
-
var mergeAudioTrack = (
|
|
20782
|
-
return limit2(mergeAudioTrackUnlimited,
|
|
22326
|
+
var mergeAudioTrack = (options2) => {
|
|
22327
|
+
return limit2(mergeAudioTrackUnlimited, options2);
|
|
20783
22328
|
};
|
|
20784
22329
|
|
|
20785
22330
|
// src/assets/calculate-atempo.ts
|
|
@@ -21109,8 +22654,8 @@ var preprocessAudioTrackUnlimited = async ({
|
|
|
21109
22654
|
return { outName, filter };
|
|
21110
22655
|
};
|
|
21111
22656
|
var limit3 = pLimit(2);
|
|
21112
|
-
var preprocessAudioTrack = (
|
|
21113
|
-
return limit3(preprocessAudioTrackUnlimited,
|
|
22657
|
+
var preprocessAudioTrack = (options2) => {
|
|
22658
|
+
return limit3(preprocessAudioTrackUnlimited, options2);
|
|
21114
22659
|
};
|
|
21115
22660
|
|
|
21116
22661
|
// src/create-audio.ts
|
|
@@ -21155,7 +22700,7 @@ var createAudio = async ({
|
|
|
21155
22700
|
onProgress(totalProgress);
|
|
21156
22701
|
};
|
|
21157
22702
|
const audioTracks = await Promise.all(assetPositions.map(async (asset, index) => {
|
|
21158
|
-
const filterFile =
|
|
22703
|
+
const filterFile = path25.join(downloadMap.audioMixing, `${index}.wav`);
|
|
21159
22704
|
const result = await preprocessAudioTrack({
|
|
21160
22705
|
outName: filterFile,
|
|
21161
22706
|
asset,
|
|
@@ -21199,9 +22744,9 @@ var createAudio = async ({
|
|
|
21199
22744
|
}
|
|
21200
22745
|
}))
|
|
21201
22746
|
];
|
|
21202
|
-
const merged =
|
|
22747
|
+
const merged = path25.join(downloadMap.audioPreprocessing, "merged.wav");
|
|
21203
22748
|
const extension = getExtensionFromAudioCodec(audioCodec);
|
|
21204
|
-
const outName =
|
|
22749
|
+
const outName = path25.join(downloadMap.audioPreprocessing, `audio.${extension}`);
|
|
21205
22750
|
await mergeAudioTrack({
|
|
21206
22751
|
files: preprocessed,
|
|
21207
22752
|
outName: merged,
|
|
@@ -21379,7 +22924,7 @@ var innerStitchFramesToVideo = async ({
|
|
|
21379
22924
|
setting: audioCodecSetting,
|
|
21380
22925
|
separateAudioTo
|
|
21381
22926
|
});
|
|
21382
|
-
const tempFile = outputLocation ? null :
|
|
22927
|
+
const tempFile = outputLocation ? null : path26.join(assetsInfo.downloadMap.stitchFrames, `out.${getFileExtensionFromCodec(codec, resolvedAudioCodec)}`);
|
|
21383
22928
|
Log.verbose({
|
|
21384
22929
|
indent,
|
|
21385
22930
|
logLevel,
|
|
@@ -21454,7 +22999,7 @@ var innerStitchFramesToVideo = async ({
|
|
|
21454
22999
|
}
|
|
21455
23000
|
cpSync2(audio, outputLocation ?? tempFile);
|
|
21456
23001
|
onProgress?.(Math.round(assetsInfo.chunkLengthInSeconds * fps));
|
|
21457
|
-
deleteDirectory(
|
|
23002
|
+
deleteDirectory(path26.dirname(audio));
|
|
21458
23003
|
const file = await new Promise((resolve2, reject) => {
|
|
21459
23004
|
if (tempFile) {
|
|
21460
23005
|
promises3.readFile(tempFile).then((f) => {
|
|
@@ -21543,7 +23088,7 @@ var innerStitchFramesToVideo = async ({
|
|
|
21543
23088
|
if (!audio) {
|
|
21544
23089
|
throw new Error(`\`separateAudioTo\` was set to ${JSON.stringify(separateAudioTo)}, but this render included no audio`);
|
|
21545
23090
|
}
|
|
21546
|
-
const finalDestination =
|
|
23091
|
+
const finalDestination = path26.resolve(remotionRoot, separateAudioTo);
|
|
21547
23092
|
cpSync2(audio, finalDestination);
|
|
21548
23093
|
rmSync4(audio);
|
|
21549
23094
|
}
|
|
@@ -21569,13 +23114,13 @@ var innerStitchFramesToVideo = async ({
|
|
|
21569
23114
|
assetsInfo.downloadMap.allowCleanup();
|
|
21570
23115
|
return result;
|
|
21571
23116
|
};
|
|
21572
|
-
var internalStitchFramesToVideo = (
|
|
23117
|
+
var internalStitchFramesToVideo = (options2) => {
|
|
21573
23118
|
const remotionRoot = findRemotionRoot();
|
|
21574
|
-
const task = innerStitchFramesToVideo(
|
|
23119
|
+
const task = innerStitchFramesToVideo(options2, remotionRoot);
|
|
21575
23120
|
return Promise.race([
|
|
21576
23121
|
task,
|
|
21577
23122
|
new Promise((_resolve, reject) => {
|
|
21578
|
-
|
|
23123
|
+
options2.cancelSignal?.(() => {
|
|
21579
23124
|
reject(new Error(cancelErrorMessages.stitchFramesToVideo));
|
|
21580
23125
|
});
|
|
21581
23126
|
})
|
|
@@ -21872,7 +23417,7 @@ var internalRenderMediaRaw = ({
|
|
|
21872
23417
|
separateAudioTo
|
|
21873
23418
|
});
|
|
21874
23419
|
}
|
|
21875
|
-
const absoluteOutputLocation = outputLocation ?
|
|
23420
|
+
const absoluteOutputLocation = outputLocation ? path27.resolve(process.cwd(), outputLocation) : null;
|
|
21876
23421
|
validateScale(scale);
|
|
21877
23422
|
validateFfmpegOverride(ffmpegOverride);
|
|
21878
23423
|
validateEveryNthFrame(everyNthFrame);
|
|
@@ -21938,8 +23483,8 @@ var internalRenderMediaRaw = ({
|
|
|
21938
23483
|
}
|
|
21939
23484
|
const imageFormat = isAudioCodec(codec) ? "none" : provisionalImageFormat ?? compositionWithPossibleUnevenDimensions.defaultVideoImageFormat ?? DEFAULT_VIDEO_IMAGE_FORMAT;
|
|
21940
23485
|
validateSelectedPixelFormatAndImageFormatCombination(pixelFormat, imageFormat);
|
|
21941
|
-
const workingDir =
|
|
21942
|
-
const preEncodedFileLocation = parallelEncoding ?
|
|
23486
|
+
const workingDir = fs18.mkdtempSync(path27.join(os9.tmpdir(), "react-motion-render"));
|
|
23487
|
+
const preEncodedFileLocation = parallelEncoding ? path27.join(workingDir, "pre-encode." + getFileExtensionFromCodec(codec, audioCodec)) : null;
|
|
21943
23488
|
if (onCtrlCExit && workingDir) {
|
|
21944
23489
|
onCtrlCExit(`Delete ${workingDir}`, () => deleteDirectory(workingDir));
|
|
21945
23490
|
}
|
|
@@ -22100,7 +23645,7 @@ var internalRenderMediaRaw = ({
|
|
|
22100
23645
|
frameRange,
|
|
22101
23646
|
puppeteerInstance,
|
|
22102
23647
|
everyNthFrame,
|
|
22103
|
-
onFrameBuffer: parallelEncoding ? async (
|
|
23648
|
+
onFrameBuffer: parallelEncoding ? async (buffer2, frame) => {
|
|
22104
23649
|
await waitForRightTimeOfFrameToBeInserted(frame);
|
|
22105
23650
|
if (cancelled) {
|
|
22106
23651
|
return;
|
|
@@ -22113,7 +23658,7 @@ var internalRenderMediaRaw = ({
|
|
|
22113
23658
|
if (exitStatus?.type === "quit-with-error") {
|
|
22114
23659
|
throw new Error(`FFmpeg quit with code ${exitStatus.exitCode}${exitStatus.signal ? ` (signal ${exitStatus.signal})` : ""} while piping frame ${frame}. Stderr: ${exitStatus.stderr}`);
|
|
22115
23660
|
}
|
|
22116
|
-
stitcherFfmpeg?.stdin?.write(
|
|
23661
|
+
stitcherFfmpeg?.stdin?.write(buffer2);
|
|
22117
23662
|
stopPerfMeasure(id);
|
|
22118
23663
|
setFrameToStitch(Math.min(realFrameRange[1] + 1, frame + everyNthFrame));
|
|
22119
23664
|
} : null,
|
|
@@ -22207,11 +23752,11 @@ var internalRenderMediaRaw = ({
|
|
|
22207
23752
|
hardwareAcceleration,
|
|
22208
23753
|
sampleRate
|
|
22209
23754
|
});
|
|
22210
|
-
}).then((
|
|
23755
|
+
}).then((buffer2) => {
|
|
22211
23756
|
Log.verbose({ indent, logLevel }, "Stitching done in", encodedDoneIn + "ms");
|
|
22212
23757
|
slowestFrames.sort((a, b) => b.time - a.time);
|
|
22213
23758
|
const result = {
|
|
22214
|
-
buffer,
|
|
23759
|
+
buffer: buffer2,
|
|
22215
23760
|
slowestFrames,
|
|
22216
23761
|
contentType: mimeLookup("file." + getFileExtensionFromCodec(codec, audioCodec)) || "application/octet-stream"
|
|
22217
23762
|
};
|
|
@@ -22267,10 +23812,10 @@ var internalRenderMediaRaw = ({
|
|
|
22267
23812
|
}
|
|
22268
23813
|
reject(err);
|
|
22269
23814
|
}).finally(() => {
|
|
22270
|
-
if (preEncodedFileLocation !== null &&
|
|
22271
|
-
deleteDirectory(
|
|
23815
|
+
if (preEncodedFileLocation !== null && fs18.existsSync(preEncodedFileLocation)) {
|
|
23816
|
+
deleteDirectory(path27.dirname(preEncodedFileLocation));
|
|
22272
23817
|
}
|
|
22273
|
-
if (workingDir &&
|
|
23818
|
+
if (workingDir && fs18.existsSync(workingDir)) {
|
|
22274
23819
|
deleteDirectory(workingDir);
|
|
22275
23820
|
}
|
|
22276
23821
|
cleanupServerFn?.(false).catch((err) => {
|
|
@@ -22439,8 +23984,8 @@ var renderMedia = ({
|
|
|
22439
23984
|
};
|
|
22440
23985
|
|
|
22441
23986
|
// src/render-still.ts
|
|
22442
|
-
import
|
|
22443
|
-
import
|
|
23987
|
+
import fs19, { statSync as statSync2 } from "node:fs";
|
|
23988
|
+
import path28 from "node:path";
|
|
22444
23989
|
import { LicensingInternals as LicensingInternals2 } from "@remotion/licensing";
|
|
22445
23990
|
import { NoReactInternals as NoReactInternals16 } from "remotion/no-react";
|
|
22446
23991
|
var innerRenderStill = async ({
|
|
@@ -22491,10 +24036,10 @@ var innerRenderStill = async ({
|
|
|
22491
24036
|
});
|
|
22492
24037
|
validatePuppeteerTimeout(timeoutInMilliseconds);
|
|
22493
24038
|
validateScale(scale);
|
|
22494
|
-
output = typeof output === "string" ?
|
|
24039
|
+
output = typeof output === "string" ? path28.resolve(process.cwd(), output) : null;
|
|
22495
24040
|
validateJpegQuality(jpegQuality);
|
|
22496
24041
|
if (output) {
|
|
22497
|
-
if (
|
|
24042
|
+
if (fs19.existsSync(output)) {
|
|
22498
24043
|
if (!overwrite) {
|
|
22499
24044
|
throw new Error(`Cannot render still - "overwrite" option was set to false, but the output destination ${output} already exists.`);
|
|
22500
24045
|
}
|
|
@@ -22618,7 +24163,7 @@ var innerRenderStill = async ({
|
|
|
22618
24163
|
logLevel,
|
|
22619
24164
|
attempt: 0
|
|
22620
24165
|
});
|
|
22621
|
-
const [
|
|
24166
|
+
const [buffer2, collectedAssets] = await Promise.all([
|
|
22622
24167
|
takeFrame({
|
|
22623
24168
|
freePage: page,
|
|
22624
24169
|
height: composition.height,
|
|
@@ -22638,7 +24183,7 @@ var innerRenderStill = async ({
|
|
|
22638
24183
|
]);
|
|
22639
24184
|
const artifactAssets = onlyArtifact({
|
|
22640
24185
|
assets: collectedAssets,
|
|
22641
|
-
frameBuffer:
|
|
24186
|
+
frameBuffer: buffer2
|
|
22642
24187
|
});
|
|
22643
24188
|
const previousArtifactAssets = [];
|
|
22644
24189
|
for (const artifact of artifactAssets) {
|
|
@@ -22652,61 +24197,61 @@ var innerRenderStill = async ({
|
|
|
22652
24197
|
}
|
|
22653
24198
|
await cleanup();
|
|
22654
24199
|
return {
|
|
22655
|
-
buffer: output ? null :
|
|
24200
|
+
buffer: output ? null : buffer2,
|
|
22656
24201
|
contentType: mimeLookup("file." + imageFormat) || "application/octet-stream"
|
|
22657
24202
|
};
|
|
22658
24203
|
};
|
|
22659
|
-
var internalRenderStillRaw = (
|
|
24204
|
+
var internalRenderStillRaw = (options2) => {
|
|
22660
24205
|
const cleanup = [];
|
|
22661
24206
|
const happyPath = new Promise((resolve2, reject) => {
|
|
22662
24207
|
const onError = (err) => reject(err);
|
|
22663
|
-
makeOrReuseServer(
|
|
22664
|
-
webpackConfigOrServeUrl:
|
|
22665
|
-
port:
|
|
24208
|
+
makeOrReuseServer(options2.server, {
|
|
24209
|
+
webpackConfigOrServeUrl: options2.serveUrl,
|
|
24210
|
+
port: options2.port,
|
|
22666
24211
|
remotionRoot: findRemotionRoot(),
|
|
22667
|
-
offthreadVideoThreads:
|
|
22668
|
-
logLevel:
|
|
22669
|
-
indent:
|
|
22670
|
-
offthreadVideoCacheSizeInBytes:
|
|
22671
|
-
binariesDirectory:
|
|
24212
|
+
offthreadVideoThreads: options2.offthreadVideoThreads ?? 2,
|
|
24213
|
+
logLevel: options2.logLevel,
|
|
24214
|
+
indent: options2.indent,
|
|
24215
|
+
offthreadVideoCacheSizeInBytes: options2.offthreadVideoCacheSizeInBytes,
|
|
24216
|
+
binariesDirectory: options2.binariesDirectory,
|
|
22672
24217
|
forceIPv4: false,
|
|
22673
24218
|
sampleRate: 48000
|
|
22674
24219
|
}, {
|
|
22675
|
-
onDownload:
|
|
24220
|
+
onDownload: options2.onDownload
|
|
22676
24221
|
}).then(({ server, cleanupServer }) => {
|
|
22677
24222
|
cleanup.push(() => cleanupServer(false));
|
|
22678
24223
|
const { serveUrl, offthreadPort, sourceMap: sourceMapGetter } = server;
|
|
22679
24224
|
return innerRenderStill({
|
|
22680
|
-
...
|
|
24225
|
+
...options2,
|
|
22681
24226
|
serveUrl,
|
|
22682
24227
|
onError,
|
|
22683
24228
|
proxyPort: offthreadPort,
|
|
22684
24229
|
sourceMapGetter
|
|
22685
24230
|
});
|
|
22686
24231
|
}).then((res) => {
|
|
22687
|
-
if (
|
|
24232
|
+
if (options2.licenseKey === null) {
|
|
22688
24233
|
resolve2(res);
|
|
22689
24234
|
return;
|
|
22690
24235
|
}
|
|
22691
24236
|
LicensingInternals2.internalRegisterUsageEvent({
|
|
22692
|
-
licenseKey:
|
|
24237
|
+
licenseKey: options2.licenseKey,
|
|
22693
24238
|
event: "cloud-render",
|
|
22694
24239
|
host: null,
|
|
22695
24240
|
succeeded: true,
|
|
22696
24241
|
isStill: true,
|
|
22697
|
-
isProduction:
|
|
24242
|
+
isProduction: options2.isProduction ?? true
|
|
22698
24243
|
}).then(() => {
|
|
22699
|
-
Log.verbose(
|
|
24244
|
+
Log.verbose(options2, "Usage event sent successfully");
|
|
22700
24245
|
}).catch((err) => {
|
|
22701
|
-
Log.error(
|
|
22702
|
-
Log.error(
|
|
24246
|
+
Log.error(options2, "Failed to send usage event");
|
|
24247
|
+
Log.error(options2, err);
|
|
22703
24248
|
}).finally(() => {
|
|
22704
24249
|
resolve2(res);
|
|
22705
24250
|
});
|
|
22706
24251
|
}).catch((err) => reject(err)).finally(() => {
|
|
22707
24252
|
cleanup.forEach((c) => {
|
|
22708
24253
|
c().catch((err) => {
|
|
22709
|
-
Log.error(
|
|
24254
|
+
Log.error(options2, "Cleanup error:", err);
|
|
22710
24255
|
});
|
|
22711
24256
|
});
|
|
22712
24257
|
});
|
|
@@ -22714,14 +24259,14 @@ var internalRenderStillRaw = (options) => {
|
|
|
22714
24259
|
return Promise.race([
|
|
22715
24260
|
happyPath,
|
|
22716
24261
|
new Promise((_resolve, reject) => {
|
|
22717
|
-
|
|
24262
|
+
options2.cancelSignal?.(() => {
|
|
22718
24263
|
reject(new Error(cancelErrorMessages.renderStill));
|
|
22719
24264
|
});
|
|
22720
24265
|
})
|
|
22721
24266
|
]);
|
|
22722
24267
|
};
|
|
22723
24268
|
var internalRenderStill = wrapWithErrorHandling(internalRenderStillRaw);
|
|
22724
|
-
var renderStill = (
|
|
24269
|
+
var renderStill = (options2) => {
|
|
22725
24270
|
const {
|
|
22726
24271
|
composition,
|
|
22727
24272
|
serveUrl,
|
|
@@ -22755,7 +24300,7 @@ var renderStill = (options) => {
|
|
|
22755
24300
|
apiKey,
|
|
22756
24301
|
licenseKey,
|
|
22757
24302
|
isProduction
|
|
22758
|
-
} =
|
|
24303
|
+
} = options2;
|
|
22759
24304
|
if (typeof jpegQuality !== "undefined" && imageFormat !== "jpeg") {
|
|
22760
24305
|
throw new Error("You can only pass the `quality` option if `imageFormat` is 'jpeg'.");
|
|
22761
24306
|
}
|
|
@@ -22919,7 +24464,7 @@ var innerSelectComposition = async ({
|
|
|
22919
24464
|
propsSize: size
|
|
22920
24465
|
};
|
|
22921
24466
|
};
|
|
22922
|
-
var internalSelectCompositionRaw = async (
|
|
24467
|
+
var internalSelectCompositionRaw = async (options2) => {
|
|
22923
24468
|
const cleanup = [];
|
|
22924
24469
|
const {
|
|
22925
24470
|
puppeteerInstance,
|
|
@@ -22941,7 +24486,7 @@ var internalSelectCompositionRaw = async (options) => {
|
|
|
22941
24486
|
onServeUrlVisited,
|
|
22942
24487
|
chromeMode,
|
|
22943
24488
|
mediaCacheSizeInBytes
|
|
22944
|
-
} =
|
|
24489
|
+
} = options2;
|
|
22945
24490
|
const [{ page, cleanupPage }, serverUsed] = await Promise.all([
|
|
22946
24491
|
getPageAndCleanupFn({
|
|
22947
24492
|
passedInInstance: puppeteerInstance,
|
|
@@ -22956,7 +24501,7 @@ var internalSelectCompositionRaw = async (options) => {
|
|
|
22956
24501
|
onBrowserLog,
|
|
22957
24502
|
onLog: RenderInternals.defaultOnLog
|
|
22958
24503
|
}),
|
|
22959
|
-
makeOrReuseServer(
|
|
24504
|
+
makeOrReuseServer(options2.server, {
|
|
22960
24505
|
webpackConfigOrServeUrl: serveUrlOrWebpackUrl,
|
|
22961
24506
|
port,
|
|
22962
24507
|
remotionRoot: findRemotionRoot(),
|
|
@@ -23019,7 +24564,7 @@ var internalSelectCompositionRaw = async (options) => {
|
|
|
23019
24564
|
});
|
|
23020
24565
|
};
|
|
23021
24566
|
var internalSelectComposition = wrapWithErrorHandling(internalSelectCompositionRaw);
|
|
23022
|
-
var selectComposition = async (
|
|
24567
|
+
var selectComposition = async (options2) => {
|
|
23023
24568
|
const {
|
|
23024
24569
|
id,
|
|
23025
24570
|
serveUrl,
|
|
@@ -23039,7 +24584,7 @@ var selectComposition = async (options) => {
|
|
|
23039
24584
|
chromeMode,
|
|
23040
24585
|
offthreadVideoThreads,
|
|
23041
24586
|
mediaCacheSizeInBytes
|
|
23042
|
-
} =
|
|
24587
|
+
} = options2;
|
|
23043
24588
|
const indent = false;
|
|
23044
24589
|
const logLevel = passedLogLevel ?? (verbose ? "verbose" : "info");
|
|
23045
24590
|
const data = await internalSelectComposition({
|
|
@@ -23159,10 +24704,9 @@ var getMaxConcurrency = () => {
|
|
|
23159
24704
|
return getCpuCount();
|
|
23160
24705
|
};
|
|
23161
24706
|
var getMinConcurrency = () => 1;
|
|
23162
|
-
|
|
23163
24707
|
// src/combine-chunks.ts
|
|
23164
24708
|
import { rmSync as rmSync6 } from "node:fs";
|
|
23165
|
-
import { join as
|
|
24709
|
+
import { join as join6 } from "node:path";
|
|
23166
24710
|
|
|
23167
24711
|
// src/can-concat-seamlessly.ts
|
|
23168
24712
|
var canConcatAudioSeamlessly = (audioCodec, chunkDurationInFrames) => {
|
|
@@ -23177,7 +24721,7 @@ var canConcatVideoSeamlessly = (codec) => {
|
|
|
23177
24721
|
|
|
23178
24722
|
// src/combine-video-streams.ts
|
|
23179
24723
|
import { rmSync as rmSync5, writeFileSync as writeFileSync3 } from "fs";
|
|
23180
|
-
import { join as
|
|
24724
|
+
import { join as join5 } from "path";
|
|
23181
24725
|
import { VERSION as VERSION6 } from "remotion/version";
|
|
23182
24726
|
var combineVideoStreams = async ({
|
|
23183
24727
|
fps,
|
|
@@ -23195,7 +24739,7 @@ var combineVideoStreams = async ({
|
|
|
23195
24739
|
}) => {
|
|
23196
24740
|
const fileList = files.map((p) => `file '${p}'`).join(`
|
|
23197
24741
|
`);
|
|
23198
|
-
const fileListTxt =
|
|
24742
|
+
const fileListTxt = join5(filelistDir, "video-files.txt");
|
|
23199
24743
|
writeFileSync3(fileListTxt, fileList);
|
|
23200
24744
|
const encoder = codec === "gif" ? "gif" : "copy";
|
|
23201
24745
|
const command = [
|
|
@@ -23372,8 +24916,8 @@ var internalCombineChunks = async ({
|
|
|
23372
24916
|
const seamlessAudio = canConcatAudioSeamlessly(resolvedAudioCodec, framesPerChunk);
|
|
23373
24917
|
const realFrameRange = getRealFrameRange(compositionDurationInFrames, frameRange);
|
|
23374
24918
|
const numberOfFrames = getFramesToRender(realFrameRange, everyNthFrame).length;
|
|
23375
|
-
const videoOutput = shouldCreateVideo ?
|
|
23376
|
-
const audioOutput = shouldCreateAudio ?
|
|
24919
|
+
const videoOutput = shouldCreateVideo ? join6(filelistDir, `video.${getFileExtensionFromCodec(codec, resolvedAudioCodec)}`) : null;
|
|
24920
|
+
const audioOutput = shouldCreateAudio ? join6(filelistDir, `audio.${getExtensionFromAudioCodec(resolvedAudioCodec)}`) : null;
|
|
23377
24921
|
const chunkDurationInSeconds = framesPerChunk / fps;
|
|
23378
24922
|
let concatenatedAudio = 0;
|
|
23379
24923
|
let concatenatedVideo = 0;
|
|
@@ -23451,42 +24995,42 @@ var internalCombineChunks = async ({
|
|
|
23451
24995
|
throw err;
|
|
23452
24996
|
}
|
|
23453
24997
|
};
|
|
23454
|
-
var combineChunks = (
|
|
24998
|
+
var combineChunks = (options2) => {
|
|
23455
24999
|
return internalCombineChunks({
|
|
23456
|
-
audioBitrate:
|
|
23457
|
-
numberOfGifLoops:
|
|
25000
|
+
audioBitrate: options2.audioBitrate ?? null,
|
|
25001
|
+
numberOfGifLoops: options2.numberOfGifLoops ?? null,
|
|
23458
25002
|
indent: false,
|
|
23459
|
-
logLevel:
|
|
23460
|
-
binariesDirectory:
|
|
23461
|
-
cancelSignal:
|
|
23462
|
-
metadata:
|
|
23463
|
-
audioCodec:
|
|
23464
|
-
preferLossless:
|
|
23465
|
-
audioFiles:
|
|
23466
|
-
codec:
|
|
23467
|
-
fps:
|
|
23468
|
-
framesPerChunk:
|
|
23469
|
-
outputLocation:
|
|
23470
|
-
onProgress:
|
|
23471
|
-
videoFiles:
|
|
23472
|
-
everyNthFrame:
|
|
23473
|
-
frameRange:
|
|
23474
|
-
compositionDurationInFrames:
|
|
23475
|
-
sampleRate:
|
|
25003
|
+
logLevel: options2.logLevel ?? "info",
|
|
25004
|
+
binariesDirectory: options2.binariesDirectory ?? null,
|
|
25005
|
+
cancelSignal: options2.cancelSignal,
|
|
25006
|
+
metadata: options2.metadata ?? null,
|
|
25007
|
+
audioCodec: options2.audioCodec ?? null,
|
|
25008
|
+
preferLossless: options2.preferLossless,
|
|
25009
|
+
audioFiles: options2.audioFiles,
|
|
25010
|
+
codec: options2.codec,
|
|
25011
|
+
fps: options2.fps,
|
|
25012
|
+
framesPerChunk: options2.framesPerChunk,
|
|
25013
|
+
outputLocation: options2.outputLocation,
|
|
25014
|
+
onProgress: options2.onProgress ?? (() => {}),
|
|
25015
|
+
videoFiles: options2.videoFiles,
|
|
25016
|
+
everyNthFrame: options2.everyNthFrame ?? 1,
|
|
25017
|
+
frameRange: options2.frameRange ?? null,
|
|
25018
|
+
compositionDurationInFrames: options2.compositionDurationInFrames,
|
|
25019
|
+
sampleRate: options2.sampleRate ?? 48000
|
|
23476
25020
|
});
|
|
23477
25021
|
};
|
|
23478
25022
|
// src/extract-audio.ts
|
|
23479
|
-
var extractAudio = async (
|
|
25023
|
+
var extractAudio = async (options2) => {
|
|
23480
25024
|
const compositor = startLongRunningCompositor({
|
|
23481
25025
|
maximumFrameCacheItemsInBytes: null,
|
|
23482
|
-
logLevel:
|
|
25026
|
+
logLevel: options2?.logLevel ?? "info",
|
|
23483
25027
|
indent: false,
|
|
23484
|
-
binariesDirectory:
|
|
25028
|
+
binariesDirectory: options2.binariesDirectory ?? null,
|
|
23485
25029
|
extraThreads: 0
|
|
23486
25030
|
});
|
|
23487
25031
|
await compositor.executeCommand("ExtractAudio", {
|
|
23488
|
-
input_path:
|
|
23489
|
-
output_path:
|
|
25032
|
+
input_path: options2.videoSource,
|
|
25033
|
+
output_path: options2.audioOutput
|
|
23490
25034
|
});
|
|
23491
25035
|
await compositor.finishCommands();
|
|
23492
25036
|
await compositor.waitForDone();
|
|
@@ -23560,12 +25104,12 @@ var getAudibleParts = ({
|
|
|
23560
25104
|
};
|
|
23561
25105
|
// src/get-video-metadata.ts
|
|
23562
25106
|
import { resolve as resolve2 } from "node:path";
|
|
23563
|
-
var getVideoMetadata = async (videoSource,
|
|
25107
|
+
var getVideoMetadata = async (videoSource, options2) => {
|
|
23564
25108
|
const compositor = startLongRunningCompositor({
|
|
23565
25109
|
maximumFrameCacheItemsInBytes: null,
|
|
23566
|
-
logLevel:
|
|
25110
|
+
logLevel: options2?.logLevel ?? "info",
|
|
23567
25111
|
indent: false,
|
|
23568
|
-
binariesDirectory:
|
|
25112
|
+
binariesDirectory: options2?.binariesDirectory ?? null,
|
|
23569
25113
|
extraThreads: 0
|
|
23570
25114
|
});
|
|
23571
25115
|
const metadataResponse = await compositor.executeCommand("GetVideoMetadata", {
|
|
@@ -23575,6 +25119,12 @@ var getVideoMetadata = async (videoSource, options) => {
|
|
|
23575
25119
|
await compositor.waitForDone();
|
|
23576
25120
|
return JSON.parse(new TextDecoder("utf-8").decode(metadataResponse));
|
|
23577
25121
|
};
|
|
25122
|
+
// src/options/chrome-mode.tsx
|
|
25123
|
+
import { jsx as jsx6, jsxs as jsxs6, Fragment as Fragment6 } from "react/jsx-runtime";
|
|
25124
|
+
// src/options/number-of-gif-loops.tsx
|
|
25125
|
+
import { jsx as jsx7, jsxs as jsxs7, Fragment as Fragment7 } from "react/jsx-runtime";
|
|
25126
|
+
// src/options/on-browser-download.tsx
|
|
25127
|
+
import { jsx as jsx8, jsxs as jsxs8, Fragment as Fragment8 } from "react/jsx-runtime";
|
|
23578
25128
|
// src/index.ts
|
|
23579
25129
|
var RenderInternals = {
|
|
23580
25130
|
resolveConcurrency,
|