remotion 4.0.372 → 4.0.374

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.
@@ -2,7 +2,6 @@ import type { ComponentType, LazyExoticComponent } from 'react';
2
2
  import React from 'react';
3
3
  import type { AnyZodObject } from 'zod';
4
4
  import type { CalculateMetadataFunction } from './Composition.js';
5
- import type { BaseMetadata } from './CompositionManagerContext.js';
6
5
  import type { DownloadBehavior } from './download-behavior.js';
7
6
  import type { InferProps, PropsIfHasProps } from './props-if-has-props.js';
8
7
  export type TComposition<Schema extends AnyZodObject, Props extends Record<string, unknown>> = {
@@ -99,11 +98,4 @@ export type TRenderAsset = AudioOrVideoAsset | ArtifactAsset | InlineAudioAsset;
99
98
  export declare const compositionsRef: React.RefObject<{
100
99
  getCompositions: () => AnyComposition[];
101
100
  } | null>;
102
- export declare const CompositionManagerProvider: React.FC<{
103
- readonly children: React.ReactNode;
104
- readonly numberOfAudioTags: number;
105
- readonly onlyRenderComposition: string | null;
106
- readonly currentCompositionMetadata: BaseMetadata | null;
107
- readonly audioLatencyHint: AudioContextLatencyCategory;
108
- }>;
109
101
  export {};
@@ -1,141 +1,8 @@
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 () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
35
5
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.CompositionManagerProvider = exports.compositionsRef = void 0;
37
- const jsx_runtime_1 = require("react/jsx-runtime");
38
- const react_1 = __importStar(require("react"));
39
- const CompositionManagerContext_js_1 = require("./CompositionManagerContext.js");
40
- const RenderAssetManager_js_1 = require("./RenderAssetManager.js");
41
- const ResolveCompositionConfig_js_1 = require("./ResolveCompositionConfig.js");
42
- const SequenceManager_js_1 = require("./SequenceManager.js");
43
- const shared_audio_tags_js_1 = require("./audio/shared-audio-tags.js");
6
+ exports.compositionsRef = void 0;
7
+ const react_1 = __importDefault(require("react"));
44
8
  exports.compositionsRef = react_1.default.createRef();
45
- const CompositionManagerProvider = ({ children, numberOfAudioTags, onlyRenderComposition, currentCompositionMetadata, audioLatencyHint, }) => {
46
- var _a;
47
- // Wontfix, expected to have
48
- const [compositions, setCompositions] = (0, react_1.useState)([]);
49
- const currentcompositionsRef = (0, react_1.useRef)(compositions);
50
- const [folders, setFolders] = (0, react_1.useState)([]);
51
- const [canvasContent, setCanvasContent] = (0, react_1.useState)(null);
52
- const updateCompositions = (0, react_1.useCallback)((updateComps) => {
53
- setCompositions((comps) => {
54
- const updated = updateComps(comps);
55
- currentcompositionsRef.current = updated;
56
- return updated;
57
- });
58
- }, []);
59
- const registerComposition = (0, react_1.useCallback)((comp) => {
60
- updateCompositions((comps) => {
61
- if (comps.find((c) => c.id === comp.id)) {
62
- throw new Error(`Multiple composition with id ${comp.id} are registered.`);
63
- }
64
- const value = [...comps, comp]
65
- .slice()
66
- .sort((a, b) => a.nonce - b.nonce);
67
- return value;
68
- });
69
- }, [updateCompositions]);
70
- const unregisterComposition = (0, react_1.useCallback)((id) => {
71
- setCompositions((comps) => {
72
- return comps.filter((c) => c.id !== id);
73
- });
74
- }, []);
75
- const registerFolder = (0, react_1.useCallback)((name, parent) => {
76
- setFolders((prevFolders) => {
77
- return [
78
- ...prevFolders,
79
- {
80
- name,
81
- parent,
82
- },
83
- ];
84
- });
85
- }, []);
86
- const unregisterFolder = (0, react_1.useCallback)((name, parent) => {
87
- setFolders((prevFolders) => {
88
- return prevFolders.filter((p) => !(p.name === name && p.parent === parent));
89
- });
90
- }, []);
91
- (0, react_1.useImperativeHandle)(exports.compositionsRef, () => {
92
- return {
93
- getCompositions: () => currentcompositionsRef.current,
94
- };
95
- }, []);
96
- const composition = compositions.find((c) => (canvasContent === null || canvasContent === void 0 ? void 0 : canvasContent.type) === 'composition'
97
- ? c.id === canvasContent.compositionId
98
- : null);
99
- const updateCompositionDefaultProps = (0, react_1.useCallback)((id, newDefaultProps) => {
100
- setCompositions((comps) => {
101
- const updated = comps.map((c) => {
102
- if (c.id === id) {
103
- return {
104
- ...c,
105
- defaultProps: newDefaultProps,
106
- };
107
- }
108
- return c;
109
- });
110
- return updated;
111
- });
112
- }, []);
113
- const contextValue = (0, react_1.useMemo)(() => {
114
- return {
115
- compositions,
116
- folders,
117
- currentCompositionMetadata,
118
- canvasContent,
119
- };
120
- }, [compositions, folders, currentCompositionMetadata, canvasContent]);
121
- const setters = (0, react_1.useMemo)(() => {
122
- return {
123
- registerComposition,
124
- unregisterComposition,
125
- registerFolder,
126
- unregisterFolder,
127
- setCanvasContent,
128
- updateCompositionDefaultProps,
129
- onlyRenderComposition,
130
- };
131
- }, [
132
- registerComposition,
133
- registerFolder,
134
- unregisterComposition,
135
- unregisterFolder,
136
- updateCompositionDefaultProps,
137
- onlyRenderComposition,
138
- ]);
139
- return ((0, jsx_runtime_1.jsx)(CompositionManagerContext_js_1.CompositionManager.Provider, { value: contextValue, children: (0, jsx_runtime_1.jsx)(CompositionManagerContext_js_1.CompositionSetters.Provider, { value: setters, children: (0, jsx_runtime_1.jsx)(SequenceManager_js_1.SequenceManagerProvider, { children: (0, jsx_runtime_1.jsx)(RenderAssetManager_js_1.RenderAssetManagerProvider, { children: (0, jsx_runtime_1.jsx)(ResolveCompositionConfig_js_1.ResolveCompositionConfig, { children: (0, jsx_runtime_1.jsx)(shared_audio_tags_js_1.SharedAudioContextProvider, { numberOfAudioTags: numberOfAudioTags, component: (_a = composition === null || composition === void 0 ? void 0 : composition.component) !== null && _a !== void 0 ? _a : null, audioLatencyHint: audioLatencyHint, children: children }) }) }) }) }) }));
140
- };
141
- exports.CompositionManagerProvider = CompositionManagerProvider;
@@ -0,0 +1,10 @@
1
+ import { type AnyComposition } from './CompositionManager';
2
+ import type { CanvasContent } from './CompositionManagerContext';
3
+ import type { BaseMetadata } from './CompositionManagerContext.js';
4
+ export declare const CompositionManagerProvider: ({ children, onlyRenderComposition, currentCompositionMetadata, initialCompositions, initialCanvasContent, }: {
5
+ readonly children: React.ReactNode;
6
+ readonly onlyRenderComposition: string | null;
7
+ readonly currentCompositionMetadata: BaseMetadata | null;
8
+ readonly initialCompositions: AnyComposition[];
9
+ readonly initialCanvasContent: CanvasContent | null;
10
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CompositionManagerProvider = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const CompositionManager_1 = require("./CompositionManager");
7
+ const CompositionManagerContext_1 = require("./CompositionManagerContext");
8
+ const CompositionManagerProvider = ({ children, onlyRenderComposition, currentCompositionMetadata, initialCompositions, initialCanvasContent, }) => {
9
+ const [folders, setFolders] = (0, react_1.useState)([]);
10
+ const [canvasContent, setCanvasContent] = (0, react_1.useState)(initialCanvasContent);
11
+ const [compositions, setCompositions] = (0, react_1.useState)(initialCompositions);
12
+ // CompositionManagerProvider state
13
+ const currentcompositionsRef = (0, react_1.useRef)(compositions);
14
+ const updateCompositions = (0, react_1.useCallback)((updateComps) => {
15
+ setCompositions((comps) => {
16
+ const updated = updateComps(comps);
17
+ currentcompositionsRef.current = updated;
18
+ return updated;
19
+ });
20
+ }, []);
21
+ const registerComposition = (0, react_1.useCallback)((comp) => {
22
+ updateCompositions((comps) => {
23
+ if (comps.find((c) => c.id === comp.id)) {
24
+ throw new Error(`Multiple composition with id ${comp.id} are registered.`);
25
+ }
26
+ const value = [...comps, comp]
27
+ .slice()
28
+ .sort((a, b) => a.nonce - b.nonce);
29
+ return value;
30
+ });
31
+ }, [updateCompositions]);
32
+ const unregisterComposition = (0, react_1.useCallback)((id) => {
33
+ setCompositions((comps) => {
34
+ return comps.filter((c) => c.id !== id);
35
+ });
36
+ }, []);
37
+ const registerFolder = (0, react_1.useCallback)((name, parent) => {
38
+ setFolders((prevFolders) => {
39
+ return [
40
+ ...prevFolders,
41
+ {
42
+ name,
43
+ parent,
44
+ },
45
+ ];
46
+ });
47
+ }, []);
48
+ const unregisterFolder = (0, react_1.useCallback)((name, parent) => {
49
+ setFolders((prevFolders) => {
50
+ return prevFolders.filter((p) => !(p.name === name && p.parent === parent));
51
+ });
52
+ }, []);
53
+ (0, react_1.useImperativeHandle)(CompositionManager_1.compositionsRef, () => {
54
+ return {
55
+ getCompositions: () => currentcompositionsRef.current,
56
+ };
57
+ }, []);
58
+ const updateCompositionDefaultProps = (0, react_1.useCallback)((id, newDefaultProps) => {
59
+ setCompositions((comps) => {
60
+ const updated = comps.map((c) => {
61
+ if (c.id === id) {
62
+ return {
63
+ ...c,
64
+ defaultProps: newDefaultProps,
65
+ };
66
+ }
67
+ return c;
68
+ });
69
+ return updated;
70
+ });
71
+ }, []);
72
+ const compositionManagerSetters = (0, react_1.useMemo)(() => {
73
+ return {
74
+ registerComposition,
75
+ unregisterComposition,
76
+ registerFolder,
77
+ unregisterFolder,
78
+ setCanvasContent,
79
+ updateCompositionDefaultProps,
80
+ onlyRenderComposition,
81
+ };
82
+ }, [
83
+ registerComposition,
84
+ registerFolder,
85
+ unregisterComposition,
86
+ unregisterFolder,
87
+ updateCompositionDefaultProps,
88
+ onlyRenderComposition,
89
+ ]);
90
+ const compositionManagerContextValue = (0, react_1.useMemo)(() => {
91
+ return {
92
+ compositions,
93
+ folders,
94
+ currentCompositionMetadata,
95
+ canvasContent,
96
+ };
97
+ }, [compositions, folders, currentCompositionMetadata, canvasContent]);
98
+ return ((0, jsx_runtime_1.jsx)(CompositionManagerContext_1.CompositionManager.Provider, { value: compositionManagerContextValue, children: (0, jsx_runtime_1.jsx)(CompositionManagerContext_1.CompositionSetters.Provider, { value: compositionManagerSetters, children: children }) }));
99
+ };
100
+ exports.CompositionManagerProvider = CompositionManagerProvider;
@@ -1,13 +1,11 @@
1
1
  import React from 'react';
2
- import type { BaseMetadata } from './CompositionManagerContext.js';
3
2
  import type { LogLevel } from './log.js';
4
3
  export declare const RemotionRoot: React.FC<{
5
4
  readonly children: React.ReactNode;
6
5
  readonly numberOfAudioTags: number;
7
6
  readonly logLevel: LogLevel;
8
- readonly onlyRenderComposition: string | null;
9
- readonly currentCompositionMetadata: BaseMetadata | null;
10
7
  readonly audioLatencyHint: AudioContextLatencyCategory;
11
8
  readonly videoEnabled: boolean | null;
12
9
  readonly audioEnabled: boolean | null;
10
+ readonly frameState: Record<string, number> | null;
13
11
  }>;
@@ -3,75 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RemotionRoot = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
- const CompositionManager_js_1 = require("./CompositionManager.js");
7
6
  const EditorProps_js_1 = require("./EditorProps.js");
7
+ const RenderAssetManager_js_1 = require("./RenderAssetManager.js");
8
+ const ResolveCompositionConfig_js_1 = require("./ResolveCompositionConfig.js");
9
+ const SequenceManager_js_1 = require("./SequenceManager.js");
10
+ const TimelineContext_js_1 = require("./TimelineContext.js");
11
+ const shared_audio_tags_js_1 = require("./audio/shared-audio-tags.js");
8
12
  const buffering_js_1 = require("./buffering.js");
9
13
  const log_level_context_js_1 = require("./log-level-context.js");
10
14
  const nonce_js_1 = require("./nonce.js");
11
15
  const prefetch_state_js_1 = require("./prefetch-state.js");
12
- const random_js_1 = require("./random.js");
13
- const timeline_position_state_js_1 = require("./timeline-position-state.js");
14
- const use_delay_render_js_1 = require("./use-delay-render.js");
15
16
  const use_media_enabled_js_1 = require("./use-media-enabled.js");
16
17
  const duration_state_js_1 = require("./video/duration-state.js");
17
- const RemotionRoot = ({ children, numberOfAudioTags, logLevel, onlyRenderComposition, currentCompositionMetadata, audioLatencyHint, videoEnabled, audioEnabled, }) => {
18
- const [remotionRootId] = (0, react_1.useState)(() => String((0, random_js_1.random)(null)));
19
- const [frame, setFrame] = (0, react_1.useState)(() => (0, timeline_position_state_js_1.getInitialFrameState)());
20
- const [playing, setPlaying] = (0, react_1.useState)(false);
21
- const imperativePlaying = (0, react_1.useRef)(false);
18
+ const RemotionRoot = ({ children, numberOfAudioTags, logLevel, audioLatencyHint, videoEnabled, audioEnabled, frameState, }) => {
22
19
  const [fastRefreshes, setFastRefreshes] = (0, react_1.useState)(0);
23
20
  const [manualRefreshes, setManualRefreshes] = (0, react_1.useState)(0);
24
- const [playbackRate, setPlaybackRate] = (0, react_1.useState)(1);
25
- const audioAndVideoTags = (0, react_1.useRef)([]);
26
- const { delayRender, continueRender } = (0, use_delay_render_js_1.useDelayRender)();
27
- if (typeof window !== 'undefined') {
28
- // eslint-disable-next-line react-hooks/rules-of-hooks
29
- (0, react_1.useLayoutEffect)(() => {
30
- window.remotion_setFrame = (f, composition, attempt) => {
31
- window.remotion_attempt = attempt;
32
- const id = delayRender(`Setting the current frame to ${f}`);
33
- let asyncUpdate = true;
34
- setFrame((s) => {
35
- var _a;
36
- const currentFrame = (_a = s[composition]) !== null && _a !== void 0 ? _a : window.remotion_initialFrame;
37
- // Avoid cloning the object
38
- if (currentFrame === f) {
39
- asyncUpdate = false;
40
- return s;
41
- }
42
- return {
43
- ...s,
44
- [composition]: f,
45
- };
46
- });
47
- // After setting the state, need to wait until it is applied in the next cycle
48
- if (asyncUpdate) {
49
- requestAnimationFrame(() => continueRender(id));
50
- }
51
- else {
52
- continueRender(id);
53
- }
54
- };
55
- window.remotion_isPlayer = false;
56
- }, [continueRender, delayRender]);
57
- }
58
- const timelineContextValue = (0, react_1.useMemo)(() => {
59
- return {
60
- frame,
61
- playing,
62
- imperativePlaying,
63
- rootId: remotionRootId,
64
- playbackRate,
65
- setPlaybackRate,
66
- audioAndVideoTags,
67
- };
68
- }, [frame, playbackRate, playing, remotionRootId]);
69
- const setTimelineContextValue = (0, react_1.useMemo)(() => {
70
- return {
71
- setFrame,
72
- setPlaying,
73
- };
74
- }, []);
75
21
  const nonceContext = (0, react_1.useMemo)(() => {
76
22
  let counter = 0;
77
23
  return {
@@ -101,6 +47,6 @@ const RemotionRoot = ({ children, numberOfAudioTags, logLevel, onlyRenderComposi
101
47
  const logging = (0, react_1.useMemo)(() => {
102
48
  return { logLevel, mountTime: Date.now() };
103
49
  }, [logLevel]);
104
- return ((0, jsx_runtime_1.jsx)(log_level_context_js_1.LogLevelContext.Provider, { value: logging, children: (0, jsx_runtime_1.jsx)(nonce_js_1.NonceContext.Provider, { value: nonceContext, children: (0, jsx_runtime_1.jsx)(nonce_js_1.SetNonceContext.Provider, { value: setNonceContext, children: (0, jsx_runtime_1.jsx)(timeline_position_state_js_1.TimelineContext.Provider, { value: timelineContextValue, children: (0, jsx_runtime_1.jsx)(timeline_position_state_js_1.SetTimelineContext.Provider, { value: setTimelineContextValue, children: (0, jsx_runtime_1.jsx)(use_media_enabled_js_1.MediaEnabledProvider, { videoEnabled: videoEnabled, audioEnabled: audioEnabled, children: (0, jsx_runtime_1.jsx)(EditorProps_js_1.EditorPropsProvider, { children: (0, jsx_runtime_1.jsx)(prefetch_state_js_1.PrefetchProvider, { children: (0, jsx_runtime_1.jsx)(CompositionManager_js_1.CompositionManagerProvider, { numberOfAudioTags: numberOfAudioTags, onlyRenderComposition: onlyRenderComposition, currentCompositionMetadata: currentCompositionMetadata, audioLatencyHint: audioLatencyHint, children: (0, jsx_runtime_1.jsx)(duration_state_js_1.DurationsContextProvider, { children: (0, jsx_runtime_1.jsx)(buffering_js_1.BufferingProvider, { children: children }) }) }) }) }) }) }) }) }) }) }));
50
+ return ((0, jsx_runtime_1.jsx)(log_level_context_js_1.LogLevelContext.Provider, { value: logging, children: (0, jsx_runtime_1.jsx)(nonce_js_1.NonceContext.Provider, { value: nonceContext, children: (0, jsx_runtime_1.jsx)(nonce_js_1.SetNonceContext.Provider, { value: setNonceContext, children: (0, jsx_runtime_1.jsx)(TimelineContext_js_1.TimelineContextProvider, { frameState: frameState, children: (0, jsx_runtime_1.jsx)(use_media_enabled_js_1.MediaEnabledProvider, { videoEnabled: videoEnabled, audioEnabled: audioEnabled, children: (0, jsx_runtime_1.jsx)(EditorProps_js_1.EditorPropsProvider, { children: (0, jsx_runtime_1.jsx)(prefetch_state_js_1.PrefetchProvider, { children: (0, jsx_runtime_1.jsx)(SequenceManager_js_1.SequenceManagerProvider, { children: (0, jsx_runtime_1.jsx)(RenderAssetManager_js_1.RenderAssetManagerProvider, { children: (0, jsx_runtime_1.jsx)(ResolveCompositionConfig_js_1.ResolveCompositionConfig, { children: (0, jsx_runtime_1.jsx)(shared_audio_tags_js_1.SharedAudioContextProvider, { numberOfAudioTags: numberOfAudioTags, audioLatencyHint: audioLatencyHint, children: (0, jsx_runtime_1.jsx)(duration_state_js_1.DurationsContextProvider, { children: (0, jsx_runtime_1.jsx)(buffering_js_1.BufferingProvider, { children: children }) }) }) }) }) }) }) }) }) }) }) }) }));
105
51
  };
106
52
  exports.RemotionRoot = RemotionRoot;
@@ -7,6 +7,7 @@ const react_1 = require("react");
7
7
  const AbsoluteFill_js_1 = require("./AbsoluteFill.js");
8
8
  const SequenceContext_js_1 = require("./SequenceContext.js");
9
9
  const SequenceManager_js_1 = require("./SequenceManager.js");
10
+ const TimelineContext_js_1 = require("./TimelineContext.js");
10
11
  const nonce_js_1 = require("./nonce.js");
11
12
  const timeline_position_state_js_1 = require("./timeline-position-state.js");
12
13
  const use_video_config_js_1 = require("./use-video-config.js");
@@ -18,7 +19,7 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, durationInFrames = Inf
18
19
  const { layout = 'absolute-fill' } = other;
19
20
  const [id] = (0, react_1.useState)(() => String(Math.random()));
20
21
  const parentSequence = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
21
- const { rootId } = (0, react_1.useContext)(timeline_position_state_js_1.TimelineContext);
22
+ const { rootId } = (0, react_1.useContext)(TimelineContext_js_1.TimelineContext);
22
23
  const cumulatedFrom = parentSequence
23
24
  ? parentSequence.cumulatedFrom + parentSequence.relativeFrom
24
25
  : 0;
@@ -0,0 +1,22 @@
1
+ import type { MutableRefObject } from 'react';
2
+ import React from 'react';
3
+ import { type PlayableMediaTag } from './timeline-position-state';
4
+ export type TimelineContextValue = {
5
+ frame: Record<string, number>;
6
+ playing: boolean;
7
+ rootId: string;
8
+ playbackRate: number;
9
+ imperativePlaying: MutableRefObject<boolean>;
10
+ setPlaybackRate: (u: React.SetStateAction<number>) => void;
11
+ audioAndVideoTags: MutableRefObject<PlayableMediaTag[]>;
12
+ };
13
+ export type SetTimelineContextValue = {
14
+ setFrame: (u: React.SetStateAction<Record<string, number>>) => void;
15
+ setPlaying: (u: React.SetStateAction<boolean>) => void;
16
+ };
17
+ export declare const SetTimelineContext: React.Context<SetTimelineContextValue>;
18
+ export declare const TimelineContext: React.Context<TimelineContextValue>;
19
+ export declare const TimelineContextProvider: React.FC<{
20
+ readonly children: React.ReactNode;
21
+ readonly frameState: Record<string, number> | null;
22
+ }>;
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TimelineContextProvider = exports.TimelineContext = exports.SetTimelineContext = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const random_1 = require("./random");
7
+ const timeline_position_state_1 = require("./timeline-position-state");
8
+ const use_delay_render_1 = require("./use-delay-render");
9
+ exports.SetTimelineContext = (0, react_1.createContext)({
10
+ setFrame: () => {
11
+ throw new Error('default');
12
+ },
13
+ setPlaying: () => {
14
+ throw new Error('default');
15
+ },
16
+ });
17
+ exports.TimelineContext = (0, react_1.createContext)({
18
+ frame: {},
19
+ playing: false,
20
+ playbackRate: 1,
21
+ rootId: '',
22
+ imperativePlaying: {
23
+ current: false,
24
+ },
25
+ setPlaybackRate: () => {
26
+ throw new Error('default');
27
+ },
28
+ audioAndVideoTags: { current: [] },
29
+ });
30
+ const TimelineContextProvider = ({ children, frameState }) => {
31
+ const [playing, setPlaying] = (0, react_1.useState)(false);
32
+ const imperativePlaying = (0, react_1.useRef)(false);
33
+ const [playbackRate, setPlaybackRate] = (0, react_1.useState)(1);
34
+ const audioAndVideoTags = (0, react_1.useRef)([]);
35
+ const [remotionRootId] = (0, react_1.useState)(() => String((0, random_1.random)(null)));
36
+ const [_frame, setFrame] = (0, react_1.useState)(() => (0, timeline_position_state_1.getInitialFrameState)());
37
+ const frame = frameState !== null && frameState !== void 0 ? frameState : _frame;
38
+ const { delayRender, continueRender } = (0, use_delay_render_1.useDelayRender)();
39
+ if (typeof window !== 'undefined') {
40
+ // eslint-disable-next-line react-hooks/rules-of-hooks
41
+ (0, react_1.useLayoutEffect)(() => {
42
+ window.remotion_setFrame = (f, composition, attempt) => {
43
+ window.remotion_attempt = attempt;
44
+ const id = delayRender(`Setting the current frame to ${f}`);
45
+ let asyncUpdate = true;
46
+ setFrame((s) => {
47
+ var _a;
48
+ const currentFrame = (_a = s[composition]) !== null && _a !== void 0 ? _a : window.remotion_initialFrame;
49
+ // Avoid cloning the object
50
+ if (currentFrame === f) {
51
+ asyncUpdate = false;
52
+ return s;
53
+ }
54
+ return {
55
+ ...s,
56
+ [composition]: f,
57
+ };
58
+ });
59
+ // After setting the state, need to wait until it is applied in the next cycle
60
+ if (asyncUpdate) {
61
+ requestAnimationFrame(() => continueRender(id));
62
+ }
63
+ else {
64
+ continueRender(id);
65
+ }
66
+ };
67
+ window.remotion_isPlayer = false;
68
+ }, [continueRender, delayRender]);
69
+ }
70
+ const timelineContextValue = (0, react_1.useMemo)(() => {
71
+ return {
72
+ frame,
73
+ playing,
74
+ imperativePlaying,
75
+ rootId: remotionRootId,
76
+ playbackRate,
77
+ setPlaybackRate,
78
+ audioAndVideoTags,
79
+ };
80
+ }, [frame, playbackRate, playing, remotionRootId]);
81
+ const setTimelineContextValue = (0, react_1.useMemo)(() => {
82
+ return {
83
+ setFrame,
84
+ setPlaying,
85
+ };
86
+ }, []);
87
+ return ((0, jsx_runtime_1.jsx)(exports.TimelineContext.Provider, { value: timelineContextValue, children: (0, jsx_runtime_1.jsx)(exports.SetTimelineContext.Provider, { value: setTimelineContextValue, children: children }) }));
88
+ };
89
+ exports.TimelineContextProvider = TimelineContextProvider;
@@ -1,4 +1,4 @@
1
- import type { AudioHTMLAttributes, ComponentType, LazyExoticComponent } from 'react';
1
+ import type { AudioHTMLAttributes } from 'react';
2
2
  import React from 'react';
3
3
  import type { SharedElementSourceNode } from './shared-element-source-node.js';
4
4
  /**
@@ -41,7 +41,6 @@ export declare const SharedAudioContext: React.Context<SharedContext | null>;
41
41
  export declare const SharedAudioContextProvider: React.FC<{
42
42
  readonly numberOfAudioTags: number;
43
43
  readonly children: React.ReactNode;
44
- readonly component: LazyExoticComponent<ComponentType<Record<string, unknown>>> | ComponentType<Record<string, unknown>> | null;
45
44
  readonly audioLatencyHint: AudioContextLatencyCategory;
46
45
  }>;
47
46
  export declare const useSharedAudio: ({ aud, audioId, premounting, }: {
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.useSharedAudio = exports.SharedAudioContextProvider = exports.SharedAudioContext = void 0;
37
37
  const jsx_runtime_1 = require("react/jsx-runtime");
38
38
  const react_1 = __importStar(require("react"));
39
+ const CompositionManagerContext_js_1 = require("../CompositionManagerContext.js");
39
40
  const log_level_context_js_1 = require("../log-level-context.js");
40
41
  const play_and_handle_not_allowed_error_js_1 = require("../play-and-handle-not-allowed-error.js");
41
42
  const use_remotion_environment_js_1 = require("../use-remotion-environment.js");
@@ -74,12 +75,19 @@ const didPropChange = (key, newProp, prevProp) => {
74
75
  return true;
75
76
  };
76
77
  exports.SharedAudioContext = (0, react_1.createContext)(null);
77
- const SharedAudioContextProvider = ({ children, numberOfAudioTags, component, audioLatencyHint }) => {
78
+ const SharedAudioContextProvider = ({ children, numberOfAudioTags, audioLatencyHint }) => {
78
79
  const audios = (0, react_1.useRef)([]);
79
80
  const [initialNumberOfAudioTags] = (0, react_1.useState)(numberOfAudioTags);
80
81
  if (numberOfAudioTags !== initialNumberOfAudioTags) {
81
82
  throw new Error('The number of shared audio tags has changed dynamically. Once you have set this property, you cannot change it afterwards.');
82
83
  }
84
+ const compositionManager = (0, react_1.useContext)(CompositionManagerContext_js_1.CompositionManager);
85
+ const component = compositionManager.compositions.find((c) => {
86
+ var _a;
87
+ return ((_a = compositionManager.canvasContent) === null || _a === void 0 ? void 0 : _a.type) === 'composition'
88
+ ? c.id === compositionManager.canvasContent.compositionId
89
+ : null;
90
+ });
83
91
  const logLevel = (0, log_level_context_js_1.useLogLevel)();
84
92
  const audioContext = (0, use_audio_context_js_1.useSingletonAudioContext)(logLevel, audioLatencyHint);
85
93
  const refs = (0, react_1.useMemo)(() => {
@@ -1 +1,8 @@
1
+ import type { DelayRenderScope } from './delay-render.js';
2
+ /**
3
+ * Internal function that accepts scope as parameter.
4
+ * This allows useDelayRender to control its own scope source.
5
+ * @private
6
+ */
7
+ export declare function cancelRenderInternal(scope: DelayRenderScope | undefined, err: unknown): never;
1
8
  export declare function cancelRender(err: unknown): never;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cancelRenderInternal = cancelRenderInternal;
3
4
  exports.cancelRender = cancelRender;
4
5
  const isErrorLike = (err) => {
5
6
  if (err instanceof Error) {
@@ -29,11 +30,12 @@ const isErrorLike = (err) => {
29
30
  }
30
31
  return true;
31
32
  };
32
- /*
33
- * @description When you invoke this function, Remotion will stop rendering all the frames without any retries.
34
- * @see [Documentation](https://remotion.dev/docs/cancel-render)
33
+ /**
34
+ * Internal function that accepts scope as parameter.
35
+ * This allows useDelayRender to control its own scope source.
36
+ * @private
35
37
  */
36
- function cancelRender(err) {
38
+ function cancelRenderInternal(scope, err) {
37
39
  let error;
38
40
  if (isErrorLike(err)) {
39
41
  error = err;
@@ -47,6 +49,15 @@ function cancelRender(err) {
47
49
  else {
48
50
  error = Error('Rendering was cancelled');
49
51
  }
50
- window.remotion_cancelledError = error.stack;
52
+ if (scope) {
53
+ scope.remotion_cancelledError = error.stack;
54
+ }
51
55
  throw error;
52
56
  }
57
+ /*
58
+ * @description When you invoke this function, Remotion will stop rendering all the frames without any retries.
59
+ * @see [Documentation](https://remotion.dev/docs/cancel-render)
60
+ */
61
+ function cancelRender(err) {
62
+ return cancelRenderInternal(typeof window !== 'undefined' ? window : undefined, err);
63
+ }
@@ -1,4 +1,18 @@
1
+ import type { LogLevel } from './log.js';
1
2
  import type { RemotionEnvironment } from './remotion-environment-context.js';
3
+ export type DelayRenderScope = {
4
+ remotion_renderReady: boolean;
5
+ remotion_delayRenderTimeouts: {
6
+ [key: string]: {
7
+ label: string | null;
8
+ timeout: number | Timer;
9
+ startTime: number;
10
+ };
11
+ };
12
+ remotion_puppeteerTimeout: number;
13
+ remotion_attempt: number;
14
+ remotion_cancelledError?: string;
15
+ };
2
16
  export declare const DELAY_RENDER_CALLSTACK_TOKEN = "The delayRender was called:";
3
17
  export declare const DELAY_RENDER_RETRIES_LEFT = "Retries left: ";
4
18
  export declare const DELAY_RENDER_RETRY_TOKEN = "- Rendering the frame will be retried.";
@@ -12,11 +26,21 @@ export type DelayRenderOptions = {
12
26
  * This allows useDelayRender to control its own environment source.
13
27
  * @private
14
28
  */
15
- export declare const delayRenderInternal: (environment: RemotionEnvironment, label?: string, options?: DelayRenderOptions) => number;
29
+ export declare const delayRenderInternal: ({ scope, environment, label, options, }: {
30
+ scope: DelayRenderScope | undefined;
31
+ environment: RemotionEnvironment;
32
+ label: string | null;
33
+ options: DelayRenderOptions;
34
+ }) => number;
16
35
  export declare const delayRender: (label?: string, options?: DelayRenderOptions) => number;
17
36
  /**
18
37
  * Internal function that accepts environment as parameter.
19
38
  * @private
20
39
  */
21
- export declare const continueRenderInternal: (handle: number, environment: RemotionEnvironment) => void;
40
+ export declare const continueRenderInternal: ({ scope, handle, environment, logLevel, }: {
41
+ scope: DelayRenderScope | undefined;
42
+ handle: number;
43
+ environment: RemotionEnvironment;
44
+ logLevel: LogLevel;
45
+ }) => void;
22
46
  export declare const continueRender: (handle: number) => void;