@remotion/cli 4.0.0-alpha5 → 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.
Files changed (160) hide show
  1. package/dist/benchmark.js +9 -4
  2. package/dist/better-opn/index.js +3 -3
  3. package/dist/chalk/index.d.ts +45 -54
  4. package/dist/chalk/index.js +2 -135
  5. package/dist/codemods/stringify-with-path.d.ts +5 -0
  6. package/dist/codemods/stringify-with-path.js +44 -0
  7. package/dist/codemods/update-default-props.d.ts +3 -1
  8. package/dist/codemods/update-default-props.js +3 -17
  9. package/dist/color-math.js +3 -1
  10. package/dist/compositions.js +1 -0
  11. package/dist/config/log.d.ts +1 -3
  12. package/dist/config/log.js +2 -9
  13. package/dist/convert-entry-point-to-serve-url.js +2 -2
  14. package/dist/download-progress.d.ts +1 -1
  15. package/dist/download-progress.js +1 -5
  16. package/dist/editor/components/MenuToolbar.js +15 -3
  17. package/dist/editor/components/NewComposition/ComboBox.js +2 -2
  18. package/dist/editor/components/NewComposition/MenuContent.js +1 -1
  19. package/dist/editor/components/NewComposition/RemInput.d.ts +1 -1
  20. package/dist/editor/components/NewComposition/RemInputTypeColor.d.ts +1 -1
  21. package/dist/editor/components/NewComposition/RemTextarea.d.ts +1 -1
  22. package/dist/editor/components/RenderModal/CliCopyButton.js +42 -9
  23. package/dist/editor/components/RenderModal/InfoTooltip.js +2 -1
  24. package/dist/editor/components/RenderModal/OptionExplainer.js +13 -3
  25. package/dist/editor/components/RenderModal/RenderModalData.js +21 -7
  26. package/dist/editor/components/RenderModal/RenderModalJSONPropsEditor.d.ts +2 -2
  27. package/dist/editor/components/RenderModal/RenderModalPicture.js +1 -1
  28. package/dist/editor/components/RenderModal/SchemaEditor/SchemaErrorMessages.js +1 -1
  29. package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.d.ts +3 -2
  30. package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.js +1 -1
  31. package/dist/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.d.ts +2 -1
  32. package/dist/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.js +1 -1
  33. package/dist/editor/components/RenderModal/SchemaEditor/ZodColorEditor.d.ts +2 -1
  34. package/dist/editor/components/RenderModal/SchemaEditor/ZodColorEditor.js +8 -8
  35. package/dist/editor/components/RenderModal/SchemaEditor/ZodDateEditor.d.ts +2 -1
  36. package/dist/editor/components/RenderModal/SchemaEditor/ZodDateEditor.js +5 -5
  37. package/dist/editor/components/RenderModal/SchemaEditor/ZodEffectEditor.d.ts +1 -1
  38. package/dist/editor/components/RenderModal/SchemaEditor/ZodEffectEditor.js +3 -2
  39. package/dist/editor/components/RenderModal/SchemaEditor/ZodEnumEditor.d.ts +3 -2
  40. package/dist/editor/components/RenderModal/SchemaEditor/ZodEnumEditor.js +4 -4
  41. package/dist/editor/components/RenderModal/SchemaEditor/ZodNullableEditor.d.ts +1 -1
  42. package/dist/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.d.ts +2 -1
  43. package/dist/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.js +9 -6
  44. package/dist/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.d.ts +1 -1
  45. package/dist/editor/components/RenderModal/SchemaEditor/ZodOptionalEditor.d.ts +1 -1
  46. package/dist/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.d.ts +1 -1
  47. package/dist/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.js +40 -7
  48. package/dist/editor/components/RenderModal/SchemaEditor/ZodStaticFileEditor.d.ts +16 -0
  49. package/dist/editor/components/RenderModal/SchemaEditor/ZodStaticFileEditor.js +73 -0
  50. package/dist/editor/components/RenderModal/SchemaEditor/ZodStringEditor.d.ts +2 -1
  51. package/dist/editor/components/RenderModal/SchemaEditor/ZodStringEditor.js +5 -5
  52. package/dist/editor/components/RenderModal/SchemaEditor/ZodSwitch.d.ts +2 -1
  53. package/dist/editor/components/RenderModal/SchemaEditor/ZodSwitch.js +4 -0
  54. package/dist/editor/components/RenderModal/SchemaEditor/ZodUnionEditor.d.ts +1 -1
  55. package/dist/editor/components/RenderModal/SchemaEditor/extract-enum-json-paths.d.ts +3 -0
  56. package/dist/editor/components/RenderModal/SchemaEditor/extract-enum-json-paths.js +126 -0
  57. package/dist/editor/components/RenderModal/SchemaEditor/input-props-serialization.d.ts +12 -0
  58. package/dist/editor/components/RenderModal/SchemaEditor/input-props-serialization.js +32 -0
  59. package/dist/editor/components/RenderModal/get-render-modal-warnings.d.ts +3 -2
  60. package/dist/editor/components/RenderModal/get-render-modal-warnings.js +9 -2
  61. package/dist/editor/components/RenderQueue/actions.d.ts +2 -1
  62. package/dist/editor/components/RenderQueue/actions.js +8 -4
  63. package/dist/editor/components/SidebarCollapserControls.js +12 -6
  64. package/dist/editor/components/Timeline/TimelineSequence.js +6 -4
  65. package/dist/editor/helpers/calculate-timeline.js +1 -1
  66. package/dist/editor/helpers/colors.d.ts +1 -1
  67. package/dist/editor/helpers/colors.js +1 -1
  68. package/dist/entry-point.js +17 -17
  69. package/dist/ffmpeg.js +12 -3
  70. package/dist/file-watcher.js +5 -5
  71. package/dist/get-cli-options.js +4 -4
  72. package/dist/get-config-file-name.js +6 -6
  73. package/dist/get-env.js +10 -10
  74. package/dist/get-input-props.js +9 -9
  75. package/dist/get-network-address.js +2 -2
  76. package/dist/handle-common-errors.d.ts +2 -1
  77. package/dist/handle-common-errors.js +2 -2
  78. package/dist/index.d.ts +9 -5
  79. package/dist/index.js +4 -1
  80. package/dist/load-config.js +8 -8
  81. package/dist/log.d.ts +5 -5
  82. package/dist/log.js +3 -42
  83. package/dist/parse-command-line.d.ts +1 -0
  84. package/dist/preview-server/api-types.d.ts +1 -1
  85. package/dist/preview-server/dev-middleware/compatible-api.d.ts +2 -2
  86. package/dist/preview-server/dev-middleware/middleware.d.ts +1 -1
  87. package/dist/preview-server/dev-middleware/middleware.js +7 -7
  88. package/dist/preview-server/dev-middleware/setup-hooks.js +2 -2
  89. package/dist/preview-server/error-overlay/react-overlay/utils/get-file-source.js +5 -5
  90. package/dist/preview-server/error-overlay/react-overlay/utils/open-in-editor.js +17 -17
  91. package/dist/preview-server/file-existence-watchers.js +3 -3
  92. package/dist/preview-server/get-absolute-public-dir.js +3 -3
  93. package/dist/preview-server/get-package-manager.js +3 -3
  94. package/dist/preview-server/handler.d.ts +1 -1
  95. package/dist/preview-server/hot-middleware/index.d.ts +1 -1
  96. package/dist/preview-server/hot-middleware/index.js +2 -2
  97. package/dist/preview-server/live-events.d.ts +1 -1
  98. package/dist/preview-server/parse-body.d.ts +1 -1
  99. package/dist/preview-server/project-info.js +5 -5
  100. package/dist/preview-server/public-folder.js +8 -8
  101. package/dist/preview-server/render-queue/job.d.ts +2 -0
  102. package/dist/preview-server/render-queue/open-directory-in-finder.js +8 -8
  103. package/dist/preview-server/render-queue/queue.js +4 -3
  104. package/dist/preview-server/routes/can-update-default-props.js +3 -2
  105. package/dist/preview-server/routes/update-default-props.js +7 -6
  106. package/dist/preview-server/routes.d.ts +1 -1
  107. package/dist/preview-server/routes.js +8 -8
  108. package/dist/preview-server/serve-static.d.ts +1 -1
  109. package/dist/preview-server/serve-static.js +7 -7
  110. package/dist/preview-server/start-server.js +2 -2
  111. package/dist/preview.js +4 -4
  112. package/dist/print-error.d.ts +2 -1
  113. package/dist/print-error.js +8 -5
  114. package/dist/progress-bar.d.ts +5 -4
  115. package/dist/progress-bar.js +42 -29
  116. package/dist/render-flows/render.js +50 -23
  117. package/dist/render-flows/still.js +20 -15
  118. package/dist/resolve-from.js +5 -5
  119. package/dist/setup-cache.d.ts +2 -1
  120. package/dist/setup-cache.js +8 -4
  121. package/dist/should-use-non-overlaying-logger.d.ts +4 -0
  122. package/dist/should-use-non-overlaying-logger.js +12 -0
  123. package/dist/upgrade.js +2 -2
  124. package/dist/user-passed-output-location.js +7 -2
  125. package/dist/versions.js +2 -2
  126. package/package.json +7 -7
  127. package/dist/ansi/ansi-regex.d.ts +0 -2
  128. package/dist/ansi/ansi-regex.js +0 -18
  129. package/dist/config/ffmpeg-executable.d.ts +0 -5
  130. package/dist/config/ffmpeg-executable.js +0 -21
  131. package/dist/config/quality.d.ts +0 -2
  132. package/dist/config/quality.js +0 -17
  133. package/dist/editor/components/ClipboardIcon.d.ts +0 -2
  134. package/dist/editor/components/ClipboardIcon.js +0 -12
  135. package/dist/editor/components/CollapsedCompositionSelector.d.ts +0 -4
  136. package/dist/editor/components/CollapsedCompositionSelector.js +0 -39
  137. package/dist/editor/components/RenderModal/SchemaEditor/date-serialization.d.ts +0 -6
  138. package/dist/editor/components/RenderModal/SchemaEditor/date-serialization.js +0 -24
  139. package/dist/editor/components/RichTimelineToggle.d.ts +0 -2
  140. package/dist/editor/components/RichTimelineToggle.js +0 -29
  141. package/dist/editor/components/Thumbnail.d.ts +0 -8
  142. package/dist/editor/components/Thumbnail.js +0 -76
  143. package/dist/editor/helpers/use-compact-ui.d.ts +0 -1
  144. package/dist/editor/helpers/use-compact-ui.js +0 -18
  145. package/dist/editor/icons/film.d.ts +0 -3
  146. package/dist/editor/icons/film.js +0 -8
  147. package/dist/editor/icons/timeline.d.ts +0 -3
  148. package/dist/editor/icons/timeline.js +0 -9
  149. package/dist/editor/state/rich-timeline.d.ts +0 -9
  150. package/dist/editor/state/rich-timeline.js +0 -17
  151. package/dist/get-render-media-options.d.ts +0 -8
  152. package/dist/get-render-media-options.js +0 -55
  153. package/dist/install.d.ts +0 -2
  154. package/dist/install.js +0 -36
  155. package/dist/is-javascript.d.ts +0 -2
  156. package/dist/is-javascript.js +0 -9
  157. package/dist/preview-server/dev-middleware/is-color-supported.d.ts +0 -1
  158. package/dist/preview-server/dev-middleware/is-color-supported.js +0 -37
  159. package/dist/preview-server/hot-middleware/strip-ansi.d.ts +0 -1
  160. package/dist/preview-server/hot-middleware/strip-ansi.js +0 -21
