remotion 3.3.38 → 3.3.40
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.
- package/dist/LayerMaster.d.ts +8 -0
- package/dist/LayerMaster.js +39 -0
- package/dist/Satori.d.ts +5 -0
- package/dist/Satori.js +92 -0
- package/dist/audio/shared-audio-tags.d.ts +5 -1
- package/dist/audio/shared-audio-tags.js +4 -3
- package/dist/config.d.ts +27 -1
- package/dist/get-compositions-from-markup.d.ts +3 -0
- package/dist/get-compositions-from-markup.js +19 -0
- package/dist/internals.d.ts +5 -1
- package/dist/layers.d.ts +24 -0
- package/dist/layers.js +149 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/video/NativeVideo.d.ts +5 -0
- package/dist/video/NativeVideo.js +33 -0
- package/dist/video/NativeVideoForRendering.d.ts +8 -0
- package/dist/video/NativeVideoForRendering.js +14 -0
- package/dist/warn-about-non-seekable-media.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Layer } from './layers';
|
|
3
|
+
export declare const LayerMaster: <T extends object>({ layers, defaultProps, inputProps, fallbackComponent: FallbackComponent, }: {
|
|
4
|
+
layers: Layer<T>[];
|
|
5
|
+
defaultProps: T | undefined;
|
|
6
|
+
inputProps: any;
|
|
7
|
+
fallbackComponent: React.FC | null;
|
|
8
|
+
}) => JSX.Element;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LayerMaster = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const AbsoluteFill_1 = require("./AbsoluteFill");
|
|
7
|
+
const get_environment_1 = require("./get-environment");
|
|
8
|
+
const LayerMaster = ({ layers, defaultProps, inputProps, fallbackComponent: FallbackComponent, }) => {
|
|
9
|
+
return (
|
|
10
|
+
// TODO: Same styles as normal
|
|
11
|
+
(0, jsx_runtime_1.jsx)(AbsoluteFill_1.AbsoluteFill, { children: layers.map((layer, i) => {
|
|
12
|
+
const Comp = layer.component;
|
|
13
|
+
if (layer.type === 'web') {
|
|
14
|
+
if (FallbackComponent === null) {
|
|
15
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
16
|
+
return (0, jsx_runtime_1.jsx)(Comp, { ...defaultProps, ...inputProps }, String(i));
|
|
17
|
+
}
|
|
18
|
+
return (
|
|
19
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
20
|
+
(0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: (0, jsx_runtime_1.jsx)(FallbackComponent, {}), children: (0, jsx_runtime_1.jsx)(Comp, { ...defaultProps, ...inputProps }) }, String(i)));
|
|
21
|
+
}
|
|
22
|
+
// SVG should not support suspense
|
|
23
|
+
if (layer.type === 'svg') {
|
|
24
|
+
if ((0, get_environment_1.getRemotionEnvironment)() === 'rendering') {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return ((0, jsx_runtime_1.jsx)(AbsoluteFill_1.AbsoluteFill, { children: (0, jsx_runtime_1.jsx)(Comp, { ...defaultProps, ...inputProps }, String(i)) }));
|
|
28
|
+
}
|
|
29
|
+
if (layer.type === 'video') {
|
|
30
|
+
if ((0, get_environment_1.getRemotionEnvironment)() === 'rendering') {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
// TODO: AbsoluteFill is different flex direction
|
|
34
|
+
return ((0, jsx_runtime_1.jsx)(AbsoluteFill_1.AbsoluteFill, { children: (0, jsx_runtime_1.jsx)(Comp, { ...defaultProps, ...inputProps }, String(i)) }));
|
|
35
|
+
}
|
|
36
|
+
throw new Error('Unknown layer type');
|
|
37
|
+
}) }));
|
|
38
|
+
};
|
|
39
|
+
exports.LayerMaster = LayerMaster;
|
package/dist/Satori.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PropsWithChildren } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export declare const Satori: React.FC<PropsWithChildren>;
|
|
4
|
+
export declare const SatoriForRendering: React.FC<PropsWithChildren>;
|
|
5
|
+
export declare const SatoriForDevelopment: React.FC<PropsWithChildren>;
|
package/dist/Satori.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.SatoriForDevelopment = exports.SatoriForRendering = exports.Satori = void 0;
|
|
30
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
31
|
+
const react_1 = __importStar(require("react"));
|
|
32
|
+
const satori_1 = __importDefault(require("satori"));
|
|
33
|
+
const _1 = require(".");
|
|
34
|
+
const get_environment_1 = require("./get-environment");
|
|
35
|
+
const NativeLayers_1 = require("./NativeLayers");
|
|
36
|
+
const use_video_config_1 = require("./use-video-config");
|
|
37
|
+
const Satori = ({ children }) => {
|
|
38
|
+
if ((0, get_environment_1.getRemotionEnvironment)() === 'rendering') {
|
|
39
|
+
return (0, jsx_runtime_1.jsx)(exports.SatoriForRendering, { children: children });
|
|
40
|
+
}
|
|
41
|
+
return (0, jsx_runtime_1.jsx)(exports.SatoriForDevelopment, { children: children });
|
|
42
|
+
};
|
|
43
|
+
exports.Satori = Satori;
|
|
44
|
+
const SatoriForRendering = ({ children }) => {
|
|
45
|
+
const { width, height } = (0, use_video_config_1.useVideoConfig)();
|
|
46
|
+
const { setSatoriStack } = (0, react_1.useContext)(NativeLayers_1.NativeLayersContext);
|
|
47
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
48
|
+
const handle = (0, _1.delayRender)();
|
|
49
|
+
(0, satori_1.default)(children, {
|
|
50
|
+
width,
|
|
51
|
+
height,
|
|
52
|
+
fonts: [],
|
|
53
|
+
})
|
|
54
|
+
.then((svg) => {
|
|
55
|
+
(0, _1.continueRender)(handle);
|
|
56
|
+
setSatoriStack(svg);
|
|
57
|
+
console.log({ svg });
|
|
58
|
+
})
|
|
59
|
+
.catch((err) => {
|
|
60
|
+
console.log(err);
|
|
61
|
+
});
|
|
62
|
+
}, [children, height, setSatoriStack, width]);
|
|
63
|
+
return (0, jsx_runtime_1.jsx)(_1.Experimental.Null, {});
|
|
64
|
+
};
|
|
65
|
+
exports.SatoriForRendering = SatoriForRendering;
|
|
66
|
+
const SatoriForDevelopment = ({ children, }) => {
|
|
67
|
+
const [markup, setMarkup] = react_1.default.useState(null);
|
|
68
|
+
const { width, height } = (0, use_video_config_1.useVideoConfig)();
|
|
69
|
+
(0, react_1.useEffect)(() => {
|
|
70
|
+
(0, satori_1.default)(children, {
|
|
71
|
+
width,
|
|
72
|
+
height,
|
|
73
|
+
fonts: [],
|
|
74
|
+
})
|
|
75
|
+
.then((svg) => {
|
|
76
|
+
setMarkup(svg);
|
|
77
|
+
console.log({ svg });
|
|
78
|
+
})
|
|
79
|
+
.catch((err) => {
|
|
80
|
+
console.log(err);
|
|
81
|
+
});
|
|
82
|
+
}, [children, height, width]);
|
|
83
|
+
if (!markup) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
return ((0, jsx_runtime_1.jsx)("div", {
|
|
87
|
+
// eslint-disable-next-line react/no-danger
|
|
88
|
+
dangerouslySetInnerHTML: {
|
|
89
|
+
__html: markup,
|
|
90
|
+
} }));
|
|
91
|
+
};
|
|
92
|
+
exports.SatoriForDevelopment = SatoriForDevelopment;
|
|
@@ -20,7 +20,11 @@ declare type AudioElem = {
|
|
|
20
20
|
declare type SharedContext = {
|
|
21
21
|
registerAudio: (aud: RemotionAudioProps, audioId: string) => AudioElem;
|
|
22
22
|
unregisterAudio: (id: number) => void;
|
|
23
|
-
updateAudio: (
|
|
23
|
+
updateAudio: (options: {
|
|
24
|
+
id: number;
|
|
25
|
+
aud: RemotionAudioProps;
|
|
26
|
+
audioId: string;
|
|
27
|
+
}) => void;
|
|
24
28
|
playAllAudios: () => void;
|
|
25
29
|
numberOfAudioTags: number;
|
|
26
30
|
};
|
|
@@ -133,7 +133,7 @@ const SharedAudioContextProvider = ({ children, numberOfAudioTags }) => {
|
|
|
133
133
|
audios.current = (_a = audios.current) === null || _a === void 0 ? void 0 : _a.filter((a) => a.id !== id);
|
|
134
134
|
rerenderAudios();
|
|
135
135
|
}, [refs, rerenderAudios]);
|
|
136
|
-
const updateAudio = (0, react_1.useCallback)((id,
|
|
136
|
+
const updateAudio = (0, react_1.useCallback)(({ aud, audioId, id, }) => {
|
|
137
137
|
var _a;
|
|
138
138
|
let changed = false;
|
|
139
139
|
audios.current = (_a = audios.current) === null || _a === void 0 ? void 0 : _a.map((prevA) => {
|
|
@@ -146,6 +146,7 @@ const SharedAudioContextProvider = ({ children, numberOfAudioTags }) => {
|
|
|
146
146
|
return {
|
|
147
147
|
...prevA,
|
|
148
148
|
props: aud,
|
|
149
|
+
audioId,
|
|
149
150
|
};
|
|
150
151
|
}
|
|
151
152
|
return prevA;
|
|
@@ -205,9 +206,9 @@ const useSharedAudio = (aud, audioId) => {
|
|
|
205
206
|
if (typeof document !== 'undefined') {
|
|
206
207
|
effectToUse(() => {
|
|
207
208
|
if (ctx && ctx.numberOfAudioTags > 0) {
|
|
208
|
-
ctx.updateAudio(elem.id, aud);
|
|
209
|
+
ctx.updateAudio({ id: elem.id, aud, audioId });
|
|
209
210
|
}
|
|
210
|
-
}, [aud, ctx, elem.id]);
|
|
211
|
+
}, [aud, ctx, elem.id, audioId]);
|
|
211
212
|
effectToUse(() => {
|
|
212
213
|
return () => {
|
|
213
214
|
if (ctx && ctx.numberOfAudioTags > 0) {
|
package/dist/config.d.ts
CHANGED
|
@@ -12,7 +12,11 @@ declare type FfmpegExecutable = string | null;
|
|
|
12
12
|
declare type Loop = number | null;
|
|
13
13
|
declare type CodecOrUndefined = 'h264' | 'h265' | 'vp8' | 'vp9' | 'mp3' | 'aac' | 'wav' | 'prores' | 'h264-mkv' | 'gif' | undefined;
|
|
14
14
|
declare type Crf = number | undefined;
|
|
15
|
-
|
|
15
|
+
declare type FlatConfig = ObjectConfig['Bundling'] & ObjectConfig['Log'] & ObjectConfig['Preview'] & ObjectConfig['Puppeteer'] & ObjectConfig['Output'] & ObjectConfig['Rendering'];
|
|
16
|
+
declare type ObjectConfig = {
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated New flat config format: You can now replace `Config.Preview.` with `Config.`
|
|
19
|
+
*/
|
|
16
20
|
readonly Preview: {
|
|
17
21
|
/**
|
|
18
22
|
* Change the maximum amount of tracks that are shown in the timeline.
|
|
@@ -46,6 +50,9 @@ export declare type ConfigType = {
|
|
|
46
50
|
*/
|
|
47
51
|
readonly setShouldOpenBrowser: (should: boolean) => void;
|
|
48
52
|
};
|
|
53
|
+
/**
|
|
54
|
+
* @deprecated New flat config format: You can now replace `Config.Bundling.` with `Config.`
|
|
55
|
+
*/
|
|
49
56
|
readonly Bundling: {
|
|
50
57
|
/**
|
|
51
58
|
* Specify the entry point so you don't have to specify it in the
|
|
@@ -76,6 +83,9 @@ export declare type ConfigType = {
|
|
|
76
83
|
*/
|
|
77
84
|
readonly setPublicDir: (publicDir: string | null) => void;
|
|
78
85
|
};
|
|
86
|
+
/**
|
|
87
|
+
* @deprecated New flat config format: You can now replace `Config.Log.` with `Config.`
|
|
88
|
+
*/
|
|
79
89
|
readonly Log: {
|
|
80
90
|
/**
|
|
81
91
|
* Set the log level.
|
|
@@ -86,6 +96,9 @@ export declare type ConfigType = {
|
|
|
86
96
|
*/
|
|
87
97
|
readonly setLevel: (newLogLevel: 'verbose' | 'info' | 'warn' | 'error') => void;
|
|
88
98
|
};
|
|
99
|
+
/**
|
|
100
|
+
* @deprecated New flat config format: You can now replace `Config.Puppeteer.` with `Config.`
|
|
101
|
+
*/
|
|
89
102
|
readonly Puppeteer: {
|
|
90
103
|
/**
|
|
91
104
|
* Specify executable path for the browser to use.
|
|
@@ -96,6 +109,12 @@ export declare type ConfigType = {
|
|
|
96
109
|
* Set how many milliseconds a frame may take to render before it times out.
|
|
97
110
|
* Default: `30000`
|
|
98
111
|
*/
|
|
112
|
+
readonly setDelayRenderTimeoutInMilliseconds: (newPuppeteerTimeout: number) => void;
|
|
113
|
+
/**
|
|
114
|
+
* @deprecated Renamed to `setDelayRenderTimeoutInMilliseconds`.
|
|
115
|
+
* Set how many milliseconds a frame may take to render before it times out.
|
|
116
|
+
* Default: `30000`
|
|
117
|
+
*/
|
|
99
118
|
readonly setTimeoutInMilliseconds: (newPuppeteerTimeout: number) => void;
|
|
100
119
|
/**
|
|
101
120
|
* Setting deciding whether to disable CORS and other Chrome security features.
|
|
@@ -118,6 +137,9 @@ export declare type ConfigType = {
|
|
|
118
137
|
*/
|
|
119
138
|
readonly setChromiumOpenGlRenderer: (renderer: 'swangle' | 'angle' | 'egl' | 'swiftshader') => void;
|
|
120
139
|
};
|
|
140
|
+
/**
|
|
141
|
+
* @deprecated New flat config format: You can now replace `Config.Rendering.` with `Config.`
|
|
142
|
+
*/
|
|
121
143
|
readonly Rendering: {
|
|
122
144
|
/**
|
|
123
145
|
* Set a custom location for a .env file.
|
|
@@ -184,6 +206,9 @@ export declare type ConfigType = {
|
|
|
184
206
|
*/
|
|
185
207
|
readonly setEnforceAudioTrack: (enforceAudioTrack: boolean) => void;
|
|
186
208
|
};
|
|
209
|
+
/**
|
|
210
|
+
* @deprecated New flat config format: You can now replace `Config.Output.` with `Config.`
|
|
211
|
+
*/
|
|
187
212
|
readonly Output: {
|
|
188
213
|
/**
|
|
189
214
|
* Set the output file location string. Default: `out/{composition}.{codec}`
|
|
@@ -254,6 +279,7 @@ export declare type ConfigType = {
|
|
|
254
279
|
readonly setVideoBitrate: (bitrate: string | null) => void;
|
|
255
280
|
};
|
|
256
281
|
};
|
|
282
|
+
export declare type ConfigType = ObjectConfig & FlatConfig;
|
|
257
283
|
export type { Concurrency, WebpackConfiguration, WebpackOverrideFn };
|
|
258
284
|
export declare const Config: ConfigType;
|
|
259
285
|
export declare const enableLegacyRemotionConfig: () => void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCompositionsFromMarkup = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const server_1 = require("react-dom/server");
|
|
6
|
+
const Composition_1 = require("./Composition");
|
|
7
|
+
const getCompositionsFromMarkup = (Comp) => {
|
|
8
|
+
// TODO: Is this still necessary?
|
|
9
|
+
process.env.REMOTION_SERVER_RENDERING = 'true';
|
|
10
|
+
const str = (0, server_1.renderToString)((0, jsx_runtime_1.jsx)(Composition_1.GetCompositionsFromMarkupModeProvider, { children: (0, jsx_runtime_1.jsx)(Comp, {}) }));
|
|
11
|
+
const matches = str.matchAll(/<div>(.*?)<\/div>/g);
|
|
12
|
+
const metadata = [];
|
|
13
|
+
for (const match of matches) {
|
|
14
|
+
const json = JSON.parse(match[1]);
|
|
15
|
+
metadata.push(json);
|
|
16
|
+
}
|
|
17
|
+
return metadata;
|
|
18
|
+
};
|
|
19
|
+
exports.getCompositionsFromMarkup = getCompositionsFromMarkup;
|
package/dist/internals.d.ts
CHANGED
|
@@ -57,7 +57,11 @@ export declare const Internals: {
|
|
|
57
57
|
audioId: string;
|
|
58
58
|
};
|
|
59
59
|
unregisterAudio: (id: number) => void;
|
|
60
|
-
updateAudio: (
|
|
60
|
+
updateAudio: (options: {
|
|
61
|
+
id: number;
|
|
62
|
+
aud: import("./audio").RemotionAudioProps;
|
|
63
|
+
audioId: string;
|
|
64
|
+
}) => void;
|
|
61
65
|
playAllAudios: () => void;
|
|
62
66
|
numberOfAudioTags: number;
|
|
63
67
|
} | null>;
|
package/dist/layers.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ComponentType, LazyExoticComponent } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export declare type LooseComponentType<T> = ComponentType<T> | ((props: T) => React.ReactNode);
|
|
4
|
+
export declare type InputLayer<T> = {
|
|
5
|
+
component: LooseComponentType<T>;
|
|
6
|
+
type: 'web' | 'svg' | 'video';
|
|
7
|
+
};
|
|
8
|
+
export declare type CompProps<T> = {
|
|
9
|
+
lazyComponent: () => Promise<{
|
|
10
|
+
default: LooseComponentType<T>;
|
|
11
|
+
}>;
|
|
12
|
+
} | {
|
|
13
|
+
component: LooseComponentType<T>;
|
|
14
|
+
} | {
|
|
15
|
+
layers: InputLayer<T>[];
|
|
16
|
+
};
|
|
17
|
+
export declare type Layer<T> = {
|
|
18
|
+
component: LazyExoticComponent<ComponentType<T>>;
|
|
19
|
+
type: 'web' | 'svg' | 'video';
|
|
20
|
+
};
|
|
21
|
+
export declare type SmallLayer = Pick<Layer<unknown>, 'type'>;
|
|
22
|
+
export declare const convertComponentTypesToLayers: <T>(compProps: CompProps<T>) => Layer<T>[];
|
|
23
|
+
export declare const convertComponentTypesToLayersWithCache: <T>(compProps: CompProps<T>, prevCompProps: CompProps<T> | null, prevReturnValue: Layer<T>[] | null) => Layer<T>[];
|
|
24
|
+
export declare const useLayers: <T>(compProps: CompProps<T>) => Layer<T>[];
|
package/dist/layers.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
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.useLayers = exports.convertComponentTypesToLayersWithCache = exports.convertComponentTypesToLayers = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const inputLayersToLayers = (layers) => {
|
|
29
|
+
return layers.map((layer) => {
|
|
30
|
+
if (layer.type === 'web') {
|
|
31
|
+
return {
|
|
32
|
+
component: react_1.default.lazy(() => Promise.resolve({ default: layer.component })),
|
|
33
|
+
type: 'web',
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
// No lazy for Video allowed!
|
|
37
|
+
if (layer.type === 'video') {
|
|
38
|
+
return {
|
|
39
|
+
component: layer.component,
|
|
40
|
+
type: 'video',
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
// No lazy for SVG allowed!
|
|
44
|
+
return {
|
|
45
|
+
component: layer.component,
|
|
46
|
+
type: 'svg',
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
const convertComponentTypesToLayers = (compProps) => {
|
|
51
|
+
if ('component' in compProps) {
|
|
52
|
+
// In SSR, suspense is not yet supported, we cannot use React.lazy
|
|
53
|
+
if (typeof document === 'undefined') {
|
|
54
|
+
return [
|
|
55
|
+
{
|
|
56
|
+
component: compProps.component,
|
|
57
|
+
type: 'web',
|
|
58
|
+
},
|
|
59
|
+
];
|
|
60
|
+
}
|
|
61
|
+
return [
|
|
62
|
+
{
|
|
63
|
+
component: react_1.default.lazy(() => Promise.resolve({ default: compProps.component })),
|
|
64
|
+
type: 'web',
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
if ('lazyComponent' in compProps) {
|
|
69
|
+
return [
|
|
70
|
+
{
|
|
71
|
+
component: react_1.default.lazy(compProps.lazyComponent),
|
|
72
|
+
type: 'web',
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
if ('layers' in compProps) {
|
|
77
|
+
return inputLayersToLayers(compProps.layers);
|
|
78
|
+
}
|
|
79
|
+
throw new Error('Unknown component type');
|
|
80
|
+
};
|
|
81
|
+
exports.convertComponentTypesToLayers = convertComponentTypesToLayers;
|
|
82
|
+
const convertComponentTypesToLayersWithCache = (compProps, prevCompProps, prevReturnValue) => {
|
|
83
|
+
if ('component' in compProps) {
|
|
84
|
+
if (prevCompProps &&
|
|
85
|
+
'component' in prevCompProps &&
|
|
86
|
+
compProps.component === prevCompProps.component &&
|
|
87
|
+
prevReturnValue) {
|
|
88
|
+
return prevReturnValue;
|
|
89
|
+
}
|
|
90
|
+
return [
|
|
91
|
+
{
|
|
92
|
+
type: 'web',
|
|
93
|
+
component: react_1.default.lazy(() => Promise.resolve({ default: compProps.component })),
|
|
94
|
+
},
|
|
95
|
+
];
|
|
96
|
+
}
|
|
97
|
+
if ('lazyComponent' in compProps) {
|
|
98
|
+
if (prevCompProps &&
|
|
99
|
+
'lazyComponent' in prevCompProps &&
|
|
100
|
+
compProps.lazyComponent === prevCompProps.lazyComponent &&
|
|
101
|
+
prevReturnValue) {
|
|
102
|
+
return prevReturnValue;
|
|
103
|
+
}
|
|
104
|
+
return [
|
|
105
|
+
{
|
|
106
|
+
type: 'web',
|
|
107
|
+
component: react_1.default.lazy(compProps.lazyComponent),
|
|
108
|
+
},
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
if ('layers' in compProps) {
|
|
112
|
+
const isTheSame = () => {
|
|
113
|
+
if (!prevCompProps) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
if (!('layers' in prevCompProps)) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
if (compProps.layers.length !== prevCompProps.layers.length) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
for (let i = 0; i < compProps.layers.length; i++) {
|
|
123
|
+
if (compProps.layers[i].component !== prevCompProps.layers[i].component) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
if (compProps.layers[i].type !== prevCompProps.layers[i].type) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return true;
|
|
131
|
+
};
|
|
132
|
+
if (isTheSame()) {
|
|
133
|
+
return prevReturnValue;
|
|
134
|
+
}
|
|
135
|
+
return inputLayersToLayers(compProps.layers);
|
|
136
|
+
}
|
|
137
|
+
throw new Error('Unknown component type');
|
|
138
|
+
};
|
|
139
|
+
exports.convertComponentTypesToLayersWithCache = convertComponentTypesToLayersWithCache;
|
|
140
|
+
const useLayers = (compProps) => {
|
|
141
|
+
var _a, _b;
|
|
142
|
+
const prevCompProps = (0, react_1.useRef)();
|
|
143
|
+
const prevLayers = (0, react_1.useRef)();
|
|
144
|
+
const layers = (0, exports.convertComponentTypesToLayersWithCache)(compProps, (_a = prevCompProps.current) !== null && _a !== void 0 ? _a : null, (_b = prevLayers.current) !== null && _b !== void 0 ? _b : null);
|
|
145
|
+
prevCompProps.current = compProps;
|
|
146
|
+
prevLayers.current = layers;
|
|
147
|
+
return layers;
|
|
148
|
+
};
|
|
149
|
+
exports.useLayers = useLayers;
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "3.3.
|
|
1
|
+
export declare const VERSION = "3.3.40";
|
package/dist/version.js
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NativeVideo = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const get_environment_1 = require("../get-environment");
|
|
7
|
+
const Sequence_1 = require("../Sequence");
|
|
8
|
+
const validate_media_props_1 = require("../validate-media-props");
|
|
9
|
+
const validate_start_from_props_1 = require("../validate-start-from-props");
|
|
10
|
+
const NativeVideoForRendering_1 = require("./NativeVideoForRendering");
|
|
11
|
+
const VideoForDevelopment_1 = require("./VideoForDevelopment");
|
|
12
|
+
const NativeVideo = (props) => {
|
|
13
|
+
const { startFrom, endAt, ...otherProps } = props;
|
|
14
|
+
const onDuration = (0, react_1.useCallback)(() => undefined, []);
|
|
15
|
+
if (typeof props.src !== 'string') {
|
|
16
|
+
throw new TypeError(`The \`<NativeVideo>\` tag requires a string for \`src\`, but got ${JSON.stringify(props.src)} instead.`);
|
|
17
|
+
}
|
|
18
|
+
if (typeof startFrom !== 'undefined' || typeof endAt !== 'undefined') {
|
|
19
|
+
(0, validate_start_from_props_1.validateStartFromProps)(startFrom, endAt);
|
|
20
|
+
const startFromFrameNo = startFrom !== null && startFrom !== void 0 ? startFrom : 0;
|
|
21
|
+
const endAtFrameNo = endAt !== null && endAt !== void 0 ? endAt : Infinity;
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)(Sequence_1.Sequence, { layout: "none", from: 0 - startFromFrameNo, showInTimeline: false, durationInFrames: endAtFrameNo, children: (0, jsx_runtime_1.jsx)(exports.NativeVideo, { ...otherProps }) }));
|
|
23
|
+
}
|
|
24
|
+
(0, validate_media_props_1.validateMediaProps)(props, 'Video');
|
|
25
|
+
if ((0, get_environment_1.getRemotionEnvironment)() === 'rendering') {
|
|
26
|
+
throw new Error('Cannot render in the browser');
|
|
27
|
+
}
|
|
28
|
+
if ((0, get_environment_1.getRemotionEnvironment)() === 'server-rendering') {
|
|
29
|
+
return (0, jsx_runtime_1.jsx)(NativeVideoForRendering_1.NativeVideoForRendering, { ...otherProps });
|
|
30
|
+
}
|
|
31
|
+
return ((0, jsx_runtime_1.jsx)(VideoForDevelopment_1.VideoForDevelopment, { onDuration: onDuration, onlyWarnForMediaSeekingError: true, ...otherProps }));
|
|
32
|
+
};
|
|
33
|
+
exports.NativeVideo = NativeVideo;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NativeVideoForRendering = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const use_current_frame_1 = require("../use-current-frame");
|
|
6
|
+
const NativeVideoForRendering = ({ src }) => {
|
|
7
|
+
const frame = (0, use_current_frame_1.useCurrentFrame)();
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)("div", {
|
|
9
|
+
// eslint-disable-next-line react/no-danger
|
|
10
|
+
dangerouslySetInnerHTML: {
|
|
11
|
+
__html: JSON.stringify({ src, frame }),
|
|
12
|
+
} }));
|
|
13
|
+
};
|
|
14
|
+
exports.NativeVideoForRendering = NativeVideoForRendering;
|
|
@@ -18,7 +18,7 @@ const warnAboutNonSeekableMedia = (ref, type) => {
|
|
|
18
18
|
}
|
|
19
19
|
const range = { start: ref.seekable.start(0), end: ref.seekable.end(0) };
|
|
20
20
|
if (range.start === 0 && range.end === 0) {
|
|
21
|
-
const msg = `The media
|
|
21
|
+
const msg = `The media ${ref.src} cannot be seeked. This could be one of two reasons: 1) The media resource was replaced while the video is playing but it was not loaded yet. 2) The media does not support seeking. Please see https://remotion.dev/docs/non-seekable-media for assistance.`;
|
|
22
22
|
if (type === 'console-error') {
|
|
23
23
|
console.error(msg);
|
|
24
24
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "remotion",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.40",
|
|
4
4
|
"description": "Render videos in React",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
]
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "be5f606a81761f7f8e1e191ebabd5f8d225d8c09"
|
|
69
69
|
}
|