remotion 4.0.157 → 4.0.160

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/bundle.ts CHANGED
@@ -1,16 +1,15 @@
1
- import {build, revision} from 'bun';
1
+ import {build, semver, version} from 'bun';
2
2
 
3
3
  if (process.env.NODE_ENV !== 'production') {
4
4
  throw new Error('This script must be run using NODE_ENV=production');
5
5
  }
6
6
 
7
- if (!revision.startsWith('07ce')) {
7
+ if (!semver.satisfies(version, '^1.1.7')) {
8
8
  // eslint-disable-next-line no-console
9
- console.warn('warn: Remotion currently uses a fork of Bun to bundle.');
10
- // eslint-disable-next-line no-console
11
- console.log(
12
- 'You dont currently run the fork, this could lead to duplicate key warnings in React.',
9
+ console.error(
10
+ `There is a bug with bundling when using Bun <1.1.7. You use ${version}. Please use a newer version`,
13
11
  );
12
+ process.exit(1);
14
13
  }
15
14
 
16
15
  const output = await build({
@@ -13,6 +13,7 @@ const use_media_playback_js_1 = require("../use-media-playback.js");
13
13
  const use_media_tag_volume_js_1 = require("../use-media-tag-volume.js");
14
14
  const use_sync_volume_with_media_tag_js_1 = require("../use-sync-volume-with-media-tag.js");
15
15
  const volume_position_state_js_1 = require("../volume-position-state.js");
16
+ const volume_prop_js_1 = require("../volume-prop.js");
16
17
  const shared_audio_tags_js_1 = require("./shared-audio-tags.js");
17
18
  const use_audio_frame_js_1 = require("./use-audio-frame.js");
18
19
  const AudioForDevelopmentForwardRefFunction = (props, ref) => {
@@ -33,9 +34,15 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
33
34
  const sequenceContext = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
34
35
  const [timelineId] = (0, react_1.useState)(() => String(Math.random()));
35
36
  const isSequenceHidden = (_a = hidden[timelineId]) !== null && _a !== void 0 ? _a : false;
37
+ const userPreferredVolume = (0, volume_prop_js_1.evaluateVolume)({
38
+ frame: volumePropFrame,
39
+ volume,
40
+ mediaVolume,
41
+ allowAmplificationDuringRender: false,
42
+ });
36
43
  const propsToPass = (0, react_1.useMemo)(() => {
37
44
  return {
38
- muted: muted || mediaMuted || isSequenceHidden,
45
+ muted: muted || mediaMuted || isSequenceHidden || userPreferredVolume <= 0,
39
46
  src: preloadedSrc,
40
47
  loop: _remotionInternalNativeLoopPassed,
41
48
  ...nativeProps,
@@ -47,6 +54,7 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
47
54
  muted,
48
55
  nativeProps,
49
56
  preloadedSrc,
57
+ userPreferredVolume,
50
58
  ]);
51
59
  // Generate a string that's as unique as possible for this asset
52
60
  // but at the same time deterministic. We use it to combat strict mode issues.
@@ -68,11 +68,11 @@ function checkInfiniteRange(name, arr) {
68
68
  if (arr.length < 2) {
69
69
  throw new Error(name + ' must have at least 2 elements');
70
70
  }
71
- for (const index in arr) {
72
- if (typeof arr[index] !== 'number') {
71
+ for (const element of arr) {
72
+ if (typeof element !== 'number') {
73
73
  throw new Error(`${name} must contain only numbers`);
74
74
  }
75
- if (arr[index] === -Infinity || arr[index] === Infinity) {
75
+ if (!Number.isFinite(element)) {
76
76
  throw new Error(`${name} must contain only finite numbers, but got [${arr.join(',')}]`);
77
77
  }
78
78
  }
@@ -37,8 +37,6 @@ function spring({ frame: passedFrame, fps, config = {}, from = 0, to = 1, durati
37
37
  ? (0, measure_spring_js_1.measureSpring)({
38
38
  fps,
39
39
  config,
40
- from,
41
- to,
42
40
  threshold: durationRestThreshold,
43
41
  })
44
42
  : undefined;
@@ -1,12 +1,17 @@
1
+ import type { ENABLE_V5_BREAKING_CHANGES } from '../v5-flag.js';
1
2
  import type { SpringConfig } from './spring-utils';
3
+ type V4Props = {
4
+ from?: number;
5
+ to?: number;
6
+ };
7
+ type MeasureSpringProps = {
8
+ fps: number;
9
+ config?: Partial<SpringConfig>;
10
+ threshold?: number;
11
+ } & (false extends typeof ENABLE_V5_BREAKING_CHANGES ? V4Props : {});
2
12
  /**
3
13
  * @description The function returns how long it takes for a spring animation to settle
4
14
  * @see [Documentation](https://www.remotion.dev/docs/measure-spring)
5
15
  */
6
- export declare function measureSpring({ fps, config, threshold, from, to, }: {
7
- fps: number;
8
- config?: Partial<SpringConfig>;
9
- threshold?: number;
10
- from?: number;
11
- to?: number;
12
- }): number;
16
+ export declare function measureSpring({ fps, config, threshold, }: MeasureSpringProps): number;
17
+ export {};
@@ -8,7 +8,7 @@ const cache = new Map();
8
8
  * @description The function returns how long it takes for a spring animation to settle
9
9
  * @see [Documentation](https://www.remotion.dev/docs/measure-spring)
10
10
  */
11
- function measureSpring({ fps, config = {}, threshold = 0.005, from = 0, to = 1, }) {
11
+ function measureSpring({ fps, config = {}, threshold = 0.005, }) {
12
12
  if (typeof threshold !== 'number') {
13
13
  throw new TypeError(`threshold must be a number, got ${threshold} of type ${typeof threshold}`);
14
14
  }
@@ -33,15 +33,12 @@ function measureSpring({ fps, config = {}, threshold = 0.005, from = 0, to = 1,
33
33
  config.mass,
34
34
  config.overshootClamping,
35
35
  config.stiffness,
36
- from,
37
- to,
38
36
  threshold,
39
37
  ].join('-');
40
38
  if (cache.has(cacheKey)) {
41
39
  return cache.get(cacheKey);
42
40
  }
43
41
  (0, validate_fps_js_1.validateFps)(fps, 'to the measureSpring() function', false);
44
- const range = Math.abs(from - to);
45
42
  let frame = 0;
46
43
  let finishedFrame = 0;
47
44
  const calc = () => {
@@ -53,8 +50,7 @@ function measureSpring({ fps, config = {}, threshold = 0.005, from = 0, to = 1,
53
50
  };
54
51
  let animation = calc();
55
52
  const calcDifference = () => {
56
- return (Math.abs(animation.current - animation.toValue) /
57
- (range === 0 ? 1 : range));
53
+ return Math.abs(animation.current - animation.toValue);
58
54
  };
59
55
  let difference = calcDifference();
60
56
  while (difference >= threshold) {
@@ -52,6 +52,13 @@ const useMediaBuffering = ({ element, shouldBuffer, isPremounting, }) => {
52
52
  const init = () => {
53
53
  if (current.readyState < current.HAVE_FUTURE_DATA) {
54
54
  onWaiting();
55
+ // Needed by iOS Safari which will not load by default
56
+ // and therefore not fire the canplay event.
57
+ // Be cautious about using `current.load()` as it will
58
+ // reset if a video is already playing.
59
+ // Therefore only calling it after checking if the video
60
+ // has no future data.
61
+ current.load();
55
62
  }
56
63
  else {
57
64
  current.addEventListener('waiting', onWaiting);
@@ -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.157";
6
+ export declare const VERSION = "4.0.160";
@@ -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.157';
10
+ exports.VERSION = '4.0.160';
@@ -132,7 +132,7 @@ function truthy(value) {
132
132
  }
133
133
 
134
134
  // src/version.ts
135
- var VERSION = "4.0.157";
135
+ var VERSION = "4.0.160";
136
136
 
137
137
  // src/multiple-versions-warning.ts
138
138
  var checkMultipleRemotionVersions = () => {
@@ -2036,6 +2036,7 @@ var useMediaBuffering = ({
2036
2036
  const init = () => {
2037
2037
  if (current.readyState < current.HAVE_FUTURE_DATA) {
2038
2038
  onWaiting();
2039
+ current.load();
2039
2040
  } else {
2040
2041
  current.addEventListener("waiting", onWaiting);
2041
2042
  cleanupFns.push(() => {
@@ -2329,11 +2330,11 @@ var checkInfiniteRange = function(name, arr) {
2329
2330
  if (arr.length < 2) {
2330
2331
  throw new Error(name + " must have at least 2 elements");
2331
2332
  }
2332
- for (const index in arr) {
2333
- if (typeof arr[index] !== "number") {
2333
+ for (const element of arr) {
2334
+ if (typeof element !== "number") {
2334
2335
  throw new Error(`${name} must contain only numbers`);
2335
2336
  }
2336
- if (arr[index] === (-Infinity) || arr[index] === Infinity) {
2337
+ if (!Number.isFinite(element)) {
2337
2338
  throw new Error(`${name} must contain only finite numbers, but got [${arr.join(",")}]`);
2338
2339
  }
2339
2340
  }
@@ -2940,9 +2941,15 @@ var AudioForDevelopmentForwardRefFunction = (props, ref) => {
2940
2941
  const sequenceContext = useContext20(SequenceContext);
2941
2942
  const [timelineId] = useState11(() => String(Math.random()));
2942
2943
  const isSequenceHidden = hidden[timelineId] ?? false;
2944
+ const userPreferredVolume = evaluateVolume({
2945
+ frame: volumePropFrame,
2946
+ volume,
2947
+ mediaVolume,
2948
+ allowAmplificationDuringRender: false
2949
+ });
2943
2950
  const propsToPass = useMemo18(() => {
2944
2951
  return {
2945
- muted: muted || mediaMuted || isSequenceHidden,
2952
+ muted: muted || mediaMuted || isSequenceHidden || userPreferredVolume <= 0,
2946
2953
  src: preloadedSrc,
2947
2954
  loop: _remotionInternalNativeLoopPassed,
2948
2955
  ...nativeProps
@@ -2953,7 +2960,8 @@ var AudioForDevelopmentForwardRefFunction = (props, ref) => {
2953
2960
  mediaMuted,
2954
2961
  muted,
2955
2962
  nativeProps,
2956
- preloadedSrc
2963
+ preloadedSrc,
2964
+ userPreferredVolume
2957
2965
  ]);
2958
2966
  const id = useMemo18(() => `audio-${random(src ?? "")}-${sequenceContext?.relativeFrom}-${sequenceContext?.cumulatedFrom}-${sequenceContext?.durationInFrames}-muted:${props.muted}-loop:${props.loop}`, [
2959
2967
  src,
@@ -5278,9 +5286,7 @@ var calculationCache = {};
5278
5286
  function measureSpring({
5279
5287
  fps,
5280
5288
  config = {},
5281
- threshold = 0.005,
5282
- from = 0,
5283
- to = 1
5289
+ threshold = 0.005
5284
5290
  }) {
5285
5291
  if (typeof threshold !== "number") {
5286
5292
  throw new TypeError(`threshold must be a number, got ${threshold} of type ${typeof threshold}`);
@@ -5306,15 +5312,12 @@ function measureSpring({
5306
5312
  config.mass,
5307
5313
  config.overshootClamping,
5308
5314
  config.stiffness,
5309
- from,
5310
- to,
5311
5315
  threshold
5312
5316
  ].join("-");
5313
5317
  if (cache.has(cacheKey)) {
5314
5318
  return cache.get(cacheKey);
5315
5319
  }
5316
5320
  validateFps(fps, "to the measureSpring() function", false);
5317
- const range = Math.abs(from - to);
5318
5321
  let frame = 0;
5319
5322
  let finishedFrame = 0;
5320
5323
  const calc = () => {
@@ -5326,7 +5329,7 @@ function measureSpring({
5326
5329
  };
5327
5330
  let animation = calc();
5328
5331
  const calcDifference = () => {
5329
- return Math.abs(animation.current - animation.toValue) / (range === 0 ? 1 : range);
5332
+ return Math.abs(animation.current - animation.toValue);
5330
5333
  };
5331
5334
  let difference = calcDifference();
5332
5335
  while (difference >= threshold) {
@@ -5372,8 +5375,6 @@ function spring({
5372
5375
  const naturalDuration = needsToCalculateNaturalDuration ? measureSpring({
5373
5376
  fps,
5374
5377
  config,
5375
- from,
5376
- to,
5377
5378
  threshold: durationRestThreshold
5378
5379
  }) : undefined;
5379
5380
  const naturalDurationGetter = needsToCalculateNaturalDuration ? {
@@ -56,11 +56,11 @@ var checkInfiniteRange = function(name, arr) {
56
56
  if (arr.length < 2) {
57
57
  throw new Error(name + " must have at least 2 elements");
58
58
  }
59
- for (const index in arr) {
60
- if (typeof arr[index] !== "number") {
59
+ for (const element of arr) {
60
+ if (typeof element !== "number") {
61
61
  throw new Error(`${name} must contain only numbers`);
62
62
  }
63
- if (arr[index] === (-Infinity) || arr[index] === Infinity) {
63
+ if (!Number.isFinite(element)) {
64
64
  throw new Error(`${name} must contain only finite numbers, but got [${arr.join(",")}]`);
65
65
  }
66
66
  }
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var VERSION = "4.0.157";
2
+ var VERSION = "4.0.160";
3
3
  export {
4
4
  VERSION
5
5
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remotion",
3
- "version": "4.0.157",
3
+ "version": "4.0.160",
4
4
  "description": "Render videos in React",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",