@remotion/studio 4.0.272 → 4.0.274

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,4 +1,4 @@
1
- import type { AnyComposition, StaticFile, TFolder } from 'remotion';
1
+ import type { _InternalTypes, StaticFile, TFolder } from 'remotion';
2
2
  import type { CompositionSelectorItemType } from '../components/CompositionSelectorItem';
3
3
  export type AssetFolder = {
4
4
  name: string;
@@ -14,4 +14,4 @@ export declare const splitParentIntoNameAndParent: (name: string | null) => {
14
14
  name: string | null;
15
15
  parent: string | null;
16
16
  };
17
- export declare const createFolderTree: (comps: AnyComposition[], folders: TFolder[], foldersExpanded: Record<string, boolean>) => CompositionSelectorItemType[];
17
+ export declare const createFolderTree: (comps: _InternalTypes["AnyComposition"][], folders: TFolder[], foldersExpanded: Record<string, boolean>) => CompositionSelectorItemType[];
@@ -1,2 +1,2 @@
1
1
  import type { X264Preset } from '@remotion/renderer';
2
- export declare const labelx264Preset: (profile: X264Preset) => "ultrafast" | "superfast" | "veryfast" | "faster" | "fast" | "medium" | "slow" | "slower" | "veryslow" | "placebo";
2
+ export declare const labelx264Preset: (profile: X264Preset) => "medium" | "ultrafast" | "superfast" | "veryfast" | "faster" | "fast" | "slow" | "slower" | "veryslow" | "placebo";
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getRoute = exports.reloadUrl = exports.clearUrl = exports.pushUrl = void 0;
4
4
  const getUrlHandlingType = () => {
5
- if (window.process.env.NODE_ENV === 'production') {
5
+ if (window.remotion_isReadOnlyStudio) {
6
6
  return 'query-string';
7
7
  }
8
8
  return 'spa';
@@ -1,4 +1,4 @@
1
- import type { AnyComposition } from 'remotion';
2
- export declare const validateCompositionName: (compName: string, compositions: AnyComposition[]) => string | null;
1
+ import type { _InternalTypes } from 'remotion';
2
+ export declare const validateCompositionName: (compName: string, compositions: _InternalTypes["AnyComposition"][]) => string | null;
3
3
  export declare const validateCompositionDimension: (dimension: "Width" | "Height", value: number) => string | null;
4
4
  export declare const validateCompositionDuration: (value: number) => string | null;
@@ -0,0 +1,2 @@
1
+ import type { BundleState } from 'remotion';
2
+ export declare const setBundleModeAndUpdate: (state: BundleState) => void;
@@ -0,0 +1,321 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ var _a;
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.setBundleModeAndUpdate = void 0;
31
+ const jsx_runtime_1 = require("react/jsx-runtime");
32
+ // This file is not compiled by Typescript, but by ESBuild
33
+ // to keep the dynamic import
34
+ const react_1 = require("react");
35
+ // In React 18, you should use createRoot() from "react-dom/client".
36
+ // In React 18, you should use render from "react-dom".
37
+ // We support both, but Webpack chooses both of them and normalizes them to "react-dom/client",
38
+ // hence why we import the right thing all the time but need to differentiate here
39
+ const client_1 = __importDefault(require("react-dom/client"));
40
+ const remotion_1 = require("remotion");
41
+ const no_react_1 = require("remotion/no-react");
42
+ let currentBundleMode = {
43
+ type: 'index',
44
+ };
45
+ const setBundleMode = (state) => {
46
+ currentBundleMode = state;
47
+ };
48
+ const getBundleMode = () => {
49
+ return currentBundleMode;
50
+ };
51
+ remotion_1.Internals.CSSUtils.injectCSS(remotion_1.Internals.CSSUtils.makeDefaultPreviewCSS(null, '#1f2428'));
52
+ const getCanSerializeDefaultProps = (object) => {
53
+ try {
54
+ const str = JSON.stringify(object);
55
+ // 256MB is the theoretical limit, making it throw if over 90% of that is reached.
56
+ return str.length < 256 * 1024 * 1024 * 0.9;
57
+ }
58
+ catch (err) {
59
+ if (err.message.includes('Invalid string length')) {
60
+ return false;
61
+ }
62
+ throw err;
63
+ }
64
+ };
65
+ const isInHeadlessBrowser = () => {
66
+ return typeof window.remotion_puppeteerTimeout !== 'undefined';
67
+ };
68
+ const DelayedSpinner = () => {
69
+ const [show, setShow] = (0, react_1.useState)(false);
70
+ (0, react_1.useEffect)(() => {
71
+ const timeout = setTimeout(() => {
72
+ setShow(true);
73
+ }, 2000);
74
+ return () => {
75
+ clearTimeout(timeout);
76
+ };
77
+ }, []);
78
+ if (!show) {
79
+ return null;
80
+ }
81
+ return ((0, jsx_runtime_1.jsx)(remotion_1.AbsoluteFill, { style: {
82
+ justifyContent: 'center',
83
+ alignItems: 'center',
84
+ fontSize: 13,
85
+ opacity: 0.6,
86
+ color: 'white',
87
+ fontFamily: 'Helvetica, Arial, sans-serif',
88
+ }, children: "Loading Studio" }));
89
+ };
90
+ const GetVideoComposition = ({ state }) => {
91
+ const { compositions, currentCompositionMetadata, canvasContent } = (0, react_1.useContext)(remotion_1.Internals.CompositionManager);
92
+ const { setCanvasContent } = (0, react_1.useContext)(remotion_1.Internals.CompositionSetters);
93
+ const portalContainer = (0, react_1.useRef)(null);
94
+ const [handle] = (0, react_1.useState)(() => (0, remotion_1.delayRender)(`Waiting for Composition "${state.compositionName}"`));
95
+ (0, react_1.useEffect)(() => {
96
+ return () => (0, remotion_1.continueRender)(handle);
97
+ }, [handle]);
98
+ (0, react_1.useEffect)(() => {
99
+ if (compositions.length === 0) {
100
+ return;
101
+ }
102
+ const foundComposition = compositions.find((c) => c.id === state.compositionName);
103
+ if (!foundComposition) {
104
+ throw new Error(`Found no composition with the name ${state.compositionName}. The following compositions were found instead: ${compositions
105
+ .map((c) => c.id)
106
+ .join(', ')}. All compositions must have their ID calculated deterministically and must be mounted at the same time.`);
107
+ }
108
+ setCanvasContent({
109
+ type: 'composition',
110
+ compositionId: foundComposition.id,
111
+ });
112
+ }, [compositions, state, currentCompositionMetadata, setCanvasContent]);
113
+ (0, react_1.useEffect)(() => {
114
+ if (!canvasContent) {
115
+ return;
116
+ }
117
+ const { current } = portalContainer;
118
+ if (!current) {
119
+ throw new Error('portal did not render');
120
+ }
121
+ current.appendChild(remotion_1.Internals.portalNode());
122
+ (0, remotion_1.continueRender)(handle);
123
+ return () => {
124
+ current.removeChild(remotion_1.Internals.portalNode());
125
+ };
126
+ }, [canvasContent, handle]);
127
+ if (!currentCompositionMetadata) {
128
+ return null;
129
+ }
130
+ return ((0, jsx_runtime_1.jsx)("div", { ref: portalContainer, id: "remotion-canvas", style: {
131
+ width: currentCompositionMetadata.width,
132
+ height: currentCompositionMetadata.height,
133
+ display: 'flex',
134
+ backgroundColor: 'transparent',
135
+ } }));
136
+ };
137
+ const DEFAULT_ROOT_COMPONENT_TIMEOUT = 10000;
138
+ const waitForRootHandle = (0, remotion_1.delayRender)('Loading root component - See https://remotion.dev/docs/troubleshooting/loading-root-component if you experience a timeout', {
139
+ timeoutInMilliseconds: typeof window === 'undefined'
140
+ ? DEFAULT_ROOT_COMPONENT_TIMEOUT
141
+ : ((_a = window.remotion_puppeteerTimeout) !== null && _a !== void 0 ? _a : DEFAULT_ROOT_COMPONENT_TIMEOUT),
142
+ });
143
+ const videoContainer = document.getElementById('video-container');
144
+ let root = null;
145
+ const getRootForElement = () => {
146
+ if (root) {
147
+ return root;
148
+ }
149
+ root = client_1.default.createRoot(videoContainer);
150
+ return root;
151
+ };
152
+ const renderToDOM = (content) => {
153
+ if (!client_1.default.createRoot) {
154
+ if (no_react_1.NoReactInternals.ENABLE_V5_BREAKING_CHANGES) {
155
+ throw new Error('Remotion 5.0 does only support React 18+. However, ReactDOM.createRoot() is undefined.');
156
+ }
157
+ client_1.default.render(content, videoContainer);
158
+ return;
159
+ }
160
+ getRootForElement().render(content);
161
+ };
162
+ const renderContent = (Root) => {
163
+ const bundleMode = getBundleMode();
164
+ if (bundleMode.type === 'composition') {
165
+ const markup = ((0, jsx_runtime_1.jsxs)(remotion_1.Internals.RemotionRoot, { logLevel: window.remotion_logLevel, numberOfAudioTags: 0, onlyRenderComposition: bundleMode.compositionName, currentCompositionMetadata: {
166
+ props: no_react_1.NoReactInternals.deserializeJSONWithCustomFields(bundleMode.serializedResolvedPropsWithSchema),
167
+ durationInFrames: bundleMode.compositionDurationInFrames,
168
+ fps: bundleMode.compositionFps,
169
+ height: bundleMode.compositionHeight,
170
+ width: bundleMode.compositionWidth,
171
+ defaultCodec: bundleMode.compositionDefaultCodec,
172
+ defaultOutName: bundleMode.compositionDefaultOutName,
173
+ }, children: [(0, jsx_runtime_1.jsx)(Root, {}), (0, jsx_runtime_1.jsx)(GetVideoComposition, { state: bundleMode })] }));
174
+ renderToDOM(markup);
175
+ }
176
+ if (bundleMode.type === 'evaluation') {
177
+ const markup = ((0, jsx_runtime_1.jsx)(remotion_1.Internals.RemotionRoot, { logLevel: window.remotion_logLevel, numberOfAudioTags: 0, onlyRenderComposition: null, currentCompositionMetadata: null, children: (0, jsx_runtime_1.jsx)(Root, {}) }));
178
+ renderToDOM(markup);
179
+ }
180
+ if (bundleMode.type === 'index') {
181
+ if (isInHeadlessBrowser()) {
182
+ return;
183
+ }
184
+ renderToDOM((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(DelayedSpinner, {}) }));
185
+ Promise.resolve().then(() => __importStar(require('./internals'))).then(({ StudioInternals }) => {
186
+ renderToDOM((0, jsx_runtime_1.jsx)(StudioInternals.Studio, { readOnly: true, rootComponent: Root }));
187
+ })
188
+ .catch((err) => {
189
+ renderToDOM((0, jsx_runtime_1.jsxs)("div", { children: ["Failed to load Remotion Studio: ", err.message] }));
190
+ });
191
+ }
192
+ };
193
+ remotion_1.Internals.waitForRoot((Root) => {
194
+ renderContent(Root);
195
+ (0, remotion_1.continueRender)(waitForRootHandle);
196
+ });
197
+ const setBundleModeAndUpdate = (state) => {
198
+ setBundleMode(state);
199
+ const delay = (0, remotion_1.delayRender)('Waiting for root component to load - See https://remotion.dev/docs/troubleshooting/loading-root-component if you experience a timeout');
200
+ remotion_1.Internals.waitForRoot((Root) => {
201
+ renderContent(Root);
202
+ requestAnimationFrame(() => {
203
+ (0, remotion_1.continueRender)(delay);
204
+ });
205
+ });
206
+ };
207
+ exports.setBundleModeAndUpdate = setBundleModeAndUpdate;
208
+ if (typeof window !== 'undefined') {
209
+ const getUnevaluatedComps = () => {
210
+ if (!remotion_1.Internals.getRoot()) {
211
+ throw new Error('registerRoot() was never called. 1. Make sure you specified the correct entrypoint for your bundle. 2. If your registerRoot() call is deferred, use the delayRender/continueRender pattern to tell Remotion to wait.');
212
+ }
213
+ if (!remotion_1.Internals.compositionsRef.current) {
214
+ throw new Error('Unexpectedly did not have a CompositionManager');
215
+ }
216
+ const compositions = remotion_1.Internals.compositionsRef.current.getCompositions();
217
+ const canSerializeDefaultProps = getCanSerializeDefaultProps(compositions);
218
+ if (!canSerializeDefaultProps) {
219
+ remotion_1.Internals.Log.warn(window.remotion_logLevel, 'defaultProps are too big to serialize - trying to find the problematic composition...');
220
+ for (const comp of compositions) {
221
+ if (!getCanSerializeDefaultProps(comp)) {
222
+ throw new Error(`defaultProps too big - could not serialize - the defaultProps of composition with ID ${comp.id} - the object that was passed to defaultProps was too big. Learn how to mitigate this error by visiting https://remotion.dev/docs/troubleshooting/serialize-defaultprops`);
223
+ }
224
+ }
225
+ remotion_1.Internals.Log.warn(window.remotion_logLevel, 'Could not single out a problematic composition - The composition list as a whole is too big to serialize.');
226
+ throw new Error('defaultProps too big - Could not serialize - an object that was passed to defaultProps was too big. Learn how to mitigate this error by visiting https://remotion.dev/docs/troubleshooting/serialize-defaultprops');
227
+ }
228
+ return compositions;
229
+ };
230
+ window.getStaticCompositions = () => {
231
+ var _a;
232
+ const compositions = getUnevaluatedComps();
233
+ const inputProps = typeof window === 'undefined' || (0, remotion_1.getRemotionEnvironment)().isPlayer
234
+ ? {}
235
+ : ((_a = (0, remotion_1.getInputProps)()) !== null && _a !== void 0 ? _a : {});
236
+ return Promise.all(compositions.map(async (c) => {
237
+ var _a, _b, _c, _d, _e, _f;
238
+ const handle = (0, remotion_1.delayRender)(`Running calculateMetadata() for composition ${c.id}. If you didn't want to evaluate this composition, use "selectComposition()" instead of "getCompositions()"`);
239
+ const originalProps = {
240
+ ...((_a = c.defaultProps) !== null && _a !== void 0 ? _a : {}),
241
+ ...(inputProps !== null && inputProps !== void 0 ? inputProps : {}),
242
+ };
243
+ const comp = remotion_1.Internals.resolveVideoConfig({
244
+ calculateMetadata: c.calculateMetadata,
245
+ compositionDurationInFrames: (_b = c.durationInFrames) !== null && _b !== void 0 ? _b : null,
246
+ compositionFps: (_c = c.fps) !== null && _c !== void 0 ? _c : null,
247
+ compositionHeight: (_d = c.height) !== null && _d !== void 0 ? _d : null,
248
+ compositionWidth: (_e = c.width) !== null && _e !== void 0 ? _e : null,
249
+ signal: new AbortController().signal,
250
+ originalProps,
251
+ defaultProps: (_f = c.defaultProps) !== null && _f !== void 0 ? _f : {},
252
+ compositionId: c.id,
253
+ });
254
+ const resolved = await Promise.resolve(comp);
255
+ (0, remotion_1.continueRender)(handle);
256
+ const { props, defaultProps, ...data } = resolved;
257
+ return {
258
+ ...data,
259
+ serializedResolvedPropsWithCustomSchema: no_react_1.NoReactInternals.serializeJSONWithDate({
260
+ data: props,
261
+ indent: undefined,
262
+ staticBase: null,
263
+ }).serializedString,
264
+ serializedDefaultPropsWithCustomSchema: no_react_1.NoReactInternals.serializeJSONWithDate({
265
+ data: defaultProps,
266
+ indent: undefined,
267
+ staticBase: null,
268
+ }).serializedString,
269
+ };
270
+ }));
271
+ };
272
+ window.remotion_getCompositionNames = () => {
273
+ return getUnevaluatedComps().map((c) => c.id);
274
+ };
275
+ window.remotion_calculateComposition = async (compId) => {
276
+ var _a, _b, _c, _d, _e, _f, _g;
277
+ const compositions = getUnevaluatedComps();
278
+ const selectedComp = compositions.find((c) => c.id === compId);
279
+ if (!selectedComp) {
280
+ throw new Error(`Could not find composition with ID ${compId}. Available compositions: ${compositions
281
+ .map((c) => c.id)
282
+ .join(', ')}`);
283
+ }
284
+ const abortController = new AbortController();
285
+ const handle = (0, remotion_1.delayRender)(`Running the calculateMetadata() function for composition ${compId}`);
286
+ const inputProps = typeof window === 'undefined' || (0, remotion_1.getRemotionEnvironment)().isPlayer
287
+ ? {}
288
+ : ((_a = (0, remotion_1.getInputProps)()) !== null && _a !== void 0 ? _a : {});
289
+ const originalProps = {
290
+ ...((_b = selectedComp.defaultProps) !== null && _b !== void 0 ? _b : {}),
291
+ ...(inputProps !== null && inputProps !== void 0 ? inputProps : {}),
292
+ };
293
+ const prom = await Promise.resolve(remotion_1.Internals.resolveVideoConfig({
294
+ calculateMetadata: selectedComp.calculateMetadata,
295
+ compositionDurationInFrames: (_c = selectedComp.durationInFrames) !== null && _c !== void 0 ? _c : null,
296
+ compositionFps: (_d = selectedComp.fps) !== null && _d !== void 0 ? _d : null,
297
+ compositionHeight: (_e = selectedComp.height) !== null && _e !== void 0 ? _e : null,
298
+ compositionWidth: (_f = selectedComp.width) !== null && _f !== void 0 ? _f : null,
299
+ originalProps,
300
+ signal: abortController.signal,
301
+ defaultProps: (_g = selectedComp.defaultProps) !== null && _g !== void 0 ? _g : {},
302
+ compositionId: selectedComp.id,
303
+ }));
304
+ (0, remotion_1.continueRender)(handle);
305
+ const { props, defaultProps, ...data } = prom;
306
+ return {
307
+ ...data,
308
+ serializedResolvedPropsWithCustomSchema: no_react_1.NoReactInternals.serializeJSONWithDate({
309
+ data: props,
310
+ indent: undefined,
311
+ staticBase: null,
312
+ }).serializedString,
313
+ serializedDefaultPropsWithCustomSchema: no_react_1.NoReactInternals.serializeJSONWithDate({
314
+ data: defaultProps,
315
+ indent: undefined,
316
+ staticBase: null,
317
+ }).serializedString,
318
+ };
319
+ };
320
+ window.remotion_setBundleMode = exports.setBundleModeAndUpdate;
321
+ }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/studio"
4
4
  },
5
5
  "name": "@remotion/studio",
6
- "version": "4.0.272",
6
+ "version": "4.0.274",
7
7
  "description": "APIs for interacting with the Remotion Studio",
8
8
  "main": "dist",
9
9
  "sideEffects": false,
@@ -18,12 +18,12 @@
18
18
  "memfs": "3.4.3",
19
19
  "source-map": "0.7.3",
20
20
  "open": "^8.4.2",
21
- "remotion": "4.0.272",
22
- "@remotion/media-utils": "4.0.272",
23
- "@remotion/player": "4.0.272",
24
- "@remotion/media-parser": "4.0.272",
25
- "@remotion/renderer": "4.0.272",
26
- "@remotion/studio-shared": "4.0.272"
21
+ "remotion": "4.0.274",
22
+ "@remotion/media-utils": "4.0.274",
23
+ "@remotion/media-parser": "4.0.274",
24
+ "@remotion/renderer": "4.0.274",
25
+ "@remotion/studio-shared": "4.0.274",
26
+ "@remotion/player": "4.0.274"
27
27
  },
