@remotion/studio-server 4.0.535 → 4.0.537
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/helpers/resolve-composition-component.d.ts +1 -2
- package/dist/helpers/resolve-composition-component.js +1 -3
- package/dist/preview-server/api-routes.js +2 -0
- package/dist/preview-server/default-props-watchers.d.ts +3 -2
- package/dist/preview-server/default-props-watchers.js +48 -77
- package/dist/preview-server/routes/can-update-default-props.d.ts +9 -3
- package/dist/preview-server/routes/can-update-default-props.js +43 -10
- package/dist/preview-server/routes/insert-basic-captions.js +1 -2
- package/dist/preview-server/routes/insert-composition-element.js +14 -6
- package/dist/preview-server/routes/insert-element.js +1 -2
- package/dist/preview-server/routes/subscribe-to-default-props.js +2 -1
- package/dist/preview-server/routes/unsubscribe-from-sequence-props.d.ts +2 -2
- package/dist/preview-server/routes/unsubscribe-from-sequence-props.js +12 -10
- package/dist/preview-server/routes/unwrap-node.d.ts +3 -0
- package/dist/preview-server/routes/{wrap-jsx-node.js → unwrap-node.js} +24 -23
- package/dist/preview-server/routes/update-default-props.js +15 -15
- package/dist/preview-server/sequence-props-watchers.js +7 -2
- package/dist/preview-server/undo-stack.d.ts +1 -1
- 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-codemod-to-file.d.ts +0 -7
- package/dist/codemods/apply-codemod-to-file.js +0 -171
- 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.d.ts +0 -22
- package/dist/codemods/delete-jsx-node.js +0 -17
- package/dist/codemods/delete-jsx-nodes.d.ts +0 -13
- package/dist/codemods/delete-jsx-nodes.js +0 -10
- 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/insert-video-layers.d.ts +0 -11
- package/dist/codemods/insert-video-layers.js +0 -5
- 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-jsx-sequence.d.ts +0 -27
- package/dist/codemods/split-jsx-sequence.js +0 -19
- 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/open-browser-shortcut.d.ts +0 -9
- package/dist/open-browser-shortcut.js +0 -121
- package/dist/preview-server/hot-middleware/types.d.ts +0 -2
- package/dist/preview-server/hot-middleware/types.js +0 -2
- package/dist/preview-server/routes/apply-codemod.d.ts +0 -4
- package/dist/preview-server/routes/apply-codemod.js +0 -272
- package/dist/preview-server/routes/delete-jsx-node.d.ts +0 -3
- package/dist/preview-server/routes/delete-jsx-node.js +0 -126
- package/dist/preview-server/routes/delete-jsx-nodes.d.ts +0 -3
- package/dist/preview-server/routes/delete-jsx-nodes.js +0 -137
- package/dist/preview-server/routes/duplicate-jsx-node.d.ts +0 -3
- package/dist/preview-server/routes/duplicate-jsx-node.js +0 -118
- package/dist/preview-server/routes/insert-jsx-element.d.ts +0 -3
- package/dist/preview-server/routes/insert-jsx-element.js +0 -231
- package/dist/preview-server/routes/insert-video-layers.d.ts +0 -3
- package/dist/preview-server/routes/insert-video-layers.js +0 -68
- package/dist/preview-server/routes/split-jsx-sequence.d.ts +0 -3
- package/dist/preview-server/routes/split-jsx-sequence.js +0 -117
- package/dist/preview-server/routes/update-public-license.d.ts +0 -11
- package/dist/preview-server/routes/update-public-license.js +0 -97
- package/dist/preview-server/routes/wrap-jsx-node.d.ts +0 -3
|
@@ -12,13 +12,12 @@ export declare const resolveCompositionComponent: ({ remotionRoot, compositionFi
|
|
|
12
12
|
compositionFile: string;
|
|
13
13
|
compositionId: string;
|
|
14
14
|
}) => Promise<ResolvedCompositionComponent>;
|
|
15
|
-
export declare const insertJsxElementIntoComposition: ({ remotionRoot, compositionFile, compositionId, element, from,
|
|
15
|
+
export declare const insertJsxElementIntoComposition: ({ remotionRoot, compositionFile, compositionId, element, from, prettierConfigOverride, wrapInSequence, sourceFileOverrides, }: {
|
|
16
16
|
remotionRoot: string;
|
|
17
17
|
compositionFile: string;
|
|
18
18
|
compositionId: string;
|
|
19
19
|
element: InsertableCompositionElement;
|
|
20
20
|
from: number | null;
|
|
21
|
-
premountFor: number | null;
|
|
22
21
|
prettierConfigOverride: Record<string, unknown> | null;
|
|
23
22
|
wrapInSequence?: {
|
|
24
23
|
dimensions: {
|
|
@@ -40,7 +40,7 @@ const resolveCompositionComponent = ({ remotionRoot, compositionFile, compositio
|
|
|
40
40
|
environment: makeCodemodEnvironment(remotionRoot, null),
|
|
41
41
|
});
|
|
42
42
|
exports.resolveCompositionComponent = resolveCompositionComponent;
|
|
43
|
-
const insertJsxElementIntoComposition = async ({ remotionRoot, compositionFile, compositionId, element, from,
|
|
43
|
+
const insertJsxElementIntoComposition = async ({ remotionRoot, compositionFile, compositionId, element, from, prettierConfigOverride, wrapInSequence = null, sourceFileOverrides, }) => {
|
|
44
44
|
var _a;
|
|
45
45
|
var _b, _c;
|
|
46
46
|
const environment = makeCodemodEnvironment(remotionRoot, sourceFileOverrides);
|
|
@@ -61,7 +61,6 @@ const insertJsxElementIntoComposition = async ({ remotionRoot, compositionFile,
|
|
|
61
61
|
element,
|
|
62
62
|
environment,
|
|
63
63
|
from,
|
|
64
|
-
premountFor,
|
|
65
64
|
prettierConfigOverride,
|
|
66
65
|
wrapInSequence: sequence,
|
|
67
66
|
});
|
|
@@ -69,7 +68,6 @@ const insertJsxElementIntoComposition = async ({ remotionRoot, compositionFile,
|
|
|
69
68
|
const codemodElement = createElementFromInsertable({
|
|
70
69
|
element,
|
|
71
70
|
from,
|
|
72
|
-
premountFor,
|
|
73
71
|
wrapInSequence: sequence,
|
|
74
72
|
});
|
|
75
73
|
const location = await resolveCompositionComponentWithFileCodemod({
|
|
@@ -71,6 +71,7 @@ const unsubscribe_from_default_props_1 = require("./routes/unsubscribe-from-defa
|
|
|
71
71
|
const unsubscribe_from_file_existence_1 = require("./routes/unsubscribe-from-file-existence");
|
|
72
72
|
const unsubscribe_from_sequence_props_1 = require("./routes/unsubscribe-from-sequence-props");
|
|
73
73
|
const unwrap_folder_1 = require("./routes/unwrap-folder");
|
|
74
|
+
const unwrap_node_1 = require("./routes/unwrap-node");
|
|
74
75
|
const update_available_1 = require("./routes/update-available");
|
|
75
76
|
const update_composition_metadata_1 = require("./routes/update-composition-metadata");
|
|
76
77
|
const update_default_props_1 = require("./routes/update-default-props");
|
|
@@ -133,6 +134,7 @@ exports.allApiRoutes = {
|
|
|
133
134
|
'/api/paste-effects': paste_effects_1.pasteEffectsHandler,
|
|
134
135
|
'/api/delete-nodes': delete_nodes_1.deleteNodesHandler,
|
|
135
136
|
'/api/duplicate-nodes': duplicate_nodes_1.duplicateNodesHandler,
|
|
137
|
+
'/api/unwrap-node': unwrap_node_1.unwrapNodeHandler,
|
|
136
138
|
'/api/wrap-node': wrap_node_1.wrapNodeHandler,
|
|
137
139
|
'/api/precompose-jsx-nodes': precompose_jsx_nodes_1.precomposeJsxNodesHandler,
|
|
138
140
|
'/api/split-sequences': split_sequences_1.splitSequencesHandler,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { CanUpdateDefaultPropsResponse } from '@remotion/studio-shared';
|
|
2
|
-
export declare const subscribeToDefaultPropsWatchers: ({ compositionId, clientId, remotionRoot, entryPoint, }: {
|
|
1
|
+
import type { CanUpdateDefaultPropsResponse, SymbolicatedStackFrame } from '@remotion/studio-shared';
|
|
2
|
+
export declare const subscribeToDefaultPropsWatchers: ({ compositionId, clientId, symbolicatedStack, remotionRoot, entryPoint, }: {
|
|
3
3
|
compositionId: string;
|
|
4
4
|
clientId: string;
|
|
5
|
+
symbolicatedStack: SymbolicatedStackFrame | null;
|
|
5
6
|
remotionRoot: string;
|
|
6
7
|
entryPoint: string;
|
|
7
8
|
}) => Promise<CanUpdateDefaultPropsResponse>;
|
|
@@ -4,104 +4,75 @@ exports.unsubscribeClientDefaultPropsWatchers = exports.unsubscribeFromDefaultPr
|
|
|
4
4
|
const file_watcher_1 = require("../file-watcher");
|
|
5
5
|
const live_events_1 = require("./live-events");
|
|
6
6
|
const can_update_default_props_1 = require("./routes/can-update-default-props");
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
let watcherConfig = null;
|
|
13
|
-
const ensureGlobalWatcher = (rootFile) => {
|
|
14
|
-
if (globalWatcher) {
|
|
15
|
-
globalWatcher.refCount++;
|
|
7
|
+
// Each client watches its own resolved registration file or root-file fallback.
|
|
8
|
+
const watchers = {};
|
|
9
|
+
const removeClient = (compositionId, clientId) => {
|
|
10
|
+
const compositionWatchers = watchers[compositionId];
|
|
11
|
+
if (!compositionWatchers) {
|
|
16
12
|
return;
|
|
17
13
|
}
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
14
|
+
for (const [file, watcher] of compositionWatchers) {
|
|
15
|
+
watcher.clientIds.delete(clientId);
|
|
16
|
+
if (watcher.clientIds.size === 0) {
|
|
17
|
+
watcher.unwatch();
|
|
18
|
+
compositionWatchers.delete(file);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (compositionWatchers.size === 0) {
|
|
22
|
+
delete watchers[compositionId];
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const subscribeToDefaultPropsWatchers = async ({ compositionId, clientId, symbolicatedStack, remotionRoot, entryPoint, }) => {
|
|
26
|
+
var _a;
|
|
27
|
+
const { result, compositionFile } = await (0, can_update_default_props_1.computeCanUpdateDefaultProps)({
|
|
28
|
+
compositionId,
|
|
29
|
+
symbolicatedStack,
|
|
30
|
+
remotionRoot,
|
|
31
|
+
entryPoint,
|
|
32
|
+
});
|
|
33
|
+
// Remove from any previous subscription for this client+composition
|
|
34
|
+
removeClient(compositionId, clientId);
|
|
35
|
+
if (!compositionFile) {
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
(_a = watchers[compositionId]) !== null && _a !== void 0 ? _a : (watchers[compositionId] = new Map());
|
|
39
|
+
const compositionWatchers = watchers[compositionId];
|
|
40
|
+
if (!compositionWatchers.has(compositionFile)) {
|
|
41
|
+
const clientIds = new Set();
|
|
42
|
+
const { unwatch } = (0, file_watcher_1.installFileWatcher)({
|
|
43
|
+
file: compositionFile,
|
|
44
|
+
existenceOnly: false,
|
|
45
|
+
onChange: (event) => {
|
|
46
|
+
if (event.type === 'deleted') {
|
|
47
|
+
return;
|
|
32
48
|
}
|
|
33
|
-
const clientIds = [...subscriptions[compositionId]];
|
|
34
49
|
const newResult = (0, can_update_default_props_1.computeCanUpdateDefaultPropsFromContent)(event.content, compositionId);
|
|
50
|
+
const subscribedClientIds = [...clientIds];
|
|
35
51
|
(0, live_events_1.waitForLiveEventsListener)().then((listener) => {
|
|
36
52
|
const updateEvent = {
|
|
37
53
|
type: 'default-props-updatable-changed',
|
|
38
54
|
compositionId,
|
|
39
55
|
result: newResult,
|
|
40
56
|
};
|
|
41
|
-
for (const cId of
|
|
57
|
+
for (const cId of subscribedClientIds) {
|
|
42
58
|
listener.sendEventToClientId(cId, updateEvent);
|
|
43
59
|
}
|
|
44
60
|
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
globalWatcher = { unwatch, rootFile, refCount: 1 };
|
|
49
|
-
};
|
|
50
|
-
const releaseGlobalWatcher = () => {
|
|
51
|
-
if (!globalWatcher) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
globalWatcher.refCount--;
|
|
55
|
-
if (globalWatcher.refCount <= 0) {
|
|
56
|
-
globalWatcher.unwatch();
|
|
57
|
-
globalWatcher = null;
|
|
58
|
-
watcherConfig = null;
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
const subscribeToDefaultPropsWatchers = async ({ compositionId, clientId, remotionRoot, entryPoint, }) => {
|
|
62
|
-
var _a;
|
|
63
|
-
const { result, rootFile } = await (0, can_update_default_props_1.computeCanUpdateDefaultProps)({
|
|
64
|
-
compositionId,
|
|
65
|
-
remotionRoot,
|
|
66
|
-
entryPoint,
|
|
67
|
-
});
|
|
68
|
-
// Remove from any previous subscription for this client+composition
|
|
69
|
-
if ((_a = subscriptions[compositionId]) === null || _a === void 0 ? void 0 : _a.has(clientId)) {
|
|
70
|
-
subscriptions[compositionId].delete(clientId);
|
|
71
|
-
releaseGlobalWatcher();
|
|
72
|
-
}
|
|
73
|
-
if (rootFile) {
|
|
74
|
-
watcherConfig = { remotionRoot, entryPoint };
|
|
75
|
-
if (!subscriptions[compositionId]) {
|
|
76
|
-
subscriptions[compositionId] = new Set();
|
|
77
|
-
}
|
|
78
|
-
subscriptions[compositionId].add(clientId);
|
|
79
|
-
ensureGlobalWatcher(rootFile);
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
compositionWatchers.set(compositionFile, { unwatch, clientIds });
|
|
80
64
|
}
|
|
65
|
+
compositionWatchers.get(compositionFile).clientIds.add(clientId);
|
|
81
66
|
return result;
|
|
82
67
|
};
|
|
83
68
|
exports.subscribeToDefaultPropsWatchers = subscribeToDefaultPropsWatchers;
|
|
84
69
|
const unsubscribeFromDefaultPropsWatchers = ({ compositionId, clientId, }) => {
|
|
85
|
-
|
|
86
|
-
if (!((_a = subscriptions[compositionId]) === null || _a === void 0 ? void 0 : _a.has(clientId))) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
subscriptions[compositionId].delete(clientId);
|
|
90
|
-
if (subscriptions[compositionId].size === 0) {
|
|
91
|
-
delete subscriptions[compositionId];
|
|
92
|
-
}
|
|
93
|
-
releaseGlobalWatcher();
|
|
70
|
+
removeClient(compositionId, clientId);
|
|
94
71
|
};
|
|
95
72
|
exports.unsubscribeFromDefaultPropsWatchers = unsubscribeFromDefaultPropsWatchers;
|
|
96
73
|
const unsubscribeClientDefaultPropsWatchers = (clientId) => {
|
|
97
|
-
for (const compositionId of Object.keys(
|
|
98
|
-
|
|
99
|
-
subscriptions[compositionId].delete(clientId);
|
|
100
|
-
if (subscriptions[compositionId].size === 0) {
|
|
101
|
-
delete subscriptions[compositionId];
|
|
102
|
-
}
|
|
103
|
-
releaseGlobalWatcher();
|
|
104
|
-
}
|
|
74
|
+
for (const compositionId of Object.keys(watchers)) {
|
|
75
|
+
removeClient(compositionId, clientId);
|
|
105
76
|
}
|
|
106
77
|
};
|
|
107
78
|
exports.unsubscribeClientDefaultPropsWatchers = unsubscribeClientDefaultPropsWatchers;
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import type { CanUpdateDefaultPropsResponse } from '@remotion/studio-shared';
|
|
1
|
+
import type { CanUpdateDefaultPropsResponse, SymbolicatedStackFrame } from '@remotion/studio-shared';
|
|
2
2
|
export declare const computeCanUpdateDefaultPropsFromContent: (content: string, compositionId: string) => CanUpdateDefaultPropsResponse;
|
|
3
3
|
export declare const checkIfTypeScriptFile: (file: string) => void;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const getDefaultPropsFile: ({ symbolicatedStack, remotionRoot, entryPoint, }: {
|
|
5
|
+
symbolicatedStack: SymbolicatedStackFrame | null;
|
|
6
|
+
remotionRoot: string;
|
|
7
|
+
entryPoint: string;
|
|
8
|
+
}) => Promise<string>;
|
|
9
|
+
export declare const computeCanUpdateDefaultProps: ({ compositionId, symbolicatedStack, remotionRoot, entryPoint, }: {
|
|
5
10
|
compositionId: string;
|
|
11
|
+
symbolicatedStack: SymbolicatedStackFrame | null;
|
|
6
12
|
remotionRoot: string;
|
|
7
13
|
entryPoint: string;
|
|
8
14
|
}) => Promise<{
|
|
9
15
|
result: CanUpdateDefaultPropsResponse;
|
|
10
|
-
|
|
16
|
+
compositionFile: string | null;
|
|
11
17
|
}>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.computeCanUpdateDefaultProps = exports.checkIfTypeScriptFile = exports.computeCanUpdateDefaultPropsFromContent = void 0;
|
|
3
|
+
exports.computeCanUpdateDefaultProps = exports.getDefaultPropsFile = exports.checkIfTypeScriptFile = exports.computeCanUpdateDefaultPropsFromContent = void 0;
|
|
4
4
|
const node_fs_1 = require("node:fs");
|
|
5
5
|
const codemods_1 = require("@remotion/codemods");
|
|
6
|
+
const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside-project");
|
|
6
7
|
const project_info_1 = require("../project-info");
|
|
7
8
|
({ computeCanUpdateDefaultPropsFromContent: exports.computeCanUpdateDefaultPropsFromContent } = codemods_1.CodemodsInternals);
|
|
8
9
|
const checkIfTypeScriptFile = (file) => {
|
|
@@ -14,18 +15,50 @@ const checkIfTypeScriptFile = (file) => {
|
|
|
14
15
|
}
|
|
15
16
|
};
|
|
16
17
|
exports.checkIfTypeScriptFile = checkIfTypeScriptFile;
|
|
17
|
-
|
|
18
|
+
// Compositions can be registered in files imported by the root file. The
|
|
19
|
+
// client sends the location of the registration, otherwise use the root file.
|
|
20
|
+
const getDefaultPropsFile = async ({ symbolicatedStack, remotionRoot, entryPoint, }) => {
|
|
21
|
+
if (symbolicatedStack === null || symbolicatedStack === void 0 ? void 0 : symbolicatedStack.originalFileName) {
|
|
22
|
+
return (0, resolve_file_inside_project_1.resolveFileInsideProject)({
|
|
23
|
+
remotionRoot,
|
|
24
|
+
fileName: symbolicatedStack.originalFileName,
|
|
25
|
+
action: 'update default props in',
|
|
26
|
+
}).absolutePath;
|
|
27
|
+
}
|
|
28
|
+
const { rootFile } = await (0, project_info_1.getProjectInfo)(remotionRoot, entryPoint);
|
|
29
|
+
if (!rootFile) {
|
|
30
|
+
throw new Error('Cannot find root file in project');
|
|
31
|
+
}
|
|
32
|
+
return rootFile;
|
|
33
|
+
};
|
|
34
|
+
exports.getDefaultPropsFile = getDefaultPropsFile;
|
|
35
|
+
const computeCanUpdateDefaultProps = async ({ compositionId, symbolicatedStack, remotionRoot, entryPoint, }) => {
|
|
18
36
|
try {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
37
|
+
const compositionFile = await (0, exports.getDefaultPropsFile)({
|
|
38
|
+
symbolicatedStack,
|
|
39
|
+
remotionRoot,
|
|
40
|
+
entryPoint,
|
|
41
|
+
});
|
|
42
|
+
(0, exports.checkIfTypeScriptFile)(compositionFile);
|
|
43
|
+
const input = (0, node_fs_1.readFileSync)(compositionFile, 'utf-8');
|
|
25
44
|
const result = (0, exports.computeCanUpdateDefaultPropsFromContent)(input, compositionId);
|
|
45
|
+
if (!result.canUpdate &&
|
|
46
|
+
!(symbolicatedStack === null || symbolicatedStack === void 0 ? void 0 : symbolicatedStack.originalFileName) &&
|
|
47
|
+
codemods_1.CodemodsInternals.getCompositionFile({
|
|
48
|
+
compositionId,
|
|
49
|
+
project: { files: { [compositionFile]: input }, rootDir: remotionRoot },
|
|
50
|
+
}) === null) {
|
|
51
|
+
return {
|
|
52
|
+
result: {
|
|
53
|
+
canUpdate: false,
|
|
54
|
+
reason: `Could not determine which file registers this composition, checked the root file: ${result.reason}`,
|
|
55
|
+
},
|
|
56
|
+
compositionFile,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
26
59
|
return {
|
|
27
60
|
result,
|
|
28
|
-
|
|
61
|
+
compositionFile,
|
|
29
62
|
};
|
|
30
63
|
}
|
|
31
64
|
catch (err) {
|
|
@@ -34,7 +67,7 @@ const computeCanUpdateDefaultProps = async ({ compositionId, remotionRoot, entry
|
|
|
34
67
|
canUpdate: false,
|
|
35
68
|
reason: err.message,
|
|
36
69
|
},
|
|
37
|
-
|
|
70
|
+
compositionFile: null,
|
|
38
71
|
};
|
|
39
72
|
}
|
|
40
73
|
};
|
|
@@ -11,7 +11,7 @@ const sequence_node_path_mutation_1 = require("../sequence-node-path-mutation");
|
|
|
11
11
|
const undo_stack_1 = require("../undo-stack");
|
|
12
12
|
const source_file_write_queue_1 = require("./source-file-write-queue");
|
|
13
13
|
const { basicCaptionsElementSource, getBasicCaptionsElementFile, insertBasicCaptions, } = codemods_1.CodemodsInternals;
|
|
14
|
-
const insertBasicCaptionsHandler = ({ input: { fileName, nodePath, captions, durationInFrames
|
|
14
|
+
const insertBasicCaptionsHandler = ({ input: { fileName, nodePath, captions, durationInFrames }, remotionRoot, logLevel, }) => (0, source_file_write_queue_1.withSourceFileWriteQueue)(() => {
|
|
15
15
|
var _a;
|
|
16
16
|
try {
|
|
17
17
|
const { absolutePath } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
|
|
@@ -50,7 +50,6 @@ const insertBasicCaptionsHandler = ({ input: { fileName, nodePath, captions, dur
|
|
|
50
50
|
nodePath,
|
|
51
51
|
captions,
|
|
52
52
|
durationInFrames,
|
|
53
|
-
premountFor,
|
|
54
53
|
importPath: elementFile.importPath,
|
|
55
54
|
});
|
|
56
55
|
const nodePathMutation = (0, sequence_node_path_mutation_1.broadcastSequenceNodePathMutation)([{ absolutePath, remappings: nodePathRemappings }], null);
|
|
@@ -54,6 +54,16 @@ const validateElement = (element, remotionRoot) => {
|
|
|
54
54
|
validateDimension('height', element.height);
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
|
+
if (element.type === 'text') {
|
|
58
|
+
if (typeof element.text !== 'string' || element.text.trim() === '') {
|
|
59
|
+
throw new Error('Text must be a non-empty string');
|
|
60
|
+
}
|
|
61
|
+
validateDimension('fontSize', element.fontSize);
|
|
62
|
+
if (typeof element.color !== 'string' || element.color.trim() === '') {
|
|
63
|
+
throw new Error('Text color must be a non-empty string');
|
|
64
|
+
}
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
57
67
|
if (element.type === 'svg') {
|
|
58
68
|
if (typeof element.markup !== 'string' || element.markup.trim() === '') {
|
|
59
69
|
throw new Error('SVG markup must be a non-empty string');
|
|
@@ -118,6 +128,9 @@ const validateElement = (element, remotionRoot) => {
|
|
|
118
128
|
throw new Error('Unsupported element type');
|
|
119
129
|
};
|
|
120
130
|
const getElementLabel = (element) => {
|
|
131
|
+
if (element.type === 'text') {
|
|
132
|
+
return '<Interactive.Div>';
|
|
133
|
+
}
|
|
121
134
|
if (element.type === 'solid') {
|
|
122
135
|
return '<Solid>';
|
|
123
136
|
}
|
|
@@ -149,17 +162,13 @@ const getElementLabel = (element) => {
|
|
|
149
162
|
}
|
|
150
163
|
throw new Error('Unsupported element type');
|
|
151
164
|
};
|
|
152
|
-
const insertCompositionElementHandler = ({ input: { compositionFile, compositionId, element, from
|
|
165
|
+
const insertCompositionElementHandler = ({ input: { compositionFile, compositionId, element, from }, remotionRoot, logLevel, }) => (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
|
|
153
166
|
try {
|
|
154
167
|
validateElement(element, remotionRoot);
|
|
155
168
|
if (from !== null &&
|
|
156
169
|
(!Number.isInteger(from) || !Number.isFinite(from) || from < 0)) {
|
|
157
170
|
throw new Error('from must be a non-negative integer');
|
|
158
171
|
}
|
|
159
|
-
if (premountFor !== null &&
|
|
160
|
-
(!Number.isInteger(premountFor) || premountFor < 0)) {
|
|
161
|
-
throw new Error('premountFor must be a non-negative integer');
|
|
162
|
-
}
|
|
163
172
|
const elementLabel = getElementLabel(element);
|
|
164
173
|
renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[insert-composition-element] Received request for compositionFile="${compositionFile}" compositionId="${compositionId}" element="${element.type}"`);
|
|
165
174
|
const { fileName, source, oldContents, output, insertedNodePath, logLine, nodePathRemappings, } = await (0, resolve_composition_component_1.insertJsxElementIntoComposition)({
|
|
@@ -168,7 +177,6 @@ const insertCompositionElementHandler = ({ input: { compositionFile, composition
|
|
|
168
177
|
compositionId,
|
|
169
178
|
element,
|
|
170
179
|
from,
|
|
171
|
-
premountFor,
|
|
172
180
|
prettierConfigOverride: null,
|
|
173
181
|
sourceFileOverrides: null,
|
|
174
182
|
});
|
|
@@ -34,7 +34,7 @@ const hasExpectedFileState = ({ expected, actual, }) => {
|
|
|
34
34
|
}
|
|
35
35
|
return actual.sourceHash === expected.sourceHash;
|
|
36
36
|
};
|
|
37
|
-
const insertElementHandler = async ({ input: { compositionFile, compositionId, captionTarget, element, installationName, expectedFileState, from,
|
|
37
|
+
const insertElementHandler = async ({ input: { compositionFile, compositionId, captionTarget, element, installationName, expectedFileState, from, position, overwriteExisting, undoRedoNavigation, newComposition, }, entryPoint, remotionRoot, logLevel, publicDir, }) => {
|
|
38
38
|
var _a;
|
|
39
39
|
let resolvedAssets;
|
|
40
40
|
try {
|
|
@@ -237,7 +237,6 @@ const insertElementHandler = async ({ input: { compositionFile, compositionId, c
|
|
|
237
237
|
position: componentOwnsSequence ? position : null,
|
|
238
238
|
},
|
|
239
239
|
from: componentOwnsSequence ? from : null,
|
|
240
|
-
premountFor,
|
|
241
240
|
prettierConfigOverride: null,
|
|
242
241
|
wrapInSequence: componentOwnsSequence
|
|
243
242
|
? null
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.subscribeToDefaultProps = void 0;
|
|
4
4
|
const default_props_watchers_1 = require("../default-props-watchers");
|
|
5
|
-
const subscribeToDefaultProps = ({ input: { compositionId, clientId }, remotionRoot, entryPoint }) => {
|
|
5
|
+
const subscribeToDefaultProps = ({ input: { compositionId, clientId, symbolicatedStack }, remotionRoot, entryPoint, }) => {
|
|
6
6
|
return (0, default_props_watchers_1.subscribeToDefaultPropsWatchers)({
|
|
7
7
|
compositionId,
|
|
8
8
|
clientId,
|
|
9
|
+
symbolicatedStack,
|
|
9
10
|
remotionRoot,
|
|
10
11
|
entryPoint,
|
|
11
12
|
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { UnsubscribeFromSequencePropsBatchRequest } from '@remotion/studio-shared';
|
|
2
2
|
import type { ApiHandler } from '../api-types';
|
|
3
|
-
export declare const unsubscribeFromSequenceProps: ApiHandler<
|
|
3
|
+
export declare const unsubscribeFromSequenceProps: ApiHandler<UnsubscribeFromSequencePropsBatchRequest, undefined>;
|
|
@@ -2,16 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.unsubscribeFromSequenceProps = void 0;
|
|
4
4
|
const sequence_props_watchers_1 = require("../sequence-props-watchers");
|
|
5
|
-
const unsubscribeFromSequenceProps = ({ input
|
|
6
|
-
(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
const unsubscribeFromSequenceProps = ({ input, remotionRoot }) => {
|
|
6
|
+
for (const { fileName, nodePath, clientId, sequenceKeys, assetKeys = [], effectKeys, } of input.requests) {
|
|
7
|
+
(0, sequence_props_watchers_1.unsubscribeFromSequencePropsWatchers)({
|
|
8
|
+
fileName,
|
|
9
|
+
nodePath: nodePath.nodePath,
|
|
10
|
+
remotionRoot,
|
|
11
|
+
clientId,
|
|
12
|
+
sequenceKeys,
|
|
13
|
+
assetKeys,
|
|
14
|
+
effectKeys,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
15
17
|
return Promise.resolve(undefined);
|
|
16
18
|
};
|
|
17
19
|
exports.unsubscribeFromSequenceProps = unsubscribeFromSequenceProps;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.unwrapNodeHandler = void 0;
|
|
4
4
|
const node_fs_1 = require("node:fs");
|
|
5
5
|
const codemods_1 = require("@remotion/codemods");
|
|
6
6
|
const renderer_1 = require("@remotion/renderer");
|
|
@@ -10,7 +10,7 @@ const format_log_file_location_1 = require("../format-log-file-location");
|
|
|
10
10
|
const sequence_node_path_mutation_1 = require("../sequence-node-path-mutation");
|
|
11
11
|
const undo_stack_1 = require("../undo-stack");
|
|
12
12
|
const source_file_write_queue_1 = require("./source-file-write-queue");
|
|
13
|
-
const
|
|
13
|
+
const unwrapNodeHandler = ({ input: { fileName, compositionId, nodePath, dryRun }, remotionRoot, logLevel, }) => {
|
|
14
14
|
return (0, source_file_write_queue_1.withSourceFileWriteQueue)(() => {
|
|
15
15
|
var _a;
|
|
16
16
|
try {
|
|
@@ -20,33 +20,34 @@ const wrapJsxNodeHandler = ({ input: { fileName, nodePath, wrapper, width, heigh
|
|
|
20
20
|
action: 'modify',
|
|
21
21
|
});
|
|
22
22
|
const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
|
|
23
|
-
const
|
|
24
|
-
if (
|
|
23
|
+
const canUnwrap = (0, codemods_1.canUnwrapNode)({ input: fileContents, nodePath });
|
|
24
|
+
if (dryRun) {
|
|
25
25
|
return Promise.resolve({
|
|
26
26
|
success: true,
|
|
27
|
-
|
|
27
|
+
canUnwrap,
|
|
28
28
|
nodePathMutation: null,
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
(wrapper === 'HtmlInCanvas' && !eligibility.canWrapHtmlInCanvas)) {
|
|
33
|
-
throw new Error('This JSX element cannot be wrapped');
|
|
34
|
-
}
|
|
35
|
-
const result = (0, codemods_1.wrapJsxNode)({
|
|
31
|
+
const result = (0, codemods_1.unwrapNode)({
|
|
36
32
|
project: { files: { [absolutePath]: fileContents }, rootDir: remotionRoot },
|
|
37
33
|
node: { filePath: absolutePath, nodePath },
|
|
38
|
-
wrapper,
|
|
39
|
-
width: width !== null && width !== void 0 ? width : 0,
|
|
40
|
-
height: height !== null && height !== void 0 ? height : 0,
|
|
41
34
|
});
|
|
42
35
|
const change = result.changes.find(({ filePath }) => filePath === absolutePath);
|
|
43
36
|
if ((change === null || change === void 0 ? void 0 : change.previousContents) !== fileContents ||
|
|
44
37
|
change.nextContents === null) {
|
|
45
|
-
throw new Error('Could not
|
|
38
|
+
throw new Error('Could not unwrap JSX node');
|
|
46
39
|
}
|
|
47
40
|
const output = change.nextContents;
|
|
48
|
-
const remappings = result.nodePathRemappings.map(({ oldNodePath, newNodePath }) => ({
|
|
49
|
-
|
|
41
|
+
const remappings = result.nodePathRemappings.map(({ oldNodePath, newNodePath, oldJsxName, newJsxName }) => ({
|
|
42
|
+
oldNodePath,
|
|
43
|
+
newNodePath,
|
|
44
|
+
oldJsxName,
|
|
45
|
+
newJsxName,
|
|
46
|
+
}));
|
|
47
|
+
const { childNodePath } = result;
|
|
48
|
+
const nodePathMutation = (0, sequence_node_path_mutation_1.broadcastSequenceNodePathMutation)([{ absolutePath, remappings }], childNodePath !== null
|
|
49
|
+
? { compositionId, absolutePath, nodePath: childNodePath }
|
|
50
|
+
: null);
|
|
50
51
|
const line = result.logLine;
|
|
51
52
|
(0, undo_stack_1.pushTransactionToUndoStack)({
|
|
52
53
|
snapshots: [
|
|
@@ -61,10 +62,10 @@ const wrapJsxNodeHandler = ({ input: { fileName, nodePath, wrapper, width, heigh
|
|
|
61
62
|
logLevel,
|
|
62
63
|
remotionRoot,
|
|
63
64
|
description: {
|
|
64
|
-
undoMessage:
|
|
65
|
-
redoMessage:
|
|
65
|
+
undoMessage: '↩️ Unwrapping JSX',
|
|
66
|
+
redoMessage: '↪️ Unwrapping JSX',
|
|
66
67
|
},
|
|
67
|
-
entryType: '
|
|
68
|
+
entryType: 'unwrap-node',
|
|
68
69
|
suppressHmrOnFileRestore: false,
|
|
69
70
|
undoRedoNavigation: null,
|
|
70
71
|
});
|
|
@@ -80,10 +81,10 @@ const wrapJsxNodeHandler = ({ input: { fileName, nodePath, wrapper, width, heigh
|
|
|
80
81
|
absolutePath,
|
|
81
82
|
line,
|
|
82
83
|
});
|
|
83
|
-
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${(0, source_file_write_queue_1.getCodemodTimingPrefix)(logLevel)}${renderer_1.RenderInternals.chalk.blueBright(locationLabel)}
|
|
84
|
-
renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `[
|
|
84
|
+
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${(0, source_file_write_queue_1.getCodemodTimingPrefix)(logLevel)}${renderer_1.RenderInternals.chalk.blueBright(locationLabel)} Unwrapped JSX`);
|
|
85
|
+
renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `[unwrap-node] Wrote ${fileRelativeToRoot}`);
|
|
85
86
|
(0, undo_stack_1.printUndoHint)(logLevel);
|
|
86
|
-
return Promise.resolve({ success: true,
|
|
87
|
+
return Promise.resolve({ success: true, canUnwrap, nodePathMutation });
|
|
87
88
|
}
|
|
88
89
|
catch (err) {
|
|
89
90
|
return Promise.resolve({
|
|
@@ -94,4 +95,4 @@ const wrapJsxNodeHandler = ({ input: { fileName, nodePath, wrapper, width, heigh
|
|
|
94
95
|
}
|
|
95
96
|
});
|
|
96
97
|
};
|
|
97
|
-
exports.
|
|
98
|
+
exports.unwrapNodeHandler = unwrapNodeHandler;
|
|
@@ -6,29 +6,29 @@ const codemods_1 = require("@remotion/codemods");
|
|
|
6
6
|
const renderer_1 = require("@remotion/renderer");
|
|
7
7
|
const file_watcher_1 = require("../../file-watcher");
|
|
8
8
|
const format_log_file_location_1 = require("../format-log-file-location");
|
|
9
|
-
const project_info_1 = require("../project-info");
|
|
10
9
|
const undo_stack_1 = require("../undo-stack");
|
|
11
10
|
const watch_ignore_next_change_1 = require("../watch-ignore-next-change");
|
|
12
11
|
const can_update_default_props_1 = require("./can-update-default-props");
|
|
13
12
|
const source_file_write_queue_1 = require("./source-file-write-queue");
|
|
14
|
-
const updateDefaultPropsHandler = ({ input: { compositionId, defaultProps, enumPaths }, remotionRoot, entryPoint, logLevel, }) => {
|
|
13
|
+
const updateDefaultPropsHandler = ({ input: { compositionId, defaultProps, enumPaths, symbolicatedStack }, remotionRoot, entryPoint, logLevel, }) => {
|
|
15
14
|
return (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
|
|
16
15
|
var _a;
|
|
17
16
|
var _b;
|
|
18
17
|
try {
|
|
19
18
|
renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[update-default-props] Received request for compositionId="${compositionId}"`);
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
const compositionFile = await (0, can_update_default_props_1.getDefaultPropsFile)({
|
|
20
|
+
symbolicatedStack,
|
|
21
|
+
remotionRoot,
|
|
22
|
+
entryPoint,
|
|
23
|
+
});
|
|
24
|
+
(0, can_update_default_props_1.checkIfTypeScriptFile)(compositionFile);
|
|
25
|
+
const fileContents = (0, node_fs_1.readFileSync)(compositionFile, 'utf-8');
|
|
26
26
|
const result = (0, codemods_1.setCompositionDefaultProps)({
|
|
27
27
|
project: {
|
|
28
|
-
files: { [
|
|
28
|
+
files: { [compositionFile]: fileContents },
|
|
29
29
|
rootDir: remotionRoot,
|
|
30
30
|
},
|
|
31
|
-
compositionFile
|
|
31
|
+
compositionFile,
|
|
32
32
|
compositionId,
|
|
33
33
|
defaultProps: JSON.parse(defaultProps),
|
|
34
34
|
enumPaths,
|
|
@@ -36,7 +36,7 @@ const updateDefaultPropsHandler = ({ input: { compositionId, defaultProps, enumP
|
|
|
36
36
|
const { logLine } = result;
|
|
37
37
|
const output = (_b = (_a = result.changes[0]) === null || _a === void 0 ? void 0 : _a.nextContents) !== null && _b !== void 0 ? _b : fileContents;
|
|
38
38
|
(0, undo_stack_1.pushToUndoStack)({
|
|
39
|
-
filePath:
|
|
39
|
+
filePath: compositionFile,
|
|
40
40
|
oldContents: fileContents,
|
|
41
41
|
newContents: null,
|
|
42
42
|
logLevel,
|
|
@@ -50,17 +50,17 @@ const updateDefaultPropsHandler = ({ input: { compositionId, defaultProps, enumP
|
|
|
50
50
|
suppressHmrOnFileRestore: true,
|
|
51
51
|
nodePathRemappings: null,
|
|
52
52
|
});
|
|
53
|
-
(0, undo_stack_1.suppressUndoStackInvalidation)(
|
|
54
|
-
(0, watch_ignore_next_change_1.suppressBundlerUpdateForFile)(
|
|
53
|
+
(0, undo_stack_1.suppressUndoStackInvalidation)(compositionFile);
|
|
54
|
+
(0, watch_ignore_next_change_1.suppressBundlerUpdateForFile)(compositionFile);
|
|
55
55
|
(0, file_watcher_1.writeFileAndNotifyFileWatchers)({
|
|
56
|
-
file:
|
|
56
|
+
file: compositionFile,
|
|
57
57
|
content: output,
|
|
58
58
|
originatorClientId: undefined,
|
|
59
59
|
metadata: null,
|
|
60
60
|
});
|
|
61
61
|
const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
|
|
62
62
|
remotionRoot,
|
|
63
|
-
absolutePath:
|
|
63
|
+
absolutePath: compositionFile,
|
|
64
64
|
line: logLine,
|
|
65
65
|
});
|
|
66
66
|
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${(0, source_file_write_queue_1.getCodemodTimingPrefix)(logLevel)}${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Updated default props for "${compositionId}"`);
|