remotion 4.0.192 → 4.0.194

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.
@@ -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.192";
6
+ export declare const VERSION = "4.0.194";
@@ -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.192';
10
+ exports.VERSION = '4.0.194';
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const useTrackSourceChange: (src: string) => import("react").MutableRefObject<number | null>;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useTrackSourceChange = void 0;
4
+ const react_1 = require("react");
5
+ const useTrackSourceChange = (src) => {
6
+ const lastChange = (0, react_1.useRef)(null);
7
+ const currentSrc = (0, react_1.useRef)(null);
8
+ (0, react_1.useEffect)(() => {
9
+ if (currentSrc.current === null) {
10
+ currentSrc.current = src;
11
+ return;
12
+ }
13
+ if (currentSrc.current !== src) {
14
+ currentSrc.current = src;
15
+ lastChange.current = Date.now();
16
+ }
17
+ }, [src]);
18
+ return lastChange;
19
+ };
20
+ exports.useTrackSourceChange = useTrackSourceChange;
@@ -18,6 +18,12 @@ exports.isIosSafari = isIosSafari;
18
18
  const isIOSSafariAndBlob = (actualSrc) => {
19
19
  return (0, exports.isIosSafari)() && actualSrc.startsWith('blob:');
20
20
  };
21
+ const getVideoFragmentStart = ({ actualFrom, fps, }) => {
22
+ return toSeconds(Math.max(0, -actualFrom), fps);
23
+ };
24
+ const getVideoFragmentEnd = ({ duration, fps, }) => {
25
+ return toSeconds(duration, fps);
26
+ };
21
27
  const appendVideoFragment = ({ actualSrc, actualFrom, duration, fps, }) => {
22
28
  var _a;
23
29
  if (isIOSSafariAndBlob(actualSrc)) {
@@ -33,16 +39,26 @@ const appendVideoFragment = ({ actualSrc, actualFrom, duration, fps, }) => {
33
39
  if (!Number.isFinite(actualFrom)) {
34
40
  return actualSrc;
35
41
  }
36
- actualSrc += `#t=${toSeconds(Math.max(0, -actualFrom), fps)}`;
42
+ const withStartHash = `${actualSrc}#t=${getVideoFragmentStart({ actualFrom, fps })}`;
37
43
  if (!Number.isFinite(duration)) {
38
- return actualSrc;
44
+ return withStartHash;
39
45
  }
40
- actualSrc += `,${toSeconds(duration, fps)}`;
41
- return actualSrc;
46
+ return `${withStartHash},${getVideoFragmentEnd({ duration, fps })}`;
42
47
  };
43
48
  exports.appendVideoFragment = appendVideoFragment;
44
- const isSubsetOfDuration = ({ prevStartFrom, newStartFrom, prevDuration, newDuration, }) => prevStartFrom <= newStartFrom &&
45
- prevStartFrom + prevDuration >= newStartFrom + newDuration;
49
+ const isSubsetOfDuration = ({ prevStartFrom, newStartFrom, prevDuration, newDuration, fps, }) => {
50
+ const previousFrom = getVideoFragmentStart({ actualFrom: prevStartFrom, fps });
51
+ const newFrom = getVideoFragmentStart({ actualFrom: newStartFrom, fps });
52
+ const previousEnd = getVideoFragmentEnd({ duration: prevDuration, fps });
53
+ const newEnd = getVideoFragmentEnd({ duration: newDuration, fps });
54
+ if (newFrom < previousFrom) {
55
+ return false;
56
+ }
57
+ if (newEnd > previousEnd) {
58
+ return false;
59
+ }
60
+ return true;
61
+ };
46
62
  const useAppendVideoFragment = ({ actualSrc: initialActualSrc, actualFrom: initialActualFrom, duration: initialDuration, fps, }) => {
47
63
  const actualFromRef = (0, react_1.useRef)(initialActualFrom);
48
64
  const actualDuration = (0, react_1.useRef)(initialDuration);
@@ -52,6 +68,7 @@ const useAppendVideoFragment = ({ actualSrc: initialActualSrc, actualFrom: initi
52
68
  newStartFrom: initialActualFrom,
53
69
  prevDuration: actualDuration.current,
54
70
  newDuration: initialDuration,
71
+ fps,
55
72
  }) ||
56
73
  initialActualSrc !== actualSrc.current) {
57
74
  actualFromRef.current = initialActualFrom;
@@ -155,7 +155,7 @@ function truthy(value) {
155
155
  }
156
156
 
157
157
  // src/version.ts
158
- var VERSION = "4.0.192";
158
+ var VERSION = "4.0.194";
159
159
 
160
160
  // src/multiple-versions-warning.ts
161
161
  var checkMultipleRemotionVersions = () => {
@@ -2757,6 +2757,18 @@ var isIosSafari = () => {
2757
2757
  var isIOSSafariAndBlob = (actualSrc) => {
2758
2758
  return isIosSafari() && actualSrc.startsWith("blob:");
2759
2759
  };
2760
+ var getVideoFragmentStart = ({
2761
+ actualFrom,
2762
+ fps
2763
+ }) => {
2764
+ return toSeconds(Math.max(0, -actualFrom), fps);
2765
+ };
2766
+ var getVideoFragmentEnd = ({
2767
+ duration,
2768
+ fps
2769
+ }) => {
2770
+ return toSeconds(duration, fps);
2771
+ };
2760
2772
  var appendVideoFragment = ({
2761
2773
  actualSrc,
2762
2774
  actualFrom,
@@ -2776,19 +2788,31 @@ var appendVideoFragment = ({
2776
2788
  if (!Number.isFinite(actualFrom)) {
2777
2789
  return actualSrc;
2778
2790
  }
2779
- actualSrc += `#t=${toSeconds(Math.max(0, -actualFrom), fps)}`;
2791
+ const withStartHash = `${actualSrc}#t=${getVideoFragmentStart({ actualFrom, fps })}`;
2780
2792
  if (!Number.isFinite(duration)) {
2781
- return actualSrc;
2793
+ return withStartHash;
2782
2794
  }
2783
- actualSrc += `,${toSeconds(duration, fps)}`;
2784
- return actualSrc;
2795
+ return `${withStartHash},${getVideoFragmentEnd({ duration, fps })}`;
2785
2796
  };
2786
2797
  var isSubsetOfDuration = ({
2787
2798
  prevStartFrom,
2788
2799
  newStartFrom,
2789
2800
  prevDuration,
2790
- newDuration
2791
- }) => prevStartFrom <= newStartFrom && prevStartFrom + prevDuration >= newStartFrom + newDuration;
2801
+ newDuration,
2802
+ fps
2803
+ }) => {
2804
+ const previousFrom = getVideoFragmentStart({ actualFrom: prevStartFrom, fps });
2805
+ const newFrom = getVideoFragmentStart({ actualFrom: newStartFrom, fps });
2806
+ const previousEnd = getVideoFragmentEnd({ duration: prevDuration, fps });
2807
+ const newEnd = getVideoFragmentEnd({ duration: newDuration, fps });
2808
+ if (newFrom < previousFrom) {
2809
+ return false;
2810
+ }
2811
+ if (newEnd > previousEnd) {
2812
+ return false;
2813
+ }
2814
+ return true;
2815
+ };
2792
2816
  var useAppendVideoFragment = ({
2793
2817
  actualSrc: initialActualSrc,
2794
2818
  actualFrom: initialActualFrom,
@@ -2802,7 +2826,8 @@ var useAppendVideoFragment = ({
2802
2826
  prevStartFrom: actualFromRef.current,
2803
2827
  newStartFrom: initialActualFrom,
2804
2828
  prevDuration: actualDuration.current,
2805
- newDuration: initialDuration
2829
+ newDuration: initialDuration,
2830
+ fps
2806
2831
  }) || initialActualSrc !== actualSrc.current) {
2807
2832
  actualFromRef.current = initialActualFrom;
2808
2833
  actualDuration.current = initialDuration;
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var VERSION = "4.0.192";
2
+ var VERSION = "4.0.194";
3
3
  export {
4
4
  VERSION
5
5
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/core"
4
4
  },
5
5
  "name": "remotion",
6
- "version": "4.0.192",
6
+ "version": "4.0.194",
7
7
  "description": "Make videos programmatically",
8
8
  "main": "dist/cjs/index.js",
9
9
  "types": "dist/cjs/index.d.ts",