@remotion/studio 4.0.153 → 4.0.154

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.turbo/turbo-test.log +85 -0
  3. package/dist/api/delete-static-file.d.ts +3 -0
  4. package/dist/api/delete-static-file.js +16 -0
  5. package/dist/api/helpers/calc-new-props.d.ts +11 -0
  6. package/dist/api/helpers/calc-new-props.js +36 -0
  7. package/dist/api/save-default-props.d.ts +7 -7
  8. package/dist/api/save-default-props.js +8 -27
  9. package/dist/api/update-default-props.d.ts +6 -0
  10. package/dist/api/update-default-props.js +21 -0
  11. package/dist/api/watch-public-folder.d.ts +13 -0
  12. package/dist/api/watch-public-folder.js +28 -0
  13. package/dist/api/watch-static-file.d.ts +1 -2
  14. package/dist/api/watch-static-file.js +5 -12
  15. package/dist/components/Editor.js +2 -1
  16. package/dist/components/PlayPause.js +1 -0
  17. package/dist/components/RenderModal/DataEditor.js +1 -1
  18. package/dist/components/RenderModal/RenderModalJSONPropsEditor.d.ts +7 -7
  19. package/dist/components/RenderModal/SchemaEditor/SchemaEditor.d.ts +9 -9
  20. package/dist/components/RenderModal/SchemaEditor/SchemaEditor.js +26 -9
  21. package/dist/components/RenderModal/SchemaEditor/ZodArrayEditor.d.ts +11 -11
  22. package/dist/components/RenderModal/SchemaEditor/ZodArrayEditor.js +2 -2
  23. package/dist/components/RenderModal/SchemaEditor/ZodBooleanEditor.d.ts +11 -11
  24. package/dist/components/RenderModal/SchemaEditor/ZodBooleanEditor.js +2 -2
  25. package/dist/components/RenderModal/SchemaEditor/ZodColorEditor.d.ts +11 -11
  26. package/dist/components/RenderModal/SchemaEditor/ZodColorEditor.js +2 -2
  27. package/dist/components/RenderModal/SchemaEditor/ZodDateEditor.d.ts +11 -11
  28. package/dist/components/RenderModal/SchemaEditor/ZodDateEditor.js +2 -2
  29. package/dist/components/RenderModal/SchemaEditor/ZodDiscriminatedUnionEditor.js +3 -3
  30. package/dist/components/RenderModal/SchemaEditor/ZodEffectEditor.d.ts +10 -10
  31. package/dist/components/RenderModal/SchemaEditor/ZodEffectEditor.js +2 -2
  32. package/dist/components/RenderModal/SchemaEditor/ZodEnumEditor.d.ts +9 -9
  33. package/dist/components/RenderModal/SchemaEditor/ZodEnumEditor.js +2 -2
  34. package/dist/components/RenderModal/SchemaEditor/ZodNumberEditor.d.ts +11 -11
  35. package/dist/components/RenderModal/SchemaEditor/ZodNumberEditor.js +2 -2
  36. package/dist/components/RenderModal/SchemaEditor/ZodObjectEditor.d.ts +12 -12
  37. package/dist/components/RenderModal/SchemaEditor/ZodObjectEditor.js +6 -6
  38. package/dist/components/RenderModal/SchemaEditor/ZodOrNullishEditor.js +2 -2
  39. package/dist/components/RenderModal/SchemaEditor/ZodStaticFileEditor.js +2 -2
  40. package/dist/components/RenderModal/SchemaEditor/ZodStringEditor.d.ts +11 -11
  41. package/dist/components/RenderModal/SchemaEditor/ZodStringEditor.js +2 -2
  42. package/dist/components/RenderModal/SchemaEditor/ZodSwitch.d.ts +11 -11
  43. package/dist/components/RenderModal/SchemaEditor/ZodSwitch.js +1 -1
  44. package/dist/components/RenderModal/SchemaEditor/ZodTextareaEditor.d.ts +11 -11
  45. package/dist/components/RenderModal/SchemaEditor/ZodTextareaEditor.js +2 -2
  46. package/dist/components/RenderModal/SchemaEditor/local-state.d.ts +7 -3
  47. package/dist/components/RenderModal/SchemaEditor/local-state.js +38 -15
  48. package/dist/components/RenderQueue/actions.js +15 -38
  49. package/dist/components/TopPanel.d.ts +5 -5
  50. package/dist/components/call-api.d.ts +2 -0
  51. package/dist/components/call-api.js +28 -0
  52. package/dist/esm/index.mjs +119 -57
  53. package/dist/esm/internals.mjs +428 -378
  54. package/dist/helpers/client-id.d.ts +2 -2
  55. package/dist/helpers/client-id.js +2 -2
  56. package/dist/index.d.ts +4 -0
  57. package/dist/index.js +7 -1
  58. package/package.json +7 -7
  59. package/tsconfig.tsbuildinfo +1 -1
@@ -1,5 +1,5 @@
1
1
 
2
- > @remotion/studio@4.0.152 build /Users/jonathanburger/remotion/packages/studio
2
+ > @remotion/studio@4.0.153 build /Users/jonathanburger/remotion/packages/studio
3
3
  > bun --env-file=../.env.bundle bundle.ts
