@remotion/bundler 4.0.0-alpha.217 → 4.0.0-alpha10

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
@@ -27,23 +27,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.bundle = exports.getConfig = void 0;
30
- const fs_1 = __importStar(require("fs"));
31
- const os_1 = __importDefault(require("os"));
32
- const path_1 = __importDefault(require("path"));
33
- const util_1 = require("util");
30
+ const node_fs_1 = __importStar(require("node:fs"));
31
+ const node_os_1 = __importDefault(require("node:os"));
32
+ const node_path_1 = __importDefault(require("node:path"));
33
+ const node_util_1 = require("node:util");
34
+ const node_worker_threads_1 = require("node:worker_threads");
34
35
  const webpack_1 = __importDefault(require("webpack"));
35
- const worker_threads_1 = require("worker_threads");
36
36
  const copy_dir_1 = require("./copy-dir");
37
37
  const index_html_1 = require("./index-html");
38
38
  const read_recursively_1 = require("./read-recursively");
39
39
  const webpack_config_1 = require("./webpack-config");
40
- const promisified = (0, util_1.promisify)(webpack_1.default);
40
+ const promisified = (0, node_util_1.promisify)(webpack_1.default);
41
41
  const prepareOutDir = async (specified) => {
42
42
  if (specified) {
43
- await fs_1.default.promises.mkdir(specified, { recursive: true });
43
+ await node_fs_1.default.promises.mkdir(specified, { recursive: true });
44
44
  return specified;
45
45
  }
46
- return fs_1.default.promises.mkdtemp(path_1.default.join(os_1.default.tmpdir(), 'remotion-webpack-bundle-'));
46
+ return node_fs_1.default.promises.mkdtemp(node_path_1.default.join(node_os_1.default.tmpdir(), 'remotion-webpack-bundle-'));
47
47
  };
