remotion 4.0.341 → 4.0.342

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 (35) hide show
  1. package/dist/cjs/Artifact.js +2 -2
  2. package/dist/cjs/Composition.d.ts +1 -0
  3. package/dist/cjs/Composition.js +2 -2
  4. package/dist/cjs/ResolveCompositionConfig.js +13 -6
  5. package/dist/cjs/Sequence.js +6 -3
  6. package/dist/cjs/audio/Audio.js +2 -2
  7. package/dist/cjs/audio/shared-audio-tags.js +4 -1
  8. package/dist/cjs/delay-render.d.ts +12 -0
  9. package/dist/cjs/delay-render.js +28 -11
  10. package/dist/cjs/get-cross-origin-value.js +1 -1
  11. package/dist/cjs/get-remotion-environment.js +2 -1
  12. package/dist/cjs/index.d.ts +4 -0
  13. package/dist/cjs/index.js +5 -1
  14. package/dist/cjs/play-and-handle-not-allowed-error.d.ts +2 -1
  15. package/dist/cjs/play-and-handle-not-allowed-error.js +2 -3
  16. package/dist/cjs/resolve-video-config.js +2 -0
  17. package/dist/cjs/timeline-position-state.js +3 -4
  18. package/dist/cjs/use-current-frame.js +3 -2
  19. package/dist/cjs/use-current-scale.js +3 -2
  20. package/dist/cjs/use-delay-render.d.ts +8 -0
  21. package/dist/cjs/use-delay-render.js +17 -0
  22. package/dist/cjs/use-media-in-timeline.js +6 -3
  23. package/dist/cjs/use-media-playback.js +5 -0
  24. package/dist/cjs/use-remotion-environment.d.ts +6 -0
  25. package/dist/cjs/use-remotion-environment.js +14 -0
  26. package/dist/cjs/version.d.ts +1 -1
  27. package/dist/cjs/version.js +1 -1
  28. package/dist/cjs/video/OffthreadVideo.js +2 -2
  29. package/dist/cjs/video/Video.js +2 -2
  30. package/dist/cjs/video/VideoForRendering.js +2 -2
  31. package/dist/esm/index.mjs +142 -89
  32. package/dist/esm/version.mjs +1 -1
  33. package/package.json +2 -2
  34. package/dist/cjs/video/use-audio-channel-index.d.ts +0 -4
  35. package/dist/cjs/video/use-audio-channel-index.js +0 -13
@@ -104,7 +104,7 @@ function truthy(value) {
104
104
  }
105
105
 
106
106
  // src/version.ts
107
- var VERSION = "4.0.341";
107
+ var VERSION = "4.0.342";
108
108
 
109
109
  // src/multiple-versions-warning.ts
