remotion 4.0.142 → 4.0.144

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 (54) hide show
  1. package/LICENSE.md +4 -0
  2. package/bunfig.toml +2 -0
  3. package/dist/cjs/CanUseRemotionHooks.d.ts +1 -1
  4. package/dist/cjs/Img.js +3 -2
  5. package/dist/cjs/Sequence.d.ts +14 -13
  6. package/dist/cjs/audio/Audio.d.ts +2 -1
  7. package/dist/cjs/audio/AudioForPreview.d.ts +7 -6
  8. package/dist/cjs/audio/AudioForPreview.js +2 -2
  9. package/dist/cjs/audio/AudioForRendering.d.ts +1 -0
  10. package/dist/cjs/audio/AudioForRendering.js +2 -2
  11. package/dist/cjs/audio/props.d.ts +2 -0
  12. package/dist/cjs/audio/use-audio-frame.d.ts +2 -1
  13. package/dist/cjs/audio/use-audio-frame.js +7 -2
  14. package/dist/cjs/default-css.d.ts +1 -1
  15. package/dist/cjs/default-css.js +3 -3
  16. package/dist/cjs/get-static-files.js +4 -0
  17. package/dist/cjs/index.d.ts +3 -3
  18. package/dist/cjs/internals.d.ts +1 -6
  19. package/dist/cjs/internals.js +0 -5
  20. package/dist/cjs/interpolate.d.ts +1 -1
  21. package/dist/cjs/loop/index.d.ts +13 -5
  22. package/dist/cjs/loop/index.js +38 -3
  23. package/dist/cjs/no-react.d.ts +5 -0
  24. package/dist/cjs/no-react.js +4 -0
  25. package/dist/cjs/series/index.js +4 -3
  26. package/dist/cjs/series/is-inside-series.d.ts +9 -0
  27. package/dist/cjs/series/is-inside-series.js +44 -0
  28. package/dist/cjs/spring/index.d.ts +2 -2
  29. package/dist/cjs/spring/index.js +8 -9
  30. package/dist/cjs/spring/measure-spring.d.ts +1 -1
  31. package/dist/cjs/spring/measure-spring.js +0 -2
  32. package/dist/cjs/spring/spring-utils.d.ts +1 -3
  33. package/dist/cjs/spring/spring-utils.js +3 -3
  34. package/dist/cjs/use-video-config.d.ts +1 -2
  35. package/dist/cjs/use-video-config.js +1 -2
  36. package/dist/cjs/version.d.ts +6 -1
  37. package/dist/cjs/version.js +7 -2
  38. package/dist/cjs/video/OffthreadVideoForRendering.js +2 -2
  39. package/dist/cjs/video/Video.d.ts +3 -2
  40. package/dist/cjs/video/VideoForPreview.d.ts +7 -7
  41. package/dist/cjs/video/VideoForPreview.js +5 -7
  42. package/dist/cjs/video/VideoForRendering.d.ts +1 -0
  43. package/dist/cjs/video/VideoForRendering.js +2 -2
  44. package/dist/cjs/video/index.d.ts +1 -1
  45. package/dist/cjs/video/props.d.ts +3 -0
  46. package/dist/cjs/video/video-fragment.js +9 -5
  47. package/dist/cjs/watch-static-file.js +4 -0
  48. package/dist/esm/index.mjs +576 -546
  49. package/dist/esm/no-react.mjs +3 -0
  50. package/dist/esm/version.mjs +6 -1
  51. package/ensure-correct-version.ts +47 -0
  52. package/happydom.ts +6 -0
  53. package/package.json +3 -1
  54. package/test.ts +1 -0
package/LICENSE.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Remotion License
2
2
 
