remotion 4.0.394 → 4.0.396

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.
package/dist/cjs/Img.js CHANGED
@@ -9,6 +9,7 @@ const get_cross_origin_value_js_1 = require("./get-cross-origin-value.js");
9
9
  const prefetch_js_1 = require("./prefetch.js");
10
10
  const use_buffer_state_js_1 = require("./use-buffer-state.js");
11
11
  const use_delay_render_js_1 = require("./use-delay-render.js");
12
+ const use_remotion_environment_js_1 = require("./use-remotion-environment.js");
12
13
  function exponentialBackoff(errorCount) {
13
14
  return 1000 * 2 ** (errorCount - 1);
14
15
  }
@@ -151,9 +152,11 @@ const ImgRefForwarding = ({ onError, maxRetries = 2, src, pauseWhenLoading, dela
151
152
  delayRender,
152
153
  ]);
153
154
  }
155
+ const { isClientSideRendering } = (0, use_remotion_environment_js_1.useRemotionEnvironment)();
154
156
  const crossOriginValue = (0, get_cross_origin_value_js_1.getCrossOriginValue)({
155
157
  crossOrigin,
156
158
  requestsVideoFrame: false,
159
+ isClientSideRendering,
157
160
  });
158
161
  // src gets set once we've loaded and decoded the image.
159
162
  return ((0, jsx_runtime_1.jsx)("img", { ...props, ref: imageRef, crossOrigin: crossOriginValue, onError: didGetError, decoding: "sync" }));
@@ -52,6 +52,7 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
52
52
  const crossOriginValue = (0, get_cross_origin_value_js_1.getCrossOriginValue)({
53
53
  crossOrigin,
54
54
  requestsVideoFrame: false,
55
+ isClientSideRendering: false,
55
56
  });