@@ -2,21 +2,54 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CliCopyButton = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const colors_1 = require("../../helpers/colors");
7
+ const svgStyle = {
8
+ width: 16,
9
+ height: 16,
10
+ verticalAlign: 'sub',
11
+ };
12
+ const copiedStyle = {
13
+ fontSize: '14px',
14
+ minHeight: '30px',
15
+ minWidth: '30px',
16
+ display: 'flex',
17
+ alignItems: 'center',
18
+ justifyContent: 'center',
19
+ };
5
20
  const CliCopyButton = ({ valueToCopy, }) => {
6
- const iconStyle = {
7
- width: 16,
8
- height: 16,
9
- color: '#a6a8aa',
10
- verticalAlign: 'sub',
11
- };
12
- const clipBoardIcon = ((0, jsx_runtime_1.jsx)("svg", { "aria-hidden": "true", focusable: "false", "data-prefix": "far", "data-icon": "clipboard", className: "svg-inline--fa fa-clipboard fa-w-12", role: "img", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 384 512", style: iconStyle, children: (0, jsx_runtime_1.jsx)("path", { fill: "#a6a8aa", d: "M336 64h-80c0-35.3-28.7-64-64-64s-64 28.7-64 64H48C21.5 64 0 85.5 0 112v352c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V112c0-26.5-21.5-48-48-48zM192 40c13.3 0 24 10.7 24 24s-10.7 24-24 24-24-10.7-24-24 10.7-24 24-24zm144 418c0 3.3-2.7 6-6 6H54c-3.3 0-6-2.7-6-6V118c0-3.3 2.7-6 6-6h42v36c0 6.6 5.4 12 12 12h168c6.6 0 12-5.4 12-12v-36h42c3.3 0 6 2.7 6 6z" }) }));
13
- return ((0, jsx_runtime_1.jsx)("button", { type: "button", style: {
21
+ const [copied, setCopied] = (0, react_1.useState)(false);
22
+ const [hovered, setHovered] = (0, react_1.useState)(false);
23
+ const fillColor = (0, react_1.useMemo)(() => {
24
+ return hovered ? 'white' : colors_1.LIGHT_TEXT;
25
+ }, [hovered]);
26
+ const clipboardIcon = ((0, jsx_runtime_1.jsx)("svg", { "aria-hidden": "true", focusable: "false", "data-prefix": "far", "data-icon": "clipboard", className: "svg-inline--fa fa-clipboard fa-w-12", role: "img", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 384 512", style: svgStyle, children: (0, jsx_runtime_1.jsx)("path", { fill: fillColor, d: "M336 64h-80c0-35.3-28.7-64-64-64s-64 28.7-64 64H48C21.5 64 0 85.5 0 112v352c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V112c0-26.5-21.5-48-48-48zM192 40c13.3 0 24 10.7 24 24s-10.7 24-24 24-24-10.7-24-24 10.7-24 24-24zm144 418c0 3.3-2.7 6-6 6H54c-3.3 0-6-2.7-6-6V118c0-3.3 2.7-6 6-6h42v36c0 6.6 5.4 12 12 12h168c6.6 0 12-5.4 12-12v-36h42c3.3 0 6 2.7 6 6z" }) }));
27
+ const checkSvg = ((0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 448 512", style: svgStyle, children: (0, jsx_runtime_1.jsx)("path", { fill: fillColor, d: "M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z" }) }));
28
+ const onPointerEnter = (0, react_1.useCallback)(() => {
29
+ setHovered(true);
30
+ }, []);
31
+ const onPointerLeave = (0, react_1.useCallback)(() => {
32
+ setHovered(false);
33
+ }, []);
34
+ (0, react_1.useEffect)(() => {
35
+ if (!copied) {
36
+ return;
37
+ }
38
+ const handleClear = () => {
39
+ setCopied(false);
40
+ setHovered(false);
41
+ };
42
+ const to = setTimeout(() => handleClear(), 2000);
43
+ return () => clearTimeout(to);
44
+ }, [copied]);
45
+ return copied ? ((0, jsx_runtime_1.jsx)("span", { style: copiedStyle, children: checkSvg })) : ((0, jsx_runtime_1.jsx)("button", { type: "button", onPointerEnter: onPointerEnter, onPointerLeave: onPointerLeave, style: {
14
46
  width: '30px',
15
47
  height: '30px',
16
48
  border: 'none',
17
49
  cursor: 'pointer',
18
50
  }, onClick: () => {
19
51
  navigator.clipboard.writeText(valueToCopy);
20
- }, children: clipBoardIcon }));
52
+ setCopied(true);
53
+ }, children: clipboardIcon }));
21
54
  };
22
55
  exports.CliCopyButton = CliCopyButton;
@@ -29,12 +29,13 @@ const InfoTooltip = ({ children, arrowDirection }) => {
29
29
  border: '0.5px solid ' + colors_1.BORDER_COLOR,
30
30
  maxHeight: 200,
31
31
  overflow: 'auto',
32
+ borderRadius: '4px',
32
33
  };
33
34
  }, [arrowDirection]);
34
35
  return ((0, jsx_runtime_1.jsxs)("div", { style: {
35
36
  display: 'flex',
36
37
  flexDirection: arrowDirection === 'up' ? 'column-reverse' : 'column',
37
38
  alignItems: 'flex-start',
38
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: container, className: is_menu_item_1.VERTICAL_SCROLLBAR_CLASSNAME, children: children }), arrowDirection === 'down' ? ((0, jsx_runtime_1.jsx)("svg", { viewBox: "0 0 14 7", style: arrowDown, children: (0, jsx_runtime_1.jsx)("path", { d: `M 14 0 L 7 7 L 0 0`, fill: colors_1.BACKGROUND, strokeLinecap: "butt", stroke: colors_1.BORDER_COLOR, strokeWidth: 0.5 }) })) : null, arrowDirection === 'up' ? ((0, jsx_runtime_1.jsx)("svg", { viewBox: "0 0 14 7", style: arrowUp, children: (0, jsx_runtime_1.jsx)("path", { d: `M 0 7 L 7 0 L 14 7`, fill: colors_1.BACKGROUND, strokeLinecap: "butt", stroke: colors_1.BORDER_COLOR, strokeWidth: 0.5 }) })) : null] }));
39
+ }, children: [(0, jsx_runtime_1.jsx)("div", { style: container, className: is_menu_item_1.VERTICAL_SCROLLBAR_CLASSNAME, children: children }), arrowDirection === 'down' ? ((0, jsx_runtime_1.jsx)("svg", { viewBox: "0 0 14 7", style: arrowDown, children: (0, jsx_runtime_1.jsx)("path", { d: `M 14 0 L 7 7 L 0 0`, fill: colors_1.INPUT_BACKGROUND, strokeLinecap: "butt", stroke: colors_1.BORDER_COLOR, strokeWidth: 0.5 }) })) : null, arrowDirection === 'up' ? ((0, jsx_runtime_1.jsx)("svg", { viewBox: "0 0 14 7", style: arrowUp, children: (0, jsx_runtime_1.jsx)("path", { d: `M 0 7 L 7 0 L 14 7`, fill: colors_1.INPUT_BACKGROUND, strokeLinecap: "butt", stroke: colors_1.BORDER_COLOR, strokeWidth: 0.5 }) })) : null] }));
39
40
  };
