@remotion/studio 4.0.372 → 4.0.374

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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  __require,
3
3
  __toESM
4
- } from "./chunk-bgfkgcmg.js";
4
+ } from "./chunk-6jf1natv.js";
5
5
 
6
6
  // src/Studio.tsx
7
7
  import { useLayoutEffect as useLayoutEffect2 } from "react";
@@ -970,11 +970,9 @@ var loadExpandedFolders = (type) => {
970
970
  return JSON.parse(item);
971
971
  };
972
972
  var ExpandedFoldersContext = createContext6({
973
- toggleFolder: () => {
974
- },
973
+ toggleFolder: () => {},
975
974
  foldersExpanded: {},
976
- setFoldersExpanded: () => {
977
- }
975
+ setFoldersExpanded: () => {}
978
976
  });
979
977
 
980
978
  // src/state/folders.tsx
@@ -4436,8 +4434,7 @@ var AskAiModal = () => {
4436
4434
  if (json.type === "cmd-i") {
4437
4435
  askAiModalRef.current?.toggle();
4438
4436
  }
4439
- } catch {
4440
- }
4437
+ } catch {}
4441
4438
  };
4442
4439
  window.addEventListener("message", onMessage);
4443
4440
  return () => {
@@ -10339,8 +10336,7 @@ var getZodSchemaFromPrimitive = (value, z) => {
10339
10336
  let stringified;
10340
10337
  try {
10341
10338
  stringified = JSON.stringify(value);
10342
- } catch {
10343
- }
10339
+ } catch {}
10344
10340
  throw new Error(`visualControl(): Specify a schema for this value: ${stringified ?? "[non-serializable value]"}. See https://remotion.dev/docs/studio/visual-control`);
10345
10341
  };
10346
10342
 
