@remotion/renderer 4.0.267 → 4.0.269

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.
@@ -0,0 +1,341 @@
1
+ // src/chalk/is-color-supported.ts
2
+ import * as tty from "tty";
3
+ var isColorSupported = () => {
4
+ const env = process.env || {};
5
+ const isForceDisabled = "NO_COLOR" in env;
6
+ if (isForceDisabled) {
7
+ return false;
8
+ }
9
+ const isForced = "FORCE_COLOR" in env;
10
+ if (isForced) {
11
+ return true;
12
+ }
13
+ const isWindows = process.platform === "win32";
14
+ const isCompatibleTerminal = tty?.isatty?.(1) && env.TERM && env.TERM !== "dumb";
15
+ const isCI = "CI" in env && (("GITHUB_ACTIONS" in env) || ("GITLAB_CI" in env) || ("CIRCLECI" in env));
16
+ return isWindows || isCompatibleTerminal || isCI;
17
+ };
18
+
19
+ // src/chalk/index.ts
20
+ var chalk = (() => {
21
+ const colors = {
22
+ enabled: () => isColorSupported(),
23
+ visible: true,
24
+ styles: {},
25
+ keys: {}
26
+ };
27
+ const ansi = (st) => {
28
+ const open = `\x1B[${st.codes[0]}m`;
29
+ const close = `\x1B[${st.codes[1]}m`;
30
+ const regex = new RegExp(`\\u001b\\[${st.codes[1]}m`, "g");
31
+ st.wrap = (input, newline) => {
32
+ if (input.includes(close))
33
+ input = input.replace(regex, close + open);
34
+ const output = open + input + close;
35
+ return newline ? output.replace(/\r*\n/g, `${close}$&${open}`) : output;
36
+ };
37
+ return st;
38
+ };
39
+ const wrap = (sty, input, newline) => {
40
+ return sty.wrap?.(input, newline);
41
+ };
42
+ const style = (input, stack) => {
43
+ if (input === "" || input === null || input === undefined)
44
+ return "";
45
+ if (colors.enabled() === false)
46
+ return input;
47
+ if (colors.visible === false)
48
+ return "";
49
+ let str = String(input);
50
+ const nl = str.includes(`
51
+ `);
52
+ let n = stack.length;
53
+ while (n-- > 0)
54
+ str = wrap(colors.styles[stack[n]], str, nl);
55
+ return str;
56
+ };
57
+ const define = (name, codes, type) => {
58
+ colors.styles[name] = ansi({ name, codes });
59
+ const keys = colors.keys[type] || (colors.keys[type] = []);
60
+ keys.push(name);
61
+ Reflect.defineProperty(colors, name, {
62
+ configurable: true,
63
+ enumerable: true,
64
+ set(value) {
65
+ colors.alias?.(name, value);
66
+ },
67
+ get() {
68
+ const color = (input) => style(input, color.stack);
69
+ Reflect.setPrototypeOf(color, colors);
70
+ color.stack = this.stack ? this.stack.concat(name) : [name];
71
+ return color;
72
+ }
73
+ });
74
+ };
75
+ define("reset", [0, 0], "modifier");
76
+ define("bold", [1, 22], "modifier");
77
+ define("dim", [2, 22], "modifier");
78
+ define("italic", [3, 23], "modifier");
79
+ define("underline", [4, 24], "modifier");
80
+ define("inverse", [7, 27], "modifier");
81
+ define("hidden", [8, 28], "modifier");
82
+ define("strikethrough", [9, 29], "modifier");
83
+ define("black", [30, 39], "color");
84
+ define("red", [31, 39], "color");
85
+ define("green", [32, 39], "color");
86
+ define("yellow", [33, 39], "color");
87
+ define("blue", [34, 39], "color");
88
+ define("magenta", [35, 39], "color");
89
+ define("cyan", [36, 39], "color");
90
+ define("white", [37, 39], "color");
91
+ define("gray", [90, 39], "color");
92
+ define("grey", [90, 39], "color");
93
+ define("bgBlack", [40, 49], "bg");
94
+ define("bgRed", [41, 49], "bg");
95
+ define("bgGreen", [42, 49], "bg");
96
+ define("bgYellow", [43, 49], "bg");
97
+ define("bgBlue", [44, 49], "bg");
98
+ define("bgMagenta", [45, 49], "bg");
99
+ define("bgWhite", [47, 49], "bg");
100
+ define("blackBright", [90, 39], "bright");
101
+ define("redBright", [91, 39], "bright");
102
+ define("greenBright", [92, 39], "bright");
103
+ define("yellowBright", [93, 39], "bright");
104
+ define("blueBright", [94, 39], "bright");
105
+ define("magentaBright", [95, 39], "bright");
106
+ define("whiteBright", [97, 39], "bright");
107
+ define("bgBlackBright", [100, 49], "bgBright");
108
+ define("bgRedBright", [101, 49], "bgBright");
109
+ define("bgGreenBright", [102, 49], "bgBright");
110
+ define("bgYellowBright", [103, 49], "bgBright");
111
+ define("bgBlueBright", [104, 49], "bgBright");
112
+ define("bgMagentaBright", [105, 49], "bgBright");
113
+ define("bgWhiteBright", [107, 49], "bgBright");
114
+ colors.alias = (name, color) => {
115
+ const fn = colors[color];
116
+ if (typeof fn !== "function") {
117
+ throw new TypeError("Expected alias to be the name of an existing color (string) or a function");
118
+ }
119
+ if (!fn.stack) {
120
+ Reflect.defineProperty(fn, "name", { value: name });
121
+ colors.styles[name] = fn;
122
+ fn.stack = [name];
123
+ }
124
+ Reflect.defineProperty(colors, name, {
125
+ configurable: true,
126
+ enumerable: true,
127
+ set(value) {
128
+ colors.alias?.(name, value);
129
+ },
130
+ get() {
131
+ const col = (input) => style(input, col.stack);
132
+ Reflect.setPrototypeOf(col, colors);
133
+ col.stack = this.stack ? this.stack.concat(fn.stack) : fn.stack;
134
+ return col;
135
+ }
136
+ });
137
+ };
138
+ return colors;
139
+ })();
140
+
141
+ // src/log-level.ts
142
+ var logLevels = ["trace", "verbose", "info", "warn", "error"];
143
+ var getNumberForLogLevel = (level) => {
144
+ return logLevels.indexOf(level);
145
+ };
146
+ var isEqualOrBelowLogLevel = (currentLevel, level) => {
147
+ return getNumberForLogLevel(currentLevel) <= getNumberForLogLevel(level);
148
+ };
149
+
150
+ // src/repro.ts
151
+ import { VERSION } from "remotion/version";
152
+ var reproWriteInstance = null;
153
+ var getReproWriter = () => {
154
+ if (!reproWriteInstance) {
155
+ throw new Error("reproWriteInstance is not initialized");
156
+ }
157
+ return reproWriteInstance;
158
+ };
159
+ var writeInRepro = (level, ...args) => {
160
+ if (isReproEnabled()) {
161
+ getReproWriter().writeLine(level, ...args);
162
+ }
163
+ };
164
+ var shouldRepro = false;
165
+ var isReproEnabled = () => shouldRepro;
166
+
167
+ // src/truthy.ts
168
+ function truthy(value) {
169
+ return Boolean(value);
170
+ }
171
+
172
+ // src/logger.ts
173
+ var INDENT_TOKEN = chalk.gray("│");
174
+ var verboseTag = (str) => {
175
+ return isColorSupported() ? chalk.bgBlack(` ${str} `) : `[${str}]`;
176
+ };
177
+ var Log = {
178
+ trace: (options, ...args) => {
179
+ writeInRepro("trace", ...args);
180
+ if (isEqualOrBelowLogLevel(options.logLevel, "trace")) {
181
+ if (args.length === 0) {
182
+ return process.stdout.write(`
183
+ `);
184
+ }
185
+ return console.log(...[
186
+ options.indent ? INDENT_TOKEN : null,
187
+ options.tag ? verboseTag(options.tag) : null
188
+ ].filter(truthy).concat(args.map((a) => chalk.gray(a))));
189
+ }
190
+ },
191
+ verbose: (options, ...args) => {
192
+ writeInRepro("verbose", ...args);
193
+ if (isEqualOrBelowLogLevel(options.logLevel, "verbose")) {
194
+ if (args.length === 0) {
195
+ return process.stdout.write(`
196
+ `);
197
+ }
198
+ return console.log(...[
199
+ options.indent ? INDENT_TOKEN : null,
200
+ options.tag ? verboseTag(options.tag) : null
201
+ ].filter(truthy).concat(args.map((a) => chalk.gray(a))));
202
+ }
203
+ },
204
+ info: (options, ...args) => {
205
+ writeInRepro("info", ...args);
206
+ if (isEqualOrBelowLogLevel(options.logLevel, "info")) {
207
+ if (args.length === 0) {
208
+ return process.stdout.write(`
209
+ `);
210
+ }
211
+ return console.log(...[options.indent ? INDENT_TOKEN : null].filter(truthy).concat(args ?? []));
212
+ }
213
+ },
214
+ warn: (options, ...args) => {
215
+ writeInRepro("warn", ...args);
216
+ if (isEqualOrBelowLogLevel(options.logLevel, "warn")) {
217
+ if (args.length === 0) {
218
+ return process.stdout.write(`
219
+ `);
220
+ }
221
+ return console.warn(...[options.indent ? chalk.yellow(INDENT_TOKEN) : null].filter(truthy).concat(args.map((a) => chalk.yellow(a))));
222
+ }
223
+ },
224
+ error: (options, ...args) => {
225
+ writeInRepro("error", ...args);
226
+ if (isEqualOrBelowLogLevel(options.logLevel, "error")) {
227
+ if (args.length === 0) {
228
+ return process.stdout.write(`
229
+ `);
230
+ }
231
+ return console.error(...[
232
+ options.indent ? INDENT_TOKEN : null,
233
+ options.tag ? verboseTag(options.tag) : null
234
+ ].filter(truthy).concat(args.map((a) => chalk.red(a))));
235
+ }
236
+ }
237
+ };
238
+
239
+ // src/print-useful-error-message.ts
240
+ var alreadyPrintedCache = [];
241
+ var printUsefulErrorMessage = (err, logLevel, indent) => {
242
+ const errorStack = err.stack;
243
+ if (errorStack && alreadyPrintedCache.includes(errorStack)) {
244
+ return;
245
+ }
246
+ if (errorStack) {
247
+ alreadyPrintedCache.push(errorStack);
248
+ alreadyPrintedCache = alreadyPrintedCache.slice(-10);
249
+ }
250
+ if (err.message.includes("Could not play video with")) {
251
+ Log.info({ indent, logLevel });
252
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/media-playback-error");
253
+ }
254
+ if (err.message.includes("A delayRender()") && err.message.includes("was called but not cleared after")) {
255
+ Log.info({ indent, logLevel });
256
+ if (err.message.includes("/proxy")) {
257
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/troubleshooting/delay-render-proxy");
258
+ }
259
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/timeout");
260
+ }
261
+ if (err.message.includes("Target closed")) {
262
+ Log.info({ indent, logLevel });
263
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/target-closed");
264
+ }
265
+ if (err.message.includes("Timed out evaluating")) {
266
+ Log.info({ indent, logLevel });
267
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/troubleshooting/timed-out-page-function");
268
+ }
269
+ if (err.message.includes("ENAMETOOLONG")) {
270
+ Log.info({ indent, logLevel });
271
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/enametoolong");
272
+ }
273
+ if (err.message.includes("Member must have value less than or equal to 3008")) {
274
+ Log.info({ indent, logLevel });
275
+ 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");
276
+ }
277
+ if (err.stack?.includes("TooManyRequestsException: Rate Exceeded.")) {
278
+ Log.info({ indent, logLevel });
279
+ 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");
280
+ }
281
+ if (err.message.includes("Error creating WebGL context")) {
282
+ Log.info({ indent, logLevel });
283
+ Log.warn({
284
+ indent,
285
+ logLevel
286
+ }, '\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');
287
+ Log.warn({
288
+ indent,
289
+ logLevel
290
+ }, "\uD83D\uDCA1 Check how it's done at https://www.remotion.dev/docs/chromium-flags#--gl");
291
+ }
292
+ if (err.message.includes("The bucket does not allow ACLs")) {
293
+ Log.info({ indent, logLevel });
294
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Fix for this issue: https://remotion.dev/docs/lambda/troubleshooting/bucket-disallows-acl");
295
+ }
296
+ if (err.message.includes("Minified React error #306")) {
297
+ const componentName = err.message.match(/<\w+>/)?.[0];
298
+ Log.info({ indent, logLevel }, [
299
+ "\uD83D\uDCA1 This error indicates that the component",
300
+ componentName ? `(${componentName})` : null,
301
+ "you are trying to render is not imported correctly."
302
+ ].filter(truthy).join(" "));
303
+ Log.info({ indent, logLevel });
304
+ Log.info({ indent, logLevel }, " Check the root file and ensure that the component is not undefined.");
305
+ Log.info({ indent, logLevel }, " Oftentimes, this happens if the component is missing the `export` keyword");
306
+ Log.info({ indent, logLevel }, " or if the component was renamed and the import statement not properly adjusted.");
307
+ }
308
+ if (err.message.includes("GLIBC_")) {
309
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Remotion requires at least Libc 2.35.");
310
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue: https://github.com/remotion-dev/remotion/issues/2439");
311
+ }
312
+ if (err.message.includes("EBADF")) {
313
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 This error might be fixed by changing your Node version:");
314
+ Log.info({ indent, logLevel }, " https://github.com/remotion-dev/remotion/issues/2452");
315
+ }
316
+ if (err.message.includes("routines::unsupported")) {
317
+ 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.");
318
+ Log.info({ indent, logLevel }, " https://github.com/remotion-dev/remotion/issues/3864");
319
+ }
320
+ if (err.message.includes("Failed to fetch")) {
321
+ 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.");
322
+ Log.info({ indent, logLevel }, "Try increasing the disk size of your Lambda function.");
323
+ }
324
+ };
325
+
326
+ // src/wrap-with-error-handling.ts
327
+ var wrapWithErrorHandling = (fn) => {
328
+ return async (...args) => {
329
+ try {
330
+ return await fn(...args);
331
+ } catch (err) {
332
+ const { indent } = args[0];
333
+ const { logLevel } = args[0];
334
+ printUsefulErrorMessage(err, logLevel, indent);
335
+ throw err;
336
+ }
337
+ };
338
+ };
339
+ export {
340
+ wrapWithErrorHandling
341
+ };