@remotion/studio 4.0.431 → 4.0.433

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 (62) hide show
  1. package/dist/Studio.d.ts +1 -0
  2. package/dist/Studio.js +4 -6
  3. package/dist/components/AssetSelectorItem.js +6 -8
  4. package/dist/components/CompositionSelector.js +16 -9
  5. package/dist/components/CurrentComposition.js +2 -5
  6. package/dist/components/EditorContent.js +4 -5
  7. package/dist/components/NewComposition/InputDragger.d.ts +1 -0
  8. package/dist/components/NewComposition/InputDragger.js +27 -8
  9. package/dist/components/OptionsPanel.js +1 -1
  10. package/dist/components/PlaybackRatePersistor.js +1 -1
  11. package/dist/components/PreviewToolbar.js +4 -2
  12. package/dist/components/RenderModal/WebRenderModal.d.ts +1 -1
  13. package/dist/components/RenderModal/WebRenderModal.js +55 -26
  14. package/dist/components/RenderModal/WebRenderModalAudio.d.ts +2 -0
  15. package/dist/components/RenderModal/WebRenderModalAudio.js +13 -5
  16. package/dist/components/RenderModal/WebRenderModalBasic.js +42 -35
  17. package/dist/components/RenderQueue/ClientRenderQueueProcessor.js +3 -3
  18. package/dist/components/RenderQueue/client-side-render-types.d.ts +1 -1
  19. package/dist/components/RendersTab.js +1 -9
  20. package/dist/components/Timeline/TimelineBooleanField.d.ts +9 -0
  21. package/dist/components/Timeline/TimelineBooleanField.js +20 -0
  22. package/dist/components/Timeline/TimelineEmptyState.d.ts +2 -0
  23. package/dist/components/Timeline/TimelineEmptyState.js +15 -0
  24. package/dist/components/Timeline/TimelineExpandedSection.d.ts +5 -0
  25. package/dist/components/Timeline/TimelineExpandedSection.js +54 -152
  26. package/dist/components/Timeline/TimelineFieldRow.d.ts +11 -0
  27. package/dist/components/Timeline/TimelineFieldRow.js +83 -0
  28. package/dist/components/Timeline/TimelineListItem.d.ts +1 -0
  29. package/dist/components/Timeline/TimelineListItem.js +12 -23
  30. package/dist/components/Timeline/TimelineNumberField.d.ts +11 -0
  31. package/dist/components/Timeline/TimelineNumberField.js +53 -0
  32. package/dist/components/Timeline/TimelinePlayCursorSyncer.js +1 -1
  33. package/dist/components/Timeline/TimelineRotationField.d.ts +11 -0
  34. package/dist/components/Timeline/TimelineRotationField.js +64 -0
  35. package/dist/components/Timeline/TimelineSchemaField.d.ts +3 -4
  36. package/dist/components/Timeline/TimelineSchemaField.js +20 -77
  37. package/dist/components/Timeline/TimelineTranslateField.d.ts +11 -0
  38. package/dist/components/Timeline/TimelineTranslateField.js +115 -0
  39. package/dist/components/Timeline/timeline-field-utils.d.ts +2 -0
  40. package/dist/components/Timeline/timeline-field-utils.js +12 -0
  41. package/dist/components/Timeline/use-resolved-stack.d.ts +2 -0
  42. package/dist/components/Timeline/use-resolved-stack.js +54 -0
  43. package/dist/components/Timeline/use-sequence-props-subscription.d.ts +4 -0
  44. package/dist/components/Timeline/use-sequence-props-subscription.js +150 -0
  45. package/dist/error-overlay/react-overlay/utils/get-source-map.d.ts +5 -0
  46. package/dist/esm/{chunk-3msfwcwh.js → chunk-bd1bkakk.js} +3001 -2433
  47. package/dist/esm/internals.mjs +3001 -2433
  48. package/dist/esm/previewEntry.mjs +3011 -2442
  49. package/dist/esm/renderEntry.mjs +5 -4
  50. package/dist/helpers/calculate-timeline.js +17 -11
  51. package/dist/helpers/get-timeline-sequence-layout.js +3 -3
  52. package/dist/helpers/get-timeline-sequence-sort-key.d.ts +1 -1
  53. package/dist/helpers/get-timeline-sequence-sort-key.js +6 -3
  54. package/dist/helpers/inject-css.js +6 -1
  55. package/dist/helpers/sort-by-nonce-history.d.ts +5 -0
  56. package/dist/helpers/sort-by-nonce-history.js +73 -0
  57. package/dist/helpers/timeline-layout.d.ts +2 -2
  58. package/dist/helpers/timeline-layout.js +10 -4
  59. package/dist/internals.d.ts +1 -0
  60. package/dist/previewEntry.js +1 -1
  61. package/dist/renderEntry.js +3 -3
  62. package/package.json +10 -10
