remotion 4.0.0-oops.3 → 4.0.0-prefetch.7

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 (189) hide show
  1. package/.turbo/turbo-build.log +5 -5
  2. package/README.md +30 -19
  3. package/dist/AbsoluteFill.d.ts +6 -2
  4. package/dist/AbsoluteFill.js +7 -3
  5. package/dist/CanUseRemotionHooks.d.ts +5 -0
  6. package/dist/CanUseRemotionHooks.js +10 -0
  7. package/dist/Composition.d.ts +3 -6
  8. package/dist/Composition.js +40 -28
  9. package/dist/CompositionManager.d.ts +7 -12
  10. package/dist/CompositionManager.js +15 -5
  11. package/dist/Folder.d.ts +15 -0
  12. package/dist/Folder.js +33 -0
  13. package/dist/IFrame.js +1 -1
  14. package/dist/Img.js +33 -16
  15. package/dist/RemotionRoot.js +1 -1
  16. package/dist/{sequencing/index.d.ts → Sequence.d.ts} +13 -3
  17. package/dist/{sequencing/index.js → Sequence.js} +40 -34
  18. package/dist/Still.d.ts +1 -1
  19. package/dist/Still.js +1 -1
  20. package/dist/asset-types.d.ts +1 -4
  21. package/dist/audio/Audio.d.ts +2 -2
  22. package/dist/audio/Audio.js +5 -5
  23. package/dist/audio/AudioForDevelopment.d.ts +3 -2
  24. package/dist/audio/AudioForDevelopment.js +19 -6
  25. package/dist/audio/AudioForRendering.d.ts +5 -2
  26. package/dist/audio/AudioForRendering.js +15 -8
  27. package/dist/audio/index.js +5 -1
  28. package/dist/audio/props.d.ts +1 -1
  29. package/dist/audio/shared-audio-tags.d.ts +4 -3
  30. package/dist/audio/shared-audio-tags.js +115 -42
  31. package/dist/audio/use-audio-frame.js +4 -4
  32. package/dist/config/bundle-out-dir.d.ts +2 -0
  33. package/dist/config/bundle-out-dir.js +12 -0
  34. package/dist/config/input-props.js +12 -14
  35. package/dist/config/public-path.d.ts +2 -0
  36. package/dist/config/public-path.js +12 -0
  37. package/dist/{config/index.d.ts → config.d.ts} +70 -22
  38. package/dist/config.js +21 -0
  39. package/dist/default-css.d.ts +1 -0
  40. package/dist/default-css.js +9 -2
  41. package/dist/delay-render.d.ts +1 -1
  42. package/dist/delay-render.js +4 -4
  43. package/dist/freeze.d.ts +2 -2
  44. package/dist/freeze.js +2 -2
  45. package/dist/get-timeline-clip-name.js +2 -1
  46. package/dist/index.d.ts +23 -8
  47. package/dist/index.js +18 -8
  48. package/dist/internals.d.ts +35 -101
  49. package/dist/internals.js +18 -94
  50. package/dist/{interpolateColors.d.ts → interpolate-colors.d.ts} +0 -0
  51. package/dist/{interpolateColors.js → interpolate-colors.js} +0 -0
  52. package/dist/loading-indicator.d.ts +2 -0
  53. package/dist/loading-indicator.js +35 -0
  54. package/dist/loop/index.js +5 -4
  55. package/dist/multiple-versions-warning.js +18 -4
  56. package/dist/play-and-handle-not-allowed-error.d.ts +1 -1
  57. package/dist/portal-node.d.ts +1 -0
  58. package/dist/portal-node.js +23 -0
  59. package/dist/preload.d.ts +7 -0
  60. package/dist/preload.js +83 -0
  61. package/dist/register-root.d.ts +2 -1
  62. package/dist/register-root.js +20 -5
  63. package/dist/series/index.d.ts +2 -2
  64. package/dist/series/index.js +4 -4
  65. package/dist/spring/index.d.ts +8 -4
  66. package/dist/spring/index.js +21 -6
  67. package/dist/spring/measure-spring.d.ts +1 -1
  68. package/dist/spring/measure-spring.js +1 -1
  69. package/dist/static-file.js +6 -0
  70. package/dist/timeline-position-state.d.ts +1 -1
  71. package/dist/{use-frame.d.ts → use-current-frame.d.ts} +0 -1
  72. package/dist/use-current-frame.js +28 -0
  73. package/dist/use-lazy-component.d.ts +3 -3
  74. package/dist/use-lazy-component.js +5 -1
  75. package/dist/use-media-in-timeline.d.ts +2 -2
  76. package/dist/use-media-in-timeline.js +10 -7
  77. package/dist/use-media-playback.d.ts +3 -2
  78. package/dist/use-media-playback.js +9 -6
  79. package/dist/use-media-tag-volume.d.ts +1 -1
  80. package/dist/use-sync-volume-with-media-tag.d.ts +2 -2
  81. package/dist/use-unsafe-video-config.d.ts +1 -1
  82. package/dist/use-unsafe-video-config.js +2 -2
  83. package/dist/use-video-config.d.ts +1 -1
  84. package/dist/use-video-config.js +6 -0
  85. package/dist/use-video.d.ts +13 -1
  86. package/dist/use-video.js +16 -3
  87. package/dist/validate-media-props.d.ts +4 -3
  88. package/dist/validation/validate-fps.d.ts +1 -1
  89. package/dist/validation/validate-fps.js +4 -1
  90. package/dist/validation/validate-offthreadvideo-image-format.d.ts +1 -0
  91. package/dist/validation/validate-offthreadvideo-image-format.js +15 -0
  92. package/dist/validation/validation-spring-duration.d.ts +1 -0
  93. package/dist/validation/validation-spring-duration.js +21 -0
  94. package/dist/version.d.ts +1 -0
  95. package/dist/version.js +5 -0
  96. package/dist/video/OffthreadVideo.d.ts +3 -0
  97. package/dist/video/OffthreadVideo.js +27 -0
  98. package/dist/video/OffthreadVideoForRendering.d.ts +3 -0
  99. package/dist/video/OffthreadVideoForRendering.js +101 -0
  100. package/dist/video/Video.d.ts +3 -3
  101. package/dist/video/Video.js +4 -4
  102. package/dist/video/VideoForDevelopment.d.ts +7 -2
  103. package/dist/video/VideoForDevelopment.js +28 -4
  104. package/dist/video/VideoForRendering.d.ts +5 -2
  105. package/dist/video/VideoForRendering.js +62 -40
  106. package/dist/video/get-current-time.d.ts +7 -1
  107. package/dist/video/get-current-time.js +17 -9
  108. package/dist/video/index.d.ts +3 -2
  109. package/dist/video/index.js +5 -12
  110. package/dist/video/props.d.ts +13 -2
  111. package/dist/volume-prop.js +1 -1
  112. package/dist/warn-about-non-seekable-media.d.ts +1 -1
  113. package/dist/warn-about-non-seekable-media.js +14 -2
  114. package/dist/wrap-remotion-context.d.ts +2 -1
  115. package/dist/wrap-remotion-context.js +12 -4
  116. package/ensure-correct-version.js +24 -0
  117. package/package.json +10 -11
  118. package/version.d.ts +1 -0
  119. package/version.js +1 -0
  120. package/dist/compress-assets.d.ts +0 -7
  121. package/dist/compress-assets.js +0 -25
  122. package/dist/config/browser-executable.d.ts +0 -3
  123. package/dist/config/browser-executable.js +0 -12
  124. package/dist/config/browser.d.ts +0 -4
  125. package/dist/config/browser.js +0 -19
  126. package/dist/config/chromium-flags.d.ts +0 -10
  127. package/dist/config/chromium-flags.js +0 -34
  128. package/dist/config/codec.d.ts +0 -17
  129. package/dist/config/codec.js +0 -103
  130. package/dist/config/concurrency.d.ts +0 -3
  131. package/dist/config/concurrency.js +0 -15
  132. package/dist/config/crf.d.ts +0 -9
  133. package/dist/config/crf.js +0 -83
  134. package/dist/config/env-file.d.ts +0 -2
  135. package/dist/config/env-file.js +0 -10
  136. package/dist/config/ffmpeg-executable.d.ts +0 -3
  137. package/dist/config/ffmpeg-executable.js +0 -12
  138. package/dist/config/frame-range.d.ts +0 -5
  139. package/dist/config/frame-range.js +0 -80
  140. package/dist/config/image-format.d.ts +0 -8
  141. package/dist/config/image-format.js +0 -37
  142. package/dist/config/image-sequence.d.ts +0 -3
  143. package/dist/config/image-sequence.js +0 -15
  144. package/dist/config/index.js +0 -175
  145. package/dist/config/log.d.ts +0 -7
  146. package/dist/config/log.js +0 -25
  147. package/dist/config/max-timeline-tracks.d.ts +0 -2
  148. package/dist/config/max-timeline-tracks.js +0 -24
  149. package/dist/config/override-webpack.d.ts +0 -12
  150. package/dist/config/override-webpack.js +0 -14
  151. package/dist/config/overwrite.d.ts +0 -3
  152. package/dist/config/overwrite.js +0 -14
  153. package/dist/config/pixel-format.d.ts +0 -8
  154. package/dist/config/pixel-format.js +0 -38
  155. package/dist/config/preview-server.d.ts +0 -2
  156. package/dist/config/preview-server.js +0 -20
  157. package/dist/config/prores-profile.d.ts +0 -7
  158. package/dist/config/prores-profile.js +0 -32
  159. package/dist/config/quality.d.ts +0 -2
  160. package/dist/config/quality.js +0 -17
  161. package/dist/config/scale.d.ts +0 -3
  162. package/dist/config/scale.js +0 -15
  163. package/dist/config/still-frame.d.ts +0 -2
  164. package/dist/config/still-frame.js +0 -12
  165. package/dist/config/timeout.d.ts +0 -2
  166. package/dist/config/timeout.js +0 -17
  167. package/dist/config/webpack-caching.d.ts +0 -3
  168. package/dist/config/webpack-caching.js +0 -16
  169. package/dist/feature-flags.d.ts +0 -1
  170. package/dist/feature-flags.js +0 -7
  171. package/dist/initial-frame.d.ts +0 -2
  172. package/dist/initial-frame.js +0 -12
  173. package/dist/is-audio-codec.d.ts +0 -2
  174. package/dist/is-audio-codec.js +0 -7
  175. package/dist/perf/index.d.ts +0 -5
  176. package/dist/perf/index.js +0 -33
  177. package/dist/timeline-inout-position-state.d.ts +0 -12
  178. package/dist/timeline-inout-position-state.js +0 -23
  179. package/dist/timeout.d.ts +0 -2
  180. package/dist/timeout.js +0 -12
  181. package/dist/use-frame.js +0 -25
  182. package/dist/validation/validate-frame.d.ts +0 -1
  183. package/dist/validation/validate-frame.js +0 -24
  184. package/dist/validation/validate-image-format.d.ts +0 -2
  185. package/dist/validation/validate-image-format.js +0 -9
  186. package/dist/validation/validate-opengl-renderer.d.ts +0 -4
  187. package/dist/validation/validate-opengl-renderer.js +0 -14
  188. package/dist/validation/validate-quality.d.ts +0 -1
  189. package/dist/validation/validate-quality.js +0 -21
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.portalNode = void 0;
4
+ let _portalNode = null;
5
+ const portalNode = () => {
6
+ if (!_portalNode) {
7
+ if (typeof document === 'undefined') {
8
+ throw new Error('Tried to call an API that only works in the browser from outside the browser');
9
+ }
10
+ _portalNode = document.createElement('div');
11
+ _portalNode.style.position = 'absolute';
12
+ _portalNode.style.top = '0px';
13
+ _portalNode.style.left = '0px';
14
+ _portalNode.style.right = '0px';
15
+ _portalNode.style.bottom = '0px';
16
+ _portalNode.style.width = '100%';
17
+ _portalNode.style.height = '100%';
18
+ _portalNode.style.display = 'flex';
19
+ _portalNode.style.flexDirection = 'column';
20
+ }
21
+ return _portalNode;
22
+ };
23
+ exports.portalNode = portalNode;
@@ -0,0 +1,7 @@
1
+ export declare const usePreload: (src: string) => string;
2
+ declare type FetchAndPreload = {
3
+ unpreload: () => void;
4
+ waitForDone: () => Promise<string>;
5
+ };
6
+ export declare const fetchAndPreload: (src: string) => FetchAndPreload;
7
+ export {};
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchAndPreload = exports.usePreload = void 0;
4
+ const react_1 = require("react");
5
+ const get_environment_1 = require("./get-environment");
6
+ const preloadRef = (0, react_1.createRef)();
7
+ const usePreload = (src) => {
8
+ var _a;
9
+ const [preloads, setPreloads] = (0, react_1.useState)({});
10
+ (0, react_1.useImperativeHandle)(preloadRef, () => {
11
+ return {
12
+ setPreloads,
13
+ };
14
+ });
15
+ return (_a = preloads[src]) !== null && _a !== void 0 ? _a : src;
16
+ };
17
+ exports.usePreload = usePreload;
18
+ const fetchAndPreload = (src) => {
19
+ if ((0, get_environment_1.getRemotionEnvironment)() === 'rendering') {
20
+ return {
21
+ unpreload: () => undefined,
22
+ waitForDone: () => Promise.resolve(src),
23
+ };
24
+ }
25
+ let canceled = false;
26
+ let objectUrl = null;
27
+ let resolve = () => undefined;
28
+ let reject = () => undefined;
29
+ const waitUntilDone = new Promise((res, rej) => {
30
+ resolve = res;
31
+ reject = rej;
32
+ });
33
+ fetch(src)
34
+ .then((res) => {
35
+ if (canceled) {
36
+ reject(new Error('Preloading cancelled'));
37
+ return null;
38
+ }
39
+ if (!res.ok) {
40
+ throw new Error(`HTTP error, status = ${res.status}`);
41
+ }
42
+ return res.blob();
43
+ })
44
+ .then((buf) => {
45
+ var _a;
46
+ if (canceled) {
47
+ reject(new Error('Preloading cancelled'));
48
+ return;
49
+ }
50
+ if (buf) {
51
+ objectUrl = URL.createObjectURL(buf);
52
+ (_a = preloadRef.current) === null || _a === void 0 ? void 0 : _a.setPreloads((p) => ({
53
+ ...p,
54
+ [src]: objectUrl,
55
+ }));
56
+ resolve(objectUrl);
57
+ }
58
+ })
59
+ .catch((err) => {
60
+ reject(err);
61
+ });
62
+ return {
63
+ unpreload: () => {
64
+ var _a;
65
+ if (objectUrl) {
66
+ URL.revokeObjectURL(objectUrl);
67
+ (_a = preloadRef.current) === null || _a === void 0 ? void 0 : _a.setPreloads((p) => {
68
+ const copy = { ...p };
69
+ delete copy[src];
70
+ return copy;
71
+ });
72
+ }
73
+ else {
74
+ canceled = true;
75
+ reject(new Error('Preloading cancelled'));
76
+ }
77
+ },
78
+ waitForDone: () => {
79
+ return waitUntilDone;
80
+ },
81
+ };
82
+ };
83
+ exports.fetchAndPreload = fetchAndPreload;
@@ -1,3 +1,4 @@
1
- import React from 'react';
1
+ import type React from 'react';
2
2
  export declare const registerRoot: (comp: React.FC) => void;
