@remotion/studio-server 4.0.526 → 4.0.528
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/apply-codemod-to-file.d.ts +2 -1
- package/dist/codemods/apply-codemod-to-file.js +142 -8
- package/dist/codemods/{delete-jsx-node.d.ts → delete-jsx-nodes.d.ts} +1 -10
- package/dist/codemods/delete-jsx-nodes.js +10 -0
- package/dist/codemods/paste-effects.d.ts +15 -1
- package/dist/codemods/paste-effects.js +3 -2
- package/dist/codemods/split-jsx-sequence.d.ts +14 -0
- package/dist/codemods/split-jsx-sequence.js +10 -3
- package/dist/codemods/update-effect-props/update-effect-props.d.ts +11 -3
- package/dist/codemods/update-effect-props/update-effect-props.js +17 -10
- package/dist/codemods/update-keyframes/update-keyframes.d.ts +31 -10
- package/dist/codemods/update-keyframes/update-keyframes.js +24 -7
- package/dist/codemods/update-sequence-props/update-sequence-props.d.ts +3 -6
- package/dist/codemods/update-sequence-props/update-sequence-props.js +16 -9
- package/dist/helpers/open-file-for-writing-without-symlinks.d.ts +6 -1
- package/dist/helpers/open-file-for-writing-without-symlinks.js +9 -6
- package/dist/helpers/resolve-composition-component.d.ts +1 -1
- package/dist/helpers/resolve-composition-component.js +5 -4
- package/dist/index.d.ts +0 -19
- package/dist/index.js +0 -6
- package/dist/preview-server/api-routes.js +8 -2
- package/dist/preview-server/hot-middleware/index.js +13 -46
- package/dist/preview-server/routes/add-effect.js +17 -8
- package/dist/preview-server/routes/apply-codemod.d.ts +0 -19
- package/dist/preview-server/routes/apply-codemod.js +24 -26
- package/dist/preview-server/routes/apply-visual-control-change.js +13 -65
- package/dist/preview-server/routes/can-update-default-props.d.ts +1 -1
- package/dist/preview-server/routes/can-update-default-props.js +3 -4
- package/dist/preview-server/routes/can-update-sequence-props.d.ts +0 -10
- package/dist/preview-server/routes/can-update-sequence-props.js +62 -495
- package/dist/preview-server/routes/delete-effect.js +15 -13
- package/dist/preview-server/routes/delete-jsx-nodes.d.ts +3 -0
- package/dist/preview-server/routes/{delete-jsx-node.js → delete-jsx-nodes.js} +23 -12
- package/dist/preview-server/routes/download-remote-asset.d.ts +5 -0
- package/dist/preview-server/routes/download-remote-asset.js +25 -20
- package/dist/preview-server/routes/duplicate-effect.js +12 -4
- package/dist/preview-server/routes/duplicate-jsx-node.js +15 -4
- package/dist/preview-server/routes/element-install-plan.d.ts +1 -1
- package/dist/preview-server/routes/find-in-file.d.ts +9 -1
- package/dist/preview-server/routes/find-in-file.js +3 -4
- package/dist/preview-server/routes/insert-basic-captions.d.ts +3 -0
- package/dist/preview-server/routes/insert-basic-captions.js +119 -0
- package/dist/preview-server/routes/insert-element.js +399 -280
- package/dist/preview-server/routes/install-dependency.js +14 -4
- package/dist/preview-server/routes/prepare-element-install.js +3 -0
- package/dist/preview-server/routes/reorder-effect.js +12 -5
- package/dist/preview-server/routes/reorder-sequence.js +10 -5
- package/dist/preview-server/routes/replace-video-source.d.ts +3 -0
- package/dist/preview-server/routes/replace-video-source.js +81 -0
- package/dist/preview-server/routes/save-sequence-props.js +8 -28
- package/dist/preview-server/routes/split-jsx-sequence.js +82 -42
- package/dist/preview-server/routes/split-video-from-audio.js +9 -4
- package/dist/preview-server/routes/subscribe-to-sequence-props.js +6 -10
- package/dist/preview-server/routes/update-config.js +38 -2
- package/dist/preview-server/routes/update-default-props.js +12 -8
- 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/studio-protocol/handle-discovery.js +1 -1
- package/dist/preview-server/studio-protocol/handle-element-library.js +3 -3
- package/dist/preview-server/undo-stack.d.ts +2 -1
- package/dist/preview-server/undo-stack.js +19 -0
- package/dist/routes.js +2 -0
- package/package.json +8 -8
- package/dist/canvas-capture/generate-canvas-capture-composition.d.ts +0 -14
- package/dist/canvas-capture/generate-canvas-capture-composition.js +0 -239
- package/dist/codemods/add-effect.d.ts +0 -1
- package/dist/codemods/add-effect.js +0 -8
- package/dist/codemods/apply-visual-control.d.ts +0 -8
- package/dist/codemods/apply-visual-control.js +0 -89
- package/dist/codemods/delete-effect.d.ts +0 -1
- package/dist/codemods/delete-effect.js +0 -6
- package/dist/codemods/delete-jsx-node.js +0 -17
- package/dist/codemods/duplicate-composition.d.ts +0 -2
- package/dist/codemods/duplicate-composition.js +0 -64
- package/dist/codemods/duplicate-effect.d.ts +0 -1
- package/dist/codemods/duplicate-effect.js +0 -6
- package/dist/codemods/duplicate-jsx-node.d.ts +0 -25
- package/dist/codemods/duplicate-jsx-node.js +0 -26
- package/dist/codemods/format-file-content.d.ts +0 -7
- package/dist/codemods/format-file-content.js +0 -80
- package/dist/codemods/format-inline-content.d.ts +0 -18
- package/dist/codemods/format-inline-content.js +0 -78
- package/dist/codemods/recast-mods.d.ts +0 -13
- package/dist/codemods/recast-mods.js +0 -902
- package/dist/codemods/reorder-effect.d.ts +0 -1
- package/dist/codemods/reorder-effect.js +0 -5
- package/dist/codemods/reorder-sequence.d.ts +0 -1
- package/dist/codemods/reorder-sequence.js +0 -5
- package/dist/codemods/simple-diff.d.ts +0 -5
- package/dist/codemods/simple-diff.js +0 -39
- package/dist/codemods/split-video-from-audio.d.ts +0 -1
- package/dist/codemods/split-video-from-audio.js +0 -5
- package/dist/codemods/update-default-props.d.ts +0 -1
- package/dist/codemods/update-default-props.js +0 -6
- package/dist/codemods/update-inline-caption-patches.d.ts +0 -1
- package/dist/codemods/update-inline-caption-patches.js +0 -5
- package/dist/codemods/update-keyframes/ensure-imports-and-frame-hook.d.ts +0 -1
- package/dist/codemods/update-keyframes/ensure-imports-and-frame-hook.js +0 -7
- package/dist/preview-server/routes/delete-jsx-node.d.ts +0 -3
- package/dist/preview-server/routes/update-public-license.d.ts +0 -11
- package/dist/preview-server/routes/update-public-license.js +0 -97
|
@@ -16,13 +16,14 @@ const copy_render_output_to_asset_1 = require("./routes/copy-render-output-to-as
|
|
|
16
16
|
const default_coding_agent_1 = require("./routes/default-coding-agent");
|
|
17
17
|
const default_editor_1 = require("./routes/default-editor");
|
|
18
18
|
const delete_effect_1 = require("./routes/delete-effect");
|
|
19
|
-
const
|
|
19
|
+
const delete_jsx_nodes_1 = require("./routes/delete-jsx-nodes");
|
|
20
20
|
const delete_keyframes_1 = require("./routes/delete-keyframes");
|
|
21
21
|
const delete_static_file_1 = require("./routes/delete-static-file");
|
|
22
22
|
const download_remote_asset_1 = require("./routes/download-remote-asset");
|
|
23
23
|
const duplicate_effect_1 = require("./routes/duplicate-effect");
|
|
24
24
|
const duplicate_jsx_node_1 = require("./routes/duplicate-jsx-node");
|
|
25
25
|
const find_in_file_1 = require("./routes/find-in-file");
|
|
26
|
+
const insert_basic_captions_1 = require("./routes/insert-basic-captions");
|
|
26
27
|
const insert_element_1 = require("./routes/insert-element");
|
|
27
28
|
const insert_jsx_element_1 = require("./routes/insert-jsx-element");
|
|
28
29
|
const install_remotion_skill_1 = require("./routes/install-remotion-skill");
|
|
@@ -44,6 +45,7 @@ const remove_render_1 = require("./routes/remove-render");
|
|
|
44
45
|
const rename_static_file_1 = require("./routes/rename-static-file");
|
|
45
46
|
const reorder_effect_1 = require("./routes/reorder-effect");
|
|
46
47
|
const reorder_sequence_1 = require("./routes/reorder-sequence");
|
|
48
|
+
const replace_video_source_1 = require("./routes/replace-video-source");
|
|
47
49
|
const restart_studio_1 = require("./routes/restart-studio");
|
|
48
50
|
const save_effect_props_1 = require("./routes/save-effect-props");
|
|
49
51
|
const save_multiple_effect_props_1 = require("./routes/save-multiple-effect-props");
|
|
@@ -65,6 +67,7 @@ const update_effect_keyframe_settings_1 = require("./routes/update-effect-keyfra
|
|
|
65
67
|
const update_element_install_target_1 = require("./routes/update-element-install-target");
|
|
66
68
|
const update_sequence_keyframe_settings_1 = require("./routes/update-sequence-keyframe-settings");
|
|
67
69
|
const upgrade_remotion_1 = require("./routes/upgrade-remotion");
|
|
70
|
+
const wrap_jsx_node_1 = require("./routes/wrap-jsx-node");
|
|
68
71
|
exports.allApiRoutes = {
|
|
69
72
|
'/api/invalidate-bundle': invalidate_bundle_1.invalidateBundleHandler,
|
|
70
73
|
'/api/composition-component-info': composition_component_info_1.compositionComponentInfoHandler,
|
|
@@ -107,10 +110,13 @@ exports.allApiRoutes = {
|
|
|
107
110
|
'/api/batch-update-keyframe-settings': batch_update_keyframe_settings_1.batchUpdateKeyframeSettingsHandler,
|
|
108
111
|
'/api/delete-effect': delete_effect_1.deleteEffectHandler,
|
|
109
112
|
'/api/paste-effects': paste_effects_1.pasteEffectsHandler,
|
|
110
|
-
'/api/delete-jsx-
|
|
113
|
+
'/api/delete-jsx-nodes': delete_jsx_nodes_1.deleteJsxNodesHandler,
|
|
111
114
|
'/api/duplicate-jsx-node': duplicate_jsx_node_1.duplicateJsxNodeHandler,
|
|
115
|
+
'/api/wrap-jsx-node': wrap_jsx_node_1.wrapJsxNodeHandler,
|
|
112
116
|
'/api/split-jsx-sequence': split_jsx_sequence_1.splitJsxSequenceHandler,
|
|
113
117
|
'/api/split-video-from-audio': split_video_from_audio_1.splitVideoFromAudioHandler,
|
|
118
|
+
'/api/insert-basic-captions': insert_basic_captions_1.insertBasicCaptionsHandler,
|
|
119
|
+
'/api/replace-video-source': replace_video_source_1.replaceVideoSourceHandler,
|
|
114
120
|
'/api/update-available': update_available_1.handleUpdate,
|
|
115
121
|
'/api/release-notes': release_notes_1.getReleaseNotesHandler,
|
|
116
122
|
'/api/remotion-skills-info': remotion_skills_info_1.remotionSkillsInfoHandler,
|
|
@@ -49,52 +49,19 @@ const setupWebpackHmr = (compiler, logLevel, liveEventsServer) => {
|
|
|
49
49
|
};
|
|
50
50
|
exports.setupWebpackHmr = setupWebpackHmr;
|
|
51
51
|
function publishStats(action, statsResult, publishHmr) {
|
|
52
|
-
const stats = statsResult.toJson({
|
|
53
|
-
all: false,
|
|
54
|
-
cached: true,
|
|
55
|
-
children: true,
|
|
56
|
-
modules: true,
|
|
57
|
-
timings: true,
|
|
58
|
-
hash: true,
|
|
59
|
-
});
|
|
60
|
-
// For multi-compiler, stats will be an object with a 'children' array of stats
|
|
61
|
-
const bundles = extractBundles(stats);
|
|
62
|
-
bundles.forEach((_stats) => {
|
|
63
|
-
let name = _stats.name || '';
|
|
64
|
-
// Fallback to compilation name in case of 1 bundle (if it exists)
|
|
65
|
-
if (bundles.length === 1 && !name && statsResult.compilation) {
|
|
66
|
-
name = statsResult.compilation.name || '';
|
|
67
|
-
}
|
|
68
|
-
publishHmr({
|
|
69
|
-
name,
|
|
70
|
-
action,
|
|
71
|
-
time: _stats.time,
|
|
72
|
-
hash: _stats.hash,
|
|
73
|
-
warnings: _stats.warnings || [],
|
|
74
|
-
errors: _stats.errors || [],
|
|
75
|
-
modules: buildModuleMap(_stats.modules),
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
function extractBundles(stats) {
|
|
80
52
|
var _a;
|
|
81
|
-
//
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
modules.forEach((module) => {
|
|
96
|
-
const id = module.id;
|
|
97
|
-
map[id] = module.name;
|
|
53
|
+
// Studio uses a single compiler. Child compilations must not replace the
|
|
54
|
+
// parent compilation's hash in the HMR message.
|
|
55
|
+
publishHmr({
|
|
56
|
+
name: (_a = statsResult.compilation.name) !== null && _a !== void 0 ? _a : '',
|
|
57
|
+
action,
|
|
58
|
+
time: statsResult.endTime - statsResult.startTime,
|
|
59
|
+
hash: statsResult.hash,
|
|
60
|
+
// Build diagnostics are printed by the dev middleware.
|
|
61
|
+
warnings: [],
|
|
62
|
+
errors: [],
|
|
63
|
+
// Module names only label browser console messages. The client already
|
|
64
|
+
// falls back to module IDs, which are named in development builds.
|
|
65
|
+
modules: {},
|
|
98
66
|
});
|
|
99
|
-
return map;
|
|
100
67
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addEffectHandler = void 0;
|
|
4
4
|
const node_fs_1 = require("node:fs");
|
|
5
|
+
const codemods_1 = require("@remotion/codemods");
|
|
5
6
|
const renderer_1 = require("@remotion/renderer");
|
|
6
|
-
const add_effect_1 = require("../../codemods/add-effect");
|
|
7
7
|
const file_watcher_1 = require("../../file-watcher");
|
|
8
8
|
const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside-project");
|
|
9
9
|
const format_log_file_location_1 = require("../format-log-file-location");
|
|
@@ -11,9 +11,12 @@ const undo_stack_1 = require("../undo-stack");
|
|
|
11
11
|
const formatting_1 = require("./log-updates/formatting");
|
|
12
12
|
const log_update_1 = require("./log-updates/log-update");
|
|
13
13
|
const source_file_write_queue_1 = require("./source-file-write-queue");
|
|
14
|
-
const addEffectHandler = ({ input:
|
|
14
|
+
const addEffectHandler = ({ input: request, remotionRoot, logLevel }) => {
|
|
15
15
|
return (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
|
|
16
|
+
var _a;
|
|
17
|
+
var _b;
|
|
16
18
|
try {
|
|
19
|
+
const { fileName, sequenceNodePath, effectName, effectImportPath, effectConfig, clientId, } = request;
|
|
17
20
|
renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[add-effect] Received request for fileName="${fileName}" effect="${effectName}"`);
|
|
18
21
|
const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
|
|
19
22
|
remotionRoot,
|
|
@@ -21,13 +24,15 @@ const addEffectHandler = ({ input: { fileName, sequenceNodePath, effectName, eff
|
|
|
21
24
|
action: 'modify',
|
|
22
25
|
});
|
|
23
26
|
const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
effectName,
|
|
28
|
-
effectImportPath,
|
|
29
|
-
effectConfig,
|
|
27
|
+
const result = await (0, codemods_1.addEffect)({
|
|
28
|
+
project: { files: { [absolutePath]: fileContents }, rootDir: remotionRoot },
|
|
29
|
+
node: { filePath: absolutePath, nodePath: sequenceNodePath.nodePath },
|
|
30
|
+
importName: effectName,
|
|
31
|
+
importPath: effectImportPath,
|
|
32
|
+
props: effectConfig,
|
|
30
33
|
});
|
|
34
|
+
const output = (_b = (_a = result.changes[0]) === null || _a === void 0 ? void 0 : _a.nextContents) !== null && _b !== void 0 ? _b : fileContents;
|
|
35
|
+
const { formatted, effectLabel, nodeLabel, logLine } = result.editDetails[0];
|
|
31
36
|
(0, undo_stack_1.pushToUndoStack)({
|
|
32
37
|
filePath: absolutePath,
|
|
33
38
|
oldContents: fileContents,
|
|
@@ -63,6 +68,10 @@ const addEffectHandler = ({ input: { fileName, sequenceNodePath, effectName, eff
|
|
|
63
68
|
(0, undo_stack_1.printUndoHint)(logLevel);
|
|
64
69
|
return {
|
|
65
70
|
success: true,
|
|
71
|
+
insertedEffect: {
|
|
72
|
+
effectIndex: result.insertedEffect.effectIndex,
|
|
73
|
+
nodePath: result.insertedEffect.nodePath,
|
|
74
|
+
},
|
|
66
75
|
};
|
|
67
76
|
}
|
|
68
77
|
catch (err) {
|
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
import type { ApplyCodemodRequest, ApplyCodemodResponse } from '@remotion/studio-shared';
|
|
2
2
|
import type { ApiHandler } from '../api-types';
|
|
3
|
-
export declare const formatNewCompositionFile: (codemod: {
|
|
4
|
-
type: "new-composition";
|
|
5
|
-
newId: string;
|
|
6
|
-
componentName: string;
|
|
7
|
-
componentImportPath: string;
|
|
8
|
-
folderName: string | null;
|
|
9
|
-
parentName: string | null;
|
|
10
|
-
newHeight: number;
|
|
11
|
-
newWidth: number;
|
|
12
|
-
newFps: number;
|
|
13
|
-
newDurationInFrames: number;
|
|
14
|
-
canvasCapture: {
|
|
15
|
-
readonly videoFileName: string;
|
|
16
|
-
readonly videoHeight: number;
|
|
17
|
-
readonly videoWidth: number;
|
|
18
|
-
readonly keyframeFps: number;
|
|
19
|
-
readonly data: import("@remotion/studio-shared").CanvasCaptureData;
|
|
20
|
-
} | null;
|
|
21
|
-
}) => string;
|
|
22
3
|
export declare const getCodemodLogMessage: (codemod: import("@remotion/studio-shared").RecastCodemod) => string;
|
|
23
4
|
export declare const applyCodemodHandler: ApiHandler<ApplyCodemodRequest, ApplyCodemodResponse>;
|
|
@@ -3,11 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.applyCodemodHandler = exports.getCodemodLogMessage =
|
|
6
|
+
exports.applyCodemodHandler = exports.getCodemodLogMessage = void 0;
|
|
7
7
|
const node_fs_1 = require("node:fs");
|
|
8
8
|
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const codemods_1 = require("@remotion/codemods");
|
|
9
10
|
const renderer_1 = require("@remotion/renderer");
|
|
10
|
-
const studio_codemods_1 = require("@remotion/studio-codemods");
|
|
11
11
|
const apply_codemod_to_file_1 = require("../../codemods/apply-codemod-to-file");
|
|
12
12
|
const file_watcher_1 = require("../../file-watcher");
|
|
13
13
|
const format_log_file_location_1 = require("../format-log-file-location");
|
|
@@ -15,8 +15,7 @@ const project_info_1 = require("../project-info");
|
|
|
15
15
|
const undo_stack_1 = require("../undo-stack");
|
|
16
16
|
const can_update_default_props_1 = require("./can-update-default-props");
|
|
17
17
|
const source_file_write_queue_1 = require("./source-file-write-queue");
|
|
18
|
-
const
|
|
19
|
-
exports.formatNewCompositionFile = formatNewCompositionFile;
|
|
18
|
+
const { simpleDiff } = codemods_1.CodemodsInternals;
|
|
20
19
|
const getFolderPath = (parentName, folderName) => {
|
|
21
20
|
return parentName ? `${parentName}/${folderName}` : folderName;
|
|
22
21
|
};
|
|
@@ -39,12 +38,6 @@ const getCodemodLogMessage = (codemod) => {
|
|
|
39
38
|
if (codemod.type === 'delete-composition') {
|
|
40
39
|
return `Deleted composition "${codemod.idToDelete}"`;
|
|
41
40
|
}
|
|
42
|
-
if (codemod.type === 'move-composition-to-folder') {
|
|
43
|
-
const destination = codemod.folderName
|
|
44
|
-
? `into folder "${getFolderPath(codemod.parentName, codemod.folderName)}"`
|
|
45
|
-
: 'to root';
|
|
46
|
-
return `Moved composition "${codemod.idToMove}" ${destination}`;
|
|
47
|
-
}
|
|
48
41
|
if (codemod.type === 'move-composition-or-folder') {
|
|
49
42
|
const source = codemod.source.type === 'composition'
|
|
50
43
|
? `composition "${codemod.source.compositionId}"`
|
|
@@ -102,17 +95,6 @@ const getCodemodUndoDescription = (codemod) => {
|
|
|
102
95
|
entryType: codemod.type,
|
|
103
96
|
};
|
|
104
97
|
}
|
|
105
|
-
if (codemod.type === 'move-composition-to-folder') {
|
|
106
|
-
const destination = codemod.folderName === null
|
|
107
|
-
? 'to root'
|
|
108
|
-
: `into folder "${getFolderPath(codemod.parentName, codemod.folderName)}"`;
|
|
109
|
-
const label = `composition "${codemod.idToMove}" ${destination}`;
|
|
110
|
-
return {
|
|
111
|
-
undoMessage: `↩️ Move of ${label}`,
|
|
112
|
-
redoMessage: `↪️ Move of ${label}`,
|
|
113
|
-
entryType: codemod.type,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
98
|
if (codemod.type === 'move-composition-or-folder') {
|
|
117
99
|
const label = codemod.source.type === 'composition'
|
|
118
100
|
? `composition "${codemod.source.compositionId}"`
|
|
@@ -164,9 +146,10 @@ const getCodemodUndoDescription = (codemod) => {
|
|
|
164
146
|
};
|
|
165
147
|
const applyCodemodHandler = ({ input: { codemod, dryRun, symbolicatedStack, undoRedoNavigation }, logLevel, remotionRoot, entryPoint, }) => {
|
|
166
148
|
return (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
|
|
167
|
-
var _a;
|
|
149
|
+
var _a, _b;
|
|
150
|
+
var _c, _d, _e;
|
|
168
151
|
try {
|
|
169
|
-
const logLine = (
|
|
152
|
+
const logLine = (_c = symbolicatedStack === null || symbolicatedStack === void 0 ? void 0 : symbolicatedStack.originalLineNumber) !== null && _c !== void 0 ? _c : 1;
|
|
170
153
|
const filePath = symbolicatedStack
|
|
171
154
|
? (0, apply_codemod_to_file_1.resolveFilePathFromSymbolicatedStack)(remotionRoot, symbolicatedStack)
|
|
172
155
|
: (await (0, project_info_1.getProjectInfo)(remotionRoot, entryPoint)).rootFile;
|
|
@@ -183,15 +166,27 @@ const applyCodemodHandler = ({ input: { codemod, dryRun, symbolicatedStack, undo
|
|
|
183
166
|
throw new Error(`Cannot create ${node_path_1.default.relative(remotionRoot, newCompositionComponentFilePath)} because it already exists`);
|
|
184
167
|
}
|
|
185
168
|
const input = (0, node_fs_1.readFileSync)(filePath, 'utf-8');
|
|
186
|
-
const
|
|
169
|
+
const result = await (0, apply_codemod_to_file_1.applyCodemodToFile)({
|
|
187
170
|
filePath,
|
|
188
171
|
codeMod: codemod,
|
|
189
172
|
});
|
|
190
|
-
const
|
|
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({
|
|
191
175
|
oldLines: input.split('\n'),
|
|
192
176
|
newLines: formatted.split('\n'),
|
|
193
177
|
});
|
|
194
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
|
+
}
|
|
195
190
|
const { entryType, undoMessage, redoMessage } = getCodemodUndoDescription(codemod);
|
|
196
191
|
const snapshots = [
|
|
197
192
|
{
|
|
@@ -209,7 +204,10 @@ const applyCodemodHandler = ({ input: { codemod, dryRun, symbolicatedStack, undo
|
|
|
209
204
|
if (componentFilePath === null) {
|
|
210
205
|
throw new Error('Could not determine the new component file path');
|
|
211
206
|
}
|
|
212
|
-
componentFileContents =
|
|
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
|
+
}
|
|
213
211
|
snapshots.push({
|
|
214
212
|
filePath: componentFilePath,
|
|
215
213
|
oldContents: null,
|
|
@@ -1,44 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.applyVisualControlHandler = void 0;
|
|
37
4
|
const node_fs_1 = require("node:fs");
|
|
5
|
+
const codemods_1 = require("@remotion/codemods");
|
|
38
6
|
const renderer_1 = require("@remotion/renderer");
|
|
39
|
-
const studio_codemods_1 = require("@remotion/studio-codemods");
|
|
40
|
-
const recast = __importStar(require("recast"));
|
|
41
|
-
const parse_ast_1 = require("../../codemods/parse-ast");
|
|
42
7
|
const file_watcher_1 = require("../../file-watcher");
|
|
43
8
|
const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside-project");
|
|
44
9
|
const format_log_file_location_1 = require("../format-log-file-location");
|
|
@@ -46,28 +11,10 @@ const live_events_1 = require("../live-events");
|
|
|
46
11
|
const undo_stack_1 = require("../undo-stack");
|
|
47
12
|
const watch_ignore_next_change_1 = require("../watch-ignore-next-change");
|
|
48
13
|
const source_file_write_queue_1 = require("./source-file-write-queue");
|
|
49
|
-
const getVisualControlChangeLine = (file, changeId) => {
|
|
50
|
-
let line = 1;
|
|
51
|
-
recast.types.visit(file.program, {
|
|
52
|
-
visitCallExpression(callPath) {
|
|
53
|
-
var _a;
|
|
54
|
-
var _b;
|
|
55
|
-
const { node } = callPath;
|
|
56
|
-
if (node.callee.type === 'Identifier' &&
|
|
57
|
-
node.callee.name === 'visualControl') {
|
|
58
|
-
const firstArg = node.arguments[0];
|
|
59
|
-
if ((firstArg === null || firstArg === void 0 ? void 0 : firstArg.type) === 'StringLiteral' && firstArg.value === changeId) {
|
|
60
|
-
line = (_b = (_a = node.loc) === null || _a === void 0 ? void 0 : _a.start.line) !== null && _b !== void 0 ? _b : 1;
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
this.traverse(callPath);
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
return line;
|
|
68
|
-
};
|
|
69
14
|
const applyVisualControlHandler = ({ input: { fileName, changes }, remotionRoot, logLevel }) => {
|
|
70
15
|
return (0, source_file_write_queue_1.withSourceFileWriteQueue)(() => {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
var _c, _d;
|
|
71
18
|
renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[apply-visual-control] Received request for ${fileName} with ${changes.length} changes`);
|
|
72
19
|
const { absolutePath } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
|
|
73
20
|
remotionRoot,
|
|
@@ -75,16 +22,17 @@ const applyVisualControlHandler = ({ input: { fileName, changes }, remotionRoot,
|
|
|
75
22
|
action: 'apply visual control change to',
|
|
76
23
|
});
|
|
77
24
|
const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
transformation: {
|
|
83
|
-
type: 'apply-visual-control',
|
|
84
|
-
changes,
|
|
85
|
-
},
|
|
25
|
+
const result = (0, codemods_1.updateVisualControls)({
|
|
26
|
+
project: { rootDir: remotionRoot, files: { [absolutePath]: fileContents } },
|
|
27
|
+
filePath: absolutePath,
|
|
28
|
+
changes,
|
|
86
29
|
});
|
|
87
|
-
|
|
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;
|
|
35
|
+
if (result.updatedControls.length === 0) {
|
|
88
36
|
throw new Error('No changes were made to the file');
|
|
89
37
|
}
|
|
90
38
|
(0, undo_stack_1.pushToUndoStack)({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CanUpdateDefaultPropsResponse } from '@remotion/studio-shared';
|
|
2
|
-
export
|
|
2
|
+
export declare const computeCanUpdateDefaultPropsFromContent: (content: string, compositionId: string) => CanUpdateDefaultPropsResponse;
|
|
3
3
|
export declare const checkIfTypeScriptFile: (file: string) => void;
|
|
4
4
|
export declare const computeCanUpdateDefaultProps: ({ compositionId, remotionRoot, entryPoint, }: {
|
|
5
5
|
compositionId: string;
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.computeCanUpdateDefaultProps = exports.checkIfTypeScriptFile = exports.computeCanUpdateDefaultPropsFromContent = void 0;
|
|
4
4
|
const node_fs_1 = require("node:fs");
|
|
5
|
-
const
|
|
5
|
+
const codemods_1 = require("@remotion/codemods");
|
|
6
6
|
const project_info_1 = require("../project-info");
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(exports, "computeCanUpdateDefaultPropsFromContent", { enumerable: true, get: function () { return studio_codemods_2.computeCanUpdateDefaultPropsFromContent; } });
|
|
7
|
+
({ computeCanUpdateDefaultPropsFromContent: exports.computeCanUpdateDefaultPropsFromContent } = codemods_1.CodemodsInternals);
|
|
9
8
|
const checkIfTypeScriptFile = (file) => {
|
|
10
9
|
if (!file.endsWith('.tsx') &&
|
|
11
10
|
!file.endsWith('.ts') &&
|
|
@@ -23,7 +22,7 @@ const computeCanUpdateDefaultProps = async ({ compositionId, remotionRoot, entry
|
|
|
23
22
|
}
|
|
24
23
|
(0, exports.checkIfTypeScriptFile)(projectInfo.rootFile);
|
|
25
24
|
const input = (0, node_fs_1.readFileSync)(projectInfo.rootFile, 'utf-8');
|
|
26
|
-
const result = (0,
|
|
25
|
+
const result = (0, exports.computeCanUpdateDefaultPropsFromContent)(input, compositionId);
|
|
27
26
|
return {
|
|
28
27
|
result,
|
|
29
28
|
rootFile: projectInfo.rootFile,
|
|
@@ -2,7 +2,6 @@ import type { Expression, File, JSXElement, JSXOpeningElement } from '@babel/typ
|
|
|
2
2
|
import type { SubscribeToSequencePropsResponse } from '@remotion/studio-shared';
|
|
3
3
|
import type { CanUpdateSequencePropsResponseTrue, CanUpdateSequencePropStatus, SequenceNodePath, VideoConfigValues } from 'remotion';
|
|
4
4
|
import { type VideoConfigIdentifierValues } from '../../helpers/video-config-values';
|
|
5
|
-
export declare const takeCachedSequencePropsStatusAst: (fileContents: string) => File | null;
|
|
6
5
|
type StaticValueOptions = {
|
|
7
6
|
allowSpecialValues: boolean;
|
|
8
7
|
};
|
|
@@ -41,15 +40,6 @@ export declare const resolveSequencePropsNodePathsFromFilename: ({ fileName, tar
|
|
|
41
40
|
}[];
|
|
42
41
|
remotionRoot: string;
|
|
43
42
|
}) => (SequenceNodePath | null)[];
|
|
44
|
-
export declare const computeSequencePropsStatusFromAst: ({ ast, nodePath, componentIdentity, keys, assetKeys, effects, videoConfigValues, }: {
|
|
45
|
-
ast: File;
|
|
46
|
-
nodePath: SequenceNodePath;
|
|
47
|
-
componentIdentity: string | null;
|
|
48
|
-
keys: string[];
|
|
49
|
-
assetKeys?: string[] | undefined;
|
|
50
|
-
effects: string[][];
|
|
51
|
-
videoConfigValues: VideoConfigValues | null;
|
|
52
|
-
}) => CanUpdateSequencePropsResponseTrue;
|
|
53
43
|
export declare const computeSequencePropsStatusFromContent: ({ fileContents, nodePath, componentIdentity, keys, assetKeys, effects, videoConfigValues, }: {
|
|
54
44
|
fileContents: string;
|
|
55
45
|
nodePath: SequenceNodePath;
|