@remotion/cli 4.0.0-alpha.217 → 4.0.0-alpha10
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 +11 -6
- package/dist/better-opn/index.js +3 -3
- 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 +4 -2
- package/dist/codemods/update-default-props.js +3 -18
- package/dist/color-math.d.ts +2 -2
- package/dist/color-math.js +5 -3
- package/dist/compositions.js +1 -0
- package/dist/config/image-format.d.ts +1 -1
- package/dist/config/index.d.ts +2 -2
- package/dist/config/log.d.ts +1 -3
- package/dist/config/log.js +2 -9
- package/dist/convert-entry-point-to-serve-url.js +2 -2
- package/dist/download-progress.d.ts +1 -1
- package/dist/download-progress.js +1 -4
- package/dist/editor/components/CanvasOrLoading.d.ts +5 -0
- package/dist/editor/components/CanvasOrLoading.js +66 -0
- package/dist/editor/components/CheckboardToggle.js +2 -1
- package/dist/editor/components/CompositionSelectorItem.js +2 -2
- package/dist/editor/components/CurrentCompositionSideEffects.js +3 -3
- package/dist/editor/components/InitialCompositionLoader.js +1 -1
- package/dist/editor/components/InlineAction.d.ts +6 -4
- package/dist/editor/components/InlineAction.js +7 -8
- package/dist/editor/components/LoopToggle.js +2 -1
- package/dist/editor/components/Menu/MenuItem.js +1 -1
- package/dist/editor/components/Menu/SubMenu.js +1 -1
- package/dist/editor/components/Menu/styles.d.ts +1 -0
- package/dist/editor/components/Menu/styles.js +6 -1
- package/dist/editor/components/MenuBuildIndicator.js +20 -1
- package/dist/editor/components/MenuToolbar.js +15 -3
- package/dist/editor/components/Modals.js +2 -2
- package/dist/editor/components/NewComposition/ComboBox.js +20 -5
- package/dist/editor/components/NewComposition/InputDragger.js +3 -2
- package/dist/editor/components/NewComposition/MenuContent.d.ts +1 -0
- package/dist/editor/components/NewComposition/MenuContent.js +12 -4
- package/dist/editor/components/Notifications/ServerDisconnected.js +2 -2
- package/dist/editor/components/OpenEditorButton.d.ts +2 -0
- package/dist/editor/components/OpenEditorButton.js +52 -0
- package/dist/editor/components/PlayPause.js +4 -2
- package/dist/editor/components/PreviewToolbar.js +2 -2
- package/dist/editor/components/QuickSwitcher/algolia-search.js +1 -1
- package/dist/editor/components/RenderButton.d.ts +1 -5
- package/dist/editor/components/RenderButton.js +48 -21
- package/dist/editor/components/RenderModal/CliCopyButton.js +51 -14
- package/dist/editor/components/RenderModal/CrfSetting.d.ts +0 -1
- package/dist/editor/components/RenderModal/CrfSetting.js +0 -1
- package/dist/editor/components/RenderModal/DataEditor.d.ts +21 -0
- package/dist/editor/components/RenderModal/DataEditor.js +287 -0
- package/dist/editor/components/RenderModal/EnforceAudioTrackSetting.js +3 -2
- package/dist/editor/components/RenderModal/InfoBubble.js +2 -1
- package/dist/editor/components/RenderModal/InfoTooltip.d.ts +1 -0
- package/dist/editor/components/RenderModal/InfoTooltip.js +6 -5
- package/dist/editor/components/RenderModal/InlineEyeIcon.js +6 -3
- package/dist/editor/components/RenderModal/InlineRemoveButton.js +6 -1
- package/dist/editor/components/RenderModal/MutedSetting.js +3 -2
- package/dist/editor/components/RenderModal/OptionExplainer.js +14 -3
- package/dist/editor/components/RenderModal/RenderModal.d.ts +7 -3
- package/dist/editor/components/RenderModal/RenderModal.js +108 -49
- package/dist/editor/components/RenderModal/RenderModalAdvanced.js +0 -2
- package/dist/editor/components/RenderModal/RenderModalAudio.js +1 -1
- package/dist/editor/components/RenderModal/RenderModalBasic.d.ts +3 -2
- package/dist/editor/components/RenderModal/RenderModalBasic.js +4 -3
- package/dist/editor/components/RenderModal/RenderModalData.d.ts +16 -4
- package/dist/editor/components/RenderModal/RenderModalData.js +109 -42
- package/dist/editor/components/RenderModal/RenderModalJSONPropsEditor.d.ts +14 -0
- package/dist/editor/components/RenderModal/{RenderModalJSONInputPropsEditor.js → RenderModalJSONPropsEditor.js} +51 -30
- package/dist/editor/components/RenderModal/RenderModalPicture.d.ts +2 -2
- package/dist/editor/components/RenderModal/RenderModalPicture.js +2 -4
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaEditor.d.ts +6 -4
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaEditor.js +4 -4
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaErrorMessages.d.ts +4 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaErrorMessages.js +15 -6
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaLabel.d.ts +5 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaLabel.js +5 -4
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaResetButton.js +6 -1
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaSaveButton.d.ts +1 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaSaveButton.js +7 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.d.ts +5 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.js +19 -29
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayItemEditor.d.ts +5 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayItemEditor.js +4 -4
- package/dist/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.d.ts +5 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.js +7 -7
- package/dist/editor/components/RenderModal/SchemaEditor/ZodColorEditor.d.ts +5 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodColorEditor.js +23 -66
- package/dist/editor/components/RenderModal/SchemaEditor/ZodDateEditor.d.ts +5 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodDateEditor.js +13 -21
- package/dist/editor/components/RenderModal/SchemaEditor/ZodDefaultEditor.d.ts +17 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodDefaultEditor.js +10 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEffectEditor.d.ts +4 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEffectEditor.js +20 -19
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEnumEditor.d.ts +4 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEnumEditor.js +12 -26
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.d.ts +1 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.js +2 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNullableEditor.d.ts +5 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNullableEditor.js +2 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.d.ts +5 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.js +16 -32
- package/dist/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.d.ts +7 -4
- package/dist/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.js +18 -11
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOptionalEditor.d.ts +5 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOptionalEditor.js +2 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.d.ts +5 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.js +44 -11
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStaticFileEditor.d.ts +17 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStaticFileEditor.js +59 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStringEditor.d.ts +5 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStringEditor.js +12 -23
- package/dist/editor/components/RenderModal/SchemaEditor/ZodSwitch.d.ts +5 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodSwitch.js +32 -21
- package/dist/editor/components/RenderModal/SchemaEditor/ZodUnionEditor.d.ts +5 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodUnionEditor.js +6 -6
- package/dist/editor/components/RenderModal/SchemaEditor/create-zod-values.d.ts +2 -2
- package/dist/editor/components/RenderModal/SchemaEditor/create-zod-values.js +22 -22
- package/dist/editor/components/RenderModal/SchemaEditor/deep-equal.d.ts +1 -0
- package/dist/editor/components/RenderModal/SchemaEditor/deep-equal.js +27 -0
- 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 +14 -0
- package/dist/editor/components/RenderModal/SchemaEditor/input-props-serialization.js +42 -0
- package/dist/editor/components/RenderModal/SchemaEditor/local-state.d.ts +16 -0
- package/dist/editor/components/RenderModal/SchemaEditor/local-state.js +38 -0
- package/dist/editor/components/RenderModal/get-render-modal-warnings.d.ts +9 -1
- package/dist/editor/components/RenderModal/get-render-modal-warnings.js +42 -8
- package/dist/editor/components/RenderModal/human-readable-codec.d.ts +1 -1
- package/dist/editor/components/RenderModal/layout.js +3 -0
- package/dist/editor/components/RenderModal/out-name-checker.js +1 -11
- package/dist/editor/components/RenderQueue/RenderQueueItemCancelButton.js +5 -1
- package/dist/editor/components/RenderQueue/RenderQueueOpenInFolder.js +5 -1
- package/dist/editor/components/RenderQueue/RenderQueueRemoveItem.js +5 -1
- package/dist/editor/components/RenderQueue/RenderQueueRepeat.js +5 -1
- package/dist/editor/components/RenderQueue/actions.d.ts +4 -3
- package/dist/editor/components/RenderQueue/actions.js +8 -3
- package/dist/editor/components/RenderQueue/index.js +9 -2
- package/dist/editor/components/RightPanel.js +8 -5
- package/dist/editor/components/SidebarCollapserControls.js +22 -9
- package/dist/editor/components/SidebarRenderButton.d.ts +6 -0
- package/dist/editor/components/{RenderToolbarIcon.js → SidebarRenderButton.js} +27 -41
- package/dist/editor/components/Spinner.d.ts +5 -0
- package/dist/editor/components/Spinner.js +41 -0
- package/dist/editor/components/Tabs/index.js +12 -14
- package/dist/editor/components/Timeline/Timeline.js +3 -1
- package/dist/editor/components/Timeline/TimelinePlayCursorSyncer.js +4 -3
- package/dist/editor/components/Timeline/TimelineSequence.js +8 -6
- package/dist/editor/components/TimelineInOutToggle.js +2 -4
- package/dist/editor/components/TopPanel.js +2 -2
- package/dist/editor/components/UpdateCheck.js +2 -1
- package/dist/editor/components/get-zod-if-possible.d.ts +3 -3
- package/dist/editor/components/get-zod-if-possible.js +11 -11
- package/dist/editor/helpers/calculate-timeline.js +1 -1
- package/dist/editor/helpers/client-id.d.ts +2 -2
- package/dist/editor/helpers/client-id.js +5 -5
- package/dist/editor/helpers/colors.d.ts +4 -2
- package/dist/editor/helpers/colors.js +4 -2
- package/dist/editor/helpers/get-timeline-sequence-layout.d.ts +2 -2
- package/dist/editor/helpers/is-composition-still.d.ts +3 -2
- package/dist/editor/helpers/is-current-selected-still.js +3 -4
- package/dist/editor/helpers/use-file-existence.js +1 -1
- package/dist/editor/helpers/use-menu-structure.js +1 -1
- package/dist/editor/icons/media-volume.js +2 -1
- package/dist/editor/icons/render.d.ts +1 -0
- package/dist/editor/icons/render.js +1 -1
- package/dist/editor/state/modals.d.ts +3 -1
- package/dist/entry-point.js +17 -17
- package/dist/event-source-events.d.ts +2 -0
- package/dist/event-source.js +2 -2
- package/dist/ffmpeg.js +14 -5
- package/dist/file-watcher.js +5 -5
- package/dist/get-cli-options.d.ts +3 -3
- package/dist/get-cli-options.js +4 -4
- package/dist/get-composition-id.d.ts +14 -2
- package/dist/get-composition-id.js +32 -8
- package/dist/get-composition-with-dimension-override.d.ts +13 -2
- package/dist/get-composition-with-dimension-override.js +12 -2
- package/dist/get-config-file-name.js +6 -6
- package/dist/get-env.js +10 -10
- package/dist/get-filename.js +1 -0
- package/dist/get-input-props.d.ts +1 -1
- package/dist/get-input-props.js +9 -9
- package/dist/get-network-address.js +2 -2
- package/dist/handle-common-errors.d.ts +2 -1
- package/dist/handle-common-errors.js +2 -2
- package/dist/index.d.ts +41 -19
- package/dist/index.js +9 -6
- package/dist/list-of-remotion-packages.js +2 -1
- package/dist/load-config.js +8 -8
- 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/api-types.d.ts +3 -3
- package/dist/preview-server/dev-middleware/compatible-api.d.ts +2 -2
- package/dist/preview-server/dev-middleware/middleware.d.ts +1 -1
- package/dist/preview-server/dev-middleware/middleware.js +7 -7
- package/dist/preview-server/dev-middleware/range-parser.d.ts +1 -1
- package/dist/preview-server/dev-middleware/setup-hooks.js +2 -2
- package/dist/preview-server/error-overlay/react-overlay/utils/get-file-source.js +5 -5
- package/dist/preview-server/error-overlay/react-overlay/utils/open-in-editor.js +17 -17
- package/dist/preview-server/error-overlay/remotion-overlay/CalculateMetadataErrorExplainer.d.ts +2 -0
- package/dist/preview-server/error-overlay/remotion-overlay/CalculateMetadataErrorExplainer.js +18 -0
- package/dist/preview-server/error-overlay/remotion-overlay/CodeFrame.js +30 -12
- package/dist/preview-server/error-overlay/remotion-overlay/ErrorDisplay.d.ts +4 -0
- package/dist/preview-server/error-overlay/remotion-overlay/ErrorDisplay.js +5 -2
- package/dist/preview-server/error-overlay/remotion-overlay/ErrorLoader.d.ts +4 -0
- package/dist/preview-server/error-overlay/remotion-overlay/ErrorLoader.js +5 -5
- package/dist/preview-server/error-overlay/remotion-overlay/ErrorTitle.d.ts +1 -0
- package/dist/preview-server/error-overlay/remotion-overlay/ErrorTitle.js +4 -3
- package/dist/preview-server/error-overlay/remotion-overlay/HelpLink.js +2 -1
- package/dist/preview-server/error-overlay/remotion-overlay/Overlay.js +1 -1
- package/dist/preview-server/error-overlay/remotion-overlay/Retry.d.ts +4 -0
- package/dist/preview-server/error-overlay/remotion-overlay/Retry.js +9 -0
- package/dist/preview-server/file-existence-watchers.js +3 -3
- package/dist/preview-server/get-absolute-public-dir.js +3 -3
- package/dist/preview-server/get-package-manager.js +3 -3
- package/dist/preview-server/handler.d.ts +1 -1
- package/dist/preview-server/hot-middleware/index.d.ts +1 -1
- package/dist/preview-server/hot-middleware/index.js +2 -2
- package/dist/preview-server/live-events.d.ts +1 -1
- package/dist/preview-server/parse-body.d.ts +1 -1
- package/dist/preview-server/project-info.js +5 -5
- package/dist/preview-server/public-folder.js +8 -8
- package/dist/preview-server/render-queue/job.d.ts +11 -2
- package/dist/preview-server/render-queue/make-retry-payload.js +5 -1
- package/dist/preview-server/render-queue/open-directory-in-finder.js +8 -8
- package/dist/preview-server/render-queue/process-still.js +1 -0
- package/dist/preview-server/render-queue/queue.js +4 -4
- package/dist/preview-server/routes/can-update-default-props.js +3 -2
- package/dist/preview-server/routes/update-default-props.d.ts +2 -2
- package/dist/preview-server/routes/update-default-props.js +26 -15
- package/dist/preview-server/routes.d.ts +3 -2
- package/dist/preview-server/routes.js +10 -10
- package/dist/preview-server/serve-static.d.ts +1 -1
- package/dist/preview-server/serve-static.js +7 -7
- package/dist/preview-server/start-server.js +3 -3
- package/dist/preview.js +6 -4
- package/dist/print-error.d.ts +2 -1
- package/dist/print-error.js +8 -5
- package/dist/print-help.js +1 -1
- package/dist/progress-bar.d.ts +5 -4
- package/dist/progress-bar.js +42 -29
- package/dist/render-flows/render.d.ts +1 -1
- package/dist/render-flows/render.js +62 -35
- package/dist/render-flows/still.d.ts +3 -2
- package/dist/render-flows/still.js +34 -28
- package/dist/resolve-from.js +5 -5
- package/dist/setup-cache.d.ts +2 -1
- package/dist/setup-cache.js +10 -6
- package/dist/should-use-non-overlaying-logger.d.ts +4 -0
- package/dist/should-use-non-overlaying-logger.js +12 -0
- package/dist/show-compositions-picker.d.ts +8 -0
- package/dist/show-compositions-picker.js +51 -0
- package/dist/still.js +1 -0
- package/dist/studio.d.ts +1 -0
- package/dist/studio.js +140 -0
- package/dist/upgrade.js +2 -2
- package/dist/user-passed-output-location.d.ts +3 -2
- package/dist/user-passed-output-location.js +10 -5
- package/dist/versions.js +2 -2
- package/dist/watch-root-file.d.ts +1 -0
- package/dist/watch-root-file.js +22 -0
- package/package.json +89 -88
- package/styles/styles.css +4 -5
- package/dist/editor/components/CollapsableOptions.d.ts +0 -6
- package/dist/editor/components/CollapsableOptions.js +0 -35
- package/dist/editor/components/RenderModal/RenderModalJSONInputPropsEditor.d.ts +0 -10
- package/dist/editor/components/RenderModal/SchemaEditor/date-serialization.d.ts +0 -2
- package/dist/editor/components/RenderModal/SchemaEditor/date-serialization.js +0 -21
- package/dist/editor/components/RenderToolbarIcon.d.ts +0 -2
- package/dist/editor/icons/RenderStillIcon.d.ts +0 -3
- package/dist/editor/icons/RenderStillIcon.js +0 -8
|
@@ -7,15 +7,18 @@ const ZodArrayEditor_1 = require("./ZodArrayEditor");
|
|
|
7
7
|
const ZodBooleanEditor_1 = require("./ZodBooleanEditor");
|
|
8
8
|
const ZodColorEditor_1 = require("./ZodColorEditor");
|
|
9
9
|
const ZodDateEditor_1 = require("./ZodDateEditor");
|
|
10
|
+
const ZodDefaultEditor_1 = require("./ZodDefaultEditor");
|
|
11
|
+
const ZodEffectEditor_1 = require("./ZodEffectEditor");
|
|
10
12
|
const ZodEnumEditor_1 = require("./ZodEnumEditor");
|
|
11
13
|
const ZodNonEditableValue_1 = require("./ZodNonEditableValue");
|
|
12
14
|
const ZodNullableEditor_1 = require("./ZodNullableEditor");
|
|
13
15
|
const ZodNumberEditor_1 = require("./ZodNumberEditor");
|
|
14
16
|
const ZodObjectEditor_1 = require("./ZodObjectEditor");
|
|
15
17
|
const ZodOptionalEditor_1 = require("./ZodOptionalEditor");
|
|
18
|
+
const ZodStaticFileEditor_1 = require("./ZodStaticFileEditor");
|
|
16
19
|
const ZodStringEditor_1 = require("./ZodStringEditor");
|
|
17
20
|
const ZodUnionEditor_1 = require("./ZodUnionEditor");
|
|
18
|
-
const ZodSwitch = ({ schema, jsonPath, compact, value, setValue, defaultValue, onSave, showSaveButton, onRemove, }) => {
|
|
21
|
+
const ZodSwitch = ({ schema, jsonPath, compact, value, setValue, defaultValue, onSave, showSaveButton, onRemove, saving, saveDisabledByParent, }) => {
|
|
19
22
|
const def = schema._def;
|
|
20
23
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
24
|
const typeName = def.typeName;
|
|
@@ -23,59 +26,67 @@ const ZodSwitch = ({ schema, jsonPath, compact, value, setValue, defaultValue, o
|
|
|
23
26
|
if (!z) {
|
|
24
27
|
throw new Error('expected zod');
|
|
25
28
|
}
|
|
26
|
-
const
|
|
29
|
+
const zodTypes = (0, get_zod_if_possible_1.useZodTypesIfPossible)();
|
|
27
30
|
// TODO: (Maybe?) enable saving of inserted input props by cmd+s /ctrl + s (also for JSON view)
|
|
28
31
|
if (typeName === z.ZodFirstPartyTypeKind.ZodObject) {
|
|
29
|
-
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 }));
|
|
32
|
+
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, saveDisabledByParent: saveDisabledByParent }));
|
|
30
33
|
}
|
|
31
34
|
if (typeName === z.ZodFirstPartyTypeKind.ZodString) {
|
|
32
|
-
|
|
35
|
+
if (value.startsWith(window.remotion_staticBase)) {
|
|
36
|
+
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, saveDisabledByParent: saveDisabledByParent }));
|
|
37
|
+
}
|
|
38
|
+
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, saveDisabledByParent: saveDisabledByParent }));
|
|
33
39
|
}
|
|
34
40
|
if (typeName === z.ZodFirstPartyTypeKind.ZodDate) {
|
|
35
|
-
return ((0, jsx_runtime_1.jsx)(ZodDateEditor_1.ZodDateEditor, { value: value, setValue: setValue, jsonPath: jsonPath, schema: schema, compact: compact, onSave: onSave, defaultValue: defaultValue, showSaveButton: showSaveButton, onRemove: onRemove }));
|
|
41
|
+
return ((0, jsx_runtime_1.jsx)(ZodDateEditor_1.ZodDateEditor, { value: value, setValue: setValue, jsonPath: jsonPath, schema: schema, compact: compact, onSave: onSave, defaultValue: defaultValue, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving, saveDisabledByParent: saveDisabledByParent }));
|
|
36
42
|
}
|
|
37
43
|
if (typeName === z.ZodFirstPartyTypeKind.ZodNumber) {
|
|
38
|
-
return ((0, jsx_runtime_1.jsx)(ZodNumberEditor_1.ZodNumberEditor, { value: value, setValue: setValue, jsonPath: jsonPath, schema: schema, compact: compact, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove }));
|
|
44
|
+
return ((0, jsx_runtime_1.jsx)(ZodNumberEditor_1.ZodNumberEditor, { value: value, setValue: setValue, jsonPath: jsonPath, schema: schema, compact: compact, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving, saveDisabledByParent: saveDisabledByParent }));
|
|
39
45
|
}
|
|
40
46
|
if (typeName === z.ZodFirstPartyTypeKind.ZodBoolean) {
|
|
41
|
-
return ((0, jsx_runtime_1.jsx)(ZodBooleanEditor_1.ZodBooleanEditor, { value: value, setValue: setValue, jsonPath: jsonPath, compact: compact, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove }));
|
|
47
|
+
return ((0, jsx_runtime_1.jsx)(ZodBooleanEditor_1.ZodBooleanEditor, { value: value, setValue: setValue, jsonPath: jsonPath, compact: compact, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving, saveDisabledByParent: saveDisabledByParent }));
|
|
42
48
|
}
|
|
43
49
|
if (typeName === z.ZodFirstPartyTypeKind.ZodUndefined) {
|
|
44
|
-
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { compact: compact, jsonPath: jsonPath, showSaveButton: showSaveButton, label: 'undefined' }));
|
|
50
|
+
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { compact: compact, jsonPath: jsonPath, showSaveButton: showSaveButton, label: 'undefined', saving: saving }));
|
|
45
51
|
}
|
|
46
52
|
if (typeName === z.ZodFirstPartyTypeKind.ZodNull) {
|
|
47
|
-
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { compact: compact, jsonPath: jsonPath, showSaveButton: showSaveButton, label: 'null' }));
|
|
53
|
+
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { compact: compact, jsonPath: jsonPath, showSaveButton: showSaveButton, label: 'null', saving: saving }));
|
|
48
54
|
}
|
|
49
55
|
if (typeName === z.ZodFirstPartyTypeKind.ZodAny) {
|
|
50
|
-
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { compact: compact, jsonPath: jsonPath, showSaveButton: showSaveButton, label: 'any (not editable)' }));
|
|
56
|
+
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { compact: compact, jsonPath: jsonPath, showSaveButton: showSaveButton, label: 'any (not editable)', saving: saving }));
|
|
51
57
|
}
|
|
52
58
|
if (typeName === z.ZodFirstPartyTypeKind.ZodBigInt) {
|
|
53
|
-
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { compact: compact, jsonPath: jsonPath, showSaveButton: showSaveButton, label: 'BigInt (not editable)' }));
|
|
59
|
+
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { compact: compact, jsonPath: jsonPath, showSaveButton: showSaveButton, label: 'BigInt (not editable)', saving: saving }));
|
|
54
60
|
}
|
|
55
61
|
if (typeName === z.ZodFirstPartyTypeKind.ZodUnknown) {
|
|
56
|
-
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { compact: compact, jsonPath: jsonPath, showSaveButton: showSaveButton, label: 'unknown (not editable)' }));
|
|
62
|
+
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { compact: compact, jsonPath: jsonPath, showSaveButton: showSaveButton, label: 'unknown (not editable)', saving: saving }));
|
|
57
63
|
}
|
|
58
64
|
if (typeName === z.ZodFirstPartyTypeKind.ZodArray) {
|
|
59
|
-
return ((0, jsx_runtime_1.jsx)(ZodArrayEditor_1.ZodArrayEditor, { setValue: setValue, value: value, jsonPath: jsonPath, schema: schema, compact: compact, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove }));
|
|
65
|
+
return ((0, jsx_runtime_1.jsx)(ZodArrayEditor_1.ZodArrayEditor, { setValue: setValue, value: value, jsonPath: jsonPath, schema: schema, compact: compact, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving, saveDisabledByParent: saveDisabledByParent }));
|
|
60
66
|
}
|
|
61
67
|
if (typeName === z.ZodFirstPartyTypeKind.ZodEnum) {
|
|
62
|
-
return ((0, jsx_runtime_1.jsx)(ZodEnumEditor_1.ZodEnumEditor, { setValue: setValue, value: value, jsonPath: jsonPath, schema: schema, compact: compact, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove }));
|
|
68
|
+
return ((0, jsx_runtime_1.jsx)(ZodEnumEditor_1.ZodEnumEditor, { setValue: setValue, value: value, jsonPath: jsonPath, schema: schema, compact: compact, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving }));
|
|
63
69
|
}
|
|
64
70
|
if (typeName === z.ZodFirstPartyTypeKind.ZodEffects) {
|
|
65
|
-
if (
|
|
66
|
-
schema._def.description ===
|
|
67
|
-
|
|
71
|
+
if (zodTypes &&
|
|
72
|
+
schema._def.description ===
|
|
73
|
+
zodTypes.ZodZypesInternals.REMOTION_COLOR_BRAND) {
|
|
74
|
+
return ((0, jsx_runtime_1.jsx)(ZodColorEditor_1.ZodColorEditor, { value: value, setValue: setValue, jsonPath: jsonPath, schema: schema, compact: compact, onSave: onSave, defaultValue: defaultValue, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving, saveDisabledByParent: saveDisabledByParent }));
|
|
68
75
|
}
|
|
76
|
+
return ((0, jsx_runtime_1.jsx)(ZodEffectEditor_1.ZodEffectEditor, { value: value, setValue: setValue, jsonPath: jsonPath, schema: schema, compact: compact, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving }));
|
|
69
77
|
}
|
|
70
78
|
if (typeName === z.ZodFirstPartyTypeKind.ZodUnion) {
|
|
71
|
-
return ((0, jsx_runtime_1.jsx)(ZodUnionEditor_1.ZodUnionEditor, { schema: schema, showSaveButton: showSaveButton, jsonPath: jsonPath, compact: compact, value: value, defaultValue: defaultValue, setValue: setValue, onSave: onSave, onRemove: onRemove }));
|
|
79
|
+
return ((0, jsx_runtime_1.jsx)(ZodUnionEditor_1.ZodUnionEditor, { schema: schema, showSaveButton: showSaveButton, jsonPath: jsonPath, compact: compact, value: value, defaultValue: defaultValue, setValue: setValue, onSave: onSave, onRemove: onRemove, saving: saving, saveDisabledByParent: saveDisabledByParent }));
|
|
72
80
|
}
|
|
73
81
|
if (typeName === z.ZodFirstPartyTypeKind.ZodOptional) {
|
|
74
|
-
return ((0, jsx_runtime_1.jsx)(ZodOptionalEditor_1.ZodOptionalEditor, { compact: compact, jsonPath: jsonPath, showSaveButton: showSaveButton, defaultValue: defaultValue, value: value, setValue: setValue, onSave: onSave, onRemove: onRemove, schema: schema }));
|
|
82
|
+
return ((0, jsx_runtime_1.jsx)(ZodOptionalEditor_1.ZodOptionalEditor, { compact: compact, jsonPath: jsonPath, showSaveButton: showSaveButton, defaultValue: defaultValue, value: value, setValue: setValue, onSave: onSave, onRemove: onRemove, schema: schema, saving: saving, saveDisabledByParent: saveDisabledByParent }));
|
|
75
83
|
}
|
|
76
84
|
if (typeName === z.ZodFirstPartyTypeKind.ZodNullable) {
|
|
77
|
-
return ((0, jsx_runtime_1.jsx)(ZodNullableEditor_1.ZodNullableEditor, { compact: compact, jsonPath: jsonPath, showSaveButton: showSaveButton, defaultValue: defaultValue, value: value, setValue: setValue, onSave: onSave, onRemove: onRemove, schema: schema }));
|
|
85
|
+
return ((0, jsx_runtime_1.jsx)(ZodNullableEditor_1.ZodNullableEditor, { compact: compact, jsonPath: jsonPath, showSaveButton: showSaveButton, defaultValue: defaultValue, value: value, setValue: setValue, onSave: onSave, onRemove: onRemove, schema: schema, saving: saving, saveDisabledByParent: saveDisabledByParent }));
|
|
86
|
+
}
|
|
87
|
+
if (typeName === z.ZodFirstPartyTypeKind.ZodDefault) {
|
|
88
|
+
return ((0, jsx_runtime_1.jsx)(ZodDefaultEditor_1.ZodDefaultEditor, { compact: compact, jsonPath: jsonPath, showSaveButton: showSaveButton, defaultValue: defaultValue, value: value, setValue: setValue, onSave: onSave, onRemove: onRemove, schema: schema, saving: saving, saveDisabledByParent: saveDisabledByParent }));
|
|
78
89
|
}
|
|
79
|
-
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { compact: compact, jsonPath: jsonPath, showSaveButton: showSaveButton, label: `${typeName} (not editable)
|
|
90
|
+
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { compact: compact, jsonPath: jsonPath, showSaveButton: showSaveButton, label: `${typeName} (not editable)`, saving: saving }));
|
|
80
91
|
};
|
|
81
92
|
exports.ZodSwitch = ZodSwitch;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="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 ZodUnionEditor: React.FC<{
|
|
5
6
|
showSaveButton: boolean;
|
|
6
7
|
jsonPath: JSONPath;
|
|
@@ -8,7 +9,9 @@ export declare const ZodUnionEditor: React.FC<{
|
|
|
8
9
|
value: unknown;
|
|
9
10
|
defaultValue: unknown;
|
|
10
11
|
schema: z.ZodTypeAny;
|
|
11
|
-
setValue:
|
|
12
|
-
onSave:
|
|
12
|
+
setValue: UpdaterFunction<unknown>;
|
|
13
|
+
onSave: UpdaterFunction<unknown>;
|
|
13
14
|
onRemove: null | (() => void);
|
|
15
|
+
saving: boolean;
|
|
16
|
+
saveDisabledByParent: boolean;
|
|
14
17
|
}>;
|
|
@@ -24,26 +24,26 @@ const findNull = (value, zodType) => {
|
|
|
24
24
|
otherSchemaIsAlsoNullish,
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
|
-
const ZodUnionEditor = ({ jsonPath, compact, schema, setValue, onSave, defaultValue, value, showSaveButton, onRemove, }) => {
|
|
27
|
+
const ZodUnionEditor = ({ jsonPath, compact, schema, setValue, onSave, defaultValue, value, showSaveButton, onRemove, saving, saveDisabledByParent, }) => {
|
|
28
28
|
const { options } = schema._def;
|
|
29
29
|
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
30
30
|
if (!z) {
|
|
31
31
|
throw new Error('expected zod');
|
|
32
32
|
}
|
|
33
33
|
if (options.length > 2) {
|
|
34
|
-
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { jsonPath: jsonPath, label: 'Union with more than 2 options not editable', compact: compact, showSaveButton: showSaveButton }));
|
|
34
|
+
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { jsonPath: jsonPath, label: 'Union with more than 2 options not editable', compact: compact, showSaveButton: showSaveButton, saving: saving }));
|
|
35
35
|
}
|
|
36
36
|
if (options.length < 2) {
|
|
37
|
-
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { jsonPath: jsonPath, label: 'Union with less than 2 options not editable', compact: compact, showSaveButton: showSaveButton }));
|
|
37
|
+
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { jsonPath: jsonPath, label: 'Union with less than 2 options not editable', compact: compact, showSaveButton: showSaveButton, saving: saving }));
|
|
38
38
|
}
|
|
39
39
|
const nullResult = findNull(options, z);
|
|
40
40
|
if (!nullResult) {
|
|
41
|
-
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { jsonPath: jsonPath, label: 'Union only editable with 1 value being null', compact: compact, showSaveButton: showSaveButton }));
|
|
41
|
+
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { jsonPath: jsonPath, label: 'Union only editable with 1 value being null', compact: compact, showSaveButton: showSaveButton, saving: saving }));
|
|
42
42
|
}
|
|
43
43
|
const { otherSchema, nullishValue, otherSchemaIsAlsoNullish } = nullResult;
|
|
44
44
|
if (otherSchemaIsAlsoNullish) {
|
|
45
|
-
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { jsonPath: jsonPath, label: 'Not editable - both union values are nullish', compact: compact, showSaveButton: showSaveButton }));
|
|
45
|
+
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { jsonPath: jsonPath, label: 'Not editable - both union values are nullish', compact: compact, showSaveButton: showSaveButton, saving: saving }));
|
|
46
46
|
}
|
|
47
|
-
return ((0, jsx_runtime_1.jsx)(ZodOrNullishEditor_1.ZodOrNullishEditor, { compact: compact, defaultValue: defaultValue, jsonPath: jsonPath, onRemove: onRemove, onSave: onSave, schema: otherSchema, setValue: setValue, showSaveButton: showSaveButton, value: value, nullishValue: nullishValue }));
|
|
47
|
+
return ((0, jsx_runtime_1.jsx)(ZodOrNullishEditor_1.ZodOrNullishEditor, { compact: compact, defaultValue: defaultValue, jsonPath: jsonPath, onRemove: onRemove, onSave: onSave, schema: otherSchema, setValue: setValue, showSaveButton: showSaveButton, value: value, nullishValue: nullishValue, saving: saving, saveDisabledByParent: saveDisabledByParent }));
|
|
48
48
|
};
|
|
49
49
|
exports.ZodUnionEditor = ZodUnionEditor;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const createZodValues: (schema: Zod.ZodTypeAny, zodRuntime: ZodType,
|
|
1
|
+
import type { ZodType, ZodTypesType } from '../../get-zod-if-possible';
|
|
2
|
+
export declare const createZodValues: (schema: Zod.ZodTypeAny, zodRuntime: ZodType, zodTypes: ZodTypesType | null) => unknown;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createZodValues = void 0;
|
|
4
|
-
const createZodValues = (schema, zodRuntime,
|
|
4
|
+
const createZodValues = (schema, zodRuntime, zodTypes) => {
|
|
5
5
|
if (!schema) {
|
|
6
6
|
throw new Error('Invalid zod schema');
|
|
7
7
|
}
|
|
@@ -38,71 +38,71 @@ const createZodValues = (schema, zodRuntime, zColorRuntime) => {
|
|
|
38
38
|
const shape = def.shape();
|
|
39
39
|
const keys = Object.keys(shape);
|
|
40
40
|
const returnValue = keys.reduce((existing, key) => {
|
|
41
|
-
existing[key] = (0, exports.createZodValues)(shape[key], zodRuntime,
|
|
41
|
+
existing[key] = (0, exports.createZodValues)(shape[key], zodRuntime, zodTypes);
|
|
42
42
|
return existing;
|
|
43
43
|
}, {});
|
|
44
44
|
return returnValue;
|
|
45
45
|
}
|
|
46
46
|
case zodRuntime.ZodFirstPartyTypeKind.ZodArray: {
|
|
47
47
|
return [
|
|
48
|
-
(0, exports.createZodValues)(def.type, zodRuntime,
|
|
48
|
+
(0, exports.createZodValues)(def.type, zodRuntime, zodTypes),
|
|
49
49
|
];
|
|
50
50
|
}
|
|
51
51
|
case zodRuntime.ZodFirstPartyTypeKind.ZodUnion: {
|
|
52
52
|
const firstOptions = def.options[0];
|
|
53
53
|
return firstOptions
|
|
54
|
-
? (0, exports.createZodValues)(firstOptions, zodRuntime,
|
|
54
|
+
? (0, exports.createZodValues)(firstOptions, zodRuntime, zodTypes)
|
|
55
55
|
: undefined;
|
|
56
56
|
}
|
|
57
57
|
case zodRuntime.ZodFirstPartyTypeKind.ZodDiscriminatedUnion: {
|
|
58
58
|
const options = def.options[0];
|
|
59
|
-
return (0, exports.createZodValues)(options, zodRuntime,
|
|
59
|
+
return (0, exports.createZodValues)(options, zodRuntime, zodTypes);
|
|
60
60
|
}
|
|
61
61
|
case zodRuntime.ZodFirstPartyTypeKind.ZodLiteral: {
|
|
62
62
|
return def.value;
|
|
63
63
|
}
|
|
64
64
|
case zodRuntime.ZodFirstPartyTypeKind.ZodEffects: {
|
|
65
|
-
if (
|
|
65
|
+
if (zodTypes &&
|
|
66
66
|
schema._def.description ===
|
|
67
|
-
|
|
67
|
+
zodTypes.ZodZypesInternals.REMOTION_COLOR_BRAND) {
|
|
68
68
|
return '#ffffff';
|
|
69
69
|
}
|
|
70
|
-
return (0, exports.createZodValues)(def.schema, zodRuntime,
|
|
70
|
+
return (0, exports.createZodValues)(def.schema, zodRuntime, zodTypes);
|
|
71
71
|
}
|
|
72
72
|
case zodRuntime.ZodFirstPartyTypeKind.ZodIntersection: {
|
|
73
73
|
const { left, right } = def;
|
|
74
|
-
const leftValue = (0, exports.createZodValues)(left, zodRuntime,
|
|
74
|
+
const leftValue = (0, exports.createZodValues)(left, zodRuntime, zodTypes);
|
|
75
75
|
if (typeof leftValue !== 'object') {
|
|
76
76
|
throw new Error('Cannot create value for type z.intersection: Left side is not an object');
|
|
77
77
|
}
|
|
78
|
-
const rightValue = (0, exports.createZodValues)(right, zodRuntime,
|
|
78
|
+
const rightValue = (0, exports.createZodValues)(right, zodRuntime, zodTypes);
|
|
79
79
|
if (typeof rightValue !== 'object') {
|
|
80
80
|
throw new Error('Cannot create value for type z.intersection: Right side is not an object');
|
|
81
81
|
}
|
|
82
82
|
return { ...leftValue, ...rightValue };
|
|
83
83
|
}
|
|
84
84
|
case zodRuntime.ZodFirstPartyTypeKind.ZodTuple: {
|
|
85
|
-
const items = def.items.map((item) => (0, exports.createZodValues)(item, zodRuntime,
|
|
85
|
+
const items = def.items.map((item) => (0, exports.createZodValues)(item, zodRuntime, zodTypes));
|
|
86
86
|
return items;
|
|
87
87
|
}
|
|
88
88
|
case zodRuntime.ZodFirstPartyTypeKind.ZodRecord: {
|
|
89
|
-
const values = (0, exports.createZodValues)(def.valueType, zodRuntime,
|
|
89
|
+
const values = (0, exports.createZodValues)(def.valueType, zodRuntime, zodTypes);
|
|
90
90
|
return { key: values };
|
|
91
91
|
}
|
|
92
92
|
case zodRuntime.ZodFirstPartyTypeKind.ZodMap: {
|
|
93
93
|
const defType = def;
|
|
94
|
-
const values = (0, exports.createZodValues)(defType.valueType, zodRuntime,
|
|
95
|
-
const key = (0, exports.createZodValues)(defType.keyType, zodRuntime,
|
|
94
|
+
const values = (0, exports.createZodValues)(defType.valueType, zodRuntime, zodTypes);
|
|
95
|
+
const key = (0, exports.createZodValues)(defType.keyType, zodRuntime, zodTypes);
|
|
96
96
|
return new Map([[key, values]]);
|
|
97
97
|
}
|
|
98
98
|
case zodRuntime.ZodFirstPartyTypeKind.ZodLazy: {
|
|
99
99
|
const defType = def;
|
|
100
100
|
const type = defType.getter();
|
|
101
|
-
return (0, exports.createZodValues)(type, zodRuntime,
|
|
101
|
+
return (0, exports.createZodValues)(type, zodRuntime, zodTypes);
|
|
102
102
|
}
|
|
103
103
|
case zodRuntime.ZodFirstPartyTypeKind.ZodSet: {
|
|
104
104
|
const defType = def;
|
|
105
|
-
const values = (0, exports.createZodValues)(defType.valueType, zodRuntime,
|
|
105
|
+
const values = (0, exports.createZodValues)(defType.valueType, zodRuntime, zodTypes);
|
|
106
106
|
return new Set([values]);
|
|
107
107
|
}
|
|
108
108
|
case zodRuntime.ZodFirstPartyTypeKind.ZodFunction: {
|
|
@@ -117,12 +117,12 @@ const createZodValues = (schema, zodRuntime, zColorRuntime) => {
|
|
|
117
117
|
}
|
|
118
118
|
case zodRuntime.ZodFirstPartyTypeKind.ZodOptional: {
|
|
119
119
|
const defType = def;
|
|
120
|
-
const value = (0, exports.createZodValues)(defType.innerType, zodRuntime,
|
|
120
|
+
const value = (0, exports.createZodValues)(defType.innerType, zodRuntime, zodTypes);
|
|
121
121
|
return value;
|
|
122
122
|
}
|
|
123
123
|
case zodRuntime.ZodFirstPartyTypeKind.ZodNullable: {
|
|
124
124
|
const defType = def;
|
|
125
|
-
const value = (0, exports.createZodValues)(defType.innerType, zodRuntime,
|
|
125
|
+
const value = (0, exports.createZodValues)(defType.innerType, zodRuntime, zodTypes);
|
|
126
126
|
return value;
|
|
127
127
|
}
|
|
128
128
|
case zodRuntime.ZodFirstPartyTypeKind.ZodDefault: {
|
|
@@ -131,24 +131,24 @@ const createZodValues = (schema, zodRuntime, zColorRuntime) => {
|
|
|
131
131
|
}
|
|
132
132
|
case zodRuntime.ZodFirstPartyTypeKind.ZodCatch: {
|
|
133
133
|
const defType = def;
|
|
134
|
-
const value = (0, exports.createZodValues)(defType.innerType, zodRuntime,
|
|
134
|
+
const value = (0, exports.createZodValues)(defType.innerType, zodRuntime, zodTypes);
|
|
135
135
|
return value;
|
|
136
136
|
}
|
|
137
137
|
case zodRuntime.ZodFirstPartyTypeKind.ZodPromise: {
|
|
138
138
|
const defType = def;
|
|
139
|
-
const value = (0, exports.createZodValues)(defType.type, zodRuntime,
|
|
139
|
+
const value = (0, exports.createZodValues)(defType.type, zodRuntime, zodTypes);
|
|
140
140
|
return Promise.resolve(value);
|
|
141
141
|
}
|
|
142
142
|
case zodRuntime.ZodFirstPartyTypeKind.ZodBranded: {
|
|
143
143
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
144
144
|
const defType = def;
|
|
145
|
-
const value = (0, exports.createZodValues)(defType.type, zodRuntime,
|
|
145
|
+
const value = (0, exports.createZodValues)(defType.type, zodRuntime, zodTypes);
|
|
146
146
|
return value;
|
|
147
147
|
}
|
|
148
148
|
case zodRuntime.ZodFirstPartyTypeKind.ZodPipeline: {
|
|
149
149
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
150
150
|
const defType = def;
|
|
151
|
-
const value = (0, exports.createZodValues)(defType.out, zodRuntime,
|
|
151
|
+
const value = (0, exports.createZodValues)(defType.out, zodRuntime, zodTypes);
|
|
152
152
|
return value;
|
|
153
153
|
}
|
|
154
154
|
default:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function deepEqual(a: any, b: any): boolean;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deepEqual = void 0;
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
+
function deepEqual(a, b) {
|
|
6
|
+
if (a === b) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
if (typeof a !== 'object' ||
|
|
10
|
+
a === null ||
|
|
11
|
+
typeof b !== 'object' ||
|
|
12
|
+
b === null) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
const keysA = Object.keys(a);
|
|
16
|
+
const keysB = Object.keys(b);
|
|
17
|
+
if (keysA.length !== keysB.length) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
for (const key of keysA) {
|
|
21
|
+
if (!keysB.includes(key) || !deepEqual(a[key], b[key])) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
exports.deepEqual = deepEqual;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractEnumJsonPaths = void 0;
|
|
4
|
+
const extractEnumJsonPaths = (schema, zodRuntime, currentPath) => {
|
|
5
|
+
const def = schema._def;
|
|
6
|
+
const typeName = def.typeName;
|
|
7
|
+
switch (typeName) {
|
|
8
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodObject: {
|
|
9
|
+
const shape = def.shape();
|
|
10
|
+
const keys = Object.keys(shape);
|
|
11
|
+
return keys
|
|
12
|
+
.map((key) => {
|
|
13
|
+
return (0, exports.extractEnumJsonPaths)(shape[key], zodRuntime, [
|
|
14
|
+
...currentPath,
|
|
15
|
+
key,
|
|
16
|
+
]);
|
|
17
|
+
})
|
|
18
|
+
.flat(1);
|
|
19
|
+
}
|
|
20
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodArray: {
|
|
21
|
+
return (0, exports.extractEnumJsonPaths)(def.type, zodRuntime, [
|
|
22
|
+
...currentPath,
|
|
23
|
+
'[]',
|
|
24
|
+
]);
|
|
25
|
+
}
|
|
26
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodUnion: {
|
|
27
|
+
return def.options
|
|
28
|
+
.map((option) => {
|
|
29
|
+
return (0, exports.extractEnumJsonPaths)(option, zodRuntime, currentPath);
|
|
30
|
+
})
|
|
31
|
+
.flat(1);
|
|
32
|
+
}
|
|
33
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodDiscriminatedUnion: {
|
|
34
|
+
return def.options
|
|
35
|
+
.map((op) => {
|
|
36
|
+
return (0, exports.extractEnumJsonPaths)(op, zodRuntime, currentPath);
|
|
37
|
+
})
|
|
38
|
+
.flat(1);
|
|
39
|
+
}
|
|
40
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodLiteral: {
|
|
41
|
+
return [currentPath];
|
|
42
|
+
}
|
|
43
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodEffects: {
|
|
44
|
+
return (0, exports.extractEnumJsonPaths)(def.schema, zodRuntime, currentPath);
|
|
45
|
+
}
|
|
46
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodIntersection: {
|
|
47
|
+
const { left, right } = def;
|
|
48
|
+
const leftValue = (0, exports.extractEnumJsonPaths)(left, zodRuntime, currentPath);
|
|
49
|
+
const rightValue = (0, exports.extractEnumJsonPaths)(right, zodRuntime, currentPath);
|
|
50
|
+
return [...leftValue, ...rightValue];
|
|
51
|
+
}
|
|
52
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodTuple: {
|
|
53
|
+
return def.items
|
|
54
|
+
.map((item, i) => (0, exports.extractEnumJsonPaths)(item, zodRuntime, [...currentPath, i]))
|
|
55
|
+
.flat(1);
|
|
56
|
+
}
|
|
57
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodRecord: {
|
|
58
|
+
const values = (0, exports.extractEnumJsonPaths)(def.valueType, zodRuntime, [...currentPath, '{}']);
|
|
59
|
+
return values;
|
|
60
|
+
}
|
|
61
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodFunction: {
|
|
62
|
+
throw new Error('Cannot create a value for type function');
|
|
63
|
+
}
|
|
64
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodEnum: {
|
|
65
|
+
return [currentPath];
|
|
66
|
+
}
|
|
67
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodNativeEnum: {
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodOptional: {
|
|
71
|
+
const defType = def;
|
|
72
|
+
const value = (0, exports.extractEnumJsonPaths)(defType.innerType, zodRuntime, currentPath);
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodNullable: {
|
|
76
|
+
const defType = def;
|
|
77
|
+
const value = (0, exports.extractEnumJsonPaths)(defType.innerType, zodRuntime, currentPath);
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
80
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodDefault: {
|
|
81
|
+
const defType = def;
|
|
82
|
+
return (0, exports.extractEnumJsonPaths)(defType.innerType, zodRuntime, currentPath);
|
|
83
|
+
}
|
|
84
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodCatch: {
|
|
85
|
+
const defType = def;
|
|
86
|
+
return (0, exports.extractEnumJsonPaths)(defType.innerType, zodRuntime, currentPath);
|
|
87
|
+
}
|
|
88
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodPromise: {
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodBranded: {
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
93
|
+
const defType = def;
|
|
94
|
+
const value = (0, exports.extractEnumJsonPaths)(defType.type, zodRuntime, currentPath);
|
|
95
|
+
return value;
|
|
96
|
+
}
|
|
97
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodPipeline: {
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
|
+
const defType = def;
|
|
100
|
+
const value = (0, exports.extractEnumJsonPaths)(defType.out, zodRuntime, currentPath);
|
|
101
|
+
return value;
|
|
102
|
+
}
|
|
103
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodString:
|
|
104
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodNumber:
|
|
105
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodBigInt:
|
|
106
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodBoolean:
|
|
107
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodNaN:
|
|
108
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodDate:
|
|
109
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodSymbol:
|
|
110
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodUndefined:
|
|
111
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodNull:
|
|
112
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodAny:
|
|
113
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodUnknown:
|
|
114
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodNever:
|
|
115
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodVoid:
|
|
116
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodMap: // Maps are not serializable
|
|
117
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodLazy:
|
|
118
|
+
case zodRuntime.ZodFirstPartyTypeKind.ZodSet: {
|
|
119
|
+
// Sets are not serializable
|
|
120
|
+
return [];
|
|
121
|
+
}
|
|
122
|
+
default:
|
|
123
|
+
throw new Error('Not implemented: ' + typeName);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
exports.extractEnumJsonPaths = extractEnumJsonPaths;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare type SerializedJSONWithCustomFields = {
|
|
2
|
+
serializedString: string;
|
|
3
|
+
customDateUsed: boolean;
|
|
4
|
+
customFileUsed: boolean;
|
|
5
|
+
mapUsed: boolean;
|
|
6
|
+
setUsed: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const FILE_TOKEN = "remotion-file:";
|
|
9
|
+
export declare const serializeJSONWithDate: ({ data, indent, staticBase, }: {
|
|
10
|
+
data: unknown;
|
|
11
|
+
indent: number | undefined;
|
|
12
|
+
staticBase: string;
|
|
13
|
+
}) => SerializedJSONWithCustomFields;
|
|
14
|
+
export declare const deserializeJSONWithCustomFields: (data: string) => any;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deserializeJSONWithCustomFields = exports.serializeJSONWithDate = exports.FILE_TOKEN = void 0;
|
|
4
|
+
const DATE_TOKEN = 'remotion-date:';
|
|
5
|
+
exports.FILE_TOKEN = 'remotion-file:';
|
|
6
|
+
const serializeJSONWithDate = ({ data, indent, staticBase, }) => {
|
|
7
|
+
let customDateUsed = false;
|
|
8
|
+
let customFileUsed = false;
|
|
9
|
+
let mapUsed = false;
|
|
10
|
+
let setUsed = false;
|
|
11
|
+
const serializedString = JSON.stringify(data, function (key, value) {
|
|
12
|
+
const item = this[key];
|
|
13
|
+
if (item instanceof Date) {
|
|
14
|
+
customDateUsed = true;
|
|
15
|
+
return `${DATE_TOKEN}${item.toISOString()}`;
|
|
16
|
+
}
|
|
17
|
+
if (item instanceof Map) {
|
|
18
|
+
mapUsed = true;
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
if (item instanceof Set) {
|
|
22
|
+
setUsed = true;
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
if (typeof item === 'string' && item.startsWith(staticBase)) {
|
|
26
|
+
customFileUsed = true;
|
|
27
|
+
return `${exports.FILE_TOKEN}${item.replace(staticBase + '/', '')}`;
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
}, indent);
|
|
31
|
+
return { serializedString, customDateUsed, customFileUsed, mapUsed, setUsed };
|
|
32
|
+
};
|
|
33
|
+
exports.serializeJSONWithDate = serializeJSONWithDate;
|
|
34
|
+
const deserializeJSONWithCustomFields = (data) => {
|
|
35
|
+
return JSON.parse(data, (_, value) => {
|
|
36
|
+
if (typeof value === 'string' && value.startsWith(DATE_TOKEN)) {
|
|
37
|
+
return new Date(value.replace(DATE_TOKEN, ''));
|
|
38
|
+
}
|
|
39
|
+
return value;
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
exports.deserializeJSONWithCustomFields = deserializeJSONWithCustomFields;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { UpdaterFunction } from './ZodSwitch';
|
|
3
|
+
declare type LocalState<T> = {
|
|
4
|
+
value: T;
|
|
5
|
+
zodValidation: z.SafeParseReturnType<unknown, unknown>;
|
|
6
|
+
revision: number;
|
|
7
|
+
};
|
|
8
|
+
export declare const useLocalState: <T>({ value, schema, setValue, }: {
|
|
9
|
+
value: T;
|
|
10
|
+
schema: z.ZodTypeAny;
|
|
11
|
+
setValue: UpdaterFunction<T>;
|
|
12
|
+
}) => {
|
|
13
|
+
localValue: LocalState<T>;
|
|
14
|
+
onChange: (updater: (oldV: T) => T, forceApply: boolean) => void;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLocalState = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const deep_equal_1 = require("./deep-equal");
|
|
6
|
+
const useLocalState = ({ value, schema, setValue, }) => {
|
|
7
|
+
const [localValue, setLocalValue] = (0, react_1.useState)(() => {
|
|
8
|
+
return {
|
|
9
|
+
value,
|
|
10
|
+
zodValidation: schema.safeParse(value),
|
|
11
|
+
revision: 0,
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
const stateRef = (0, react_1.useRef)(localValue);
|
|
15
|
+
stateRef.current = localValue;
|
|
16
|
+
const onChange = (0, react_1.useCallback)((updater, forceApply) => {
|
|
17
|
+
const newValue = updater(stateRef.current.value);
|
|
18
|
+
const isSame = (0, deep_equal_1.deepEqual)(newValue, stateRef.current.value);
|
|
19
|
+
if (isSame) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const safeParse = schema.safeParse(newValue);
|
|
23
|
+
if (safeParse.success || forceApply) {
|
|
24
|
+
setValue(updater, forceApply);
|
|
25
|
+
}
|
|
26
|
+
setLocalValue((oldLocalState) => {
|
|
27
|
+
const newState = {
|
|
28
|
+
revision: oldLocalState.revision + 1,
|
|
29
|
+
value: newValue,
|
|
30
|
+
zodValidation: safeParse,
|
|
31
|
+
};
|
|
32
|
+
stateRef.current = newState;
|
|
33
|
+
return newState;
|
|
34
|
+
});
|
|
35
|
+
}, [schema, setValue]);
|
|
36
|
+
return { localValue, onChange };
|
|
37
|
+
};
|
|
38
|
+
exports.useLocalState = useLocalState;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PropsEditType } from './DataEditor';
|
|
1
2
|
export declare type TypeCanSaveState = {
|
|
2
3
|
canUpdate: true;
|
|
3
4
|
} | {
|
|
@@ -5,7 +6,14 @@ export declare type TypeCanSaveState = {
|
|
|
5
6
|
reason: string;
|
|
6
7
|
determined: boolean;
|
|
7
8
|
};
|
|
8
|
-
export declare const
|
|
9
|
+
export declare const defaultTypeCanSaveState: TypeCanSaveState;
|
|
10
|
+
export declare const getRenderModalWarnings: ({ cliProps, canSaveDefaultProps, isCustomDateUsed, customFileUsed, jsMapUsed, jsSetUsed, inJSONEditor, propsEditType, }: {
|
|
9
11
|
cliProps: unknown;
|
|
10
12
|
canSaveDefaultProps: TypeCanSaveState;
|
|
13
|
+
isCustomDateUsed: boolean;
|
|
14
|
+
customFileUsed: boolean;
|
|
15
|
+
jsMapUsed: boolean;
|
|
16
|
+
jsSetUsed: boolean;
|
|
17
|
+
inJSONEditor: boolean;
|
|
18
|
+
propsEditType: PropsEditType;
|
|
11
19
|
}) => string[];
|