@remotion/studio-server 4.0.519 → 4.0.520

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.
@@ -2,15 +2,7 @@ import type { ElementInstallExpectedFileState, PrepareElementInstallRequest } fr
2
2
  export declare const normalizeElementSourceForComparison: (source: string) => string;
3
3
  export declare const getElementSourceHash: (source: string) => string;
4
4
  export declare const validateElementInstallPosition: (position: import("@remotion/studio-shared").InsertableCompositionElementPosition | null) => void;
5
- export declare const validateElementForInstallation: (element: {
6
- dependencies: import("@remotion/studio-protocol").ElementDependency[];
7
- durationInFrames?: number | undefined;
8
- installationMode?: import("@remotion/studio-protocol").ElementInstallationMode | undefined;
9
- slug: string;
10
- displayName: string;
11
- sourceCode: string;
12
- dimensions: import("@remotion/studio-protocol").ComponentDimensions | null;
13
- }) => void;
5
+ export declare const validateElementForInstallation: (element: import("@remotion/studio-shared").InstallableElement) => void;
14
6
  export declare const makeRelativeElementImportPath: ({ fromFile, toFile, }: {
15
7
  fromFile: string;
16
8
  toFile: string;
@@ -23,14 +23,15 @@ const hasExpectedFileState = ({ expected, actual, }) => {
23
23
  return actual.sourceHash === expected.sourceHash;
24
24
  };
25
25
  const insertElementHandler = ({ input: { compositionFile, compositionId, element, expectedFileState, from, position, overwriteExisting, }, entryPoint, remotionRoot, logLevel, }) => (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
26
- var _a, _b;
27
26
  try {
28
27
  (0, element_install_plan_1.validateElementInstallPosition)(position);
29
28
  if (from !== null &&
30
29
  (!Number.isInteger(from) || !Number.isFinite(from) || from < 0)) {
31
30
  throw new Error('from must be a non-negative integer');
32
31
  }
33
- const installationMode = (_a = element.installationMode) !== null && _a !== void 0 ? _a : 'wrapped';
32
+ const installationMode = element.installationMode === null
33
+ ? 'wrapped'
34
+ : element.installationMode;
34
35
  const componentOwnsSequence = installationMode === 'component-owned-sequence';
35
36
  renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[insert-element] Received request for compositionFile="${compositionFile}" compositionId="${compositionId}" element="${element.slug}"`);
36
37
  const plan = await (0, element_install_plan_1.getElementInstallPlan)({
@@ -90,7 +91,7 @@ const insertElementHandler = ({ input: { compositionFile, compositionId, element
90
91
  importPath: plan.importPath,
91
92
  props: componentOwnsSequence
92
93
  ? [
93
- ...(element.durationInFrames === undefined
94
+ ...(element.durationInFrames === null
94
95
  ? []
95
96
  : [
96
97
  {
@@ -109,7 +110,7 @@ const insertElementHandler = ({ input: { compositionFile, compositionId, element
109
110
  ? null
110
111
  : {
111
112
  dimensions: element.dimensions,
112
- durationInFrames: (_b = element.durationInFrames) !== null && _b !== void 0 ? _b : null,
113
+ durationInFrames: element.durationInFrames,
113
114
  from,
114
115
  name: element.displayName,
115
116
  position,
@@ -1,19 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handleStudioProtocolElementLibrary = void 0;
4
- const zod_1 = require("zod");
4
+ const studio_protocol_1 = require("@remotion/studio-protocol");
5
5
  const element_install_state_1 = require("../element-install-state");
6
6
  const parse_body_1 = require("../parse-body");
7
7
  const origin_policy_1 = require("./origin-policy");
8
8
  const protocol_response_1 = require("./protocol-response");
9
- const studioProtocolElementLibraryRequestSchema = zod_1.z.object({
10
- operation: zod_1.z.literal('add-element-library'),
11
- protocol: zod_1.z.literal('remotion-studio-protocol'),
12
- protocolVersion: zod_1.z.literal(1),
13
- targetId: zod_1.z.string().min(1),
14
- url: zod_1.z.string(),
15
- displayName: zod_1.z.string().nullable(),
16
- });
17
9
  const MAX_STUDIO_PROTOCOL_ELEMENT_LIBRARY_BODY_SIZE = 16 * 1024;
18
10
  const handleStudioProtocolElementLibrary = async ({ configFile, focusStudioTab, liveEventsServer, request, response, }) => {
19
11
  var _a;
@@ -62,8 +54,8 @@ const handleStudioProtocolElementLibrary = async ({ configFile, focusStudioTab,
62
54
  });
63
55
  return;
64
56
  }
65
- const parsedRequest = studioProtocolElementLibraryRequestSchema.safeParse(body);
66
- if (!parsedRequest.success) {
57
+ const parsedRequest = studio_protocol_1.StudioProtocolInternals.parseStudioProtocolAddElementLibraryRequest(body);
58
+ if (parsedRequest === null) {
67
59
  (0, protocol_response_1.writeStudioProtocolError)({
68
60
  code: 'unsupported-protocol',
69
61
  message: 'Invalid Remotion Studio Protocol request.',
@@ -74,7 +66,7 @@ const handleStudioProtocolElementLibrary = async ({ configFile, focusStudioTab,
74
66
  }
75
67
  let normalizedUrl;
76
68
  try {
77
- const parsedUrl = new URL(parsedRequest.data.url);
69
+ const parsedUrl = new URL(parsedRequest.url);
78
70
  if (parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:') {
79
71
  throw new Error('Unsupported protocol');
80
72
  }
@@ -89,7 +81,7 @@ const handleStudioProtocolElementLibrary = async ({ configFile, focusStudioTab,
89
81
  });
90
82
  return;
91
83
  }
92
- const displayName = (_b = (_a = parsedRequest.data.displayName) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : null;
84
+ const displayName = (_b = (_a = parsedRequest.displayName) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : null;
93
85
  if (displayName === '') {
94
86
  (0, protocol_response_1.writeStudioProtocolError)({
95
87
  code: 'invalid-display-name',
@@ -103,7 +95,7 @@ const handleStudioProtocolElementLibrary = async ({ configFile, focusStudioTab,
103
95
  now: Date.now(),
104
96
  origin: requestOrigin,
105
97
  purpose: 'add-element-library',
106
- targetId: parsedRequest.data.targetId,
98
+ targetId: parsedRequest.targetId,
107
99
  });
108
100
  if (target === null) {
109
101
  (0, protocol_response_1.writeStudioProtocolError)({
@@ -2,22 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handleStudioProtocolInstall = void 0;
4
4
  const studio_protocol_1 = require("@remotion/studio-protocol");
5
- const zod_1 = require("zod");
6
5
  const element_install_state_1 = require("../element-install-state");
7
6
  const parse_body_1 = require("../parse-body");
8
7
  const origin_policy_1 = require("./origin-policy");
9
8
  const protocol_response_1 = require("./protocol-response");
10
- const studioProtocolInstallRequestSchema = zod_1.z.object({
11
- operation: zod_1.z.literal('install-element'),
12
- protocol: zod_1.z.literal('remotion-studio-protocol'),
13
- protocolVersion: zod_1.z.literal(1),
14
- targetId: zod_1.z.string(),
15
- payload: zod_1.z.unknown(),
16
- });
17
9
  // A valid payload may contain 250,000 JSON characters. Allow room for its
18
10
  // UTF-8 representation and the protocol envelope while keeping memory bounded.
19
11
  const MAX_STUDIO_PROTOCOL_INSTALL_BODY_SIZE = 1000000;
20
12
  const deliverElementInstall = ({ element, focusStudioTab, liveEventsServer, origin, target, }) => {
13
+ var _a, _b;
21
14
  if (target.compositionFile === null || target.compositionId === null) {
22
15
  return false;
23
16
  }
@@ -27,7 +20,11 @@ const deliverElementInstall = ({ element, focusStudioTab, liveEventsServer, orig
27
20
  createdAt: Date.now(),
28
21
  compositionFile: target.compositionFile,
29
22
  compositionId: target.compositionId,
30
- element,
23
+ element: {
24
+ ...element,
25
+ durationInFrames: (_a = element.durationInFrames) !== null && _a !== void 0 ? _a : null,
26
+ installationMode: (_b = element.installationMode) !== null && _b !== void 0 ? _b : null,
27
+ },
31
28
  from: null,
32
29
  position: null,
33
30
  source: {
@@ -89,21 +86,15 @@ const handleStudioProtocolInstall = async ({ focusStudioTab, liveEventsServer, r
89
86
  });
90
87
  return;
91
88
  }
92
- const parsedRequest = studioProtocolInstallRequestSchema.safeParse(body);
93
- if (!parsedRequest.success) {
94
- (0, protocol_response_1.writeStudioProtocolError)({
95
- code: 'unsupported-protocol',
96
- message: 'Invalid Remotion Studio Protocol request.',
97
- response,
98
- status: 400,
99
- });
100
- return;
101
- }
102
- const payload = studio_protocol_1.StudioProtocolInternals.parseStudioElementPayload(parsedRequest.data.payload);
103
- if (payload === null) {
89
+ const parsedRequest = studio_protocol_1.StudioProtocolInternals.parseStudioProtocolInstallRequest(body);
90
+ if (parsedRequest.status !== 'valid') {
104
91
  (0, protocol_response_1.writeStudioProtocolError)({
105
- code: 'invalid-payload',
106
- message: 'Invalid Element payload.',
92
+ code: parsedRequest.status === 'invalid-payload'
93
+ ? 'invalid-payload'
94
+ : 'unsupported-protocol',
95
+ message: parsedRequest.status === 'invalid-payload'
96
+ ? 'Invalid Element payload.'
97
+ : 'Invalid Remotion Studio Protocol request.',
107
98
  response,
108
99
  status: 400,
109
100
  });
@@ -113,7 +104,7 @@ const handleStudioProtocolInstall = async ({ focusStudioTab, liveEventsServer, r
113
104
  now: Date.now(),
114
105
  origin: requestOrigin,
115
106
  purpose: 'install-element',
116
- targetId: parsedRequest.data.targetId,
107
+ targetId: parsedRequest.request.targetId,
117
108
  });
118
109
  if (target === null) {
119
110
  (0, protocol_response_1.writeStudioProtocolError)({
@@ -125,7 +116,7 @@ const handleStudioProtocolInstall = async ({ focusStudioTab, liveEventsServer, r
125
116
  return;
126
117
  }
127
118
  if (!deliverElementInstall({
128
- element: payload.element,
119
+ element: parsedRequest.request.payload.element,
129
120
  focusStudioTab,
130
121
  liveEventsServer,
131
122
  origin: requestOrigin,
@@ -2,18 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handleStudioProtocolLicenseKey = void 0;
4
4
  const studio_protocol_1 = require("@remotion/studio-protocol");
5
- const zod_1 = require("zod");
6
5
  const element_install_state_1 = require("../element-install-state");
7
6
  const parse_body_1 = require("../parse-body");
8
7
  const origin_policy_1 = require("./origin-policy");
9
8
  const protocol_response_1 = require("./protocol-response");
10
- const studioProtocolLicenseKeyRequestSchema = zod_1.z.object({
11
- operation: zod_1.z.literal('set-license-key'),
12
- protocol: zod_1.z.literal('remotion-studio-protocol'),
13
- protocolVersion: zod_1.z.literal(1),
14
- targetId: zod_1.z.string().min(1),
15
- licenseKey: zod_1.z.string(),
16
- });
17
9
  const MAX_STUDIO_PROTOCOL_LICENSE_KEY_BODY_SIZE = 4096;
18
10
  const handleStudioProtocolLicenseKey = async ({ configFile, focusStudioTab, liveEventsServer, request, response, }) => {
19
11
  (0, origin_policy_1.setStudioProtocolCorsHeaders)({ request, response });
@@ -60,8 +52,8 @@ const handleStudioProtocolLicenseKey = async ({ configFile, focusStudioTab, live
60
52
  });
61
53
  return;
62
54
  }
63
- const parsedRequest = studioProtocolLicenseKeyRequestSchema.safeParse(body);
64
- if (!parsedRequest.success) {
55
+ const parsedRequest = studio_protocol_1.StudioProtocolInternals.parseStudioProtocolSetLicenseKeyRequest(body);
56
+ if (parsedRequest === null) {
65
57
  (0, protocol_response_1.writeStudioProtocolError)({
66
58
  code: 'unsupported-protocol',
67
59
  message: 'Invalid Remotion Studio Protocol request.',
@@ -70,7 +62,7 @@ const handleStudioProtocolLicenseKey = async ({ configFile, focusStudioTab, live
70
62
  });
71
63
  return;
72
64
  }
73
- if (!studio_protocol_1.StudioProtocolInternals.isValidPublicLicenseKey(parsedRequest.data.licenseKey)) {
65
+ if (!studio_protocol_1.StudioProtocolInternals.isValidPublicLicenseKey(parsedRequest.licenseKey)) {
74
66
  (0, protocol_response_1.writeStudioProtocolError)({
75
67
  code: 'invalid-license-key',
76
68
  message: 'The license key is not a valid public Remotion license key.',
@@ -83,7 +75,7 @@ const handleStudioProtocolLicenseKey = async ({ configFile, focusStudioTab, live
83
75
  now: Date.now(),
84
76
  origin: requestOrigin,
85
77
  purpose: 'set-license-key',
86
- targetId: parsedRequest.data.targetId,
78
+ targetId: parsedRequest.targetId,
87
79
  });
88
80
  if (target === null) {
89
81
  (0, protocol_response_1.writeStudioProtocolError)({
@@ -105,7 +97,7 @@ const handleStudioProtocolLicenseKey = async ({ configFile, focusStudioTab, live
105
97
  }
106
98
  const delivered = liveEventsServer.sendEventToClientId(target.clientId, {
107
99
  type: 'license-key-install-request',
108
- licenseKey: parsedRequest.data.licenseKey,
100
+ licenseKey: parsedRequest.licenseKey,
109
101
  });
110
102
  if (!delivered) {
111
103
  (0, protocol_response_1.writeStudioProtocolError)({
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/studio-server"
4
4
  },
5
5
  "name": "@remotion/studio-server",
6
- "version": "4.0.519",
6
+ "version": "4.0.520",
7
7
  "description": "Run a Remotion Studio with a server backend",
8
8
  "main": "dist",
9
9
  "scripts": {
@@ -23,7 +23,7 @@
23
23
  "access": "public"
24
24
  },
25
25
  "dependencies": {
26
- "@remotion/studio-protocol": "4.0.519",
26
+ "@remotion/studio-protocol": "4.0.520",
27
27
  "@babel/types": "7.24.0",
28
28
  "@babel/parser": "7.24.1",
29
29
  "@svgr/core": "8.1.0",
@@ -32,12 +32,12 @@
32
32
  "semver": "7.5.3",
33
33
  "zod": "4.4.3",
34
34
  "prettier": "3.8.1",
35
- "remotion": "4.0.519",
35
+ "remotion": "4.0.520",
36
36
  "recast": "0.23.21",
37
- "@remotion/bundler": "4.0.519",
38
- "@remotion/renderer": "4.0.519",
39
- "@remotion/studio-codemods": "4.0.519",
40
- "@remotion/studio-shared": "4.0.519",
37
+ "@remotion/bundler": "4.0.520",
38
+ "@remotion/renderer": "4.0.520",
39
+ "@remotion/studio-codemods": "4.0.520",
40
+ "@remotion/studio-shared": "4.0.520",
41
41
  "memfs": "3.4.3",
42
42
  "open": "8.4.2"
43
43
  },
@@ -45,7 +45,7 @@
45
45
  "ast-types": "0.16.1",
46
46
  "react": "19.2.3",
47
47
  "@types/semver": "7.5.3",
48
- "@remotion/eslint-config-internal": "4.0.519",
48
+ "@remotion/eslint-config-internal": "4.0.520",
49
49
  "eslint": "9.19.0",
50
50
  "@types/node": "20.12.14",
51
51
  "@typescript/native-preview": "7.0.0-dev.20260217.1"