48
48
  const trimLeadingSlash = (p) => {
49
49
  if (p.startsWith('/')) {
@@ -100,17 +100,17 @@ const recursionLimit = 5;
100
100
  const findClosestPackageJsonFolder = (currentDir) => {
101
101
  let possiblePackageJson = '';
102
102
  for (let i = 0; i < recursionLimit; i++) {
103
- possiblePackageJson = path_1.default.join(currentDir, 'package.json');
104
- const exists = fs_1.default.existsSync(possiblePackageJson);
103
+ possiblePackageJson = node_path_1.default.join(currentDir, 'package.json');
104
+ const exists = node_fs_1.default.existsSync(possiblePackageJson);
105
105
  if (exists) {
106
- return path_1.default.dirname(possiblePackageJson);
106
+ return node_path_1.default.dirname(possiblePackageJson);
107
107
  }
108
- currentDir = path_1.default.dirname(currentDir);
108
+ currentDir = node_path_1.default.dirname(currentDir);
109
109
  }
110
110
  return null;
111
111
  };
112
112
  const validateEntryPoint = async (entryPoint) => {
113
- const contents = await fs_1.promises.readFile(entryPoint, 'utf8');
113
+ const contents = await node_fs_1.promises.readFile(entryPoint, 'utf8');
114
114
  if (!contents.includes('registerRoot')) {
115
115
  throw new Error([
116
116
  `You passed ${entryPoint} as your entry point, but this file does not contain "registerRoot".`,
@@ -127,7 +127,7 @@ const validateEntryPoint = async (entryPoint) => {
127
127
  async function bundle(...args) {
128
128
  var _a, _b, _c, _d, _e;
129
129
  const actualArgs = convertArgumentsIntoOptions(args);
130
- const entryPoint = path_1.default.resolve(process.cwd(), actualArgs.entryPoint);
130
+ const entryPoint = node_path_1.default.resolve(process.cwd(), actualArgs.entryPoint);
131
131
  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();
132
132
  if (!actualArgs.ignoreRegisterRootWarning) {
133
133
  await validateEntryPoint(entryPoint);
@@ -138,7 +138,7 @@ async function bundle(...args) {
138
138
  // `process.cwd()`. The context should always be the Remotion root.
139
139
  // This is not supported in worker threads (used for tests)
140
140
  const currentCwd = process.cwd();
141
- if (worker_threads_1.isMainThread) {
141
+ if (node_worker_threads_1.isMainThread) {
142
142
  process.chdir(resolvedRemotionRoot);
143
143
  }
144
144
  const { onProgress, ...options } = actualArgs;
@@ -150,7 +150,7 @@ async function bundle(...args) {
150
150
  options,
151
151
  });
152
152
  const output = await promisified([config]);
153
- if (worker_threads_1.isMainThread) {
153
+ if (node_worker_threads_1.isMainThread) {
154
154
  process.chdir(currentCwd);
155
155
  }
156
156
  if (!output) {
@@ -166,15 +166,15 @@ async function bundle(...args) {
166
166
  .filter(Boolean)
167
167
  .join('/');
168
168
  const from = (options === null || options === void 0 ? void 0 : options.publicDir)
169
- ? path_1.default.resolve(resolvedRemotionRoot, options.publicDir)
170
- : path_1.default.join(resolvedRemotionRoot, 'public');
171
- const to = path_1.default.join(outDir, 'public');
169
+ ? node_path_1.default.resolve(resolvedRemotionRoot, options.publicDir)
170
+ : node_path_1.default.join(resolvedRemotionRoot, 'public');
171
+ const to = node_path_1.default.join(outDir, 'public');
172
172
  let symlinkWarningShown = false;
173
173
  const showSymlinkWarning = (ent, src) => {
174
174
  if (symlinkWarningShown) {
175
175
  return;
176
176
  }
177
- const absolutePath = path_1.default.join(src, ent.name);
177
+ const absolutePath = node_path_1.default.join(src, ent.name);
178
178
  if (options.onSymlinkDetected) {
179
179
  options.onSymlinkDetected(absolutePath);
180
180
  return;
@@ -182,7 +182,7 @@ async function bundle(...args) {
182
182
  symlinkWarningShown = true;
183
183
  console.warn(`\nFound a symbolic link in the public folder (${absolutePath}). The symlink will be forwarded into the bundle.`);
184
184
  };
185
- if (fs_1.default.existsSync(from)) {
185
+ if (node_fs_1.default.existsSync(from)) {
186
186
  await (0, copy_dir_1.copyDir)({
187
187
  src: from,
188
188
  dest: to,
@@ -197,7 +197,7 @@ async function bundle(...args) {
197
197
  editorName: null,
198
198
  inputProps: null,
199
199
  remotionRoot: resolvedRemotionRoot,
200
- previewServerCommand: null,
200
+ studioServerCommand: null,
201
201
  renderQueue: null,
202
202
  numberOfAudioTags: 0,
203
203
  publicFiles: (0, read_recursively_1.readRecursively)({
@@ -210,7 +210,7 @@ async function bundle(...args) {
210
210
  title: 'Remotion Bundle',
211
211
  renderDefaults: undefined,
212
212
  });
213
- fs_1.default.writeFileSync(path_1.default.join(outDir, 'index.html'), html);
213
+ node_fs_1.default.writeFileSync(node_path_1.default.join(outDir, 'index.html'), html);
214
214
  return outDir;
215
215
  }
216
216
  exports.bundle = bundle;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import fs from 'fs';
2
+ import fs from 'node:fs';
3
3
  export declare function copyDir({ src, dest, onSymlinkDetected, onProgress, copied, }: {
4
4
  src: string;
5
5
  dest: string;
package/dist/copy-dir.js CHANGED
@@ -4,14 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.copyDir = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_path_1 = __importDefault(require("node:path"));
9
9
  async function copyDir({ src, dest, onSymlinkDetected, onProgress, copied = 0, }) {
10
- await fs_1.default.promises.mkdir(dest, { recursive: true });
11
- const entries = await fs_1.default.promises.readdir(src, { withFileTypes: true });
10
+ await node_fs_1.default.promises.mkdir(dest, { recursive: true });
11
+ const entries = await node_fs_1.default.promises.readdir(src, { withFileTypes: true });
12
12
  for (const entry of entries) {
13
- const srcPath = path_1.default.join(src, entry.name);
14
- const destPath = path_1.default.join(dest, entry.name);
13
+ const srcPath = node_path_1.default.join(src, entry.name);
14
+ const destPath = node_path_1.default.join(dest, entry.name);
15
15
  if (entry.isDirectory()) {
16
16
  await copyDir({
17
17
  src: srcPath,
@@ -22,14 +22,14 @@ async function copyDir({ src, dest, onSymlinkDetected, onProgress, copied = 0, }
22
22
  });
23
23
  }
24
24
  else if (entry.isSymbolicLink()) {
25
- const realpath = await fs_1.default.promises.realpath(srcPath);
25
+ const realpath = await node_fs_1.default.promises.realpath(srcPath);
26
26
  onSymlinkDetected(entry, src);
27
- await fs_1.default.promises.symlink(realpath, destPath);
27
+ await node_fs_1.default.promises.symlink(realpath, destPath);
28
28
  }
29
29
  else {
30
30
  const [, { size }] = await Promise.all([
31
- fs_1.default.promises.copyFile(srcPath, destPath),
32
- fs_1.default.promises.stat(srcPath),
31
+ node_fs_1.default.promises.copyFile(srcPath, destPath),
32
+ node_fs_1.default.promises.stat(srcPath),
33
33
  ]);
34
34
  copied += size;
35
35
  onProgress(copied);
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const esbuild_1 = require("esbuild");
7
- const path_1 = __importDefault(require("path"));
7
+ const node_path_1 = __importDefault(require("node:path"));
8
8
  const isTsExtensionPtrn = /\.ts$/i;
9
9
  const isTypescriptInstalled = () => {
10
10
  try {
@@ -21,7 +21,7 @@ async function ESBuildLoader(source) {
21
21
  this.getOptions();
22
22
  const options = this.getOptions();
23
23
  const { implementation, ...esbuildTransformOptions } = options;
24
- const tsConfigPath = path_1.default.join(this.context, 'tsconfig.json');
24
+ const tsConfigPath = node_path_1.default.join(this.context, 'tsconfig.json');
25
25
  if (implementation && typeof implementation.transform !== 'function') {
26
26
  done(new TypeError(`esbuild-loader: options.implementation.transform must be an ESBuild transform function. Received ${typeof implementation.transform}`));
27
27
  return;
@@ -24,7 +24,6 @@ self.$RefreshInterceptModuleExecution$ = function (webpackModuleId) {
24
24
  };
25
25
  self.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
26
26
  // Modeled after `useEffect` cleanup pattern:
27
- // https://reactjs.org/docs/hooks-effect.html#effects-with-cleanup
28
27
  return () => {
29
28
  self.$RefreshReg$ = prevRefreshReg;
30
29
  self.$RefreshSig$ = prevRefreshSig;
@@ -24,7 +24,9 @@ const pre = {
24
24
  overflowX: 'auto',
25
25
  };
26
26
  const AvailableCompositions = () => {
27
- const [comps, setComps] = (0, react_1.useState)(null);
27
+ const [state, setComps] = (0, react_1.useState)({
28
+ type: 'not-initialized',
29
+ });
28
30
  (0, react_1.useEffect)(() => {
29
31
  if ((0, bundle_mode_1.getBundleMode)().type !== 'evaluation') {
30
32
  return;
@@ -32,8 +34,13 @@ const AvailableCompositions = () => {
32
34
  let timeout = null;
33
35
  const check = () => {
34
36
  if (window.ready === true) {
35
- const newComps = window.getStaticCompositions();
36
- setComps(newComps);
37
+ setComps({ type: 'loading' });
38
+ window
39
+ .getStaticCompositions()
40
+ .then((newComps) => {
41
+ setComps({ type: 'loaded', comps: newComps });
42
+ })
43
+ .catch((err) => ({ type: 'error', error: err }));
37
44
  }
38
45
  else {
39
46
  timeout = setTimeout(check, 250);
@@ -53,11 +60,20 @@ const AvailableCompositions = () => {
53
60
  if ((0, bundle_mode_1.getBundleMode)().type !== 'evaluation') {
54
61
  return ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: showComps, children: "Click here to see a list of available compositions." }));
55
62
  }
56
- return ((0, jsx_runtime_1.jsxs)("div", { children: [comps === null ? (0, jsx_runtime_1.jsx)("p", { children: "Loading compositions..." }) : null, (0, jsx_runtime_1.jsx)("ul", { children: comps === null
57
- ? []
58
- : comps.map((c) => {
59
- return (0, jsx_runtime_1.jsx)("li", { children: c.id }, c.id);
60
- }) })] }));
63
+ if (state.type === 'loading') {
64
+ return (0, jsx_runtime_1.jsx)("div", { children: state === null ? (0, jsx_runtime_1.jsx)("p", { children: "Loading compositions..." }) : null });
65
+ }
66
+ if (state.type === 'error') {
67
+ return (0, jsx_runtime_1.jsxs)("div", { children: ["Error loading compositions: ", state.error.stack] });
68
+ }
69
+ if (state.type === 'not-initialized') {
70
+ return (0, jsx_runtime_1.jsx)("div", { children: "Not initialized" });
71
+ }
72
+ return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("ul", { children: state === null
73
+ ? []
74
+ : state.comps.map((c) => {
75
+ return (0, jsx_runtime_1.jsx)("li", { children: c.id }, c.id);
76
+ }) }) }));
61
77
  };
62
78
  const TestCORS = () => {
63
79
  const [serveUrl, setServeUrl] = (0, react_1.useState)('');
@@ -29,14 +29,14 @@ declare global {
29
29
  remotion_renderDefaults: RenderDefaults | undefined;
30
30
  }
31
31
  }
32
- export declare const indexHtml: ({ baseDir, editorName, inputProps, envVariables, staticHash, remotionRoot, previewServerCommand, renderQueue, numberOfAudioTags, publicFiles, includeFavicon, title, renderDefaults, }: {
32
+ export declare const indexHtml: ({ baseDir, editorName, inputProps, envVariables, staticHash, remotionRoot, studioServerCommand, renderQueue, numberOfAudioTags, publicFiles, includeFavicon, title, renderDefaults, }: {
33
33
  staticHash: string;
34
34
  baseDir: string;
35
35
  editorName: string | null;
36
36
  inputProps: object | null;
37
37
  envVariables?: Record<string, string> | undefined;
38
38
  remotionRoot: string;
39
- previewServerCommand: string | null;
39
+ studioServerCommand: string | null;
40
40
  renderQueue: unknown | null;
41
41
  numberOfAudioTags: number;
42
42
  publicFiles: StaticFile[];
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.indexHtml = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const indexHtml = ({ baseDir, editorName, inputProps, envVariables, staticHash, remotionRoot, previewServerCommand, renderQueue, numberOfAudioTags, publicFiles, includeFavicon, title, renderDefaults, }) => `
7
+ const node_path_1 = __importDefault(require("node:path"));
8
+ const indexHtml = ({ baseDir, editorName, inputProps, envVariables, staticHash, remotionRoot, studioServerCommand, renderQueue, numberOfAudioTags, publicFiles, includeFavicon, title, renderDefaults, }) => `
9
9
  <!DOCTYPE html>
10
10
  <html lang="en">
11
11
  <head>
@@ -25,10 +25,10 @@ ${includeFavicon
25
25
  ${editorName
26
26
  ? `<script>window.remotion_editorName = "${editorName}";</script>`
27
27
  : '<script>window.remotion_editorName = null;</script>'}
28
- <script>window.remotion_projectName = ${JSON.stringify(path_1.default.basename(remotionRoot))};</script>
28
+ <script>window.remotion_projectName = ${JSON.stringify(node_path_1.default.basename(remotionRoot))};</script>
29
29
  <script>window.remotion_renderDefaults = ${JSON.stringify(renderDefaults)};</script>
30
30
  <script>window.remotion_cwd = ${JSON.stringify(remotionRoot)};</script>
31
- <script>window.remotion_previewServerCommand = ${previewServerCommand ? JSON.stringify(previewServerCommand) : 'null'};</script>
31
+ <script>window.remotion_studioServerCommand = ${studioServerCommand ? JSON.stringify(studioServerCommand) : 'null'};</script>
32
32
  ${inputProps
33
33
  ? `<script>window.remotion_inputProps = ${JSON.stringify(JSON.stringify(inputProps))};</script>
34
34
  `
package/dist/index.d.ts CHANGED
@@ -17,14 +17,14 @@ export declare const BundlerInternals: {
17
17
  remotionRoot: string;
18
18
  poll: number | null;
19
19
  }) => [string, webpack.Configuration];
20
- indexHtml: ({ baseDir, editorName, inputProps, envVariables, staticHash, remotionRoot, previewServerCommand, renderQueue, numberOfAudioTags, publicFiles, includeFavicon, title, renderDefaults, }: {
20
+ indexHtml: ({ baseDir, editorName, inputProps, envVariables, staticHash, remotionRoot, studioServerCommand, renderQueue, numberOfAudioTags, publicFiles, includeFavicon, title, renderDefaults, }: {
21
21
  staticHash: string;
22
22
  baseDir: string;
23
23
  editorName: string | null;
24
24
  inputProps: object | null;
25
25
  envVariables?: Record<string, string> | undefined;
26
26
  remotionRoot: string;
27
- previewServerCommand: string | null;
27
+ studioServerCommand: string | null;
28
28
  renderQueue: unknown;
29
29
  numberOfAudioTags: number;
30
30
  publicFiles: import("remotion").StaticFile[];
@@ -33,7 +33,7 @@ export declare const BundlerInternals: {
33
33
  renderDefaults: import("./index-html").RenderDefaults | undefined;
34
34
  }) => string;
35
35
  cacheExists: (remotionRoot: string, environment: "development" | "production", hash: string) => "exists" | "other-exists" | "does-not-exist";
36
- clearCache: (remotionRoot: string) => Promise<void>;
36
+ clearCache: (remotionRoot: string, env: "development" | "production") => Promise<void>;
37
37
  getConfig: ({ entryPoint, outDir, resolvedRemotionRoot, onProgress, options, }: {
38
38
  outDir: string;
39
39
  entryPoint: string;
@@ -0,0 +1,5 @@
1
+ import type { Compiler } from 'webpack';
2
+ export declare class AllowOptionalDependenciesPlugin {
3
+ filter(error: Error): boolean;
4
+ apply(compiler: Compiler): void;
5
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ // When Webpack cannot resolve these dependencies, it will not print an error message.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.AllowOptionalDependenciesPlugin = void 0;
5
+ const OPTIONAL_DEPENDENCIES = [
6
+ 'zod',
7
+ '@remotion/zod-types',
8
+ 'react-native-reanimated',
9
+ 'react-native-reanimated/package.json',
10
+ ];
11
+ class AllowOptionalDependenciesPlugin {
12
+ filter(error) {
13
+ for (const dependency of OPTIONAL_DEPENDENCIES) {
14
+ if (error.message.includes(`Can't resolve '${dependency}'`)) {
15
+ return false;
16
+ }
17
+ }
18
+ return true;
19
+ }
20
+ apply(compiler) {
21
+ compiler.hooks.afterEmit.tap('AllowOptionalDependenciesPlugin', (compilation) => {
22
+ compilation.errors = compilation.errors.filter(this.filter);
23
+ compilation.warnings = compilation.warnings.filter(this.filter);
24
+ });
25
+ }
26
+ }
27
+ exports.AllowOptionalDependenciesPlugin = AllowOptionalDependenciesPlugin;
@@ -0,0 +1,5 @@
1
+ import type { Compiler } from 'webpack';
2
+ export declare class AllowOptionalDependenciesPlugin {
3
+ filter(error: Error): boolean;
4
+ apply(compiler: Compiler): void;
5
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ // When Webpack cannot resolve these dependencies, it will not print an error message.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.AllowOptionalDependenciesPlugin = void 0;
5
+ const OPTIONAL_DEPENDENCIES = [
6
+ 'zod',
7
+ '@remotion/zod-types',
8
+ 'react-native-reanimated',
9
+ 'react-native-reanimated/package.json',
10
+ ];
11
+ class AllowOptionalDependenciesPlugin {
12
+ filter(error) {
13
+ for (const dependency of OPTIONAL_DEPENDENCIES) {
14
+ if (error.message.includes(`Can't resolve '${dependency}'`)) {
15
+ return false;
16
+ }
17
+ }
18
+ return true;
19
+ }
20
+ apply(compiler) {
21
+ compiler.hooks.afterEmit.tap('AllowOptionalDependenciesPlugin', (compilation) => {
22
+ compilation.errors = compilation.errors.filter(this.filter);
23
+ compilation.warnings = compilation.warnings.filter(this.filter);
24
+ });
25
+ }
26
+ }
27
+ exports.AllowOptionalDependenciesPlugin = AllowOptionalDependenciesPlugin;
@@ -27,14 +27,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.readRecursively = void 0;
30
- const fs_1 = __importStar(require("fs"));
31
- const path_1 = __importDefault(require("path"));
30
+ const node_fs_1 = __importStar(require("node:fs"));
31
+ const node_path_1 = __importDefault(require("node:path"));
32
32
  const readRecursively = ({ folder, output = [], startPath, staticHash, limit, }) => {
33
- const absFolder = path_1.default.join(startPath, folder);
34
- if (!fs_1.default.existsSync(absFolder)) {
33
+ const absFolder = node_path_1.default.join(startPath, folder);
34
+ if (!node_fs_1.default.existsSync(absFolder)) {
35
35
  return [];
36
36
  }
37
- const files = fs_1.default.readdirSync(absFolder);
37
+ const files = node_fs_1.default.readdirSync(absFolder);
38
38
  for (const file of files) {
39
39
  if (output.length >= limit) {
40
40
  break;
@@ -42,11 +42,11 @@ const readRecursively = ({ folder, output = [], startPath, staticHash, limit, })
42
42
  if (file.startsWith('.DS_Store')) {
43
43
  continue;
44
44
  }
45
- const stat = (0, fs_1.statSync)(path_1.default.join(absFolder, file));
45
+ const stat = (0, node_fs_1.statSync)(node_path_1.default.join(absFolder, file));
46
46
  if (stat.isDirectory()) {
47
47
  (0, exports.readRecursively)({
48
48
  startPath,
49
- folder: path_1.default.join(folder, file),
49
+ folder: node_path_1.default.join(folder, file),
50
50
  output,
51
51
  staticHash,
52
52
  limit,
@@ -54,21 +54,21 @@ const readRecursively = ({ folder, output = [], startPath, staticHash, limit, })
54
54
  }
55
55
  else if (stat.isFile()) {
56
56
  output.push({
57
- name: path_1.default.join(folder, file),
57
+ name: node_path_1.default.join(folder, file),
58
58
  lastModified: Math.floor(stat.mtimeMs),
59
59
  sizeInBytes: stat.size,
60
- src: staticHash + '/' + path_1.default.join(folder, file),
60
+ src: staticHash + '/' + encodeURIComponent(node_path_1.default.join(folder, file)),
61
61
  });
62
62
  }
63
63
  else if (stat.isSymbolicLink()) {
64
- const realpath = fs_1.default.realpathSync(path_1.default.join(folder, file));
65
- const realStat = fs_1.default.statSync(realpath);
64
+ const realpath = node_fs_1.default.realpathSync(node_path_1.default.join(folder, file));
65
+ const realStat = node_fs_1.default.statSync(realpath);
66
66
  if (realStat.isFile()) {
67
67
  output.push({
68
68
  name: realpath,
69
69
  lastModified: Math.floor(realStat.mtimeMs),
70
70
  sizeInBytes: realStat.size,
71
- src: staticHash + '/' + realpath,
71
+ src: staticHash + '/' + encodeURIComponent(realpath),
72
72
  });
73
73
  }
74
74
  }
@@ -44,7 +44,9 @@ const GetVideo = ({ state }) => {
44
44
  if (!video && compositions.compositions.length > 0) {
45
45
  const foundComposition = compositions.compositions.find((c) => c.id === state.compositionName);
46
46
  if (!foundComposition) {
47
- throw new Error('Found no composition with the name ' + state.compositionName);
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.`);
48
50
  }
49
51
  compositions.setCurrentComposition((_a = foundComposition === null || foundComposition === void 0 ? void 0 : foundComposition.id) !== null && _a !== void 0 ? _a : null);
50
52
  compositions.setCurrentCompositionMetadata({
@@ -186,18 +188,31 @@ if (typeof window !== 'undefined') {
186
188
  console.warn('Could not single out a problematic composition - The composition list as a whole is too big to serialize.');
187
189
  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');
188
190
  }
189
- return compositions.map((c) => {
190
- return {
191
- defaultProps: c.defaultProps,
192
- durationInFrames: c.durationInFrames,
193
- fps: c.fps,
194
- height: c.height,
195
- id: c.id,
196
- width: c.width,
197
- };
198
- });
191
+ return Promise.all(compositions.map((c) => {
192
+ return Promise.resolve(remotion_1.Internals.resolveVideoConfig({
193
+ composition: c,
194
+ editorProps: {},
195
+ signal: new AbortController().signal,
196
+ }));
197
+ }));
198
+ };
199
+ window.calculateComposition = (compId) => {
200
+ if (!remotion_1.Internals.compositionsRef.current) {
201
+ throw new Error('Unexpectedly did not have a CompositionManager');
202
+ }
203
+ const compositions = remotion_1.Internals.compositionsRef.current.getCompositions();
204
+ const selectedComp = compositions.find((c) => c.id === compId);
205
+ if (!selectedComp) {
206
+ throw new Error(`Could not find composition with ID ${compId}`);
207
+ }
208
+ const abortController = new AbortController();
209
+ return Promise.resolve(remotion_1.Internals.resolveVideoConfig({
210
+ composition: selectedComp,
211
+ editorProps: {},
212
+ signal: abortController.signal,
213
+ }));
199
214
  };
200
- window.siteVersion = '4';
215
+ window.siteVersion = '5';
201
216
  window.remotion_version = remotion_1.VERSION;
202
217
  window.setBundleMode = exports.setBundleModeAndUpdate;
203
218
  }
@@ -36,6 +36,7 @@ remotion_1.Internals.CSSUtils.injectCSS(`
36
36
  background-color: rgba(0, 0, 0, 1);
37
37
  }
38
38
 
39
+
39
40
  .__remotion-horizontal-scrollbar::-webkit-scrollbar {
40
41
  height: 6px;
41
42
  }
@@ -49,6 +50,29 @@ remotion_1.Internals.CSSUtils.injectCSS(`
49
50
  background-color: rgba(0, 0, 0, 1);
50
51
  }
51
52
 
53
+
54
+ @-moz-document url-prefix() {
55
+ .__remotion-vertical-scrollbar {
56
+ scrollbar-width: thin;
57
+ scrollbar-color: rgba(0, 0, 0, 0.6) rgba(0, 0, 0, 0);
58
+ }
59
+
60
+ .__remotion-vertical-scrollbar:hover {
61
+ scrollbar-color: rgba(0, 0, 0, 1) rgba(0, 0, 0, 0);
62
+ }
63
+
64
+ .__remotion-horizontal-scrollbar {
65
+ scrollbar-width: thin;
66
+ scrollbar-color: rgba(0, 0, 0, 0.6) rgba(0, 0, 0, 0);
67
+ }
68
+
69
+ .__remotion-horizontal-scrollbar:hover {
70
+ scrollbar-width: thin;
71
+ scrollbar-color: rgba(0, 0, 0, 1) rgba(0, 0, 0, 0);
72
+ }
73
+ }
74
+
75
+
52
76
  .__remotion-timeline-slider {
53
77
  appearance: none;
54
78
  width: 100px;
@@ -66,4 +90,6 @@ remotion_1.Internals.CSSUtils.injectCSS(`
66
90
  appearance: none;
67
91
  }
68
92
 
93
+
94
+
69
95
  `);
@@ -3,12 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const path_1 = __importDefault(require("path"));
6
+ const node_path_1 = __importDefault(require("node:path"));
7
7
  const vitest_1 = require("vitest");
8
8
  const validate_public_dir_1 = require("../validate-public-dir");
9
9
  (0, vitest_1.describe)('validatePublicDir()', () => {
10
10
  (0, vitest_1.test)('Should not allow root directory as public dir.', () => {
11
- (0, vitest_1.expect)(() => (0, validate_public_dir_1.validatePublicDir)(path_1.default.parse(process.cwd()).root)).toThrow(/which is the root directory. This is not allowed./);
11
+ (0, vitest_1.expect)(() => (0, validate_public_dir_1.validatePublicDir)(node_path_1.default.parse(process.cwd()).root)).toThrow(/which is the root directory. This is not allowed./);
12
12
  });
13
13
  (0, vitest_1.test)('Should not allow a path where the parent directory does not exist', () => {
14
14
  const pathToPass = process.platform === 'win32' ? 'C:\\foo\\bar' : '/foo/bar';
@@ -4,15 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.validatePublicDir = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_path_1 = __importDefault(require("node:path"));
9
9
  const validatePublicDir = (p) => {
10
- const { root } = path_1.default.parse(process.cwd());
10
+ const { root } = node_path_1.default.parse(process.cwd());
11
11
  if (p === root) {
12
12
  throw new Error(`The public directory was specified as "${p}", which is the root directory. This is not allowed.`);
13
13
  }
14
14
  try {
15
- const stat = fs_1.default.lstatSync(p);
15
+ const stat = node_fs_1.default.lstatSync(p);
16
16
  if (!stat.isDirectory()) {
17
17
  throw new Error(`The public directory was specified as "${p}", and while this path exists on the filesystem, it is not a directory.`);
18
18
  }
@@ -20,8 +20,8 @@ const validatePublicDir = (p) => {
20
20
  catch (e) {
21
21
  // Path does not exist
22
22
  // Check if the parent path exists
23
- const parentPath = path_1.default.dirname(p);
24
- const exists = fs_1.default.existsSync(parentPath);
23
+ const parentPath = node_path_1.default.dirname(p);
24
+ const exists = node_fs_1.default.existsSync(parentPath);
25
25
  if (!exists) {
26
26
  throw new Error(`The public directory was specified as "${p}", but this folder does not exist and the parent directory "${parentPath}" does also not exist. Create at least the parent directory.`);
27
27
  }
@@ -7,7 +7,8 @@ declare global {
7
7
  }
8
8
  }
9
9
  }
10
- export declare const clearCache: (remotionRoot: string) => Promise<void>;
10
+ export declare const clearCache: (remotionRoot: string, env: Environment) => Promise<void>;
11
+ export declare const getWebpackCacheEnvDir: (environment: Environment) => string;
11
12
  export declare const getWebpackCacheName: (environment: Environment, hash: string) => string;
12
13
  export declare const cacheExists: (remotionRoot: string, environment: Environment, hash: string) => CacheState;
13
14
  export {};
@@ -3,22 +3,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.cacheExists = exports.getWebpackCacheName = exports.clearCache = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
6
+ exports.cacheExists = exports.getWebpackCacheName = exports.getWebpackCacheEnvDir = exports.clearCache = void 0;
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_path_1 = __importDefault(require("node:path"));
9
9
  // Inlined from https://github.com/webpack/webpack/blob/4c2ee7a4ddb8db2362ca83b6c4190523387ba7ee/lib/config/defaults.js#L265
10
10
  // An algorithm to determine where Webpack will cache the depencies
11
11
  const getWebpackCacheDir = (remotionRoot) => {
12
12
  let dir = remotionRoot;
13
13
  for (;;) {
14
14
  try {
15
- if (fs_1.default.statSync(path_1.default.join(dir, 'package.json')).isFile()) {
15
+ if (node_fs_1.default.statSync(node_path_1.default.join(dir, 'package.json')).isFile()) {
16
16
  break;
17
17
  }
18
18
  // eslint-disable-next-line no-empty
19
19
  }
20
20
  catch (e) { }
21
- const parent = path_1.default.dirname(dir);
21
+ const parent = node_path_1.default.dirname(dir);
22
22
  if (dir === parent) {
23
23
  dir = undefined;
24
24
  break;
@@ -26,39 +26,41 @@ const getWebpackCacheDir = (remotionRoot) => {
26
26
  dir = parent;
27
27
  }
28
28
  if (!dir) {
29
- return path_1.default.resolve(remotionRoot, '.cache/webpack');
29
+ return node_path_1.default.resolve(remotionRoot, '.cache/webpack');
30
30
  }
31
31
  if (process.versions.pnp === '1') {
32
- return path_1.default.resolve(dir, '.pnp/.cache/webpack');
32
+ return node_path_1.default.resolve(dir, '.pnp/.cache/webpack');
33
33
  }
34
34
  if (process.versions.pnp === '3') {
35
- return path_1.default.resolve(dir, '.yarn/.cache/webpack');
35
+ return node_path_1.default.resolve(dir, '.yarn/.cache/webpack');
36
36
  }
37
- return path_1.default.resolve(dir, 'node_modules/.cache/webpack');
37
+ return node_path_1.default.resolve(dir, 'node_modules/.cache/webpack');
38
+ };
39
+ const remotionCacheLocationForEnv = (remotionRoot, environment) => {
40
+ return node_path_1.default.join(getWebpackCacheDir(remotionRoot), (0, exports.getWebpackCacheEnvDir)(environment));
38
41
  };
39
42
  const remotionCacheLocation = (remotionRoot, environment, hash) => {
40
- return path_1.default.join(getWebpackCacheDir(remotionRoot), (0, exports.getWebpackCacheName)(environment, hash));
43
+ return node_path_1.default.join(getWebpackCacheDir(remotionRoot), (0, exports.getWebpackCacheName)(environment, hash));
41
44
  };
42
- const clearCache = (remotionRoot) => {
43
- return fs_1.default.promises.rm(getWebpackCacheDir(remotionRoot), {
45
+ const clearCache = (remotionRoot, env) => {
46
+ return node_fs_1.default.promises.rm(remotionCacheLocationForEnv(remotionRoot, env), {
44
47
  recursive: true,
45
48
  });
46
49
  };
47
50
  exports.clearCache = clearCache;
48
51
  const getPrefix = (environment) => {
49
- return `remotion-v4-${environment}`;
52
+ return `remotion-v5-${environment}`;
53
+ };
54
+ const getWebpackCacheEnvDir = (environment) => {
55
+ return getPrefix(environment);
50
56
  };
57
+ exports.getWebpackCacheEnvDir = getWebpackCacheEnvDir;
51
58
  const getWebpackCacheName = (environment, hash) => {
52
- if (environment === 'development') {
53
- return `${getPrefix(environment)}-${hash}`;
54
- }
55
- // In production, the cache is independent from input props because
56
- // they are passed over URL params. Speed is mostly important in production.
57
- return `${getPrefix(environment)}-${hash}`;
59
+ return [(0, exports.getWebpackCacheEnvDir)(environment), hash].join(node_path_1.default.sep);
58
60
  };
59
61
  exports.getWebpackCacheName = getWebpackCacheName;
60
62
  const hasOtherCache = ({ remotionRoot, environment, }) => {
61
- const cacheDir = fs_1.default.readdirSync(getWebpackCacheDir(remotionRoot));
63
+ const cacheDir = node_fs_1.default.readdirSync(getWebpackCacheDir(remotionRoot));
62
64
  if (cacheDir.find((c) => {
63
65
  return c.startsWith(getPrefix(environment));
64
66
  })) {
@@ -67,10 +69,10 @@ const hasOtherCache = ({ remotionRoot, environment, }) => {
67
69
  return false;
68
70
  };
69
71
  const cacheExists = (remotionRoot, environment, hash) => {
70
- if (fs_1.default.existsSync(remotionCacheLocation(remotionRoot, environment, hash))) {
72
+ if (node_fs_1.default.existsSync(remotionCacheLocation(remotionRoot, environment, hash))) {
71
73
  return 'exists';
72
74
  }
73
- if (!fs_1.default.existsSync(getWebpackCacheDir(remotionRoot))) {
75
+ if (!node_fs_1.default.existsSync(getWebpackCacheDir(remotionRoot))) {
74
76
  return 'does-not-exist';
75
77
  }
76
78
  if (hasOtherCache({ remotionRoot, environment })) {
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.webpackConfig = void 0;
30
- const crypto_1 = require("crypto");
30
+ const node_crypto_1 = require("node:crypto");
31
31
  const react_dom_1 = __importDefault(require("react-dom"));
32
32
  const remotion_1 = require("remotion");
33
33
  const webpack_1 = __importStar(require("webpack"));
@@ -35,6 +35,7 @@ const fast_refresh_1 = require("./fast-refresh");
35
35
  const stringify_with_circular_references_1 = require("./stringify-with-circular-references");
36
36
  const webpack_cache_1 = require("./webpack-cache");
37
37
  const esbuild = require("esbuild");
38
+ const optional_dependencies_1 = require("./optional-dependencies");
38
39
  if (!react_dom_1.default || !react_dom_1.default.version) {
39
40
  throw new Error('Could not find "react-dom" package. Did you install it?');
40
41
  }
@@ -92,6 +93,7 @@ const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpa
92
93
  'process.env.KEYBOARD_SHORTCUTS_ENABLED': keyboardShortcutsEnabled,
93
94
  [`process.env.${remotion_1.Internals.ENV_VARIABLES_ENV_NAME}`]: JSON.stringify(envVariables),
94
95
  }),
96
+ new optional_dependencies_1.AllowOptionalDependenciesPlugin(),
95
97
  ]
96
98
  : [
97
99
  new webpack_1.ProgressPlugin((p) => {
@@ -99,10 +101,10 @@ const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpa
99
101
  onProgress(Number((p * 100).toFixed(2)));
100
102
  }
101
103
  }),
104
+ new optional_dependencies_1.AllowOptionalDependenciesPlugin(),
102
105
  ],
103
106
  output: {
104
107
  hashFunction: 'xxhash64',
105
- globalObject: 'this',
106
108
  filename: 'bundle.js',
107
109
  devtoolModuleFilenameTemplate: '[resource-path]',
108
110
  assetModuleFilename: environment === 'development' ? '[path][name][ext]' : '[hash][ext]',
@@ -117,7 +119,6 @@ const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpa
117
119
  ? require.resolve('react-dom/client')
118
120
  : require.resolve('react-dom'),
119
121
  remotion: require.resolve('remotion'),
120
- 'react-native$': 'react-native-web',
121
122
  },
122
123
  },
123
124
  module: {
@@ -168,7 +169,7 @@ const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpa
168
169
  ],
169
170
  },
170
171
  });
171
- const hash = (0, crypto_1.createHash)('md5')
172
+ const hash = (0, node_crypto_1.createHash)('md5')
172
173
  .update((0, stringify_with_circular_references_1.jsonStringifyWithCircularReferences)(conf))
173
174
  .digest('hex');
174
175
  return [
package/package.json CHANGED
@@ -1,67 +1,67 @@
1
1
  {
2
- "name": "@remotion/bundler",
3
- "version": "4.0.0-alpha.217+27eff7599",
4
- "description": "Bundler for Remotion",
5
- "main": "dist/index.js",
6
- "sideEffects": false,
7
- "repository": {
8
- "url": "https://github.com/remotion-dev/remotion"
9
- },
10
- "bugs": {
11
- "url": "https://github.com/remotion-dev/remotion/issues"
12
- },
13
- "scripts": {
14
- "lint": "eslint src --ext ts,tsx",
15
- "build": "tsc -d",
16
- "watch": "tsc -w",
17
- "test": "vitest --run"
18
- },
19
- "files": [
20
- "dist",
21
- "react-shim.js"
22
- ],
23
- "author": "Jonny Burger <jonny@remotion.dev>",
24
- "license": "SEE LICENSE IN LICENSE.md",
25
- "dependencies": {
26
- "css-loader": "5.2.7",
27
- "esbuild": "0.16.12",
28
- "react-refresh": "0.9.0",
29
- "remotion": "4.0.0-alpha.217+27eff7599",
30
- "style-loader": "2.0.0",
31
- "webpack": "5.76.1"
32
- },
33
- "peerDependencies": {
34
- "react": ">=16.8.0",
35
- "react-dom": ">=16.8.0"
36
- },
37
- "devDependencies": {
38
- "@jonny/eslint-config": "3.0.266",
39
- "@types/node": "^16.7.5",
40
- "@types/react": "18.0.26",
41
- "@types/react-dom": "18.0.10",
42
- "@typescript-eslint/eslint-plugin": "5.18.0",
43
- "@typescript-eslint/parser": "5.18.0",
44
- "eslint": "8.25.0",
45
- "eslint-plugin-10x": "1.5.2",
46
- "eslint-plugin-react": "7.29.4",
47
- "eslint-plugin-react-hooks": "4.4.0",
48
- "prettier": "^2.7.1",
49
- "prettier-plugin-organize-imports": "^2.3.4",
50
- "react": "^18.0.0",
51
- "react-dom": "^18.0.0",
52
- "typescript": "^4.7.0",
53
- "vitest": "0.24.3"
54
- },
55
- "keywords": [
56
- "remotion",
57
- "ffmpeg",
58
- "video",
59
- "react",
60
- "webpack",
61
- "player"
62
- ],
63
- "publishConfig": {
64
- "access": "public"
65
- },
66
- "gitHead": "27eff759935b19b666e29f4f46dd5bdd6214e188"
67
- }
2
+ "name": "@remotion/bundler",
3
+ "version": "4.0.0-alpha10",
4
+ "description": "Bundler for Remotion",
5
+ "main": "dist/index.js",
6
+ "sideEffects": false,
7
+ "repository": {
8
+ "url": "https://github.com/remotion-dev/remotion"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/remotion-dev/remotion/issues"
12
+ },
13
+ "files": [
14
+ "dist",
15
+ "react-shim.js"
16
+ ],
17
+ "author": "Jonny Burger <jonny@remotion.dev>",
18
+ "license": "SEE LICENSE IN LICENSE.md",
19
+ "dependencies": {
20
+ "css-loader": "5.2.7",
21
+ "esbuild": "0.16.12",
22
+ "react-refresh": "0.9.0",
23
+ "style-loader": "2.0.0",
24
+ "webpack": "5.83.1",
25
+ "remotion": "4.0.0-alpha10"
26
+ },
27
+ "peerDependencies": {
28
+ "react": ">=16.8.0",
29
+ "react-dom": ">=16.8.0"
30
+ },
31
+ "devDependencies": {
32
+ "@jonny/eslint-config": "3.0.266",
33
+ "@types/node": "18.14.6",
34
+ "@types/react": "18.0.26",
35
+ "@types/react-dom": "18.0.10",
36
+ "@typescript-eslint/eslint-plugin": "5.18.0",
37
+ "@typescript-eslint/parser": "5.18.0",
38
+ "eslint": "8.25.0",
39
+ "eslint-plugin-10x": "1.5.2",
40
+ "eslint-plugin-react": "7.29.4",
41
+ "eslint-plugin-react-hooks": "4.4.0",
42
+ "prettier": "^2.7.1",
43
+ "prettier-plugin-organize-imports": "^2.3.4",
44
+ "react": "^18.0.0",
45
+ "react-dom": "^18.0.0",
46
+ "typescript": "^4.7.0",
47
+ "vitest": "0.31.1"
48
+ },
49
+ "keywords": [
50
+ "remotion",
51
+ "ffmpeg",
52
+ "video",
53
+ "react",
54
+ "webpack",
55
+ "player"
56
+ ],
57
+ "publishConfig": {
58
+ "access": "public"
59
+ },
60
+ "scripts": {
61
+ "formatting": "prettier src --check",
62
+ "lint": "eslint src --ext ts,tsx",
63
+ "build": "tsc -d",
64
+ "watch": "tsc -w",
65
+ "test": "vitest --run"
66
+ }
67
+ }