@remotion/vercel 4.0.462 → 4.0.464

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,7 +839,17 @@ var sequenceStyleSchema = {
773
839
  type: "hidden"
774
840
  }
775
841
  };
842
+ var sequenceStyleSchema = {
843
+ ...sequenceVisualStyleSchema,
844
+ ...sequencePremountSchema
845
+ };
846
+ var hiddenField = {
847
+ type: "boolean",
848
+ default: false,
849
+ description: "Hidden"
850
+ };
776
851
  var sequenceSchema = {
852
+ hidden: hiddenField,
777
853
  layout: {
778
854
  type: "enum",
779
855
  default: "absolute-fill",
@@ -1744,7 +1820,7 @@ var proResProfileOptions = [
1744
1820
  "light",
1745
1821
  "proxy"
1746
1822
  ];
1747
- var sequenceStyleSchema = {
1823
+ var sequenceVisualStyleSchema = {
1748
1824
  "style.translate": {
1749
1825
  type: "translate",
1750
1826
  step: 1,
@@ -1772,7 +1848,9 @@ var sequenceStyleSchema = {
1772
1848
  step: 0.01,
1773
1849
  default: 1,
1774
1850
  description: "Opacity"
1775
- },
1851
+ }
1852
+ };
1853
+ var sequencePremountSchema = {
1776
1854
  premountFor: {
1777
1855
  type: "number",
1778
1856
  default: 0,
@@ -1790,7 +1868,17 @@ var sequenceStyleSchema = {
1790
1868
  type: "hidden"
1791
1869
  }
1792
1870
  };
1871
+ var sequenceStyleSchema = {
1872
+ ...sequenceVisualStyleSchema,
1873
+ ...sequencePremountSchema
1874
+ };
1875
+ var hiddenField = {
1876
+ type: "boolean",
1877
+ default: false,
1878
+ description: "Hidden"
1879
+ };
1793
1880
  var sequenceSchema = {
1881
+ hidden: hiddenField,
1794
1882
  layout: {
1795
1883
  type: "enum",
1796
1884
  default: "absolute-fill",
@@ -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.462",
3
+ "version": "4.0.464",
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.462",
27
- "remotion": "4.0.462"
26
+ "@remotion/renderer": "4.0.464",
27
+ "remotion": "4.0.464"
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.462",
41
+ "@remotion/eslint-config-internal": "4.0.464",
42
42
  "@vercel/blob": "2.3.0",
43
43
  "@vercel/sandbox": "1.6.0",
44
44
  "eslint": "9.19.0",