3
3
  export declare const getRoot: () => React.FC<{}> | null;
4
+ export declare const waitForRoot: (fn: (comp: React.FC) => void) => (() => void);
@@ -1,15 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRoot = exports.registerRoot = void 0;
4
- let root = null;
3
+ exports.waitForRoot = exports.getRoot = exports.registerRoot = void 0;
4
+ let Root = null;
5
+ let listeners = [];
5
6
  const registerRoot = (comp) => {
6
- if (root) {
7
+ if (Root) {
7
8
  throw new Error('registerRoot() was called more than once.');
8
9
  }
9
- root = comp;
10
+ Root = comp;
11
+ listeners.forEach((l) => {
12
+ l(comp);
13
+ });
10
14
  };
11
15
  exports.registerRoot = registerRoot;
12
16
  const getRoot = () => {
13
- return root;
17
+ return Root;
14
18
  };
15
19
  exports.getRoot = getRoot;
20
+ const waitForRoot = (fn) => {
21
+ if (Root) {
22
+ fn(Root);
23
+ return () => undefined;
24
+ }
25
+ listeners.push(fn);
26
+ return () => {
27
+ listeners = listeners.filter((l) => l !== fn);
28
+ };
29
+ };
30
+ exports.waitForRoot = waitForRoot;
@@ -1,5 +1,5 @@
1
- import { FC, PropsWithChildren } from 'react';
2
- import { SequenceProps } from '../sequencing';
1
+ import type { FC, PropsWithChildren } from 'react';
2
+ import type { SequenceProps } from '../Sequence';
3
3
  declare type SeriesSequenceProps = PropsWithChildren<{
4
4
  durationInFrames: number;
5
5
  offset?: number;
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Series = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
- const sequencing_1 = require("../sequencing");
6
+ const Sequence_1 = require("../Sequence");
7
7
  const validate_duration_in_frames_1 = require("../validation/validate-duration-in-frames");
8
8
  const flatten_children_1 = require("./flatten-children");
9
9
  const SeriesSequence = ({ children }) => {
10
10
  // eslint-disable-next-line react/jsx-no-useless-fragment
11
- return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children }, void 0);
11
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
12
12
  };