40
41
  exports.InfoTooltip = InfoTooltip;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OptionExplainer = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const colors_1 = require("../../helpers/colors");
5
6
  const layout_1 = require("../layout");
6
7
  const MenuDivider_1 = require("../Menu/MenuDivider");
7
8
  const CliCopyButton_1 = require("./CliCopyButton");
@@ -9,10 +10,11 @@ const container = {
9
10
  fontSize: 14,
10
11
  paddingTop: 10,
11
12
  paddingBottom: 10,
13
+ backgroundColor: colors_1.INPUT_BACKGROUND,
12
14
  };
13
15
  const padding = {
14
- paddingLeft: 12,
15
- paddingRight: 12,
16
+ paddingLeft: 20,
17
+ paddingRight: 20,
16
18
  };
17
19
  const title = {
18
20
  fontSize: 14,
@@ -39,7 +41,15 @@ const infoRowLabel = {
39
41
  fontSize: 14,
40
42
  color: 'white',
41
43
  };
44
+ const flexSpacer = {
45
+ display: 'flex',
46
+ flex: 1,
47
+ };
48
+ const copyWrapper = {
49
+ display: 'flex',
50
+ justifyContent: 'flex-end',
51
+ };
42
52
  const OptionExplainer = ({ option }) => {
43
- return ((0, jsx_runtime_1.jsxs)("div", { style: container, className: "__remotion-info-button-container", children: [(0, jsx_runtime_1.jsxs)("div", { style: padding, children: [(0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("strong", { style: title, children: option.name }) }), (0, jsx_runtime_1.jsx)("div", { style: description, children: option.description })] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 0.5, block: true }), (0, jsx_runtime_1.jsx)(MenuDivider_1.MenuDivider, {}), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 0.5, block: true }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { style: infoRow, children: [(0, jsx_runtime_1.jsx)("div", { style: infoRowLabel, children: "CLI flag:" }), (0, jsx_runtime_1.jsx)("code", { children: option.cliFlag }), (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', justifyContent: 'flex-end', flex: 1 }, children: (0, jsx_runtime_1.jsx)(CliCopyButton_1.CliCopyButton, { valueToCopy: option.cliFlag }) })] }), (0, jsx_runtime_1.jsxs)("div", { style: infoRow, children: [(0, jsx_runtime_1.jsx)("div", { style: infoRowLabel, children: "Node.JS option:" }), (0, jsx_runtime_1.jsx)("code", { children: option.ssrName })] }), (0, jsx_runtime_1.jsx)("div", { style: infoRow, children: (0, jsx_runtime_1.jsx)("a", { style: link, href: option.docLink, target: "_blank", children: "Docs" }) })] })] }));
53
+ return ((0, jsx_runtime_1.jsxs)("div", { style: container, className: "__remotion-info-button-container", children: [(0, jsx_runtime_1.jsxs)("div", { style: padding, children: [(0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("strong", { style: title, children: option.name }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), (0, jsx_runtime_1.jsx)("a", { style: link, href: option.docLink, target: "_blank", children: "Docs" })] }), (0, jsx_runtime_1.jsx)("div", { style: description, children: option.description })] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 0.5, block: true }), (0, jsx_runtime_1.jsx)(MenuDivider_1.MenuDivider, {}), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 0.5, block: true }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { style: infoRow, children: [(0, jsx_runtime_1.jsx)("div", { style: infoRowLabel, children: "CLI flag" }), (0, jsx_runtime_1.jsx)("div", { style: flexSpacer }), (0, jsx_runtime_1.jsx)("code", { children: option.cliFlag }), (0, jsx_runtime_1.jsx)("div", { style: copyWrapper, children: (0, jsx_runtime_1.jsx)(CliCopyButton_1.CliCopyButton, { valueToCopy: option.cliFlag }) })] }), (0, jsx_runtime_1.jsxs)("div", { style: infoRow, children: [(0, jsx_runtime_1.jsx)("div", { style: infoRowLabel, children: "Node.JS option" }), (0, jsx_runtime_1.jsx)("div", { style: flexSpacer }), (0, jsx_runtime_1.jsx)("code", { children: option.ssrName }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 3.75 })] }), (0, jsx_runtime_1.jsx)("div", { style: infoRow })] })] }));
44
54
  };
