@remotion/serverless-client 4.0.266 → 4.0.268

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.
@@ -1,4 +1,3 @@
1
- import { createRequire } from "node:module";
2
1
  var __create = Object.create;
3
2
  var __getProtoOf = Object.getPrototypeOf;
4
3
  var __defProp = Object.defineProperty;
@@ -16,666 +15,6 @@ var __toESM = (mod, isNodeMode, target) => {
16
15
  return to;
17
16
  };
18
17
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
19
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
20
-
21
- // ../renderer/dist/chalk/is-color-supported.js
22
- var require_is_color_supported = __commonJS((exports) => {
23
- var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
24
- if (k2 === undefined)
25
- k2 = k;
26
- var desc = Object.getOwnPropertyDescriptor(m, k);
27
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
28
- desc = { enumerable: true, get: function() {
29
- return m[k];
30
- } };
31
- }
32
- Object.defineProperty(o, k2, desc);
33
- } : function(o, m, k, k2) {
34
- if (k2 === undefined)
35
- k2 = k;
36
- o[k2] = m[k];
37
- });
38
- var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
39
- Object.defineProperty(o, "default", { enumerable: true, value: v });
40
- } : function(o, v) {
41
- o["default"] = v;
42
- });
43
- var __importStar = exports && exports.__importStar || function(mod) {
44
- if (mod && mod.__esModule)
45
- return mod;
46
- var result = {};
47
- if (mod != null) {
48
- for (var k in mod)
49
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
50
- __createBinding(result, mod, k);
51
- }
52
- __setModuleDefault(result, mod);
53
- return result;
54
- };
55
- Object.defineProperty(exports, "__esModule", { value: true });
56
- exports.isColorSupported = undefined;
57
- var tty = __importStar(__require("tty"));
58
- var isColorSupported = () => {
59
- var _a;
60
- const env = process.env || {};
61
- const isForceDisabled = "NO_COLOR" in env;
62
- if (isForceDisabled) {
63
- return false;
64
- }
65
- const isForced = "FORCE_COLOR" in env;
66
- if (isForced) {
67
- return true;
68
- }
69
- const isWindows = process.platform === "win32";
70
- const isCompatibleTerminal = ((_a = tty === null || tty === undefined ? undefined : tty.isatty) === null || _a === undefined ? undefined : _a.call(tty, 1)) && env.TERM && env.TERM !== "dumb";
71
- const isCI = "CI" in env && (("GITHUB_ACTIONS" in env) || ("GITLAB_CI" in env) || ("CIRCLECI" in env));
72
- return isWindows || isCompatibleTerminal || isCI;
73
- };
74
- exports.isColorSupported = isColorSupported;
75
- });
76
-
77
- // ../renderer/dist/chalk/index.js
78
- var require_chalk = __commonJS((exports) => {
79
- Object.defineProperty(exports, "__esModule", { value: true });
80
- exports.chalk = undefined;
81
- var is_color_supported_1 = require_is_color_supported();
82
- exports.chalk = (() => {
83
- const colors = {
84
- enabled: () => (0, is_color_supported_1.isColorSupported)(),
85
- visible: true,
86
- styles: {},
87
- keys: {}
88
- };
89
- const ansi = (st) => {
90
- const open = `\x1B[${st.codes[0]}m`;
91
- const close = `\x1B[${st.codes[1]}m`;
92
- const regex = new RegExp(`\\u001b\\[${st.codes[1]}m`, "g");
93
- st.wrap = (input, newline) => {
94
- if (input.includes(close))
95
- input = input.replace(regex, close + open);
96
- const output = open + input + close;
97
- return newline ? output.replace(/\r*\n/g, `${close}$&${open}`) : output;
98
- };
99
- return st;
100
- };
101
- const wrap = (sty, input, newline) => {
102
- var _a;
103
- return (_a = sty.wrap) === null || _a === undefined ? undefined : _a.call(sty, input, newline);
104
- };
105
- const style = (input, stack) => {
106
- if (input === "" || input === null || input === undefined)
107
- return "";
108
- if (colors.enabled() === false)
109
- return input;
110
- if (colors.visible === false)
111
- return "";
112
- let str = String(input);
113
- const nl = str.includes(`
114
- `);
115
- let n = stack.length;
116
- while (n-- > 0)
117
- str = wrap(colors.styles[stack[n]], str, nl);
118
- return str;
119
- };
120
- const define = (name, codes, type) => {
121
- colors.styles[name] = ansi({ name, codes });
122
- const keys = colors.keys[type] || (colors.keys[type] = []);
123
- keys.push(name);
124
- Reflect.defineProperty(colors, name, {
125
- configurable: true,
126
- enumerable: true,
127
- set(value) {
128
- var _a;
129
- (_a = colors.alias) === null || _a === undefined || _a.call(colors, name, value);
130
- },
131
- get() {
132
- const color = (input) => style(input, color.stack);
133
- Reflect.setPrototypeOf(color, colors);
134
- color.stack = this.stack ? this.stack.concat(name) : [name];
135
- return color;
136
- }
137
- });
138
- };
139
- define("reset", [0, 0], "modifier");
140
- define("bold", [1, 22], "modifier");
141
- define("dim", [2, 22], "modifier");
142
- define("italic", [3, 23], "modifier");
143
- define("underline", [4, 24], "modifier");
144
- define("inverse", [7, 27], "modifier");
145
- define("hidden", [8, 28], "modifier");
146
- define("strikethrough", [9, 29], "modifier");
147
- define("black", [30, 39], "color");
148
- define("red", [31, 39], "color");
149
- define("green", [32, 39], "color");
150
- define("yellow", [33, 39], "color");
151
- define("blue", [34, 39], "color");
152
- define("magenta", [35, 39], "color");
153
- define("cyan", [36, 39], "color");
154
- define("white", [37, 39], "color");
155
- define("gray", [90, 39], "color");
156
- define("grey", [90, 39], "color");
157
- define("bgBlack", [40, 49], "bg");
158
- define("bgRed", [41, 49], "bg");
159
- define("bgGreen", [42, 49], "bg");
160
- define("bgYellow", [43, 49], "bg");
161
- define("bgBlue", [44, 49], "bg");
162
- define("bgMagenta", [45, 49], "bg");
163
- define("bgWhite", [47, 49], "bg");
164
- define("blackBright", [90, 39], "bright");
165
- define("redBright", [91, 39], "bright");
166
- define("greenBright", [92, 39], "bright");
167
- define("yellowBright", [93, 39], "bright");
168
- define("blueBright", [94, 39], "bright");
169
- define("magentaBright", [95, 39], "bright");
170
- define("whiteBright", [97, 39], "bright");
171
- define("bgBlackBright", [100, 49], "bgBright");
172
- define("bgRedBright", [101, 49], "bgBright");
173
- define("bgGreenBright", [102, 49], "bgBright");
174
- define("bgYellowBright", [103, 49], "bgBright");
175
- define("bgBlueBright", [104, 49], "bgBright");
176
- define("bgMagentaBright", [105, 49], "bgBright");
177
- define("bgWhiteBright", [107, 49], "bgBright");
178
- colors.alias = (name, color) => {
179
- const fn = colors[color];
180
- if (typeof fn !== "function") {
181
- throw new TypeError("Expected alias to be the name of an existing color (string) or a function");
182
- }
183
- if (!fn.stack) {
184
- Reflect.defineProperty(fn, "name", { value: name });
185
- colors.styles[name] = fn;
186
- fn.stack = [name];
187
- }
188
- Reflect.defineProperty(colors, name, {
189
- configurable: true,
190
- enumerable: true,
191
- set(value) {
192
- var _a;
193
- (_a = colors.alias) === null || _a === undefined || _a.call(colors, name, value);
194
- },
195
- get() {
196
- const col = (input) => style(input, col.stack);
197
- Reflect.setPrototypeOf(col, colors);
198
- col.stack = this.stack ? this.stack.concat(fn.stack) : fn.stack;
199
- return col;
200
- }
201
- });
202
- };
203
- return colors;
204
- })();
205
- });
206
-
207
- // ../renderer/dist/log-level.js
208
- var require_log_level = __commonJS((exports) => {
209
- Object.defineProperty(exports, "__esModule", { value: true });
210
- exports.isEqualOrBelowLogLevel = exports.isValidLogLevel = exports.logLevels = undefined;
211
- exports.logLevels = ["trace", "verbose", "info", "warn", "error"];
212
- var getNumberForLogLevel = (level) => {
213
- return exports.logLevels.indexOf(level);
214
- };
215
- var isValidLogLevel = (level) => {
216
- return getNumberForLogLevel(level) > -1;
217
- };
218
- exports.isValidLogLevel = isValidLogLevel;
219
- var isEqualOrBelowLogLevel = (currentLevel, level) => {
220
- return getNumberForLogLevel(currentLevel) <= getNumberForLogLevel(level);
221
- };
222
- exports.isEqualOrBelowLogLevel = isEqualOrBelowLogLevel;
223
- });
224
-
225
- // ../core/dist/cjs/version.js
226
- var require_version = __commonJS((exports) => {
227
- Object.defineProperty(exports, "__esModule", { value: true });
228
- exports.VERSION = undefined;
229
- exports.VERSION = "4.0.266";
230
- });
231
-
232
- // ../renderer/dist/find-closest-package-json.js
233
- var require_find_closest_package_json = __commonJS((exports) => {
234
- var __importDefault = exports && exports.__importDefault || function(mod) {
235
- return mod && mod.__esModule ? mod : { default: mod };
236
- };
237
- Object.defineProperty(exports, "__esModule", { value: true });
238
- exports.findRemotionRoot = exports.findClosestPackageJson = undefined;
239
- var node_fs_1 = __importDefault(__require("node:fs"));
240
- var node_path_1 = __importDefault(__require("node:path"));
241
- var recursionLimit = 5;
242
- var findClosestPackageJson = () => {
243
- let currentDir = process.cwd();
244
- let possiblePackageJson = "";
245
- for (let i = 0;i < recursionLimit; i++) {
246
- possiblePackageJson = node_path_1.default.join(currentDir, "package.json");
247
- const exists = node_fs_1.default.existsSync(possiblePackageJson);
248
- if (exists) {
249
- return possiblePackageJson;
250
- }
251
- currentDir = node_path_1.default.dirname(currentDir);
252
- }
253
- return null;
254
- };
255
- exports.findClosestPackageJson = findClosestPackageJson;
256
- var findRemotionRoot = () => {
257
- const closestPackageJson = (0, exports.findClosestPackageJson)();
258
- if (closestPackageJson === null) {
259
- return process.cwd();
260
- }
261
- return node_path_1.default.dirname(closestPackageJson);
262
- };
263
- exports.findRemotionRoot = findRemotionRoot;
264
- });
265
-
266
- // ../renderer/dist/is-serve-url.js
267
- var require_is_serve_url = __commonJS((exports) => {
268
- Object.defineProperty(exports, "__esModule", { value: true });
269
- exports.isServeUrl = undefined;
270
- var isServeUrl = (potentialUrl) => {
271
- if (typeof potentialUrl === "undefined") {
272
- throw new Error("serveUrl is undefined");
273
- }
274
- if (potentialUrl.startsWith("www.") || potentialUrl.includes("amazonaws.com")) {
275
- return true;
276
- }
277
- return potentialUrl.startsWith("https://") || potentialUrl.startsWith("http://");
278
- };
279
- exports.isServeUrl = isServeUrl;
280
- });
281
-
282
- // ../renderer/dist/repro.js
283
- var require_repro = __commonJS((exports) => {
284
- var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
285
- if (k2 === undefined)
286
- k2 = k;
287
- var desc = Object.getOwnPropertyDescriptor(m, k);
288
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
289
- desc = { enumerable: true, get: function() {
290
- return m[k];
291
- } };
292
- }
293
- Object.defineProperty(o, k2, desc);
294
- } : function(o, m, k, k2) {
295
- if (k2 === undefined)
296
- k2 = k;
297
- o[k2] = m[k];
298
- });
299
- var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
300
- Object.defineProperty(o, "default", { enumerable: true, value: v });
301
- } : function(o, v) {
302
- o["default"] = v;
303
- });
304
- var __importStar = exports && exports.__importStar || function(mod) {
305
- if (mod && mod.__esModule)
306
- return mod;
307
- var result = {};
308
- if (mod != null) {
309
- for (var k in mod)
310
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
311
- __createBinding(result, mod, k);
312
- }
313
- __setModuleDefault(result, mod);
314
- return result;
315
- };
316
- var __importDefault = exports && exports.__importDefault || function(mod) {
317
- return mod && mod.__esModule ? mod : { default: mod };
318
- };
319
- Object.defineProperty(exports, "__esModule", { value: true });
320
- exports.isReproEnabled = exports.disableRepro = exports.enableRepro = exports.writeInRepro = exports.getReproWriter = undefined;
321
- var node_child_process_1 = __require("node:child_process");
322
- var node_fs_1 = __importStar(__require("node:fs"));
323
- var node_os_1 = __importDefault(__require("node:os"));
324
- var node_path_1 = __importDefault(__require("node:path"));
325
- var version_1 = require_version();
326
- var chalk_1 = require_chalk();
327
- var find_closest_package_json_1 = require_find_closest_package_json();
328
- var is_serve_url_1 = require_is_serve_url();
329
- var logger_1 = require_logger();
330
- var REPRO_DIR = ".remotionrepro";
331
- var LOG_FILE_NAME = "logs.txt";
332
- var INPUT_DIR = "bundle";
333
- var OUTPUT_DIR = "output";
334
- var LINE_SPLIT = `
335
- `;
336
- var getZipFileName = (name) => `remotion-repro-${name}-${Date.now()}.zip`;
337
- var readyDirSync = (dir) => {
338
- let items;
339
- try {
340
- items = node_fs_1.default.readdirSync(dir);
341
- } catch (_a) {
342
- return node_fs_1.default.mkdirSync(dir, { recursive: true });
343
- }
344
- items.forEach((item) => {
345
- item = node_path_1.default.join(dir, item);
346
- node_fs_1.default.rmSync(item, { recursive: true, force: true });
347
- });
348
- };
349
- var zipFolder = ({ sourceFolder, targetZip, indent, logLevel }) => {
350
- const platform = node_os_1.default.platform();
351
- try {
352
- logger_1.Log.info({ indent, logLevel }, "+ Creating reproduction ZIP");
353
- if (platform === "win32") {
354
- (0, node_child_process_1.execSync)(`powershell.exe Compress-Archive -Path "${sourceFolder}" -DestinationPath "${targetZip}"`);
355
- } else {
356
- (0, node_child_process_1.execSync)(`zip -r "${targetZip}" "${sourceFolder}"`);
357
- }
358
- (0, node_fs_1.rmSync)(sourceFolder, { recursive: true });
359
- logger_1.Log.info({ indent, logLevel }, `${chalk_1.chalk.blue(`+ Repro: ${targetZip}`)}`);
360
- } catch (error) {
361
- logger_1.Log.error({ indent, logLevel }, `Failed to zip repro folder, The repro folder is ${sourceFolder}. You can try manually zip it.`);
362
- logger_1.Log.error({ indent, logLevel }, error);
363
- }
364
- };
365
- var reproWriter = (name) => {
366
- const root = (0, find_closest_package_json_1.findRemotionRoot)();
367
- const reproFolder = node_path_1.default.join(root, REPRO_DIR);
368
- const logPath = node_path_1.default.join(reproFolder, LOG_FILE_NAME);
369
- const zipFile = node_path_1.default.join(root, getZipFileName(name));
370
- readyDirSync(reproFolder);
371
- const reproLogWriteStream = node_fs_1.default.createWriteStream(logPath, { flags: "a" });
372
- const serializeArgs = (args) => JSON.stringify(args);
373
- const writeLine = (level, ...args) => {
374
- if (!args.length)
375
- return;
376
- const startTime = new Date().toISOString();
377
- const line = `[${startTime}] ${level} ${serializeArgs(args)}`;
378
- reproLogWriteStream.write(line + LINE_SPLIT);
379
- };
380
- const start = ({ serveUrl, serializedInputPropsWithCustomSchema, serializedResolvedPropsWithCustomSchema }) => {
381
- const isServe = (0, is_serve_url_1.isServeUrl)(serveUrl);
382
- if (!isServe) {
383
- const inputDir = node_path_1.default.resolve(reproFolder, INPUT_DIR);
384
- readyDirSync(inputDir);
385
- node_fs_1.default.cpSync(serveUrl, inputDir, { recursive: true });
386
- }
387
- const serializedProps = node_path_1.default.resolve(reproFolder, "input-props.json");
388
- node_fs_1.default.writeFileSync(serializedProps, serializedInputPropsWithCustomSchema);
389
- const serializedResolvedProps = node_path_1.default.resolve(reproFolder, "resolved-props.json");
390
- node_fs_1.default.writeFileSync(serializedResolvedProps, serializedResolvedPropsWithCustomSchema);
391
- writeLine("info", [`Args: ${JSON.stringify(process.argv)}`]);
392
- writeLine("info", [`Node/Bun version: ${process.version}`]);
393
- writeLine("info", [`OS: ${process.platform}-${process.arch}`]);
394
- writeLine("info", [`Serve URL: ${serveUrl}`]);
395
- writeLine("info", [`Remotion version: ${version_1.VERSION}`]);
396
- };
397
- const onRenderSucceed = ({ indent, logLevel, output }) => {
398
- return new Promise((resolve, reject) => {
399
- try {
400
- if (output) {
401
- const outputDir = node_path_1.default.resolve(reproFolder, OUTPUT_DIR);
402
- readyDirSync(outputDir);
403
- const fileName = node_path_1.default.basename(output);
404
- const targetPath = node_path_1.default.join(outputDir, fileName);
405
- node_fs_1.default.copyFileSync(output, targetPath);
406
- }
407
- (0, exports.disableRepro)();
408
- reproLogWriteStream.end(() => {
409
- reproLogWriteStream.close(() => {
410
- zipFolder({
411
- sourceFolder: reproFolder,
412
- targetZip: zipFile,
413
- indent,
414
- logLevel
415
- });
416
- resolve();
417
- });
418
- });
419
- } catch (error) {
420
- logger_1.Log.error({ indent: false, logLevel }, `repro render success error:`);
421
- logger_1.Log.error({ indent: false, logLevel }, error);
422
- reject(error);
423
- }
424
- });
425
- };
426
- return {
427
- start,
428
- writeLine,
429
- onRenderSucceed
430
- };
431
- };
432
- var reproWriteInstance = null;
433
- var getReproWriter = () => {
434
- if (!reproWriteInstance) {
435
- throw new Error("reproWriteInstance is not initialized");
436
- }
437
- return reproWriteInstance;
438
- };
439
- exports.getReproWriter = getReproWriter;
440
- var writeInRepro = (level, ...args) => {
441
- if ((0, exports.isReproEnabled)()) {
442
- (0, exports.getReproWriter)().writeLine(level, ...args);
443
- }
444
- };
445
- exports.writeInRepro = writeInRepro;
446
- var shouldRepro = false;
447
- var enableRepro = ({ serveUrl, compositionName, serializedInputPropsWithCustomSchema, serializedResolvedPropsWithCustomSchema }) => {
448
- shouldRepro = true;
449
- reproWriteInstance = reproWriter(compositionName);
450
- (0, exports.getReproWriter)().start({
451
- serveUrl,
452
- serializedInputPropsWithCustomSchema,
453
- serializedResolvedPropsWithCustomSchema
454
- });
455
- };
456
- exports.enableRepro = enableRepro;
457
- var disableRepro = () => {
458
- shouldRepro = false;
459
- };
460
- exports.disableRepro = disableRepro;
461
- var isReproEnabled = () => shouldRepro;
462
- exports.isReproEnabled = isReproEnabled;
463
- });
464
-
465
- // ../renderer/dist/truthy.js
466
- var require_truthy = __commonJS((exports) => {
467
- Object.defineProperty(exports, "__esModule", { value: true });
468
- exports.truthy = truthy2;
469
- function truthy2(value) {
470
- return Boolean(value);
471
- }
472
- });
473
-
474
- // ../renderer/dist/logger.js
475
- var require_logger = __commonJS((exports) => {
476
- Object.defineProperty(exports, "__esModule", { value: true });
477
- exports.Log = exports.secondverboseTag = exports.verboseTag = exports.INDENT_TOKEN = undefined;
478
- var chalk_1 = require_chalk();
479
- var is_color_supported_1 = require_is_color_supported();
480
- var log_level_1 = require_log_level();
481
- var repro_1 = require_repro();
482
- var truthy_1 = require_truthy();
483
- exports.INDENT_TOKEN = chalk_1.chalk.gray("│");
484
- var verboseTag = (str) => {
485
- return (0, is_color_supported_1.isColorSupported)() ? chalk_1.chalk.bgBlack(` ${str} `) : `[${str}]`;
486
- };
487
- exports.verboseTag = verboseTag;
488
- var secondverboseTag = (str) => {
489
- return (0, is_color_supported_1.isColorSupported)() ? chalk_1.chalk.bgWhite(` ${str} `) : `[${str}]`;
490
- };
491
- exports.secondverboseTag = secondverboseTag;
492
- exports.Log = {
493
- trace: (options, ...args) => {
494
- (0, repro_1.writeInRepro)("trace", ...args);
495
- if ((0, log_level_1.isEqualOrBelowLogLevel)(options.logLevel, "trace")) {
496
- if (args.length === 0) {
497
- return process.stdout.write(`
498
- `);
499
- }
500
- return console.log(...[
501
- options.indent ? exports.INDENT_TOKEN : null,
502
- options.tag ? (0, exports.verboseTag)(options.tag) : null
503
- ].filter(truthy_1.truthy).concat(args.map((a) => chalk_1.chalk.gray(a))));
504
- }
505
- },
506
- verbose: (options, ...args) => {
507
- (0, repro_1.writeInRepro)("verbose", ...args);
508
- if ((0, log_level_1.isEqualOrBelowLogLevel)(options.logLevel, "verbose")) {
509
- if (args.length === 0) {
510
- return process.stdout.write(`
511
- `);
512
- }
513
- return console.log(...[
514
- options.indent ? exports.INDENT_TOKEN : null,
515
- options.tag ? (0, exports.verboseTag)(options.tag) : null
516
- ].filter(truthy_1.truthy).concat(args.map((a) => chalk_1.chalk.gray(a))));
517
- }
518
- },
519
- info: (options, ...args) => {
520
- (0, repro_1.writeInRepro)("info", ...args);
521
- if ((0, log_level_1.isEqualOrBelowLogLevel)(options.logLevel, "info")) {
522
- if (args.length === 0) {
523
- return process.stdout.write(`
524
- `);
525
- }
526
- return console.log(...[options.indent ? exports.INDENT_TOKEN : null].filter(truthy_1.truthy).concat(args !== null && args !== undefined ? args : []));
527
- }
528
- },
529
- warn: (options, ...args) => {
530
- (0, repro_1.writeInRepro)("warn", ...args);
531
- if ((0, log_level_1.isEqualOrBelowLogLevel)(options.logLevel, "warn")) {
532
- if (args.length === 0) {
533
- return process.stdout.write(`
534
- `);
535
- }
536
- return console.warn(...[options.indent ? chalk_1.chalk.yellow(exports.INDENT_TOKEN) : null].filter(truthy_1.truthy).concat(args.map((a) => chalk_1.chalk.yellow(a))));
537
- }
538
- },
539
- error: (options, ...args) => {
540
- (0, repro_1.writeInRepro)("error", ...args);
541
- if ((0, log_level_1.isEqualOrBelowLogLevel)(options.logLevel, "error")) {
542
- if (args.length === 0) {
543
- return process.stdout.write(`
544
- `);
545
- }
546
- return console.error(...[
547
- options.indent ? exports.INDENT_TOKEN : null,
548
- options.tag ? (0, exports.verboseTag)(options.tag) : null
549
- ].filter(truthy_1.truthy).concat(args.map((a) => chalk_1.chalk.red(a))));
550
- }
551
- }
552
- };
553
- });
554
-
555
- // ../renderer/dist/print-useful-error-message.js
556
- var require_print_useful_error_message = __commonJS((exports) => {
557
- Object.defineProperty(exports, "__esModule", { value: true });
558
- exports.printUsefulErrorMessage = undefined;
559
- var logger_1 = require_logger();
560
- var truthy_1 = require_truthy();
561
- var alreadyPrintedCache = [];
562
- var printUsefulErrorMessage = (err, logLevel, indent) => {
563
- var _a, _b;
564
- const errorStack = err.stack;
565
- if (errorStack && alreadyPrintedCache.includes(errorStack)) {
566
- return;
567
- }
568
- if (errorStack) {
569
- alreadyPrintedCache.push(errorStack);
570
- alreadyPrintedCache = alreadyPrintedCache.slice(-10);
571
- }
572
- if (err.message.includes("Could not play video with")) {
573
- logger_1.Log.info({ indent, logLevel });
574
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/media-playback-error");
575
- }
576
- if (err.message.includes("A delayRender()") && err.message.includes("was called but not cleared after")) {
577
- logger_1.Log.info({ indent, logLevel });
578
- if (err.message.includes("/proxy")) {
579
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/troubleshooting/delay-render-proxy");
580
- }
581
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/timeout");
582
- }
583
- if (err.message.includes("Target closed")) {
584
- logger_1.Log.info({ indent, logLevel });
585
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/target-closed");
586
- }
587
- if (err.message.includes("Timed out evaluating")) {
588
- logger_1.Log.info({ indent, logLevel });
589
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/troubleshooting/timed-out-page-function");
590
- }
591
- if (err.message.includes("ENAMETOOLONG")) {
592
- logger_1.Log.info({ indent, logLevel });
593
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/enametoolong");
594
- }
595
- if (err.message.includes("Member must have value less than or equal to 3008")) {
596
- logger_1.Log.info({ indent, logLevel });
597
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 This error indicates that you have a AWS account on the free tier or have been limited by your organization. Often times this can be solved by adding a credit card. See also: https://repost.aws/questions/QUKruWYNDYTSmP17jCnIz6IQ/questions/QUKruWYNDYTSmP17jCnIz6IQ/unable-to-set-lambda-memory-over-3008mb");
598
- }
599
- if ((_a = err.stack) === null || _a === undefined ? undefined : _a.includes("TooManyRequestsException: Rate Exceeded.")) {
600
- logger_1.Log.info({ indent, logLevel });
601
- logger_1.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");
602
- }
603
- if (err.message.includes("Error creating WebGL context")) {
604
- logger_1.Log.info({ indent, logLevel });
605
- logger_1.Log.warn({
606
- indent,
607
- logLevel
608
- }, '\uD83D\uDCA1 You might need to set the OpenGL renderer to "angle-egl", "angle" (or "swangle" if rendering on lambda). Learn why at https://www.remotion.dev/docs/three');
609
- logger_1.Log.warn({
610
- indent,
611
- logLevel
612
- }, "\uD83D\uDCA1 Check how it's done at https://www.remotion.dev/docs/chromium-flags#--gl");
613
- }
614
- if (err.message.includes("The bucket does not allow ACLs")) {
615
- logger_1.Log.info({ indent, logLevel });
616
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 Fix for this issue: https://remotion.dev/docs/lambda/troubleshooting/bucket-disallows-acl");
617
- }
618
- if (err.message.includes("Minified React error #306")) {
619
- const componentName = (_b = err.message.match(/<\w+>/)) === null || _b === undefined ? undefined : _b[0];
620
- logger_1.Log.info({ indent, logLevel }, [
621
- "\uD83D\uDCA1 This error indicates that the component",
622
- componentName ? `(${componentName})` : null,
623
- "you are trying to render is not imported correctly."
624
- ].filter(truthy_1.truthy).join(" "));
625
- logger_1.Log.info({ indent, logLevel });
626
- logger_1.Log.info({ indent, logLevel }, " Check the root file and ensure that the component is not undefined.");
627
- logger_1.Log.info({ indent, logLevel }, " Oftentimes, this happens if the component is missing the `export` keyword");
628
- logger_1.Log.info({ indent, logLevel }, " or if the component was renamed and the import statement not properly adjusted.");
629
- }
630
- if (err.message.includes("GLIBC_")) {
631
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 Remotion requires at least Libc 2.35.");
632
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue: https://github.com/remotion-dev/remotion/issues/2439");
633
- }
634
- if (err.message.includes("EBADF")) {
635
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 This error might be fixed by changing your Node version:");
636
- logger_1.Log.info({ indent, logLevel }, " https://github.com/remotion-dev/remotion/issues/2452");
637
- }
638
- if (err.message.includes("routines::unsupported")) {
639
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 This error might happen if using Cloud Run with credentials that have a newline at the end or are otherwise badly encoded.");
640
- logger_1.Log.info({ indent, logLevel }, " https://github.com/remotion-dev/remotion/issues/3864");
641
- }
642
- if (err.message.includes("Failed to fetch")) {
643
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 On Lambda, one reason this could happen is that Chrome is rejecting an asset to be loaded when it is running low on disk space.");
644
- logger_1.Log.info({ indent, logLevel }, "Try increasing the disk size of your Lambda function.");
645
- }
646
- };
647
- exports.printUsefulErrorMessage = printUsefulErrorMessage;
648
- });
649
-
650
- // ../renderer/dist/wrap-with-error-handling.js
651
- var require_wrap_with_error_handling = __commonJS((exports) => {
652
- Object.defineProperty(exports, "__esModule", { value: true });
653
- exports.wrapWithErrorHandling = undefined;
654
- var print_useful_error_message_1 = require_print_useful_error_message();
655
- var wrapWithErrorHandling = (fn) => {
656
- return async (...args) => {
657
- try {
658
- return await fn(...args);
659
- } catch (err) {
660
- const { indent } = args[0];
661
- const { logLevel } = args[0];
662
- (0, print_useful_error_message_1.printUsefulErrorMessage)(err, logLevel, indent);
663
- throw err;
664
- }
665
- };
666
- };
667
- exports.wrapWithErrorHandling = wrapWithErrorHandling;
668
- });
669
-
670
- // ../renderer/dist/error-handling.js
671
- var require_error_handling = __commonJS((exports) => {
672
- Object.defineProperty(exports, "__esModule", { value: true });
673
- exports.wrapWithErrorHandling = undefined;
674
- var wrap_with_error_handling_1 = require_wrap_with_error_handling();
675
- Object.defineProperty(exports, "wrapWithErrorHandling", { enumerable: true, get: function() {
676
- return wrap_with_error_handling_1.wrapWithErrorHandling;
677
- } });
678
- });
679
18
 
