@remotion/studio 4.0.153 → 4.0.154
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +85 -0
- package/dist/api/delete-static-file.d.ts +3 -0
- package/dist/api/delete-static-file.js +16 -0
- package/dist/api/helpers/calc-new-props.d.ts +11 -0
- package/dist/api/helpers/calc-new-props.js +36 -0
- package/dist/api/save-default-props.d.ts +7 -7
- package/dist/api/save-default-props.js +8 -27
- package/dist/api/update-default-props.d.ts +6 -0
- package/dist/api/update-default-props.js +21 -0
- package/dist/api/watch-public-folder.d.ts +13 -0
- package/dist/api/watch-public-folder.js +28 -0
- package/dist/api/watch-static-file.d.ts +1 -2
- package/dist/api/watch-static-file.js +5 -12
- package/dist/components/Editor.js +2 -1
- package/dist/components/PlayPause.js +1 -0
- package/dist/components/RenderModal/DataEditor.js +1 -1
- package/dist/components/RenderModal/RenderModalJSONPropsEditor.d.ts +7 -7
- package/dist/components/RenderModal/SchemaEditor/SchemaEditor.d.ts +9 -9
- package/dist/components/RenderModal/SchemaEditor/SchemaEditor.js +26 -9
- package/dist/components/RenderModal/SchemaEditor/ZodArrayEditor.d.ts +11 -11
- package/dist/components/RenderModal/SchemaEditor/ZodArrayEditor.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodBooleanEditor.d.ts +11 -11
- package/dist/components/RenderModal/SchemaEditor/ZodBooleanEditor.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodColorEditor.d.ts +11 -11
- package/dist/components/RenderModal/SchemaEditor/ZodColorEditor.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodDateEditor.d.ts +11 -11
- package/dist/components/RenderModal/SchemaEditor/ZodDateEditor.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodDiscriminatedUnionEditor.js +3 -3
- package/dist/components/RenderModal/SchemaEditor/ZodEffectEditor.d.ts +10 -10
- package/dist/components/RenderModal/SchemaEditor/ZodEffectEditor.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodEnumEditor.d.ts +9 -9
- package/dist/components/RenderModal/SchemaEditor/ZodEnumEditor.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodNumberEditor.d.ts +11 -11
- package/dist/components/RenderModal/SchemaEditor/ZodNumberEditor.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodObjectEditor.d.ts +12 -12
- package/dist/components/RenderModal/SchemaEditor/ZodObjectEditor.js +6 -6
- package/dist/components/RenderModal/SchemaEditor/ZodOrNullishEditor.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodStaticFileEditor.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodStringEditor.d.ts +11 -11
- package/dist/components/RenderModal/SchemaEditor/ZodStringEditor.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodSwitch.d.ts +11 -11
- package/dist/components/RenderModal/SchemaEditor/ZodSwitch.js +1 -1
- package/dist/components/RenderModal/SchemaEditor/ZodTextareaEditor.d.ts +11 -11
- package/dist/components/RenderModal/SchemaEditor/ZodTextareaEditor.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/local-state.d.ts +7 -3
- package/dist/components/RenderModal/SchemaEditor/local-state.js +38 -15
- package/dist/components/RenderQueue/actions.js +15 -38
- package/dist/components/TopPanel.d.ts +5 -5
- package/dist/components/call-api.d.ts +2 -0
- package/dist/components/call-api.js +28 -0
- package/dist/esm/index.mjs +119 -57
- package/dist/esm/internals.mjs +428 -378
- package/dist/helpers/client-id.d.ts +2 -2
- package/dist/helpers/client-id.js +2 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.js +7 -1
- package/package.json +7 -7
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -3,15 +3,15 @@ import type { z } from 'zod';
|
|
|
3
3
|
import type { UpdaterFunction } from './ZodSwitch';
|
|
4
4
|
import type { JSONPath } from './zod-types';
|
|
5
5
|
export declare const ZodColorEditor: React.FC<{
|
|
6
|
-
schema: z.ZodTypeAny;
|
|
7
|
-
jsonPath: JSONPath;
|
|
8
|
-
value: string;
|
|
9
|
-
defaultValue: string;
|
|
10
|
-
setValue: UpdaterFunction<string>;
|
|
11
|
-
onSave: UpdaterFunction<string>;
|
|
12
|
-
onRemove: null | (() => void);
|
|
13
|
-
showSaveButton: boolean;
|
|
14
|
-
saving: boolean;
|
|
15
|
-
saveDisabledByParent: boolean;
|
|
16
|
-
mayPad: boolean;
|
|
6
|
+
readonly schema: z.ZodTypeAny;
|
|
7
|
+
readonly jsonPath: JSONPath;
|
|
8
|
+
readonly value: string;
|
|
9
|
+
readonly defaultValue: string;
|
|
10
|
+
readonly setValue: UpdaterFunction<string>;
|
|
11
|
+
readonly onSave: UpdaterFunction<string>;
|
|
12
|
+
readonly onRemove: null | (() => void);
|
|
13
|
+
readonly showSaveButton: boolean;
|
|
14
|
+
readonly saving: boolean;
|
|
15
|
+
readonly saveDisabledByParent: boolean;
|
|
16
|
+
readonly mayPad: boolean;
|
|
17
17
|
}>;
|
|
@@ -28,8 +28,8 @@ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValu
|
|
|
28
28
|
const { localValue, onChange: onValueChange, reset, } = (0, local_state_1.useLocalState)({
|
|
29
29
|
schema,
|
|
30
30
|
setValue,
|
|
31
|
-
value,
|
|
32
|
-
defaultValue,
|
|
31
|
+
unsavedValue: value,
|
|
32
|
+
savedValue: defaultValue,
|
|
33
33
|
});
|
|
34
34
|
const { a, b, g, r } = localValue.zodValidation.success
|
|
35
35
|
? zodTypes.ZodZypesInternals.parseColor(localValue.value)
|
|
@@ -3,15 +3,15 @@ import type { z } from 'zod';
|
|
|
3
3
|
import type { UpdaterFunction } from './ZodSwitch';
|
|
4
4
|
import type { JSONPath } from './zod-types';
|
|
5
5
|
export declare const ZodDateEditor: React.FC<{
|
|
6
|
-
schema: z.ZodTypeAny;
|
|
7
|
-
jsonPath: JSONPath;
|
|
8
|
-
value: Date;
|
|
9
|
-
defaultValue: Date;
|
|
10
|
-
setValue: UpdaterFunction<Date>;
|
|
11
|
-
onSave: UpdaterFunction<Date>;
|
|
12
|
-
onRemove: null | (() => void);
|
|
13
|
-
showSaveButton: boolean;
|
|
14
|
-
saving: boolean;
|
|
15
|
-
saveDisabledByParent: boolean;
|
|
16
|
-
mayPad: boolean;
|
|
6
|
+
readonly schema: z.ZodTypeAny;
|
|
7
|
+
readonly jsonPath: JSONPath;
|
|
8
|
+
readonly value: Date;
|
|
9
|
+
readonly defaultValue: Date;
|
|
10
|
+
readonly setValue: UpdaterFunction<Date>;
|
|
11
|
+
readonly onSave: UpdaterFunction<Date>;
|
|
12
|
+
readonly onRemove: null | (() => void);
|
|
13
|
+
readonly showSaveButton: boolean;
|
|
14
|
+
readonly saving: boolean;
|
|
15
|
+
readonly saveDisabledByParent: boolean;
|
|
16
|
+
readonly mayPad: boolean;
|
|
17
17
|
}>;
|
|
@@ -47,8 +47,8 @@ const ZodDateEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue
|
|
|
47
47
|
const { localValue, onChange: setLocalValue, reset, } = (0, local_state_1.useLocalState)({
|
|
48
48
|
schema,
|
|
49
49
|
setValue,
|
|
50
|
-
value,
|
|
51
|
-
defaultValue,
|
|
50
|
+
unsavedValue: value,
|
|
51
|
+
savedValue: defaultValue,
|
|
52
52
|
});
|
|
53
53
|
const onChange = (0, react_1.useCallback)((e) => {
|
|
54
54
|
// React does not support e.target.valueAsDate :(
|
|
@@ -22,8 +22,8 @@ const ZodDiscriminatedUnionEditor = ({ schema, setValue, showSaveButton, saving,
|
|
|
22
22
|
const { localValue, onChange: setLocalValue, reset, } = (0, local_state_1.useLocalState)({
|
|
23
23
|
schema,
|
|
24
24
|
setValue,
|
|
25
|
-
value,
|
|
26
|
-
defaultValue,
|
|
25
|
+
unsavedValue: value,
|
|
26
|
+
savedValue: defaultValue,
|
|
27
27
|
});
|
|
28
28
|
const comboBoxValues = (0, react_1.useMemo)(() => {
|
|
29
29
|
return options.map((option) => {
|
|
@@ -78,6 +78,6 @@ const ZodDiscriminatedUnionEditor = ({ schema, setValue, showSaveButton, saving,
|
|
|
78
78
|
]);
|
|
79
79
|
return ((0, jsx_runtime_1.jsx)(ZodObjectEditor_1.ZodObjectEditor
|
|
80
80
|
// Re-render the object editor when the discriminator changes
|
|
81
|
-
, { jsonPath: jsonPath, mayPad: mayPad,
|
|
81
|
+
, { jsonPath: jsonPath, mayPad: mayPad, savedValue: defaultValue, onRemove: onRemove, onSave: onSave, saveDisabledByParent: saveDisabledByParent, saving: saving, schema: typedSchema.optionsMap.get(value[typedSchema.discriminator]), setValue: setLocalValue, showSaveButton: showSaveButton, unsavedValue: value, discriminatedUnionReplacement: discriminatedUnionReplacement }, value[typedSchema.discriminator]));
|
|
82
82
|
};
|
|
83
83
|
exports.ZodDiscriminatedUnionEditor = ZodDiscriminatedUnionEditor;
|
|
@@ -3,14 +3,14 @@ import type { z } from 'zod';
|
|
|
3
3
|
import type { UpdaterFunction } from './ZodSwitch';
|
|
4
4
|
import type { JSONPath } from './zod-types';
|
|
5
5
|
export declare const ZodEffectEditor: React.FC<{
|
|
6
|
-
schema: z.ZodTypeAny;
|
|
7
|
-
jsonPath: JSONPath;
|
|
8
|
-
value: unknown;
|
|
9
|
-
setValue: UpdaterFunction<unknown>;
|
|
10
|
-
defaultValue: unknown;
|
|
11
|
-
onSave: UpdaterFunction<unknown>;
|
|
12
|
-
showSaveButton: boolean;
|
|
13
|
-
onRemove: null | (() => void);
|
|
14
|
-
saving: boolean;
|
|
15
|
-
mayPad: boolean;
|
|
6
|
+
readonly schema: z.ZodTypeAny;
|
|
7
|
+
readonly jsonPath: JSONPath;
|
|
8
|
+
readonly value: unknown;
|
|
9
|
+
readonly setValue: UpdaterFunction<unknown>;
|
|
10
|
+
readonly defaultValue: unknown;
|
|
11
|
+
readonly onSave: UpdaterFunction<unknown>;
|
|
12
|
+
readonly showSaveButton: boolean;
|
|
13
|
+
readonly onRemove: null | (() => void);
|
|
14
|
+
readonly saving: boolean;
|
|
15
|
+
readonly mayPad: boolean;
|
|
16
16
|
}>;
|
|
@@ -16,10 +16,10 @@ const ZodEffectEditor = ({ schema, jsonPath, value, setValue: updateValue, defau
|
|
|
16
16
|
throw new Error('expected zod');
|
|
17
17
|
}
|
|
18
18
|
const { localValue, onChange } = (0, local_state_1.useLocalState)({
|
|
19
|
-
value,
|
|
19
|
+
unsavedValue: value,
|
|
20
20
|
schema,
|
|
21
21
|
setValue: updateValue,
|
|
22
|
-
defaultValue,
|
|
22
|
+
savedValue: defaultValue,
|
|
23
23
|
});
|
|
24
24
|
const def = schema._def;
|
|
25
25
|
const typeName = def.typeName;
|
|
@@ -3,13 +3,13 @@ import type { z } from 'zod';
|
|
|
3
3
|
import type { UpdaterFunction } from './ZodSwitch';
|
|
4
4
|
import type { JSONPath } from './zod-types';
|
|
5
5
|
export declare const ZodEnumEditor: React.FC<{
|
|
6
|
-
schema: z.ZodTypeAny;
|
|
7
|
-
jsonPath: JSONPath;
|
|
8
|
-
value: string;
|
|
9
|
-
defaultValue: string;
|
|
10
|
-
setValue: UpdaterFunction<string>;
|
|
11
|
-
onSave: UpdaterFunction<string>;
|
|
12
|
-
showSaveButton: boolean;
|
|
13
|
-
onRemove: null | (() => void);
|
|
14
|
-
saving: boolean;
|
|
6
|
+
readonly schema: z.ZodTypeAny;
|
|
7
|
+
readonly jsonPath: JSONPath;
|
|
8
|
+
readonly value: string;
|
|
9
|
+
readonly defaultValue: string;
|
|
10
|
+
readonly setValue: UpdaterFunction<string>;
|
|
11
|
+
readonly onSave: UpdaterFunction<string>;
|
|
12
|
+
readonly showSaveButton: boolean;
|
|
13
|
+
readonly onRemove: null | (() => void);
|
|
14
|
+
readonly saving: boolean;
|
|
15
15
|
}>;
|
|
@@ -21,8 +21,8 @@ const ZodEnumEditor = ({ schema, jsonPath, setValue, defaultValue, value, onSave
|
|
|
21
21
|
const { localValue, onChange: setLocalValue, reset, } = (0, local_state_1.useLocalState)({
|
|
22
22
|
schema,
|
|
23
23
|
setValue,
|
|
24
|
-
value,
|
|
25
|
-
defaultValue,
|
|
24
|
+
unsavedValue: value,
|
|
25
|
+
savedValue: defaultValue,
|
|
26
26
|
});
|
|
27
27
|
const def = schema._def;
|
|
28
28
|
const typeName = def.typeName;
|
|
@@ -3,15 +3,15 @@ import type { z } from 'zod';
|
|
|
3
3
|
import type { UpdaterFunction } from './ZodSwitch';
|
|
4
4
|
import type { JSONPath } from './zod-types';
|
|
5
5
|
export declare const ZodNumberEditor: React.FC<{
|
|
6
|
-
schema: z.ZodTypeAny;
|
|
7
|
-
jsonPath: JSONPath;
|
|
8
|
-
value: number;
|
|
9
|
-
setValue: UpdaterFunction<number>;
|
|
10
|
-
defaultValue: number;
|
|
11
|
-
onSave: UpdaterFunction<number>;
|
|
12
|
-
onRemove: null | (() => void);
|
|
13
|
-
showSaveButton: boolean;
|
|
14
|
-
saving: boolean;
|
|
15
|
-
saveDisabledByParent: boolean;
|
|
16
|
-
mayPad: boolean;
|
|
6
|
+
readonly schema: z.ZodTypeAny;
|
|
7
|
+
readonly jsonPath: JSONPath;
|
|
8
|
+
readonly value: number;
|
|
9
|
+
readonly setValue: UpdaterFunction<number>;
|
|
10
|
+
readonly defaultValue: number;
|
|
11
|
+
readonly onSave: UpdaterFunction<number>;
|
|
12
|
+
readonly onRemove: null | (() => void);
|
|
13
|
+
readonly showSaveButton: boolean;
|
|
14
|
+
readonly saving: boolean;
|
|
15
|
+
readonly saveDisabledByParent: boolean;
|
|
16
|
+
readonly mayPad: boolean;
|
|
17
17
|
}>;
|
|
@@ -49,10 +49,10 @@ const getStep = (schema) => {
|
|
|
49
49
|
};
|
|
50
50
|
const ZodNumberEditor = ({ jsonPath, value, schema, setValue, onSave, defaultValue, onRemove, showSaveButton, saving, saveDisabledByParent, mayPad, }) => {
|
|
51
51
|
const { localValue, onChange: setLocalValue, reset, } = (0, local_state_1.useLocalState)({
|
|
52
|
-
value,
|
|
52
|
+
unsavedValue: value,
|
|
53
53
|
schema,
|
|
54
54
|
setValue,
|
|
55
|
-
defaultValue,
|
|
55
|
+
savedValue: defaultValue,
|
|
56
56
|
});
|
|
57
57
|
const onNumberChange = (0, react_1.useCallback)((newValue) => {
|
|
58
58
|
setLocalValue(() => newValue, false, false);
|
|
@@ -7,16 +7,16 @@ export type ObjectDiscrimatedUnionReplacement = {
|
|
|
7
7
|
markup: React.ReactNode;
|
|
8
8
|
};
|
|
9
9
|
export declare const ZodObjectEditor: React.FC<{
|
|
10
|
-
schema: z.ZodTypeAny;
|
|
11
|
-
jsonPath: JSONPath;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
setValue: UpdaterFunction<Record<string, unknown>>;
|
|
15
|
-
onSave: UpdaterFunction<Record<string, unknown>>;
|
|
16
|
-
showSaveButton: boolean;
|
|
17
|
-
onRemove: null | (() => void);
|
|
18
|
-
saving: boolean;
|
|
19
|
-
saveDisabledByParent: boolean;
|
|
20
|
-
mayPad: boolean;
|
|
21
|
-
discriminatedUnionReplacement: ObjectDiscrimatedUnionReplacement | null;
|
|
10
|
+
readonly schema: z.ZodTypeAny;
|
|
11
|
+
readonly jsonPath: JSONPath;
|
|
12
|
+
readonly unsavedValue: Record<string, unknown>;
|
|
13
|
+
readonly savedValue: Record<string, unknown>;
|
|
14
|
+
readonly setValue: UpdaterFunction<Record<string, unknown>>;
|
|
15
|
+
readonly onSave: UpdaterFunction<Record<string, unknown>>;
|
|
16
|
+
readonly showSaveButton: boolean;
|
|
17
|
+
readonly onRemove: null | (() => void);
|
|
18
|
+
readonly saving: boolean;
|
|
19
|
+
readonly saveDisabledByParent: boolean;
|
|
20
|
+
readonly mayPad: boolean;
|
|
21
|
+
readonly discriminatedUnionReplacement: ObjectDiscrimatedUnionReplacement | null;
|
|
22
22
|
}>;
|
|
@@ -35,7 +35,7 @@ const SchemaVerticalGuide_1 = require("./SchemaVerticalGuide");
|
|
|
35
35
|
const ZodSwitch_1 = require("./ZodSwitch");
|
|
36
36
|
const deep_equal_1 = require("./deep-equal");
|
|
37
37
|
const local_state_1 = require("./local-state");
|
|
38
|
-
const ZodObjectEditor = ({ schema, jsonPath, setValue,
|
|
38
|
+
const ZodObjectEditor = ({ schema, jsonPath, setValue, unsavedValue, savedValue, onSave, showSaveButton, onRemove, saving, saveDisabledByParent, mayPad, discriminatedUnionReplacement, }) => {
|
|
39
39
|
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
40
40
|
if (!z) {
|
|
41
41
|
throw new Error('expected zod');
|
|
@@ -44,8 +44,8 @@ const ZodObjectEditor = ({ schema, jsonPath, setValue, value, defaultValue, onSa
|
|
|
44
44
|
const { localValue, onChange, RevisionContextProvider, reset } = (0, local_state_1.useLocalState)({
|
|
45
45
|
schema,
|
|
46
46
|
setValue,
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
unsavedValue,
|
|
48
|
+
savedValue,
|
|
49
49
|
});
|
|
50
50
|
const def = schema._def;
|
|
51
51
|
const typeName = def.typeName;
|
|
@@ -56,8 +56,8 @@ const ZodObjectEditor = ({ schema, jsonPath, setValue, value, defaultValue, onSa
|
|
|
56
56
|
const keys = Object.keys(shape);
|
|
57
57
|
const isRoot = jsonPath.length === 0;
|
|
58
58
|
const isDefaultValue = (0, react_1.useMemo)(() => {
|
|
59
|
-
return (0, deep_equal_1.deepEqual)(localValue.value,
|
|
60
|
-
}, [
|
|
59
|
+
return (0, deep_equal_1.deepEqual)(localValue.value, savedValue);
|
|
60
|
+
}, [savedValue, localValue]);
|
|
61
61
|
const suffix = (0, react_1.useMemo)(() => {
|
|
62
62
|
return expanded ? ' {' : ' {...}';
|
|
63
63
|
}, [expanded]);
|
|
@@ -72,7 +72,7 @@ const ZodObjectEditor = ({ schema, jsonPath, setValue, value, defaultValue, onSa
|
|
|
72
72
|
}
|
|
73
73
|
return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(ZodSwitch_1.ZodSwitch, { mayPad: true, jsonPath: [...jsonPath, key], schema: shape[key], value: localValue.value[key],
|
|
74
74
|
// In case of null | {a: string, b: string} type, we need to fallback to the default value
|
|
75
|
-
defaultValue: (
|
|
75
|
+
defaultValue: (savedValue !== null && savedValue !== void 0 ? savedValue : unsavedValue)[key], setValue: (val, forceApply) => {
|
|
76
76
|
onChange((oldVal) => {
|
|
77
77
|
return {
|
|
78
78
|
...oldVal,
|
|
@@ -33,8 +33,8 @@ const ZodOrNullishEditor = ({ jsonPath, schema, setValue, onSave, defaultValue,
|
|
|
33
33
|
const { localValue, onChange: setLocalValue, reset, } = (0, local_state_1.useLocalState)({
|
|
34
34
|
schema,
|
|
35
35
|
setValue,
|
|
36
|
-
value,
|
|
37
|
-
defaultValue,
|
|
36
|
+
unsavedValue: value,
|
|
37
|
+
savedValue: defaultValue,
|
|
38
38
|
});
|
|
39
39
|
const onCheckBoxChange = (0, react_1.useCallback)((e) => {
|
|
40
40
|
const val = e.target.checked
|
|
@@ -22,8 +22,8 @@ const ZodStaticFileEditor = ({ schema, jsonPath, setValue, defaultValue, value,
|
|
|
22
22
|
const { localValue, onChange: setLocalValue, reset, } = (0, local_state_1.useLocalState)({
|
|
23
23
|
schema,
|
|
24
24
|
setValue,
|
|
25
|
-
value,
|
|
26
|
-
defaultValue,
|
|
25
|
+
unsavedValue: value,
|
|
26
|
+
savedValue: defaultValue,
|
|
27
27
|
});
|
|
28
28
|
const def = schema._def;
|
|
29
29
|
const typeName = def.typeName;
|
|
@@ -3,15 +3,15 @@ import type { z } from 'zod';
|
|
|
3
3
|
import type { UpdaterFunction } from './ZodSwitch';
|
|
4
4
|
import type { JSONPath } from './zod-types';
|
|
5
5
|
export declare const ZodStringEditor: React.FC<{
|
|
6
|
-
schema: z.ZodTypeAny;
|
|
7
|
-
jsonPath: JSONPath;
|
|
8
|
-
value: string;
|
|
9
|
-
defaultValue: string;
|
|
10
|
-
setValue: UpdaterFunction<string>;
|
|
11
|
-
onSave: UpdaterFunction<string>;
|
|
12
|
-
onRemove: null | (() => void);
|
|
13
|
-
showSaveButton: boolean;
|
|
14
|
-
saving: boolean;
|
|
15
|
-
saveDisabledByParent: boolean;
|
|
16
|
-
mayPad: boolean;
|
|
6
|
+
readonly schema: z.ZodTypeAny;
|
|
7
|
+
readonly jsonPath: JSONPath;
|
|
8
|
+
readonly value: string;
|
|
9
|
+
readonly defaultValue: string;
|
|
10
|
+
readonly setValue: UpdaterFunction<string>;
|
|
11
|
+
readonly onSave: UpdaterFunction<string>;
|
|
12
|
+
readonly onRemove: null | (() => void);
|
|
13
|
+
readonly showSaveButton: boolean;
|
|
14
|
+
readonly saving: boolean;
|
|
15
|
+
readonly saveDisabledByParent: boolean;
|
|
16
|
+
readonly mayPad: boolean;
|
|
17
17
|
}>;
|
|
@@ -20,8 +20,8 @@ const ZodStringEditor = ({ jsonPath, value, setValue, showSaveButton, defaultVal
|
|
|
20
20
|
const { localValue, onChange: setLocalValue, reset, } = (0, local_state_1.useLocalState)({
|
|
21
21
|
schema,
|
|
22
22
|
setValue,
|
|
23
|
-
value,
|
|
24
|
-
defaultValue,
|
|
23
|
+
unsavedValue: value,
|
|
24
|
+
savedValue: defaultValue,
|
|
25
25
|
});
|
|
26
26
|
const onChange = (0, react_1.useCallback)((e) => {
|
|
27
27
|
setLocalValue(() => e.target.value, false, false);
|
|
@@ -3,15 +3,15 @@ import type { z } from 'zod';
|
|
|
3
3
|
import type { JSONPath } from './zod-types';
|
|
4
4
|
export type UpdaterFunction<T> = (updater: (oldValue: T) => T, forceApply: boolean, increment: boolean) => void;
|
|
5
5
|
export declare const ZodSwitch: React.FC<{
|
|
6
|
-
schema: z.ZodTypeAny;
|
|
7
|
-
jsonPath: JSONPath;
|
|
8
|
-
value: unknown;
|
|
9
|
-
defaultValue: unknown;
|
|
10
|
-
setValue: UpdaterFunction<unknown>;
|
|
11
|
-
onSave: UpdaterFunction<unknown>;
|
|
12
|
-
showSaveButton: boolean;
|
|
13
|
-
onRemove: null | (() => void);
|
|
14
|
-
saving: boolean;
|
|
15
|
-
saveDisabledByParent: boolean;
|
|
16
|
-
mayPad: boolean;
|
|
6
|
+
readonly schema: z.ZodTypeAny;
|
|
7
|
+
readonly jsonPath: JSONPath;
|
|
8
|
+
readonly value: unknown;
|
|
9
|
+
readonly defaultValue: unknown;
|
|
10
|
+
readonly setValue: UpdaterFunction<unknown>;
|
|
11
|
+
readonly onSave: UpdaterFunction<unknown>;
|
|
12
|
+
readonly showSaveButton: boolean;
|
|
13
|
+
readonly onRemove: null | (() => void);
|
|
14
|
+
readonly saving: boolean;
|
|
15
|
+
readonly saveDisabledByParent: boolean;
|
|
16
|
+
readonly mayPad: boolean;
|
|
17
17
|
}>;
|
|
@@ -30,7 +30,7 @@ const ZodSwitch = ({ schema, jsonPath, value, setValue, defaultValue, onSave, sh
|
|
|
30
30
|
}
|
|
31
31
|
const zodTypes = (0, get_zod_if_possible_1.useZodTypesIfPossible)();
|
|
32
32
|
if (typeName === z.ZodFirstPartyTypeKind.ZodObject) {
|
|
33
|
-
return ((0, jsx_runtime_1.jsx)(ZodObjectEditor_1.ZodObjectEditor, { setValue: setValue,
|
|
33
|
+
return ((0, jsx_runtime_1.jsx)(ZodObjectEditor_1.ZodObjectEditor, { setValue: setValue, unsavedValue: value, savedValue: defaultValue, jsonPath: jsonPath, schema: schema, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving, saveDisabledByParent: saveDisabledByParent, mayPad: mayPad, discriminatedUnionReplacement: null }));
|
|
34
34
|
}
|
|
35
35
|
if (typeName === z.ZodFirstPartyTypeKind.ZodString) {
|
|
36
36
|
if (value.startsWith(window.remotion_staticBase)) {
|
|
@@ -3,15 +3,15 @@ import type { z } from 'zod';
|
|
|
3
3
|
import type { UpdaterFunction } from './ZodSwitch';
|
|
4
4
|
import type { JSONPath } from './zod-types';
|
|
5
5
|
export declare const ZodTextareaEditor: React.FC<{
|
|
6
|
-
schema: z.ZodTypeAny;
|
|
7
|
-
jsonPath: JSONPath;
|
|
8
|
-
value: string;
|
|
9
|
-
defaultValue: string;
|
|
10
|
-
setValue: UpdaterFunction<string>;
|
|
11
|
-
onSave: UpdaterFunction<string>;
|
|
12
|
-
onRemove: null | (() => void);
|
|
13
|
-
showSaveButton: boolean;
|
|
14
|
-
saving: boolean;
|
|
15
|
-
saveDisabledByParent: boolean;
|
|
16
|
-
mayPad: boolean;
|
|
6
|
+
readonly schema: z.ZodTypeAny;
|
|
7
|
+
readonly jsonPath: JSONPath;
|
|
8
|
+
readonly value: string;
|
|
9
|
+
readonly defaultValue: string;
|
|
10
|
+
readonly setValue: UpdaterFunction<string>;
|
|
11
|
+
readonly onSave: UpdaterFunction<string>;
|
|
12
|
+
readonly onRemove: null | (() => void);
|
|
13
|
+
readonly showSaveButton: boolean;
|
|
14
|
+
readonly saving: boolean;
|
|
15
|
+
readonly saveDisabledByParent: boolean;
|
|
16
|
+
readonly mayPad: boolean;
|
|
17
17
|
}>;
|
|
@@ -28,8 +28,8 @@ const ZodTextareaEditor = ({ jsonPath, value, setValue, showSaveButton, defaultV
|
|
|
28
28
|
const { localValue, onChange: setLocalValue, reset, } = (0, local_state_1.useLocalState)({
|
|
29
29
|
schema,
|
|
30
30
|
setValue,
|
|
31
|
-
value,
|
|
32
|
-
defaultValue,
|
|
31
|
+
unsavedValue: value,
|
|
32
|
+
savedValue: defaultValue,
|
|
33
33
|
});
|
|
34
34
|
const onChange = (0, react_1.useCallback)((e) => {
|
|
35
35
|
setLocalValue(() => e.target.value, false, false);
|
|
@@ -6,11 +6,15 @@ export type LocalState<T> = {
|
|
|
6
6
|
zodValidation: z.SafeParseReturnType<unknown, unknown>;
|
|
7
7
|
keyStabilityRevision: number;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
10
|
-
|
|
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;
|
|
11
15
|
schema: z.ZodTypeAny;
|
|
12
16
|
setValue: UpdaterFunction<T>;
|
|
13
|
-
|
|
17
|
+
savedValue: T;
|
|
14
18
|
}) => {
|
|
15
19
|
localValue: LocalState<T>;
|
|
16
20
|
onChange: (updater: (oldV: T) => T, forceApply: boolean, increment: boolean) => void;
|
|
@@ -1,32 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useLocalState = void 0;
|
|
3
|
+
exports.useLocalState = exports.RevisionContext = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
+
const update_default_props_1 = require("../../../api/update-default-props");
|
|
6
7
|
const deep_equal_1 = require("./deep-equal");
|
|
7
|
-
|
|
8
|
+
exports.RevisionContext = (0, react_1.createContext)({
|
|
8
9
|
childResetRevision: 0,
|
|
9
10
|
});
|
|
10
|
-
const useLocalState = ({
|
|
11
|
-
const parentRevision = (0, react_1.useContext)(RevisionContext).childResetRevision;
|
|
11
|
+
const useLocalState = ({ unsavedValue, schema, setValue, savedValue, }) => {
|
|
12
|
+
const parentRevision = (0, react_1.useContext)(exports.RevisionContext).childResetRevision;
|
|
12
13
|
const [resetRevision, setResetRevision] = (0, react_1.useState)(0);
|
|
13
|
-
const [
|
|
14
|
+
const [localValueOrNull, setLocalValue] = (0, react_1.useState)(() => {
|
|
14
15
|
return {
|
|
15
16
|
[parentRevision]: {
|
|
16
|
-
value,
|
|
17
|
+
value: unsavedValue,
|
|
17
18
|
keyStabilityRevision: 0,
|
|
18
|
-
zodValidation: schema.safeParse(
|
|
19
|
+
zodValidation: schema.safeParse(unsavedValue),
|
|
19
20
|
},
|
|
20
21
|
};
|
|
21
22
|
});
|
|
23
|
+
const localValue = (0, react_1.useMemo)(() => {
|
|
24
|
+
if (localValueOrNull === null) {
|
|
25
|
+
return {
|
|
26
|
+
[parentRevision]: {
|
|
27
|
+
value: unsavedValue,
|
|
28
|
+
keyStabilityRevision: 0,
|
|
29
|
+
zodValidation: schema.safeParse(unsavedValue),
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return localValueOrNull;
|
|
34
|
+
}, [localValueOrNull, parentRevision, schema, unsavedValue]);
|
|
35
|
+
(0, react_1.useEffect)(() => {
|
|
36
|
+
const checkFile = () => {
|
|
37
|
+
setResetRevision((old) => old + 1);
|
|
38
|
+
setLocalValue(null);
|
|
39
|
+
};
|
|
40
|
+
window.addEventListener(update_default_props_1.PROPS_UPDATED_EXTERNALLY, checkFile);
|
|
41
|
+
return () => {
|
|
42
|
+
window.removeEventListener(update_default_props_1.PROPS_UPDATED_EXTERNALLY, checkFile);
|
|
43
|
+
};
|
|
44
|
+
}, []);
|
|
22
45
|
const currentLocalValue = (0, react_1.useMemo)(() => {
|
|
23
46
|
var _a;
|
|
24
47
|
return ((_a = localValue[parentRevision]) !== null && _a !== void 0 ? _a : {
|
|
25
|
-
value:
|
|
48
|
+
value: savedValue,
|
|
26
49
|
keyStabilityRevision: 0,
|
|
27
|
-
zodValidation: schema.safeParse(
|
|
50
|
+
zodValidation: schema.safeParse(savedValue),
|
|
28
51
|
});
|
|
29
|
-
}, [
|
|
52
|
+
}, [savedValue, localValue, parentRevision, schema]);
|
|
30
53
|
const stateRef = (0, react_1.useRef)(currentLocalValue);
|
|
31
54
|
stateRef.current = currentLocalValue;
|
|
32
55
|
const onChange = (0, react_1.useCallback)(
|
|
@@ -69,17 +92,17 @@ const useLocalState = ({ value, schema, setValue, defaultValue, }) => {
|
|
|
69
92
|
const reset = (0, react_1.useCallback)(() => {
|
|
70
93
|
// Only need to do key stability for arrays, but
|
|
71
94
|
// since user is not editing right now, should be fine
|
|
72
|
-
onChange(() =>
|
|
95
|
+
onChange(() => savedValue, true, true);
|
|
73
96
|
setResetRevision((old) => old + 1);
|
|
74
|
-
}, [
|
|
97
|
+
}, [savedValue, onChange]);
|
|
75
98
|
const RevisionContextProvider = (0, react_1.useCallback)(({ children }) => {
|
|
76
|
-
return ((0, jsx_runtime_1.jsx)(RevisionContext.Provider, { value: contextValue, children: children }));
|
|
99
|
+
return ((0, jsx_runtime_1.jsx)(exports.RevisionContext.Provider, { value: contextValue, children: children }));
|
|
77
100
|
}, [contextValue]);
|
|
78
|
-
return {
|
|
101
|
+
return (0, react_1.useMemo)(() => ({
|
|
79
102
|
localValue: currentLocalValue,
|
|
80
103
|
onChange,
|
|
81
104
|
reset,
|
|
82
105
|
RevisionContextProvider,
|
|
83
|
-
};
|
|
106
|
+
}), [RevisionContextProvider, currentLocalValue, onChange, reset]);
|
|
84
107
|
};
|
|
85
108
|
exports.useLocalState = useLocalState;
|