45
55
  exports.OptionExplainer = OptionExplainer;
@@ -37,7 +37,8 @@ const actions_1 = require("../RenderQueue/actions");
37
37
  const SegmentedControl_1 = require("../SegmentedControl");
38
38
  const get_render_modal_warnings_1 = require("./get-render-modal-warnings");
39
39
  const RenderModalJSONPropsEditor_1 = require("./RenderModalJSONPropsEditor");
40
- const date_serialization_1 = require("./SchemaEditor/date-serialization");
40
+ const extract_enum_json_paths_1 = require("./SchemaEditor/extract-enum-json-paths");
41
+ const input_props_serialization_1 = require("./SchemaEditor/input-props-serialization");
41
42
  const SchemaEditor_1 = require("./SchemaEditor/SchemaEditor");
42
43
  const SchemaErrorMessages_1 = require("./SchemaEditor/SchemaErrorMessages");
43
44
  const WarningIndicatorButton_1 = require("./WarningIndicatorButton");
@@ -77,7 +78,7 @@ const tabWrapper = {
77
78
  const persistanceKey = 'remotion.show-render-modalwarning';
78
79
  const parseJSON = (str) => {
79
80
  try {
80
- const value = (0, date_serialization_1.deserializeJSONWithDate)(str);
81
+ const value = (0, input_props_serialization_1.deserializeJSONWithCustomFields)(str);
81
82
  return { str, value, validJSON: true };
82
83
  }
83
84
  catch (e) {
@@ -105,7 +106,11 @@ const RenderModalData = ({ composition, inputProps, setInputProps, compact, mayS
105
106
  return null;
106
107
  }
107
108
  const value = inputProps !== null && inputProps !== void 0 ? inputProps : {};
108
- return (0, date_serialization_1.serializeJSONWithDate)(value, 2);
109
+ return (0, input_props_serialization_1.serializeJSONWithDate)({
110
+ data: value,
111
+ indent: 2,
112
+ staticBase: window.remotion_staticBase,
113
+ });
109
114
  }, [inJSONEditor, inputProps]);
110
115
  const cliProps = (0, remotion_1.getInputProps)();
111
116
  const [canSaveDefaultProps, setCanSaveDefaultProps] = (0, react_1.useState)({
@@ -192,25 +197,34 @@ const RenderModalData = ({ composition, inputProps, setInputProps, compact, mayS
192
197
  setMode('schema');
193
198
  }, []);
194
199
  const onUpdate = (0, react_1.useCallback)(() => {
200
+ if (schema === 'no-zod' || z === null) {
201
+ (0, NotificationCenter_1.sendErrorNotification)('Cannot update default props: No Zod schema');
202
+ return;
203
+ }
195
204
  setValBeforeSafe(inputProps);
196
- (0, actions_1.updateDefaultProps)(composition.id, inputProps);
197
- }, [composition.id, inputProps]);
205
+ (0, actions_1.updateDefaultProps)(composition.id, inputProps, (0, extract_enum_json_paths_1.extractEnumJsonPaths)(schema, z, []));
206
+ }, [composition.id, inputProps, schema, z]);
198
207
  (0, react_1.useEffect)(() => {
199
208
  setSaving(false);
200
209
  }, [fastRefreshes]);
201
210
  const onSave = (0, react_1.useCallback)((updater) => {
211
+ if (schema === 'no-zod' || z === null) {
212
+ (0, NotificationCenter_1.sendErrorNotification)('Cannot update default props: No Zod schema');
213
+ return;
214
+ }
202
215
  setSaving(true);
203
- (0, actions_1.updateDefaultProps)(composition.id, updater(composition.defaultProps)).catch((err) => {
216
+ (0, actions_1.updateDefaultProps)(composition.id, updater(composition.defaultProps), (0, extract_enum_json_paths_1.extractEnumJsonPaths)(schema, z, [])).catch((err) => {
204
217
  (0, NotificationCenter_1.sendErrorNotification)(`Cannot update default props: ${err.message}`);
205
218
  setSaving(false);
206
219
  });
207
- }, [composition.defaultProps, composition.id]);
220
+ }, [composition.defaultProps, composition.id, schema, z]);
208
221
  const connectionStatus = (0, react_1.useContext)(client_id_1.PreviewServerConnectionCtx).type;
209
222
  const warnings = (0, react_1.useMemo)(() => {
210
223
  return (0, get_render_modal_warnings_1.getRenderModalWarnings)({
211
224
  canSaveDefaultProps,
212
225
  cliProps,
213
226
  isCustomDateUsed: serializedJSON ? serializedJSON.customDateUsed : false,
227
+ customFileUsed: serializedJSON ? serializedJSON.customFileUsed : false,
214
228
  inJSONEditor,
215
229
  propsEditType,
216
230
  });
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import type { State } from './RenderModalData';
3
- import type { SerializedJSONWithDate } from './SchemaEditor/date-serialization';
3
+ import type { SerializedJSONWithCustomFields } from './SchemaEditor/input-props-serialization';
4
4
  export declare type EditType = 'inputProps' | 'defaultProps';
5
5
  export declare const RenderModalJSONPropsEditor: React.FC<{
6
6
  value: unknown;
@@ -11,5 +11,5 @@ export declare const RenderModalJSONPropsEditor: React.FC<{
11
11
  valBeforeSafe: unknown;
12
12
  showSaveButton: boolean;
13
13
  parseJSON: (str: string) => State;
14
- serializedJSON: SerializedJSONWithDate | null;
14
+ serializedJSON: SerializedJSONWithCustomFields | null;
15
15
  }>;
@@ -49,6 +49,6 @@ const RenderModalPicture = ({ renderMode, scale, setScale, pixelFormat, setPixel
49
49
  const onTargetVideoBitrateChanged = (0, react_1.useCallback)((e) => {
50
50
  setCustomTargetVideoBitrateValue(e.target.value);
51
51
  }, [setCustomTargetVideoBitrateValue]);
52
- return ((0, jsx_runtime_1.jsxs)("div", { style: container, children: [renderMode === 'video' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Image Format" }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)(SegmentedControl_1.SegmentedControl, { items: imageFormatOptions, needsWrapping: false }) })] })) : null, renderMode === 'video' && videoImageFormat === 'jpeg' && ((0, jsx_runtime_1.jsx)(JpegQualitySetting_1.JpegQualitySetting, { jpegQuality: jpegQuality, setJpegQuality: setJpegQuality })), renderMode === 'still' && stillImageFormat === 'jpeg' && ((0, jsx_runtime_1.jsx)(JpegQualitySetting_1.JpegQualitySetting, { jpegQuality: jpegQuality, setJpegQuality: setJpegQuality })), renderMode === 'video' && qualityControlType !== null ? ((0, jsx_runtime_1.jsx)(RenderModalHr_1.RenderModalHr, {})) : null, shouldDisplayQualityControlPicker && renderMode === 'video' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Quality control" }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)(SegmentedControl_1.SegmentedControl, { items: qualityControlOptions, needsWrapping: true }) })] })) : null, qualityControlType === 'crf' && renderMode !== 'still' ? ((0, jsx_runtime_1.jsx)(CrfSetting_1.CrfSetting, { crf: crf, min: minCrf, max: maxCrf, setCrf: setCrf, option: client_1.BrowserSafeApis.options.crfOption })) : null, qualityControlType === 'bitrate' && renderMode !== 'still' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Target video bitrate" }), (0, jsx_runtime_1.jsx)(InfoBubble_1.InfoBubble, { title: "Learn more about this option", children: (0, jsx_runtime_1.jsx)(OptionExplainer_1.OptionExplainer, { option: client_1.BrowserSafeApis.options.videoBitrate }) }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(RemInput_1.RemotionInput, { style: layout_1.input, value: customTargetVideoBitrate, onChange: onTargetVideoBitrateChanged, status: "ok", rightAlign: true }) }) })] })) : null, renderMode === 'video' ? (0, jsx_runtime_1.jsx)(RenderModalHr_1.RenderModalHr, {}) : null, (0, jsx_runtime_1.jsx)(ScaleSetting_1.ScaleSetting, { scale: scale, setScale: setScale }), renderMode === 'video' ? (0, jsx_runtime_1.jsx)(RenderModalHr_1.RenderModalHr, {}) : null, renderMode === 'video' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Pixel format" }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)(ComboBox_1.Combobox, { values: pixelFormatOptions, selectedId: pixelFormat, title: "Pixel Format" }) })] })) : null] }));
52
+ return ((0, jsx_runtime_1.jsxs)("div", { style: container, children: [renderMode === 'video' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Image Format" }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)(SegmentedControl_1.SegmentedControl, { items: imageFormatOptions, needsWrapping: false }) })] })) : null, renderMode === 'video' && videoImageFormat === 'jpeg' && ((0, jsx_runtime_1.jsx)(JpegQualitySetting_1.JpegQualitySetting, { jpegQuality: jpegQuality, setJpegQuality: setJpegQuality })), renderMode === 'still' && stillImageFormat === 'jpeg' && ((0, jsx_runtime_1.jsx)(JpegQualitySetting_1.JpegQualitySetting, { jpegQuality: jpegQuality, setJpegQuality: setJpegQuality })), renderMode === 'video' && qualityControlType !== null ? ((0, jsx_runtime_1.jsx)(RenderModalHr_1.RenderModalHr, {})) : null, shouldDisplayQualityControlPicker && renderMode === 'video' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Quality control" }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)(SegmentedControl_1.SegmentedControl, { items: qualityControlOptions, needsWrapping: true }) })] })) : null, qualityControlType === 'crf' && renderMode !== 'still' ? ((0, jsx_runtime_1.jsx)(CrfSetting_1.CrfSetting, { crf: crf, min: minCrf, max: maxCrf, setCrf: setCrf, option: client_1.BrowserSafeApis.options.crfOption })) : null, qualityControlType === 'bitrate' && renderMode !== 'still' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsxs)("div", { style: layout_1.label, children: ["Target video bitrate", (0, jsx_runtime_1.jsx)(InfoBubble_1.InfoBubble, { title: "Learn more about this option", children: (0, jsx_runtime_1.jsx)(OptionExplainer_1.OptionExplainer, { option: client_1.BrowserSafeApis.options.videoBitrate }) })] }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(RemInput_1.RemotionInput, { style: layout_1.input, value: customTargetVideoBitrate, onChange: onTargetVideoBitrateChanged, status: "ok", rightAlign: true }) }) })] })) : null, renderMode === 'video' ? (0, jsx_runtime_1.jsx)(RenderModalHr_1.RenderModalHr, {}) : null, (0, jsx_runtime_1.jsx)(ScaleSetting_1.ScaleSetting, { scale: scale, setScale: setScale }), renderMode === 'video' ? (0, jsx_runtime_1.jsx)(RenderModalHr_1.RenderModalHr, {}) : null, renderMode === 'video' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Pixel format" }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)(ComboBox_1.Combobox, { values: pixelFormatOptions, selectedId: pixelFormat, title: "Pixel Format" }) })] })) : null] }));
53
53
  };
