@remotion/bundler 4.0.126 → 4.0.128

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ import type { BundleState } from 'remotion';
2
+ export declare const setBundleMode: (state: BundleState) => void;
3
+ export declare const getBundleMode: () => BundleState;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBundleMode = exports.setBundleMode = void 0;
4
+ let bundleMode = {
5
+ type: 'index',
6
+ };
7
+ const setBundleMode = (state) => {
8
+ bundleMode = state;
9
+ };
10
+ exports.setBundleMode = setBundleMode;
11
+ const getBundleMode = () => {
12
+ return bundleMode;
13
+ };
14
+ exports.getBundleMode = getBundleMode;
package/dist/bundle.d.ts CHANGED
@@ -1,16 +1,17 @@
1
1
  import type { GitSource } from '@remotion/studio-shared';
2
2
  import webpack from 'webpack';
3
3
  import type { WebpackOverrideFn } from './webpack-config';
4
- export type LegacyBundleOptions = {
5
- webpackOverride?: WebpackOverrideFn;
6
- outDir?: string;
7
- enableCaching?: boolean;
8
- publicPath?: string;
9
- rootDir?: string;
10
- publicDir?: string | null;
11
- onPublicDirCopyProgress?: (bytes: number) => void;
12
- onSymlinkDetected?: (path: string) => void;
4
+ export type MandatoryLegacyBundleOptions = {
5
+ webpackOverride: WebpackOverrideFn;
6
+ outDir: string | null;
7
+ enableCaching: boolean;
8
+ publicPath: string | null;
9
+ rootDir: string | null;
10
+ publicDir: string | null;
11
+ onPublicDirCopyProgress: (bytes: number) => void;
12
+ onSymlinkDetected: (path: string) => void;
13
13
  };
14
+ export type LegacyBundleOptions = Partial<MandatoryLegacyBundleOptions>;
14
15
  export declare const getConfig: ({ entryPoint, outDir, resolvedRemotionRoot, onProgress, options, bufferStateDelayInMilliseconds, maxTimelineTracks, }: {
15
16
  outDir: string;
16
17
  entryPoint: string;
@@ -18,25 +19,32 @@ export declare const getConfig: ({ entryPoint, outDir, resolvedRemotionRoot, onP
18
19
  bufferStateDelayInMilliseconds: number | null;
19
20
  maxTimelineTracks: number | null;
20
21
  onProgress?: ((progress: number) => void) | undefined;
21
- options?: LegacyBundleOptions | undefined;
22
+ options?: Partial<MandatoryLegacyBundleOptions> | undefined;
22
23
  }) => Promise<[string, webpack.Configuration]>;
24
+ type NewBundleOptions = {
25
+ entryPoint: string;
26
+ onProgress: (progress: number) => void;
27
+ ignoreRegisterRootWarning: boolean;
28
+ onDirectoryCreated: (dir: string) => void;
29
+ gitSource: GitSource | null;
30
+ maxTimelineTracks: number | null;
31
+ bufferStateDelayInMilliseconds: number | null;
32
+ };
33
+ type MandatoryBundleOptions = {
34
+ entryPoint: string;
35
+ } & NewBundleOptions & MandatoryLegacyBundleOptions;
23
36
  export type BundleOptions = {
24
37
  entryPoint: string;
25
- onProgress?: (progress: number) => void;
26
- ignoreRegisterRootWarning?: boolean;
27
- onDirectoryCreated?: (dir: string) => void;
28
- gitSource?: GitSource | null;
29
- maxTimelineTracks?: number;
30
- bufferStateDelayInMilliseconds?: number;
31
- } & LegacyBundleOptions;
38
+ } & Partial<NewBundleOptions> & LegacyBundleOptions;
32
39
  type Arguments = [options: BundleOptions] | [
33
40
  entryPoint: string,
34
41
  onProgress?: (progress: number) => void,
35
42
  options?: LegacyBundleOptions
36
43
  ];
37
44
  export declare const findClosestFolderWithItem: (currentDir: string, file: string) => string | null;
45
+ export declare const internalBundle: (actualArgs: MandatoryBundleOptions) => Promise<string>;
38
46
  /**
39
- * @description The method bundles a Remotion project using Webpack and prepares it for rendering using renderMedia()
47
+ * @description The method bundles a Remotion project using Webpack and prepares it for rendering.
40
48
  * @see [Documentation](https://www.remotion.dev/docs/bundle)
41
49
  */
42
50
  export declare function bundle(...args: Arguments): Promise<string>;
package/dist/bundle.js CHANGED
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.bundle = exports.findClosestFolderWithItem = exports.getConfig = void 0;
29
+ exports.bundle = exports.internalBundle = exports.findClosestFolderWithItem = exports.getConfig = void 0;
30
30
  const studio_shared_1 = require("@remotion/studio-shared");
31
31
  const node_fs_1 = __importStar(require("node:fs"));
32
32
  const node_os_1 = __importDefault(require("node:os"));
@@ -123,13 +123,8 @@ const validateEntryPoint = async (entryPoint) => {
123
123
  ].join(' '));
124
124
  }