@@ -10458,8 +10454,7 @@ var VisualControlsProvider = ({ children }) => {
10458
10454
  const changedRef = useRef23(false);
10459
10455
  const env = useRemotionEnvironment();
10460
10456
  const visualControl = useCallback41(function(key, value, schema) {
10461
- if (handles && false) {
10462
- }
10457
+ if (handles && false) {}
10463
10458
  if (!env.isStudio) {
10464
10459
  return value;
10465
10460
  }
@@ -10778,8 +10773,7 @@ var saveDefaultProps = async ({
10778
10773
  let zodTypes = null;
10779
10774
  try {
10780
10775
  zodTypes = await import("@remotion/zod-types");
10781
- } catch {
10782
- }
10776
+ } catch {}
10783
10777
  const { generatedDefaultProps, composition } = calcNewProps(compositionId, defaultProps);
10784
10778
  const res = await callUpdateDefaultPropsApi(compositionId, generatedDefaultProps, composition.schema ? extractEnumJsonPaths({
10785
10779
  schema: composition.schema,
@@ -17621,7 +17615,7 @@ var loadPlaybackRate = () => {
17621
17615
 
17622
17616
  // src/components/PlaybackRatePersistor.tsx
17623
17617
  var PlaybackRatePersistor = () => {
17624
- const { setPlaybackRate, playbackRate } = useContext49(Internals40.Timeline.TimelineContext);
17618
+ const { setPlaybackRate, playbackRate } = useContext49(Internals40.TimelineContext);
17625
17619
  useEffect54(() => {
17626
17620
  setPlaybackRate(loadPlaybackRate());
17627
17621
  }, [setPlaybackRate]);
@@ -17930,7 +17924,35 @@ var TimelineZoomControls = () => {
17930
17924
  import ReactDOM8 from "react-dom/client";
17931
17925
  import { Internals as Internals44 } from "remotion";
17932
17926
  import { jsx as jsx176 } from "react/jsx-runtime";
17933
- var compose = ({
17927
+ var svgToImageBitmap = (svg) => {
17928
+ const computedStyle = getComputedStyle(svg);
17929
+ const { transform: originalTransform } = computedStyle;
17930
+ svg.style.transform = "none";
17931
+ const svgDimensions = svg.getBoundingClientRect();
17932
+ svg.style.transform = originalTransform;
17933
+ if (svgDimensions.width === 0 || svgDimensions.height === 0) {
17934
+ return Promise.resolve(null);
17935
+ }
17936
+ const svgData = new XMLSerializer().serializeToString(svg);
17937
+ return new Promise((resolve, reject) => {
17938
+ const image = new Image(svgDimensions.width, svgDimensions.height);
17939
+ const url = "data:image/svg+xml;base64," + window.btoa(svgData);
17940
+ image.onload = function() {
17941
+ resolve({
17942
+ image,
17943
+ width: svgDimensions.width,
17944
+ height: svgDimensions.height,
17945
+ left: svgDimensions.left,
17946
+ top: svgDimensions.top
17947
+ });
17948
+ };
17949
+ image.onerror = () => {
17950
+ reject(new Error("Failed to convert SVG to image"));
17951
+ };
17952
+ image.src = url;
17953
+ });
17954
+ };
17955
+ var compose = async ({
17934
17956
  composables,
17935
17957
  width,
17936
17958
  height
@@ -17941,7 +17963,15 @@ var compose = ({
17941
17963
  throw new Error("Could not get context");
17942
17964
  }
17943
17965
  for (const composable of composables) {
17944
- context.drawImage(composable, 0, 0);
17966
+ if (composable.type === "canvas") {
17967
+ const boundingClientRect = composable.element.getBoundingClientRect();
17968
+ context.drawImage(composable.element, boundingClientRect.left, boundingClientRect.top);
17969
+ } else if (composable.type === "svg") {
17970
+ const imageBitmap = await svgToImageBitmap(composable.element);
17971
+ if (imageBitmap) {
17972
+ context.drawImage(imageBitmap.image, imageBitmap.left, imageBitmap.top);
17973
+ }
17974
+ }
17945
17975
  }
17946
17976
  return canvas;
17947
17977
  };
@@ -17950,86 +17980,75 @@ var findCanvasElements = (element) => {
17950
17980
  const composables = [];
17951
17981
  Array.from(canvasElements).forEach((canvasElement) => {
17952
17982
  const canvas = canvasElement;
17953
- composables.push(canvas);
17983
+ composables.push({
17984
+ type: "canvas",
17985
+ element: canvas
17986
+ });
17954
17987
  });
17955
17988
  return composables;
17956
17989
  };
17957
- var waitForReady = (timeoutInMilliseconds) => {
17990
+ var findSvgElements = (element) => {
17991
+ const svgElements = element.querySelectorAll("svg");
17992
+ const composables = [];
17993
+ Array.from(svgElements).forEach((svgElement) => {
17994
+ const svg = svgElement;
17995
+ composables.push({
17996
+ type: "svg",
17997
+ element: svg
17998
+ });
17999
+ });
18000
+ return composables;
18001
+ };
18002
+ var waitForReady = (timeoutInMilliseconds, scope) => {
17958
18003
  const { promise, resolve, reject } = Promise.withResolvers();
17959
18004
  const start = Date.now();
17960
18005
  const interval = setInterval(() => {
17961
- if (window.remotion_renderReady === true) {
18006
+ if (scope.remotion_renderReady === true) {
17962
18007
  resolve(true);
17963
18008
  clearInterval(interval);
17964
18009
  return;
17965
18010
  }
17966
- if (window.remotion_cancelledError !== undefined) {
17967
- reject(window.remotion_cancelledError);
18011
+ if (scope.remotion_cancelledError !== undefined) {
18012
+ reject(scope.remotion_cancelledError);
17968
18013
  clearInterval(interval);
17969
18014
  return;
17970
18015
  }
17971
18016
  if (Date.now() - start > timeoutInMilliseconds + 3000) {
17972
- reject(new Error(Object.values(window.remotion_delayRenderTimeouts).map((d) => d.label).join(", ")));
18017
+ reject(new Error(Object.values(scope.remotion_delayRenderTimeouts).map((d) => d.label).join(", ")));
17973
18018
  clearInterval(interval);
17974
18019
  }
17975
18020
  }, 50);
17976
18021
  return promise;
17977
18022
  };
17978
- var renderStillOnWeb = async ({
18023
+ var COMP_ID = "markup";
18024
+ var internalRenderStillOnWeb = async ({
17979
18025
  Component,
17980
18026
  width,
17981
18027
  height,
17982
18028
  fps,
17983
18029
  durationInFrames,
17984
- frame: frame2
18030
+ frame: frame2,
18031
+ delayRenderTimeoutInMilliseconds,
18032
+ logLevel
17985
18033
  }) => {
17986
18034
  const div = document.createElement("div");
17987
18035
  div.style.display = "flex";
17988
18036
  div.style.backgroundColor = "transparent";
17989
- div.style.position = "absolute";
18037
+ div.style.position = "fixed";
17990
18038
  div.style.width = `${width}px`;
17991
18039
  div.style.height = `${height}px`;
18040
+ div.style.zIndex = "-9999";
17992
18041
  document.body.appendChild(div);
17993
- const delayRenderTimeoutInMilliseconds = 1e4;
17994
18042
  if (!ReactDOM8.createRoot) {
17995
18043
  throw new Error("@remotion/web-renderer requires React 18 or higher");
17996
18044
  }
17997
- const compositionManagerContext = {
17998
- currentCompositionMetadata: {
17999
- durationInFrames,
18000
- fps,
18001
- height,
18002
- width,
18003
- props: {},
18004
- defaultCodec: null,
18005
- defaultOutName: null,
18006
- defaultVideoImageFormat: null,
18007
- defaultPixelFormat: null,
18008
- defaultProResProfile: null
18009
- },
18010
- folders: [],
18011
- compositions: [
18012
- {
18013
- id: "markup",
18014
- component: Component,
18015
- nonce: 0,
18016
- defaultProps: undefined,
18017
- folderName: null,
18018
- parentFolderName: null,
18019
- schema: null,
18020
- calculateMetadata: null,
18021
- durationInFrames,
18022
- fps,
18023
- height,
18024
- width
18025
- }
18026
- ],
18027
- canvasContent: {
18028
- type: "composition",
18029
- compositionId: "markup"
18030
- }
18031
- };
18032
18045
  const root = ReactDOM8.createRoot(div);
18046
+ const delayRenderScope = {
18047
+ remotion_renderReady: true,
18048
+ remotion_delayRenderTimeouts: {},
18049
+ remotion_puppeteerTimeout: delayRenderTimeoutInMilliseconds,
18050
+ remotion_attempt: 0
18051
+ };
18033
18052
  root.render(/* @__PURE__ */ jsx176(Internals44.RemotionEnvironmentContext, {
18034
18053
  value: {
18035
18054
  isStudio: false,
@@ -18038,54 +18057,80 @@ var renderStillOnWeb = async ({
18038
18057
  isReadOnlyStudio: false,
18039
18058
  isClientSideRendering: true
18040
18059
  },
18041
- children: /* @__PURE__ */ jsx176(Internals44.RemotionRoot, {
18042
- audioEnabled: true,
18043
- videoEnabled: true,
18044
- logLevel: "info",
18045
- numberOfAudioTags: 0,
18046
- onlyRenderComposition: null,
18047
- currentCompositionMetadata: {
18048
- props: {},
18049
- durationInFrames,
18050
- fps,
18051
- height,
18052
- width,
18053
- defaultCodec: null,
18054
- defaultOutName: null,
18055
- defaultVideoImageFormat: null,
18056
- defaultPixelFormat: null,
18057
- defaultProResProfile: null
18058
- },
18059
- audioLatencyHint: "interactive",
18060
- children: /* @__PURE__ */ jsx176(Internals44.CanUseRemotionHooks, {
18061
- value: true,
18062
- children: /* @__PURE__ */ jsx176(Internals44.CompositionManager.Provider, {
18063
- value: compositionManagerContext,
18064
- children: /* @__PURE__ */ jsx176(Component, {})
18060
+ children: /* @__PURE__ */ jsx176(Internals44.DelayRenderContextType.Provider, {
18061
+ value: delayRenderScope,
18062
+ children: /* @__PURE__ */ jsx176(Internals44.CompositionManagerProvider, {
18063
+ initialCanvasContent: {
18064
+ type: "composition",
18065
+ compositionId: COMP_ID
18066
+ },
18067
+ onlyRenderComposition: null,
18068
+ currentCompositionMetadata: {
18069
+ props: {},
18070
+ durationInFrames,
18071
+ fps,
18072
+ height,
18073
+ width,
18074
+ defaultCodec: null,
18075
+ defaultOutName: null,
18076
+ defaultVideoImageFormat: null,
18077
+ defaultPixelFormat: null,
18078
+ defaultProResProfile: null
18079
+ },
18080
+ initialCompositions: [
18081
+ {
18082
+ id: COMP_ID,
18083
+ component: Component,
18084
+ nonce: 0,
18085
+ defaultProps: undefined,
18086
+ folderName: null,
18087
+ parentFolderName: null,
18088
+ schema: null,
18089
+ calculateMetadata: null,
18090
+ durationInFrames,
18091
+ fps,
18092
+ height,
18093
+ width
18094
+ }
18095
+ ],
18096
+ children: /* @__PURE__ */ jsx176(Internals44.RemotionRoot, {
18097
+ audioEnabled: false,
18098
+ videoEnabled: true,
18099
+ logLevel,
18100
+ numberOfAudioTags: 0,
18101
+ audioLatencyHint: "interactive",
18102
+ frameState: {
18103
+ [COMP_ID]: frame2
18104
+ },
18105
+ children: /* @__PURE__ */ jsx176(Internals44.CanUseRemotionHooks, {
18106
+ value: true,
18107
+ children: /* @__PURE__ */ jsx176(Component, {})
18108
+ })
18065
18109
  })
18066
18110
  })
18067
18111
  })
18068
18112
  }));
18069
- window.remotion_setFrame(frame2, "markup", frame2);
18070
- await waitForReady(delayRenderTimeoutInMilliseconds);
18113
+ await waitForReady(delayRenderTimeoutInMilliseconds, delayRenderScope);
18071
18114
  const canvasElements = findCanvasElements(div);
18072
- const composed = compose({
18073
- composables: canvasElements,
18115
+ const svgElements = findSvgElements(div);
18116
+ const composed = await compose({
18117
+ composables: [...canvasElements, ...svgElements],
18074
18118
  width,
18075
18119
  height
18076
18120
  });
18077
18121
  const imageData = await composed.convertToBlob({
18078
18122
  type: "image/png"
18079
18123
  });
18080
- const blob = new Blob([imageData], { type: "image/png" });
18081
- const url = URL.createObjectURL(blob);
18082
- const a = document.createElement("a");
18083
- a.href = url;
18084
- a.download = "composed.png";
18085
- a.click();
18086
- URL.revokeObjectURL(url);
18087
18124
  root.unmount();
18088
18125
  div.remove();
18126
+ return imageData;
18127
+ };
18128
+ var renderStillOnWeb = (options) => {
18129
+ return internalRenderStillOnWeb({
18130
+ ...options,
18131
+ delayRenderTimeoutInMilliseconds: options.delayRenderTimeoutInMilliseconds ?? 30000,
18132
+ logLevel: options.logLevel ?? "info"
18133
+ });
18089
18134
  };
18090
18135
 
18091
18136
  // src/components/WebRender/TriggerWebRender.tsx
@@ -18112,6 +18157,13 @@ var TriggerWebRender = () => {
18112
18157
  fps: video.fps,
18113
18158
  durationInFrames: video.durationInFrames,
18114
18159
  frame: frame2
18160
+ }).then((blob) => {
18161
+ const url = URL.createObjectURL(blob);
18162
+ const a = document.createElement("a");
18163
+ a.href = url;
18164
+ a.download = "composed.png";
18165
+ a.click();
18166
+ URL.revokeObjectURL(url);
18115
18167
  });
18116
18168
  }, [video, frame2]);
18117
18169
  return /* @__PURE__ */ jsx177(Button, {
@@ -18174,7 +18226,7 @@ var padding2 = {
18174
18226
  width: TIMELINE_PADDING
18175
18227
  };
18176
18228
  var PreviewToolbar = ({ readOnlyStudio, bufferStateDelayInMilliseconds }) => {
18177
- const { playbackRate, setPlaybackRate } = useContext53(Internals46.Timeline.TimelineContext);
18229
+ const { playbackRate, setPlaybackRate } = useContext53(Internals46.TimelineContext);
18178
18230
  const { mediaMuted } = useContext53(Internals46.MediaVolumeContext);
18179
18231
  const { setMediaMuted } = useContext53(Internals46.SetMediaVolumeContext);
18180
18232
  const isVideoComposition = useIsVideoComposition();
@@ -20455,7 +20507,7 @@ import { Internals as Internals52 } from "remotion";
20455
20507
  var lastTimelinePositionWhileScrolling = null;
20456
20508
  var TimelinePlayCursorSyncer = () => {
20457
20509
  const video = Internals52.useVideo();
20458
- const timelineContext = useContext65(Internals52.Timeline.TimelineContext);
20510
+ const timelineContext = useContext65(Internals52.TimelineContext);
20459
20511
  const timelinePosition = Internals52.Timeline.useTimelinePosition();
20460
20512
  const { canvasContent } = useContext65(Internals52.CompositionManager);
20461
20513
  const { zoom: zoomMap } = useContext65(TimelineZoomCtx);
@@ -24514,8 +24566,7 @@ class IsobmffDemuxer extends Demuxer {
24514
24566
  for (let i = 0;i < sampleTable.presentationTimestamps.length; i++) {
24515
24567
  sampleTable.presentationTimestampIndexMap[sampleTable.presentationTimestamps[i].sampleIndex] = i;
24516
24568
  }
24517
- } else {
24518
- }
24569
+ } else {}
24519
24570
  return sampleTable;
24520
24571
  }
24521
24572
  async readFragment(startPos) {
@@ -24547,8 +24598,7 @@ class IsobmffDemuxer extends Demuxer {
24547
24598
  if (lastCacheIndex !== -1) {
24548
24599
  const lastCache = fragmentPositionCache[lastCacheIndex];
24549
24600
  offsetFragmentTrackDataByTimestamp(trackData, lastCache.endTimestamp);
24550
- } else {
24551
- }
24601
+ } else {}
24552
24602
  }
24553
24603
  trackData.startTimestampIsFinal = true;
24554
24604
  }
@@ -24854,13 +24904,11 @@ class IsobmffDemuxer extends Demuxer {
24854
24904
  slice.skip(4 + 4 + 4 + 2 + 32 + 2 + 2);
24855
24905
  this.readContiguousBoxes(slice.slice(slice.filePos, sampleBoxStartPos + sampleBoxInfo.totalSize - slice.filePos));
24856
24906
  } else {
24857
- if (lowercaseBoxName === "mp4a") {
24858
- } else if (lowercaseBoxName === "opus") {
24907
+ if (lowercaseBoxName === "mp4a") {} else if (lowercaseBoxName === "opus") {
24859
24908
  track.info.codec = "opus";
24860
24909
  } else if (lowercaseBoxName === "flac") {
24861
24910
  track.info.codec = "flac";
24862
- } else if (lowercaseBoxName === "twos" || lowercaseBoxName === "sowt" || lowercaseBoxName === "raw " || lowercaseBoxName === "in24" || lowercaseBoxName === "in32" || lowercaseBoxName === "fl32" || lowercaseBoxName === "fl64" || lowercaseBoxName === "lpcm" || lowercaseBoxName === "ipcm" || lowercaseBoxName === "fpcm") {
24863
- } else if (lowercaseBoxName === "ulaw") {
24911
+ } else if (lowercaseBoxName === "twos" || lowercaseBoxName === "sowt" || lowercaseBoxName === "raw " || lowercaseBoxName === "in24" || lowercaseBoxName === "in32" || lowercaseBoxName === "fl32" || lowercaseBoxName === "fl64" || lowercaseBoxName === "lpcm" || lowercaseBoxName === "ipcm" || lowercaseBoxName === "fpcm") {} else if (lowercaseBoxName === "ulaw") {
24864
24912
  track.info.codec = "ulaw";
24865
24913
  } else if (lowercaseBoxName === "alaw") {
24866
24914
  track.info.codec = "alaw";
@@ -26996,8 +27044,7 @@ class MatroskaDemuxer extends Demuxer {
26996
27044
  if (!segment.metadataTagsCollected) {
26997
27045
  if (this.reader.fileSize !== null) {
26998
27046
  await this.loadSegmentMetadata(segment);
26999
- } else {
27000
- }
27047
+ } else {}
27001
27048
  segment.metadataTagsCollected = true;
27002
27049
  }
27003
27050
  }
@@ -27264,8 +27311,7 @@ class MatroskaDemuxer extends Demuxer {
27264
27311
  if (track.defaultDuration != null) {
27265
27312
  if (currentBlock.lacing === BlockLacing.None) {
27266
27313
  currentBlock.duration = track.defaultDuration;
27267
- } else {
27268
- }
27314
+ } else {}
27269
27315
  }
27270
27316
  }
27271
27317
  }
@@ -27401,9 +27447,7 @@ class MatroskaDemuxer extends Demuxer {
27401
27447
  }
27402
27448
  async loadSegmentMetadata(segment) {
27403
27449
  for (const seekEntry of segment.seekEntries) {
27404
- if (seekEntry.id === EBMLId.Tags && !segment.tagsSeen) {
27405
- } else if (seekEntry.id === EBMLId.Attachments && !segment.attachmentsSeen) {
27406
- } else {
27450
+ if (seekEntry.id === EBMLId.Tags && !segment.tagsSeen) {} else if (seekEntry.id === EBMLId.Attachments && !segment.attachmentsSeen) {} else {
27407
27451
  continue;
27408
27452
  }
27409
27453
  let slice = this.reader.requestSliceRange(segment.dataStartPos + seekEntry.segmentPosition, MIN_HEADER_SIZE, MAX_HEADER_SIZE);
@@ -27826,8 +27870,7 @@ class MatroskaDemuxer extends Demuxer {
27826
27870
  const flippedRotation = -rotation;
27827
27871
  try {
27828
27872
  this.currentTrack.info.rotation = normalizeRotation(flippedRotation);
27829
- } catch {
27830
- }
27873
+ } catch {}
27831
27874
  }
27832
27875
  ;
27833
27876
  break;
@@ -28297,16 +28340,14 @@ class MatroskaDemuxer extends Demuxer {
28297
28340
  ;
28298
28341
  break;
28299
28342
  default:
28300
- {
28301
- }
28343
+ {}
28302
28344
  ;
28303
28345
  }
28304
28346
  }
28305
28347
  ;
28306
28348
  break;
28307
28349
  default:
28308
- {
28309
- }
28350
+ {}
28310
28351
  ;
28311
28352
  }
28312
28353
  }
@@ -31821,6 +31862,12 @@ class FlacDemuxer extends Demuxer {
31821
31862
  slice.skip(-1);
31822
31863
  continue;
31823
31864
  }
31865
+ if (nextIsLegit.num - frameHeader.num !== 1) {
31866
+ console.log("skipping", nextIsLegit.num, frameHeader.num);
31867
+ slice.skip(-1);
31868
+ continue;
31869
+ }
31870
+ console.log(frameHeader.num, nextIsLegit.num, slice.filePos);
31824
31871
  return {
31825
31872
  num: frameHeader.num,
31826
31873
  blockSize: frameHeader.blockSize,
@@ -32409,8 +32456,7 @@ var DEFAULT_RETRY_DELAY = (previousAttempts, error, src) => {
32409
32456
  if (typeof window !== "undefined" && typeof window.location !== "undefined") {
32410
32457
  originOfSrc = new URL(src instanceof Request ? src.url : src, window.location.href).origin;
32411
32458
  }
32412
- } catch {
32413
- }
32459
+ } catch {}
32414
32460
  const isOnline = typeof navigator !== "undefined" && typeof navigator.onLine === "boolean" ? navigator.onLine : true;
32415
32461
  if (isOnline && originOfSrc !== null && originOfSrc !== window.location.origin) {
32416
32462
  return null;
@@ -32487,7 +32533,7 @@ class UrlSource extends Source {
32487
32533
  return this._orchestrator.read(start, end);
32488
32534
  }
32489
32535
  async _runWorker(worker) {
32490
- while (true) {
32536
+ while (!worker.aborted) {
32491
32537
  const existing = this._existingResponses.get(worker);
32492
32538
  this._existingResponses.delete(worker);
32493
32539
  let abortController = existing?.abortController;
@@ -32536,9 +32582,6 @@ class UrlSource extends Source {
32536
32582
  throw error;
32537
32583
  }
32538
32584
  }
32539
- if (worker.aborted) {
32540
- break;
32541
- }
32542
32585
  const { done, value } = readResult;
32543
32586
  if (done) {
32544
32587
  this._orchestrator.forgetWorker(worker);
@@ -32551,9 +32594,6 @@ class UrlSource extends Source {
32551
32594
  this.onread?.(worker.currentPos, worker.currentPos + value.length);
32552
32595
  this._orchestrator.supplyWorkerData(worker, value);
32553
32596
  }
32554
- if (worker.aborted) {
32555
- break;
32556
- }
32557
32597
  }
32558
32598
  worker.running = false;
32559
32599
  }
@@ -32736,8 +32776,7 @@ class ReadOrchestrator {
32736
32776
  view: toDataView(bytes2),
32737
32777
  offset: innerStart
32738
32778
  }));
32739
- } else {
32740
- }
32779
+ } else {}
32741
32780
  return result;
32742
32781
  }
32743
32782
  createWorker(startPos, targetPos) {
@@ -32746,7 +32785,7 @@ class ReadOrchestrator {
32746
32785
  currentPos: startPos,
32747
32786
  targetPos,
32748
32787
  running: false,
32749
- aborted: this.disposed,
32788
+ aborted: false,
32750
32789
  pendingSlices: [],
32751
32790
  age: this.nextAge++
32752
32791
  };
@@ -32785,7 +32824,9 @@ class ReadOrchestrator {
32785
32824
  });
32786
32825
  }
32787
32826
  supplyWorkerData(worker, bytes) {
32788
- assert(!worker.aborted);
32827
+ if (this.disposed) {
32828
+ return;
32829
+ }
32789
32830
  const start = worker.currentPos;
32790
32831
  const end = start + bytes.length;
32791
32832
  this.insertIntoCache({
@@ -33280,8 +33321,7 @@ var useMaxMediaDuration = (s, fps) => {
33280
33321
  const durationOrInfinity = metadata.durationInSeconds ?? Infinity;
33281
33322
  cache.set(src, Math.floor(durationOrInfinity * fps));
33282
33323
  setMaxMediaDuration(Math.floor(durationOrInfinity * fps));
33283
- }).catch(() => {
33284
- });
33324
+ }).catch(() => {});
33285
33325
  });
33286
33326
  return () => {
33287
33327
  input2.dispose();
@@ -33573,7 +33613,7 @@ import { useVideoConfig as useVideoConfig5 } from "remotion";
33573
33613
  async function extractFrames({
33574
33614
  src,
33575
33615
  timestampsInSeconds,
33576
- onFrame,
33616
+ onVideoSample,
33577
33617
  signal
33578
33618
  }) {
33579
33619
  const input2 = new Input({
@@ -33614,8 +33654,7 @@ async function extractFrames({
33614
33654
  if (!videoSample) {
33615
33655
  continue;
33616
33656
  }
33617
- const videoFrame = videoSample.toVideoFrame();
33618
- onFrame(videoFrame);
33657
+ onVideoSample(videoSample);
33619
33658
  }
33620
33659
  } catch (error) {
33621
33660
  if (error instanceof InputDisposedError) {
@@ -33631,11 +33670,15 @@ async function extractFrames({
33631
33670
  }
33632
33671
 
33633
33672
  // src/helpers/frame-database.ts
33634
- var makeFrameDatabaseKey = (src, timestamp) => `${src}|${timestamp}`;
33673
+ var KEY_SEPARATOR = "|";
33674
+ var makeFrameDatabaseKey = (src, timestamp) => `${src}${KEY_SEPARATOR}${timestamp}`;
33675
+ var getFrameDatabaseKeyPrefix = (src) => {
33676
+ return `${src}${KEY_SEPARATOR}`;
33677
+ };
33635
33678
  var frameDatabase = new Map;
33636
33679
  var aspectRatioCache = new Map;
33637
33680
  var getTimestampFromFrameDatabaseKey = (key4) => {
33638
- const split = key4.split("|");
33681
+ const split = key4.split(KEY_SEPARATOR);
33639
33682
  return Number(split[split.length - 1]);
33640
33683
  };
33641
33684
  var getAspectRatioFromCache = (src) => {
@@ -33656,6 +33699,19 @@ var clearOldFrames = () => {
33656
33699
  frameDatabase.delete(key4);
33657
33700
  }
33658
33701
  };
33702
+ var clearFramesForSrc = (src) => {
33703
+ const keysToRemove = [];
33704
+ const prefix = getFrameDatabaseKeyPrefix(src);
33705
+ for (const [key4, frame2] of frameDatabase.entries()) {
33706
+ if (key4.startsWith(prefix)) {
33707
+ frame2.frame.close();
33708
+ keysToRemove.push(key4);
33709
+ }
33710
+ }
33711
+ for (const key4 of keysToRemove) {
33712
+ frameDatabase.delete(key4);
33713
+ }
33714
+ };
33659
33715
 
33660
33716
  // src/helpers/resize-video-frame.ts
33661
33717
  var calculateNewDimensionsFromScale = ({
@@ -33797,7 +33853,8 @@ var fillWithCachedFrames = ({
33797
33853
  segmentDuration,
33798
33854
  fromSeconds
33799
33855
  }) => {
33800
- const keys = Array.from(frameDatabase.keys()).filter((k) => k.startsWith(src));
33856
+ const prefix = getFrameDatabaseKeyPrefix(src);
33857
+ const keys = Array.from(frameDatabase.keys()).filter((k) => k.startsWith(prefix));
33801
33858
  const targets = Array.from(filledSlots.keys());
33802
33859
  for (const timestamp of targets) {
33803
33860
  let bestKey;
@@ -33866,6 +33923,11 @@ var TimelineVideoInfo = ({ src, visualizationWidth, startFrom, durationInFrames
33866
33923
  const ref = useRef37(null);
33867
33924
  const [error, setError] = useState67(null);
33868
33925
  const aspectRatio = useRef37(getAspectRatioFromCache(src));
33926
+ useEffect67(() => {
33927
+ return () => {
33928
+ clearFramesForSrc(src);
33929
+ };
33930
+ }, [src]);
33869
33931
  useEffect67(() => {
33870
33932
  if (error) {
33871
33933
  return;
@@ -33927,7 +33989,8 @@ var TimelineVideoInfo = ({ src, visualizationWidth, startFrom, durationInFrames
33927
33989
  return Array.from(filledSlots.keys()).map((timestamp) => timestamp / WEBCODECS_TIMESCALE);
33928
33990
  },
33929
33991
  src,
33930
- onFrame: (frame2) => {
33992
+ onVideoSample: (sample) => {
33993
+ const frame2 = sample.toVideoFrame();
33931
33994
  const scale = HEIGHT / frame2.displayHeight * window.devicePixelRatio;
33932
33995
  const transformed = resizeVideoFrame({
33933
33996
  frame: frame2,
@@ -42411,23 +42474,28 @@ var Studio = ({ rootComponent, readOnly }) => {
42411
42474
  useLayoutEffect2(() => {
42412
42475
  injectCSS();
42413
42476
  }, []);
42414
- return /* @__PURE__ */ jsx274(Internals67.RemotionRoot, {
42415
- audioEnabled: window.remotion_audioEnabled,
42416
- videoEnabled: window.remotion_videoEnabled,
42417
- logLevel: window.remotion_logLevel,
42418
- numberOfAudioTags: window.remotion_numberOfAudioTags,
42477
+ return /* @__PURE__ */ jsx274(Internals67.CompositionManagerProvider, {
42419
42478
  onlyRenderComposition: null,
42420
42479
  currentCompositionMetadata: null,
42421
- audioLatencyHint: window.remotion_audioLatencyHint ?? "interactive",
42422
- children: /* @__PURE__ */ jsxs141(EditorContexts, {
42423
- readOnlyStudio: readOnly,
42424
- children: [
42425
- /* @__PURE__ */ jsx274(Editor, {
42426
- readOnlyStudio: readOnly,
42427
- Root: rootComponent
42428
- }),
42429
- readOnly ? null : createPortal(/* @__PURE__ */ jsx274(ServerDisconnected, {}), getServerDisconnectedDomElement())
42430
- ]
42480
+ initialCompositions: [],
42481
+ initialCanvasContent: null,
42482
+ children: /* @__PURE__ */ jsx274(Internals67.RemotionRoot, {
42483
+ frameState: null,
42484
+ audioEnabled: window.remotion_audioEnabled,
42485
+ videoEnabled: window.remotion_videoEnabled,
42486
+ logLevel: window.remotion_logLevel,
42487
+ numberOfAudioTags: window.remotion_numberOfAudioTags,
42488
+ audioLatencyHint: window.remotion_audioLatencyHint ?? "interactive",
42489
+ children: /* @__PURE__ */ jsxs141(EditorContexts, {
42490
+ readOnlyStudio: readOnly,
42491
+ children: [
42492
+ /* @__PURE__ */ jsx274(Editor, {
42493
+ readOnlyStudio: readOnly,
42494
+ Root: rootComponent
42495
+ }),
42496
+ readOnly ? null : createPortal(/* @__PURE__ */ jsx274(ServerDisconnected, {}), getServerDisconnectedDomElement())
42497
+ ]
42498
+ })
42431
42499
  })
42432
42500
  });
42433
42501
  };