remotion 4.0.126 → 4.0.128

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.
@@ -1,6 +1,6 @@
1
1
  import type { ForwardRefExoticComponent, RefAttributes } from 'react';
2
2
  import React from 'react';
3
- export declare const AudioForDevelopment: ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.AudioHTMLAttributes<HTMLAudioElement>, HTMLAudioElement>, "autoPlay" | "controls" | "onEnded" | "nonce" | "onResize" | "onResizeCapture"> & {
3
+ export declare const AudioForDevelopment: ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.AudioHTMLAttributes<HTMLAudioElement>, HTMLAudioElement>, "nonce" | "onEnded" | "onResize" | "onResizeCapture" | "autoPlay" | "controls"> & {
4
4
  name?: string | undefined;
5
5
  volume?: import("../volume-prop.js").VolumeProp | undefined;
6
6
  playbackRate?: number | undefined;
@@ -1 +1 @@
1
- export declare const getInputProps: () => Record<string, unknown>;
1
+ export declare const getInputProps: <T extends Record<string, unknown> = Record<string, unknown>>() => T;
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  type FreezeProps = {
3
3
  frame: number;
4
4
  children: React.ReactNode;
5
+ active?: boolean | ((f: number) => boolean);
5
6
  };
6
7
  /**
7
8
  * @description This method freezes all of its children to the frame that you specify as a prop
@@ -5,38 +5,58 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const SequenceContext_js_1 = require("./SequenceContext.js");
7
7
  const timeline_position_state_js_1 = require("./timeline-position-state.js");
8
+ const use_current_frame_js_1 = require("./use-current-frame.js");
8
9
  const use_video_config_js_1 = require("./use-video-config.js");
9
10
  /**
10
11
  * @description This method freezes all of its children to the frame that you specify as a prop
11
12
  * @see [Documentation](https://www.remotion.dev/docs/freeze)
12
13
  */
13
- const Freeze = ({ frame, children }) => {
14
+ const Freeze = ({ frame: frameToFreeze, children, active = true, }) => {
15
+ const frame = (0, use_current_frame_js_1.useCurrentFrame)();
14
16
  const videoConfig = (0, use_video_config_js_1.useVideoConfig)();
15
- if (typeof frame === 'undefined') {
17
+ if (typeof frameToFreeze === 'undefined') {
16
18
  throw new Error(`The <Freeze /> component requires a 'frame' prop, but none was passed.`);
17
19
  }
18
- if (typeof frame !== 'number') {
19
- throw new Error(`The 'frame' prop of <Freeze /> must be a number, but is of type ${typeof frame}`);
20
+ if (typeof frameToFreeze !== 'number') {
21
+ throw new Error(`The 'frame' prop of <Freeze /> must be a number, but is of type ${typeof frameToFreeze}`);
20
22
  }
21
- if (Number.isNaN(frame)) {
23
+ if (Number.isNaN(frameToFreeze)) {
22
24
  throw new Error(`The 'frame' prop of <Freeze /> must be a real number, but it is NaN.`);
23
25
  }
24
- if (!Number.isFinite(frame)) {
25
- throw new Error(`The 'frame' prop of <Freeze /> must be a finite number, but it is ${frame}.`);
26
+ if (!Number.isFinite(frameToFreeze)) {
27
+ throw new Error(`The 'frame' prop of <Freeze /> must be a finite number, but it is ${frameToFreeze}.`);
26
28
  }
27
- const context = (0, react_1.useContext)(timeline_position_state_js_1.TimelineContext);
28
- const value = (0, react_1.useMemo)(() => {
29
+ const isActive = (0, react_1.useMemo)(() => {
30
+ if (typeof active === 'boolean') {
31
+ return active;
32
+ }
33
+ if (typeof active === 'function') {
34
+ return active(frame);
35
+ }
36
+ }, [active, frame]);
37
+ const timelineContext = (0, react_1.useContext)(timeline_position_state_js_1.TimelineContext);
38
+ const sequenceContext = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
39
+ const timelineValue = (0, react_1.useMemo)(() => {
40
+ if (!isActive) {
41
+ return timelineContext;
42
+ }
29
43
  return {
30
- ...context,
44
+ ...timelineContext,
31
45
  playing: false,
32
46
  imperativePlaying: {
33
47
  current: false,
34
48
  },
35
49
  frame: {
36
- [videoConfig.id]: frame,
50
+ [videoConfig.id]: frameToFreeze,
37
51
  },
38
52
  };
39
- }, [context, frame, videoConfig.id]);
40
- return ((0, jsx_runtime_1.jsx)(timeline_position_state_js_1.TimelineContext.Provider, { value: value, children: (0, jsx_runtime_1.jsx)(SequenceContext_js_1.SequenceContext.Provider, { value: null, children: children }) }));
53
+ }, [timelineContext, frameToFreeze, isActive, videoConfig.id]);
54
+ const sequenceValue = (0, react_1.useMemo)(() => {
55
+ if (isActive) {
56
+ return null;
57
+ }
58
+ return sequenceContext;
59
+ }, [isActive, sequenceContext]);
60
+ return ((0, jsx_runtime_1.jsx)(timeline_position_state_js_1.TimelineContext.Provider, { value: timelineValue, children: (0, jsx_runtime_1.jsx)(SequenceContext_js_1.SequenceContext.Provider, { value: sequenceValue, children: children }) }));
41
61
  };
42
62
  exports.Freeze = Freeze;
@@ -0,0 +1 @@
1
+ export declare const getTimelineClipName: (children: React.ReactNode) => string;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTimelineClipName = void 0;
4
+ const react_1 = require("react");
5
+ const HIDDEN_NAMES = ['__WEBPACK_DEFAULT_EXPORT__'];
6
+ const getTimelineClipName = (children) => {
7
+ var _a;
8
+ const tree = (_a = react_1.Children.map(children, (ch) => {
9
+ if (!(0, react_1.isValidElement)(ch)) {
10
+ return null;
11
+ }
12
+ // Must be name, not ID
13
+ const name = typeof ch.type !== 'string' && ch.type.name;
14
+ if (name && !HIDDEN_NAMES.includes(name)) {
15
+ return name;
16
+ }
17
+ if (ch.props.children) {
18
+ const chName = (0, exports.getTimelineClipName)(ch.props.children);
19
+ return chName;
20
+ }
21
+ return null;
22
+ })) === null || _a === void 0 ? void 0 : _a.filter(Boolean);
23
+ return (tree === null || tree === void 0 ? void 0 : tree.length) ? tree[0] : '';
24
+ };
25
+ exports.getTimelineClipName = getTimelineClipName;
@@ -12,4 +12,4 @@ export declare const serializeJSONWithDate: ({ data, indent, staticBase, }: {
12
12
  indent: number | undefined;
13
13
  staticBase: string | null;
14
14
  }) => SerializedJSONWithCustomFields;
15
- export declare const deserializeJSONWithCustomFields: (data: string) => Record<string, unknown>;
15
+ export declare const deserializeJSONWithCustomFields: <T = Record<string, unknown>>(data: string) => T;
@@ -1,4 +1,4 @@
1
- export type ExtrapolateType = 'extend' | 'identity' | 'clamp';
1
+ export type ExtrapolateType = 'extend' | 'identity' | 'clamp' | 'wrap';
2
2
  /**
3
3
  * @description This function allows you to map a range of values to another with a conside syntax
4
4
  * @see [Documentation](https://www.remotion.dev/docs/interpolate)
@@ -14,8 +14,12 @@ function interpolateFunction(input, inputRange, outputRange, options) {
14
14
  if (extrapolateLeft === 'clamp') {
15
15
  result = inputMin;
16
16
  }
17
+ else if (extrapolateLeft === 'wrap') {
18
+ const range = inputMax - inputMin;
19
+ result = ((((result - inputMin) % range) + range) % range) + inputMin;
20
+ }
17
21
  else if (extrapolateLeft === 'extend') {
18
- // noop
22
+ // Noop
19
23
  }
20
24
  }
21
25
  if (result > inputMax) {
@@ -25,8 +29,12 @@ function interpolateFunction(input, inputRange, outputRange, options) {
25
29
  if (extrapolateRight === 'clamp') {
26
30
  result = inputMax;
27
31
  }
32
+ else if (extrapolateRight === 'wrap') {
33
+ const range = inputMax - inputMin;
34
+ result = ((((result - inputMin) % range) + range) % range) + inputMin;
35
+ }
28
36
  else if (extrapolateRight === 'extend') {
29
- // noop
37
+ // Noop
30
38
  }
31
39
  }
32
40
  if (outputMin === outputMax) {
@@ -27,7 +27,7 @@ export declare const NoReactInternals: {
27
27
  }) => import("./input-props-serialization").SerializedJSONWithCustomFields;
28
28
  bundleName: string;
29
29
  bundleMapName: string;
30
- deserializeJSONWithCustomFields: (data: string) => Record<string, unknown>;
30
+ deserializeJSONWithCustomFields: <T = Record<string, unknown>>(data: string) => T;
31
31
  DELAY_RENDER_CALLSTACK_TOKEN: string;
32
32
  getOffthreadVideoSource: ({ src, transparent, currentTime, toneMapped, }: {
33
33
  src: string;
@@ -1 +1 @@
1
- export declare const VERSION = "4.0.126";
1
+ export declare const VERSION = "4.0.128";
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // Automatically generated on publish
5
- exports.VERSION = '4.0.126';
5
+ exports.VERSION = '4.0.128';
@@ -1,6 +1,6 @@
1
1
  import type { ForwardRefExoticComponent, RefAttributes } from 'react';
2
2
  import React from 'react';
3
- export declare const VideoForDevelopment: ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>, "autoPlay" | "controls" | "onEnded" | "nonce"> & {
3
+ export declare const VideoForDevelopment: ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>, "nonce" | "onEnded" | "autoPlay" | "controls"> & {
4
4
  name?: string | undefined;
5
5
  volume?: import("../volume-prop.js").VolumeProp | undefined;
6
6
  playbackRate?: number | undefined;
@@ -6,10 +6,12 @@ const toSeconds = (time, fps) => {
6
6
  return Math.round((time / fps) * 100) / 100;
7
7
  };
8
8
  const isIosSafari = () => {
9
- return typeof window === 'undefined'
10
- ? false
11
- : /iP(ad|od|hone)/i.test(window.navigator.userAgent) &&
12
- Boolean(navigator.userAgent.match(/Version\/[\d.]+.*Safari/));
9
+ if (typeof window === 'undefined') {
10
+ return false;
11
+ }
12
+ const isIpadIPodIPhone = /iP(ad|od|hone)/i.test(window.navigator.userAgent);
13
+ const isAppleWebKit = /AppleWebKit/.test(window.navigator.userAgent);
14
+ return isIpadIPodIPhone && isAppleWebKit;
13
15
  };
14
16
  exports.isIosSafari = isIosSafari;
15
17
  // https://github.com/remotion-dev/remotion/issues/1655
@@ -105,7 +105,7 @@ function truthy(value) {
105
105
  }
106
106
 
107
107
  // Automatically generated on publish
108
- const VERSION = '4.0.126';
108
+ const VERSION = '4.0.128';
109
109
 
110
110
  const checkMultipleRemotionVersions = () => {
111
111
  if (typeof globalThis === 'undefined') {
@@ -1816,6 +1816,11 @@ function interpolateFunction(input, inputRange, outputRange, options) {
1816
1816
  if (extrapolateLeft === 'clamp') {
1817
1817
  result = inputMin;
1818
1818
  }
1819
+ else if (extrapolateLeft === 'wrap') {
1820
+ const range = inputMax - inputMin;
1821
+ result = ((((result - inputMin) % range) + range) % range) + inputMin;
1822
+ }
1823
+ else ;
1819
1824
  }
1820
1825
  if (result > inputMax) {
1821
1826
  if (extrapolateRight === 'identity') {
@@ -1824,6 +1829,11 @@ function interpolateFunction(input, inputRange, outputRange, options) {
1824
1829
  if (extrapolateRight === 'clamp') {
1825
1830
  result = inputMax;
1826
1831
  }
1832
+ else if (extrapolateRight === 'wrap') {
1833
+ const range = inputMax - inputMin;
1834
+ result = ((((result - inputMin) % range) + range) % range) + inputMin;
1835
+ }
1836
+ else ;
1827
1837
  }
1828
1838
  if (outputMin === outputMax) {
1829
1839
  return outputMin;
@@ -1935,10 +1945,12 @@ const toSeconds = (time, fps) => {
1935
1945
  return Math.round((time / fps) * 100) / 100;
1936
1946
  };
1937
1947
  const isIosSafari = () => {
1938
- return typeof window === 'undefined'
1939
- ? false
1940
- : /iP(ad|od|hone)/i.test(window.navigator.userAgent) &&
1941
- Boolean(navigator.userAgent.match(/Version\/[\d.]+.*Safari/));
1948
+ if (typeof window === 'undefined') {
1949
+ return false;
1950
+ }
1951
+ const isIpadIPodIPhone = /iP(ad|od|hone)/i.test(window.navigator.userAgent);
1952
+ const isAppleWebKit = /AppleWebKit/.test(window.navigator.userAgent);
1953
+ return isIpadIPodIPhone && isAppleWebKit;
1942
1954
  };
1943
1955
  // https://github.com/remotion-dev/remotion/issues/1655
1944
1956
  const isIOSSafariAndBlob = (actualSrc) => {
@@ -3242,34 +3254,53 @@ class Easing {
3242
3254
  * @description This method freezes all of its children to the frame that you specify as a prop
3243
3255
  * @see [Documentation](https://www.remotion.dev/docs/freeze)
3244
3256
  */
3245
- const Freeze = ({ frame, children }) => {
3257
+ const Freeze = ({ frame: frameToFreeze, children, active = true, }) => {
3258
+ const frame = useCurrentFrame();
3246
3259
  const videoConfig = useVideoConfig();
3247
- if (typeof frame === 'undefined') {
3260
+ if (typeof frameToFreeze === 'undefined') {
3248
3261
  throw new Error(`The <Freeze /> component requires a 'frame' prop, but none was passed.`);
3249
3262
  }
3250
- if (typeof frame !== 'number') {
3251
- throw new Error(`The 'frame' prop of <Freeze /> must be a number, but is of type ${typeof frame}`);
3263
+ if (typeof frameToFreeze !== 'number') {
3264
+ throw new Error(`The 'frame' prop of <Freeze /> must be a number, but is of type ${typeof frameToFreeze}`);
3252
3265
  }
3253
- if (Number.isNaN(frame)) {
3266
+ if (Number.isNaN(frameToFreeze)) {
3254
3267
  throw new Error(`The 'frame' prop of <Freeze /> must be a real number, but it is NaN.`);
3255
3268
  }
3256
- if (!Number.isFinite(frame)) {
3257
- throw new Error(`The 'frame' prop of <Freeze /> must be a finite number, but it is ${frame}.`);
3269
+ if (!Number.isFinite(frameToFreeze)) {
3270
+ throw new Error(`The 'frame' prop of <Freeze /> must be a finite number, but it is ${frameToFreeze}.`);
3258
3271
  }
3259
- const context = useContext(TimelineContext);
3260
- const value = useMemo(() => {
3272
+ const isActive = useMemo(() => {
3273
+ if (typeof active === 'boolean') {
3274
+ return active;
3275
+ }
3276
+ if (typeof active === 'function') {
3277
+ return active(frame);
3278
+ }
3279
+ }, [active, frame]);
3280
+ const timelineContext = useContext(TimelineContext);
3281
+ const sequenceContext = useContext(SequenceContext);
3282
+ const timelineValue = useMemo(() => {
3283
+ if (!isActive) {
3284
+ return timelineContext;
3285
+ }
3261
3286
  return {
3262
- ...context,
3287
+ ...timelineContext,
3263
3288
  playing: false,
3264
3289
  imperativePlaying: {
3265
3290
  current: false,
3266
3291
  },
3267
3292
  frame: {
3268
- [videoConfig.id]: frame,
3293
+ [videoConfig.id]: frameToFreeze,
3269
3294
  },
3270
3295
  };
3271
- }, [context, frame, videoConfig.id]);
3272
- return (jsx(TimelineContext.Provider, { value: value, children: jsx(SequenceContext.Provider, { value: null, children: children }) }));
3296
+ }, [timelineContext, frameToFreeze, isActive, videoConfig.id]);
3297
+ const sequenceValue = useMemo(() => {
3298
+ if (isActive) {
3299
+ return null;
3300
+ }
3301
+ return sequenceContext;
3302
+ }, [isActive, sequenceContext]);
3303
+ return (jsx(TimelineContext.Provider, { value: timelineValue, children: jsx(SequenceContext.Provider, { value: sequenceValue, children: children }) }));
3273
3304
  };
3274
3305
 
3275
3306
  let warnedServer = false;
@@ -11,6 +11,11 @@ function interpolateFunction(input, inputRange, outputRange, options) {
11
11
  if (extrapolateLeft === 'clamp') {
12
12
  result = inputMin;
13
13
  }
14
+ else if (extrapolateLeft === 'wrap') {
15
+ const range = inputMax - inputMin;
16
+ result = ((((result - inputMin) % range) + range) % range) + inputMin;
17
+ }
18
+ else ;
14
19
  }
15
20
  if (result > inputMax) {
16
21
  if (extrapolateRight === 'identity') {
@@ -19,6 +24,11 @@ function interpolateFunction(input, inputRange, outputRange, options) {
19
24
  if (extrapolateRight === 'clamp') {
20
25
  result = inputMax;
21
26
  }
27
+ else if (extrapolateRight === 'wrap') {
28
+ const range = inputMax - inputMin;
29
+ result = ((((result - inputMin) % range) + range) % range) + inputMin;
30
+ }
31
+ else ;
22
32
  }
23
33
  if (outputMin === outputMax) {
24
34
  return outputMin;
@@ -1,4 +1,4 @@
1
1
  // Automatically generated on publish
2
- const VERSION = '4.0.126';
2
+ const VERSION = '4.0.128';
3
3
 
4
4
  export { VERSION };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remotion",
3
- "version": "4.0.126",
3
+ "version": "4.0.128",
4
4
  "description": "Render videos in React",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",
@@ -1,5 +0,0 @@
1
- export declare const useBufferState: () => {
2
- delayPlayback: () => {
3
- unblock: () => void;
4
- };
5
- };
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useBufferState = void 0;
4
- const react_1 = require("react");
5
- const buffering_1 = require("./buffering");
6
- const CanUseRemotionHooks_1 = require("./CanUseRemotionHooks");
7
- const useBufferState = () => {
8
- const canUseRemotionHooks = (0, react_1.useContext)(CanUseRemotionHooks_1.CanUseRemotionHooks);
9
- if (!canUseRemotionHooks) {
10
- if (typeof window !== 'undefined' && window.remotion_isPlayer) {
11
- throw new Error(`useCurrentFrame can only be called inside a component that was passed to <Player>. See: https://www.remotion.dev/docs/player/examples`);
12
- }
13
- 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`);
14
- }
15
- const buffer = (0, react_1.useContext)(buffering_1.BufferingContextReact);
16
- if (!buffer) {
17
- throw new Error('BufferingContextReact was unexpectedly not found. Most likely your Remotion versions are mismatching.');
18
- }
19
- return (0, react_1.useMemo)(() => ({
20
- delayPlayback: () => {
21
- const { unblock } = buffer.addBlock({
22
- id: String(Math.random()),
23
- });
24
- return { unblock };
25
- },
26
- }), [buffer]);
27
- };
28
- exports.useBufferState = useBufferState;