@remotion/studio 4.0.438 → 4.0.439
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/Studio.js +2 -2
- package/dist/api/helpers/calc-new-props.js +5 -8
- package/dist/api/update-default-props.d.ts +7 -3
- package/dist/api/update-default-props.js +7 -21
- package/dist/api/visual-control.js +6 -0
- package/dist/components/DefaultPropsEditor.d.ts +8 -0
- package/dist/components/DefaultPropsEditor.js +15 -0
- package/dist/components/Editor.js +0 -14
- package/dist/components/EditorContexts.js +6 -3
- package/dist/components/KeyboardShortcutsExplainer.js +6 -2
- package/dist/components/MenuBuildIndicator.js +1 -0
- package/dist/components/MenuToolbar.js +3 -1
- package/dist/components/NewComposition/InputDragger.js +2 -2
- package/dist/components/NewComposition/RemTextarea.js +4 -0
- package/dist/components/ObserveDefaultPropsContext.d.ts +11 -0
- package/dist/components/ObserveDefaultPropsContext.js +120 -0
- package/dist/components/OptionsPanel.js +90 -28
- package/dist/components/RenderModal/DataEditor.d.ts +4 -5
- package/dist/components/RenderModal/DataEditor.js +9 -111
- package/dist/components/RenderModal/RenderModalJSONPropsEditor.d.ts +1 -1
- package/dist/components/RenderModal/RenderModalJSONPropsEditor.js +52 -48
- package/dist/components/RenderModal/SchemaEditor/Fieldset.d.ts +0 -1
- package/dist/components/RenderModal/SchemaEditor/SchemaEditor.d.ts +4 -9
- package/dist/components/RenderModal/SchemaEditor/SchemaEditor.js +2 -61
- package/dist/components/RenderModal/SchemaEditor/SchemaErrorMessages.d.ts +0 -1
- package/dist/components/RenderModal/SchemaEditor/SchemaErrorMessages.js +2 -3
- package/dist/components/RenderModal/SchemaEditor/SchemaLabel.d.ts +0 -6
- package/dist/components/RenderModal/SchemaEditor/SchemaLabel.js +2 -5
- package/dist/components/RenderModal/SchemaEditor/SchemaSeparationLine.d.ts +3 -1
- package/dist/components/RenderModal/SchemaEditor/SchemaSeparationLine.js +1 -1
- package/dist/components/RenderModal/SchemaEditor/ZodArrayEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodArrayEditor.js +15 -26
- package/dist/components/RenderModal/SchemaEditor/ZodArrayItemEditor.d.ts +0 -5
- package/dist/components/RenderModal/SchemaEditor/ZodArrayItemEditor.js +7 -12
- package/dist/components/RenderModal/SchemaEditor/ZodBooleanEditor.d.ts +0 -7
- package/dist/components/RenderModal/SchemaEditor/ZodBooleanEditor.js +5 -15
- package/dist/components/RenderModal/SchemaEditor/ZodColorEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodColorEditor.js +30 -28
- package/dist/components/RenderModal/SchemaEditor/ZodDateEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodDateEditor.js +13 -17
- package/dist/components/RenderModal/SchemaEditor/ZodDefaultEditor.d.ts +0 -5
- package/dist/components/RenderModal/SchemaEditor/ZodDefaultEditor.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodDiscriminatedUnionEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodDiscriminatedUnionEditor.js +13 -28
- package/dist/components/RenderModal/SchemaEditor/ZodEffectEditor.d.ts +1 -5
- package/dist/components/RenderModal/SchemaEditor/ZodEffectEditor.js +11 -12
- package/dist/components/RenderModal/SchemaEditor/ZodEnumEditor.d.ts +1 -5
- package/dist/components/RenderModal/SchemaEditor/ZodEnumEditor.js +12 -16
- package/dist/components/RenderModal/SchemaEditor/ZodFieldValidation.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodFieldValidation.js +1 -2
- package/dist/components/RenderModal/SchemaEditor/ZodMatrixEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodMatrixEditor.js +20 -30
- package/dist/components/RenderModal/SchemaEditor/ZodNonEditableValue.d.ts +0 -2
- package/dist/components/RenderModal/SchemaEditor/ZodNonEditableValue.js +3 -6
- package/dist/components/RenderModal/SchemaEditor/ZodNullableEditor.d.ts +0 -5
- package/dist/components/RenderModal/SchemaEditor/ZodNullableEditor.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodNumberEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodNumberEditor.js +16 -21
- package/dist/components/RenderModal/SchemaEditor/ZodObjectEditor.d.ts +2 -7
- package/dist/components/RenderModal/SchemaEditor/ZodObjectEditor.js +27 -49
- package/dist/components/RenderModal/SchemaEditor/ZodOptionalEditor.d.ts +0 -5
- package/dist/components/RenderModal/SchemaEditor/ZodOptionalEditor.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodOrNullishEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodOrNullishEditor.js +8 -15
- package/dist/components/RenderModal/SchemaEditor/ZodStaticFileEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodStaticFileEditor.js +10 -15
- package/dist/components/RenderModal/SchemaEditor/ZodStringEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodStringEditor.js +13 -17
- package/dist/components/RenderModal/SchemaEditor/ZodSwitch.d.ts +3 -6
- package/dist/components/RenderModal/SchemaEditor/ZodSwitch.js +27 -27
- package/dist/components/RenderModal/SchemaEditor/ZodTextareaEditor.d.ts +0 -5
- package/dist/components/RenderModal/SchemaEditor/ZodTextareaEditor.js +45 -17
- package/dist/components/RenderModal/SchemaEditor/ZodTupleEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodTupleEditor.js +15 -26
- package/dist/components/RenderModal/SchemaEditor/ZodTupleItemEditor.d.ts +0 -5
- package/dist/components/RenderModal/SchemaEditor/ZodTupleItemEditor.js +4 -11
- package/dist/components/RenderModal/SchemaEditor/ZodUnionEditor.d.ts +0 -5
- package/dist/components/RenderModal/SchemaEditor/ZodUnionEditor.js +6 -6
- package/dist/components/RenderModal/ServerRenderModal.js +9 -3
- package/dist/components/RenderModal/WebRenderModal.js +9 -3
- package/dist/components/RenderModal/get-render-modal-warnings.d.ts +1 -2
- package/dist/components/RenderModal/get-render-modal-warnings.js +4 -6
- package/dist/components/RenderQueue/actions.d.ts +1 -2
- package/dist/components/RenderQueue/actions.js +1 -13
- package/dist/components/Timeline/TimelineExpandedSection.js +7 -1
- package/dist/components/Timeline/TimelineFieldRow.d.ts +1 -0
- package/dist/components/Timeline/TimelineFieldRow.js +25 -3
- package/dist/components/Timeline/TimelineNumberField.js +4 -6
- package/dist/components/Timeline/TimelineRotationField.js +4 -6
- package/dist/components/Timeline/TimelineTranslateField.js +28 -13
- package/dist/components/TopPanel.js +10 -5
- package/dist/components/UndoRedoButtons.d.ts +2 -0
- package/dist/components/UndoRedoButtons.js +116 -0
- package/dist/components/VisualControls/VisualControlHandle.js +18 -18
- package/dist/components/VisualControls/VisualControlsUndoSync.d.ts +2 -0
- package/dist/components/VisualControls/VisualControlsUndoSync.js +23 -0
- package/dist/error-overlay/react-overlay/listen-to-runtime-errors.js +0 -1
- package/dist/esm/{chunk-ba0scebn.js → chunk-nnz9f1vq.js} +4233 -5091
- package/dist/esm/index.mjs +25 -28
- package/dist/esm/internals.mjs +4233 -5091
- package/dist/esm/previewEntry.mjs +4427 -5292
- package/dist/esm/renderEntry.mjs +6 -6
- package/dist/helpers/client-id.js +9 -0
- package/dist/helpers/document-title.d.ts +0 -1
- package/dist/helpers/document-title.js +1 -17
- package/dist/hot-middleware-client/process-update.js +6 -14
- package/dist/icons/redo.d.ts +3 -0
- package/dist/icons/redo.js +8 -0
- package/dist/icons/undo.d.ts +3 -0
- package/dist/icons/undo.js +8 -0
- package/dist/renderEntry.js +7 -6
- package/dist/visual-controls/VisualControls.js +9 -5
- package/dist/visual-controls/get-current-edited-value.js +5 -4
- package/dist/visual-controls/visual-control-store.d.ts +7 -0
- package/dist/visual-controls/visual-control-store.js +22 -0
- package/package.json +9 -9
- package/dist/components/GlobalPropsEditorUpdateButton.d.ts +0 -5
- package/dist/components/GlobalPropsEditorUpdateButton.js +0 -78
- package/dist/components/RenderModal/SchemaEditor/SchemaSaveButton.d.ts +0 -5
- package/dist/components/RenderModal/SchemaEditor/SchemaSaveButton.js +0 -18
- package/dist/components/RenderModal/SchemaEditor/local-state.d.ts +0 -25
- package/dist/components/RenderModal/SchemaEditor/local-state.js +0 -107
package/dist/esm/renderEntry.mjs
CHANGED
|
@@ -162,7 +162,7 @@ var renderContent = (Root) => {
|
|
|
162
162
|
frameState: null,
|
|
163
163
|
audioEnabled: window.remotion_audioEnabled,
|
|
164
164
|
videoEnabled: window.remotion_videoEnabled,
|
|
165
|
-
logLevel: window.remotion_logLevel,
|
|
165
|
+
logLevel: window.remotion_logLevel ?? "info",
|
|
166
166
|
numberOfAudioTags: 0,
|
|
167
167
|
audioLatencyHint: window.remotion_audioLatencyHint ?? "interactive",
|
|
168
168
|
visualModeEnabled: false,
|
|
@@ -189,7 +189,7 @@ var renderContent = (Root) => {
|
|
|
189
189
|
frameState: null,
|
|
190
190
|
audioEnabled: window.remotion_audioEnabled,
|
|
191
191
|
videoEnabled: window.remotion_videoEnabled,
|
|
192
|
-
logLevel: window.remotion_logLevel,
|
|
192
|
+
logLevel: window.remotion_logLevel ?? "info",
|
|
193
193
|
numberOfAudioTags: 0,
|
|
194
194
|
audioLatencyHint: window.remotion_audioLatencyHint ?? "interactive",
|
|
195
195
|
visualModeEnabled: false,
|
|
@@ -208,7 +208,7 @@ var renderContent = (Root) => {
|
|
|
208
208
|
renderToDOM(/* @__PURE__ */ jsx("div", {
|
|
209
209
|
children: /* @__PURE__ */ jsx(DelayedSpinner, {})
|
|
210
210
|
}));
|
|
211
|
-
import("./chunk-
|
|
211
|
+
import("./chunk-nnz9f1vq.js").then(({ StudioInternals }) => {
|
|
212
212
|
window.remotion_isStudio = true;
|
|
213
213
|
window.remotion_isReadOnlyStudio = true;
|
|
214
214
|
window.remotion_inputProps = "{}";
|
|
@@ -252,14 +252,14 @@ if (typeof window !== "undefined") {
|
|
|
252
252
|
const compositions = Internals.compositionsRef.current.getCompositions();
|
|
253
253
|
const canSerializeDefaultProps = getCanSerializeDefaultProps(compositions);
|
|
254
254
|
if (!canSerializeDefaultProps) {
|
|
255
|
-
Internals.Log.warn({ logLevel: window.remotion_logLevel, tag: null }, "defaultProps are too big to serialize - trying to find the problematic composition...");
|
|
256
|
-
Internals.Log.warn({ logLevel: window.remotion_logLevel, tag: null }, "Serialization:", compositions);
|
|
255
|
+
Internals.Log.warn({ logLevel: window.remotion_logLevel ?? "info", tag: null }, "defaultProps are too big to serialize - trying to find the problematic composition...");
|
|
256
|
+
Internals.Log.warn({ logLevel: window.remotion_logLevel ?? "info", tag: null }, "Serialization:", compositions);
|
|
257
257
|
for (const comp of compositions) {
|
|
258
258
|
if (!getCanSerializeDefaultProps(comp)) {
|
|
259
259
|
throw new Error(`defaultProps too big - could not serialize - the defaultProps of composition with ID ${comp.id} - the object that was passed to defaultProps was too big. Learn how to mitigate this error by visiting https://remotion.dev/docs/troubleshooting/serialize-defaultprops`);
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
|
-
Internals.Log.warn({ logLevel: window.remotion_logLevel, tag: null }, "Could not single out a problematic composition - The composition list as a whole is too big to serialize.");
|
|
262
|
+
Internals.Log.warn({ logLevel: window.remotion_logLevel ?? "info", tag: null }, "Could not single out a problematic composition - The composition list as a whole is too big to serialize.");
|
|
263
263
|
throw new Error("defaultProps too big - Could not serialize - an object that was passed to defaultProps was too big. Learn how to mitigate this error by visiting https://remotion.dev/docs/troubleshooting/serialize-defaultprops");
|
|
264
264
|
}
|
|
265
265
|
return compositions;
|
|
@@ -74,6 +74,15 @@ const PreviewServerConnection = ({ children, readOnlyStudio }) => {
|
|
|
74
74
|
type: 'connected',
|
|
75
75
|
clientId: newEvent.clientId,
|
|
76
76
|
});
|
|
77
|
+
listeners.current.forEach((l) => {
|
|
78
|
+
if (l.type === 'undo-redo-stack-changed') {
|
|
79
|
+
l.listener({
|
|
80
|
+
type: 'undo-redo-stack-changed',
|
|
81
|
+
undoFile: newEvent.undoFile,
|
|
82
|
+
redoFile: newEvent.redoFile,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
});
|
|
77
86
|
}
|
|
78
87
|
if (newEvent.type === 'render-queue-updated') {
|
|
79
88
|
(_a = context_1.renderJobsRef.current) === null || _a === void 0 ? void 0 : _a.updateRenderJobs(newEvent.queue);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { AnyRenderJob } from '../components/RenderQueue/context';
|
|
2
2
|
export declare const setCurrentCanvasContentId: (id: string | null) => void;
|
|
3
|
-
export declare const setUnsavedProps: (unsaved: boolean) => void;
|
|
4
3
|
export declare const setRenderJobs: (jobs: AnyRenderJob[]) => void;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setRenderJobs = exports.
|
|
3
|
+
exports.setRenderJobs = exports.setCurrentCanvasContentId = void 0;
|
|
4
4
|
const no_react_1 = require("remotion/no-react");
|
|
5
5
|
const context_1 = require("../components/RenderQueue/context");
|
|
6
6
|
let currentItemName = null;
|
|
7
|
-
let unsavedProps = false;
|
|
8
|
-
let tabInactive = false;
|
|
9
7
|
let renderJobs = [];
|
|
10
8
|
const setCurrentCanvasContentId = (id) => {
|
|
11
9
|
if (!id) {
|
|
@@ -18,20 +16,11 @@ const setCurrentCanvasContentId = (id) => {
|
|
|
18
16
|
updateTitle();
|
|
19
17
|
};
|
|
20
18
|
exports.setCurrentCanvasContentId = setCurrentCanvasContentId;
|
|
21
|
-
const setUnsavedProps = (unsaved) => {
|
|
22
|
-
window.remotion_unsavedProps = unsaved;
|
|
23
|
-
unsavedProps = unsaved;
|
|
24
|
-
};
|
|
25
|
-
exports.setUnsavedProps = setUnsavedProps;
|
|
26
19
|
const setRenderJobs = (jobs) => {
|
|
27
20
|
renderJobs = jobs;
|
|
28
21
|
updateTitle();
|
|
29
22
|
};
|
|
30
23
|
exports.setRenderJobs = setRenderJobs;
|
|
31
|
-
document.addEventListener('visibilitychange', () => {
|
|
32
|
-
tabInactive = document.visibilityState === 'hidden';
|
|
33
|
-
updateTitle();
|
|
34
|
-
});
|
|
35
24
|
const productName = 'Remotion Studio';
|
|
36
25
|
const suffix = `- ${productName}`;
|
|
37
26
|
const updateTitle = () => {
|
|
@@ -42,7 +31,6 @@ const updateTitle = () => {
|
|
|
42
31
|
const currentCompTitle = `${currentItemName} / ${window.remotion_projectName}`;
|
|
43
32
|
document.title = [
|
|
44
33
|
getProgressInBrackets(currentItemName, renderJobs),
|
|
45
|
-
unsavedProps && tabInactive ? '✏️' : null,
|
|
46
34
|
`${currentCompTitle} ${suffix}`,
|
|
47
35
|
]
|
|
48
36
|
.filter(no_react_1.NoReactInternals.truthy)
|
|
@@ -70,7 +58,3 @@ const getProgressInBrackets = (selectedCompositionId, jobs) => {
|
|
|
70
58
|
: `[${progInPercent}% ${currentRender.compositionId}]`;
|
|
71
59
|
return progressInBrackets;
|
|
72
60
|
};
|
|
73
|
-
document.addEventListener('visibilitychange', () => {
|
|
74
|
-
tabInactive = document.visibilityState === 'hidden';
|
|
75
|
-
updateTitle();
|
|
76
|
-
});
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.processUpdate = void 0;
|
|
10
|
-
const NotificationCenter_1 = require("../components/Notifications/NotificationCenter");
|
|
11
10
|
const url_state_1 = require("../helpers/url-state");
|
|
12
11
|
if (!__webpack_module__.hot) {
|
|
13
12
|
throw new Error('[Fast refresh] Hot Module Replacement is disabled.');
|
|
@@ -50,10 +49,6 @@ function upToDate(hash) {
|
|
|
50
49
|
}
|
|
51
50
|
const processUpdate = function (hash, moduleMap, options) {
|
|
52
51
|
var _a;
|
|
53
|
-
const { reload } = options;
|
|
54
|
-
if (!upToDate(hash) && ((_a = __webpack_module__.hot) === null || _a === void 0 ? void 0 : _a.status()) === 'idle') {
|
|
55
|
-
check();
|
|
56
|
-
}
|
|
57
52
|
async function check() {
|
|
58
53
|
var _a;
|
|
59
54
|
const cb = function (err, updatedModules) {
|
|
@@ -137,9 +132,7 @@ const processUpdate = function (hash, moduleMap, options) {
|
|
|
137
132
|
}
|
|
138
133
|
if (options.warn) {
|
|
139
134
|
console.warn('[Fast refresh] Update check failed: ' + (err.stack || err.message));
|
|
140
|
-
|
|
141
|
-
(0, url_state_1.reloadUrl)();
|
|
142
|
-
}
|
|
135
|
+
(0, url_state_1.reloadUrl)();
|
|
143
136
|
}
|
|
144
137
|
}
|
|
145
138
|
function performReload() {
|
|
@@ -148,12 +141,11 @@ const processUpdate = function (hash, moduleMap, options) {
|
|
|
148
141
|
}
|
|
149
142
|
if (options.warn)
|
|
150
143
|
console.warn('[Fast refresh] Reloading page');
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
144
|
+
(0, url_state_1.reloadUrl)();
|
|
145
|
+
}
|
|
146
|
+
const { reload } = options;
|
|
147
|
+
if (!upToDate(hash) && ((_a = __webpack_module__.hot) === null || _a === void 0 ? void 0 : _a.status()) === 'idle') {
|
|
148
|
+
check();
|
|
157
149
|
}
|
|
158
150
|
};
|
|
159
151
|
exports.processUpdate = processUpdate;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RedoIcon = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const RedoIcon = (props) => {
|
|
6
|
+
return (jsx_runtime_1.jsx("svg", { viewBox: "0 0 640 640", ...props, children: jsx_runtime_1.jsx("path", { fill: "currentColor", d: "M552 256L408 256C398.3 256 389.5 250.2 385.8 241.2C382.1 232.2 384.1 221.9 391 215L437.7 168.3C362.4 109.7 253.4 115 184.2 184.2C109.2 259.2 109.2 380.7 184.2 455.7C259.2 530.7 380.7 530.7 455.7 455.7C463.9 447.5 471.2 438.8 477.6 429.6C487.7 415.1 507.7 411.6 522.2 421.7C536.7 431.8 540.2 451.8 530.1 466.3C521.6 478.5 511.9 490.1 501 501C401 601 238.9 601 139 501C39.1 401 39 239 139 139C233.3 44.7 382.7 39.4 483.3 122.8L535 71C541.9 64.1 552.2 62.1 561.2 65.8C570.2 69.5 576 78.3 576 88L576 232C576 245.3 565.3 256 552 256z" }) }));
|
|
7
|
+
};
|
|
8
|
+
exports.RedoIcon = RedoIcon;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UndoIcon = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const UndoIcon = (props) => {
|
|
6
|
+
return (jsx_runtime_1.jsx("svg", { viewBox: "0 0 640 640", ...props, children: jsx_runtime_1.jsx("path", { fill: "currentColor", d: "M88 256L232 256C241.7 256 250.5 250.2 254.2 241.2C257.9 232.2 255.9 221.9 249 215L202.3 168.3C277.6 109.7 386.6 115 455.8 184.2C530.8 259.2 530.8 380.7 455.8 455.7C380.8 530.7 259.3 530.7 184.3 455.7C174.1 445.5 165.3 434.4 157.9 422.7C148.4 407.8 128.6 403.4 113.7 412.9C98.8 422.4 94.4 442.2 103.9 457.1C113.7 472.7 125.4 487.5 139 501C239 601 401 601 501 501C601 401 601 239 501 139C406.8 44.7 257.3 39.3 156.7 122.8L105 71C98.1 64.2 87.8 62.1 78.8 65.8C69.8 69.5 64 78.3 64 88L64 232C64 245.3 74.7 256 88 256z" }) }));
|
|
7
|
+
};
|
|
8
|
+
exports.UndoIcon = UndoIcon;
|
package/dist/renderEntry.js
CHANGED
|
@@ -171,7 +171,7 @@ const renderToDOM = (content) => {
|
|
|
171
171
|
getRootForElement().render(content);
|
|
172
172
|
};
|
|
173
173
|
const renderContent = (Root) => {
|
|
174
|
-
var _a, _b;
|
|
174
|
+
var _a, _b, _c, _d;
|
|
175
175
|
const bundleMode = getBundleMode();
|
|
176
176
|
if (bundleMode.type === 'composition') {
|
|
177
177
|
const markup = (jsx_runtime_1.jsx(remotion_1.Internals.CompositionManagerProvider, { initialCanvasContent: null, onlyRenderComposition: bundleMode.compositionName, currentCompositionMetadata: {
|
|
@@ -185,13 +185,13 @@ const renderContent = (Root) => {
|
|
|
185
185
|
defaultVideoImageFormat: bundleMode.compositionDefaultVideoImageFormat,
|
|
186
186
|
defaultPixelFormat: bundleMode.compositionDefaultPixelFormat,
|
|
187
187
|
defaultProResProfile: bundleMode.compositionDefaultProResProfile,
|
|
188
|
-
}, initialCompositions: [], children: jsx_runtime_1.jsx(remotion_1.Internals.RemotionRootContexts, { frameState: null, audioEnabled: window.remotion_audioEnabled, videoEnabled: window.remotion_videoEnabled, logLevel: window.remotion_logLevel, numberOfAudioTags: 0, audioLatencyHint: (
|
|
188
|
+
}, initialCompositions: [], children: jsx_runtime_1.jsx(remotion_1.Internals.RemotionRootContexts, { frameState: null, audioEnabled: window.remotion_audioEnabled, videoEnabled: window.remotion_videoEnabled, logLevel: (_a = window.remotion_logLevel) !== null && _a !== void 0 ? _a : 'info', numberOfAudioTags: 0, audioLatencyHint: (_b = window.remotion_audioLatencyHint) !== null && _b !== void 0 ? _b : 'interactive', visualModeEnabled: false, children: jsx_runtime_1.jsxs(remotion_1.Internals.RenderAssetManagerProvider, { collectAssets: null, children: [
|
|
189
189
|
jsx_runtime_1.jsx(Root, {}), jsx_runtime_1.jsx(GetVideoComposition, { state: bundleMode })
|
|
190
190
|
] }) }) }));
|
|
191
191
|
renderToDOM(markup);
|
|
192
192
|
}
|
|
193
193
|
if (bundleMode.type === 'evaluation') {
|
|
194
|
-
const markup = (jsx_runtime_1.jsx(remotion_1.Internals.CompositionManagerProvider, { initialCanvasContent: null, onlyRenderComposition: null, currentCompositionMetadata: null, initialCompositions: [], children: jsx_runtime_1.jsx(remotion_1.Internals.RemotionRootContexts, { frameState: null, audioEnabled: window.remotion_audioEnabled, videoEnabled: window.remotion_videoEnabled, logLevel: window.remotion_logLevel, numberOfAudioTags: 0, audioLatencyHint: (
|
|
194
|
+
const markup = (jsx_runtime_1.jsx(remotion_1.Internals.CompositionManagerProvider, { initialCanvasContent: null, onlyRenderComposition: null, currentCompositionMetadata: null, initialCompositions: [], children: jsx_runtime_1.jsx(remotion_1.Internals.RemotionRootContexts, { frameState: null, audioEnabled: window.remotion_audioEnabled, videoEnabled: window.remotion_videoEnabled, logLevel: (_c = window.remotion_logLevel) !== null && _c !== void 0 ? _c : 'info', numberOfAudioTags: 0, audioLatencyHint: (_d = window.remotion_audioLatencyHint) !== null && _d !== void 0 ? _d : 'interactive', visualModeEnabled: false, children: jsx_runtime_1.jsx(remotion_1.Internals.RenderAssetManagerProvider, { collectAssets: null, children: jsx_runtime_1.jsx(Root, {}) }) }) }));
|
|
195
195
|
renderToDOM(markup);
|
|
196
196
|
}
|
|
197
197
|
if (bundleMode.type === 'index') {
|
|
@@ -227,6 +227,7 @@ const setBundleModeAndUpdate = (state) => {
|
|
|
227
227
|
exports.setBundleModeAndUpdate = setBundleModeAndUpdate;
|
|
228
228
|
if (typeof window !== 'undefined') {
|
|
229
229
|
const getUnevaluatedComps = () => {
|
|
230
|
+
var _a, _b, _c;
|
|
230
231
|
if (!remotion_1.Internals.getRoot()) {
|
|
231
232
|
throw new Error('registerRoot() was never called. 1. Make sure you specified the correct entrypoint for your bundle. 2. If your registerRoot() call is deferred, use the delayRender/continueRender pattern to tell Remotion to wait.');
|
|
232
233
|
}
|
|
@@ -236,14 +237,14 @@ if (typeof window !== 'undefined') {
|
|
|
236
237
|
const compositions = remotion_1.Internals.compositionsRef.current.getCompositions();
|
|
237
238
|
const canSerializeDefaultProps = getCanSerializeDefaultProps(compositions);
|
|
238
239
|
if (!canSerializeDefaultProps) {
|
|
239
|
-
remotion_1.Internals.Log.warn({ logLevel: window.remotion_logLevel, tag: null }, 'defaultProps are too big to serialize - trying to find the problematic composition...');
|
|
240
|
-
remotion_1.Internals.Log.warn({ logLevel: window.remotion_logLevel, tag: null }, 'Serialization:', compositions);
|
|
240
|
+
remotion_1.Internals.Log.warn({ logLevel: (_a = window.remotion_logLevel) !== null && _a !== void 0 ? _a : 'info', tag: null }, 'defaultProps are too big to serialize - trying to find the problematic composition...');
|
|
241
|
+
remotion_1.Internals.Log.warn({ logLevel: (_b = window.remotion_logLevel) !== null && _b !== void 0 ? _b : 'info', tag: null }, 'Serialization:', compositions);
|
|
241
242
|
for (const comp of compositions) {
|
|
242
243
|
if (!getCanSerializeDefaultProps(comp)) {
|
|
243
244
|
throw new Error(`defaultProps too big - could not serialize - the defaultProps of composition with ID ${comp.id} - the object that was passed to defaultProps was too big. Learn how to mitigate this error by visiting https://remotion.dev/docs/troubleshooting/serialize-defaultprops`);
|
|
244
245
|
}
|
|
245
246
|
}
|
|
246
|
-
remotion_1.Internals.Log.warn({ logLevel: window.remotion_logLevel, tag: null }, 'Could not single out a problematic composition - The composition list as a whole is too big to serialize.');
|
|
247
|
+
remotion_1.Internals.Log.warn({ logLevel: (_c = window.remotion_logLevel) !== null && _c !== void 0 ? _c : 'info', tag: null }, 'Could not single out a problematic composition - The composition list as a whole is too big to serialize.');
|
|
247
248
|
throw new Error('defaultProps too big - Could not serialize - an object that was passed to defaultProps was too big. Learn how to mitigate this error by visiting https://remotion.dev/docs/troubleshooting/serialize-defaultprops');
|
|
248
249
|
}
|
|
249
250
|
return compositions;
|
|
@@ -7,6 +7,7 @@ const remotion_1 = require("remotion");
|
|
|
7
7
|
const get_zod_schema_from_primitive_1 = require("../api/get-zod-schema-from-primitive");
|
|
8
8
|
const get_zod_if_possible_1 = require("../components/get-zod-if-possible");
|
|
9
9
|
const get_current_edited_value_1 = require("./get-current-edited-value");
|
|
10
|
+
const visual_control_store_1 = require("./visual-control-store");
|
|
10
11
|
exports.VisualControlsTabActivatedContext = (0, react_1.createContext)(false);
|
|
11
12
|
exports.VisualControlsContext = (0, react_1.createContext)({
|
|
12
13
|
handles: {},
|
|
@@ -32,16 +33,18 @@ const VisualControlsProvider = ({ children }) => {
|
|
|
32
33
|
};
|
|
33
34
|
}, [handles]);
|
|
34
35
|
const setControl = (0, react_1.useCallback)((key, value) => {
|
|
35
|
-
var _a
|
|
36
|
-
const
|
|
37
|
-
const currentSavedState =
|
|
36
|
+
var _a;
|
|
37
|
+
const existingHandle = (_a = imperativeHandles.current) === null || _a === void 0 ? void 0 : _a[key];
|
|
38
|
+
const currentSavedState = existingHandle === null || existingHandle === void 0 ? void 0 : existingHandle.valueInCode;
|
|
38
39
|
const changedSavedValue = value.valueInCode !== currentSavedState;
|
|
39
|
-
const changedUnsavedValue =
|
|
40
|
+
const changedUnsavedValue = existingHandle === undefined && value.valueInCode !== undefined;
|
|
40
41
|
imperativeHandles.current = {
|
|
41
42
|
...imperativeHandles.current,
|
|
42
43
|
[key]: {
|
|
43
44
|
...value,
|
|
44
|
-
unsavedValue:
|
|
45
|
+
unsavedValue: existingHandle !== undefined && !changedSavedValue
|
|
46
|
+
? existingHandle.unsavedValue
|
|
47
|
+
: value.valueInCode,
|
|
45
48
|
valueInCode: value.valueInCode,
|
|
46
49
|
},
|
|
47
50
|
};
|
|
@@ -93,6 +96,7 @@ const VisualControlsProvider = ({ children }) => {
|
|
|
93
96
|
},
|
|
94
97
|
};
|
|
95
98
|
updateHandles();
|
|
99
|
+
visual_control_store_1.visualControlStore.emitChange();
|
|
96
100
|
}, [updateHandles]);
|
|
97
101
|
(0, react_1.useImperativeHandle)(exports.visualControlRef, () => {
|
|
98
102
|
return {
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getVisualControlEditedValue = void 0;
|
|
4
4
|
const getVisualControlEditedValue = ({ handles, key, }) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const handle = handles === null || handles === void 0 ? void 0 : handles[key];
|
|
6
|
+
if (handle === undefined) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
return handle.unsavedValue;
|
|
9
10
|
};
|
|
10
11
|
exports.getVisualControlEditedValue = getVisualControlEditedValue;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.visualControlStore = void 0;
|
|
4
|
+
let version = 0;
|
|
5
|
+
const listeners = new Set();
|
|
6
|
+
exports.visualControlStore = {
|
|
7
|
+
subscribe(listener) {
|
|
8
|
+
listeners.add(listener);
|
|
9
|
+
return () => {
|
|
10
|
+
listeners.delete(listener);
|
|
11
|
+
};
|
|
12
|
+
},
|
|
13
|
+
getSnapshot() {
|
|
14
|
+
return version;
|
|
15
|
+
},
|
|
16
|
+
emitChange() {
|
|
17
|
+
version++;
|
|
18
|
+
for (const listener of listeners) {
|
|
19
|
+
listener();
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"url": "https://github.com/remotion-dev/remotion/tree/main/packages/studio"
|
|
4
4
|
},
|
|
5
5
|
"name": "@remotion/studio",
|
|
6
|
-
"version": "4.0.
|
|
6
|
+
"version": "4.0.439",
|
|
7
7
|
"description": "APIs for interacting with the Remotion Studio",
|
|
8
8
|
"main": "dist",
|
|
9
9
|
"sideEffects": false,
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"semver": "7.5.3",
|
|
29
|
-
"remotion": "4.0.
|
|
30
|
-
"@remotion/player": "4.0.
|
|
31
|
-
"@remotion/media-utils": "4.0.
|
|
32
|
-
"@remotion/renderer": "4.0.
|
|
33
|
-
"@remotion/web-renderer": "4.0.
|
|
34
|
-
"@remotion/studio-shared": "4.0.
|
|
35
|
-
"@remotion/zod-types": "4.0.
|
|
29
|
+
"remotion": "4.0.439",
|
|
30
|
+
"@remotion/player": "4.0.439",
|
|
31
|
+
"@remotion/media-utils": "4.0.439",
|
|
32
|
+
"@remotion/renderer": "4.0.439",
|
|
33
|
+
"@remotion/web-renderer": "4.0.439",
|
|
34
|
+
"@remotion/studio-shared": "4.0.439",
|
|
35
|
+
"@remotion/zod-types": "4.0.439",
|
|
36
36
|
"mediabunny": "1.39.2",
|
|
37
37
|
"memfs": "3.4.3",
|
|
38
38
|
"source-map": "0.7.3",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"react": "19.2.3",
|
|
44
44
|
"react-dom": "19.2.3",
|
|
45
45
|
"@types/semver": "^7.3.4",
|
|
46
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
46
|
+
"@remotion/eslint-config-internal": "4.0.439",
|
|
47
47
|
"eslint": "9.19.0",
|
|
48
48
|
"@typescript/native-preview": "7.0.0-dev.20260217.1"
|
|
49
49
|
},
|
|
@@ -1,78 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.GlobalPropsEditorUpdateButton = void 0;
|
|
37
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
38
|
-
const react_1 = __importStar(require("react"));
|
|
39
|
-
const remotion_1 = require("remotion");
|
|
40
|
-
const save_default_props_1 = require("../api/save-default-props");
|
|
41
|
-
const fast_refresh_context_1 = require("../fast-refresh-context");
|
|
42
|
-
const NotificationCenter_1 = require("./Notifications/NotificationCenter");
|
|
43
|
-
const SchemaResetButton_1 = require("./RenderModal/SchemaEditor/SchemaResetButton");
|
|
44
|
-
const SchemaSaveButton_1 = require("./RenderModal/SchemaEditor/SchemaSaveButton");
|
|
45
|
-
const container = {
|
|
46
|
-
display: 'inline-block',
|
|
47
|
-
flexDirection: 'row',
|
|
48
|
-
};
|
|
49
|
-
const GlobalPropsEditorUpdateButton = ({ compositionId, currentDefaultProps }) => {
|
|
50
|
-
const { fastRefreshes } = (0, react_1.useContext)(fast_refresh_context_1.FastRefreshContext);
|
|
51
|
-
const [disabled, setDisabled] = react_1.default.useState(false);
|
|
52
|
-
const onClicked = (0, react_1.useCallback)(() => {
|
|
53
|
-
setDisabled(true);
|
|
54
|
-
window.remotion_ignoreFastRefreshUpdate = fastRefreshes + 1;
|
|
55
|
-
(0, save_default_props_1.saveDefaultProps)({
|
|
56
|
-
compositionId,
|
|
57
|
-
defaultProps: () => currentDefaultProps,
|
|
58
|
-
})
|
|
59
|
-
.catch((err) => {
|
|
60
|
-
(0, NotificationCenter_1.showNotification)(`Cannot update default props: ${err.stack}`, 2000);
|
|
61
|
-
})
|
|
62
|
-
.finally(() => {
|
|
63
|
-
setDisabled(true);
|
|
64
|
-
});
|
|
65
|
-
}, [compositionId, currentDefaultProps, fastRefreshes]);
|
|
66
|
-
const onReset = (0, react_1.useCallback)(() => {
|
|
67
|
-
window.remotion_ignoreFastRefreshUpdate = null;
|
|
68
|
-
window.dispatchEvent(new CustomEvent(remotion_1.Internals.PROPS_UPDATED_EXTERNALLY, {
|
|
69
|
-
detail: {
|
|
70
|
-
resetUnsaved: compositionId,
|
|
71
|
-
},
|
|
72
|
-
}));
|
|
73
|
-
}, [compositionId]);
|
|
74
|
-
return (jsx_runtime_1.jsxs("div", { style: container, children: [
|
|
75
|
-
jsx_runtime_1.jsx(SchemaResetButton_1.SchemaResetButton, { onClick: onReset }), jsx_runtime_1.jsx(SchemaSaveButton_1.SchemaSaveButton, { disabled: disabled, onClick: onClicked })
|
|
76
|
-
] }));
|
|
77
|
-
};
|
|
78
|
-
exports.GlobalPropsEditorUpdateButton = GlobalPropsEditorUpdateButton;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SchemaSaveButton = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const colors_1 = require("../../../helpers/colors");
|
|
7
|
-
const InlineAction_1 = require("../../InlineAction");
|
|
8
|
-
const icon = {
|
|
9
|
-
height: 14,
|
|
10
|
-
color: 'currentColor',
|
|
11
|
-
};
|
|
12
|
-
const SchemaSaveButton = ({ onClick, disabled }) => {
|
|
13
|
-
const renderAction = (0, react_1.useCallback)((color) => {
|
|
14
|
-
return (jsx_runtime_1.jsx("svg", { style: icon, viewBox: "0 0 448 512", children: jsx_runtime_1.jsx("path", { fill: disabled ? colors_1.LIGHT_TEXT : color, d: "M64 32C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64H384c35.3 0 64-28.7 64-64V173.3c0-17-6.7-33.3-18.7-45.3L352 50.7C340 38.7 323.7 32 306.7 32H64zm0 96c0-17.7 14.3-32 32-32H288c17.7 0 32 14.3 32 32v64c0 17.7-14.3 32-32 32H96c-17.7 0-32-14.3-32-32V128zM224 288a64 64 0 1 1 0 128 64 64 0 1 1 0-128z" }) }));
|
|
15
|
-
}, [disabled]);
|
|
16
|
-
return (jsx_runtime_1.jsx(InlineAction_1.InlineAction, { renderAction: renderAction, onClick: onClick, disabled: disabled }));
|
|
17
|
-
};
|
|
18
|
-
exports.SchemaSaveButton = SchemaSaveButton;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { AnyZodSchema, ZodSafeParseResult } from './zod-schema-type';
|
|
3
|
-
import type { UpdaterFunction } from './ZodSwitch';
|
|
4
|
-
export type LocalState<T> = {
|
|
5
|
-
value: T;
|
|
6
|
-
zodValidation: ZodSafeParseResult;
|
|
7
|
-
keyStabilityRevision: number;
|
|
8
|
-
};
|
|
9
|
-
export type RevisionContextType = {
|
|
10
|
-
childResetRevision: number;
|
|
11
|
-
};
|
|
12
|
-
export declare const RevisionContext: React.Context<RevisionContextType>;
|
|
13
|
-
export declare const useLocalState: <T>({ unsavedValue, schema, setValue, savedValue, }: {
|
|
14
|
-
unsavedValue: T;
|
|
15
|
-
schema: AnyZodSchema;
|
|
16
|
-
setValue: UpdaterFunction<T>;
|
|
17
|
-
savedValue: T;
|
|
18
|
-
}) => {
|
|
19
|
-
localValue: LocalState<T>;
|
|
20
|
-
onChange: (updater: (oldV: T) => T, forceApply: boolean, increment: boolean) => void;
|
|
21
|
-
reset: () => void;
|
|
22
|
-
RevisionContextProvider: ({ children }: {
|
|
23
|
-
children: React.ReactNode;
|
|
24
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
-
};
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useLocalState = exports.RevisionContext = 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 deep_equal_1 = require("./deep-equal");
|
|
8
|
-
const zod_schema_type_1 = require("./zod-schema-type");
|
|
9
|
-
exports.RevisionContext = (0, react_1.createContext)({
|
|
10
|
-
childResetRevision: 0,
|
|
11
|
-
});
|
|
12
|
-
const useLocalState = ({ unsavedValue, schema, setValue, savedValue, }) => {
|
|
13
|
-
const parentRevision = (0, react_1.useContext)(exports.RevisionContext).childResetRevision;
|
|
14
|
-
const [resetRevision, setResetRevision] = (0, react_1.useState)(0);
|
|
15
|
-
const [localValueOrNull, setLocalValue] = (0, react_1.useState)(() => {
|
|
16
|
-
return {
|
|
17
|
-
[parentRevision]: {
|
|
18
|
-
value: unsavedValue,
|
|
19
|
-
keyStabilityRevision: 0,
|
|
20
|
-
zodValidation: (0, zod_schema_type_1.zodSafeParse)(schema, unsavedValue),
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
const localUnsavedValue = (0, react_1.useMemo)(() => {
|
|
25
|
-
var _a;
|
|
26
|
-
if (((_a = localValueOrNull[parentRevision]) !== null && _a !== void 0 ? _a : null) === null) {
|
|
27
|
-
return {
|
|
28
|
-
value: unsavedValue,
|
|
29
|
-
keyStabilityRevision: 0,
|
|
30
|
-
zodValidation: (0, zod_schema_type_1.zodSafeParse)(schema, unsavedValue),
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
return localValueOrNull[parentRevision];
|
|
34
|
-
}, [localValueOrNull, parentRevision, schema, unsavedValue]);
|
|
35
|
-
(0, react_1.useEffect)(() => {
|
|
36
|
-
const checkFile = () => {
|
|
37
|
-
setResetRevision((old) => old + 1);
|
|
38
|
-
setLocalValue({});
|
|
39
|
-
};
|
|
40
|
-
window.addEventListener(remotion_1.Internals.PROPS_UPDATED_EXTERNALLY, checkFile);
|
|
41
|
-
return () => {
|
|
42
|
-
window.removeEventListener(remotion_1.Internals.PROPS_UPDATED_EXTERNALLY, checkFile);
|
|
43
|
-
};
|
|
44
|
-
}, []);
|
|
45
|
-
const currentLocalValue = (0, react_1.useMemo)(() => {
|
|
46
|
-
return (localUnsavedValue !== null && localUnsavedValue !== void 0 ? localUnsavedValue : {
|
|
47
|
-
value: savedValue,
|
|
48
|
-
keyStabilityRevision: 0,
|
|
49
|
-
zodValidation: (0, zod_schema_type_1.zodSafeParse)(schema, savedValue),
|
|
50
|
-
});
|
|
51
|
-
}, [localUnsavedValue, savedValue, schema]);
|
|
52
|
-
const stateRef = (0, react_1.useRef)(currentLocalValue);
|
|
53
|
-
stateRef.current = currentLocalValue;
|
|
54
|
-
const onChange = (0, react_1.useCallback)(
|
|
55
|
-
// Increment is to regenerate `key` attributes in array items,
|
|
56
|
-
// so should increment when changing array items
|
|
57
|
-
(updater, forceApply, increment) => {
|
|
58
|
-
const newValue = updater(stateRef.current.value);
|
|
59
|
-
const isSame = (0, deep_equal_1.deepEqual)(newValue, stateRef.current.value);
|
|
60
|
-
if (isSame) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const safeParse = (0, zod_schema_type_1.zodSafeParse)(schema, newValue);
|
|
64
|
-
if (safeParse.success || forceApply) {
|
|
65
|
-
setValue(updater, forceApply, increment);
|
|
66
|
-
}
|
|
67
|
-
setLocalValue(() => {
|
|
68
|
-
const newState = {
|
|
69
|
-
keyStabilityRevision: currentLocalValue.keyStabilityRevision + (increment ? 1 : 0),
|
|
70
|
-
value: newValue,
|
|
71
|
-
zodValidation: safeParse,
|
|
72
|
-
};
|
|
73
|
-
stateRef.current = newState;
|
|
74
|
-
return {
|
|
75
|
-
...localUnsavedValue,
|
|
76
|
-
[parentRevision]: newState,
|
|
77
|
-
};
|
|
78
|
-
});
|
|
79
|
-
}, [
|
|
80
|
-
currentLocalValue.keyStabilityRevision,
|
|
81
|
-
localUnsavedValue,
|
|
82
|
-
parentRevision,
|
|
83
|
-
schema,
|
|
84
|
-
setValue,
|
|
85
|
-
]);
|
|
86
|
-
const contextValue = (0, react_1.useMemo)(() => {
|
|
87
|
-
return {
|
|
88
|
-
childResetRevision: resetRevision,
|
|
89
|
-
};
|
|
90
|
-
}, [resetRevision]);
|
|
91
|
-
const reset = (0, react_1.useCallback)(() => {
|
|
92
|
-
// Only need to do key stability for arrays, but
|
|
93
|
-
// since user is not editing right now, should be fine
|
|
94
|
-
onChange(() => savedValue, true, true);
|
|
95
|
-
setResetRevision((old) => old + 1);
|
|
96
|
-
}, [savedValue, onChange]);
|
|
97
|
-
const RevisionContextProvider = (0, react_1.useCallback)(({ children }) => {
|
|
98
|
-
return (jsx_runtime_1.jsx(exports.RevisionContext.Provider, { value: contextValue, children: children }));
|
|
99
|
-
}, [contextValue]);
|
|
100
|
-
return (0, react_1.useMemo)(() => ({
|
|
101
|
-
localValue: currentLocalValue,
|
|
102
|
-
onChange,
|
|
103
|
-
reset,
|
|
104
|
-
RevisionContextProvider,
|
|
105
|
-
}), [RevisionContextProvider, currentLocalValue, onChange, reset]);
|
|
106
|
-
};
|
|
107
|
-
exports.useLocalState = useLocalState;
|