@remotion/studio 4.0.133 → 4.0.135
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/.turbo/turbo-build.log +1 -1
- package/dist/components/AssetSelectorItem.js +3 -9
- package/dist/components/CompositionSelectorItem.js +58 -16
- package/dist/components/CopyButton.js +1 -1
- package/dist/components/CurrentCompositionSideEffects.js +2 -2
- package/dist/components/Editor.js +1 -1
- package/dist/components/GlobalKeybindings.js +2 -4
- package/dist/components/KeyboardShortcutsExplainer.js +1 -1
- package/dist/components/Modals.js +4 -2
- package/dist/components/NewComposition/CodemodFooter.d.ts +13 -0
- package/dist/components/NewComposition/CodemodFooter.js +124 -0
- package/dist/components/NewComposition/DeleteComposition.d.ts +4 -0
- package/dist/components/NewComposition/DeleteComposition.js +34 -0
- package/dist/components/NewComposition/DiffPreview.d.ts +14 -0
- package/dist/components/NewComposition/DiffPreview.js +19 -0
- package/dist/components/{PlayerEmitterContext.d.ts → NewComposition/DismissableModal.d.ts} +1 -1
- package/dist/components/NewComposition/DismissableModal.js +15 -0
- package/dist/components/NewComposition/DuplicateComposition.d.ts +4 -0
- package/dist/components/NewComposition/DuplicateComposition.js +177 -0
- package/dist/components/NewComposition/NewCompDuration.d.ts +2 -3
- package/dist/components/NewComposition/NewCompDuration.js +7 -7
- package/dist/components/NewComposition/RenameComposition.d.ts +4 -0
- package/dist/components/NewComposition/RenameComposition.js +52 -0
- package/dist/components/Notifications/Notification.d.ts +1 -1
- package/dist/components/Notifications/Notification.js +3 -0
- package/dist/components/Notifications/NotificationCenter.d.ts +3 -10
- package/dist/components/Notifications/NotificationCenter.js +24 -8
- package/dist/components/OpenEditorButton.js +2 -2
- package/dist/components/QuickSwitcher/QuickSwitcher.js +2 -9
- package/dist/components/RenderModal/DataEditor.js +5 -5
- package/dist/components/RenderModal/RenderModal.js +21 -62
- package/dist/components/RenderModal/RenderStatusModal.js +2 -2
- package/dist/components/RenderModal/ResolveCompositionBeforeModal.d.ts +15 -0
- package/dist/components/RenderModal/ResolveCompositionBeforeModal.js +83 -0
- package/dist/components/RenderQueue/RenderQueueCopyToClipboard.js +2 -8
- package/dist/components/RenderQueue/RenderQueueItemCancelButton.js +1 -1
- package/dist/components/RenderQueue/RenderQueueOpenInFolder.js +1 -1
- package/dist/components/RenderQueue/RenderQueueRemoveItem.js +2 -8
- package/dist/components/RenderQueue/actions.d.ts +7 -1
- package/dist/components/RenderQueue/actions.js +13 -1
- package/dist/components/Timeline/TimelineStack/index.js +1 -1
- package/dist/components/UpdateModal/UpdateModal.js +3 -8
- package/dist/components/utils.js +4 -25
- package/dist/helpers/client-id.js +1 -1
- package/dist/helpers/pick-color.js +3 -15
- package/dist/helpers/use-menu-structure.js +4 -49
- package/dist/helpers/validate-new-comp-data.d.ts +2 -2
- package/dist/helpers/validate-new-comp-data.js +3 -3
- package/dist/hot-middleware-client/process-update.js +1 -7
- package/dist/state/modals.d.ts +8 -3
- package/package.json +7 -7
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/components/PlayerEmitterContext.js +0 -11
- package/dist/components/RenderModal/RenderModalInput.d.ts +0 -12
- package/dist/components/RenderModal/RenderModalInput.js +0 -13
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DuplicateComposition = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const remotion_1 = require("remotion");
|
|
7
|
+
const validate_new_comp_data_1 = require("../../helpers/validate-new-comp-data");
|
|
8
|
+
const layout_1 = require("../layout");
|
|
9
|
+
const ModalHeader_1 = require("../ModalHeader");
|
|
10
|
+
const layout_2 = require("../RenderModal/layout");
|
|
11
|
+
const ResolveCompositionBeforeModal_1 = require("../RenderModal/ResolveCompositionBeforeModal");
|
|
12
|
+
const CodemodFooter_1 = require("./CodemodFooter");
|
|
13
|
+
const ComboBox_1 = require("./ComboBox");
|
|
14
|
+
const DismissableModal_1 = require("./DismissableModal");
|
|
15
|
+
const InputDragger_1 = require("./InputDragger");
|
|
16
|
+
const NewCompDuration_1 = require("./NewCompDuration");
|
|
17
|
+
const RemInput_1 = require("./RemInput");
|
|
18
|
+
const ValidationMessage_1 = require("./ValidationMessage");
|
|
19
|
+
const content = {
|
|
20
|
+
padding: 12,
|
|
21
|
+
paddingRight: 12,
|
|
22
|
+
flex: 1,
|
|
23
|
+
fontSize: 13,
|
|
24
|
+
minWidth: 500,
|
|
25
|
+
};
|
|
26
|
+
const comboBoxStyle = {
|
|
27
|
+
width: 190,
|
|
28
|
+
};
|
|
29
|
+
const DuplicateCompositionLoaded = () => {
|
|
30
|
+
const context = (0, react_1.useContext)(ResolveCompositionBeforeModal_1.ResolvedCompositionContext);
|
|
31
|
+
if (!context) {
|
|
32
|
+
throw new Error('Resolved composition context');
|
|
33
|
+
}
|
|
34
|
+
const { resolved, unresolved } = context;
|
|
35
|
+
const initialCompType = resolved.result.durationInFrames === 1 ? 'still' : 'composition';
|
|
36
|
+
const hadDimensionsDefined = unresolved.width && unresolved.height;
|
|
37
|
+
const hadFpsDefined = unresolved.fps !== undefined;
|
|
38
|
+
const hadDurationDefined = unresolved.durationInFrames !== undefined;
|
|
39
|
+
const [selectedFrameRate, setFrameRate] = (0, react_1.useState)(resolved.result.fps);
|
|
40
|
+
const { compositions } = (0, react_1.useContext)(remotion_1.Internals.CompositionManager);
|
|
41
|
+
const [type, setType] = (0, react_1.useState)(initialCompType);
|
|
42
|
+
const [newId, setName] = (0, react_1.useState)(() => {
|
|
43
|
+
var _a;
|
|
44
|
+
const numberAtEnd = (_a = resolved.result.id.match(/([0-9]+)$/)) === null || _a === void 0 ? void 0 : _a[0];
|
|
45
|
+
let prefix = numberAtEnd ? Number(numberAtEnd) : 1;
|
|
46
|
+
const initialName = resolved.result.id.replace(/([0-9]+)$/, '');
|
|
47
|
+
let currentName = initialName;
|
|
48
|
+
// eslint-disable-next-line no-constant-condition
|
|
49
|
+
while (true) {
|
|
50
|
+
currentName = initialName + prefix;
|
|
51
|
+
const err = (0, validate_new_comp_data_1.validateCompositionName)(currentName, compositions);
|
|
52
|
+
if (!err) {
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
prefix++;
|
|
56
|
+
}
|
|
57
|
+
return currentName;
|
|
58
|
+
});
|
|
59
|
+
const [size, setSize] = (0, react_1.useState)(() => ({
|
|
60
|
+
width: resolved.result.width,
|
|
61
|
+
height: resolved.result.height,
|
|
62
|
+
}));
|
|
63
|
+
const [durationInFrames, setDurationInFrames] = (0, react_1.useState)(resolved.result.durationInFrames);
|
|
64
|
+
const onTypeChanged = (0, react_1.useCallback)((newType) => {
|
|
65
|
+
setType(newType);
|
|
66
|
+
}, []);
|
|
67
|
+
const onWidthChanged = (0, react_1.useCallback)((newValue) => {
|
|
68
|
+
setSize((s) => {
|
|
69
|
+
const { height } = s;
|
|
70
|
+
const newWidth = Number(newValue);
|
|
71
|
+
return {
|
|
72
|
+
height,
|
|
73
|
+
width: newWidth,
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
}, []);
|
|
77
|
+
const onWidthDirectlyChanged = (0, react_1.useCallback)((newWidth) => {
|
|
78
|
+
setSize((s) => {
|
|
79
|
+
const { height } = s;
|
|
80
|
+
return {
|
|
81
|
+
height,
|
|
82
|
+
width: newWidth,
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
}, []);
|
|
86
|
+
const onHeightDirectlyChanged = (0, react_1.useCallback)((newHeight) => {
|
|
87
|
+
setSize((s) => {
|
|
88
|
+
const { width } = s;
|
|
89
|
+
return {
|
|
90
|
+
width,
|
|
91
|
+
height: newHeight,
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
}, []);
|
|
95
|
+
const onHeightChanged = (0, react_1.useCallback)((newValue) => {
|
|
96
|
+
setSize((s) => {
|
|
97
|
+
const { width } = s;
|
|
98
|
+
const newHeight = Number(newValue);
|
|
99
|
+
return {
|
|
100
|
+
width,
|
|
101
|
+
height: newHeight,
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
}, []);
|
|
105
|
+
const onNameChange = (0, react_1.useCallback)((e) => {
|
|
106
|
+
setName(e.target.value);
|
|
107
|
+
}, []);
|
|
108
|
+
const onTextFpsChange = (0, react_1.useCallback)((newFps) => {
|
|
109
|
+
setFrameRate(Number(newFps));
|
|
110
|
+
}, []);
|
|
111
|
+
const onFpsChange = (0, react_1.useCallback)((newFps) => {
|
|
112
|
+
setFrameRate(newFps);
|
|
113
|
+
}, []);
|
|
114
|
+
const compNameErrMessage = (0, validate_new_comp_data_1.validateCompositionName)(newId, compositions);
|
|
115
|
+
const compWidthErrMessage = (0, validate_new_comp_data_1.validateCompositionDimension)('Width', size.width);
|
|
116
|
+
const compHeightErrMessage = (0, validate_new_comp_data_1.validateCompositionDimension)('Height', size.height);
|
|
117
|
+
const typeValues = (0, react_1.useMemo)(() => {
|
|
118
|
+
return [
|
|
119
|
+
{
|
|
120
|
+
id: 'composition',
|
|
121
|
+
keyHint: null,
|
|
122
|
+
label: '<Composition />',
|
|
123
|
+
leftItem: null,
|
|
124
|
+
onClick: () => onTypeChanged('composition'),
|
|
125
|
+
subMenu: null,
|
|
126
|
+
type: 'item',
|
|
127
|
+
value: 'composition',
|
|
128
|
+
quickSwitcherLabel: null,
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
id: 'still',
|
|
132
|
+
keyHint: null,
|
|
133
|
+
label: '<Still />',
|
|
134
|
+
leftItem: null,
|
|
135
|
+
onClick: () => onTypeChanged('still'),
|
|
136
|
+
subMenu: null,
|
|
137
|
+
type: 'item',
|
|
138
|
+
value: 'still',
|
|
139
|
+
quickSwitcherLabel: null,
|
|
140
|
+
},
|
|
141
|
+
];
|
|
142
|
+
}, [onTypeChanged]);
|
|
143
|
+
const valid = compNameErrMessage === null &&
|
|
144
|
+
compWidthErrMessage === null &&
|
|
145
|
+
compHeightErrMessage === null;
|
|
146
|
+
const codemod = (0, react_1.useMemo)(() => {
|
|
147
|
+
return {
|
|
148
|
+
type: 'duplicate-composition',
|
|
149
|
+
idToDuplicate: resolved.result.id,
|
|
150
|
+
newDurationInFrames: hadDurationDefined ? Number(durationInFrames) : null,
|
|
151
|
+
newFps: hadFpsDefined ? Number(selectedFrameRate) : null,
|
|
152
|
+
newHeight: hadDimensionsDefined ? Number(size.height) : null,
|
|
153
|
+
newWidth: hadDimensionsDefined ? Number(size.width) : null,
|
|
154
|
+
newId,
|
|
155
|
+
tag: type === 'still' ? 'Still' : 'Composition',
|
|
156
|
+
};
|
|
157
|
+
}, [
|
|
158
|
+
durationInFrames,
|
|
159
|
+
hadDimensionsDefined,
|
|
160
|
+
hadDurationDefined,
|
|
161
|
+
hadFpsDefined,
|
|
162
|
+
newId,
|
|
163
|
+
resolved.result.id,
|
|
164
|
+
selectedFrameRate,
|
|
165
|
+
size.height,
|
|
166
|
+
size.width,
|
|
167
|
+
type,
|
|
168
|
+
]);
|
|
169
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ModalHeader_1.NewCompHeader, { title: `Duplicate ${resolved.result.id}` }), (0, jsx_runtime_1.jsxs)("form", { children: [(0, jsx_runtime_1.jsxs)("div", { style: content, children: [initialCompType === 'composition' ? (
|
|
170
|
+
// We allow converting from a composition to a still, but
|
|
171
|
+
// not the other way around
|
|
172
|
+
(0, jsx_runtime_1.jsxs)("div", { style: layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_2.label, children: "Type" }), (0, jsx_runtime_1.jsx)("div", { style: layout_2.rightRow, children: (0, jsx_runtime_1.jsx)(ComboBox_1.Combobox, { title: "Type of composition", style: comboBoxStyle, values: typeValues, selectedId: type }) })] })) : null, (0, jsx_runtime_1.jsxs)("div", { style: layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_2.label, children: "ID" }), (0, jsx_runtime_1.jsx)("div", { style: layout_2.rightRow, children: (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(RemInput_1.RemotionInput, { value: newId, onChange: onNameChange, type: "text", autoFocus: true, placeholder: "Composition ID", status: "ok", rightAlign: true }), compNameErrMessage ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: compNameErrMessage, type: "error" })] })) : null] }) })] }), hadDimensionsDefined ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { style: layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_2.label, children: "Width" }), (0, jsx_runtime_1.jsxs)("div", { style: layout_2.rightRow, children: [(0, jsx_runtime_1.jsx)(InputDragger_1.InputDragger, { type: "number", value: size.width, placeholder: "Width", onTextChange: onWidthChanged, name: "width", step: 2, min: 2, required: true, status: "ok", formatter: (w) => `${w}px`, max: 100000000, onValueChange: onWidthDirectlyChanged, rightAlign: false }), compWidthErrMessage ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: compWidthErrMessage, type: "error" })] })) : null] })] }), (0, jsx_runtime_1.jsxs)("div", { style: layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_2.label, children: "Height" }), (0, jsx_runtime_1.jsxs)("div", { style: layout_2.rightRow, children: [(0, jsx_runtime_1.jsx)(InputDragger_1.InputDragger, { type: "number", value: size.height, onTextChange: onHeightChanged, placeholder: "Height", name: "height", step: 2, required: true, formatter: (h) => `${h}px`, min: 2, status: "ok", max: 100000000, onValueChange: onHeightDirectlyChanged, rightAlign: false }), compHeightErrMessage ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: compHeightErrMessage, type: "error" })] })) : null] })] })] })) : null, type === 'composition' && hadDurationDefined ? ((0, jsx_runtime_1.jsx)(NewCompDuration_1.NewCompDuration, { durationInFrames: durationInFrames, setDurationInFrames: setDurationInFrames })) : null, type === 'composition' && hadFpsDefined ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_2.label, children: "FPS" }), (0, jsx_runtime_1.jsx)("div", { style: layout_2.rightRow, children: (0, jsx_runtime_1.jsx)(InputDragger_1.InputDragger, { type: "number", value: selectedFrameRate, onTextChange: onTextFpsChange, placeholder: "Frame rate (fps)", name: "fps", min: 1, required: true, status: "ok", max: 240, step: 0.01, onValueChange: onFpsChange, rightAlign: false }) })] })) : null] }), (0, jsx_runtime_1.jsx)("div", { style: { ...content, borderTop: '1px solid black' }, children: (0, jsx_runtime_1.jsx)(CodemodFooter_1.CodemodFooter, { loadingNotification: 'Duplicating...', errorNotification: 'Could not duplicate composition', succeessNotifcation: `Duplicated ${unresolved.id}`, genericSubmitLabel: 'Duplicate', submitLabel: ({ relativeRootPath }) => `Add to ${relativeRootPath}`, codemod: codemod, valid: valid }) })] })] }));
|
|
173
|
+
};
|
|
174
|
+
const DuplicateComposition = ({ compositionId }) => {
|
|
175
|
+
return ((0, jsx_runtime_1.jsx)(DismissableModal_1.DismissableModal, { children: (0, jsx_runtime_1.jsx)(ResolveCompositionBeforeModal_1.ResolveCompositionBeforeModal, { compositionId: compositionId, children: (0, jsx_runtime_1.jsx)(DuplicateCompositionLoaded, {}) }) }));
|
|
176
|
+
};
|
|
177
|
+
exports.DuplicateComposition = DuplicateComposition;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export declare const NewCompDuration: React.FC<{
|
|
3
|
-
durationInFrames:
|
|
4
|
-
|
|
5
|
-
setDurationInFrames: React.Dispatch<React.SetStateAction<string>>;
|
|
3
|
+
durationInFrames: number;
|
|
4
|
+
setDurationInFrames: React.Dispatch<React.SetStateAction<number>>;
|
|
6
5
|
}>;
|
|
@@ -5,19 +5,19 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const validate_new_comp_data_1 = require("../../helpers/validate-new-comp-data");
|
|
7
7
|
const layout_1 = require("../layout");
|
|
8
|
+
const layout_2 = require("../RenderModal/layout");
|
|
8
9
|
const InputDragger_1 = require("./InputDragger");
|
|
9
|
-
const new_comp_layout_1 = require("./new-comp-layout");
|
|
10
10
|
const ValidationMessage_1 = require("./ValidationMessage");
|
|
11
|
-
const NewCompDuration = ({ durationInFrames, setDurationInFrames
|
|
11
|
+
const NewCompDuration = ({ durationInFrames, setDurationInFrames }) => {
|
|
12
12
|
const onDurationInFramesChanged = (0, react_1.useCallback)((newValue) => {
|
|
13
|
-
setDurationInFrames(
|
|
13
|
+
setDurationInFrames(Number(newValue));
|
|
14
14
|
}, [setDurationInFrames]);
|
|
15
15
|
const onDurationChangedDirectly = (0, react_1.useCallback)((newVal) => {
|
|
16
|
-
setDurationInFrames(
|
|
16
|
+
setDurationInFrames(newVal);
|
|
17
17
|
}, [setDurationInFrames]);
|
|
18
18
|
const compDurationErrMessage = (0, validate_new_comp_data_1.validateCompositionDuration)(durationInFrames);
|
|
19
|
-
return ((0, jsx_runtime_1.
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_2.label, children: "Duration in frames" }), (0, jsx_runtime_1.jsxs)("div", { style: layout_2.rightRow, children: [(0, jsx_runtime_1.jsx)(InputDragger_1.InputDragger, { type: "number", value: durationInFrames, onTextChange: onDurationInFramesChanged, placeholder: "Duration (frames)", name: "durationInFrames", min: 1, step: 1, required: true, status: "ok",
|
|
20
|
+
// Hitting Promise.all() limit in Chrome
|
|
21
|
+
max: 300000, onValueChange: onDurationChangedDirectly, rightAlign: false }), compDurationErrMessage ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: compDurationErrMessage, type: "error" })] })) : null] })] }));
|
|
22
22
|
};
|
|
23
23
|
exports.NewCompDuration = NewCompDuration;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RenameComposition = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const remotion_1 = require("remotion");
|
|
7
|
+
const validate_new_comp_data_1 = require("../../helpers/validate-new-comp-data");
|
|
8
|
+
const layout_1 = require("../layout");
|
|
9
|
+
const ModalHeader_1 = require("../ModalHeader");
|
|
10
|
+
const layout_2 = require("../RenderModal/layout");
|
|
11
|
+
const ResolveCompositionBeforeModal_1 = require("../RenderModal/ResolveCompositionBeforeModal");
|
|
12
|
+
const CodemodFooter_1 = require("./CodemodFooter");
|
|
13
|
+
const DismissableModal_1 = require("./DismissableModal");
|
|
14
|
+
const RemInput_1 = require("./RemInput");
|
|
15
|
+
const ValidationMessage_1 = require("./ValidationMessage");
|
|
16
|
+
const content = {
|
|
17
|
+
padding: 12,
|
|
18
|
+
paddingRight: 12,
|
|
19
|
+
flex: 1,
|
|
20
|
+
fontSize: 13,
|
|
21
|
+
minWidth: 500,
|
|
22
|
+
};
|
|
23
|
+
const RenameCompositionLoaded = () => {
|
|
24
|
+
const context = (0, react_1.useContext)(ResolveCompositionBeforeModal_1.ResolvedCompositionContext);
|
|
25
|
+
if (!context) {
|
|
26
|
+
throw new Error('Resolved composition context');
|
|
27
|
+
}
|
|
28
|
+
const { resolved } = context;
|
|
29
|
+
const { compositions } = (0, react_1.useContext)(remotion_1.Internals.CompositionManager);
|
|
30
|
+
const [newId, setName] = (0, react_1.useState)(() => {
|
|
31
|
+
return resolved.result.id;
|
|
32
|
+
});
|
|
33
|
+
const onNameChange = (0, react_1.useCallback)((e) => {
|
|
34
|
+
setName(e.target.value);
|
|
35
|
+
}, []);
|
|
36
|
+
const compNameErrMessage = newId === resolved.result.id
|
|
37
|
+
? null
|
|
38
|
+
: (0, validate_new_comp_data_1.validateCompositionName)(newId, compositions);
|
|
39
|
+
const valid = compNameErrMessage === null && resolved.result.id !== newId;
|
|
40
|
+
const codemod = (0, react_1.useMemo)(() => {
|
|
41
|
+
return {
|
|
42
|
+
type: 'rename-composition',
|
|
43
|
+
idToRename: resolved.result.id,
|
|
44
|
+
newId,
|
|
45
|
+
};
|
|
46
|
+
}, [newId, resolved.result.id]);
|
|
47
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ModalHeader_1.NewCompHeader, { title: `Rename ${resolved.result.id}` }), (0, jsx_runtime_1.jsxs)("form", { children: [(0, jsx_runtime_1.jsx)("div", { style: content, children: (0, jsx_runtime_1.jsxs)("div", { style: layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_2.label, children: "ID" }), (0, jsx_runtime_1.jsx)("div", { style: layout_2.rightRow, children: (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(RemInput_1.RemotionInput, { value: newId, onChange: onNameChange, type: "text", autoFocus: true, placeholder: "Composition ID", status: "ok", rightAlign: true }), compNameErrMessage ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: compNameErrMessage, type: "error" })] })) : null] }) })] }) }), (0, jsx_runtime_1.jsx)("div", { style: { ...content, borderTop: '1px solid black' }, children: (0, jsx_runtime_1.jsx)(CodemodFooter_1.CodemodFooter, { loadingNotification: 'Renaming...', errorNotification: 'Could not rename composition', succeessNotifcation: `Renamed to ${newId}`, genericSubmitLabel: 'Rename', submitLabel: ({ relativeRootPath }) => `Modify ${relativeRootPath}`, codemod: codemod, valid: valid }) })] })] }));
|
|
48
|
+
};
|
|
49
|
+
const RenameComposition = ({ compositionId }) => {
|
|
50
|
+
return ((0, jsx_runtime_1.jsx)(DismissableModal_1.DismissableModal, { children: (0, jsx_runtime_1.jsx)(ResolveCompositionBeforeModal_1.ResolveCompositionBeforeModal, { compositionId: compositionId, children: (0, jsx_runtime_1.jsx)(RenameCompositionLoaded, {}) }) }));
|
|
51
|
+
};
|
|
52
|
+
exports.RenameComposition = RenameComposition;
|
|
@@ -19,6 +19,9 @@ const notification = {
|
|
|
19
19
|
};
|
|
20
20
|
const Notification = ({ children, id, duration, created, onRemove }) => {
|
|
21
21
|
(0, react_1.useEffect)(() => {
|
|
22
|
+
if (duration === null) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
22
25
|
const timeout = setTimeout(() => {
|
|
23
26
|
onRemove(id);
|
|
24
27
|
}, duration - (Date.now() - created));
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
type
|
|
3
|
-
|
|
4
|
-
content: React.ReactNode;
|
|
5
|
-
created: number;
|
|
6
|
-
duration: number;
|
|
2
|
+
type CreatedNotification = {
|
|
3
|
+
replaceContent: (newContent: React.ReactNode, durationInMs: number | null) => void;
|
|
7
4
|
};
|
|
8
|
-
|
|
9
|
-
addNotification: (notification: TNotification) => void;
|
|
10
|
-
};
|
|
11
|
-
export declare const notificationCenter: React.RefObject<TNotificationCenter>;
|
|
12
|
-
export declare const sendErrorNotification: (content: React.ReactNode) => void;
|
|
5
|
+
export declare const showNotification: (content: React.ReactNode, durationInMs: number | null) => CreatedNotification;
|
|
13
6
|
export declare const NotificationCenter: React.FC;
|
|
14
7
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NotificationCenter = exports.
|
|
3
|
+
exports.NotificationCenter = exports.showNotification = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const Notification_1 = require("./Notification");
|
|
@@ -15,17 +15,16 @@ const container = {
|
|
|
15
15
|
pointerEvents: 'none',
|
|
16
16
|
backgroundColor: 'transparent',
|
|
17
17
|
};
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
(_a = exports.notificationCenter.current) === null || _a === void 0 ? void 0 : _a.addNotification({
|
|
18
|
+
const notificationCenter = (0, react_1.createRef)();
|
|
19
|
+
const showNotification = (content, durationInMs) => {
|
|
20
|
+
return notificationCenter.current.addNotification({
|
|
22
21
|
content,
|
|
23
|
-
duration:
|
|
22
|
+
duration: durationInMs,
|
|
24
23
|
created: Date.now(),
|
|
25
24
|
id: String(Math.random()).replace('0.', ''),
|
|
26
25
|
});
|
|
27
26
|
};
|
|
28
|
-
exports.
|
|
27
|
+
exports.showNotification = showNotification;
|
|
29
28
|
const NotificationCenter = () => {
|
|
30
29
|
const [notifications, setNotifications] = (0, react_1.useState)([]);
|
|
31
30
|
const onRemove = (0, react_1.useCallback)((id) => {
|
|
@@ -37,8 +36,25 @@ const NotificationCenter = () => {
|
|
|
37
36
|
setNotifications((previousNotifications) => {
|
|
38
37
|
return [...previousNotifications, notification];
|
|
39
38
|
});
|
|
39
|
+
return {
|
|
40
|
+
replaceContent: (newContent, durationInMs) => {
|
|
41
|
+
setNotifications((oldNotifications) => {
|
|
42
|
+
return oldNotifications.map((notificationToMap) => {
|
|
43
|
+
if (notificationToMap.id === notification.id) {
|
|
44
|
+
return {
|
|
45
|
+
...notificationToMap,
|
|
46
|
+
duration: durationInMs,
|
|
47
|
+
content: newContent,
|
|
48
|
+
created: Date.now(),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return notificationToMap;
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
};
|
|
40
56
|
}, []);
|
|
41
|
-
(0, react_1.useImperativeHandle)(
|
|
57
|
+
(0, react_1.useImperativeHandle)(notificationCenter, () => {
|
|
42
58
|
return {
|
|
43
59
|
addNotification,
|
|
44
60
|
};
|
|
@@ -35,13 +35,13 @@ const OpenEditorButton = ({ type }) => {
|
|
|
35
35
|
.then((res) => res.json())
|
|
36
36
|
.then(({ success }) => {
|
|
37
37
|
if (!success) {
|
|
38
|
-
(0, NotificationCenter_1.
|
|
38
|
+
(0, NotificationCenter_1.showNotification)(`Could not open ${window.remotion_editorName}`, 2000);
|
|
39
39
|
}
|
|
40
40
|
})
|
|
41
41
|
.catch((err) => {
|
|
42
42
|
// eslint-disable-next-line no-console
|
|
43
43
|
console.error(err);
|
|
44
|
-
(0, NotificationCenter_1.
|
|
44
|
+
(0, NotificationCenter_1.showNotification)(`Could not open ${window.remotion_editorName}`, 2000);
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
if (type === 'git') {
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
-
const
|
|
5
|
-
const modals_1 = require("../../state/modals");
|
|
6
|
-
const ModalContainer_1 = require("../ModalContainer");
|
|
4
|
+
const DismissableModal_1 = require("../NewComposition/DismissableModal");
|
|
7
5
|
const QuickSwitcherContent_1 = require("./QuickSwitcherContent");
|
|
8
6
|
const QuickSwitcher = ({ initialMode, invocationTimestamp, readOnlyStudio }) => {
|
|
9
|
-
|
|
10
|
-
const onQuit = (0, react_1.useCallback)(() => {
|
|
11
|
-
setSelectedModal(null);
|
|
12
|
-
}, [setSelectedModal]);
|
|
13
|
-
// Separate child component to correctly capture keybindings
|
|
14
|
-
return ((0, jsx_runtime_1.jsx)(ModalContainer_1.ModalContainer, { onOutsideClick: onQuit, onEscape: onQuit, children: (0, jsx_runtime_1.jsx)(QuickSwitcherContent_1.QuickSwitcherContent, { readOnlyStudio: readOnlyStudio, invocationTimestamp: invocationTimestamp, initialMode: initialMode }) }));
|
|
7
|
+
return ((0, jsx_runtime_1.jsx)(DismissableModal_1.DismissableModal, { children: (0, jsx_runtime_1.jsx)(QuickSwitcherContent_1.QuickSwitcherContent, { readOnlyStudio: readOnlyStudio, invocationTimestamp: invocationTimestamp, initialMode: initialMode }) }));
|
|
15
8
|
};
|
|
16
9
|
exports.default = QuickSwitcher;
|
|
@@ -210,12 +210,12 @@ const DataEditor = ({ unresolvedComposition, inputProps, setInputProps, mayShowS
|
|
|
210
210
|
}, [mode]);
|
|
211
211
|
const onUpdate = (0, react_1.useCallback)(() => {
|
|
212
212
|
if (schema === 'no-zod' || schema === 'no-schema' || z === null) {
|
|
213
|
-
(0, NotificationCenter_1.
|
|
213
|
+
(0, NotificationCenter_1.showNotification)('Cannot update default props: No Zod schema', 2000);
|
|
214
214
|
return;
|
|
215
215
|
}
|
|
216
216
|
(0, actions_1.updateDefaultProps)(unresolvedComposition.id, inputProps, (0, extract_enum_json_paths_1.extractEnumJsonPaths)(schema, z, [])).then((response) => {
|
|
217
217
|
if (!response.success) {
|
|
218
|
-
(0, NotificationCenter_1.
|
|
218
|
+
(0, NotificationCenter_1.showNotification)(`Cannot update default props: ${response.reason}`, 2000);
|
|
219
219
|
}
|
|
220
220
|
});
|
|
221
221
|
}, [unresolvedComposition.id, inputProps, schema, z]);
|
|
@@ -225,7 +225,7 @@ const DataEditor = ({ unresolvedComposition, inputProps, setInputProps, mayShowS
|
|
|
225
225
|
const onSave = (0, react_1.useCallback)((updater) => {
|
|
226
226
|
var _a;
|
|
227
227
|
if (schema === 'no-zod' || schema === 'no-schema' || z === null) {
|
|
228
|
-
(0, NotificationCenter_1.
|
|
228
|
+
(0, NotificationCenter_1.showNotification)('Cannot update default props: No Zod schema', 2000);
|
|
229
229
|
return;
|
|
230
230
|
}
|
|
231
231
|
setSaving(true);
|
|
@@ -234,11 +234,11 @@ const DataEditor = ({ unresolvedComposition, inputProps, setInputProps, mayShowS
|
|
|
234
234
|
if (!response.success) {
|
|
235
235
|
// eslint-disable-next-line no-console
|
|
236
236
|
console.log(response.stack);
|
|
237
|
-
(0, NotificationCenter_1.
|
|
237
|
+
(0, NotificationCenter_1.showNotification)(`Cannot update default props: ${response.reason}. See console for more information.`, 2000);
|
|
238
238
|
}
|
|
239
239
|
})
|
|
240
240
|
.catch((err) => {
|
|
241
|
-
(0, NotificationCenter_1.
|
|
241
|
+
(0, NotificationCenter_1.showNotification)(`Cannot update default props: ${err.message}`, 2000);
|
|
242
242
|
setSaving(false);
|
|
243
243
|
});
|
|
244
244
|
}, [
|