@remotion/renderer 4.0.0-alpha.217 → 4.0.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/README.md +5 -37
- package/dist/assets/download-and-map-assets-to-file.js +6 -6
- package/dist/assets/download-file.d.ts +3 -2
- package/dist/assets/download-file.js +18 -3
- package/dist/assets/download-map.d.ts +0 -26
- package/dist/assets/download-map.js +7 -12
- package/dist/assets/get-video-stream-duration.d.ts +5 -2
- package/dist/assets/get-video-stream-duration.js +12 -6
- package/dist/assets/read-file.d.ts +1 -1
- package/dist/assets/read-file.js +2 -2
- package/dist/assets/sanitize-filepath.js +2 -2
- package/dist/browser/Browser.d.ts +4 -4
- package/dist/browser/Browser.js +38 -38
- package/dist/browser/BrowserFetcher.d.ts +15 -63
- package/dist/browser/BrowserFetcher.js +138 -226
- package/dist/browser/BrowserPage.d.ts +4 -4
- package/dist/browser/BrowserRunner.d.ts +1 -1
- package/dist/browser/BrowserRunner.js +9 -22
- package/dist/browser/DOMWorld.d.ts +3 -3
- package/dist/browser/LaunchOptions.d.ts +1 -2
- package/dist/browser/Launcher.d.ts +3 -3
- package/dist/browser/Launcher.js +10 -23
- package/dist/browser/NodeWebSocketTransport.js +4 -4
- package/dist/browser/PuppeteerNode.d.ts +2 -5
- package/dist/browser/PuppeteerNode.js +0 -5
- package/dist/browser/Target.d.ts +2 -2
- package/dist/browser/create-browser-fetcher.js +34 -48
- package/dist/browser/get-download-destination.js +8 -8
- package/dist/browser/util.d.ts +2 -2
- package/dist/call-ffmpeg.d.ts +4 -7
- package/dist/call-ffmpeg.js +24 -16
- package/dist/chalk/index.d.ts +54 -0
- package/dist/chalk/index.js +135 -0
- package/dist/chalk/is-color-supported.d.ts +1 -0
- package/dist/chalk/is-color-supported.js +37 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.js +1 -0
- package/dist/codec-supports-media.d.ts +1 -0
- package/dist/codec-supports-media.js +20 -5
- package/dist/combine-videos.js +6 -6
- package/dist/compositor/compose.d.ts +6 -2
- package/dist/compositor/compose.js +43 -20
- package/dist/compositor/compositor.d.ts +4 -8
- package/dist/compositor/compositor.js +67 -53
- package/dist/compositor/get-executable-path.js +3 -0
- package/dist/compositor/payloads.d.ts +34 -7
- package/dist/crf.js +8 -2
- package/dist/delete-directory.js +3 -3
- package/dist/does-have-m2-bug.js +2 -2
- package/dist/ensure-output-directory.js +5 -5
- package/dist/ensure-presentation-timestamp.d.ts +9 -2
- package/dist/ensure-presentation-timestamp.js +13 -5
- package/dist/extract-frame-from-video.d.ts +3 -1
- package/dist/extract-frame-from-video.js +29 -7
- package/dist/ffmpeg-filter-file.js +7 -7
- package/dist/find-closest-package-json.js +6 -6
- package/dist/get-browser-instance.d.ts +2 -2
- package/dist/get-can-extract-frames-fast.d.ts +4 -1
- package/dist/get-can-extract-frames-fast.js +12 -1
- package/dist/get-compositions.d.ts +8 -3
- package/dist/get-compositions.js +6 -2
- package/dist/get-concurrency.js +3 -3
- package/dist/get-extension-of-filename.js +2 -2
- package/dist/get-frame-of-video-slow.d.ts +8 -3
- package/dist/get-frame-of-video-slow.js +11 -3
- package/dist/get-local-browser-executable.js +6 -15
- package/dist/get-video-info.d.ts +5 -2
- package/dist/get-video-info.js +12 -6
- package/dist/get-video-threads-flag.js +3 -3
- package/dist/index.d.ts +92 -16
- package/dist/index.js +15 -6
- package/dist/last-frame-from-video-cache.d.ts +4 -1
- package/dist/last-frame-from-video-cache.js +1 -0
- package/dist/logger.d.ts +22 -0
- package/dist/logger.js +61 -0
- package/dist/merge-audio-track.js +2 -2
- package/dist/mime-types.js +2 -2
- package/dist/offthread-video-server.d.ts +12 -6
- package/dist/offthread-video-server.js +66 -56
- package/dist/open-browser.d.ts +3 -3
- package/dist/open-browser.js +1 -1
- package/dist/options/jpeg-quality.js +1 -1
- package/dist/options/video-codec.js +1 -1
- package/dist/prepare-server.d.ts +6 -1
- package/dist/prepare-server.js +15 -7
- package/dist/prespawn-ffmpeg.d.ts +1 -0
- package/dist/prespawn-ffmpeg.js +37 -14
- package/dist/prestitcher-memory-usage.js +2 -2
- package/dist/puppeteer-evaluate.js +2 -2
- package/dist/puppeteer-screenshot.js +1 -1
- package/dist/render-frames.d.ts +9 -4
- package/dist/render-frames.js +28 -12
- package/dist/render-media.d.ts +7 -4
- package/dist/render-media.js +49 -26
- package/dist/render-still.d.ts +10 -3
- package/dist/render-still.js +26 -9
- package/dist/replace-browser.d.ts +4 -4
- package/dist/resolve-asset-src.js +2 -2
- package/dist/screenshot-task.js +2 -2
- package/dist/select-composition.d.ts +33 -0
- package/dist/select-composition.js +119 -0
- package/dist/serve-handler/index.d.ts +1 -1
- package/dist/serve-handler/index.js +15 -15
- package/dist/serve-handler/is-path-inside.js +3 -3
- package/dist/serve-static.d.ts +5 -0
- package/dist/serve-static.js +25 -20
- package/dist/set-props-and-env.d.ts +5 -3
- package/dist/set-props-and-env.js +13 -3
- package/dist/stitch-frames-to-video.d.ts +1 -0
- package/dist/stitch-frames-to-video.js +76 -53
- package/dist/take-frame-and-compose.d.ts +3 -1
- package/dist/take-frame-and-compose.js +8 -7
- package/dist/tmp-dir.js +7 -7
- package/dist/try-to-extract-frame-of-video-fast.d.ts +4 -2
- package/dist/try-to-extract-frame-of-video-fast.js +7 -3
- package/install-toolchain.mjs +3 -9
- package/package.json +70 -71
- package/types/ws/index.d.ts +5 -5
- package/ffmpeg/SOURCE.md +0 -1
- package/ffmpeg/linux-arm-musl.gz +0 -0
- package/ffmpeg/linux-arm.gz +0 -0
- package/ffmpeg/linux-x64-musl.gz +0 -0
- package/ffmpeg/linux-x64.gz +0 -0
- package/ffmpeg/macos-arm.gz +0 -0
- package/ffmpeg/macos-x64.gz +0 -0
- package/ffmpeg/windows.gz +0 -0
package/dist/render-still.js
CHANGED
|
@@ -27,8 +27,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.renderStill = void 0;
|
|
30
|
-
const
|
|
31
|
-
const
|
|
30
|
+
const node_fs_1 = __importStar(require("node:fs"));
|
|
31
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
32
32
|
const remotion_1 = require("remotion");
|
|
33
33
|
const download_map_1 = require("./assets/download-map");
|
|
34
34
|
const browser_1 = require("./browser");
|
|
@@ -47,7 +47,7 @@ const set_props_and_env_1 = require("./set-props-and-env");
|
|
|
47
47
|
const take_frame_and_compose_1 = require("./take-frame-and-compose");
|
|
48
48
|
const validate_puppeteer_timeout_1 = require("./validate-puppeteer-timeout");
|
|
49
49
|
const validate_scale_1 = require("./validate-scale");
|
|
50
|
-
const innerRenderStill = async ({ composition, quality, imageFormat = image_format_1.DEFAULT_STILL_IMAGE_FORMAT, serveUrl, puppeteerInstance, dumpBrowserLogs = false, onError, inputProps, envVariables, output, frame = 0, overwrite = true, browserExecutable, timeoutInMilliseconds, chromiumOptions, scale = 1, proxyPort, cancelSignal, downloadMap, jpegQuality, }) => {
|
|
50
|
+
const innerRenderStill = async ({ composition, quality, imageFormat = image_format_1.DEFAULT_STILL_IMAGE_FORMAT, serveUrl, puppeteerInstance, dumpBrowserLogs = false, onError, inputProps, envVariables, output, frame = 0, overwrite = true, browserExecutable, timeoutInMilliseconds, chromiumOptions, scale = 1, proxyPort, cancelSignal, downloadMap, jpegQuality, onBrowserLog, compositor, }) => {
|
|
51
51
|
if (quality) {
|
|
52
52
|
throw new Error('quality has been renamed to jpegQuality. Please rename the option.');
|
|
53
53
|
}
|
|
@@ -72,17 +72,17 @@ const innerRenderStill = async ({ composition, quality, imageFormat = image_form
|
|
|
72
72
|
(0, validate_puppeteer_timeout_1.validatePuppeteerTimeout)(timeoutInMilliseconds);
|
|
73
73
|
(0, validate_scale_1.validateScale)(scale);
|
|
74
74
|
output =
|
|
75
|
-
typeof output === 'string' ?
|
|
75
|
+
typeof output === 'string' ? node_path_1.default.resolve(process.cwd(), output) : null;
|
|
76
76
|
if (jpegQuality !== undefined && imageFormat !== 'jpeg') {
|
|
77
77
|
throw new Error("You can only pass the `quality` option if `imageFormat` is 'jpeg'.");
|
|
78
78
|
}
|
|
79
79
|
(0, jpeg_quality_1.validateJpegQuality)(jpegQuality);
|
|
80
80
|
if (output) {
|
|
81
|
-
if (
|
|
81
|
+
if (node_fs_1.default.existsSync(output)) {
|
|
82
82
|
if (!overwrite) {
|
|
83
83
|
throw new Error(`Cannot render still - "overwrite" option was set to false, but the output destination ${output} already exists.`);
|
|
84
84
|
}
|
|
85
|
-
const stat = (0,
|
|
85
|
+
const stat = (0, node_fs_1.statSync)(output);
|
|
86
86
|
if (!stat.isFile()) {
|
|
87
87
|
throw new Error(`The output location ${output} already exists, but is not a file, but something else (e.g. folder). Cannot save to it.`);
|
|
88
88
|
}
|
|
@@ -94,6 +94,7 @@ const innerRenderStill = async ({ composition, quality, imageFormat = image_form
|
|
|
94
94
|
shouldDumpIo: dumpBrowserLogs,
|
|
95
95
|
chromiumOptions,
|
|
96
96
|
forceDeviceScaleFactor: scale !== null && scale !== void 0 ? scale : 1,
|
|
97
|
+
indent: false,
|
|
97
98
|
}));
|
|
98
99
|
const page = await browserInstance.newPage();
|
|
99
100
|
await page.setViewport({
|
|
@@ -110,8 +111,16 @@ const innerRenderStill = async ({ composition, quality, imageFormat = image_form
|
|
|
110
111
|
onError: errorCallback,
|
|
111
112
|
frame: null,
|
|
112
113
|
});
|
|
114
|
+
const logCallback = (log) => {
|
|
115
|
+
onBrowserLog === null || onBrowserLog === void 0 ? void 0 : onBrowserLog({
|
|
116
|
+
stackTrace: log.stackTrace(),
|
|
117
|
+
text: log.text,
|
|
118
|
+
type: log.type,
|
|
119
|
+
});
|
|
120
|
+
};
|
|
113
121
|
const cleanup = async () => {
|
|
114
122
|
cleanUpJSException();
|
|
123
|
+
page.off('console', logCallback);
|
|
115
124
|
if (puppeteerInstance) {
|
|
116
125
|
await page.close();
|
|
117
126
|
}
|
|
@@ -124,8 +133,11 @@ const innerRenderStill = async ({ composition, quality, imageFormat = image_form
|
|
|
124
133
|
cancelSignal === null || cancelSignal === void 0 ? void 0 : cancelSignal(() => {
|
|
125
134
|
cleanup();
|
|
126
135
|
});
|
|
136
|
+
if (onBrowserLog) {
|
|
137
|
+
page.on('console', logCallback);
|
|
138
|
+
}
|
|
127
139
|
await (0, set_props_and_env_1.setPropsAndEnv)({
|
|
128
|
-
inputProps,
|
|
140
|
+
inputProps: inputProps !== null && inputProps !== void 0 ? inputProps : {},
|
|
129
141
|
envVariables,
|
|
130
142
|
page,
|
|
131
143
|
serveUrl,
|
|
@@ -172,6 +184,7 @@ const innerRenderStill = async ({ composition, quality, imageFormat = image_form
|
|
|
172
184
|
output,
|
|
173
185
|
jpegQuality,
|
|
174
186
|
wantsBuffer: !output,
|
|
187
|
+
compositor,
|
|
175
188
|
});
|
|
176
189
|
await cleanup();
|
|
177
190
|
return { buffer: output ? null : buffer };
|
|
@@ -186,7 +199,7 @@ const renderStill = (options) => {
|
|
|
186
199
|
const downloadMap = (_a = options.downloadMap) !== null && _a !== void 0 ? _a : (0, download_map_1.makeDownloadMap)();
|
|
187
200
|
const onDownload = (_b = options.onDownload) !== null && _b !== void 0 ? _b : (() => () => undefined);
|
|
188
201
|
const happyPath = new Promise((resolve, reject) => {
|
|
189
|
-
var _a;
|
|
202
|
+
var _a, _b, _c;
|
|
190
203
|
const onError = (err) => reject(err);
|
|
191
204
|
let close = null;
|
|
192
205
|
(0, prepare_server_1.prepareServer)({
|
|
@@ -196,8 +209,11 @@ const renderStill = (options) => {
|
|
|
196
209
|
port: (_a = options.port) !== null && _a !== void 0 ? _a : null,
|
|
197
210
|
downloadMap,
|
|
198
211
|
remotionRoot: (0, find_closest_package_json_1.findRemotionRoot)(),
|
|
212
|
+
concurrency: 1,
|
|
213
|
+
verbose: (_b = options.verbose) !== null && _b !== void 0 ? _b : false,
|
|
214
|
+
indent: (_c = options.indent) !== null && _c !== void 0 ? _c : false,
|
|
199
215
|
})
|
|
200
|
-
.then(({ serveUrl, closeServer, offthreadPort }) => {
|
|
216
|
+
.then(({ serveUrl, closeServer, offthreadPort, compositor }) => {
|
|
201
217
|
close = closeServer;
|
|
202
218
|
return innerRenderStill({
|
|
203
219
|
...options,
|
|
@@ -205,6 +221,7 @@ const renderStill = (options) => {
|
|
|
205
221
|
onError: (err) => reject(err),
|
|
206
222
|
proxyPort: offthreadPort,
|
|
207
223
|
downloadMap,
|
|
224
|
+
compositor,
|
|
208
225
|
});
|
|
209
226
|
})
|
|
210
227
|
.then((res) => resolve(res))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HeadlessBrowser } from './browser/Browser';
|
|
2
2
|
export declare type BrowserReplacer = {
|
|
3
|
-
getBrowser: () =>
|
|
4
|
-
replaceBrowser: (make: () => Promise<
|
|
3
|
+
getBrowser: () => HeadlessBrowser;
|
|
4
|
+
replaceBrowser: (make: () => Promise<HeadlessBrowser>, makeNewPages: () => Promise<void>) => Promise<HeadlessBrowser>;
|
|
5
5
|
};
|
|
6
|
-
export declare const handleBrowserCrash: (instance:
|
|
6
|
+
export declare const handleBrowserCrash: (instance: HeadlessBrowser) => BrowserReplacer;
|
|
@@ -4,14 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.resolveAssetSrc = void 0;
|
|
7
|
-
const
|
|
7
|
+
const node_url_1 = __importDefault(require("node:url"));
|
|
8
8
|
const resolveAssetSrc = (src) => {
|
|
9
9
|
if (!src.startsWith('file:')) {
|
|
10
10
|
return src;
|
|
11
11
|
}
|
|
12
12
|
const { protocol } = new URL(src);
|
|
13
13
|
if (protocol === 'file:')
|
|
14
|
-
return
|
|
14
|
+
return node_url_1.default.fileURLToPath(src);
|
|
15
15
|
throw new TypeError(`Unexpected src ${src}`);
|
|
16
16
|
};
|
|
17
17
|
exports.resolveAssetSrc = resolveAssetSrc;
|
package/dist/screenshot-task.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.screenshotTask = void 0;
|
|
7
|
-
const
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
8
|
const perf_1 = require("./perf");
|
|
9
9
|
const screenshotTask = async ({ format, height, omitBackground, page, width, path, jpegQuality, clipRegion, }) => {
|
|
10
10
|
var _a;
|
|
@@ -64,7 +64,7 @@ const screenshotTask = async ({ format, height, omitBackground, page, width, pat
|
|
|
64
64
|
const saveMarker = (0, perf_1.startPerfMeasure)('save');
|
|
65
65
|
const buffer = Buffer.from(result.data, 'base64');
|
|
66
66
|
if (path)
|
|
67
|
-
await
|
|
67
|
+
await node_fs_1.default.promises.writeFile(path, buffer);
|
|
68
68
|
(0, perf_1.stopPerfMeasure)(saveMarker);
|
|
69
69
|
return buffer;
|
|
70
70
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { AnyCompMetadata } from 'remotion';
|
|
2
|
+
import type { DownloadMap } from './assets/download-map';
|
|
3
|
+
import type { BrowserExecutable } from './browser-executable';
|
|
4
|
+
import type { BrowserLog } from './browser-log';
|
|
5
|
+
import type { HeadlessBrowser } from './browser/Browser';
|
|
6
|
+
import type { ChromiumOptions } from './open-browser';
|
|
7
|
+
declare type SelectCompositionsConfig = {
|
|
8
|
+
inputProps?: Record<string, unknown> | null;
|
|
9
|
+
envVariables?: Record<string, string>;
|
|
10
|
+
puppeteerInstance?: HeadlessBrowser;
|
|
11
|
+
onBrowserLog?: (log: BrowserLog) => void;
|
|
12
|
+
browserExecutable?: BrowserExecutable;
|
|
13
|
+
timeoutInMilliseconds?: number;
|
|
14
|
+
chromiumOptions?: ChromiumOptions;
|
|
15
|
+
port?: number | null;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Only for Remotion internal usage
|
|
18
|
+
*/
|
|
19
|
+
downloadMap?: DownloadMap;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated Only for Remotion internal usage
|
|
22
|
+
*/
|
|
23
|
+
indent?: boolean;
|
|
24
|
+
verbose?: boolean;
|
|
25
|
+
serveUrl: string;
|
|
26
|
+
id: string;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* @description Gets a composition defined in a Remotion project based on a Webpack bundle.
|
|
30
|
+
* @see [Documentation](https://www.remotion.dev/docs/renderer/select-composition)
|
|
31
|
+
*/
|
|
32
|
+
export declare const selectComposition: (options: SelectCompositionsConfig) => Promise<AnyCompMetadata>;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.selectComposition = void 0;
|
|
4
|
+
const download_map_1 = require("./assets/download-map");
|
|
5
|
+
const handle_javascript_exception_1 = require("./error-handling/handle-javascript-exception");
|
|
6
|
+
const find_closest_package_json_1 = require("./find-closest-package-json");
|
|
7
|
+
const get_browser_instance_1 = require("./get-browser-instance");
|
|
8
|
+
const prepare_server_1 = require("./prepare-server");
|
|
9
|
+
const puppeteer_evaluate_1 = require("./puppeteer-evaluate");
|
|
10
|
+
const seek_to_frame_1 = require("./seek-to-frame");
|
|
11
|
+
const set_props_and_env_1 = require("./set-props-and-env");
|
|
12
|
+
const validate_puppeteer_timeout_1 = require("./validate-puppeteer-timeout");
|
|
13
|
+
const innerSelectComposition = async ({ page, onBrowserLog, inputProps, envVariables, serveUrl, timeoutInMilliseconds, port, id, }) => {
|
|
14
|
+
if (onBrowserLog) {
|
|
15
|
+
page.on('console', (log) => {
|
|
16
|
+
onBrowserLog === null || onBrowserLog === void 0 ? void 0 : onBrowserLog({
|
|
17
|
+
stackTrace: log.stackTrace(),
|
|
18
|
+
text: log.text,
|
|
19
|
+
type: log.type,
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
(0, validate_puppeteer_timeout_1.validatePuppeteerTimeout)(timeoutInMilliseconds);
|
|
24
|
+
await (0, set_props_and_env_1.setPropsAndEnv)({
|
|
25
|
+
inputProps: inputProps !== null && inputProps !== void 0 ? inputProps : {},
|
|
26
|
+
envVariables,
|
|
27
|
+
page,
|
|
28
|
+
serveUrl,
|
|
29
|
+
initialFrame: 0,
|
|
30
|
+
timeoutInMilliseconds,
|
|
31
|
+
proxyPort: port,
|
|
32
|
+
retriesRemaining: 2,
|
|
33
|
+
audioEnabled: false,
|
|
34
|
+
videoEnabled: false,
|
|
35
|
+
});
|
|
36
|
+
await (0, puppeteer_evaluate_1.puppeteerEvaluateWithCatch)({
|
|
37
|
+
page,
|
|
38
|
+
pageFunction: () => {
|
|
39
|
+
window.setBundleMode({
|
|
40
|
+
type: 'evaluation',
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
frame: null,
|
|
44
|
+
args: [],
|
|
45
|
+
});
|
|
46
|
+
await (0, seek_to_frame_1.waitForReady)(page);
|
|
47
|
+
const result = await (0, puppeteer_evaluate_1.puppeteerEvaluateWithCatch)({
|
|
48
|
+
pageFunction: (_id) => {
|
|
49
|
+
return window.calculateComposition(_id);
|
|
50
|
+
},
|
|
51
|
+
frame: null,
|
|
52
|
+
page,
|
|
53
|
+
args: [id],
|
|
54
|
+
});
|
|
55
|
+
return result;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* @description Gets a composition defined in a Remotion project based on a Webpack bundle.
|
|
59
|
+
* @see [Documentation](https://www.remotion.dev/docs/renderer/select-composition)
|
|
60
|
+
*/
|
|
61
|
+
const selectComposition = async (options) => {
|
|
62
|
+
const { puppeteerInstance, browserExecutable, chromiumOptions, downloadMap: passedDownloadMap, serveUrl: serveUrlOrWebpackUrl, verbose, indent, port, } = options;
|
|
63
|
+
const downloadMap = passedDownloadMap !== null && passedDownloadMap !== void 0 ? passedDownloadMap : (0, download_map_1.makeDownloadMap)();
|
|
64
|
+
const { page, cleanup } = await (0, get_browser_instance_1.getPageAndCleanupFn)({
|
|
65
|
+
passedInInstance: puppeteerInstance,
|
|
66
|
+
browserExecutable: browserExecutable !== null && browserExecutable !== void 0 ? browserExecutable : null,
|
|
67
|
+
chromiumOptions: chromiumOptions !== null && chromiumOptions !== void 0 ? chromiumOptions : {},
|
|
68
|
+
});
|
|
69
|
+
return new Promise((resolve, reject) => {
|
|
70
|
+
const onError = (err) => reject(err);
|
|
71
|
+
const cleanupPageError = (0, handle_javascript_exception_1.handleJavascriptException)({
|
|
72
|
+
page,
|
|
73
|
+
frame: null,
|
|
74
|
+
onError,
|
|
75
|
+
});
|
|
76
|
+
let close = null;
|
|
77
|
+
(0, prepare_server_1.prepareServer)({
|
|
78
|
+
webpackConfigOrServeUrl: serveUrlOrWebpackUrl,
|
|
79
|
+
onDownload: () => undefined,
|
|
80
|
+
onError,
|
|
81
|
+
port: port !== null && port !== void 0 ? port : null,
|
|
82
|
+
downloadMap,
|
|
83
|
+
remotionRoot: (0, find_closest_package_json_1.findRemotionRoot)(),
|
|
84
|
+
concurrency: 1,
|
|
85
|
+
verbose: verbose !== null && verbose !== void 0 ? verbose : false,
|
|
86
|
+
indent: indent !== null && indent !== void 0 ? indent : false,
|
|
87
|
+
})
|
|
88
|
+
.then(({ serveUrl, closeServer, offthreadPort }) => {
|
|
89
|
+
close = closeServer;
|
|
90
|
+
return innerSelectComposition({
|
|
91
|
+
...options,
|
|
92
|
+
serveUrl,
|
|
93
|
+
page,
|
|
94
|
+
port: offthreadPort,
|
|
95
|
+
});
|
|
96
|
+
})
|
|
97
|
+
.then((comp) => {
|
|
98
|
+
if (close) {
|
|
99
|
+
return Promise.all([comp, close(true)]);
|
|
100
|
+
}
|
|
101
|
+
return Promise.resolve([comp, null]);
|
|
102
|
+
})
|
|
103
|
+
.then(([comp]) => {
|
|
104
|
+
return resolve(comp);
|
|
105
|
+
})
|
|
106
|
+
.catch((err) => {
|
|
107
|
+
reject(err);
|
|
108
|
+
})
|
|
109
|
+
.finally(() => {
|
|
110
|
+
cleanup();
|
|
111
|
+
cleanupPageError();
|
|
112
|
+
// Clean download map if it was not passed in
|
|
113
|
+
if (!passedDownloadMap) {
|
|
114
|
+
(0, download_map_1.cleanDownloadMap)(downloadMap);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
exports.selectComposition = selectComposition;
|
|
@@ -4,15 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.serveHandler = void 0;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const node_url_1 = __importDefault(require("node:url"));
|
|
10
10
|
const mime_types_1 = require("../mime-types");
|
|
11
11
|
// Packages
|
|
12
12
|
const is_path_inside_1 = require("./is-path-inside");
|
|
13
13
|
const range_parser_1 = require("./range-parser");
|
|
14
14
|
const getHeaders = (absolutePath, stats) => {
|
|
15
|
-
const { base } =
|
|
15
|
+
const { base } = node_path_1.default.parse(absolutePath);
|
|
16
16
|
let defaultHeaders = {};
|
|
17
17
|
if (stats) {
|
|
18
18
|
defaultHeaders = {
|
|
@@ -28,19 +28,19 @@ const getHeaders = (absolutePath, stats) => {
|
|
|
28
28
|
return defaultHeaders;
|
|
29
29
|
};
|
|
30
30
|
const getPossiblePaths = (relativePath, extension) => [
|
|
31
|
-
|
|
31
|
+
node_path_1.default.join(relativePath, `index${extension}`),
|
|
32
32
|
relativePath.endsWith('/')
|
|
33
33
|
? relativePath.replace(/\/$/g, extension)
|
|
34
34
|
: relativePath + extension,
|
|
35
|
-
].filter((item) =>
|
|
35
|
+
].filter((item) => node_path_1.default.basename(item) !== extension);
|
|
36
36
|
const findRelated = async (current, relativePath) => {
|
|
37
37
|
const possible = getPossiblePaths(relativePath, '.html');
|
|
38
38
|
let stats = null;
|
|
39
39
|
for (let index = 0; index < possible.length; index++) {
|
|
40
40
|
const related = possible[index];
|
|
41
|
-
const absolutePath =
|
|
41
|
+
const absolutePath = node_path_1.default.join(current, related);
|
|
42
42
|
try {
|
|
43
|
-
stats = await
|
|
43
|
+
stats = await node_fs_1.promises.lstat(absolutePath);
|
|
44
44
|
}
|
|
45
45
|
catch (err) {
|
|
46
46
|
if (err.code !== 'ENOENT' &&
|
|
@@ -75,10 +75,10 @@ const internalError = (absolutePath, response) => {
|
|
|
75
75
|
};
|
|
76
76
|
const serveHandler = async (request, response, config) => {
|
|
77
77
|
const cwd = process.cwd();
|
|
78
|
-
const current =
|
|
78
|
+
const current = node_path_1.default.resolve(cwd, config.public);
|
|
79
79
|
let relativePath = null;
|
|
80
80
|
try {
|
|
81
|
-
relativePath = decodeURIComponent(
|
|
81
|
+
relativePath = decodeURIComponent(node_url_1.default.parse(request.url).pathname);
|
|
82
82
|
}
|
|
83
83
|
catch (err) {
|
|
84
84
|
return sendError('/', response, {
|
|
@@ -87,7 +87,7 @@ const serveHandler = async (request, response, config) => {
|
|
|
87
87
|
message: 'Bad Request',
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
|
-
let absolutePath =
|
|
90
|
+
let absolutePath = node_path_1.default.join(current, relativePath);
|
|
91
91
|
// Prevent path traversal vulnerabilities. We could do this
|
|
92
92
|
// by ourselves, but using the package covers all the edge cases.
|
|
93
93
|
if (!(0, is_path_inside_1.isPathInside)(absolutePath, current)) {
|
|
@@ -109,9 +109,9 @@ const serveHandler = async (request, response, config) => {
|
|
|
109
109
|
// directory exists requires loading all the file paths and then checking if
|
|
110
110
|
// one of them includes the path of the directory. As that's a very
|
|
111
111
|
// performance-expensive thing to do, we need to ensure it's not happening if not really necessary.
|
|
112
|
-
if (
|
|
112
|
+
if (node_path_1.default.extname(relativePath) !== '') {
|
|
113
113
|
try {
|
|
114
|
-
stats = await
|
|
114
|
+
stats = await node_fs_1.promises.lstat(absolutePath);
|
|
115
115
|
}
|
|
116
116
|
catch (err) {
|
|
117
117
|
if (err.code !== 'ENOENT' &&
|
|
@@ -135,7 +135,7 @@ const serveHandler = async (request, response, config) => {
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
try {
|
|
138
|
-
stats = await
|
|
138
|
+
stats = await node_fs_1.promises.lstat(absolutePath);
|
|
139
139
|
}
|
|
140
140
|
catch (err) {
|
|
141
141
|
if (err.code !== 'ENOENT' &&
|
|
@@ -190,7 +190,7 @@ const serveHandler = async (request, response, config) => {
|
|
|
190
190
|
}
|
|
191
191
|
let stream = null;
|
|
192
192
|
try {
|
|
193
|
-
stream = (0,
|
|
193
|
+
stream = (0, node_fs_1.createReadStream)(absolutePath, streamOpts !== null && streamOpts !== void 0 ? streamOpts : {});
|
|
194
194
|
}
|
|
195
195
|
catch (err) {
|
|
196
196
|
return internalError(absolutePath, response);
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.isPathInside = void 0;
|
|
7
|
-
const
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
8
|
const isPathInside = function (thePath, potentialParent) {
|
|
9
9
|
// For inside-directory checking, we want to allow trailing slashes, so normalize.
|
|
10
10
|
thePath = stripTrailingSep(thePath);
|
|
@@ -15,12 +15,12 @@ const isPathInside = function (thePath, potentialParent) {
|
|
|
15
15
|
potentialParent = potentialParent.toLowerCase();
|
|
16
16
|
}
|
|
17
17
|
return (thePath.lastIndexOf(potentialParent, 0) === 0 &&
|
|
18
|
-
(thePath[potentialParent.length] ===
|
|
18
|
+
(thePath[potentialParent.length] === node_path_1.default.sep ||
|
|
19
19
|
thePath[potentialParent.length] === undefined));
|
|
20
20
|
};
|
|
21
21
|
exports.isPathInside = isPathInside;
|
|
22
22
|
function stripTrailingSep(thePath) {
|
|
23
|
-
if (thePath[thePath.length - 1] ===
|
|
23
|
+
if (thePath[thePath.length - 1] === node_path_1.default.sep) {
|
|
24
24
|
return thePath.slice(0, -1);
|
|
25
25
|
}
|
|
26
26
|
return thePath;
|
package/dist/serve-static.d.ts
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import type { RenderMediaOnDownload } from './assets/download-and-map-assets-to-file';
|
|
2
2
|
import type { DownloadMap } from './assets/download-map';
|
|
3
|
+
import type { Compositor } from './compositor/compositor';
|
|
3
4
|
export declare const serveStatic: (path: string | null, options: {
|
|
4
5
|
port: number | null;
|
|
5
6
|
onDownload: RenderMediaOnDownload;
|
|
6
7
|
onError: (err: Error) => void;
|
|
7
8
|
downloadMap: DownloadMap;
|
|
8
9
|
remotionRoot: string;
|
|
10
|
+
concurrency: number;
|
|
11
|
+
verbose: boolean;
|
|
12
|
+
indent: boolean;
|
|
9
13
|
}) => Promise<{
|
|
10
14
|
port: number;
|
|
11
15
|
close: () => Promise<void>;
|
|
16
|
+
compositor: Compositor;
|
|
12
17
|
}>;
|
package/dist/serve-static.js
CHANGED
|
@@ -4,19 +4,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.serveStatic = void 0;
|
|
7
|
-
const
|
|
7
|
+
const node_http_1 = __importDefault(require("node:http"));
|
|
8
8
|
const get_port_1 = require("./get-port");
|
|
9
9
|
const offthread_video_server_1 = require("./offthread-video-server");
|
|
10
10
|
const serve_handler_1 = require("./serve-handler");
|
|
11
11
|
const serveStatic = async (path, options) => {
|
|
12
|
-
const offthreadRequest = (0, offthread_video_server_1.startOffthreadVideoServer)({
|
|
12
|
+
const { listener: offthreadRequest, close: closeCompositor, compositor, } = (0, offthread_video_server_1.startOffthreadVideoServer)({
|
|
13
13
|
onDownload: options.onDownload,
|
|
14
14
|
onError: options.onError,
|
|
15
15
|
downloadMap: options.downloadMap,
|
|
16
|
-
|
|
16
|
+
concurrency: options.concurrency,
|
|
17
|
+
verbose: options.verbose,
|
|
18
|
+
indent: options.indent,
|
|
17
19
|
});
|
|
18
20
|
const connections = {};
|
|
19
|
-
const server =
|
|
21
|
+
const server = node_http_1.default.createServer((request, response) => {
|
|
20
22
|
var _a;
|
|
21
23
|
if ((_a = request.url) === null || _a === void 0 ? void 0 : _a.startsWith('/proxy')) {
|
|
22
24
|
return offthreadRequest(request, response);
|
|
@@ -65,24 +67,27 @@ const serveStatic = async (path, options) => {
|
|
|
65
67
|
for (const key in connections)
|
|
66
68
|
connections[key].destroy();
|
|
67
69
|
};
|
|
68
|
-
const close = () => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
const close = async () => {
|
|
71
|
+
await Promise.all([
|
|
72
|
+
closeCompositor(),
|
|
73
|
+
new Promise((resolve, reject) => {
|
|
74
|
+
destroyConnections();
|
|
75
|
+
server.close((err) => {
|
|
76
|
+
if (err) {
|
|
77
|
+
if (err.code ===
|
|
78
|
+
'ERR_SERVER_NOT_RUNNING') {
|
|
79
|
+
return resolve();
|
|
80
|
+
}
|
|
81
|
+
reject(err);
|
|
76
82
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
});
|
|
83
|
+
else {
|
|
84
|
+
resolve();
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}),
|
|
88
|
+
]);
|
|
84
89
|
};
|
|
85
|
-
return { port: selectedPort, close };
|
|
90
|
+
return { port: selectedPort, close, compositor };
|
|
86
91
|
}
|
|
87
92
|
catch (err) {
|
|
88
93
|
if (!(err instanceof Error)) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Page } from './browser/BrowserPage';
|
|
2
|
-
|
|
3
|
-
inputProps: unknown
|
|
2
|
+
declare type SetPropsAndEnv = {
|
|
3
|
+
inputProps: Record<string, unknown>;
|
|
4
4
|
envVariables: Record<string, string> | undefined;
|
|
5
5
|
page: Page;
|
|
6
6
|
serveUrl: string;
|
|
@@ -10,4 +10,6 @@ export declare const setPropsAndEnv: ({ inputProps, envVariables, page, serveUrl
|
|
|
10
10
|
retriesRemaining: number;
|
|
11
11
|
audioEnabled: boolean;
|
|
12
12
|
videoEnabled: boolean;
|
|
13
|
-
}
|
|
13
|
+
};
|
|
14
|
+
export declare const setPropsAndEnv: (params: SetPropsAndEnv) => Promise<unknown>;
|
|
15
|
+
export {};
|
|
@@ -7,7 +7,7 @@ const normalize_serve_url_1 = require("./normalize-serve-url");
|
|
|
7
7
|
const puppeteer_evaluate_1 = require("./puppeteer-evaluate");
|
|
8
8
|
const redirect_status_codes_1 = require("./redirect-status-codes");
|
|
9
9
|
const validate_puppeteer_timeout_1 = require("./validate-puppeteer-timeout");
|
|
10
|
-
const
|
|
10
|
+
const innerSetPropsAndEnv = async ({ inputProps, envVariables, page, serveUrl, initialFrame, timeoutInMilliseconds, proxyPort, retriesRemaining, audioEnabled, videoEnabled, }) => {
|
|
11
11
|
(0, validate_puppeteer_timeout_1.validatePuppeteerTimeout)(timeoutInMilliseconds);
|
|
12
12
|
const actualTimeout = timeoutInMilliseconds !== null && timeoutInMilliseconds !== void 0 ? timeoutInMilliseconds : TimeoutSettings_1.DEFAULT_TIMEOUT;
|
|
13
13
|
page.setDefaultTimeout(actualTimeout);
|
|
@@ -54,7 +54,7 @@ const setPropsAndEnv = async ({ inputProps, envVariables, page, serveUrl, initia
|
|
|
54
54
|
resolve();
|
|
55
55
|
}, 2000);
|
|
56
56
|
});
|
|
57
|
-
return (
|
|
57
|
+
return innerSetPropsAndEnv({
|
|
58
58
|
envVariables,
|
|
59
59
|
initialFrame,
|
|
60
60
|
inputProps,
|
|
@@ -97,7 +97,7 @@ const setPropsAndEnv = async ({ inputProps, envVariables, page, serveUrl, initia
|
|
|
97
97
|
frame: null,
|
|
98
98
|
page,
|
|
99
99
|
});
|
|
100
|
-
const requiredVersion = '
|
|
100
|
+
const requiredVersion = '5';
|
|
101
101
|
if (siteVersion !== requiredVersion) {
|
|
102
102
|
throw new Error(`Incompatible site: When visiting ${urlToVisit}, a bundle was found, but one that is not compatible with this version of Remotion. Found version: ${siteVersion} - Required version: ${requiredVersion}. To resolve this error, please bundle and deploy again.`);
|
|
103
103
|
}
|
|
@@ -110,4 +110,14 @@ const setPropsAndEnv = async ({ inputProps, envVariables, page, serveUrl, initia
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
};
|
|
113
|
+
const setPropsAndEnv = (params) => {
|
|
114
|
+
return Promise.race([
|
|
115
|
+
innerSetPropsAndEnv(params),
|
|
116
|
+
new Promise((_, reject) => {
|
|
117
|
+
setTimeout(() => {
|
|
118
|
+
reject(new Error('Timed out while setting up the headless browser - the browser seems to not respond. This error is thrown to trigger a retry.'));
|
|
119
|
+
}, 10000);
|
|
120
|
+
}),
|
|
121
|
+
]);
|
|
122
|
+
};
|
|
113
123
|
exports.setPropsAndEnv = setPropsAndEnv;
|