56
57
  const propsToPass = (0, react_1.useMemo)(() => {
57
58
  return {
@@ -38,12 +38,20 @@ const jsx_runtime_1 = require("react/jsx-runtime");
38
38
  const react_1 = __importStar(require("react"));
39
39
  const log_level_context_1 = require("./log-level-context");
40
40
  const playback_logging_1 = require("./playback-logging");
41
+ const use_remotion_environment_1 = require("./use-remotion-environment");
41
42
  const useBufferManager = (logLevel, mountTime) => {
42
43
  const [blocks, setBlocks] = (0, react_1.useState)([]);
43
44
  const [onBufferingCallbacks, setOnBufferingCallbacks] = (0, react_1.useState)([]);
44
45
  const [onResumeCallbacks, setOnResumeCallbacks] = (0, react_1.useState)([]);
46
+ const env = (0, use_remotion_environment_1.useRemotionEnvironment)();
47
+ const rendering = env.isRendering;
45
48
  const buffering = (0, react_1.useRef)(false);
46
49
  const addBlock = (0, react_1.useCallback)((block) => {
50
+ if (rendering) {
51
+ return {
52
+ unblock: () => undefined,
53
+ };
54
+ }
47
55
  setBlocks((b) => [...b, block]);
48
56
  return {
49
57
  unblock: () => {
@@ -56,7 +64,7 @@ const useBufferManager = (logLevel, mountTime) => {
56
64
  });
57
65
  },
58
66
  };
59
- }, []);
67
+ }, [rendering]);
60
68
  const listenForBuffering = (0, react_1.useCallback)((callback) => {
61
69
  setOnBufferingCallbacks((c) => [...c, callback]);
62
70
  return {
@@ -74,6 +82,9 @@ const useBufferManager = (logLevel, mountTime) => {
74
82
  };
75
83
  }, []);
76
84
  (0, react_1.useEffect)(() => {
85
+ if (rendering) {
86
+ return;
87
+ }
77
88
  if (blocks.length > 0) {
78
89
  onBufferingCallbacks.forEach((c) => c());
79
90
  (0, playback_logging_1.playbackLogging)({
@@ -91,6 +102,9 @@ const useBufferManager = (logLevel, mountTime) => {
91
102
  if (typeof window !== 'undefined') {
92
103
  // eslint-disable-next-line react-hooks/rules-of-hooks
93
104
  (0, react_1.useLayoutEffect)(() => {
105
+ if (rendering) {
106
+ return;
107
+ }
94
108
  if (blocks.length === 0) {
95
109
  onResumeCallbacks.forEach((c) => c());
96
110
  (0, playback_logging_1.playbackLogging)({
@@ -0,0 +1,6 @@
1
+ export declare const calculateLoopDuration: ({ endAt, mediaDuration, playbackRate, startFrom, }: {
2
+ mediaDuration: number;
3
+ playbackRate: number;
4
+ startFrom: number | undefined;
5
+ endAt: number | undefined;
6
+ }) => number;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calculateLoopDuration = void 0;
4
+ const calculateLoopDuration = ({ endAt, mediaDuration, playbackRate, startFrom, }) => {
5
+ let duration = mediaDuration;
6
+ // Account for endAt
7
+ if (typeof endAt !== 'undefined') {
8
+ duration = endAt;
9
+ }
10
+ // Account for startFrom
11
+ if (typeof startFrom !== 'undefined') {
12
+ duration -= startFrom;
13
+ }
14
+ const actualDuration = duration / playbackRate;
15
+ return Math.floor(actualDuration);
16
+ };
17
+ exports.calculateLoopDuration = calculateLoopDuration;
@@ -1,4 +1,5 @@
1
- export declare const getCrossOriginValue: ({ crossOrigin, requestsVideoFrame, }: {
1
+ export declare const getCrossOriginValue: ({ crossOrigin, requestsVideoFrame, isClientSideRendering, }: {
2
2
  crossOrigin: "" | "anonymous" | "use-credentials" | undefined;
3
3
  requestsVideoFrame: boolean;
4
+ isClientSideRendering: boolean;
4
5
  }) => "" | "anonymous" | "use-credentials" | undefined;
@@ -1,11 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getCrossOriginValue = void 0;
4
- const getCrossOriginValue = ({ crossOrigin, requestsVideoFrame, }) => {
4
+ const getCrossOriginValue = ({ crossOrigin, requestsVideoFrame, isClientSideRendering, }) => {
5
5
  // If user specifies a value explicitly, use that
6
6
  if (crossOrigin !== undefined && crossOrigin !== null) {
7
7
  return crossOrigin;
8
8
  }
9
+ if (isClientSideRendering) {
10
+ return 'anonymous';
11
+ }
9
12
  // We need to set anonymous because otherwise we are not allowed
10
13
  // to get frames
11
14
  if (requestsVideoFrame) {
@@ -3,4 +3,4 @@
3
3
  * @see [Documentation](https://remotion.dev/docs/version)
4
4
  * @returns {string} The current version of the remotion package
5
5
  */
6
- export declare const VERSION = "4.0.394";
6
+ export declare const VERSION = "4.0.396";
@@ -7,4 +7,4 @@ exports.VERSION = void 0;
7
7
  * @see [Documentation](https://remotion.dev/docs/version)
8
8
  * @returns {string} The current version of the remotion package
9
9
  */
10
- exports.VERSION = '4.0.394';
10
+ exports.VERSION = '4.0.396';
@@ -210,6 +210,7 @@ const VideoForDevelopmentRefForwardingFunction = (props, ref) => {
210
210
  const crossOriginValue = (0, get_cross_origin_value_js_1.getCrossOriginValue)({
211
211
  crossOrigin,
212
212
  requestsVideoFrame: Boolean(onVideoFrame),
213
+ isClientSideRendering: false,
213
214
  });
214
215
  return ((0, jsx_runtime_1.jsx)("video", { ref: videoRef, muted: muted || mediaMuted || isSequenceHidden || userPreferredVolume <= 0, playsInline: true, src: actualSrc, loop: _remotionInternalNativeLoopPassed, style: actualStyle, disableRemotePlayback: true, crossOrigin: crossOriginValue, ...nativeProps }));
215
216
  };
@@ -0,0 +1,4 @@
1
+ export declare const useAudioChannelIndex: ({ ref, audioChannelIndex, }: {
2
+ ref: React.RefObject<HTMLVideoElement | HTMLAudioElement | null>;
3
+ audioChannelIndex: number;
4
+ }) => void;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useAudioChannelIndex = void 0;
4
+ const react_1 = require("react");
5
+ const useAudioChannelIndex = ({ ref, audioChannelIndex, }) => {
6
+ (0, react_1.useEffect)(() => {
7
+ var _a;
8
+ // @ts-expect-error
9
+ const audioChannels = (_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a.audioTracks;
10
+ console.log({ audioChannels, audioChannelIndex });
11
+ }, [ref, audioChannelIndex]);
12
+ };
13
+ exports.useAudioChannelIndex = useAudioChannelIndex;
@@ -110,7 +110,7 @@ function truthy(value) {
110
110
  }
111
111
 
112
112
  // src/version.ts
113
- var VERSION = "4.0.394";
113
+ var VERSION = "4.0.396";
114
114
 
115
115
  // src/multiple-versions-warning.ts
116
116
  var checkMultipleRemotionVersions = () => {
@@ -2992,11 +2992,15 @@ import {
2992
2992
  // src/get-cross-origin-value.ts
2993
2993
  var getCrossOriginValue = ({
2994
2994
  crossOrigin,
2995
- requestsVideoFrame
2995
+ requestsVideoFrame,
2996
+ isClientSideRendering
2996
2997
  }) => {
2997
2998
  if (crossOrigin !== undefined && crossOrigin !== null) {
2998
2999
  return crossOrigin;
2999
3000
  }
3001
+ if (isClientSideRendering) {
3002
+ return "anonymous";
3003
+ }
3000
3004
  if (requestsVideoFrame) {
3001
3005
  return "anonymous";
3002
3006
  }
@@ -3805,8 +3809,17 @@ var useBufferManager = (logLevel, mountTime) => {
3805
3809
  const [blocks, setBlocks] = useState13([]);
3806
3810
  const [onBufferingCallbacks, setOnBufferingCallbacks] = useState13([]);
3807
3811
  const [onResumeCallbacks, setOnResumeCallbacks] = useState13([]);
3812
+ const env = useRemotionEnvironment();
3813
+ const rendering = env.isRendering;
3808
3814
  const buffering = useRef9(false);
3809
3815
  const addBlock = useCallback8((block) => {
3816
+ if (rendering) {
3817
+ return {
3818
+ unblock: () => {
3819
+ return;
3820
+ }
3821
+ };
3822
+ }
3810
3823
  setBlocks((b) => [...b, block]);
3811
3824
  return {
3812
3825
  unblock: () => {
@@ -3819,7 +3832,7 @@ var useBufferManager = (logLevel, mountTime) => {
3819
3832
  });
3820
3833
  }
3821
3834
  };
3822
- }, []);
3835
+ }, [rendering]);
3823
3836
  const listenForBuffering = useCallback8((callback) => {
3824
3837
  setOnBufferingCallbacks((c) => [...c, callback]);
3825
3838
  return {
@@ -3837,6 +3850,9 @@ var useBufferManager = (logLevel, mountTime) => {
3837
3850
  };
3838
3851
  }, []);
3839
3852
  useEffect7(() => {
3853
+ if (rendering) {
3854
+ return;
3855
+ }
3840
3856
  if (blocks.length > 0) {
3841
3857
  onBufferingCallbacks.forEach((c) => c());
3842
3858
  playbackLogging({
@@ -3849,6 +3865,9 @@ var useBufferManager = (logLevel, mountTime) => {
3849
3865
  }, [blocks]);
3850
3866
  if (typeof window !== "undefined") {
3851
3867
  useLayoutEffect6(() => {
3868
+ if (rendering) {
3869
+ return;
3870
+ }
3852
3871
  if (blocks.length === 0) {
3853
3872
  onResumeCallbacks.forEach((c) => c());
3854
3873
  playbackLogging({
@@ -4797,7 +4816,8 @@ var AudioForDevelopmentForwardRefFunction = (props, ref) => {
4797
4816
  warnAboutTooHighVolume(userPreferredVolume);
4798
4817
  const crossOriginValue = getCrossOriginValue({
4799
4818
  crossOrigin,
4800
- requestsVideoFrame: false
4819
+ requestsVideoFrame: false,
4820
+ isClientSideRendering: false
4801
4821
  });
4802
4822
  const propsToPass = useMemo21(() => {
4803
4823
  return {
@@ -5880,9 +5900,11 @@ var ImgRefForwarding = ({
5880
5900
  delayRender2
5881
5901
  ]);
5882
5902
  }
5903
+ const { isClientSideRendering } = useRemotionEnvironment();
5883
5904
  const crossOriginValue = getCrossOriginValue({
5884
5905
  crossOrigin,
5885
- requestsVideoFrame: false
5906
+ requestsVideoFrame: false,
5907
+ isClientSideRendering
5886
5908
  });
5887
5909
  return /* @__PURE__ */ jsx25("img", {
5888
5910
  ...props2,
@@ -6762,7 +6784,8 @@ var VideoForDevelopmentRefForwardingFunction = (props2, ref) => {
6762
6784
  }, [isSequenceHidden, style]);
6763
6785
  const crossOriginValue = getCrossOriginValue({
6764
6786
  crossOrigin,
6765
- requestsVideoFrame: Boolean(onVideoFrame)
6787
+ requestsVideoFrame: Boolean(onVideoFrame),
6788
+ isClientSideRendering: false
6766
6789
  });
6767
6790
  return /* @__PURE__ */ jsx30("video", {
6768
6791
  ref: videoRef,