@remotion/bundler 3.0.16 → 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.
- package/dist/error-overlay/remotion-overlay/carets.d.ts +0 -1
- package/dist/get-port.js +6 -1
- package/dist/index-html.d.ts +1 -0
- package/dist/index-html.js +40 -0
- package/dist/is-path-inside.d.ts +1 -0
- package/dist/is-path-inside.js +27 -0
- package/dist/p-limit.d.ts +1 -0
- package/dist/p-limit.js +57 -0
- package/dist/renderEntry.js +20 -14
- package/dist/routes.d.ts +2 -0
- package/dist/routes.js +121 -0
- package/dist/serve-static.d.ts +9 -0
- package/dist/serve-static.js +81 -0
- package/dist/start-server-pure.d.ts +8 -0
- package/dist/start-server-pure.js +68 -0
- package/dist/ts-alias-plugin.d.ts +4 -0
- package/dist/ts-alias-plugin.js +21 -0
- package/dist/webpack-config.js +0 -6
- package/package.json +3 -5
package/dist/get-port.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getDesiredPort = void 0;
|
|
7
7
|
const net_1 = __importDefault(require("net"));
|
|
8
|
+
const p_limit_1 = require("./p-limit");
|
|
8
9
|
const getAvailablePort = (portToTry) => new Promise((resolve) => {
|
|
9
10
|
let status = 'unavailable';
|
|
10
11
|
const host = '127.0.0.1';
|
|
@@ -40,7 +41,7 @@ const getPort = async (from, to) => {
|
|
|
40
41
|
}
|
|
41
42
|
throw new Error('No available ports found');
|
|
42
43
|
};
|
|
43
|
-
const
|
|
44
|
+
const getDesiredPortUnlimited = async (desiredPort, from, to) => {
|
|
44
45
|
if (typeof desiredPort !== 'undefined' &&
|
|
45
46
|
(await getAvailablePort(desiredPort)) === 'available') {
|
|
46
47
|
return desiredPort;
|
|
@@ -52,6 +53,10 @@ const getDesiredPort = async (desiredPort, from, to) => {
|
|
|
52
53
|
}
|
|
53
54
|
return actualPort;
|
|
54
55
|
};
|
|
56
|
+
const limit = (0, p_limit_1.pLimit)(1);
|
|
57
|
+
const getDesiredPort = (desiredPort, from, to) => {
|
|
58
|
+
return limit(getDesiredPortUnlimited, desiredPort, from, to);
|
|
59
|
+
};
|
|
55
60
|
exports.getDesiredPort = getDesiredPort;
|
|
56
61
|
const makeRange = (from, to) => {
|
|
57
62
|
if (!Number.isInteger(from) || !Number.isInteger(to)) {
|
|
@@ -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 @@
|
|
|
1
|
+
export declare const pLimit: (concurrency: number) => <Arguments extends unknown[], ReturnType_1>(fn: (..._arguments: Arguments) => ReturnType_1 | PromiseLike<ReturnType_1>, ...args: Arguments) => Promise<ReturnType_1>;
|
package/dist/p-limit.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pLimit = void 0;
|
|
4
|
+
const pLimit = (concurrency) => {
|
|
5
|
+
const queue = [];
|
|
6
|
+
let activeCount = 0;
|
|
7
|
+
const next = () => {
|
|
8
|
+
var _a;
|
|
9
|
+
activeCount--;
|
|
10
|
+
if (queue.length > 0) {
|
|
11
|
+
(_a = queue.shift()) === null || _a === void 0 ? void 0 : _a();
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const run = async (fn, resolve, ...args) => {
|
|
15
|
+
activeCount++;
|
|
16
|
+
// eslint-disable-next-line require-await
|
|
17
|
+
const result = (async () => fn(...args))();
|
|
18
|
+
resolve(result);
|
|
19
|
+
try {
|
|
20
|
+
await result;
|
|
21
|
+
}
|
|
22
|
+
catch (_a) { }
|
|
23
|
+
next();
|
|
24
|
+
};
|
|
25
|
+
const enqueue = (fn, resolve, ...args) => {
|
|
26
|
+
queue.push(() => run(fn, resolve, ...args));
|
|
27
|
+
(async () => {
|
|
28
|
+
var _a;
|
|
29
|
+
// This function needs to wait until the next microtask before comparing
|
|
30
|
+
// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously
|
|
31
|
+
// when the run function is dequeued and called. The comparison in the if-statement
|
|
32
|
+
// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.
|
|
33
|
+
await Promise.resolve();
|
|
34
|
+
if (activeCount < concurrency && queue.length > 0) {
|
|
35
|
+
(_a = queue.shift()) === null || _a === void 0 ? void 0 : _a();
|
|
36
|
+
}
|
|
37
|
+
})();
|
|
38
|
+
};
|
|
39
|
+
const generator = (fn, ...args) => new Promise((resolve) => {
|
|
40
|
+
enqueue(fn, resolve, ...args);
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperties(generator, {
|
|
43
|
+
activeCount: {
|
|
44
|
+
get: () => activeCount,
|
|
45
|
+
},
|
|
46
|
+
pendingCount: {
|
|
47
|
+
get: () => queue.length,
|
|
48
|
+
},
|
|
49
|
+
clearQueue: {
|
|
50
|
+
value: () => {
|
|
51
|
+
queue.length = 0;
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
return generator;
|
|
56
|
+
};
|
|
57
|
+
exports.pLimit = pLimit;
|
package/dist/renderEntry.js
CHANGED
|
@@ -20,18 +20,11 @@ if (!Root) {
|
|
|
20
20
|
throw new Error('Root has not been registered.');
|
|
21
21
|
}
|
|
22
22
|
const handle = (0, remotion_1.delayRender)('Loading root component');
|
|
23
|
-
const Fallback = () => {
|
|
24
|
-
(0, react_1.useEffect)(() => {
|
|
25
|
-
const fallback = (0, remotion_1.delayRender)('Waiting for Root component to unsuspend');
|
|
26
|
-
return () => (0, remotion_1.continueRender)(fallback);
|
|
27
|
-
}, []);
|
|
28
|
-
return null;
|
|
29
|
-
};
|
|
30
23
|
const GetVideo = ({ state }) => {
|
|
31
|
-
var _a;
|
|
32
24
|
const video = remotion_1.Internals.useVideo();
|
|
33
25
|
const compositions = (0, react_1.useContext)(remotion_1.Internals.CompositionManager);
|
|
34
26
|
const [Component, setComponent] = (0, react_1.useState)(null);
|
|
27
|
+
const portalContainer = (0, react_1.useRef)(null);
|
|
35
28
|
(0, react_1.useEffect)(() => {
|
|
36
29
|
var _a;
|
|
37
30
|
if (state.type !== 'composition') {
|
|
@@ -65,15 +58,28 @@ const GetVideo = ({ state }) => {
|
|
|
65
58
|
(0, remotion_1.continueRender)(handle);
|
|
66
59
|
}
|
|
67
60
|
}, [Component, state.type]);
|
|
61
|
+
(0, react_1.useEffect)(() => {
|
|
62
|
+
if (!video) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const { current } = portalContainer;
|
|
66
|
+
if (!current) {
|
|
67
|
+
throw new Error('portal did not render');
|
|
68
|
+
}
|
|
69
|
+
current.appendChild(remotion_1.Internals.portalNode());
|
|
70
|
+
return () => {
|
|
71
|
+
current.removeChild(remotion_1.Internals.portalNode());
|
|
72
|
+
};
|
|
73
|
+
}, [video]);
|
|
68
74
|
if (!video) {
|
|
69
75
|
return null;
|
|
70
76
|
}
|
|
71
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: portalContainer, id: "remotion-canvas", style: {
|
|
78
|
+
width: video.width,
|
|
79
|
+
height: video.height,
|
|
80
|
+
display: 'flex',
|
|
81
|
+
backgroundColor: 'transparent',
|
|
82
|
+
} }));
|
|
77
83
|
};
|
|
78
84
|
const videoContainer = document.getElementById('video-container');
|
|
79
85
|
const explainerContainer = document.getElementById('explainer-container');
|
package/dist/routes.d.ts
ADDED
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;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.myPlugin = void 0;
|
|
4
|
+
// tsc-helpers.js
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const tsconfig = require('../../tsconfig.json');
|
|
7
|
+
const fixBaseUrl = (importPath) => importPath.startsWith('./')
|
|
8
|
+
? importPath
|
|
9
|
+
: // Assumption: this is an aliased import
|
|
10
|
+
// Read tsconfig directly to avoid any drift
|
|
11
|
+
path.join(tsconfig.compilerOptions.baseUrl, importPath);
|
|
12
|
+
// some-plugin.js
|
|
13
|
+
exports.myPlugin = {
|
|
14
|
+
name: 'my-plugin',
|
|
15
|
+
setup: (build) => {
|
|
16
|
+
build.onResolve({ filter: /(.*)/ }, async (args) => {
|
|
17
|
+
args.path = fixBaseUrl(args.path);
|
|
18
|
+
// 🍕 delicious
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
};
|
package/dist/webpack-config.js
CHANGED
|
@@ -179,14 +179,8 @@ const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpa
|
|
|
179
179
|
: null,
|
|
180
180
|
].filter(truthy),
|
|
181
181
|
},
|
|
182
|
-
{
|
|
183
|
-
test: /\.js$/,
|
|
184
|
-
enforce: 'pre',
|
|
185
|
-
use: [require.resolve('source-map-loader')],
|
|
186
|
-
},
|
|
187
182
|
],
|
|
188
183
|
},
|
|
189
|
-
ignoreWarnings: [/Failed to parse source map/],
|
|
190
184
|
});
|
|
191
185
|
};
|
|
192
186
|
exports.webpackConfig = webpackConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/bundler",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.19",
|
|
4
4
|
"description": "Bundler for Remotion",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -26,15 +26,13 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"css-loader": "5.2.7",
|
|
28
28
|
"esbuild": "0.14.19",
|
|
29
|
-
"execa": "5.1.1",
|
|
30
29
|
"express": "4.17.1",
|
|
31
30
|
"memfs": "3.4.3",
|
|
32
31
|
"mime-types": "2.1.34",
|
|
33
32
|
"react-refresh": "0.9.0",
|
|
34
|
-
"remotion": "3.0.
|
|
33
|
+
"remotion": "3.0.19",
|
|
35
34
|
"semver": "7.3.4",
|
|
36
35
|
"source-map": "0.6.1",
|
|
37
|
-
"source-map-loader": "3.0.0",
|
|
38
36
|
"style-loader": "2.0.0",
|
|
39
37
|
"webpack": "5.72.0"
|
|
40
38
|
},
|
|
@@ -77,5 +75,5 @@
|
|
|
77
75
|
"publishConfig": {
|
|
78
76
|
"access": "public"
|
|
79
77
|
},
|
|
80
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "388ef0a2eacf9dbadbc860fdb8d6b3e32acb10f3"
|
|
81
79
|
}
|