@remotion/vercel 4.0.463 → 4.0.465

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.
@@ -4,10 +4,55 @@ import path from "path";
4
4
 
5
5
  // src/internals/add-bundle.ts
6
6
  var REMOTION_SANDBOX_BUNDLE_DIR = "remotion-bundle";
7
+ var toPosixPath = (filePath) => {
8
+ return filePath.split(/[/\\]/).join("/");
9
+ };
10
+ var getAncestorDirectories = (relativePath) => {
11
+ const normalized = toPosixPath(relativePath);
12
+ const parts = normalized.split("/").filter(Boolean);
13
+ const dirs = [];
14
+ for (let i = 0;i < parts.length - 1; i++) {
15
+ dirs.push(parts.slice(0, i + 1).join("/"));
16
+ }
17
+ return dirs;
18
+ };
19
+ var toSandboxBundlePath = (relativePath) => {
20
+ return `${REMOTION_SANDBOX_BUNDLE_DIR}/${toPosixPath(relativePath)}`;
21
+ };
22
+
23
+ // src/internals/format-sandbox-error.ts
24
+ import { APIError } from "@vercel/sandbox";
25
+ var formatSandboxError = (error) => {
26
+ if (error instanceof APIError) {
27
+ const parts = [error.message];
28
+ if (error.json !== undefined) {
29
+ parts.push(`Response JSON: ${JSON.stringify(error.json)}`);
30
+ } else if (error.text) {
31
+ parts.push(`Response body: ${error.text}`);
32
+ }
33
+ return parts.join(`
34
+ `);
35
+ }
36
+ if (error instanceof Error) {
37
+ return error.message;
38
+ }
39
+ return String(error);
40
+ };
41
+ var rethrowSandboxError = ({
42
+ error,
43
+ operation,
44
+ sandboxPath
45
+ }) => {
46
+ const pathSuffix = sandboxPath ? ` at "${sandboxPath}"` : "";
47
+ throw new Error(`Failed to ${operation} in Vercel sandbox${pathSuffix}: ${formatSandboxError(error)}`, { cause: error instanceof Error ? error : undefined });
48
+ };
7
49
 
8
50
  // src/add-bundle-to-sandbox.ts
51
+ var resolveBundleDirectory = (bundleDir) => {
52
+ return path.resolve(bundleDir);
53
+ };
9
54
  async function getRemotionBundleFiles(bundleDir) {
10
- const fullBundleDir = path.join(process.cwd(), bundleDir);
55
+ const fullBundleDir = resolveBundleDirectory(bundleDir);
11
56
  const files = [];
12
57
  async function readDirRecursive(dir, basePath = "") {
13
58
  const entries = await readdir(dir, { withFileTypes: true });
@@ -18,32 +63,51 @@ async function getRemotionBundleFiles(bundleDir) {
18
63
  await readDirRecursive(fullPath, relativePath);
19
64
  } else {
20
65
  const content = await readFile(fullPath);
21
- files.push({ path: relativePath, content });
66
+ files.push({ path: toPosixPath(relativePath), content });
22
67
  }
23
68
  }
24
69
  }
25
70
  await readDirRecursive(fullBundleDir);
26
71
  return files;
27
72
  }
