@remotion/studio 4.0.429 → 4.0.430

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.
@@ -53,6 +53,7 @@ const InputDraggerForwardRefFn = ({ onValueChange, onValueChangeEnd, min: _min,
53
53
  ...RemInput_1.inputBaseStyle,
54
54
  backgroundColor: 'transparent',
55
55
  borderColor: 'transparent',
56
+ padding: '4px 6px',
56
57
  };
57
58
  }, []);
58
59
  const span = (0, react_1.useMemo)(() => ({
@@ -4,6 +4,7 @@ exports.TimelineExpandedSection = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const remotion_1 = require("remotion");
7
+ const client_id_1 = require("../../helpers/client-id");
7
8
  const colors_1 = require("../../helpers/colors");
8
9
  const timeline_layout_1 = require("../../helpers/timeline-layout");
9
10
  const call_api_1 = require("../call-api");
@@ -34,19 +35,17 @@ const fieldLabelRow = {
34
35
  gap: 6,
35
36
  };
36
37
  const TimelineFieldRow = ({ field, onSave, onDragValueChange, onDragEnd, propStatus }) => {
37
- var _a;
38
- const [saving, setSaving] = (0, react_1.useState)(false);
39
- const onSavingChange = (0, react_1.useCallback)((s) => {
40
- setSaving(s);
41
- }, []);
38
+ var _a, _b;
42
39
  return (jsx_runtime_1.jsxs("div", { style: { ...fieldRow, height: field.rowHeight }, children: [
43
- jsx_runtime_1.jsxs("div", { style: fieldLabelRow, children: [
44
- jsx_runtime_1.jsx("span", { style: fieldName, children: field.key }), jsx_runtime_1.jsx(TimelineSchemaField_1.TimelineFieldSavingSpinner, { saving: saving })
45
- ] }), jsx_runtime_1.jsx(TimelineSchemaField_1.TimelineFieldValue, { field: field, propStatus: propStatus, onSave: onSave, onSavingChange: onSavingChange, onDragValueChange: onDragValueChange, onDragEnd: onDragEnd, canUpdate: (_a = propStatus === null || propStatus === void 0 ? void 0 : propStatus.canUpdate) !== null && _a !== void 0 ? _a : false })
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 })
46
41
  ] }));
47
42
  };
48
43
  const TimelineExpandedSection = ({ sequence, originalLocation }) => {
44
+ var _a;
45
+ var _b, _c, _d, _e;
49
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;
50
49
  const schemaFields = (0, react_1.useMemo)(() => (0, timeline_layout_1.getSchemaFields)(sequence.controls), [sequence.controls]);
51
50
  const validatedLocation = (0, react_1.useMemo)(() => {
52
51
  var _a;
@@ -61,18 +60,39 @@ const TimelineExpandedSection = ({ sequence, originalLocation }) => {
61
60
  column: (_a = originalLocation.column) !== null && _a !== void 0 ? _a : 0,
62
61
  };
63
62
  }, [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;
64
73
  (0, react_1.useEffect)(() => {
65
- if (!sequence.controls || !validatedLocation || !schemaFields) {
74
+ if (!clientId ||
75
+ !locationSource ||
76
+ !locationLine ||
77
+ locationColumn === null ||
78
+ !schemaKeysString) {
66
79
  setPropStatuses(null);
67
80
  return;
68
81
  }
69
- (0, call_api_1.callApi)('/api/can-update-sequence-props', {
70
- fileName: validatedLocation.source,
71
- line: validatedLocation.line,
72
- column: validatedLocation.column,
73
- keys: schemaFields.map((f) => f.key),
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,
74
89
  })
75
90
  .then((result) => {
91
+ if (currentLocationSource.current !== locationSource ||
92
+ currentLocationLine.current !== locationLine ||
93
+ currentLocationColumn.current !== locationColumn) {
94
+ return;
95
+ }
76
96
  if (result.canUpdate) {
77
97
  setPropStatuses(result.props);
78
98
  }
@@ -83,7 +103,48 @@ const TimelineExpandedSection = ({ sequence, originalLocation }) => {
83
103
  .catch(() => {
84
104
  setPropStatuses(null);
85
105
  });
86
- }, [sequence.controls, validatedLocation, schemaFields]);
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]);
87
148
  const expandedHeight = (0, react_1.useMemo)(() => (0, timeline_layout_1.getExpandedTrackHeight)(sequence.controls), [sequence.controls]);
88
149
  const { setOverride, clearOverrides } = (0, react_1.useContext)(remotion_1.Internals.SequenceControlOverrideContext);
89
150
  const onSave = (0, react_1.useCallback)((key, value) => {
@@ -94,6 +155,10 @@ const TimelineExpandedSection = ({ sequence, originalLocation }) => {
94
155
  if (!status || !status.canUpdate) {
95
156
  return Promise.reject(new Error('Cannot save'));
96
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;
97
162
  return (0, call_api_1.callApi)('/api/save-sequence-props', {
98
163
  fileName: validatedLocation.source,
99
164
  line: validatedLocation.line,
@@ -101,14 +166,16 @@ const TimelineExpandedSection = ({ sequence, originalLocation }) => {
101
166
  key,
102
167
  value: JSON.stringify(value),
103
168
  enumPaths: [],
169
+ defaultValue,
104
170
  }).then(() => undefined);
105
- }, [propStatuses, validatedLocation]);
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;
106
173
  const onDragValueChange = (0, react_1.useCallback)((key, value) => {
107
- setOverride(sequence.id, key, value);
108
- }, [setOverride, sequence.id]);
174
+ setOverride(overrideId, key, value);
175
+ }, [setOverride, overrideId]);
109
176
  const onDragEnd = (0, react_1.useCallback)(() => {
110
- clearOverrides(sequence.id);
111
- }, [clearOverrides, sequence.id]);
177
+ clearOverrides(overrideId);
178
+ }, [clearOverrides, overrideId]);
112
179
  return (jsx_runtime_1.jsx("div", { style: { ...expandedSectionBase, height: expandedHeight }, children: schemaFields
113
180
  ? schemaFields.map((field) => {
114
181
  var _a;
@@ -4,6 +4,7 @@ exports.TimelineListItem = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const remotion_1 = require("remotion");
7
+ const client_id_1 = require("../../helpers/client-id");
7
8
  const colors_1 = require("../../helpers/colors");
8
9
  const timeline_layout_1 = require("../../helpers/timeline-layout");
9
10
  const ExpandedTracksProvider_1 = require("../ExpandedTracksProvider");
@@ -36,7 +37,9 @@ const arrowButton = {
36
37
  };
37
38
  const TimelineListItem = ({ nestedDepth, sequence, isCompact }) => {
38
39
  var _a;
39
- const visualModeEnabled = Boolean(process.env.EXPERIMENTAL_VISUAL_MODE_ENABLED);
40
+ const { previewServerState } = (0, react_1.useContext)(client_id_1.StudioServerConnectionCtx);
41
+ const visualModeEnabled = Boolean(process.env.EXPERIMENTAL_VISUAL_MODE_ENABLED) &&
42
+ previewServerState.type === 'connected';
40
43
  const { hidden, setHidden } = (0, react_1.useContext)(remotion_1.Internals.SequenceVisibilityToggleContext);
41
44
  const { expandedTracks, toggleTrack } = (0, react_1.useContext)(ExpandedTracksProvider_1.ExpandedTracksContext);
42
45
  const [originalLocation, setOriginalLocation] = (0, react_1.useState)(null);
@@ -53,7 +56,7 @@ const TimelineListItem = ({ nestedDepth, sequence, isCompact }) => {
53
56
  console.error('Could not get original location of Sequence', err);
54
57
  });
55
58
  }, [sequence.stack]);
56
- const isExpanded = (_a = expandedTracks[sequence.id]) !== null && _a !== void 0 ? _a : false;
59
+ const isExpanded = visualModeEnabled && ((_a = expandedTracks[sequence.id]) !== null && _a !== void 0 ? _a : false);
57
60
  const onToggleExpand = (0, react_1.useCallback)(() => {
58
61
  toggleTrack(sequence.id);
59
62
  }, [sequence.id, toggleTrack]);
@@ -4,7 +4,6 @@ import type { SchemaFieldInfo } from '../../helpers/timeline-layout';
4
4
  export declare const TimelineFieldValue: React.FC<{
5
5
  readonly field: SchemaFieldInfo;
6
6
  readonly onSave: (key: string, value: unknown) => Promise<void>;
7
- readonly onSavingChange: (saving: boolean) => void;
8
7
  readonly onDragValueChange: (key: string, value: unknown) => void;
9
8
  readonly onDragEnd: () => void;
10
9
  readonly canUpdate: boolean;
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TimelineFieldSavingSpinner = exports.TimelineFieldValue = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
+ const Checkbox_1 = require("../Checkbox");
6
7
  const InputDragger_1 = require("../NewComposition/InputDragger");
7
- const zod_number_constraints_1 = require("../RenderModal/SchemaEditor/zod-number-constraints");
8
8
  const Spinner_1 = require("../Spinner");
9
9
  const unsupportedLabel = {
10
10
  color: 'rgba(255, 255, 255, 0.4)',
@@ -16,12 +16,16 @@ const draggerStyle = {
16
16
  width: 80,
17
17
  marginLeft: 'auto',
18
18
  };
19
+ const checkboxContainer = {
20
+ marginLeft: 'auto',
21
+ };
19
22
  const notEditableBackground = {
20
23
  backgroundColor: 'rgba(255, 0, 0, 0.2)',
21
24
  borderRadius: 3,
22
25
  padding: '0 4px',
23
26
  };
24
- const TimelineNumberField = ({ field, canUpdate, onSave, onSavingChange, onDragValueChange, onDragEnd, }) => {
27
+ const TimelineNumberField = ({ field, codeValue, canUpdate, onSave, onDragValueChange, onDragEnd }) => {
28
+ var _a, _b, _c;
25
29
  const [dragValue, setDragValue] = (0, react_1.useState)(null);
26
30
  const dragging = (0, react_1.useRef)(false);
27
31
  const onValueChange = (0, react_1.useCallback)((newVal) => {
@@ -31,37 +35,46 @@ const TimelineNumberField = ({ field, canUpdate, onSave, onSavingChange, onDragV
31
35
  }, [onDragValueChange, field.key]);
32
36
  (0, react_1.useEffect)(() => {
33
37
  setDragValue(null);
34
- onSavingChange(false);
35
38
  onDragEnd();
36
- }, [field.currentValue, onSavingChange, onDragEnd]);
39
+ }, [field.currentValue, onDragEnd]);
37
40
  const onValueChangeEnd = (0, react_1.useCallback)((newVal) => {
38
- if (canUpdate && newVal !== field.currentValue) {
39
- onSavingChange(true);
41
+ if (canUpdate && newVal !== codeValue) {
40
42
  onSave(field.key, newVal).catch(() => {
41
- onSavingChange(false);
42
43
  setDragValue(null);
43
44
  });
44
45
  }
45
46
  else {
46
47
  setDragValue(null);
47
48
  }
48
- }, [canUpdate, onSave, onSavingChange, field.key, field.currentValue]);
49
+ }, [canUpdate, onSave, field.key, codeValue]);
49
50
  const onTextChange = (0, react_1.useCallback)((newVal) => {
50
51
  if (canUpdate) {
51
52
  const parsed = Number(newVal);
52
- if (!Number.isNaN(parsed) && parsed !== field.currentValue) {
53
+ if (!Number.isNaN(parsed) && parsed !== codeValue) {
53
54
  setDragValue(parsed);
54
- onSavingChange(true);
55
55
  onSave(field.key, parsed).catch(() => {
56
- onSavingChange(false);
57
56
  setDragValue(null);
58
57
  });
59
58
  }
60
59
  }
61
- }, [canUpdate, onSave, onSavingChange, field.key, field.currentValue]);
62
- return (jsx_runtime_1.jsx(InputDragger_1.InputDragger, { type: "number", value: dragValue !== null && dragValue !== void 0 ? dragValue : field.currentValue, style: draggerStyle, status: "ok", onValueChange: onValueChange, onValueChangeEnd: onValueChangeEnd, onTextChange: onTextChange, min: (0, zod_number_constraints_1.getZodNumberMinimum)(field.fieldSchema), max: (0, zod_number_constraints_1.getZodNumberMaximum)(field.fieldSchema), step: (0, zod_number_constraints_1.getZodNumberStep)(field.fieldSchema), rightAlign: true }));
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 }) }));
63
75
  };
64
- const TimelineFieldValue = ({ field, onSave, onSavingChange, onDragValueChange, onDragEnd, propStatus, canUpdate, }) => {
76
+ const TimelineFieldValue = ({ field, onSave, onDragValueChange, onDragEnd, propStatus, canUpdate }) => {
77
+ var _a, _b;
65
78
  const wrapperStyle = canUpdate === null || canUpdate === false
66
79
  ? notEditableBackground
67
80
  : undefined;
@@ -74,10 +87,14 @@ const TimelineFieldValue = ({ field, onSave, onSavingChange, onDragValueChange,
74
87
  if (propStatus === null) {
75
88
  return (jsx_runtime_1.jsx("span", { style: { ...notEditableBackground }, children: jsx_runtime_1.jsx("span", { style: unsupportedLabel, children: "error" }) }));
76
89
  }
90
+ const effectiveCodeValue = (_b = (_a = propStatus.codeValue) !== null && _a !== void 0 ? _a : field.currentValue) !== null && _b !== void 0 ? _b : field.fieldSchema.default;
77
91
  if (field.typeName === 'number') {
78
- return (jsx_runtime_1.jsx("span", { style: wrapperStyle, children: jsx_runtime_1.jsx(TimelineNumberField, { field: field, canUpdate: canUpdate, onSave: onSave, onSavingChange: onSavingChange, onDragValueChange: onDragValueChange, onDragEnd: onDragEnd }) }));
92
+ return (jsx_runtime_1.jsx("span", { style: wrapperStyle, children: jsx_runtime_1.jsx(TimelineNumberField, { field: field, codeValue: effectiveCodeValue, canUpdate: canUpdate, onSave: onSave, onDragValueChange: onDragValueChange, onDragEnd: onDragEnd }) }));
93
+ }
94
+ if (field.typeName === 'boolean') {
95
+ return (jsx_runtime_1.jsx("span", { style: wrapperStyle, children: jsx_runtime_1.jsx(TimelineBooleanField, { field: field, codeValue: effectiveCodeValue, canUpdate: canUpdate, onSave: onSave }) }));
79
96
  }
80
- return (jsx_runtime_1.jsx("span", { style: { ...unsupportedLabel, fontStyle: 'normal' }, children: String(field.currentValue) }));
97
+ return (jsx_runtime_1.jsx("span", { style: { ...unsupportedLabel, fontStyle: 'normal' }, children: String(effectiveCodeValue) }));
81
98
  };
82
99
  exports.TimelineFieldValue = TimelineFieldValue;
83
100
  const TimelineFieldSavingSpinner = ({ saving }) => {
@@ -7,6 +7,7 @@ const relativeFrameStyle = {
7
7
  fontFamily: 'Arial, Helvetica, sans-serif',
8
8
  color: 'white',
9
9
  opacity: 0.5,
10
+ whiteSpace: 'nowrap',
10
11
  };
11
12
  const TimelineSequenceFrame = ({ roundedFrame, premounted, postmounted }) => {
12
13
  return (jsx_runtime_1.jsx("div", { style: relativeFrameStyle, children: premounted
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TimelineTracks = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
+ const client_id_1 = require("../../helpers/client-id");
6
7
  const timeline_layout_1 = require("../../helpers/timeline-layout");
7
8
  const ExpandedTracksProvider_1 = require("../ExpandedTracksProvider");
8
9
  const is_collapsed_1 = require("./is-collapsed");
@@ -22,7 +23,9 @@ const getExpandedPlaceholderStyle = (controls) => ({
22
23
  });
23
24
  const TimelineTracks = ({ timeline, hasBeenCut }) => {
24
25
  const { expandedTracks } = (0, react_1.useContext)(ExpandedTracksProvider_1.ExpandedTracksContext);
25
- const visualModeEnabled = Boolean(process.env.EXPERIMENTAL_VISUAL_MODE_ENABLED);
26
+ const { previewServerState } = (0, react_1.useContext)(client_id_1.StudioServerConnectionCtx);
27
+ const visualModeEnabled = Boolean(process.env.EXPERIMENTAL_VISUAL_MODE_ENABLED) &&
28
+ previewServerState.type === 'connected';
26
29
  const timelineStyle = (0, react_1.useMemo)(() => {
27
30
  return {
28
31
  ...timelineContent,
@@ -213,47 +213,62 @@ const TimelineVideoInfo = ({ src, visualizationWidth, naturalWidth, trimBefore,
213
213
  },
214
214
  src,
215
215
  onVideoSample: (sample) => {
216
- const frame = sample.toVideoFrame();
217
- const scale = (HEIGHT / frame.displayHeight) * window.devicePixelRatio;
218
- const transformed = (0, resize_video_frame_1.resizeVideoFrame)({
219
- frame,
220
- scale,
221
- });
222
- if (transformed !== frame) {
223
- frame.close();
216
+ let frame;
217
+ try {
218
+ frame = sample.toVideoFrame();
219
+ const scale = (HEIGHT / frame.displayHeight) * window.devicePixelRatio;
220
+ const transformed = (0, resize_video_frame_1.resizeVideoFrame)({
221
+ frame,
222
+ scale,
223
+ });
224
+ if (transformed !== frame) {
225
+ frame.close();
226
+ }
227
+ frame = undefined;
228
+ const databaseKey = (0, frame_database_1.makeFrameDatabaseKey)(src, transformed.timestamp);
229
+ const existingFrame = frame_database_1.frameDatabase.get(databaseKey);
230
+ if (existingFrame) {
231
+ existingFrame.frame.close();
232
+ }
233
+ frame_database_1.frameDatabase.set(databaseKey, {
234
+ frame: transformed,
235
+ lastUsed: Date.now(),
236
+ });
237
+ if (aspectRatio.current === null) {
238
+ throw new Error('Aspect ratio is not set');
239
+ }
240
+ ensureSlots({
241
+ filledSlots,
242
+ fromSeconds,
243
+ toSeconds,
244
+ naturalWidth,
245
+ aspectRatio: aspectRatio.current,
246
+ });
247
+ fillFrameWhereItFits({
248
+ ctx,
249
+ filledSlots,
250
+ visualizationWidth: naturalWidth,
251
+ frame: transformed,
252
+ segmentDuration: toSeconds - fromSeconds,
253
+ fromSeconds,
254
+ });
224
255
  }
225
- const databaseKey = (0, frame_database_1.makeFrameDatabaseKey)(src, transformed.timestamp);
226
- const existingFrame = frame_database_1.frameDatabase.get(databaseKey);
227
- if (existingFrame) {
228
- existingFrame.frame.close();
256
+ catch (e) {
257
+ if (frame) {
258
+ frame.close();
259
+ }
260
+ throw e;
229
261
  }
230
- frame_database_1.frameDatabase.set(databaseKey, {
231
- frame: transformed,
232
- lastUsed: Date.now(),
233
- });
234
- if (aspectRatio.current === null) {
235
- throw new Error('Aspect ratio is not set');
262
+ finally {
263
+ sample.close();
236
264
  }
237
- ensureSlots({
238
- filledSlots,
239
- fromSeconds,
240
- toSeconds,
241
- naturalWidth,
242
- aspectRatio: aspectRatio.current,
243
- });
244
- fillFrameWhereItFits({
245
- ctx,
246
- filledSlots,
247
- visualizationWidth: naturalWidth,
248
- frame: transformed,
249
- segmentDuration: toSeconds - fromSeconds,
250
- fromSeconds,
251
- });
252
- sample.close();
253
265
  },
254
266
  signal: controller.signal,
255
267
  })
256
268
  .then(() => {
269
+ if (controller.signal.aborted) {
270
+ return;
271
+ }
257
272
  fillWithCachedFrames({
258
273
  ctx,
259
274
  naturalWidth,