remotion 4.0.0-alpha12 → 4.0.0-alpha14

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.
@@ -57,7 +57,6 @@ const RemotionRoot = ({ children, numberOfAudioTags }) => {
57
57
  };
58
58
  }, [fastRefreshes]);
59
59
  (0, react_1.useEffect)(() => {
60
- // TODO: This can be moved to renderer?
61
60
  if (typeof __webpack_module__ !== 'undefined') {
62
61
  if (__webpack_module__.hot) {
63
62
  __webpack_module__.hot.addStatusHandler((status) => {
@@ -6,12 +6,13 @@ const react_1 = require("react");
6
6
  const CompositionManagerContext_js_1 = require("./CompositionManagerContext.js");
7
7
  const input_props_js_1 = require("./config/input-props.js");
8
8
  const EditorProps_js_1 = require("./EditorProps.js");
9
+ const get_environment_js_1 = require("./get-environment.js");
9
10
  const resolve_video_config_js_1 = require("./resolve-video-config.js");
10
11
  exports.ResolveCompositionContext = (0, react_1.createContext)(null);
11
12
  exports.resolveCompositionsRef = (0, react_1.createRef)();
12
13
  const ResolveCompositionConfig = ({ children }) => {
13
14
  const [currentRenderModalComposition, setCurrentRenderModalComposition] = (0, react_1.useState)(null);
14
- const { compositions, currentComposition } = (0, react_1.useContext)(CompositionManagerContext_js_1.CompositionManager);
15
+ const { compositions, currentComposition, currentCompositionMetadata } = (0, react_1.useContext)(CompositionManagerContext_js_1.CompositionManager);
15
16
  const selectedComposition = compositions.find((c) => c.id === currentComposition);
16
17
  const renderModalComposition = compositions.find((c) => c.id === currentRenderModalComposition);
17
18
  const { props: allEditorProps } = (0, react_1.useContext)(EditorProps_js_1.EditorPropsContext);
@@ -30,6 +31,9 @@ const ResolveCompositionConfig = ({ children }) => {
30
31
  }, [allEditorProps, renderModalComposition]);
31
32
  const doResolution = (0, react_1.useCallback)((composition, editorProps) => {
32
33
  const controller = new AbortController();
34
+ if (currentCompositionMetadata) {
35
+ return controller;
36
+ }
33
37
  const { signal } = controller;
34
38
  const promOrNot = (0, resolve_video_config_js_1.resolveVideoConfig)({ composition, editorProps, signal });
35
39
  if (typeof promOrNot === 'object' && 'then' in promOrNot) {
@@ -75,7 +79,7 @@ const ResolveCompositionConfig = ({ children }) => {
75
79
  }));
76
80
  }
77
81
  return controller;
78
- }, []);
82
+ }, [currentCompositionMetadata]);
79
83
  (0, react_1.useImperativeHandle)(exports.resolveCompositionsRef, () => {
80
84
  return {
81
85
  setCurrentRenderModalComposition: (id) => {
@@ -140,7 +144,7 @@ exports.needsResolution = needsResolution;
140
144
  const useResolvedVideoConfig = (preferredCompositionId) => {
141
145
  const context = (0, react_1.useContext)(exports.ResolveCompositionContext);
142
146
  const { props: allEditorProps } = (0, react_1.useContext)(EditorProps_js_1.EditorPropsContext);
143
- const { compositions, currentComposition } = (0, react_1.useContext)(CompositionManagerContext_js_1.CompositionManager);
147
+ const { compositions, currentComposition, currentCompositionMetadata } = (0, react_1.useContext)(CompositionManagerContext_js_1.CompositionManager);
144
148
  const compositionId = preferredCompositionId !== null && preferredCompositionId !== void 0 ? preferredCompositionId : currentComposition;
145
149
  const composition = compositions.find((c) => c.id === compositionId);
146
150
  const selectedEditorProps = (0, react_1.useMemo)(() => {
@@ -148,19 +152,33 @@ const useResolvedVideoConfig = (preferredCompositionId) => {
148
152
  return composition ? (_a = allEditorProps[composition.id]) !== null && _a !== void 0 ? _a : {} : {};
149
153
  }, [allEditorProps, composition]);
150
154
  return (0, react_1.useMemo)(() => {
151
- var _a, _b;
155
+ var _a, _b, _c;
152
156
  if (!composition) {
153
157
  return null;
154
158
  }
159
+ if (currentCompositionMetadata) {
160
+ return {
161
+ type: 'success',
162
+ result: {
163
+ ...currentCompositionMetadata,
164
+ id: composition.id,
165
+ defaultProps: (_a = currentCompositionMetadata.defaultProps) !== null && _a !== void 0 ? _a : {},
166
+ },
167
+ };
168
+ }
155
169
  if (!(0, exports.needsResolution)(composition)) {
156
170
  return {
157
171
  type: 'success',
158
172
  result: {
159
173
  ...composition,
160
174
  defaultProps: {
161
- ...((_a = composition.defaultProps) !== null && _a !== void 0 ? _a : {}),
175
+ ...((_b = composition.defaultProps) !== null && _b !== void 0 ? _b : {}),
162
176
  ...(selectedEditorProps !== null && selectedEditorProps !== void 0 ? selectedEditorProps : {}),
163
- ...(typeof window === 'undefined' ? {} : (_b = (0, input_props_js_1.getInputProps)()) !== null && _b !== void 0 ? _b : {}),
177
+ ...(typeof window === 'undefined' ||
178
+ (0, get_environment_js_1.getRemotionEnvironment)() === 'player-development' ||
179
+ (0, get_environment_js_1.getRemotionEnvironment)() === 'player-production'
180
+ ? {}
181
+ : (_c = (0, input_props_js_1.getInputProps)()) !== null && _c !== void 0 ? _c : {}),
164
182
  },
165
183
  },
166
184
  };
@@ -169,6 +187,6 @@ const useResolvedVideoConfig = (preferredCompositionId) => {
169
187
  return null;
170
188
  }
171
189
  return context[composition.id];
172
- }, [composition, context, selectedEditorProps]);
190
+ }, [composition, context, currentCompositionMetadata, selectedEditorProps]);
173
191
  };
174
192
  exports.useResolvedVideoConfig = useResolvedVideoConfig;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { TSequence } from './CompositionManager.js';
3
+ export declare type SequenceManagerContext = {
4
+ registerSequence: (seq: TSequence) => void;
5
+ unregisterSequence: (id: string) => void;
6
+ sequences: TSequence[];
7
+ };
8
+ export declare const SequenceManager: React.Context<SequenceManagerContext>;
9
+ export declare const SequenceAndAssetManagerProvider: React.FC<{
10
+ children: React.ReactNode;
11
+ }>;
@@ -0,0 +1,57 @@
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.SequenceAndAssetManagerProvider = exports.SequenceManager = void 0;
27
+ const jsx_runtime_1 = require("react/jsx-runtime");
28
+ const react_1 = __importStar(require("react"));
29
+ exports.SequenceManager = react_1.default.createContext({
30
+ registerSequence: () => {
31
+ throw new Error('SequenceManagerContext not initialized');
32
+ },
33
+ unregisterSequence: () => {
34
+ throw new Error('SequenceManagerContext not initialized');
35
+ },
36
+ sequences: [],
37
+ });
38
+ const SequenceAndAssetManagerProvider = ({ children }) => {
39
+ const [sequences, setSequences] = (0, react_1.useState)([]);
40
+ const registerSequence = (0, react_1.useCallback)((seq) => {
41
+ setSequences((seqs) => {
42
+ return [...seqs, seq];
43
+ });
44
+ }, []);
45
+ const unregisterSequence = (0, react_1.useCallback)((seq) => {
46
+ setSequences((seqs) => seqs.filter((s) => s.id !== seq));
47
+ }, []);
48
+ const context = (0, react_1.useMemo)(() => {
49
+ return {
50
+ registerSequence,
51
+ sequences,
52
+ unregisterSequence,
53
+ };
54
+ }, [registerSequence, sequences, unregisterSequence]);
55
+ return ((0, jsx_runtime_1.jsx)(exports.SequenceManager.Provider, { value: context, children: children }));
56
+ };
57
+ exports.SequenceAndAssetManagerProvider = SequenceAndAssetManagerProvider;
@@ -0,0 +1,294 @@
1
+ /**
2
+ * The configuration has moved to @remotion/cli.
3
+ * For the moment the type definitions are going to stay here
4
+ */
5
+ import type { Configuration } from 'webpack';
6
+ declare type Concurrency = number | null;
7
+ declare type BrowserExecutable = string | null;
8
+ declare type FrameRange = number | [number, number];
9
+ declare type FfmpegExecutable = string | null;
10
+ declare type Loop = number | null;
11
+ declare type CodecOrUndefined = 'h264' | 'h265' | 'vp8' | 'vp9' | 'mp3' | 'aac' | 'wav' | 'prores' | 'h264-mkv' | 'gif' | undefined;
12
+ declare type Crf = number | undefined;
13
+ export declare type WebpackConfiguration = Configuration;
14
+ export declare type WebpackOverrideFn = (currentConfiguration: WebpackConfiguration) => WebpackConfiguration;
15
+ declare type FlatConfig = RemotionConfigObject['Bundling'] & RemotionConfigObject['Log'] & RemotionConfigObject['Preview'] & RemotionConfigObject['Puppeteer'] & RemotionConfigObject['Output'] & RemotionConfigObject['Rendering'] & {
16
+ /**
17
+ * Set the audio codec to use for the output video.
18
+ * See the Encoding guide in the docs for defaults and available options.
19
+ */
20
+ setAudioCodec: (codec: 'pcm-16' | 'aac' | 'mp3' | 'opus') => void;
21
+ };
22
+ declare global {
23
+ interface RemotionBundlingOptions {
24
+ /**
25
+ * Specify the entry point so you don't have to specify it in the
26
+ * CLI command
27
+ */
28
+ readonly setEntryPoint: (src: string) => void;
29
+ /**
30
+ * Whether Webpack bundles should be cached to make
31
+ * subsequent renders faster. Default: true
32
+ */
33
+ readonly setCachingEnabled: (flag: boolean) => void;
34
+ /**
35
+ * Define on which port Remotion should start it's HTTP servers during preview and rendering.
36
+ * By default, Remotion will try to find a free port.
37
+ * If you specify a port, but it's not available, Remotion will throw an error.
38
+ */
39
+ readonly setPort: (port: number | undefined) => void;
40
+ /**
41
+ * Define the location of the public/ directory.
42
+ * By default it is a folder named "public" inside the current working directory.
43
+ * You can set an absolute path or a relative path that will be resolved from the closest package.json location.
44
+ */
45
+ readonly setPublicDir: (publicDir: string | null) => void;
46
+ readonly overrideWebpackConfig: (f: WebpackOverrideFn) => void;
47
+ }
48
+ interface RemotionConfigObject {
49
+ /**
50
+ * @deprecated New flat config format: You can now replace `Config.Preview.` with `Config.`
51
+ */
52
+ readonly Preview: {
53
+ /**
54
+ * Change the maximum amount of tracks that are shown in the timeline.
55
+ * @param maxTracks The maximum amount of timeline tracks that you would like to show.
56
+ * @default 15
57
+ */
58
+ readonly setMaxTimelineTracks: (maxTracks: number) => void;
59
+ /**
60
+ * Enable Keyboard shortcuts in the Remotion Preview.
61
+ * @param enabled Boolean whether to enable the keyboard shortcuts
62
+ * @default true
63
+ */
64
+ readonly setKeyboardShortcutsEnabled: (enableShortcuts: boolean) => void;
65
+ /**
66
+ * Set number of shared audio tags. https://www.remotion.dev/docs/player/autoplay#use-the-numberofsharedaudiotags-property
67
+ * @param numberOfAudioTags
68
+ * @default 0
69
+ */
70
+ readonly setNumberOfSharedAudioTags: (numberOfAudioTags: number) => void;
71
+ /**
72
+ * Enable Webpack polling instead of file system listeners for hot reloading in the preview.
73
+ * This is useful if you are using a remote directory or a virtual machine.
74
+ * @param interval
75
+ * @default null
76
+ */
77
+ readonly setWebpackPollingInMilliseconds: (interval: number | null) => void;
78
+ /**
79
+ * Whether Remotion should open a browser when starting the Preview.
80
+ * @param should
81
+ * @default true
82
+ */
83
+ readonly setShouldOpenBrowser: (should: boolean) => void;
84
+ };
85
+ /**
86
+ * @deprecated New flat config format: You can now replace `Config.Bundling.` with `Config.`
87
+ */
88
+ readonly Bundling: RemotionBundlingOptions;
89
+ /**
90
+ * @deprecated New flat config format: You can now replace `Config.Log.` with `Config.`
91
+ */
92
+ readonly Log: {
93
+ /**
94
+ * Set the log level.
95
+ * Acceptable values: 'error' | 'warning' | 'info' | 'verbose'
96
+ * Default value: 'info'
97
+ *
98
+ * Set this to 'verbose' to get browser logs and other IO.
99
+ */
100
+ readonly setLevel: (newLogLevel: 'verbose' | 'info' | 'warn' | 'error') => void;
101
+ };
102
+ /**
103
+ * @deprecated New flat config format: You can now replace `Config.Puppeteer.` with `Config.`
104
+ */
105
+ readonly Puppeteer: {
106
+ /**
107
+ * Specify executable path for the browser to use.
108
+ * Default: null, which will make Remotion find or download a version of said browser.
109
+ */
110
+ readonly setBrowserExecutable: (newBrowserExecutablePath: BrowserExecutable) => void;
111
+ /**
112
+ * Set how many milliseconds a frame may take to render before it times out.
113
+ * Default: `30000`
114
+ */
115
+ readonly setDelayRenderTimeoutInMilliseconds: (newPuppeteerTimeout: number) => void;
116
+ /**
117
+ * @deprecated Renamed to `setDelayRenderTimeoutInMilliseconds`.
118
+ * Set how many milliseconds a frame may take to render before it times out.
119
+ * Default: `30000`
120
+ */
121
+ readonly setTimeoutInMilliseconds: (newPuppeteerTimeout: number) => void;
122
+ /**
123
+ * Setting deciding whether to disable CORS and other Chrome security features.
124
+ * Default: false
125
+ */
126
+ readonly setChromiumDisableWebSecurity: (should: boolean) => void;
127
+ /**
128
+ * Setting whether to ignore any invalid SSL certificates, such as self-signed ones.
129
+ * Default: false
130
+ */
131
+ readonly setChromiumIgnoreCertificateErrors: (should: boolean) => void;
132
+ /**
133
+ * If false, will open an actual browser during rendering to observe progress.
134
+ * Default: true
135
+ */
136
+ readonly setChromiumHeadlessMode: (should: boolean) => void;
137
+ /**
138
+ * Set the OpenGL rendering backend for Chrome. Possible values: 'egl', 'angle', 'swiftshader' and 'swangle'.
139
+ * Default: 'swangle' in Lambda, null elsewhere.
140
+ */
141
+ readonly setChromiumOpenGlRenderer: (renderer: 'swangle' | 'angle' | 'egl' | 'swiftshader') => void;
142
+ /**
143
+ * Set the user agent for Chrome. Only works during rendering.
144
+ * Default:
145
+ */
146
+ readonly setChromiumUserAgent: (userAgent: string | null) => void;
147
+ };
148
+ /**
149
+ * @deprecated New flat config format: You can now replace `Config.Rendering.` with `Config.`
150
+ */
151
+ readonly Rendering: {
152
+ /**
153
+ * Set a custom location for a .env file.
154
+ * Default: `.env`
155
+ */
156
+ readonly setDotEnvLocation: (file: string) => void;
157
+ /**
158
+ * Sets how many Puppeteer instances will work on rendering your video in parallel.
159
+ * Default: `null`, meaning half of the threads available on your CPU.
160
+ */
161
+ readonly setConcurrency: (newConcurrency: Concurrency) => void;
162
+ /**
163
+ * Set the JPEG quality for the frames.
164
+ * Must be between 0 and 100.
165
+ * Must be between 0 and 100.
166
+ * Default: 80
167
+ */
168
+ readonly setQuality: (q: number | undefined) => void;
169
+ /** Decide in which image format to render. Can be either 'jpeg' or 'png'.
170
+ * PNG is slower, but supports transparency.
171
+ */
172
+ readonly setImageFormat: (format: 'png' | 'jpeg' | 'none') => void;
173
+ /**
174
+ * Render only a subset of a video.
175
+ * Pass in a tuple [20, 30] to only render frames 20-30 into a video.
176
+ * Pass in a single number `20` to only render a single frame as an image.
177
+ * The frame count starts at 0.
178
+ */
179
+ readonly setFrameRange: (newFrameRange: FrameRange | null) => void;
180
+ /**
181
+ * Specify local ffmpeg executable.
182
+ * Default: null, which will use ffmpeg available in PATH.
183
+ */
184
+ readonly setFfmpegExecutable: (ffmpegPath: FfmpegExecutable) => void;
185
+ /**
186
+ * Specify local ffprobe executable.
187
+ * Default: null, which will use ffprobe available in PATH.
188
+ */
189
+ readonly setFfprobeExecutable: (ffprobePath: FfmpegExecutable) => void;
190
+ /**
191
+ * Scales the output dimensions by a factor.
192
+ * Default: 1.
193
+ */
194
+ readonly setScale: (newScale: number) => void;
195
+ /**
196
+ * Specify which frames should be picked for rendering a GIF
197
+ * Default: 1, which means every frame
198
+ * https://remotion.dev/docs/render-as-gif
199
+ */
200
+ readonly setEveryNthFrame: (frame: number) => void;
201
+ /**
202
+ * Specify the number of Loop a GIF should have.
203
+ * Default: null (means GIF will loop infinite)
204
+ */
205
+ readonly setNumberOfGifLoops: (newLoop: Loop) => void;
206
+ /**
207
+ * Disable audio output.
208
+ * Default: false
209
+ */
210
+ readonly setMuted: (muted: boolean) => void;
211
+ /**
212
+ * Don't render an audio track if it would be silent.
213
+ * Default: true
214
+ */
215
+ readonly setEnforceAudioTrack: (enforceAudioTrack: boolean) => void;
216
+ };
217
+ /**
218
+ * @deprecated New flat config format: You can now replace `Config.Output.` with `Config.`
219
+ */
220
+ readonly Output: {
221
+ /**
222
+ * Set the output file location string. Default: `out/{composition}.{codec}`
223
+ */
224
+ readonly setOutputLocation: (newOutputLocation: string) => void;
225
+ /**
226
+ * If the video file already exists, should Remotion overwrite
227
+ * the output? Default: true
228
+ */
229
+ readonly setOverwriteOutput: (newOverwrite: boolean) => void;
230
+ /**
231
+ * Sets the pixel format in FFMPEG.
232
+ * See https://trac.ffmpeg.org/wiki/Chroma%20Subsampling for an explanation.
233
+ * You can override this using the `--pixel-format` Cli flag.
234
+ */
235
+ readonly setPixelFormat: (format: 'yuv420p' | 'yuva420p' | 'yuv422p' | 'yuv444p' | 'yuv420p10le' | 'yuv422p10le' | 'yuv444p10le' | 'yuva444p10le') => void;
236
+ /**
237
+ * @deprecated Use setCodec() and setImageSequence() instead.
238
+ * Specify what kind of output you, either `mp4` or `png-sequence`.
239
+ */
240
+ readonly setOutputFormat: (newLegacyFormat: 'mp4' | 'png-sequence') => void;
241
+ /**
242
+ * Specify the codec for stitching the frames into a video.
243
+ * Can be `h264` (default), `h265`, `vp8` or `vp9`
244
+ */
245
+ readonly setCodec: (newCodec: CodecOrUndefined) => void;
246
+ /**
247
+ * Set the Constant Rate Factor to pass to FFMPEG.
248
+ * Lower values mean better quality, but be aware that the ranges of
249
+ * possible values greatly differs between codecs.
250
+ */
251
+ readonly setCrf: (newCrf: Crf) => void;
252
+ /**
253
+ * Set to true if don't want a video but an image sequence as the output.
254
+ */
255
+ readonly setImageSequence: (newImageSequence: boolean) => void;
256
+ /**
257
+ * Overrides the height of a composition
258
+ */
259
+ readonly overrideHeight: (newHeight: number) => void;
260
+ /**
261
+ * Overrides the width of a composition
262
+ */
263
+ readonly overrideWidth: (newWidth: number) => void;
264
+ /**
265
+ * Set the ProRes profile.
266
+ * This method is only valid if the codec has been set to 'prores'.
267
+ * Possible values: 4444-xq, 4444, hq, standard, light, proxy. Default: 'hq'
268
+ * See https://avpres.net/FFmpeg/im_ProRes.html for meaning of possible values.
269
+ */
270
+ readonly setProResProfile: (profile: '4444-xq' | '4444' | 'hq' | 'standard' | 'light' | 'proxy' | undefined) => void;
271
+ /**
272
+ * Override the arguments that Remotion passes to FFMPEG.
273
+ * Consult https://remotion.dev/docs/renderer/render-media#ffmpegoverride before using this feature.
274
+ */
275
+ readonly overrideFfmpegCommand: (command: (info: {
276
+ type: 'pre-stitcher' | 'stitcher';
277
+ args: string[];
278
+ }) => string[]) => void;
279
+ /**
280
+ * Set a target audio bitrate to be passed to FFMPEG.
281
+ */
282
+ readonly setAudioBitrate: (bitrate: string | null) => void;
283
+ /**
284
+ * Set a target video bitrate to be passed to FFMPEG.
285
+ * Mutually exclusive with setCrf().
286
+ */
287
+ readonly setVideoBitrate: (bitrate: string | null) => void;
288
+ };
289
+ }
290
+ }
291
+ export declare type ConfigType = RemotionConfigObject & FlatConfig;
292
+ export type { Concurrency };
293
+ export declare const Config: ConfigType;
294
+ export declare const enableLegacyRemotionConfig: () => void;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.enableLegacyRemotionConfig = exports.Config = void 0;
4
+ const conf = {};
5
+ let enabled = false;
6
+ exports.Config = new Proxy(conf, {
7
+ get(target, prop, receiver) {
8
+ if (!enabled) {
9
+ if (typeof document !== 'undefined') {
10
+ // We are in the browser
11
+ return {};
12
+ }
13
+ throw new Error('To use the Remotion config file, you need to have @remotion/cli installed.\n- Make sure that all versions of Remotion are the same.\n- Make sure that @remotion/cli is installed.\n- Make sure Config is imported from "@remotion/cli", not "remotion".');
14
+ }
15
+ return Reflect.get(target, prop, receiver);
16
+ },
17
+ });
18
+ const enableLegacyRemotionConfig = () => {
19
+ enabled = true;
20
+ };
21
+ exports.enableLegacyRemotionConfig = enableLegacyRemotionConfig;
@@ -7,9 +7,10 @@ declare global {
7
7
  interface Window {
8
8
  remotion_renderReady: boolean;
9
9
  remotion_cancelledError: string | undefined;
10
+ remotion_getCompositionNames: () => string[];
10
11
  getStaticCompositions: () => Promise<AnyCompMetadata[]>;
11
- calculateComposition: (compId: string) => Promise<VideoConfig>;
12
- setBundleMode: (bundleMode: BundleState) => void;
12
+ remotion_calculateComposition: (compId: string) => Promise<VideoConfig>;
13
+ remotion_setBundleMode: (bundleMode: BundleState) => void;
13
14
  remotion_staticBase: string;
14
15
  remotion_staticFiles: StaticFile[];
15
16
  remotion_editorName: string | null;
@@ -35,7 +36,7 @@ declare global {
35
36
  remotion_imported: string | boolean;
36
37
  }
37
38
  }
38
- export declare type BundleState = {
39
+ export type BundleState = {
39
40
  type: 'index';
40
41
  } | {
41
42
  type: 'evaluation';
@@ -125,5 +125,7 @@ export declare const Internals: {
125
125
  children: import("react").ReactNode;
126
126
  }>>;
127
127
  REMOTION_STUDIO_CONTAINER_ELEMENT: string;
128
+ AssetManager: import("react").Context<import("./AssetManager.js").AssetManagerContext>;
129
+ bundleName: string;
128
130
  };
129
131
  export type { TComposition, Timeline, TCompMetadata, TSequence, TAsset, TimelineContextValue, SetTimelineContextValue, CompProps, CompositionManagerContext, MediaVolumeContextValue, SetMediaVolumeContextValue, RemotionEnvironment, };
@@ -24,6 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.Internals = void 0;
27
+ const AssetManager_js_1 = require("./AssetManager.js");
27
28
  const shared_audio_tags_js_1 = require("./audio/shared-audio-tags.js");
28
29
  const CanUseRemotionHooks_js_1 = require("./CanUseRemotionHooks.js");
29
30
  const CompositionManager_js_1 = require("./CompositionManager.js");
@@ -114,4 +115,6 @@ exports.Internals = {
114
115
  resolveCompositionsRef: ResolveCompositionConfig_js_1.resolveCompositionsRef,
115
116
  ResolveCompositionConfig: ResolveCompositionConfig_js_1.ResolveCompositionConfig,
116
117
  REMOTION_STUDIO_CONTAINER_ELEMENT: get_preview_dom_element_js_1.REMOTION_STUDIO_CONTAINER_ELEMENT,
118
+ AssetManager: AssetManager_js_1.AssetManager,
119
+ bundleName: 'bundle.js',
117
120
  };
@@ -2,17 +2,22 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveVideoConfig = void 0;
4
4
  const input_props_js_1 = require("./config/input-props.js");
5
+ const get_environment_js_1 = require("./get-environment.js");
5
6
  const validate_dimensions_js_1 = require("./validation/validate-dimensions.js");
6
7
  const validate_duration_in_frames_js_1 = require("./validation/validate-duration-in-frames.js");
7
8
  const resolveVideoConfig = ({ composition, editorProps: editorPropsOrUndefined, signal, }) => {
8
- var _a, _b, _c;
9
+ var _a, _b, _c, _d, _e;
9
10
  const calculatedProm = composition.calculateMetadata
10
11
  ? composition.calculateMetadata({
11
12
  defaultProps: (_a = composition.defaultProps) !== null && _a !== void 0 ? _a : {},
12
13
  props: {
13
14
  ...((_b = composition.defaultProps) !== null && _b !== void 0 ? _b : {}),
14
15
  ...(editorPropsOrUndefined !== null && editorPropsOrUndefined !== void 0 ? editorPropsOrUndefined : {}),
15
- ...(typeof window === 'undefined' ? {} : (_c = (0, input_props_js_1.getInputProps)()) !== null && _c !== void 0 ? _c : {}),
16
+ ...(typeof window === 'undefined' ||
17
+ (0, get_environment_js_1.getRemotionEnvironment)() === 'player-development' ||
18
+ (0, get_environment_js_1.getRemotionEnvironment)() === 'player-production'
19
+ ? {}
20
+ : (_c = (0, input_props_js_1.getInputProps)()) !== null && _c !== void 0 ? _c : {}),
16
21
  },
17
22
  abortSignal: signal,
18
23
  })
@@ -31,7 +36,7 @@ const resolveVideoConfig = ({ composition, editorProps: editorPropsOrUndefined,
31
36
  fps,
32
37
  durationInFrames,
33
38
  id: composition.id,
34
- defaultProps: composition.defaultProps,
39
+ defaultProps: c.props,
35
40
  };
36
41
  });
37
42
  }
@@ -39,10 +44,17 @@ const resolveVideoConfig = ({ composition, editorProps: editorPropsOrUndefined,
39
44
  calculated: calculatedProm,
40
45
  composition,
41
46
  });
47
+ if (calculatedProm === null) {
48
+ return {
49
+ ...data,
50
+ id: composition.id,
51
+ defaultProps: (_d = composition === null || composition === void 0 ? void 0 : composition.defaultProps) !== null && _d !== void 0 ? _d : {},
52
+ };
53
+ }
42
54
  return {
43
55
  ...data,
44
56
  id: composition.id,
45
- defaultProps: composition.defaultProps,
57
+ defaultProps: ((_e = calculatedProm === null || calculatedProm === void 0 ? void 0 : calculatedProm.props) !== null && _e !== void 0 ? _e : {}),
46
58
  };
47
59
  };
48
60
  exports.resolveVideoConfig = resolveVideoConfig;
@@ -0,0 +1 @@
1
+ export declare const validateOffthreadVideoImageFormat: (input: unknown) => void;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateOffthreadVideoImageFormat = void 0;
4
+ const validateOffthreadVideoImageFormat = (input) => {
5
+ if (typeof input === 'undefined') {
6
+ return;
7
+ }
8
+ if (typeof input !== 'string') {
9
+ throw new TypeError(`<OffthreadVideo imageFormat=""> must be a string, but got ${JSON.stringify(input)} instead.`);
10
+ }
11
+ if (input !== 'png' && input !== 'jpeg') {
12
+ throw new TypeError(`<OffthreadVideo imageFormat=""> must be either "png" or "jpeg", but got ${input}`);
13
+ }
14
+ };
15
+ exports.validateOffthreadVideoImageFormat = validateOffthreadVideoImageFormat;
@@ -1 +1 @@
1
- export declare const VERSION = "4.0.0-alpha12";
1
+ export declare const VERSION = "4.0.0-alpha14";
@@ -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.0-alpha12';
5
+ exports.VERSION = '4.0.0-alpha14';
@@ -58,7 +58,7 @@ function truthy(value) {
58
58
  }
59
59
 
60
60
  // Automatically generated on publish
61
- const VERSION = '4.0.0-alpha12';
61
+ const VERSION = '4.0.0-alpha14';
62
62
 
63
63
  const checkMultipleRemotionVersions = () => {
64
64
  if (typeof globalThis === 'undefined') {
@@ -378,14 +378,18 @@ const validateDurationInFrames = ({ allowFloats, component, durationInFrames, })
378
378
  };
379
379
 
380
380
  const resolveVideoConfig = ({ composition, editorProps: editorPropsOrUndefined, signal, }) => {
381
- var _a, _b, _c;
381
+ var _a, _b, _c, _d, _e;
382
382
  const calculatedProm = composition.calculateMetadata
383
383
  ? composition.calculateMetadata({
384
384
  defaultProps: (_a = composition.defaultProps) !== null && _a !== void 0 ? _a : {},
385
385
  props: {
386
386
  ...((_b = composition.defaultProps) !== null && _b !== void 0 ? _b : {}),
387
387
  ...(editorPropsOrUndefined !== null && editorPropsOrUndefined !== void 0 ? editorPropsOrUndefined : {}),
388
- ...(typeof window === 'undefined' ? {} : (_c = getInputProps()) !== null && _c !== void 0 ? _c : {}),
388
+ ...(typeof window === 'undefined' ||
389
+ getRemotionEnvironment() === 'player-development' ||
390
+ getRemotionEnvironment() === 'player-production'
391
+ ? {}
392
+ : (_c = getInputProps()) !== null && _c !== void 0 ? _c : {}),
389
393
  },
390
394
  abortSignal: signal,
391
395
  })
@@ -404,7 +408,7 @@ const resolveVideoConfig = ({ composition, editorProps: editorPropsOrUndefined,
404
408
  fps,
405
409
  durationInFrames,
406
410
  id: composition.id,
407
- defaultProps: composition.defaultProps,
411
+ defaultProps: c.props,
408
412
  };
409
413
  });
410
414
  }
@@ -412,10 +416,17 @@ const resolveVideoConfig = ({ composition, editorProps: editorPropsOrUndefined,
412
416
  calculated: calculatedProm,
413
417
  composition,
414
418
  });
419
+ if (calculatedProm === null) {
420
+ return {
421
+ ...data,
422
+ id: composition.id,
423
+ defaultProps: (_d = composition === null || composition === void 0 ? void 0 : composition.defaultProps) !== null && _d !== void 0 ? _d : {},
424
+ };
425
+ }
415
426
  return {
416
427
  ...data,
417
428
  id: composition.id,
418
- defaultProps: composition.defaultProps,
429
+ defaultProps: ((_e = calculatedProm === null || calculatedProm === void 0 ? void 0 : calculatedProm.props) !== null && _e !== void 0 ? _e : {}),
419
430
  };
420
431
  };
421
432
  const validateCalculated = ({ composition, calculated, }) => {
@@ -451,7 +462,7 @@ const ResolveCompositionContext = createContext(null);
451
462
  const resolveCompositionsRef = createRef();
452
463
  const ResolveCompositionConfig = ({ children }) => {
453
464
  const [currentRenderModalComposition, setCurrentRenderModalComposition] = useState(null);
454
- const { compositions, currentComposition } = useContext(CompositionManager);
465
+ const { compositions, currentComposition, currentCompositionMetadata } = useContext(CompositionManager);
455
466
  const selectedComposition = compositions.find((c) => c.id === currentComposition);
456
467
  const renderModalComposition = compositions.find((c) => c.id === currentRenderModalComposition);
457
468
  const { props: allEditorProps } = useContext(EditorPropsContext);
@@ -470,6 +481,9 @@ const ResolveCompositionConfig = ({ children }) => {
470
481
  }, [allEditorProps, renderModalComposition]);
471
482
  const doResolution = useCallback((composition, editorProps) => {
472
483
  const controller = new AbortController();
484
+ if (currentCompositionMetadata) {
485
+ return controller;
486
+ }
473
487
  const { signal } = controller;
474
488
  const promOrNot = resolveVideoConfig({ composition, editorProps, signal });
475
489
  if (typeof promOrNot === 'object' && 'then' in promOrNot) {
@@ -515,7 +529,7 @@ const ResolveCompositionConfig = ({ children }) => {
515
529
  }));
516
530
  }
517
531
  return controller;
518
- }, []);
532
+ }, [currentCompositionMetadata]);
519
533
  useImperativeHandle(resolveCompositionsRef, () => {
520
534
  return {
521
535
  setCurrentRenderModalComposition: (id) => {
@@ -578,7 +592,7 @@ const needsResolution = (composition) => {
578
592
  const useResolvedVideoConfig = (preferredCompositionId) => {
579
593
  const context = useContext(ResolveCompositionContext);
580
594
  const { props: allEditorProps } = useContext(EditorPropsContext);
581
- const { compositions, currentComposition } = useContext(CompositionManager);
595
+ const { compositions, currentComposition, currentCompositionMetadata } = useContext(CompositionManager);
582
596
  const compositionId = preferredCompositionId !== null && preferredCompositionId !== void 0 ? preferredCompositionId : currentComposition;
583
597
  const composition = compositions.find((c) => c.id === compositionId);
584
598
  const selectedEditorProps = useMemo(() => {
@@ -586,19 +600,33 @@ const useResolvedVideoConfig = (preferredCompositionId) => {
586
600
  return composition ? (_a = allEditorProps[composition.id]) !== null && _a !== void 0 ? _a : {} : {};
587
601
  }, [allEditorProps, composition]);
588
602
  return useMemo(() => {
589
- var _a, _b;
603
+ var _a, _b, _c;
590
604
  if (!composition) {
591
605
  return null;
592
606
  }
607
+ if (currentCompositionMetadata) {
608
+ return {
609
+ type: 'success',
610
+ result: {
611
+ ...currentCompositionMetadata,
612
+ id: composition.id,
613
+ defaultProps: (_a = currentCompositionMetadata.defaultProps) !== null && _a !== void 0 ? _a : {},
614
+ },
615
+ };
616
+ }
593
617
  if (!needsResolution(composition)) {
594
618
  return {
595
619
  type: 'success',
596
620
  result: {
597
621
  ...composition,
598
622
  defaultProps: {
599
- ...((_a = composition.defaultProps) !== null && _a !== void 0 ? _a : {}),
623
+ ...((_b = composition.defaultProps) !== null && _b !== void 0 ? _b : {}),
600
624
  ...(selectedEditorProps !== null && selectedEditorProps !== void 0 ? selectedEditorProps : {}),
601
- ...(typeof window === 'undefined' ? {} : (_b = getInputProps()) !== null && _b !== void 0 ? _b : {}),
625
+ ...(typeof window === 'undefined' ||
626
+ getRemotionEnvironment() === 'player-development' ||
627
+ getRemotionEnvironment() === 'player-production'
628
+ ? {}
629
+ : (_c = getInputProps()) !== null && _c !== void 0 ? _c : {}),
602
630
  },
603
631
  },
604
632
  };
@@ -607,7 +635,7 @@ const useResolvedVideoConfig = (preferredCompositionId) => {
607
635
  return null;
608
636
  }
609
637
  return context[composition.id];
610
- }, [composition, context, selectedEditorProps]);
638
+ }, [composition, context, currentCompositionMetadata, selectedEditorProps]);
611
639
  };
612
640
 
613
641
  const useVideo = () => {
@@ -3470,7 +3498,6 @@ const RemotionRoot = ({ children, numberOfAudioTags }) => {
3470
3498
  };
3471
3499
  }, [fastRefreshes]);
3472
3500
  useEffect(() => {
3473
- // TODO: This can be moved to renderer?
3474
3501
  if (typeof __webpack_module__ !== 'undefined') {
3475
3502
  if (__webpack_module__.hot) {
3476
3503
  __webpack_module__.hot.addStatusHandler((status) => {
@@ -3632,6 +3659,8 @@ const Internals = {
3632
3659
  resolveCompositionsRef,
3633
3660
  ResolveCompositionConfig,
3634
3661
  REMOTION_STUDIO_CONTAINER_ELEMENT,
3662
+ AssetManager,
3663
+ bundleName: 'bundle.js',
3635
3664
  };
3636
3665
 
3637
3666
  const flattenChildren = (children) => {
@@ -1,4 +1,4 @@
1
1
  // Automatically generated on publish
2
- const VERSION = '4.0.0-alpha12';
2
+ const VERSION = '4.0.0-alpha14';
3
3
 
4
4
  export { VERSION };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remotion",
3
- "version": "4.0.0-alpha12",
3
+ "version": "4.0.0-alpha14",
4
4
  "description": "Render videos in React",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",
@@ -25,7 +25,7 @@
25
25
  "@types/react": "18.0.26",
26
26
  "@types/react-dom": "18.0.10",
27
27
  "@vitejs/plugin-react": "^2.0.0",
28
- "eslint": "8.25.0",
28
+ "eslint": "8.42.0",
29
29
  "eslint-plugin-require-extensions": "^0.1.2",
30
30
  "jsdom": "21.1.0",
31
31
  "prettier": "^2.7.1",
@@ -34,7 +34,7 @@
34
34
  "react-dom": "^18.0.0",
35
35
  "rimraf": "^3.0.2",
36
36
  "rollup": "^2.70.1",
37
- "typescript": "^4.7.0",
37
+ "typescript": "4.9.5",
38
38
  "vitest": "0.31.1",
39
39
  "webpack": "5.83.1",
40
40
  "zod": "3.21.4"