73
+ var collectBundleDirectories = (bundleFiles) => {
74
+ const dirs = new Set;
75
+ for (const file of bundleFiles) {
76
+ for (const dir of getAncestorDirectories(file.path)) {
77
+ dirs.add(dir);
78
+ }
79
+ }
80
+ return Array.from(dirs).sort();
81
+ };
28
82
  async function addBundleToSandbox({
29
83
  sandbox,
30
84
  bundleDir
31
85
  }) {
32
86
  const bundleFiles = await getRemotionBundleFiles(bundleDir);
33
- const dirs = new Set;
34
- for (const file of bundleFiles) {
35
- const dir = path.dirname(file.path);
36
- if (dir && dir !== ".") {
37
- dirs.add(dir);
87
+ const directories = collectBundleDirectories(bundleFiles);
88
+ for (const dir of directories) {
89
+ const sandboxPath = toSandboxBundlePath(dir);
90
+ try {
91
+ await sandbox.mkDir(sandboxPath);
92
+ } catch (error) {
93
+ rethrowSandboxError({
94
+ error,
95
+ operation: `create directory "${dir}"`,
96
+ sandboxPath
97
+ });
38
98
  }
39
99
  }
40
- for (const dir of Array.from(dirs).sort()) {
41
- await sandbox.mkDir(REMOTION_SANDBOX_BUNDLE_DIR + "/" + dir);
100
+ try {
101
+ await sandbox.writeFiles(bundleFiles.map((file) => ({
102
+ path: toSandboxBundlePath(file.path),
103
+ content: file.content
104
+ })));
105
+ } catch (error) {
106
+ rethrowSandboxError({
107
+ error,
108
+ operation: `upload ${bundleFiles.length} bundle file(s) to "${REMOTION_SANDBOX_BUNDLE_DIR}"`
109
+ });
42
110
  }
43
- await sandbox.writeFiles(bundleFiles.map((file) => ({
44
- path: REMOTION_SANDBOX_BUNDLE_DIR + "/" + file.path,
45
- content: file.content
46
- })));
47
111
  }
48
112
  // script-embed:render-still-script
49
113
  var script = `// src/scripts/render-still.ts
@@ -727,7 +791,7 @@ var proResProfileOptions = [
727
791
  "light",
728
792
  "proxy"
729
793
  ];
730
- var sequenceStyleSchema = {
794
+ var sequenceVisualStyleSchema = {
731
795
  "style.translate": {
732
796
  type: "translate",
733
797
  step: 1,
@@ -755,7 +819,9 @@ var sequenceStyleSchema = {
755
819
  step: 0.01,
756
820
  default: 1,
757
821
  description: "Opacity"
758
- },
822
+ }
823
+ };
824
+ var sequencePremountSchema = {
759
825
  premountFor: {
760
826
  type: "number",
761
827
  default: 0,
@@ -773,6 +839,10 @@ var sequenceStyleSchema = {
773
839
  type: "hidden"
774
840
  }
775
841
  };
842
+ var sequenceStyleSchema = {
843
+ ...sequenceVisualStyleSchema,
844
+ ...sequencePremountSchema
845
+ };
776
846
  var hiddenField = {
777
847
  type: "boolean",
778
848
  default: false,
@@ -1750,7 +1820,7 @@ var proResProfileOptions = [
1750
1820
  "light",
1751
1821
  "proxy"
1752
1822
  ];
1753
- var sequenceStyleSchema = {
1823
+ var sequenceVisualStyleSchema = {
1754
1824
  "style.translate": {
1755
1825
  type: "translate",
1756
1826
  step: 1,
@@ -1778,7 +1848,9 @@ var sequenceStyleSchema = {
1778
1848
  step: 0.01,
1779
1849
  default: 1,
1780
1850
  description: "Opacity"
1781
- },
1851
+ }
1852
+ };
1853
+ var sequencePremountSchema = {
1782
1854
  premountFor: {
1783
1855
  type: "number",
1784
1856
  default: 0,
@@ -1796,6 +1868,10 @@ var sequenceStyleSchema = {
1796
1868
  type: "hidden"
1797
1869
  }
1798
1870
  };
1871
+ var sequenceStyleSchema = {
1872
+ ...sequenceVisualStyleSchema,
1873
+ ...sequencePremountSchema
1874
+ };
1799
1875
  var hiddenField = {
1800
1876
  type: "boolean",
1801
1877
  default: false,
@@ -1 +1,4 @@
1
1
  export declare const REMOTION_SANDBOX_BUNDLE_DIR = "remotion-bundle";
2
+ export declare const toPosixPath: (filePath: string) => string;
3
+ export declare const getAncestorDirectories: (relativePath: string) => string[];
4
+ export declare const toSandboxBundlePath: (relativePath: string) => string;
@@ -0,0 +1,6 @@
1
+ export declare const formatSandboxError: (error: unknown) => string;
2
+ export declare const rethrowSandboxError: ({ error, operation, sandboxPath, }: {
3
+ error: unknown;
4
+ operation: string;
5
+ sandboxPath?: string | undefined;
6
+ }) => never;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/vercel",
3
- "version": "4.0.463",
3
+ "version": "4.0.465",
4
4
  "description": "Render Remotion videos on Vercel Sandbox",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -23,8 +23,8 @@
23
23
  "url": "https://github.com/remotion-dev/remotion/issues"
24
24
  },
25
25
  "dependencies": {
26
- "@remotion/renderer": "4.0.463",
27
- "remotion": "4.0.463"
26
+ "@remotion/renderer": "4.0.465",
27
+ "remotion": "4.0.465"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "@vercel/sandbox": ">=1.0.0"
@@ -38,7 +38,7 @@
38
38
  "./package.json": "./package.json"
39
39
  },
40
40
  "devDependencies": {
41
- "@remotion/eslint-config-internal": "4.0.463",
41
+ "@remotion/eslint-config-internal": "4.0.465",
42
42
  "@vercel/blob": "2.3.0",
43
43
  "@vercel/sandbox": "1.6.0",
44
44
  "eslint": "9.19.0",