@remotion/studio-server 4.0.469 → 4.0.471
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/add-effect.d.ts +15 -0
- package/dist/codemods/add-effect.js +231 -0
- package/dist/codemods/delete-effect.d.ts +18 -0
- package/dist/codemods/delete-effect.js +95 -21
- package/dist/codemods/delete-jsx-node.d.ts +10 -0
- package/dist/codemods/delete-jsx-node.js +38 -14
- package/dist/codemods/reorder-effect.d.ts +13 -0
- package/dist/codemods/reorder-effect.js +61 -0
- package/dist/codemods/update-keyframes/ensure-imports-and-frame-hook.d.ts +4 -0
- package/dist/codemods/update-keyframes/ensure-imports-and-frame-hook.js +152 -0
- package/dist/codemods/update-keyframes/update-keyframes.d.ts +12 -0
- package/dist/codemods/update-keyframes/update-keyframes.js +116 -31
- package/dist/codemods/update-sequence-props/update-sequence-props.d.ts +32 -10
- package/dist/codemods/update-sequence-props/update-sequence-props.js +39 -7
- package/dist/helpers/open-in-editor.d.ts +2 -2
- package/dist/helpers/open-in-editor.js +35 -2
- package/dist/helpers/resolve-composition-component.d.ts +15 -0
- package/dist/helpers/resolve-composition-component.js +269 -31
- package/dist/index.d.ts +2 -1
- package/dist/preview-server/api-routes.js +20 -0
- package/dist/preview-server/routes/add-effect-keyframe.d.ts +3 -0
- package/dist/preview-server/routes/add-effect-keyframe.js +91 -0
- package/dist/preview-server/routes/add-effect.d.ts +3 -0
- package/dist/preview-server/routes/add-effect.js +68 -0
- package/dist/preview-server/routes/add-sequence-keyframe.d.ts +3 -0
- package/dist/preview-server/routes/add-sequence-keyframe.js +87 -0
- package/dist/preview-server/routes/apply-codemod.js +1 -0
- package/dist/preview-server/routes/apply-visual-control-change.js +1 -0
- package/dist/preview-server/routes/can-update-sequence-props.d.ts +1 -0
- package/dist/preview-server/routes/can-update-sequence-props.js +48 -14
- package/dist/preview-server/routes/composition-component-info.d.ts +3 -0
- package/dist/preview-server/routes/composition-component-info.js +26 -0
- package/dist/preview-server/routes/delete-effect-keyframe.d.ts +3 -0
- package/dist/preview-server/routes/delete-effect-keyframe.js +89 -0
- package/dist/preview-server/routes/delete-effect.js +76 -37
- package/dist/preview-server/routes/delete-jsx-node.js +67 -36
- package/dist/preview-server/routes/delete-keyframes.d.ts +13 -0
- package/dist/preview-server/routes/delete-keyframes.js +263 -0
- package/dist/preview-server/routes/delete-sequence-keyframe.d.ts +3 -0
- package/dist/preview-server/routes/delete-sequence-keyframe.js +82 -0
- package/dist/preview-server/routes/duplicate-jsx-node.js +1 -0
- package/dist/preview-server/routes/insert-jsx-element.d.ts +3 -0
- package/dist/preview-server/routes/insert-jsx-element.js +79 -0
- package/dist/preview-server/routes/open-in-editor.d.ts +4 -0
- package/dist/preview-server/routes/open-in-editor.js +40 -0
- package/dist/preview-server/routes/register-client-render.d.ts +3 -0
- package/dist/preview-server/routes/register-client-render.js +11 -0
- package/dist/preview-server/routes/reorder-effect.d.ts +3 -0
- package/dist/preview-server/routes/reorder-effect.js +67 -0
- package/dist/preview-server/routes/save-effect-props.js +1 -0
- package/dist/preview-server/routes/save-sequence-props.js +158 -72
- package/dist/preview-server/routes/subscribe-to-sequence-props.js +2 -1
- package/dist/preview-server/routes/unregister-client-render.d.ts +4 -0
- package/dist/preview-server/routes/unregister-client-render.js +11 -0
- package/dist/preview-server/routes/update-default-props.js +1 -0
- package/dist/preview-server/sequence-props-watchers.d.ts +2 -1
- package/dist/preview-server/sequence-props-watchers.js +22 -2
- package/dist/preview-server/start-server.d.ts +1 -0
- package/dist/preview-server/start-server.js +1 -0
- package/dist/preview-server/undo-stack.d.ts +35 -4
- package/dist/preview-server/undo-stack.js +130 -42
- package/dist/preview-server/validate-same-origin.d.ts +2 -0
- package/dist/preview-server/validate-same-origin.js +13 -0
- package/dist/routes.d.ts +2 -1
- package/dist/routes.js +9 -136
- package/dist/start-studio.d.ts +2 -1
- package/dist/start-studio.js +2 -1
- package/package.json +6 -6
|
@@ -9,44 +9,75 @@ const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside
|
|
|
9
9
|
const format_log_file_location_1 = require("../format-log-file-location");
|
|
10
10
|
const undo_stack_1 = require("../undo-stack");
|
|
11
11
|
const log_update_1 = require("./log-updates/log-update");
|
|
12
|
-
const
|
|
12
|
+
const getDeletedNodeDescription = (nodeLabels) => {
|
|
13
|
+
if (nodeLabels.length === 1) {
|
|
14
|
+
return nodeLabels[0];
|
|
15
|
+
}
|
|
16
|
+
return `${nodeLabels.length} JSX nodes`;
|
|
17
|
+
};
|
|
18
|
+
const deleteJsxNodeHandler = async ({ input: { nodes }, remotionRoot, logLevel }) => {
|
|
19
|
+
var _a;
|
|
13
20
|
try {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
(0,
|
|
21
|
+
if (nodes.length === 0) {
|
|
22
|
+
throw new Error('No JSX nodes were specified for deletion');
|
|
23
|
+
}
|
|
24
|
+
renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[delete-jsx-node] Received request to delete ${nodes.length} JSX node${nodes.length === 1 ? '' : 's'}`);
|
|
25
|
+
const itemsByFileName = new Map();
|
|
26
|
+
for (const item of nodes) {
|
|
27
|
+
const fileItems = (_a = itemsByFileName.get(item.fileName)) !== null && _a !== void 0 ? _a : [];
|
|
28
|
+
fileItems.push(item);
|
|
29
|
+
itemsByFileName.set(item.fileName, fileItems);
|
|
30
|
+
}
|
|
31
|
+
const updates = await Promise.all([...itemsByFileName.entries()].map(async ([fileName, fileItems]) => {
|
|
32
|
+
const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
|
|
33
|
+
remotionRoot,
|
|
34
|
+
fileName,
|
|
35
|
+
action: 'modify',
|
|
36
|
+
});
|
|
37
|
+
const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
|
|
38
|
+
const { output, formatted, nodeLabels, logLines } = await (0, delete_jsx_node_1.deleteJsxNodes)({
|
|
39
|
+
input: fileContents,
|
|
40
|
+
nodePaths: fileItems.map((item) => item.nodePath),
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
absolutePath,
|
|
44
|
+
fileRelativeToRoot,
|
|
45
|
+
fileContents,
|
|
46
|
+
output,
|
|
47
|
+
formatted,
|
|
48
|
+
nodeLabels,
|
|
49
|
+
logLine: Math.min(...logLines),
|
|
50
|
+
};
|
|
51
|
+
}));
|
|
52
|
+
for (const update of updates) {
|
|
53
|
+
const deletedNodeDescription = getDeletedNodeDescription(update.nodeLabels);
|
|
54
|
+
(0, undo_stack_1.pushToUndoStack)({
|
|
55
|
+
filePath: update.absolutePath,
|
|
56
|
+
oldContents: update.fileContents,
|
|
57
|
+
newContents: null,
|
|
58
|
+
logLevel,
|
|
59
|
+
remotionRoot,
|
|
60
|
+
logLine: update.logLine,
|
|
61
|
+
description: {
|
|
62
|
+
undoMessage: `↩️ Deletion of ${deletedNodeDescription}`,
|
|
63
|
+
redoMessage: `↪️ Deletion of ${deletedNodeDescription}`,
|
|
64
|
+
},
|
|
65
|
+
entryType: 'delete-jsx-node',
|
|
66
|
+
suppressHmrOnFileRestore: false,
|
|
67
|
+
});
|
|
68
|
+
(0, undo_stack_1.suppressUndoStackInvalidation)(update.absolutePath);
|
|
69
|
+
(0, file_watcher_1.writeFileAndNotifyFileWatchers)(update.absolutePath, update.output, undefined);
|
|
70
|
+
const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
|
|
71
|
+
remotionRoot,
|
|
72
|
+
absolutePath: update.absolutePath,
|
|
73
|
+
line: update.logLine,
|
|
74
|
+
});
|
|
75
|
+
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Deleted ${deletedNodeDescription}`);
|
|
76
|
+
if (!update.formatted) {
|
|
77
|
+
(0, log_update_1.warnAboutPrettierOnce)(logLevel);
|
|
78
|
+
}
|
|
79
|
+
renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `[delete-jsx-node] Wrote ${update.fileRelativeToRoot}${update.formatted ? ' (formatted)' : ''}`);
|
|
48
80
|
}
|
|
49
|
-
renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `[delete-jsx-node] Wrote ${fileRelativeToRoot}${formatted ? ' (formatted)' : ''}`);
|
|
50
81
|
(0, undo_stack_1.printUndoHint)(logLevel);
|
|
51
82
|
return {
|
|
52
83
|
success: true,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DeleteEffectKeyframe, DeleteKeyframesRequest, DeleteKeyframesResponse, DeleteSequenceKeyframe, SaveSequencePropsResult } from '@remotion/studio-shared';
|
|
2
|
+
import type { ApiHandler } from '../api-types';
|
|
3
|
+
export declare const deleteKeyframes: ({ sequenceKeyframes, effectKeyframes, clientId, remotionRoot, logLevel, }: {
|
|
4
|
+
sequenceKeyframes: DeleteSequenceKeyframe[];
|
|
5
|
+
effectKeyframes: DeleteEffectKeyframe[];
|
|
6
|
+
clientId: string;
|
|
7
|
+
remotionRoot: string;
|
|
8
|
+
logLevel: "error" | "info" | "trace" | "verbose" | "warn";
|
|
9
|
+
}) => Promise<{
|
|
10
|
+
sequenceResults: SaveSequencePropsResult[];
|
|
11
|
+
effectResults: import("remotion").CanUpdateEffectPropsResponse[];
|
|
12
|
+
}>;
|
|
13
|
+
export declare const deleteKeyframesHandler: ApiHandler<DeleteKeyframesRequest, DeleteKeyframesResponse>;
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteKeyframesHandler = exports.deleteKeyframes = void 0;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const renderer_1 = require("@remotion/renderer");
|
|
6
|
+
const studio_shared_1 = require("@remotion/studio-shared");
|
|
7
|
+
const parse_ast_1 = require("../../codemods/parse-ast");
|
|
8
|
+
const update_keyframes_1 = require("../../codemods/update-keyframes/update-keyframes");
|
|
9
|
+
const file_watcher_1 = require("../../file-watcher");
|
|
10
|
+
const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside-project");
|
|
11
|
+
const undo_stack_1 = require("../undo-stack");
|
|
12
|
+
const watch_ignore_next_change_1 = require("../watch-ignore-next-change");
|
|
13
|
+
const can_update_effect_props_1 = require("./can-update-effect-props");
|
|
14
|
+
const can_update_sequence_props_1 = require("./can-update-sequence-props");
|
|
15
|
+
const log_effect_update_1 = require("./log-updates/log-effect-update");
|
|
16
|
+
const log_update_1 = require("./log-updates/log-update");
|
|
17
|
+
const save_props_mutex_1 = require("./save-props-mutex");
|
|
18
|
+
const groupBy = (items, getKey) => {
|
|
19
|
+
var _a;
|
|
20
|
+
const groups = new Map();
|
|
21
|
+
for (const item of items) {
|
|
22
|
+
const key = getKey(item);
|
|
23
|
+
const group = (_a = groups.get(key)) !== null && _a !== void 0 ? _a : [];
|
|
24
|
+
group.push(item);
|
|
25
|
+
groups.set(key, group);
|
|
26
|
+
}
|
|
27
|
+
return [...groups.values()];
|
|
28
|
+
};
|
|
29
|
+
const getBatchDescription = ({ totalKeyframes, firstKeyframe, }) => {
|
|
30
|
+
if (totalKeyframes === 1) {
|
|
31
|
+
return {
|
|
32
|
+
undoMessage: `↩️ ${firstKeyframe.key} keyframe restored at frame ${firstKeyframe.frame}`,
|
|
33
|
+
redoMessage: `↪️ ${firstKeyframe.key} keyframe deleted at frame ${firstKeyframe.frame}`,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
undoMessage: `↩️ ${totalKeyframes} keyframes restored`,
|
|
38
|
+
redoMessage: `↪️ ${totalKeyframes} keyframes deleted`,
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
const deleteKeyframes = async ({ sequenceKeyframes, effectKeyframes, clientId, remotionRoot, logLevel, }) => {
|
|
42
|
+
var _a, _b;
|
|
43
|
+
const totalKeyframes = sequenceKeyframes.length + effectKeyframes.length;
|
|
44
|
+
if (totalKeyframes === 0) {
|
|
45
|
+
throw new Error('No keyframes were specified for deletion');
|
|
46
|
+
}
|
|
47
|
+
const fileGroups = new Map();
|
|
48
|
+
const resolvedSequenceKeyframes = [];
|
|
49
|
+
const resolvedEffectKeyframes = [];
|
|
50
|
+
for (const [index, keyframe] of sequenceKeyframes.entries()) {
|
|
51
|
+
const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
|
|
52
|
+
remotionRoot,
|
|
53
|
+
fileName: keyframe.fileName,
|
|
54
|
+
action: 'modify',
|
|
55
|
+
});
|
|
56
|
+
const group = (_a = fileGroups.get(absolutePath)) !== null && _a !== void 0 ? _a : {
|
|
57
|
+
fileRelativeToRoot,
|
|
58
|
+
sequenceKeyframes: [],
|
|
59
|
+
effectKeyframes: [],
|
|
60
|
+
};
|
|
61
|
+
const resolved = { ...keyframe, index, absolutePath, fileRelativeToRoot };
|
|
62
|
+
group.sequenceKeyframes.push(resolved);
|
|
63
|
+
resolvedSequenceKeyframes.push(resolved);
|
|
64
|
+
fileGroups.set(absolutePath, group);
|
|
65
|
+
}
|
|
66
|
+
for (const [index, keyframe] of effectKeyframes.entries()) {
|
|
67
|
+
const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
|
|
68
|
+
remotionRoot,
|
|
69
|
+
fileName: keyframe.fileName,
|
|
70
|
+
action: 'modify',
|
|
71
|
+
});
|
|
72
|
+
const group = (_b = fileGroups.get(absolutePath)) !== null && _b !== void 0 ? _b : {
|
|
73
|
+
fileRelativeToRoot,
|
|
74
|
+
sequenceKeyframes: [],
|
|
75
|
+
effectKeyframes: [],
|
|
76
|
+
};
|
|
77
|
+
const resolved = { ...keyframe, index, absolutePath, fileRelativeToRoot };
|
|
78
|
+
group.effectKeyframes.push(resolved);
|
|
79
|
+
resolvedEffectKeyframes.push(resolved);
|
|
80
|
+
fileGroups.set(absolutePath, group);
|
|
81
|
+
}
|
|
82
|
+
const snapshots = [];
|
|
83
|
+
const outputByPath = new Map();
|
|
84
|
+
const sequenceLogs = [];
|
|
85
|
+
const effectLogs = [];
|
|
86
|
+
for (const [absolutePath, group] of fileGroups) {
|
|
87
|
+
const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
|
|
88
|
+
let output = fileContents;
|
|
89
|
+
let firstLogLine = Number.POSITIVE_INFINITY;
|
|
90
|
+
for (const keyframeGroup of groupBy(group.sequenceKeyframes, (keyframe) => JSON.stringify(keyframe.nodePath.nodePath))) {
|
|
91
|
+
const [firstSequenceKeyframe] = keyframeGroup;
|
|
92
|
+
if (!firstSequenceKeyframe) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const result = await (0, update_keyframes_1.updateSequenceKeyframes)({
|
|
96
|
+
input: output,
|
|
97
|
+
nodePath: firstSequenceKeyframe.nodePath.nodePath,
|
|
98
|
+
updates: keyframeGroup.map((keyframe) => ({
|
|
99
|
+
key: keyframe.key,
|
|
100
|
+
operation: {
|
|
101
|
+
type: 'remove',
|
|
102
|
+
frame: keyframe.frame,
|
|
103
|
+
},
|
|
104
|
+
})),
|
|
105
|
+
});
|
|
106
|
+
output = result.output;
|
|
107
|
+
firstLogLine = Math.min(firstLogLine, result.logLine);
|
|
108
|
+
for (const [keyframeIndex, keyframe] of keyframeGroup.entries()) {
|
|
109
|
+
sequenceLogs.push({
|
|
110
|
+
fileRelativeToRoot: keyframe.fileRelativeToRoot,
|
|
111
|
+
line: result.logLine,
|
|
112
|
+
key: keyframe.key,
|
|
113
|
+
oldValueString: result.oldValueStrings[keyframeIndex],
|
|
114
|
+
newValueString: result.newValueStrings[keyframeIndex],
|
|
115
|
+
formatted: result.formatted,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
for (const keyframeGroup of groupBy(group.effectKeyframes, (keyframe) => `${JSON.stringify(keyframe.sequenceNodePath.nodePath)}:${keyframe.effectIndex}`)) {
|
|
120
|
+
const [firstEffectKeyframe] = keyframeGroup;
|
|
121
|
+
if (!firstEffectKeyframe) {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const result = await (0, update_keyframes_1.updateEffectKeyframes)({
|
|
125
|
+
input: output,
|
|
126
|
+
sequenceNodePath: firstEffectKeyframe.sequenceNodePath.nodePath,
|
|
127
|
+
effectIndex: firstEffectKeyframe.effectIndex,
|
|
128
|
+
updates: keyframeGroup.map((keyframe) => ({
|
|
129
|
+
key: keyframe.key,
|
|
130
|
+
operation: {
|
|
131
|
+
type: 'remove',
|
|
132
|
+
frame: keyframe.frame,
|
|
133
|
+
},
|
|
134
|
+
})),
|
|
135
|
+
});
|
|
136
|
+
output = result.output;
|
|
137
|
+
firstLogLine = Math.min(firstLogLine, result.logLine);
|
|
138
|
+
for (const [keyframeIndex, keyframe] of keyframeGroup.entries()) {
|
|
139
|
+
effectLogs.push({
|
|
140
|
+
fileRelativeToRoot: keyframe.fileRelativeToRoot,
|
|
141
|
+
line: result.logLine,
|
|
142
|
+
effectName: result.effectCallee,
|
|
143
|
+
propKey: keyframe.key,
|
|
144
|
+
oldValueString: result.oldValueStrings[keyframeIndex],
|
|
145
|
+
newValueString: result.newValueStrings[keyframeIndex],
|
|
146
|
+
formatted: result.formatted,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
snapshots.push({
|
|
151
|
+
filePath: absolutePath,
|
|
152
|
+
oldContents: fileContents,
|
|
153
|
+
newContents: output,
|
|
154
|
+
logLine: Number.isFinite(firstLogLine) ? firstLogLine : 1,
|
|
155
|
+
});
|
|
156
|
+
outputByPath.set(absolutePath, output);
|
|
157
|
+
}
|
|
158
|
+
const [firstKeyframe] = sequenceKeyframes.length > 0 ? sequenceKeyframes : effectKeyframes;
|
|
159
|
+
if (!firstKeyframe) {
|
|
160
|
+
throw new Error('No keyframes were specified for deletion');
|
|
161
|
+
}
|
|
162
|
+
(0, undo_stack_1.pushTransactionToUndoStack)({
|
|
163
|
+
snapshots,
|
|
164
|
+
logLevel,
|
|
165
|
+
remotionRoot,
|
|
166
|
+
description: getBatchDescription({ totalKeyframes, firstKeyframe }),
|
|
167
|
+
entryType: sequenceKeyframes.length > 0 && effectKeyframes.length > 0
|
|
168
|
+
? 'keyframe-delete'
|
|
169
|
+
: sequenceKeyframes.length > 0
|
|
170
|
+
? 'sequence-props'
|
|
171
|
+
: 'effect-props',
|
|
172
|
+
suppressHmrOnFileRestore: true,
|
|
173
|
+
});
|
|
174
|
+
for (const snapshot of snapshots) {
|
|
175
|
+
(0, undo_stack_1.suppressUndoStackInvalidation)(snapshot.filePath);
|
|
176
|
+
(0, watch_ignore_next_change_1.suppressBundlerUpdateForFile)(snapshot.filePath);
|
|
177
|
+
(0, file_watcher_1.writeFileAndNotifyFileWatchers)(snapshot.filePath, snapshot.newContents, clientId);
|
|
178
|
+
}
|
|
179
|
+
for (const log of sequenceLogs) {
|
|
180
|
+
(0, log_update_1.logUpdate)({
|
|
181
|
+
fileRelativeToRoot: log.fileRelativeToRoot,
|
|
182
|
+
line: log.line,
|
|
183
|
+
key: log.key,
|
|
184
|
+
oldValueString: log.oldValueString,
|
|
185
|
+
newValueString: log.newValueString,
|
|
186
|
+
defaultValueString: null,
|
|
187
|
+
formatted: log.formatted,
|
|
188
|
+
logLevel,
|
|
189
|
+
removedProps: [],
|
|
190
|
+
addedProps: [],
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
for (const log of effectLogs) {
|
|
194
|
+
(0, log_effect_update_1.logEffectUpdate)({
|
|
195
|
+
fileRelativeToRoot: log.fileRelativeToRoot,
|
|
196
|
+
line: log.line,
|
|
197
|
+
effectName: log.effectName,
|
|
198
|
+
propKey: log.propKey,
|
|
199
|
+
oldValueString: log.oldValueString,
|
|
200
|
+
newValueString: log.newValueString,
|
|
201
|
+
defaultValueString: null,
|
|
202
|
+
formatted: log.formatted,
|
|
203
|
+
logLevel,
|
|
204
|
+
removedProps: [],
|
|
205
|
+
addedProps: [],
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
(0, undo_stack_1.printUndoHint)(logLevel);
|
|
209
|
+
const sequenceResults = resolvedSequenceKeyframes.map((keyframe) => {
|
|
210
|
+
const output = outputByPath.get(keyframe.absolutePath);
|
|
211
|
+
if (!output) {
|
|
212
|
+
throw new Error('Could not compute sequence keyframe deletion status');
|
|
213
|
+
}
|
|
214
|
+
const status = (0, can_update_sequence_props_1.computeSequencePropsStatusFromContent)({
|
|
215
|
+
fileContents: output,
|
|
216
|
+
keys: (0, studio_shared_1.getAllSchemaKeys)(keyframe.schema),
|
|
217
|
+
nodePath: keyframe.nodePath.nodePath,
|
|
218
|
+
effects: [],
|
|
219
|
+
});
|
|
220
|
+
return {
|
|
221
|
+
fileName: keyframe.fileName,
|
|
222
|
+
nodePath: keyframe.nodePath,
|
|
223
|
+
props: status.props,
|
|
224
|
+
};
|
|
225
|
+
});
|
|
226
|
+
const astByPath = new Map();
|
|
227
|
+
const effectResults = resolvedEffectKeyframes.map((keyframe) => {
|
|
228
|
+
var _a;
|
|
229
|
+
const output = outputByPath.get(keyframe.absolutePath);
|
|
230
|
+
if (!output) {
|
|
231
|
+
throw new Error('Could not compute effect keyframe deletion status');
|
|
232
|
+
}
|
|
233
|
+
const ast = (_a = astByPath.get(keyframe.absolutePath)) !== null && _a !== void 0 ? _a : (0, parse_ast_1.parseAst)(output);
|
|
234
|
+
astByPath.set(keyframe.absolutePath, ast);
|
|
235
|
+
const jsx = (0, can_update_sequence_props_1.findJsxElementAtNodePath)(ast, keyframe.sequenceNodePath.nodePath);
|
|
236
|
+
if (!jsx) {
|
|
237
|
+
return {
|
|
238
|
+
canUpdate: false,
|
|
239
|
+
effectIndex: keyframe.effectIndex,
|
|
240
|
+
reason: 'not-found',
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
return (0, can_update_effect_props_1.computeEffectPropStatus)({
|
|
244
|
+
jsx,
|
|
245
|
+
effectIndex: keyframe.effectIndex,
|
|
246
|
+
keys: (0, studio_shared_1.getAllSchemaKeys)(keyframe.schema),
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
return { sequenceResults, effectResults };
|
|
250
|
+
};
|
|
251
|
+
exports.deleteKeyframes = deleteKeyframes;
|
|
252
|
+
const deleteKeyframesHandler = ({ input: { sequenceKeyframes, effectKeyframes, clientId }, remotionRoot, logLevel, }) => (0, save_props_mutex_1.withSavePropsLock)(async () => {
|
|
253
|
+
renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[delete-keyframes] Received request to delete ${sequenceKeyframes.length + effectKeyframes.length} keyframe(s)`);
|
|
254
|
+
await (0, exports.deleteKeyframes)({
|
|
255
|
+
sequenceKeyframes,
|
|
256
|
+
effectKeyframes,
|
|
257
|
+
clientId,
|
|
258
|
+
remotionRoot,
|
|
259
|
+
logLevel,
|
|
260
|
+
});
|
|
261
|
+
return { success: true };
|
|
262
|
+
});
|
|
263
|
+
exports.deleteKeyframesHandler = deleteKeyframesHandler;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { DeleteSequenceKeyframeRequest, DeleteSequenceKeyframeResponse } from '@remotion/studio-shared';
|
|
2
|
+
import type { ApiHandler } from '../api-types';
|
|
3
|
+
export declare const deleteSequenceKeyframeHandler: ApiHandler<DeleteSequenceKeyframeRequest, DeleteSequenceKeyframeResponse>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteSequenceKeyframeHandler = void 0;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const renderer_1 = require("@remotion/renderer");
|
|
6
|
+
const studio_shared_1 = require("@remotion/studio-shared");
|
|
7
|
+
const update_keyframes_1 = require("../../codemods/update-keyframes/update-keyframes");
|
|
8
|
+
const file_watcher_1 = require("../../file-watcher");
|
|
9
|
+
const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside-project");
|
|
10
|
+
const undo_stack_1 = require("../undo-stack");
|
|
11
|
+
const watch_ignore_next_change_1 = require("../watch-ignore-next-change");
|
|
12
|
+
const can_update_sequence_props_1 = require("./can-update-sequence-props");
|
|
13
|
+
const log_update_1 = require("./log-updates/log-update");
|
|
14
|
+
const save_props_mutex_1 = require("./save-props-mutex");
|
|
15
|
+
const deleteSequenceKeyframeHandler = ({ input: { fileName, nodePath, key, frame, schema, clientId }, remotionRoot, logLevel, }) => (0, save_props_mutex_1.withSavePropsLock)(async () => {
|
|
16
|
+
renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[delete-sequence-keyframe] Received request for fileName="${fileName}" key="${key}" frame=${frame}`);
|
|
17
|
+
const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
|
|
18
|
+
remotionRoot,
|
|
19
|
+
fileName,
|
|
20
|
+
action: 'modify',
|
|
21
|
+
});
|
|
22
|
+
const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
|
|
23
|
+
const { output, oldValueStrings, newValueStrings, formatted, logLine } = await (0, update_keyframes_1.updateSequenceKeyframes)({
|
|
24
|
+
input: fileContents,
|
|
25
|
+
nodePath: nodePath.nodePath,
|
|
26
|
+
updates: [
|
|
27
|
+
{
|
|
28
|
+
key,
|
|
29
|
+
operation: {
|
|
30
|
+
type: 'remove',
|
|
31
|
+
frame,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
});
|
|
36
|
+
const oldValueString = oldValueStrings[0];
|
|
37
|
+
const newValueString = newValueStrings[0];
|
|
38
|
+
const undoPropChange = `${key} keyframe restored at frame ${frame}`;
|
|
39
|
+
const redoPropChange = `${key} keyframe deleted at frame ${frame}`;
|
|
40
|
+
(0, undo_stack_1.pushToUndoStack)({
|
|
41
|
+
filePath: absolutePath,
|
|
42
|
+
oldContents: fileContents,
|
|
43
|
+
newContents: null,
|
|
44
|
+
logLevel,
|
|
45
|
+
remotionRoot,
|
|
46
|
+
logLine,
|
|
47
|
+
description: {
|
|
48
|
+
undoMessage: `↩️ ${undoPropChange}`,
|
|
49
|
+
redoMessage: `↪️ ${redoPropChange}`,
|
|
50
|
+
},
|
|
51
|
+
entryType: 'sequence-props',
|
|
52
|
+
suppressHmrOnFileRestore: true,
|
|
53
|
+
});
|
|
54
|
+
(0, undo_stack_1.suppressUndoStackInvalidation)(absolutePath);
|
|
55
|
+
(0, watch_ignore_next_change_1.suppressBundlerUpdateForFile)(absolutePath);
|
|
56
|
+
(0, file_watcher_1.writeFileAndNotifyFileWatchers)(absolutePath, output, clientId);
|
|
57
|
+
(0, log_update_1.logUpdate)({
|
|
58
|
+
fileRelativeToRoot,
|
|
59
|
+
line: logLine,
|
|
60
|
+
key,
|
|
61
|
+
oldValueString,
|
|
62
|
+
newValueString,
|
|
63
|
+
defaultValueString: null,
|
|
64
|
+
formatted,
|
|
65
|
+
logLevel,
|
|
66
|
+
removedProps: [],
|
|
67
|
+
addedProps: [],
|
|
68
|
+
});
|
|
69
|
+
(0, undo_stack_1.printUndoHint)(logLevel);
|
|
70
|
+
const status = (0, can_update_sequence_props_1.computeSequencePropsStatusFromContent)({
|
|
71
|
+
fileContents: output,
|
|
72
|
+
keys: (0, studio_shared_1.getAllSchemaKeys)(schema),
|
|
73
|
+
nodePath: nodePath.nodePath,
|
|
74
|
+
effects: [],
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
canUpdate: true,
|
|
78
|
+
props: status.props,
|
|
79
|
+
results: [{ fileName, nodePath, props: status.props }],
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
exports.deleteSequenceKeyframeHandler = deleteSequenceKeyframeHandler;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.insertJsxElementHandler = void 0;
|
|
4
|
+
const renderer_1 = require("@remotion/renderer");
|
|
5
|
+
const file_watcher_1 = require("../../file-watcher");
|
|
6
|
+
const resolve_composition_component_1 = require("../../helpers/resolve-composition-component");
|
|
7
|
+
const format_log_file_location_1 = require("../format-log-file-location");
|
|
8
|
+
const undo_stack_1 = require("../undo-stack");
|
|
9
|
+
const log_update_1 = require("./log-updates/log-update");
|
|
10
|
+
const save_props_mutex_1 = require("./save-props-mutex");
|
|
11
|
+
const validateDimension = (name, value) => {
|
|
12
|
+
if (!Number.isFinite(value) || value < 1) {
|
|
13
|
+
throw new Error(`${name} must be a positive number`);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const validateElement = (element) => {
|
|
17
|
+
if (element.type === 'solid') {
|
|
18
|
+
validateDimension('width', element.width);
|
|
19
|
+
validateDimension('height', element.height);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const getElementLabel = (element) => {
|
|
23
|
+
if (element.type === 'solid') {
|
|
24
|
+
return '<Solid>';
|
|
25
|
+
}
|
|
26
|
+
throw new Error('Unsupported element type');
|
|
27
|
+
};
|
|
28
|
+
const insertJsxElementHandler = ({ input: { compositionFile, compositionId, element }, remotionRoot, logLevel, }) => (0, save_props_mutex_1.withSavePropsLock)(async () => {
|
|
29
|
+
try {
|
|
30
|
+
validateElement(element);
|
|
31
|
+
const elementLabel = getElementLabel(element);
|
|
32
|
+
renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[insert-jsx-element] Received request for compositionFile="${compositionFile}" compositionId="${compositionId}" element="${element.type}"`);
|
|
33
|
+
const { fileName, source, oldContents, output, formatted, logLine } = await (0, resolve_composition_component_1.insertJsxElementIntoComposition)({
|
|
34
|
+
remotionRoot,
|
|
35
|
+
compositionFile,
|
|
36
|
+
compositionId,
|
|
37
|
+
element,
|
|
38
|
+
prettierConfigOverride: null,
|
|
39
|
+
});
|
|
40
|
+
(0, undo_stack_1.pushToUndoStack)({
|
|
41
|
+
filePath: fileName,
|
|
42
|
+
oldContents,
|
|
43
|
+
newContents: output,
|
|
44
|
+
logLevel,
|
|
45
|
+
remotionRoot,
|
|
46
|
+
logLine,
|
|
47
|
+
description: {
|
|
48
|
+
undoMessage: `↩️ Added ${elementLabel}`,
|
|
49
|
+
redoMessage: `↪️ Added ${elementLabel}`,
|
|
50
|
+
},
|
|
51
|
+
entryType: 'insert-jsx-element',
|
|
52
|
+
suppressHmrOnFileRestore: false,
|
|
53
|
+
});
|
|
54
|
+
(0, undo_stack_1.suppressUndoStackInvalidation)(fileName);
|
|
55
|
+
(0, file_watcher_1.writeFileAndNotifyFileWatchers)(fileName, output, undefined);
|
|
56
|
+
const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
|
|
57
|
+
remotionRoot,
|
|
58
|
+
absolutePath: fileName,
|
|
59
|
+
line: logLine,
|
|
60
|
+
});
|
|
61
|
+
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Added ${elementLabel}`);
|
|
62
|
+
if (!formatted) {
|
|
63
|
+
(0, log_update_1.warnAboutPrettierOnce)(logLevel);
|
|
64
|
+
}
|
|
65
|
+
renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `[insert-jsx-element] Wrote ${source}${formatted ? ' (formatted)' : ''}`);
|
|
66
|
+
(0, undo_stack_1.printUndoHint)(logLevel);
|
|
67
|
+
return {
|
|
68
|
+
success: true,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
return {
|
|
73
|
+
success: false,
|
|
74
|
+
reason: err.message,
|
|
75
|
+
stack: err.stack,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
exports.insertJsxElementHandler = insertJsxElementHandler;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { OpenInEditorRequest, OpenInEditorResponse } from '@remotion/studio-shared';
|
|
2
|
+
import type { ApiHandler } from '../api-types';
|
|
3
|
+
export declare const getEditorName: () => Promise<string | null>;
|
|
4
|
+
export declare const openInEditorHandler: ApiHandler<OpenInEditorRequest, OpenInEditorResponse>;
|
|
@@ -0,0 +1,40 @@
|
|
|
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.openInEditorHandler = exports.getEditorName = void 0;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const open_in_editor_1 = require("../../helpers/open-in-editor");
|
|
9
|
+
const editorGuess = (0, open_in_editor_1.guessEditor)();
|
|
10
|
+
const getEditorName = async () => {
|
|
11
|
+
const [edit] = await editorGuess;
|
|
12
|
+
return (0, open_in_editor_1.getDisplayNameForEditor)(edit ? edit.command : null);
|
|
13
|
+
};
|
|
14
|
+
exports.getEditorName = getEditorName;
|
|
15
|
+
const openInEditorHandler = async ({ input, remotionRoot, logLevel }) => {
|
|
16
|
+
try {
|
|
17
|
+
if (!('stack' in input)) {
|
|
18
|
+
throw new TypeError('Need to pass stack');
|
|
19
|
+
}
|
|
20
|
+
const { stack } = input;
|
|
21
|
+
const guess = await editorGuess;
|
|
22
|
+
const didOpen = await (0, open_in_editor_1.launchEditor)({
|
|
23
|
+
colNumber: stack.originalColumnNumber,
|
|
24
|
+
editor: guess[0],
|
|
25
|
+
fileName: node_path_1.default.resolve(remotionRoot, stack.originalFileName),
|
|
26
|
+
lineNumber: stack.originalLineNumber,
|
|
27
|
+
vsCodeNewWindow: false,
|
|
28
|
+
logLevel,
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
success: didOpen,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
catch (_a) {
|
|
35
|
+
return {
|
|
36
|
+
success: false,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.openInEditorHandler = openInEditorHandler;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerClientRenderHandler = void 0;
|
|
4
|
+
const client_render_queue_1 = require("../../client-render-queue");
|
|
5
|
+
const validate_same_origin_1 = require("../validate-same-origin");
|
|
6
|
+
const registerClientRenderHandler = ({ input, remotionRoot, request }) => {
|
|
7
|
+
(0, validate_same_origin_1.validateSameOrigin)(request);
|
|
8
|
+
(0, client_render_queue_1.addCompletedClientRender)({ render: input, remotionRoot });
|
|
9
|
+
return Promise.resolve();
|
|
10
|
+
};
|
|
11
|
+
exports.registerClientRenderHandler = registerClientRenderHandler;
|