28
28
  "devDependencies": {
29
29
  "react": "19.0.0",
@@ -31,8 +31,8 @@
31
31
  "@types/semver": "^7.3.4",
32
32
  "zod": "3.22.3",
33
33
  "eslint": "9.19.0",
34
- "@remotion/zod-types": "4.0.272",
35
- "@remotion/eslint-config-internal": "4.0.272"
34
+ "@remotion/eslint-config-internal": "4.0.274",
35
+ "@remotion/zod-types": "4.0.274"
36
36
  },
37
37
  "publishConfig": {
38
38
  "access": "public"
@@ -41,19 +41,43 @@
41
41
  "./package.json": "./package.json",
42
42
  ".": {
43
43
  "types": "./dist/index.d.ts",
44
+ "require": "./dist/index.js",
44
45
  "module": "./dist/esm/index.mjs",
45
- "import": "./dist/esm/index.mjs",
46
- "require": "./dist/index.js"
46
+ "import": "./dist/esm/index.mjs"
47
+ },
48
+ "./renderEntry": {
49
+ "types": "./dist/renderEntry.d.ts",
50
+ "require": "./dist/renderEntry.js",
51
+ "module": "./dist/esm/renderEntry.mjs",
52
+ "import": "./dist/esm/renderEntry.mjs"
47
53
  },
48
- "./entry": "./dist/previewEntry.js",
49
54
  "./internals": {
50
55
  "types": "./dist/internals.d.ts",
56
+ "require": "./dist/internals.js",
51
57
  "module": "./dist/esm/internals.mjs",
52
- "import": "./dist/esm/internals.mjs",
53
- "require": "./dist/internals.js"
58
+ "import": "./dist/esm/internals.mjs"
59
+ },
60
+ "./previewEntry": {
61
+ "types": "./dist/previewEntry.d.ts",
62
+ "require": "./dist/previewEntry.js",
63
+ "module": "./dist/esm/previewEntry.mjs",
64
+ "import": "./dist/esm/previewEntry.mjs"
54
65
  }
55
66
  },
56
67
  "homepage": "https://www.remotion.dev/docs/studio/api",
68
+ "typesVersions": {
69
+ ">=1.0": {
70
+ "renderEntry": [
71
+ "dist/renderEntry.d.ts"
72
+ ],
73
+ "internals": [
74
+ "dist/internals.d.ts"
75
+ ],
76
+ "previewEntry": [
77
+ "dist/previewEntry.d.ts"
78
+ ]
79
+ }
80
+ },
57
81
  "scripts": {
58
82
  "lint": "eslint src",
59
83
  "make": "tsc -d && bun --env-file=../.env.bundle bundle.ts",