@remotion/cli 4.0.0-alpha6 → 4.0.0-alpha7
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/benchmark.js +9 -4
- package/dist/chalk/index.d.ts +45 -54
- package/dist/chalk/index.js +2 -135
- package/dist/codemods/stringify-with-path.d.ts +5 -0
- package/dist/codemods/stringify-with-path.js +44 -0
- package/dist/codemods/update-default-props.d.ts +3 -1
- package/dist/codemods/update-default-props.js +3 -17
- package/dist/compositions.js +1 -0
- package/dist/config/log.d.ts +1 -3
- package/dist/config/log.js +2 -9
- package/dist/download-progress.d.ts +1 -1
- package/dist/download-progress.js +1 -5
- package/dist/editor/components/NewComposition/ComboBox.js +2 -2
- package/dist/editor/components/NewComposition/MenuContent.js +1 -1
- package/dist/editor/components/NewComposition/RemInput.d.ts +1 -1
- package/dist/editor/components/NewComposition/RemInputTypeColor.d.ts +1 -1
- package/dist/editor/components/NewComposition/RemTextarea.d.ts +1 -1
- package/dist/editor/components/RenderModal/RenderModalData.js +21 -7
- package/dist/editor/components/RenderModal/RenderModalJSONPropsEditor.d.ts +2 -2
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaErrorMessages.js +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.d.ts +3 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.js +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.d.ts +2 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.js +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodColorEditor.d.ts +2 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodColorEditor.js +8 -8
- package/dist/editor/components/RenderModal/SchemaEditor/ZodDateEditor.d.ts +2 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodDateEditor.js +5 -5
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEffectEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEffectEditor.js +3 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEnumEditor.d.ts +3 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEnumEditor.js +4 -4
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNullableEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.d.ts +2 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.js +9 -6
- package/dist/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOptionalEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.js +40 -7
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStaticFileEditor.d.ts +16 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStaticFileEditor.js +73 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStringEditor.d.ts +2 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStringEditor.js +5 -5
- package/dist/editor/components/RenderModal/SchemaEditor/ZodSwitch.d.ts +2 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodSwitch.js +4 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodUnionEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/extract-enum-json-paths.d.ts +3 -0
- package/dist/editor/components/RenderModal/SchemaEditor/extract-enum-json-paths.js +126 -0
- package/dist/editor/components/RenderModal/SchemaEditor/input-props-serialization.d.ts +12 -0
- package/dist/editor/components/RenderModal/SchemaEditor/input-props-serialization.js +32 -0
- package/dist/editor/components/RenderModal/get-render-modal-warnings.d.ts +3 -2
- package/dist/editor/components/RenderModal/get-render-modal-warnings.js +9 -2
- package/dist/editor/components/RenderQueue/actions.d.ts +2 -1
- package/dist/editor/components/RenderQueue/actions.js +8 -4
- package/dist/editor/components/Timeline/TimelineSequence.js +6 -4
- package/dist/editor/helpers/calculate-timeline.js +1 -1
- package/dist/ffmpeg.js +6 -2
- package/dist/handle-common-errors.d.ts +2 -1
- package/dist/handle-common-errors.js +2 -2
- package/dist/index.d.ts +9 -5
- package/dist/index.js +4 -5
- package/dist/log.d.ts +5 -5
- package/dist/log.js +3 -42
- package/dist/parse-command-line.d.ts +1 -0
- package/dist/preview-server/dev-middleware/setup-hooks.js +2 -2
- package/dist/preview-server/render-queue/job.d.ts +2 -0
- package/dist/preview-server/render-queue/queue.js +2 -1
- package/dist/preview-server/routes/can-update-default-props.js +1 -0
- package/dist/preview-server/routes/update-default-props.js +4 -3
- package/dist/print-error.d.ts +2 -1
- package/dist/print-error.js +8 -5
- package/dist/progress-bar.d.ts +5 -4
- package/dist/progress-bar.js +42 -29
- package/dist/render-flows/render.js +46 -19
- package/dist/render-flows/still.js +17 -12
- package/dist/setup-cache.d.ts +2 -1
- package/dist/setup-cache.js +8 -4
- package/dist/should-use-non-overlaying-logger.d.ts +4 -0
- package/dist/should-use-non-overlaying-logger.js +12 -0
- package/dist/user-passed-output-location.js +7 -2
- package/package.json +7 -7
- package/dist/ansi/ansi-regex.d.ts +0 -2
- package/dist/ansi/ansi-regex.js +0 -18
- package/dist/cloudrun-command.d.ts +0 -1
- package/dist/cloudrun-command.js +0 -27
- package/dist/config/ffmpeg-executable.d.ts +0 -5
- package/dist/config/ffmpeg-executable.js +0 -21
- package/dist/config/quality.d.ts +0 -2
- package/dist/config/quality.js +0 -17
- package/dist/editor/components/ClipboardIcon.d.ts +0 -2
- package/dist/editor/components/ClipboardIcon.js +0 -12
- package/dist/editor/components/CollapsedCompositionSelector.d.ts +0 -4
- package/dist/editor/components/CollapsedCompositionSelector.js +0 -39
- package/dist/editor/components/RenderModal/SchemaEditor/date-serialization.d.ts +0 -6
- package/dist/editor/components/RenderModal/SchemaEditor/date-serialization.js +0 -24
- package/dist/editor/components/RichTimelineToggle.d.ts +0 -2
- package/dist/editor/components/RichTimelineToggle.js +0 -29
- package/dist/editor/components/Thumbnail.d.ts +0 -8
- package/dist/editor/components/Thumbnail.js +0 -76
- package/dist/editor/helpers/use-compact-ui.d.ts +0 -1
- package/dist/editor/helpers/use-compact-ui.js +0 -18
- package/dist/editor/icons/film.d.ts +0 -3
- package/dist/editor/icons/film.js +0 -8
- package/dist/editor/icons/timeline.d.ts +0 -3
- package/dist/editor/icons/timeline.js +0 -9
- package/dist/editor/state/rich-timeline.d.ts +0 -9
- package/dist/editor/state/rich-timeline.js +0 -17
- package/dist/get-render-media-options.d.ts +0 -8
- package/dist/get-render-media-options.js +0 -55
- package/dist/install.d.ts +0 -2
- package/dist/install.js +0 -36
- package/dist/is-javascript.d.ts +0 -2
- package/dist/is-javascript.js +0 -9
- package/dist/preview-server/dev-middleware/is-color-supported.d.ts +0 -1
- package/dist/preview-server/dev-middleware/is-color-supported.js +0 -37
- package/dist/preview-server/hot-middleware/strip-ansi.d.ts +0 -1
- package/dist/preview-server/hot-middleware/strip-ansi.js +0 -21
|
@@ -73,7 +73,7 @@ const ZodArrayEditor = ({ schema, jsonPath, compact, setValue: updateValue, defa
|
|
|
73
73
|
onChange((oldV) => {
|
|
74
74
|
return [...oldV, (0, create_zod_values_1.createZodValues)(def.type, z, zodTypes)];
|
|
75
75
|
}, true);
|
|
76
|
-
}, [def.type, onChange, z]);
|
|
76
|
+
}, [def.type, onChange, z, zodTypes]);
|
|
77
77
|
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) => {
|
|
78
78
|
var _a;
|
|
79
79
|
return ((0, jsx_runtime_1.jsx)(ZodArrayItemEditor_1.ZodArrayItemEditor
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { JSONPath } from './zod-types';
|
|
3
|
+
import type { UpdaterFunction } from './ZodSwitch';
|
|
3
4
|
export declare const ZodBooleanEditor: React.FC<{
|
|
4
5
|
jsonPath: JSONPath;
|
|
5
6
|
value: boolean;
|
|
6
|
-
setValue:
|
|
7
|
+
setValue: UpdaterFunction<boolean>;
|
|
7
8
|
compact: boolean;
|
|
8
9
|
defaultValue: boolean;
|
|
9
10
|
onSave: (updater: (oldNum: unknown) => boolean) => void;
|
|
@@ -11,7 +11,7 @@ const fullWidth = {
|
|
|
11
11
|
};
|
|
12
12
|
const ZodBooleanEditor = ({ jsonPath, value, setValue, onSave, compact, defaultValue, onRemove, showSaveButton, saving, }) => {
|
|
13
13
|
const onValueChange = (0, react_1.useCallback)((newValue) => {
|
|
14
|
-
setValue(newValue);
|
|
14
|
+
setValue(() => newValue);
|
|
15
15
|
}, [setValue]);
|
|
16
16
|
const onChange = (0, react_1.useCallback)((e) => {
|
|
17
17
|
onValueChange(e.target.checked);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { z } from 'zod';
|
|
3
3
|
import type { JSONPath } from './zod-types';
|
|
4
|
+
import type { UpdaterFunction } from './ZodSwitch';
|
|
4
5
|
export declare const ZodColorEditor: React.FC<{
|
|
5
6
|
schema: z.ZodTypeAny;
|
|
6
7
|
jsonPath: JSONPath;
|
|
7
8
|
value: string;
|
|
8
9
|
defaultValue: string;
|
|
9
|
-
setValue:
|
|
10
|
+
setValue: UpdaterFunction<string>;
|
|
10
11
|
onSave: (updater: (oldNum: unknown) => string) => void;
|
|
11
12
|
onRemove: null | (() => void);
|
|
12
13
|
compact: boolean;
|
|
@@ -30,15 +30,15 @@ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValu
|
|
|
30
30
|
zodValidation: schema.safeParse(value),
|
|
31
31
|
};
|
|
32
32
|
});
|
|
33
|
-
const onValueChange = (0, react_1.useCallback)((newValue) => {
|
|
33
|
+
const onValueChange = (0, react_1.useCallback)((newValue, forceApply) => {
|
|
34
34
|
const safeParse = schema.safeParse(newValue);
|
|
35
35
|
const newLocalState = {
|
|
36
36
|
value: newValue,
|
|
37
37
|
zodValidation: safeParse,
|
|
38
38
|
};
|
|
39
39
|
setLocalValue(newLocalState);
|
|
40
|
-
if (safeParse.success) {
|
|
41
|
-
setValue(newValue);
|
|
40
|
+
if (safeParse.success || forceApply) {
|
|
41
|
+
setValue(() => newValue);
|
|
42
42
|
}
|
|
43
43
|
}, [schema, setValue]);
|
|
44
44
|
const { a, b, g, r } = localValue.zodValidation.success
|
|
@@ -53,7 +53,7 @@ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValu
|
|
|
53
53
|
};
|
|
54
54
|
setLocalValue(newLocalState);
|
|
55
55
|
if (safeParse.success) {
|
|
56
|
-
setValue(newColor);
|
|
56
|
+
setValue(() => newColor);
|
|
57
57
|
}
|
|
58
58
|
}, [a, schema, setValue, zodTypes]);
|
|
59
59
|
const onTextChange = (0, react_1.useCallback)((e) => {
|
|
@@ -65,11 +65,11 @@ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValu
|
|
|
65
65
|
};
|
|
66
66
|
setLocalValue(newLocalState);
|
|
67
67
|
if (safeParse.success) {
|
|
68
|
-
setValue(newValue);
|
|
68
|
+
setValue(() => newValue);
|
|
69
69
|
}
|
|
70
70
|
}, [schema, setValue]);
|
|
71
71
|
const reset = (0, react_1.useCallback)(() => {
|
|
72
|
-
onValueChange(defaultValue);
|
|
72
|
+
onValueChange(defaultValue, true);
|
|
73
73
|
}, [defaultValue, onValueChange]);
|
|
74
74
|
const save = (0, react_1.useCallback)(() => {
|
|
75
75
|
onSave(() => value);
|
|
@@ -94,7 +94,7 @@ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValu
|
|
|
94
94
|
};
|
|
95
95
|
setLocalValue(newLocalState);
|
|
96
96
|
if (safeParse.success) {
|
|
97
|
-
setValue(newColor);
|
|
97
|
+
setValue(() => newColor);
|
|
98
98
|
}
|
|
99
99
|
}, [localValue.value, schema, setValue, zodTypes]);
|
|
100
100
|
const onOpacityValueChange = (0, react_1.useCallback)((newValue) => {
|
|
@@ -106,7 +106,7 @@ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValu
|
|
|
106
106
|
};
|
|
107
107
|
setLocalValue(newLocalState);
|
|
108
108
|
if (safeParse.success) {
|
|
109
|
-
setValue(newColor);
|
|
109
|
+
setValue(() => newColor);
|
|
110
110
|
}
|
|
111
111
|
}, [localValue.value, schema, setValue, zodTypes]);
|
|
112
112
|
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 === defaultValue, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving }), (0, jsx_runtime_1.jsxs)("div", { style: fullWidth, children: [(0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: colorPicker, children: (0, jsx_runtime_1.jsx)(RemInputTypeColor_1.RemInputTypeColor, { type: "color", style: {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { z } from 'zod';
|
|
3
3
|
import type { JSONPath } from './zod-types';
|
|
4
|
+
import type { UpdaterFunction } from './ZodSwitch';
|
|
4
5
|
export declare const ZodDateEditor: React.FC<{
|
|
5
6
|
schema: z.ZodTypeAny;
|
|
6
7
|
jsonPath: JSONPath;
|
|
7
8
|
value: Date;
|
|
8
9
|
defaultValue: Date;
|
|
9
|
-
setValue:
|
|
10
|
+
setValue: UpdaterFunction<Date>;
|
|
10
11
|
onSave: (updater: (oldNum: unknown) => Date) => void;
|
|
11
12
|
onRemove: null | (() => void);
|
|
12
13
|
compact: boolean;
|
|
@@ -50,23 +50,23 @@ const ZodDateEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue
|
|
|
50
50
|
zodValidation: schema.safeParse(value),
|
|
51
51
|
};
|
|
52
52
|
});
|
|
53
|
-
const onValueChange = (0, react_1.useCallback)((newValue) => {
|
|
53
|
+
const onValueChange = (0, react_1.useCallback)((newValue, forceApply) => {
|
|
54
54
|
const safeParse = schema.safeParse(newValue);
|
|
55
55
|
const newLocalState = {
|
|
56
56
|
value: newValue,
|
|
57
57
|
zodValidation: safeParse,
|
|
58
58
|
};
|
|
59
59
|
setLocalValue(newLocalState);
|
|
60
|
-
if (safeParse.success) {
|
|
61
|
-
setValue(newValue);
|
|
60
|
+
if (safeParse.success || forceApply) {
|
|
61
|
+
setValue(() => newValue);
|
|
62
62
|
}
|
|
63
63
|
}, [schema, setValue]);
|
|
64
64
|
const onChange = (0, react_1.useCallback)((e) => {
|
|
65
65
|
// React does not support e.target.valueAsDate :(
|
|
66
|
-
onValueChange(new Date(e.target.value));
|
|
66
|
+
onValueChange(new Date(e.target.value), false);
|
|
67
67
|
}, [onValueChange]);
|
|
68
68
|
const reset = (0, react_1.useCallback)(() => {
|
|
69
|
-
onValueChange(defaultValue);
|
|
69
|
+
onValueChange(defaultValue, true);
|
|
70
70
|
}, [defaultValue, onValueChange]);
|
|
71
71
|
const save = (0, react_1.useCallback)(() => {
|
|
72
72
|
onSave(() => value);
|
|
@@ -5,7 +5,7 @@ export declare const ZodEffectEditor: React.FC<{
|
|
|
5
5
|
schema: z.ZodTypeAny;
|
|
6
6
|
jsonPath: JSONPath;
|
|
7
7
|
value: unknown;
|
|
8
|
-
setValue: (
|
|
8
|
+
setValue: (updater: (oldState: unknown) => unknown) => void;
|
|
9
9
|
compact: boolean;
|
|
10
10
|
defaultValue: unknown;
|
|
11
11
|
onSave: (updater: (oldState: unknown) => unknown) => void;
|
|
@@ -26,8 +26,9 @@ const ZodEffectEditor = ({ schema, jsonPath, value, setValue: updateValue, compa
|
|
|
26
26
|
if (typeName !== z.ZodFirstPartyTypeKind.ZodEffects) {
|
|
27
27
|
throw new Error('expected effect');
|
|
28
28
|
}
|
|
29
|
-
const onChange = (0, react_1.useCallback)((
|
|
30
|
-
setLocalValue(() => {
|
|
29
|
+
const onChange = (0, react_1.useCallback)((updater) => {
|
|
30
|
+
setLocalValue((oldLocalState) => {
|
|
31
|
+
const newValue = updater(oldLocalState.value);
|
|
31
32
|
const safeParse = schema.safeParse(newValue);
|
|
32
33
|
if (safeParse.success) {
|
|
33
34
|
updateValue(() => newValue);
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { z } from 'zod';
|
|
3
3
|
import type { JSONPath } from './zod-types';
|
|
4
|
+
import type { UpdaterFunction } from './ZodSwitch';
|
|
4
5
|
export declare const ZodEnumEditor: React.FC<{
|
|
5
6
|
schema: z.ZodTypeAny;
|
|
6
7
|
jsonPath: JSONPath;
|
|
7
8
|
value: string;
|
|
8
9
|
defaultValue: string;
|
|
9
|
-
setValue:
|
|
10
|
-
onSave:
|
|
10
|
+
setValue: UpdaterFunction<string>;
|
|
11
|
+
onSave: UpdaterFunction<string>;
|
|
11
12
|
compact: boolean;
|
|
12
13
|
showSaveButton: boolean;
|
|
13
14
|
onRemove: null | (() => void);
|
|
@@ -31,11 +31,11 @@ const ZodEnumEditor = ({ schema, jsonPath, compact, setValue: updateValue, defau
|
|
|
31
31
|
throw new Error('expected enum');
|
|
32
32
|
}
|
|
33
33
|
const isRoot = jsonPath.length === 0;
|
|
34
|
-
const onChange = (0, react_1.useCallback)((updater) => {
|
|
34
|
+
const onChange = (0, react_1.useCallback)((updater, forceApply) => {
|
|
35
35
|
setLocalValue((oldLocalState) => {
|
|
36
36
|
const newValue = updater(oldLocalState.value);
|
|
37
37
|
const safeParse = schema.safeParse(newValue);
|
|
38
|
-
if (safeParse.success) {
|
|
38
|
+
if (safeParse.success || forceApply) {
|
|
39
39
|
updateValue(updater);
|
|
40
40
|
}
|
|
41
41
|
return {
|
|
@@ -45,7 +45,7 @@ const ZodEnumEditor = ({ schema, jsonPath, compact, setValue: updateValue, defau
|
|
|
45
45
|
});
|
|
46
46
|
}, [schema, updateValue]);
|
|
47
47
|
const reset = (0, react_1.useCallback)(() => {
|
|
48
|
-
onChange(() => defaultValue);
|
|
48
|
+
onChange(() => defaultValue, true);
|
|
49
49
|
}, [defaultValue, onChange]);
|
|
50
50
|
const comboBoxValues = (0, react_1.useMemo)(() => {
|
|
51
51
|
return def.values.map((option) => {
|
|
@@ -56,7 +56,7 @@ const ZodEnumEditor = ({ schema, jsonPath, compact, setValue: updateValue, defau
|
|
|
56
56
|
keyHint: null,
|
|
57
57
|
leftItem: option === value ? (0, jsx_runtime_1.jsx)(Checkmark_1.Checkmark, {}) : null,
|
|
58
58
|
onClick: (id) => {
|
|
59
|
-
onChange(() => id);
|
|
59
|
+
onChange(() => id, false);
|
|
60
60
|
},
|
|
61
61
|
quickSwitcherLabel: null,
|
|
62
62
|
subMenu: null,
|
|
@@ -8,7 +8,7 @@ export declare const ZodNullableEditor: React.FC<{
|
|
|
8
8
|
value: unknown;
|
|
9
9
|
defaultValue: unknown;
|
|
10
10
|
schema: z.ZodTypeAny;
|
|
11
|
-
setValue:
|
|
11
|
+
setValue: (updater: (oldNum: unknown) => unknown) => void;
|
|
12
12
|
onSave: (updater: (oldNum: unknown) => unknown) => void;
|
|
13
13
|
onRemove: null | (() => void);
|
|
14
14
|
saving: boolean;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { z } from 'zod';
|
|
3
3
|
import type { JSONPath } from './zod-types';
|
|
4
|
+
import type { UpdaterFunction } from './ZodSwitch';
|
|
4
5
|
export declare const ZodNumberEditor: React.FC<{
|
|
5
6
|
schema: z.ZodTypeAny;
|
|
6
7
|
jsonPath: JSONPath;
|
|
7
8
|
value: number;
|
|
8
|
-
setValue:
|
|
9
|
+
setValue: UpdaterFunction<number>;
|
|
9
10
|
compact: boolean;
|
|
10
11
|
defaultValue: number;
|
|
11
12
|
onSave: (updater: (oldNum: unknown) => number) => void;
|
|
@@ -62,27 +62,30 @@ const ZodNumberEditor = ({ jsonPath, value, schema, setValue, onSave, compact, d
|
|
|
62
62
|
};
|
|
63
63
|
setLocalValue(newLocalState);
|
|
64
64
|
if (safeParse.success) {
|
|
65
|
-
setValue(Number(newValue));
|
|
65
|
+
setValue(() => Number(newValue));
|
|
66
66
|
}
|
|
67
67
|
}, [schema, setValue]);
|
|
68
|
-
const onValueChange = (0, react_1.useCallback)((newValue) => {
|
|
68
|
+
const onValueChange = (0, react_1.useCallback)((newValue, forceApply) => {
|
|
69
69
|
const safeParse = schema.safeParse(newValue);
|
|
70
70
|
const newLocalState = {
|
|
71
71
|
value: String(newValue),
|
|
72
72
|
zodValidation: safeParse,
|
|
73
73
|
};
|
|
74
74
|
setLocalValue(newLocalState);
|
|
75
|
-
if (safeParse.success) {
|
|
76
|
-
setValue(newValue);
|
|
75
|
+
if (safeParse.success || forceApply) {
|
|
76
|
+
setValue(() => newValue);
|
|
77
77
|
}
|
|
78
78
|
}, [schema, setValue]);
|
|
79
|
+
const onNumberChange = (0, react_1.useCallback)((newValue) => {
|
|
80
|
+
onValueChange(newValue, false);
|
|
81
|
+
}, [onValueChange]);
|
|
79
82
|
const isDefault = value === defaultValue;
|
|
80
83
|
const reset = (0, react_1.useCallback)(() => {
|
|
81
|
-
onValueChange(defaultValue);
|
|
84
|
+
onValueChange(defaultValue, true);
|
|
82
85
|
}, [defaultValue, onValueChange]);
|
|
83
86
|
const save = (0, react_1.useCallback)(() => {
|
|
84
87
|
onSave(() => value);
|
|
85
88
|
}, [onSave, value]);
|
|
86
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_2.narrowOption : layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { isDefaultValue: isDefault, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, compact: compact, onRemove: onRemove, saving: saving }), (0, jsx_runtime_1.jsxs)("div", { style: fullWidth, children: [(0, jsx_runtime_1.jsx)(InputDragger_1.InputDragger, { type: 'number', value: localValue.value, style: fullWidth, status: localValue.zodValidation.success ? 'ok' : 'error', placeholder: jsonPath.join('.'), onTextChange: onChange, onValueChange:
|
|
89
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_2.narrowOption : layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { isDefaultValue: isDefault, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, compact: compact, onRemove: onRemove, saving: saving }), (0, jsx_runtime_1.jsxs)("div", { style: fullWidth, children: [(0, jsx_runtime_1.jsx)(InputDragger_1.InputDragger, { type: 'number', value: localValue.value, style: fullWidth, status: localValue.zodValidation.success ? 'ok' : 'error', placeholder: jsonPath.join('.'), onTextChange: onChange, onValueChange: onNumberChange, min: getMinValue(schema), max: getMaxValue(schema), step: getStep(schema), rightAlign: false }), !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-start", message: localValue.zodValidation.error.format()._errors[0], type: "error" })] }))] })] }));
|
|
87
90
|
};
|
|
88
91
|
exports.ZodNumberEditor = ZodNumberEditor;
|
|
@@ -6,7 +6,7 @@ export declare const ZodObjectEditor: React.FC<{
|
|
|
6
6
|
jsonPath: JSONPath;
|
|
7
7
|
value: unknown;
|
|
8
8
|
defaultValue: unknown;
|
|
9
|
-
setValue:
|
|
9
|
+
setValue: (updater: (oldState: Record<string, unknown>) => Record<string, unknown>) => void;
|
|
10
10
|
compact: boolean;
|
|
11
11
|
onSave: (updater: (oldVal: Record<string, unknown>) => Record<string, unknown>) => void;
|
|
12
12
|
showSaveButton: boolean;
|
|
@@ -8,7 +8,7 @@ export declare const ZodOptionalEditor: React.FC<{
|
|
|
8
8
|
value: unknown;
|
|
9
9
|
defaultValue: unknown;
|
|
10
10
|
schema: z.ZodTypeAny;
|
|
11
|
-
setValue:
|
|
11
|
+
setValue: (updater: (oldNum: unknown) => unknown) => void;
|
|
12
12
|
onSave: (updater: (oldNum: unknown) => unknown) => void;
|
|
13
13
|
onRemove: null | (() => void);
|
|
14
14
|
saving: boolean;
|
|
@@ -8,7 +8,7 @@ export declare const ZodOrNullishEditor: React.FC<{
|
|
|
8
8
|
value: unknown;
|
|
9
9
|
defaultValue: unknown;
|
|
10
10
|
schema: z.ZodTypeAny;
|
|
11
|
-
setValue:
|
|
11
|
+
setValue: (updater: (oldState: unknown) => unknown) => void;
|
|
12
12
|
onSave: (updater: (oldNum: unknown) => unknown) => void;
|
|
13
13
|
onRemove: null | (() => void);
|
|
14
14
|
nullishValue: null | undefined;
|
|
@@ -32,17 +32,50 @@ const ZodOrNullishEditor = ({ jsonPath, compact, schema, setValue, onSave, defau
|
|
|
32
32
|
}
|
|
33
33
|
const zodTypes = (0, get_zod_if_possible_1.useZodTypesIfPossible)();
|
|
34
34
|
const isChecked = value === nullishValue;
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const [localNonNullishValueValue, setLocalNonNullishValue] = (0, react_1.useState)(() => {
|
|
36
|
+
return {
|
|
37
|
+
value,
|
|
38
|
+
zodValidation: value === nullishValue
|
|
39
|
+
? { success: true, data: value }
|
|
40
|
+
: schema.safeParse(value),
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
const onValueChange = (0, react_1.useCallback)((updater) => {
|
|
44
|
+
setLocalNonNullishValue((oldState) => {
|
|
45
|
+
const newValue = updater(oldState.value);
|
|
46
|
+
if (newValue === nullishValue) {
|
|
47
|
+
return oldState;
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
value: newValue,
|
|
51
|
+
zodValidation: schema.safeParse(newValue),
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
setValue(updater);
|
|
55
|
+
}, [nullishValue, schema, setValue]);
|
|
38
56
|
const onCheckBoxChange = (0, react_1.useCallback)((e) => {
|
|
39
57
|
const val = e.target.checked
|
|
40
58
|
? nullishValue
|
|
41
|
-
:
|
|
42
|
-
|
|
43
|
-
|
|
59
|
+
: localNonNullishValueValue.value === nullishValue
|
|
60
|
+
? (0, create_zod_values_1.createZodValues)(schema, z, zodTypes)
|
|
61
|
+
: localNonNullishValueValue.value;
|
|
62
|
+
if (val !== nullishValue) {
|
|
63
|
+
setLocalNonNullishValue({
|
|
64
|
+
value: val,
|
|
65
|
+
zodValidation: schema.safeParse(val),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
onValueChange(() => val);
|
|
69
|
+
}, [
|
|
70
|
+
localNonNullishValueValue,
|
|
71
|
+
nullishValue,
|
|
72
|
+
onValueChange,
|
|
73
|
+
schema,
|
|
74
|
+
z,
|
|
75
|
+
zodTypes,
|
|
76
|
+
]);
|
|
44
77
|
const reset = (0, react_1.useCallback)(() => {
|
|
45
|
-
onValueChange(defaultValue);
|
|
78
|
+
onValueChange(() => defaultValue);
|
|
46
79
|
}, [defaultValue, onValueChange]);
|
|
47
80
|
const save = (0, react_1.useCallback)(() => {
|
|
48
81
|
onSave(() => value);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
import type { JSONPath } from './zod-types';
|
|
4
|
+
import type { UpdaterFunction } from './ZodSwitch';
|
|
5
|
+
export declare const ZodStaticFileEditor: React.FC<{
|
|
6
|
+
schema: z.ZodTypeAny;
|
|
7
|
+
jsonPath: JSONPath;
|
|
8
|
+
value: string;
|
|
9
|
+
defaultValue: string;
|
|
10
|
+
setValue: UpdaterFunction<string>;
|
|
11
|
+
onSave: (updater: (oldState: string) => string) => void;
|
|
12
|
+
compact: boolean;
|
|
13
|
+
showSaveButton: boolean;
|
|
14
|
+
onRemove: null | (() => void);
|
|
15
|
+
saving: boolean;
|
|
16
|
+
}>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZodStaticFileEditor = 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 Checkmark_1 = require("../../../icons/Checkmark");
|
|
8
|
+
const get_zod_if_possible_1 = require("../../get-zod-if-possible");
|
|
9
|
+
const layout_1 = require("../../layout");
|
|
10
|
+
const ComboBox_1 = require("../../NewComposition/ComboBox");
|
|
11
|
+
const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
|
|
12
|
+
const layout_2 = require("../layout");
|
|
13
|
+
const SchemaLabel_1 = require("./SchemaLabel");
|
|
14
|
+
const container = {
|
|
15
|
+
width: '100%',
|
|
16
|
+
};
|
|
17
|
+
const ZodStaticFileEditor = ({ schema, jsonPath, compact, setValue: updateValue, defaultValue, value, onSave, showSaveButton, onRemove, saving, }) => {
|
|
18
|
+
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
19
|
+
if (!z) {
|
|
20
|
+
throw new Error('expected zod');
|
|
21
|
+
}
|
|
22
|
+
const [localValue, setLocalValue] = (0, react_1.useState)(() => {
|
|
23
|
+
return {
|
|
24
|
+
value,
|
|
25
|
+
zodValidation: schema.safeParse(value),
|
|
26
|
+
revision: 0,
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
const def = schema._def;
|
|
30
|
+
const typeName = def.typeName;
|
|
31
|
+
if (typeName !== z.ZodFirstPartyTypeKind.ZodString) {
|
|
32
|
+
throw new Error('expected enum');
|
|
33
|
+
}
|
|
34
|
+
const isRoot = jsonPath.length === 0;
|
|
35
|
+
const onChange = (0, react_1.useCallback)((updater, forceApply) => {
|
|
36
|
+
setLocalValue((oldLocalState) => {
|
|
37
|
+
const newValue = updater(oldLocalState.value);
|
|
38
|
+
const safeParse = schema.safeParse(newValue);
|
|
39
|
+
if (safeParse.success || forceApply) {
|
|
40
|
+
updateValue(updater);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
value: newValue,
|
|
44
|
+
zodValidation: safeParse,
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
}, [schema, updateValue]);
|
|
48
|
+
const reset = (0, react_1.useCallback)(() => {
|
|
49
|
+
onChange(() => defaultValue, true);
|
|
50
|
+
}, [defaultValue, onChange]);
|
|
51
|
+
const comboBoxValues = (0, react_1.useMemo)(() => {
|
|
52
|
+
return (0, remotion_1.getStaticFiles)().map((option) => {
|
|
53
|
+
return {
|
|
54
|
+
value: option.src,
|
|
55
|
+
label: option.name,
|
|
56
|
+
id: option.src,
|
|
57
|
+
keyHint: null,
|
|
58
|
+
leftItem: option.src === value ? (0, jsx_runtime_1.jsx)(Checkmark_1.Checkmark, {}) : null,
|
|
59
|
+
onClick: (id) => {
|
|
60
|
+
onChange(() => id, false);
|
|
61
|
+
},
|
|
62
|
+
quickSwitcherLabel: null,
|
|
63
|
+
subMenu: null,
|
|
64
|
+
type: 'item',
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
}, [onChange, value]);
|
|
68
|
+
const save = (0, react_1.useCallback)(() => {
|
|
69
|
+
onSave(() => value);
|
|
70
|
+
}, [onSave, value]);
|
|
71
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_2.narrowOption : layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { onSave: save, showSaveButton: showSaveButton, isDefaultValue: value === defaultValue, compact: compact, onReset: reset, jsonPath: jsonPath, onRemove: onRemove, saving: saving }), (0, jsx_runtime_1.jsx)("div", { style: isRoot ? undefined : container, children: (0, jsx_runtime_1.jsx)(ComboBox_1.Combobox, { values: comboBoxValues, selectedId: localValue.value, title: value }) }), !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-start", message: localValue.zodValidation.error.format()._errors[0], type: "error" })] }))] }));
|
|
72
|
+
};
|
|
73
|
+
exports.ZodStaticFileEditor = ZodStaticFileEditor;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { z } from 'zod';
|
|
3
3
|
import type { JSONPath } from './zod-types';
|
|
4
|
+
import type { UpdaterFunction } from './ZodSwitch';
|
|
4
5
|
export declare const ZodStringEditor: React.FC<{
|
|
5
6
|
schema: z.ZodTypeAny;
|
|
6
7
|
jsonPath: JSONPath;
|
|
7
8
|
value: string;
|
|
8
9
|
defaultValue: string;
|
|
9
|
-
setValue:
|
|
10
|
+
setValue: UpdaterFunction<string>;
|
|
10
11
|
onSave: (updater: (oldNum: unknown) => string) => void;
|
|
11
12
|
onRemove: null | (() => void);
|
|
12
13
|
compact: boolean;
|
|
@@ -23,22 +23,22 @@ const ZodStringEditor = ({ jsonPath, value, setValue, showSaveButton, defaultVal
|
|
|
23
23
|
zodValidation: schema.safeParse(value),
|
|
24
24
|
};
|
|
25
25
|
});
|
|
26
|
-
const onValueChange = (0, react_1.useCallback)((newValue) => {
|
|
26
|
+
const onValueChange = (0, react_1.useCallback)((newValue, forceApply) => {
|
|
27
27
|
const safeParse = schema.safeParse(newValue);
|
|
28
28
|
const newLocalState = {
|
|
29
29
|
value: newValue,
|
|
30
30
|
zodValidation: safeParse,
|
|
31
31
|
};
|
|
32
32
|
setLocalValue(newLocalState);
|
|
33
|
-
if (safeParse.success) {
|
|
34
|
-
setValue(newValue);
|
|
33
|
+
if (safeParse.success || forceApply) {
|
|
34
|
+
setValue(() => newValue);
|
|
35
35
|
}
|
|
36
36
|
}, [schema, setValue]);
|
|
37
37
|
const onChange = (0, react_1.useCallback)((e) => {
|
|
38
|
-
onValueChange(e.target.value);
|
|
38
|
+
onValueChange(e.target.value, false);
|
|
39
39
|
}, [onValueChange]);
|
|
40
40
|
const reset = (0, react_1.useCallback)(() => {
|
|
41
|
-
onValueChange(defaultValue);
|
|
41
|
+
onValueChange(defaultValue, true);
|
|
42
42
|
}, [defaultValue, onValueChange]);
|
|
43
43
|
const save = (0, react_1.useCallback)(() => {
|
|
44
44
|
onSave(() => value);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { z } from 'zod';
|
|
3
3
|
import type { JSONPath } from './zod-types';
|
|
4
|
+
export declare type UpdaterFunction<T> = (updater: (oldValue: T) => T) => void;
|
|
4
5
|
export declare const ZodSwitch: React.FC<{
|
|
5
6
|
schema: z.ZodTypeAny;
|
|
6
7
|
jsonPath: JSONPath;
|
|
7
8
|
value: unknown;
|
|
8
9
|
defaultValue: unknown;
|
|
9
|
-
setValue:
|
|
10
|
+
setValue: UpdaterFunction<unknown>;
|
|
10
11
|
onSave: (newValue: (oldVal: unknown) => unknown) => void;
|
|
11
12
|
compact: boolean;
|
|
12
13
|
showSaveButton: boolean;
|
|
@@ -14,6 +14,7 @@ const ZodNullableEditor_1 = require("./ZodNullableEditor");
|
|
|
14
14
|
const ZodNumberEditor_1 = require("./ZodNumberEditor");
|
|
15
15
|
const ZodObjectEditor_1 = require("./ZodObjectEditor");
|
|
16
16
|
const ZodOptionalEditor_1 = require("./ZodOptionalEditor");
|
|
17
|
+
const ZodStaticFileEditor_1 = require("./ZodStaticFileEditor");
|
|
17
18
|
const ZodStringEditor_1 = require("./ZodStringEditor");
|
|
18
19
|
const ZodUnionEditor_1 = require("./ZodUnionEditor");
|
|
19
20
|
const ZodSwitch = ({ schema, jsonPath, compact, value, setValue, defaultValue, onSave, showSaveButton, onRemove, saving, }) => {
|
|
@@ -30,6 +31,9 @@ const ZodSwitch = ({ schema, jsonPath, compact, value, setValue, defaultValue, o
|
|
|
30
31
|
return ((0, jsx_runtime_1.jsx)(ZodObjectEditor_1.ZodObjectEditor, { setValue: setValue, value: value, defaultValue: defaultValue, jsonPath: jsonPath, schema: schema, compact: compact, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving }));
|
|
31
32
|
}
|
|
32
33
|
if (typeName === z.ZodFirstPartyTypeKind.ZodString) {
|
|
34
|
+
if (value.startsWith(window.remotion_staticBase)) {
|
|
35
|
+
return ((0, jsx_runtime_1.jsx)(ZodStaticFileEditor_1.ZodStaticFileEditor, { setValue: setValue, value: value, jsonPath: jsonPath, schema: schema, compact: compact, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving }));
|
|
36
|
+
}
|
|
33
37
|
return ((0, jsx_runtime_1.jsx)(ZodStringEditor_1.ZodStringEditor, { value: value, setValue: setValue, jsonPath: jsonPath, schema: schema, compact: compact, onSave: onSave, defaultValue: defaultValue, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving }));
|
|
34
38
|
}
|
|
35
39
|
if (typeName === z.ZodFirstPartyTypeKind.ZodDate) {
|
|
@@ -8,7 +8,7 @@ export declare const ZodUnionEditor: React.FC<{
|
|
|
8
8
|
value: unknown;
|
|
9
9
|
defaultValue: unknown;
|
|
10
10
|
schema: z.ZodTypeAny;
|
|
11
|
-
setValue:
|
|
11
|
+
setValue: (updater: (oldState: unknown) => unknown) => void;
|
|
12
12
|
onSave: (updater: (oldNum: unknown) => unknown) => void;
|
|
13
13
|
onRemove: null | (() => void);
|
|
14
14
|
saving: boolean;
|