@remotion/studio-server 4.0.460 → 4.0.462
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/codemods/update-effect-props/update-effect-props.d.ts +52 -0
- package/dist/codemods/update-effect-props/update-effect-props.js +229 -0
- package/dist/codemods/update-sequence-props/find-props-to-delete.d.ts +6 -0
- package/dist/codemods/update-sequence-props/find-props-to-delete.js +37 -0
- package/dist/codemods/update-sequence-props/update-sequence-props.d.ts +35 -0
- package/dist/codemods/update-sequence-props/update-sequence-props.js +224 -0
- package/dist/codemods/update-sequence-props.d.ts +7 -1
- package/dist/codemods/update-sequence-props.js +46 -3
- package/dist/index.d.ts +1 -2
- package/dist/preview-server/api-routes.js +2 -0
- package/dist/preview-server/routes/apply-visual-control-change.js +4 -4
- package/dist/preview-server/routes/can-update-effect-props.d.ts +20 -0
- package/dist/preview-server/routes/can-update-effect-props.js +146 -0
- package/dist/preview-server/routes/can-update-sequence-props.d.ts +26 -6
- package/dist/preview-server/routes/can-update-sequence-props.js +82 -35
- package/dist/preview-server/routes/delete-jsx-node.js +4 -4
- package/dist/preview-server/routes/duplicate-jsx-node.js +4 -4
- package/dist/preview-server/routes/log-update.d.ts +13 -2
- package/dist/preview-server/routes/log-update.js +56 -30
- package/dist/preview-server/routes/log-updates/format-effect-prop-change.d.ts +10 -0
- package/dist/preview-server/routes/log-updates/format-effect-prop-change.js +51 -0
- package/dist/preview-server/routes/log-updates/format-prop-change.d.ts +9 -0
- package/dist/preview-server/routes/log-updates/format-prop-change.js +29 -0
- package/dist/preview-server/routes/log-updates/format-side-prop.d.ts +0 -0
- package/dist/preview-server/routes/log-updates/format-side-prop.js +1 -0
- package/dist/preview-server/routes/log-updates/format-side-props.d.ts +5 -0
- package/dist/preview-server/routes/log-updates/format-side-props.js +18 -0
- package/dist/preview-server/routes/log-updates/formatting.d.ts +19 -0
- package/dist/preview-server/routes/log-updates/formatting.js +67 -0
- package/dist/preview-server/routes/log-updates/log-effect-update.d.ts +14 -0
- package/dist/preview-server/routes/log-updates/log-effect-update.js +23 -0
- package/dist/preview-server/routes/log-updates/log-update.d.ts +15 -0
- package/dist/preview-server/routes/log-updates/log-update.js +39 -0
- package/dist/preview-server/routes/save-effect-props.d.ts +3 -0
- package/dist/preview-server/routes/save-effect-props.js +107 -0
- package/dist/preview-server/routes/save-sequence-props.js +82 -87
- package/dist/preview-server/routes/subscribe-to-sequence-props.js +4 -3
- package/dist/preview-server/routes/unsubscribe-from-sequence-props.js +4 -2
- package/dist/preview-server/routes/update-default-props.js +4 -4
- package/dist/preview-server/sequence-props-watchers.d.ts +9 -4
- package/dist/preview-server/sequence-props-watchers.js +54 -24
- package/dist/preview-server/start-server.d.ts +0 -1
- package/dist/preview-server/start-server.js +0 -1
- package/dist/preview-server/undo-stack.d.ts +3 -1
- package/dist/preview-server/undo-stack.js +1 -1
- package/dist/routes.js +0 -14
- package/dist/start-studio.d.ts +1 -2
- package/dist/start-studio.js +1 -2
- package/package.json +8 -10
- package/dist/codemods/jsx-sequence-context.d.ts +0 -11
- package/dist/codemods/jsx-sequence-context.js +0 -68
|
@@ -61,9 +61,32 @@ const removeVariantKey = ({ node, variantKey, }) => {
|
|
|
61
61
|
isDefault: true,
|
|
62
62
|
});
|
|
63
63
|
};
|
|
64
|
+
const snapshotTopLevelAttrs = (node) => {
|
|
65
|
+
var _a;
|
|
66
|
+
const result = new Map();
|
|
67
|
+
for (const a of (_a = node.attributes) !== null && _a !== void 0 ? _a : []) {
|
|
68
|
+
if (a.type === 'JSXAttribute' && a.name.type === 'JSXIdentifier') {
|
|
69
|
+
const name = a.name.name;
|
|
70
|
+
const printed = recast
|
|
71
|
+
.print(a)
|
|
72
|
+
.code.replace(/\s+/g, ' ')
|
|
73
|
+
.replace(/,(\s*[}\]])/g, '$1')
|
|
74
|
+
.trim();
|
|
75
|
+
const prefix = `${name}=`;
|
|
76
|
+
let valueOnly = printed.startsWith(prefix)
|
|
77
|
+
? printed.slice(prefix.length)
|
|
78
|
+
: printed;
|
|
79
|
+
if (valueOnly.startsWith('{') && valueOnly.endsWith('}')) {
|
|
80
|
+
valueOnly = valueOnly.slice(1, -1).trim();
|
|
81
|
+
}
|
|
82
|
+
result.set(name, valueOnly);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return result;
|
|
86
|
+
};
|
|
64
87
|
const updateSequencePropsAst = ({ input, nodePath, updates, schema, }) => {
|
|
65
88
|
var _a, _b, _c;
|
|
66
|
-
var _d;
|
|
89
|
+
var _d, _e;
|
|
67
90
|
const ast = (0, parse_ast_1.parseAst)(input);
|
|
68
91
|
const node = (0, can_update_sequence_props_1.findJsxElementAtNodePath)(ast, nodePath);
|
|
69
92
|
if (!node) {
|
|
@@ -71,6 +94,11 @@ const updateSequencePropsAst = ({ input, nodePath, updates, schema, }) => {
|
|
|
71
94
|
}
|
|
72
95
|
const logLine = (_d = (_a = node.loc) === null || _a === void 0 ? void 0 : _a.start.line) !== null && _d !== void 0 ? _d : 1;
|
|
73
96
|
const oldValueStrings = [];
|
|
97
|
+
const initialAttrs = snapshotTopLevelAttrs(node);
|
|
98
|
+
const updatedTopLevelKeys = new Set(updates.map(({ key }) => {
|
|
99
|
+
const dot = key.indexOf('.');
|
|
100
|
+
return dot === -1 ? key : key.slice(0, dot);
|
|
101
|
+
}));
|
|
74
102
|
for (const { key, value, defaultValue } of updates) {
|
|
75
103
|
let oldValueString = '';
|
|
76
104
|
const isDefault = defaultValue !== null &&
|
|
@@ -145,7 +173,7 @@ const updateSequencePropsAst = ({ input, nodePath, updates, schema, }) => {
|
|
|
145
173
|
try {
|
|
146
174
|
oldRawValue = JSON.parse(oldValueString);
|
|
147
175
|
}
|
|
148
|
-
catch (
|
|
176
|
+
catch (_f) {
|
|
149
177
|
oldRawValue = oldValueString;
|
|
150
178
|
}
|
|
151
179
|
if (oldRawValue !== value) {
|
|
@@ -166,15 +194,29 @@ const updateSequencePropsAst = ({ input, nodePath, updates, schema, }) => {
|
|
|
166
194
|
}
|
|
167
195
|
}
|
|
168
196
|
}
|
|
197
|
+
const finalAttrNames = new Set();
|
|
198
|
+
for (const a of (_e = node.attributes) !== null && _e !== void 0 ? _e : []) {
|
|
199
|
+
if (a.type === 'JSXAttribute' && a.name.type === 'JSXIdentifier') {
|
|
200
|
+
finalAttrNames.add(a.name.name);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const removedProps = [];
|
|
204
|
+
for (const [name, valueString] of initialAttrs) {
|
|
205
|
+
if (finalAttrNames.has(name) || updatedTopLevelKeys.has(name)) {
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
removedProps.push({ key: name, valueString });
|
|
209
|
+
}
|
|
169
210
|
return {
|
|
170
211
|
serialized: (0, parse_ast_1.serializeAst)(ast),
|
|
171
212
|
oldValueStrings,
|
|
172
213
|
logLine,
|
|
214
|
+
removedProps,
|
|
173
215
|
};
|
|
174
216
|
};
|
|
175
217
|
exports.updateSequencePropsAst = updateSequencePropsAst;
|
|
176
218
|
const updateSequenceProps = async ({ input, nodePath, updates, schema, prettierConfigOverride, }) => {
|
|
177
|
-
const { serialized, oldValueStrings, logLine } = (0, exports.updateSequencePropsAst)({
|
|
219
|
+
const { serialized, oldValueStrings, logLine, removedProps } = (0, exports.updateSequencePropsAst)({
|
|
178
220
|
input,
|
|
179
221
|
nodePath,
|
|
180
222
|
updates,
|
|
@@ -189,6 +231,7 @@ const updateSequenceProps = async ({ input, nodePath, updates, schema, prettierC
|
|
|
189
231
|
oldValueStrings,
|
|
190
232
|
formatted,
|
|
191
233
|
logLine,
|
|
234
|
+
removedProps,
|
|
192
235
|
};
|
|
193
236
|
};
|
|
194
237
|
exports.updateSequenceProps = updateSequenceProps;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { ApiRoutes, CopyStillToClipboardRequest, getDefaultOutLocation, OpenInFi
|
|
|
2
2
|
export type { AggregateRenderProgress, BundlingState, CopyingState, DownloadProgress, HotMiddlewareOptions, JobProgressCallback, ModuleMap, PackageManager, ProjectInfo, RenderingProgressInput, RenderJob, RenderJobWithCleanup, RequiredChromiumOptions, StitchingProgressInput, UiOpenGlOptions, } from '@remotion/studio-shared';
|
|
3
3
|
import { AnsiDiff } from './ansi-diff';
|
|
4
4
|
export declare const StudioServerInternals: {
|
|
5
|
-
startStudio: ({ browserArgs, browserFlag, shouldOpenBrowser, fullEntryPath, logLevel, getCurrentInputProps, getEnvVariables, desiredPort, maxTimelineTracks, remotionRoot, keyboardShortcutsEnabled, experimentalClientSideRenderingEnabled,
|
|
5
|
+
startStudio: ({ browserArgs, browserFlag, shouldOpenBrowser, fullEntryPath, logLevel, getCurrentInputProps, getEnvVariables, desiredPort, maxTimelineTracks, remotionRoot, keyboardShortcutsEnabled, experimentalClientSideRenderingEnabled, relativePublicDir, webpackOverride, poll, getRenderDefaults, getRenderQueue, numberOfAudioTags, queueMethods, previewEntry, gitSource, bufferStateDelayInMilliseconds, binariesDirectory, forceIPv4, audioLatencyHint, enableCrossSiteIsolation, askAIEnabled, forceNew, rspack, }: {
|
|
6
6
|
browserArgs: string;
|
|
7
7
|
browserFlag: string;
|
|
8
8
|
logLevel: "error" | "info" | "trace" | "verbose" | "warn";
|
|
@@ -16,7 +16,6 @@ export declare const StudioServerInternals: {
|
|
|
16
16
|
remotionRoot: string;
|
|
17
17
|
keyboardShortcutsEnabled: boolean;
|
|
18
18
|
experimentalClientSideRenderingEnabled: boolean;
|
|
19
|
-
experimentalVisualModeEnabled: boolean;
|
|
20
19
|
relativePublicDir: string | null;
|
|
21
20
|
webpackOverride: import("@remotion/bundler").WebpackOverrideFn;
|
|
22
21
|
poll: number | null;
|
|
@@ -14,6 +14,7 @@ const project_info_1 = require("./routes/project-info");
|
|
|
14
14
|
const redo_1 = require("./routes/redo");
|
|
15
15
|
const remove_render_1 = require("./routes/remove-render");
|
|
16
16
|
const restart_studio_1 = require("./routes/restart-studio");
|
|
17
|
+
const save_effect_props_1 = require("./routes/save-effect-props");
|
|
17
18
|
const save_sequence_props_1 = require("./routes/save-sequence-props");
|
|
18
19
|
const subscribe_to_default_props_1 = require("./routes/subscribe-to-default-props");
|
|
19
20
|
const subscribe_to_file_existence_1 = require("./routes/subscribe-to-file-existence");
|
|
@@ -39,6 +40,7 @@ exports.allApiRoutes = {
|
|
|
39
40
|
'/api/subscribe-to-sequence-props': subscribe_to_sequence_props_1.subscribeToSequenceProps,
|
|
40
41
|
'/api/unsubscribe-from-sequence-props': unsubscribe_from_sequence_props_1.unsubscribeFromSequenceProps,
|
|
41
42
|
'/api/save-sequence-props': save_sequence_props_1.saveSequencePropsHandler,
|
|
43
|
+
'/api/save-effect-props': save_effect_props_1.saveEffectPropsHandler,
|
|
42
44
|
'/api/delete-jsx-node': delete_jsx_node_1.deleteJsxNodeHandler,
|
|
43
45
|
'/api/duplicate-jsx-node': duplicate_jsx_node_1.duplicateJsxNodeHandler,
|
|
44
46
|
'/api/update-available': update_available_1.handleUpdate,
|
|
@@ -48,7 +48,7 @@ const format_log_file_location_1 = require("../format-log-file-location");
|
|
|
48
48
|
const live_events_1 = require("../live-events");
|
|
49
49
|
const undo_stack_1 = require("../undo-stack");
|
|
50
50
|
const watch_ignore_next_change_1 = require("../watch-ignore-next-change");
|
|
51
|
-
const log_update_1 = require("./log-update");
|
|
51
|
+
const log_update_1 = require("./log-updates/log-update");
|
|
52
52
|
const getVisualControlChangeLine = (file, changeId) => {
|
|
53
53
|
let line = 1;
|
|
54
54
|
recast.types.visit(file.program, {
|
|
@@ -118,8 +118,8 @@ const applyVisualControlHandler = async ({ input: { fileName, changes }, remotio
|
|
|
118
118
|
remotionRoot,
|
|
119
119
|
logLine,
|
|
120
120
|
description: {
|
|
121
|
-
undoMessage: '
|
|
122
|
-
redoMessage: '
|
|
121
|
+
undoMessage: '↩️ Visual control change',
|
|
122
|
+
redoMessage: '↪️ Visual control change',
|
|
123
123
|
},
|
|
124
124
|
entryType: 'visual-control',
|
|
125
125
|
suppressHmrOnFileRestore: true,
|
|
@@ -144,7 +144,7 @@ const applyVisualControlHandler = async ({ input: { fileName, changes }, remotio
|
|
|
144
144
|
absolutePath,
|
|
145
145
|
line: logLine,
|
|
146
146
|
});
|
|
147
|
-
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}
|
|
147
|
+
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Applied visual control changes`);
|
|
148
148
|
if (!formatted) {
|
|
149
149
|
(0, log_update_1.warnAboutPrettierOnce)(logLevel);
|
|
150
150
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { JSXOpeningElement } from '@babel/types';
|
|
2
|
+
import type { CanUpdateEffectPropsResponse, SequenceNodePath, SequenceSchema } from 'remotion';
|
|
3
|
+
export declare const computeEffectPropStatus: ({ jsx, effectIndex, keys, }: {
|
|
4
|
+
jsx: JSXOpeningElement;
|
|
5
|
+
effectIndex: number;
|
|
6
|
+
keys: string[];
|
|
7
|
+
}) => CanUpdateEffectPropsResponse;
|
|
8
|
+
export declare const computeEffectPropsStatusesFromContent: ({ fileContents, sequenceNodePath, effects, keysFor, }: {
|
|
9
|
+
fileContents: string;
|
|
10
|
+
sequenceNodePath: SequenceNodePath;
|
|
11
|
+
effects: SequenceSchema[];
|
|
12
|
+
keysFor: (effect: SequenceSchema) => string[];
|
|
13
|
+
}) => CanUpdateEffectPropsResponse[];
|
|
14
|
+
export declare const computeEffectPropsStatusesFromFile: ({ fileName, sequenceNodePath, effects, keysFor, remotionRoot, }: {
|
|
15
|
+
fileName: string;
|
|
16
|
+
sequenceNodePath: SequenceNodePath;
|
|
17
|
+
effects: SequenceSchema[];
|
|
18
|
+
keysFor: (effect: SequenceSchema) => string[];
|
|
19
|
+
remotionRoot: string;
|
|
20
|
+
}) => CanUpdateEffectPropsResponse[];
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.computeEffectPropsStatusesFromFile = exports.computeEffectPropsStatusesFromContent = exports.computeEffectPropStatus = void 0;
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const parse_ast_1 = require("../../codemods/parse-ast");
|
|
10
|
+
const update_effect_props_1 = require("../../codemods/update-effect-props/update-effect-props");
|
|
11
|
+
const can_update_sequence_props_1 = require("./can-update-sequence-props");
|
|
12
|
+
const findExperimentalEffectsAttr = (jsx) => {
|
|
13
|
+
for (const attr of jsx.attributes) {
|
|
14
|
+
if (attr.type !== 'JSXAttribute') {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
if (attr.name.type === 'JSXIdentifier' &&
|
|
18
|
+
attr.name.name === '_experimentalEffects') {
|
|
19
|
+
return attr;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
};
|
|
24
|
+
const getEffectsArrayElements = (attr) => {
|
|
25
|
+
if (!attr || !attr.value || attr.value.type !== 'JSXExpressionContainer') {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const expr = attr.value.expression;
|
|
29
|
+
if (expr.type !== 'ArrayExpression') {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return (0, update_effect_props_1.enumerateEffectArrayElements)(expr);
|
|
33
|
+
};
|
|
34
|
+
const getPropsFromObjectExpression = ({ objExpr, keys, }) => {
|
|
35
|
+
const out = {};
|
|
36
|
+
for (const key of keys) {
|
|
37
|
+
const prop = objExpr.properties.find((p) => p.type === 'ObjectProperty' &&
|
|
38
|
+
((p.key.type === 'Identifier' && p.key.name === key) ||
|
|
39
|
+
(p.key.type === 'StringLiteral' &&
|
|
40
|
+
p.key.value === key)));
|
|
41
|
+
if (!prop) {
|
|
42
|
+
out[key] = { canUpdate: true, codeValue: undefined };
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const valueExpr = prop.value;
|
|
46
|
+
if (!(0, can_update_sequence_props_1.isStaticValue)(valueExpr)) {
|
|
47
|
+
out[key] = { canUpdate: false, reason: 'computed' };
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
out[key] = {
|
|
51
|
+
canUpdate: true,
|
|
52
|
+
codeValue: (0, can_update_sequence_props_1.extractStaticValue)(valueExpr),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
};
|
|
57
|
+
const computeEffectPropStatus = ({ jsx, effectIndex, keys, }) => {
|
|
58
|
+
const attr = findExperimentalEffectsAttr(jsx);
|
|
59
|
+
const elements = getEffectsArrayElements(attr);
|
|
60
|
+
if (!elements) {
|
|
61
|
+
return {
|
|
62
|
+
canUpdate: false,
|
|
63
|
+
effectIndex,
|
|
64
|
+
reason: 'not-found',
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (effectIndex < 0 || effectIndex >= elements.length) {
|
|
68
|
+
return {
|
|
69
|
+
canUpdate: false,
|
|
70
|
+
effectIndex,
|
|
71
|
+
reason: 'not-found',
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const target = elements[effectIndex];
|
|
75
|
+
if (target.kind !== 'call') {
|
|
76
|
+
return {
|
|
77
|
+
canUpdate: false,
|
|
78
|
+
effectIndex,
|
|
79
|
+
reason: 'not-call-expression',
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const call = target.node;
|
|
83
|
+
if (call.arguments.length === 0) {
|
|
84
|
+
const emptyProps = {};
|
|
85
|
+
for (const key of keys) {
|
|
86
|
+
emptyProps[key] = { canUpdate: true, codeValue: undefined };
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
canUpdate: true,
|
|
90
|
+
callee: target.callee,
|
|
91
|
+
effectIndex,
|
|
92
|
+
props: emptyProps,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
const firstArg = call.arguments[0];
|
|
96
|
+
if (firstArg.type !== 'ObjectExpression') {
|
|
97
|
+
return {
|
|
98
|
+
canUpdate: false,
|
|
99
|
+
effectIndex,
|
|
100
|
+
reason: 'computed',
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
const resolvedProps = getPropsFromObjectExpression({
|
|
104
|
+
objExpr: firstArg,
|
|
105
|
+
keys,
|
|
106
|
+
});
|
|
107
|
+
return {
|
|
108
|
+
canUpdate: true,
|
|
109
|
+
effectIndex,
|
|
110
|
+
callee: target.callee,
|
|
111
|
+
props: resolvedProps,
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
exports.computeEffectPropStatus = computeEffectPropStatus;
|
|
115
|
+
const computeEffectPropsStatusesFromContent = ({ fileContents, sequenceNodePath, effects, keysFor, }) => {
|
|
116
|
+
const ast = (0, parse_ast_1.parseAst)(fileContents);
|
|
117
|
+
const jsx = (0, can_update_sequence_props_1.findJsxElementAtNodePath)(ast, sequenceNodePath);
|
|
118
|
+
if (!jsx) {
|
|
119
|
+
return effects.map((_effect, effectIndex) => ({
|
|
120
|
+
canUpdate: false,
|
|
121
|
+
effectIndex,
|
|
122
|
+
reason: 'not-found',
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
return effects.map((effect, effectIndex) => (0, exports.computeEffectPropStatus)({
|
|
126
|
+
jsx,
|
|
127
|
+
effectIndex,
|
|
128
|
+
keys: keysFor(effect),
|
|
129
|
+
}));
|
|
130
|
+
};
|
|
131
|
+
exports.computeEffectPropsStatusesFromContent = computeEffectPropsStatusesFromContent;
|
|
132
|
+
const computeEffectPropsStatusesFromFile = ({ fileName, sequenceNodePath, effects, keysFor, remotionRoot, }) => {
|
|
133
|
+
const absolutePath = node_path_1.default.resolve(remotionRoot, fileName);
|
|
134
|
+
const fileRelativeToRoot = node_path_1.default.relative(remotionRoot, absolutePath);
|
|
135
|
+
if (fileRelativeToRoot.startsWith('..')) {
|
|
136
|
+
throw new Error('Cannot read a file outside the project');
|
|
137
|
+
}
|
|
138
|
+
const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
|
|
139
|
+
return (0, exports.computeEffectPropsStatusesFromContent)({
|
|
140
|
+
fileContents,
|
|
141
|
+
sequenceNodePath,
|
|
142
|
+
effects,
|
|
143
|
+
keysFor,
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
exports.computeEffectPropsStatusesFromFile = computeEffectPropsStatusesFromFile;
|
|
@@ -1,19 +1,39 @@
|
|
|
1
1
|
import type { Expression, File, JSXOpeningElement } from '@babel/types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SubscribeToSequencePropsResponse } from '@remotion/studio-shared';
|
|
3
|
+
import type { CanUpdateSequencePropsResponseTrue } from 'remotion';
|
|
4
|
+
import type { SequenceNodePath } from 'remotion';
|
|
5
|
+
import type { CanUpdateSequencePropStatus } from 'remotion';
|
|
3
6
|
export declare const isStaticValue: (node: Expression) => boolean;
|
|
4
7
|
export declare const extractStaticValue: (node: Expression) => unknown;
|
|
5
8
|
export declare const findJsxElementAtNodePath: (ast: File, nodePath: SequenceNodePath) => JSXOpeningElement | null;
|
|
6
9
|
export declare const lineColumnToNodePath: (ast: File, targetLine: number) => SequenceNodePath | null;
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const computeSequencePropsStatus: ({ fileName, nodePath, keys, remotionRoot, }: {
|
|
10
|
+
export declare const computeSequencePropsOnlyStatus: ({ fileName, nodePath, keys, remotionRoot, }: {
|
|
9
11
|
fileName: string;
|
|
10
12
|
nodePath: SequenceNodePath;
|
|
11
13
|
keys: string[];
|
|
12
14
|
remotionRoot: string;
|
|
13
|
-
}) =>
|
|
14
|
-
|
|
15
|
+
}) => {
|
|
16
|
+
canUpdate: true;
|
|
17
|
+
props: Record<string, CanUpdateSequencePropStatus>;
|
|
18
|
+
};
|
|
19
|
+
export declare const computeSequencePropsStatusFromContent: ({ fileContents, nodePath, keys, effects, }: {
|
|
20
|
+
fileContents: string;
|
|
21
|
+
nodePath: SequenceNodePath;
|
|
22
|
+
keys: string[];
|
|
23
|
+
effects: string[][];
|
|
24
|
+
}) => CanUpdateSequencePropsResponseTrue;
|
|
25
|
+
export declare const computeSequencePropsStatus: ({ fileName, nodePath, keys, effects, remotionRoot, }: {
|
|
26
|
+
fileName: string;
|
|
27
|
+
nodePath: SequenceNodePath;
|
|
28
|
+
keys: string[];
|
|
29
|
+
effects: string[][];
|
|
30
|
+
remotionRoot: string;
|
|
31
|
+
}) => CanUpdateSequencePropsResponseTrue;
|
|
32
|
+
export declare const computeSequencePropsStatusFromFilenameByLine: ({ fileName, line, keys, effects, remotionRoot, logLevel, }: {
|
|
15
33
|
fileName: string;
|
|
16
34
|
line: number;
|
|
17
35
|
keys: string[];
|
|
36
|
+
effects: string[][];
|
|
18
37
|
remotionRoot: string;
|
|
19
|
-
|
|
38
|
+
logLevel: "error" | "info" | "trace" | "verbose" | "warn";
|
|
39
|
+
}) => SubscribeToSequencePropsResponse;
|
|
@@ -36,13 +36,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.computeSequencePropsStatusFromFilenameByLine = exports.computeSequencePropsStatus = exports.computeSequencePropsStatusFromContent = exports.lineColumnToNodePath = exports.findJsxElementAtNodePath = exports.extractStaticValue = exports.isStaticValue = void 0;
|
|
39
|
+
exports.computeSequencePropsStatusFromFilenameByLine = exports.computeSequencePropsStatus = exports.computeSequencePropsStatusFromContent = exports.computeSequencePropsOnlyStatus = exports.lineColumnToNodePath = exports.findJsxElementAtNodePath = exports.extractStaticValue = exports.isStaticValue = void 0;
|
|
40
40
|
const node_fs_1 = require("node:fs");
|
|
41
41
|
const node_path_1 = __importDefault(require("node:path"));
|
|
42
|
+
const renderer_1 = require("@remotion/renderer");
|
|
42
43
|
const recast = __importStar(require("recast"));
|
|
43
|
-
const jsx_sequence_context_1 = require("../../codemods/jsx-sequence-context");
|
|
44
44
|
const parse_ast_1 = require("../../codemods/parse-ast");
|
|
45
45
|
const get_ast_node_path_1 = require("../../helpers/get-ast-node-path");
|
|
46
|
+
const can_update_effect_props_1 = require("./can-update-effect-props");
|
|
46
47
|
const isStaticValue = (node) => {
|
|
47
48
|
switch (node.type) {
|
|
48
49
|
case 'NumericLiteral':
|
|
@@ -248,12 +249,14 @@ const getNestedPropStatus = (jsxElement, parentKey, childKey) => {
|
|
|
248
249
|
}
|
|
249
250
|
return { canUpdate: true, codeValue };
|
|
250
251
|
};
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
252
|
+
const computeEffectsForJsx = ({ jsxElement, effects, }) => {
|
|
253
|
+
return effects.map((effect, effectIndex) => (0, can_update_effect_props_1.computeEffectPropStatus)({
|
|
254
|
+
jsx: jsxElement,
|
|
255
|
+
effectIndex,
|
|
256
|
+
keys: effect,
|
|
257
|
+
}));
|
|
258
|
+
};
|
|
259
|
+
const computeSequenceOnlyPropsRecord = ({ jsxElement, keys, }) => {
|
|
257
260
|
const allProps = getPropsStatus(jsxElement);
|
|
258
261
|
const filteredProps = {};
|
|
259
262
|
for (const key of keys) {
|
|
@@ -268,33 +271,57 @@ const computeSequencePropsStatusFromContent = (fileContents, nodePath, keys) =>
|
|
|
268
271
|
filteredProps[key] = { canUpdate: true, codeValue: undefined };
|
|
269
272
|
}
|
|
270
273
|
}
|
|
274
|
+
return filteredProps;
|
|
275
|
+
};
|
|
276
|
+
const computeSequencePropsOnlyStatus = ({ fileName, nodePath, keys, remotionRoot, }) => {
|
|
277
|
+
const absolutePath = node_path_1.default.resolve(remotionRoot, fileName);
|
|
278
|
+
const fileRelativeToRoot = node_path_1.default.relative(remotionRoot, absolutePath);
|
|
279
|
+
if (fileRelativeToRoot.startsWith('..')) {
|
|
280
|
+
throw new Error('Cannot read a file outside the project');
|
|
281
|
+
}
|
|
282
|
+
const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
|
|
283
|
+
const ast = (0, parse_ast_1.parseAst)(fileContents);
|
|
284
|
+
const jsxElement = (0, exports.findJsxElementAtNodePath)(ast, nodePath);
|
|
285
|
+
if (!jsxElement) {
|
|
286
|
+
throw new Error('Cannot compute sequence props: Could not find a JSX element at the specified location');
|
|
287
|
+
}
|
|
288
|
+
return {
|
|
289
|
+
canUpdate: true,
|
|
290
|
+
props: computeSequenceOnlyPropsRecord({ jsxElement, keys }),
|
|
291
|
+
};
|
|
292
|
+
};
|
|
293
|
+
exports.computeSequencePropsOnlyStatus = computeSequencePropsOnlyStatus;
|
|
294
|
+
const computeSequencePropsStatusFromContent = ({ fileContents, nodePath, keys, effects, }) => {
|
|
295
|
+
const ast = (0, parse_ast_1.parseAst)(fileContents);
|
|
296
|
+
const jsxElement = (0, exports.findJsxElementAtNodePath)(ast, nodePath);
|
|
297
|
+
if (!jsxElement) {
|
|
298
|
+
throw new Error('Cannot compute sequence props status: Could not find a JSX element at the specified location');
|
|
299
|
+
}
|
|
300
|
+
const filteredProps = computeSequenceOnlyPropsRecord({ jsxElement, keys });
|
|
301
|
+
const effectsStatuses = computeEffectsForJsx({ jsxElement, effects });
|
|
271
302
|
return {
|
|
272
303
|
canUpdate: true,
|
|
273
304
|
props: filteredProps,
|
|
274
|
-
|
|
275
|
-
jsxInMapCallback: (0, jsx_sequence_context_1.isJsxUnderMapCallback)(ast, nodePath),
|
|
305
|
+
effects: effectsStatuses,
|
|
276
306
|
};
|
|
277
307
|
};
|
|
278
308
|
exports.computeSequencePropsStatusFromContent = computeSequencePropsStatusFromContent;
|
|
279
|
-
const computeSequencePropsStatus = ({ fileName, nodePath, keys, remotionRoot, }) => {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
throw new Error('Cannot read a file outside the project');
|
|
285
|
-
}
|
|
286
|
-
const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
|
|
287
|
-
return (0, exports.computeSequencePropsStatusFromContent)(fileContents, nodePath, keys);
|
|
288
|
-
}
|
|
289
|
-
catch (err) {
|
|
290
|
-
return {
|
|
291
|
-
canUpdate: false,
|
|
292
|
-
reason: err.message,
|
|
293
|
-
};
|
|
309
|
+
const computeSequencePropsStatus = ({ fileName, nodePath, keys, effects, remotionRoot, }) => {
|
|
310
|
+
const absolutePath = node_path_1.default.resolve(remotionRoot, fileName);
|
|
311
|
+
const fileRelativeToRoot = node_path_1.default.relative(remotionRoot, absolutePath);
|
|
312
|
+
if (fileRelativeToRoot.startsWith('..')) {
|
|
313
|
+
throw new Error('Cannot read a file outside the project');
|
|
294
314
|
}
|
|
315
|
+
const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
|
|
316
|
+
return (0, exports.computeSequencePropsStatusFromContent)({
|
|
317
|
+
fileContents,
|
|
318
|
+
nodePath,
|
|
319
|
+
keys,
|
|
320
|
+
effects,
|
|
321
|
+
});
|
|
295
322
|
};
|
|
296
323
|
exports.computeSequencePropsStatus = computeSequencePropsStatus;
|
|
297
|
-
const computeSequencePropsStatusFromFilenameByLine = ({ fileName, line, keys, remotionRoot, }) => {
|
|
324
|
+
const computeSequencePropsStatusFromFilenameByLine = ({ fileName, line, keys, effects, remotionRoot, logLevel, }) => {
|
|
298
325
|
try {
|
|
299
326
|
const absolutePath = node_path_1.default.resolve(remotionRoot, fileName);
|
|
300
327
|
const fileRelativeToRoot = node_path_1.default.relative(remotionRoot, absolutePath);
|
|
@@ -305,19 +332,39 @@ const computeSequencePropsStatusFromFilenameByLine = ({ fileName, line, keys, re
|
|
|
305
332
|
const ast = (0, parse_ast_1.parseAst)(fileContents);
|
|
306
333
|
const resolvedNodePath = (0, exports.lineColumnToNodePath)(ast, line);
|
|
307
334
|
if (!resolvedNodePath) {
|
|
308
|
-
|
|
335
|
+
return {
|
|
336
|
+
status: {
|
|
337
|
+
canUpdate: false,
|
|
338
|
+
reason: 'not-found',
|
|
339
|
+
},
|
|
340
|
+
success: false,
|
|
341
|
+
};
|
|
309
342
|
}
|
|
310
|
-
return
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
343
|
+
return {
|
|
344
|
+
status: (0, exports.computeSequencePropsStatus)({
|
|
345
|
+
fileName,
|
|
346
|
+
nodePath: resolvedNodePath,
|
|
347
|
+
keys,
|
|
348
|
+
effects,
|
|
349
|
+
remotionRoot,
|
|
350
|
+
}),
|
|
351
|
+
nodePath: {
|
|
352
|
+
absolutePath,
|
|
353
|
+
nodePath: resolvedNodePath,
|
|
354
|
+
sequenceKeys: keys,
|
|
355
|
+
effectKeys: effects,
|
|
356
|
+
},
|
|
357
|
+
success: true,
|
|
358
|
+
};
|
|
316
359
|
}
|
|
317
360
|
catch (err) {
|
|
361
|
+
renderer_1.RenderInternals.Log.error({ indent: false, logLevel }, err);
|
|
318
362
|
return {
|
|
319
|
-
|
|
320
|
-
|
|
363
|
+
status: {
|
|
364
|
+
canUpdate: false,
|
|
365
|
+
reason: 'error',
|
|
366
|
+
},
|
|
367
|
+
success: false,
|
|
321
368
|
};
|
|
322
369
|
}
|
|
323
370
|
};
|
|
@@ -11,7 +11,7 @@ const delete_jsx_node_1 = require("../../codemods/delete-jsx-node");
|
|
|
11
11
|
const file_watcher_1 = require("../../file-watcher");
|
|
12
12
|
const format_log_file_location_1 = require("../format-log-file-location");
|
|
13
13
|
const undo_stack_1 = require("../undo-stack");
|
|
14
|
-
const log_update_1 = require("./log-update");
|
|
14
|
+
const log_update_1 = require("./log-updates/log-update");
|
|
15
15
|
const deleteJsxNodeHandler = async ({ input: { fileName, nodePath }, remotionRoot, logLevel }) => {
|
|
16
16
|
try {
|
|
17
17
|
renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[delete-jsx-node] Received request for fileName="${fileName}"`);
|
|
@@ -32,8 +32,8 @@ const deleteJsxNodeHandler = async ({ input: { fileName, nodePath }, remotionRoo
|
|
|
32
32
|
remotionRoot,
|
|
33
33
|
logLine,
|
|
34
34
|
description: {
|
|
35
|
-
undoMessage:
|
|
36
|
-
redoMessage:
|
|
35
|
+
undoMessage: `↩️ Deletion of ${nodeLabel}`,
|
|
36
|
+
redoMessage: `↪️ Deletion of ${nodeLabel}`,
|
|
37
37
|
},
|
|
38
38
|
entryType: 'delete-jsx-node',
|
|
39
39
|
suppressHmrOnFileRestore: false,
|
|
@@ -45,7 +45,7 @@ const deleteJsxNodeHandler = async ({ input: { fileName, nodePath }, remotionRoo
|
|
|
45
45
|
absolutePath,
|
|
46
46
|
line: logLine,
|
|
47
47
|
});
|
|
48
|
-
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}
|
|
48
|
+
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Deleted ${nodeLabel}`);
|
|
49
49
|
if (!formatted) {
|
|
50
50
|
(0, log_update_1.warnAboutPrettierOnce)(logLevel);
|
|
51
51
|
}
|
|
@@ -11,7 +11,7 @@ const duplicate_jsx_node_1 = require("../../codemods/duplicate-jsx-node");
|
|
|
11
11
|
const file_watcher_1 = require("../../file-watcher");
|
|
12
12
|
const format_log_file_location_1 = require("../format-log-file-location");
|
|
13
13
|
const undo_stack_1 = require("../undo-stack");
|
|
14
|
-
const log_update_1 = require("./log-update");
|
|
14
|
+
const log_update_1 = require("./log-updates/log-update");
|
|
15
15
|
const duplicateJsxNodeHandler = async ({ input: { fileName, nodePath }, remotionRoot, logLevel }) => {
|
|
16
16
|
try {
|
|
17
17
|
renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[duplicate-jsx-node] Received request for fileName="${fileName}"`);
|
|
@@ -32,8 +32,8 @@ const duplicateJsxNodeHandler = async ({ input: { fileName, nodePath }, remotion
|
|
|
32
32
|
remotionRoot,
|
|
33
33
|
logLine,
|
|
34
34
|
description: {
|
|
35
|
-
undoMessage:
|
|
36
|
-
redoMessage:
|
|
35
|
+
undoMessage: `↩️ Duplication of ${nodeLabel}`,
|
|
36
|
+
redoMessage: `↪️ Duplication of ${nodeLabel}`,
|
|
37
37
|
},
|
|
38
38
|
entryType: 'duplicate-jsx-node',
|
|
39
39
|
suppressHmrOnFileRestore: false,
|
|
@@ -45,7 +45,7 @@ const duplicateJsxNodeHandler = async ({ input: { fileName, nodePath }, remotion
|
|
|
45
45
|
absolutePath,
|
|
46
46
|
line: logLine,
|
|
47
47
|
});
|
|
48
|
-
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}
|
|
48
|
+
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Duplicated ${nodeLabel}`);
|
|
49
49
|
if (!formatted) {
|
|
50
50
|
(0, log_update_1.warnAboutPrettierOnce)(logLevel);
|
|
51
51
|
}
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
export declare const warnAboutPrettierOnce: (logLevel: "error" | "info" | "trace" | "verbose" | "warn") => void;
|
|
2
2
|
export declare const normalizeQuotes: (str: string) => string;
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const fg: (r: number, g: number, b: number, str: string) => string;
|
|
4
|
+
export declare const bg: (r: number, g: number, b: number, str: string) => string;
|
|
5
|
+
export declare const strikeThrough: (str: string) => string;
|
|
6
|
+
export type PropDelta = {
|
|
7
|
+
key: string;
|
|
8
|
+
valueString: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const formatPropChange: ({ key, oldValueString, newValueString, defaultValueString, removedProps, addedProps, }: {
|
|
4
11
|
key: string;
|
|
5
12
|
oldValueString: string;
|
|
6
13
|
newValueString: string;
|
|
7
14
|
defaultValueString: string | null;
|
|
15
|
+
removedProps: PropDelta[];
|
|
16
|
+
addedProps: PropDelta[];
|
|
8
17
|
}) => string;
|
|
9
|
-
export declare const logUpdate: ({ fileRelativeToRoot, line, key, oldValueString, newValueString, defaultValueString, formatted, logLevel, }: {
|
|
18
|
+
export declare const logUpdate: ({ fileRelativeToRoot, line, key, oldValueString, newValueString, defaultValueString, formatted, logLevel, removedProps, addedProps, }: {
|
|
10
19
|
fileRelativeToRoot: string;
|
|
11
20
|
line: number;
|
|
12
21
|
key: string;
|
|
@@ -15,4 +24,6 @@ export declare const logUpdate: ({ fileRelativeToRoot, line, key, oldValueString
|
|
|
15
24
|
defaultValueString: string | null;
|
|
16
25
|
formatted: boolean;
|
|
17
26
|
logLevel: "error" | "info" | "trace" | "verbose" | "warn";
|
|
27
|
+
removedProps: PropDelta[];
|
|
28
|
+
addedProps: PropDelta[];
|
|
18
29
|
}) => void;
|