@remotion/bundler 3.0.18 → 3.0.19

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 @@
1
+ export declare const indexHtml: (staticHash: string, baseDir: string, editorName: string | null) => string;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.indexHtml = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const indexHtml = (staticHash, baseDir, editorName) => `
9
+ <!DOCTYPE html>
10
+ <html lang="en">
11
+ <head>
12
+ <meta charset="UTF-8" />
13
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
14
+ <link rel="preconnect" href="https://fonts.gstatic.com" />
15
+ <link rel="icon" type="image/png" href="/remotion.png" />
16
+ <title>Remotion Preview</title>
17
+ </head>
18
+ <body>
19
+ <script>window.remotion_staticBase = "${staticHash}";</script>
20
+ <div id="video-container"></div>
21
+ <div id="explainer-container"></div>
22
+ ${editorName
23
+ ? `<script>window.remotion_editorName = "${editorName}";</script>`
24
+ : '<script>window.remotion_editorName = null;</script>'}
25
+ <script>window.remotion_projectName = ${JSON.stringify(path_1.default.basename(process.cwd()))};</script>
26
+ <script>window.remotion_cwd = ${JSON.stringify(process.cwd())};</script>
27
+
28
+ <div id="container"></div>
29
+ <div id="menuportal-0"></div>
30
+ <div id="menuportal-1"></div>
31
+ <div id="menuportal-2"></div>
32
+ <div id="menuportal-3"></div>
33
+ <div id="menuportal-4"></div>
34
+ <div id="menuportal-5"></div>
35
+ <div id="remotion-error-overlay"></div>
36
+ <script src="${baseDir}bundle.js"></script>
37
+ </body>
38
+ </html>
39
+ `.trim();
40
+ exports.indexHtml = indexHtml;
@@ -0,0 +1 @@
1
+ export declare const isPathInside: (thePath: string, potentialParent: string) => boolean;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isPathInside = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const isPathInside = function (thePath, potentialParent) {
9
+ // For inside-directory checking, we want to allow trailing slashes, so normalize.
10
+ thePath = stripTrailingSep(thePath);
11
+ potentialParent = stripTrailingSep(potentialParent);
12
+ // Node treats only Windows as case-insensitive in its path module; we follow those conventions.
13
+ if (process.platform === 'win32') {
14
+ thePath = thePath.toLowerCase();
15
+ potentialParent = potentialParent.toLowerCase();
16
+ }
17
+ return (thePath.lastIndexOf(potentialParent, 0) === 0 &&
18
+ (thePath[potentialParent.length] === path_1.default.sep ||
19
+ thePath[potentialParent.length] === undefined));
20
+ };
21
+ exports.isPathInside = isPathInside;
22
+ function stripTrailingSep(thePath) {
23
+ if (thePath[thePath.length - 1] === path_1.default.sep) {
24
+ return thePath.slice(0, -1);
25
+ }
26
+ return thePath;
27
+ }
@@ -0,0 +1,2 @@
1
+ import { IncomingMessage, ServerResponse } from 'http';
2
+ export declare const handleRoutes: (hash: string, request: IncomingMessage, response: ServerResponse) => void | Promise<void>;
package/dist/routes.js ADDED
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.handleRoutes = void 0;
7
+ const fs_1 = require("fs");
8
+ const path_1 = __importDefault(require("path"));
9
+ const url_1 = require("url");
10
+ const get_file_source_1 = require("./error-overlay/react-overlay/utils/get-file-source");
11
+ const open_in_editor_1 = require("./error-overlay/react-overlay/utils/open-in-editor");
12
+ const project_info_1 = require("./project-info");
13
+ const serve_static_1 = require("./serve-static");
14
+ const static_preview_1 = require("./static-preview");
15
+ const update_available_1 = require("./update-available");
16
+ const handleUpdate = async (_, response) => {
17
+ const data = await (0, update_available_1.isUpdateAvailableWithTimeout)();
18
+ response.setHeader('content-type', 'application/json');
19
+ response.writeHead(200);
20
+ response.end(JSON.stringify(data));
21
+ };
22
+ const editorGuess = (0, open_in_editor_1.guessEditor)();
23
+ const handleFallback = async (hash, _, response) => {
24
+ const edit = await editorGuess;
25
+ const displayName = (0, open_in_editor_1.getDisplayNameForEditor)(edit[0]);
26
+ response.setHeader('content-type', 'text/html');
27
+ response.writeHead(200);
28
+ response.end((0, static_preview_1.indexHtml)(hash, '/', displayName));
29
+ };
30
+ const handleProjectInfo = async (_, response) => {
31
+ const data = await (0, project_info_1.getProjectInfo)();
32
+ response.setHeader('content-type', 'application/json');
33
+ response.writeHead(200);
34
+ response.end(JSON.stringify(data));
35
+ };
36
+ const handleFileSource = async (search, _, response) => {
37
+ if (!search.startsWith('?')) {
38
+ throw new Error('query must start with ?');
39
+ }
40
+ const query = new url_1.URLSearchParams(search);
41
+ const f = query.get('f');
42
+ if (typeof f !== 'string') {
43
+ throw new Error('must pass `f` parameter');
44
+ }
45
+ const data = await (0, get_file_source_1.getFileSource)(decodeURIComponent(f));
46
+ response.writeHead(200);
47
+ response.write(data);
48
+ return response.end();
49
+ };
50
+ const handleOpenInEditor = async (req, res) => {
51
+ try {
52
+ const b = await new Promise((_resolve) => {
53
+ let data = '';
54
+ req.on('data', (chunk) => {
55
+ data += chunk;
56
+ });
57
+ req.on('end', () => {
58
+ _resolve(data.toString());
59
+ });
60
+ });
61
+ const body = JSON.parse(b);
62
+ if (!('stack' in body)) {
63
+ throw new TypeError('Need to pass stack');
64
+ }
65
+ const stack = body.stack;
66
+ const guess = await editorGuess;
67
+ const didOpen = await (0, open_in_editor_1.launchEditor)({
68
+ colNumber: stack.originalColumnNumber,
69
+ editor: guess[0],
70
+ fileName: path_1.default.resolve(process.cwd(), stack.originalFileName),
71
+ lineNumber: stack.originalLineNumber,
72
+ vsCodeNewWindow: false,
73
+ });
74
+ res.setHeader('content-type', 'application/json');
75
+ res.writeHead(200);
76
+ res.end(JSON.stringify({
77
+ success: didOpen,
78
+ }));
79
+ }
80
+ catch (err) {
81
+ res.setHeader('content-type', 'application/json');
82
+ res.writeHead(200);
83
+ res.end(JSON.stringify({
84
+ success: false,
85
+ }));
86
+ }
87
+ };
88
+ const handleFavicon = (_, response) => {
89
+ const filePath = path_1.default.join(__dirname, '..', 'web', 'favicon.png');
90
+ const stat = (0, fs_1.statSync)(filePath);
91
+ response.writeHead(200, {
92
+ 'Content-Type': 'image/png',
93
+ 'Content-Length': stat.size,
94
+ });
95
+ const readStream = (0, fs_1.createReadStream)(filePath);
96
+ readStream.pipe(response);
97
+ };
98
+ const handleRoutes = (hash, request, response) => {
99
+ const url = new URL(request.url, 'http://localhost');
100
+ if (url.pathname === '/api/update') {
101
+ return handleUpdate(request, response);
102
+ }
103
+ if (url.pathname === '/api/project-info') {
104
+ return handleProjectInfo(request, response);
105
+ }
106
+ if (url.pathname === '/api/file-source') {
107
+ return handleFileSource(url.search, request, response);
108
+ }
109
+ if (url.pathname === '/api/open-in-editor') {
110
+ return handleOpenInEditor(request, response);
111
+ }
112
+ if (url.pathname === '/remotion.png') {
113
+ return handleFavicon(request, response);
114
+ }
115
+ if (url.pathname.startsWith(hash)) {
116
+ const root = path_1.default.join(process.cwd(), 'public');
117
+ return (0, serve_static_1.serveStatic)(root, hash, request, response);
118
+ }
119
+ return handleFallback(hash, request, response);
120
+ };
121
+ exports.handleRoutes = handleRoutes;
@@ -0,0 +1,9 @@
1
+ /*!
2
+ * serve-static
3
+ * Copyright(c) 2010 Sencha Inc.
4
+ * Copyright(c) 2011 TJ Holowaychuk
5
+ * Copyright(c) 2014-2016 Douglas Christopher Wilson
6
+ * MIT Licensed
7
+ */
8
+ import { IncomingMessage, ServerResponse } from 'http';
9
+ export declare const serveStatic: (root: string, hash: string, req: IncomingMessage, res: ServerResponse) => Promise<void>;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ /*!
3
+ * serve-static
4
+ * Copyright(c) 2010 Sencha Inc.
5
+ * Copyright(c) 2011 TJ Holowaychuk
6
+ * Copyright(c) 2014-2016 Douglas Christopher Wilson
7
+ * MIT Licensed
8
+ */
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.serveStatic = void 0;
14
+ const fs_1 = require("fs");
15
+ const mime_types_1 = __importDefault(require("mime-types"));
16
+ const path_1 = require("path");
17
+ const middleware_1 = require("./dev-middleware/middleware");
18
+ const range_parser_1 = require("./dev-middleware/range-parser");
19
+ const is_path_inside_1 = require("./is-path-inside");
20
+ const serveStatic = async function (root, hash, req, res) {
21
+ if (req.method !== 'GET' && req.method !== 'HEAD') {
22
+ // method not allowed
23
+ res.statusCode = 405;
24
+ res.setHeader('Allow', 'GET, HEAD');
25
+ res.setHeader('Content-Length', '0');
26
+ res.end();
27
+ return;
28
+ }
29
+ const path = (0, path_1.join)(root, new URL(req.url, 'http://localhost').pathname.replace(new RegExp(`^${hash}`), ''));
30
+ if (!(0, is_path_inside_1.isPathInside)(path, root)) {
31
+ res.writeHead(500);
32
+ res.write('Not allowed to read');
33
+ res.end();
34
+ return;
35
+ }
36
+ const exists = (0, fs_1.existsSync)(path);
37
+ if (!exists) {
38
+ res.writeHead(404);
39
+ res.write('Not found');
40
+ res.end();
41
+ return;
42
+ }
43
+ const lstat = await fs_1.promises.lstat(path);
44
+ const isDirectory = lstat.isDirectory();
45
+ if (isDirectory) {
46
+ res.writeHead(500);
47
+ res.write('Is a directory');
48
+ res.end();
49
+ return;
50
+ }
51
+ const hasRange = req.headers.range && lstat.size;
52
+ if (!hasRange) {
53
+ const readStream = (0, fs_1.createReadStream)(path);
54
+ res.setHeader('content-type', mime_types_1.default.lookup(path) || 'application/octet-stream');
55
+ res.setHeader('content-length', lstat.size);
56
+ res.writeHead(200);
57
+ readStream.pipe(res);
58
+ return;
59
+ }
60
+ const range = (0, range_parser_1.parseRange)(lstat.size, req.headers.range);
61
+ if (typeof range === 'object' && range.type === 'bytes') {
62
+ const { start, end } = range[0];
63
+ res.setHeader('content-type', mime_types_1.default.lookup(path) || 'application/octet-stream');
64
+ res.setHeader('content-range', (0, middleware_1.getValueContentRangeHeader)('bytes', lstat.size, {
65
+ end,
66
+ start,
67
+ }));
68
+ res.setHeader('content-length', end - start + 1);
69
+ res.writeHead(206);
70
+ const readStream = (0, fs_1.createReadStream)(path, {
71
+ start,
72
+ end,
73
+ });
74
+ readStream.pipe(res);
75
+ return;
76
+ }
77
+ res.statusCode = 416;
78
+ res.setHeader('Content-Range', `bytes */${lstat.size}`);
79
+ res.end();
80
+ };
81
+ exports.serveStatic = serveStatic;
@@ -0,0 +1,8 @@
1
+ import { WebpackOverrideFn } from 'remotion';
2
+ export declare const startServerPure: (entry: string, userDefinedComponent: string, options?: {
3
+ webpackOverride?: WebpackOverrideFn;
4
+ inputProps?: object;
5
+ envVariables?: Record<string, string>;
6
+ port: number | null;
7
+ maxTimelineTracks?: number;
8
+ }) => Promise<number>;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.startServerPure = void 0;
7
+ const crypto_1 = __importDefault(require("crypto"));
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const http_1 = __importDefault(require("http"));
10
+ const os_1 = __importDefault(require("os"));
11
+ const path_1 = __importDefault(require("path"));
12
+ const remotion_1 = require("remotion");
13
+ const webpack_1 = __importDefault(require("webpack"));
14
+ const dev_middleware_1 = require("./dev-middleware");
15
+ const get_port_1 = require("./get-port");
16
+ const hot_middleware_1 = require("./hot-middleware");
17
+ const routes_1 = require("./routes");
18
+ const webpack_config_1 = require("./webpack-config");
19
+ const startServerPure = async (entry, userDefinedComponent, options) => {
20
+ var _a, _b, _c, _d, _e;
21
+ const tmpDir = await fs_1.default.promises.mkdtemp(path_1.default.join(os_1.default.tmpdir(), 'react-motion-graphics'));
22
+ const config = (0, webpack_config_1.webpackConfig)({
23
+ entry,
24
+ userDefinedComponent,
25
+ outDir: tmpDir,
26
+ environment: 'development',
27
+ webpackOverride: (_a = options === null || options === void 0 ? void 0 : options.webpackOverride) !== null && _a !== void 0 ? _a : remotion_1.Internals.getWebpackOverrideFn(),
28
+ inputProps: (_b = options === null || options === void 0 ? void 0 : options.inputProps) !== null && _b !== void 0 ? _b : {},
29
+ envVariables: (_c = options === null || options === void 0 ? void 0 : options.envVariables) !== null && _c !== void 0 ? _c : {},
30
+ maxTimelineTracks: (_d = options === null || options === void 0 ? void 0 : options.maxTimelineTracks) !== null && _d !== void 0 ? _d : 15,
31
+ });
32
+ const compiler = (0, webpack_1.default)(config);
33
+ const hash = `/static-${crypto_1.default.randomBytes(6).toString('hex')}`;
34
+ /**
35
+ * TODO: Put static server
36
+ */
37
+ const wdmMiddleware = (0, dev_middleware_1.wdm)(compiler);
38
+ const whm = (0, hot_middleware_1.webpackHotMiddleware)(compiler);
39
+ const server = http_1.default.createServer((request, response) => {
40
+ new Promise((resolve) => {
41
+ wdmMiddleware(request, response, () => {
42
+ resolve();
43
+ });
44
+ })
45
+ .then(() => {
46
+ return new Promise((resolve) => {
47
+ whm(request, response, () => {
48
+ resolve();
49
+ });
50
+ });
51
+ })
52
+ .then(() => {
53
+ (0, routes_1.handleRoutes)(hash, request, response);
54
+ })
55
+ .catch((err) => {
56
+ response.setHeader('content-type', 'application/json');
57
+ response.writeHead(500);
58
+ response.end(JSON.stringify({
59
+ err: err.message,
60
+ }));
61
+ });
62
+ });
63
+ const desiredPort = (_e = options === null || options === void 0 ? void 0 : options.port) !== null && _e !== void 0 ? _e : undefined;
64
+ const port = await (0, get_port_1.getDesiredPort)(desiredPort, 3000, 3100);
65
+ server.listen(port);
66
+ return port;
67
+ };
68
+ exports.startServerPure = startServerPure;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/bundler",
3
- "version": "3.0.18",
3
+ "version": "3.0.19",
4
4
  "description": "Bundler for Remotion",
5
5
  "main": "dist/index.js",
6
6
  "sideEffects": false,
@@ -30,7 +30,7 @@
30
30
  "memfs": "3.4.3",
31
31
  "mime-types": "2.1.34",
32
32
  "react-refresh": "0.9.0",
33
- "remotion": "3.0.18",
33
+ "remotion": "3.0.19",
34
34
  "semver": "7.3.4",
35
35
  "source-map": "0.6.1",
36
36
  "style-loader": "2.0.0",
@@ -75,5 +75,5 @@
75
75
  "publishConfig": {
76
76
  "access": "public"
77
77
  },
78
- "gitHead": "64eadd48b303d0f627ed5883f9200345af002ee2"
78
+ "gitHead": "388ef0a2eacf9dbadbc860fdb8d6b3e32acb10f3"
79
79
  }