13
13
  const Series = ({ children }) => {
14
14
  const childrenValue = (0, react_1.useMemo)(() => {
@@ -45,11 +45,11 @@ const Series = ({ children }) => {
45
45
  }
46
46
  const currentStartFrame = startFrame + offset;
47
47
  startFrame += durationInFramesProp + offset;
48
- return ((0, jsx_runtime_1.jsx)(sequencing_1.Sequence, { from: currentStartFrame, durationInFrames: durationInFramesProp, ...passedProps, children: child }, void 0));
48
+ return ((0, jsx_runtime_1.jsx)(Sequence_1.Sequence, { from: currentStartFrame, durationInFrames: durationInFramesProp, ...passedProps, children: child }));
49
49
  });
50
50
  }, [children]);
51
51
  /* eslint-disable react/jsx-no-useless-fragment */
52
- return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: childrenValue }, void 0);
52
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: childrenValue });
53
53
  };
54
54
  exports.Series = Series;
55
55
  Series.Sequence = SeriesSequence;
@@ -1,4 +1,4 @@
1
- import { SpringConfig } from './spring-utils';
1
+ import type { SpringConfig } from './spring-utils';
2
2
  /**
3
3
  * Calculates a position based on physical parameters, start and end value, and time.
4
4
  * @link https://www.remotion.dev/docs/spring
@@ -9,15 +9,19 @@ import { SpringConfig } from './spring-utils';
9
9
  * @param {number} [config.damping=10] How hard the animation decelerates.
10
10
  * @param {number} [config.stiffness=100] Affects bounciness of the animation.
11
11
  * @param {boolean} [config.overshootClamping=false] Whether to prevent the animation going beyond the target value.
12
- * @param {?number} from The initial value of the animation. Default `0`
13
- * @param {?number} to The end value of the animation. Default `1`
12
+ * @param {?number} [config.from] The initial value of the animation. Default `0`
13
+ * @param {?number} [config.to] The end value of the animation. Default `1`
14
+ * @param {?number} [config.durationInFrames] Stretch the duration of an animation to a set value.. Default `undefined`
15
+ * @param {?number} [config.durationThreshold] How close to the end the animation is considered to be done. Default `0.005`
14
16
  */