4
4
 
5
5
  warn: Remotion currently uses a fork of Bun to bundle.
@@ -0,0 +1,85 @@
1
+
2
+ > @remotion/studio@4.0.149 test /Users/jonathanburger/remotion/packages/studio
3
+ > bun test src
4
+
5
+ bun test v1.1.7 (07cefe63)
6
+ 
7
+ src/test/stringify-default-props.test.ts:
8
+ ✓ Should stringify default props correctly [1.64ms]
9
+ ✓ Should stringify default props correctly [1.24ms]
10
+ 
11
+ src/test/sequenced-timeline.test.ts:
12
+ ✓ Should calculate sequences correctly [3.46ms]
13
+ 
14
+ src/test/create-zod-values.test.ts:
15
+ ✓ Should be able to create a string [12.48ms]
16
+ ✓ Should be able to create a number [0.48ms]
17
+ ✓ Should be able to create an object [0.28ms]
18
+ ✓ Should be able to create an array [0.36ms]
19
+ ✓ Should be able to create a union [0.20ms]
20
+ ✓ Zod literal [0.09ms]
21
+ ✓ Should be able to create a discriminated union [0.50ms]
22
+ ✓ Zod instanceof [0.13ms]
23
+ ✓ Zod intersection [0.29ms]
24
+ ✓ Zod tuples [0.16ms]
25
+ ✓ Zod record [0.27ms]
26
+ ✓ Zod map [0.08ms]
27
+ ✓ Zod lazy [0.08ms]
28
+ ✓ Zod set [0.10ms]
29
+ ✓ Zod function [0.15ms]
30
+ ✓ Zod undefined [0.07ms]
31
+ ✓ Zod null [0.07ms]
32
+ ✓ Zod enum [0.06ms]
33
+ ✓ Zod nativeEnum [0.09ms]
34
+ ✓ Zod optional [0.07ms]
35
+ ✓ Zod nullable [0.07ms]
36
+ ✓ Zod undefined [0.07ms]
37
+ ✓ Zod catch [0.06ms]
38
+ ✓ Zod promise [0.11ms]
39
+ ✓ Zod transform [0.07ms]
40
+ ✓ Zod branded [0.10ms]
41
+ ✓ Zod lazy [0.41ms]
42
+ ✓ Zod coerce [0.37ms]
43
+ ✓ Zod strict [0.12ms]
44
+ ✓ Should create a color [0.09ms]
45
+ ✓ Should create a textarea [0.05ms]
46
+ 
47
+ src/test/folder-tree.test.ts:
48
+ ✓ Should create a good folder tree with 1 item inside and 1 item outside [1.66ms]
49
+ ✓ Should handle nested folders well [0.49ms]
50
+ ✓ Should throw if two folders with the same name [0.30ms]
51
+ 
52
+ src/test/big-timeline.test.ts:
53
+ ✓ Should calculate timeline as expected [6.91ms]
54
+ 
55
+ src/test/smooth-zoom.test.ts:
56
+ ✓ Smoothen zoom [0.04ms]
57
+ ✓ Unsmoothen zoom [0.04ms]
58
+ 
59
+ src/test/validate-gui-output-filename.test.ts:
60
+ ✓ Should catch dot after slash [2.97ms]
61
+ ✓ Should catch dot in front  [0.03ms]
62
+ 
63
+ src/test/timeline-sequence-layout.test.ts:
64
+ ✓ Should test timeline sequence layout without max media duration [0.31ms]
65
+ ✓ Should test timeline sequence layout with max media duration [0.05ms]
66
+ 
67
+ src/test/extract-zod-enums.test.ts:
68
+ ✓ Extract Zod enums [0.13ms]
69
+ ✓ Extract Zod enums #2 [0.42ms]
70
+ 
71
+ src/test/color-math.test.ts:
72
+ ✓ Color math [0.74ms]
73
+ 
74
+ src/test/format-time.test.ts:
75
+ ✓ Format time [0.24ms]
76
+ 
77
+ src/test/timeline.test.ts:
78
+ ✓ Should calculate timeline with no sequences [0.05ms]
79
+ ✓ Should calculate a basic timeline [0.14ms]
80
+ ✓ Should follow order of nesting [0.13ms]
81
+
82
+  51 pass
83
+  0 fail
84
+ 67 expect() calls
85
+ Ran 51 tests across 12 files. [119.00ms]
@@ -0,0 +1,3 @@
1
+ import type { DeleteStaticFileResponse } from '@remotion/studio-shared';
2
+ export declare const deleteStaticFile: (relativePath: string) => Promise<DeleteStaticFileResponse>;
3
+ export { DeleteStaticFileResponse };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteStaticFile = void 0;
4
+ const remotion_1 = require("remotion");
5
+ const call_api_1 = require("../components/call-api");
6
+ const deleteStaticFile = async (relativePath) => {
7
+ if (!(0, remotion_1.getRemotionEnvironment)().isStudio) {
8
+ throw new Error('deleteStaticFile() is only available in the Studio');
9
+ }
10
+ if (relativePath.startsWith(window.remotion_staticBase)) {
11
+ relativePath = relativePath.substring(window.remotion_staticBase.length + 1);
12
+ }
13
+ const res = await (0, call_api_1.callApi)('/api/delete-static-file', { relativePath });
14
+ return res;
15
+ };
16
+ exports.deleteStaticFile = deleteStaticFile;
@@ -0,0 +1,11 @@
1
+ import type { AnyComposition } from 'remotion';
2
+ import type { AnyZodObject } from 'zod';
3
+ export type UpdateDefaultPropsFunction = (currentValues: {
4
+ schema: AnyZodObject | null;
5
+ savedDefaultProps: Record<string, unknown>;
6
+ unsavedDefaultProps: Record<string, unknown>;
7
+ }) => Record<string, unknown>;
8
+ export declare const calcNewProps: (compositionId: string, defaultProps: UpdateDefaultPropsFunction) => {
9
+ composition: AnyComposition;
10
+ generatedDefaultProps: Record<string, unknown>;
11
+ };
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calcNewProps = void 0;
4
+ const remotion_1 = require("remotion");
5
+ const calcNewProps = (compositionId, defaultProps) => {
6
+ var _a, _b;
7
+ if (!(0, remotion_1.getRemotionEnvironment)().isStudio) {
8
+ throw new Error('saveDefaultProps can only be called in the Remotion Studio.');
9
+ }
10
+ const { compositionsRef, editorPropsProviderRef } = remotion_1.Internals;
11
+ const compositionsStore = compositionsRef.current;
12
+ if (!compositionsStore) {
13
+ throw new Error('No compositions ref found. Are you in the Remotion Studio and are the Remotion versions aligned?');
14
+ }
15
+ const compositions = compositionsStore.getCompositions();
16
+ const composition = compositions.find((c) => c.id === compositionId);
17
+ if (!composition) {
18
+ throw new Error(`No composition with the ID ${compositionId} found. Available compositions: ${compositions.map((c) => c.id).join(', ')}`);
19
+ }
20
+ const propsStore = editorPropsProviderRef.current;
21
+ if (!propsStore) {
22
+ throw new Error('No props store found. Are you in the Remotion Studio and are the Remotion versions aligned?');
23
+ }
24
+ const savedDefaultProps = (_a = composition.defaultProps) !== null && _a !== void 0 ? _a : {};
25
+ const unsavedDefaultProps = (_b = propsStore.getProps()[compositionId]) !== null && _b !== void 0 ? _b : savedDefaultProps;
26
+ const generatedDefaultProps = defaultProps({
27
+ schema: composition.schema,
28
+ savedDefaultProps,
29
+ unsavedDefaultProps,
30
+ });
31
+ return {
32
+ composition,
33
+ generatedDefaultProps,
34
+ };
35
+ };
36
+ exports.calcNewProps = calcNewProps;
@@ -1,10 +1,10 @@
1
- import type { AnyZodObject } from 'zod';
2
- export type SafeDefaultPropsFunction = (currentValues: {
3
- schema: AnyZodObject | null;
4
- savedDefaultProps: Record<string, unknown>;
5
- unsavedDefaultProps: Record<string, unknown>;
6
- }) => Record<string, unknown>;
1
+ import type { UpdateDefaultPropsFunction } from './helpers/calc-new-props';
2
+ /**
3
+ * Saves the defaultProps for a composition back to the root file.
4
+ * @param {string} compositionId The ID of the composition to save the defaultProps for.
5
+ * @param {SafeDefaultPropsFunction} defaultProps A function that returns the new defaultProps for the composition.
6
+ */
7
7
  export declare const saveDefaultProps: ({ compositionId, defaultProps, }: {
8
8
  compositionId: string;
9
- defaultProps: SafeDefaultPropsFunction;
9
+ defaultProps: UpdateDefaultPropsFunction;
10
10
  }) => Promise<void>;
