@remotion/renderer 4.1.0-alpha1 → 4.1.0-alpha10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/download-and-map-assets-to-file.d.ts +2 -4
- package/dist/assets/download-and-map-assets-to-file.js +14 -10
- package/dist/assets/download-map.d.ts +4 -0
- package/dist/assets/download-map.js +3 -0
- package/dist/audio-codec.d.ts +1 -1
- package/dist/browser/Browser.d.ts +7 -6
- package/dist/browser/Browser.js +13 -13
- package/dist/browser/BrowserPage.d.ts +21 -6
- package/dist/browser/BrowserPage.js +80 -19
- package/dist/browser/BrowserRunner.d.ts +0 -1
- package/dist/browser/BrowserRunner.js +6 -6
- package/dist/browser/Connection.d.ts +9 -3
- package/dist/browser/Connection.js +11 -3
- package/dist/browser/ConsoleMessage.d.ts +8 -1
- package/dist/browser/ConsoleMessage.js +2 -1
- package/dist/browser/DOMWorld.d.ts +10 -4
- package/dist/browser/DOMWorld.js +16 -15
- package/dist/browser/ExecutionContext.js +4 -4
- package/dist/browser/FrameManager.d.ts +3 -6
- package/dist/browser/FrameManager.js +11 -16
- package/dist/browser/LaunchOptions.d.ts +2 -0
- package/dist/browser/Launcher.js +3 -3
- package/dist/browser/NetworkManager.d.ts +4 -1
- package/dist/browser/Target.d.ts +2 -1
- package/dist/browser/Target.js +3 -1
- package/dist/browser/create-browser-fetcher.js +19 -24
- package/dist/browser/devtools-types.d.ts +59 -0
- package/dist/browser/should-log-message.js +14 -0
- package/dist/chalk/index.d.ts +2 -1
- package/dist/chalk/index.js +3 -8
- package/dist/chalk/is-color-supported.d.ts +1 -1
- package/dist/chalk/is-color-supported.js +18 -10
- package/dist/client.d.ts +26 -31
- package/dist/compositor/compose.js +6 -1
- package/dist/compositor/compositor.d.ts +3 -2
- package/dist/compositor/compositor.js +10 -10
- package/dist/compositor/payloads.d.ts +15 -1
- package/dist/create-ffmpeg-merge-filter.js +1 -2
- package/dist/cycle-browser-tabs.d.ts +2 -1
- package/dist/cycle-browser-tabs.js +2 -2
- package/dist/format-logs.d.ts +3 -0
- package/dist/format-logs.js +207 -0
- package/dist/get-browser-instance.d.ts +3 -2
- package/dist/get-browser-instance.js +5 -5
- package/dist/get-bundle-url-from-serve-url.d.ts +2 -0
- package/dist/get-bundle-url-from-serve-url.js +30 -0
- package/dist/get-compositions.d.ts +7 -6
- package/dist/get-compositions.js +21 -11
- package/dist/get-extension-from-codec.d.ts +2 -2
- package/dist/get-local-browser-executable.js +15 -0
- package/dist/get-video-metadata.d.ts +2 -0
- package/dist/get-video-metadata.js +14 -0
- package/dist/index.d.ts +64 -61
- package/dist/index.js +3 -1
- package/dist/logger.d.ts +2 -2
- package/dist/logger.js +23 -18
- package/dist/offthread-video-server.d.ts +3 -3
- package/dist/offthread-video-server.js +65 -29
- package/dist/open-browser.d.ts +3 -2
- package/dist/open-browser.js +7 -5
- package/dist/options/crf.js +1 -1
- package/dist/options/video-codec.js +1 -1
- package/dist/perf.js +4 -2
- package/dist/prepare-server.d.ts +4 -5
- package/dist/prepare-server.js +16 -14
- package/dist/prespawn-ffmpeg.d.ts +2 -1
- package/dist/prespawn-ffmpeg.js +3 -31
- package/dist/puppeteer-evaluate.d.ts +4 -1
- package/dist/puppeteer-evaluate.js +5 -5
- package/dist/render-frames.d.ts +16 -8
- package/dist/render-frames.js +50 -22
- package/dist/render-media.d.ts +17 -9
- package/dist/render-media.js +41 -26
- package/dist/render-still.d.ts +13 -6
- package/dist/render-still.js +32 -17
- package/dist/replace-browser.d.ts +2 -1
- package/dist/replace-browser.js +2 -2
- package/dist/screenshot-task.js +4 -2
- package/dist/seek-to-frame.d.ts +8 -2
- package/dist/seek-to-frame.js +87 -25
- package/dist/select-composition.d.ts +10 -5
- package/dist/select-composition.js +39 -18
- package/dist/serialize-props.d.ts +6 -0
- package/dist/serialize-props.js +36 -0
- package/dist/serve-handler/index.js +1 -1
- package/dist/serve-static.d.ts +2 -3
- package/dist/serve-static.js +10 -4
- package/dist/set-props-and-env.d.ts +4 -1
- package/dist/set-props-and-env.js +52 -22
- package/dist/stitch-frames-to-video.d.ts +2 -1
- package/dist/stitch-frames-to-video.js +12 -22
- package/dist/symbolicate-stacktrace.d.ts +3 -2
- package/dist/symbolicate-stacktrace.js +14 -7
- package/dist/take-frame-and-compose.js +1 -1
- package/dist/validate-output-filename.d.ts +1 -1
- package/package.json +10 -10
package/dist/render-still.js
CHANGED
|
@@ -38,6 +38,7 @@ const handle_javascript_exception_1 = require("./error-handling/handle-javascrip
|
|
|
38
38
|
const find_closest_package_json_1 = require("./find-closest-package-json");
|
|
39
39
|
const image_format_1 = require("./image-format");
|
|
40
40
|
const jpeg_quality_1 = require("./jpeg-quality");
|
|
41
|
+
const logger_1 = require("./logger");
|
|
41
42
|
const make_cancel_signal_1 = require("./make-cancel-signal");
|
|
42
43
|
const open_browser_1 = require("./open-browser");
|
|
43
44
|
const overwrite_1 = require("./overwrite");
|
|
@@ -48,12 +49,11 @@ const set_props_and_env_1 = require("./set-props-and-env");
|
|
|
48
49
|
const take_frame_and_compose_1 = require("./take-frame-and-compose");
|
|
49
50
|
const validate_puppeteer_timeout_1 = require("./validate-puppeteer-timeout");
|
|
50
51
|
const validate_scale_1 = require("./validate-scale");
|
|
51
|
-
const innerRenderStill = async ({ composition, imageFormat = image_format_1.DEFAULT_STILL_IMAGE_FORMAT, serveUrl, puppeteerInstance,
|
|
52
|
+
const innerRenderStill = async ({ composition, imageFormat = image_format_1.DEFAULT_STILL_IMAGE_FORMAT, serveUrl, puppeteerInstance, onError, serializedInputPropsWithCustomSchema, envVariables, output, frame = 0, overwrite, browserExecutable, timeoutInMilliseconds, chromiumOptions, scale, proxyPort, cancelSignal, jpegQuality, onBrowserLog, compositor, sourceMapContext, downloadMap, logLevel, indent, serializedResolvedPropsWithCustomSchema, }) => {
|
|
52
53
|
remotion_1.Internals.validateDimension(composition.height, 'height', 'in the `config` object passed to `renderStill()`');
|
|
53
54
|
remotion_1.Internals.validateDimension(composition.width, 'width', 'in the `config` object passed to `renderStill()`');
|
|
54
55
|
remotion_1.Internals.validateFps(composition.fps, 'in the `config` object of `renderStill()`', false);
|
|
55
|
-
remotion_1.Internals.validateDurationInFrames({
|
|
56
|
-
durationInFrames: composition.durationInFrames,
|
|
56
|
+
remotion_1.Internals.validateDurationInFrames(composition.durationInFrames, {
|
|
57
57
|
component: 'in the `config` object passed to `renderStill()`',
|
|
58
58
|
allowFloats: false,
|
|
59
59
|
});
|
|
@@ -87,13 +87,13 @@ const innerRenderStill = async ({ composition, imageFormat = image_format_1.DEFA
|
|
|
87
87
|
const browserInstance = puppeteerInstance !== null && puppeteerInstance !== void 0 ? puppeteerInstance : (await (0, open_browser_1.internalOpenBrowser)({
|
|
88
88
|
browser: browser_1.DEFAULT_BROWSER,
|
|
89
89
|
browserExecutable,
|
|
90
|
-
shouldDumpIo: dumpBrowserLogs,
|
|
91
90
|
chromiumOptions,
|
|
92
91
|
forceDeviceScaleFactor: scale,
|
|
93
|
-
indent
|
|
92
|
+
indent,
|
|
94
93
|
viewport: null,
|
|
94
|
+
logLevel,
|
|
95
95
|
}));
|
|
96
|
-
const page = await browserInstance.newPage(sourceMapContext);
|
|
96
|
+
const page = await browserInstance.newPage(Promise.resolve(sourceMapContext), logLevel, indent);
|
|
97
97
|
await page.setViewport({
|
|
98
98
|
width: composition.width,
|
|
99
99
|
height: composition.height,
|
|
@@ -122,7 +122,7 @@ const innerRenderStill = async ({ composition, imageFormat = image_format_1.DEFA
|
|
|
122
122
|
await page.close();
|
|
123
123
|
}
|
|
124
124
|
else {
|
|
125
|
-
browserInstance.close(true).catch((err) => {
|
|
125
|
+
browserInstance.close(true, logLevel, indent).catch((err) => {
|
|
126
126
|
console.log('Unable to close browser', err);
|
|
127
127
|
});
|
|
128
128
|
}
|
|
@@ -134,7 +134,7 @@ const innerRenderStill = async ({ composition, imageFormat = image_format_1.DEFA
|
|
|
134
134
|
page.on('console', logCallback);
|
|
135
135
|
}
|
|
136
136
|
await (0, set_props_and_env_1.setPropsAndEnv)({
|
|
137
|
-
|
|
137
|
+
serializedInputPropsWithCustomSchema,
|
|
138
138
|
envVariables,
|
|
139
139
|
page,
|
|
140
140
|
serveUrl,
|
|
@@ -144,14 +144,16 @@ const innerRenderStill = async ({ composition, imageFormat = image_format_1.DEFA
|
|
|
144
144
|
retriesRemaining: 2,
|
|
145
145
|
audioEnabled: false,
|
|
146
146
|
videoEnabled: true,
|
|
147
|
+
indent,
|
|
148
|
+
logLevel,
|
|
147
149
|
});
|
|
148
150
|
await (0, puppeteer_evaluate_1.puppeteerEvaluateWithCatch)({
|
|
149
151
|
// eslint-disable-next-line max-params
|
|
150
|
-
pageFunction: (id,
|
|
152
|
+
pageFunction: (id, props, durationInFrames, fps, height, width) => {
|
|
151
153
|
window.remotion_setBundleMode({
|
|
152
154
|
type: 'composition',
|
|
153
155
|
compositionName: id,
|
|
154
|
-
|
|
156
|
+
serializedResolvedPropsWithSchema: props,
|
|
155
157
|
compositionDurationInFrames: durationInFrames,
|
|
156
158
|
compositionFps: fps,
|
|
157
159
|
compositionHeight: height,
|
|
@@ -160,7 +162,7 @@ const innerRenderStill = async ({ composition, imageFormat = image_format_1.DEFA
|
|
|
160
162
|
},
|
|
161
163
|
args: [
|
|
162
164
|
composition.id,
|
|
163
|
-
|
|
165
|
+
serializedResolvedPropsWithCustomSchema,
|
|
164
166
|
composition.durationInFrames,
|
|
165
167
|
composition.fps,
|
|
166
168
|
composition.height,
|
|
@@ -169,7 +171,12 @@ const innerRenderStill = async ({ composition, imageFormat = image_format_1.DEFA
|
|
|
169
171
|
frame: null,
|
|
170
172
|
page,
|
|
171
173
|
});
|
|
172
|
-
await (0, seek_to_frame_1.seekToFrame)({
|
|
174
|
+
await (0, seek_to_frame_1.seekToFrame)({
|
|
175
|
+
frame: stillFrame,
|
|
176
|
+
page,
|
|
177
|
+
composition: composition.id,
|
|
178
|
+
timeoutInMilliseconds,
|
|
179
|
+
});
|
|
173
180
|
const { buffer } = await (0, take_frame_and_compose_1.takeFrameAndCompose)({
|
|
174
181
|
frame: stillFrame,
|
|
175
182
|
freePage: page,
|
|
@@ -195,7 +202,7 @@ const internalRenderStill = (options) => {
|
|
|
195
202
|
port: options.port,
|
|
196
203
|
remotionRoot: (0, find_closest_package_json_1.findRemotionRoot)(),
|
|
197
204
|
concurrency: 1,
|
|
198
|
-
|
|
205
|
+
logLevel: options.logLevel,
|
|
199
206
|
indent: options.indent,
|
|
200
207
|
}, {
|
|
201
208
|
onDownload: options.onDownload,
|
|
@@ -239,7 +246,7 @@ exports.internalRenderStill = internalRenderStill;
|
|
|
239
246
|
* @see [Documentation](https://www.remotion.dev/docs/renderer/render-still)
|
|
240
247
|
*/
|
|
241
248
|
const renderStill = (options) => {
|
|
242
|
-
var _a;
|
|
249
|
+
var _a, _b;
|
|
243
250
|
const { composition, serveUrl, browserExecutable, cancelSignal, chromiumOptions, dumpBrowserLogs, envVariables, frame, imageFormat, inputProps, jpegQuality, onBrowserLog, onDownload, output, overwrite, port, puppeteerInstance, scale, timeoutInMilliseconds, verbose, quality, } = options;
|
|
244
251
|
if (typeof jpegQuality !== 'undefined' && imageFormat !== 'jpeg') {
|
|
245
252
|
throw new Error("You can only pass the `quality` option if `imageFormat` is 'jpeg'.");
|
|
@@ -252,12 +259,15 @@ const renderStill = (options) => {
|
|
|
252
259
|
browserExecutable: browserExecutable !== null && browserExecutable !== void 0 ? browserExecutable : null,
|
|
253
260
|
cancelSignal: cancelSignal !== null && cancelSignal !== void 0 ? cancelSignal : null,
|
|
254
261
|
chromiumOptions: chromiumOptions !== null && chromiumOptions !== void 0 ? chromiumOptions : {},
|
|
255
|
-
dumpBrowserLogs: dumpBrowserLogs !== null && dumpBrowserLogs !== void 0 ? dumpBrowserLogs : false,
|
|
256
262
|
envVariables: envVariables !== null && envVariables !== void 0 ? envVariables : {},
|
|
257
263
|
frame: frame !== null && frame !== void 0 ? frame : 0,
|
|
258
264
|
imageFormat: imageFormat !== null && imageFormat !== void 0 ? imageFormat : image_format_1.DEFAULT_STILL_IMAGE_FORMAT,
|
|
259
265
|
indent: false,
|
|
260
|
-
|
|
266
|
+
serializedInputPropsWithCustomSchema: remotion_1.Internals.serializeJSONWithDate({
|
|
267
|
+
staticBase: null,
|
|
268
|
+
indent: undefined,
|
|
269
|
+
data: inputProps !== null && inputProps !== void 0 ? inputProps : {},
|
|
270
|
+
}).serializedString,
|
|
261
271
|
jpegQuality: (_a = jpegQuality !== null && jpegQuality !== void 0 ? jpegQuality : quality) !== null && _a !== void 0 ? _a : jpeg_quality_1.DEFAULT_JPEG_QUALITY,
|
|
262
272
|
onBrowserLog: onBrowserLog !== null && onBrowserLog !== void 0 ? onBrowserLog : null,
|
|
263
273
|
onDownload: onDownload !== null && onDownload !== void 0 ? onDownload : null,
|
|
@@ -269,7 +279,12 @@ const renderStill = (options) => {
|
|
|
269
279
|
server: undefined,
|
|
270
280
|
serveUrl,
|
|
271
281
|
timeoutInMilliseconds: timeoutInMilliseconds !== null && timeoutInMilliseconds !== void 0 ? timeoutInMilliseconds : TimeoutSettings_1.DEFAULT_TIMEOUT,
|
|
272
|
-
|
|
282
|
+
logLevel: verbose || dumpBrowserLogs ? 'verbose' : (0, logger_1.getLogLevel)(),
|
|
283
|
+
serializedResolvedPropsWithCustomSchema: remotion_1.Internals.serializeJSONWithDate({
|
|
284
|
+
indent: undefined,
|
|
285
|
+
staticBase: null,
|
|
286
|
+
data: (_b = composition.props) !== null && _b !== void 0 ? _b : {},
|
|
287
|
+
}).serializedString,
|
|
273
288
|
});
|
|
274
289
|
};
|
|
275
290
|
exports.renderStill = renderStill;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { HeadlessBrowser } from './browser/Browser';
|
|
2
|
+
import type { LogLevel } from './log-level';
|
|
2
3
|
export type BrowserReplacer = {
|
|
3
4
|
getBrowser: () => HeadlessBrowser;
|
|
4
5
|
replaceBrowser: (make: () => Promise<HeadlessBrowser>, makeNewPages: () => Promise<void>) => Promise<HeadlessBrowser>;
|
|
5
6
|
};
|
|
6
|
-
export declare const handleBrowserCrash: (instance: HeadlessBrowser) => BrowserReplacer;
|
|
7
|
+
export declare const handleBrowserCrash: (instance: HeadlessBrowser, logLevel: LogLevel, indent: boolean) => BrowserReplacer;
|
package/dist/replace-browser.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handleBrowserCrash = void 0;
|
|
4
|
-
const handleBrowserCrash = (instance) => {
|
|
4
|
+
const handleBrowserCrash = (instance, logLevel, indent) => {
|
|
5
5
|
let _instance = instance;
|
|
6
6
|
const waiters = [];
|
|
7
7
|
let replacing = false;
|
|
@@ -20,7 +20,7 @@ const handleBrowserCrash = (instance) => {
|
|
|
20
20
|
try {
|
|
21
21
|
replacing = true;
|
|
22
22
|
await _instance
|
|
23
|
-
.close(true)
|
|
23
|
+
.close(true, logLevel, indent)
|
|
24
24
|
.then(() => {
|
|
25
25
|
console.log('Killed previous browser and making new one');
|
|
26
26
|
})
|
package/dist/screenshot-task.js
CHANGED
|
@@ -24,7 +24,7 @@ const screenshotTask = async ({ format, height, omitBackground, page, width, pat
|
|
|
24
24
|
try {
|
|
25
25
|
let result;
|
|
26
26
|
if (format === 'pdf') {
|
|
27
|
-
|
|
27
|
+
const res = await client.send('Page.printToPDF', {
|
|
28
28
|
paperWidth: width / 96,
|
|
29
29
|
paperHeight: height / 96,
|
|
30
30
|
marginTop: 0,
|
|
@@ -34,9 +34,10 @@ const screenshotTask = async ({ format, height, omitBackground, page, width, pat
|
|
|
34
34
|
scale: 1,
|
|
35
35
|
printBackground: true,
|
|
36
36
|
});
|
|
37
|
+
result = res.value;
|
|
37
38
|
}
|
|
38
39
|
else {
|
|
39
|
-
|
|
40
|
+
const { value } = await client.send('Page.captureScreenshot', {
|
|
40
41
|
format,
|
|
41
42
|
quality: jpegQuality,
|
|
42
43
|
clip: clipRegion !== null && clipRegion !== 'hide'
|
|
@@ -57,6 +58,7 @@ const screenshotTask = async ({ format, height, omitBackground, page, width, pat
|
|
|
57
58
|
captureBeyondViewport: true,
|
|
58
59
|
optimizeForSpeed: true,
|
|
59
60
|
});
|
|
61
|
+
result = value;
|
|
60
62
|
}
|
|
61
63
|
(0, perf_1.stopPerfMeasure)(cap);
|
|
62
64
|
if (shouldSetDefaultBackground)
|
package/dist/seek-to-frame.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { Page } from './browser/BrowserPage';
|
|
2
|
-
export declare const waitForReady: (page
|
|
3
|
-
|
|
2
|
+
export declare const waitForReady: ({ page, timeoutInMilliseconds, frame, }: {
|
|
3
|
+
page: Page;
|
|
4
|
+
timeoutInMilliseconds: number;
|
|
5
|
+
frame: number | null;
|
|
6
|
+
}) => Promise<unknown>;
|
|
7
|
+
export declare const seekToFrame: ({ frame, page, composition, timeoutInMilliseconds, }: {
|
|
4
8
|
frame: number;
|
|
9
|
+
composition: string;
|
|
5
10
|
page: Page;
|
|
11
|
+
timeoutInMilliseconds: number;
|
|
6
12
|
}) => Promise<void>;
|
package/dist/seek-to-frame.js
CHANGED
|
@@ -1,30 +1,68 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.seekToFrame = exports.waitForReady = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
4
5
|
const symbolicateable_error_1 = require("./error-handling/symbolicateable-error");
|
|
5
6
|
const parse_browser_error_stack_1 = require("./parse-browser-error-stack");
|
|
6
7
|
const puppeteer_evaluate_1 = require("./puppeteer-evaluate");
|
|
7
|
-
const waitForReady = (page) => {
|
|
8
|
-
|
|
9
|
-
new Promise((_, reject) => {
|
|
10
|
-
page.on("disposed" /* PageEmittedEvents.Disposed */, () => {
|
|
11
|
-
reject(new Error('Target closed (page disposed)'));
|
|
12
|
-
});
|
|
13
|
-
}),
|
|
14
|
-
new Promise((_, reject) => {
|
|
15
|
-
page.browser.on("closed-silent" /* BrowserEmittedEvents.ClosedSilent */, () => {
|
|
16
|
-
reject(new Error('Target closed'));
|
|
17
|
-
});
|
|
18
|
-
}),
|
|
8
|
+
const waitForReady = ({ page, timeoutInMilliseconds, frame, }) => {
|
|
9
|
+
const waitForReadyProm = new Promise((resolve, reject) => {
|
|
19
10
|
page
|
|
20
11
|
.mainFrame()
|
|
21
|
-
._mainWorld.waitForFunction(
|
|
12
|
+
._mainWorld.waitForFunction({
|
|
13
|
+
browser: page.browser,
|
|
14
|
+
// Increase timeout so the delayRender() timeout fires earlier
|
|
15
|
+
timeout: timeoutInMilliseconds + 3000,
|
|
16
|
+
pageFunction: 'window.remotion_renderReady === true',
|
|
17
|
+
title: frame === null
|
|
18
|
+
? 'the page to render the React component'
|
|
19
|
+
: `the page to render the React component at frame ${frame}`,
|
|
20
|
+
shouldClosePage: false,
|
|
21
|
+
})
|
|
22
|
+
.then((a) => resolve(a))
|
|
22
23
|
.catch((err) => {
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
if (err.message.includes('timeout') &&
|
|
25
|
+
err.message.includes('exceeded')) {
|
|
26
|
+
(0, puppeteer_evaluate_1.puppeteerEvaluateWithCatch)({
|
|
27
|
+
pageFunction: () => {
|
|
28
|
+
return Object.keys(window.remotion_delayRenderTimeouts)
|
|
29
|
+
.map((id, i) => {
|
|
30
|
+
const { label } = window.remotion_delayRenderTimeouts[id];
|
|
31
|
+
if (label === null) {
|
|
32
|
+
return `${i + 1}. (no label)`;
|
|
33
|
+
}
|
|
34
|
+
return `"${i + 1}. ${label}"`;
|
|
35
|
+
})
|
|
36
|
+
.join(', ');
|
|
37
|
+
},
|
|
38
|
+
args: [],
|
|
39
|
+
frame,
|
|
40
|
+
page,
|
|
41
|
+
})
|
|
42
|
+
.then((res) => {
|
|
43
|
+
reject(new Error(`Timeout exceeded rendering the component${frame ? ' at frame ' + frame : ''}. ${res.value ? `Open delayRender() handles: ${res.value}` : ''}`));
|
|
44
|
+
})
|
|
45
|
+
.catch((newErr) => {
|
|
46
|
+
_1.RenderInternals.Log.warn('Tried to get delayRender() handles for timeout, but could not do so because of', newErr);
|
|
47
|
+
// Ignore, use prev error
|
|
48
|
+
reject(err);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
reject(err);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
const waitForErrorProm = new Promise((_shouldNeverResolve, reject) => {
|
|
25
57
|
page
|
|
26
58
|
.mainFrame()
|
|
27
|
-
._mainWorld.waitForFunction(
|
|
59
|
+
._mainWorld.waitForFunction({
|
|
60
|
+
browser: page.browser,
|
|
61
|
+
timeout: null,
|
|
62
|
+
pageFunction: 'window.remotion_cancelledError !== undefined',
|
|
63
|
+
title: 'remotion_cancelledError variable to appear on the page',
|
|
64
|
+
shouldClosePage: false,
|
|
65
|
+
})
|
|
28
66
|
.then(() => {
|
|
29
67
|
return (0, puppeteer_evaluate_1.puppeteerEvaluateWithCatch)({
|
|
30
68
|
pageFunction: () => window.remotion_cancelledError,
|
|
@@ -33,32 +71,56 @@ const waitForReady = (page) => {
|
|
|
33
71
|
page,
|
|
34
72
|
});
|
|
35
73
|
})
|
|
36
|
-
.then((val) => {
|
|
74
|
+
.then(({ value: val }) => {
|
|
37
75
|
if (typeof val !== 'string') {
|
|
38
|
-
|
|
76
|
+
reject(val);
|
|
77
|
+
return;
|
|
39
78
|
}
|
|
40
|
-
|
|
79
|
+
reject(new symbolicateable_error_1.SymbolicateableError({
|
|
41
80
|
frame: null,
|
|
42
81
|
stack: val,
|
|
43
82
|
name: 'CancelledError',
|
|
44
83
|
message: val.split('\n')[0],
|
|
45
84
|
stackFrame: (0, parse_browser_error_stack_1.parseStack)(val.split('\n')),
|
|
85
|
+
}));
|
|
86
|
+
})
|
|
87
|
+
.catch((err) => {
|
|
88
|
+
if (err.message.includes('timeout') &&
|
|
89
|
+
err.message.includes('exceeded')) {
|
|
90
|
+
// Don't care if a error never appeared
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
reject(err);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
return Promise.race([
|
|
98
|
+
new Promise((_, reject) => {
|
|
99
|
+
page.on("disposed" /* PageEmittedEvents.Disposed */, () => {
|
|
100
|
+
reject(new Error('Target closed (page disposed)'));
|
|
101
|
+
});
|
|
102
|
+
}),
|
|
103
|
+
new Promise((_, reject) => {
|
|
104
|
+
page.browser.on("closed-silent" /* BrowserEmittedEvents.ClosedSilent */, () => {
|
|
105
|
+
reject(new Error('Target closed'));
|
|
46
106
|
});
|
|
47
107
|
}),
|
|
108
|
+
waitForReadyProm,
|
|
109
|
+
waitForErrorProm,
|
|
48
110
|
]);
|
|
49
111
|
};
|
|
50
112
|
exports.waitForReady = waitForReady;
|
|
51
|
-
const seekToFrame = async ({ frame, page, }) => {
|
|
52
|
-
await (0, exports.waitForReady)(page);
|
|
113
|
+
const seekToFrame = async ({ frame, page, composition, timeoutInMilliseconds, }) => {
|
|
114
|
+
await (0, exports.waitForReady)({ page, timeoutInMilliseconds, frame: null });
|
|
53
115
|
await (0, puppeteer_evaluate_1.puppeteerEvaluateWithCatch)({
|
|
54
|
-
pageFunction: (f) => {
|
|
55
|
-
window.remotion_setFrame(f);
|
|
116
|
+
pageFunction: (f, c) => {
|
|
117
|
+
window.remotion_setFrame(f, c);
|
|
56
118
|
},
|
|
57
|
-
args: [frame],
|
|
119
|
+
args: [frame, composition],
|
|
58
120
|
frame,
|
|
59
121
|
page,
|
|
60
122
|
});
|
|
61
|
-
await (0, exports.waitForReady)(page);
|
|
123
|
+
await (0, exports.waitForReady)({ page, timeoutInMilliseconds, frame });
|
|
62
124
|
await page.evaluateHandle('document.fonts.ready');
|
|
63
125
|
};
|
|
64
126
|
exports.seekToFrame = seekToFrame;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type VideoConfig } from 'remotion';
|
|
2
2
|
import type { BrowserExecutable } from './browser-executable';
|
|
3
3
|
import type { BrowserLog } from './browser-log';
|
|
4
4
|
import type { HeadlessBrowser } from './browser/Browser';
|
|
5
|
+
import { type LogLevel } from './log-level';
|
|
5
6
|
import type { ChromiumOptions } from './open-browser';
|
|
6
7
|
import type { RemotionServer } from './prepare-server';
|
|
7
8
|
type InternalSelectCompositionsConfig = {
|
|
8
|
-
|
|
9
|
+
serializedInputPropsWithCustomSchema: string;
|
|
9
10
|
envVariables: Record<string, string>;
|
|
10
11
|
puppeteerInstance: HeadlessBrowser | undefined;
|
|
11
12
|
onBrowserLog: null | ((log: BrowserLog) => void);
|
|
@@ -15,7 +16,7 @@ type InternalSelectCompositionsConfig = {
|
|
|
15
16
|
port: number | null;
|
|
16
17
|
indent: boolean;
|
|
17
18
|
server: RemotionServer | undefined;
|
|
18
|
-
|
|
19
|
+
logLevel: LogLevel;
|
|
19
20
|
serveUrl: string;
|
|
20
21
|
id: string;
|
|
21
22
|
};
|
|
@@ -32,10 +33,14 @@ export type SelectCompositionOptions = {
|
|
|
32
33
|
serveUrl: string;
|
|
33
34
|
id: string;
|
|
34
35
|
};
|
|
35
|
-
|
|
36
|
+
type InternalReturnType = {
|
|
37
|
+
metadata: VideoConfig;
|
|
38
|
+
propsSize: number;
|
|
39
|
+
};
|
|
40
|
+
export declare const internalSelectComposition: (options: InternalSelectCompositionsConfig) => Promise<InternalReturnType>;
|
|
36
41
|
/**
|
|
37
42
|
* @description Gets a composition defined in a Remotion project based on a Webpack bundle.
|
|
38
43
|
* @see [Documentation](https://www.remotion.dev/docs/renderer/select-composition)
|
|
39
44
|
*/
|
|
40
|
-
export declare const selectComposition: (options: SelectCompositionOptions) => Promise<
|
|
45
|
+
export declare const selectComposition: (options: SelectCompositionOptions) => Promise<VideoConfig>;
|
|
41
46
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.selectComposition = exports.internalSelectComposition = void 0;
|
|
4
|
+
const remotion_1 = require("remotion");
|
|
4
5
|
const TimeoutSettings_1 = require("./browser/TimeoutSettings");
|
|
5
6
|
const handle_javascript_exception_1 = require("./error-handling/handle-javascript-exception");
|
|
6
7
|
const find_closest_package_json_1 = require("./find-closest-package-json");
|
|
@@ -11,7 +12,7 @@ const puppeteer_evaluate_1 = require("./puppeteer-evaluate");
|
|
|
11
12
|
const seek_to_frame_1 = require("./seek-to-frame");
|
|
12
13
|
const set_props_and_env_1 = require("./set-props-and-env");
|
|
13
14
|
const validate_puppeteer_timeout_1 = require("./validate-puppeteer-timeout");
|
|
14
|
-
const innerSelectComposition = async ({ page, onBrowserLog,
|
|
15
|
+
const innerSelectComposition = async ({ page, onBrowserLog, serializedInputPropsWithCustomSchema, envVariables, serveUrl, timeoutInMilliseconds, port, id, indent, logLevel, }) => {
|
|
15
16
|
if (onBrowserLog) {
|
|
16
17
|
page.on('console', (log) => {
|
|
17
18
|
onBrowserLog({
|
|
@@ -23,7 +24,7 @@ const innerSelectComposition = async ({ page, onBrowserLog, inputProps, envVaria
|
|
|
23
24
|
}
|
|
24
25
|
(0, validate_puppeteer_timeout_1.validatePuppeteerTimeout)(timeoutInMilliseconds);
|
|
25
26
|
await (0, set_props_and_env_1.setPropsAndEnv)({
|
|
26
|
-
|
|
27
|
+
serializedInputPropsWithCustomSchema,
|
|
27
28
|
envVariables,
|
|
28
29
|
page,
|
|
29
30
|
serveUrl,
|
|
@@ -33,6 +34,8 @@ const innerSelectComposition = async ({ page, onBrowserLog, inputProps, envVaria
|
|
|
33
34
|
retriesRemaining: 2,
|
|
34
35
|
audioEnabled: false,
|
|
35
36
|
videoEnabled: false,
|
|
37
|
+
indent,
|
|
38
|
+
logLevel,
|
|
36
39
|
});
|
|
37
40
|
await (0, puppeteer_evaluate_1.puppeteerEvaluateWithCatch)({
|
|
38
41
|
page,
|
|
@@ -44,14 +47,14 @@ const innerSelectComposition = async ({ page, onBrowserLog, inputProps, envVaria
|
|
|
44
47
|
frame: null,
|
|
45
48
|
args: [],
|
|
46
49
|
});
|
|
47
|
-
await (0, seek_to_frame_1.waitForReady)(page);
|
|
50
|
+
await (0, seek_to_frame_1.waitForReady)({ page, timeoutInMilliseconds, frame: null });
|
|
48
51
|
logger_1.Log.verboseAdvanced({
|
|
49
52
|
indent,
|
|
50
53
|
tag: 'selectComposition()',
|
|
51
|
-
logLevel
|
|
54
|
+
logLevel,
|
|
52
55
|
}, 'Running calculateMetadata()...');
|
|
53
56
|
const time = Date.now();
|
|
54
|
-
const result = await (0, puppeteer_evaluate_1.puppeteerEvaluateWithCatch)({
|
|
57
|
+
const { value: result, size } = await (0, puppeteer_evaluate_1.puppeteerEvaluateWithCatch)({
|
|
55
58
|
pageFunction: (_id) => {
|
|
56
59
|
return window.remotion_calculateComposition(_id);
|
|
57
60
|
},
|
|
@@ -62,13 +65,26 @@ const innerSelectComposition = async ({ page, onBrowserLog, inputProps, envVaria
|
|
|
62
65
|
logger_1.Log.verboseAdvanced({
|
|
63
66
|
indent,
|
|
64
67
|
tag: 'selectComposition()',
|
|
65
|
-
logLevel
|
|
68
|
+
logLevel,
|
|
66
69
|
}, `calculateMetadata() took ${Date.now() - time}ms`);
|
|
67
|
-
|
|
70
|
+
const res = result;
|
|
71
|
+
const { width, durationInFrames, fps, height } = res;
|
|
72
|
+
return {
|
|
73
|
+
metadata: {
|
|
74
|
+
id,
|
|
75
|
+
width,
|
|
76
|
+
height,
|
|
77
|
+
fps,
|
|
78
|
+
durationInFrames,
|
|
79
|
+
props: remotion_1.Internals.deserializeJSONWithCustomFields(res.serializedResolvedPropsWithCustomSchema),
|
|
80
|
+
defaultProps: remotion_1.Internals.deserializeJSONWithCustomFields(res.serializedDefaultPropsWithCustomSchema),
|
|
81
|
+
},
|
|
82
|
+
propsSize: size,
|
|
83
|
+
};
|
|
68
84
|
};
|
|
69
85
|
const internalSelectComposition = async (options) => {
|
|
70
86
|
const cleanup = [];
|
|
71
|
-
const { puppeteerInstance, browserExecutable, chromiumOptions, serveUrl: serveUrlOrWebpackUrl,
|
|
87
|
+
const { puppeteerInstance, browserExecutable, chromiumOptions, serveUrl: serveUrlOrWebpackUrl, logLevel, indent, port, envVariables, id, serializedInputPropsWithCustomSchema, onBrowserLog, server, timeoutInMilliseconds, } = options;
|
|
72
88
|
const { page, cleanup: cleanupPage } = await (0, get_browser_instance_1.getPageAndCleanupFn)({
|
|
73
89
|
passedInInstance: puppeteerInstance,
|
|
74
90
|
browserExecutable,
|
|
@@ -76,7 +92,7 @@ const internalSelectComposition = async (options) => {
|
|
|
76
92
|
context: null,
|
|
77
93
|
forceDeviceScaleFactor: undefined,
|
|
78
94
|
indent,
|
|
79
|
-
|
|
95
|
+
logLevel,
|
|
80
96
|
});
|
|
81
97
|
cleanup.push(() => cleanupPage());
|
|
82
98
|
return new Promise((resolve, reject) => {
|
|
@@ -91,7 +107,7 @@ const internalSelectComposition = async (options) => {
|
|
|
91
107
|
port,
|
|
92
108
|
remotionRoot: (0, find_closest_package_json_1.findRemotionRoot)(),
|
|
93
109
|
concurrency: 1,
|
|
94
|
-
|
|
110
|
+
logLevel,
|
|
95
111
|
indent,
|
|
96
112
|
}, {
|
|
97
113
|
onDownload: () => undefined,
|
|
@@ -108,17 +124,17 @@ const internalSelectComposition = async (options) => {
|
|
|
108
124
|
chromiumOptions,
|
|
109
125
|
envVariables,
|
|
110
126
|
id,
|
|
111
|
-
|
|
127
|
+
serializedInputPropsWithCustomSchema,
|
|
112
128
|
onBrowserLog,
|
|
113
129
|
timeoutInMilliseconds,
|
|
114
|
-
|
|
130
|
+
logLevel,
|
|
115
131
|
indent,
|
|
116
132
|
puppeteerInstance,
|
|
117
133
|
server,
|
|
118
134
|
});
|
|
119
135
|
})
|
|
120
|
-
.then((
|
|
121
|
-
return resolve(
|
|
136
|
+
.then((data) => {
|
|
137
|
+
return resolve(data);
|
|
122
138
|
})
|
|
123
139
|
.catch((err) => {
|
|
124
140
|
reject(err);
|
|
@@ -135,22 +151,27 @@ exports.internalSelectComposition = internalSelectComposition;
|
|
|
135
151
|
* @description Gets a composition defined in a Remotion project based on a Webpack bundle.
|
|
136
152
|
* @see [Documentation](https://www.remotion.dev/docs/renderer/select-composition)
|
|
137
153
|
*/
|
|
138
|
-
const selectComposition = (options) => {
|
|
154
|
+
const selectComposition = async (options) => {
|
|
139
155
|
const { id, serveUrl, browserExecutable, chromiumOptions, envVariables, inputProps, onBrowserLog, port, puppeteerInstance, timeoutInMilliseconds, verbose, } = options;
|
|
140
|
-
|
|
156
|
+
const data = await (0, exports.internalSelectComposition)({
|
|
141
157
|
id,
|
|
142
158
|
serveUrl,
|
|
143
159
|
browserExecutable: browserExecutable !== null && browserExecutable !== void 0 ? browserExecutable : null,
|
|
144
160
|
chromiumOptions: chromiumOptions !== null && chromiumOptions !== void 0 ? chromiumOptions : {},
|
|
145
161
|
envVariables: envVariables !== null && envVariables !== void 0 ? envVariables : {},
|
|
146
|
-
|
|
162
|
+
serializedInputPropsWithCustomSchema: remotion_1.Internals.serializeJSONWithDate({
|
|
163
|
+
indent: undefined,
|
|
164
|
+
staticBase: null,
|
|
165
|
+
data: inputProps !== null && inputProps !== void 0 ? inputProps : {},
|
|
166
|
+
}).serializedString,
|
|
147
167
|
onBrowserLog: onBrowserLog !== null && onBrowserLog !== void 0 ? onBrowserLog : null,
|
|
148
168
|
port: port !== null && port !== void 0 ? port : null,
|
|
149
169
|
puppeteerInstance,
|
|
150
170
|
timeoutInMilliseconds: timeoutInMilliseconds !== null && timeoutInMilliseconds !== void 0 ? timeoutInMilliseconds : TimeoutSettings_1.DEFAULT_TIMEOUT,
|
|
151
|
-
|
|
171
|
+
logLevel: verbose ? 'verbose' : 'info',
|
|
152
172
|
indent: false,
|
|
153
173
|
server: undefined,
|
|
154
174
|
});
|
|
175
|
+
return data.metadata;
|
|
155
176
|
};
|
|
156
177
|
exports.selectComposition = selectComposition;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SerializedJSONWithCustomFields } from 'remotion';
|
|
2
|
+
export declare const serializeJSONWithDate: ({ data, indent, staticBase, }: {
|
|
3
|
+
data: Record<string, unknown>;
|
|
4
|
+
indent: number | undefined;
|
|
5
|
+
staticBase: string | null;
|
|
6
|
+
}) => SerializedJSONWithCustomFields;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serializeJSONWithDate = void 0;
|
|
4
|
+
// Keep in sync with /packages/core/src/input-props-serialization.ts
|
|
5
|
+
const DATE_TOKEN = 'remotion-date:';
|
|
6
|
+
const FILE_TOKEN = 'remotion-file:';
|
|
7
|
+
const serializeJSONWithDate = ({ data, indent, staticBase, }) => {
|
|
8
|
+
let customDateUsed = false;
|
|
9
|
+
let customFileUsed = false;
|
|
10
|
+
let mapUsed = false;
|
|
11
|
+
let setUsed = false;
|
|
12
|
+
const serializedString = JSON.stringify(data, function (key, value) {
|
|
13
|
+
const item = this[key];
|
|
14
|
+
if (item instanceof Date) {
|
|
15
|
+
customDateUsed = true;
|
|
16
|
+
return `${DATE_TOKEN}${item.toISOString()}`;
|
|
17
|
+
}
|
|
18
|
+
if (item instanceof Map) {
|
|
19
|
+
mapUsed = true;
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
if (item instanceof Set) {
|
|
23
|
+
setUsed = true;
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
if (typeof item === 'string' &&
|
|
27
|
+
staticBase !== null &&
|
|
28
|
+
item.startsWith(staticBase)) {
|
|
29
|
+
customFileUsed = true;
|
|
30
|
+
return `${FILE_TOKEN}${item.replace(staticBase + '/', '')}`;
|
|
31
|
+
}
|
|
32
|
+
return value;
|
|
33
|
+
}, indent);
|
|
34
|
+
return { serializedString, customDateUsed, customFileUsed, mapUsed, setUsed };
|
|
35
|
+
};
|
|
36
|
+
exports.serializeJSONWithDate = serializeJSONWithDate;
|
|
@@ -169,7 +169,7 @@ const serveHandler = async (request, response, config) => {
|
|
|
169
169
|
return sendError(absolutePath, response, {
|
|
170
170
|
statusCode: 404,
|
|
171
171
|
code: 'not_found',
|
|
172
|
-
message: 'The requested path could not be found',
|
|
172
|
+
message: 'The requested path (' + absolutePath + ') could not be found',
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
175
|
let streamOpts = null;
|
package/dist/serve-static.d.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import type { DownloadMap } from './assets/download-map';
|
|
2
2
|
import type { Compositor } from './compositor/compositor';
|
|
3
|
-
import type {
|
|
3
|
+
import type { LogLevel } from './log-level';
|
|
4
4
|
export declare const serveStatic: (path: string | null, options: {
|
|
5
5
|
port: number | null;
|
|
6
6
|
downloadMap: DownloadMap;
|
|
7
7
|
remotionRoot: string;
|
|
8
8
|
concurrency: number;
|
|
9
|
-
|
|
9
|
+
logLevel: LogLevel;
|
|
10
10
|
indent: boolean;
|
|
11
11
|
}) => Promise<{
|
|
12
12
|
port: number;
|
|
13
13
|
close: () => Promise<void>;
|
|
14
14
|
compositor: Compositor;
|
|
15
|
-
events: OffthreadVideoServerEmitter;
|
|
16
15
|
}>;
|