@remotion/cli 3.3.78 → 3.3.80
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/better-opn/index.d.ts +6 -0
- package/dist/better-opn/index.js +202 -0
- package/dist/codemods/update-default-props.d.ts +5 -0
- package/dist/codemods/update-default-props.js +98 -0
- package/dist/editor/components/Checkbox.js +1 -0
- package/dist/editor/components/CollapsedSidebarExpander.d.ts +5 -0
- package/dist/editor/components/CollapsedSidebarExpander.js +40 -0
- package/dist/editor/components/CurrentCompositionSideEffects.js +11 -2
- package/dist/editor/components/InlineAction.js +1 -1
- package/dist/editor/components/Modals.js +3 -3
- package/dist/editor/components/NewComposition/RemTextarea.d.ts +7 -0
- package/dist/editor/components/NewComposition/RemTextarea.js +90 -0
- package/dist/editor/components/RenderButton.d.ts +2 -2
- package/dist/editor/components/RenderButton.js +5 -0
- package/dist/editor/components/RenderModal/CliCopyButton.d.ts +4 -0
- package/dist/editor/components/RenderModal/CliCopyButton.js +22 -0
- package/dist/editor/components/RenderModal/CrfSetting.d.ts +2 -1
- package/dist/editor/components/RenderModal/CrfSetting.js +2 -2
- package/dist/editor/components/RenderModal/EnforceAudioTrackSetting.d.ts +2 -0
- package/dist/editor/components/RenderModal/EnforceAudioTrackSetting.js +4 -2
- package/dist/editor/components/RenderModal/EnvInput.d.ts +10 -0
- package/dist/editor/components/RenderModal/EnvInput.js +54 -0
- package/dist/editor/components/RenderModal/FrameRangeSetting.js +1 -1
- package/dist/editor/components/RenderModal/{RenderErrorModal.d.ts → GuiRenderStatus.d.ts} +1 -1
- package/dist/editor/components/RenderModal/GuiRenderStatus.js +78 -0
- package/dist/editor/components/RenderModal/InfoBubble.js +16 -12
- package/dist/editor/components/RenderModal/InfoTooltip.d.ts +1 -0
- package/dist/editor/components/RenderModal/InfoTooltip.js +25 -16
- package/dist/editor/components/RenderModal/InlineEyeIcon.d.ts +5 -0
- package/dist/editor/components/RenderModal/InlineEyeIcon.js +38 -0
- package/dist/editor/components/RenderModal/InlineRemoveButton.d.ts +4 -0
- package/dist/editor/components/RenderModal/InlineRemoveButton.js +14 -0
- package/dist/editor/components/RenderModal/JpegQualitySetting.d.ts +5 -0
- package/dist/editor/components/RenderModal/JpegQualitySetting.js +12 -0
- package/dist/editor/components/RenderModal/MutedSetting.d.ts +2 -0
- package/dist/editor/components/RenderModal/MutedSetting.js +4 -2
- package/dist/editor/components/RenderModal/NumberOfLoopsSetting.js +1 -1
- package/dist/editor/components/RenderModal/NumberSetting.js +1 -1
- package/dist/editor/components/RenderModal/OptionExplainer.d.ts +1 -1
- package/dist/editor/components/RenderModal/OptionExplainer.js +26 -2
- package/dist/editor/components/RenderModal/RenderModal.d.ts +6 -1
- package/dist/editor/components/RenderModal/RenderModal.js +52 -9
- package/dist/editor/components/RenderModal/RenderModalAdvanced.d.ts +11 -0
- package/dist/editor/components/RenderModal/RenderModalAdvanced.js +34 -2
- package/dist/editor/components/RenderModal/RenderModalAudio.js +3 -1
- package/dist/editor/components/RenderModal/RenderModalBasic.d.ts +3 -2
- package/dist/editor/components/RenderModal/RenderModalBasic.js +5 -7
- package/dist/editor/components/RenderModal/RenderModalData.d.ts +10 -0
- package/dist/editor/components/RenderModal/RenderModalData.js +55 -0
- package/dist/editor/components/RenderModal/RenderModalEnvironmentVariables.d.ts +5 -0
- package/dist/editor/components/RenderModal/RenderModalEnvironmentVariables.js +52 -0
- package/dist/editor/components/RenderModal/RenderModalInput.d.ts +10 -0
- package/dist/editor/components/RenderModal/RenderModalInput.js +13 -0
- package/dist/editor/components/RenderModal/RenderModalJSONInputPropsEditor.d.ts +8 -0
- package/dist/editor/components/RenderModal/RenderModalJSONInputPropsEditor.js +87 -0
- package/dist/editor/components/RenderModal/RenderModalPicture.js +6 -4
- package/dist/editor/components/RenderModal/RenderStatusModal.d.ts +4 -0
- package/dist/editor/components/RenderModal/{RenderErrorModal.js → RenderStatusModal.js} +21 -14
- package/dist/editor/components/RenderModal/ScaleSetting.js +6 -3
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaEditor.d.ts +12 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaEditor.js +36 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaLabel.d.ts +15 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaLabel.js +43 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaResetButton.d.ts +4 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaResetButton.js +12 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaSaveButton.d.ts +4 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaSaveButton.js +12 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.d.ts +14 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.js +70 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayItemEditor.d.ts +13 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayItemEditor.js +28 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.d.ts +12 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.js +27 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodDateEditor.d.ts +14 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodDateEditor.js +75 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEffectEditor.d.ts +14 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEffectEditor.js +51 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodErrorMessages.d.ts +5 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodErrorMessages.js +23 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.d.ts +8 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.js +23 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.d.ts +14 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.js +89 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.d.ts +14 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.js +57 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStringEditor.d.ts +14 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStringEditor.js +43 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodSwitch.d.ts +14 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodSwitch.js +56 -0
- package/dist/editor/components/RenderModal/SchemaEditor/date-serialization.d.ts +2 -0
- package/dist/editor/components/RenderModal/SchemaEditor/date-serialization.js +21 -0
- package/dist/editor/components/RenderModal/SchemaEditor/get-schema-label.d.ts +2 -0
- package/dist/editor/components/RenderModal/SchemaEditor/get-schema-label.js +15 -0
- package/dist/editor/components/RenderModal/SchemaEditor/zod-types.d.ts +1 -0
- package/dist/editor/components/RenderModal/SchemaEditor/zod-types.js +2 -0
- package/dist/editor/components/RenderModal/layout.d.ts +3 -1
- package/dist/editor/components/RenderModal/layout.js +19 -3
- package/dist/editor/components/RenderModal/out-name-checker.d.ts +15 -0
- package/dist/editor/components/RenderModal/out-name-checker.js +79 -0
- package/dist/editor/components/RenderQueue/RenderQueueError.js +3 -3
- package/dist/editor/components/RenderQueue/RenderQueueItemStatus.js +18 -2
- package/dist/editor/components/RenderQueue/RenderQueueOutputName.js +4 -2
- package/dist/editor/components/RenderQueue/RenderQueueProgressMessage.js +3 -4
- package/dist/editor/components/RenderQueue/RenderQueueRemoveItem.js +11 -1
- package/dist/editor/components/RenderQueue/SuccessIcon.d.ts +2 -0
- package/dist/editor/components/RenderQueue/SuccessIcon.js +14 -0
- package/dist/editor/components/RenderQueue/actions.d.ts +11 -2
- package/dist/editor/components/RenderQueue/actions.js +18 -3
- package/dist/editor/components/RenderToolbarIcon.js +5 -0
- package/dist/editor/components/RightPanel.d.ts +2 -0
- package/dist/editor/components/RightPanel.js +43 -0
- package/dist/editor/components/SidebarContent.js +1 -0
- package/dist/editor/helpers/convert-env-variables.d.ts +2 -0
- package/dist/editor/helpers/convert-env-variables.js +20 -0
- package/dist/editor/helpers/get-timeline-sequence-layout.js +1 -1
- package/dist/editor/helpers/render-modal-sections.d.ts +1 -1
- package/dist/editor/helpers/render-modal-sections.js +4 -4
- package/dist/editor/icons/data.d.ts +2 -0
- package/dist/editor/icons/data.js +8 -0
- package/dist/editor/icons/save.d.ts +2 -0
- package/dist/editor/icons/save.js +8 -0
- package/dist/handle-common-errors.js +16 -0
- package/dist/parse-command-line.d.ts +2 -0
- package/dist/preview-server/api-routes.js +2 -0
- package/dist/preview-server/api-types.d.ts +2 -1
- package/dist/preview-server/render-queue/job.d.ts +25 -12
- package/dist/preview-server/render-queue/make-retry-payload.js +11 -1
- package/dist/preview-server/render-queue/open-directory-in-finder.d.ts +1 -1
- package/dist/preview-server/render-queue/open-directory-in-finder.js +10 -1
- package/dist/preview-server/render-queue/process-still.js +4 -10
- package/dist/preview-server/render-queue/process-video.js +4 -10
- package/dist/preview-server/render-queue/queue.js +38 -16
- package/dist/preview-server/routes/add-render.js +7 -0
- package/dist/preview-server/routes/open-in-file-explorer.js +1 -7
- package/dist/preview-server/routes/update-default-props.d.ts +3 -0
- package/dist/preview-server/routes/update-default-props.js +22 -0
- package/dist/preview.js +8 -3
- package/dist/progress-types.d.ts +32 -0
- package/dist/progress-types.js +17 -0
- package/dist/render-flows/render.js +66 -52
- package/dist/render-flows/still.js +18 -18
- package/dist/required-chromium-options.d.ts +3 -0
- package/dist/required-chromium-options.js +2 -0
- package/package.json +7 -7
- package/dist/editor/components/RenderModal/QualitySetting.d.ts +0 -5
- package/dist/editor/components/RenderModal/QualitySetting.js +0 -27
- package/dist/gcp-command.d.ts +0 -1
- package/dist/gcp-command.js +0 -27
|
@@ -8,9 +8,11 @@ const Checkmark_1 = require("../../icons/Checkmark");
|
|
|
8
8
|
const ComboBox_1 = require("../NewComposition/ComboBox");
|
|
9
9
|
const RemInput_1 = require("../NewComposition/RemInput");
|
|
10
10
|
const SegmentedControl_1 = require("../SegmentedControl");
|
|
11
|
+
const CrfSetting_1 = require("./CrfSetting");
|
|
12
|
+
const InfoBubble_1 = require("./InfoBubble");
|
|
13
|
+
const JpegQualitySetting_1 = require("./JpegQualitySetting");
|
|
11
14
|
const layout_1 = require("./layout");
|
|
12
|
-
const
|
|
13
|
-
const QualitySetting_1 = require("./QualitySetting");
|
|
15
|
+
const OptionExplainer_1 = require("./OptionExplainer");
|
|
14
16
|
const RenderModalHr_1 = require("./RenderModalHr");
|
|
15
17
|
const ScaleSetting_1 = require("./ScaleSetting");
|
|
16
18
|
const qualityControlModes = ['crf', 'bitrate'];
|
|
@@ -44,8 +46,8 @@ const RenderModalPicture = ({ renderMode, scale, setScale, pixelFormat, setPixel
|
|
|
44
46
|
const onTargetVideoBitrateChanged = (0, react_1.useCallback)((e) => {
|
|
45
47
|
setCustomTargetVideoBitrateValue(e.target.value);
|
|
46
48
|
}, [setCustomTargetVideoBitrateValue]);
|
|
47
|
-
return ((0, jsx_runtime_1.jsxs)("div", { children: [renderMode === 'video' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Image Format" }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)(SegmentedControl_1.SegmentedControl, { items: imageFormatOptions, needsWrapping: false }) })] })) : null, renderMode === 'video' && videoImageFormat === 'jpeg' && ((0, jsx_runtime_1.jsx)(
|
|
49
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [renderMode === 'video' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Image Format" }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)(SegmentedControl_1.SegmentedControl, { items: imageFormatOptions, needsWrapping: false }) })] })) : null, renderMode === 'video' && videoImageFormat === 'jpeg' && ((0, jsx_runtime_1.jsx)(JpegQualitySetting_1.JpegQualitySetting, { quality: quality, setQuality: setQuality })), renderMode === 'still' && stillImageFormat === 'jpeg' && ((0, jsx_runtime_1.jsx)(JpegQualitySetting_1.JpegQualitySetting, { quality: quality, setQuality: setQuality })), renderMode === 'video' ? (0, jsx_runtime_1.jsx)(RenderModalHr_1.RenderModalHr, {}) : null, renderMode === 'video' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Quality control" }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)(SegmentedControl_1.SegmentedControl, { items: qualityControlOptions, needsWrapping: true }) })] })) : null, shouldDisplayCrfOption &&
|
|
48
50
|
qualityControlType === 'crf' &&
|
|
49
|
-
renderMode !== 'still' ? ((0, jsx_runtime_1.jsx)(
|
|
51
|
+
renderMode !== 'still' ? ((0, jsx_runtime_1.jsx)(CrfSetting_1.CrfSetting, { crf: crf, min: minCrf, max: maxCrf, setCrf: setCrf, option: client_1.BrowserSafeApis.options.crfOption })) : null, qualityControlType === 'bitrate' && renderMode !== 'still' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Target video bitrate" }), (0, jsx_runtime_1.jsx)(InfoBubble_1.InfoBubble, { title: "Learn more about this option", children: (0, jsx_runtime_1.jsx)(OptionExplainer_1.OptionExplainer, { option: client_1.BrowserSafeApis.options.videoBitrate }) }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(RemInput_1.RemotionInput, { style: layout_1.input, value: customTargetVideoBitrate, onChange: onTargetVideoBitrateChanged, status: "ok" }) }) })] })) : null, renderMode === 'video' ? (0, jsx_runtime_1.jsx)(RenderModalHr_1.RenderModalHr, {}) : null, (0, jsx_runtime_1.jsx)(ScaleSetting_1.ScaleSetting, { scale: scale, setScale: setScale }), renderMode === 'video' ? (0, jsx_runtime_1.jsx)(RenderModalHr_1.RenderModalHr, {}) : null, renderMode === 'video' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Pixel format" }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)(ComboBox_1.Combobox, { values: pixelFormatOptions, selectedId: pixelFormat, title: "Pixel Format" }) })] })) : null] }));
|
|
50
52
|
};
|
|
51
53
|
exports.RenderModalPicture = RenderModalPicture;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.RenderStatusModal = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const Button_1 = require("../../../preview-server/error-overlay/remotion-overlay/Button");
|
|
@@ -11,13 +11,15 @@ const ModalContainer_1 = require("../ModalContainer");
|
|
|
11
11
|
const ModalHeader_1 = require("../ModalHeader");
|
|
12
12
|
const NotificationCenter_1 = require("../Notifications/NotificationCenter");
|
|
13
13
|
const actions_1 = require("../RenderQueue/actions");
|
|
14
|
+
const context_1 = require("../RenderQueue/context");
|
|
15
|
+
const GuiRenderStatus_1 = require("./GuiRenderStatus");
|
|
14
16
|
const container = {
|
|
15
17
|
padding: 20,
|
|
16
|
-
maxWidth:
|
|
18
|
+
maxWidth: 900,
|
|
17
19
|
paddingTop: 0,
|
|
18
20
|
};
|
|
19
21
|
const codeBlock = {
|
|
20
|
-
backgroundColor: '
|
|
22
|
+
backgroundColor: '#222',
|
|
21
23
|
whiteSpace: 'pre',
|
|
22
24
|
padding: 12,
|
|
23
25
|
borderRadius: 4,
|
|
@@ -34,8 +36,13 @@ const buttonRow = {
|
|
|
34
36
|
flexDirection: 'row',
|
|
35
37
|
justifyContent: 'flex-end',
|
|
36
38
|
};
|
|
37
|
-
const
|
|
39
|
+
const RenderStatusModal = ({ jobId }) => {
|
|
38
40
|
const { setSelectedModal } = (0, react_1.useContext)(modals_1.ModalsContext);
|
|
41
|
+
const { jobs } = (0, react_1.useContext)(context_1.RenderQueueContext);
|
|
42
|
+
const job = jobs.find((j) => j.id === jobId);
|
|
43
|
+
if (!job) {
|
|
44
|
+
throw new Error('job not found');
|
|
45
|
+
}
|
|
39
46
|
const onQuit = (0, react_1.useCallback)(() => {
|
|
40
47
|
setSelectedModal(null);
|
|
41
48
|
}, [setSelectedModal]);
|
|
@@ -46,19 +53,19 @@ const RenderErrorModal = ({ job }) => {
|
|
|
46
53
|
const onClickOnRemove = (0, react_1.useCallback)(() => {
|
|
47
54
|
setSelectedModal(null);
|
|
48
55
|
(0, actions_1.removeRenderJob)(job).catch((err) => {
|
|
49
|
-
|
|
50
|
-
(_a = NotificationCenter_1.notificationCenter.current) === null || _a === void 0 ? void 0 : _a.addNotification({
|
|
51
|
-
content: 'Failed to remove render job: ' + err.message,
|
|
52
|
-
created: Date.now(),
|
|
53
|
-
duration: 2000,
|
|
54
|
-
id: String(Math.random()),
|
|
55
|
-
});
|
|
56
|
+
(0, NotificationCenter_1.sendErrorNotification)(`Could not remove job: ${err.message}`);
|
|
56
57
|
console.log(err);
|
|
57
58
|
});
|
|
58
59
|
}, [job, setSelectedModal]);
|
|
59
|
-
|
|
60
|
+
const onClickOnCancel = (0, react_1.useCallback)(() => {
|
|
61
|
+
(0, actions_1.cancelRenderJob)(job).catch((err) => {
|
|
62
|
+
(0, NotificationCenter_1.sendErrorNotification)(`Could not cancel job: ${err.message}`);
|
|
63
|
+
console.log(err);
|
|
64
|
+
});
|
|
65
|
+
}, [job]);
|
|
66
|
+
if (!job || job.status === 'idle') {
|
|
60
67
|
throw new Error('should not have rendered this modal');
|
|
61
68
|
}
|
|
62
|
-
return ((0, jsx_runtime_1.jsxs)(ModalContainer_1.ModalContainer, { onOutsideClick: onQuit, onEscape: onQuit, children: [(0, jsx_runtime_1.jsx)(ModalHeader_1.NewCompHeader, { title: `Render ${job.compositionId}` }), (0, jsx_runtime_1.jsxs)("div", { style: container, children: [(0, jsx_runtime_1.jsx)("p", { children: "The render failed because of the following error:" }), (0, jsx_runtime_1.jsx)("div", { style: codeBlock, children: job.error.stack }), (0, jsx_runtime_1.jsx)("div", { style: spacer }), (0, jsx_runtime_1.jsxs)("div", { style: buttonRow, children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: onClickOnRemove, children: "Remove render" }), (0, jsx_runtime_1.jsx)(layout_1.Flex, {}), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: onRetry, children: "Retry" }), (0, jsx_runtime_1.jsx)("div", { style: spacer }), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: onQuit, children: "Close" })] })] })] }));
|
|
69
|
+
return ((0, jsx_runtime_1.jsxs)(ModalContainer_1.ModalContainer, { onOutsideClick: onQuit, onEscape: onQuit, children: [(0, jsx_runtime_1.jsx)(ModalHeader_1.NewCompHeader, { title: `Render ${job.compositionId}` }), (0, jsx_runtime_1.jsxs)("div", { style: container, children: [job.status === 'failed' ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("p", { children: "The render failed because of the following error:" }), (0, jsx_runtime_1.jsx)("div", { className: "__remotion-horizontal-scrollbar", style: codeBlock, children: job.error.stack })] })) : null, job.status === 'done' || job.status === 'running' ? ((0, jsx_runtime_1.jsx)(GuiRenderStatus_1.GuiRenderStatus, { job: job })) : null, (0, jsx_runtime_1.jsx)("div", { style: spacer }), (0, jsx_runtime_1.jsxs)("div", { style: buttonRow, children: [job.status === 'running' ? ((0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: onClickOnCancel, children: "Cancel render" })) : ((0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: onClickOnRemove, children: "Remove render" })), (0, jsx_runtime_1.jsx)(layout_1.Flex, {}), job.status === 'failed' ? ((0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: onRetry, children: "Retry" })) : null, (0, jsx_runtime_1.jsx)("div", { style: spacer }), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: onQuit, children: "Close" })] })] })] }));
|
|
63
70
|
};
|
|
64
|
-
exports.
|
|
71
|
+
exports.RenderStatusModal = RenderStatusModal;
|
|
@@ -7,8 +7,11 @@ const NumberSetting_1 = require("./NumberSetting");
|
|
|
7
7
|
const MIN_SCALE = 0.1;
|
|
8
8
|
const MAX_SCALE = 10;
|
|
9
9
|
const ScaleSetting = ({ scale, setScale }) => {
|
|
10
|
-
return (
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)(NumberSetting_1.NumberSetting, { min: MIN_SCALE, max: MAX_SCALE, step: 0.1, name: "Scale", formatter: (w) => {
|
|
11
|
+
if (typeof w === 'number') {
|
|
12
|
+
return `${w.toFixed(1)}x`;
|
|
13
|
+
}
|
|
14
|
+
return `${w}x`;
|
|
15
|
+
}, onValueChanged: setScale, value: scale, hint: client_1.BrowserSafeApis.options.scaleOption }));
|
|
13
16
|
};
|
|
14
17
|
exports.ScaleSetting = ScaleSetting;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { z } from 'remotion';
|
|
3
|
+
export declare const SchemaEditor: React.FC<{
|
|
4
|
+
schema: z.ZodTypeAny;
|
|
5
|
+
value: unknown;
|
|
6
|
+
setValue: React.Dispatch<React.SetStateAction<unknown>>;
|
|
7
|
+
zodValidationResult: z.SafeParseReturnType<unknown, unknown>;
|
|
8
|
+
compact: boolean;
|
|
9
|
+
defaultProps: unknown;
|
|
10
|
+
onSave: (updater: (oldState: unknown) => unknown) => void;
|
|
11
|
+
showSaveButton: boolean;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SchemaEditor = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const remotion_1 = require("remotion");
|
|
6
|
+
const colors_1 = require("../../../helpers/colors");
|
|
7
|
+
const layout_1 = require("../../layout");
|
|
8
|
+
const ZodErrorMessages_1 = require("./ZodErrorMessages");
|
|
9
|
+
const ZodObjectEditor_1 = require("./ZodObjectEditor");
|
|
10
|
+
const errorExplanation = {
|
|
11
|
+
fontSize: 14,
|
|
12
|
+
color: colors_1.LIGHT_TEXT,
|
|
13
|
+
fontFamily: 'sans-serif',
|
|
14
|
+
};
|
|
15
|
+
const codeSnippet = {
|
|
16
|
+
fontSize: 14,
|
|
17
|
+
color: colors_1.LIGHT_TEXT,
|
|
18
|
+
fontFamily: 'monospace',
|
|
19
|
+
};
|
|
20
|
+
const SchemaEditor = ({ schema, value, setValue, zodValidationResult, compact, defaultProps, onSave, showSaveButton, }) => {
|
|
21
|
+
const def = schema._def;
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
|
+
const typeName = def.typeName;
|
|
24
|
+
if (typeName === remotion_1.z.ZodFirstPartyTypeKind.ZodAny) {
|
|
25
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["The schema has an ", (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: "any" }), " type.", (0, jsx_runtime_1.jsx)("br", {}), " Tweak the schema by adding a", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: "schema" }), " prop to the", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: '<Composition>' }), " component."] }));
|
|
26
|
+
}
|
|
27
|
+
if (!zodValidationResult.success) {
|
|
28
|
+
// TODO: Distinguish between default props not valid and JSON input not valid
|
|
29
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", { style: errorExplanation, children: "The data does not satisfy the schema:" }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ZodErrorMessages_1.ZodErrorMessages, { zodValidationResult: zodValidationResult }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)("div", { style: errorExplanation, children: "Fix the schema using the JSON editor." })] }));
|
|
30
|
+
}
|
|
31
|
+
if (typeName === remotion_1.z.ZodFirstPartyTypeKind.ZodObject) {
|
|
32
|
+
return ((0, jsx_runtime_1.jsx)(ZodObjectEditor_1.ZodObjectEditor, { value: value, setValue: setValue, jsonPath: [], schema: schema, compact: compact, defaultValue: defaultProps, onSave: onSave, showSaveButton: showSaveButton, onRemove: null }));
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
};
|
|
36
|
+
exports.SchemaEditor = SchemaEditor;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { JSONPath } from './zod-types';
|
|
3
|
+
export declare const SchemaLabel: React.FC<{
|
|
4
|
+
jsonPath: JSONPath;
|
|
5
|
+
isDefaultValue: boolean;
|
|
6
|
+
onReset: () => void;
|
|
7
|
+
onSave: () => void;
|
|
8
|
+
onRemove: null | (() => void);
|
|
9
|
+
showSaveButton: boolean;
|
|
10
|
+
compact: boolean;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const SchemaFieldsetLabel: React.FC<{
|
|
13
|
+
jsonPath: JSONPath;
|
|
14
|
+
onRemove: null | (() => void);
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SchemaFieldsetLabel = exports.SchemaLabel = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const colors_1 = require("../../../helpers/colors");
|
|
6
|
+
const layout_1 = require("../../layout");
|
|
7
|
+
const InlineRemoveButton_1 = require("../InlineRemoveButton");
|
|
8
|
+
const layout_2 = require("../layout");
|
|
9
|
+
const get_schema_label_1 = require("./get-schema-label");
|
|
10
|
+
const SchemaResetButton_1 = require("./SchemaResetButton");
|
|
11
|
+
const SchemaSaveButton_1 = require("./SchemaSaveButton");
|
|
12
|
+
const commonStyles = {
|
|
13
|
+
fontSize: 15,
|
|
14
|
+
color: colors_1.LIGHT_TEXT,
|
|
15
|
+
fontFamily: 'sans-serif',
|
|
16
|
+
lineHeight: '40px',
|
|
17
|
+
};
|
|
18
|
+
const compactStyles = {
|
|
19
|
+
...commonStyles,
|
|
20
|
+
display: 'flex',
|
|
21
|
+
flexDirection: 'row',
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
};
|
|
24
|
+
const wideStyles = {
|
|
25
|
+
...commonStyles,
|
|
26
|
+
width: layout_2.label.width,
|
|
27
|
+
display: 'flex',
|
|
28
|
+
flexDirection: 'row',
|
|
29
|
+
alignItems: 'center',
|
|
30
|
+
};
|
|
31
|
+
const labelStyle = {
|
|
32
|
+
fontFamily: 'monospace',
|
|
33
|
+
fontSize: 14,
|
|
34
|
+
color: colors_1.LIGHT_TEXT,
|
|
35
|
+
};
|
|
36
|
+
const SchemaLabel = ({ jsonPath, isDefaultValue, onReset, onSave, showSaveButton, compact, onRemove, }) => {
|
|
37
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? compactStyles : wideStyles, children: [(0, jsx_runtime_1.jsx)("span", { style: labelStyle, children: (0, get_schema_label_1.getSchemaLabel)(jsonPath) }), compact ? (0, jsx_runtime_1.jsx)(layout_1.Flex, {}) : (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), isDefaultValue ? null : (0, jsx_runtime_1.jsx)(SchemaResetButton_1.SchemaResetButton, { onClick: onReset }), isDefaultValue ? null : showSaveButton ? ((0, jsx_runtime_1.jsx)(SchemaSaveButton_1.SchemaSaveButton, { onClick: onSave })) : null, onRemove ? (0, jsx_runtime_1.jsx)(InlineRemoveButton_1.InlineRemoveButton, { onClick: onRemove }) : null] }));
|
|
38
|
+
};
|
|
39
|
+
exports.SchemaLabel = SchemaLabel;
|
|
40
|
+
const SchemaFieldsetLabel = ({ jsonPath, onRemove }) => {
|
|
41
|
+
return ((0, jsx_runtime_1.jsxs)("legend", { style: layout_2.fieldsetLabel, children: [(0, get_schema_label_1.getSchemaLabel)(jsonPath), (0, jsx_runtime_1.jsx)(layout_1.Flex, {}), onRemove ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), " ", (0, jsx_runtime_1.jsx)(InlineRemoveButton_1.InlineRemoveButton, { onClick: onRemove })] })) : null] }));
|
|
42
|
+
};
|
|
43
|
+
exports.SchemaFieldsetLabel = SchemaFieldsetLabel;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SchemaResetButton = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const InlineAction_1 = require("../../InlineAction");
|
|
6
|
+
const icon = {
|
|
7
|
+
height: 14,
|
|
8
|
+
};
|
|
9
|
+
const SchemaResetButton = ({ onClick }) => {
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)(InlineAction_1.InlineAction, { onClick: onClick, children: (0, jsx_runtime_1.jsx)("svg", { style: icon, viewBox: "0 0 512 512", children: (0, jsx_runtime_1.jsx)("path", { fill: "currentcolor", d: "M48.5 224H40c-13.3 0-24-10.7-24-24V72c0-9.7 5.8-18.5 14.8-22.2s19.3-1.7 26.2 5.2L98.6 96.6c87.6-86.5 228.7-86.2 315.8 1c87.5 87.5 87.5 229.3 0 316.8s-229.3 87.5-316.8 0c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0c62.5 62.5 163.8 62.5 226.3 0s62.5-163.8 0-226.3c-62.2-62.2-162.7-62.5-225.3-1L185 183c6.9 6.9 8.9 17.2 5.2 26.2s-12.5 14.8-22.2 14.8H48.5z" }) }) }));
|
|
11
|
+
};
|
|
12
|
+
exports.SchemaResetButton = SchemaResetButton;
|
|
@@ -0,0 +1,12 @@
|
|
|
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 InlineAction_1 = require("../../InlineAction");
|
|
6
|
+
const icon = {
|
|
7
|
+
height: 14,
|
|
8
|
+
};
|
|
9
|
+
const SchemaSaveButton = ({ onClick }) => {
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)(InlineAction_1.InlineAction, { onClick: onClick, children: (0, jsx_runtime_1.jsx)("svg", { style: icon, viewBox: "0 0 448 512", children: (0, jsx_runtime_1.jsx)("path", { fill: "currentcolor", 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" }) }) }));
|
|
11
|
+
};
|
|
12
|
+
exports.SchemaSaveButton = SchemaSaveButton;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { z } from 'remotion';
|
|
3
|
+
import type { JSONPath } from './zod-types';
|
|
4
|
+
export declare const ZodArrayEditor: React.FC<{
|
|
5
|
+
schema: z.ZodTypeAny;
|
|
6
|
+
jsonPath: JSONPath;
|
|
7
|
+
value: unknown[];
|
|
8
|
+
defaultValue: unknown[];
|
|
9
|
+
setValue: React.Dispatch<React.SetStateAction<unknown[]>>;
|
|
10
|
+
onSave: (updater: (oldState: unknown[]) => unknown[]) => void;
|
|
11
|
+
compact: boolean;
|
|
12
|
+
showSaveButton: boolean;
|
|
13
|
+
onRemove: null | (() => void);
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZodArrayEditor = 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 colors_1 = require("../../../helpers/colors");
|
|
8
|
+
const layout_1 = require("../../layout");
|
|
9
|
+
const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
|
|
10
|
+
const layout_2 = require("../layout");
|
|
11
|
+
const SchemaLabel_1 = require("./SchemaLabel");
|
|
12
|
+
const ZodArrayItemEditor_1 = require("./ZodArrayItemEditor");
|
|
13
|
+
const container = {
|
|
14
|
+
width: '100%',
|
|
15
|
+
};
|
|
16
|
+
const fullWidth = {
|
|
17
|
+
width: '100%',
|
|
18
|
+
};
|
|
19
|
+
// TODO: Ability to add another item
|
|
20
|
+
const ZodArrayEditor = ({ schema, jsonPath, compact, setValue: updateValue, defaultValue, value, onSave, showSaveButton, onRemove, }) => {
|
|
21
|
+
const [localValue, setLocalValue] = (0, react_1.useState)(() => {
|
|
22
|
+
return {
|
|
23
|
+
value,
|
|
24
|
+
zodValidation: schema.safeParse(value),
|
|
25
|
+
revision: 0,
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
const def = schema._def;
|
|
29
|
+
const typeName = def.typeName;
|
|
30
|
+
if (typeName !== remotion_1.z.ZodFirstPartyTypeKind.ZodArray) {
|
|
31
|
+
throw new Error('expected object');
|
|
32
|
+
}
|
|
33
|
+
const isRoot = jsonPath.length === 0;
|
|
34
|
+
const Element = isRoot ? 'div' : 'fieldset';
|
|
35
|
+
const { paddingTop } = layout_2.optionRow;
|
|
36
|
+
const fieldset = (0, react_1.useMemo)(() => {
|
|
37
|
+
return {
|
|
38
|
+
borderRadius: 4,
|
|
39
|
+
borderColor: localValue.zodValidation.success
|
|
40
|
+
? colors_1.INPUT_BORDER_COLOR_UNHOVERED
|
|
41
|
+
: colors_1.FAIL_COLOR,
|
|
42
|
+
};
|
|
43
|
+
}, [localValue.zodValidation.success]);
|
|
44
|
+
const onChange = (0, react_1.useCallback)((updater, incrementRevision) => {
|
|
45
|
+
setLocalValue((oldLocalState) => {
|
|
46
|
+
const newValue = updater(oldLocalState.value);
|
|
47
|
+
const safeParse = schema.safeParse(newValue);
|
|
48
|
+
if (safeParse.success) {
|
|
49
|
+
updateValue(updater);
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
revision: oldLocalState.revision + (incrementRevision ? 1 : 0),
|
|
53
|
+
value: newValue,
|
|
54
|
+
zodValidation: safeParse,
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
}, [schema, updateValue]);
|
|
58
|
+
const style = (0, react_1.useMemo)(() => {
|
|
59
|
+
if (isRoot) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
return { paddingTop };
|
|
63
|
+
}, [isRoot, paddingTop]);
|
|
64
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: style, children: (0, jsx_runtime_1.jsx)("div", { style: fullWidth, children: (0, jsx_runtime_1.jsxs)(Element, { style: fieldset, children: [isRoot ? null : ((0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaFieldsetLabel, { jsonPath: jsonPath, onRemove: onRemove })), (0, jsx_runtime_1.jsx)("div", { style: isRoot ? undefined : container, children: localValue.value.map((child, i) => {
|
|
65
|
+
return ((0, jsx_runtime_1.jsx)(ZodArrayItemEditor_1.ZodArrayItemEditor
|
|
66
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
67
|
+
, { onChange: onChange, value: child, def: def, index: i, jsonPath: jsonPath, compact: compact, defaultValue: defaultValue[i], onSave: onSave, showSaveButton: showSaveButton }, `${i}${localValue.revision}`));
|
|
68
|
+
}) }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-end", message: localValue.zodValidation.error.format()._errors[0], type: "error" })] }))] }) }) }));
|
|
69
|
+
};
|
|
70
|
+
exports.ZodArrayEditor = ZodArrayEditor;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { JSONPath } from './zod-types';
|
|
3
|
+
export declare const ZodArrayItemEditor: React.FC<{
|
|
4
|
+
jsonPath: JSONPath;
|
|
5
|
+
onChange: (updater: (oldV: unknown[]) => unknown[], incrementRevision: boolean) => void;
|
|
6
|
+
def: any;
|
|
7
|
+
index: number;
|
|
8
|
+
value: unknown;
|
|
9
|
+
compact: boolean;
|
|
10
|
+
defaultValue: unknown;
|
|
11
|
+
onSave: (updater: (oldState: unknown[]) => unknown[]) => void;
|
|
12
|
+
showSaveButton: boolean;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZodArrayItemEditor = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const ZodSwitch_1 = require("./ZodSwitch");
|
|
7
|
+
const ZodArrayItemEditor = ({ def, onChange, jsonPath, index, value, compact, defaultValue, onSave: onSaveObject, showSaveButton, }) => {
|
|
8
|
+
const onRemove = (0, react_1.useCallback)(() => {
|
|
9
|
+
onChange((oldV) => [...oldV.slice(0, index), ...oldV.slice(index + 1)], true);
|
|
10
|
+
}, [index, onChange]);
|
|
11
|
+
const setValue = (0, react_1.useCallback)((val) => {
|
|
12
|
+
onChange((oldV) => [
|
|
13
|
+
...oldV.slice(0, index),
|
|
14
|
+
typeof val === 'function' ? val(oldV[index]) : val,
|
|
15
|
+
...oldV.slice(index + 1),
|
|
16
|
+
], false);
|
|
17
|
+
}, [index, onChange]);
|
|
18
|
+
const newJsonPath = (0, react_1.useMemo)(() => [...jsonPath, index], [index, jsonPath]);
|
|
19
|
+
const onSave = (0, react_1.useCallback)((updater) => {
|
|
20
|
+
onSaveObject((oldV) => [
|
|
21
|
+
...oldV.slice(0, index),
|
|
22
|
+
updater(oldV[index]),
|
|
23
|
+
...oldV.slice(index + 1),
|
|
24
|
+
]);
|
|
25
|
+
}, [index, onSaveObject]);
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(ZodSwitch_1.ZodSwitch, { jsonPath: newJsonPath, schema: def.type, value: value, setValue: setValue, compact: compact, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove }));
|
|
27
|
+
};
|
|
28
|
+
exports.ZodArrayItemEditor = ZodArrayItemEditor;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { JSONPath } from './zod-types';
|
|
3
|
+
export declare const ZodBooleanEditor: React.FC<{
|
|
4
|
+
jsonPath: JSONPath;
|
|
5
|
+
value: boolean;
|
|
6
|
+
setValue: React.Dispatch<React.SetStateAction<boolean>>;
|
|
7
|
+
compact: boolean;
|
|
8
|
+
defaultValue: boolean;
|
|
9
|
+
onSave: (updater: (oldNum: unknown) => boolean) => void;
|
|
10
|
+
onRemove: null | (() => void);
|
|
11
|
+
showSaveButton: boolean;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZodBooleanEditor = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const Checkbox_1 = require("../../Checkbox");
|
|
7
|
+
const layout_1 = require("../layout");
|
|
8
|
+
const SchemaLabel_1 = require("./SchemaLabel");
|
|
9
|
+
const fullWidth = {
|
|
10
|
+
width: '100%',
|
|
11
|
+
};
|
|
12
|
+
const ZodBooleanEditor = ({ jsonPath, value, setValue, onSave, compact, defaultValue, onRemove, showSaveButton, }) => {
|
|
13
|
+
const onValueChange = (0, react_1.useCallback)((newValue) => {
|
|
14
|
+
setValue(newValue);
|
|
15
|
+
}, [setValue]);
|
|
16
|
+
const onChange = (0, react_1.useCallback)((e) => {
|
|
17
|
+
onValueChange(e.target.checked);
|
|
18
|
+
}, [onValueChange]);
|
|
19
|
+
const reset = (0, react_1.useCallback)(() => {
|
|
20
|
+
onValueChange(defaultValue);
|
|
21
|
+
}, [defaultValue, onValueChange]);
|
|
22
|
+
const save = (0, react_1.useCallback)(() => {
|
|
23
|
+
onSave(() => value);
|
|
24
|
+
}, [onSave, value]);
|
|
25
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_1.narrowOption : layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { isDefaultValue: value === defaultValue, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, compact: compact, onRemove: onRemove }), (0, jsx_runtime_1.jsx)("div", { style: fullWidth, children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { checked: value, onChange: onChange, disabled: false }) })] }));
|
|
26
|
+
};
|
|
27
|
+
exports.ZodBooleanEditor = ZodBooleanEditor;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { z } from 'remotion';
|
|
3
|
+
import type { JSONPath } from './zod-types';
|
|
4
|
+
export declare const ZodDateEditor: React.FC<{
|
|
5
|
+
schema: z.ZodTypeAny;
|
|
6
|
+
jsonPath: JSONPath;
|
|
7
|
+
value: Date;
|
|
8
|
+
defaultValue: Date;
|
|
9
|
+
setValue: React.Dispatch<React.SetStateAction<Date>>;
|
|
10
|
+
onSave: (updater: (oldNum: unknown) => Date) => void;
|
|
11
|
+
onRemove: null | (() => void);
|
|
12
|
+
compact: boolean;
|
|
13
|
+
showSaveButton: boolean;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZodDateEditor = 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 layout_1 = require("../../layout");
|
|
8
|
+
const RemInput_1 = require("../../NewComposition/RemInput");
|
|
9
|
+
const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
|
|
10
|
+
const layout_2 = require("../layout");
|
|
11
|
+
const SchemaLabel_1 = require("./SchemaLabel");
|
|
12
|
+
const fullWidth = {
|
|
13
|
+
width: '100%',
|
|
14
|
+
};
|
|
15
|
+
const explainer = {
|
|
16
|
+
fontFamily: 'sans-serif',
|
|
17
|
+
fontSize: 12,
|
|
18
|
+
color: colors_1.LIGHT_TEXT,
|
|
19
|
+
};
|
|
20
|
+
// This will do 2 things:
|
|
21
|
+
// - Make the calendar icon white
|
|
22
|
+
// Turn the input popup a dark mode input
|
|
23
|
+
const inputStyle = {
|
|
24
|
+
colorScheme: 'dark',
|
|
25
|
+
};
|
|
26
|
+
const formatDate = (date) => {
|
|
27
|
+
// Get the year, month, day, hours, minutes, seconds, and milliseconds
|
|
28
|
+
const year = date.getFullYear();
|
|
29
|
+
const month = date.getMonth() + 1; // Month is zero-indexed, so we add 1
|
|
30
|
+
const day = date.getDate();
|
|
31
|
+
const hours = date.getHours();
|
|
32
|
+
const minutes = date.getMinutes();
|
|
33
|
+
const seconds = date.getSeconds();
|
|
34
|
+
const milliseconds = date.getMilliseconds();
|
|
35
|
+
// Format the date as a string
|
|
36
|
+
const formattedDate = `${year}-${month.toString().padStart(2, '0')}-${day
|
|
37
|
+
.toString()
|
|
38
|
+
.padStart(2, '0')}T${hours.toString().padStart(2, '0')}:${minutes
|
|
39
|
+
.toString()
|
|
40
|
+
.padStart(2, '0')}:${seconds.toString().padStart(2, '0')}.${milliseconds
|
|
41
|
+
.toString()
|
|
42
|
+
.padStart(3, '0')}`;
|
|
43
|
+
return formattedDate;
|
|
44
|
+
};
|
|
45
|
+
const ZodDateEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue, schema, compact, onSave, onRemove, }) => {
|
|
46
|
+
const [localValue, setLocalValue] = (0, react_1.useState)(() => {
|
|
47
|
+
return {
|
|
48
|
+
value,
|
|
49
|
+
zodValidation: schema.safeParse(value),
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
const onValueChange = (0, react_1.useCallback)((newValue) => {
|
|
53
|
+
const safeParse = schema.safeParse(newValue);
|
|
54
|
+
const newLocalState = {
|
|
55
|
+
value: newValue,
|
|
56
|
+
zodValidation: safeParse,
|
|
57
|
+
};
|
|
58
|
+
setLocalValue(newLocalState);
|
|
59
|
+
if (safeParse.success) {
|
|
60
|
+
setValue(newValue);
|
|
61
|
+
}
|
|
62
|
+
}, [schema, setValue]);
|
|
63
|
+
const onChange = (0, react_1.useCallback)((e) => {
|
|
64
|
+
// React does not support e.target.valueAsDate :(
|
|
65
|
+
onValueChange(new Date(e.target.value));
|
|
66
|
+
}, [onValueChange]);
|
|
67
|
+
const reset = (0, react_1.useCallback)(() => {
|
|
68
|
+
onValueChange(defaultValue);
|
|
69
|
+
}, [defaultValue, onValueChange]);
|
|
70
|
+
const save = (0, react_1.useCallback)(() => {
|
|
71
|
+
onSave(() => value);
|
|
72
|
+
}, [onSave, value]);
|
|
73
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_2.narrowOption : layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { compact: compact, isDefaultValue: value.getTime() === defaultValue.getTime(), jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, onRemove: onRemove }), (0, jsx_runtime_1.jsxs)("div", { style: fullWidth, children: [(0, jsx_runtime_1.jsx)(RemInput_1.RemotionInput, { value: formatDate(localValue.value), type: "datetime-local", status: localValue.zodValidation.success ? 'ok' : 'error', placeholder: jsonPath.join('.'), onChange: onChange, style: inputStyle }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)("div", { style: explainer, children: "Date is in local format" }), !localValue.zodValidation.success && ((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-end", message: localValue.zodValidation.error.format()._errors[0], type: "error" })] }))] })] }));
|
|
74
|
+
};
|
|
75
|
+
exports.ZodDateEditor = ZodDateEditor;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { z } from 'remotion';
|
|
3
|
+
import type { JSONPath } from './zod-types';
|
|
4
|
+
export declare const ZodEffectEditor: React.FC<{
|
|
5
|
+
schema: z.ZodTypeAny;
|
|
6
|
+
jsonPath: JSONPath;
|
|
7
|
+
value: unknown;
|
|
8
|
+
setValue: (value: unknown) => void;
|
|
9
|
+
compact: boolean;
|
|
10
|
+
defaultValue: unknown;
|
|
11
|
+
onSave: (updater: (oldState: unknown) => unknown) => void;
|
|
12
|
+
showSaveButton: boolean;
|
|
13
|
+
onRemove: null | (() => void);
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZodEffectEditor = 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 colors_1 = require("../../../helpers/colors");
|
|
8
|
+
const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
|
|
9
|
+
const ZodSwitch_1 = require("./ZodSwitch");
|
|
10
|
+
const fullWidth = {
|
|
11
|
+
width: '100%',
|
|
12
|
+
};
|
|
13
|
+
const ZodEffectEditor = ({ schema, jsonPath, value, setValue: updateValue, compact, defaultValue, onSave, onRemove, showSaveButton, }) => {
|
|
14
|
+
const [localValue, setLocalValue] = (0, react_1.useState)(() => {
|
|
15
|
+
return {
|
|
16
|
+
value,
|
|
17
|
+
zodValidation: schema.safeParse(value),
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
const def = schema._def;
|
|
21
|
+
const typeName = def.typeName;
|
|
22
|
+
if (typeName !== remotion_1.z.ZodFirstPartyTypeKind.ZodEffects) {
|
|
23
|
+
throw new Error('expected effect');
|
|
24
|
+
}
|
|
25
|
+
const onChange = (0, react_1.useCallback)((newValue) => {
|
|
26
|
+
setLocalValue(() => {
|
|
27
|
+
const safeParse = schema.safeParse(newValue);
|
|
28
|
+
if (safeParse.success) {
|
|
29
|
+
updateValue(() => newValue);
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
value: newValue,
|
|
33
|
+
zodValidation: safeParse,
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
}, [schema, updateValue]);
|
|
37
|
+
const container = (0, react_1.useMemo)(() => {
|
|
38
|
+
if (!localValue.zodValidation.success) {
|
|
39
|
+
return {
|
|
40
|
+
border: `1px solid ${colors_1.FAIL_COLOR}`,
|
|
41
|
+
borderRadius: 4,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
border: 'none',
|
|
46
|
+
padding: 0,
|
|
47
|
+
};
|
|
48
|
+
}, [localValue.zodValidation.success]);
|
|
49
|
+
return ((0, jsx_runtime_1.jsxs)("fieldset", { style: container, children: [(0, jsx_runtime_1.jsx)("div", { style: fullWidth, children: (0, jsx_runtime_1.jsx)(ZodSwitch_1.ZodSwitch, { value: value, setValue: onChange, jsonPath: jsonPath, schema: def.schema, compact: compact, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove }) }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsx)("legend", { children: (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-end", message: localValue.zodValidation.error.format()._errors[0], type: "error" }) }))] }));
|
|
50
|
+
};
|
|
51
|
+
exports.ZodEffectEditor = ZodEffectEditor;
|