15
- export declare function spring({ frame, fps, config, from, to, }: {
17
+ export declare function spring({ frame, fps, config, from, to, durationInFrames, durationRestThreshold, }: {
16
18
  frame: number;
17
19
  fps: number;
18
20
  config?: Partial<SpringConfig>;
19
21
  from?: number;
20
22
  to?: number;
23
+ durationInFrames?: number;
24
+ durationRestThreshold?: number;
21
25
  }): number;
22
26
  export { measureSpring } from './measure-spring';
23
27
  export { SpringConfig } from './spring-utils';
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.measureSpring = exports.spring = void 0;
4
+ const validation_spring_duration_1 = require("../validation/validation-spring-duration");
5
+ const measure_spring_1 = require("./measure-spring");
4
6
  const spring_utils_1 = require("./spring-utils");
5
7
  /**
6
8
  * Calculates a position based on physical parameters, start and end value, and time.
@@ -12,13 +14,26 @@ const spring_utils_1 = require("./spring-utils");
12
14
  * @param {number} [config.damping=10] How hard the animation decelerates.
13
15
  * @param {number} [config.stiffness=100] Affects bounciness of the animation.
14
16
  * @param {boolean} [config.overshootClamping=false] Whether to prevent the animation going beyond the target value.
15
- * @param {?number} from The initial value of the animation. Default `0`
16
- * @param {?number} to The end value of the animation. Default `1`
17
+ * @param {?number} [config.from] The initial value of the animation. Default `0`
18
+ * @param {?number} [config.to] The end value of the animation. Default `1`
19
+ * @param {?number} [config.durationInFrames] Stretch the duration of an animation to a set value.. Default `undefined`
20
+ * @param {?number} [config.durationThreshold] How close to the end the animation is considered to be done. Default `0.005`
17
21
  */
18
- function spring({ frame, fps, config = {}, from = 0, to = 1, }) {
22
+ function spring({ frame, fps, config = {}, from = 0, to = 1, durationInFrames, durationRestThreshold, }) {
23
+ (0, validation_spring_duration_1.validateSpringDuration)(durationInFrames);
24
+ const durationRatio = durationInFrames === undefined
25
+ ? 1
26
+ : durationInFrames /
27
+ (0, measure_spring_1.measureSpring)({
28
+ fps,
29
+ config,
30
+ from,
31
+ to,
32
+ threshold: durationRestThreshold,
33
+ });
19
34
  const spr = (0, spring_utils_1.springCalculation)({
20
35
  fps,
21
- frame,
36
+ frame: frame / durationRatio,
22
37
  config,
23
38
  from,
24
39
  to,
@@ -32,5 +47,5 @@ function spring({ frame, fps, config = {}, from = 0, to = 1, }) {
32
47
  return Math.max(spr.current, to);
33
48
  }
34
49
  exports.spring = spring;
35
- var measure_spring_1 = require("./measure-spring");
36
- Object.defineProperty(exports, "measureSpring", { enumerable: true, get: function () { return measure_spring_1.measureSpring; } });
50
+ var measure_spring_2 = require("./measure-spring");
51
+ Object.defineProperty(exports, "measureSpring", { enumerable: true, get: function () { return measure_spring_2.measureSpring; } });
@@ -1,4 +1,4 @@
1
- import { SpringConfig } from './spring-utils';
1
+ import type { SpringConfig } from './spring-utils';
2
2
  export declare function measureSpring({ fps, config, threshold, from, to, }: {
3
3
  fps: number;
4
4
  config?: Partial<SpringConfig>;
@@ -22,7 +22,7 @@ function measureSpring({ fps, config = {}, threshold = 0.005, from = 0, to = 1,
22
22
  if (threshold < 0) {
23
23
  throw new TypeError('Threshold is below 0');
24
24
  }
25
- (0, validate_fps_1.validateFps)(fps, 'to the measureSpring() function');
25
+ (0, validate_fps_1.validateFps)(fps, 'to the measureSpring() function', false);
26
26
  const range = Math.abs(from - to);
27
27
  let frame = 0;
28
28
  let finishedFrame = 0;
@@ -14,6 +14,12 @@ const inner = (path) => {
14
14
  return `/${trimLeadingSlash(path)}`;
15
15
  };
16
16
  const staticFile = (path) => {
17
+ if (path.startsWith('http://') || path.startsWith('https://')) {
18
+ throw new TypeError(`staticFile() does not support remote URLs - got "${path}". Instead, pass the URL without wrapping it in staticFile(). See: https://remotion.dev/docs/staticfile-remote-urls`);
19
+ }
20
+ if (path.startsWith('..') || path.startsWith('./')) {
21
+ throw new TypeError(`staticFile() does not support relative paths - got "${path}". Instead, pass the name of a file that is inside the public/ folder. See: https://remotion.dev/docs/staticfile-relative-paths`);
22
+ }
17
23
  const preparsed = inner(path);
18
24
  if (!preparsed.startsWith('/')) {
19
25
  return `/${preparsed}`;
@@ -1,4 +1,4 @@
1
- import { MutableRefObject } from 'react';
1
+ import type { MutableRefObject } from 'react';
2
2
  export declare type PlayableMediaTag = {
3
3
  play: () => void;
4
4
  id: string;
@@ -1,4 +1,3 @@
1
- export declare const useAbsoluteCurrentFrame: () => number;
2
1
  /**
3
2
  * Get the current frame of the video.
4
3
  * Frames are 0-indexed, meaning the first frame is 0, the last frame is the duration of the composition in frames minus one.
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCurrentFrame = void 0;
4
+ const react_1 = require("react");
5
+ const CanUseRemotionHooks_1 = require("./CanUseRemotionHooks");
6
+ const Sequence_1 = require("./Sequence");
7
+ const timeline_position_state_1 = require("./timeline-position-state");
8
+ /**
9
+ * Get the current frame of the video.
10
+ * Frames are 0-indexed, meaning the first frame is 0, the last frame is the duration of the composition in frames minus one.
11
+ * @link https://www.remotion.dev/docs/use-current-frame
12
+ */
13
+ const useCurrentFrame = () => {
14
+ const canUseRemotionHooks = (0, react_1.useContext)(CanUseRemotionHooks_1.CanUseRemotionHooks);
15
+ if (!canUseRemotionHooks) {
16
+ if (typeof window !== 'undefined' && window.remotion_isPlayer) {
17
+ throw new Error(`useCurrentFrame can only be called inside a component that was passed to <Player>. See: https://www.remotion.dev/docs/player/examples`);
18
+ }
19
+ 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`);
20
+ }
21
+ const frame = (0, timeline_position_state_1.useTimelinePosition)();
22
+ const context = (0, react_1.useContext)(Sequence_1.SequenceContext);
23
+ const contextOffset = context
24
+ ? context.cumulatedFrom + context.relativeFrom
25
+ : 0;
26
+ return frame - contextOffset;
27
+ };
28
+ exports.useCurrentFrame = useCurrentFrame;
@@ -1,7 +1,7 @@
1
- import React, { ComponentPropsWithRef, ComponentType, ExoticComponent } from 'react';
2
- import { CompProps } from './internals';
1
+ import type { ComponentPropsWithRef, ComponentType, ExoticComponent } from 'react';
2
+ import type { CompProps } from './internals';
3
3
  declare type LazyExoticComponent<T extends ComponentType<any>> = ExoticComponent<ComponentPropsWithRef<T>> & {
4
4
  readonly _result: T;
5
5
  };
6
- export declare const useLazyComponent: <T>(compProps: CompProps<T>) => LazyExoticComponent<React.ComponentType<T>>;
6
+ export declare const useLazyComponent: <T>(compProps: CompProps<T>) => LazyExoticComponent<ComponentType<T>>;
7
7
  export {};
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,5 +1,5 @@
1
- import { RefObject } from 'react';
2
- import { VolumeProp } from './volume-prop';
1
+ import type { RefObject } from 'react';
2
+ import type { VolumeProp } from './volume-prop';
3
3
  export declare const useMediaInTimeline: ({ volume, mediaVolume, mediaRef, src, mediaType, }: {
4
4
  volume: VolumeProp | undefined;
5
5
  mediaVolume: number;
@@ -5,9 +5,10 @@ const react_1 = require("react");
5
5
  const use_audio_frame_1 = require("./audio/use-audio-frame");
6
6
  const CompositionManager_1 = require("./CompositionManager");
7
7
  const get_asset_file_name_1 = require("./get-asset-file-name");
8
+ const get_environment_1 = require("./get-environment");
8
9
  const nonce_1 = require("./nonce");
9
10
  const play_and_handle_not_allowed_error_1 = require("./play-and-handle-not-allowed-error");
10
- const sequencing_1 = require("./sequencing");
11
+ const Sequence_1 = require("./Sequence");
11
12
  const timeline_position_state_1 = require("./timeline-position-state");
12
13
  const use_video_config_1 = require("./use-video-config");
13
14
  const volume_prop_1 = require("./volume-prop");
@@ -22,7 +23,7 @@ const warnOnce = (message) => {
22
23
  const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, }) => {
23
24
  const videoConfig = (0, use_video_config_1.useVideoConfig)();
24
25
  const { rootId, audioAndVideoTags } = (0, react_1.useContext)(timeline_position_state_1.TimelineContext);
25
- const parentSequence = (0, react_1.useContext)(sequencing_1.SequenceContext);
26
+ const parentSequence = (0, react_1.useContext)(Sequence_1.SequenceContext);
26
27
  const actualFrom = parentSequence
27
28
  ? parentSequence.relativeFrom + parentSequence.cumulatedFrom
28
29
  : 0;
@@ -32,11 +33,9 @@ const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, })
32
33
  const [id] = (0, react_1.useState)(() => String(Math.random()));
33
34
  const [initialVolume] = (0, react_1.useState)(() => volume);
34
35
  const nonce = (0, nonce_1.useNonce)();
35
- const duration = (() => {
36
- return parentSequence
37
- ? Math.min(parentSequence.durationInFrames, videoConfig.durationInFrames)
38
- : videoConfig.durationInFrames;
39
- })();
36
+ const duration = parentSequence
37
+ ? Math.min(parentSequence.durationInFrames, videoConfig.durationInFrames)
38
+ : videoConfig.durationInFrames;
40
39
  const doesVolumeChange = typeof volume === 'function';
41
40
  const volumes = (0, react_1.useMemo)(() => {
42
41
  if (typeof volume === 'number') {
@@ -66,6 +65,10 @@ const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, })
66
65
  if (!src) {
67
66
  throw new Error('No src passed');
68
67
  }
68
+ if ((0, get_environment_1.getRemotionEnvironment)() !== 'preview' &&
69
+ process.env.NODE_ENV !== 'test') {
70
+ return;
71
+ }
69
72
  registerSequence({
70
73
  type: mediaType,
71
74
  src,
@@ -1,7 +1,8 @@
1
- import { RefObject } from 'react';
2
- export declare const useMediaPlayback: ({ mediaRef, src, mediaType, playbackRate: localPlaybackRate, }: {
1
+ import type { RefObject } from 'react';
2
+ export declare const useMediaPlayback: ({ mediaRef, src, mediaType, playbackRate: localPlaybackRate, onlyWarnForMediaSeekingError, }: {
3
3
  mediaRef: RefObject<HTMLVideoElement | HTMLAudioElement>;
4
4
  src: string | undefined;
5
5
  mediaType: 'audio' | 'video';
6
6
  playbackRate: number;
7
+ onlyWarnForMediaSeekingError: boolean;
7
8
  }) => void;
@@ -5,14 +5,14 @@ const react_1 = require("react");
5
5
  const use_audio_frame_1 = require("./audio/use-audio-frame");
6
6
  const play_and_handle_not_allowed_error_1 = require("./play-and-handle-not-allowed-error");
7
7
  const timeline_position_state_1 = require("./timeline-position-state");
8
- const use_frame_1 = require("./use-frame");
8
+ const use_current_frame_1 = require("./use-current-frame");
9
9
  const use_video_config_1 = require("./use-video-config");
10
10
  const get_current_time_1 = require("./video/get-current-time");
11
11
  const warn_about_non_seekable_media_1 = require("./warn-about-non-seekable-media");
12
- const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybackRate, }) => {
12
+ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybackRate, onlyWarnForMediaSeekingError, }) => {
13
13
  const { playbackRate: globalPlaybackRate } = (0, react_1.useContext)(timeline_position_state_1.TimelineContext);
14
- const frame = (0, use_frame_1.useCurrentFrame)();
15
- const absoluteFrame = (0, use_frame_1.useAbsoluteCurrentFrame)();
14
+ const frame = (0, use_current_frame_1.useCurrentFrame)();
15
+ const absoluteFrame = (0, timeline_position_state_1.useTimelinePosition)();
16
16
  const [playing] = (0, timeline_position_state_1.usePlayingState)();
17
17
  const { fps } = (0, use_video_config_1.useVideoConfig)();
18
18
  const mediaStartsAt = (0, use_audio_frame_1.useMediaStartsAt)();
@@ -38,15 +38,17 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
38
38
  src,
39
39
  playbackRate: localPlaybackRate,
40
40
  startFrom: -mediaStartsAt,
41
+ mediaType,
41
42
  });
42
43
  const isTime = mediaRef.current.currentTime;
43
44
  const timeShift = Math.abs(shouldBeTime - isTime);
44
45
  if (timeShift > 0.45 && !mediaRef.current.ended) {
45
- console.log('Time has shifted by', timeShift, 'sec. Fixing...', `(isTime=${isTime},shouldBeTime=${shouldBeTime})`);
46
46
  // If scrubbing around, adjust timing
47
47
  // or if time shift is bigger than 0.2sec
48
48
  mediaRef.current.currentTime = shouldBeTime;
49
- (0, warn_about_non_seekable_media_1.warnAboutNonSeekableMedia)(mediaRef.current);
49
+ if (!onlyWarnForMediaSeekingError) {
50
+ (0, warn_about_non_seekable_media_1.warnAboutNonSeekableMedia)(mediaRef.current, onlyWarnForMediaSeekingError ? 'console-warning' : 'console-error');
51
+ }
50
52
  }
51
53
  if (!playing || absoluteFrame === 0) {
52
54
  mediaRef.current.currentTime = shouldBeTime;
@@ -67,6 +69,7 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
67
69
  src,
68
70
  mediaStartsAt,
69
71
  localPlaybackRate,
72
+ onlyWarnForMediaSeekingError,
70
73
  ]);
71
74
  };
72
75
  exports.useMediaPlayback = useMediaPlayback;
@@ -1,2 +1,2 @@
1
- import { RefObject } from 'react';
1
+ import type { RefObject } from 'react';
2
2
  export declare const useMediaTagVolume: (mediaRef: RefObject<HTMLVideoElement | HTMLAudioElement>) => number;
@@ -1,5 +1,5 @@
1
- import { RefObject } from 'react';
2
- import { VolumeProp } from './volume-prop';
1
+ import type { RefObject } from 'react';
2
+ import type { VolumeProp } from './volume-prop';
3
3
  export declare type UseSyncVolumeWithMediaTagOptions = {
4
4
  volumePropFrame: number;
5
5
  actualVolume: number;
@@ -1,2 +1,2 @@
1
- import { VideoConfig } from './video-config';
1
+ import type { VideoConfig } from './video-config';
2
2
  export declare const useUnsafeVideoConfig: () => VideoConfig | null;
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useUnsafeVideoConfig = void 0;
4
4
  const react_1 = require("react");
5
- const sequencing_1 = require("./sequencing");
5
+ const Sequence_1 = require("./Sequence");
6
6
  const use_video_1 = require("./use-video");
7
7
  const useUnsafeVideoConfig = () => {
8
8
  var _a;
9
- const context = (0, react_1.useContext)(sequencing_1.SequenceContext);
9
+ const context = (0, react_1.useContext)(Sequence_1.SequenceContext);
10
10
  const ctxDuration = (_a = context === null || context === void 0 ? void 0 : context.durationInFrames) !== null && _a !== void 0 ? _a : null;
11
11
  const video = (0, use_video_1.useVideo)();
12
12
  return (0, react_1.useMemo)(() => {
@@ -1,4 +1,4 @@
1
- import { VideoConfig } from './video-config';
1
+ import type { VideoConfig } from './video-config';
2
2
  /**
3
3
  * Get some info about the context of the video that you are making.
4
4
  * Returns an object containing `fps`, `width`, `height` and `durationInFrames`, all of type `number`.
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useVideoConfig = void 0;
4
+ const react_1 = require("react");
5
+ const CanUseRemotionHooks_1 = require("./CanUseRemotionHooks");
4
6
  const use_unsafe_video_config_1 = require("./use-unsafe-video-config");
5
7
  /**
6
8
  * Get some info about the context of the video that you are making.
@@ -9,12 +11,16 @@ const use_unsafe_video_config_1 = require("./use-unsafe-video-config");
9
11
  */
10
12
  const useVideoConfig = () => {
11
13
  const videoConfig = (0, use_unsafe_video_config_1.useUnsafeVideoConfig)();
14
+ const context = (0, react_1.useContext)(CanUseRemotionHooks_1.CanUseRemotionHooks);
12
15
  if (!videoConfig) {
13
16
  if (typeof window !== 'undefined' && window.remotion_isPlayer) {
14
17
  throw new Error('No video config found. You are probably calling useVideoConfig() from outside the component passed to <Player />. See https://www.remotion.dev/docs/player/examples for how to set up the Player correctly.');
15
18
  }
16
19
  throw new Error('No video config found. You are probably calling useVideoConfig() from a component which has not been registered as a <Composition />. See https://www.remotion.dev/docs/the-fundamentals#defining-compositions for more information.');
17
20
  }
21
+ if (!context) {
22
+ throw new Error('Called useVideoConfig() outside a Remotion composition.');
23
+ }
18
24
  return videoConfig;
19
25
  };
20
26
  exports.useVideoConfig = useVideoConfig;
@@ -1 +1,13 @@
1
- export declare const useVideo: () => import("./CompositionManager").TComposition<unknown> | null;
1
+ /// <reference types="react" />
2
+ export declare const useVideo: () => {
3
+ height: number;
4
+ width: number;
5
+ fps: number;
6
+ durationInFrames: number;
7
+ defaultProps: unknown;
8
+ id: string;
9
+ folderName: string | null;
10
+ parentFolderName: string | null;
11
+ component: import("react").LazyExoticComponent<import("react").ComponentType<unknown>>;
12
+ nonce: number;
13
+ } | null;
package/dist/use-video.js CHANGED
@@ -7,9 +7,22 @@ const useVideo = () => {
7
7
  const context = (0, react_1.useContext)(CompositionManager_1.CompositionManager);
8
8
  return (0, react_1.useMemo)(() => {
9
9
  var _a;
10
- return (_a = context.compositions.find((c) => {
10
+ const selected = context.compositions.find((c) => {
11
11
  return c.id === context.currentComposition;
12
- })) !== null && _a !== void 0 ? _a : null;
13
- }, [context.compositions, context.currentComposition]);
12
+ });
13
+ if (selected) {
14
+ return {
15
+ ...selected,
16
+ // We override the selected metadata with the metadata that was passed to renderMedia(),
17
+ // and don't allow it to be changed during render anymore
18
+ ...((_a = context.currentCompositionMetadata) !== null && _a !== void 0 ? _a : {}),
19
+ };
20
+ }
21
+ return null;
22
+ }, [
23
+ context.compositions,
24
+ context.currentComposition,
25
+ context.currentCompositionMetadata,
26
+ ]);
14
27
  };
15
28
  exports.useVideo = useVideo;
@@ -1,3 +1,4 @@
1
- import { RemotionAudioProps } from './audio';
2
- import { RemotionVideoProps } from './video';
3
- export declare const validateMediaProps: (props: RemotionVideoProps | RemotionAudioProps, component: 'Video' | 'Audio') => void;
1
+ import type { RemotionAudioProps } from './audio';
2
+ import type { RemotionVideoProps } from './video';
3
+ import type { OffthreadVideoProps } from './video/props';
4
+ export declare const validateMediaProps: (props: RemotionVideoProps | RemotionAudioProps | OffthreadVideoProps, component: 'Video' | 'Audio') => void;
@@ -1 +1 @@
1
- export declare const validateFps: (fps: number, location: string) => void;
1
+ export declare const validateFps: (fps: number, location: string, isGif: boolean) => void;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateFps = void 0;
4
- const validateFps = (fps, location) => {
4
+ const validateFps = (fps, location, isGif) => {
5
5
  if (typeof fps !== 'number') {
6
6
  throw new Error(`"fps" must be a number, but you passed a value of type ${typeof fps} ${location}`);
7
7
  }
@@ -14,5 +14,8 @@ const validateFps = (fps, location) => {
14
14
  if (fps <= 0) {
15
15
  throw new TypeError(`"fps" must be positive, but got ${fps} ${location}`);
16
16
  }
17
+ if (isGif && fps > 50) {
18
+ throw new TypeError(`The FPS for a GIF cannot be higher than 50. Use the --every-nth-frame option to lower the FPS: https://remotion.dev/docs/render-as-gif`);
19
+ }
17
20
  };
18
21
  exports.validateFps = validateFps;
@@ -0,0 +1 @@
1
+ export declare const validateOffthreadVideoImageFormat: (input: unknown) => void;