@remotion/studio 4.0.154 → 4.0.157
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/api/update-default-props.d.ts +0 -1
- package/dist/api/update-default-props.js +2 -3
- package/dist/components/OptionsPanel.js +10 -1
- package/dist/components/RenderModal/DataEditor.js +10 -5
- package/dist/components/RenderModal/SchemaEditor/SchemaEditor.js +3 -3
- package/dist/components/RenderModal/SchemaEditor/local-state.js +14 -17
- package/dist/esm/index.mjs +1 -2
- package/dist/esm/internals.mjs +192 -182
- package/package.json +7 -7
- package/tsconfig.tsbuildinfo +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { UpdateDefaultPropsFunction } from './helpers/calc-new-props';
|
|
2
|
-
export declare const PROPS_UPDATED_EXTERNALLY = "remotion.propsUpdatedExternally";
|
|
3
2
|
export declare const updateDefaultProps: ({ compositionId, defaultProps, }: {
|
|
4
3
|
compositionId: string;
|
|
5
4
|
defaultProps: UpdateDefaultPropsFunction;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateDefaultProps =
|
|
3
|
+
exports.updateDefaultProps = void 0;
|
|
4
4
|
const remotion_1 = require("remotion");
|
|
5
5
|
const calc_new_props_1 = require("./helpers/calc-new-props");
|
|
6
|
-
exports.PROPS_UPDATED_EXTERNALLY = 'remotion.propsUpdatedExternally';
|
|
7
6
|
const updateDefaultProps = ({ compositionId, defaultProps, }) => {
|
|
8
7
|
const { generatedDefaultProps, composition } = (0, calc_new_props_1.calcNewProps)(compositionId, defaultProps);
|
|
9
8
|
const propsStore = remotion_1.Internals.editorPropsProviderRef.current;
|
|
@@ -16,6 +15,6 @@ const updateDefaultProps = ({ compositionId, defaultProps, }) => {
|
|
|
16
15
|
[composition.id]: generatedDefaultProps,
|
|
17
16
|
};
|
|
18
17
|
});
|
|
19
|
-
window.dispatchEvent(new CustomEvent(
|
|
18
|
+
window.dispatchEvent(new CustomEvent(remotion_1.Internals.PROPS_UPDATED_EXTERNALLY));
|
|
20
19
|
};
|
|
21
20
|
exports.updateDefaultProps = updateDefaultProps;
|
|
@@ -37,7 +37,7 @@ const persistSelectedOptionsSidebarPanel = (panel) => {
|
|
|
37
37
|
exports.persistSelectedOptionsSidebarPanel = persistSelectedOptionsSidebarPanel;
|
|
38
38
|
exports.optionsSidebarTabs = (0, react_1.createRef)();
|
|
39
39
|
const OptionsPanel = ({ readOnlyStudio }) => {
|
|
40
|
-
const { props, updateProps } = (0, react_1.useContext)(remotion_1.Internals.EditorPropsContext);
|
|
40
|
+
const { props, updateProps, resetUnsaved } = (0, react_1.useContext)(remotion_1.Internals.EditorPropsContext);
|
|
41
41
|
const [saving, setSaving] = (0, react_1.useState)(false);
|
|
42
42
|
const isMobileLayout = (0, mobile_layout_1.useMobileLayout)();
|
|
43
43
|
const container = (0, react_1.useMemo)(() => ({
|
|
@@ -113,6 +113,15 @@ const OptionsPanel = ({ readOnlyStudio }) => {
|
|
|
113
113
|
}
|
|
114
114
|
return !(0, deep_equal_1.deepEqual)(composition.defaultProps, currentDefaultProps);
|
|
115
115
|
}, [currentDefaultProps, composition]);
|
|
116
|
+
const reset = (0, react_1.useCallback)(() => {
|
|
117
|
+
resetUnsaved();
|
|
118
|
+
}, [resetUnsaved]);
|
|
119
|
+
(0, react_1.useEffect)(() => {
|
|
120
|
+
window.addEventListener(remotion_1.Internals.PROPS_UPDATED_EXTERNALLY, reset);
|
|
121
|
+
return () => {
|
|
122
|
+
window.removeEventListener(remotion_1.Internals.PROPS_UPDATED_EXTERNALLY, reset);
|
|
123
|
+
};
|
|
124
|
+
}, [reset]);
|
|
116
125
|
return ((0, jsx_runtime_1.jsxs)("div", { style: container, className: "css-reset", children: [(0, jsx_runtime_1.jsx)("div", { style: tabsContainer, children: (0, jsx_runtime_1.jsxs)(Tabs_1.Tabs, { children: [composition ? ((0, jsx_runtime_1.jsxs)(Tabs_1.Tab, { selected: panel === 'input-props', onClick: onPropsSelected, style: { justifyContent: 'space-between' }, children: ["Props", unsavedChangesExist ? ((0, jsx_runtime_1.jsx)("div", { title: saveToolTip, style: circleStyle })) : null] })) : null, readOnlyStudio ? null : ((0, jsx_runtime_1.jsx)(RendersTab_1.RendersTab, { onClick: onRendersSelected, selected: panel === 'renders' }))] }) }), panel === `input-props` && composition ? ((0, jsx_runtime_1.jsx)(DataEditor_1.DataEditor, { unresolvedComposition: composition, defaultProps: currentDefaultProps, setDefaultProps: setDefaultProps, mayShowSaveButton: true, propsEditType: "default-props", saving: saving, setSaving: setSaving, readOnlyStudio: readOnlyStudio }, composition.id)) : readOnlyStudio ? null : ((0, jsx_runtime_1.jsx)(RenderQueue_1.RenderQueue, {}))] }));
|
|
117
126
|
};
|
|
118
127
|
exports.OptionsPanel = OptionsPanel;
|
|
@@ -90,6 +90,7 @@ const setPersistedShowWarningState = (val) => {
|
|
|
90
90
|
const DataEditor = ({ unresolvedComposition, defaultProps, setDefaultProps, mayShowSaveButton, propsEditType, saving, setSaving, readOnlyStudio, }) => {
|
|
91
91
|
const [mode, setMode] = (0, react_1.useState)('schema');
|
|
92
92
|
const [showWarning, setShowWarningWithoutPersistance] = (0, react_1.useState)(() => getPersistedShowWarningState());
|
|
93
|
+
const { updateCompositionDefaultProps } = (0, react_1.useContext)(remotion_1.Internals.CompositionManager);
|
|
93
94
|
const inJSONEditor = mode === 'json';
|
|
94
95
|
const serializedJSON = (0, react_1.useMemo)(() => {
|
|
95
96
|
if (!inJSONEditor) {
|
|
@@ -219,34 +220,38 @@ const DataEditor = ({ unresolvedComposition, defaultProps, setDefaultProps, mayS
|
|
|
219
220
|
}
|
|
220
221
|
});
|
|
221
222
|
}, [unresolvedComposition.id, defaultProps, schema, z]);
|
|
222
|
-
(0, react_1.useEffect)(() => {
|
|
223
|
-
setSaving(false);
|
|
224
|
-
}, [fastRefreshes, setSaving]);
|
|
225
223
|
const onSave = (0, react_1.useCallback)((updater) => {
|
|
226
224
|
var _a;
|
|
227
225
|
if (schema === 'no-zod' || schema === 'no-schema' || z === null) {
|
|
228
226
|
(0, NotificationCenter_1.showNotification)('Cannot update default props: No Zod schema', 2000);
|
|
229
227
|
return;
|
|
230
228
|
}
|
|
229
|
+
window.remotion_ignoreFastRefreshUpdate = fastRefreshes + 1;
|
|
231
230
|
setSaving(true);
|
|
232
|
-
|
|
231
|
+
const newDefaultProps = updater((_a = unresolvedComposition.defaultProps) !== null && _a !== void 0 ? _a : {});
|
|
232
|
+
(0, actions_1.callUpdateDefaultPropsApi)(unresolvedComposition.id, newDefaultProps, (0, extract_enum_json_paths_1.extractEnumJsonPaths)(schema, z, []))
|
|
233
233
|
.then((response) => {
|
|
234
234
|
if (!response.success) {
|
|
235
235
|
// eslint-disable-next-line no-console
|
|
236
236
|
console.log(response.stack);
|
|
237
237
|
(0, NotificationCenter_1.showNotification)(`Cannot update default props: ${response.reason}. See console for more information.`, 2000);
|
|
238
238
|
}
|
|
239
|
+
updateCompositionDefaultProps(unresolvedComposition.id, newDefaultProps);
|
|
239
240
|
})
|
|
240
241
|
.catch((err) => {
|
|
241
242
|
(0, NotificationCenter_1.showNotification)(`Cannot update default props: ${err.message}`, 2000);
|
|
243
|
+
})
|
|
244
|
+
.finally(() => {
|
|
242
245
|
setSaving(false);
|
|
243
246
|
});
|
|
244
247
|
}, [
|
|
245
248
|
schema,
|
|
246
249
|
z,
|
|
250
|
+
fastRefreshes,
|
|
247
251
|
setSaving,
|
|
248
|
-
unresolvedComposition.id,
|
|
249
252
|
unresolvedComposition.defaultProps,
|
|
253
|
+
unresolvedComposition.id,
|
|
254
|
+
updateCompositionDefaultProps,
|
|
250
255
|
]);
|
|
251
256
|
const connectionStatus = previewServerState.type;
|
|
252
257
|
const warnings = (0, react_1.useMemo)(() => {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SchemaEditor = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
const
|
|
6
|
+
const remotion_1 = require("remotion");
|
|
7
7
|
const document_title_1 = require("../../../helpers/document-title");
|
|
8
8
|
const use_keybinding_1 = require("../../../helpers/use-keybinding");
|
|
9
9
|
const is_menu_item_1 = require("../../Menu/is-menu-item");
|
|
@@ -29,9 +29,9 @@ const SchemaEditor = ({ schema, unsavedDefaultProps, setValue, zodValidationResu
|
|
|
29
29
|
const bumpRevision = () => {
|
|
30
30
|
setRevision((old) => old + 1);
|
|
31
31
|
};
|
|
32
|
-
window.addEventListener(
|
|
32
|
+
window.addEventListener(remotion_1.Internals.PROPS_UPDATED_EXTERNALLY, bumpRevision);
|
|
33
33
|
return () => {
|
|
34
|
-
window.removeEventListener(
|
|
34
|
+
window.removeEventListener(remotion_1.Internals.PROPS_UPDATED_EXTERNALLY, bumpRevision);
|
|
35
35
|
};
|
|
36
36
|
}, []);
|
|
37
37
|
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useLocalState = exports.RevisionContext = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
const
|
|
6
|
+
const remotion_1 = require("remotion");
|
|
7
7
|
const deep_equal_1 = require("./deep-equal");
|
|
8
8
|
exports.RevisionContext = (0, react_1.createContext)({
|
|
9
9
|
childResetRevision: 0,
|
|
@@ -20,36 +20,33 @@ const useLocalState = ({ unsavedValue, schema, setValue, savedValue, }) => {
|
|
|
20
20
|
},
|
|
21
21
|
};
|
|
22
22
|
});
|
|
23
|
-
const
|
|
24
|
-
if (localValueOrNull === null) {
|
|
23
|
+
const localUnsavedValue = (0, react_1.useMemo)(() => {
|
|
24
|
+
if (localValueOrNull[parentRevision] === null) {
|
|
25
25
|
return {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
zodValidation: schema.safeParse(unsavedValue),
|
|
30
|
-
},
|
|
26
|
+
value: unsavedValue,
|
|
27
|
+
keyStabilityRevision: 0,
|
|
28
|
+
zodValidation: schema.safeParse(unsavedValue),
|
|
31
29
|
};
|
|
32
30
|
}
|
|
33
|
-
return localValueOrNull;
|
|
31
|
+
return localValueOrNull[parentRevision];
|
|
34
32
|
}, [localValueOrNull, parentRevision, schema, unsavedValue]);
|
|
35
33
|
(0, react_1.useEffect)(() => {
|
|
36
34
|
const checkFile = () => {
|
|
37
35
|
setResetRevision((old) => old + 1);
|
|
38
|
-
setLocalValue(
|
|
36
|
+
setLocalValue({});
|
|
39
37
|
};
|
|
40
|
-
window.addEventListener(
|
|
38
|
+
window.addEventListener(remotion_1.Internals.PROPS_UPDATED_EXTERNALLY, checkFile);
|
|
41
39
|
return () => {
|
|
42
|
-
window.removeEventListener(
|
|
40
|
+
window.removeEventListener(remotion_1.Internals.PROPS_UPDATED_EXTERNALLY, checkFile);
|
|
43
41
|
};
|
|
44
42
|
}, []);
|
|
45
43
|
const currentLocalValue = (0, react_1.useMemo)(() => {
|
|
46
|
-
|
|
47
|
-
return ((_a = localValue[parentRevision]) !== null && _a !== void 0 ? _a : {
|
|
44
|
+
return (localUnsavedValue !== null && localUnsavedValue !== void 0 ? localUnsavedValue : {
|
|
48
45
|
value: savedValue,
|
|
49
46
|
keyStabilityRevision: 0,
|
|
50
47
|
zodValidation: schema.safeParse(savedValue),
|
|
51
48
|
});
|
|
52
|
-
}, [
|
|
49
|
+
}, [localUnsavedValue, savedValue, schema]);
|
|
53
50
|
const stateRef = (0, react_1.useRef)(currentLocalValue);
|
|
54
51
|
stateRef.current = currentLocalValue;
|
|
55
52
|
const onChange = (0, react_1.useCallback)(
|
|
@@ -73,13 +70,13 @@ const useLocalState = ({ unsavedValue, schema, setValue, savedValue, }) => {
|
|
|
73
70
|
};
|
|
74
71
|
stateRef.current = newState;
|
|
75
72
|
return {
|
|
76
|
-
...
|
|
73
|
+
...localUnsavedValue,
|
|
77
74
|
[parentRevision]: newState,
|
|
78
75
|
};
|
|
79
76
|
});
|
|
80
77
|
}, [
|
|
81
78
|
currentLocalValue.keyStabilityRevision,
|
|
82
|
-
|
|
79
|
+
localUnsavedValue,
|
|
83
80
|
parentRevision,
|
|
84
81
|
schema,
|
|
85
82
|
setValue,
|
package/dist/esm/index.mjs
CHANGED
|
@@ -4461,7 +4461,6 @@ var saveDefaultProps = async ({
|
|
|
4461
4461
|
|
|
4462
4462
|
// src/api/update-default-props.ts
|
|
4463
4463
|
import {Internals as Internals2} from "remotion";
|
|
4464
|
-
var PROPS_UPDATED_EXTERNALLY = "remotion.propsUpdatedExternally";
|
|
4465
4464
|
var updateDefaultProps = ({
|
|
4466
4465
|
compositionId,
|
|
4467
4466
|
defaultProps
|
|
@@ -4477,7 +4476,7 @@ var updateDefaultProps = ({
|
|
|
4477
4476
|
[composition.id]: generatedDefaultProps
|
|
4478
4477
|
};
|
|
4479
4478
|
});
|
|
4480
|
-
window.dispatchEvent(new CustomEvent(PROPS_UPDATED_EXTERNALLY));
|
|
4479
|
+
window.dispatchEvent(new CustomEvent(Internals2.PROPS_UPDATED_EXTERNALLY));
|
|
4481
4480
|
};
|
|
4482
4481
|
|
|
4483
4482
|
// src/api/watch-public-folder.ts
|