110
110
  var checkMultipleRemotionVersions = () => {
@@ -146,7 +146,7 @@ import {
146
146
  useContext as useContext10,
147
147
  useEffect as useEffect3,
148
148
  useMemo as useMemo9,
149
- useState as useState4
149
+ useState as useState5
150
150
  } from "react";
151
151
 
152
152
  // src/AbsoluteFill.tsx
@@ -338,6 +338,13 @@ __export(exports_timeline_position_state, {
338
338
  });
339
339
  import { createContext as createContext8, useContext as useContext5, useMemo as useMemo6 } from "react";
340
340
 
341
+ // src/use-remotion-environment.ts
342
+ import { useState as useState3 } from "react";
343
+ var useRemotionEnvironment = () => {
344
+ const [env] = useState3(() => getRemotionEnvironment());
345
+ return env;
346
+ };
347
+
341
348
  // src/use-video.ts
342
349
  import { useContext as useContext4, useMemo as useMemo5 } from "react";
343
350
 
@@ -380,7 +387,7 @@ import {
380
387
  useEffect as useEffect2,
381
388
  useImperativeHandle as useImperativeHandle2,
382
389
  useMemo as useMemo4,
383
- useState as useState3
390
+ useState as useState4
384
391
  } from "react";
385
392
 
386
393
  // src/EditorProps.tsx
@@ -670,7 +677,8 @@ var resolveVideoConfig = ({
670
677
  defaultProps,
671
678
  props: originalProps,
672
679
  abortSignal: signal,
673
- compositionId
680
+ compositionId,
681
+ isRendering: getRemotionEnvironment().isRendering
674
682
  }) : null;
675
683
  if (calculatedProm !== null && typeof calculatedProm === "object" && "then" in calculatedProm) {
676
684
  return calculatedProm.then((c) => {
@@ -761,7 +769,7 @@ var needsResolution = (composition) => {
761
769
  };
762
770
  var PROPS_UPDATED_EXTERNALLY = "remotion.propsUpdatedExternally";
763
771
  var ResolveCompositionConfig = ({ children }) => {
764
- const [currentRenderModalComposition, setCurrentRenderModalComposition] = useState3(null);
772
+ const [currentRenderModalComposition, setCurrentRenderModalComposition] = useState4(null);
765
773
  const { compositions, canvasContent, currentCompositionMetadata } = useContext3(CompositionManager);
766
774
  const { fastRefreshes, manualRefreshes } = useContext3(NonceContext);
767
775
  if (manualRefreshes) {}
@@ -770,10 +778,11 @@ var ResolveCompositionConfig = ({ children }) => {
770
778
  }, [canvasContent, compositions]);
771
779
  const renderModalComposition = compositions.find((c) => c.id === currentRenderModalComposition);
772
780
  const { props: allEditorProps } = useContext3(EditorPropsContext);
781
+ const env = useRemotionEnvironment();
773
782
  const inputProps = useMemo4(() => {
774
- return typeof window === "undefined" || getRemotionEnvironment().isPlayer ? {} : getInputProps() ?? {};
775
- }, []);
776
- const [resolvedConfigs, setResolvedConfigs] = useState3({});
783
+ return typeof window === "undefined" || env.isPlayer ? {} : getInputProps() ?? {};
784
+ }, [env.isPlayer]);
785
+ const [resolvedConfigs, setResolvedConfigs] = useState4({});
777
786
  const selectedEditorProps = useMemo4(() => {
778
787
  return selectedComposition ? allEditorProps[selectedComposition.id] ?? {} : {};
779
788
  }, [allEditorProps, selectedComposition]);
@@ -1021,6 +1030,7 @@ var useResolvedVideoConfig = (preferredCompositionId) => {
1021
1030
  const selectedEditorProps = useMemo4(() => {
1022
1031
  return composition ? allEditorProps[composition.id] ?? {} : {};
1023
1032
  }, [allEditorProps, composition]);
1033
+ const env = useRemotionEnvironment();
1024
1034
  return useMemo4(() => {
1025
1035
  if (!composition) {
1026
1036
  return null;
@@ -1055,7 +1065,7 @@ var useResolvedVideoConfig = (preferredCompositionId) => {
1055
1065
  props: {
1056
1066
  ...composition.defaultProps ?? {},
1057
1067
  ...selectedEditorProps ?? {},
1058
- ...typeof window === "undefined" || getRemotionEnvironment().isPlayer ? {} : getInputProps() ?? {}
1068
+ ...typeof window === "undefined" || env.isPlayer ? {} : getInputProps() ?? {}
1059
1069
  },
1060
1070
  defaultCodec: null,
1061
1071
  defaultOutName: null,
@@ -1068,7 +1078,13 @@ var useResolvedVideoConfig = (preferredCompositionId) => {
1068
1078
  return null;
1069
1079
  }
1070
1080
  return context[composition.id];
1071
- }, [composition, context, currentCompositionMetadata, selectedEditorProps]);
1081
+ }, [
1082
+ composition,
1083
+ context,
1084
+ currentCompositionMetadata,
1085
+ selectedEditorProps,
1086
+ env.isPlayer
1087
+ ]);
1072
1088
  };
1073
1089
 
1074
1090
  // src/use-video.ts
@@ -1148,10 +1164,11 @@ var getFrameForComposition = (composition) => {
1148
1164
  var useTimelinePosition = () => {
1149
1165
  const videoConfig = useVideo();
1150
1166
  const state = useContext5(TimelineContext);
1167
+ const env = useRemotionEnvironment();
1151
1168
  if (!videoConfig) {
1152
1169
  return typeof window === "undefined" ? 0 : window.remotion_initialFrame ?? 0;
1153
1170
  }
1154
- const unclamped = state.frame[videoConfig.id] ?? (getRemotionEnvironment().isPlayer ? 0 : getFrameForComposition(videoConfig.id));
1171
+ const unclamped = state.frame[videoConfig.id] ?? (env.isPlayer ? 0 : getFrameForComposition(videoConfig.id));
1155
1172
  return Math.min(videoConfig.durationInFrames - 1, unclamped);
1156
1173
  };
1157
1174
  var useTimelineSetFrame = () => {
@@ -1247,8 +1264,9 @@ import { useContext as useContext9, useMemo as useMemo8 } from "react";
1247
1264
  import { useContext as useContext8 } from "react";
1248
1265
  var useCurrentFrame = () => {
1249
1266
  const canUseRemotionHooks = useContext8(CanUseRemotionHooks);
1267
+ const env = useRemotionEnvironment();
1250
1268
  if (!canUseRemotionHooks) {
1251
- if (getRemotionEnvironment().isPlayer) {
1269
+ if (env.isPlayer) {
1252
1270
  throw new Error(`useCurrentFrame can only be called inside a component that was passed to <Player>. See: https://www.remotion.dev/docs/player/examples`);
1253
1271
  }
1254
1272
  throw new Error(`useCurrentFrame() can only be called inside a component that was registered as a composition. See https://www.remotion.dev/docs/the-fundamentals#defining-compositions`);
@@ -1329,7 +1347,7 @@ var RegularSequenceRefForwardingFunction = ({
1329
1347
  ...other
1330
1348
  }, ref) => {
1331
1349
  const { layout = "absolute-fill" } = other;
1332
- const [id] = useState4(() => String(Math.random()));
1350
+ const [id] = useState5(() => String(Math.random()));
1333
1351
  const parentSequence = useContext10(SequenceContext);
1334
1352
  const { rootId } = useContext10(TimelineContext);
1335
1353
  const cumulatedFrom = parentSequence ? parentSequence.cumulatedFrom + parentSequence.relativeFrom : 0;
@@ -1390,8 +1408,9 @@ var RegularSequenceRefForwardingFunction = ({
1390
1408
  const timelineClipName = useMemo9(() => {
1391
1409
  return name ?? "";
1392
1410
  }, [name]);
1411
+ const env = useRemotionEnvironment();
1393
1412
  useEffect3(() => {
1394
- if (!getRemotionEnvironment().isStudio) {
1413
+ if (!env.isStudio) {
1395
1414
  return;
1396
1415
  }
1397
1416
  registerSequence({
@@ -1428,7 +1447,8 @@ var RegularSequenceRefForwardingFunction = ({
1428
1447
  loopDisplay,
1429
1448
  stack,
1430
1449
  premountDisplay,
1431
- postmountDisplay
1450
+ postmountDisplay,
1451
+ env.isStudio
1432
1452
  ]);
1433
1453
  const endThreshold = Math.ceil(cumulatedFrom + from + durationInFrames - 1);
1434
1454
  const content = absoluteFrame < cumulatedFrom + from ? null : absoluteFrame > endThreshold ? null : children;
@@ -1512,7 +1532,8 @@ var PremountedPostmountedSequenceRefForwardingFunction = (props, ref) => {
1512
1532
  };
1513
1533
  var PremountedPostmountedSequence = forwardRef2(PremountedPostmountedSequenceRefForwardingFunction);
1514
1534
  var SequenceRefForwardingFunction = (props, ref) => {
1515
- if (props.layout !== "none" && !getRemotionEnvironment().isRendering) {
1535
+ const env = useRemotionEnvironment();
1536
+ if (props.layout !== "none" && !env.isRendering) {
1516
1537
  if (props.premountFor || props.postmountFor) {
1517
1538
  return /* @__PURE__ */ jsx8(PremountedPostmountedSequence, {
1518
1539
  ...props,
@@ -1533,7 +1554,7 @@ import {
1533
1554
  useImperativeHandle as useImperativeHandle4,
1534
1555
  useLayoutEffect,
1535
1556
  useRef as useRef3,
1536
- useState as useState5
1557
+ useState as useState6
1537
1558
  } from "react";
1538
1559
 
1539
1560
  // src/cancel-render.ts
@@ -1624,14 +1645,14 @@ var DELAY_RENDER_RETRIES_LEFT = "Retries left: ";
1624
1645
  var DELAY_RENDER_RETRY_TOKEN = "- Rendering the frame will be retried.";
1625
1646
  var DELAY_RENDER_CLEAR_TOKEN = "handle was cleared after";
1626
1647
  var defaultTimeout = 30000;
1627
- var delayRender = (label, options) => {
1648
+ var delayRenderInternal = (environment, label, options) => {
1628
1649
  if (typeof label !== "string" && typeof label !== "undefined") {
1629
1650
  throw new Error("The label parameter of delayRender() must be a string or undefined, got: " + JSON.stringify(label));
1630
1651
  }
1631
1652
  const handle = Math.random();
1632
1653
  handles.push(handle);
1633
1654
  const called = Error().stack?.replace(/^Error/g, "") ?? "";
1634
- if (getRemotionEnvironment().isRendering) {
1655
+ if (environment.isRendering) {
1635
1656
  const timeoutToUse = (options?.timeoutInMilliseconds ?? (typeof window === "undefined" ? defaultTimeout : window.remotion_puppeteerTimeout ?? defaultTimeout)) - 2000;
1636
1657
  if (typeof window !== "undefined") {
1637
1658
  const retriesLeft = (options?.retries ?? 0) - (window.remotion_attempt - 1);
@@ -1658,7 +1679,10 @@ var delayRender = (label, options) => {
1658
1679
  }
1659
1680
  return handle;
1660
1681
  };
1661
- var continueRender = (handle) => {
1682
+ var delayRender = (label, options) => {
1683
+ return delayRenderInternal(getRemotionEnvironment(), label, options);
1684
+ };
1685
+ var continueRenderInternal = (handle, environment) => {
1662
1686
  if (typeof handle === "undefined") {
1663
1687
  throw new TypeError("The continueRender() method must be called with a parameter that is the return value of delayRender(). No value was passed.");
1664
1688
  }
@@ -1667,7 +1691,7 @@ var continueRender = (handle) => {
1667
1691
  }
1668
1692
  handles = handles.filter((h) => {
1669
1693
  if (h === handle) {
1670
- if (getRemotionEnvironment().isRendering) {
1694
+ if (environment.isRendering) {
1671
1695
  if (!window.remotion_delayRenderTimeouts[handle]) {
1672
1696
  return false;
1673
1697
  }
@@ -1689,6 +1713,9 @@ var continueRender = (handle) => {
1689
1713
  window.remotion_renderReady = true;
1690
1714
  }
1691
1715
  };
1716
+ var continueRender = (handle) => {
1717
+ continueRenderInternal(handle, getRemotionEnvironment());
1718
+ };
1692
1719
 
1693
1720
  // src/animated-image/canvas.tsx
1694
1721
  import React8, { useCallback as useCallback4, useImperativeHandle as useImperativeHandle3, useRef as useRef2 } from "react";
@@ -1961,8 +1988,8 @@ var AnimatedImage = forwardRef3(({
1961
1988
  };
1962
1989
  }, []);
1963
1990
  const resolvedSrc = resolveAnimatedImageSource(src);
1964
- const [imageDecoder, setImageDecoder] = useState5(null);
1965
- const [decodeHandle] = useState5(() => delayRender(`Rendering <AnimatedImage/> with src="${resolvedSrc}"`));
1991
+ const [imageDecoder, setImageDecoder] = useState6(null);
1992
+ const [decodeHandle] = useState6(() => delayRender(`Rendering <AnimatedImage/> with src="${resolvedSrc}"`));
1966
1993
  const frame = useCurrentFrame();
1967
1994
  const { fps } = useVideoConfig();
1968
1995
  const currentTime = frame / playbackRate / fps;
@@ -1976,7 +2003,7 @@ var AnimatedImage = forwardRef3(({
1976
2003
  }
1977
2004
  return c;
1978
2005
  }, []);
1979
- const [initialLoopBehavior] = useState5(() => loopBehavior);
2006
+ const [initialLoopBehavior] = useState6(() => loopBehavior);
1980
2007
  useEffect4(() => {
1981
2008
  const controller = new AbortController;
1982
2009
  decodeImage({
@@ -2035,7 +2062,7 @@ var AnimatedImage = forwardRef3(({
2035
2062
  });
2036
2063
  });
2037
2064
  // src/Artifact.tsx
2038
- import { useContext as useContext11, useEffect as useEffect5, useState as useState7 } from "react";
2065
+ import { useContext as useContext11, useEffect as useEffect5, useState as useState8 } from "react";
2039
2066
 
2040
2067
  // src/RenderAssetManager.tsx
2041
2068
  import {
@@ -2043,7 +2070,7 @@ import {
2043
2070
  useCallback as useCallback5,
2044
2071
  useLayoutEffect as useLayoutEffect2,
2045
2072
  useMemo as useMemo10,
2046
- useState as useState6
2073
+ useState as useState7
2047
2074
  } from "react";
2048
2075
 
2049
2076
  // src/validation/validate-artifact.ts
@@ -2089,7 +2116,7 @@ var RenderAssetManager = createContext10({
2089
2116
  renderAssets: []
2090
2117
  });
2091
2118
  var RenderAssetManagerProvider = ({ children }) => {
2092
- const [renderAssets, setRenderAssets] = useState6([]);
2119
+ const [renderAssets, setRenderAssets] = useState7([]);
2093
2120
  const registerRenderAsset = useCallback5((renderAsset) => {
2094
2121
  validateRenderAsset(renderAsset);
2095
2122
  setRenderAssets((assets) => {
@@ -2126,9 +2153,9 @@ var RenderAssetManagerProvider = ({ children }) => {
2126
2153
  var ArtifactThumbnail = Symbol("Thumbnail");
2127
2154
  var Artifact = ({ filename, content, downloadBehavior }) => {
2128
2155
  const { registerRenderAsset, unregisterRenderAsset } = useContext11(RenderAssetManager);
2129
- const [env] = useState7(() => getRemotionEnvironment());
2156
+ const env = useRemotionEnvironment();
2130
2157
  const frame = useCurrentFrame();
2131
- const [id] = useState7(() => {
2158
+ const [id] = useState8(() => {
2132
2159
  return String(Math.random());
2133
2160
  });
2134
2161
  useEffect5(() => {
@@ -2286,7 +2313,7 @@ var playbackLogging = ({
2286
2313
  };
2287
2314
 
2288
2315
  // src/prefetch-state.tsx
2289
- import { createContext as createContext12, useEffect as useEffect6, useState as useState8 } from "react";
2316
+ import { createContext as createContext12, useEffect as useEffect6, useState as useState9 } from "react";
2290
2317
  import { jsx as jsx13 } from "react/jsx-runtime";
2291
2318
  var PreloadContext = createContext12({});
2292
2319
  var preloads = {};
@@ -2296,7 +2323,7 @@ var setPreloads = (updater) => {
2296
2323
  updaters.forEach((u) => u());
2297
2324
  };
2298
2325
  var PrefetchProvider = ({ children }) => {
2299
- const [_preloads, _setPreloads] = useState8(() => preloads);
2326
+ const [_preloads, _setPreloads] = useState9(() => preloads);
2300
2327
  useEffect6(() => {
2301
2328
  const updaterFunction = () => {
2302
2329
  _setPreloads(preloads);
@@ -2647,7 +2674,7 @@ import {
2647
2674
  useImperativeHandle as useImperativeHandle5,
2648
2675
  useMemo as useMemo20,
2649
2676
  useRef as useRef11,
2650
- useState as useState13
2677
+ useState as useState14
2651
2678
  } from "react";
2652
2679
 
2653
2680
  // src/get-cross-origin-value.ts
@@ -2732,7 +2759,7 @@ import React13, {
2732
2759
  useEffect as useEffect7,
2733
2760
  useMemo as useMemo14,
2734
2761
  useRef as useRef4,
2735
- useState as useState9
2762
+ useState as useState10
2736
2763
  } from "react";
2737
2764
 
2738
2765
  // src/play-and-handle-not-allowed-error.ts
@@ -2742,7 +2769,8 @@ var playAndHandleNotAllowedError = ({
2742
2769
  onAutoPlayError,
2743
2770
  logLevel,
2744
2771
  mountTime,
2745
- reason
2772
+ reason,
2773
+ isPlayer
2746
2774
  }) => {
2747
2775
  const { current } = mediaRef;
2748
2776
  if (!current) {
@@ -2787,7 +2815,7 @@ var playAndHandleNotAllowedError = ({
2787
2815
  return;
2788
2816
  }
2789
2817
  console.log(`The video will be muted and we'll retry playing it.`);
2790
- if (mediaType === "video" && getRemotionEnvironment().isPlayer) {
2818
+ if (mediaType === "video" && isPlayer) {
2791
2819
  console.log("Use onAutoPlayError() to handle this error yourself.");
2792
2820
  }
2793
2821
  current.muted = true;
@@ -2874,7 +2902,7 @@ var didPropChange = (key, newProp, prevProp) => {
2874
2902
  var SharedAudioContext = createContext15(null);
2875
2903
  var SharedAudioContextProvider = ({ children, numberOfAudioTags, component, audioLatencyHint }) => {
2876
2904
  const audios = useRef4([]);
2877
- const [initialNumberOfAudioTags] = useState9(numberOfAudioTags);
2905
+ const [initialNumberOfAudioTags] = useState10(numberOfAudioTags);
2878
2906
  if (numberOfAudioTags !== initialNumberOfAudioTags) {
2879
2907
  throw new Error("The number of shared audio tags has changed dynamically. Once you have set this property, you cannot change it afterwards.");
2880
2908
  }
@@ -2980,6 +3008,7 @@ var SharedAudioContextProvider = ({ children, numberOfAudioTags, component, audi
2980
3008
  }
2981
3009
  }, [rerenderAudios]);
2982
3010
  const mountTime = useMountTime();
3011
+ const env = useRemotionEnvironment();
2983
3012
  const playAllAudios = useCallback6(() => {
2984
3013
  refs.forEach((ref) => {
2985
3014
  const audio = audios.current.find((a) => a.el === ref.ref);
@@ -2992,11 +3021,12 @@ var SharedAudioContextProvider = ({ children, numberOfAudioTags, component, audi
2992
3021
  onAutoPlayError: null,
2993
3022
  logLevel,
2994
3023
  mountTime,
2995
- reason: "playing all audios"
3024
+ reason: "playing all audios",
3025
+ isPlayer: env.isPlayer
2996
3026
  });
2997
3027
  });
2998
3028
  audioContext?.resume();
2999
- }, [audioContext, logLevel, mountTime, refs]);
3029
+ }, [audioContext, logLevel, mountTime, refs, env.isPlayer]);
3000
3030
  const value = useMemo14(() => {
3001
3031
  return {
3002
3032
  registerAudio,
@@ -3044,7 +3074,7 @@ var useSharedAudio = ({
3044
3074
  premounting
3045
3075
  }) => {
3046
3076
  const ctx = useContext14(SharedAudioContext);
3047
- const [elem] = useState9(() => {
3077
+ const [elem] = useState10(() => {
3048
3078
  if (ctx && ctx.numberOfAudioTags > 0) {
3049
3079
  return ctx.registerAudio({ aud, audioId, premounting });
3050
3080
  }
@@ -3274,7 +3304,7 @@ var useVolume = ({
3274
3304
  };
3275
3305
 
3276
3306
  // src/use-media-in-timeline.ts
3277
- import { useContext as useContext17, useEffect as useEffect8, useMemo as useMemo15, useState as useState10 } from "react";
3307
+ import { useContext as useContext17, useEffect as useEffect8, useMemo as useMemo15, useState as useState11 } from "react";
3278
3308
 
3279
3309
  // src/audio/use-audio-frame.ts
3280
3310
  import { useContext as useContext16 } from "react";
@@ -3360,7 +3390,7 @@ var useMediaInTimeline = ({
3360
3390
  const { imperativePlaying } = useContext17(TimelineContext);
3361
3391
  const startsAt = useMediaStartsAt();
3362
3392
  const { registerSequence, unregisterSequence } = useContext17(SequenceManager);
3363
- const [initialVolume] = useState10(() => volume);
3393
+ const [initialVolume] = useState11(() => volume);
3364
3394
  const logLevel = useLogLevel();
3365
3395
  const mountTime = useMountTime();
3366
3396
  const nonce = useNonce();
@@ -3383,6 +3413,7 @@ var useMediaInTimeline = ({
3383
3413
  warnOnce2(`Remotion: The ${mediaType} with src ${src} has changed it's volume. Prefer the callback syntax for setting volume to get better timeline display: https://www.remotion.dev/docs/audio/volume`);
3384
3414
  }
3385
3415
  }, [initialVolume, mediaType, src, volume]);
3416
+ const env = useRemotionEnvironment();
3386
3417
  useEffect8(() => {
3387
3418
  if (!mediaRef.current) {
3388
3419
  return;
@@ -3390,7 +3421,7 @@ var useMediaInTimeline = ({
3390
3421
  if (!src) {
3391
3422
  throw new Error("No src passed");
3392
3423
  }
3393
- if (!getRemotionEnvironment().isStudio && window.process?.env?.NODE_ENV !== "test") {
3424
+ if (!env.isStudio && window.process?.env?.NODE_ENV !== "test") {
3394
3425
  return;
3395
3426
  }
3396
3427
  if (!showInTimeline) {
@@ -3440,7 +3471,8 @@ var useMediaInTimeline = ({
3440
3471
  stack,
3441
3472
  showInTimeline,
3442
3473
  premountDisplay,
3443
- postmountDisplay
3474
+ postmountDisplay,
3475
+ env.isStudio
3444
3476
  ]);
3445
3477
  useEffect8(() => {
3446
3478
  const tag = {
@@ -3458,7 +3490,8 @@ var useMediaInTimeline = ({
3458
3490
  onAutoPlayError,
3459
3491
  logLevel,
3460
3492
  mountTime,
3461
- reason
3493
+ reason,
3494
+ isPlayer: env.isPlayer
3462
3495
  });
3463
3496
  }
3464
3497
  };
@@ -3476,7 +3509,8 @@ var useMediaInTimeline = ({
3476
3509
  isPremounting,
3477
3510
  isPostmounting,
3478
3511
  logLevel,
3479
- mountTime
3512
+ mountTime,
3513
+ env.isPlayer
3480
3514
  ]);
3481
3515
  };
3482
3516
 
@@ -3503,13 +3537,13 @@ import React14, {
3503
3537
  useLayoutEffect as useLayoutEffect4,
3504
3538
  useMemo as useMemo16,
3505
3539
  useRef as useRef7,
3506
- useState as useState11
3540
+ useState as useState12
3507
3541
  } from "react";
3508
3542
  import { jsx as jsx16 } from "react/jsx-runtime";
3509
3543
  var useBufferManager = (logLevel, mountTime) => {
3510
- const [blocks, setBlocks] = useState11([]);
3511
- const [onBufferingCallbacks, setOnBufferingCallbacks] = useState11([]);
3512
- const [onResumeCallbacks, setOnResumeCallbacks] = useState11([]);
3544
+ const [blocks, setBlocks] = useState12([]);
3545
+ const [onBufferingCallbacks, setOnBufferingCallbacks] = useState12([]);
3546
+ const [onResumeCallbacks, setOnResumeCallbacks] = useState12([]);
3513
3547
  const buffering = useRef7(false);
3514
3548
  const addBlock = useCallback7((block) => {
3515
3549
  setBlocks((b) => [...b, block]);
@@ -3579,7 +3613,7 @@ var BufferingProvider = ({ children }) => {
3579
3613
  });
3580
3614
  };
3581
3615
  var useIsPlayerBuffering = (bufferManager) => {
3582
- const [isBuffering, setIsBuffering] = useState11(bufferManager.buffering.current);
3616
+ const [isBuffering, setIsBuffering] = useState12(bufferManager.buffering.current);
3583
3617
  useEffect9(() => {
3584
3618
  const onBuffer = () => {
3585
3619
  setIsBuffering(true);
@@ -3749,7 +3783,7 @@ var seek = ({
3749
3783
  };
3750
3784
 
3751
3785
  // src/use-media-buffering.ts
3752
- import { useEffect as useEffect10, useState as useState12 } from "react";
3786
+ import { useEffect as useEffect10, useState as useState13 } from "react";
3753
3787
  var useMediaBuffering = ({
3754
3788
  element,
3755
3789
  shouldBuffer,
@@ -3760,7 +3794,7 @@ var useMediaBuffering = ({
3760
3794
  src
3761
3795
  }) => {
3762
3796
  const buffer = useBufferState();
3763
- const [isBuffering, setIsBuffering] = useState12(false);
3797
+ const [isBuffering, setIsBuffering] = useState13(false);
3764
3798
  useEffect10(() => {
3765
3799
  let cleanupFns = [];
3766
3800
  const { current } = element;
@@ -4229,6 +4263,7 @@ var useMediaPlayback = ({
4229
4263
  playing,
4230
4264
  isPostmounting
4231
4265
  ]);
4266
+ const env = useRemotionEnvironment();
4232
4267
  useLayoutEffect5(() => {
4233
4268
  const playbackRateToSet = Math.max(0, playbackRate);
4234
4269
  if (mediaRef.current && mediaRef.current.playbackRate !== playbackRateToSet) {
@@ -4272,7 +4307,8 @@ var useMediaPlayback = ({
4272
4307
  onAutoPlayError,
4273
4308
  logLevel,
4274
4309
  mountTime,
4275
- reason: "player is playing but media tag is paused, and just seeked"
4310
+ reason: "player is playing but media tag is paused, and just seeked",
4311
+ isPlayer: env.isPlayer
4276
4312
  });
4277
4313
  }
4278
4314
  }
@@ -4319,7 +4355,8 @@ var useMediaPlayback = ({
4319
4355
  onAutoPlayError,
4320
4356
  logLevel,
4321
4357
  mountTime,
4322
- reason: `player is playing and ${reason}`
4358
+ reason: `player is playing and ${reason}`,
4359
+ isPlayer: env.isPlayer
4323
4360
  });
4324
4361
  if (!isVariableFpsVideo && playbackRate > 0) {
4325
4362
  bufferUntilFirstFrame(shouldBeTime);
@@ -4346,7 +4383,8 @@ var useMediaPlayback = ({
4346
4383
  isPostmounting,
4347
4384
  pauseWhenBuffering,
4348
4385
  mountTime,
4349
- mediaTagCurrentTime
4386
+ mediaTagCurrentTime,
4387
+ env.isPlayer
4350
4388
  ]);
4351
4389
  };
4352
4390
 
@@ -4382,7 +4420,7 @@ var useMediaMutedState = () => {
4382
4420
  // src/audio/AudioForPreview.tsx
4383
4421
  import { jsx as jsx17 } from "react/jsx-runtime";
4384
4422
  var AudioForDevelopmentForwardRefFunction = (props, ref) => {
4385
- const [initialShouldPreMountAudioElements] = useState13(props.shouldPreMountAudioTags);
4423
+ const [initialShouldPreMountAudioElements] = useState14(props.shouldPreMountAudioTags);
4386
4424
  if (props.shouldPreMountAudioTags !== initialShouldPreMountAudioElements) {
4387
4425
  throw new Error("Cannot change the behavior for pre-mounting audio tags dynamically.");
4388
4426
  }
@@ -4427,7 +4465,7 @@ var AudioForDevelopmentForwardRefFunction = (props, ref) => {
4427
4465
  }
4428
4466
  const preloadedSrc = usePreload(src);
4429
4467
  const sequenceContext = useContext22(SequenceContext);
4430
- const [timelineId] = useState13(() => String(Math.random()));
4468
+ const [timelineId] = useState14(() => String(Math.random()));
4431
4469
  const isSequenceHidden = hidden[timelineId] ?? false;
4432
4470
  const userPreferredVolume = evaluateVolume({
4433
4471
  frame: volumePropFrame,
@@ -4701,7 +4739,7 @@ var AudioRefForwardingFunction = (props, ref) => {
4701
4739
  } = props;
4702
4740
  const { loop, ...propsOtherThanLoop } = props;
4703
4741
  const { fps } = useVideoConfig();
4704
- const environment = getRemotionEnvironment();
4742
+ const environment = useRemotionEnvironment();
4705
4743
  const { durations, setDurations } = useContext24(DurationsContext);
4706
4744
  if (typeof props.src !== "string") {
4707
4745
  throw new TypeError(`The \`<Audio>\` tag requires a string for \`src\`, but got ${JSON.stringify(props.src)} instead.`);
@@ -5017,7 +5055,7 @@ var InnerComposition = ({
5017
5055
  });
5018
5056
  const nonce = useNonce();
5019
5057
  const isPlayer = useIsPlayer();
5020
- const environment = getRemotionEnvironment();
5058
+ const environment = useRemotionEnvironment();
5021
5059
  const canUseComposition = useContext26(CanUseRemotionHooks);
5022
5060
  if (canUseComposition) {
5023
5061
  if (isPlayer) {
@@ -5326,7 +5364,7 @@ var getStaticFiles = () => {
5326
5364
  return window.remotion_staticFiles;
5327
5365
  };
5328
5366
  // src/IFrame.tsx
5329
- import { forwardRef as forwardRef7, useCallback as useCallback11, useState as useState14 } from "react";
5367
+ import { forwardRef as forwardRef7, useCallback as useCallback11, useState as useState15 } from "react";
5330
5368
  import { jsx as jsx23 } from "react/jsx-runtime";
5331
5369
  var IFrameRefForwarding = ({
5332
5370
  onLoad,
@@ -5335,7 +5373,7 @@ var IFrameRefForwarding = ({
5335
5373
  delayRenderTimeoutInMilliseconds,
5336
5374
  ...props2
5337
5375
  }, ref) => {
5338
- const [handle] = useState14(() => delayRender(`Loading <IFrame> with source ${props2.src}`, {
5376
+ const [handle] = useState15(() => delayRender(`Loading <IFrame> with source ${props2.src}`, {
5339
5377
  retries: delayRenderRetries ?? undefined,
5340
5378
  timeoutInMilliseconds: delayRenderTimeoutInMilliseconds ?? undefined
5341
5379
  }));
@@ -5524,7 +5562,7 @@ import React23, {
5524
5562
  useImperativeHandle as useImperativeHandle8,
5525
5563
  useMemo as useMemo24,
5526
5564
  useRef as useRef14,
5527
- useState as useState15
5565
+ useState as useState16
5528
5566
  } from "react";
5529
5567
  import { jsx as jsx25 } from "react/jsx-runtime";
5530
5568
  var compositionsRef = React23.createRef();
@@ -5535,10 +5573,10 @@ var CompositionManagerProvider = ({
5535
5573
  currentCompositionMetadata,
5536
5574
  audioLatencyHint
5537
5575
  }) => {
5538
- const [compositions, setCompositions] = useState15([]);
5576
+ const [compositions, setCompositions] = useState16([]);
5539
5577
  const currentcompositionsRef = useRef14(compositions);
5540
- const [folders, setFolders] = useState15([]);
5541
- const [canvasContent, setCanvasContent] = useState15(null);
5578
+ const [folders, setFolders] = useState16([]);
5579
+ const [canvasContent, setCanvasContent] = useState16(null);
5542
5580
  const updateCompositions = useCallback13((updateComps) => {
5543
5581
  setCompositions((comps) => {
5544
5582
  const updated = updateComps(comps);
@@ -5736,7 +5774,7 @@ import {
5736
5774
  useLayoutEffect as useLayoutEffect8,
5737
5775
  useMemo as useMemo25,
5738
5776
  useRef as useRef15,
5739
- useState as useState16
5777
+ useState as useState17
5740
5778
  } from "react";
5741
5779
  import { jsx as jsx26 } from "react/jsx-runtime";
5742
5780
  var RemotionRoot = ({
@@ -5747,13 +5785,13 @@ var RemotionRoot = ({
5747
5785
  currentCompositionMetadata,
5748
5786
  audioLatencyHint
5749
5787
  }) => {
5750
- const [remotionRootId] = useState16(() => String(random(null)));
5751
- const [frame, setFrame] = useState16(() => getInitialFrameState());
5752
- const [playing, setPlaying] = useState16(false);
5788
+ const [remotionRootId] = useState17(() => String(random(null)));
5789
+ const [frame, setFrame] = useState17(() => getInitialFrameState());
5790
+ const [playing, setPlaying] = useState17(false);
5753
5791
  const imperativePlaying = useRef15(false);
5754
- const [fastRefreshes, setFastRefreshes] = useState16(0);
5755
- const [manualRefreshes, setManualRefreshes] = useState16(0);
5756
- const [playbackRate, setPlaybackRate] = useState16(1);
5792
+ const [fastRefreshes, setFastRefreshes] = useState17(0);
5793
+ const [manualRefreshes, setManualRefreshes] = useState17(0);
5794
+ const [playbackRate, setPlaybackRate] = useState17(1);
5757
5795
  const audioAndVideoTags = useRef15([]);
5758
5796
  if (typeof window !== "undefined") {
5759
5797
  useLayoutEffect8(() => {
@@ -5916,11 +5954,12 @@ var useCurrentScale = (options) => {
5916
5954
  const hasContext = React25.useContext(CurrentScaleContext);
5917
5955
  const zoomContext = React25.useContext(PreviewSizeContext);
5918
5956
  const config = useUnsafeVideoConfig();
5957
+ const env = useRemotionEnvironment();
5919
5958
  if (hasContext === null || config === null || zoomContext === null) {
5920
5959
  if (options?.dontThrowIfOutsideOfRemotion) {
5921
5960
  return 1;
5922
5961
  }
5923
- if (getRemotionEnvironment().isRendering) {
5962
+ if (env.isRendering) {
5924
5963
  return 1;
5925
5964
  }
5926
5965
  throw new Error([
@@ -5950,7 +5989,7 @@ import {
5950
5989
  useImperativeHandle as useImperativeHandle9,
5951
5990
  useMemo as useMemo26,
5952
5991
  useRef as useRef16,
5953
- useState as useState17
5992
+ useState as useState18
5954
5993
  } from "react";
5955
5994
 
5956
5995
  // src/video/emit-video-frame.ts
@@ -6037,7 +6076,7 @@ var VideoForDevelopmentRefForwardingFunction = (props2, ref) => {
6037
6076
  const { hidden } = useContext28(SequenceVisibilityToggleContext);
6038
6077
  const logLevel = useLogLevel();
6039
6078
  const mountTime = useMountTime();
6040
- const [timelineId] = useState17(() => String(Math.random()));
6079
+ const [timelineId] = useState18(() => String(Math.random()));
6041
6080
  const isSequenceHidden = hidden[timelineId] ?? false;
6042
6081
  if (typeof acceptableTimeShift !== "undefined") {
6043
6082
  throw new Error("acceptableTimeShift has been removed. Use acceptableTimeShiftInSeconds instead.");
@@ -6097,7 +6136,7 @@ var VideoForDevelopmentRefForwardingFunction = (props2, ref) => {
6097
6136
  useImperativeHandle9(ref, () => {
6098
6137
  return videoRef.current;
6099
6138
  }, []);
6100
- useState17(() => playbackLogging({
6139
+ useState18(() => playbackLogging({
6101
6140
  logLevel,
6102
6141
  message: `Mounting video with source = ${actualSrc}, v=${VERSION}, user agent=${typeof navigator === "undefined" ? "server" : navigator.userAgent}`,
6103
6142
  tag: "video",
@@ -7217,17 +7256,29 @@ var Still = (props2) => {
7217
7256
  };
7218
7257
  return React31.createElement(Composition, newProps);
7219
7258
  };
7259
+ // src/use-delay-render.ts
7260
+ import { useCallback as useCallback14 } from "react";
7261
+ var useDelayRender = () => {
7262
+ const environment = useRemotionEnvironment();
7263
+ const delayRender2 = useCallback14((label2, options) => {
7264
+ return delayRenderInternal(environment, label2, options);
7265
+ }, [environment]);
7266
+ const continueRender2 = useCallback14((handle) => {
7267
+ continueRenderInternal(handle, environment);
7268
+ }, [environment]);
7269
+ return { delayRender: delayRender2, continueRender: continueRender2 };
7270
+ };
7220
7271
  // src/video/OffthreadVideo.tsx
7221
- import { useCallback as useCallback15 } from "react";
7272
+ import { useCallback as useCallback16 } from "react";
7222
7273
 
7223
7274
  // src/video/OffthreadVideoForRendering.tsx
7224
7275
  import {
7225
- useCallback as useCallback14,
7276
+ useCallback as useCallback15,
7226
7277
  useContext as useContext29,
7227
7278
  useEffect as useEffect20,
7228
7279
  useLayoutEffect as useLayoutEffect9,
7229
7280
  useMemo as useMemo29,
7230
- useState as useState18
7281
+ useState as useState19
7231
7282
  } from "react";
7232
7283
  import { jsx as jsx31 } from "react/jsx-runtime";
7233
7284
  var OffthreadVideoForRendering = ({
@@ -7328,7 +7379,7 @@ var OffthreadVideoForRendering = ({
7328
7379
  toneMapped
7329
7380
  });
7330
7381
  }, [toneMapped, currentTime, src, transparent]);
7331
- const [imageSrc, setImageSrc] = useState18(null);
7382
+ const [imageSrc, setImageSrc] = useState19(null);
7332
7383
  useLayoutEffect9(() => {
7333
7384
  if (!window.remotion_videoEnabled) {
7334
7385
  return;
@@ -7398,7 +7449,7 @@ var OffthreadVideoForRendering = ({
7398
7449
  delayRenderTimeoutInMilliseconds,
7399
7450
  onError
7400
7451
  ]);
7401
- const onErr = useCallback14(() => {
7452
+ const onErr = useCallback15(() => {
7402
7453
  if (onError) {
7403
7454
  onError?.(new Error("Failed to load image with src " + imageSrc));
7404
7455
  } else {
@@ -7408,7 +7459,7 @@ var OffthreadVideoForRendering = ({
7408
7459
  const className = useMemo29(() => {
7409
7460
  return [OFFTHREAD_VIDEO_CLASS_NAME, props2.className].filter(truthy).join(" ");
7410
7461
  }, [props2.className]);
7411
- const onImageFrame = useCallback14((img) => {
7462
+ const onImageFrame = useCallback15((img) => {
7412
7463
  if (onVideoFrame) {
7413
7464
  onVideoFrame(img);
7414
7465
  }
@@ -7442,8 +7493,8 @@ var OffthreadVideo = (props2) => {
7442
7493
  showInTimeline,
7443
7494
  ...otherProps
7444
7495
  } = props2;
7445
- const environment = getRemotionEnvironment();
7446
- const onDuration = useCallback15(() => {
7496
+ const environment = useRemotionEnvironment();
7497
+ const onDuration = useCallback16(() => {
7447
7498
  return;
7448
7499
  }, []);
7449
7500
  if (typeof props2.src !== "string") {
@@ -7502,7 +7553,7 @@ var OffthreadVideo = (props2) => {
7502
7553
  });
7503
7554
  };
7504
7555
  // src/video/Video.tsx
7505
- import { forwardRef as forwardRef12, useCallback as useCallback16, useContext as useContext31 } from "react";
7556
+ import { forwardRef as forwardRef12, useCallback as useCallback17, useContext as useContext31 } from "react";
7506
7557
 
7507
7558
  // src/video/VideoForRendering.tsx
7508
7559
  import {
@@ -7663,7 +7714,7 @@ var VideoForRenderingForwardFunction = ({
7663
7714
  const videoRef = useRef17(null);
7664
7715
  const sequenceContext = useContext30(SequenceContext);
7665
7716
  const mediaStartsAt = useMediaStartsAt();
7666
- const environment = getRemotionEnvironment();
7717
+ const environment = useRemotionEnvironment();
7667
7718
  const logLevel = useLogLevel();
7668
7719
  const mountTime = useMountTime();
7669
7720
  const { registerRenderAsset, unregisterRenderAsset } = useContext30(RenderAssetManager);
@@ -7859,7 +7910,7 @@ var VideoForwardingFunction = (props2, ref) => {
7859
7910
  } = props2;
7860
7911
  const { loop, ...propsOtherThanLoop } = props2;
7861
7912
  const { fps } = useVideoConfig();
7862
- const environment = getRemotionEnvironment();
7913
+ const environment = useRemotionEnvironment();
7863
7914
  const { durations, setDurations } = useContext31(DurationsContext);
7864
7915
  if (typeof ref === "string") {
7865
7916
  throw new Error("string refs are not supported");
@@ -7868,10 +7919,10 @@ var VideoForwardingFunction = (props2, ref) => {
7868
7919
  throw new TypeError(`The \`<Video>\` tag requires a string for \`src\`, but got ${JSON.stringify(props2.src)} instead.`);
7869
7920
  }
7870
7921
  const preloadedSrc = usePreload(props2.src);
7871
- const onDuration = useCallback16((src, durationInSeconds) => {
7922
+ const onDuration = useCallback17((src, durationInSeconds) => {
7872
7923
  setDurations({ type: "got-duration", durationInSeconds, src });
7873
7924
  }, [setDurations]);
7874
- const onVideoFrame = useCallback16(() => {}, []);
7925
+ const onVideoFrame = useCallback17(() => {}, []);
7875
7926
  const durationFetched = durations[getAbsoluteSrc(preloadedSrc)] ?? durations[getAbsoluteSrc(props2.src)];
7876
7927
  validateMediaTrimProps({ startFrom, endAt, trimBefore, trimAfter });
7877
7928
  const { trimBeforeValue, trimAfterValue } = resolveTrimProps({
@@ -7974,6 +8025,8 @@ addSequenceStackTraces(Sequence);
7974
8025
  export {
7975
8026
  watchStaticFile,
7976
8027
  useVideoConfig,
8028
+ useRemotionEnvironment,
8029
+ useDelayRender,
7977
8030
  useCurrentScale,
7978
8031
  useCurrentFrame,
7979
8032
  useBufferState,