@remotion/studio-server 4.0.537 → 4.0.539
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/ansi-diff.js +3 -19
- package/dist/better-opn/index.d.ts +4 -2
- package/dist/canvas-capture/generate-canvas-capture-composition.d.ts +14 -0
- package/dist/canvas-capture/generate-canvas-capture-composition.js +239 -0
- package/dist/codemods/add-effect.d.ts +1 -0
- package/dist/codemods/add-effect.js +8 -0
- package/dist/codemods/apply-codemod-to-file.d.ts +7 -0
- package/dist/codemods/apply-codemod-to-file.js +171 -0
- package/dist/codemods/apply-visual-control.d.ts +8 -0
- package/dist/codemods/apply-visual-control.js +89 -0
- package/dist/codemods/delete-effect.d.ts +1 -0
- package/dist/codemods/delete-effect.js +6 -0
- package/dist/codemods/delete-jsx-node.d.ts +22 -0
- package/dist/codemods/delete-jsx-node.js +17 -0
- package/dist/codemods/delete-jsx-nodes.d.ts +13 -0
- package/dist/codemods/delete-jsx-nodes.js +10 -0
- package/dist/codemods/duplicate-composition.d.ts +2 -0
- package/dist/codemods/duplicate-composition.js +64 -0
- package/dist/codemods/duplicate-effect.d.ts +1 -0
- package/dist/codemods/duplicate-effect.js +6 -0
- package/dist/codemods/duplicate-jsx-node.d.ts +25 -0
- package/dist/codemods/duplicate-jsx-node.js +26 -0
- package/dist/codemods/effect-param-expression.d.ts +2 -2
- package/dist/codemods/format-file-content.d.ts +7 -0
- package/dist/codemods/format-file-content.js +80 -0
- package/dist/codemods/format-inline-content.d.ts +18 -0
- package/dist/codemods/format-inline-content.js +78 -0
- package/dist/codemods/get-node-path-remappings.d.ts +1 -12
- package/dist/codemods/get-node-path-remappings.js +1 -51
- package/dist/codemods/insert-video-layers.d.ts +11 -0
- package/dist/codemods/insert-video-layers.js +5 -0
- package/dist/codemods/paste-effects.d.ts +2 -15
- package/dist/codemods/recast-mods.d.ts +13 -0
- package/dist/codemods/recast-mods.js +902 -0
- package/dist/codemods/reorder-effect.d.ts +1 -0
- package/dist/codemods/reorder-effect.js +5 -0
- package/dist/codemods/reorder-sequence.d.ts +1 -0
- package/dist/codemods/reorder-sequence.js +5 -0
- package/dist/codemods/simple-diff.d.ts +5 -0
- package/dist/codemods/simple-diff.js +39 -0
- package/dist/codemods/split-jsx-sequence.d.ts +27 -0
- package/dist/codemods/split-jsx-sequence.js +19 -0
- package/dist/codemods/split-video-from-audio.d.ts +1 -0
- package/dist/codemods/split-video-from-audio.js +5 -0
- package/dist/codemods/update-default-props.d.ts +1 -0
- package/dist/codemods/update-default-props.js +6 -0
- package/dist/codemods/update-effect-props/update-effect-props.d.ts +2 -2
- package/dist/codemods/update-inline-caption-patches.d.ts +1 -0
- package/dist/codemods/update-inline-caption-patches.js +5 -0
- package/dist/codemods/update-keyframes/ensure-imports-and-frame-hook.d.ts +1 -0
- package/dist/codemods/update-keyframes/ensure-imports-and-frame-hook.js +7 -0
- package/dist/codemods/update-keyframes/update-keyframes.d.ts +3 -3
- package/dist/codemods/update-nested-prop.d.ts +1 -1
- package/dist/detect-outdated-remotion-skills.d.ts +3 -3
- package/dist/figma/figma-to-svg.d.ts +1 -1
- package/dist/file-watcher.d.ts +1 -1
- package/dist/helpers/coding-agent-registry.d.ts +3 -3
- package/dist/helpers/css-shorthand-properties.d.ts +8 -7
- package/dist/helpers/custom-editor.d.ts +2 -2
- package/dist/helpers/editor-registry.d.ts +2 -2
- package/dist/helpers/get-ast-node-path.d.ts +2 -1
- package/dist/helpers/import-agnostic-node-path.js +22 -13
- package/dist/helpers/open-in-app.d.ts +3 -3
- package/dist/helpers/open-in-editor.d.ts +2 -2
- package/dist/helpers/package-manager-spawn-options.d.ts +1 -1
- package/dist/helpers/read-source-file.d.ts +4 -0
- package/dist/helpers/read-source-file.js +14 -0
- package/dist/helpers/recently-used-apps.d.ts +2 -2
- package/dist/helpers/resolve-composition-component.d.ts +2 -2
- package/dist/helpers/resolve-editor.d.ts +3 -3
- package/dist/helpers/terminal-artwork.d.ts +4 -4
- package/dist/helpers/video-config-values.d.ts +4 -0
- package/dist/helpers/video-config-values.js +11 -3
- package/dist/index.d.ts +39 -100
- package/dist/index.js +1 -1
- package/dist/maybe-open-browser.d.ts +2 -1
- package/dist/open-browser-shortcut.d.ts +9 -0
- package/dist/open-browser-shortcut.js +121 -0
- package/dist/preview-server/api-types.d.ts +1 -1
- package/dist/preview-server/dev-middleware/index.d.ts +2 -1
- package/dist/preview-server/dev-middleware/middleware.d.ts +1 -1
- package/dist/preview-server/dev-middleware/middleware.js +14 -17
- package/dist/preview-server/element-install-state.d.ts +1 -1
- package/dist/preview-server/get-package-manager.d.ts +3 -2
- package/dist/preview-server/handler.d.ts +4 -4
- package/dist/preview-server/hmr-timing.d.ts +2 -1
- package/dist/preview-server/hot-middleware/index.d.ts +2 -1
- package/dist/preview-server/hot-middleware/types.d.ts +2 -0
- package/dist/preview-server/hot-middleware/types.js +2 -0
- package/dist/preview-server/jsx-component-identity.d.ts +4 -3
- package/dist/preview-server/live-events.d.ts +3 -2
- package/dist/preview-server/public-folder.js +11 -2
- package/dist/preview-server/routes/add-keyframes.d.ts +2 -1
- package/dist/preview-server/routes/app-icon.d.ts +1 -1
- package/dist/preview-server/routes/apply-codemod.d.ts +4 -0
- package/dist/preview-server/routes/apply-codemod.js +272 -0
- package/dist/preview-server/routes/apply-visual-control-change.js +1 -4
- package/dist/preview-server/routes/batch-update-keyframe-settings.d.ts +2 -1
- package/dist/preview-server/routes/can-update-default-props.d.ts +2 -1
- package/dist/preview-server/routes/can-update-effect-props.d.ts +2 -6
- package/dist/preview-server/routes/can-update-sequence-props.d.ts +17 -13
- package/dist/preview-server/routes/can-update-sequence-props.js +21 -25
- package/dist/preview-server/routes/delete-jsx-node.d.ts +3 -0
- package/dist/preview-server/routes/delete-jsx-node.js +126 -0
- package/dist/preview-server/routes/delete-jsx-nodes.d.ts +3 -0
- package/dist/preview-server/routes/delete-jsx-nodes.js +137 -0
- package/dist/preview-server/routes/delete-keyframes.d.ts +4 -6
- package/dist/preview-server/routes/delete-keyframes.js +4 -66
- package/dist/preview-server/routes/duplicate-jsx-node.d.ts +3 -0
- package/dist/preview-server/routes/duplicate-jsx-node.js +118 -0
- package/dist/preview-server/routes/element-install-plan.d.ts +3 -3
- package/dist/preview-server/routes/find-in-file.d.ts +2 -9
- package/dist/preview-server/routes/insert-element.js +1 -4
- package/dist/preview-server/routes/insert-jsx-element.d.ts +3 -0
- package/dist/preview-server/routes/insert-jsx-element.js +231 -0
- package/dist/preview-server/routes/insert-video-layers.d.ts +3 -0
- package/dist/preview-server/routes/insert-video-layers.js +68 -0
- package/dist/preview-server/routes/install-dependency.d.ts +2 -14
- package/dist/preview-server/routes/log-updates/log-effect-update.d.ts +2 -1
- package/dist/preview-server/routes/log-updates/log-update.d.ts +3 -2
- package/dist/preview-server/routes/move-keyframes.d.ts +2 -1
- package/dist/preview-server/routes/open-in-editor.d.ts +2 -2
- package/dist/preview-server/routes/remotion-skills-info.d.ts +1 -1
- package/dist/preview-server/routes/save-multiple-effect-props.js +25 -8
- package/dist/preview-server/routes/save-sequence-props.d.ts +2 -2
- package/dist/preview-server/routes/source-file-write-queue.d.ts +3 -2
- package/dist/preview-server/routes/split-jsx-sequence.d.ts +3 -0
- package/dist/preview-server/routes/split-jsx-sequence.js +117 -0
- package/dist/preview-server/routes/subscribe-to-sequence-props.js +55 -34
- package/dist/preview-server/routes/update-public-license.d.ts +11 -0
- package/dist/preview-server/routes/update-public-license.js +97 -0
- package/dist/preview-server/routes/wrap-jsx-node.d.ts +3 -0
- package/dist/preview-server/routes/wrap-jsx-node.js +97 -0
- package/dist/preview-server/sequence-node-path-mutation.d.ts +2 -6
- package/dist/preview-server/sequence-props-watchers.d.ts +7 -5
- package/dist/preview-server/sequence-props-watchers.js +7 -2
- package/dist/preview-server/serve-static.d.ts +1 -1
- package/dist/preview-server/serve-static.js +18 -1
- package/dist/preview-server/start-server.d.ts +3 -3
- package/dist/preview-server/studio-protocol/handle-discovery.d.ts +1 -1
- package/dist/preview-server/studio-protocol/handle-element-library.d.ts +1 -1
- package/dist/preview-server/studio-protocol/handle-install.d.ts +1 -1
- package/dist/preview-server/studio-protocol/handle-license-key.d.ts +1 -1
- package/dist/preview-server/studio-protocol/origin-policy.d.ts +2 -2
- package/dist/preview-server/studio-protocol/protocol-response.d.ts +1 -1
- package/dist/preview-server/undo-stack.d.ts +3 -3
- package/dist/preview-server/undo-stack.js +9 -0
- package/dist/preview-server/update-available.d.ts +3 -2
- package/dist/preview-server/validate-same-origin.js +2 -1
- package/dist/remotion-skill-names.d.ts +1 -1
- package/dist/routes.d.ts +4 -4
- package/dist/server-ready.d.ts +2 -1
- package/dist/start-studio.d.ts +3 -3
- package/dist/studio-shortcuts.d.ts +3 -3
- package/package.json +10 -10
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* and rewritten in TypeScript. This file is MIT licensed
|
|
5
5
|
*/
|
|
6
6
|
import type { webpack } from '@remotion/bundler';
|
|
7
|
+
import type { LogLevel } from '@remotion/renderer';
|
|
7
8
|
import type { LiveEventsServer } from '../live-events';
|
|
8
9
|
declare global {
|
|
9
10
|
const __webpack_hash__: unknown;
|
|
@@ -99,4 +100,4 @@ declare global {
|
|
|
99
100
|
};
|
|
100
101
|
type ModuleId = string | number;
|
|
101
102
|
}
|
|
102
|
-
export declare const setupWebpackHmr: (compiler: webpack.Compiler, logLevel:
|
|
103
|
+
export declare const setupWebpackHmr: (compiler: webpack.Compiler, logLevel: LogLevel, liveEventsServer: LiveEventsServer) => void;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { File, JSXOpeningElement } from '@babel/types';
|
|
2
|
+
import type { JsxComponentIdentity } from 'remotion';
|
|
2
3
|
export declare class JsxElementIdentityMismatchError extends Error {
|
|
3
4
|
constructor();
|
|
4
5
|
}
|
|
5
6
|
export declare const getJsxComponentIdentity: ({ ast, jsxElement, }: {
|
|
6
7
|
ast: File;
|
|
7
8
|
jsxElement: JSXOpeningElement;
|
|
8
|
-
}) =>
|
|
9
|
+
}) => JsxComponentIdentity | null;
|
|
9
10
|
export declare const jsxComponentIdentitiesMatch: ({ expected, actual, }: {
|
|
10
|
-
expected:
|
|
11
|
-
actual:
|
|
11
|
+
expected: JsxComponentIdentity | null;
|
|
12
|
+
actual: JsxComponentIdentity | null;
|
|
12
13
|
}) => boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import type { LogLevel } from '@remotion/renderer';
|
|
2
3
|
import type { EventSourceEvent } from '@remotion/studio-shared';
|
|
3
4
|
export type LiveEventsServer = {
|
|
4
5
|
sendEventToClient: (event: EventSourceEvent) => void;
|
|
@@ -7,13 +8,13 @@ export type LiveEventsServer = {
|
|
|
7
8
|
closeConnections: () => Promise<void>;
|
|
8
9
|
addNewClientListener: (cb: () => void) => () => void;
|
|
9
10
|
};
|
|
10
|
-
export declare const subscribeToConfigChanges: (onChange: () => void) => () => void;
|
|
11
|
+
export declare const subscribeToConfigChanges: (onChange: () => void) => (() => void);
|
|
11
12
|
export declare const clearPrintPortMessageTimeout: () => void;
|
|
12
13
|
export type InitialUndoRedoState = {
|
|
13
14
|
undoFile: string | null;
|
|
14
15
|
redoFile: string | null;
|
|
15
16
|
};
|
|
16
|
-
export declare const makeLiveEventsRouter: (logLevel:
|
|
17
|
+
export declare const makeLiveEventsRouter: (logLevel: LogLevel, getInitialUndoRedoState: () => InitialUndoRedoState) => LiveEventsServer;
|
|
17
18
|
export declare const waitForLiveEventsListener: () => Promise<LiveEventsServer>;
|
|
18
19
|
export declare const getLiveEventsListener: () => LiveEventsServer | null;
|
|
19
20
|
export declare const setLiveEventsListener: (listener: LiveEventsServer) => () => void;
|
|
@@ -47,9 +47,18 @@ const watchPublicFolder = ({ publicDir, onUpdate, staticHash, }) => {
|
|
|
47
47
|
}
|
|
48
48
|
// Known bug: If whole public folder is deleted, this will not be called on macOS.
|
|
49
49
|
// This is not severe, so a wontfix for now.
|
|
50
|
+
let updateTimeout = null;
|
|
50
51
|
(0, node_fs_1.watch)(publicDir, { recursive: (0, env_supports_fs_recursive_1.envSupportsFsRecursive)() }, () => {
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
if (updateTimeout !== null) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
// Imports can emit many events, each of which would scan and broadcast the
|
|
56
|
+
// entire asset list. Keep the deadline fixed so ongoing writes still update.
|
|
57
|
+
updateTimeout = setTimeout(() => {
|
|
58
|
+
updateTimeout = null;
|
|
59
|
+
(0, exports.fetchFolder)({ publicDir, staticHash });
|
|
60
|
+
onUpdate();
|
|
61
|
+
}, 100);
|
|
53
62
|
});
|
|
54
63
|
};
|
|
55
64
|
const getFiles = () => {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { LogLevel } from '@remotion/renderer';
|
|
1
2
|
import type { AddKeyframesRequest, AddKeyframesResponse, SequenceNodePathMutation } from '@remotion/studio-shared';
|
|
2
3
|
import type { ApiHandler } from '../api-types';
|
|
3
4
|
export declare const addKeyframes: ({ sequenceKeyframes, effectKeyframes, clientId, remotionRoot, logLevel, }: AddKeyframesRequest & {
|
|
4
5
|
readonly remotionRoot: string;
|
|
5
|
-
readonly logLevel:
|
|
6
|
+
readonly logLevel: LogLevel;
|
|
6
7
|
}) => Promise<SequenceNodePathMutation | null>;
|
|
7
8
|
export declare const addKeyframesHandler: ApiHandler<AddKeyframesRequest, AddKeyframesResponse>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
2
|
export declare const handleAppIcon: ({ request, response, pathname, }: {
|
|
3
3
|
request: IncomingMessage;
|
|
4
|
-
response: ServerResponse
|
|
4
|
+
response: ServerResponse;
|
|
5
5
|
pathname: string;
|
|
6
6
|
}) => Promise<void>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ApplyCodemodRequest, ApplyCodemodResponse } from '@remotion/studio-shared';
|
|
2
|
+
import type { ApiHandler } from '../api-types';
|
|
3
|
+
export declare const getCodemodLogMessage: (codemod: import("@remotion/studio-shared").RecastCodemod) => string;
|
|
4
|
+
export declare const applyCodemodHandler: ApiHandler<ApplyCodemodRequest, ApplyCodemodResponse>;
|
|
@@ -0,0 +1,272 @@
|
|
|
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.applyCodemodHandler = exports.getCodemodLogMessage = void 0;
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const codemods_1 = require("@remotion/codemods");
|
|
10
|
+
const renderer_1 = require("@remotion/renderer");
|
|
11
|
+
const apply_codemod_to_file_1 = require("../../codemods/apply-codemod-to-file");
|
|
12
|
+
const file_watcher_1 = require("../../file-watcher");
|
|
13
|
+
const format_log_file_location_1 = require("../format-log-file-location");
|
|
14
|
+
const project_info_1 = require("../project-info");
|
|
15
|
+
const undo_stack_1 = require("../undo-stack");
|
|
16
|
+
const can_update_default_props_1 = require("./can-update-default-props");
|
|
17
|
+
const source_file_write_queue_1 = require("./source-file-write-queue");
|
|
18
|
+
const { simpleDiff } = codemods_1.CodemodsInternals;
|
|
19
|
+
const getFolderPath = (parentName, folderName) => {
|
|
20
|
+
return parentName ? `${parentName}/${folderName}` : folderName;
|
|
21
|
+
};
|
|
22
|
+
const getCodemodLogMessage = (codemod) => {
|
|
23
|
+
if (codemod.type === 'new-composition') {
|
|
24
|
+
const destination = codemod.folderName
|
|
25
|
+
? ` in folder "${getFolderPath(codemod.parentName, codemod.folderName)}"`
|
|
26
|
+
: '';
|
|
27
|
+
return `Created composition "${codemod.newId}"${destination}`;
|
|
28
|
+
}
|
|
29
|
+
if (codemod.type === 'duplicate-composition') {
|
|
30
|
+
return `Duplicated composition "${codemod.idToDuplicate}" to "${codemod.newId}"`;
|
|
31
|
+
}
|
|
32
|
+
if (codemod.type === 'rename-composition') {
|
|
33
|
+
return `Renamed composition "${codemod.idToRename}" to "${codemod.newId}"`;
|
|
34
|
+
}
|
|
35
|
+
if (codemod.type === 'update-composition-metadata') {
|
|
36
|
+
return `Updated metadata of composition "${codemod.idToUpdate}"`;
|
|
37
|
+
}
|
|
38
|
+
if (codemod.type === 'delete-composition') {
|
|
39
|
+
return `Deleted composition "${codemod.idToDelete}"`;
|
|
40
|
+
}
|
|
41
|
+
if (codemod.type === 'move-composition-or-folder') {
|
|
42
|
+
const source = codemod.source.type === 'composition'
|
|
43
|
+
? `composition "${codemod.source.compositionId}"`
|
|
44
|
+
: `folder "${getFolderPath(codemod.source.parentName, codemod.source.folderName)}"`;
|
|
45
|
+
return `Moved ${source}`;
|
|
46
|
+
}
|
|
47
|
+
if (codemod.type === 'rename-folder') {
|
|
48
|
+
const oldName = getFolderPath(codemod.parentName, codemod.folderName);
|
|
49
|
+
const newName = getFolderPath(codemod.parentName, codemod.newName);
|
|
50
|
+
return `Renamed folder "${oldName}" to "${newName}"`;
|
|
51
|
+
}
|
|
52
|
+
if (codemod.type === 'new-folder') {
|
|
53
|
+
return `Created folder "${getFolderPath(codemod.parentName, codemod.folderName)}"`;
|
|
54
|
+
}
|
|
55
|
+
if (codemod.type === 'delete-folder') {
|
|
56
|
+
return `Deleted folder "${getFolderPath(codemod.parentName, codemod.folderName)}"`;
|
|
57
|
+
}
|
|
58
|
+
if (codemod.changes.length === 1) {
|
|
59
|
+
return `Updated visual control "${codemod.changes[0].id}"`;
|
|
60
|
+
}
|
|
61
|
+
return `Updated visual controls ${codemod.changes
|
|
62
|
+
.map((change) => `"${change.id}"`)
|
|
63
|
+
.join(', ')}`;
|
|
64
|
+
};
|
|
65
|
+
exports.getCodemodLogMessage = getCodemodLogMessage;
|
|
66
|
+
const getCodemodUndoDescription = (codemod) => {
|
|
67
|
+
if (codemod.type === 'delete-composition') {
|
|
68
|
+
return {
|
|
69
|
+
undoMessage: `↩️ Deletion of composition "${codemod.idToDelete}"`,
|
|
70
|
+
redoMessage: `↪️ Deletion of composition "${codemod.idToDelete}"`,
|
|
71
|
+
entryType: codemod.type,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
if (codemod.type === 'rename-composition') {
|
|
75
|
+
const label = `composition "${codemod.idToRename}" to "${codemod.newId}"`;
|
|
76
|
+
return {
|
|
77
|
+
undoMessage: `↩️ Rename of ${label}`,
|
|
78
|
+
redoMessage: `↪️ Rename of ${label}`,
|
|
79
|
+
entryType: codemod.type,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
if (codemod.type === 'update-composition-metadata') {
|
|
83
|
+
const label = `metadata of composition "${codemod.idToUpdate}"`;
|
|
84
|
+
return {
|
|
85
|
+
undoMessage: `↩️ Update of ${label}`,
|
|
86
|
+
redoMessage: `↪️ Update of ${label}`,
|
|
87
|
+
entryType: codemod.type,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
if (codemod.type === 'duplicate-composition') {
|
|
91
|
+
const label = `composition "${codemod.idToDuplicate}" to "${codemod.newId}"`;
|
|
92
|
+
return {
|
|
93
|
+
undoMessage: `↩️ Duplication of ${label}`,
|
|
94
|
+
redoMessage: `↪️ Duplication of ${label}`,
|
|
95
|
+
entryType: codemod.type,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
if (codemod.type === 'move-composition-or-folder') {
|
|
99
|
+
const label = codemod.source.type === 'composition'
|
|
100
|
+
? `composition "${codemod.source.compositionId}"`
|
|
101
|
+
: `folder "${getFolderPath(codemod.source.parentName, codemod.source.folderName)}"`;
|
|
102
|
+
return {
|
|
103
|
+
undoMessage: `↩️ Move of ${label}`,
|
|
104
|
+
redoMessage: `↪️ Move of ${label}`,
|
|
105
|
+
entryType: codemod.type,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
if (codemod.type === 'new-composition') {
|
|
109
|
+
return {
|
|
110
|
+
undoMessage: `↩️ Creation of composition "${codemod.newId}"`,
|
|
111
|
+
redoMessage: `↪️ Creation of composition "${codemod.newId}"`,
|
|
112
|
+
entryType: codemod.type,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
if (codemod.type === 'delete-folder') {
|
|
116
|
+
const label = `folder "${getFolderPath(codemod.parentName, codemod.folderName)}"`;
|
|
117
|
+
return {
|
|
118
|
+
undoMessage: `↩️ Deletion of ${label}`,
|
|
119
|
+
redoMessage: `↪️ Deletion of ${label}`,
|
|
120
|
+
entryType: codemod.type,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
if (codemod.type === 'new-folder') {
|
|
124
|
+
const label = `folder "${getFolderPath(codemod.parentName, codemod.folderName)}"`;
|
|
125
|
+
return {
|
|
126
|
+
undoMessage: `↩️ Creation of ${label}`,
|
|
127
|
+
redoMessage: `↪️ Creation of ${label}`,
|
|
128
|
+
entryType: codemod.type,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
if (codemod.type === 'rename-folder') {
|
|
132
|
+
const oldName = getFolderPath(codemod.parentName, codemod.folderName);
|
|
133
|
+
const newName = getFolderPath(codemod.parentName, codemod.newName);
|
|
134
|
+
const label = `folder "${oldName}" to "${newName}"`;
|
|
135
|
+
return {
|
|
136
|
+
undoMessage: `↩️ Rename of ${label}`,
|
|
137
|
+
redoMessage: `↪️ Rename of ${label}`,
|
|
138
|
+
entryType: codemod.type,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
undoMessage: '↩️ Visual control change',
|
|
143
|
+
redoMessage: '↪️ Visual control change',
|
|
144
|
+
entryType: 'visual-control',
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
const applyCodemodHandler = ({ input: { codemod, dryRun, symbolicatedStack, undoRedoNavigation }, logLevel, remotionRoot, entryPoint, }) => {
|
|
148
|
+
return (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
|
|
149
|
+
var _a, _b;
|
|
150
|
+
var _c, _d, _e;
|
|
151
|
+
try {
|
|
152
|
+
const logLine = (_c = symbolicatedStack === null || symbolicatedStack === void 0 ? void 0 : symbolicatedStack.originalLineNumber) !== null && _c !== void 0 ? _c : 1;
|
|
153
|
+
const filePath = symbolicatedStack
|
|
154
|
+
? (0, apply_codemod_to_file_1.resolveFilePathFromSymbolicatedStack)(remotionRoot, symbolicatedStack)
|
|
155
|
+
: (await (0, project_info_1.getProjectInfo)(remotionRoot, entryPoint)).rootFile;
|
|
156
|
+
if (!filePath) {
|
|
157
|
+
throw new Error('Cannot find file for composition in project');
|
|
158
|
+
}
|
|
159
|
+
(0, can_update_default_props_1.checkIfTypeScriptFile)(filePath);
|
|
160
|
+
const newCompositionComponentFilePath = codemod.type === 'new-composition'
|
|
161
|
+
? node_path_1.default.join(node_path_1.default.dirname(filePath), `${codemod.componentName}.tsx`)
|
|
162
|
+
: null;
|
|
163
|
+
if (codemod.type === 'new-composition' &&
|
|
164
|
+
newCompositionComponentFilePath &&
|
|
165
|
+
(0, node_fs_1.existsSync)(newCompositionComponentFilePath)) {
|
|
166
|
+
throw new Error(`Cannot create ${node_path_1.default.relative(remotionRoot, newCompositionComponentFilePath)} because it already exists`);
|
|
167
|
+
}
|
|
168
|
+
const input = (0, node_fs_1.readFileSync)(filePath, 'utf-8');
|
|
169
|
+
const result = await (0, apply_codemod_to_file_1.applyCodemodToFile)({
|
|
170
|
+
filePath,
|
|
171
|
+
codeMod: codemod,
|
|
172
|
+
});
|
|
173
|
+
const formatted = (_d = (_a = result.changes.find((change) => change.filePath === filePath)) === null || _a === void 0 ? void 0 : _a.nextContents) !== null && _d !== void 0 ? _d : input;
|
|
174
|
+
const diff = simpleDiff({
|
|
175
|
+
oldLines: input.split('\n'),
|
|
176
|
+
newLines: formatted.split('\n'),
|
|
177
|
+
});
|
|
178
|
+
if (!dryRun) {
|
|
179
|
+
if ((0, node_fs_1.readFileSync)(filePath, 'utf-8') !== input) {
|
|
180
|
+
throw new Error(`Source changed before applying codemod: ${filePath}`);
|
|
181
|
+
}
|
|
182
|
+
for (const change of result.changes) {
|
|
183
|
+
const currentContents = (0, node_fs_1.existsSync)(change.filePath)
|
|
184
|
+
? (0, node_fs_1.readFileSync)(change.filePath, 'utf-8')
|
|
185
|
+
: null;
|
|
186
|
+
if (currentContents !== change.previousContents) {
|
|
187
|
+
throw new Error(`Source changed before applying codemod: ${change.filePath}`);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
const { entryType, undoMessage, redoMessage } = getCodemodUndoDescription(codemod);
|
|
191
|
+
const snapshots = [
|
|
192
|
+
{
|
|
193
|
+
filePath,
|
|
194
|
+
oldContents: input,
|
|
195
|
+
newContents: null,
|
|
196
|
+
logLine,
|
|
197
|
+
nodePathRemappings: null,
|
|
198
|
+
},
|
|
199
|
+
];
|
|
200
|
+
let componentFilePath = null;
|
|
201
|
+
let componentFileContents = null;
|
|
202
|
+
if (codemod.type === 'new-composition') {
|
|
203
|
+
componentFilePath = newCompositionComponentFilePath;
|
|
204
|
+
if (componentFilePath === null) {
|
|
205
|
+
throw new Error('Could not determine the new component file path');
|
|
206
|
+
}
|
|
207
|
+
componentFileContents = (_e = (_b = result.changes.find((change) => change.filePath === componentFilePath)) === null || _b === void 0 ? void 0 : _b.nextContents) !== null && _e !== void 0 ? _e : null;
|
|
208
|
+
if (componentFileContents === null) {
|
|
209
|
+
throw new Error('Could not create the composition component');
|
|
210
|
+
}
|
|
211
|
+
snapshots.push({
|
|
212
|
+
filePath: componentFilePath,
|
|
213
|
+
oldContents: null,
|
|
214
|
+
newContents: componentFileContents,
|
|
215
|
+
logLine: 1,
|
|
216
|
+
nodePathRemappings: null,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
(0, undo_stack_1.pushTransactionToUndoStack)({
|
|
220
|
+
snapshots,
|
|
221
|
+
logLevel,
|
|
222
|
+
remotionRoot,
|
|
223
|
+
description: {
|
|
224
|
+
undoMessage,
|
|
225
|
+
redoMessage,
|
|
226
|
+
},
|
|
227
|
+
entryType,
|
|
228
|
+
suppressHmrOnFileRestore: false,
|
|
229
|
+
undoRedoNavigation,
|
|
230
|
+
});
|
|
231
|
+
(0, undo_stack_1.suppressUndoStackInvalidation)(filePath);
|
|
232
|
+
if (componentFilePath) {
|
|
233
|
+
(0, undo_stack_1.suppressUndoStackInvalidation)(componentFilePath);
|
|
234
|
+
}
|
|
235
|
+
(0, file_watcher_1.writeFileAndNotifyFileWatchers)({
|
|
236
|
+
file: filePath,
|
|
237
|
+
content: formatted,
|
|
238
|
+
originatorClientId: undefined,
|
|
239
|
+
metadata: null,
|
|
240
|
+
});
|
|
241
|
+
if (componentFilePath && componentFileContents !== null) {
|
|
242
|
+
(0, file_watcher_1.writeFileAndNotifyFileWatchers)({
|
|
243
|
+
file: componentFilePath,
|
|
244
|
+
content: componentFileContents,
|
|
245
|
+
originatorClientId: undefined,
|
|
246
|
+
metadata: null,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
const logMessage = (0, exports.getCodemodLogMessage)(codemod);
|
|
250
|
+
const editMessage = `${(0, source_file_write_queue_1.getCodemodTimingPrefix)(logLevel)}${renderer_1.RenderInternals.chalk.blueBright((0, format_log_file_location_1.formatLogFileLocation)({
|
|
251
|
+
remotionRoot,
|
|
252
|
+
absolutePath: filePath,
|
|
253
|
+
line: logLine,
|
|
254
|
+
}))} ${logMessage}`;
|
|
255
|
+
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, editMessage);
|
|
256
|
+
(0, undo_stack_1.printUndoHint)(logLevel);
|
|
257
|
+
}
|
|
258
|
+
return {
|
|
259
|
+
success: true,
|
|
260
|
+
diff,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
catch (err) {
|
|
264
|
+
return {
|
|
265
|
+
success: false,
|
|
266
|
+
reason: err.message,
|
|
267
|
+
stack: err.stack,
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
};
|
|
272
|
+
exports.applyCodemodHandler = applyCodemodHandler;
|
|
@@ -28,10 +28,7 @@ const applyVisualControlHandler = ({ input: { fileName, changes }, remotionRoot,
|
|
|
28
28
|
changes,
|
|
29
29
|
});
|
|
30
30
|
const output = (_c = (_a = result.changes[0]) === null || _a === void 0 ? void 0 : _a.nextContents) !== null && _c !== void 0 ? _c : fileContents;
|
|
31
|
-
const logLine = (_d = (_b = result.updatedControls.findLast((control) => {
|
|
32
|
-
var _a;
|
|
33
|
-
return control.id === ((_a = changes[0]) === null || _a === void 0 ? void 0 : _a.id);
|
|
34
|
-
})) === null || _b === void 0 ? void 0 : _b.line) !== null && _d !== void 0 ? _d : 1;
|
|
31
|
+
const logLine = (_d = (_b = result.updatedControls.findLast((control) => { var _a; return control.id === ((_a = changes[0]) === null || _a === void 0 ? void 0 : _a.id); })) === null || _b === void 0 ? void 0 : _b.line) !== null && _d !== void 0 ? _d : 1;
|
|
35
32
|
if (result.updatedControls.length === 0) {
|
|
36
33
|
throw new Error('No changes were made to the file');
|
|
37
34
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { LogLevel } from '@remotion/renderer';
|
|
1
2
|
import type { BatchUpdateKeyframeSettingsRequest, BatchUpdateKeyframeSettingsResponse } from '@remotion/studio-shared';
|
|
2
3
|
import type { ApiHandler } from '../api-types';
|
|
3
4
|
export declare const batchUpdateKeyframeSettings: ({ sequenceKeyframes, effectKeyframes, clientId, remotionRoot, logLevel, }: BatchUpdateKeyframeSettingsRequest & {
|
|
4
5
|
remotionRoot: string;
|
|
5
|
-
logLevel:
|
|
6
|
+
logLevel: LogLevel;
|
|
6
7
|
}) => Promise<void>;
|
|
7
8
|
export declare const batchUpdateKeyframeSettingsHandler: ApiHandler<BatchUpdateKeyframeSettingsRequest, BatchUpdateKeyframeSettingsResponse>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { CodemodsInternals } from '@remotion/codemods';
|
|
1
2
|
import type { CanUpdateDefaultPropsResponse, SymbolicatedStackFrame } from '@remotion/studio-shared';
|
|
2
|
-
export declare const computeCanUpdateDefaultPropsFromContent
|
|
3
|
+
export declare const { computeCanUpdateDefaultPropsFromContent, }: typeof CodemodsInternals;
|
|
3
4
|
export declare const checkIfTypeScriptFile: (file: string) => void;
|
|
4
5
|
export declare const getDefaultPropsFile: ({ symbolicatedStack, remotionRoot, entryPoint, }: {
|
|
5
6
|
symbolicatedStack: SymbolicatedStackFrame | null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { File, JSXOpeningElement } from '@babel/types';
|
|
2
|
+
import { CodemodsInternals } from '@remotion/codemods';
|
|
2
3
|
import type { CanUpdateEffectPropsResponse, SequenceNodePath, InteractivitySchema } from 'remotion';
|
|
3
4
|
import { type VideoConfigIdentifierValues } from '../../helpers/video-config-values';
|
|
4
5
|
export declare const computeEffectPropStatus: ({ ast, jsx, effectIndex, keys, videoConfigValues, }: {
|
|
@@ -8,12 +9,7 @@ export declare const computeEffectPropStatus: ({ ast, jsx, effectIndex, keys, vi
|
|
|
8
9
|
keys: string[];
|
|
9
10
|
videoConfigValues: VideoConfigIdentifierValues;
|
|
10
11
|
}) => CanUpdateEffectPropsResponse;
|
|
11
|
-
export declare const
|
|
12
|
-
fileContents: string;
|
|
13
|
-
sequenceNodePath: SequenceNodePath;
|
|
14
|
-
effects: InteractivitySchema[];
|
|
15
|
-
keysFor: (effect: InteractivitySchema) => string[];
|
|
16
|
-
}) => CanUpdateEffectPropsResponse<import("remotion").SourceNumericValue>[];
|
|
12
|
+
export declare const { computeEffectPropsStatusesFromContent }: typeof CodemodsInternals;
|
|
17
13
|
export declare const computeEffectPropsStatusesFromFile: ({ fileName, sequenceNodePath, effects, keysFor, remotionRoot, }: {
|
|
18
14
|
fileName: string;
|
|
19
15
|
sequenceNodePath: SequenceNodePath;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Expression, File, JSXElement, JSXOpeningElement } from '@babel/types';
|
|
2
2
|
import type { SubscribeToSequencePropsResponse } from '@remotion/studio-shared';
|
|
3
|
-
import
|
|
3
|
+
import * as recast from 'recast';
|
|
4
|
+
import type { CanUpdateSequencePropsResponseTrue, CanUpdateSequencePropStatus, JsxComponentIdentity, LogLevel, SequenceNodePath } from 'remotion';
|
|
4
5
|
import { type VideoConfigIdentifierValues } from '../../helpers/video-config-values';
|
|
5
6
|
type CanUpdatePropStatus = CanUpdateSequencePropStatus;
|
|
6
7
|
type StaticValueOptions = {
|
|
@@ -10,7 +11,7 @@ export declare const isStaticValue: (node: Expression, options?: StaticValueOpti
|
|
|
10
11
|
export declare const extractStaticValue: (node: Expression, options?: StaticValueOptions) => unknown;
|
|
11
12
|
export declare const getComputedStatus: (node: Expression, ast: File, videoConfigValues: VideoConfigIdentifierValues) => CanUpdatePropStatus;
|
|
12
13
|
export declare const getNodePathForRecastPath: (recastPath: any, ast: File) => SequenceNodePath;
|
|
13
|
-
export declare const findJsxElementPathAtNodePath: (ast: File, nodePath: SequenceNodePath) =>
|
|
14
|
+
export declare const findJsxElementPathAtNodePath: (ast: File, nodePath: SequenceNodePath) => recast.types.NodePath<any, any> | null;
|
|
14
15
|
export declare const findJsxElementAtNodePath: (ast: File, nodePath: SequenceNodePath) => JSXOpeningElement | null;
|
|
15
16
|
export declare const findJsxElementNodeAtNodePath: (ast: File, nodePath: SequenceNodePath) => JSXElement | null;
|
|
16
17
|
export type StaticJsxTextContent = {
|
|
@@ -24,7 +25,7 @@ export declare const getStaticJsxChildrenAttribute: (jsxElement: JSXOpeningEleme
|
|
|
24
25
|
export declare const hasJsxChildrenAttribute: (jsxElement: JSXOpeningElement) => boolean;
|
|
25
26
|
export declare const getStaticJsxTextContent: (jsxElement: JSXElement) => StaticJsxTextContent | null;
|
|
26
27
|
export declare const findNodePathForJsxElement: (ast: File, target: JSXOpeningElement) => SequenceNodePath | null;
|
|
27
|
-
export declare const lineColumnToNodePath: (ast: File, targetLine: number, targetColumn?: number
|
|
28
|
+
export declare const lineColumnToNodePath: (ast: File, targetLine: number, targetColumn?: number, fileContents?: string) => SequenceNodePath | null;
|
|
28
29
|
export declare const lineColumnsToNodePaths: ({ ast, targets, fileContents, }: {
|
|
29
30
|
ast: File;
|
|
30
31
|
targets: {
|
|
@@ -33,40 +34,43 @@ export declare const lineColumnsToNodePaths: ({ ast, targets, fileContents, }: {
|
|
|
33
34
|
}[];
|
|
34
35
|
fileContents: string;
|
|
35
36
|
}) => (SequenceNodePath | null)[];
|
|
36
|
-
export declare const resolveSequencePropsNodePathsFromFilename: ({ fileName, targets, remotionRoot, }: {
|
|
37
|
+
export declare const resolveSequencePropsNodePathsFromFilename: ({ fileName, targets, remotionRoot, fileContentsCache, }: {
|
|
37
38
|
fileName: string;
|
|
38
39
|
targets: {
|
|
39
40
|
line: number;
|
|
40
41
|
column: number;
|
|
41
42
|
}[];
|
|
42
43
|
remotionRoot: string;
|
|
44
|
+
fileContentsCache: Map<string, string> | null;
|
|
43
45
|
}) => (SequenceNodePath | null)[];
|
|
44
46
|
export declare const computeSequencePropsStatusFromContent: ({ fileContents, nodePath, componentIdentity, keys, assetKeys, effects, }: {
|
|
45
47
|
fileContents: string;
|
|
46
48
|
nodePath: SequenceNodePath;
|
|
47
|
-
componentIdentity:
|
|
49
|
+
componentIdentity: JsxComponentIdentity | null;
|
|
48
50
|
keys: string[];
|
|
49
|
-
assetKeys?: string[]
|
|
51
|
+
assetKeys?: string[];
|
|
50
52
|
effects: string[][];
|
|
51
53
|
}) => CanUpdateSequencePropsResponseTrue;
|
|
52
|
-
export declare const computeSequencePropsStatus: ({ fileName, nodePath, componentIdentity, keys, assetKeys, effects, remotionRoot, }: {
|
|
54
|
+
export declare const computeSequencePropsStatus: ({ fileName, nodePath, componentIdentity, keys, assetKeys, effects, remotionRoot, fileContentsCache, }: {
|
|
53
55
|
fileName: string;
|
|
54
56
|
nodePath: SequenceNodePath;
|
|
55
|
-
componentIdentity:
|
|
57
|
+
componentIdentity: JsxComponentIdentity | null;
|
|
56
58
|
keys: string[];
|
|
57
|
-
assetKeys?: string[]
|
|
59
|
+
assetKeys?: string[];
|
|
58
60
|
effects: string[][];
|
|
59
61
|
remotionRoot: string;
|
|
62
|
+
fileContentsCache: Map<string, string> | null;
|
|
60
63
|
}) => CanUpdateSequencePropsResponseTrue;
|
|
61
|
-
export declare const computeSequencePropsStatusFromFilenameByLocation: ({ fileName, line, column, componentIdentity, keys, assetKeys, effects, remotionRoot, logLevel, }: {
|
|
64
|
+
export declare const computeSequencePropsStatusFromFilenameByLocation: ({ fileName, line, column, componentIdentity, keys, assetKeys, effects, remotionRoot, logLevel, fileContentsCache, }: {
|
|
62
65
|
fileName: string;
|
|
63
66
|
line: number;
|
|
64
67
|
column: number;
|
|
65
|
-
componentIdentity:
|
|
68
|
+
componentIdentity: JsxComponentIdentity | null;
|
|
66
69
|
keys: string[];
|
|
67
|
-
assetKeys?: string[]
|
|
70
|
+
assetKeys?: string[];
|
|
68
71
|
effects: string[][];
|
|
69
72
|
remotionRoot: string;
|
|
70
|
-
logLevel:
|
|
73
|
+
logLevel: LogLevel;
|
|
74
|
+
fileContentsCache: Map<string, string> | null;
|
|
71
75
|
}) => SubscribeToSequencePropsResponse;
|
|
72
76
|
export {};
|