@remotion/bundler 4.0.89 → 4.0.91
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.js +4 -3
- package/dist/index-html.d.ts +1 -39
- package/dist/index.d.ts +2 -4
- package/dist/optional-dependencies.d.ts +2 -0
- package/dist/optional-dependencies.js +14 -0
- package/dist/webpack-config.d.ts +1 -2
- package/dist/webpack-config.js +8 -7
- package/package.json +7 -4
- package/renderEntry.tsx +411 -0
- package/dist/homepage/homepage.d.ts +0 -4
- package/dist/homepage/homepage.js +0 -109
- package/dist/renderEntry.d.ts +0 -2
- package/dist/renderEntry.js +0 -243
package/dist/bundle.js
CHANGED
|
@@ -27,6 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.bundle = exports.findClosestFolderWithFile = exports.getConfig = void 0;
|
|
30
|
+
const studio_shared_1 = require("@remotion/studio-shared");
|
|
30
31
|
const node_fs_1 = __importStar(require("node:fs"));
|
|
31
32
|
const node_os_1 = __importDefault(require("node:os"));
|
|
32
33
|
const node_path_1 = __importDefault(require("node:path"));
|
|
@@ -59,7 +60,7 @@ const trimTrailingSlash = (p) => {
|
|
|
59
60
|
};
|
|
60
61
|
const getConfig = ({ entryPoint, outDir, resolvedRemotionRoot, onProgress, options, }) => {
|
|
61
62
|
var _a, _b;
|
|
62
|
-
const entry =
|
|
63
|
+
const entry = node_path_1.default.resolve(__dirname, '..', './renderEntry.tsx');
|
|
63
64
|
return (0, webpack_config_1.webpackConfig)({
|
|
64
65
|
entry,
|
|
65
66
|
userDefinedComponent: entryPoint,
|
|
@@ -69,9 +70,8 @@ const getConfig = ({ entryPoint, outDir, resolvedRemotionRoot, onProgress, optio
|
|
|
69
70
|
onProgress,
|
|
70
71
|
enableCaching: (_b = options === null || options === void 0 ? void 0 : options.enableCaching) !== null && _b !== void 0 ? _b : true,
|
|
71
72
|
maxTimelineTracks: 90,
|
|
72
|
-
entryPoints: [],
|
|
73
73
|
remotionRoot: resolvedRemotionRoot,
|
|
74
|
-
keyboardShortcutsEnabled:
|
|
74
|
+
keyboardShortcutsEnabled: true,
|
|
75
75
|
poll: null,
|
|
76
76
|
});
|
|
77
77
|
};
|
|
@@ -221,6 +221,7 @@ async function bundle(...args) {
|
|
|
221
221
|
});
|
|
222
222
|
node_fs_1.default.writeFileSync(node_path_1.default.join(outDir, 'index.html'), html);
|
|
223
223
|
node_fs_1.default.copyFileSync(node_path_1.default.join(__dirname, '../favicon.ico'), node_path_1.default.join(outDir, 'favicon.ico'));
|
|
224
|
+
node_fs_1.default.copyFileSync(node_path_1.default.resolve(require.resolve('source-map'), '..', 'lib', 'mappings.wasm'), node_path_1.default.join(outDir, studio_shared_1.SOURCE_MAP_ENDPOINT.replace('/', '')));
|
|
224
225
|
return outDir;
|
|
225
226
|
}
|
|
226
227
|
exports.bundle = bundle;
|
package/dist/index-html.d.ts
CHANGED
|
@@ -1,43 +1,5 @@
|
|
|
1
|
+
import type { RenderDefaults } from '@remotion/studio';
|
|
1
2
|
import type { StaticFile } from 'remotion';
|
|
2
|
-
export type RenderDefaults = {
|
|
3
|
-
jpegQuality: number;
|
|
4
|
-
scale: number;
|
|
5
|
-
logLevel: string;
|
|
6
|
-
codec: string;
|
|
7
|
-
concurrency: number;
|
|
8
|
-
minConcurrency: number;
|
|
9
|
-
muted: boolean;
|
|
10
|
-
maxConcurrency: number;
|
|
11
|
-
stillImageFormat: 'png' | 'jpeg' | 'webp' | 'pdf';
|
|
12
|
-
videoImageFormat: 'png' | 'jpeg' | 'none';
|
|
13
|
-
audioCodec: string | null;
|
|
14
|
-
enforceAudioTrack: boolean;
|
|
15
|
-
proResProfile: string;
|
|
16
|
-
x264Preset: string;
|
|
17
|
-
pixelFormat: string;
|
|
18
|
-
audioBitrate: string | null;
|
|
19
|
-
videoBitrate: string | null;
|
|
20
|
-
encodingBufferSize: string | null;
|
|
21
|
-
encodingMaxRate: string | null;
|
|
22
|
-
userAgent: string | null;
|
|
23
|
-
everyNthFrame: number;
|
|
24
|
-
numberOfGifLoops: number | null;
|
|
25
|
-
delayRenderTimeout: number;
|
|
26
|
-
disableWebSecurity: boolean;
|
|
27
|
-
openGlRenderer: string | null;
|
|
28
|
-
ignoreCertificateErrors: boolean;
|
|
29
|
-
offthreadVideoCacheSizeInBytes: number | null;
|
|
30
|
-
headless: boolean;
|
|
31
|
-
colorSpace: string;
|
|
32
|
-
multiProcessOnLinux: boolean;
|
|
33
|
-
beepOnFinish: boolean;
|
|
34
|
-
repro: boolean;
|
|
35
|
-
};
|
|
36
|
-
declare global {
|
|
37
|
-
interface Window {
|
|
38
|
-
remotion_renderDefaults: RenderDefaults | undefined;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
3
|
export declare const indexHtml: ({ baseDir, editorName, inputProps, envVariables, staticHash, remotionRoot, studioServerCommand, renderQueue, numberOfAudioTags, publicFiles, includeFavicon, title, renderDefaults, publicFolderExists, }: {
|
|
42
4
|
staticHash: string;
|
|
43
5
|
baseDir: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import esbuild = require('esbuild');
|
|
|
2
2
|
import webpack = require('webpack');
|
|
3
3
|
export declare const BundlerInternals: {
|
|
4
4
|
esbuild: typeof esbuild;
|
|
5
|
-
webpackConfig: ({ entry, userDefinedComponent, outDir, environment, webpackOverride, onProgress, enableCaching, maxTimelineTracks,
|
|
5
|
+
webpackConfig: ({ entry, userDefinedComponent, outDir, environment, webpackOverride, onProgress, enableCaching, maxTimelineTracks, remotionRoot, keyboardShortcutsEnabled, poll, }: {
|
|
6
6
|
entry: string;
|
|
7
7
|
userDefinedComponent: string;
|
|
8
8
|
outDir: string | null;
|
|
@@ -12,7 +12,6 @@ export declare const BundlerInternals: {
|
|
|
12
12
|
enableCaching?: boolean | undefined;
|
|
13
13
|
maxTimelineTracks: number;
|
|
14
14
|
keyboardShortcutsEnabled: boolean;
|
|
15
|
-
entryPoints: string[];
|
|
16
15
|
remotionRoot: string;
|
|
17
16
|
poll: number | null;
|
|
18
17
|
}) => [string, webpack.Configuration];
|
|
@@ -30,7 +29,7 @@ export declare const BundlerInternals: {
|
|
|
30
29
|
publicFolderExists: string | null;
|
|
31
30
|
includeFavicon: boolean;
|
|
32
31
|
title: string;
|
|
33
|
-
renderDefaults: import("
|
|
32
|
+
renderDefaults: import("@remotion/studio-shared/dist").RenderDefaults | undefined;
|
|
34
33
|
}) => string;
|
|
35
34
|
cacheExists: (remotionRoot: string, environment: "development" | "production", hash: string) => "exists" | "other-exists" | "does-not-exist";
|
|
36
35
|
clearCache: (remotionRoot: string, env: "development" | "production") => Promise<void>;
|
|
@@ -51,6 +50,5 @@ export declare const BundlerInternals: {
|
|
|
51
50
|
findClosestFolderWithFile: (currentDir: string, file: string) => string | null;
|
|
52
51
|
};
|
|
53
52
|
export { bundle, BundleOptions, LegacyBundleOptions } from './bundle';
|
|
54
|
-
export type { RenderDefaults } from './index-html';
|
|
55
53
|
export { WebpackConfiguration, WebpackOverrideFn } from './webpack-config';
|
|
56
54
|
export { webpack };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Compiler } from 'webpack';
|
|
2
|
+
import type { webpack } from '.';
|
|
2
3
|
export declare class AllowOptionalDependenciesPlugin {
|
|
4
|
+
checkIgnore: (resolveData: webpack.ResolveData) => false | undefined;
|
|
3
5
|
filter(error: Error): boolean;
|
|
4
6
|
apply(compiler: Compiler): void;
|
|
5
7
|
}
|
|
@@ -10,6 +10,14 @@ const OPTIONAL_DEPENDENCIES = [
|
|
|
10
10
|
];
|
|
11
11
|
const SOURCE_MAP_IGNORE = ['path', 'fs'];
|
|
12
12
|
class AllowOptionalDependenciesPlugin {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.checkIgnore = (resolveData) => {
|
|
15
|
+
if (resolveData.context.includes('source-map') &&
|
|
16
|
+
SOURCE_MAP_IGNORE.includes(resolveData.request)) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
13
21
|
filter(error) {
|
|
14
22
|
for (const dependency of OPTIONAL_DEPENDENCIES) {
|
|
15
23
|
if (error.message.includes(`Can't resolve '${dependency}'`)) {
|
|
@@ -29,6 +37,12 @@ class AllowOptionalDependenciesPlugin {
|
|
|
29
37
|
compilation.errors = compilation.errors.filter(this.filter);
|
|
30
38
|
compilation.warnings = compilation.warnings.filter(this.filter);
|
|
31
39
|
});
|
|
40
|
+
compiler.hooks.normalModuleFactory.tap('AllowOptionalDependenciesPlugin', (nmf) => {
|
|
41
|
+
nmf.hooks.beforeResolve.tap('AllowOptionalDependenciesPlugin', this.checkIgnore);
|
|
42
|
+
});
|
|
43
|
+
compiler.hooks.contextModuleFactory.tap('AllowOptionalDependenciesPlugin', (cmf) => {
|
|
44
|
+
cmf.hooks.beforeResolve.tap('AllowOptionalDependenciesPlugin', this.checkIgnore);
|
|
45
|
+
});
|
|
32
46
|
}
|
|
33
47
|
}
|
|
34
48
|
exports.AllowOptionalDependenciesPlugin = AllowOptionalDependenciesPlugin;
|
package/dist/webpack-config.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Configuration } from 'webpack';
|
|
2
2
|
export type WebpackConfiguration = Configuration;
|
|
3
3
|
export type WebpackOverrideFn = (currentConfiguration: WebpackConfiguration) => WebpackConfiguration;
|
|
4
|
-
export declare const webpackConfig: ({ entry, userDefinedComponent, outDir, environment, webpackOverride, onProgress, enableCaching, maxTimelineTracks,
|
|
4
|
+
export declare const webpackConfig: ({ entry, userDefinedComponent, outDir, environment, webpackOverride, onProgress, enableCaching, maxTimelineTracks, remotionRoot, keyboardShortcutsEnabled, poll, }: {
|
|
5
5
|
entry: string;
|
|
6
6
|
userDefinedComponent: string;
|
|
7
7
|
outDir: string | null;
|
|
@@ -11,7 +11,6 @@ export declare const webpackConfig: ({ entry, userDefinedComponent, outDir, envi
|
|
|
11
11
|
enableCaching?: boolean | undefined;
|
|
12
12
|
maxTimelineTracks: number;
|
|
13
13
|
keyboardShortcutsEnabled: boolean;
|
|
14
|
-
entryPoints: string[];
|
|
15
14
|
remotionRoot: string;
|
|
16
15
|
poll: number | null;
|
|
17
16
|
}) => [string, WebpackConfiguration];
|
package/dist/webpack-config.js
CHANGED
|
@@ -52,9 +52,13 @@ const esbuildLoaderOptions = {
|
|
|
52
52
|
function truthy(value) {
|
|
53
53
|
return Boolean(value);
|
|
54
54
|
}
|
|
55
|
-
const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpackOverride = (f) => f, onProgress, enableCaching = true, maxTimelineTracks,
|
|
55
|
+
const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpackOverride = (f) => f, onProgress, enableCaching = true, maxTimelineTracks, remotionRoot, keyboardShortcutsEnabled, poll, }) => {
|
|
56
56
|
let lastProgress = 0;
|
|
57
57
|
const isBun = typeof Bun !== 'undefined';
|
|
58
|
+
const define = new webpack_1.default.DefinePlugin({
|
|
59
|
+
'process.env.MAX_TIMELINE_TRACKS': maxTimelineTracks,
|
|
60
|
+
'process.env.KEYBOARD_SHORTCUTS_ENABLED': keyboardShortcutsEnabled,
|
|
61
|
+
});
|
|
58
62
|
const conf = webpackOverride({
|
|
59
63
|
optimization: {
|
|
60
64
|
minimize: false,
|
|
@@ -71,7 +75,7 @@ const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpa
|
|
|
71
75
|
watchOptions: {
|
|
72
76
|
poll: poll !== null && poll !== void 0 ? poll : undefined,
|
|
73
77
|
aggregateTimeout: 0,
|
|
74
|
-
ignored: ['**/.git/**', '**/node_modules/**'],
|
|
78
|
+
ignored: ['**/.git/**', '**/.turbo/**', '**/node_modules/**'],
|
|
75
79
|
},
|
|
76
80
|
// Higher source map quality in development to power line numbers for stack traces
|
|
77
81
|
devtool: environment === 'development' ? 'source-map' : 'cheap-module-source-map',
|
|
@@ -83,7 +87,6 @@ const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpa
|
|
|
83
87
|
? require.resolve('./fast-refresh/runtime.js')
|
|
84
88
|
: null,
|
|
85
89
|
require.resolve('./setup-environment'),
|
|
86
|
-
...entryPoints,
|
|
87
90
|
userDefinedComponent,
|
|
88
91
|
require.resolve('../react-shim.js'),
|
|
89
92
|
entry,
|
|
@@ -93,10 +96,7 @@ const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpa
|
|
|
93
96
|
? [
|
|
94
97
|
new fast_refresh_1.ReactFreshWebpackPlugin(),
|
|
95
98
|
new webpack_1.default.HotModuleReplacementPlugin(),
|
|
96
|
-
|
|
97
|
-
'process.env.MAX_TIMELINE_TRACKS': maxTimelineTracks,
|
|
98
|
-
'process.env.KEYBOARD_SHORTCUTS_ENABLED': keyboardShortcutsEnabled,
|
|
99
|
-
}),
|
|
99
|
+
define,
|
|
100
100
|
new optional_dependencies_1.AllowOptionalDependenciesPlugin(),
|
|
101
101
|
]
|
|
102
102
|
: [
|
|
@@ -108,6 +108,7 @@ const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpa
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
}),
|
|
111
|
+
define,
|
|
111
112
|
new optional_dependencies_1.AllowOptionalDependenciesPlugin(),
|
|
112
113
|
],
|
|
113
114
|
output: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/bundler",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.91",
|
|
4
4
|
"description": "Bundler for Remotion",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"files": [
|
|
14
14
|
"dist",
|
|
15
15
|
"react-shim.js",
|
|
16
|
+
"renderEntry.tsx",
|
|
16
17
|
"favicon.ico"
|
|
17
18
|
],
|
|
18
19
|
"author": "Jonny Burger <jonny@remotion.dev>",
|
|
@@ -23,7 +24,9 @@
|
|
|
23
24
|
"react-refresh": "0.9.0",
|
|
24
25
|
"style-loader": "2.0.0",
|
|
25
26
|
"webpack": "5.83.1",
|
|
26
|
-
"remotion": "4.0.
|
|
27
|
+
"remotion": "4.0.91",
|
|
28
|
+
"@remotion/studio": "4.0.91",
|
|
29
|
+
"@remotion/studio-shared": "4.0.91"
|
|
27
30
|
},
|
|
28
31
|
"peerDependencies": {
|
|
29
32
|
"react": ">=16.8.0",
|
|
@@ -33,8 +36,8 @@
|
|
|
33
36
|
"@jonny/eslint-config": "3.0.276",
|
|
34
37
|
"@types/node": "18.14.6",
|
|
35
38
|
"bun-types": "0.8.0",
|
|
36
|
-
"@types/react": "18.
|
|
37
|
-
"@types/react-dom": "18.
|
|
39
|
+
"@types/react": "18.2.48",
|
|
40
|
+
"@types/react-dom": "18.2.18",
|
|
38
41
|
"eslint": "8.42.0",
|
|
39
42
|
"eslint-plugin-10x": "1.5.2",
|
|
40
43
|
"eslint-plugin-react": "7.32.2",
|
package/renderEntry.tsx
ADDED
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
// This file is not compiled by Typescript, but by ESBuild
|
|
2
|
+
// to keep the dynamic import
|
|
3
|
+
|
|
4
|
+
import React, {useContext, useEffect, useRef, useState} from 'react';
|
|
5
|
+
import type {render} from 'react-dom';
|
|
6
|
+
// In React 18, you should use createRoot() from "react-dom/client".
|
|
7
|
+
// In React 18, you should use render from "react-dom".
|
|
8
|
+
// We support both, but Webpack chooses both of them and normalizes them to "react-dom/client",
|
|
9
|
+
// hence why we import the right thing all the time but need to differentiate here
|
|
10
|
+
import ReactDOM from 'react-dom/client';
|
|
11
|
+
import type {
|
|
12
|
+
AnyComposition,
|
|
13
|
+
BundleState,
|
|
14
|
+
VideoConfigWithSerializedProps,
|
|
15
|
+
} from 'remotion';
|
|
16
|
+
import {
|
|
17
|
+
AbsoluteFill,
|
|
18
|
+
Internals,
|
|
19
|
+
VERSION,
|
|
20
|
+
continueRender,
|
|
21
|
+
delayRender,
|
|
22
|
+
getInputProps,
|
|
23
|
+
getRemotionEnvironment,
|
|
24
|
+
} from 'remotion';
|
|
25
|
+
import {NoReactInternals} from 'remotion/no-react';
|
|
26
|
+
import {getBundleMode, setBundleMode} from './src/bundle-mode';
|
|
27
|
+
|
|
28
|
+
Internals.CSSUtils.injectCSS(
|
|
29
|
+
Internals.CSSUtils.makeDefaultCSS(null, '#1f2428'),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const getCanSerializeDefaultProps = (object: unknown) => {
|
|
33
|
+
try {
|
|
34
|
+
const str = JSON.stringify(object);
|
|
35
|
+
// 256MB is the theoretical limit, making it throw if over 90% of that is reached.
|
|
36
|
+
return str.length < 256 * 1024 * 1024 * 0.9;
|
|
37
|
+
} catch (err) {
|
|
38
|
+
if ((err as Error).message.includes('Invalid string length')) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
throw err;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const isInHeadlessBrowser = () => {
|
|
47
|
+
return typeof window.remotion_puppeteerTimeout !== 'undefined';
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const DelayedSpinner: React.FC = () => {
|
|
51
|
+
const [show, setShow] = useState(false);
|
|
52
|
+
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
const timeout = setTimeout(() => {
|
|
55
|
+
setShow(true);
|
|
56
|
+
}, 2000);
|
|
57
|
+
return () => {
|
|
58
|
+
clearTimeout(timeout);
|
|
59
|
+
};
|
|
60
|
+
}, []);
|
|
61
|
+
|
|
62
|
+
if (!show) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<AbsoluteFill
|
|
68
|
+
style={{
|
|
69
|
+
justifyContent: 'center',
|
|
70
|
+
alignItems: 'center',
|
|
71
|
+
fontSize: 13,
|
|
72
|
+
opacity: 0.6,
|
|
73
|
+
color: 'white',
|
|
74
|
+
fontFamily: 'Helvetica, Arial, sans-serif',
|
|
75
|
+
}}
|
|
76
|
+
>
|
|
77
|
+
Loading Studio
|
|
78
|
+
</AbsoluteFill>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const GetVideo: React.FC<{state: BundleState}> = ({state}) => {
|
|
83
|
+
const video = Internals.useVideo();
|
|
84
|
+
const compositions = useContext(Internals.CompositionManager);
|
|
85
|
+
|
|
86
|
+
const portalContainer = useRef<HTMLDivElement>(null);
|
|
87
|
+
const [handle] = useState(() =>
|
|
88
|
+
delayRender('Wait for Composition' + JSON.stringify(state)),
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
return () => continueRender(handle);
|
|
93
|
+
}, [handle]);
|
|
94
|
+
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (state.type !== 'composition') {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (!video && compositions.compositions.length > 0) {
|
|
101
|
+
const foundComposition = compositions.compositions.find(
|
|
102
|
+
(c) => c.id === state.compositionName,
|
|
103
|
+
) as AnyComposition;
|
|
104
|
+
if (!foundComposition) {
|
|
105
|
+
throw new Error(
|
|
106
|
+
`Found no composition with the name ${
|
|
107
|
+
state.compositionName
|
|
108
|
+
}. The following compositions were found instead: ${compositions.compositions
|
|
109
|
+
.map((c) => c.id)
|
|
110
|
+
.join(
|
|
111
|
+
', ',
|
|
112
|
+
)}. All compositions must have their ID calculated deterministically and must be mounted at the same time.`,
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (foundComposition) {
|
|
117
|
+
compositions.setCanvasContent({
|
|
118
|
+
type: 'composition',
|
|
119
|
+
compositionId: foundComposition.id,
|
|
120
|
+
});
|
|
121
|
+
} else {
|
|
122
|
+
compositions.setCanvasContent(null);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
compositions.setCurrentCompositionMetadata({
|
|
126
|
+
props: NoReactInternals.deserializeJSONWithCustomFields(
|
|
127
|
+
state.serializedResolvedPropsWithSchema,
|
|
128
|
+
),
|
|
129
|
+
durationInFrames: state.compositionDurationInFrames,
|
|
130
|
+
fps: state.compositionFps,
|
|
131
|
+
height: state.compositionHeight,
|
|
132
|
+
width: state.compositionWidth,
|
|
133
|
+
defaultCodec: state.compositionDefaultCodec,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}, [compositions, compositions.compositions, state, video]);
|
|
137
|
+
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
if (state.type === 'evaluation') {
|
|
140
|
+
continueRender(handle);
|
|
141
|
+
} else if (video) {
|
|
142
|
+
continueRender(handle);
|
|
143
|
+
}
|
|
144
|
+
}, [handle, state.type, video]);
|
|
145
|
+
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
if (!video) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const {current} = portalContainer;
|
|
152
|
+
if (!current) {
|
|
153
|
+
throw new Error('portal did not render');
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
current.appendChild(Internals.portalNode());
|
|
157
|
+
return () => {
|
|
158
|
+
current.removeChild(Internals.portalNode());
|
|
159
|
+
};
|
|
160
|
+
}, [video]);
|
|
161
|
+
|
|
162
|
+
if (!video) {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return (
|
|
167
|
+
<div
|
|
168
|
+
ref={portalContainer}
|
|
169
|
+
id="remotion-canvas"
|
|
170
|
+
style={{
|
|
171
|
+
width: video.width,
|
|
172
|
+
height: video.height,
|
|
173
|
+
display: 'flex',
|
|
174
|
+
backgroundColor: 'transparent',
|
|
175
|
+
}}
|
|
176
|
+
/>
|
|
177
|
+
);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const waitForRootHandle = delayRender(
|
|
181
|
+
'Loading root component - See https://remotion.dev/docs/troubleshooting/loading-root-component if you experience a timeout',
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
const videoContainer = document.getElementById(
|
|
185
|
+
'video-container',
|
|
186
|
+
) as HTMLElement;
|
|
187
|
+
|
|
188
|
+
let root: ReturnType<typeof ReactDOM.createRoot> | null = null;
|
|
189
|
+
|
|
190
|
+
const getRootForElement = () => {
|
|
191
|
+
if (root) {
|
|
192
|
+
return root;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
root = ReactDOM.createRoot(videoContainer);
|
|
196
|
+
return root;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const renderToDOM = (content: React.ReactElement) => {
|
|
200
|
+
// @ts-expect-error
|
|
201
|
+
if (ReactDOM.createRoot) {
|
|
202
|
+
getRootForElement().render(content);
|
|
203
|
+
} else {
|
|
204
|
+
(ReactDOM as unknown as {render: typeof render}).render(
|
|
205
|
+
content,
|
|
206
|
+
videoContainer,
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const renderContent = (Root: React.FC) => {
|
|
212
|
+
const bundleMode = getBundleMode();
|
|
213
|
+
|
|
214
|
+
if (bundleMode.type === 'composition') {
|
|
215
|
+
const markup = (
|
|
216
|
+
<Internals.RemotionRoot numberOfAudioTags={0}>
|
|
217
|
+
<Root />
|
|
218
|
+
<GetVideo state={bundleMode} />
|
|
219
|
+
</Internals.RemotionRoot>
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
renderToDOM(markup);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (bundleMode.type === 'evaluation') {
|
|
226
|
+
const markup = (
|
|
227
|
+
<Internals.RemotionRoot numberOfAudioTags={0}>
|
|
228
|
+
<Root />
|
|
229
|
+
<GetVideo state={bundleMode} />
|
|
230
|
+
</Internals.RemotionRoot>
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
renderToDOM(markup);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (bundleMode.type === 'index') {
|
|
237
|
+
if (isInHeadlessBrowser()) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
renderToDOM(
|
|
242
|
+
<div>
|
|
243
|
+
<DelayedSpinner />
|
|
244
|
+
</div>,
|
|
245
|
+
);
|
|
246
|
+
import('@remotion/studio')
|
|
247
|
+
.then(({Studio}) => {
|
|
248
|
+
renderToDOM(<Studio readOnly rootComponent={Root} />);
|
|
249
|
+
})
|
|
250
|
+
.catch((err) => {
|
|
251
|
+
renderToDOM(<div>Failed to load Remotion Studio: {err.message}</div>);
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
Internals.waitForRoot((Root) => {
|
|
257
|
+
renderContent(Root);
|
|
258
|
+
continueRender(waitForRootHandle);
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
export const setBundleModeAndUpdate = (state: BundleState) => {
|
|
262
|
+
setBundleMode(state);
|
|
263
|
+
const delay = delayRender(
|
|
264
|
+
'Waiting for root component to load - See https://remotion.dev/docs/troubleshooting/loading-root-component if you experience a timeout',
|
|
265
|
+
);
|
|
266
|
+
Internals.waitForRoot((Root) => {
|
|
267
|
+
renderContent(Root);
|
|
268
|
+
requestAnimationFrame(() => {
|
|
269
|
+
continueRender(delay);
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
if (typeof window !== 'undefined') {
|
|
275
|
+
const getUnevaluatedComps = () => {
|
|
276
|
+
if (!Internals.getRoot()) {
|
|
277
|
+
throw new Error(
|
|
278
|
+
'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.',
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (!Internals.compositionsRef.current) {
|
|
283
|
+
throw new Error('Unexpectedly did not have a CompositionManager');
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const compositions = Internals.compositionsRef.current.getCompositions();
|
|
287
|
+
|
|
288
|
+
const canSerializeDefaultProps = getCanSerializeDefaultProps(compositions);
|
|
289
|
+
if (!canSerializeDefaultProps) {
|
|
290
|
+
console.warn(
|
|
291
|
+
'defaultProps are too big to serialize - trying to find the problematic composition...',
|
|
292
|
+
);
|
|
293
|
+
for (const comp of compositions) {
|
|
294
|
+
if (!getCanSerializeDefaultProps(comp)) {
|
|
295
|
+
throw new Error(
|
|
296
|
+
`defaultProps too big - could not serialize - the defaultProps of composition with ID ${comp.id} - the object that was passed to defaultProps was too big. Learn how to mitigate this error by visiting https://remotion.dev/docs/troubleshooting/serialize-defaultprops`,
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
console.warn(
|
|
302
|
+
'Could not single out a problematic composition - The composition list as a whole is too big to serialize.',
|
|
303
|
+
);
|
|
304
|
+
|
|
305
|
+
throw new Error(
|
|
306
|
+
'defaultProps too big - Could not serialize - an object that was passed to defaultProps was too big. Learn how to mitigate this error by visiting https://remotion.dev/docs/troubleshooting/serialize-defaultprops',
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
return compositions;
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
window.getStaticCompositions = (): Promise<
|
|
314
|
+
VideoConfigWithSerializedProps[]
|
|
315
|
+
> => {
|
|
316
|
+
const compositions = getUnevaluatedComps();
|
|
317
|
+
|
|
318
|
+
const inputProps =
|
|
319
|
+
typeof window === 'undefined' || getRemotionEnvironment().isPlayer
|
|
320
|
+
? {}
|
|
321
|
+
: getInputProps() ?? {};
|
|
322
|
+
|
|
323
|
+
return Promise.all(
|
|
324
|
+
compositions.map(async (c): Promise<VideoConfigWithSerializedProps> => {
|
|
325
|
+
const handle = delayRender(
|
|
326
|
+
`Running calculateMetadata() for composition ${c.id}. If you didn't want to evaluate this composition, use "selectComposition()" instead of "getCompositions()"`,
|
|
327
|
+
);
|
|
328
|
+
|
|
329
|
+
const comp = Internals.resolveVideoConfig({
|
|
330
|
+
composition: c,
|
|
331
|
+
editorProps: {},
|
|
332
|
+
signal: new AbortController().signal,
|
|
333
|
+
inputProps,
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
const resolved = await Promise.resolve(comp);
|
|
337
|
+
continueRender(handle);
|
|
338
|
+
const {props, defaultProps, ...data} = resolved;
|
|
339
|
+
|
|
340
|
+
return {
|
|
341
|
+
...data,
|
|
342
|
+
serializedResolvedPropsWithCustomSchema:
|
|
343
|
+
NoReactInternals.serializeJSONWithDate({
|
|
344
|
+
data: props,
|
|
345
|
+
indent: undefined,
|
|
346
|
+
staticBase: null,
|
|
347
|
+
}).serializedString,
|
|
348
|
+
serializedDefaultPropsWithCustomSchema:
|
|
349
|
+
NoReactInternals.serializeJSONWithDate({
|
|
350
|
+
data: defaultProps,
|
|
351
|
+
indent: undefined,
|
|
352
|
+
staticBase: null,
|
|
353
|
+
}).serializedString,
|
|
354
|
+
};
|
|
355
|
+
}),
|
|
356
|
+
);
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
window.remotion_getCompositionNames = () => {
|
|
360
|
+
return getUnevaluatedComps().map((c) => c.id);
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
window.remotion_calculateComposition = async (compId: string) => {
|
|
364
|
+
const compositions = getUnevaluatedComps();
|
|
365
|
+
const selectedComp = compositions.find((c) => c.id === compId);
|
|
366
|
+
if (!selectedComp) {
|
|
367
|
+
throw new Error(`Could not find composition with ID ${compId}`);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
const abortController = new AbortController();
|
|
371
|
+
const handle = delayRender(
|
|
372
|
+
`Running the calculateMetadata() function for composition ${compId}`,
|
|
373
|
+
);
|
|
374
|
+
|
|
375
|
+
const inputProps =
|
|
376
|
+
typeof window === 'undefined' || getRemotionEnvironment().isPlayer
|
|
377
|
+
? {}
|
|
378
|
+
: getInputProps() ?? {};
|
|
379
|
+
|
|
380
|
+
const prom = await Promise.resolve(
|
|
381
|
+
Internals.resolveVideoConfig({
|
|
382
|
+
composition: selectedComp,
|
|
383
|
+
editorProps: {},
|
|
384
|
+
signal: abortController.signal,
|
|
385
|
+
inputProps,
|
|
386
|
+
}),
|
|
387
|
+
);
|
|
388
|
+
continueRender(handle);
|
|
389
|
+
|
|
390
|
+
const {props, defaultProps, ...data} = prom;
|
|
391
|
+
return {
|
|
392
|
+
...data,
|
|
393
|
+
serializedResolvedPropsWithCustomSchema:
|
|
394
|
+
NoReactInternals.serializeJSONWithDate({
|
|
395
|
+
data: props,
|
|
396
|
+
indent: undefined,
|
|
397
|
+
staticBase: null,
|
|
398
|
+
}).serializedString,
|
|
399
|
+
serializedDefaultPropsWithCustomSchema:
|
|
400
|
+
NoReactInternals.serializeJSONWithDate({
|
|
401
|
+
data: defaultProps,
|
|
402
|
+
indent: undefined,
|
|
403
|
+
staticBase: null,
|
|
404
|
+
}).serializedString,
|
|
405
|
+
};
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
window.siteVersion = '10';
|
|
409
|
+
window.remotion_version = VERSION;
|
|
410
|
+
window.remotion_setBundleMode = setBundleModeAndUpdate;
|
|
411
|
+
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Homepage = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const bundle_mode_1 = require("../bundle-mode");
|
|
7
|
-
const renderEntry_1 = require("../renderEntry");
|
|
8
|
-
const container = {
|
|
9
|
-
width: 800,
|
|
10
|
-
margin: 'auto',
|
|
11
|
-
paddingLeft: 20,
|
|
12
|
-
paddingRight: 20,
|
|
13
|
-
fontFamily: 'sans-serif',
|
|
14
|
-
lineHeight: 1.5,
|
|
15
|
-
};
|
|
16
|
-
const pre = {
|
|
17
|
-
display: 'block',
|
|
18
|
-
backgroundColor: '#f7f7f7',
|
|
19
|
-
whiteSpace: 'nowrap',
|
|
20
|
-
padding: 16,
|
|
21
|
-
fontFamily: 'monospace',
|
|
22
|
-
borderRadius: 5,
|
|
23
|
-
fontSize: 15,
|
|
24
|
-
overflowX: 'auto',
|
|
25
|
-
};
|
|
26
|
-
const AvailableCompositions = () => {
|
|
27
|
-
const [state, setComps] = (0, react_1.useState)({
|
|
28
|
-
type: 'not-initialized',
|
|
29
|
-
});
|
|
30
|
-
(0, react_1.useEffect)(() => {
|
|
31
|
-
if ((0, bundle_mode_1.getBundleMode)().type !== 'evaluation') {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
let timeout = null;
|
|
35
|
-
const check = () => {
|
|
36
|
-
if (window.remotion_renderReady === true) {
|
|
37
|
-
setComps({ type: 'loading' });
|
|
38
|
-
setTimeout(() => {
|
|
39
|
-
try {
|
|
40
|
-
const newComps = window.remotion_getCompositionNames();
|
|
41
|
-
setComps({ type: 'loaded', comps: newComps });
|
|
42
|
-
}
|
|
43
|
-
catch (err) {
|
|
44
|
-
setComps({ type: 'error', error: err });
|
|
45
|
-
}
|
|
46
|
-
}, 250);
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
timeout = setTimeout(check, 250);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
check();
|
|
53
|
-
return () => {
|
|
54
|
-
if (!timeout) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
clearTimeout(timeout);
|
|
58
|
-
};
|
|
59
|
-
}, []);
|
|
60
|
-
const showComps = (0, react_1.useCallback)(() => {
|
|
61
|
-
(0, renderEntry_1.setBundleModeAndUpdate)({ type: 'evaluation' });
|
|
62
|
-
}, []);
|
|
63
|
-
if ((0, bundle_mode_1.getBundleMode)().type !== 'evaluation') {
|
|
64
|
-
return ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: showComps, children: "Click here to see a list of available compositions." }));
|
|
65
|
-
}
|
|
66
|
-
if (state.type === 'loading') {
|
|
67
|
-
return (0, jsx_runtime_1.jsx)("div", { children: state === null ? (0, jsx_runtime_1.jsx)("p", { children: "Loading compositions..." }) : null });
|
|
68
|
-
}
|
|
69
|
-
if (state.type === 'error') {
|
|
70
|
-
return (0, jsx_runtime_1.jsxs)("div", { children: ["Error loading compositions: ", state.error.stack] });
|
|
71
|
-
}
|
|
72
|
-
if (state.type === 'not-initialized') {
|
|
73
|
-
return (0, jsx_runtime_1.jsx)("div", { children: "Not initialized" });
|
|
74
|
-
}
|
|
75
|
-
return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("ul", { children: state === null
|
|
76
|
-
? []
|
|
77
|
-
: state.comps.map((c) => {
|
|
78
|
-
return (0, jsx_runtime_1.jsx)("li", { children: c }, c);
|
|
79
|
-
}) }) }));
|
|
80
|
-
};
|
|
81
|
-
const TestCORS = () => {
|
|
82
|
-
const [serveUrl, setServeUrl] = (0, react_1.useState)('');
|
|
83
|
-
const [result, setResult] = (0, react_1.useState)('');
|
|
84
|
-
const handleServeUrl = (0, react_1.useCallback)((e) => {
|
|
85
|
-
setServeUrl(e.target.value);
|
|
86
|
-
}, []);
|
|
87
|
-
const isCORSWorking = (0, react_1.useCallback)(async (e) => {
|
|
88
|
-
e.preventDefault();
|
|
89
|
-
try {
|
|
90
|
-
const response = await fetch(serveUrl, { mode: 'cors' });
|
|
91
|
-
if (response.ok) {
|
|
92
|
-
setResult(`CORS is enabled on this URL: ${serveUrl}`);
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
setResult('URL does not support CORS - See DevTools console for more details');
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
catch (error) {
|
|
99
|
-
setResult('URL does not support CORS - See DevTools console for more details');
|
|
100
|
-
}
|
|
101
|
-
}, [serveUrl]);
|
|
102
|
-
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("p", { children: ["Quickly test if a URL is supported being loaded on origin", ' ', (0, jsx_runtime_1.jsx)("code", { children: window.location.origin }), ". Enter the URL of an asset below."] }), result ? (0, jsx_runtime_1.jsx)("p", { className: "result", children: result }) : null, (0, jsx_runtime_1.jsxs)("form", { onSubmit: isCORSWorking, children: [(0, jsx_runtime_1.jsx)("label", { htmlFor: "serveurl", children: (0, jsx_runtime_1.jsx)("input", { placeholder: "Enter URL", type: "text", name: "serveurl", value: serveUrl, onChange: handleServeUrl }) }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("button", { type: "submit", children: "Test CORS" })] })] }));
|
|
103
|
-
};
|
|
104
|
-
const Homepage = ({ rootComponent }) => {
|
|
105
|
-
const url = window.location.origin + window.location.pathname;
|
|
106
|
-
const Root = rootComponent;
|
|
107
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: container, children: [(0, jsx_runtime_1.jsx)(Root, {}), (0, jsx_runtime_1.jsx)("h1", { children: "Remotion Bundle" }), "This is a website which contains a bundled Remotion video. You can render videos based on this URL.", (0, jsx_runtime_1.jsx)("h2", { children: "Available compositions" }), (0, jsx_runtime_1.jsx)(AvailableCompositions, {}), (0, jsx_runtime_1.jsx)("h2", { children: "How to render" }), "Locally: ", (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsxs)("div", { style: pre, children: ["npx remotion render ", url, " ", '<comp-name> <output-location>'] }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("br", {}), "With Remotion Lambda: ", (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsxs)("div", { style: pre, children: ["npx remotion lambda render ", url, " ", '<comp-name>'] }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsxs)("p", { children: ["You can also render still images, and use the Node.JS APIs", ' ', (0, jsx_runtime_1.jsx)("code", { children: "getCompositions()" }), ", ", (0, jsx_runtime_1.jsx)("code", { children: "renderMedia()" }), ",", ' ', (0, jsx_runtime_1.jsx)("code", { children: "renderMediaOnLambda()" }), ", ", (0, jsx_runtime_1.jsx)("code", { children: "renderStill()" }), " and", ' ', (0, jsx_runtime_1.jsx)("code", { children: "renderStillOnLambda()" }), " with this URL."] }), (0, jsx_runtime_1.jsxs)("p", { children: ["Visit", ' ', (0, jsx_runtime_1.jsx)("a", { href: "https://remotion.dev/docs", target: "_blank", children: "remotion.dev/docs" }), ' ', "to read the documentation."] }), (0, jsx_runtime_1.jsx)("h2", { children: "CORS testing tool" }), (0, jsx_runtime_1.jsx)(TestCORS, {}), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("br", {})] }));
|
|
108
|
-
};
|
|
109
|
-
exports.Homepage = Homepage;
|
package/dist/renderEntry.d.ts
DELETED
package/dist/renderEntry.js
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
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.setBundleModeAndUpdate = void 0;
|
|
7
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const react_1 = require("react");
|
|
9
|
-
// In React 18, you should use createRoot() from "react-dom/client".
|
|
10
|
-
// In React 18, you should use render from "react-dom".
|
|
11
|
-
// We support both, but Webpack chooses both of them and normalizes them to "react-dom/client",
|
|
12
|
-
// hence why we import the right thing all the time but need to differentiate here
|
|
13
|
-
const client_1 = __importDefault(require("react-dom/client"));
|
|
14
|
-
const remotion_1 = require("remotion");
|
|
15
|
-
const no_react_1 = require("remotion/no-react");
|
|
16
|
-
const bundle_mode_1 = require("./bundle-mode");
|
|
17
|
-
const homepage_1 = require("./homepage/homepage");
|
|
18
|
-
remotion_1.Internals.CSSUtils.injectCSS(remotion_1.Internals.CSSUtils.makeDefaultCSS(null, '#1f2428'));
|
|
19
|
-
const getCanSerializeDefaultProps = (object) => {
|
|
20
|
-
try {
|
|
21
|
-
const str = JSON.stringify(object);
|
|
22
|
-
// 256MB is the theoretical limit, making it throw if over 90% of that is reached.
|
|
23
|
-
return str.length < 256 * 1024 * 1024 * 0.9;
|
|
24
|
-
}
|
|
25
|
-
catch (err) {
|
|
26
|
-
if (err.message.includes('Invalid string length')) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
throw err;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
const GetVideo = ({ state }) => {
|
|
33
|
-
const video = remotion_1.Internals.useVideo();
|
|
34
|
-
const compositions = (0, react_1.useContext)(remotion_1.Internals.CompositionManager);
|
|
35
|
-
const portalContainer = (0, react_1.useRef)(null);
|
|
36
|
-
const [handle] = (0, react_1.useState)(() => (0, remotion_1.delayRender)('Wait for Composition' + JSON.stringify(state)));
|
|
37
|
-
(0, react_1.useEffect)(() => {
|
|
38
|
-
return () => (0, remotion_1.continueRender)(handle);
|
|
39
|
-
}, [handle]);
|
|
40
|
-
(0, react_1.useEffect)(() => {
|
|
41
|
-
if (state.type !== 'composition') {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
if (!video && compositions.compositions.length > 0) {
|
|
45
|
-
const foundComposition = compositions.compositions.find((c) => c.id === state.compositionName);
|
|
46
|
-
if (!foundComposition) {
|
|
47
|
-
throw new Error(`Found no composition with the name ${state.compositionName}. The following compositions were found instead: ${compositions.compositions
|
|
48
|
-
.map((c) => c.id)
|
|
49
|
-
.join(', ')}. All compositions must have their ID calculated deterministically and must be mounted at the same time.`);
|
|
50
|
-
}
|
|
51
|
-
if (foundComposition) {
|
|
52
|
-
compositions.setCanvasContent({
|
|
53
|
-
type: 'composition',
|
|
54
|
-
compositionId: foundComposition.id,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
compositions.setCanvasContent(null);
|
|
59
|
-
}
|
|
60
|
-
compositions.setCurrentCompositionMetadata({
|
|
61
|
-
props: no_react_1.NoReactInternals.deserializeJSONWithCustomFields(state.serializedResolvedPropsWithSchema),
|
|
62
|
-
durationInFrames: state.compositionDurationInFrames,
|
|
63
|
-
fps: state.compositionFps,
|
|
64
|
-
height: state.compositionHeight,
|
|
65
|
-
width: state.compositionWidth,
|
|
66
|
-
defaultCodec: state.compositionDefaultCodec,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}, [compositions, compositions.compositions, state, video]);
|
|
70
|
-
(0, react_1.useEffect)(() => {
|
|
71
|
-
if (state.type === 'evaluation') {
|
|
72
|
-
(0, remotion_1.continueRender)(handle);
|
|
73
|
-
}
|
|
74
|
-
else if (video) {
|
|
75
|
-
(0, remotion_1.continueRender)(handle);
|
|
76
|
-
}
|
|
77
|
-
}, [handle, state.type, video]);
|
|
78
|
-
(0, react_1.useEffect)(() => {
|
|
79
|
-
if (!video) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
const { current } = portalContainer;
|
|
83
|
-
if (!current) {
|
|
84
|
-
throw new Error('portal did not render');
|
|
85
|
-
}
|
|
86
|
-
current.appendChild(remotion_1.Internals.portalNode());
|
|
87
|
-
return () => {
|
|
88
|
-
current.removeChild(remotion_1.Internals.portalNode());
|
|
89
|
-
};
|
|
90
|
-
}, [video]);
|
|
91
|
-
if (!video) {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
return ((0, jsx_runtime_1.jsx)("div", { ref: portalContainer, id: "remotion-canvas", style: {
|
|
95
|
-
width: video.width,
|
|
96
|
-
height: video.height,
|
|
97
|
-
display: 'flex',
|
|
98
|
-
backgroundColor: 'transparent',
|
|
99
|
-
} }));
|
|
100
|
-
};
|
|
101
|
-
const waitForRootHandle = (0, remotion_1.delayRender)('Loading root component - See https://remotion.dev/docs/troubleshooting/loading-root-component if you experience a timeout');
|
|
102
|
-
const videoContainer = document.getElementById('video-container');
|
|
103
|
-
let root = null;
|
|
104
|
-
const getRootForElement = () => {
|
|
105
|
-
if (root) {
|
|
106
|
-
return root;
|
|
107
|
-
}
|
|
108
|
-
root = client_1.default.createRoot(videoContainer);
|
|
109
|
-
return root;
|
|
110
|
-
};
|
|
111
|
-
const renderToDOM = (content) => {
|
|
112
|
-
// @ts-expect-error
|
|
113
|
-
if (client_1.default.createRoot) {
|
|
114
|
-
getRootForElement().render(content);
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
client_1.default.render(content, videoContainer);
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
const renderContent = (Root) => {
|
|
121
|
-
const bundleMode = (0, bundle_mode_1.getBundleMode)();
|
|
122
|
-
if (bundleMode.type === 'composition') {
|
|
123
|
-
const markup = ((0, jsx_runtime_1.jsxs)(remotion_1.Internals.RemotionRoot, { numberOfAudioTags: 0, children: [(0, jsx_runtime_1.jsx)(Root, {}), (0, jsx_runtime_1.jsx)(GetVideo, { state: bundleMode })] }));
|
|
124
|
-
renderToDOM(markup);
|
|
125
|
-
}
|
|
126
|
-
if (bundleMode.type === 'evaluation') {
|
|
127
|
-
const markup = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(remotion_1.Internals.RemotionRoot, { numberOfAudioTags: 0, children: [(0, jsx_runtime_1.jsx)(Root, {}), (0, jsx_runtime_1.jsx)(GetVideo, { state: bundleMode })] }), (0, jsx_runtime_1.jsx)(homepage_1.Homepage, { rootComponent: Root })] }));
|
|
128
|
-
renderToDOM(markup);
|
|
129
|
-
}
|
|
130
|
-
if (bundleMode.type === 'index') {
|
|
131
|
-
renderToDOM((0, jsx_runtime_1.jsx)(homepage_1.Homepage, { rootComponent: Root }));
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
remotion_1.Internals.waitForRoot((Root) => {
|
|
135
|
-
renderContent(Root);
|
|
136
|
-
(0, remotion_1.continueRender)(waitForRootHandle);
|
|
137
|
-
});
|
|
138
|
-
const setBundleModeAndUpdate = (state) => {
|
|
139
|
-
(0, bundle_mode_1.setBundleMode)(state);
|
|
140
|
-
const delay = (0, remotion_1.delayRender)('Waiting for root component to load - See https://remotion.dev/docs/troubleshooting/loading-root-component if you experience a timeout');
|
|
141
|
-
remotion_1.Internals.waitForRoot((Root) => {
|
|
142
|
-
renderContent(Root);
|
|
143
|
-
requestAnimationFrame(() => {
|
|
144
|
-
(0, remotion_1.continueRender)(delay);
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
};
|
|
148
|
-
exports.setBundleModeAndUpdate = setBundleModeAndUpdate;
|
|
149
|
-
if (typeof window !== 'undefined') {
|
|
150
|
-
const getUnevaluatedComps = () => {
|
|
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
|
-
}
|
|
154
|
-
if (!remotion_1.Internals.compositionsRef.current) {
|
|
155
|
-
throw new Error('Unexpectedly did not have a CompositionManager');
|
|
156
|
-
}
|
|
157
|
-
const compositions = remotion_1.Internals.compositionsRef.current.getCompositions();
|
|
158
|
-
const canSerializeDefaultProps = getCanSerializeDefaultProps(compositions);
|
|
159
|
-
if (!canSerializeDefaultProps) {
|
|
160
|
-
console.warn('defaultProps are too big to serialize - trying to find the problematic composition...');
|
|
161
|
-
for (const comp of compositions) {
|
|
162
|
-
if (!getCanSerializeDefaultProps(comp)) {
|
|
163
|
-
throw new Error(`defaultProps too big - could not serialize - the defaultProps of composition with ID ${comp.id} - the object that was passed to defaultProps was too big. Learn how to mitigate this error by visiting https://remotion.dev/docs/troubleshooting/serialize-defaultprops`);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
console.warn('Could not single out a problematic composition - The composition list as a whole is too big to serialize.');
|
|
167
|
-
throw new Error('defaultProps too big - Could not serialize - an object that was passed to defaultProps was too big. Learn how to mitigate this error by visiting https://remotion.dev/docs/troubleshooting/serialize-defaultprops');
|
|
168
|
-
}
|
|
169
|
-
return compositions;
|
|
170
|
-
};
|
|
171
|
-
window.getStaticCompositions = () => {
|
|
172
|
-
var _a;
|
|
173
|
-
const compositions = getUnevaluatedComps();
|
|
174
|
-
const inputProps = typeof window === 'undefined' || (0, remotion_1.getRemotionEnvironment)().isPlayer
|
|
175
|
-
? {}
|
|
176
|
-
: (_a = (0, remotion_1.getInputProps)()) !== null && _a !== void 0 ? _a : {};
|
|
177
|
-
return Promise.all(compositions.map(async (c) => {
|
|
178
|
-
const handle = (0, remotion_1.delayRender)(`Running calculateMetadata() for composition ${c.id}. If you didn't want to evaluate this composition, use "selectComposition()" instead of "getCompositions()"`);
|
|
179
|
-
const comp = remotion_1.Internals.resolveVideoConfig({
|
|
180
|
-
composition: c,
|
|
181
|
-
editorProps: {},
|
|
182
|
-
signal: new AbortController().signal,
|
|
183
|
-
inputProps,
|
|
184
|
-
});
|
|
185
|
-
const resolved = await Promise.resolve(comp);
|
|
186
|
-
(0, remotion_1.continueRender)(handle);
|
|
187
|
-
const { props, defaultProps, ...data } = resolved;
|
|
188
|
-
return {
|
|
189
|
-
...data,
|
|
190
|
-
serializedResolvedPropsWithCustomSchema: no_react_1.NoReactInternals.serializeJSONWithDate({
|
|
191
|
-
data: props,
|
|
192
|
-
indent: undefined,
|
|
193
|
-
staticBase: null,
|
|
194
|
-
}).serializedString,
|
|
195
|
-
serializedDefaultPropsWithCustomSchema: no_react_1.NoReactInternals.serializeJSONWithDate({
|
|
196
|
-
data: defaultProps,
|
|
197
|
-
indent: undefined,
|
|
198
|
-
staticBase: null,
|
|
199
|
-
}).serializedString,
|
|
200
|
-
};
|
|
201
|
-
}));
|
|
202
|
-
};
|
|
203
|
-
window.remotion_getCompositionNames = () => {
|
|
204
|
-
return getUnevaluatedComps().map((c) => c.id);
|
|
205
|
-
};
|
|
206
|
-
window.remotion_calculateComposition = async (compId) => {
|
|
207
|
-
var _a;
|
|
208
|
-
const compositions = getUnevaluatedComps();
|
|
209
|
-
const selectedComp = compositions.find((c) => c.id === compId);
|
|
210
|
-
if (!selectedComp) {
|
|
211
|
-
throw new Error(`Could not find composition with ID ${compId}`);
|
|
212
|
-
}
|
|
213
|
-
const abortController = new AbortController();
|
|
214
|
-
const handle = (0, remotion_1.delayRender)(`Running the calculateMetadata() function for composition ${compId}`);
|
|
215
|
-
const inputProps = typeof window === 'undefined' || (0, remotion_1.getRemotionEnvironment)().isPlayer
|
|
216
|
-
? {}
|
|
217
|
-
: (_a = (0, remotion_1.getInputProps)()) !== null && _a !== void 0 ? _a : {};
|
|
218
|
-
const prom = await Promise.resolve(remotion_1.Internals.resolveVideoConfig({
|
|
219
|
-
composition: selectedComp,
|
|
220
|
-
editorProps: {},
|
|
221
|
-
signal: abortController.signal,
|
|
222
|
-
inputProps,
|
|
223
|
-
}));
|
|
224
|
-
(0, remotion_1.continueRender)(handle);
|
|
225
|
-
const { props, defaultProps, ...data } = prom;
|
|
226
|
-
return {
|
|
227
|
-
...data,
|
|
228
|
-
serializedResolvedPropsWithCustomSchema: no_react_1.NoReactInternals.serializeJSONWithDate({
|
|
229
|
-
data: props,
|
|
230
|
-
indent: undefined,
|
|
231
|
-
staticBase: null,
|
|
232
|
-
}).serializedString,
|
|
233
|
-
serializedDefaultPropsWithCustomSchema: no_react_1.NoReactInternals.serializeJSONWithDate({
|
|
234
|
-
data: defaultProps,
|
|
235
|
-
indent: undefined,
|
|
236
|
-
staticBase: null,
|
|
237
|
-
}).serializedString,
|
|
238
|
-
};
|
|
239
|
-
};
|
|
240
|
-
window.siteVersion = '10';
|
|
241
|
-
window.remotion_version = remotion_1.VERSION;
|
|
242
|
-
window.remotion_setBundleMode = exports.setBundleModeAndUpdate;
|
|
243
|
-
}
|