@@ -17,6 +17,32 @@ const RenderModalOutputName_1 = require("./RenderModalOutputName");
17
17
  const tabContainer = {
18
18
  flex: 1,
19
19
  };
20
+ const containerLabels = {
21
+ mp4: 'MP4',
22
+ webm: 'WebM',
23
+ mkv: 'MKV',
24
+ mov: 'MOV',
25
+ wav: 'WAV',
26
+ mp3: 'MP3',
27
+ aac: 'AAC',
28
+ ogg: 'OGG',
29
+ flac: 'FLAC',
30
+ };
31
+ const videoContainers = ['mp4', 'webm', 'mkv', 'mov'];
32
+ const audioContainers = [
33
+ 'wav',
34
+ 'mp3',
35
+ 'aac',
36
+ 'ogg',
37
+ 'flac',
38
+ ];
39
+ const codecLabels = {
40
+ h264: 'H.264',
41
+ h265: 'H.265',
42
+ vp8: 'VP8',
43
+ vp9: 'VP9',
44
+ av1: 'AV1',
45
+ };
20
46
  const WebRenderModalBasic = ({ renderMode, resolvedComposition, imageFormat, setStillFormat, frame, onFrameChanged, onFrameSetDirectly, container, setContainerFormat, setCodec, encodableVideoCodecs, effectiveVideoCodec, startFrame, setStartFrame, endFrame, setEndFrame, outName, onOutNameChange, validationMessage, logLevel, setLogLevel, }) => {
21
47
  const imageFormatOptions = (0, react_1.useMemo)(() => {
22
48
  return [
@@ -56,38 +82,19 @@ const WebRenderModalBasic = ({ renderMode, resolvedComposition, imageFormat, set
56
82
  });
57
83
  }, [logLevel, setLogLevel]);
58
84
  const containerOptions = (0, react_1.useMemo)(() => {
59
- return [
60
- {
61
- label: 'MP4',
62
- onClick: () => setContainerFormat('mp4'),
63
- leftItem: container === 'mp4' ? jsx_runtime_1.jsx(Checkmark_1.Checkmark, {}) : null,
64
- id: 'mp4',
65
- keyHint: null,
66
- quickSwitcherLabel: null,
67
- subMenu: null,
68
- type: 'item',
69
- value: 'mp4',
70
- },
71
- {
72
- label: 'WebM',
73
- onClick: () => setContainerFormat('webm'),
74
- leftItem: container === 'webm' ? jsx_runtime_1.jsx(Checkmark_1.Checkmark, {}) : null,
75
- id: 'webm',
76
- keyHint: null,
77
- quickSwitcherLabel: null,
78
- subMenu: null,
79
- type: 'item',
80
- value: 'webm',
81
- },
82
- ];
83
- }, [container, setContainerFormat]);
84
- const codecLabels = (0, react_1.useMemo)(() => ({
85
- h264: 'H.264',
86
- h265: 'H.265',
87
- vp8: 'VP8',
88
- vp9: 'VP9',
89
- av1: 'AV1',
90
- }), []);
85
+ const containers = renderMode === 'audio' ? audioContainers : videoContainers;
86
+ return containers.map((c) => ({
87
+ label: containerLabels[c],
88
+ onClick: () => setContainerFormat(c),
89
+ leftItem: container === c ? jsx_runtime_1.jsx(Checkmark_1.Checkmark, {}) : null,
90
+ id: c,
91
+ keyHint: null,
92
+ quickSwitcherLabel: null,
93
+ subMenu: null,
94
+ type: 'item',
95
+ value: c,
96
+ }));
97
+ }, [container, setContainerFormat, renderMode]);
91
98
  const codecOptions = (0, react_1.useMemo)(() => {
92
99
  return encodableVideoCodecs.map((c) => ({
93
100
  label: codecLabels[c],
@@ -100,7 +107,7 @@ const WebRenderModalBasic = ({ renderMode, resolvedComposition, imageFormat, set
100
107
  type: 'item',
101
108
  value: c,
102
109
  }));
103
- }, [encodableVideoCodecs, effectiveVideoCodec, setCodec, codecLabels]);
110
+ }, [encodableVideoCodecs, effectiveVideoCodec, setCodec]);
104
111
  return (jsx_runtime_1.jsxs("div", { style: tabContainer, children: [renderMode === 'still' ? (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
105
112
  jsx_runtime_1.jsxs("div", { style: layout_2.optionRow, children: [
106
113
  jsx_runtime_1.jsx("div", { style: layout_2.label, children: "Format" }), jsx_runtime_1.jsx("div", { style: layout_2.rightRow, children: jsx_runtime_1.jsx(SegmentedControl_1.SegmentedControl, { items: imageFormatOptions, needsWrapping: true }) })
@@ -109,11 +116,11 @@ const WebRenderModalBasic = ({ renderMode, resolvedComposition, imageFormat, set
109
116
  ] })) : null] })) : (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
110
117
  jsx_runtime_1.jsxs("div", { style: layout_2.optionRow, children: [
111
118
  jsx_runtime_1.jsx("div", { style: layout_2.label, children: "Container" }), jsx_runtime_1.jsx("div", { style: layout_2.rightRow, children: jsx_runtime_1.jsx(ComboBox_1.Combobox, { values: containerOptions, selectedId: container, title: "Container" }) })
112
- ] }), jsx_runtime_1.jsxs("div", { style: layout_2.optionRow, children: [
119
+ ] }), renderMode === 'video' ? (jsx_runtime_1.jsxs("div", { style: layout_2.optionRow, children: [
113
120
  jsx_runtime_1.jsxs("div", { style: layout_2.label, children: ["Codec",
114
121
  jsx_runtime_1.jsx(layout_1.Spacing, { x: 0.5 }), jsx_runtime_1.jsx(OptionExplainerBubble_1.OptionExplainerBubble, { id: "videoCodecOption" })
115
122
  ] }), jsx_runtime_1.jsx("div", { style: layout_2.rightRow, children: jsx_runtime_1.jsx(ComboBox_1.Combobox, { values: codecOptions, selectedId: effectiveVideoCodec, title: "Codec" }) })
116
- ] }), jsx_runtime_1.jsx(FrameRangeSetting_1.FrameRangeSetting, { durationInFrames: resolvedComposition.durationInFrames, startFrame: startFrame !== null && startFrame !== void 0 ? startFrame : 0, endFrame: endFrame !== null && endFrame !== void 0 ? endFrame : resolvedComposition.durationInFrames - 1, setStartFrame: setStartFrame, setEndFrame: setEndFrame })
123
+ ] })) : null, jsx_runtime_1.jsx(FrameRangeSetting_1.FrameRangeSetting, { durationInFrames: resolvedComposition.durationInFrames, startFrame: startFrame !== null && startFrame !== void 0 ? startFrame : 0, endFrame: endFrame !== null && endFrame !== void 0 ? endFrame : resolvedComposition.durationInFrames - 1, setStartFrame: setStartFrame, setEndFrame: setEndFrame })
117
124
  ] })), jsx_runtime_1.jsx(RenderModalOutputName_1.RenderModalOutputName, { existence: false, inputStyle: layout_2.input, outName: outName, onValueChange: onOutNameChange, validationMessage: validationMessage, label: window.remotion_isReadOnlyStudio ? 'Download name' : 'Output name' }), jsx_runtime_1.jsxs("div", { style: layout_2.optionRow, children: [
118
125
  jsx_runtime_1.jsxs("div", { style: layout_2.label, children: ["Log Level ",
119
126
  jsx_runtime_1.jsx(layout_1.Spacing, { x: 0.5 }), jsx_runtime_1.jsx(OptionExplainerBubble_1.OptionExplainerBubble, { id: "logLevelOption" })
@@ -53,7 +53,7 @@ const ClientRenderQueueProcessor = () => {
53
53
  };
54
54
  }, [getCompositionForJob]);
55
55
  const processVideoJob = (0, react_1.useCallback)(async (job, signal, onProgress) => {
56
- var _a, _b;
56
+ var _a, _b, _c;
57
57
  const compositionRef = getCompositionForJob(job.id);
58
58
  if (!compositionRef) {
59
59
  throw new Error(`Composition not found for job ${job.id}`);
@@ -74,7 +74,7 @@ const ClientRenderQueueProcessor = () => {
74
74
  delayRenderTimeoutInMilliseconds: job.delayRenderTimeout,
75
75
  mediaCacheSizeInBytes: job.mediaCacheSizeInBytes,
76
76
  logLevel: job.logLevel,
77
- videoCodec: job.videoCodec,
77
+ videoCodec: (_b = job.videoCodec) !== null && _b !== void 0 ? _b : undefined,
78
78
  audioCodec: job.audioCodec,
79
79
  audioBitrate: job.audioBitrate,
80
80
  container: job.container,
@@ -93,7 +93,7 @@ const ClientRenderQueueProcessor = () => {
93
93
  });
94
94
  },
95
95
  outputTarget: 'web-fs',
96
- licenseKey: (_b = job.licenseKey) !== null && _b !== void 0 ? _b : undefined,
96
+ licenseKey: (_c = job.licenseKey) !== null && _c !== void 0 ? _c : undefined,
97
97
  });
98
98
  return {
99
99
  getBlob,
@@ -46,7 +46,7 @@ export type ClientStillRenderJob = ClientRenderJobBase & {
46
46
  export type ClientVideoRenderJob = ClientRenderJobBase & {
47
47
  type: 'client-video';
48
48
  container: WebRendererContainer;
49
- videoCodec: WebRendererVideoCodec;
49
+ videoCodec: WebRendererVideoCodec | null;
50
50
  audioCodec: WebRendererAudioCodec;
51
51
  startFrame: number;
52
52
  endFrame: number;
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RendersTab = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
- const remotion_1 = require("remotion");
7
6
  const colors_1 = require("../helpers/colors");
8
7
  const layout_1 = require("./layout");
9
8
  const context_1 = require("./RenderQueue/context");
@@ -27,15 +26,8 @@ const badge = {
27
26
  };
28
27
  const RendersTab = ({ selected, onClick }) => {
29
28
  const { jobs } = (0, react_1.useContext)(context_1.RenderQueueContext);
30
- const { canvasContent } = (0, react_1.useContext)(remotion_1.Internals.CompositionManager);
31
29
  const failedJobs = jobs.filter((j) => j.status === 'failed').length;
32
30
  const jobCount = jobs.length;
33
- const isActuallySelected = (0, react_1.useMemo)(() => {
34
- if (!canvasContent || canvasContent.type !== 'composition') {
35
- return true;
36
- }
37
- return selected;
38
- }, [canvasContent, selected]);
39
31
  const badgeStyle = (0, react_1.useMemo)(() => {
40
32
  return {
41
33
  ...badge,
@@ -46,7 +38,7 @@ const RendersTab = ({ selected, onClick }) => {
46
38
  borderColor: colors_1.LIGHT_TEXT,
47
39
  };
48
40
  }, [failedJobs]);
49
- return (jsx_runtime_1.jsx(Tabs_1.Tab, { selected: isActuallySelected, onClick: onClick, children: jsx_runtime_1.jsxs("div", { style: row, children: ["Renders", jobCount > 0 ? (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
41
+ return (jsx_runtime_1.jsx(Tabs_1.Tab, { selected: selected, onClick: onClick, children: jsx_runtime_1.jsxs("div", { style: row, children: ["Renders", jobCount > 0 ? (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
50
42
  jsx_runtime_1.jsx(layout_1.Flex, {}), jsx_runtime_1.jsx("div", { style: badgeStyle, children: jobCount })
51
43
  ] })) : null] }) }));
52
44
  };
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import type { SchemaFieldInfo } from '../../helpers/timeline-layout';
3
+ export declare const TimelineBooleanField: React.FC<{
4
+ readonly field: SchemaFieldInfo;
5
+ readonly codeValue: unknown;
6
+ readonly effectiveValue: unknown;
7
+ readonly canUpdate: boolean;
8
+ readonly onSave: (key: string, value: unknown) => Promise<void>;
9
+ }>;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TimelineBooleanField = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const Checkbox_1 = require("../Checkbox");
7
+ const checkboxContainer = {
8
+ marginLeft: 8,
9
+ };
10
+ const TimelineBooleanField = ({ field, codeValue, effectiveValue, canUpdate, onSave }) => {
11
+ const checked = Boolean(effectiveValue);
12
+ const onChange = (0, react_1.useCallback)(() => {
13
+ const newValue = !checked;
14
+ if (canUpdate && newValue !== codeValue) {
15
+ onSave(field.key, newValue);
16
+ }
17
+ }, [canUpdate, onSave, field.key, checked, codeValue]);
18
+ return (jsx_runtime_1.jsx("div", { style: checkboxContainer, children: jsx_runtime_1.jsx(Checkbox_1.Checkbox, { checked: checked, onChange: onChange, name: field.key, disabled: !canUpdate }) }));
19
+ };
20
+ exports.TimelineBooleanField = TimelineBooleanField;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const TimelineEmptyState: React.FC;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TimelineEmptyState = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const colors_1 = require("../../helpers/colors");
6
+ const container = {
7
+ display: 'flex',
8
+ flex: 1,
9
+ height: 0,
10
+ backgroundColor: colors_1.BACKGROUND,
11
+ };
12
+ const TimelineEmptyState = () => {
13
+ return jsx_runtime_1.jsx("div", { style: container });
14
+ };
15
+ exports.TimelineEmptyState = TimelineEmptyState;
@@ -1,7 +1,12 @@
1
+ import type { SequenceNodePath } from '@remotion/studio-shared';
1
2
  import React from 'react';
2
3
  import type { TSequence } from 'remotion';
3
4
  import type { OriginalPosition } from '../../error-overlay/react-overlay/utils/get-source-map';
5
+ export declare const EXPANDED_SECTION_PADDING_LEFT = 28;
6
+ export declare const EXPANDED_SECTION_PADDING_RIGHT = 10;
4
7
  export declare const TimelineExpandedSection: React.FC<{
5
8
  readonly sequence: TSequence;
6
9
  readonly originalLocation: OriginalPosition | null;
10
+ readonly nestedDepth: number;
11
+ readonly nodePath: SequenceNodePath | null;
7
12
  }>;
@@ -1,51 +1,62 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TimelineExpandedSection = void 0;
36
+ exports.TimelineExpandedSection = exports.EXPANDED_SECTION_PADDING_RIGHT = exports.EXPANDED_SECTION_PADDING_LEFT = void 0;
4
37
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("react");
6
- const remotion_1 = require("remotion");
7
- const client_id_1 = require("../../helpers/client-id");
38
+ const react_1 = __importStar(require("react"));
8
39
  const colors_1 = require("../../helpers/colors");
9
40
  const timeline_layout_1 = require("../../helpers/timeline-layout");
10
- const call_api_1 = require("../call-api");
11
- const TimelineSchemaField_1 = require("./TimelineSchemaField");
41
+ const TimelineFieldRow_1 = require("./TimelineFieldRow");
42
+ exports.EXPANDED_SECTION_PADDING_LEFT = 28;
43
+ exports.EXPANDED_SECTION_PADDING_RIGHT = 10;
12
44
  const expandedSectionBase = {
13
45
  color: 'white',
14
46
  fontFamily: 'Arial, Helvetica, sans-serif',
15
47
  fontSize: 12,
16
48
  display: 'flex',
17
49
  flexDirection: 'column',
18
- paddingLeft: 28,
19
- paddingRight: 10,
20
50
  borderBottom: `1px solid ${colors_1.TIMELINE_TRACK_SEPARATOR}`,
21
51
  };
22
- const fieldRow = {
23
- display: 'flex',
24
- alignItems: 'center',
25
- gap: 8,
26
- };
27
- const fieldName = {
28
- fontSize: 12,
29
- };
30
- const fieldLabelRow = {
31
- flex: 1,
32
- display: 'flex',
33
- flexDirection: 'row',
34
- alignItems: 'center',
35
- gap: 6,
36
- };
37
- const TimelineFieldRow = ({ field, onSave, onDragValueChange, onDragEnd, propStatus }) => {
38
- var _a, _b;
39
- return (jsx_runtime_1.jsxs("div", { style: { ...fieldRow, height: field.rowHeight }, children: [
40
- jsx_runtime_1.jsx("div", { style: fieldLabelRow, children: jsx_runtime_1.jsx("span", { style: fieldName, children: (_a = field.description) !== null && _a !== void 0 ? _a : field.key }) }), jsx_runtime_1.jsx(TimelineSchemaField_1.TimelineFieldValue, { field: field, propStatus: propStatus, onSave: onSave, onDragValueChange: onDragValueChange, onDragEnd: onDragEnd, canUpdate: (_b = propStatus === null || propStatus === void 0 ? void 0 : propStatus.canUpdate) !== null && _b !== void 0 ? _b : false })
41
- ] }));
52
+ const separator = {
53
+ height: 1,
54
+ backgroundColor: colors_1.TIMELINE_TRACK_SEPARATOR,
42
55
  };
43
- const TimelineExpandedSection = ({ sequence, originalLocation }) => {
56
+ const TimelineExpandedSection = ({ sequence, originalLocation, nestedDepth, nodePath }) => {
44
57
  var _a;
45
- var _b, _c, _d, _e;
46
- const [propStatuses, setPropStatuses] = (0, react_1.useState)(null);
47
- const { previewServerState: state, subscribeToEvent } = (0, react_1.useContext)(client_id_1.StudioServerConnectionCtx);
48
- const clientId = state.type === 'connected' ? state.clientId : undefined;
58
+ var _b;
59
+ const overrideId = (_b = (_a = sequence.controls) === null || _a === void 0 ? void 0 : _a.overrideId) !== null && _b !== void 0 ? _b : sequence.id;
49
60
  const schemaFields = (0, react_1.useMemo)(() => (0, timeline_layout_1.getSchemaFields)(sequence.controls), [sequence.controls]);
50
61
  const validatedLocation = (0, react_1.useMemo)(() => {
51
62
  var _a;
@@ -60,126 +71,17 @@ const TimelineExpandedSection = ({ sequence, originalLocation }) => {
60
71
  column: (_a = originalLocation.column) !== null && _a !== void 0 ? _a : 0,
61
72
  };
62
73
  }, [originalLocation]);
63
- const locationSource = (_b = validatedLocation === null || validatedLocation === void 0 ? void 0 : validatedLocation.source) !== null && _b !== void 0 ? _b : null;
64
- const locationLine = (_c = validatedLocation === null || validatedLocation === void 0 ? void 0 : validatedLocation.line) !== null && _c !== void 0 ? _c : null;
65
- const locationColumn = (_d = validatedLocation === null || validatedLocation === void 0 ? void 0 : validatedLocation.column) !== null && _d !== void 0 ? _d : null;
66
- const schemaKeysString = (0, react_1.useMemo)(() => (schemaFields ? schemaFields.map((f) => f.key).join(',') : null), [schemaFields]);
67
- const currentLocationSource = (0, react_1.useRef)(locationSource);
68
- currentLocationSource.current = locationSource;
69
- const currentLocationLine = (0, react_1.useRef)(locationLine);
70
- currentLocationLine.current = locationLine;
71
- const currentLocationColumn = (0, react_1.useRef)(locationColumn);
72
- currentLocationColumn.current = locationColumn;
73
- (0, react_1.useEffect)(() => {
74
- if (!clientId ||
75
- !locationSource ||
76
- !locationLine ||
77
- locationColumn === null ||
78
- !schemaKeysString) {
79
- setPropStatuses(null);
80
- return;
81
- }
82
- const keys = schemaKeysString.split(',');
83
- (0, call_api_1.callApi)('/api/subscribe-to-sequence-props', {
84
- fileName: locationSource,
85
- line: locationLine,
86
- column: locationColumn,
87
- keys,
88
- clientId,
89
- })
90
- .then((result) => {
91
- if (currentLocationSource.current !== locationSource ||
92
- currentLocationLine.current !== locationLine ||
93
- currentLocationColumn.current !== locationColumn) {
94
- return;
95
- }
96
- if (result.canUpdate) {
97
- setPropStatuses(result.props);
98
- }
99
- else {
100
- setPropStatuses(null);
101
- }
102
- })
103
- .catch(() => {
104
- setPropStatuses(null);
105
- });
106
- return () => {
107
- (0, call_api_1.callApi)('/api/unsubscribe-from-sequence-props', {
108
- fileName: locationSource,
109
- line: locationLine,
110
- column: locationColumn,
111
- clientId,
112
- }).catch(() => {
113
- // Ignore unsubscribe errors
114
- });
115
- };
116
- }, [
117
- clientId,
118
- locationSource,
119
- locationLine,
120
- locationColumn,
121
- schemaKeysString,
122
- ]);
123
- (0, react_1.useEffect)(() => {
124
- if (!locationSource || !locationLine || locationColumn === null) {
125
- return;
126
- }
127
- const listener = (event) => {
128
- if (event.type !== 'sequence-props-updated') {
129
- return;
130
- }
131
- if (event.fileName !== currentLocationSource.current ||
132
- event.line !== currentLocationLine.current ||
133
- event.column !== currentLocationColumn.current) {
134
- return;
135
- }
136
- if (event.result.canUpdate) {
137
- setPropStatuses(event.result.props);
138
- }
139
- else {
140
- setPropStatuses(null);
141
- }
142
- };
143
- const unsub = subscribeToEvent('sequence-props-updated', listener);
144
- return () => {
145
- unsub();
146
- };
147
- }, [locationSource, locationLine, locationColumn, subscribeToEvent]);
148
74
  const expandedHeight = (0, react_1.useMemo)(() => (0, timeline_layout_1.getExpandedTrackHeight)(sequence.controls), [sequence.controls]);
149
- const { setOverride, clearOverrides } = (0, react_1.useContext)(remotion_1.Internals.SequenceControlOverrideContext);
150
- const onSave = (0, react_1.useCallback)((key, value) => {
151
- if (!propStatuses || !validatedLocation) {
152
- return Promise.reject(new Error('Cannot save'));
153
- }
154
- const status = propStatuses[key];
155
- if (!status || !status.canUpdate) {
156
- return Promise.reject(new Error('Cannot save'));
157
- }
158
- const field = schemaFields === null || schemaFields === void 0 ? void 0 : schemaFields.find((f) => f.key === key);
159
- const defaultValue = field && field.fieldSchema.default !== undefined
160
- ? JSON.stringify(field.fieldSchema.default)
161
- : null;
162
- return (0, call_api_1.callApi)('/api/save-sequence-props', {
163
- fileName: validatedLocation.source,
164
- line: validatedLocation.line,
165
- column: validatedLocation.column,
166
- key,
167
- value: JSON.stringify(value),
168
- enumPaths: [],
169
- defaultValue,
170
- }).then(() => undefined);
171
- }, [propStatuses, validatedLocation, schemaFields]);
172
- const overrideId = (_e = (_a = sequence.controls) === null || _a === void 0 ? void 0 : _a.overrideId) !== null && _e !== void 0 ? _e : sequence.id;
173
- const onDragValueChange = (0, react_1.useCallback)((key, value) => {
174
- setOverride(overrideId, key, value);
175
- }, [setOverride, overrideId]);
176
- const onDragEnd = (0, react_1.useCallback)(() => {
177
- clearOverrides(overrideId);
178
- }, [clearOverrides, overrideId]);
179
- return (jsx_runtime_1.jsx("div", { style: { ...expandedSectionBase, height: expandedHeight }, children: schemaFields
180
- ? schemaFields.map((field) => {
181
- var _a;
182
- return (jsx_runtime_1.jsx(TimelineFieldRow, { field: field, propStatus: (_a = propStatuses === null || propStatuses === void 0 ? void 0 : propStatuses[field.key]) !== null && _a !== void 0 ? _a : null, onSave: onSave, onDragValueChange: onDragValueChange, onDragEnd: onDragEnd }, field.key));
75
+ const style = (0, react_1.useMemo)(() => {
76
+ return {
77
+ ...expandedSectionBase,
78
+ height: expandedHeight,
79
+ };
80
+ }, [expandedHeight]);
81
+ return (jsx_runtime_1.jsx("div", { style: style, children: schemaFields
82
+ ? schemaFields.map((field, i) => {
83
+ return (jsx_runtime_1.jsxs(react_1.default.Fragment, { children: [i > 0 ? jsx_runtime_1.jsx("div", { style: separator }) : null, jsx_runtime_1.jsx(TimelineFieldRow_1.TimelineFieldRow, { field: field, overrideId: overrideId, validatedLocation: validatedLocation, nestedDepth: nestedDepth, nodePath: nodePath })
84
+ ] }, field.key));
183
85
  })
184
86
  : 'No schema' }));
185
87
  };
@@ -0,0 +1,11 @@
1
+ import type { SequenceNodePath } from '@remotion/studio-shared';
2
+ import React from 'react';
3
+ import type { CodePosition } from '../../error-overlay/react-overlay/utils/get-source-map';
4
+ import type { SchemaFieldInfo } from '../../helpers/timeline-layout';
5
+ export declare const TimelineFieldRow: React.FC<{
6
+ readonly field: SchemaFieldInfo;
7
+ readonly overrideId: string;
8
+ readonly validatedLocation: CodePosition | null;
9
+ readonly nestedDepth: number;
10
+ readonly nodePath: SequenceNodePath | null;
11
+ }>;
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TimelineFieldRow = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const remotion_1 = require("remotion");
7
+ const call_api_1 = require("../call-api");
8
+ const TimelineExpandedSection_1 = require("./TimelineExpandedSection");
9
+ const TimelineListItem_1 = require("./TimelineListItem");
10
+ const TimelineSchemaField_1 = require("./TimelineSchemaField");
11
+ const FIELD_ROW_PADDING_LEFT = 24;
12
+ const fieldRowBase = {
13
+ display: 'flex',
14
+ alignItems: 'center',
15
+ gap: 8,
16
+ paddingRight: TimelineExpandedSection_1.EXPANDED_SECTION_PADDING_RIGHT,
17
+ };
18
+ const fieldName = {
19
+ fontSize: 12,
20
+ color: 'rgba(255, 255, 255, 0.8)',
21
+ };
22
+ const fieldLabelRow = {
23
+ flex: '0 0 50%',
24
+ display: 'flex',
25
+ flexDirection: 'row',
26
+ alignItems: 'center',
27
+ gap: 6,
28
+ };
29
+ const TimelineFieldRow = ({ field, overrideId, validatedLocation, nestedDepth, nodePath }) => {
30
+ var _a, _b, _c, _d;
31
+ const { setDragOverrides, clearDragOverrides, dragOverrides, codeValues: allPropStatuses, } = (0, react_1.useContext)(remotion_1.Internals.VisualModeOverridesContext);
32
+ const propStatuses = ((_a = allPropStatuses[overrideId]) !== null && _a !== void 0 ? _a : null);
33
+ const propStatus = (_b = propStatuses === null || propStatuses === void 0 ? void 0 : propStatuses[field.key]) !== null && _b !== void 0 ? _b : null;
34
+ const dragOverrideValue = (0, react_1.useMemo)(() => {
35
+ var _a;
36
+ return ((_a = dragOverrides[overrideId]) !== null && _a !== void 0 ? _a : {})[field.key];
37
+ }, [dragOverrides, overrideId, field.key]);
38
+ const effectiveValue = remotion_1.Internals.getEffectiveVisualModeValue({
39
+ codeValue: propStatus,
40
+ runtimeValue: field.currentValue,
41
+ dragOverrideValue,
42
+ defaultValue: field.fieldSchema.default,
43
+ shouldResortToDefaultValueIfUndefined: true,
44
+ });
45
+ const onSave = (0, react_1.useCallback)((key, value) => {
46
+ if (!propStatuses || !validatedLocation || !nodePath) {
47
+ return Promise.reject(new Error('Cannot save'));
48
+ }
49
+ const status = propStatuses[key];
50
+ if (!status || !status.canUpdate) {
51
+ return Promise.reject(new Error('Cannot save'));
52
+ }
53
+ const defaultValue = field.fieldSchema.default !== undefined
54
+ ? JSON.stringify(field.fieldSchema.default)
55
+ : null;
56
+ return (0, call_api_1.callApi)('/api/save-sequence-props', {
57
+ fileName: validatedLocation.source,
58
+ nodePath,
59
+ key,
60
+ value: JSON.stringify(value),
61
+ defaultValue,
62
+ }).then(() => undefined);
63
+ }, [propStatuses, validatedLocation, nodePath, field.fieldSchema.default]);
64
+ const onDragValueChange = (0, react_1.useCallback)((key, value) => {
65
+ setDragOverrides(overrideId, key, value);
66
+ }, [setDragOverrides, overrideId]);
67
+ const onDragEnd = (0, react_1.useCallback)(() => {
68
+ clearDragOverrides(overrideId);
69
+ }, [clearDragOverrides, overrideId]);
70
+ const style = (0, react_1.useMemo)(() => {
71
+ return {
72
+ ...fieldRowBase,
73
+ height: field.rowHeight,
74
+ paddingLeft: TimelineExpandedSection_1.EXPANDED_SECTION_PADDING_LEFT +
75
+ FIELD_ROW_PADDING_LEFT +
76
+ TimelineListItem_1.SPACING * 3 * nestedDepth,
77
+ };
78
+ }, [field.rowHeight, nestedDepth]);
79
+ return (jsx_runtime_1.jsxs("div", { style: style, children: [
80
+ jsx_runtime_1.jsx("div", { style: fieldLabelRow, children: jsx_runtime_1.jsx("span", { style: fieldName, children: (_c = field.description) !== null && _c !== void 0 ? _c : field.key }) }), jsx_runtime_1.jsx(TimelineSchemaField_1.TimelineFieldValue, { field: field, propStatus: propStatus, onSave: onSave, onDragValueChange: onDragValueChange, onDragEnd: onDragEnd, canUpdate: (_d = propStatus === null || propStatus === void 0 ? void 0 : propStatus.canUpdate) !== null && _d !== void 0 ? _d : false, effectiveValue: effectiveValue, codeValue: propStatus })
81
+ ] }));
82
+ };
83
+ exports.TimelineFieldRow = TimelineFieldRow;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import type { TSequence } from 'remotion';
3
+ export declare const SPACING = 5;
3
4
  export declare const TimelineListItem: React.FC<{
4
5
  readonly sequence: TSequence;
5
6
  readonly nestedDepth: number;