@remotion/studio-server 4.0.515 → 4.0.516

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.
@@ -1,9 +1,10 @@
1
1
  import { deleteJsxElementAtPath, findJsxElementPathForDeletion, getJsxElementTagLabel } from '@remotion/studio-codemods';
2
2
  import type { SequenceNodePath } from 'remotion';
3
3
  export { deleteJsxElementAtPath, findJsxElementPathForDeletion, getJsxElementTagLabel, };
4
- export declare const deleteJsxNodes: ({ input, nodePaths, prettierConfigOverride, }: {
4
+ export declare const deleteJsxNodes: ({ input, nodePaths, onFormatFile, prettierConfigOverride, }: {
5
5
  input: string;
6
6
  nodePaths: SequenceNodePath[];
7
+ onFormatFile: ((stage: "complete" | "start") => void) | null;
7
8
  prettierConfigOverride?: Record<string, unknown> | null | undefined;
8
9
  }) => Promise<{
9
10
  output: string;
@@ -6,13 +6,18 @@ Object.defineProperty(exports, "deleteJsxElementAtPath", { enumerable: true, get
6
6
  Object.defineProperty(exports, "findJsxElementPathForDeletion", { enumerable: true, get: function () { return studio_codemods_1.findJsxElementPathForDeletion; } });
7
7
  Object.defineProperty(exports, "getJsxElementTagLabel", { enumerable: true, get: function () { return studio_codemods_1.getJsxElementTagLabel; } });
8
8
  const format_file_content_1 = require("./format-file-content");
9
- const deleteJsxNodes = ({ input, nodePaths, prettierConfigOverride, }) => (0, studio_codemods_1.deleteJsxNodes)({
9
+ const deleteJsxNodes = ({ input, nodePaths, onFormatFile, prettierConfigOverride, }) => (0, studio_codemods_1.deleteJsxNodes)({
10
10
  input,
11
11
  nodePaths,
12
- formatFile: ({ contents, prettierConfigOverride: override }) => (0, format_file_content_1.formatFileContent)({
13
- input: contents,
14
- prettierConfigOverride: override,
15
- }),
12
+ formatFile: async ({ contents, prettierConfigOverride: override }) => {
13
+ onFormatFile === null || onFormatFile === void 0 ? void 0 : onFormatFile('start');
14
+ const result = await (0, format_file_content_1.formatFileContent)({
15
+ input: contents,
16
+ prettierConfigOverride: override,
17
+ });
18
+ onFormatFile === null || onFormatFile === void 0 ? void 0 : onFormatFile('complete');
19
+ return result;
20
+ },
16
21
  prettierConfigOverride,
17
22
  });
18
23
  exports.deleteJsxNodes = deleteJsxNodes;
@@ -1,6 +1,6 @@
1
- import type { SequenceNodePathRemapping } from '@remotion/studio-shared';
1
+ import { duplicateJsxElementAtPath } from '@remotion/studio-codemods';
2
2
  import type { SequenceNodePath } from 'remotion';
3
- export declare const duplicateJsxElementAtPath: (jsxPath: import("ast-types/lib/node-path").NodePath<N, V>) => void;
3
+ export { duplicateJsxElementAtPath };
4
4
  export declare const duplicateJsxNode: ({ input, nodePath, prettierConfigOverride, }: {
5
5
  input: string;
6
6
  nodePath: SequenceNodePath;
@@ -10,5 +10,5 @@ export declare const duplicateJsxNode: ({ input, nodePath, prettierConfigOverrid
10
10
  formatted: boolean;
11
11
  nodeLabel: string;
12
12
  logLine: number;
13
- nodePathRemappings: SequenceNodePathRemapping[];
13
+ nodePathRemappings: import("@remotion/studio-shared").SequenceNodePathRemapping[];
14
14
  }>;
@@ -1,319 +1,16 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
3
  exports.duplicateJsxNode = exports.duplicateJsxElementAtPath = void 0;
37
- const types_1 = require("@babel/types");
38
- const recast = __importStar(require("recast"));
39
- const delete_jsx_node_1 = require("./delete-jsx-node");
4
+ const studio_codemods_1 = require("@remotion/studio-codemods");
5
+ Object.defineProperty(exports, "duplicateJsxElementAtPath", { enumerable: true, get: function () { return studio_codemods_1.duplicateJsxElementAtPath; } });
40
6
  const format_file_content_1 = require("./format-file-content");
41
- const get_node_path_remappings_1 = require("./get-node-path-remappings");
42
- const parse_ast_1 = require("./parse-ast");
43
- const { namedTypes } = recast.types;
44
- const makeFragment = (first, second) => ({
45
- type: 'JSXFragment',
46
- openingFragment: { type: 'JSXOpeningFragment' },
47
- closingFragment: { type: 'JSXClosingFragment' },
48
- children: [first, second],
7
+ const duplicateJsxNode = ({ input, nodePath, prettierConfigOverride, }) => (0, studio_codemods_1.duplicateJsxNode)({
8
+ input,
9
+ nodePath,
10
+ formatFile: ({ contents, prettierConfigOverride: override }) => (0, format_file_content_1.formatFileContent)({
11
+ input: contents,
12
+ prettierConfigOverride: override,
13
+ }),
14
+ prettierConfigOverride,
49
15
  });
50
- const uniquifyNamePropOnClone = (clone) => {
51
- for (const attr of clone.openingElement.attributes) {
52
- if (attr.type !== 'JSXAttribute' || attr.name.type !== 'JSXIdentifier') {
53
- continue;
54
- }
55
- if (attr.name.name !== 'name') {
56
- continue;
57
- }
58
- if (!attr.value) {
59
- continue;
60
- }
61
- if (attr.value.type === 'StringLiteral') {
62
- attr.value.value = `${attr.value.value}-copy`;
63
- return;
64
- }
65
- if (attr.value.type === 'JSXExpressionContainer' &&
66
- attr.value.expression.type === 'StringLiteral') {
67
- attr.value.expression.value = `${attr.value.expression.value}-copy`;
68
- return;
69
- }
70
- }
71
- };
72
- const duplicateInLogicalExpression = (parent, node, clone) => {
73
- const frag = makeFragment(node, clone);
74
- if (parent.left === node) {
75
- parent.left = frag;
76
- return true;
77
- }
78
- if (parent.right === node) {
79
- parent.right = frag;
80
- return true;
81
- }
82
- return false;
83
- };
84
- const duplicateInConditionalExpression = (parent, node, clone) => {
85
- const frag = makeFragment(node, clone);
86
- if (parent.consequent === node) {
87
- parent.consequent = frag;
88
- return true;
89
- }
90
- if (parent.alternate === node) {
91
- parent.alternate = frag;
92
- return true;
93
- }
94
- return false;
95
- };
96
- const duplicateInArrowFunctionExpression = (parent, node, clone) => {
97
- const frag = makeFragment(node, clone);
98
- if (parent.body === node) {
99
- parent.body = frag;
100
- return true;
101
- }
102
- return false;
103
- };
104
- const duplicateInReturnStatement = (parent, node, clone) => {
105
- const frag = makeFragment(node, clone);
106
- if (parent.argument === node) {
107
- parent.argument = frag;
108
- return true;
109
- }
110
- return false;
111
- };
112
- const duplicateInCallExpression = (parent, node, clone) => {
113
- const idx = parent.arguments.indexOf(node);
114
- if (idx !== -1) {
115
- parent.arguments.splice(idx + 1, 0, clone);
116
- return true;
117
- }
118
- return false;
119
- };
120
- const duplicateInOptionalCallExpression = (parent, node, clone) => {
121
- const idx = parent.arguments.indexOf(node);
122
- if (idx !== -1) {
123
- parent.arguments.splice(idx + 1, 0, clone);
124
- return true;
125
- }
126
- return false;
127
- };
128
- const duplicateInArrayExpression = (parent, node, clone) => {
129
- const idx = parent.elements.indexOf(node);
130
- if (idx !== -1) {
131
- parent.elements.splice(idx + 1, 0, clone);
132
- return true;
133
- }
134
- return false;
135
- };
136
- const duplicateInAssignmentExpression = (parent, node, clone) => {
137
- const frag = makeFragment(node, clone);
138
- if (parent.right === node) {
139
- parent.right = frag;
140
- return true;
141
- }
142
- return false;
143
- };
144
- const duplicateInVariableDeclarator = (parent, node, clone) => {
145
- const frag = makeFragment(node, clone);
146
- if (parent.init === node) {
147
- parent.init = frag;
148
- return true;
149
- }
150
- return false;
151
- };
152
- const duplicateInExportDefaultDeclaration = (parent, node, clone) => {
153
- const frag = makeFragment(node, clone);
154
- if (parent.declaration === node) {
155
- parent.declaration =
156
- frag;
157
- return true;
158
- }
159
- return false;
160
- };
161
- const duplicateInSequenceExpression = (parent, node, clone) => {
162
- const idx = parent.expressions.indexOf(node);
163
- if (idx !== -1) {
164
- parent.expressions.splice(idx + 1, 0, clone);
165
- return true;
166
- }
167
- return false;
168
- };
169
- const duplicateInNewExpression = (parent, node, clone) => {
170
- const idx = parent.arguments.indexOf(node);
171
- if (idx !== -1) {
172
- parent.arguments.splice(idx + 1, 0, clone);
173
- return true;
174
- }
175
- return false;
176
- };
177
- const duplicateInExpressionStatement = (parent, node, clone) => {
178
- const frag = makeFragment(node, clone);
179
- if (parent.expression === node) {
180
- parent.expression = frag;
181
- return true;
182
- }
183
- return false;
184
- };
185
- const duplicateInParenthesizedExpression = (parent, node, clone) => {
186
- const frag = makeFragment(node, clone);
187
- if (parent.expression === node) {
188
- parent.expression = frag;
189
- return true;
190
- }
191
- return false;
192
- };
193
- const duplicateInJSXExpressionContainer = (parent, node, clone) => {
194
- const frag = makeFragment(node, clone);
195
- if (parent.expression === node) {
196
- parent.expression = frag;
197
- return true;
198
- }
199
- return false;
200
- };
201
- const duplicateInTSAsExpression = (parent, node, clone) => {
202
- const frag = makeFragment(node, clone);
203
- if (parent.expression === node) {
204
- parent.expression = frag;
205
- return true;
206
- }
207
- return false;
208
- };
209
- const duplicateInJSXParentChildren = (parent, node, clone) => {
210
- const idx = parent.children.indexOf(node);
211
- if (idx !== -1) {
212
- parent.children.splice(idx + 1, 0, clone);
213
- return true;
214
- }
215
- return false;
216
- };
217
- const insertDuplicateForParent = (parentNode, node, clone) => {
218
- if (namedTypes.LogicalExpression.check(parentNode)) {
219
- return duplicateInLogicalExpression(parentNode, node, clone);
220
- }
221
- if (namedTypes.ConditionalExpression.check(parentNode)) {
222
- return duplicateInConditionalExpression(parentNode, node, clone);
223
- }
224
- if (namedTypes.ArrowFunctionExpression.check(parentNode)) {
225
- return duplicateInArrowFunctionExpression(parentNode, node, clone);
226
- }
227
- if (namedTypes.ReturnStatement.check(parentNode)) {
228
- return duplicateInReturnStatement(parentNode, node, clone);
229
- }
230
- if (namedTypes.CallExpression.check(parentNode)) {
231
- return duplicateInCallExpression(parentNode, node, clone);
232
- }
233
- if (parentNode.type === 'OptionalCallExpression') {
234
- return duplicateInOptionalCallExpression(parentNode, node, clone);
235
- }
236
- if (namedTypes.ArrayExpression.check(parentNode)) {
237
- return duplicateInArrayExpression(parentNode, node, clone);
238
- }
239
- if (namedTypes.AssignmentExpression.check(parentNode)) {
240
- return duplicateInAssignmentExpression(parentNode, node, clone);
241
- }
242
- if (namedTypes.VariableDeclarator.check(parentNode)) {
243
- return duplicateInVariableDeclarator(parentNode, node, clone);
244
- }
245
- if (namedTypes.ExportDefaultDeclaration.check(parentNode)) {
246
- return duplicateInExportDefaultDeclaration(parentNode, node, clone);
247
- }
248
- if (namedTypes.SequenceExpression.check(parentNode)) {
249
- return duplicateInSequenceExpression(parentNode, node, clone);
250
- }
251
- if (namedTypes.NewExpression.check(parentNode)) {
252
- return duplicateInNewExpression(parentNode, node, clone);
253
- }
254
- if (namedTypes.ExpressionStatement.check(parentNode)) {
255
- return duplicateInExpressionStatement(parentNode, node, clone);
256
- }
257
- if (namedTypes.ParenthesizedExpression.check(parentNode)) {
258
- return duplicateInParenthesizedExpression(parentNode, node, clone);
259
- }
260
- if (namedTypes.JSXExpressionContainer.check(parentNode)) {
261
- return duplicateInJSXExpressionContainer(parentNode, node, clone);
262
- }
263
- if (namedTypes.TSAsExpression.check(parentNode)) {
264
- return duplicateInTSAsExpression(parentNode, node, clone);
265
- }
266
- if (namedTypes.JSXElement.check(parentNode)) {
267
- return duplicateInJSXParentChildren(parentNode, node, clone);
268
- }
269
- if (namedTypes.JSXFragment.check(parentNode)) {
270
- return duplicateInJSXParentChildren(parentNode, node, clone);
271
- }
272
- return false;
273
- };
274
- const duplicateJsxElementAtPath = (jsxPath) => {
275
- const { node, parentPath } = jsxPath;
276
- if (!parentPath) {
277
- throw new Error('Cannot duplicate JSX element with no parent');
278
- }
279
- const jsxNode = node;
280
- const clone = (0, types_1.cloneNode)(jsxNode, true);
281
- uniquifyNamePropOnClone(clone);
282
- if (insertDuplicateForParent(parentPath.node, jsxNode, clone)) {
283
- return;
284
- }
285
- jsxPath.replace(makeFragment(jsxNode, clone));
286
- };
287
- exports.duplicateJsxElementAtPath = duplicateJsxElementAtPath;
288
- const duplicateJsxNode = async ({ input, nodePath, prettierConfigOverride, }) => {
289
- var _a, _b;
290
- var _c, _d;
291
- const ast = (0, parse_ast_1.parseAst)(input);
292
- const capturedNodePaths = (0, get_node_path_remappings_1.captureJsxNodePaths)(ast);
293
- const jsxPath = (0, delete_jsx_node_1.findJsxElementPathForDeletion)(ast, nodePath);
294
- if (!jsxPath) {
295
- throw new Error('Could not find a JSX element at the specified location to duplicate');
296
- }
297
- const jsxElement = jsxPath.node;
298
- const nodeLabel = (0, delete_jsx_node_1.getJsxElementTagLabel)(jsxElement);
299
- const logLine = (_d = (_c = (_a = jsxElement.openingElement.loc) === null || _a === void 0 ? void 0 : _a.start.line) !== null && _c !== void 0 ? _c : (_b = jsxElement.loc) === null || _b === void 0 ? void 0 : _b.start.line) !== null && _d !== void 0 ? _d : 1;
300
- (0, exports.duplicateJsxElementAtPath)(jsxPath);
301
- const finalFile = (0, parse_ast_1.serializeAst)(ast);
302
- const { output, formatted } = await (0, format_file_content_1.formatFileContent)({
303
- input: finalFile,
304
- prettierConfigOverride,
305
- });
306
- const { nodePathRemappings } = (0, get_node_path_remappings_1.getNodePathRemappings)({
307
- ast,
308
- captured: capturedNodePaths,
309
- output,
310
- });
311
- return {
312
- output,
313
- formatted,
314
- nodeLabel,
315
- logLine,
316
- nodePathRemappings,
317
- };
318
- };
319
16
  exports.duplicateJsxNode = duplicateJsxNode;
@@ -0,0 +1,5 @@
1
+ export declare const logHmrTiming: ({ detail, logLevel, stage, }: {
2
+ detail: string | null;
3
+ logLevel: "error" | "info" | "trace" | "verbose" | "warn";
4
+ stage: string;
5
+ }) => void;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logHmrTiming = void 0;
4
+ const renderer_1 = require("@remotion/renderer");
5
+ const logHmrTiming = ({ detail, logLevel, stage, }) => {
6
+ const detailSuffix = detail ? ` ${detail}` : '';
7
+ renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[hmr-timing] epoch=${Date.now()} monotonic=${performance.now().toFixed(3)} stage=${stage}${detailSuffix}`);
8
+ };
9
+ exports.logHmrTiming = logHmrTiming;
@@ -7,14 +7,23 @@
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.setupWebpackHmr = void 0;
9
9
  const renderer_1 = require("@remotion/renderer");
10
+ const hmr_timing_1 = require("../hmr-timing");
10
11
  const setupWebpackHmr = (compiler, logLevel, liveEventsServer) => {
11
12
  let latestStats = null;
12
13
  const publishHmr = (hmrEvent) => {
13
14
  liveEventsServer.sendEventToClient({ type: 'hmr', hmrEvent });
14
15
  };
15
16
  compiler.hooks.invalid.tap('remotion', onInvalid);
17
+ compiler.hooks.watchRun.tap('remotion-hmr-timing', () => {
18
+ (0, hmr_timing_1.logHmrTiming)({ detail: null, logLevel, stage: 'compiler-watch-run' });
19
+ });
16
20
  compiler.hooks.done.tap('remotion', onDone);
17
- function onInvalid() {
21
+ function onInvalid(fileName, changeTime) {
22
+ (0, hmr_timing_1.logHmrTiming)({
23
+ detail: `file=${fileName !== null && fileName !== void 0 ? fileName : 'manual'} changeTime=${changeTime}`,
24
+ logLevel,
25
+ stage: 'compiler-invalid',
26
+ });
18
27
  latestStats = null;
19
28
  renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, 'Building...');
20
29
  publishHmr({
@@ -22,9 +31,15 @@ const setupWebpackHmr = (compiler, logLevel, liveEventsServer) => {
22
31
  });
23
32
  }
24
33
  function onDone(statsResult) {
34
+ (0, hmr_timing_1.logHmrTiming)({
35
+ detail: `reportedBuildDuration=${statsResult.endTime - statsResult.startTime}ms`,
36
+ logLevel,
37
+ stage: 'compiler-done',
38
+ });
25
39
  // Keep hold of latest stats so they can be propagated to new clients
26
40
  latestStats = statsResult;
27
41
  publishStats('built', latestStats, publishHmr);
42
+ (0, hmr_timing_1.logHmrTiming)({ detail: null, logLevel, stage: 'hmr-stats-published' });
28
43
  }
29
44
  liveEventsServer.addNewClientListener(() => {
30
45
  if (latestStats) {
@@ -775,6 +775,10 @@ const getPropsStatus = (jsxElement, ast, videoConfigValues, assetKeys) => {
775
775
  const props = {};
776
776
  for (const attr of jsxElement.attributes) {
777
777
  if (attr.type === 'JSXSpreadAttribute') {
778
+ // The spread may override every prop written before it
779
+ for (const key of Object.keys(props)) {
780
+ props[key] = computedStatus();
781
+ }
778
782
  continue;
779
783
  }
780
784
  if (attr.name.type === 'JSXNamespacedName') {
@@ -1113,14 +1117,28 @@ const getBorderRadiusShorthandStatus = ({ propValue, ast, videoConfigValues, })
1113
1117
  }
1114
1118
  return computedStatus();
1115
1119
  };
1116
- const getNestedPropStatus = ({ jsxElement, ast, parentKey, childKey, videoConfigValues, allowSpecialValues, }) => {
1117
- const attr = jsxElement.attributes.find((a) => a.type !== 'JSXSpreadAttribute' &&
1120
+ const getNestedPropStatus = ({ jsxElement, ast, parentKey, childKey, videoConfigValues, allowSpecialValues, lastSpreadIndex, }) => {
1121
+ const attrIndex = jsxElement.attributes.findIndex((a) => a.type !== 'JSXSpreadAttribute' &&
1118
1122
  a.name.type !== 'JSXNamespacedName' &&
1119
1123
  a.name.name === parentKey);
1120
- if (!attr || !attr.value) {
1124
+ const attr = attrIndex === -1
1125
+ ? undefined
1126
+ : jsxElement.attributes[attrIndex];
1127
+ if (attrIndex !== -1 && attrIndex < lastSpreadIndex) {
1128
+ // A later spread may replace the whole parent object
1129
+ return computedStatus();
1130
+ }
1131
+ if (!attr) {
1132
+ if (lastSpreadIndex !== -1) {
1133
+ // The spread may provide the parent object
1134
+ return computedStatus();
1135
+ }
1121
1136
  // Parent attribute doesn't exist, nested prop can be added
1122
1137
  return staticStatus(undefined, null);
1123
1138
  }
1139
+ if (!attr.value) {
1140
+ return staticStatus(undefined, null);
1141
+ }
1124
1142
  if (attr.value.type !== 'JSXExpressionContainer') {
1125
1143
  return computedStatus();
1126
1144
  }
@@ -1210,6 +1228,13 @@ const computeEffectsForJsx = ({ ast, jsxElement, effects, videoConfigValues, })
1210
1228
  }));
1211
1229
  };
1212
1230
  const computeSequenceOnlyPropsRecord = ({ jsxElement, jsxElementNode, ast, keys, assetKeys, videoConfigValues, }) => {
1231
+ // A JSX spread attribute ({...props}) is invisible to the parser and may
1232
+ // set or override every prop that is not explicitly written after it.
1233
+ // Affected props are treated as computed so the runtime values pass
1234
+ // through untouched and Visual Mode does not offer to edit them.
1235
+ // Attributes written after the last spread win at runtime and can be
1236
+ // parsed as usual.
1237
+ const lastSpreadIndex = jsxElement.attributes.reduce((highest, attr, index) => attr.type === 'JSXSpreadAttribute' ? index : highest, -1);
1213
1238
  const allProps = getPropsStatus(jsxElement, ast, videoConfigValues, assetKeys);
1214
1239
  const filteredProps = {};
1215
1240
  const mixedBorderRadius = hasMixedBorderRadiusRepresentation(jsxElement);
@@ -1221,6 +1246,14 @@ const computeSequenceOnlyPropsRecord = ({ jsxElement, jsxElementNode, ast, keys,
1221
1246
  continue;
1222
1247
  }
1223
1248
  if (key === 'children') {
1249
+ const childrenAttrIndex = jsxElement.attributes.findIndex((attr) => attr.type === 'JSXAttribute' &&
1250
+ attr.name.type === 'JSXIdentifier' &&
1251
+ attr.name.name === 'children');
1252
+ if (childrenAttrIndex !== -1 && childrenAttrIndex < lastSpreadIndex) {
1253
+ // A later spread may override the children attribute
1254
+ filteredProps[key] = computedStatus();
1255
+ continue;
1256
+ }
1224
1257
  const staticChildrenAttribute = (0, exports.getStaticJsxChildrenAttribute)(jsxElement);
1225
1258
  if (staticChildrenAttribute) {
1226
1259
  filteredProps[key] = staticStatus(staticChildrenAttribute.value, null);
@@ -1230,6 +1263,14 @@ const computeSequenceOnlyPropsRecord = ({ jsxElement, jsxElementNode, ast, keys,
1230
1263
  filteredProps[key] = computedStatus();
1231
1264
  continue;
1232
1265
  }
1266
+ // JSX element children are compiled after any spread and win over
1267
+ // it. Only if the element body is empty may the spread provide the
1268
+ // children.
1269
+ const hasMeaningfulJsxChildren = jsxElementNode.children.some((candidate) => !(candidate.type === 'JSXText' && candidate.value.trim() === ''));
1270
+ if (!hasMeaningfulJsxChildren && lastSpreadIndex !== -1) {
1271
+ filteredProps[key] = computedStatus();
1272
+ continue;
1273
+ }
1233
1274
  const staticTextContent = (0, exports.getStaticJsxTextContent)(jsxElementNode);
1234
1275
  filteredProps[key] = staticTextContent
1235
1276
  ? staticStatus(staticTextContent.value, null)
@@ -1245,11 +1286,16 @@ const computeSequenceOnlyPropsRecord = ({ jsxElement, jsxElementNode, ast, keys,
1245
1286
  childKey: key.slice(dotIndex + 1),
1246
1287
  videoConfigValues,
1247
1288
  allowSpecialValues: assetKeys.includes(key),
1289
+ lastSpreadIndex,
1248
1290
  });
1249
1291
  }
1250
1292
  else if (key in allProps) {
1251
1293
  filteredProps[key] = allProps[key];
1252
1294
  }
1295
+ else if (lastSpreadIndex !== -1) {
1296
+ // The spread may provide this prop
1297
+ filteredProps[key] = computedStatus();
1298
+ }
1253
1299
  else {
1254
1300
  filteredProps[key] = staticStatus(undefined, null);
1255
1301
  }
@@ -7,6 +7,7 @@ const delete_jsx_node_1 = require("../../codemods/delete-jsx-node");
7
7
  const file_watcher_1 = require("../../file-watcher");
8
8
  const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside-project");
9
9
  const format_log_file_location_1 = require("../format-log-file-location");
10
+ const hmr_timing_1 = require("../hmr-timing");
10
11
  const sequence_node_path_mutation_1 = require("../sequence-node-path-mutation");
11
12
  const undo_stack_1 = require("../undo-stack");
12
13
  const log_update_1 = require("./log-updates/log-update");
@@ -21,6 +22,11 @@ const deleteJsxNodeHandler = ({ input: { nodes }, remotionRoot, logLevel }) => {
21
22
  return (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
22
23
  var _a;
23
24
  try {
25
+ (0, hmr_timing_1.logHmrTiming)({
26
+ detail: null,
27
+ logLevel,
28
+ stage: 'delete-jsx-node-request-start',
29
+ });
24
30
  if (nodes.length === 0) {
25
31
  throw new Error('No JSX nodes were specified for deletion');
26
32
  }
@@ -41,6 +47,13 @@ const deleteJsxNodeHandler = ({ input: { nodes }, remotionRoot, logLevel }) => {
41
47
  const { output, formatted, nodeLabels, logLines, nodePathRemappings } = await (0, delete_jsx_node_1.deleteJsxNodes)({
42
48
  input: fileContents,
43
49
  nodePaths: fileItems.map((item) => item.nodePath),
50
+ onFormatFile: (stage) => {
51
+ (0, hmr_timing_1.logHmrTiming)({
52
+ detail: `file=${fileRelativeToRoot}`,
53
+ logLevel,
54
+ stage: `source-file-format-${stage}`,
55
+ });
56
+ },
44
57
  });
45
58
  return {
46
59
  absolutePath,
@@ -53,6 +66,11 @@ const deleteJsxNodeHandler = ({ input: { nodes }, remotionRoot, logLevel }) => {
53
66
  logLine: Math.min(...logLines),
54
67
  };
55
68
  }));
69
+ (0, hmr_timing_1.logHmrTiming)({
70
+ detail: `files=${updates.length}`,
71
+ logLevel,
72
+ stage: 'delete-jsx-node-codemod-complete',
73
+ });
56
74
  const nodePathMutation = (0, sequence_node_path_mutation_1.broadcastSequenceNodePathMutation)(updates.map((update) => ({
57
75
  absolutePath: update.absolutePath,
58
76
  remappings: update.nodePathRemappings,
@@ -76,12 +94,22 @@ const deleteJsxNodeHandler = ({ input: { nodes }, remotionRoot, logLevel }) => {
76
94
  nodePathRemappings: update.nodePathRemappings,
77
95
  });
78
96
  (0, undo_stack_1.suppressUndoStackInvalidation)(update.absolutePath);
97
+ (0, hmr_timing_1.logHmrTiming)({
98
+ detail: `file=${update.fileRelativeToRoot}`,
99
+ logLevel,
100
+ stage: 'source-file-write-start',
101
+ });
79
102
  (0, file_watcher_1.writeFileAndNotifyFileWatchers)({
80
103
  file: update.absolutePath,
81
104
  content: update.output,
82
105
  originatorClientId: undefined,
83
106
  metadata: { skipSequencePropsUpdate: true },
84
107
  });
108
+ (0, hmr_timing_1.logHmrTiming)({
109
+ detail: `file=${update.fileRelativeToRoot}`,
110
+ logLevel,
111
+ stage: 'source-file-write-complete',
112
+ });
85
113
  const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
86
114
  remotionRoot,
87
115
  absolutePath: update.absolutePath,
@@ -1,7 +1,4 @@
1
- import { type DownloadRemoteAssetRequest, type DownloadRemoteAssetResponse, type ImageFileType } from '@remotion/studio-shared';
1
+ import { getRemoteAssetFilename, type DownloadRemoteAssetRequest, type DownloadRemoteAssetResponse } from '@remotion/studio-shared';
2
2
  import type { ApiHandler } from '../api-types';
3
- export declare const getRemoteAssetFilename: ({ fileType, url, }: {
4
- fileType: ImageFileType;
5
- url: URL;
6
- }) => string;
3
+ export { getRemoteAssetFilename };
7
4
  export declare const downloadRemoteAssetHandler: ApiHandler<DownloadRemoteAssetRequest, DownloadRemoteAssetResponse>;
@@ -9,58 +9,9 @@ const node_fs_1 = require("node:fs");
9
9
  const node_net_1 = require("node:net");
10
10
  const node_path_1 = __importDefault(require("node:path"));
11
11
  const studio_shared_1 = require("@remotion/studio-shared");
12
+ Object.defineProperty(exports, "getRemoteAssetFilename", { enumerable: true, get: function () { return studio_shared_1.getRemoteAssetFilename; } });
12
13
  const validate_same_origin_1 = require("../validate-same-origin");
13
- const maxRemoteAssetSize = 50 * 1024 * 1024;
14
- const remoteAssetDownloadTimeout = 15000;
15
14
  const maxRemoteAssetRedirects = 5;
16
- const remoteAssetAcceptHeader = 'image/png,image/apng,image/jpeg,image/webp,image/bmp,image/gif';
17
- const extensionsForFileType = {
18
- png: ['png'],
19
- apng: ['png', 'apng'],
20
- jpeg: ['jpg', 'jpeg'],
21
- webp: ['webp'],
22
- bmp: ['bmp'],
23
- gif: ['gif'],
24
- };
25
- const safeDecodeURIComponent = (value) => {
26
- try {
27
- return decodeURIComponent(value);
28
- }
29
- catch (_a) {
30
- return value;
31
- }
32
- };
33
- const sanitizeAssetFilename = (filename) => {
34
- return Array.from(filename)
35
- .map((character) => {
36
- const charCode = character.charCodeAt(0);
37
- return charCode <= 31 || '<>:"/\\|?*'.includes(character)
38
- ? '-'
39
- : character;
40
- })
41
- .join('')
42
- .trim()
43
- .replace(/^[. ]+|[. ]+$/g, '');
44
- };
45
- const getRemoteAssetFilename = ({ fileType, url, }) => {
46
- const basename = safeDecodeURIComponent(node_path_1.default.posix.basename(url.pathname));
47
- const sanitized = sanitizeAssetFilename(basename);
48
- const filenameWithoutFallback = sanitized === '' ? 'image' : sanitized;
49
- const extensions = extensionsForFileType[fileType.type];
50
- const extension = node_path_1.default
51
- .extname(filenameWithoutFallback)
52
- .slice(1)
53
- .toLowerCase();
54
- if (extensions.includes(extension)) {
55
- return filenameWithoutFallback;
56
- }
57
- const withoutExtension = extension
58
- ? filenameWithoutFallback.slice(0, -(extension.length + 1))
59
- : filenameWithoutFallback;
60
- const safeName = withoutExtension === '' ? 'image' : withoutExtension;
61
- return `${safeName}.${extensions[0]}`;
62
- };
63
- exports.getRemoteAssetFilename = getRemoteAssetFilename;
64
15
  const isForbiddenIpv4Address = (address) => {
65
16
  const parts = address.split('.').map((part) => Number(part));
66
17
  if (parts.length !== 4 ||
@@ -131,7 +82,7 @@ const fetchRemoteAsset = async ({ signal, url, }) => {
131
82
  await ensureRemoteUrlIsAllowed(currentUrl);
132
83
  const response = await fetch(currentUrl, {
133
84
  headers: {
134
- accept: remoteAssetAcceptHeader,
85
+ accept: studio_shared_1.remoteAssetAcceptHeader,
135
86
  },
136
87
  redirect: 'manual',
137
88
  signal,
@@ -153,13 +104,13 @@ const fetchRemoteAsset = async ({ signal, url, }) => {
153
104
  };
154
105
  const readRemoteAsset = async ({ response, abort, }) => {
155
106
  const contentLength = response.headers.get('content-length');
156
- if (contentLength !== null && Number(contentLength) > maxRemoteAssetSize) {
107
+ if (contentLength !== null && Number(contentLength) > studio_shared_1.maxRemoteAssetSize) {
157
108
  abort();
158
109
  throw new Error('Remote asset exceeds the 50MB size limit');
159
110
  }
160
111
  if (!response.body) {
161
112
  const buffer = await response.arrayBuffer();
162
- if (buffer.byteLength > maxRemoteAssetSize) {
113
+ if (buffer.byteLength > studio_shared_1.maxRemoteAssetSize) {
163
114
  throw new Error('Remote asset exceeds the 50MB size limit');
164
115
  }
165
116
  return new Uint8Array(buffer);
@@ -176,7 +127,7 @@ const readRemoteAsset = async ({ response, abort, }) => {
176
127
  continue;
177
128
  }
178
129
  size += value.byteLength;
179
- if (size > maxRemoteAssetSize) {
130
+ if (size > studio_shared_1.maxRemoteAssetSize) {
180
131
  abort();
181
132
  await reader.cancel();
182
133
  throw new Error('Remote asset exceeds the 50MB size limit');
@@ -203,7 +154,7 @@ const downloadRemoteAssetHandler = async ({ input, publicDir, request }) => {
203
154
  const controller = new AbortController();
204
155
  const timeout = setTimeout(() => {
205
156
  controller.abort();
206
- }, remoteAssetDownloadTimeout);
157
+ }, studio_shared_1.remoteAssetDownloadTimeout);
207
158
  let contents;
208
159
  try {
209
160
  const response = await fetchRemoteAsset({
@@ -231,7 +182,7 @@ const downloadRemoteAssetHandler = async ({ input, publicDir, request }) => {
231
182
  if (!(0, studio_shared_1.isImageFileType)(fileType)) {
232
183
  throw new Error('Remote asset is not a supported image');
233
184
  }
234
- const assetPath = (0, exports.getRemoteAssetFilename)({ fileType, url });
185
+ const assetPath = (0, studio_shared_1.getRemoteAssetFilename)({ fileType, url });
235
186
  const absolutePath = node_path_1.default.join(publicDir, assetPath);
236
187
  const relativeToPublicDir = node_path_1.default.relative(publicDir, absolutePath);
237
188
  if (relativeToPublicDir.startsWith('..') ||
@@ -252,20 +203,7 @@ const downloadRemoteAssetHandler = async ({ input, publicDir, request }) => {
252
203
  (0, node_fs_1.mkdirSync)(node_path_1.default.dirname(absolutePath), { recursive: true });
253
204
  (0, node_fs_1.writeFileSync)(absolutePath, contents);
254
205
  }
255
- const element = {
256
- type: 'asset',
257
- assetType: fileType.type === 'gif'
258
- ? 'gif'
259
- : fileType.type === 'apng' ||
260
- (fileType.type === 'webp' && fileType.animated)
261
- ? 'animated-image'
262
- : 'image',
263
- src: assetPath,
264
- srcType: 'static',
265
- dimensions: fileType.dimensions,
266
- durationInFrames: null,
267
- position: null,
268
- };
206
+ const element = (0, studio_shared_1.getRemoteAssetElement)({ assetPath, fileType });
269
207
  return {
270
208
  assetPath,
271
209
  sizeInBytes: contents.byteLength,
@@ -8,15 +8,25 @@ const node_fs_1 = require("node:fs");
8
8
  const node_os_1 = require("node:os");
9
9
  const node_path_1 = __importDefault(require("node:path"));
10
10
  const detect_outdated_remotion_skills_1 = require("../../detect-outdated-remotion-skills");
11
+ const remotion_skill_names_1 = require("../../remotion-skill-names");
11
12
  const getRemotionSkillsInfo = ({ remotionRoot, homeDirectory = (0, node_os_1.homedir)(), }) => {
12
13
  const skillsDirectories = (0, detect_outdated_remotion_skills_1.getRemotionSkillsDirectories)({
13
14
  cwd: remotionRoot,
14
15
  homeDirectory,
15
16
  });
16
- const isSkillAvailable = (skillName) => Object.values(skillsDirectories).some((skillsDirectory) => (0, node_fs_1.existsSync)(node_path_1.default.join(skillsDirectory, skillName, 'SKILL.md')));
17
+ const skills = remotion_skill_names_1.remotionSkillNames.map((name) => ({
18
+ name,
19
+ installedInProject: (0, node_fs_1.existsSync)(node_path_1.default.join(skillsDirectories.project, name, 'SKILL.md')),
20
+ installedGlobally: (0, node_fs_1.existsSync)(node_path_1.default.join(skillsDirectories.global, name, 'SKILL.md')),
21
+ }));
22
+ const isSkillAvailable = (skillName) => {
23
+ const skill = skills.find(({ name }) => name === skillName);
24
+ return Boolean((skill === null || skill === void 0 ? void 0 : skill.installedInProject) || (skill === null || skill === void 0 ? void 0 : skill.installedGlobally));
25
+ };
17
26
  return {
18
27
  remotionUpgradeSkillAvailable: isSkillAvailable('remotion-upgrade'),
19
28
  remotionInteractivitySkillAvailable: isSkillAvailable('remotion-interactivity'),
29
+ skills,
20
30
  };
21
31
  };
22
32
  exports.getRemotionSkillsInfo = getRemotionSkillsInfo;
@@ -6,10 +6,11 @@
6
6
  * MIT Licensed
7
7
  */
8
8
  import type { IncomingMessage, ServerResponse } from 'node:http';
9
- export declare const serveStatic: ({ root, path, req, res, allowOutsidePublicFolder, }: {
9
+ export declare const serveStatic: ({ root, path, req, res, allowOutsidePublicFolder, allowRemotionConvertCors, }: {
10
10
  root: string;
11
11
  path: string;
12
12
  req: IncomingMessage;
13
13
  res: ServerResponse<IncomingMessage>;
14
14
  allowOutsidePublicFolder: boolean;
15
+ allowRemotionConvertCors: boolean;
15
16
  }) => Promise<void>;
@@ -12,7 +12,36 @@ const node_fs_1 = require("node:fs");
12
12
  const renderer_1 = require("@remotion/renderer");
13
13
  const middleware_1 = require("./dev-middleware/middleware");
14
14
  const range_parser_1 = require("./dev-middleware/range-parser");
15
- const serveStatic = async function ({ root, path, req, res, allowOutsidePublicFolder, }) {
15
+ const remotionConvertOrigins = [
16
+ 'https://remotion.dev',
17
+ 'https://www.remotion.dev',
18
+ 'https://convert.remotion.dev',
19
+ ];
20
+ const applyRemotionConvertCorsHeaders = ({ req, res, }) => {
21
+ const { origin } = req.headers;
22
+ if (!origin || !remotionConvertOrigins.includes(origin)) {
23
+ return false;
24
+ }
25
+ res.setHeader('Access-Control-Allow-Origin', origin);
26
+ res.setHeader('Vary', 'Origin, Access-Control-Request-Headers, Access-Control-Request-Private-Network');
27
+ res.setHeader('Access-Control-Allow-Methods', 'GET, HEAD, OPTIONS');
28
+ res.setHeader('Access-Control-Allow-Headers', 'Range, Content-Type');
29
+ res.setHeader('Access-Control-Expose-Headers', 'Accept-Ranges, Content-Length, Content-Range');
30
+ res.setHeader('Access-Control-Max-Age', '600');
31
+ if (req.headers['access-control-request-private-network']) {
32
+ res.setHeader('Access-Control-Allow-Private-Network', 'true');
33
+ }
34
+ return true;
35
+ };
36
+ const serveStatic = async function ({ root, path, req, res, allowOutsidePublicFolder, allowRemotionConvertCors, }) {
37
+ const remotionConvertCorsAllowed = allowRemotionConvertCors
38
+ ? applyRemotionConvertCorsHeaders({ req, res })
39
+ : false;
40
+ if (req.method === 'OPTIONS' && remotionConvertCorsAllowed) {
41
+ res.statusCode = 204;
42
+ res.end();
43
+ return;
44
+ }
16
45
  if (req.method !== 'GET' && req.method !== 'HEAD') {
17
46
  // method not allowed
18
47
  res.statusCode = 405;
@@ -43,6 +72,7 @@ const serveStatic = async function ({ root, path, req, res, allowOutsidePublicFo
43
72
  req,
44
73
  res,
45
74
  allowOutsidePublicFolder: true,
75
+ allowRemotionConvertCors,
46
76
  });
47
77
  }
48
78
  const isDirectory = lstat.isDirectory();
package/dist/routes.js CHANGED
@@ -396,6 +396,7 @@ const handleRoutes = ({ staticHash, staticHashPrefix, outputHash, outputHashPref
396
396
  req: request,
397
397
  res: response,
398
398
  allowOutsidePublicFolder: false,
399
+ allowRemotionConvertCors: true,
399
400
  });
400
401
  }
401
402
  if (url.pathname.startsWith(staticHashPrefix)) {
@@ -410,6 +411,7 @@ const handleRoutes = ({ staticHash, staticHashPrefix, outputHash, outputHashPref
410
411
  req: request,
411
412
  res: response,
412
413
  allowOutsidePublicFolder: false,
414
+ allowRemotionConvertCors: false,
413
415
  });
414
416
  }
415
417
  if (url.pathname.startsWith(outputHashPrefix)) {
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.515",
6
+ "version": "4.0.516",
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.515",
26
+ "@remotion/studio-protocol": "4.0.516",
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.515",
36
- "recast": "0.23.11",
37
- "@remotion/bundler": "4.0.515",
38
- "@remotion/renderer": "4.0.515",
39
- "@remotion/studio-codemods": "4.0.515",
40
- "@remotion/studio-shared": "4.0.515",
35
+ "remotion": "4.0.516",
36
+ "recast": "0.23.21",
37
+ "@remotion/bundler": "4.0.516",
38
+ "@remotion/renderer": "4.0.516",
39
+ "@remotion/studio-codemods": "4.0.516",
40
+ "@remotion/studio-shared": "4.0.516",
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.515",
48
+ "@remotion/eslint-config-internal": "4.0.516",
49
49
  "eslint": "9.19.0",
50
50
  "@types/node": "20.12.14",
51
51
  "@typescript/native-preview": "7.0.0-dev.20260217.1"