@remotion/bundler 4.1.0-alpha10 → 4.1.0-alpha12

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
@@ -186,7 +186,7 @@ async function bundle(...args) {
186
186
  dest: to,
187
187
  onSymlinkDetected: showSymlinkWarning,
188
188
  onProgress: (prog) => { var _a; return (_a = options.onPublicDirCopyProgress) === null || _a === void 0 ? void 0 : _a.call(options, prog); },
189
- copied: 0,
189
+ copiedBytes: 0,
190
190
  lastReportedProgress: 0,
191
191
  });
192
192
  }
@@ -208,6 +208,7 @@ async function bundle(...args) {
208
208
  includeFavicon: false,
209
209
  title: 'Remotion Bundle',
210
210
  renderDefaults: undefined,
211
+ publicFolderExists: baseDir + '/public',
211
212
  });
212
213
  node_fs_1.default.writeFileSync(node_path_1.default.join(outDir, 'index.html'), html);
213
214
  return outDir;
@@ -1,10 +1,10 @@
1
1
  /// <reference types="node" />
2
2
  import fs from 'node:fs';
3
- export declare function copyDir({ src, dest, onSymlinkDetected, onProgress, copied, lastReportedProgress, }: {
3
+ export declare function copyDir({ src, dest, onSymlinkDetected, onProgress, copiedBytes, lastReportedProgress, }: {
4
4
  src: string;
5
5
  dest: string;
6
6
  onSymlinkDetected: (entry: fs.Dirent, dir: string) => void;
7
7
  onProgress: (bytes: number) => void;
8
- copied: number;
8
+ copiedBytes: number;
9
9
  lastReportedProgress: number;
10
- }): Promise<void>;
10
+ }): Promise<number>;
package/dist/copy-dir.js CHANGED
@@ -6,19 +6,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.copyDir = void 0;
7
7
  const node_fs_1 = __importDefault(require("node:fs"));
8
8
  const node_path_1 = __importDefault(require("node:path"));
