remotion 4.0.125 → 4.0.127

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;
@@ -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;
@@ -1 +1 @@
1
- export declare const VERSION = "4.0.125";
1
+ export declare const VERSION = "4.0.127";
@@ -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.125';
5
+ exports.VERSION = '4.0.127';
@@ -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;
@@ -105,7 +105,7 @@ function truthy(value) {
105
105
  }
106
106
 
107
107
  // Automatically generated on publish
108
- const VERSION = '4.0.125';
108
+ const VERSION = '4.0.127';
109
109
 
110
110
  const checkMultipleRemotionVersions = () => {
111
111
  if (typeof globalThis === 'undefined') {
@@ -3242,34 +3242,53 @@ class Easing {
3242
3242
  * @description This method freezes all of its children to the frame that you specify as a prop
3243
3243
  * @see [Documentation](https://www.remotion.dev/docs/freeze)
3244
3244
  */
3245
- const Freeze = ({ frame, children }) => {
3245
+ const Freeze = ({ frame: frameToFreeze, children, active = true, }) => {
3246
+ const frame = useCurrentFrame();
3246
3247
  const videoConfig = useVideoConfig();
3247
- if (typeof frame === 'undefined') {
3248
+ if (typeof frameToFreeze === 'undefined') {
3248
3249
  throw new Error(`The <Freeze /> component requires a 'frame' prop, but none was passed.`);
3249
3250
  }
3250
- if (typeof frame !== 'number') {
3251
- throw new Error(`The 'frame' prop of <Freeze /> must be a number, but is of type ${typeof frame}`);
3251
+ if (typeof frameToFreeze !== 'number') {
3252
+ throw new Error(`The 'frame' prop of <Freeze /> must be a number, but is of type ${typeof frameToFreeze}`);
3252
3253
  }
3253
- if (Number.isNaN(frame)) {
3254
+ if (Number.isNaN(frameToFreeze)) {
3254
3255
  throw new Error(`The 'frame' prop of <Freeze /> must be a real number, but it is NaN.`);
3255
3256
  }
3256
- if (!Number.isFinite(frame)) {
3257
- throw new Error(`The 'frame' prop of <Freeze /> must be a finite number, but it is ${frame}.`);
3257
+ if (!Number.isFinite(frameToFreeze)) {
3258
+ throw new Error(`The 'frame' prop of <Freeze /> must be a finite number, but it is ${frameToFreeze}.`);
3258
3259
  }
3259
- const context = useContext(TimelineContext);
3260
- const value = useMemo(() => {
3260
+ const isActive = useMemo(() => {
3261
+ if (typeof active === 'boolean') {
3262
+ return active;
3263
+ }
3264
+ if (typeof active === 'function') {
3265
+ return active(frame);
3266
+ }
3267
+ }, [active, frame]);
3268
+ const timelineContext = useContext(TimelineContext);
3269
+ const sequenceContext = useContext(SequenceContext);
3270
+ const timelineValue = useMemo(() => {
3271
+ if (!isActive) {
3272
+ return timelineContext;
3273
+ }
3261
3274
  return {
3262
- ...context,
3275
+ ...timelineContext,
3263
3276
  playing: false,
3264
3277
  imperativePlaying: {
3265
3278
  current: false,
3266
3279
  },
3267
3280
  frame: {
3268
- [videoConfig.id]: frame,
3281
+ [videoConfig.id]: frameToFreeze,
3269
3282
  },
3270
3283
  };
3271
- }, [context, frame, videoConfig.id]);
3272
- return (jsx(TimelineContext.Provider, { value: value, children: jsx(SequenceContext.Provider, { value: null, children: children }) }));
3284
+ }, [timelineContext, frameToFreeze, isActive, videoConfig.id]);
3285
+ const sequenceValue = useMemo(() => {
3286
+ if (isActive) {
3287
+ return null;
3288
+ }
3289
+ return sequenceContext;
3290
+ }, [isActive, sequenceContext]);
3291
+ return (jsx(TimelineContext.Provider, { value: timelineValue, children: jsx(SequenceContext.Provider, { value: sequenceValue, children: children }) }));
3273
3292
  };
3274
3293
 
3275
3294
  let warnedServer = false;
@@ -1,4 +1,4 @@
1
1
  // Automatically generated on publish
2
- const VERSION = '4.0.125';
2
+ const VERSION = '4.0.127';
3
3
 
4
4
  export { VERSION };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remotion",
3
- "version": "4.0.125",
3
+ "version": "4.0.127",
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;