125
125
  };
126
- /**
127
- * @description The method bundles a Remotion project using Webpack and prepares it for rendering using renderMedia()
128
- * @see [Documentation](https://www.remotion.dev/docs/bundle)
129
- */
130
- async function bundle(...args) {
126
+ const internalBundle = async (actualArgs) => {
131
127
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
132
- const actualArgs = convertArgumentsIntoOptions(args);
133
128
  const entryPoint = node_path_1.default.resolve(process.cwd(), actualArgs.entryPoint);
134
129
  const resolvedRemotionRoot = (_b = (_a = actualArgs === null || actualArgs === void 0 ? void 0 : actualArgs.rootDir) !== null && _a !== void 0 ? _a : findClosestPackageJsonFolder(entryPoint)) !== null && _b !== void 0 ? _b : process.cwd();
135
130
  if (!actualArgs.ignoreRegisterRootWarning) {
@@ -233,5 +228,32 @@ async function bundle(...args) {
233
228
  node_fs_1.default.copyFileSync(node_path_1.default.join(__dirname, '../favicon.ico'), node_path_1.default.join(outDir, 'favicon.ico'));
234
229
  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('/', '')));
235
230
  return outDir;
231
+ };
232
+ exports.internalBundle = internalBundle;
233
+ /**
234
+ * @description The method bundles a Remotion project using Webpack and prepares it for rendering.
235
+ * @see [Documentation](https://www.remotion.dev/docs/bundle)
236
+ */
237
+ async function bundle(...args) {
238
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
239
+ const actualArgs = convertArgumentsIntoOptions(args);
240
+ const result = await (0, exports.internalBundle)({
241
+ bufferStateDelayInMilliseconds: (_a = actualArgs.bufferStateDelayInMilliseconds) !== null && _a !== void 0 ? _a : null,
242
+ enableCaching: (_b = actualArgs.enableCaching) !== null && _b !== void 0 ? _b : true,
243
+ entryPoint: actualArgs.entryPoint,
244
+ gitSource: (_c = actualArgs.gitSource) !== null && _c !== void 0 ? _c : null,
245
+ ignoreRegisterRootWarning: (_d = actualArgs.ignoreRegisterRootWarning) !== null && _d !== void 0 ? _d : false,
246
+ maxTimelineTracks: (_e = actualArgs.maxTimelineTracks) !== null && _e !== void 0 ? _e : null,
247
+ onDirectoryCreated: (_f = actualArgs.onDirectoryCreated) !== null && _f !== void 0 ? _f : (() => { }),
248
+ onProgress: (_g = actualArgs.onProgress) !== null && _g !== void 0 ? _g : (() => { }),
249
+ onPublicDirCopyProgress: (_h = actualArgs.onPublicDirCopyProgress) !== null && _h !== void 0 ? _h : (() => { }),
250
+ onSymlinkDetected: (_j = actualArgs.onSymlinkDetected) !== null && _j !== void 0 ? _j : (() => { }),
251
+ outDir: (_k = actualArgs.outDir) !== null && _k !== void 0 ? _k : null,
252
+ publicDir: (_l = actualArgs.publicDir) !== null && _l !== void 0 ? _l : null,
253
+ publicPath: (_m = actualArgs.publicPath) !== null && _m !== void 0 ? _m : null,
254
+ rootDir: (_o = actualArgs.rootDir) !== null && _o !== void 0 ? _o : null,
255
+ webpackOverride: (_p = actualArgs.webpackOverride) !== null && _p !== void 0 ? _p : ((f) => f),
256
+ });
257
+ return result;
236
258
  }
237
259
  exports.bundle = bundle;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const Homepage: React.FC;
@@ -0,0 +1,108 @@
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 = () => {
105
+ const url = window.location.origin + window.location.pathname;
106
+ return ((0, jsx_runtime_1.jsxs)("div", { style: container, children: [(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", {})] }));
107
+ };
108
+ exports.Homepage = Homepage;
package/dist/index.d.ts CHANGED
@@ -43,7 +43,7 @@ export declare const BundlerInternals: {
43
43
  bufferStateDelayInMilliseconds: number | null;
44
44
  maxTimelineTracks: number | null;
45
45
  onProgress?: ((progress: number) => void) | undefined;
46
- options?: import("./bundle").LegacyBundleOptions | undefined;
46
+ options?: Partial<import("./bundle").MandatoryLegacyBundleOptions> | undefined;
47
47
  }) => Promise<[string, webpack.Configuration]>;
48
48
  readRecursively: ({ folder, output, startPath, staticHash, limit, }: {
49
49
  folder: string;
@@ -53,8 +53,19 @@ export declare const BundlerInternals: {
53
53
  limit: number;
54
54
  }) => import("remotion").StaticFile[];
55
55
  findClosestFolderWithItem: (currentDir: string, file: string) => string | null;
56
+ internalBundle: (actualArgs: {
57
+ entryPoint: string;
58
+ } & {
59
+ entryPoint: string;
60
+ onProgress: (progress: number) => void;
61
+ ignoreRegisterRootWarning: boolean;
62
+ onDirectoryCreated: (dir: string) => void;
63
+ gitSource: import("@remotion/studio").GitSource | null;
64
+ maxTimelineTracks: number | null;
65
+ bufferStateDelayInMilliseconds: number | null;
66
+ } & import("./bundle").MandatoryLegacyBundleOptions) => Promise<string>;
56
67
  };
57
68
  export type { GitSource } from '@remotion/studio';
58
- export { bundle, BundleOptions, LegacyBundleOptions } from './bundle';
69
+ export { bundle, BundleOptions, LegacyBundleOptions, MandatoryLegacyBundleOptions, } from './bundle';
59
70
  export { WebpackConfiguration, WebpackOverrideFn } from './webpack-config';
60
71
  export { webpack };
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@ exports.BundlerInternals = {
18
18
  getConfig: bundle_1.getConfig,
19
19
  readRecursively: read_recursively_1.readRecursively,
20
20
  findClosestFolderWithItem: bundle_1.findClosestFolderWithItem,
21
+ internalBundle: bundle_1.internalBundle,
21
22
  };
22
23
  var bundle_2 = require("./bundle");
23
24
  Object.defineProperty(exports, "bundle", { enumerable: true, get: function () { return bundle_2.bundle; } });
@@ -0,0 +1,2 @@
1
+ import type { BundleState } from 'remotion';
2
+ export declare const setBundleModeAndUpdate: (state: BundleState) => void;
@@ -0,0 +1,274 @@
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, '#fff'));
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 videoContainer = document.getElementById('video-container');
102
+ const explainerContainer = document.getElementById('explainer-container');
103
+ let cleanupVideoContainer = () => {
104
+ videoContainer.innerHTML = '';
105
+ };
106
+ let cleanupExplainerContainer = () => {
107
+ explainerContainer.innerHTML = '';
108
+ };
109
+ const waitForRootHandle = (0, remotion_1.delayRender)('Loading root component - See https://remotion.dev/docs/troubleshooting/loading-root-component if you experience a timeout');
110
+ const WaitForRoot = () => {
111
+ const [Root, setRoot] = (0, react_1.useState)(() => remotion_1.Internals.getRoot());
112
+ (0, react_1.useEffect)(() => {
113
+ if (Root) {
114
+ (0, remotion_1.continueRender)(waitForRootHandle);
115
+ return;
116
+ }
117
+ const cleanup = remotion_1.Internals.waitForRoot((NewRoot) => {
118
+ setRoot(() => NewRoot);
119
+ });
120
+ return () => cleanup();
121
+ }, [Root]);
122
+ if (Root === null) {
123
+ return null;
124
+ }
125
+ return (0, jsx_runtime_1.jsx)(Root, {});
126
+ };
127
+ const renderContent = () => {
128
+ const bundleMode = (0, bundle_mode_1.getBundleMode)();
129
+ if (bundleMode.type === 'composition' || bundleMode.type === 'evaluation') {
130
+ const markup = ((0, jsx_runtime_1.jsxs)(remotion_1.Internals.RemotionRoot, { numberOfAudioTags: 0, children: [(0, jsx_runtime_1.jsx)(WaitForRoot, {}), (0, jsx_runtime_1.jsx)(GetVideo, { state: bundleMode })] }));
131
+ if (client_1.default.createRoot) {
132
+ const root = client_1.default.createRoot(videoContainer);
133
+ root.render(markup);
134
+ cleanupVideoContainer = () => {
135
+ root.unmount();
136
+ };
137
+ }
138
+ else {
139
+ client_1.default.render(markup, videoContainer);
140
+ cleanupVideoContainer = () => {
141
+ client_1.default.unmountComponentAtNode(videoContainer);
142
+ };
143
+ }
144
+ }
145
+ else {
146
+ cleanupVideoContainer();
147
+ cleanupVideoContainer = () => {
148
+ videoContainer.innerHTML = '';
149
+ };
150
+ }
151
+ if (bundleMode.type === 'index' || bundleMode.type === 'evaluation') {
152
+ if (client_1.default.createRoot) {
153
+ const root = client_1.default.createRoot(explainerContainer);
154
+ root.render((0, jsx_runtime_1.jsx)(homepage_1.Homepage, {}));
155
+ cleanupExplainerContainer = () => {
156
+ root.unmount();
157
+ };
158
+ }
159
+ else {
160
+ const root = client_1.default;
161
+ root.render((0, jsx_runtime_1.jsx)(homepage_1.Homepage, {}), explainerContainer);
162
+ cleanupExplainerContainer = () => {
163
+ root.unmountComponentAtNode(explainerContainer);
164
+ };
165
+ }
166
+ }
167
+ else {
168
+ cleanupExplainerContainer();
169
+ cleanupExplainerContainer = () => {
170
+ explainerContainer.innerHTML = '';
171
+ };
172
+ }
173
+ };
174
+ renderContent();
175
+ const setBundleModeAndUpdate = (state) => {
176
+ (0, bundle_mode_1.setBundleMode)(state);
177
+ renderContent();
178
+ };
179
+ exports.setBundleModeAndUpdate = setBundleModeAndUpdate;
180
+ if (typeof window !== 'undefined') {
181
+ const getUnevaluatedComps = () => {
182
+ if (!remotion_1.Internals.getRoot()) {
183
+ 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.');
184
+ }
185
+ if (!remotion_1.Internals.compositionsRef.current) {
186
+ throw new Error('Unexpectedly did not have a CompositionManager');
187
+ }
188
+ const compositions = remotion_1.Internals.compositionsRef.current.getCompositions();
189
+ const canSerializeDefaultProps = getCanSerializeDefaultProps(compositions);
190
+ if (!canSerializeDefaultProps) {
191
+ console.warn('defaultProps are too big to serialize - trying to find the problematic composition...');
192
+ for (const comp of compositions) {
193
+ if (!getCanSerializeDefaultProps(comp)) {
194
+ 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`);
195
+ }
196
+ }
197
+ console.warn('Could not single out a problematic composition - The composition list as a whole is too big to serialize.');
198
+ 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');
199
+ }
200
+ return compositions;
201
+ };
202
+ window.getStaticCompositions = () => {
203
+ var _a;
204
+ const compositions = getUnevaluatedComps();
205
+ const inputProps = typeof window === 'undefined' || (0, remotion_1.getRemotionEnvironment)().isPlayer
206
+ ? {}
207
+ : (_a = (0, remotion_1.getInputProps)()) !== null && _a !== void 0 ? _a : {};
208
+ return Promise.all(compositions.map(async (c) => {
209
+ 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()"`);
210
+ const comp = remotion_1.Internals.resolveVideoConfig({
211
+ composition: c,
212
+ editorProps: {},
213
+ signal: new AbortController().signal,
214
+ inputProps,
215
+ });
216
+ const resolved = await Promise.resolve(comp);
217
+ (0, remotion_1.continueRender)(handle);
218
+ const { props, defaultProps, ...data } = resolved;
219
+ return {
220
+ ...data,
221
+ serializedResolvedPropsWithCustomSchema: no_react_1.NoReactInternals.serializeJSONWithDate({
222
+ data: props,
223
+ indent: undefined,
224
+ staticBase: null,
225
+ }).serializedString,
226
+ serializedDefaultPropsWithCustomSchema: no_react_1.NoReactInternals.serializeJSONWithDate({
227
+ data: defaultProps,
228
+ indent: undefined,
229
+ staticBase: null,
230
+ }).serializedString,
231
+ };
232
+ }));
233
+ };
234
+ window.remotion_getCompositionNames = () => {
235
+ return getUnevaluatedComps().map((c) => c.id);
236
+ };
237
+ window.remotion_calculateComposition = async (compId) => {
238
+ var _a;
239
+ const compositions = getUnevaluatedComps();
240
+ const selectedComp = compositions.find((c) => c.id === compId);
241
+ if (!selectedComp) {
242
+ throw new Error(`Could not find composition with ID ${compId}`);
243
+ }
244
+ const abortController = new AbortController();
245
+ const handle = (0, remotion_1.delayRender)(`Running the calculateMetadata() function for composition ${compId}`);
246
+ const inputProps = typeof window === 'undefined' || (0, remotion_1.getRemotionEnvironment)().isPlayer
247
+ ? {}
248
+ : (_a = (0, remotion_1.getInputProps)()) !== null && _a !== void 0 ? _a : {};
249
+ const prom = await Promise.resolve(remotion_1.Internals.resolveVideoConfig({
250
+ composition: selectedComp,
251
+ editorProps: {},
252
+ signal: abortController.signal,
253
+ inputProps,
254
+ }));
255
+ (0, remotion_1.continueRender)(handle);
256
+ const { props, defaultProps, ...data } = prom;
257
+ return {
258
+ ...data,
259
+ serializedResolvedPropsWithCustomSchema: no_react_1.NoReactInternals.serializeJSONWithDate({
260
+ data: props,
261
+ indent: undefined,
262
+ staticBase: null,
263
+ }).serializedString,
264
+ serializedDefaultPropsWithCustomSchema: no_react_1.NoReactInternals.serializeJSONWithDate({
265
+ data: defaultProps,
266
+ indent: undefined,
267
+ staticBase: null,
268
+ }).serializedString,
269
+ };
270
+ };
271
+ window.siteVersion = '10';
272
+ window.remotion_version = remotion_1.VERSION;
273
+ window.remotion_setBundleMode = exports.setBundleModeAndUpdate;
274
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/bundler",
3
- "version": "4.0.126",
3
+ "version": "4.0.128",
4
4
  "description": "Bundler for Remotion",
5
5
  "main": "dist/index.js",
6
6
  "sideEffects": false,
@@ -25,9 +25,9 @@
25
25
  "style-loader": "2.0.0",
26
26
  "source-map": "0.7.3",
27
27
  "webpack": "5.83.1",
28
- "remotion": "4.0.126",
29
- "@remotion/studio": "4.0.126",
30
- "@remotion/studio-shared": "4.0.126"
28
+ "remotion": "4.0.128",
29
+ "@remotion/studio": "4.0.128",
30
+ "@remotion/studio-shared": "4.0.128"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "react": ">=16.8.0",
package/renderEntry.tsx CHANGED
@@ -375,7 +375,11 @@ if (typeof window !== 'undefined') {
375
375
  const compositions = getUnevaluatedComps();
376
376
  const selectedComp = compositions.find((c) => c.id === compId);
377
377
  if (!selectedComp) {
378
- throw new Error(`Could not find composition with ID ${compId}`);
378
+ throw new Error(
379
+ `Could not find composition with ID ${compId}. Available compositions: ${compositions
380
+ .map((c) => c.id)
381
+ .join(', ')}`,
382
+ );
379
383
  }
380
384
 
381
385
  const abortController = new AbortController();