9
- async function copyDir({ src, dest, onSymlinkDetected, onProgress, copied = 0, lastReportedProgress = 0, }) {
9
+ async function copyDir({ src, dest, onSymlinkDetected, onProgress, copiedBytes = 0, lastReportedProgress = 0, }) {
10
10
  await node_fs_1.default.promises.mkdir(dest, { recursive: true });
11
11
  const entries = await node_fs_1.default.promises.readdir(src, { withFileTypes: true });
12
12
  for (const entry of entries) {
13
13
  const srcPath = node_path_1.default.join(src, entry.name);
14
14
  const destPath = node_path_1.default.join(dest, entry.name);
15
15
  if (entry.isDirectory()) {
16
- await copyDir({
16
+ copiedBytes = await copyDir({
17
17
  src: srcPath,
18
18
  dest: destPath,
19
19
  onSymlinkDetected,
20
20
  onProgress,
21
- copied,
21
+ copiedBytes,
22
22
  lastReportedProgress,
23
23
  });
24
24
  }
@@ -32,12 +32,13 @@ async function copyDir({ src, dest, onSymlinkDetected, onProgress, copied = 0, l
32
32
  node_fs_1.default.promises.copyFile(srcPath, destPath),
33
33
  node_fs_1.default.promises.stat(srcPath),
34
34
  ]);
35
- copied += size;
36
- if (copied - lastReportedProgress > 1024 * 1024 * 10) {
37
- onProgress(copied);
38
- lastReportedProgress = copied;
35
+ copiedBytes += size;
36
+ if (copiedBytes - lastReportedProgress > 1024 * 1024 * 10) {
37
+ onProgress(copiedBytes);
38
+ lastReportedProgress = copiedBytes;
39
39
  }
40
40
  }
41
41
  }
42
+ return copiedBytes;
42
43
  }
43
44
  exports.copyDir = copyDir;
@@ -29,7 +29,7 @@ declare global {
29
29
  remotion_renderDefaults: RenderDefaults | undefined;
30
30
  }
31
31
  }
32
- export declare const indexHtml: ({ baseDir, editorName, inputProps, envVariables, staticHash, remotionRoot, studioServerCommand, renderQueue, numberOfAudioTags, publicFiles, includeFavicon, title, renderDefaults, }: {
32
+ export declare const indexHtml: ({ baseDir, editorName, inputProps, envVariables, staticHash, remotionRoot, studioServerCommand, renderQueue, numberOfAudioTags, publicFiles, includeFavicon, title, renderDefaults, publicFolderExists, }: {
33
33
  staticHash: string;
34
34
  baseDir: string;
35
35
  editorName: string | null;
@@ -40,6 +40,7 @@ export declare const indexHtml: ({ baseDir, editorName, inputProps, envVariables
40
40
  renderQueue: unknown | null;
41
41
  numberOfAudioTags: number;
42
42
  publicFiles: StaticFile[];
43
+ publicFolderExists: string | null;
43
44
  includeFavicon: boolean;
44
45
  title: string;
45
46
  renderDefaults: RenderDefaults | undefined;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.indexHtml = void 0;
7
7
  const node_path_1 = __importDefault(require("node:path"));
8
8
  const remotion_1 = require("remotion");
9
- const indexHtml = ({ baseDir, editorName, inputProps, envVariables, staticHash, remotionRoot, studioServerCommand, renderQueue, numberOfAudioTags, publicFiles, includeFavicon, title, renderDefaults, }) => `
9
+ const indexHtml = ({ baseDir, editorName, inputProps, envVariables, staticHash, remotionRoot, studioServerCommand, renderQueue, numberOfAudioTags, publicFiles, includeFavicon, title, renderDefaults, publicFolderExists, }) => `
10
10
  <!DOCTYPE html>
11
11
  <html lang="en">
12
12
  <head>
@@ -45,6 +45,7 @@ ${includeFavicon
45
45
  `
46
46
  : ''}
47
47
  <script>window.remotion_staticFiles = ${JSON.stringify(publicFiles)}</script>
48
+ <script>window.remotion_publicFolderExists = ${publicFolderExists ? `"${publicFolderExists}"` : 'null'};</script>
48
49
 
49
50
  <div id="${remotion_1.Internals.REMOTION_STUDIO_CONTAINER_ELEMENT}"></div>
50
51
  <div id="menuportal-0"></div>
package/dist/index.d.ts CHANGED
@@ -16,7 +16,7 @@ export declare const BundlerInternals: {
16
16
  remotionRoot: string;
17
17
  poll: number | null;
18
18
  }) => [string, webpack.Configuration];
19
- indexHtml: ({ baseDir, editorName, inputProps, envVariables, staticHash, remotionRoot, studioServerCommand, renderQueue, numberOfAudioTags, publicFiles, includeFavicon, title, renderDefaults, }: {
19
+ indexHtml: ({ baseDir, editorName, inputProps, envVariables, staticHash, remotionRoot, studioServerCommand, renderQueue, numberOfAudioTags, publicFiles, includeFavicon, title, renderDefaults, publicFolderExists, }: {
20
20
  staticHash: string;
21
21
  baseDir: string;
22
22
  editorName: string | null;
@@ -27,6 +27,7 @@ export declare const BundlerInternals: {
27
27
  renderQueue: unknown;
28
28
  numberOfAudioTags: number;
29
29
  publicFiles: import("remotion").StaticFile[];
30
+ publicFolderExists: string | null;
30
31
  includeFavicon: boolean;
31
32
  title: string;
32
33
  renderDefaults: import("./index-html").RenderDefaults | undefined;
@@ -29,6 +29,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.readRecursively = void 0;
30
30
  const node_fs_1 = __importStar(require("node:fs"));
31
31
  const node_path_1 = __importDefault(require("node:path"));
32
+ // There can be symbolic links that point to files that don't exist.
33
+ // https://github.com/remotion-dev/remotion/issues/2587
34
+ const statOrNull = (p) => {
35
+ try {
36
+ return (0, node_fs_1.statSync)(p);
37
+ }
38
+ catch (err) {
39
+ return null;
40
+ }
41
+ };
42
+ const encodeBySplitting = (p) => {
43
+ // Intentional: split by path.sep, then join by /
44
+ const splitBySlash = p.split(node_path_1.default.sep);
45
+ const encodedArray = splitBySlash.map((element) => {
46
+ return encodeURIComponent(element);
47
+ });
48
+ const merged = encodedArray.join('/');
49
+ return merged;
50
+ };
32
51
  const readRecursively = ({ folder, output = [], startPath, staticHash, limit, }) => {
33
52
  const absFolder = node_path_1.default.join(startPath, folder);
34
53
  if (!node_fs_1.default.existsSync(absFolder)) {
@@ -42,7 +61,10 @@ const readRecursively = ({ folder, output = [], startPath, staticHash, limit, })
42
61
  if (file.startsWith('.DS_Store')) {
43
62
  continue;
44
63
  }
45
- const stat = (0, node_fs_1.statSync)(node_path_1.default.join(absFolder, file));
64
+ const stat = statOrNull(node_path_1.default.join(absFolder, file));
65
+ if (!stat) {
66
+ continue;
67
+ }
46
68
  if (stat.isDirectory()) {
47
69
  (0, exports.readRecursively)({
48
70
  startPath,
@@ -57,18 +79,21 @@ const readRecursively = ({ folder, output = [], startPath, staticHash, limit, })
57
79
  name: node_path_1.default.join(folder, file),
58
80
  lastModified: Math.floor(stat.mtimeMs),
59
81
  sizeInBytes: stat.size,
60
- src: staticHash + '/' + encodeURIComponent(node_path_1.default.join(folder, file)),
82
+ src: staticHash + '/' + encodeBySplitting(node_path_1.default.join(folder, file)),
61
83
  });
62
84
  }
63
85
  else if (stat.isSymbolicLink()) {
64
86
  const realpath = node_fs_1.default.realpathSync(node_path_1.default.join(folder, file));
65
- const realStat = node_fs_1.default.statSync(realpath);
87
+ const realStat = statOrNull(realpath);
88
+ if (!realStat) {
89
+ continue;
90
+ }
66
91
  if (realStat.isFile()) {
67
92
  output.push({
68
93
  name: realpath,
69
94
  lastModified: Math.floor(realStat.mtimeMs),
70
95
  sizeInBytes: realStat.size,
71
- src: staticHash + '/' + encodeURIComponent(realpath),
96
+ src: staticHash + '/' + encodeBySplitting(realpath),
72
97
  });
73
98
  }
74
99
  }
@@ -117,6 +117,7 @@ const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpa
117
117
  alias: {
118
118
  // Only one version of react
119
119
  'react/jsx-runtime': require.resolve('react/jsx-runtime'),
120
+ 'react/jsx-dev-runtime': require.resolve('react/jsx-dev-runtime'),
120
121
  react: require.resolve('react'),
121
122
  'react-dom/client': shouldUseReactDomClient
122
123
  ? require.resolve('react-dom/client')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/bundler",
3
- "version": "4.1.0-alpha10",
3
+ "version": "4.1.0-alpha12",
4
4
  "description": "Bundler for Remotion",
5
5
  "main": "dist/index.js",
6
6
  "sideEffects": false,
@@ -22,7 +22,7 @@
22
22
  "react-refresh": "0.9.0",
23
23
  "style-loader": "2.0.0",
24
24
  "webpack": "5.83.1",
25
- "remotion": "4.1.0-alpha10"
25
+ "remotion": "4.1.0-alpha12"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "react": ">=16.8.0",
@@ -1,6 +0,0 @@
1
- import type { SerializedJSONWithCustomFields } from 'remotion';
2
- export declare const serializeJSONWithDate: ({ data, indent, staticBase, }: {
3
- data: Record<string, unknown>;
4
- indent: number | undefined;
5
- staticBase: string | null;
6
- }) => SerializedJSONWithCustomFields;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.serializeJSONWithDate = void 0;
4
- // Keep in sync with /packages/core/src/input-props-serialization.ts
5
- const DATE_TOKEN = 'remotion-date:';
6
- const FILE_TOKEN = 'remotion-file:';
7
- const serializeJSONWithDate = ({ data, indent, staticBase, }) => {
8
- let customDateUsed = false;
9
- let customFileUsed = false;
10
- let mapUsed = false;
11
- let setUsed = false;
12
- const serializedString = JSON.stringify(data, function (key, value) {
13
- const item = this[key];
14
- if (item instanceof Date) {
15
- customDateUsed = true;
16
- return `${DATE_TOKEN}${item.toISOString()}`;
17
- }
18
- if (item instanceof Map) {
19
- mapUsed = true;
20
- return value;
21
- }
22
- if (item instanceof Set) {
23
- setUsed = true;
24
- return value;
25
- }
26
- if (typeof item === 'string' &&
27
- staticBase !== null &&
28
- item.startsWith(staticBase)) {
29
- customFileUsed = true;
30
- return `${FILE_TOKEN}${item.replace(staticBase + '/', '')}`;
31
- }
32
- return value;
33
- }, indent);
34
- return { serializedString, customDateUsed, customFileUsed, mapUsed, setUsed };
35
- };
36
- exports.serializeJSONWithDate = serializeJSONWithDate;