@remotion/bundler 4.0.136 → 4.0.138

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 CHANGED
@@ -161,9 +161,9 @@ const internalBundle = async (actualArgs) => {
161
161
  if (errors !== undefined && errors.length > 0) {
162
162
  throw new Error(errors[0].message + '\n' + errors[0].details);
163
163
  }
164
- const baseDir = (_g = actualArgs === null || actualArgs === void 0 ? void 0 : actualArgs.publicPath) !== null && _g !== void 0 ? _g : '/';
164
+ const publicPath = (_g = actualArgs === null || actualArgs === void 0 ? void 0 : actualArgs.publicPath) !== null && _g !== void 0 ? _g : '/';
165
165
  const staticHash = '/' +
166
- [trimTrailingSlash(trimLeadingSlash(baseDir)), 'public']
166
+ [trimTrailingSlash(trimLeadingSlash(publicPath)), 'public']
167
167
  .filter(Boolean)
168
168
  .join('/');
169
169
  const from = (options === null || options === void 0 ? void 0 : options.publicDir)
@@ -195,7 +195,7 @@ const internalBundle = async (actualArgs) => {
195
195
  }
196
196
  const html = (0, index_html_1.indexHtml)({
197
197
  staticHash,
198
- baseDir,
198
+ publicPath,
199
199
  editorName: null,
200
200
  inputProps: null,
201
201
  remotionRoot: resolvedRemotionRoot,
@@ -213,10 +213,10 @@ const internalBundle = async (actualArgs) => {
213
213
  name: f.name.split(node_path_1.default.sep).join('/'),
214
214
  };
215
215
  }),
216
- includeFavicon: false,
216
+ includeFavicon: true,
217
217
  title: 'Remotion Bundle',
218
218
  renderDefaults: undefined,
219
- publicFolderExists: `${baseDir + (baseDir.endsWith('/') ? '' : '/')}public`,
219
+ publicFolderExists: `${publicPath + (publicPath.endsWith('/') ? '' : '/')}public`,
220
220
  gitSource: (_h = actualArgs.gitSource) !== null && _h !== void 0 ? _h : null,
221
221
  projectName: (0, studio_shared_1.getProjectName)({
222
222
  gitSource: (_j = actualArgs.gitSource) !== null && _j !== void 0 ? _j : null,
@@ -0,0 +1,20 @@
1
+ import type { Compiler } from 'webpack';
2
+ export declare class CaseSensitivePathsPlugin {
3
+ fs: Compiler['inputFileSystem'];
4
+ context: string;
5
+ cacheMap: Map<string, string[]>;
6
+ deferrerMap: Map<string, Promise<string[]>>;
7
+ /**
8
+ * Check if resource need to be checked
9
+ */
10
+ isCheckable(res: string, type?: string, issuer?: string): boolean;
11
+ /**
12
+ * Check if file exists with case sensitive
13
+ */
14
+ checkFileExistsWithCase(res: string): Promise<unknown>;
15
+ /**
16
+ * reset this plugin, wait for the next compilation
17
+ */
18
+ reset(): void;
19
+ apply(compiler: Compiler): void;
20
+ }
@@ -0,0 +1,143 @@
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.CaseSensitivePathsPlugin = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ // Inlined from https://github.com/umijs/case-sensitive-paths-webpack-plugin/blob/master/src/index.ts
9
+ /**
10
+ * The MIT License (MIT)
11
+
12
+ Copyright (c) 2022-present UmiJS Team
13
+
14
+ Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ of this software and associated documentation files (the "Software"), to deal
16
+ in the Software without restriction, including without limitation the rights
17
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ copies of the Software, and to permit persons to whom the Software is
19
+ furnished to do so, subject to the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be included in
22
+ all copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30
+ THE SOFTWARE.
31
+ */
32
+ const PLUGIN_NAME = 'CaseSensitive';
33
+ class CaseSensitivePathsPlugin {
34
+ constructor() {
35
+ this.context = '';
36
+ this.cacheMap = new Map();
37
+ this.deferrerMap = new Map();
38
+ }
39
+ /**
40
+ * Check if resource need to be checked
41
+ */
42
+ isCheckable(res, type, issuer) {
43
+ return (
44
+ // skip base64 url in css files
45
+ type !== 'asset/inline' &&
46
+ // skip resources which outside project
47
+ res.startsWith(this.context) &&
48
+ // skip node_modules
49
+ !/(\/|\\)node_modules\1/.test(res) &&
50
+ // skip duplicated css resource by unknown reason
51
+ res !== issuer);
52
+ }
53
+ /**
54
+ * Check if file exists with case sensitive
55
+ */
56
+ checkFileExistsWithCase(res) {
57
+ return new Promise((resolve, reject) => {
58
+ let full = res;
59
+ let caseError = null;
60
+ const deferrers = [];
61
+ // check every level directories for resource, except outside project
62
+ while (full.length > this.context.length) {
63
+ const { dir, base: current } = path_1.default.parse(full);
64
+ let deferrer;
65
+ if (this.cacheMap.get(dir)) {
66
+ // use cache first
67
+ deferrer = Promise.resolve(this.cacheMap.get(dir));
68
+ }
69
+ else if (this.deferrerMap.get(dir)) {
70
+ // wait another same directory to be resolved
71
+ deferrer = this.deferrerMap.get(dir);
72
+ }
73
+ else {
74
+ // read directory for the first time
75
+ deferrer = new Promise((resolve2) => {
76
+ this.fs.readdir(dir, (_, files = []) => {
77
+ // save cache, resolve promise and release deferrer
78
+ this.cacheMap.set(dir, files);
79
+ resolve2(files);
80
+ this.deferrerMap.delete(dir);
81
+ });
82
+ });
83
+ // save deferrer for another called
84
+ this.deferrerMap.set(dir, deferrer);
85
+ }
86
+ // check current file synchronously, for performance
87
+ deferrer.then((files) => {
88
+ // try to find correct name
89
+ // if current file not exists in current directory and there has no existing error
90
+ if (!files.includes(current) && !caseError) {
91
+ const correctName = files.find((file) => file.toLowerCase() === current.toLowerCase());
92
+ // only throw first error for the single resource
93
+ if (correctName) {
94
+ caseError = new Error(`Capitalization mismatch in \`${path_1.default.join(res)}\`: \`${current}\` does not match the name on disk \`${correctName}\``);
95
+ reject(caseError);
96
+ }
97
+ }
98
+ });
99
+ deferrers.push(deferrer);
100
+ // continue to check upper directory
101
+ full = dir;
102
+ }
103
+ Promise.all(deferrers).then(() => {
104
+ // resolve if no error
105
+ if (!caseError) {
106
+ resolve(caseError);
107
+ }
108
+ });
109
+ });
110
+ }
111
+ /**
112
+ * reset this plugin, wait for the next compilation
113
+ */
114
+ reset() {
115
+ this.cacheMap = new Map();
116
+ this.deferrerMap = new Map();
117
+ }
118
+ apply(compiler) {
119
+ this.context = compiler.options.context || process.cwd();
120
+ this.fs = compiler.inputFileSystem;
121
+ compiler.hooks.normalModuleFactory.tap(PLUGIN_NAME, (factory) => {
122
+ factory.hooks.afterResolve.tapAsync(PLUGIN_NAME, (data, done) => {
123
+ var _a, _b;
124
+ // compatible with webpack 4.x
125
+ const { createData = data } = data;
126
+ if (createData.resource &&
127
+ this.isCheckable(createData.resource, createData.type, (_b = (_a = createData.resourceResolveData) === null || _a === void 0 ? void 0 : _a.context) === null || _b === void 0 ? void 0 : _b.issuer)) {
128
+ this.checkFileExistsWithCase(createData.resource
129
+ .replace(/\?.+$/, '')
130
+ // replace escaped \0# with # see: https://github.com/webpack/enhanced-resolve#escaping
131
+ .replace('\u0000#', '#')).then(() => done(null), (err) => done(err));
132
+ }
133
+ else {
134
+ done(null);
135
+ }
136
+ });
137
+ });
138
+ compiler.hooks.done.tap(PLUGIN_NAME, () => {
139
+ this.reset();
140
+ });
141
+ }
142
+ }
143
+ exports.CaseSensitivePathsPlugin = CaseSensitivePathsPlugin;
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="bun-types" />
2
3
  import fs from 'node:fs';
3
4
  export declare function copyDir({ src, dest, onSymlinkDetected, onProgress, copiedBytes, lastReportedProgress, }: {
4
5
  src: string;
@@ -1,8 +1,8 @@
1
1
  import type { GitSource, RenderDefaults } from '@remotion/studio';
2
2
  import type { StaticFile } from 'remotion';
3
- export declare const indexHtml: ({ baseDir, editorName, inputProps, envVariables, staticHash, remotionRoot, studioServerCommand, renderQueue, numberOfAudioTags, publicFiles, includeFavicon, title, renderDefaults, publicFolderExists, gitSource, projectName, }: {
3
+ export declare const indexHtml: ({ publicPath, editorName, inputProps, envVariables, staticHash, remotionRoot, studioServerCommand, renderQueue, numberOfAudioTags, publicFiles, includeFavicon, title, renderDefaults, publicFolderExists, gitSource, projectName, }: {
4
4
  staticHash: string;
5
- baseDir: string;
5
+ publicPath: string;
6
6
  editorName: string | null;
7
7
  inputProps: object | null;
8
8
  envVariables?: Record<string, string> | undefined;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.indexHtml = void 0;
4
4
  const remotion_1 = require("remotion");
5
- const indexHtml = ({ baseDir, editorName, inputProps, envVariables, staticHash, remotionRoot, studioServerCommand, renderQueue, numberOfAudioTags, publicFiles, includeFavicon, title, renderDefaults, publicFolderExists, gitSource, projectName, }) =>
5
+ const indexHtml = ({ publicPath, editorName, inputProps, envVariables, staticHash, remotionRoot, studioServerCommand, renderQueue, numberOfAudioTags, publicFiles, includeFavicon, title, renderDefaults, publicFolderExists, gitSource, projectName, }) =>
6
6
  // Must setup remotion_editorName and remotion.remotion_projectName before bundle.js is loaded
7
7
  `
8
8
  <!DOCTYPE html>
@@ -12,7 +12,7 @@ const indexHtml = ({ baseDir, editorName, inputProps, envVariables, staticHash,
12
12
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
13
13
  <link rel="preconnect" href="https://fonts.gstatic.com" />
14
14
  ${includeFavicon
15
- ? `<link id="__remotion_favicon" rel="icon" type="image/png" href="/remotion.png" />`
15
+ ? `<link id="__remotion_favicon" rel="icon" type="image/png" href="${publicPath}favicon.ico" />`
16
16
  : ''}
17
17
  <title>${title}</title>
18
18
  </head>
@@ -23,6 +23,7 @@ const indexHtml = ({ baseDir, editorName, inputProps, envVariables, staticHash,
23
23
  ? `<script>window.remotion_editorName = "${editorName}";</script>`
24
24
  : '<script>window.remotion_editorName = null;</script>'}
25
25
  <script>window.remotion_projectName = ${JSON.stringify(projectName)};</script>
26
+ <script>window.remotion_publicPath = ${JSON.stringify(publicPath)};</script>
26
27
  <script>window.remotion_renderDefaults = ${JSON.stringify(renderDefaults)};</script>
27
28
  <script>window.remotion_cwd = ${JSON.stringify(remotionRoot)};</script>
28
29
  <script>window.remotion_studioServerCommand = ${studioServerCommand ? JSON.stringify(studioServerCommand) : 'null'};</script>
@@ -51,7 +52,7 @@ const indexHtml = ({ baseDir, editorName, inputProps, envVariables, staticHash,
51
52
  <div id="menuportal-5"></div>
52
53
  <div id="remotion-error-overlay"></div>
53
54
  <div id="server-disconnected-overlay"></div>
54
- <script src="${baseDir}bundle.js"></script>
55
+ <script src="${publicPath}bundle.js"></script>
55
56
  </body>
56
57
  </html>
57
58
  `.trim();
package/dist/index.d.ts CHANGED
@@ -16,9 +16,9 @@ export declare const BundlerInternals: {
16
16
  remotionRoot: string;
17
17
  poll: number | null;
18
18
  }) => Promise<[string, webpack.Configuration]>;
19
- indexHtml: ({ baseDir, editorName, inputProps, envVariables, staticHash, remotionRoot, studioServerCommand, renderQueue, numberOfAudioTags, publicFiles, includeFavicon, title, renderDefaults, publicFolderExists, gitSource, projectName, }: {
19
+ indexHtml: ({ publicPath, editorName, inputProps, envVariables, staticHash, remotionRoot, studioServerCommand, renderQueue, numberOfAudioTags, publicFiles, includeFavicon, title, renderDefaults, publicFolderExists, gitSource, projectName, }: {
20
20
  staticHash: string;
21
- baseDir: string;
21
+ publicPath: string;
22
22
  editorName: string | null;
23
23
  inputProps: object | null;
24
24
  envVariables?: Record<string, string> | undefined;
@@ -66,6 +66,6 @@ export declare const BundlerInternals: {
66
66
  } & import("./bundle").MandatoryLegacyBundleOptions) => Promise<string>;
67
67
  };
68
68
  export type { GitSource } from '@remotion/studio';
69
- export { bundle, BundleOptions, LegacyBundleOptions, MandatoryLegacyBundleOptions, } from './bundle';
69
+ export { BundleOptions, LegacyBundleOptions, MandatoryLegacyBundleOptions, bundle, } from './bundle';
70
70
  export { WebpackConfiguration, WebpackOverrideFn } from './webpack-config';
71
71
  export { webpack };
@@ -35,6 +35,7 @@ const stringify_with_circular_references_1 = require("./stringify-with-circular-
35
35
  const webpack_cache_1 = require("./webpack-cache");
36
36
  const esbuild = require("esbuild");
37
37
  const no_react_1 = require("remotion/no-react");
38
+ const case_sensitive_paths_1 = require("./case-sensitive-paths");
38
39
  const optional_dependencies_1 = require("./optional-dependencies");
39
40
  if (!(react_dom_1.default === null || react_dom_1.default === void 0 ? void 0 : react_dom_1.default.version)) {
40
41
  throw new Error('Could not find "react-dom" package. Did you install it?');
@@ -96,6 +97,7 @@ const webpackConfig = async ({ entry, userDefinedComponent, outDir, environment,
96
97
  plugins: environment === 'development'
97
98
  ? [
98
99
  new fast_refresh_1.ReactFreshWebpackPlugin(),
100
+ new case_sensitive_paths_1.CaseSensitivePathsPlugin(),
99
101
  new webpack_1.default.HotModuleReplacementPlugin(),
100
102
  define,
101
103
  new optional_dependencies_1.AllowOptionalDependenciesPlugin(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/bundler",
3
- "version": "4.0.136",
3
+ "version": "4.0.138",
4
4
  "description": "Bundler for Remotion",
5
5
  "main": "dist/index.js",
6
6
  "sideEffects": false,
@@ -25,25 +25,25 @@
25
25
  "style-loader": "2.0.0",
26
26
  "source-map": "0.7.3",
27
27
  "webpack": "5.83.1",
28
- "remotion": "4.0.136",
29
- "@remotion/studio": "4.0.136",
30
- "@remotion/studio-shared": "4.0.136"
28
+ "remotion": "4.0.138",
29
+ "@remotion/studio": "4.0.138",
30
+ "@remotion/studio-shared": "4.0.138"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "react": ">=16.8.0",
34
34
  "react-dom": ">=16.8.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@jonny/eslint-config": "3.0.276",
37
+ "@jonny/eslint-config": "3.0.281",
38
38
  "@types/node": "18.14.6",
39
39
  "bun-types": "0.8.0",
40
40
  "@types/react": "18.2.48",
41
41
  "@types/react-dom": "18.2.18",
42
- "eslint": "8.42.0",
42
+ "eslint": "8.56.0",
43
43
  "eslint-plugin-10x": "1.5.2",
44
44
  "eslint-plugin-react": "7.32.2",
45
45
  "eslint-plugin-react-hooks": "4.4.0",
46
- "prettier": "3.1.1",
46
+ "prettier": "3.2.5",
47
47
  "prettier-plugin-organize-imports": "3.2.4",
48
48
  "react": "18.2.0",
49
49
  "react-dom": "18.2.0",
@@ -1,3 +0,0 @@
1
- import type { BundleState } from 'remotion';
2
- export declare const setBundleMode: (state: BundleState) => void;
3
- export declare const getBundleMode: () => BundleState;
@@ -1,14 +0,0 @@
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;
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export declare const Homepage: React.FC;
@@ -1,108 +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 = () => {
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;
@@ -1,2 +0,0 @@
1
- import type { BundleState } from 'remotion';
2
- export declare const setBundleModeAndUpdate: (state: BundleState) => void;
@@ -1,274 +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, '#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
- }