54
54
  exports.RenderModalPicture = RenderModalPicture;
@@ -54,6 +54,6 @@ const InvalidDefaultProps = ({ zodValidationResult }) => {
54
54
  };
55
55
  exports.InvalidDefaultProps = InvalidDefaultProps;
56
56
  const InvalidSchema = ({ zodValidationResult, reset }) => {
57
- return ((0, jsx_runtime_1.jsxs)("div", { style: errorContainer, children: [(0, jsx_runtime_1.jsx)("div", { style: errorExplanation, children: "The data does not satisfy the schema:" }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ZodErrorMessages_1.ZodErrorMessages, { zodValidationResult: zodValidationResult }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)("div", { style: errorExplanation, children: "Fix the schema using the JSON editor." }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["Alternatively, reset the data to the ", (0, jsx_runtime_1.jsx)("code", { children: "defaultProps" }), " that you have defined."] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: reset, children: "Reset props" })] }));
57
+ return ((0, jsx_runtime_1.jsxs)("div", { style: errorContainer, children: [(0, jsx_runtime_1.jsx)("div", { style: errorExplanation, children: "The data does not satisfy the schema:" }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ZodErrorMessages_1.ZodErrorMessages, { zodValidationResult: zodValidationResult }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)("div", { style: errorExplanation, children: "Fix the schema using the JSON editor." }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["Alternatively, reset the data to the", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: "defaultProps" }), " that you have defined."] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: reset, children: "Reset props" })] }));
58
58
  };
