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