@remotion/bundler 4.0.0-oops.3 → 4.0.0-publish.10
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/bundle-mode.d.ts +1 -1
- package/dist/bundle.d.ts +7 -0
- package/dist/bundle.js +77 -0
- package/dist/dev-middleware/compatible-api.d.ts +1 -0
- package/dist/dev-middleware/is-color-supported.js +5 -1
- package/dist/error-overlay/react-overlay/utils/open-in-editor.js +5 -1
- package/dist/error-overlay/remotion-overlay/AskOnDiscord.js +1 -1
- package/dist/error-overlay/remotion-overlay/Button.js +1 -1
- package/dist/error-overlay/remotion-overlay/CodeFrame.js +2 -2
- package/dist/error-overlay/remotion-overlay/DismissButton.js +1 -1
- package/dist/error-overlay/remotion-overlay/ErrorDisplay.js +2 -2
- package/dist/error-overlay/remotion-overlay/ErrorLoader.js +4 -4
- package/dist/error-overlay/remotion-overlay/ErrorTitle.js +1 -1
- package/dist/error-overlay/remotion-overlay/OpenInEditor.js +1 -1
- package/dist/error-overlay/remotion-overlay/Overlay.js +1 -1
- package/dist/error-overlay/remotion-overlay/SearchGitHubIssues.js +1 -1
- package/dist/error-overlay/remotion-overlay/StackFrame.js +2 -2
- package/dist/error-overlay/remotion-overlay/Symbolicating.js +1 -1
- package/dist/error-overlay/remotion-overlay/carets.js +2 -2
- package/dist/error-overlay/remotion-overlay/index.js +2 -2
- package/dist/esbuild-loader/index.d.ts +2 -2
- package/dist/esbuild-loader/index.js +1 -0
- package/dist/esbuild-loader/interfaces.d.ts +1 -1
- package/dist/fast-refresh/index.d.ts +1 -1
- package/dist/fast-refresh/index.js +0 -27
- package/dist/fast-refresh/loader.d.ts +1 -1
- package/dist/get-port.js +26 -24
- package/dist/homepage/homepage.d.ts +0 -1
- package/dist/homepage/homepage.js +5 -6
- package/dist/hot-middleware/process-update.js +2 -2
- package/dist/index-html.d.ts +1 -0
- package/dist/index-html.js +40 -0
- package/dist/index.d.ts +18 -19
- package/dist/index.js +10 -16
- 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.d.ts +1 -1
- package/dist/renderEntry.js +51 -38
- 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/setup-environment.js +0 -1
- package/dist/start-server-pure.d.ts +8 -0
- package/dist/start-server-pure.js +68 -0
- package/dist/start-server.d.ts +6 -6
- package/dist/start-server.js +4 -4
- package/dist/ts-alias-plugin.d.ts +4 -0
- package/dist/ts-alias-plugin.js +21 -0
- package/dist/webpack-config.d.ts +3 -2
- package/dist/webpack-config.js +11 -21
- package/package.json +5 -19
- package/web/favicon.png +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import mimeTypes from 'mime-types';
|
|
2
1
|
import esbuild = require('esbuild');
|
|
2
|
+
import webpack = require('webpack');
|
|
3
3
|
export declare const BundlerInternals: {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
esbuild: typeof esbuild;
|
|
5
|
+
webpackConfig: ({ entry, userDefinedComponent, outDir, environment, webpackOverride, onProgressUpdate, enableCaching, inputProps, envVariables, maxTimelineTracks, entryPoints, }: {
|
|
6
|
+
entry: string;
|
|
7
|
+
userDefinedComponent: string;
|
|
8
|
+
outDir: string;
|
|
9
|
+
environment: "development" | "production";
|
|
10
|
+
webpackOverride: import("remotion").WebpackOverrideFn;
|
|
11
|
+
onProgressUpdate?: ((f: number) => void) | undefined;
|
|
12
|
+
enableCaching?: boolean | undefined;
|
|
13
|
+
inputProps: object;
|
|
14
|
+
envVariables: Record<string, string>;
|
|
15
|
+
maxTimelineTracks: number;
|
|
16
|
+
entryPoints: string[];
|
|
17
|
+
}) => webpack.Configuration;
|
|
18
|
+
indexHtml: (staticHash: string, baseDir: string, editorName: string | null) => string;
|
|
11
19
|
cacheExists: (environment: "development" | "production", inputProps: object | null) => boolean;
|
|
12
20
|
clearCache: (environment: "development" | "production", inputProps: object | null) => Promise<void>;
|
|
13
|
-
getLatestRemotionVersion: () => Promise<any>;
|
|
14
|
-
getPackageManager: () => import("./get-package-manager").PackageManager | "unknown";
|
|
15
|
-
lockFilePaths: {
|
|
16
|
-
manager: import("./get-package-manager").PackageManager;
|
|
17
|
-
path: string;
|
|
18
|
-
}[];
|
|
19
|
-
esbuild: typeof esbuild;
|
|
20
|
-
mimeTypes: typeof mimeTypes;
|
|
21
21
|
};
|
|
22
|
-
export { bundle } from './
|
|
23
|
-
export {
|
|
24
|
-
export type { ProjectInfo } from './project-info';
|
|
22
|
+
export { bundle } from './bundle';
|
|
23
|
+
export { webpack };
|
package/dist/index.js
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.bundle = exports.BundlerInternals = void 0;
|
|
7
|
-
const
|
|
8
|
-
const get_latest_remotion_version_1 = require("./get-latest-remotion-version");
|
|
9
|
-
const get_package_manager_1 = require("./get-package-manager");
|
|
10
|
-
const start_server_1 = require("./start-server");
|
|
3
|
+
exports.webpack = exports.bundle = exports.BundlerInternals = void 0;
|
|
4
|
+
const index_html_1 = require("./index-html");
|
|
11
5
|
const webpack_cache_1 = require("./webpack-cache");
|
|
6
|
+
const webpack_config_1 = require("./webpack-config");
|
|
12
7
|
const esbuild = require("esbuild");
|
|
8
|
+
const webpack = require("webpack");
|
|
9
|
+
exports.webpack = webpack;
|
|
13
10
|
exports.BundlerInternals = {
|
|
14
|
-
|
|
11
|
+
esbuild,
|
|
12
|
+
webpackConfig: webpack_config_1.webpackConfig,
|
|
13
|
+
indexHtml: index_html_1.indexHtml,
|
|
15
14
|
cacheExists: webpack_cache_1.cacheExists,
|
|
16
15
|
clearCache: webpack_cache_1.clearCache,
|
|
17
|
-
getLatestRemotionVersion: get_latest_remotion_version_1.getLatestRemotionVersion,
|
|
18
|
-
getPackageManager: get_package_manager_1.getPackageManager,
|
|
19
|
-
lockFilePaths: get_package_manager_1.lockFilePaths,
|
|
20
|
-
esbuild,
|
|
21
|
-
mimeTypes: mime_types_1.default,
|
|
22
16
|
};
|
|
23
|
-
var
|
|
24
|
-
Object.defineProperty(exports, "bundle", { enumerable: true, get: function () { return
|
|
17
|
+
var bundle_1 = require("./bundle");
|
|
18
|
+
Object.defineProperty(exports, "bundle", { enumerable: true, get: function () { return bundle_1.bundle; } });
|
|
@@ -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.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BundleState } from 'remotion';
|
|
1
|
+
import type { BundleState } from 'remotion';
|
|
2
2
|
export declare const setBundleModeAndUpdate: (state: BundleState) => void;
|
package/dist/renderEntry.js
CHANGED
|
@@ -15,23 +15,14 @@ const remotion_1 = require("remotion");
|
|
|
15
15
|
const bundle_mode_1 = require("./bundle-mode");
|
|
16
16
|
const homepage_1 = require("./homepage/homepage");
|
|
17
17
|
remotion_1.Internals.CSSUtils.injectCSS(remotion_1.Internals.CSSUtils.makeDefaultCSS(null, '#fff'));
|
|
18
|
-
const Root = remotion_1.Internals.getRoot();
|
|
19
|
-
if (!Root) {
|
|
20
|
-
throw new Error('Root has not been registered.');
|
|
21
|
-
}
|
|
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
18
|
const GetVideo = ({ state }) => {
|
|
31
|
-
var _a;
|
|
32
19
|
const video = remotion_1.Internals.useVideo();
|
|
33
20
|
const compositions = (0, react_1.useContext)(remotion_1.Internals.CompositionManager);
|
|
34
|
-
const
|
|
21
|
+
const portalContainer = (0, react_1.useRef)(null);
|
|
22
|
+
const [handle] = (0, react_1.useState)(() => (0, remotion_1.delayRender)('Wait for Composition' + JSON.stringify(state)));
|
|
23
|
+
(0, react_1.useEffect)(() => {
|
|
24
|
+
return () => (0, remotion_1.continueRender)(handle);
|
|
25
|
+
}, [handle]);
|
|
35
26
|
(0, react_1.useEffect)(() => {
|
|
36
27
|
var _a;
|
|
37
28
|
if (state.type !== 'composition') {
|
|
@@ -45,35 +36,36 @@ const GetVideo = ({ state }) => {
|
|
|
45
36
|
compositions.setCurrentComposition((_a = foundComposition === null || foundComposition === void 0 ? void 0 : foundComposition.id) !== null && _a !== void 0 ? _a : null);
|
|
46
37
|
}
|
|
47
38
|
}, [compositions, compositions.compositions, state, video]);
|
|
48
|
-
const fetchComponent = (0, react_1.useCallback)(() => {
|
|
49
|
-
if (!video) {
|
|
50
|
-
throw new Error('Expected to have video');
|
|
51
|
-
}
|
|
52
|
-
const Comp = video.component;
|
|
53
|
-
setComponent(Comp);
|
|
54
|
-
}, [video]);
|
|
55
|
-
(0, react_1.useEffect)(() => {
|
|
56
|
-
if (video) {
|
|
57
|
-
fetchComponent();
|
|
58
|
-
}
|
|
59
|
-
}, [fetchComponent, video]);
|
|
60
39
|
(0, react_1.useEffect)(() => {
|
|
61
40
|
if (state.type === 'evaluation') {
|
|
62
41
|
(0, remotion_1.continueRender)(handle);
|
|
63
42
|
}
|
|
64
|
-
else if (
|
|
43
|
+
else if (video) {
|
|
65
44
|
(0, remotion_1.continueRender)(handle);
|
|
66
45
|
}
|
|
67
|
-
}, [
|
|
46
|
+
}, [handle, state.type, video]);
|
|
47
|
+
(0, react_1.useEffect)(() => {
|
|
48
|
+
if (!video) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const { current } = portalContainer;
|
|
52
|
+
if (!current) {
|
|
53
|
+
throw new Error('portal did not render');
|
|
54
|
+
}
|
|
55
|
+
current.appendChild(remotion_1.Internals.portalNode());
|
|
56
|
+
return () => {
|
|
57
|
+
current.removeChild(remotion_1.Internals.portalNode());
|
|
58
|
+
};
|
|
59
|
+
}, [video]);
|
|
68
60
|
if (!video) {
|
|
69
61
|
return null;
|
|
70
62
|
}
|
|
71
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
63
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: portalContainer, id: "remotion-canvas", style: {
|
|
64
|
+
width: video.width,
|
|
65
|
+
height: video.height,
|
|
66
|
+
display: 'flex',
|
|
67
|
+
backgroundColor: 'transparent',
|
|
68
|
+
} }));
|
|
77
69
|
};
|
|
78
70
|
const videoContainer = document.getElementById('video-container');
|
|
79
71
|
const explainerContainer = document.getElementById('explainer-container');
|
|
@@ -83,10 +75,28 @@ let cleanupVideoContainer = () => {
|
|
|
83
75
|
let cleanupExplainerContainer = () => {
|
|
84
76
|
explainerContainer.innerHTML = '';
|
|
85
77
|
};
|
|
78
|
+
const waitForRootHandle = (0, remotion_1.delayRender)('Loading root component');
|
|
79
|
+
const WaitForRoot = () => {
|
|
80
|
+
const [Root, setRoot] = (0, react_1.useState)(() => remotion_1.Internals.getRoot());
|
|
81
|
+
(0, react_1.useEffect)(() => {
|
|
82
|
+
if (Root) {
|
|
83
|
+
(0, remotion_1.continueRender)(waitForRootHandle);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const cleanup = remotion_1.Internals.waitForRoot((NewRoot) => {
|
|
87
|
+
setRoot(() => NewRoot);
|
|
88
|
+
});
|
|
89
|
+
return () => cleanup();
|
|
90
|
+
}, [Root]);
|
|
91
|
+
if (Root === null) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
return (0, jsx_runtime_1.jsx)(Root, {});
|
|
95
|
+
};
|
|
86
96
|
const renderContent = () => {
|
|
87
97
|
const bundleMode = (0, bundle_mode_1.getBundleMode)();
|
|
88
98
|
if (bundleMode.type === 'composition' || bundleMode.type === 'evaluation') {
|
|
89
|
-
const markup = ((0, jsx_runtime_1.jsxs)(remotion_1.Internals.RemotionRoot, { children: [(0, jsx_runtime_1.jsx)(
|
|
99
|
+
const markup = ((0, jsx_runtime_1.jsxs)(remotion_1.Internals.RemotionRoot, { children: [(0, jsx_runtime_1.jsx)(WaitForRoot, {}), (0, jsx_runtime_1.jsx)(GetVideo, { state: bundleMode })] }));
|
|
90
100
|
if (client_1.default.createRoot) {
|
|
91
101
|
const root = client_1.default.createRoot(videoContainer);
|
|
92
102
|
root.render(markup);
|
|
@@ -110,14 +120,14 @@ const renderContent = () => {
|
|
|
110
120
|
if (bundleMode.type === 'index' || bundleMode.type === 'evaluation') {
|
|
111
121
|
if (client_1.default.createRoot) {
|
|
112
122
|
const root = client_1.default.createRoot(explainerContainer);
|
|
113
|
-
root.render((0, jsx_runtime_1.jsx)(homepage_1.Homepage, {}
|
|
123
|
+
root.render((0, jsx_runtime_1.jsx)(homepage_1.Homepage, {}));
|
|
114
124
|
cleanupExplainerContainer = () => {
|
|
115
125
|
root.unmount();
|
|
116
126
|
};
|
|
117
127
|
}
|
|
118
128
|
else {
|
|
119
129
|
const root = client_1.default;
|
|
120
|
-
root.render((0, jsx_runtime_1.jsx)(homepage_1.Homepage, {}
|
|
130
|
+
root.render((0, jsx_runtime_1.jsx)(homepage_1.Homepage, {}), explainerContainer);
|
|
121
131
|
cleanupExplainerContainer = () => {
|
|
122
132
|
root.unmountComponentAtNode(explainerContainer);
|
|
123
133
|
};
|
|
@@ -138,6 +148,9 @@ const setBundleModeAndUpdate = (state) => {
|
|
|
138
148
|
exports.setBundleModeAndUpdate = setBundleModeAndUpdate;
|
|
139
149
|
if (typeof window !== 'undefined') {
|
|
140
150
|
window.getStaticCompositions = () => {
|
|
151
|
+
if (!remotion_1.Internals.getRoot()) {
|
|
152
|
+
throw new Error('registerRoot() was never called. 1. Make sure you specified the correct entrypoint for your bundle. 2. If your registerRoot() call is deferred, use the delayRender/continueRender pattern to tell Remotion to wait.');
|
|
153
|
+
}
|
|
141
154
|
if (!remotion_1.Internals.compositionsRef.current) {
|
|
142
155
|
throw new Error('Unexpectedly did not have a CompositionManager');
|
|
143
156
|
}
|
|
@@ -154,6 +167,6 @@ if (typeof window !== 'undefined') {
|
|
|
154
167
|
};
|
|
155
168
|
});
|
|
156
169
|
};
|
|
157
|
-
window.siteVersion = '
|
|
170
|
+
window.siteVersion = '3';
|
|
158
171
|
window.setBundleMode = exports.setBundleModeAndUpdate;
|
|
159
172
|
}
|
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;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const remotion_1 = require("remotion");
|
|
4
4
|
remotion_1.Internals.setupEnvVariables();
|
|
5
|
-
remotion_1.Internals.setupInitialFrame();
|
|
6
5
|
remotion_1.Internals.setupPuppeteerTimeout();
|
|
7
6
|
remotion_1.Internals.CSSUtils.injectCSS(`
|
|
8
7
|
.css-reset * {
|
|
@@ -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/dist/start-server.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { WebpackOverrideFn } from 'remotion';
|
|
2
2
|
export declare const startServer: (entry: string, userDefinedComponent: string, options?: {
|
|
3
|
-
webpackOverride?: WebpackOverrideFn
|
|
4
|
-
inputProps?: object
|
|
5
|
-
envVariables?: Record<string, string
|
|
6
|
-
port
|
|
7
|
-
maxTimelineTracks?: number
|
|
8
|
-
}
|
|
3
|
+
webpackOverride?: WebpackOverrideFn;
|
|
4
|
+
inputProps?: object;
|
|
5
|
+
envVariables?: Record<string, string>;
|
|
6
|
+
port: number | null;
|
|
7
|
+
maxTimelineTracks?: number;
|
|
8
|
+
}) => Promise<number>;
|