@@ -24,42 +24,23 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.saveDefaultProps = void 0;
27
- const remotion_1 = require("remotion");
28
27
  const extract_enum_json_paths_1 = require("../components/RenderModal/SchemaEditor/extract-enum-json-paths");
29
28
  const actions_1 = require("../components/RenderQueue/actions");
29
+ const calc_new_props_1 = require("./helpers/calc-new-props");
30
+ /**
31
+ * Saves the defaultProps for a composition back to the root file.
32
+ * @param {string} compositionId The ID of the composition to save the defaultProps for.
33
+ * @param {SafeDefaultPropsFunction} defaultProps A function that returns the new defaultProps for the composition.
34
+ */
30
35
  const saveDefaultProps = async ({ compositionId, defaultProps, }) => {
31
- var _a, _b;
32
- if (!(0, remotion_1.getRemotionEnvironment)().isStudio) {
33
- throw new Error('saveDefaultProps can only be called in the Remotion Studio.');
34
- }
35
36
  try {
36
37
  await Promise.resolve().then(() => __importStar(require('zod')));
37
38
  }
38
- catch (_c) {
39
+ catch (_a) {
39
40
  throw new Error('"zod" is required to use saveDefaultProps(), but is not installed.');
40
41
  }
41
42
  const z = await Promise.resolve().then(() => __importStar(require('zod')));
42
- const { compositionsRef, editorPropsProviderRef } = remotion_1.Internals;
43
- const compositionsStore = compositionsRef.current;
44
- if (!compositionsStore) {
45
- throw new Error('No compositions ref found. Are you in the Remotion Studio and are the Remotion versions aligned?');
46
- }
47
- const compositions = compositionsStore.getCompositions();
48
- const composition = compositions.find((c) => c.id === compositionId);
49
- if (!composition) {
50
- throw new Error(`No composition with the ID ${compositionId} found. Available compositions: ${compositions.map((c) => c.id).join(', ')}`);
51
- }
52
- const propsStore = editorPropsProviderRef.current;
53
- if (!propsStore) {
54
- throw new Error('No props store found. Are you in the Remotion Studio and are the Remotion versions aligned?');
55
- }
56
- const savedDefaultProps = (_a = composition.defaultProps) !== null && _a !== void 0 ? _a : {};
57
- const unsavedDefaultProps = (_b = propsStore.getProps()[compositionId]) !== null && _b !== void 0 ? _b : savedDefaultProps;
58
- const generatedDefaultProps = defaultProps({
59
- schema: composition.schema,
60
- savedDefaultProps,
61
- unsavedDefaultProps,
62
- });
43
+ const { generatedDefaultProps, composition } = (0, calc_new_props_1.calcNewProps)(compositionId, defaultProps);
63
44
  const res = await (0, actions_1.callUpdateDefaultPropsApi)(compositionId, generatedDefaultProps, composition.schema ? (0, extract_enum_json_paths_1.extractEnumJsonPaths)(composition.schema, z, []) : []);
64
45
  if (res.success) {
65
46
  return Promise.resolve();
@@ -0,0 +1,6 @@
1
+ import type { UpdateDefaultPropsFunction } from './helpers/calc-new-props';
2
+ export declare const PROPS_UPDATED_EXTERNALLY = "remotion.propsUpdatedExternally";
3
+ export declare const updateDefaultProps: ({ compositionId, defaultProps, }: {
4
+ compositionId: string;
5
+ defaultProps: UpdateDefaultPropsFunction;
6
+ }) => void;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateDefaultProps = exports.PROPS_UPDATED_EXTERNALLY = void 0;
4
+ const remotion_1 = require("remotion");
5
+ const calc_new_props_1 = require("./helpers/calc-new-props");
6
+ exports.PROPS_UPDATED_EXTERNALLY = 'remotion.propsUpdatedExternally';
7
+ const updateDefaultProps = ({ compositionId, defaultProps, }) => {
8
+ const { generatedDefaultProps, composition } = (0, calc_new_props_1.calcNewProps)(compositionId, defaultProps);
9
+ const propsStore = remotion_1.Internals.editorPropsProviderRef.current;
10
+ if (!propsStore) {
11
+ throw new Error('No props store found. Are you in the Remotion Studio and are the Remotion versions aligned?');
12
+ }
13
+ propsStore.setProps((prev) => {
14
+ return {
15
+ ...prev,
16
+ [composition.id]: generatedDefaultProps,
17
+ };
18
+ });
19
+ window.dispatchEvent(new CustomEvent(exports.PROPS_UPDATED_EXTERNALLY));
20
+ };
21
+ exports.updateDefaultProps = updateDefaultProps;
@@ -0,0 +1,13 @@
1
+ import { type StaticFile } from './get-static-files';
2
+ type WatcherCallback = (newFiles: StaticFile[]) => void;
3
+ export declare const WATCH_REMOTION_STATIC_FILES = "remotion_staticFilesChanged";
4
+ /**
5
+ * @description Watch for changes in the public folder.
6
+ * @param {Function} callback - A callback function to be called when the file changes.
7
+ * @returns {{cancel: () => void}} A function that can be used to cancel the event listener.
8
+ * @see [Documentation](https://remotion.dev/docs/studio/watch-public-folder)
9
+ */
10
+ export declare const watchPublicFolder: (callback: WatcherCallback) => {
11
+ cancel: () => void;
12
+ };
13
+ export {};
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.watchPublicFolder = exports.WATCH_REMOTION_STATIC_FILES = void 0;
4
+ const remotion_1 = require("remotion");
5
+ const get_static_files_1 = require("./get-static-files");
6
+ exports.WATCH_REMOTION_STATIC_FILES = 'remotion_staticFilesChanged';
7
+ /**
8
+ * @description Watch for changes in the public folder.
9
+ * @param {Function} callback - A callback function to be called when the file changes.
10
+ * @returns {{cancel: () => void}} A function that can be used to cancel the event listener.
11
+ * @see [Documentation](https://remotion.dev/docs/studio/watch-public-folder)
12
+ */
13
+ const watchPublicFolder = (callback) => {
14
+ if (!(0, remotion_1.getRemotionEnvironment)().isStudio) {
15
+ // eslint-disable-next-line no-console
16
+ console.warn('The API is only available while using the Remotion Studio.');
17
+ return { cancel: () => undefined };
18
+ }
19
+ const emitUpdate = () => {
20
+ callback((0, get_static_files_1.getStaticFiles)());
21
+ };
22
+ window.addEventListener(exports.WATCH_REMOTION_STATIC_FILES, emitUpdate);
23
+ const cancel = () => {
24
+ return window.removeEventListener(exports.WATCH_REMOTION_STATIC_FILES, emitUpdate);
25
+ };
26
+ return { cancel };
27
+ };
28
+ exports.watchPublicFolder = watchPublicFolder;
@@ -1,6 +1,5 @@
1
1
  import type { StaticFile } from './get-static-files';
2
2
  type WatcherCallback = (newData: StaticFile | null) => void;
3
- export declare const WATCH_REMOTION_STATIC_FILES = "remotion_staticFilesChanged";
4
3
  export type WatchRemotionStaticFilesPayload = {
5
4
  files: StaticFile[];
6
5
  };
@@ -9,7 +8,7 @@ export type WatchRemotionStaticFilesPayload = {
9
8
  * @param {string} fileName - The name of the static file to watch for changes.
10
9
  * @param {WatcherCallback} callback - A callback function to be called when the file changes.
11
10
  * @returns {{cancel: () => void}} A function that can be used to cancel the event listener.
12
- * @see [Documentation](https://www.remotion.dev/docs/watchstaticfile)
11
+ * @see [Documentation](https://remotion.dev/docs/studio/watch-static-file)
13
12
  */
14
13
  export declare const watchStaticFile: (fileName: string, callback: WatcherCallback) => {
15
14
  cancel: () => void;
@@ -1,17 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.watchStaticFile = exports.WATCH_REMOTION_STATIC_FILES = void 0;
3
+ exports.watchStaticFile = void 0;
4
4
  const remotion_1 = require("remotion");
5
- exports.WATCH_REMOTION_STATIC_FILES = 'remotion_staticFilesChanged';
5
+ const watch_public_folder_1 = require("./watch-public-folder");
6
6
  /**
7
7
  * @description Watch for changes in a specific static file.
8
8
  * @param {string} fileName - The name of the static file to watch for changes.
9
9
  * @param {WatcherCallback} callback - A callback function to be called when the file changes.
10
10
  * @returns {{cancel: () => void}} A function that can be used to cancel the event listener.
11
- * @see [Documentation](https://www.remotion.dev/docs/watchstaticfile)
11
+ * @see [Documentation](https://remotion.dev/docs/studio/watch-static-file)
12
12
  */
13
13
  const watchStaticFile = (fileName, callback) => {
14
- // Check if function is called in Remotion Studio
15
14
  if (!(0, remotion_1.getRemotionEnvironment)().isStudio) {
16
15
  // eslint-disable-next-line no-console
17
16
  console.warn('The API is only available while using the Remotion Studio.');
@@ -24,9 +23,7 @@ const watchStaticFile = (fileName, callback) => {
24
23
  ? withoutStaticBase.slice(1)
25
24
  : withoutStaticBase;
26
25
  let prevFileData = window.remotion_staticFiles.find((file) => file.name === withoutLeadingSlash);
27
- // Check if the specified static file has updated or deleted
28
- const checkFile = (event) => {
29
- const staticFiles = event.detail.files;
26
+ const { cancel } = (0, watch_public_folder_1.watchPublicFolder)((staticFiles) => {
30
27
  // Check for user specified file
31
28
  const newFileData = staticFiles.find((file) => file.name === withoutLeadingSlash);
32
29
  if (!newFileData) {
@@ -42,11 +39,7 @@ const watchStaticFile = (fileName, callback) => {
42
39
  callback(newFileData); // File is added or modified
43
40
  prevFileData = newFileData;
44
41
  }
45
- };
46
- window.addEventListener(exports.WATCH_REMOTION_STATIC_FILES, checkFile);
47
- const cancel = () => {
48
- return window.removeEventListener(exports.WATCH_REMOTION_STATIC_FILES, checkFile);
49
- };
42
+ });
50
43
  return { cancel };
51
44
  };
52
45
  exports.watchStaticFile = watchStaticFile;
@@ -46,7 +46,8 @@ const background = {
46
46
  position: 'absolute',
47
47
  };
48
48
  const DEFAULT_BUFFER_STATE_DELAY_IN_MILLISECONDS = 300;
49
- exports.BUFFER_STATE_DELAY_IN_MILLISECONDS = typeof process.env.BUFFER_STATE_DELAY_IN_MILLISECONDS === 'undefined'
49
+ exports.BUFFER_STATE_DELAY_IN_MILLISECONDS = typeof process.env.BUFFER_STATE_DELAY_IN_MILLISECONDS === 'undefined' ||
50
+ process.env.BUFFER_STATE_DELAY_IN_MILLISECONDS === null
50
51
  ? DEFAULT_BUFFER_STATE_DELAY_IN_MILLISECONDS
51
52
  : Number(process.env.BUFFER_STATE_DELAY_IN_MILLISECONDS);
52
53
  const Editor = ({ Root, readOnlyStudio }) => {
@@ -208,6 +208,7 @@ const PlayPause = ({ playbackRate, loop, bufferStateDelayInMilliseconds }) => {
208
208
  let stopped = false;
209
209
  const onBuffer = () => {
210
210
  requestAnimationFrame(() => {
211
+ stopped = false;
211
212
  timeout = setTimeout(() => {
212
213
  if (!stopped) {
213
214
  setShowBufferState(true);
@@ -296,6 +296,6 @@ const DataEditor = ({ unresolvedComposition, defaultProps, setDefaultProps, mayS
296
296
  }
297
297
  return ((0, jsx_runtime_1.jsxs)("div", { style: outer, children: [(0, jsx_runtime_1.jsxs)("div", { style: controlContainer, children: [(0, jsx_runtime_1.jsxs)("div", { style: tabWrapper, children: [(0, jsx_runtime_1.jsx)(SegmentedControl_1.SegmentedControl, { items: modeItems, needsWrapping: false }), (0, jsx_runtime_1.jsx)(layout_1.Flex, {}), warnings.length > 0 ? ((0, jsx_runtime_1.jsx)(WarningIndicatorButton_1.WarningIndicatorButton, { setShowWarning: setShowWarning, showWarning: showWarning, warningCount: warnings.length })) : null] }), showWarning && warnings.length > 0
298
298
  ? warnings.map((warning) => ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1 }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { message: warning, align: "flex-start", type: "warning" })] }, warning)))
299
- : null] }), mode === 'schema' ? ((0, jsx_runtime_1.jsx)(SchemaEditor_1.SchemaEditor, { value: defaultProps, setValue: setDefaultProps, schema: schema, zodValidationResult: zodValidationResult, defaultProps: unresolvedComposition.defaultProps, onSave: onSave, showSaveButton: showSaveButton, saving: saving, saveDisabledByParent: !zodValidationResult.success })) : ((0, jsx_runtime_1.jsx)(RenderModalJSONPropsEditor_1.RenderModalJSONPropsEditor, { value: defaultProps !== null && defaultProps !== void 0 ? defaultProps : {}, setValue: setDefaultProps, onSave: onUpdate, showSaveButton: showSaveButton, serializedJSON: serializedJSON, defaultProps: unresolvedComposition.defaultProps, schema: schema }))] }));
299
+ : null] }), mode === 'schema' ? ((0, jsx_runtime_1.jsx)(SchemaEditor_1.SchemaEditor, { unsavedDefaultProps: defaultProps, setValue: setDefaultProps, schema: schema, zodValidationResult: zodValidationResult, savedDefaultProps: unresolvedComposition.defaultProps, onSave: onSave, showSaveButton: showSaveButton, saving: saving, saveDisabledByParent: !zodValidationResult.success })) : ((0, jsx_runtime_1.jsx)(RenderModalJSONPropsEditor_1.RenderModalJSONPropsEditor, { value: defaultProps !== null && defaultProps !== void 0 ? defaultProps : {}, setValue: setDefaultProps, onSave: onUpdate, showSaveButton: showSaveButton, serializedJSON: serializedJSON, defaultProps: unresolvedComposition.defaultProps, schema: schema }))] }));
300
300
  };
301
301
  exports.DataEditor = DataEditor;
@@ -2,11 +2,11 @@ import React from 'react';
2
2
  import type { SerializedJSONWithCustomFields } from 'remotion';
3
3
  import type { z } from 'zod';
4
4
  export declare const RenderModalJSONPropsEditor: React.FC<{
5
- value: unknown;
6
- setValue: React.Dispatch<React.SetStateAction<Record<string, unknown>>>;
7
- onSave: () => void;
8
- showSaveButton: boolean;
9
- serializedJSON: SerializedJSONWithCustomFields | null;
10
- defaultProps: Record<string, unknown>;
11
- schema: z.ZodTypeAny;
5
+ readonly value: unknown;
6
+ readonly setValue: React.Dispatch<React.SetStateAction<Record<string, unknown>>>;
7
+ readonly onSave: () => void;
8
+ readonly showSaveButton: boolean;
9
+ readonly serializedJSON: SerializedJSONWithCustomFields | null;
10
+ readonly defaultProps: Record<string, unknown>;
11
+ readonly schema: z.ZodTypeAny;
12
12
  }>;
@@ -1,13 +1,13 @@
1
1
  import React from 'react';
2
2
  import type { AnyZodObject, z } from 'zod';
3
3
  export declare const SchemaEditor: React.FC<{
4
- schema: AnyZodObject;
5
- value: Record<string, unknown>;
6
- setValue: React.Dispatch<React.SetStateAction<Record<string, unknown>>>;
7
- zodValidationResult: z.SafeParseReturnType<unknown, unknown>;
8
- defaultProps: Record<string, unknown>;
9
- onSave: (updater: (oldState: Record<string, unknown>) => Record<string, unknown>) => void;
10
- showSaveButton: boolean;
11
- saving: boolean;
12
- saveDisabledByParent: boolean;
4
+ readonly schema: AnyZodObject;
5
+ readonly unsavedDefaultProps: Record<string, unknown>;
6
+ readonly setValue: React.Dispatch<React.SetStateAction<Record<string, unknown>>>;
7
+ readonly zodValidationResult: z.SafeParseReturnType<unknown, unknown>;
8
+ readonly savedDefaultProps: Record<string, unknown>;
9
+ readonly onSave: (updater: (oldState: Record<string, unknown>) => Record<string, unknown>) => void;
10
+ readonly showSaveButton: boolean;
11
+ readonly saving: boolean;
12
+ readonly saveDisabledByParent: boolean;
13
13
  }>;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SchemaEditor = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
+ const update_default_props_1 = require("../../../api/update-default-props");
6
7
  const document_title_1 = require("../../../helpers/document-title");
7
8
  const use_keybinding_1 = require("../../../helpers/use-keybinding");
8
9
  const is_menu_item_1 = require("../../Menu/is-menu-item");
@@ -10,30 +11,46 @@ const get_zod_if_possible_1 = require("../../get-zod-if-possible");
10
11
  const SchemaErrorMessages_1 = require("./SchemaErrorMessages");
11
12
  const ZodObjectEditor_1 = require("./ZodObjectEditor");
12
13
  const deep_equal_1 = require("./deep-equal");
14
+ const local_state_1 = require("./local-state");
13
15
  const scrollable = {
14
16
  display: 'flex',
15
17
  flexDirection: 'column',
16
18
  overflowY: 'auto',
17
19
  };
18
- const SchemaEditor = ({ schema, value, setValue, zodValidationResult, defaultProps, onSave, showSaveButton, saving, saveDisabledByParent, }) => {
20
+ const SchemaEditor = ({ schema, unsavedDefaultProps, setValue, zodValidationResult, savedDefaultProps, onSave, showSaveButton, saving, saveDisabledByParent, }) => {
19
21
  const keybindings = (0, use_keybinding_1.useKeybinding)();
22
+ const [revision, setRevision] = (0, react_1.useState)(0);
23
+ const revisionState = (0, react_1.useMemo)(() => {
24
+ return {
25
+ childResetRevision: revision,
26
+ };
27
+ }, [revision]);
28
+ (0, react_1.useEffect)(() => {
29
+ const bumpRevision = () => {
30
+ setRevision((old) => old + 1);
31
+ };
32
+ window.addEventListener(update_default_props_1.PROPS_UPDATED_EXTERNALLY, bumpRevision);
33
+ return () => {
34
+ window.removeEventListener(update_default_props_1.PROPS_UPDATED_EXTERNALLY, bumpRevision);
35
+ };
36
+ }, []);
20
37
  const z = (0, get_zod_if_possible_1.useZodIfPossible)();
21
38
  if (!z) {
22
39
  throw new Error('expected zod');
23
40
  }
24
41
  const hasChanged = (0, react_1.useMemo)(() => {
25
- return !(0, deep_equal_1.deepEqual)(defaultProps, value);
26
- }, [defaultProps, value]);
42
+ return !(0, deep_equal_1.deepEqual)(savedDefaultProps, unsavedDefaultProps);
43
+ }, [savedDefaultProps, unsavedDefaultProps]);
27
44
  (0, react_1.useEffect)(() => {
28
45
  (0, document_title_1.setUnsavedProps)(hasChanged);
29
46
  }, [hasChanged]);
30
47
  const onQuickSave = (0, react_1.useCallback)(() => {
31
48
  if (hasChanged && showSaveButton) {
32
49
  onSave(() => {
33
- return value;
50
+ return unsavedDefaultProps;
34
51
  });
35
52
  }
36
- }, [hasChanged, onSave, showSaveButton, value]);
53
+ }, [hasChanged, onSave, showSaveButton, unsavedDefaultProps]);
37
54
  (0, react_1.useEffect)(() => {
38
55
  const save = keybindings.registerKeybinding({
39
56
  event: 'keydown',
@@ -52,10 +69,10 @@ const SchemaEditor = ({ schema, value, setValue, zodValidationResult, defaultPro
52
69
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
70
  const typeName = def.typeName;
54
71
  const reset = (0, react_1.useCallback)(() => {
55
- setValue(defaultProps);
56
- }, [defaultProps, setValue]);
72
+ setValue(savedDefaultProps);
73
+ }, [savedDefaultProps, setValue]);
57
74
  if (!zodValidationResult.success) {
58
- const defaultPropsValid = schema.safeParse(defaultProps);
75
+ const defaultPropsValid = schema.safeParse(savedDefaultProps);
59
76
  if (!defaultPropsValid.success) {
60
77
  return (0, jsx_runtime_1.jsx)(SchemaErrorMessages_1.InvalidDefaultProps, { zodValidationResult: zodValidationResult });
61
78
  }
@@ -64,6 +81,6 @@ const SchemaEditor = ({ schema, value, setValue, zodValidationResult, defaultPro
64
81
  if (typeName !== z.ZodFirstPartyTypeKind.ZodObject) {
65
82
  return (0, jsx_runtime_1.jsx)(SchemaErrorMessages_1.TopLevelZodValue, { typeReceived: typeName });
66
83
  }
67
- return ((0, jsx_runtime_1.jsx)("div", { style: scrollable, className: is_menu_item_1.VERTICAL_SCROLLBAR_CLASSNAME, children: (0, jsx_runtime_1.jsx)(ZodObjectEditor_1.ZodObjectEditor, { discriminatedUnionReplacement: null, value: value, setValue: setValue, jsonPath: [], schema: schema, defaultValue: defaultProps, onSave: onSave, showSaveButton: showSaveButton, onRemove: null, saving: saving, saveDisabledByParent: saveDisabledByParent, mayPad: true }) }));
84
+ return ((0, jsx_runtime_1.jsx)("div", { style: scrollable, className: is_menu_item_1.VERTICAL_SCROLLBAR_CLASSNAME, children: (0, jsx_runtime_1.jsx)(local_state_1.RevisionContext.Provider, { value: revisionState, children: (0, jsx_runtime_1.jsx)(ZodObjectEditor_1.ZodObjectEditor, { discriminatedUnionReplacement: null, unsavedValue: unsavedDefaultProps, setValue: setValue, jsonPath: [], schema: schema, savedValue: savedDefaultProps, onSave: onSave, showSaveButton: showSaveButton, onRemove: null, saving: saving, saveDisabledByParent: saveDisabledByParent, mayPad: true }) }) }));
68
85
  };
69
86
  exports.SchemaEditor = SchemaEditor;
@@ -3,15 +3,15 @@ import type { z } from 'zod';
3
3
  import type { UpdaterFunction } from './ZodSwitch';
4
4
  import type { JSONPath } from './zod-types';
5
5
  export declare const ZodArrayEditor: React.FC<{
6
- schema: z.ZodTypeAny;
7
- jsonPath: JSONPath;
8
- value: unknown[];
9
- defaultValue: unknown[];
10
- setValue: UpdaterFunction<unknown[]>;
11
- onSave: UpdaterFunction<unknown[]>;
12
- showSaveButton: boolean;
13
- onRemove: null | (() => void);
14
- saving: boolean;
15
- saveDisabledByParent: boolean;
16
- mayPad: boolean;
6
+ readonly schema: z.ZodTypeAny;
7
+ readonly jsonPath: JSONPath;
8
+ readonly value: unknown[];
9
+ readonly defaultValue: unknown[];
10
+ readonly setValue: UpdaterFunction<unknown[]>;
11
+ readonly onSave: UpdaterFunction<unknown[]>;
12
+ readonly showSaveButton: boolean;
13
+ readonly onRemove: null | (() => void);
14
+ readonly saving: boolean;
15
+ readonly saveDisabledByParent: boolean;
16
+ readonly mayPad: boolean;
17
17
  }>;
@@ -38,10 +38,10 @@ const deep_equal_1 = require("./deep-equal");
38
38
  const local_state_1 = require("./local-state");
39
39
  const ZodArrayEditor = ({ schema, jsonPath, setValue, defaultValue, value, onSave, showSaveButton, onRemove, saving, saveDisabledByParent, mayPad, }) => {
40
40
  const { localValue, onChange, RevisionContextProvider, reset } = (0, local_state_1.useLocalState)({
41
- value,
41
+ unsavedValue: value,
42
42
  schema,
43
43
  setValue,
44
- defaultValue,
44
+ savedValue: defaultValue,
45
45
  });
46
46
  const [expanded, setExpanded] = (0, react_1.useState)(true);
47
47
  const def = schema._def;
@@ -3,15 +3,15 @@ import type { z } from 'zod';
3
3
  import type { UpdaterFunction } from './ZodSwitch';
4
4
  import type { JSONPath } from './zod-types';
5
5
  export declare const ZodBooleanEditor: React.FC<{
6
- schema: z.ZodTypeAny;
7
- jsonPath: JSONPath;
8
- value: boolean;
9
- setValue: UpdaterFunction<boolean>;
10
- defaultValue: boolean;
11
- onSave: UpdaterFunction<boolean>;
12
- onRemove: null | (() => void);
13
- showSaveButton: boolean;
14
- saving: boolean;
15
- saveDisabledByParent: boolean;
16
- mayPad: boolean;
6
+ readonly schema: z.ZodTypeAny;
7
+ readonly jsonPath: JSONPath;
8
+ readonly value: boolean;
9
+ readonly setValue: UpdaterFunction<boolean>;
10
+ readonly defaultValue: boolean;
11
+ readonly onSave: UpdaterFunction<boolean>;
12
+ readonly onRemove: null | (() => void);
13
+ readonly showSaveButton: boolean;
14
+ readonly saving: boolean;
15
+ readonly saveDisabledByParent: boolean;
16
+ readonly mayPad: boolean;
17
17
  }>;
@@ -14,8 +14,8 @@ const ZodBooleanEditor = ({ schema, jsonPath, value, setValue, onSave, defaultVa
14
14
  const { localValue, onChange, reset } = (0, local_state_1.useLocalState)({
15
15
  schema,
16
16
  setValue,
17
- value,
18
- defaultValue,
17
+ unsavedValue: value,
18
+ savedValue: defaultValue,
19
19
  });
20
20
  const onToggle = (0, react_1.useCallback)((e) => {
21
21
  onChange(() => e.target.checked, false, false);