59
59
  exports.InvalidSchema = InvalidSchema;
@@ -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 ZodArrayEditor: React.FC<{
5
6
  schema: z.ZodTypeAny;
6
7
  jsonPath: JSONPath;
7
8
  value: unknown[];
8
9
  defaultValue: unknown[];
9
- setValue: React.Dispatch<React.SetStateAction<unknown[]>>;
10
- onSave: (updater: (oldState: unknown[]) => unknown[]) => void;
10
+ setValue: UpdaterFunction<unknown[]>;
11
+ onSave: UpdaterFunction<unknown[]>;
11
12
  compact: boolean;
12
13
  showSaveButton: boolean;
13
14
  onRemove: null | (() => void);
@@ -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: React.Dispatch<React.SetStateAction<boolean>>;
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: React.Dispatch<React.SetStateAction<string>>;
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: React.Dispatch<React.SetStateAction<Date>>;
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: (value: unknown) => void;
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)((newValue) => {
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: React.Dispatch<React.SetStateAction<string>>;
10
- onSave: (updater: (oldState: string) => string) => void;
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: React.Dispatch<React.SetStateAction<unknown>>;
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: React.Dispatch<React.SetStateAction<number>>;
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: onValueChange, 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" })] }))] })] }));
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: React.Dispatch<React.SetStateAction<unknown>>;
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: React.Dispatch<React.SetStateAction<unknown>>;
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: React.Dispatch<React.SetStateAction<unknown>>;
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;