3
+ In Remotion 5.0, the license will slightly change. [View the changes here](https://github.com/remotion-dev/remotion/pull/3750).
4
+
5
+ ---
6
+
3
7
  Depending on the type of your legal entity, you are granted permission to use Remotion for your project. Individuals and small companies are allowed to use Remotion to create videos for free (even commercial), while a company license is required for for-profit organizations of a certain size. This two-tier system was designed to ensure funding for this project while still allowing the source code to be available and the program to be free for most. Read below for the exact terms of use.
4
8
 
5
9
  - [Free license](#free-license)
package/bunfig.toml ADDED
@@ -0,0 +1,2 @@
1
+ [test]
2
+ #preload = "./happydom.ts"
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  export declare const CanUseRemotionHooks: React.Context<boolean>;
3
3
  export declare const CanUseRemotionHooksProvider: React.FC<{
4
- children: React.ReactNode;
4
+ readonly children: React.ReactNode;
5
5
  }>;
package/dist/cjs/Img.js CHANGED
@@ -65,6 +65,7 @@ const ImgRefForwarding = ({ onError, maxRetries = 2, src, pauseWhenLoading, dela
65
65
  (0, cancel_render_js_1.cancelRender)('Error loading image with src: ' + ((_l = imageRef.current) === null || _l === void 0 ? void 0 : _l.src));
66
66
  }, [maxRetries, onError, retryIn]);
67
67
  if (typeof window !== 'undefined') {
68
+ const isPremounting = Boolean(sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.premounting);
68
69
  // eslint-disable-next-line react-hooks/rules-of-hooks
69
70
  (0, react_1.useLayoutEffect)(() => {
70
71
  if (process.env.NODE_ENV === 'test') {
@@ -74,7 +75,7 @@ const ImgRefForwarding = ({ onError, maxRetries = 2, src, pauseWhenLoading, dela
74
75
  retries: delayRenderRetries !== null && delayRenderRetries !== void 0 ? delayRenderRetries : undefined,
75
76
  timeoutInMilliseconds: delayRenderTimeoutInMilliseconds !== null && delayRenderTimeoutInMilliseconds !== void 0 ? delayRenderTimeoutInMilliseconds : undefined,
76
77
  });
77
- const unblock = pauseWhenLoading && !(sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.premounting)
78
+ const unblock = pauseWhenLoading && !isPremounting
78
79
  ? delayPlayback().unblock
79
80
  : () => undefined;
80
81
  const { current } = imageRef;
@@ -109,7 +110,7 @@ const ImgRefForwarding = ({ onError, maxRetries = 2, src, pauseWhenLoading, dela
109
110
  delayRenderRetries,
110
111
  delayRenderTimeoutInMilliseconds,
111
112
  pauseWhenLoading,
112
- sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.premounting,
113
+ isPremounting,
113
114
  ]);
114
115
  }
115
116
  return ((0, jsx_runtime_1.jsx)("img", { ...props, ref: imageRef, src: actualSrc, onError: didGetError }));
@@ -1,39 +1,40 @@
1
1
  import React from 'react';
2
2
  import type { LoopDisplay } from './CompositionManager.js';
3
- export type LayoutAndStyle = {
3
+ export type AbsoluteFillLayout = {
4
4
  layout?: 'absolute-fill';
5
5
  premountFor?: number;
6
6
  style?: React.CSSProperties;
7
7
  className?: string;
8
- } | {
8
+ };
9
+ export type LayoutAndStyle = AbsoluteFillLayout | {
9
10
  layout: 'none';
10
11
  };
11
12
  export type SequencePropsWithoutDuration = {
12
- children: React.ReactNode;
13
- width?: number;
14
- height?: number;
15
- from?: number;
16
- name?: string;
17
- showInTimeline?: boolean;
13
+ readonly children: React.ReactNode;
14
+ readonly width?: number;
15
+ readonly height?: number;
16
+ readonly from?: number;
17
+ readonly name?: string;
18
+ readonly showInTimeline?: boolean;
18
19
  /**
19
20
  * @deprecated For internal use only.
20
21
  */
21
- _remotionInternalLoopDisplay?: LoopDisplay;
22
+ readonly _remotionInternalLoopDisplay?: LoopDisplay;
22
23
  /**
23
24
  * @deprecated For internal use only.
24
25
  */
25
- _remotionInternalPremountDisplay?: number | null;
26
+ readonly _remotionInternalPremountDisplay?: number | null;
26
27
  /**
27
28
  * @deprecated For internal use only.
28
29
  */
29
- _remotionInternalStack?: string;
30
+ readonly _remotionInternalStack?: string;
30
31
  /**
31
32
  * @deprecated For internal use only.
32
33
  */
33
- _remotionInternalIsPremounting?: boolean;
34
+ readonly _remotionInternalIsPremounting?: boolean;
34
35
  } & LayoutAndStyle;
35
36
  export type SequenceProps = {
36
- durationInFrames?: number;
37
+ readonly durationInFrames?: number;
37
38
  } & SequencePropsWithoutDuration;
38
39
  /**
39
40
  * @description A component that time-shifts its children and wraps them in an absolutely positioned <div>.
@@ -17,9 +17,10 @@ export declare const Audio: React.ForwardRefExoticComponent<Omit<Omit<React.Deta
17
17
  showInTimeline?: boolean | undefined;
18
18
  delayRenderTimeoutInMilliseconds?: number | undefined;
19
19
  delayRenderRetries?: number | undefined;
20
+ loopVolumeCurveBehavior?: import("./use-audio-frame.js").LoopVolumeCurveBehavior | undefined;
20
21
  } & RemotionMainAudioProps & {
21
22
  /**
22
23
  * @deprecated For internal use only
23
24
  */
24
- stack?: string | undefined;
25
+ readonly stack?: string | undefined;
25
26
  }, "ref"> & React.RefAttributes<HTMLAudioElement>>;
@@ -1,12 +1,13 @@
1
1
  import React from 'react';
2
2
  import type { RemotionAudioProps } from './props.js';
3
3
  type AudioForPreviewProps = RemotionAudioProps & {
4
- shouldPreMountAudioTags: boolean;
5
- onDuration: (src: string, durationInSeconds: number) => void;
6
- pauseWhenBuffering: boolean;
7
- _remotionInternalNativeLoopPassed: boolean;
8
- _remotionInternalStack: string | null;
9
- showInTimeline: boolean;
4
+ readonly shouldPreMountAudioTags: boolean;
5
+ readonly onDuration: (src: string, durationInSeconds: number) => void;
6
+ readonly pauseWhenBuffering: boolean;
7
+ readonly _remotionInternalNativeLoopPassed: boolean;
8
+ readonly _remotionInternalStack: string | null;
9
+ readonly showInTimeline: boolean;
10
+ readonly stack?: string | undefined;
10
11
  };
11
12
  export declare const AudioForPreview: React.ForwardRefExoticComponent<Omit<AudioForPreviewProps, "ref"> & React.RefAttributes<HTMLAudioElement>>;
12
13
  export {};
@@ -21,10 +21,10 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
21
21
  if (props.shouldPreMountAudioTags !== initialShouldPreMountAudioElements) {
22
22
  throw new Error('Cannot change the behavior for pre-mounting audio tags dynamically.');
23
23
  }
24
+ const { volume, muted, playbackRate, shouldPreMountAudioTags, src, onDuration, acceptableTimeShiftInSeconds, _remotionInternalNeedsDurationCalculation, _remotionInternalNativeLoopPassed, _remotionInternalStack, allowAmplificationDuringRender, name, pauseWhenBuffering, showInTimeline, loopVolumeCurveBehavior, stack, ...nativeProps } = props;
24
25
  const [mediaVolume] = (0, volume_position_state_js_1.useMediaVolumeState)();
25
26
  const [mediaMuted] = (0, volume_position_state_js_1.useMediaMutedState)();
26
- const volumePropFrame = (0, use_audio_frame_js_1.useFrameForVolumeProp)();
27
- const { volume, muted, playbackRate, shouldPreMountAudioTags, src, onDuration, acceptableTimeShiftInSeconds, _remotionInternalNeedsDurationCalculation, _remotionInternalNativeLoopPassed, _remotionInternalStack, allowAmplificationDuringRender, name, pauseWhenBuffering, showInTimeline, ...nativeProps } = props;
27
+ const volumePropFrame = (0, use_audio_frame_js_1.useFrameForVolumeProp)(loopVolumeCurveBehavior !== null && loopVolumeCurveBehavior !== void 0 ? loopVolumeCurveBehavior : 'repeat');
28
28
  const { hidden } = (0, react_1.useContext)(SequenceManager_js_1.SequenceVisibilityToggleContext);
29
29
  if (!src) {
30
30
  throw new TypeError("No 'src' was passed to <Audio>.");
@@ -13,6 +13,7 @@ export declare const AudioForRendering: ForwardRefExoticComponent<Omit<React.Det
13
13
  showInTimeline?: boolean | undefined;
14
14
  delayRenderTimeoutInMilliseconds?: number | undefined;
15
15
  delayRenderRetries?: number | undefined;
16
+ loopVolumeCurveBehavior?: import("./use-audio-frame.js").LoopVolumeCurveBehavior | undefined;
16
17
  } & {
17
18
  readonly onDuration: (src: string, durationInSeconds: number) => void;
18
19
  } & RefAttributes<HTMLAudioElement>>;
@@ -14,8 +14,9 @@ const volume_prop_js_1 = require("../volume-prop.js");
14
14
  const use_audio_frame_js_1 = require("./use-audio-frame.js");
15
15
  const AudioForRenderingRefForwardingFunction = (props, ref) => {
16
16
  const audioRef = (0, react_1.useRef)(null);
17
+ const { volume: volumeProp, playbackRate, allowAmplificationDuringRender, onDuration, toneFrequency, _remotionInternalNeedsDurationCalculation, _remotionInternalNativeLoopPassed, acceptableTimeShiftInSeconds, name, onError, delayRenderRetries, delayRenderTimeoutInMilliseconds, loopVolumeCurveBehavior, ...nativeProps } = props;
17
18
  const absoluteFrame = (0, timeline_position_state_js_1.useTimelinePosition)();
18
- const volumePropFrame = (0, use_audio_frame_js_1.useFrameForVolumeProp)();
19
+ const volumePropFrame = (0, use_audio_frame_js_1.useFrameForVolumeProp)(loopVolumeCurveBehavior !== null && loopVolumeCurveBehavior !== void 0 ? loopVolumeCurveBehavior : 'repeat');
19
20
  const frame = (0, use_current_frame_js_1.useCurrentFrame)();
20
21
  const sequenceContext = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
21
22
  const { registerRenderAsset, unregisterRenderAsset } = (0, react_1.useContext)(RenderAssetManager_js_1.RenderAssetManager);
@@ -30,7 +31,6 @@ const AudioForRenderingRefForwardingFunction = (props, ref) => {
30
31
  sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.cumulatedFrom,
31
32
  sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.durationInFrames,
32
33
  ]);
33
- const { volume: volumeProp, playbackRate, allowAmplificationDuringRender, onDuration, toneFrequency, _remotionInternalNeedsDurationCalculation, _remotionInternalNativeLoopPassed, acceptableTimeShiftInSeconds, name, onError, delayRenderRetries, delayRenderTimeoutInMilliseconds, ...nativeProps } = props;
34
34
  const volume = (0, volume_prop_js_1.evaluateVolume)({
35
35
  volume: volumeProp,
36
36
  frame: volumePropFrame,
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { VolumeProp } from '../volume-prop.js';
3
+ import type { LoopVolumeCurveBehavior } from './use-audio-frame.js';
3
4
  export type RemotionMainAudioProps = {
4
5
  startFrom?: number;
5
6
  endAt?: number;
@@ -17,4 +18,5 @@ export type RemotionAudioProps = Omit<React.DetailedHTMLProps<React.AudioHTMLAtt
17
18
  showInTimeline?: boolean;
18
19
  delayRenderTimeoutInMilliseconds?: number;
19
20
  delayRenderRetries?: number;
21
+ loopVolumeCurveBehavior?: LoopVolumeCurveBehavior;
20
22
  };
@@ -1,6 +1,7 @@
1
1
  export declare const useMediaStartsAt: () => number;
2
+ export type LoopVolumeCurveBehavior = 'repeat' | 'extend';
2
3
  /**
3
4
  * When passing a function as the prop for `volume`,
4
5
  * we calculate the way more intuitive value for currentFrame
5
6
  */
6
- export declare const useFrameForVolumeProp: () => number;
7
+ export declare const useFrameForVolumeProp: (behavior: LoopVolumeCurveBehavior) => number;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useFrameForVolumeProp = exports.useMediaStartsAt = void 0;
4
4
  const react_1 = require("react");
5
5
  const SequenceContext_js_1 = require("../SequenceContext.js");
6
+ const index_js_1 = require("../loop/index.js");
6
7
  const use_current_frame_js_1 = require("../use-current-frame.js");
7
8
  const useMediaStartsAt = () => {
8
9
  var _a;
@@ -15,9 +16,13 @@ exports.useMediaStartsAt = useMediaStartsAt;
15
16
  * When passing a function as the prop for `volume`,
16
17
  * we calculate the way more intuitive value for currentFrame
17
18
  */
18
- const useFrameForVolumeProp = () => {
19
+ const useFrameForVolumeProp = (behavior) => {
20
+ const loop = index_js_1.Loop.useLoop();
19
21
  const frame = (0, use_current_frame_js_1.useCurrentFrame)();
20
22
  const startsAt = (0, exports.useMediaStartsAt)();
21
- return frame + startsAt;
23
+ if (behavior === 'repeat' || loop === null) {
24
+ return frame + startsAt;
25
+ }
26
+ return frame + startsAt + loop.durationInFrames * loop.iteration;
22
27
  };
23
28
  exports.useFrameForVolumeProp = useFrameForVolumeProp;
@@ -1,3 +1,3 @@
1
1
  export declare const injectCSS: (css: string) => void;
2
2
  export declare const OFFTHREAD_VIDEO_CLASS_NAME = "__remotion_offthreadvideo";
3
- export declare const makeDefaultCSS: (scope: string | null, backgroundColor: string) => string;
3
+ export declare const makeDefaultPreviewCSS: (scope: string | null, backgroundColor: string) => string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeDefaultCSS = exports.OFFTHREAD_VIDEO_CLASS_NAME = exports.injectCSS = void 0;
3
+ exports.makeDefaultPreviewCSS = exports.OFFTHREAD_VIDEO_CLASS_NAME = exports.injectCSS = void 0;
4
4
  const injected = {};
5
5
  const injectCSS = (css) => {
6
6
  // Skip in node
@@ -18,7 +18,7 @@ const injectCSS = (css) => {
18
18
  };
19
19
  exports.injectCSS = injectCSS;
20
20
  exports.OFFTHREAD_VIDEO_CLASS_NAME = '__remotion_offthreadvideo';
21
- const makeDefaultCSS = (scope, backgroundColor) => {
21
+ const makeDefaultPreviewCSS = (scope, backgroundColor) => {
22
22
  if (!scope) {
23
23
  return `
24
24
  * {
@@ -46,4 +46,4 @@ const makeDefaultCSS = (scope, backgroundColor) => {
46
46
  }
47
47
  `;
48
48
  };
49
- exports.makeDefaultCSS = makeDefaultCSS;
49
+ exports.makeDefaultPreviewCSS = makeDefaultPreviewCSS;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getStaticFiles = void 0;
4
+ const v5_flag_1 = require("./v5-flag");
4
5
  let warnedServer = false;
5
6
  let warnedPlayer = false;
6
7
  const warnServerOnce = () => {
@@ -24,6 +25,9 @@ const warnPlayerOnce = () => {
24
25
  * @see [Documentation](https://www.remotion.dev/docs/getstaticfiles)
25
26
  */
26
27
  const getStaticFiles = () => {
28
+ if (v5_flag_1.ENABLE_V5_BREAKING_CHANGES) {
29
+ throw new Error('getStaticFiles() has moved into the `@remotion/studio` package. Update your imports.');
30
+ }
27
31
  if (typeof document === 'undefined') {
28
32
  warnServerOnce();
29
33
  return [];
@@ -1,4 +1,4 @@
1
- /// <reference types="node" />
1
+ /// <reference types="bun-types" />
2
2
  /// <reference types="react" />
3
3
  import './asset-types.js';
4
4
  import type { Codec } from './codec.js';
@@ -16,7 +16,7 @@ declare global {
16
16
  remotion_delayRenderTimeouts: {
17
17
  [key: string]: {
18
18
  label: string | null;
19
- timeout: number | NodeJS.Timeout;
19
+ timeout: number | Timer;
20
20
  };
21
21
  };
22
22
  remotion_cancelledError: string | undefined;
@@ -90,7 +90,7 @@ export { ClipRegion } from './NativeLayers.js';
90
90
  export { EasingFunction, ExtrapolateType, interpolate, InterpolateOptions, random, RandomSeed, } from './no-react';
91
91
  export { prefetch, PrefetchOnProgress } from './prefetch.js';
92
92
  export { registerRoot } from './register-root.js';
93
- export { LayoutAndStyle, Sequence, SequenceProps, SequencePropsWithoutDuration, } from './Sequence.js';
93
+ export { AbsoluteFillLayout, LayoutAndStyle, Sequence, SequenceProps, SequencePropsWithoutDuration, } from './Sequence.js';
94
94
  export { Series } from './series/index.js';
95
95
  export * from './spring/index.js';
96
96
  export { staticFile } from './static-file.js';
@@ -69,7 +69,7 @@ export declare const Internals: {
69
69
  readonly portalNode: () => HTMLElement;
70
70
  readonly waitForRoot: (fn: (comp: import("react").FC<{}>) => void) => () => void;
71
71
  readonly CanUseRemotionHooksProvider: import("react").FC<{
72
- children: import("react").ReactNode;
72
+ readonly children: import("react").ReactNode;
73
73
  }>;
74
74
  readonly CanUseRemotionHooks: import("react").Context<boolean>;
75
75
  readonly PrefetchProvider: import("react").FC<{
@@ -116,8 +116,6 @@ export declare const Internals: {
116
116
  [x: string]: number;
117
117
  }) => void;
118
118
  readonly useTimelineSetFrame: () => (u: import("react").SetStateAction<Record<string, number>>) => void;
119
- readonly FILE_TOKEN: "remotion-file:";
120
- readonly DATE_TOKEN: "remotion-date:";
121
119
  readonly NativeLayersProvider: import("react").FC<{
122
120
  children?: import("react").ReactNode;
123
121
  }>;
@@ -146,9 +144,6 @@ export declare const Internals: {
146
144
  buffering: import("react").MutableRefObject<boolean>;
147
145
  } | null>;
148
146
  readonly enableSequenceStackTraces: () => void;
149
- readonly colorNames: {
150
- [key: string]: number;
151
- };
152
147
  readonly CurrentScaleContext: import("react").Context<import("./use-current-scale.js").CurrentScaleContextType | null>;
153
148
  readonly PreviewSizeContext: import("react").Context<import("./use-current-scale.js").PreviewSizeCtx>;
154
149
  readonly calculateScale: ({ canvasSize, compositionHeight, compositionWidth, previewSize, }: {
@@ -36,8 +36,6 @@ const EditorProps_js_1 = require("./EditorProps.js");
36
36
  const enable_sequence_stack_traces_js_1 = require("./enable-sequence-stack-traces.js");
37
37
  const get_preview_dom_element_js_1 = require("./get-preview-dom-element.js");
38
38
  const get_remotion_environment_js_1 = require("./get-remotion-environment.js");
39
- const input_props_serialization_js_1 = require("./input-props-serialization.js");
40
- const interpolate_colors_js_1 = require("./interpolate-colors.js");
41
39
  const is_player_js_1 = require("./is-player.js");
42
40
  const NativeLayers_js_1 = require("./NativeLayers.js");
43
41
  const nonce_js_1 = require("./nonce.js");
@@ -114,8 +112,6 @@ exports.Internals = {
114
112
  RenderAssetManager: RenderAssetManager_js_1.RenderAssetManager,
115
113
  persistCurrentFrame: timeline_position_state_js_1.persistCurrentFrame,
116
114
  useTimelineSetFrame: timeline_position_state_js_1.useTimelineSetFrame,
117
- FILE_TOKEN: input_props_serialization_js_1.FILE_TOKEN,
118
- DATE_TOKEN: input_props_serialization_js_1.DATE_TOKEN,
119
115
  NativeLayersProvider: NativeLayers_js_1.NativeLayersProvider,
120
116
  ClipComposition: Composition_js_1.ClipComposition,
121
117
  isIosSafari: video_fragment_js_1.isIosSafari,
@@ -125,7 +121,6 @@ exports.Internals = {
125
121
  BufferingProvider: buffering_js_1.BufferingProvider,
126
122
  BufferingContextReact: buffering_js_1.BufferingContextReact,
127
123
  enableSequenceStackTraces: enable_sequence_stack_traces_js_1.enableSequenceStackTraces,
128
- colorNames: interpolate_colors_js_1.colorNames,
129
124
  CurrentScaleContext: use_current_scale_js_1.CurrentScaleContext,
130
125
  PreviewSizeContext: use_current_scale_js_1.PreviewSizeContext,
131
126
  calculateScale: use_current_scale_js_1.calculateScale,
@@ -1,6 +1,6 @@
1
1
  export type ExtrapolateType = 'extend' | 'identity' | 'clamp' | 'wrap';
2
2
  /**
3
- * @description This function allows you to map a range of values to another with a conside syntax
3
+ * @description This function allows you to map a range of values to another with a concise syntax
4
4
  * @see [Documentation](https://www.remotion.dev/docs/interpolate)
5
5
  */
6
6
  export type EasingFunction = (input: number) => number;
@@ -1,13 +1,21 @@
1
1
  import React from 'react';
2
2
  import type { LayoutAndStyle } from '../Sequence.js';
3
3
  export type LoopProps = {
4
- durationInFrames: number;
5
- times?: number;
6
- name?: string;
7
- children: React.ReactNode;
4
+ readonly durationInFrames: number;
5
+ readonly times?: number;
6
+ readonly name?: string;
7
+ readonly children: React.ReactNode;
8
8
  } & LayoutAndStyle;
9
+ type LoopContextType = {
10
+ iteration: number;
11
+ durationInFrames: number;
12
+ };
13
+ declare const useLoop: () => LoopContextType | null;
9
14
  /**
10
15
  * @description This component allows you to quickly lay out an animation so it repeats itself.
11
16
  * @see [Documentation](https://www.remotion.dev/docs/loop)
12
17
  */
13
- export declare const Loop: React.FC<LoopProps>;
18
+ export declare const Loop: React.FC<LoopProps> & {
19
+ useLoop: typeof useLoop;
20
+ };
21
+ export {};
@@ -1,12 +1,39 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = 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);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.Loop = void 0;
4
27
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("react");
28
+ const react_1 = __importStar(require("react"));
6
29
  const Sequence_js_1 = require("../Sequence.js");
7
30
  const use_current_frame_js_1 = require("../use-current-frame.js");
8
31
  const use_video_config_js_1 = require("../use-video-config.js");
9
32
  const validate_duration_in_frames_js_1 = require("../validation/validate-duration-in-frames.js");
33
+ const LoopContext = (0, react_1.createContext)(null);
34
+ const useLoop = () => {
35
+ return react_1.default.useContext(LoopContext);
36
+ };
10
37
  /**
11
38
  * @description This component allows you to quickly lay out an animation so it repeats itself.
12
39
  * @see [Documentation](https://www.remotion.dev/docs/loop)
@@ -31,7 +58,8 @@ const Loop = ({ durationInFrames, times = Infinity, children, name, ...props })
31
58
  const actualTimes = Math.min(maxTimes, times);
32
59
  const style = props.layout === 'none' ? undefined : props.style;
33
60
  const maxFrame = durationInFrames * (actualTimes - 1);
34
- const start = Math.floor(currentFrame / durationInFrames) * durationInFrames;
61
+ const iteration = Math.floor(currentFrame / durationInFrames);
62
+ const start = iteration * durationInFrames;
35
63
  const from = Math.min(start, maxFrame);
36
64
  const loopDisplay = (0, react_1.useMemo)(() => {
37
65
  return {
@@ -40,6 +68,13 @@ const Loop = ({ durationInFrames, times = Infinity, children, name, ...props })
40
68
  durationInFrames,
41
69
  };
42
70
  }, [actualTimes, durationInFrames, from]);
43
- return ((0, jsx_runtime_1.jsx)(Sequence_js_1.Sequence, { durationInFrames: durationInFrames, from: from, name: name !== null && name !== void 0 ? name : '<Loop>', _remotionInternalLoopDisplay: loopDisplay, layout: props.layout, style: style, children: children }));
71
+ const loopContext = (0, react_1.useMemo)(() => {
72
+ return {
73
+ iteration: Math.floor(currentFrame / durationInFrames),
74
+ durationInFrames,
75
+ };
76
+ }, [currentFrame, durationInFrames]);
77
+ return ((0, jsx_runtime_1.jsx)(LoopContext.Provider, { value: loopContext, children: (0, jsx_runtime_1.jsx)(Sequence_js_1.Sequence, { durationInFrames: durationInFrames, from: from, name: name !== null && name !== void 0 ? name : '<Loop>', _remotionInternalLoopDisplay: loopDisplay, layout: props.layout, style: style, children: children }) }));
44
78
  };
45
79
  exports.Loop = Loop;
80
+ exports.Loop.useLoop = useLoop;
@@ -45,4 +45,9 @@ export declare const NoReactInternals: {
45
45
  ENABLE_V5_BREAKING_CHANGES: false;
46
46
  MIN_NODE_VERSION: number;
47
47
  MIN_BUN_VERSION: string;
48
+ colorNames: {
49
+ [key: string]: number;
50
+ };
51
+ DATE_TOKEN: string;
52
+ FILE_TOKEN: string;
48
53
  };
@@ -7,6 +7,7 @@ var random_js_1 = require("./random.js");
7
7
  Object.defineProperty(exports, "random", { enumerable: true, get: function () { return random_js_1.random; } });
8
8
  const delay_render_1 = require("./delay-render");
9
9
  const input_props_serialization_1 = require("./input-props-serialization");
10
+ const input_props_serialization_js_1 = require("./input-props-serialization.js");
10
11
  const interpolate_colors_1 = require("./interpolate-colors");
11
12
  const truthy_1 = require("./truthy");
12
13
  const v5_flag_1 = require("./v5-flag");
@@ -37,4 +38,7 @@ exports.NoReactInternals = {
37
38
  ENABLE_V5_BREAKING_CHANGES: v5_flag_1.ENABLE_V5_BREAKING_CHANGES,
38
39
  MIN_NODE_VERSION: v5_flag_1.ENABLE_V5_BREAKING_CHANGES ? 18 : 16,
39
40
  MIN_BUN_VERSION: v5_flag_1.ENABLE_V5_BREAKING_CHANGES ? '1.1.3' : '1.0.3',
41
+ colorNames: interpolate_colors_1.colorNames,
42
+ DATE_TOKEN: input_props_serialization_js_1.DATE_TOKEN,
43
+ FILE_TOKEN: input_props_serialization_js_1.FILE_TOKEN,
40
44
  };
@@ -7,10 +7,12 @@ const Sequence_js_1 = require("../Sequence.js");
7
7
  const enable_sequence_stack_traces_js_1 = require("../enable-sequence-stack-traces.js");
8
8
  const validate_duration_in_frames_js_1 = require("../validation/validate-duration-in-frames.js");
9
9
  const flatten_children_js_1 = require("./flatten-children.js");
10
+ const is_inside_series_js_1 = require("./is-inside-series.js");
10
11
  const SeriesSequenceRefForwardingFunction = ({ children }, _ref) => {
12
+ (0, is_inside_series_js_1.useRequireToBeInsideSeries)();
11
13
  // Discard ref
12
14
  // eslint-disable-next-line react/jsx-no-useless-fragment
13
- return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
15
+ return (0, jsx_runtime_1.jsx)(is_inside_series_js_1.IsNotInsideSeriesProvider, { children: children });
14
16
  };
15
17
  const SeriesSequence = (0, react_1.forwardRef)(SeriesSequenceRefForwardingFunction);
16
18
  /**
@@ -62,8 +64,7 @@ const Series = ({ children }) => {
62
64
  return ((0, jsx_runtime_1.jsx)(Sequence_js_1.Sequence, { name: name || '<Series.Sequence>', from: currentStartFrame, durationInFrames: durationInFramesProp, ...passedProps, ref: castedChild.ref, children: child }));
63
65
  });
64
66
  }, [children]);
65
- /* eslint-disable react/jsx-no-useless-fragment */
66
- return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: childrenValue });
67
+ return (0, jsx_runtime_1.jsx)(is_inside_series_js_1.IsInsideSeriesContainer, { children: childrenValue });
67
68
  };
68
69
  exports.Series = Series;
69
70
  Series.Sequence = SeriesSequence;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ export declare const IsInsideSeriesContext: React.Context<boolean>;
3
+ export declare const IsInsideSeriesContainer: React.FC<{
4
+ readonly children: React.ReactNode;
5
+ }>;
6
+ export declare const IsNotInsideSeriesProvider: React.FC<{
7
+ readonly children: React.ReactNode;
8
+ }>;
9
+ export declare const useRequireToBeInsideSeries: () => void;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = 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);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.useRequireToBeInsideSeries = exports.IsNotInsideSeriesProvider = exports.IsInsideSeriesContainer = exports.IsInsideSeriesContext = void 0;
27
+ const jsx_runtime_1 = require("react/jsx-runtime");
28
+ const react_1 = __importStar(require("react"));
29
+ exports.IsInsideSeriesContext = (0, react_1.createContext)(false);
30
+ const IsInsideSeriesContainer = ({ children }) => {
31
+ return ((0, jsx_runtime_1.jsx)(exports.IsInsideSeriesContext.Provider, { value: true, children: children }));
32
+ };
33
+ exports.IsInsideSeriesContainer = IsInsideSeriesContainer;
34
+ const IsNotInsideSeriesProvider = ({ children }) => {
35
+ return ((0, jsx_runtime_1.jsx)(exports.IsInsideSeriesContext.Provider, { value: false, children: children }));
36
+ };
37
+ exports.IsNotInsideSeriesProvider = IsNotInsideSeriesProvider;
38
+ const useRequireToBeInsideSeries = () => {
39
+ const isInsideSeries = react_1.default.useContext(exports.IsInsideSeriesContext);
40
+ if (!isInsideSeries) {
41
+ throw new Error('This component must be inside a <Series /> component.');
42
+ }
43
+ };
44
+ exports.useRequireToBeInsideSeries = useRequireToBeInsideSeries;
@@ -1,4 +1,4 @@
1
- import type { SpringConfig } from './spring-utils.js';
1
+ import type { SpringConfig } from './spring-utils';
2
2
  /**
3
3
  * @description Calculates a position based on physical parameters, start and end value, and time.
4
4
  * @see [Documentation](https://www.remotion.dev/docs/spring)
@@ -28,4 +28,4 @@ export declare function spring({ frame: passedFrame, fps, config, from, to, dura
28
28
  reverse?: boolean;
29
29
  }): number;
30
30
  export { measureSpring } from './measure-spring.js';
31
- export { SpringConfig } from './spring-utils.js';
31
+ export type { SpringConfig } from './spring-utils';
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.measureSpring = exports.spring = void 0;
4
+ const interpolate_js_1 = require("../interpolate.js");
4
5
  const validate_frame_js_1 = require("../validate-frame.js");
5
6
  const validate_fps_js_1 = require("../validation/validate-fps.js");
6
7
  const validation_spring_duration_js_1 = require("../validation/validation-spring-duration.js");
@@ -64,16 +65,14 @@ function spring({ frame: passedFrame, fps, config = {}, from = 0, to = 1, durati
64
65
  fps,
65
66
  frame: durationProcessed,
66
67
  config,
67
- from,
68
- to,
69
68
  });
70
- if (!config.overshootClamping) {
71
- return spr.current;
72
- }
73
- if (to >= from) {
74
- return Math.min(spr.current, to);
75
- }
76
- return Math.max(spr.current, to);
69
+ const inner = config.overshootClamping
70
+ ? to >= from
71
+ ? Math.min(spr.current, to)
72
+ : Math.max(spr.current, to)
73
+ : spr.current;
74
+ const interpolated = from === 0 && to === 1 ? inner : (0, interpolate_js_1.interpolate)(inner, [0, 1], [from, to]);
75
+ return interpolated;
77
76
  }
78
77
  exports.spring = spring;
79
78
  var measure_spring_js_2 = require("./measure-spring.js");
@@ -1,4 +1,4 @@
1
- import type { SpringConfig } from './spring-utils.js';
1
+ import type { SpringConfig } from './spring-utils';
2
2
  /**
3
3
  * @description The function returns how long it takes for a spring animation to settle
4
4
  * @see [Documentation](https://www.remotion.dev/docs/measure-spring)
@@ -49,8 +49,6 @@ function measureSpring({ fps, config = {}, threshold = 0.005, from = 0, to = 1,
49
49
  fps,
50
50
  frame,
51
51
  config,
52
- from,
53
- to,
54
52
  });
55
53
  };
56
54
  let animation = calc();