remotion 4.0.153 → 4.0.155

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.
@@ -11,6 +11,7 @@ export type EditorPropsContextType = {
11
11
  export declare const EditorPropsContext: React.Context<EditorPropsContextType>;
12
12
  export declare const editorPropsProviderRef: React.RefObject<{
13
13
  getProps: () => Props;
14
+ setProps: React.Dispatch<React.SetStateAction<Props>>;
14
15
  }>;
15
16
  export declare const EditorPropsProvider: React.FC<{
16
17
  readonly children: React.ReactNode;
@@ -49,6 +49,7 @@ const EditorPropsProvider = ({ children }) => {
49
49
  (0, react_1.useImperativeHandle)(exports.editorPropsProviderRef, () => {
50
50
  return {
51
51
  getProps: () => props,
52
+ setProps,
52
53
  };
53
54
  }, [props]);
54
55
  const ctx = (0, react_1.useMemo)(() => {
@@ -150,7 +150,7 @@ const PremountedSequenceRefForwardingFunction = (props, ref) => {
150
150
  if (props.layout === 'none') {
151
151
  throw new Error('`<Sequence>` with `premountFor` prop does not support layout="none"');
152
152
  }
153
- const { style: passedStyle, from = 0, premountFor = 0, name, ...otherProps } = props;
153
+ const { style: passedStyle, from = 0, premountFor = 0, ...otherProps } = props;
154
154
  const premountingActive = frame < from && frame >= from - premountFor;
155
155
  const style = (0, react_1.useMemo)(() => {
156
156
  var _a;
@@ -21,6 +21,6 @@ type BufferManager = {
21
21
  };
22
22
  export declare const BufferingContextReact: React.Context<BufferManager | null>;
23
23
  export declare const BufferingProvider: React.FC<{
24
- children: React.ReactNode;
24
+ readonly children: React.ReactNode;
25
25
  }>;
26
26
  export {};
@@ -35,7 +35,13 @@ const useBufferManager = () => {
35
35
  setBlocks((b) => [...b, block]);
36
36
  return {
37
37
  unblock: () => {
38
- setBlocks((b) => b.filter((bx) => bx !== block));
38
+ setBlocks((b) => {
39
+ const newArr = b.filter((bx) => bx !== block);
40
+ if (newArr.length === b.length) {
41
+ return b;
42
+ }
43
+ return newArr;
44
+ });
39
45
  },
40
46
  };
41
47
  }, []);
@@ -59,10 +65,20 @@ const useBufferManager = () => {
59
65
  if (blocks.length > 0) {
60
66
  onBufferingCallbacks.forEach((c) => c());
61
67
  }
62
- else {
68
+ // Intentionally only firing when blocks change, not the callbacks
69
+ // otherwise a buffering callback might remove itself after being called
70
+ // and trigger again
71
+ // eslint-disable-next-line react-hooks/exhaustive-deps
72
+ }, [blocks]);
73
+ (0, react_1.useEffect)(() => {
74
+ if (blocks.length === 0) {
63
75
  onResumeCallbacks.forEach((c) => c());
64
76
  }
65
- }, [blocks, onBufferingCallbacks, onResumeCallbacks]);
77
+ // Intentionally only firing when blocks change, not the callbacks
78
+ // otherwise a resume callback might remove itself after being called
79
+ // and trigger again
80
+ // eslint-disable-next-line react-hooks/exhaustive-deps
81
+ }, [blocks]);
66
82
  return (0, react_1.useMemo)(() => {
67
83
  return { addBlock, listenForBuffering, listenForResume, buffering };
68
84
  }, [addBlock, buffering, listenForBuffering, listenForResume]);
@@ -130,7 +130,7 @@ export declare const Internals: {
130
130
  readonly addSequenceStackTraces: (component: unknown) => void;
131
131
  readonly useMediaStartsAt: () => number;
132
132
  readonly BufferingProvider: import("react").FC<{
133
- children: import("react").ReactNode;
133
+ readonly children: import("react").ReactNode;
134
134
  }>;
135
135
  readonly BufferingContextReact: import("react").Context<{
136
136
  addBlock: (block: {
@@ -162,6 +162,9 @@ export declare const Internals: {
162
162
  getProps: () => {
163
163
  [x: string]: Record<string, unknown>;
164
164
  };
165
+ setProps: import("react").Dispatch<import("react").SetStateAction<{
166
+ [x: string]: Record<string, unknown>;
167
+ }>>;
165
168
  }>;
166
169
  };
167
170
  export type { CompositionManagerContext, CompProps, MediaVolumeContextValue, RemotionEnvironment, SerializedJSONWithCustomFields, SetMediaVolumeContextValue, SetTimelineContextValue, TRenderAsset as TAsset, TCompMetadata, TComposition, TimelinePosition as Timeline, TimelineContextValue, TSequence, WatchRemotionStaticFilesPayload, };
@@ -6,7 +6,7 @@ const use_buffer_state_1 = require("./use-buffer-state");
6
6
  const useMediaBuffering = ({ element, shouldBuffer, isPremounting, }) => {
7
7
  const buffer = (0, use_buffer_state_1.useBufferState)();
8
8
  (0, react_1.useEffect)(() => {
9
- let cleanup = () => undefined;
9
+ let cleanupFns = [];
10
10
  const { current } = element;
11
11
  if (!current) {
12
12
  return;
@@ -17,33 +17,50 @@ const useMediaBuffering = ({ element, shouldBuffer, isPremounting, }) => {
17
17
  if (isPremounting) {
18
18
  return;
19
19
  }
20
+ const cleanup = () => {
21
+ cleanupFns.forEach((fn) => fn());
22
+ cleanupFns = [];
23
+ };
20
24
  const onWaiting = () => {
21
25
  const { unblock } = buffer.delayPlayback();
22
26
  const onCanPlay = () => {
23
- unblock();
27
+ cleanup();
28
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
29
+ init();
24
30
  };
25
31
  const onError = () => {
26
- unblock();
32
+ cleanup();
33
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
34
+ init();
27
35
  };
28
36
  current.addEventListener('canplay', onCanPlay, {
29
37
  once: true,
30
38
  });
39
+ cleanupFns.push(() => {
40
+ current.removeEventListener('canplay', onCanPlay);
41
+ });
31
42
  current.addEventListener('error', onError, {
32
43
  once: true,
33
44
  });
34
- cleanup = () => {
35
- current.removeEventListener('canplay', onCanPlay);
45
+ cleanupFns.push(() => {
36
46
  current.removeEventListener('error', onError);
47
+ });
48
+ cleanupFns.push(() => {
37
49
  unblock();
38
- return undefined;
39
- };
50
+ });
40
51
  };
41
- if (current.readyState < current.HAVE_FUTURE_DATA) {
42
- onWaiting();
43
- }
44
- else {
45
- current.addEventListener('waiting', onWaiting);
46
- }
52
+ const init = () => {
53
+ if (current.readyState < current.HAVE_FUTURE_DATA) {
54
+ onWaiting();
55
+ }
56
+ else {
57
+ current.addEventListener('waiting', onWaiting);
58
+ cleanupFns.push(() => {
59
+ current.removeEventListener('waiting', onWaiting);
60
+ });
61
+ }
62
+ };
63
+ init();
47
64
  return () => {
48
65
  cleanup();
49
66
  };
@@ -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.153";
6
+ export declare const VERSION = "4.0.155";
@@ -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.153';
10
+ exports.VERSION = '4.0.155';
@@ -132,7 +132,7 @@ function truthy(value) {
132
132
  }
133
133
 
134
134
  // src/version.ts
135
- var VERSION = "4.0.153";
135
+ var VERSION = "4.0.155";
136
136
 
137
137
  // src/multiple-versions-warning.ts
138
138
  var checkMultipleRemotionVersions = () => {
@@ -412,7 +412,8 @@ var EditorPropsProvider = ({ children }) => {
412
412
  }, []);
413
413
  useImperativeHandle(editorPropsProviderRef, () => {
414
414
  return {
415
- getProps: () => props
415
+ getProps: () => props,
416
+ setProps
416
417
  };
417
418
  }, [props]);
418
419
  const ctx = useMemo4(() => {
@@ -1305,13 +1306,7 @@ var PremountedSequenceRefForwardingFunction = (props, ref) => {
1305
1306
  if (props.layout === "none") {
1306
1307
  throw new Error('`<Sequence>` with `premountFor` prop does not support layout="none"');
1307
1308
  }
1308
- const {
1309
- style: passedStyle,
1310
- from = 0,
1311
- premountFor = 0,
1312
- name,
1313
- ...otherProps
1314
- } = props;
1309
+ const { style: passedStyle, from = 0, premountFor = 0, ...otherProps } = props;
1315
1310
  const premountingActive = frame < from && frame >= from - premountFor;
1316
1311
  const style = useMemo10(() => {
1317
1312
  return {
@@ -1795,7 +1790,13 @@ var useBufferManager = () => {
1795
1790
  setBlocks((b) => [...b, block]);
1796
1791
  return {
1797
1792
  unblock: () => {
1798
- setBlocks((b) => b.filter((bx) => bx !== block));
1793
+ setBlocks((b) => {
1794
+ const newArr = b.filter((bx) => bx !== block);
1795
+ if (newArr.length === b.length) {
1796
+ return b;
1797
+ }
1798
+ return newArr;
1799
+ });
1799
1800
  }
1800
1801
  };
1801
1802
  }, []);
@@ -1818,10 +1819,13 @@ var useBufferManager = () => {
1818
1819
  useEffect7(() => {
1819
1820
  if (blocks.length > 0) {
1820
1821
  onBufferingCallbacks.forEach((c) => c());
1821
- } else {
1822
+ }
1823
+ }, [blocks]);
1824
+ useEffect7(() => {
1825
+ if (blocks.length === 0) {
1822
1826
  onResumeCallbacks.forEach((c) => c());
1823
1827
  }
1824
- }, [blocks, onBufferingCallbacks, onResumeCallbacks]);
1828
+ }, [blocks]);
1825
1829
  return useMemo13(() => {
1826
1830
  return { addBlock, listenForBuffering, listenForResume, buffering };
1827
1831
  }, [addBlock, buffering, listenForBuffering, listenForResume]);
@@ -1859,9 +1863,7 @@ var useMediaBuffering = ({
1859
1863
  }) => {
1860
1864
  const buffer = useBufferState();
1861
1865
  useEffect8(() => {
1862
- let cleanup = () => {
1863
- return;
1864
- };
1866
+ let cleanupFns = [];
1865
1867
  const { current } = element;
1866
1868
  if (!current) {
1867
1869
  return;
@@ -1872,32 +1874,47 @@ var useMediaBuffering = ({
1872
1874
  if (isPremounting) {
1873
1875
  return;
1874
1876
  }
1877
+ const cleanup = () => {
1878
+ cleanupFns.forEach((fn) => fn());
1879
+ cleanupFns = [];
1880
+ };
1875
1881
  const onWaiting = () => {
1876
1882
  const { unblock } = buffer.delayPlayback();
1877
1883
  const onCanPlay = () => {
1878
- unblock();
1884
+ cleanup();
1885
+ init();
1879
1886
  };
1880
1887
  const onError = () => {
1881
- unblock();
1888
+ cleanup();
1889
+ init();
1882
1890
  };
1883
1891
  current.addEventListener("canplay", onCanPlay, {
1884
1892
  once: true
1885
1893
  });
1894
+ cleanupFns.push(() => {
1895
+ current.removeEventListener("canplay", onCanPlay);
1896
+ });
1886
1897
  current.addEventListener("error", onError, {
1887
1898
  once: true
1888
1899
  });
1889
- cleanup = () => {
1890
- current.removeEventListener("canplay", onCanPlay);
1900
+ cleanupFns.push(() => {
1891
1901
  current.removeEventListener("error", onError);
1902
+ });
1903
+ cleanupFns.push(() => {
1892
1904
  unblock();
1893
- return;
1894
- };
1905
+ });
1895
1906
  };
1896
- if (current.readyState < current.HAVE_FUTURE_DATA) {
1897
- onWaiting();
1898
- } else {
1899
- current.addEventListener("waiting", onWaiting);
1900
- }
1907
+ const init = () => {
1908
+ if (current.readyState < current.HAVE_FUTURE_DATA) {
1909
+ onWaiting();
1910
+ } else {
1911
+ current.addEventListener("waiting", onWaiting);
1912
+ cleanupFns.push(() => {
1913
+ current.removeEventListener("waiting", onWaiting);
1914
+ });
1915
+ }
1916
+ };
1917
+ init();
1901
1918
  return () => {
1902
1919
  cleanup();
1903
1920
  };
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var VERSION = "4.0.153";
2
+ var VERSION = "4.0.155";
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.153",
3
+ "version": "4.0.155",
4
4
  "description": "Render videos in React",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",