680
19
  // ../streaming/dist/make-stream-payload-message.js
681
20
  var require_make_stream_payload_message = __commonJS((exports) => {
@@ -777,860 +116,88 @@ var require_make_streamer = __commonJS((exports) => {
777
116
  separatorIndex++;
778
117
  statusString += String.fromCharCode(nextDigit);
779
118
  }
780
- const length = Number(lengthString);
781
- const status = Number(statusString);
782
- const dataLength = outputBuffer.length - separatorIndex - 1;
783
- if (dataLength < length) {
784
- missingData = {
785
- dataMissing: length - dataLength
786
- };
787
- return;
788
- }
789
- const data = outputBuffer.subarray(separatorIndex + 1, separatorIndex + 1 + Number(lengthString));
790
- onMessage(status === 1 ? "error" : "success", nonceString, data);
791
- missingData = null;
792
- outputBuffer = outputBuffer.subarray(separatorIndex + Number(lengthString) + 1);
793
- processInput();
794
- };
795
- const onData = (data) => {
796
- unprocessedBuffers.push(data);
797
- if (missingData) {
798
- missingData.dataMissing -= data.length;
799
- }
800
- if (missingData && missingData.dataMissing > 0) {
801
- return;
802
- }
803
- const newBuffer = new Uint8Array(outputBuffer.length + unprocessedBuffers.reduce((acc, val) => acc + val.length, 0));
804
- newBuffer.set(outputBuffer, 0);
805
- let offset = outputBuffer.length;
806
- for (const buf of unprocessedBuffers) {
807
- newBuffer.set(buf, offset);
808
- offset += buf.length;
809
- }
810
- outputBuffer = newBuffer;
811
- unprocessedBuffers = [];
812
- processInput();
813
- };
814
- return {
815
- onData,
816
- getOutputBuffer: () => outputBuffer,
817
- clear: () => {
818
- unprocessedBuffers = [];
819
- outputBuffer = new Uint8Array(0);
820
- }
821
- };
822
- };
823
- exports.makeStreamer = makeStreamer;
824
- var makeStreamPayloadMessage = ({ status, body, nonce }) => {
825
- const nonceArr = new TextEncoder().encode(nonce);
826
- const magicWordArr = new TextEncoder().encode(exports.streamingKey);
827
- const separatorArr = new TextEncoder().encode(":");
828
- const bodyLengthArr = new TextEncoder().encode(body.length.toString());
829
- const statusArr = new TextEncoder().encode(String(status));
830
- const totalLength = nonceArr.length + magicWordArr.length + separatorArr.length * 3 + bodyLengthArr.length + statusArr.length + body.length;
831
- const concat = new Uint8Array(totalLength);
832
- let offset = 0;
833
- const appendToConcat = (data) => {
834
- concat.set(data, offset);
835
- offset += data.length;
836
- };
837
- appendToConcat(magicWordArr);
838
- appendToConcat(nonceArr);
839
- appendToConcat(separatorArr);
840
- appendToConcat(bodyLengthArr);
841
- appendToConcat(separatorArr);
842
- appendToConcat(statusArr);
843
- appendToConcat(separatorArr);
844
- appendToConcat(body);
845
- return concat;
846
- };
847
- exports.makeStreamPayloadMessage = makeStreamPayloadMessage;
848
- });
849
-
850
- // ../streaming/dist/index.js
851
- var require_dist = __commonJS((exports) => {
852
- Object.defineProperty(exports, "__esModule", { value: true });
853
- exports.makeStreamer = exports.makeStreamPayloadMessage = undefined;
854
- var make_stream_payload_message_1 = require_make_stream_payload_message();
855
- Object.defineProperty(exports, "makeStreamPayloadMessage", { enumerable: true, get: function() {
856
- return make_stream_payload_message_1.makeStreamPayloadMessage;
857
- } });
858
- var make_streamer_1 = require_make_streamer();
859
- Object.defineProperty(exports, "makeStreamer", { enumerable: true, get: function() {
860
- return make_streamer_1.makeStreamer;
861
- } });
862
- });
863
-
864
- // ../renderer/dist/is-audio-codec.js
865
- var require_is_audio_codec = __commonJS((exports) => {
866
- Object.defineProperty(exports, "__esModule", { value: true });
867
- exports.isAudioCodec = undefined;
868
- var isAudioCodec = (codec) => {
869
- return codec === "mp3" || codec === "aac" || codec === "wav";
870
- };
871
- exports.isAudioCodec = isAudioCodec;
872
- });
873
-
874
- // ../renderer/dist/crf.js
875
- var require_crf = __commonJS((exports) => {
876
- Object.defineProperty(exports, "__esModule", { value: true });
877
- exports.validateQualitySettings = exports.getValidCrfRanges = exports.getDefaultCrfForCodec = undefined;
878
- var is_audio_codec_1 = require_is_audio_codec();
879
- var defaultCrfMap = {
880
- h264: 18,
881
- h265: 23,
882
- vp8: 9,
883
- vp9: 28,
884
- prores: null,
885
- gif: null,
886
- "h264-mkv": 18,
887
- "h264-ts": 18,
888
- aac: null,
889
- mp3: null,
890
- wav: null
891
- };
892
- var getDefaultCrfForCodec = (codec) => {
893
- const val = defaultCrfMap[codec];
894
- if (val === undefined) {
895
- throw new TypeError(`Got unexpected codec "${codec}"`);
896
- }
897
- return val;
898
- };
899
- exports.getDefaultCrfForCodec = getDefaultCrfForCodec;
900
- var crfRanges = {
901
- h264: [1, 51],
902
- h265: [0, 51],
903
- vp8: [4, 63],
904
- vp9: [0, 63],
905
- prores: [0, 0],
906
- gif: [0, 0],
907
- "h264-mkv": [1, 51],
908
- "h264-ts": [1, 51],
909
- aac: [0, 0],
910
- mp3: [0, 0],
911
- wav: [0, 0]
912
- };
913
- var getValidCrfRanges = (codec) => {
914
- const val = crfRanges[codec];
915
- if (val === undefined) {
916
- throw new TypeError(`Got unexpected codec "${codec}"`);
917
- }
918
- return val;
919
- };
920
- exports.getValidCrfRanges = getValidCrfRanges;
921
- var validateQualitySettings = ({ codec, crf, videoBitrate, encodingMaxRate, encodingBufferSize, hardwareAcceleration }) => {
922
- if (crf && videoBitrate) {
923
- throw new Error('"crf" and "videoBitrate" can not both be set. Choose one of either.');
924
- }
925
- if (crf && hardwareAcceleration === "required") {
926
- throw new Error('"crf" option is not supported with hardware acceleration');
927
- }
928
- if (encodingMaxRate && !encodingBufferSize) {
929
- throw new Error('"encodingMaxRate" can not be set without also setting "encodingBufferSize".');
930
- }
931
- const bufSizeArray = encodingBufferSize ? ["-bufsize", encodingBufferSize] : [];
932
- const maxRateArray = encodingMaxRate ? ["-maxrate", encodingMaxRate] : [];
933
- if (videoBitrate) {
934
- if (codec === "prores") {
935
- console.warn("ProRes does not support videoBitrate. Ignoring.");
936
- return [];
937
- }
938
- if ((0, is_audio_codec_1.isAudioCodec)(codec)) {
939
- console.warn(`${codec} does not support videoBitrate. Ignoring.`);
940
- return [];
941
- }
942
- return ["-b:v", videoBitrate, ...bufSizeArray, ...maxRateArray];
943
- }
944
- if (crf === null || typeof crf === "undefined") {
945
- const actualCrf = (0, exports.getDefaultCrfForCodec)(codec);
946
- if (actualCrf === null) {
947
- return [...bufSizeArray, ...maxRateArray];
948
- }
949
- return ["-crf", String(actualCrf), ...bufSizeArray, ...maxRateArray];
950
- }
951
- if (typeof crf !== "number") {
952
- throw new TypeError("Expected CRF to be a number, but is " + JSON.stringify(crf));
953
- }
954
- const range = (0, exports.getValidCrfRanges)(codec);
955
- if (crf === 0 && (codec === "h264" || codec === "h264-mkv" || codec === "h264-ts")) {
956
- throw new TypeError("Setting the CRF to 0 with a H264 codec is not supported anymore because of it's inconsistencies between platforms. Videos with CRF 0 cannot be played on iOS/macOS. 0 is a extreme value with inefficient settings which you probably do not want. Set CRF to a higher value to fix this error.");
957
- }
958
- if (crf < range[0] || crf > range[1]) {
959
- if (range[0] === 0 && range[1] === 0) {
960
- throw new TypeError(`The "${codec}" codec does not support the --crf option.`);
961
- }
962
- throw new TypeError(`CRF must be between ${range[0]} and ${range[1]} for codec ${codec}. Passed: ${crf}`);
963
- }
964
- if (codec === "prores") {
965
- console.warn('ProRes does not support the "crf" option. Ignoring.');
966
- return [];
967
- }
968
- if ((0, is_audio_codec_1.isAudioCodec)(codec)) {
969
- console.warn(`${codec} does not support the "crf" option. Ignoring.`);
970
- return [];
971
- }
972
- return ["-crf", String(crf), ...bufSizeArray, ...maxRateArray];
973
- };
974
- exports.validateQualitySettings = validateQualitySettings;
975
- });
976
-
977
- // ../renderer/dist/codec-supports-media.js
978
- var require_codec_supports_media = __commonJS((exports) => {
979
- Object.defineProperty(exports, "__esModule", { value: true });
980
- exports.codecSupportsVideoBitrate = exports.codecSupportsCrf = exports.codecSupportsMedia = undefined;
981
- var crf_1 = require_crf();
982
- var support = {
983
- "h264-mkv": {
984
- audio: true,
985
- video: true
986
- },
987
- aac: {
988
- audio: true,
989
- video: false
990
- },
991
- gif: {
992
- video: true,
993
- audio: false
994
- },
995
- h264: {
996
- video: true,
997
- audio: true
998
- },
999
- "h264-ts": {
1000
- video: true,
1001
- audio: true
1002
- },
1003
- h265: {
1004
- video: true,
1005
- audio: true
1006
- },
1007
- mp3: {
1008
- audio: true,
1009
- video: false
1010
- },
1011
- prores: {
1012
- audio: true,
1013
- video: true
1014
- },
1015
- vp8: {
1016
- audio: true,
1017
- video: true
1018
- },
1019
- vp9: {
1020
- audio: true,
1021
- video: true
1022
- },
1023
- wav: {
1024
- audio: true,
1025
- video: false
1026
- }
1027
- };
1028
- var codecSupportsMedia = (codec) => {
1029
- return support[codec];
1030
- };
1031
- exports.codecSupportsMedia = codecSupportsMedia;
1032
- var codecSupportsVideoBitrateMap = {
1033
- "h264-mkv": true,
1034
- "h264-ts": true,
1035
- aac: false,
1036
- gif: false,
1037
- h264: true,
1038
- h265: true,
1039
- mp3: false,
1040
- prores: false,
1041
- vp8: true,
1042
- vp9: true,
1043
- wav: false
1044
- };
1045
- var codecSupportsCrf = (codec) => {
1046
- const range = (0, crf_1.getValidCrfRanges)(codec);
1047
- return range[0] !== range[1];
1048
- };
1049
- exports.codecSupportsCrf = codecSupportsCrf;
1050
- var codecSupportsVideoBitrate = (codec) => {
1051
- return codecSupportsVideoBitrateMap[codec];
1052
- };
1053
- exports.codecSupportsVideoBitrate = codecSupportsVideoBitrate;
1054
- });
1055
-
1056
- // ../renderer/dist/get-duration-from-frame-range.js
1057
- var require_get_duration_from_frame_range = __commonJS((exports) => {
1058
- Object.defineProperty(exports, "__esModule", { value: true });
1059
- exports.getFramesToRender = undefined;
1060
- var getFramesToRender = (frameRange, everyNthFrame) => {
1061
- if (everyNthFrame === 0) {
1062
- throw new Error("everyNthFrame cannot be 0");
1063
- }
1064
- return new Array(frameRange[1] - frameRange[0] + 1).fill(true).map((_, index) => {
1065
- return index + frameRange[0];
1066
- }).filter((index) => {
1067
- return index % everyNthFrame === 0;
1068
- });
1069
- };
1070
- exports.getFramesToRender = getFramesToRender;
1071
- });
1072
-
1073
- // ../renderer/dist/codec.js
1074
- var require_codec = __commonJS((exports) => {
1075
- Object.defineProperty(exports, "__esModule", { value: true });
1076
- exports.DEFAULT_CODEC = exports.validCodecs = undefined;
1077
- exports.validCodecs = [
1078
- "h264",
1079
- "h265",
1080
- "vp8",
1081
- "vp9",
1082
- "mp3",
1083
- "aac",
1084
- "wav",
1085
- "prores",
1086
- "h264-mkv",
1087
- "h264-ts",
1088
- "gif"
1089
- ];
1090
- exports.DEFAULT_CODEC = "h264";
1091
- });
1092
-
1093
- // ../renderer/dist/file-extensions.js
1094
- var require_file_extensions = __commonJS((exports) => {
1095
- Object.defineProperty(exports, "__esModule", { value: true });
1096
- exports.defaultFileExtensionMap = undefined;
1097
- exports.defaultFileExtensionMap = {
1098
- "h264-mkv": {
1099
- default: "mkv",
1100
- forAudioCodec: {
1101
- "pcm-16": { possible: ["mkv"], default: "mkv" },
1102
- mp3: { possible: ["mkv"], default: "mkv" }
1103
- }
1104
- },
1105
- "h264-ts": {
1106
- default: "ts",
1107
- forAudioCodec: {
1108
- "pcm-16": { possible: ["ts"], default: "ts" },
1109
- aac: { possible: ["ts"], default: "ts" }
1110
- }
1111
- },
1112
- aac: {
1113
- default: "aac",
1114
- forAudioCodec: {
1115
- aac: {
1116
- possible: ["aac", "3gp", "m4a", "m4b", "mpg", "mpeg"],
1117
- default: "aac"
1118
- },
1119
- "pcm-16": {
1120
- possible: ["wav"],
1121
- default: "wav"
1122
- }
1123
- }
1124
- },
1125
- gif: {
1126
- default: "gif",
1127
- forAudioCodec: {}
1128
- },
1129
- h264: {
1130
- default: "mp4",
1131
- forAudioCodec: {
1132
- "pcm-16": { possible: ["mkv", "mov"], default: "mkv" },
1133
- aac: { possible: ["mp4", "mkv", "mov"], default: "mp4" },
1134
- mp3: { possible: ["mp4", "mkv", "mov"], default: "mp4" }
1135
- }
1136
- },
1137
- h265: {
1138
- default: "mp4",
1139
- forAudioCodec: {
1140
- aac: { possible: ["mp4", "mkv", "hevc"], default: "mp4" },
1141
- "pcm-16": { possible: ["mkv"], default: "mkv" }
1142
- }
1143
- },
1144
- mp3: {
1145
- default: "mp3",
1146
- forAudioCodec: {
1147
- mp3: { possible: ["mp3"], default: "mp3" },
1148
- "pcm-16": { possible: ["wav"], default: "wav" }
1149
- }
1150
- },
1151
- prores: {
1152
- default: "mov",
1153
- forAudioCodec: {
1154
- aac: { possible: ["mov", "mkv", "mxf"], default: "mov" },
1155
- "pcm-16": { possible: ["mov", "mkv", "mxf"], default: "mov" }
1156
- }
1157
- },
1158
- vp8: {
1159
- default: "webm",
1160
- forAudioCodec: {
1161
- "pcm-16": { possible: ["mkv"], default: "mkv" },
1162
- opus: { possible: ["webm"], default: "webm" }
1163
- }
1164
- },
1165
- vp9: {
1166
- default: "webm",
1167
- forAudioCodec: {
1168
- "pcm-16": { possible: ["mkv"], default: "mkv" },
1169
- opus: { possible: ["webm"], default: "webm" }
1170
- }
1171
- },
1172
- wav: {
1173
- default: "wav",
1174
- forAudioCodec: {
1175
- "pcm-16": { possible: ["wav"], default: "wav" }
1176
- }
1177
- }
1178
- };
1179
- });
1180
-
1181
- // ../renderer/dist/get-extension-from-codec.js
1182
- var require_get_extension_from_codec = __commonJS((exports) => {
1183
- Object.defineProperty(exports, "__esModule", { value: true });
1184
- exports.defaultCodecsForFileExtension = exports.makeFileExtensionMap = exports.getFileExtensionFromCodec = undefined;
1185
- var codec_1 = require_codec();
1186
- var file_extensions_1 = require_file_extensions();
1187
- var getFileExtensionFromCodec = (codec, audioCodec) => {
1188
- if (!codec_1.validCodecs.includes(codec)) {
1189
- throw new Error(`Codec must be one of the following: ${codec_1.validCodecs.join(", ")}, but got ${codec}`);
1190
- }
1191
- const map = file_extensions_1.defaultFileExtensionMap[codec];
1192
- if (audioCodec === null) {
1193
- return map.default;
1194
- }
1195
- const typedAudioCodec = audioCodec;
1196
- if (!(typedAudioCodec in map.forAudioCodec)) {
1197
- throw new Error(`Audio codec ${typedAudioCodec} is not supported for codec ${codec}`);
1198
- }
1199
- return map.forAudioCodec[audioCodec].default;
1200
- };
1201
- exports.getFileExtensionFromCodec = getFileExtensionFromCodec;
1202
- var makeFileExtensionMap = () => {
1203
- const map = {};
1204
- Object.keys(file_extensions_1.defaultFileExtensionMap).forEach((_codec) => {
1205
- const codec = _codec;
1206
- const fileExtMap = file_extensions_1.defaultFileExtensionMap[codec];
1207
- const audioCodecs = Object.keys(fileExtMap.forAudioCodec);
1208
- const possibleExtensionsForAudioCodec = audioCodecs.map((audioCodec) => fileExtMap.forAudioCodec[audioCodec].possible);
1209
- const allPossibleExtensions = [
1210
- fileExtMap.default,
1211
- ...possibleExtensionsForAudioCodec.flat(1)
1212
- ];
1213
- for (const extension of allPossibleExtensions) {
1214
- if (!map[extension]) {
1215
- map[extension] = [];
1216
- }
1217
- if (!map[extension].includes(codec)) {
1218
- map[extension].push(codec);
1219
- }
1220
- }
1221
- });
1222
- return map;
1223
- };
1224
- exports.makeFileExtensionMap = makeFileExtensionMap;
1225
- exports.defaultCodecsForFileExtension = {
1226
- "3gp": "aac",
1227
- aac: "aac",
1228
- gif: "gif",
1229
- hevc: "h265",
1230
- m4a: "aac",
1231
- m4b: "aac",
1232
- mkv: "h264-mkv",
1233
- mov: "prores",
1234
- mp3: "mp3",
1235
- mp4: "h264",
1236
- mpeg: "aac",
1237
- mpg: "aac",
1238
- mxf: "prores",
1239
- wav: "wav",
1240
- webm: "vp8",
1241
- ts: "h264-ts"
1242
- };
1243
- });
1244
-
1245
- // ../renderer/dist/path-normalize.js
1246
- var require_path_normalize = __commonJS((exports) => {
1247
- Object.defineProperty(exports, "__esModule", { value: true });
1248
- exports.pathNormalize = undefined;
1249
- var SLASH = 47;
1250
- var DOT = 46;
1251
- var assertPath = (path) => {
1252
- const t = typeof path;
1253
- if (t !== "string") {
1254
- throw new TypeError(`Expected a string, got a ${t}`);
1255
- }
1256
- };
1257
- var posixNormalize = (path, allowAboveRoot) => {
1258
- let res = "";
1259
- let lastSegmentLength = 0;
1260
- let lastSlash = -1;
1261
- let dots = 0;
1262
- let code;
1263
- for (let i = 0;i <= path.length; ++i) {
1264
- if (i < path.length) {
1265
- code = path.charCodeAt(i);
1266
- } else if (code === SLASH) {
1267
- break;
1268
- } else {
1269
- code = SLASH;
1270
- }
1271
- if (code === SLASH) {
1272
- if (lastSlash === i - 1 || dots === 1) {
1273
- } else if (lastSlash !== i - 1 && dots === 2) {
1274
- if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== DOT || res.charCodeAt(res.length - 2) !== DOT) {
1275
- if (res.length > 2) {
1276
- const lastSlashIndex = res.lastIndexOf("/");
1277
- if (lastSlashIndex !== res.length - 1) {
1278
- if (lastSlashIndex === -1) {
1279
- res = "";
1280
- lastSegmentLength = 0;
1281
- } else {
1282
- res = res.slice(0, lastSlashIndex);
1283
- lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
1284
- }
1285
- lastSlash = i;
1286
- dots = 0;
1287
- continue;
1288
- }
1289
- } else if (res.length === 2 || res.length === 1) {
1290
- res = "";
1291
- lastSegmentLength = 0;
1292
- lastSlash = i;
1293
- dots = 0;
1294
- continue;
1295
- }
1296
- }
1297
- if (allowAboveRoot) {
1298
- if (res.length > 0) {
1299
- res += "/..";
1300
- } else {
1301
- res = "..";
1302
- }
1303
- lastSegmentLength = 2;
1304
- }
1305
- } else {
1306
- if (res.length > 0) {
1307
- res += "/" + path.slice(lastSlash + 1, i);
1308
- } else {
1309
- res = path.slice(lastSlash + 1, i);
1310
- }
1311
- lastSegmentLength = i - lastSlash - 1;
1312
- }
1313
- lastSlash = i;
1314
- dots = 0;
1315
- } else if (code === DOT && dots !== -1) {
1316
- ++dots;
1317
- } else {
1318
- dots = -1;
1319
- }
1320
- }
1321
- return res;
1322
- };
1323
- var decode = (s) => {
1324
- try {
1325
- return decodeURIComponent(s);
1326
- } catch (_a) {
1327
- return s;
1328
- }
1329
- };
1330
- var pathNormalize = (p) => {
1331
- assertPath(p);
1332
- let path = p;
1333
- if (path.length === 0) {
1334
- return ".";
1335
- }
1336
- const isAbsolute = path.charCodeAt(0) === SLASH;
1337
- const trailingSeparator = path.charCodeAt(path.length - 1) === SLASH;
1338
- path = decode(path);
1339
- path = posixNormalize(path, !isAbsolute);
1340
- if (path.length === 0 && !isAbsolute) {
1341
- path = ".";
1342
- }
1343
- if (path.length > 0 && trailingSeparator) {
1344
- path += "/";
1345
- }
1346
- if (isAbsolute) {
1347
- return "/" + path;
1348
- }
1349
- return path;
1350
- };
1351
- exports.pathNormalize = pathNormalize;
1352
- });
1353
-
1354
- // ../renderer/dist/get-extension-of-filename.js
1355
- var require_get_extension_of_filename = __commonJS((exports) => {
1356
- Object.defineProperty(exports, "__esModule", { value: true });
1357
- exports.getExtensionOfFilename = undefined;
1358
- var path_normalize_1 = require_path_normalize();
1359
- var getExtensionOfFilename = (filename) => {
1360
- if (filename === null) {
1361
- return null;
1362
- }
1363
- const filenameArr = (0, path_normalize_1.pathNormalize)(filename).split(".");
1364
- const hasExtension = filenameArr.length >= 2;
1365
- const filenameArrLength = filenameArr.length;
1366
- const extension = hasExtension ? filenameArr[filenameArrLength - 1] : null;
1367
- return extension;
1368
- };
1369
- exports.getExtensionOfFilename = getExtensionOfFilename;
1370
- });
1371
-
1372
- // ../renderer/dist/options/separate-audio.js
1373
- var require_separate_audio = __commonJS((exports) => {
1374
- Object.defineProperty(exports, "__esModule", { value: true });
1375
- exports.separateAudioOption = undefined;
1376
- var DEFAULT = null;
1377
- var cliFlag = "separate-audio-to";
1378
- exports.separateAudioOption = {
1379
- cliFlag,
1380
- description: () => `If set, the audio will not be included in the main output but rendered as a separate file at the location you pass. It is recommended to use an absolute path. If a relative path is passed, it is relative to the Remotion Root.`,
1381
- docLink: "https://remotion.dev/docs/renderer/render-media",
1382
- getValue: ({ commandLine }) => {
1383
- if (commandLine[cliFlag]) {
1384
- return {
1385
- source: "cli",
1386
- value: commandLine[cliFlag]
1387
- };
1388
- }
1389
- return {
1390
- source: "default",
1391
- value: DEFAULT
1392
- };
1393
- },
1394
- name: "Separate audio to",
1395
- setConfig: () => {
1396
- throw new Error("Not implemented");
1397
- },
1398
- ssrName: "separateAudioTo",
1399
- type: "string"
1400
- };
1401
- });
1402
-
1403
- // ../renderer/dist/options/audio-codec.js
1404
- var require_audio_codec = __commonJS((exports) => {
1405
- Object.defineProperty(exports, "__esModule", { value: true });
1406
- exports.audioCodecOption = exports.getDefaultAudioCodec = exports.resolveAudioCodec = exports.getExtensionFromAudioCodec = exports.defaultAudioCodecs = exports.mapAudioCodecToFfmpegAudioCodecName = exports.supportedAudioCodecs = exports.validAudioCodecs = undefined;
1407
- var separate_audio_1 = require_separate_audio();
1408
- exports.validAudioCodecs = ["pcm-16", "aac", "mp3", "opus"];
1409
- exports.supportedAudioCodecs = {
1410
- h264: ["aac", "pcm-16", "mp3"],
1411
- "h264-mkv": ["pcm-16", "mp3"],
1412
- "h264-ts": ["pcm-16", "aac"],
1413
- aac: ["aac", "pcm-16"],
1414
- avi: [],
1415
- gif: [],
1416
- h265: ["aac", "pcm-16"],
1417
- mp3: ["mp3", "pcm-16"],
1418
- prores: ["aac", "pcm-16"],
1419
- vp8: ["opus", "pcm-16"],
1420
- vp9: ["opus", "pcm-16"],
1421
- wav: ["pcm-16"]
1422
- };
1423
- var _satisfies = exports.supportedAudioCodecs;
1424
- if (_satisfies) {
1425
- }
1426
- var mapAudioCodecToFfmpegAudioCodecName = (audioCodec) => {
1427
- if (audioCodec === "aac") {
1428
- return "libfdk_aac";
1429
- }
1430
- if (audioCodec === "mp3") {
1431
- return "libmp3lame";
1432
- }
1433
- if (audioCodec === "opus") {
1434
- return "libopus";
1435
- }
1436
- if (audioCodec === "pcm-16") {
1437
- return "pcm_s16le";
1438
- }
1439
- throw new Error("unknown audio codec: " + audioCodec);
1440
- };
1441
- exports.mapAudioCodecToFfmpegAudioCodecName = mapAudioCodecToFfmpegAudioCodecName;
1442
- var cliFlag = "audio-codec";
1443
- var ssrName = "audioCodec";
1444
- exports.defaultAudioCodecs = {
1445
- "h264-mkv": {
1446
- lossless: "pcm-16",
1447
- compressed: "pcm-16"
1448
- },
1449
- "h264-ts": {
1450
- lossless: "pcm-16",
1451
- compressed: "aac"
1452
- },
1453
- aac: {
1454
- lossless: "pcm-16",
1455
- compressed: "aac"
1456
- },
1457
- gif: {
1458
- lossless: null,
1459
- compressed: null
1460
- },
1461
- h264: {
1462
- lossless: "pcm-16",
1463
- compressed: "aac"
1464
- },
1465
- h265: {
1466
- lossless: "pcm-16",
1467
- compressed: "aac"
1468
- },
1469
- mp3: {
1470
- lossless: "pcm-16",
1471
- compressed: "mp3"
1472
- },
1473
- prores: {
1474
- lossless: "pcm-16",
1475
- compressed: "pcm-16"
1476
- },
1477
- vp8: {
1478
- lossless: "pcm-16",
1479
- compressed: "opus"
1480
- },
1481
- vp9: {
1482
- lossless: "pcm-16",
1483
- compressed: "opus"
1484
- },
1485
- wav: {
1486
- lossless: "pcm-16",
1487
- compressed: "pcm-16"
1488
- }
1489
- };
1490
- var extensionMap = {
1491
- aac: "aac",
1492
- mp3: "mp3",
1493
- opus: "opus",
1494
- "pcm-16": "wav"
1495
- };
1496
- var getExtensionFromAudioCodec = (audioCodec) => {
1497
- if (extensionMap[audioCodec]) {
1498
- return extensionMap[audioCodec];
1499
- }
1500
- throw new Error(`Unsupported audio codec: ${audioCodec}`);
1501
- };
1502
- exports.getExtensionFromAudioCodec = getExtensionFromAudioCodec;
1503
- var resolveAudioCodec = ({ codec, setting, preferLossless, separateAudioTo }) => {
1504
- let derivedFromSeparateAudioToExtension = null;
1505
- if (separateAudioTo) {
1506
- const extension = separateAudioTo.split(".").pop();
1507
- for (const [key, value] of Object.entries(extensionMap)) {
1508
- if (value === extension) {
1509
- derivedFromSeparateAudioToExtension = key;
1510
- if (!exports.supportedAudioCodecs[codec].includes(derivedFromSeparateAudioToExtension) && derivedFromSeparateAudioToExtension) {
1511
- throw new Error(`The codec is ${codec} but the audio codec derived from --${separate_audio_1.separateAudioOption.cliFlag} is ${derivedFromSeparateAudioToExtension}. The only supported codecs are: ${exports.supportedAudioCodecs[codec].join(", ")}`);
1512
- }
1513
- }
1514
- }
1515
- }
1516
- if (preferLossless) {
1517
- const selected = (0, exports.getDefaultAudioCodec)({ codec, preferLossless });
1518
- if (derivedFromSeparateAudioToExtension && selected !== derivedFromSeparateAudioToExtension) {
1519
- throw new Error(`The audio codec derived from --${separate_audio_1.separateAudioOption.cliFlag} is ${derivedFromSeparateAudioToExtension}, but does not match the audio codec derived from the "Prefer lossless" option (${selected}). Remove any conflicting options.`);
119
+ const length = Number(lengthString);
120
+ const status = Number(statusString);
121
+ const dataLength = outputBuffer.length - separatorIndex - 1;
122
+ if (dataLength < length) {
123
+ missingData = {
124
+ dataMissing: length - dataLength
125
+ };
126
+ return;
1520
127
  }
1521
- return selected;
1522
- }
1523
- if (setting === null) {
1524
- if (derivedFromSeparateAudioToExtension) {
1525
- return derivedFromSeparateAudioToExtension;
128
+ const data = outputBuffer.subarray(separatorIndex + 1, separatorIndex + 1 + Number(lengthString));
129
+ onMessage(status === 1 ? "error" : "success", nonceString, data);
130
+ missingData = null;
131
+ outputBuffer = outputBuffer.subarray(separatorIndex + Number(lengthString) + 1);
132
+ processInput();
133
+ };
134
+ const onData = (data) => {
135
+ unprocessedBuffers.push(data);
136
+ if (missingData) {
137
+ missingData.dataMissing -= data.length;
1526
138
  }
1527
- return (0, exports.getDefaultAudioCodec)({ codec, preferLossless });
1528
- }
1529
- if (derivedFromSeparateAudioToExtension !== setting && derivedFromSeparateAudioToExtension) {
1530
- throw new Error(`The audio codec derived from --${separate_audio_1.separateAudioOption.cliFlag} is ${derivedFromSeparateAudioToExtension}, but does not match the audio codec derived from your ${exports.audioCodecOption.name} setting (${setting}). Remove any conflicting options.`);
1531
- }
1532
- return setting;
1533
- };
1534
- exports.resolveAudioCodec = resolveAudioCodec;
1535
- var getDefaultAudioCodec = ({ codec, preferLossless }) => {
1536
- return exports.defaultAudioCodecs[codec][preferLossless ? "lossless" : "compressed"];
1537
- };
1538
- exports.getDefaultAudioCodec = getDefaultAudioCodec;
1539
- var _audioCodec = null;
1540
- exports.audioCodecOption = {
1541
- cliFlag,
1542
- setConfig: (audioCodec) => {
1543
- if (audioCodec === null) {
1544
- _audioCodec = null;
139
+ if (missingData && missingData.dataMissing > 0) {
1545
140
  return;
1546
141
  }
1547
- if (!exports.validAudioCodecs.includes(audioCodec)) {
1548
- throw new Error(`Audio codec must be one of the following: ${exports.validAudioCodecs.join(", ")}, but got ${audioCodec}`);
1549
- }
1550
- _audioCodec = audioCodec;
1551
- },
1552
- getValue: ({ commandLine }) => {
1553
- if (commandLine[cliFlag]) {
1554
- const codec = commandLine[cliFlag];
1555
- if (!exports.validAudioCodecs.includes(commandLine[cliFlag])) {
1556
- throw new Error(`Audio codec must be one of the following: ${exports.validAudioCodecs.join(", ")}, but got ${codec}`);
1557
- }
1558
- return {
1559
- source: "cli",
1560
- value: commandLine[cliFlag]
1561
- };
142
+ const newBuffer = new Uint8Array(outputBuffer.length + unprocessedBuffers.reduce((acc, val) => acc + val.length, 0));
143
+ newBuffer.set(outputBuffer, 0);
144
+ let offset = outputBuffer.length;
145
+ for (const buf of unprocessedBuffers) {
146
+ newBuffer.set(buf, offset);
147
+ offset += buf.length;
1562
148
  }
1563
- if (_audioCodec !== null) {
1564
- return {
1565
- source: "config",
1566
- value: _audioCodec
1567
- };
149
+ outputBuffer = newBuffer;
150
+ unprocessedBuffers = [];
151
+ processInput();
152
+ };
153
+ return {
154
+ onData,
155
+ getOutputBuffer: () => outputBuffer,
156
+ clear: () => {
157
+ unprocessedBuffers = [];
158
+ outputBuffer = new Uint8Array(0);
1568
159
  }
1569
- return {
1570
- source: "default",
1571
- value: null
1572
- };
1573
- },
1574
- description: () => `Set the format of the audio that is embedded in the video. Not all codec and audio codec combinations are supported and certain combinations require a certain file extension and container format. See the table in the docs to see possible combinations.`,
1575
- docLink: "https://www.remotion.dev/docs/encoding/#audio-codec",
1576
- name: "Audio Codec",
1577
- ssrName,
1578
- type: "aac"
160
+ };
1579
161
  };
1580
- });
1581
-
1582
- // ../renderer/dist/validate-output-filename.js
1583
- var require_validate_output_filename = __commonJS((exports) => {
1584
- Object.defineProperty(exports, "__esModule", { value: true });
1585
- exports.validateOutputFilename = undefined;
1586
- var file_extensions_1 = require_file_extensions();
1587
- var audio_codec_1 = require_audio_codec();
1588
- var validateOutputFilename = ({ codec, audioCodecSetting, extension, preferLossless, separateAudioTo }) => {
1589
- if (!file_extensions_1.defaultFileExtensionMap[codec]) {
1590
- throw new TypeError(`The codec "${codec}" is not supported. Supported codecs are: ${Object.keys(file_extensions_1.defaultFileExtensionMap).join(", ")}`);
1591
- }
1592
- const map = file_extensions_1.defaultFileExtensionMap[codec];
1593
- const resolvedAudioCodec = (0, audio_codec_1.resolveAudioCodec)({
1594
- codec,
1595
- preferLossless,
1596
- setting: audioCodecSetting,
1597
- separateAudioTo
1598
- });
1599
- if (resolvedAudioCodec === null) {
1600
- if (extension !== map.default) {
1601
- throw new TypeError(`When using the ${codec} codec, the output filename must end in .${map.default}.`);
1602
- }
1603
- return;
1604
- }
1605
- if (!(resolvedAudioCodec in map.forAudioCodec)) {
1606
- throw new Error(`Audio codec ${resolvedAudioCodec} is not supported for codec ${codec}`);
1607
- }
1608
- const acceptableExtensions = map.forAudioCodec[resolvedAudioCodec].possible;
1609
- if (!acceptableExtensions.includes(extension) && !separateAudioTo) {
1610
- throw new TypeError(`When using the ${codec} codec with the ${resolvedAudioCodec} audio codec, the output filename must end in one of the following: ${acceptableExtensions.join(", ")}.`);
1611
- }
162
+ exports.makeStreamer = makeStreamer;
163
+ var makeStreamPayloadMessage = ({ status, body, nonce }) => {
164
+ const nonceArr = new TextEncoder().encode(nonce);
165
+ const magicWordArr = new TextEncoder().encode(exports.streamingKey);
166
+ const separatorArr = new TextEncoder().encode(":");
167
+ const bodyLengthArr = new TextEncoder().encode(body.length.toString());
168
+ const statusArr = new TextEncoder().encode(String(status));
169
+ const totalLength = nonceArr.length + magicWordArr.length + separatorArr.length * 3 + bodyLengthArr.length + statusArr.length + body.length;
170
+ const concat = new Uint8Array(totalLength);
171
+ let offset = 0;
172
+ const appendToConcat = (data) => {
173
+ concat.set(data, offset);
174
+ offset += data.length;
175
+ };
176
+ appendToConcat(magicWordArr);
177
+ appendToConcat(nonceArr);
178
+ appendToConcat(separatorArr);
179
+ appendToConcat(bodyLengthArr);
180
+ appendToConcat(separatorArr);
181
+ appendToConcat(statusArr);
182
+ appendToConcat(separatorArr);
183
+ appendToConcat(body);
184
+ return concat;
1612
185
  };
1613
- exports.validateOutputFilename = validateOutputFilename;
186
+ exports.makeStreamPayloadMessage = makeStreamPayloadMessage;
1614
187
  });
1615
188
 
1616
- // ../renderer/dist/pure.js
1617
- var require_pure = __commonJS((exports) => {
189
+ // ../streaming/dist/index.js
190
+ var require_dist = __commonJS((exports) => {
1618
191
  Object.defineProperty(exports, "__esModule", { value: true });
1619
- exports.NoReactAPIs = undefined;
1620
- var codec_supports_media_1 = require_codec_supports_media();
1621
- var get_duration_from_frame_range_1 = require_get_duration_from_frame_range();
1622
- var get_extension_from_codec_1 = require_get_extension_from_codec();
1623
- var get_extension_of_filename_1 = require_get_extension_of_filename();
1624
- var is_audio_codec_1 = require_is_audio_codec();
1625
- var validate_output_filename_1 = require_validate_output_filename();
1626
- exports.NoReactAPIs = {
1627
- getExtensionOfFilename: get_extension_of_filename_1.getExtensionOfFilename,
1628
- getFileExtensionFromCodec: get_extension_from_codec_1.getFileExtensionFromCodec,
1629
- validateOutputFilename: validate_output_filename_1.validateOutputFilename,
1630
- getFramesToRender: get_duration_from_frame_range_1.getFramesToRender,
1631
- codecSupportsMedia: codec_supports_media_1.codecSupportsMedia,
1632
- isAudioCodec: is_audio_codec_1.isAudioCodec
1633
- };
192
+ exports.makeStreamer = exports.makeStreamPayloadMessage = undefined;
193
+ var make_stream_payload_message_1 = require_make_stream_payload_message();
194
+ Object.defineProperty(exports, "makeStreamPayloadMessage", { enumerable: true, get: function() {
195
+ return make_stream_payload_message_1.makeStreamPayloadMessage;
196
+ } });
197
+ var make_streamer_1 = require_make_streamer();
198
+ Object.defineProperty(exports, "makeStreamer", { enumerable: true, get: function() {
199
+ return make_streamer_1.makeStreamer;
200
+ } });
1634
201
  });
1635
202
 
1636
203
  // ../core/dist/esm/no-react.mjs
@@ -2387,13 +954,338 @@ var validateFramesPerFunction = ({
2387
954
  throw new TypeError(`The framesPerLambda needs to be at least ${effectiveMinimum}, but is ${framesPerFunction}`);
2388
955
  }
2389
956
  };
957
+ // ../renderer/dist/esm/error-handling.mjs
958
+ import * as tty from "tty";
959
+
960
+ // ../core/dist/esm/version.mjs
961
+ var VERSION = "4.0.268";
962
+
963
+ // ../renderer/dist/esm/error-handling.mjs
964
+ var isColorSupported = () => {
965
+ const env = process.env || {};
966
+ const isForceDisabled = "NO_COLOR" in env;
967
+ if (isForceDisabled) {
968
+ return false;
969
+ }
970
+ const isForced = "FORCE_COLOR" in env;
971
+ if (isForced) {
972
+ return true;
973
+ }
974
+ const isWindows = process.platform === "win32";
975
+ const isCompatibleTerminal = tty?.isatty?.(1) && env.TERM && env.TERM !== "dumb";
976
+ const isCI = "CI" in env && (("GITHUB_ACTIONS" in env) || ("GITLAB_CI" in env) || ("CIRCLECI" in env));
977
+ return isWindows || isCompatibleTerminal || isCI;
978
+ };
979
+ var chalk = (() => {
980
+ const colors = {
981
+ enabled: () => isColorSupported(),
982
+ visible: true,
983
+ styles: {},
984
+ keys: {}
985
+ };
986
+ const ansi = (st) => {
987
+ const open = `\x1B[${st.codes[0]}m`;
988
+ const close = `\x1B[${st.codes[1]}m`;
989
+ const regex = new RegExp(`\\u001b\\[${st.codes[1]}m`, "g");
990
+ st.wrap = (input, newline) => {
991
+ if (input.includes(close))
992
+ input = input.replace(regex, close + open);
993
+ const output = open + input + close;
994
+ return newline ? output.replace(/\r*\n/g, `${close}$&${open}`) : output;
995
+ };
996
+ return st;
997
+ };
998
+ const wrap = (sty, input, newline) => {
999
+ return sty.wrap?.(input, newline);
1000
+ };
1001
+ const style = (input, stack) => {
1002
+ if (input === "" || input === null || input === undefined)
1003
+ return "";
1004
+ if (colors.enabled() === false)
1005
+ return input;
1006
+ if (colors.visible === false)
1007
+ return "";
1008
+ let str = String(input);
1009
+ const nl = str.includes(`
1010
+ `);
1011
+ let n = stack.length;
1012
+ while (n-- > 0)
1013
+ str = wrap(colors.styles[stack[n]], str, nl);
1014
+ return str;
1015
+ };
1016
+ const define = (name, codes, type) => {
1017
+ colors.styles[name] = ansi({ name, codes });
1018
+ const keys = colors.keys[type] || (colors.keys[type] = []);
1019
+ keys.push(name);
1020
+ Reflect.defineProperty(colors, name, {
1021
+ configurable: true,
1022
+ enumerable: true,
1023
+ set(value) {
1024
+ colors.alias?.(name, value);
1025
+ },
1026
+ get() {
1027
+ const color = (input) => style(input, color.stack);
1028
+ Reflect.setPrototypeOf(color, colors);
1029
+ color.stack = this.stack ? this.stack.concat(name) : [name];
1030
+ return color;
1031
+ }
1032
+ });
1033
+ };
1034
+ define("reset", [0, 0], "modifier");
1035
+ define("bold", [1, 22], "modifier");
1036
+ define("dim", [2, 22], "modifier");
1037
+ define("italic", [3, 23], "modifier");
1038
+ define("underline", [4, 24], "modifier");
1039
+ define("inverse", [7, 27], "modifier");
1040
+ define("hidden", [8, 28], "modifier");
1041
+ define("strikethrough", [9, 29], "modifier");
1042
+ define("black", [30, 39], "color");
1043
+ define("red", [31, 39], "color");
1044
+ define("green", [32, 39], "color");
1045
+ define("yellow", [33, 39], "color");
1046
+ define("blue", [34, 39], "color");
1047
+ define("magenta", [35, 39], "color");
1048
+ define("cyan", [36, 39], "color");
1049
+ define("white", [37, 39], "color");
1050
+ define("gray", [90, 39], "color");
1051
+ define("grey", [90, 39], "color");
1052
+ define("bgBlack", [40, 49], "bg");
1053
+ define("bgRed", [41, 49], "bg");
1054
+ define("bgGreen", [42, 49], "bg");
1055
+ define("bgYellow", [43, 49], "bg");
1056
+ define("bgBlue", [44, 49], "bg");
1057
+ define("bgMagenta", [45, 49], "bg");
1058
+ define("bgWhite", [47, 49], "bg");
1059
+ define("blackBright", [90, 39], "bright");
1060
+ define("redBright", [91, 39], "bright");
1061
+ define("greenBright", [92, 39], "bright");
1062
+ define("yellowBright", [93, 39], "bright");
1063
+ define("blueBright", [94, 39], "bright");
1064
+ define("magentaBright", [95, 39], "bright");
1065
+ define("whiteBright", [97, 39], "bright");
1066
+ define("bgBlackBright", [100, 49], "bgBright");
1067
+ define("bgRedBright", [101, 49], "bgBright");
1068
+ define("bgGreenBright", [102, 49], "bgBright");
1069
+ define("bgYellowBright", [103, 49], "bgBright");
1070
+ define("bgBlueBright", [104, 49], "bgBright");
1071
+ define("bgMagentaBright", [105, 49], "bgBright");
1072
+ define("bgWhiteBright", [107, 49], "bgBright");
1073
+ colors.alias = (name, color) => {
1074
+ const fn = colors[color];
1075
+ if (typeof fn !== "function") {
1076
+ throw new TypeError("Expected alias to be the name of an existing color (string) or a function");
1077
+ }
1078
+ if (!fn.stack) {
1079
+ Reflect.defineProperty(fn, "name", { value: name });
1080
+ colors.styles[name] = fn;
1081
+ fn.stack = [name];
1082
+ }
1083
+ Reflect.defineProperty(colors, name, {
1084
+ configurable: true,
1085
+ enumerable: true,
1086
+ set(value) {
1087
+ colors.alias?.(name, value);
1088
+ },
1089
+ get() {
1090
+ const col = (input) => style(input, col.stack);
1091
+ Reflect.setPrototypeOf(col, colors);
1092
+ col.stack = this.stack ? this.stack.concat(fn.stack) : fn.stack;
1093
+ return col;
1094
+ }
1095
+ });
1096
+ };
1097
+ return colors;
1098
+ })();
1099
+ var logLevels = ["trace", "verbose", "info", "warn", "error"];
1100
+ var getNumberForLogLevel = (level) => {
1101
+ return logLevels.indexOf(level);
1102
+ };
1103
+ var isEqualOrBelowLogLevel = (currentLevel, level) => {
1104
+ return getNumberForLogLevel(currentLevel) <= getNumberForLogLevel(level);
1105
+ };
1106
+ var reproWriteInstance = null;
1107
+ var getReproWriter = () => {
1108
+ if (!reproWriteInstance) {
1109
+ throw new Error("reproWriteInstance is not initialized");
1110
+ }
1111
+ return reproWriteInstance;
1112
+ };
1113
+ var writeInRepro = (level, ...args) => {
1114
+ if (isReproEnabled()) {
1115
+ getReproWriter().writeLine(level, ...args);
1116
+ }
1117
+ };
1118
+ var shouldRepro = false;
1119
+ var isReproEnabled = () => shouldRepro;
1120
+ function truthy2(value) {
1121
+ return Boolean(value);
1122
+ }
1123
+ var INDENT_TOKEN = chalk.gray("│");
1124
+ var verboseTag = (str) => {
1125
+ return isColorSupported() ? chalk.bgBlack(` ${str} `) : `[${str}]`;
1126
+ };
1127
+ var Log = {
1128
+ trace: (options, ...args) => {
1129
+ writeInRepro("trace", ...args);
1130
+ if (isEqualOrBelowLogLevel(options.logLevel, "trace")) {
1131
+ if (args.length === 0) {
1132
+ return process.stdout.write(`
1133
+ `);
1134
+ }
1135
+ return console.log(...[
1136
+ options.indent ? INDENT_TOKEN : null,
1137
+ options.tag ? verboseTag(options.tag) : null
1138
+ ].filter(truthy2).concat(args.map((a) => chalk.gray(a))));
1139
+ }
1140
+ },
1141
+ verbose: (options, ...args) => {
1142
+ writeInRepro("verbose", ...args);
1143
+ if (isEqualOrBelowLogLevel(options.logLevel, "verbose")) {
1144
+ if (args.length === 0) {
1145
+ return process.stdout.write(`
1146
+ `);
1147
+ }
1148
+ return console.log(...[
1149
+ options.indent ? INDENT_TOKEN : null,
1150
+ options.tag ? verboseTag(options.tag) : null
1151
+ ].filter(truthy2).concat(args.map((a) => chalk.gray(a))));
1152
+ }
1153
+ },
1154
+ info: (options, ...args) => {
1155
+ writeInRepro("info", ...args);
1156
+ if (isEqualOrBelowLogLevel(options.logLevel, "info")) {
1157
+ if (args.length === 0) {
1158
+ return process.stdout.write(`
1159
+ `);
1160
+ }
1161
+ return console.log(...[options.indent ? INDENT_TOKEN : null].filter(truthy2).concat(args ?? []));
1162
+ }
1163
+ },
1164
+ warn: (options, ...args) => {
1165
+ writeInRepro("warn", ...args);
1166
+ if (isEqualOrBelowLogLevel(options.logLevel, "warn")) {
1167
+ if (args.length === 0) {
1168
+ return process.stdout.write(`
1169
+ `);
1170
+ }
1171
+ return console.warn(...[options.indent ? chalk.yellow(INDENT_TOKEN) : null].filter(truthy2).concat(args.map((a) => chalk.yellow(a))));
1172
+ }
1173
+ },
1174
+ error: (options, ...args) => {
1175
+ writeInRepro("error", ...args);
1176
+ if (isEqualOrBelowLogLevel(options.logLevel, "error")) {
1177
+ if (args.length === 0) {
1178
+ return process.stdout.write(`
1179
+ `);
1180
+ }
1181
+ return console.error(...[
1182
+ options.indent ? INDENT_TOKEN : null,
1183
+ options.tag ? verboseTag(options.tag) : null
1184
+ ].filter(truthy2).concat(args.map((a) => chalk.red(a))));
1185
+ }
1186
+ }
1187
+ };
1188
+ var alreadyPrintedCache = [];
1189
+ var printUsefulErrorMessage = (err, logLevel, indent) => {
1190
+ const errorStack = err.stack;
1191
+ if (errorStack && alreadyPrintedCache.includes(errorStack)) {
1192
+ return;
1193
+ }
1194
+ if (errorStack) {
1195
+ alreadyPrintedCache.push(errorStack);
1196
+ alreadyPrintedCache = alreadyPrintedCache.slice(-10);
1197
+ }
1198
+ if (err.message.includes("Could not play video with")) {
1199
+ Log.info({ indent, logLevel });
1200
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/media-playback-error");
1201
+ }
1202
+ if (err.message.includes("A delayRender()") && err.message.includes("was called but not cleared after")) {
1203
+ Log.info({ indent, logLevel });
1204
+ if (err.message.includes("/proxy")) {
1205
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/troubleshooting/delay-render-proxy");
1206
+ }
1207
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/timeout");
1208
+ }
1209
+ if (err.message.includes("Target closed")) {
1210
+ Log.info({ indent, logLevel });
1211
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/target-closed");
1212
+ }
1213
+ if (err.message.includes("Timed out evaluating")) {
1214
+ Log.info({ indent, logLevel });
1215
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/troubleshooting/timed-out-page-function");
1216
+ }
1217
+ if (err.message.includes("ENAMETOOLONG")) {
1218
+ Log.info({ indent, logLevel });
1219
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/enametoolong");
1220
+ }
1221
+ if (err.message.includes("Member must have value less than or equal to 3008")) {
1222
+ Log.info({ indent, logLevel });
1223
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 This error indicates that you have a AWS account on the free tier or have been limited by your organization. Often times this can be solved by adding a credit card. See also: https://repost.aws/questions/QUKruWYNDYTSmP17jCnIz6IQ/questions/QUKruWYNDYTSmP17jCnIz6IQ/unable-to-set-lambda-memory-over-3008mb");
1224
+ }
1225
+ if (err.stack?.includes("TooManyRequestsException: Rate Exceeded.")) {
1226
+ Log.info({ indent, logLevel });
1227
+ 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");
1228
+ }
1229
+ if (err.message.includes("Error creating WebGL context")) {
1230
+ Log.info({ indent, logLevel });
1231
+ Log.warn({
1232
+ indent,
1233
+ logLevel
1234
+ }, '\uD83D\uDCA1 You might need to set the OpenGL renderer to "angle-egl", "angle" (or "swangle" if rendering on lambda). Learn why at https://www.remotion.dev/docs/three');
1235
+ Log.warn({
1236
+ indent,
1237
+ logLevel
1238
+ }, "\uD83D\uDCA1 Check how it's done at https://www.remotion.dev/docs/chromium-flags#--gl");
1239
+ }
1240
+ if (err.message.includes("The bucket does not allow ACLs")) {
1241
+ Log.info({ indent, logLevel });
1242
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Fix for this issue: https://remotion.dev/docs/lambda/troubleshooting/bucket-disallows-acl");
1243
+ }
1244
+ if (err.message.includes("Minified React error #306")) {
1245
+ const componentName = err.message.match(/<\w+>/)?.[0];
1246
+ Log.info({ indent, logLevel }, [
1247
+ "\uD83D\uDCA1 This error indicates that the component",
1248
+ componentName ? `(${componentName})` : null,
1249
+ "you are trying to render is not imported correctly."
1250
+ ].filter(truthy2).join(" "));
1251
+ Log.info({ indent, logLevel });
1252
+ Log.info({ indent, logLevel }, " Check the root file and ensure that the component is not undefined.");
1253
+ Log.info({ indent, logLevel }, " Oftentimes, this happens if the component is missing the `export` keyword");
1254
+ Log.info({ indent, logLevel }, " or if the component was renamed and the import statement not properly adjusted.");
1255
+ }
1256
+ if (err.message.includes("GLIBC_")) {
1257
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Remotion requires at least Libc 2.35.");
1258
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue: https://github.com/remotion-dev/remotion/issues/2439");
1259
+ }
1260
+ if (err.message.includes("EBADF")) {
1261
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 This error might be fixed by changing your Node version:");
1262
+ Log.info({ indent, logLevel }, " https://github.com/remotion-dev/remotion/issues/2452");
1263
+ }
1264
+ if (err.message.includes("routines::unsupported")) {
1265
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 This error might happen if using Cloud Run with credentials that have a newline at the end or are otherwise badly encoded.");
1266
+ Log.info({ indent, logLevel }, " https://github.com/remotion-dev/remotion/issues/3864");
1267
+ }
1268
+ if (err.message.includes("Failed to fetch")) {
1269
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 On Lambda, one reason this could happen is that Chrome is rejecting an asset to be loaded when it is running low on disk space.");
1270
+ Log.info({ indent, logLevel }, "Try increasing the disk size of your Lambda function.");
1271
+ }
1272
+ };
1273
+ var wrapWithErrorHandling = (fn) => {
1274
+ return async (...args) => {
1275
+ try {
1276
+ return await fn(...args);
1277
+ } catch (err) {
1278
+ const { indent } = args[0];
1279
+ const { logLevel } = args[0];
1280
+ printUsefulErrorMessage(err, logLevel, indent);
1281
+ throw err;
1282
+ }
1283
+ };
1284
+ };
2390
1285
 
2391
1286
  // src/index.ts
2392
- var import_error_handling = __toESM(require_error_handling(), 1);
2393
1287
  var import_streaming2 = __toESM(require_dist(), 1);
2394
1288
 
2395
- // ../core/dist/esm/version.mjs
2396
- var VERSION = "4.0.266";
2397
1289
  // src/min-max.ts
2398
1290
  var min = (arr) => {
2399
1291
  if (arr.length === 0) {
@@ -2670,8 +1562,509 @@ var estimatePriceFromMetadata = ({
2670
1562
  }).toPrecision(5));
2671
1563
  return { accruedSoFar, estimatedBillingDurationInMilliseconds };
2672
1564
  };
2673
- // src/expected-out-name.ts
2674
- var import_pure2 = __toESM(require_pure(), 1);
1565
+ // ../renderer/dist/esm/pure.mjs
1566
+ var isAudioCodec = (codec) => {
1567
+ return codec === "mp3" || codec === "aac" || codec === "wav";
1568
+ };
1569
+ var support = {
1570
+ "h264-mkv": {
1571
+ audio: true,
1572
+ video: true
1573
+ },
1574
+ aac: {
1575
+ audio: true,
1576
+ video: false
1577
+ },
1578
+ gif: {
1579
+ video: true,
1580
+ audio: false
1581
+ },
1582
+ h264: {
1583
+ video: true,
1584
+ audio: true
1585
+ },
1586
+ "h264-ts": {
1587
+ video: true,
1588
+ audio: true
1589
+ },
1590
+ h265: {
1591
+ video: true,
1592
+ audio: true
1593
+ },
1594
+ mp3: {
1595
+ audio: true,
1596
+ video: false
1597
+ },
1598
+ prores: {
1599
+ audio: true,
1600
+ video: true
1601
+ },
1602
+ vp8: {
1603
+ audio: true,
1604
+ video: true
1605
+ },
1606
+ vp9: {
1607
+ audio: true,
1608
+ video: true
1609
+ },
1610
+ wav: {
1611
+ audio: true,
1612
+ video: false
1613
+ }
1614
+ };
1615
+ var codecSupportsMedia = (codec) => {
1616
+ return support[codec];
1617
+ };
1618
+ var getFramesToRender = (frameRange, everyNthFrame) => {
1619
+ if (everyNthFrame === 0) {
1620
+ throw new Error("everyNthFrame cannot be 0");
1621
+ }
1622
+ return new Array(frameRange[1] - frameRange[0] + 1).fill(true).map((_, index) => {
1623
+ return index + frameRange[0];
1624
+ }).filter((index) => {
1625
+ return index % everyNthFrame === 0;
1626
+ });
1627
+ };
1628
+ var validCodecs = [
1629
+ "h264",
1630
+ "h265",
1631
+ "vp8",
1632
+ "vp9",
1633
+ "mp3",
1634
+ "aac",
1635
+ "wav",
1636
+ "prores",
1637
+ "h264-mkv",
1638
+ "h264-ts",
1639
+ "gif"
1640
+ ];
1641
+ var defaultFileExtensionMap = {
1642
+ "h264-mkv": {
1643
+ default: "mkv",
1644
+ forAudioCodec: {
1645
+ "pcm-16": { possible: ["mkv"], default: "mkv" },
1646
+ mp3: { possible: ["mkv"], default: "mkv" }
1647
+ }
1648
+ },
1649
+ "h264-ts": {
1650
+ default: "ts",
1651
+ forAudioCodec: {
1652
+ "pcm-16": { possible: ["ts"], default: "ts" },
1653
+ aac: { possible: ["ts"], default: "ts" }
1654
+ }
1655
+ },
1656
+ aac: {
1657
+ default: "aac",
1658
+ forAudioCodec: {
1659
+ aac: {
1660
+ possible: ["aac", "3gp", "m4a", "m4b", "mpg", "mpeg"],
1661
+ default: "aac"
1662
+ },
1663
+ "pcm-16": {
1664
+ possible: ["wav"],
1665
+ default: "wav"
1666
+ }
1667
+ }
1668
+ },
1669
+ gif: {
1670
+ default: "gif",
1671
+ forAudioCodec: {}
1672
+ },
1673
+ h264: {
1674
+ default: "mp4",
1675
+ forAudioCodec: {
1676
+ "pcm-16": { possible: ["mkv", "mov"], default: "mkv" },
1677
+ aac: { possible: ["mp4", "mkv", "mov"], default: "mp4" },
1678
+ mp3: { possible: ["mp4", "mkv", "mov"], default: "mp4" }
1679
+ }
1680
+ },
1681
+ h265: {
1682
+ default: "mp4",
1683
+ forAudioCodec: {
1684
+ aac: { possible: ["mp4", "mkv", "hevc"], default: "mp4" },
1685
+ "pcm-16": { possible: ["mkv"], default: "mkv" }
1686
+ }
1687
+ },
1688
+ mp3: {
1689
+ default: "mp3",
1690
+ forAudioCodec: {
1691
+ mp3: { possible: ["mp3"], default: "mp3" },
1692
+ "pcm-16": { possible: ["wav"], default: "wav" }
1693
+ }
1694
+ },
1695
+ prores: {
1696
+ default: "mov",
1697
+ forAudioCodec: {
1698
+ aac: { possible: ["mov", "mkv", "mxf"], default: "mov" },
1699
+ "pcm-16": { possible: ["mov", "mkv", "mxf"], default: "mov" }
1700
+ }
1701
+ },
1702
+ vp8: {
1703
+ default: "webm",
1704
+ forAudioCodec: {
1705
+ "pcm-16": { possible: ["mkv"], default: "mkv" },
1706
+ opus: { possible: ["webm"], default: "webm" }
1707
+ }
1708
+ },
1709
+ vp9: {
1710
+ default: "webm",
1711
+ forAudioCodec: {
1712
+ "pcm-16": { possible: ["mkv"], default: "mkv" },
1713
+ opus: { possible: ["webm"], default: "webm" }
1714
+ }
1715
+ },
1716
+ wav: {
1717
+ default: "wav",
1718
+ forAudioCodec: {
1719
+ "pcm-16": { possible: ["wav"], default: "wav" }
1720
+ }
1721
+ }
1722
+ };
1723
+ var getFileExtensionFromCodec = (codec, audioCodec) => {
1724
+ if (!validCodecs.includes(codec)) {
1725
+ throw new Error(`Codec must be one of the following: ${validCodecs.join(", ")}, but got ${codec}`);
1726
+ }
1727
+ const map = defaultFileExtensionMap[codec];
1728
+ if (audioCodec === null) {
1729
+ return map.default;
1730
+ }
1731
+ const typedAudioCodec = audioCodec;
1732
+ if (!(typedAudioCodec in map.forAudioCodec)) {
1733
+ throw new Error(`Audio codec ${typedAudioCodec} is not supported for codec ${codec}`);
1734
+ }
1735
+ return map.forAudioCodec[audioCodec].default;
1736
+ };
1737
+ var SLASH = 47;
1738
+ var DOT = 46;
1739
+ var assertPath = (path) => {
1740
+ const t = typeof path;
1741
+ if (t !== "string") {
1742
+ throw new TypeError(`Expected a string, got a ${t}`);
1743
+ }
1744
+ };
1745
+ var posixNormalize = (path, allowAboveRoot) => {
1746
+ let res = "";
1747
+ let lastSegmentLength = 0;
1748
+ let lastSlash = -1;
1749
+ let dots = 0;
1750
+ let code;
1751
+ for (let i = 0;i <= path.length; ++i) {
1752
+ if (i < path.length) {
1753
+ code = path.charCodeAt(i);
1754
+ } else if (code === SLASH) {
1755
+ break;
1756
+ } else {
1757
+ code = SLASH;
1758
+ }
1759
+ if (code === SLASH) {
1760
+ if (lastSlash === i - 1 || dots === 1) {
1761
+ } else if (lastSlash !== i - 1 && dots === 2) {
1762
+ if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== DOT || res.charCodeAt(res.length - 2) !== DOT) {
1763
+ if (res.length > 2) {
1764
+ const lastSlashIndex = res.lastIndexOf("/");
1765
+ if (lastSlashIndex !== res.length - 1) {
1766
+ if (lastSlashIndex === -1) {
1767
+ res = "";
1768
+ lastSegmentLength = 0;
1769
+ } else {
1770
+ res = res.slice(0, lastSlashIndex);
1771
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
1772
+ }
1773
+ lastSlash = i;
1774
+ dots = 0;
1775
+ continue;
1776
+ }
1777
+ } else if (res.length === 2 || res.length === 1) {
1778
+ res = "";
1779
+ lastSegmentLength = 0;
1780
+ lastSlash = i;
1781
+ dots = 0;
1782
+ continue;
1783
+ }
1784
+ }
1785
+ if (allowAboveRoot) {
1786
+ if (res.length > 0) {
1787
+ res += "/..";
1788
+ } else {
1789
+ res = "..";
1790
+ }
1791
+ lastSegmentLength = 2;
1792
+ }
1793
+ } else {
1794
+ if (res.length > 0) {
1795
+ res += "/" + path.slice(lastSlash + 1, i);
1796
+ } else {
1797
+ res = path.slice(lastSlash + 1, i);
1798
+ }
1799
+ lastSegmentLength = i - lastSlash - 1;
1800
+ }
1801
+ lastSlash = i;
1802
+ dots = 0;
1803
+ } else if (code === DOT && dots !== -1) {
1804
+ ++dots;
1805
+ } else {
1806
+ dots = -1;
1807
+ }
1808
+ }
1809
+ return res;
1810
+ };
1811
+ var decode = (s) => {
1812
+ try {
1813
+ return decodeURIComponent(s);
1814
+ } catch {
1815
+ return s;
1816
+ }
1817
+ };
1818
+ var pathNormalize = (p) => {
1819
+ assertPath(p);
1820
+ let path = p;
1821
+ if (path.length === 0) {
1822
+ return ".";
1823
+ }
1824
+ const isAbsolute = path.charCodeAt(0) === SLASH;
1825
+ const trailingSeparator = path.charCodeAt(path.length - 1) === SLASH;
1826
+ path = decode(path);
1827
+ path = posixNormalize(path, !isAbsolute);
1828
+ if (path.length === 0 && !isAbsolute) {
1829
+ path = ".";
1830
+ }
1831
+ if (path.length > 0 && trailingSeparator) {
1832
+ path += "/";
1833
+ }
1834
+ if (isAbsolute) {
1835
+ return "/" + path;
1836
+ }
1837
+ return path;
1838
+ };
1839
+ var getExtensionOfFilename = (filename) => {
1840
+ if (filename === null) {
1841
+ return null;
1842
+ }
1843
+ const filenameArr = pathNormalize(filename).split(".");
1844
+ const hasExtension = filenameArr.length >= 2;
1845
+ const filenameArrLength = filenameArr.length;
1846
+ const extension = hasExtension ? filenameArr[filenameArrLength - 1] : null;
1847
+ return extension;
1848
+ };
1849
+ var DEFAULT = null;
1850
+ var cliFlag = "separate-audio-to";
1851
+ var separateAudioOption = {
1852
+ cliFlag,
1853
+ description: () => `If set, the audio will not be included in the main output but rendered as a separate file at the location you pass. It is recommended to use an absolute path. If a relative path is passed, it is relative to the Remotion Root.`,
1854
+ docLink: "https://remotion.dev/docs/renderer/render-media",
1855
+ getValue: ({ commandLine }) => {
1856
+ if (commandLine[cliFlag]) {
1857
+ return {
1858
+ source: "cli",
1859
+ value: commandLine[cliFlag]
1860
+ };
1861
+ }
1862
+ return {
1863
+ source: "default",
1864
+ value: DEFAULT
1865
+ };
1866
+ },
1867
+ name: "Separate audio to",
1868
+ setConfig: () => {
1869
+ throw new Error("Not implemented");
1870
+ },
1871
+ ssrName: "separateAudioTo",
1872
+ type: "string"
1873
+ };
1874
+ var validAudioCodecs = ["pcm-16", "aac", "mp3", "opus"];
1875
+ var supportedAudioCodecs = {
1876
+ h264: ["aac", "pcm-16", "mp3"],
1877
+ "h264-mkv": ["pcm-16", "mp3"],
1878
+ "h264-ts": ["pcm-16", "aac"],
1879
+ aac: ["aac", "pcm-16"],
1880
+ avi: [],
1881
+ gif: [],
1882
+ h265: ["aac", "pcm-16"],
1883
+ mp3: ["mp3", "pcm-16"],
1884
+ prores: ["aac", "pcm-16"],
1885
+ vp8: ["opus", "pcm-16"],
1886
+ vp9: ["opus", "pcm-16"],
1887
+ wav: ["pcm-16"]
1888
+ };
1889
+ var _satisfies = supportedAudioCodecs;
1890
+ if (_satisfies) {
1891
+ }
1892
+ var cliFlag2 = "audio-codec";
1893
+ var ssrName = "audioCodec";
1894
+ var defaultAudioCodecs = {
1895
+ "h264-mkv": {
1896
+ lossless: "pcm-16",
1897
+ compressed: "pcm-16"
1898
+ },
1899
+ "h264-ts": {
1900
+ lossless: "pcm-16",
1901
+ compressed: "aac"
1902
+ },
1903
+ aac: {
1904
+ lossless: "pcm-16",
1905
+ compressed: "aac"
1906
+ },
1907
+ gif: {
1908
+ lossless: null,
1909
+ compressed: null
1910
+ },
1911
+ h264: {
1912
+ lossless: "pcm-16",
1913
+ compressed: "aac"
1914
+ },
1915
+ h265: {
1916
+ lossless: "pcm-16",
1917
+ compressed: "aac"
1918
+ },
1919
+ mp3: {
1920
+ lossless: "pcm-16",
1921
+ compressed: "mp3"
1922
+ },
1923
+ prores: {
1924
+ lossless: "pcm-16",
1925
+ compressed: "pcm-16"
1926
+ },
1927
+ vp8: {
1928
+ lossless: "pcm-16",
1929
+ compressed: "opus"
1930
+ },
1931
+ vp9: {
1932
+ lossless: "pcm-16",
1933
+ compressed: "opus"
1934
+ },
1935
+ wav: {
1936
+ lossless: "pcm-16",
1937
+ compressed: "pcm-16"
1938
+ }
1939
+ };
1940
+ var extensionMap = {
1941
+ aac: "aac",
1942
+ mp3: "mp3",
1943
+ opus: "opus",
1944
+ "pcm-16": "wav"
1945
+ };
1946
+ var resolveAudioCodec = ({
1947
+ codec,
1948
+ setting,
1949
+ preferLossless,
1950
+ separateAudioTo
1951
+ }) => {
1952
+ let derivedFromSeparateAudioToExtension = null;
1953
+ if (separateAudioTo) {
1954
+ const extension = separateAudioTo.split(".").pop();
1955
+ for (const [key, value] of Object.entries(extensionMap)) {
1956
+ if (value === extension) {
1957
+ derivedFromSeparateAudioToExtension = key;
1958
+ if (!supportedAudioCodecs[codec].includes(derivedFromSeparateAudioToExtension) && derivedFromSeparateAudioToExtension) {
1959
+ throw new Error(`The codec is ${codec} but the audio codec derived from --${separateAudioOption.cliFlag} is ${derivedFromSeparateAudioToExtension}. The only supported codecs are: ${supportedAudioCodecs[codec].join(", ")}`);
1960
+ }
1961
+ }
1962
+ }
1963
+ }
1964
+ if (preferLossless) {
1965
+ const selected = getDefaultAudioCodec({ codec, preferLossless });
1966
+ if (derivedFromSeparateAudioToExtension && selected !== derivedFromSeparateAudioToExtension) {
1967
+ throw new Error(`The audio codec derived from --${separateAudioOption.cliFlag} is ${derivedFromSeparateAudioToExtension}, but does not match the audio codec derived from the "Prefer lossless" option (${selected}). Remove any conflicting options.`);
1968
+ }
1969
+ return selected;
1970
+ }
1971
+ if (setting === null) {
1972
+ if (derivedFromSeparateAudioToExtension) {
1973
+ return derivedFromSeparateAudioToExtension;
1974
+ }
1975
+ return getDefaultAudioCodec({ codec, preferLossless });
1976
+ }
1977
+ if (derivedFromSeparateAudioToExtension !== setting && derivedFromSeparateAudioToExtension) {
1978
+ throw new Error(`The audio codec derived from --${separateAudioOption.cliFlag} is ${derivedFromSeparateAudioToExtension}, but does not match the audio codec derived from your ${audioCodecOption.name} setting (${setting}). Remove any conflicting options.`);
1979
+ }
1980
+ return setting;
1981
+ };
1982
+ var getDefaultAudioCodec = ({
1983
+ codec,
1984
+ preferLossless
1985
+ }) => {
1986
+ return defaultAudioCodecs[codec][preferLossless ? "lossless" : "compressed"];
1987
+ };
1988
+ var _audioCodec = null;
1989
+ var audioCodecOption = {
1990
+ cliFlag: cliFlag2,
1991
+ setConfig: (audioCodec) => {
1992
+ if (audioCodec === null) {
1993
+ _audioCodec = null;
1994
+ return;
1995
+ }
1996
+ if (!validAudioCodecs.includes(audioCodec)) {
1997
+ throw new Error(`Audio codec must be one of the following: ${validAudioCodecs.join(", ")}, but got ${audioCodec}`);
1998
+ }
1999
+ _audioCodec = audioCodec;
2000
+ },
2001
+ getValue: ({ commandLine }) => {
2002
+ if (commandLine[cliFlag2]) {
2003
+ const codec = commandLine[cliFlag2];
2004
+ if (!validAudioCodecs.includes(commandLine[cliFlag2])) {
2005
+ throw new Error(`Audio codec must be one of the following: ${validAudioCodecs.join(", ")}, but got ${codec}`);
2006
+ }
2007
+ return {
2008
+ source: "cli",
2009
+ value: commandLine[cliFlag2]
2010
+ };
2011
+ }
2012
+ if (_audioCodec !== null) {
2013
+ return {
2014
+ source: "config",
2015
+ value: _audioCodec
2016
+ };
2017
+ }
2018
+ return {
2019
+ source: "default",
2020
+ value: null
2021
+ };
2022
+ },
2023
+ description: () => `Set the format of the audio that is embedded in the video. Not all codec and audio codec combinations are supported and certain combinations require a certain file extension and container format. See the table in the docs to see possible combinations.`,
2024
+ docLink: "https://www.remotion.dev/docs/encoding/#audio-codec",
2025
+ name: "Audio Codec",
2026
+ ssrName,
2027
+ type: "aac"
2028
+ };
2029
+ var validateOutputFilename = ({
2030
+ codec,
2031
+ audioCodecSetting,
2032
+ extension,
2033
+ preferLossless,
2034
+ separateAudioTo
2035
+ }) => {
2036
+ if (!defaultFileExtensionMap[codec]) {
2037
+ throw new TypeError(`The codec "${codec}" is not supported. Supported codecs are: ${Object.keys(defaultFileExtensionMap).join(", ")}`);
2038
+ }
2039
+ const map = defaultFileExtensionMap[codec];
2040
+ const resolvedAudioCodec = resolveAudioCodec({
2041
+ codec,
2042
+ preferLossless,
2043
+ setting: audioCodecSetting,
2044
+ separateAudioTo
2045
+ });
2046
+ if (resolvedAudioCodec === null) {
2047
+ if (extension !== map.default) {
2048
+ throw new TypeError(`When using the ${codec} codec, the output filename must end in .${map.default}.`);
2049
+ }
2050
+ return;
2051
+ }
2052
+ if (!(resolvedAudioCodec in map.forAudioCodec)) {
2053
+ throw new Error(`Audio codec ${resolvedAudioCodec} is not supported for codec ${codec}`);
2054
+ }
2055
+ const acceptableExtensions = map.forAudioCodec[resolvedAudioCodec].possible;
2056
+ if (!acceptableExtensions.includes(extension) && !separateAudioTo) {
2057
+ throw new TypeError(`When using the ${codec} codec with the ${resolvedAudioCodec} audio codec, the output filename must end in one of the following: ${acceptableExtensions.join(", ")}.`);
2058
+ }
2059
+ };
2060
+ var NoReactAPIs = {
2061
+ getExtensionOfFilename,
2062
+ getFileExtensionFromCodec,
2063
+ validateOutputFilename,
2064
+ getFramesToRender,
2065
+ codecSupportsMedia,
2066
+ isAudioCodec
2067
+ };
2675
2068
 
2676
2069
  // src/get-custom-out-name.ts
2677
2070
  var getCustomOutName = ({
@@ -2706,9 +2099,6 @@ var getCustomOutName = ({
2706
2099
  };
2707
2100
  };
2708
2101
 
2709
- // src/validate-outname.ts
2710
- var import_pure = __toESM(require_pure(), 1);
2711
-
2712
2102
  // src/validate-bucket-name.ts
2713
2103
  var validateBucketName = ({
2714
2104
  bucketName,
@@ -2757,10 +2147,10 @@ var validateOutname = ({
2757
2147
  return;
2758
2148
  }
2759
2149
  if (codec) {
2760
- import_pure.NoReactAPIs.validateOutputFilename({
2150
+ NoReactAPIs.validateOutputFilename({
2761
2151
  codec,
2762
2152
  audioCodecSetting,
2763
- extension: import_pure.NoReactAPIs.getExtensionOfFilename(outName2),
2153
+ extension: NoReactAPIs.getExtensionOfFilename(outName2),
2764
2154
  preferLossless: false,
2765
2155
  separateAudioTo
2766
2156
  });
@@ -2811,7 +2201,7 @@ var getExpectedOutName = ({
2811
2201
  if (renderMetadata.type === "video") {
2812
2202
  return {
2813
2203
  renderBucketName: bucketName,
2814
- key: outName(renderMetadata.renderId, import_pure2.NoReactAPIs.getFileExtensionFromCodec(renderMetadata.codec, renderMetadata.audioCodec)),
2204
+ key: outName(renderMetadata.renderId, NoReactAPIs.getFileExtensionFromCodec(renderMetadata.codec, renderMetadata.audioCodec)),
2815
2205
  customCredentials: null
2816
2206
  };
2817
2207
  }
@@ -2922,9 +2312,6 @@ var getMostExpensiveChunks = ({
2922
2312
  };
2923
2313
  });
2924
2314
  };
2925
- // src/progress.ts
2926
- var import_pure4 = __toESM(require_pure(), 1);
2927
-
2928
2315
  // src/get-overall-progress.ts
2929
2316
  var weights = {
2930
2317
  evaluating: 0.1,
@@ -3071,14 +2458,13 @@ var makeTimeoutError = ({
3071
2458
  };
3072
2459
 
3073
2460
  // src/render-has-audio-video.ts
3074
- var import_pure3 = __toESM(require_pure(), 1);
3075
2461
  var lambdaRenderHasAudioVideo = (renderMetadata) => {
3076
2462
  if (renderMetadata.type === "still") {
3077
2463
  throw new Error("Cannot merge stills");
3078
2464
  }
3079
- const support = import_pure3.NoReactAPIs.codecSupportsMedia(renderMetadata.codec);
3080
- const hasVideo = renderMetadata ? !import_pure3.NoReactAPIs.isAudioCodec(renderMetadata.codec) : false;
3081
- const hasAudio = renderMetadata ? !renderMetadata.muted && support.audio : false;
2465
+ const support2 = NoReactAPIs.codecSupportsMedia(renderMetadata.codec);
2466
+ const hasVideo = renderMetadata ? !NoReactAPIs.isAudioCodec(renderMetadata.codec) : false;
2467
+ const hasAudio = renderMetadata ? !renderMetadata.muted && support2.audio : false;
3082
2468
  return {
3083
2469
  hasAudio,
3084
2470
  hasVideo
@@ -3086,7 +2472,7 @@ var lambdaRenderHasAudioVideo = (renderMetadata) => {
3086
2472
  };
3087
2473
 
3088
2474
  // src/truthy.ts
3089
- function truthy2(value) {
2475
+ function truthy3(value) {
3090
2476
  return Boolean(value);
3091
2477
  }
3092
2478
 
@@ -3124,7 +2510,7 @@ var getProgress = async ({
3124
2510
  customCredentials,
3125
2511
  bucketNamePrefix: providerSpecifics.getBucketPrefix()
3126
2512
  });
3127
- const totalFrameCount = import_pure4.NoReactAPIs.getFramesToRender(overallProgress.renderMetadata.frameRange, overallProgress.renderMetadata.everyNthFrame).length;
2513
+ const totalFrameCount = NoReactAPIs.getFramesToRender(overallProgress.renderMetadata.frameRange, overallProgress.renderMetadata.everyNthFrame).length;
3128
2514
  return {
3129
2515
  framesRendered: totalFrameCount,
3130
2516
  bucket: bucketName,
@@ -3245,12 +2631,12 @@ var getProgress = async ({
3245
2631
  region,
3246
2632
  providerSpecifics
3247
2633
  });
3248
- const chunkMultiplier = [hasAudio, hasVideo].filter(truthy2).length;
2634
+ const chunkMultiplier = [hasAudio, hasVideo].filter(truthy3).length;
3249
2635
  if (renderMetadata.type === "still") {
3250
2636
  throw new Error("You don't need to call getRenderProgress() on a still render. Once you have obtained the `renderId`, the render is already done! \uD83D\uDE09");
3251
2637
  }
3252
2638
  const allChunks = (overallProgress.chunks ?? []).length / chunkMultiplier === (renderMetadata.totalChunks ?? Infinity);
3253
- const frameCount = import_pure4.NoReactAPIs.getFramesToRender(renderMetadata.frameRange, renderMetadata.everyNthFrame).length;
2639
+ const frameCount = NoReactAPIs.getFramesToRender(renderMetadata.frameRange, renderMetadata.everyNthFrame).length;
3254
2640
  const missingChunks = new Array(renderMetadata.totalChunks).fill(true).map((_, i) => i).filter((index) => {
3255
2641
  return typeof (overallProgress.chunks ?? []).find((c) => c === index) === "undefined";
3256
2642
  });
@@ -3267,7 +2653,7 @@ var getProgress = async ({
3267
2653
  providerSpecifics
3268
2654
  }) : null,
3269
2655
  ...errorExplanations
3270
- ].filter(truthy2);
2656
+ ].filter(truthy3);
3271
2657
  return {
3272
2658
  framesRendered: overallProgress.framesRendered ?? 0,
3273
2659
  chunks: chunkCount,
@@ -3397,12 +2783,11 @@ var {
3397
2783
  validateDimension: validateDimension2,
3398
2784
  validateDurationInFrames: validateDurationInFrames2
3399
2785
  } = NoReactInternals;
3400
- var export_wrapWithErrorHandling = import_error_handling.wrapWithErrorHandling;
3401
2786
  var export_makeStreamer = import_streaming2.makeStreamer;
3402
2787
  var export_makeStreamPayloadMessage = import_streaming2.makeStreamPayloadMessage;
3403
2788
 
3404
2789
  export {
3405
- export_wrapWithErrorHandling as wrapWithErrorHandling,
2790
+ wrapWithErrorHandling,
3406
2791
  validateWebhook,
3407
2792
  validatePrivacy,
3408
2793
  validateOutname,
@@ -3412,7 +2797,7 @@ export {
3412
2797
  validateDownloadBehavior,
3413
2798
  validateDimension2 as validateDimension,
3414
2799
  validateBucketName,
3415
- truthy2 as truthy,
2800
+ truthy3 as truthy,
3416
2801
  streamToString,
3417
2802
  serverlessCodecs,
3418
2803
  serializeOrThrow,