@remotion/studio 4.0.432 → 4.0.434

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 (68) hide show
  1. package/dist/Studio.js +1 -3
  2. package/dist/components/CompositionSelector.js +16 -9
  3. package/dist/components/CurrentComposition.js +2 -5
  4. package/dist/components/CurrentCompositionSideEffects.js +2 -4
  5. package/dist/components/EditorContent.js +4 -5
  6. package/dist/components/Modals.js +3 -2
  7. package/dist/components/NewComposition/DuplicateComposition.js +4 -1
  8. package/dist/components/NewComposition/InputDragger.d.ts +1 -0
  9. package/dist/components/NewComposition/InputDragger.js +27 -8
  10. package/dist/components/OptionsPanel.js +1 -1
  11. package/dist/components/PlaybackRatePersistor.js +1 -1
  12. package/dist/components/PreviewToolbar.js +5 -4
  13. package/dist/components/RenderButton.d.ts +1 -1
  14. package/dist/components/RenderButton.js +64 -17
  15. package/dist/components/RenderModal/RenderModalBasic.d.ts +1 -0
  16. package/dist/components/RenderModal/RenderModalBasic.js +2 -2
  17. package/dist/components/RenderModal/SchemaEditor/SchemaLabel.js +3 -1
  18. package/dist/components/RenderModal/SchemaEditor/ZodArrayEditor.js +3 -1
  19. package/dist/components/RenderModal/SchemaEditor/ZodFieldValidation.js +3 -1
  20. package/dist/components/RenderModal/SchemaEditor/ZodTupleEditor.js +3 -1
  21. package/dist/components/RenderModal/ServerRenderModal.d.ts +1 -0
  22. package/dist/components/RenderModal/ServerRenderModal.js +170 -5
  23. package/dist/components/RenderModal/WebRenderModalAudio.js +5 -2
  24. package/dist/components/RenderModal/WebRenderModalBasic.js +8 -1
  25. package/dist/components/RendersTab.js +1 -9
  26. package/dist/components/SidebarRenderButton.js +1 -0
  27. package/dist/components/Timeline/TimelineBooleanField.d.ts +9 -0
  28. package/dist/components/Timeline/TimelineBooleanField.js +20 -0
  29. package/dist/components/Timeline/TimelineEmptyState.d.ts +2 -0
  30. package/dist/components/Timeline/TimelineEmptyState.js +15 -0
  31. package/dist/components/Timeline/TimelineExpandedSection.d.ts +5 -0
  32. package/dist/components/Timeline/TimelineExpandedSection.js +45 -7
  33. package/dist/components/Timeline/TimelineFieldRow.d.ts +3 -0
  34. package/dist/components/Timeline/TimelineFieldRow.js +17 -12
  35. package/dist/components/Timeline/TimelineListItem.d.ts +1 -0
  36. package/dist/components/Timeline/TimelineListItem.js +7 -7
  37. package/dist/components/Timeline/TimelineNumberField.d.ts +11 -0
  38. package/dist/components/Timeline/TimelineNumberField.js +53 -0
  39. package/dist/components/Timeline/TimelinePlayCursorSyncer.js +1 -1
  40. package/dist/components/Timeline/TimelineRotationField.d.ts +11 -0
  41. package/dist/components/Timeline/TimelineRotationField.js +64 -0
  42. package/dist/components/Timeline/TimelineSchemaField.d.ts +1 -3
  43. package/dist/components/Timeline/TimelineSchemaField.js +19 -74
  44. package/dist/components/Timeline/TimelineTranslateField.d.ts +11 -0
  45. package/dist/components/Timeline/TimelineTranslateField.js +115 -0
  46. package/dist/components/Timeline/timeline-field-utils.d.ts +2 -0
  47. package/dist/components/Timeline/timeline-field-utils.js +12 -0
  48. package/dist/components/Timeline/use-sequence-props-subscription.d.ts +2 -1
  49. package/dist/components/Timeline/use-sequence-props-subscription.js +32 -12
  50. package/dist/esm/{chunk-t28xqw5n.js → chunk-t3wtt582.js} +3198 -2341
  51. package/dist/esm/internals.mjs +3198 -2341
  52. package/dist/esm/previewEntry.mjs +3203 -2346
  53. package/dist/esm/renderEntry.mjs +1 -3
  54. package/dist/helpers/calculate-timeline.js +17 -11
  55. package/dist/helpers/get-timeline-sequence-sort-key.d.ts +1 -1
  56. package/dist/helpers/get-timeline-sequence-sort-key.js +6 -3
  57. package/dist/helpers/inject-css.js +6 -1
  58. package/dist/helpers/make-render-command.d.ts +51 -0
  59. package/dist/helpers/make-render-command.js +201 -0
  60. package/dist/helpers/retry-payload.js +3 -0
  61. package/dist/helpers/sort-by-nonce-history.d.ts +5 -0
  62. package/dist/helpers/sort-by-nonce-history.js +73 -0
  63. package/dist/helpers/timeline-layout.js +8 -2
  64. package/dist/renderEntry.js +2 -2
  65. package/dist/state/modals.d.ts +1 -0
  66. package/package.json +11 -11
  67. package/dist/helpers/should-show-render-button.d.ts +0 -1
  68. package/dist/helpers/should-show-render-button.js +0 -11
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { SchemaFieldInfo } from '../../helpers/timeline-layout';
3
+ export declare const TimelineNumberField: React.FC<{
4
+ readonly field: SchemaFieldInfo;
5
+ readonly effectiveValue: unknown;
6
+ readonly codeValue: unknown;
7
+ readonly canUpdate: boolean;
8
+ readonly onSave: (key: string, value: unknown) => Promise<void>;
9
+ readonly onDragValueChange: (key: string, value: unknown) => void;
10
+ readonly onDragEnd: () => void;
11
+ }>;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TimelineNumberField = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const InputDragger_1 = require("../NewComposition/InputDragger");
7
+ const timeline_field_utils_1 = require("./timeline-field-utils");
8
+ const TimelineNumberField = ({ field, effectiveValue, canUpdate, onSave, onDragValueChange, onDragEnd, codeValue, }) => {
9
+ var _a, _b, _c;
10
+ const [dragValue, setDragValue] = (0, react_1.useState)(null);
11
+ const onValueChange = (0, react_1.useCallback)((newVal) => {
12
+ setDragValue(newVal);
13
+ onDragValueChange(field.key, newVal);
14
+ }, [onDragValueChange, field.key]);
15
+ (0, react_1.useEffect)(() => {
16
+ setDragValue(null);
17
+ onDragEnd();
18
+ }, [field.currentValue, onDragEnd]);
19
+ const onValueChangeEnd = (0, react_1.useCallback)((newVal) => {
20
+ if (canUpdate && newVal !== codeValue) {
21
+ onSave(field.key, newVal).catch(() => {
22
+ setDragValue(null);
23
+ });
24
+ }
25
+ else {
26
+ setDragValue(null);
27
+ }
28
+ }, [canUpdate, onSave, field.key, codeValue]);
29
+ const onTextChange = (0, react_1.useCallback)((newVal) => {
30
+ if (canUpdate) {
31
+ const parsed = Number(newVal);
32
+ if (!Number.isNaN(parsed) && parsed !== codeValue) {
33
+ setDragValue(parsed);
34
+ onSave(field.key, parsed).catch(() => {
35
+ setDragValue(null);
36
+ });
37
+ }
38
+ }
39
+ }, [canUpdate, onSave, field.key, codeValue]);
40
+ const step = field.fieldSchema.type === 'number' ? ((_a = field.fieldSchema.step) !== null && _a !== void 0 ? _a : 1) : 1;
41
+ const stepDecimals = (0, react_1.useMemo)(() => (0, timeline_field_utils_1.getDecimalPlaces)(step), [step]);
42
+ const formatter = (0, react_1.useCallback)((v) => {
43
+ const num = Number(v);
44
+ const digits = Math.max(stepDecimals, (0, timeline_field_utils_1.getDecimalPlaces)(num));
45
+ return digits === 0 ? String(num) : num.toFixed(digits);
46
+ }, [stepDecimals]);
47
+ return (jsx_runtime_1.jsx(InputDragger_1.InputDragger, { type: "number", value: dragValue !== null && dragValue !== void 0 ? dragValue : effectiveValue, style: timeline_field_utils_1.draggerStyle, status: "ok", small: true, onValueChange: onValueChange, onValueChangeEnd: onValueChangeEnd, onTextChange: onTextChange, min: field.fieldSchema.type === 'number'
48
+ ? ((_b = field.fieldSchema.min) !== null && _b !== void 0 ? _b : -Infinity)
49
+ : -Infinity, max: field.fieldSchema.type === 'number'
50
+ ? ((_c = field.fieldSchema.max) !== null && _c !== void 0 ? _c : Infinity)
51
+ : Infinity, step: step, formatter: formatter, rightAlign: false }));
52
+ };
53
+ exports.TimelineNumberField = TimelineNumberField;
@@ -11,7 +11,7 @@ let lastTimelinePositionWhileScrolling = null;
11
11
  const TimelinePlayCursorSyncer = () => {
12
12
  var _a, _b;
13
13
  const video = remotion_1.Internals.useVideo();
14
- const timelineContext = (0, react_1.useContext)(remotion_1.Internals.TimelineContext);
14
+ const timelineContext = remotion_1.Internals.useTimelineContext();
15
15
  const timelinePosition = remotion_1.Internals.Timeline.useTimelinePosition();
16
16
  const { canvasContent } = (0, react_1.useContext)(remotion_1.Internals.CompositionManager);
17
17
  const { zoom: zoomMap } = (0, react_1.useContext)(timeline_zoom_1.TimelineZoomCtx);
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { SchemaFieldInfo } from '../../helpers/timeline-layout';
3
+ export declare const TimelineRotationField: React.FC<{
4
+ readonly field: SchemaFieldInfo;
5
+ readonly effectiveValue: unknown;
6
+ readonly codeValue: unknown;
7
+ readonly canUpdate: boolean;
8
+ readonly onSave: (key: string, value: unknown) => Promise<void>;
9
+ readonly onDragValueChange: (key: string, value: unknown) => void;
10
+ readonly onDragEnd: () => void;
11
+ }>;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TimelineRotationField = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const InputDragger_1 = require("../NewComposition/InputDragger");
7
+ const timeline_field_utils_1 = require("./timeline-field-utils");
8
+ const parseCssRotationToDegrees = (value) => {
9
+ try {
10
+ const m = new DOMMatrix(`rotate(${value})`);
11
+ return Math.round(Math.atan2(m.b, m.a) * (180 / Math.PI) * 1e6) / 1e6;
12
+ }
13
+ catch (_a) {
14
+ return 0;
15
+ }
16
+ };
17
+ const TimelineRotationField = ({ field, effectiveValue, codeValue, canUpdate, onSave, onDragValueChange, onDragEnd, }) => {
18
+ var _a;
19
+ const [dragValue, setDragValue] = (0, react_1.useState)(null);
20
+ const degrees = (0, react_1.useMemo)(() => parseCssRotationToDegrees(String(effectiveValue !== null && effectiveValue !== void 0 ? effectiveValue : '0deg')), [effectiveValue]);
21
+ const onValueChange = (0, react_1.useCallback)((newVal) => {
22
+ setDragValue(newVal);
23
+ onDragValueChange(field.key, `${newVal}deg`);
24
+ }, [onDragValueChange, field.key]);
25
+ (0, react_1.useEffect)(() => {
26
+ setDragValue(null);
27
+ onDragEnd();
28
+ }, [field.currentValue, onDragEnd]);
29
+ const onValueChangeEnd = (0, react_1.useCallback)((newVal) => {
30
+ const newStr = `${newVal}deg`;
31
+ if (canUpdate && newStr !== codeValue) {
32
+ onSave(field.key, newStr).catch(() => {
33
+ setDragValue(null);
34
+ });
35
+ }
36
+ else {
37
+ setDragValue(null);
38
+ }
39
+ }, [canUpdate, onSave, field.key, codeValue]);
40
+ const onTextChange = (0, react_1.useCallback)((newVal) => {
41
+ if (canUpdate) {
42
+ const parsed = Number(newVal);
43
+ if (!Number.isNaN(parsed)) {
44
+ const newStr = `${parsed}deg`;
45
+ if (newStr !== codeValue) {
46
+ setDragValue(parsed);
47
+ onSave(field.key, newStr).catch(() => {
48
+ setDragValue(null);
49
+ });
50
+ }
51
+ }
52
+ }
53
+ }, [canUpdate, onSave, field.key, codeValue]);
54
+ const step = field.fieldSchema.type === 'rotation' ? ((_a = field.fieldSchema.step) !== null && _a !== void 0 ? _a : 1) : 1;
55
+ const stepDecimals = (0, react_1.useMemo)(() => (0, timeline_field_utils_1.getDecimalPlaces)(step), [step]);
56
+ const formatter = (0, react_1.useCallback)((v) => {
57
+ const num = Number(v);
58
+ const digits = Math.max(stepDecimals, (0, timeline_field_utils_1.getDecimalPlaces)(num));
59
+ const formatted = digits === 0 ? String(num) : num.toFixed(digits);
60
+ return `${formatted}\u00B0`;
61
+ }, [stepDecimals]);
62
+ return (jsx_runtime_1.jsx(InputDragger_1.InputDragger, { type: "number", value: dragValue !== null && dragValue !== void 0 ? dragValue : degrees, style: timeline_field_utils_1.draggerStyle, status: "ok", small: true, onValueChange: onValueChange, onValueChangeEnd: onValueChangeEnd, onTextChange: onTextChange, min: -Infinity, max: Infinity, step: step, formatter: formatter, rightAlign: false }));
63
+ };
64
+ exports.TimelineRotationField = TimelineRotationField;
@@ -8,8 +8,6 @@ export declare const TimelineFieldValue: React.FC<{
8
8
  readonly onDragEnd: () => void;
9
9
  readonly canUpdate: boolean;
10
10
  readonly propStatus: CanUpdateSequencePropStatus | null;
11
+ readonly codeValue: unknown;
11
12
  readonly effectiveValue: unknown;
12
13
  }>;
13
- export declare const TimelineFieldSavingSpinner: React.FC<{
14
- readonly saving: boolean;
15
- }>;
@@ -1,79 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TimelineFieldSavingSpinner = exports.TimelineFieldValue = void 0;
3
+ exports.TimelineFieldValue = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("react");
6
- const Checkbox_1 = require("../Checkbox");
7
- const InputDragger_1 = require("../NewComposition/InputDragger");
8
- const Spinner_1 = require("../Spinner");
5
+ const TimelineBooleanField_1 = require("./TimelineBooleanField");
6
+ const TimelineNumberField_1 = require("./TimelineNumberField");
7
+ const TimelineRotationField_1 = require("./TimelineRotationField");
8
+ const TimelineTranslateField_1 = require("./TimelineTranslateField");
9
9
  const unsupportedLabel = {
10
10
  color: 'rgba(255, 255, 255, 0.4)',
11
11
  fontSize: 12,
12
- marginLeft: 'auto',
13
12
  fontStyle: 'italic',
14
13
  };
15
- const draggerStyle = {
16
- width: 80,
17
- marginLeft: 'auto',
18
- };
19
- const checkboxContainer = {
20
- marginLeft: 'auto',
21
- };
22
14
  const notEditableBackground = {
23
15
  backgroundColor: 'rgba(255, 0, 0, 0.2)',
24
16
  borderRadius: 3,
25
17
  padding: '0 4px',
26
18
  };
27
- const TimelineNumberField = ({ field, codeValue, canUpdate, onSave, onDragValueChange, onDragEnd }) => {
28
- var _a, _b, _c;
29
- const [dragValue, setDragValue] = (0, react_1.useState)(null);
30
- const dragging = (0, react_1.useRef)(false);
31
- const onValueChange = (0, react_1.useCallback)((newVal) => {
32
- dragging.current = true;
33
- setDragValue(newVal);
34
- onDragValueChange(field.key, newVal);
35
- }, [onDragValueChange, field.key]);
36
- (0, react_1.useEffect)(() => {
37
- setDragValue(null);
38
- onDragEnd();
39
- }, [field.currentValue, onDragEnd]);
40
- const onValueChangeEnd = (0, react_1.useCallback)((newVal) => {
41
- if (canUpdate && newVal !== codeValue) {
42
- onSave(field.key, newVal).catch(() => {
43
- setDragValue(null);
44
- });
45
- }
46
- else {
47
- setDragValue(null);
48
- }
49
- }, [canUpdate, onSave, field.key, codeValue]);
50
- const onTextChange = (0, react_1.useCallback)((newVal) => {
51
- if (canUpdate) {
52
- const parsed = Number(newVal);
53
- if (!Number.isNaN(parsed) && parsed !== codeValue) {
54
- setDragValue(parsed);
55
- onSave(field.key, parsed).catch(() => {
56
- setDragValue(null);
57
- });
58
- }
59
- }
60
- }, [canUpdate, onSave, field.key, codeValue]);
61
- return (jsx_runtime_1.jsx(InputDragger_1.InputDragger, { type: "number", value: dragValue !== null && dragValue !== void 0 ? dragValue : codeValue, style: draggerStyle, status: "ok", onValueChange: onValueChange, onValueChangeEnd: onValueChangeEnd, onTextChange: onTextChange, min: field.fieldSchema.type === 'number'
62
- ? ((_a = field.fieldSchema.min) !== null && _a !== void 0 ? _a : -Infinity)
63
- : -Infinity, max: field.fieldSchema.type === 'number'
64
- ? ((_b = field.fieldSchema.max) !== null && _b !== void 0 ? _b : Infinity)
65
- : Infinity, step: field.fieldSchema.type === 'number' ? ((_c = field.fieldSchema.step) !== null && _c !== void 0 ? _c : 1) : 1, rightAlign: true }));
66
- };
67
- const TimelineBooleanField = ({ field, codeValue, canUpdate, onSave }) => {
68
- const checked = Boolean(codeValue);
69
- const onChange = (0, react_1.useCallback)(() => {
70
- if (canUpdate) {
71
- onSave(field.key, !checked);
72
- }
73
- }, [canUpdate, onSave, field.key, checked]);
74
- 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 }) }));
75
- };
76
- const TimelineFieldValue = ({ field, onSave, onDragValueChange, onDragEnd, propStatus, canUpdate, effectiveValue, }) => {
19
+ const TimelineFieldValue = ({ field, onSave, onDragValueChange, onDragEnd, propStatus, canUpdate, effectiveValue, codeValue, }) => {
77
20
  const wrapperStyle = canUpdate === null || canUpdate === false
78
21
  ? notEditableBackground
79
22
  : undefined;
@@ -81,24 +24,26 @@ const TimelineFieldValue = ({ field, onSave, onDragValueChange, onDragEnd, propS
81
24
  return jsx_runtime_1.jsx("span", { style: unsupportedLabel, children: "unsupported" });
82
25
  }
83
26
  if (propStatus !== null && !propStatus.canUpdate) {
84
- return jsx_runtime_1.jsx("span", { style: unsupportedLabel, children: propStatus.reason });
27
+ if (propStatus.reason === 'computed') {
28
+ return jsx_runtime_1.jsx("span", { style: unsupportedLabel, children: "computed" });
29
+ }
30
+ throw new Error(`Unsupported prop status: ${propStatus.reason}`);
85
31
  }
86
32
  if (propStatus === null) {
87
- return (jsx_runtime_1.jsx("span", { style: { ...notEditableBackground }, children: jsx_runtime_1.jsx("span", { style: unsupportedLabel, children: "error" }) }));
33
+ return (jsx_runtime_1.jsx("span", { style: notEditableBackground, children: jsx_runtime_1.jsx("span", { style: unsupportedLabel, children: "error" }) }));
88
34
  }
89
35
  if (field.typeName === 'number') {
90
- return (jsx_runtime_1.jsx("span", { style: wrapperStyle, children: jsx_runtime_1.jsx(TimelineNumberField, { field: field, codeValue: effectiveValue, canUpdate: canUpdate, onSave: onSave, onDragValueChange: onDragValueChange, onDragEnd: onDragEnd }) }));
36
+ return (jsx_runtime_1.jsx("span", { style: wrapperStyle, children: jsx_runtime_1.jsx(TimelineNumberField_1.TimelineNumberField, { field: field, effectiveValue: effectiveValue, canUpdate: canUpdate, onSave: onSave, codeValue: codeValue, onDragValueChange: onDragValueChange, onDragEnd: onDragEnd }) }));
37
+ }
38
+ if (field.typeName === 'rotation') {
39
+ return (jsx_runtime_1.jsx("span", { style: wrapperStyle, children: jsx_runtime_1.jsx(TimelineRotationField_1.TimelineRotationField, { field: field, effectiveValue: effectiveValue, codeValue: codeValue, canUpdate: canUpdate, onSave: onSave, onDragValueChange: onDragValueChange, onDragEnd: onDragEnd }) }));
40
+ }
41
+ if (field.typeName === 'translate') {
42
+ return (jsx_runtime_1.jsx("span", { style: wrapperStyle, children: jsx_runtime_1.jsx(TimelineTranslateField_1.TimelineTranslateField, { field: field, effectiveValue: effectiveValue, codeValue: codeValue, canUpdate: canUpdate, onSave: onSave, onDragValueChange: onDragValueChange, onDragEnd: onDragEnd }) }));
91
43
  }
92
44
  if (field.typeName === 'boolean') {
93
- return (jsx_runtime_1.jsx("span", { style: wrapperStyle, children: jsx_runtime_1.jsx(TimelineBooleanField, { field: field, codeValue: effectiveValue, canUpdate: canUpdate, onSave: onSave }) }));
45
+ return (jsx_runtime_1.jsx("span", { style: wrapperStyle, children: jsx_runtime_1.jsx(TimelineBooleanField_1.TimelineBooleanField, { field: field, codeValue: codeValue, canUpdate: canUpdate, onSave: onSave, effectiveValue: effectiveValue }) }));
94
46
  }
95
47
  return (jsx_runtime_1.jsx("span", { style: { ...unsupportedLabel, fontStyle: 'normal' }, children: String(effectiveValue) }));
96
48
  };
97
49
  exports.TimelineFieldValue = TimelineFieldValue;
98
- const TimelineFieldSavingSpinner = ({ saving }) => {
99
- if (!saving) {
100
- return null;
101
- }
102
- return jsx_runtime_1.jsx(Spinner_1.Spinner, { duration: 0.5, size: 12 });
103
- };
104
- exports.TimelineFieldSavingSpinner = TimelineFieldSavingSpinner;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { SchemaFieldInfo } from '../../helpers/timeline-layout';
3
+ export declare const TimelineTranslateField: 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
+ readonly onDragValueChange: (key: string, value: unknown) => void;
10
+ readonly onDragEnd: () => void;
11
+ }>;
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TimelineTranslateField = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const InputDragger_1 = require("../NewComposition/InputDragger");
7
+ const timeline_field_utils_1 = require("./timeline-field-utils");
8
+ const leftDraggerStyle = {
9
+ paddingLeft: 0,
10
+ };
11
+ const rightDraggerStyle = {
12
+ paddingRight: 0,
13
+ };
14
+ const PIXEL_PATTERN = /^(-?\d+(?:\.\d+)?)px(?:\s+(-?\d+(?:\.\d+)?)px)?$/;
15
+ const parseTranslate = (value) => {
16
+ const m = value.match(PIXEL_PATTERN);
17
+ if (!m) {
18
+ return [0, 0];
19
+ }
20
+ return [Number(m[1]), m[2] !== undefined ? Number(m[2]) : 0];
21
+ };
22
+ const containerStyle = {
23
+ display: 'flex',
24
+ gap: 4,
25
+ };
26
+ const TimelineTranslateField = ({ field, codeValue, effectiveValue, canUpdate, onSave, onDragValueChange, onDragEnd, }) => {
27
+ var _a;
28
+ const [dragX, setDragX] = (0, react_1.useState)(null);
29
+ const [dragY, setDragY] = (0, react_1.useState)(null);
30
+ const [codeX, codeY] = (0, react_1.useMemo)(() => parseTranslate(String(effectiveValue !== null && effectiveValue !== void 0 ? effectiveValue : '0px 0px')), [effectiveValue]);
31
+ const makeString = (0, react_1.useCallback)((x, y) => `${x}px ${y}px`, []);
32
+ (0, react_1.useEffect)(() => {
33
+ setDragX(null);
34
+ setDragY(null);
35
+ onDragEnd();
36
+ }, [field.currentValue, onDragEnd]);
37
+ const step = field.fieldSchema.type === 'translate' ? ((_a = field.fieldSchema.step) !== null && _a !== void 0 ? _a : 1) : 1;
38
+ const stepDecimals = (0, react_1.useMemo)(() => (0, timeline_field_utils_1.getDecimalPlaces)(step), [step]);
39
+ const formatter = (0, react_1.useCallback)((v) => {
40
+ const num = Number(v);
41
+ const digits = Math.max(stepDecimals, (0, timeline_field_utils_1.getDecimalPlaces)(num));
42
+ const formatted = digits === 0 ? String(num) : num.toFixed(digits);
43
+ return `${formatted}px`;
44
+ }, [stepDecimals]);
45
+ // --- X callbacks ---
46
+ const onXChange = (0, react_1.useCallback)((newVal) => {
47
+ setDragX(newVal);
48
+ const currentY = dragY !== null && dragY !== void 0 ? dragY : codeY;
49
+ onDragValueChange(field.key, makeString(newVal, currentY));
50
+ }, [onDragValueChange, field.key, dragY, codeY, makeString]);
51
+ const onXChangeEnd = (0, react_1.useCallback)((newVal) => {
52
+ const currentY = dragY !== null && dragY !== void 0 ? dragY : codeY;
53
+ const newStr = makeString(newVal, currentY);
54
+ if (canUpdate && newStr !== codeValue) {
55
+ onSave(field.key, newStr).catch(() => {
56
+ setDragX(null);
57
+ });
58
+ }
59
+ else {
60
+ setDragX(null);
61
+ }
62
+ }, [canUpdate, onSave, field.key, codeValue, dragY, codeY, makeString]);
63
+ const onXTextChange = (0, react_1.useCallback)((newVal) => {
64
+ if (canUpdate) {
65
+ const parsed = Number(newVal);
66
+ if (!Number.isNaN(parsed)) {
67
+ const currentY = dragY !== null && dragY !== void 0 ? dragY : codeY;
68
+ const newStr = makeString(parsed, currentY);
69
+ if (newStr !== codeValue) {
70
+ setDragX(parsed);
71
+ onSave(field.key, newStr).catch(() => {
72
+ setDragX(null);
73
+ });
74
+ }
75
+ }
76
+ }
77
+ }, [canUpdate, onSave, field.key, codeValue, dragY, codeY, makeString]);
78
+ // --- Y callbacks ---
79
+ const onYChange = (0, react_1.useCallback)((newVal) => {
80
+ setDragY(newVal);
81
+ const currentX = dragX !== null && dragX !== void 0 ? dragX : codeX;
82
+ onDragValueChange(field.key, makeString(currentX, newVal));
83
+ }, [onDragValueChange, field.key, dragX, codeX, makeString]);
84
+ const onYChangeEnd = (0, react_1.useCallback)((newVal) => {
85
+ const currentX = dragX !== null && dragX !== void 0 ? dragX : codeX;
86
+ const newStr = makeString(currentX, newVal);
87
+ if (canUpdate && newStr !== codeValue) {
88
+ onSave(field.key, newStr).catch(() => {
89
+ setDragY(null);
90
+ });
91
+ }
92
+ else {
93
+ setDragY(null);
94
+ }
95
+ }, [canUpdate, onSave, field.key, codeValue, dragX, codeX, makeString]);
96
+ const onYTextChange = (0, react_1.useCallback)((newVal) => {
97
+ if (canUpdate) {
98
+ const parsed = Number(newVal);
99
+ if (!Number.isNaN(parsed)) {
100
+ const currentX = dragX !== null && dragX !== void 0 ? dragX : codeX;
101
+ const newStr = makeString(currentX, parsed);
102
+ if (newStr !== codeValue) {
103
+ setDragY(parsed);
104
+ onSave(field.key, newStr).catch(() => {
105
+ setDragY(null);
106
+ });
107
+ }
108
+ }
109
+ }
110
+ }, [canUpdate, onSave, field.key, codeValue, dragX, codeX, makeString]);
111
+ return (jsx_runtime_1.jsxs("span", { style: containerStyle, children: [
112
+ jsx_runtime_1.jsx(InputDragger_1.InputDragger, { type: "number", value: dragX !== null && dragX !== void 0 ? dragX : codeX, style: leftDraggerStyle, status: "ok", small: true, onValueChange: onXChange, onValueChangeEnd: onXChangeEnd, onTextChange: onXTextChange, min: -Infinity, max: Infinity, step: step, formatter: formatter, rightAlign: false }), jsx_runtime_1.jsx("div", { style: { marginLeft: -6, marginRight: -6 } }), jsx_runtime_1.jsx(InputDragger_1.InputDragger, { type: "number", value: dragY !== null && dragY !== void 0 ? dragY : codeY, style: rightDraggerStyle, status: "ok", small: true, onValueChange: onYChange, onValueChangeEnd: onYChangeEnd, onTextChange: onYTextChange, min: -Infinity, max: Infinity, step: step, formatter: formatter, rightAlign: false })
113
+ ] }));
114
+ };
115
+ exports.TimelineTranslateField = TimelineTranslateField;
@@ -0,0 +1,2 @@
1
+ export declare const getDecimalPlaces: (num: number) => number;
2
+ export declare const draggerStyle: React.CSSProperties;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.draggerStyle = exports.getDecimalPlaces = void 0;
4
+ const getDecimalPlaces = (num) => {
5
+ const str = String(num);
6
+ const decimalIndex = str.indexOf('.');
7
+ return decimalIndex === -1 ? 0 : str.length - decimalIndex - 1;
8
+ };
9
+ exports.getDecimalPlaces = getDecimalPlaces;
10
+ exports.draggerStyle = {
11
+ width: 80,
12
+ };
@@ -1,3 +1,4 @@
1
+ import type { SequenceNodePath } from '@remotion/studio-shared';
1
2
  import type { TSequence } from 'remotion';
2
3
  import type { OriginalPosition } from '../../error-overlay/react-overlay/utils/get-source-map';
3
- export declare const useSequencePropsSubscription: (sequence: TSequence, originalLocation: OriginalPosition | null) => void;
4
+ export declare const useSequencePropsSubscription: (sequence: TSequence, originalLocation: OriginalPosition | null) => SequenceNodePath | null;
@@ -43,6 +43,14 @@ const useSequencePropsSubscription = (sequence, originalLocation) => {
43
43
  currentLocationLine.current = locationLine;
44
44
  const currentLocationColumn = (0, react_1.useRef)(locationColumn);
45
45
  currentLocationColumn.current = locationColumn;
46
+ const nodePathRef = (0, react_1.useRef)(null);
47
+ const isMountedRef = (0, react_1.useRef)(true);
48
+ (0, react_1.useEffect)(() => {
49
+ isMountedRef.current = true;
50
+ return () => {
51
+ isMountedRef.current = false;
52
+ };
53
+ }, []);
46
54
  (0, react_1.useEffect)(() => {
47
55
  if (!clientId ||
48
56
  !locationSource ||
@@ -67,25 +75,36 @@ const useSequencePropsSubscription = (sequence, originalLocation) => {
67
75
  return;
68
76
  }
69
77
  if (result.canUpdate) {
78
+ nodePathRef.current = result.nodePath;
70
79
  setPropStatusesForSequence(result.props);
71
80
  }
72
81
  else {
82
+ nodePathRef.current = null;
73
83
  setPropStatusesForSequence(null);
74
84
  }
75
85
  })
76
- .catch(() => {
86
+ .catch((err) => {
87
+ nodePathRef.current = null;
88
+ remotion_1.Internals.Log.error(err);
77
89
  setPropStatusesForSequence(null);
78
90
  });
79
91
  return () => {
80
- setPropStatusesForSequence(null);
81
- (0, call_api_1.callApi)('/api/unsubscribe-from-sequence-props', {
82
- fileName: locationSource,
83
- line: locationLine,
84
- column: locationColumn,
85
- clientId,
86
- }).catch(() => {
87
- // Ignore unsubscribe errors
88
- });
92
+ const currentNodePath = nodePathRef.current;
93
+ // Only clear props on true unmount, not on re-subscribe due to
94
+ // line number changes — avoids flicker while re-subscribing.
95
+ if (!isMountedRef.current) {
96
+ setPropStatusesForSequence(null);
97
+ }
98
+ nodePathRef.current = null;
99
+ if (currentNodePath) {
100
+ (0, call_api_1.callApi)('/api/unsubscribe-from-sequence-props', {
101
+ fileName: locationSource,
102
+ nodePath: currentNodePath,
103
+ clientId,
104
+ }).catch(() => {
105
+ // Ignore unsubscribe errors
106
+ });
107
+ }
89
108
  };
90
109
  }, [
91
110
  clientId,
@@ -104,8 +123,8 @@ const useSequencePropsSubscription = (sequence, originalLocation) => {
104
123
  return;
105
124
  }
106
125
  if (event.fileName !== currentLocationSource.current ||
107
- event.line !== currentLocationLine.current ||
108
- event.column !== currentLocationColumn.current) {
126
+ !nodePathRef.current ||
127
+ JSON.stringify(event.nodePath) !== JSON.stringify(nodePathRef.current)) {
109
128
  return;
110
129
  }
111
130
  if (event.result.canUpdate) {
@@ -126,5 +145,6 @@ const useSequencePropsSubscription = (sequence, originalLocation) => {
126
145
  subscribeToEvent,
127
146
  setPropStatusesForSequence,
128
147
  ]);
148
+ return nodePathRef.current;
129
149
  };
130
150
  exports.useSequencePropsSubscription = useSequencePropsSubscription;