remotion 4.0.468 → 4.0.470
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/cjs/CompositionManager.d.ts +1 -0
- package/dist/cjs/Img.d.ts +34 -1
- package/dist/cjs/Img.js +70 -17
- package/dist/cjs/RemotionRoot.d.ts +1 -0
- package/dist/cjs/RemotionRoot.js +2 -2
- package/dist/cjs/Sequence.d.ts +4 -0
- package/dist/cjs/Sequence.js +5 -1
- package/dist/cjs/audio/AudioForPreview.js +1 -0
- package/dist/cjs/audio/shared-audio-tags.d.ts +2 -2
- package/dist/cjs/audio/shared-audio-tags.js +9 -1
- package/dist/cjs/audio/use-audio-context.d.ts +2 -1
- package/dist/cjs/audio/use-audio-context.js +7 -3
- package/dist/cjs/canvas-image/CanvasImage.d.ts +44 -1
- package/dist/cjs/canvas-image/CanvasImage.js +12 -12
- package/dist/cjs/canvas-image/props.d.ts +6 -1
- package/dist/cjs/effects/Solid.js +12 -7
- package/dist/cjs/effects/effect-types.d.ts +2 -2
- package/dist/cjs/effects/run-effect-chain.d.ts +1 -1
- package/dist/cjs/effects/run-effect-chain.js +15 -5
- package/dist/cjs/index.d.ts +10 -9
- package/dist/cjs/index.js +8 -11
- package/dist/cjs/internals.d.ts +14 -4
- package/dist/cjs/internals.js +4 -0
- package/dist/cjs/interpolate-colors.d.ts +4 -1
- package/dist/cjs/interpolate-colors.js +4 -3
- package/dist/cjs/interpolate-keyframed-status.d.ts +5 -0
- package/dist/cjs/interpolate-keyframed-status.js +58 -0
- package/dist/cjs/interpolate.d.ts +2 -0
- package/dist/cjs/interpolate.js +22 -4
- package/dist/cjs/no-react.d.ts +1 -1
- package/dist/cjs/no-react.js +2 -1
- package/dist/cjs/sequence-field-schema.d.ts +9 -1
- package/dist/cjs/truncate-src-for-label.d.ts +1 -0
- package/dist/cjs/truncate-src-for-label.js +11 -0
- package/dist/cjs/use-media-in-timeline.d.ts +2 -1
- package/dist/cjs/use-media-in-timeline.js +3 -1
- package/dist/cjs/use-schema.d.ts +20 -3
- package/dist/cjs/use-schema.js +21 -4
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/video/VideoForPreview.js +1 -0
- package/dist/cjs/wrap-in-schema.js +5 -0
- package/dist/esm/index.mjs +7394 -7131
- package/dist/esm/no-react.mjs +18 -4
- package/dist/esm/version.mjs +1 -1
- package/package.json +2 -2
|
@@ -70,6 +70,7 @@ export type TSequence = {
|
|
|
70
70
|
premountDisplay: number | null;
|
|
71
71
|
postmountDisplay: number | null;
|
|
72
72
|
controls: SequenceControls | null;
|
|
73
|
+
refForOutline: React.RefObject<HTMLElement | null> | null;
|
|
73
74
|
effects: readonly EffectDefinition<unknown>[];
|
|
74
75
|
} & EnhancedTSequenceData;
|
|
75
76
|
export type AudioOrVideoAsset = {
|
package/dist/cjs/Img.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { EffectsProp } from './effects/effect-types.js';
|
|
2
3
|
import type { SequenceProps } from './Sequence.js';
|
|
3
|
-
export declare function truncateSrcForLabel(src: string): string;
|
|
4
4
|
type NativeImgProps = Omit<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, 'src'>;
|
|
5
5
|
export type ImgProps = NativeImgProps & {
|
|
6
6
|
readonly maxRetries?: number;
|
|
@@ -9,6 +9,7 @@ export type ImgProps = NativeImgProps & {
|
|
|
9
9
|
readonly delayRenderTimeoutInMilliseconds?: number;
|
|
10
10
|
readonly onImageFrame?: (imageElement: HTMLImageElement) => void;
|
|
11
11
|
readonly src: string;
|
|
12
|
+
readonly effects?: EffectsProp;
|
|
12
13
|
readonly showInTimeline?: boolean;
|
|
13
14
|
readonly name?: string;
|
|
14
15
|
/**
|
|
@@ -16,6 +17,37 @@ export type ImgProps = NativeImgProps & {
|
|
|
16
17
|
*/
|
|
17
18
|
readonly stack?: string;
|
|
18
19
|
} & Pick<SequenceProps, 'durationInFrames' | 'from' | 'hidden'>;
|
|
20
|
+
export declare const imgSchema: {
|
|
21
|
+
readonly hidden: import("./sequence-field-schema.js").SequenceFieldSchema;
|
|
22
|
+
readonly 'style.translate': {
|
|
23
|
+
readonly type: "translate";
|
|
24
|
+
readonly step: 1;
|
|
25
|
+
readonly default: "0px 0px";
|
|
26
|
+
readonly description: "Offset";
|
|
27
|
+
};
|
|
28
|
+
readonly 'style.scale': {
|
|
29
|
+
readonly type: "number";
|
|
30
|
+
readonly min: 0.05;
|
|
31
|
+
readonly max: 100;
|
|
32
|
+
readonly step: 0.01;
|
|
33
|
+
readonly default: 1;
|
|
34
|
+
readonly description: "Scale";
|
|
35
|
+
};
|
|
36
|
+
readonly 'style.rotate': {
|
|
37
|
+
readonly type: "rotation";
|
|
38
|
+
readonly step: 1;
|
|
39
|
+
readonly default: "0deg";
|
|
40
|
+
readonly description: "Rotation";
|
|
41
|
+
};
|
|
42
|
+
readonly 'style.opacity': {
|
|
43
|
+
readonly type: "number";
|
|
44
|
+
readonly min: 0;
|
|
45
|
+
readonly max: 1;
|
|
46
|
+
readonly step: 0.01;
|
|
47
|
+
readonly default: 1;
|
|
48
|
+
readonly description: "Opacity";
|
|
49
|
+
};
|
|
50
|
+
};
|
|
19
51
|
export declare const Img: React.ComponentType<NativeImgProps & {
|
|
20
52
|
readonly maxRetries?: number;
|
|
21
53
|
readonly pauseWhenLoading?: boolean;
|
|
@@ -23,6 +55,7 @@ export declare const Img: React.ComponentType<NativeImgProps & {
|
|
|
23
55
|
readonly delayRenderTimeoutInMilliseconds?: number;
|
|
24
56
|
readonly onImageFrame?: (imageElement: HTMLImageElement) => void;
|
|
25
57
|
readonly src: string;
|
|
58
|
+
readonly effects?: EffectsProp;
|
|
26
59
|
readonly showInTimeline?: boolean;
|
|
27
60
|
readonly name?: string;
|
|
28
61
|
/**
|
package/dist/cjs/Img.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Img = void 0;
|
|
4
|
-
exports.truncateSrcForLabel = truncateSrcForLabel;
|
|
3
|
+
exports.Img = exports.imgSchema = void 0;
|
|
5
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
5
|
const react_1 = require("react");
|
|
6
|
+
const index_js_1 = require("./canvas-image/index.js");
|
|
7
7
|
const enable_sequence_stack_traces_js_1 = require("./enable-sequence-stack-traces.js");
|
|
8
8
|
const get_cross_origin_value_js_1 = require("./get-cross-origin-value.js");
|
|
9
9
|
const prefetch_js_1 = require("./prefetch.js");
|
|
10
10
|
const sequence_field_schema_js_1 = require("./sequence-field-schema.js");
|
|
11
11
|
const Sequence_js_1 = require("./Sequence.js");
|
|
12
12
|
const SequenceContext_js_1 = require("./SequenceContext.js");
|
|
13
|
+
const truncate_src_for_label_js_1 = require("./truncate-src-for-label.js");
|
|
13
14
|
const use_buffer_state_js_1 = require("./use-buffer-state.js");
|
|
14
15
|
const use_delay_render_js_1 = require("./use-delay-render.js");
|
|
15
16
|
const use_remotion_environment_js_1 = require("./use-remotion-environment.js");
|
|
@@ -17,14 +18,6 @@ const wrap_in_schema_js_1 = require("./wrap-in-schema.js");
|
|
|
17
18
|
function exponentialBackoff(errorCount) {
|
|
18
19
|
return 1000 * 2 ** (errorCount - 1);
|
|
19
20
|
}
|
|
20
|
-
// Data URLs like the ones from canvas.toDataURL() can be many megabytes, which makes the delayRender() label
|
|
21
|
-
// unreadable and bloats log output
|
|
22
|
-
function truncateSrcForLabel(src) {
|
|
23
|
-
if (src.startsWith('data:') && src.length > 100) {
|
|
24
|
-
return src.slice(0, 60) + '...[' + src.length + ' chars total]';
|
|
25
|
-
}
|
|
26
|
-
return src;
|
|
27
|
-
}
|
|
28
21
|
const ImgContent = ({ onError, maxRetries = 2, src, pauseWhenLoading, delayRenderRetries, delayRenderTimeoutInMilliseconds, onImageFrame, crossOrigin, decoding, ref, ...props }) => {
|
|
29
22
|
const imageRef = (0, react_1.useRef)(null);
|
|
30
23
|
const errors = (0, react_1.useRef)({});
|
|
@@ -74,13 +67,13 @@ const ImgContent = ({ onError, maxRetries = 2, src, pauseWhenLoading, delayRende
|
|
|
74
67
|
if (((_g = errors.current[(_f = imageRef.current) === null || _f === void 0 ? void 0 : _f.src]) !== null && _g !== void 0 ? _g : 0) <= maxRetries) {
|
|
75
68
|
const backoff = exponentialBackoff((_j = errors.current[(_h = imageRef.current) === null || _h === void 0 ? void 0 : _h.src]) !== null && _j !== void 0 ? _j : 0);
|
|
76
69
|
// eslint-disable-next-line no-console
|
|
77
|
-
console.warn(`Could not load image with source ${truncateSrcForLabel((_k = imageRef.current) === null || _k === void 0 ? void 0 : _k.src)}, retrying again in ${backoff}ms`);
|
|
70
|
+
console.warn(`Could not load image with source ${(0, truncate_src_for_label_js_1.truncateSrcForLabel)((_k = imageRef.current) === null || _k === void 0 ? void 0 : _k.src)}, retrying again in ${backoff}ms`);
|
|
78
71
|
retryIn(backoff);
|
|
79
72
|
return;
|
|
80
73
|
}
|
|
81
74
|
try {
|
|
82
75
|
cancelRender('Error loading image with src: ' +
|
|
83
|
-
truncateSrcForLabel((_l = imageRef.current) === null || _l === void 0 ? void 0 : _l.src));
|
|
76
|
+
(0, truncate_src_for_label_js_1.truncateSrcForLabel)((_l = imageRef.current) === null || _l === void 0 ? void 0 : _l.src));
|
|
84
77
|
}
|
|
85
78
|
catch (_m) {
|
|
86
79
|
// cancelRender() intentionally throws after storing the error in scope.
|
|
@@ -103,7 +96,7 @@ const ImgContent = ({ onError, maxRetries = 2, src, pauseWhenLoading, delayRende
|
|
|
103
96
|
if (!current) {
|
|
104
97
|
return;
|
|
105
98
|
}
|
|
106
|
-
const newHandle = delayRender('Loading <Img> with src=' + truncateSrcForLabel(actualSrc), {
|
|
99
|
+
const newHandle = delayRender('Loading <Img> with src=' + (0, truncate_src_for_label_js_1.truncateSrcForLabel)(actualSrc), {
|
|
107
100
|
retries: delayRenderRetries !== null && delayRenderRetries !== void 0 ? delayRenderRetries : undefined,
|
|
108
101
|
timeoutInMilliseconds: delayRenderTimeoutInMilliseconds !== null && delayRenderTimeoutInMilliseconds !== void 0 ? delayRenderTimeoutInMilliseconds : undefined,
|
|
109
102
|
});
|
|
@@ -121,7 +114,7 @@ const ImgContent = ({ onError, maxRetries = 2, src, pauseWhenLoading, delayRende
|
|
|
121
114
|
if (((_b = errors.current[(_a = imageRef.current) === null || _a === void 0 ? void 0 : _a.src]) !== null && _b !== void 0 ? _b : 0) > 0) {
|
|
122
115
|
delete errors.current[(_c = imageRef.current) === null || _c === void 0 ? void 0 : _c.src];
|
|
123
116
|
// eslint-disable-next-line no-console
|
|
124
|
-
console.info(`Retry successful - ${truncateSrcForLabel((_d = imageRef.current) === null || _d === void 0 ? void 0 : _d.src)} is now loaded`);
|
|
117
|
+
console.info(`Retry successful - ${(0, truncate_src_for_label_js_1.truncateSrcForLabel)((_d = imageRef.current) === null || _d === void 0 ? void 0 : _d.src)} is now loaded`);
|
|
125
118
|
}
|
|
126
119
|
if (current) {
|
|
127
120
|
onImageFrame === null || onImageFrame === void 0 ? void 0 : onImageFrame(current);
|
|
@@ -181,19 +174,79 @@ const ImgContent = ({ onError, maxRetries = 2, src, pauseWhenLoading, delayRende
|
|
|
181
174
|
// src gets set once we've loaded and decoded the image.
|
|
182
175
|
return ((0, jsx_runtime_1.jsx)("img", { ...props, ref: imageRef, crossOrigin: crossOriginValue, onError: didGetError, decoding: isRendering ? 'sync' : decoding }));
|
|
183
176
|
};
|
|
184
|
-
const
|
|
177
|
+
const NativeImgInner = ({ hidden, name, stack, showInTimeline, src, from, durationInFrames, _experimentalControls: controls, ...props }) => {
|
|
185
178
|
if (!src) {
|
|
186
179
|
throw new Error('No "src" prop was passed to <Img>.');
|
|
187
180
|
}
|
|
188
181
|
return ((0, jsx_runtime_1.jsx)(Sequence_js_1.Sequence, { layout: "none", from: from !== null && from !== void 0 ? from : 0, durationInFrames: durationInFrames !== null && durationInFrames !== void 0 ? durationInFrames : Infinity, _remotionInternalStack: stack, _remotionInternalDocumentationLink: name === undefined ? 'https://www.remotion.dev/docs/img' : undefined, _remotionInternalIsMedia: { type: 'image', src }, name: name !== null && name !== void 0 ? name : '<Img>', _experimentalControls: controls, showInTimeline: showInTimeline !== null && showInTimeline !== void 0 ? showInTimeline : true, hidden: hidden, children: (0, jsx_runtime_1.jsx)(ImgContent, { src: src, ...props }) }));
|
|
189
182
|
};
|
|
190
|
-
const
|
|
183
|
+
const CanvasImageWithPrivateProps = index_js_1.CanvasImage;
|
|
184
|
+
exports.imgSchema = {
|
|
191
185
|
...sequence_field_schema_js_1.sequenceVisualStyleSchema,
|
|
192
186
|
hidden: sequence_field_schema_js_1.hiddenField,
|
|
193
187
|
};
|
|
188
|
+
const imgCanvasFallbackIncompatibleProps = new Set([
|
|
189
|
+
'alt',
|
|
190
|
+
'crossOrigin',
|
|
191
|
+
'decoding',
|
|
192
|
+
'fetchPriority',
|
|
193
|
+
'loading',
|
|
194
|
+
'onError',
|
|
195
|
+
'onImageFrame',
|
|
196
|
+
'onLoad',
|
|
197
|
+
'sizes',
|
|
198
|
+
'srcSet',
|
|
199
|
+
'useMap',
|
|
200
|
+
]);
|
|
201
|
+
const getIncompatiblePropNames = (props) => Object.keys(props).filter((key) => props[key] !== undefined && imgCanvasFallbackIncompatibleProps.has(key));
|
|
202
|
+
const formatPropList = (props) => {
|
|
203
|
+
return props.map((prop) => `"${prop}"`).join(', ');
|
|
204
|
+
};
|
|
205
|
+
const validateCanvasImageFallbackProps = ({ props, ref, width, height, }) => {
|
|
206
|
+
if (typeof width === 'string' || typeof height === 'string') {
|
|
207
|
+
throw new Error('The "width" and "height" props must be numbers on <Img> when effects are passed, because <Img> renders a <CanvasImage>. Use numeric props or CSS dimensions in "style".');
|
|
208
|
+
}
|
|
209
|
+
const conflictingProps = getIncompatiblePropNames(props);
|
|
210
|
+
if (ref !== null && ref !== undefined) {
|
|
211
|
+
conflictingProps.unshift('ref');
|
|
212
|
+
}
|
|
213
|
+
if (conflictingProps.length === 0) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
throw new Error(`The ${formatPropList(conflictingProps)} prop${conflictingProps.length === 1 ? '' : 's'} cannot be used on <Img> when effects are passed, because <Img> renders a <canvas> instead of a native <img>. Remove ${conflictingProps.length === 1 ? 'this prop' : 'these props'}.`);
|
|
217
|
+
};
|
|
218
|
+
const getFitFromObjectFit = (style) => {
|
|
219
|
+
const objectFit = style === null || style === void 0 ? void 0 : style.objectFit;
|
|
220
|
+
if (objectFit === 'fill' ||
|
|
221
|
+
objectFit === 'contain' ||
|
|
222
|
+
objectFit === 'cover') {
|
|
223
|
+
return objectFit;
|
|
224
|
+
}
|
|
225
|
+
return undefined;
|
|
226
|
+
};
|
|
227
|
+
const ImgInner = ({ effects = [], ref, hidden, name, stack, showInTimeline, src, from, durationInFrames, _experimentalControls: controls, width, height, className, style, id, pauseWhenLoading, maxRetries, delayRenderRetries, delayRenderTimeoutInMilliseconds, ...props }) => {
|
|
228
|
+
var _a;
|
|
229
|
+
if (effects.length === 0) {
|
|
230
|
+
return ((0, jsx_runtime_1.jsx)(NativeImgInner, { ...props, ref: ref, hidden: hidden, name: name, stack: stack, showInTimeline: showInTimeline, src: src, from: from, durationInFrames: durationInFrames, _experimentalControls: controls, width: width, height: height, className: className, style: style, id: id, pauseWhenLoading: pauseWhenLoading, maxRetries: maxRetries, delayRenderRetries: delayRenderRetries, delayRenderTimeoutInMilliseconds: delayRenderTimeoutInMilliseconds }));
|
|
231
|
+
}
|
|
232
|
+
if (!src) {
|
|
233
|
+
throw new Error('No "src" prop was passed to <Img>.');
|
|
234
|
+
}
|
|
235
|
+
validateCanvasImageFallbackProps({
|
|
236
|
+
props,
|
|
237
|
+
ref,
|
|
238
|
+
width,
|
|
239
|
+
height,
|
|
240
|
+
});
|
|
241
|
+
const canvasWidth = typeof width === 'number' ? width : undefined;
|
|
242
|
+
const canvasHeight = typeof height === 'number' ? height : undefined;
|
|
243
|
+
const canvasProps = props;
|
|
244
|
+
const canvasFit = (_a = getFitFromObjectFit(style)) !== null && _a !== void 0 ? _a : 'fill';
|
|
245
|
+
return ((0, jsx_runtime_1.jsx)(CanvasImageWithPrivateProps, { src: src, width: canvasWidth, height: canvasHeight, fit: canvasFit, effects: effects, className: className, style: style, id: id, pauseWhenLoading: pauseWhenLoading, maxRetries: maxRetries, delayRenderRetries: delayRenderRetries, delayRenderTimeoutInMilliseconds: delayRenderTimeoutInMilliseconds, from: from, durationInFrames: durationInFrames, hidden: hidden, name: name !== null && name !== void 0 ? name : '<Img>', showInTimeline: showInTimeline, stack: stack, _remotionInternalDocumentationLink: name === undefined ? 'https://www.remotion.dev/docs/img' : undefined, _experimentalControls: controls, ...canvasProps }));
|
|
246
|
+
};
|
|
194
247
|
/*
|
|
195
248
|
* @description Works just like a regular HTML img tag. When you use the <Img> tag, Remotion will ensure that the image is loaded before rendering the frame.
|
|
196
249
|
* @see [Documentation](https://remotion.dev/docs/img)
|
|
197
250
|
*/
|
|
198
|
-
exports.Img = (0, wrap_in_schema_js_1.wrapInSchema)(ImgInner, imgSchema);
|
|
251
|
+
exports.Img = (0, wrap_in_schema_js_1.wrapInSchema)(ImgInner, exports.imgSchema);
|
|
199
252
|
(0, enable_sequence_stack_traces_js_1.addSequenceStackTraces)(exports.Img);
|
|
@@ -5,6 +5,7 @@ export declare const RemotionRootContexts: React.FC<{
|
|
|
5
5
|
readonly numberOfAudioTags: number;
|
|
6
6
|
readonly logLevel: LogLevel;
|
|
7
7
|
readonly audioLatencyHint: AudioContextLatencyCategory;
|
|
8
|
+
readonly previewSampleRate: number | null;
|
|
8
9
|
readonly videoEnabled: boolean;
|
|
9
10
|
readonly audioEnabled: boolean;
|
|
10
11
|
readonly frameState: Record<string, number> | null;
|
package/dist/cjs/RemotionRoot.js
CHANGED
|
@@ -13,7 +13,7 @@ const SequenceManager_js_1 = require("./SequenceManager.js");
|
|
|
13
13
|
const TimelineContext_js_1 = require("./TimelineContext.js");
|
|
14
14
|
const use_media_enabled_js_1 = require("./use-media-enabled.js");
|
|
15
15
|
const duration_state_js_1 = require("./video/duration-state.js");
|
|
16
|
-
const RemotionRootContexts = ({ children, numberOfAudioTags, logLevel, audioLatencyHint, videoEnabled, audioEnabled, frameState, }) => {
|
|
16
|
+
const RemotionRootContexts = ({ children, numberOfAudioTags, logLevel, audioLatencyHint, previewSampleRate, videoEnabled, audioEnabled, frameState, }) => {
|
|
17
17
|
const nonceContext = (0, react_1.useMemo)(() => {
|
|
18
18
|
let counter = 0;
|
|
19
19
|
return {
|
|
@@ -23,6 +23,6 @@ const RemotionRootContexts = ({ children, numberOfAudioTags, logLevel, audioLate
|
|
|
23
23
|
const logging = (0, react_1.useMemo)(() => {
|
|
24
24
|
return { logLevel, mountTime: Date.now() };
|
|
25
25
|
}, [logLevel]);
|
|
26
|
-
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)(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)(duration_state_js_1.DurationsContextProvider, { children: (0, jsx_runtime_1.jsx)(buffering_js_1.BufferingProvider, { children: (0, jsx_runtime_1.jsx)(shared_audio_tags_js_1.SharedAudioContextProvider, { audioLatencyHint: audioLatencyHint, audioEnabled: audioEnabled, children: (0, jsx_runtime_1.jsx)(shared_audio_tags_js_1.SharedAudioTagsContextProvider, { numberOfAudioTags: numberOfAudioTags, children: children }) }) }) }) }) }) }) }) }) }) }));
|
|
26
|
+
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)(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)(duration_state_js_1.DurationsContextProvider, { children: (0, jsx_runtime_1.jsx)(buffering_js_1.BufferingProvider, { children: (0, jsx_runtime_1.jsx)(shared_audio_tags_js_1.SharedAudioContextProvider, { audioLatencyHint: audioLatencyHint, audioEnabled: audioEnabled, previewSampleRate: previewSampleRate, children: (0, jsx_runtime_1.jsx)(shared_audio_tags_js_1.SharedAudioTagsContextProvider, { numberOfAudioTags: numberOfAudioTags, children: children }) }) }) }) }) }) }) }) }) }) }));
|
|
27
27
|
};
|
|
28
28
|
exports.RemotionRootContexts = RemotionRootContexts;
|
package/dist/cjs/Sequence.d.ts
CHANGED
|
@@ -62,6 +62,10 @@ export type SequencePropsWithoutDuration = {
|
|
|
62
62
|
type: 'image';
|
|
63
63
|
src: string;
|
|
64
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* @deprecated For internal use only.
|
|
67
|
+
*/
|
|
68
|
+
readonly _remotionInternalRefForOutline?: React.RefObject<HTMLElement | null> | null;
|
|
65
69
|
} & LayoutAndStyle;
|
|
66
70
|
export type SequenceProps = {
|
|
67
71
|
readonly durationInFrames?: number;
|
package/dist/cjs/Sequence.js
CHANGED
|
@@ -17,7 +17,7 @@ const use_remotion_environment_js_1 = require("./use-remotion-environment.js");
|
|
|
17
17
|
const use_video_config_js_1 = require("./use-video-config.js");
|
|
18
18
|
const v5_flag_js_1 = require("./v5-flag.js");
|
|
19
19
|
const wrap_in_schema_js_1 = require("./wrap-in-schema.js");
|
|
20
|
-
const RegularSequenceRefForwardingFunction = ({ from = 0, durationInFrames = Infinity, children, name, height, width, showInTimeline = true, hidden = false, _experimentalControls: controls, _remotionInternalEffects, _remotionInternalLoopDisplay: loopDisplay, _remotionInternalStack: stack, _remotionInternalDocumentationLink: documentationLink, _remotionInternalPremountDisplay: premountDisplay, _remotionInternalPostmountDisplay: postmountDisplay, _remotionInternalIsMedia: isMedia, ...other }, ref) => {
|
|
20
|
+
const RegularSequenceRefForwardingFunction = ({ from = 0, durationInFrames = Infinity, children, name, height, width, showInTimeline = true, hidden = false, _experimentalControls: controls, _remotionInternalEffects, _remotionInternalLoopDisplay: loopDisplay, _remotionInternalStack: stack, _remotionInternalDocumentationLink: documentationLink, _remotionInternalPremountDisplay: premountDisplay, _remotionInternalPostmountDisplay: postmountDisplay, _remotionInternalIsMedia: isMedia, _remotionInternalRefForOutline: refForOutline, ...other }, ref) => {
|
|
21
21
|
var _a;
|
|
22
22
|
const { layout = 'absolute-fill' } = other;
|
|
23
23
|
const [id] = (0, react_1.useState)(() => String(Math.random()));
|
|
@@ -152,6 +152,7 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, durationInFrames = Inf
|
|
|
152
152
|
showInTimeline,
|
|
153
153
|
src: isMedia.src,
|
|
154
154
|
getStack: () => stackRef.current,
|
|
155
|
+
refForOutline: refForOutline !== null && refForOutline !== void 0 ? refForOutline : null,
|
|
155
156
|
});
|
|
156
157
|
}
|
|
157
158
|
else {
|
|
@@ -177,6 +178,7 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, durationInFrames = Inf
|
|
|
177
178
|
getStack: () => stackRef.current,
|
|
178
179
|
startMediaFrom: isMedia.data.startMediaFrom,
|
|
179
180
|
volume: isMedia.data.volumes,
|
|
181
|
+
refForOutline: refForOutline !== null && refForOutline !== void 0 ? refForOutline : null,
|
|
180
182
|
});
|
|
181
183
|
}
|
|
182
184
|
return () => {
|
|
@@ -200,6 +202,7 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, durationInFrames = Inf
|
|
|
200
202
|
postmountDisplay: postmountDisplay !== null && postmountDisplay !== void 0 ? postmountDisplay : null,
|
|
201
203
|
controls: controls !== null && controls !== void 0 ? controls : null,
|
|
202
204
|
effects: _remotionInternalEffects !== null && _remotionInternalEffects !== void 0 ? _remotionInternalEffects : [],
|
|
205
|
+
refForOutline: refForOutline !== null && refForOutline !== void 0 ? refForOutline : null,
|
|
203
206
|
});
|
|
204
207
|
return () => {
|
|
205
208
|
unregisterSequence(id);
|
|
@@ -225,6 +228,7 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, durationInFrames = Inf
|
|
|
225
228
|
_remotionInternalEffects,
|
|
226
229
|
isMedia,
|
|
227
230
|
resolvedDocumentationLink,
|
|
231
|
+
refForOutline,
|
|
228
232
|
]);
|
|
229
233
|
// Ceil to support floats
|
|
230
234
|
// https://github.com/remotion-dev/remotion/issues/2958
|
|
@@ -135,6 +135,7 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
|
|
|
135
135
|
postmountDisplay: (_b = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.postmountDisplay) !== null && _b !== void 0 ? _b : null,
|
|
136
136
|
loopDisplay: undefined,
|
|
137
137
|
documentationLink: name === undefined ? 'https://www.remotion.dev/docs/html5-audio' : null,
|
|
138
|
+
refForOutline: null,
|
|
138
139
|
});
|
|
139
140
|
// putting playback before useVolume
|
|
140
141
|
// because volume looks at playbackrate
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { type AudioHTMLAttributes } from 'react';
|
|
2
|
-
import React from 'react';
|
|
1
|
+
import React, { type AudioHTMLAttributes } from 'react';
|
|
3
2
|
import type { SharedElementSourceNode } from './shared-element-source-node.js';
|
|
4
3
|
import type { RemotionAudioContextState } from './use-audio-context.js';
|
|
5
4
|
/**
|
|
@@ -85,6 +84,7 @@ export declare const SharedAudioContextProvider: React.FC<{
|
|
|
85
84
|
readonly children: React.ReactNode;
|
|
86
85
|
readonly audioLatencyHint: AudioContextLatencyCategory;
|
|
87
86
|
readonly audioEnabled: boolean;
|
|
87
|
+
readonly previewSampleRate: number | null;
|
|
88
88
|
}>;
|
|
89
89
|
export declare const SharedAudioTagsContextProvider: React.FC<{
|
|
90
90
|
readonly numberOfAudioTags: number;
|
|
@@ -88,12 +88,20 @@ const shouldSaveForLater = (state) => {
|
|
|
88
88
|
}
|
|
89
89
|
throw new Error(`Unexpected audio context state: ${state}`);
|
|
90
90
|
};
|
|
91
|
-
const SharedAudioContextProvider = ({ children, audioLatencyHint, audioEnabled }) => {
|
|
91
|
+
const SharedAudioContextProvider = ({ children, audioLatencyHint, audioEnabled, previewSampleRate }) => {
|
|
92
92
|
const logLevel = (0, log_level_context_js_1.useLogLevel)();
|
|
93
|
+
const sampleRate = previewSampleRate !== null && previewSampleRate !== void 0 ? previewSampleRate : 48000;
|
|
94
|
+
(0, react_1.useEffect)(() => {
|
|
95
|
+
if (typeof window === 'undefined') {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
window.remotion_sampleRate = sampleRate;
|
|
99
|
+
}, [sampleRate]);
|
|
93
100
|
const ctxAndGain = (0, use_audio_context_js_1.useSingletonAudioContext)({
|
|
94
101
|
logLevel,
|
|
95
102
|
latencyHint: audioLatencyHint,
|
|
96
103
|
audioEnabled,
|
|
104
|
+
sampleRate,
|
|
97
105
|
});
|
|
98
106
|
const audioContextIsPlayingEventually = (0, react_1.useRef)(false);
|
|
99
107
|
const isResuming = (0, react_1.useRef)(null);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { LogLevel } from '../log';
|
|
2
2
|
export type RemotionAudioContextState = AudioContextState | 'running-to-suspended' | 'suspended-to-running';
|
|
3
|
-
export declare const useSingletonAudioContext: ({ logLevel, latencyHint, audioEnabled, }: {
|
|
3
|
+
export declare const useSingletonAudioContext: ({ logLevel, latencyHint, audioEnabled, sampleRate, }: {
|
|
4
4
|
logLevel: LogLevel;
|
|
5
5
|
latencyHint: AudioContextLatencyCategory;
|
|
6
6
|
audioEnabled: boolean;
|
|
7
|
+
sampleRate: number;
|
|
7
8
|
}) => {
|
|
8
9
|
audioContext: AudioContext;
|
|
9
10
|
gainNode: GainNode;
|
|
@@ -15,8 +15,12 @@ const warnOnce = (logLevel) => {
|
|
|
15
15
|
log_1.Log.warn({ logLevel, tag: null }, 'AudioContext is not supported in this browser');
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
|
-
const useSingletonAudioContext = ({ logLevel, latencyHint, audioEnabled, }) => {
|
|
18
|
+
const useSingletonAudioContext = ({ logLevel, latencyHint, audioEnabled, sampleRate, }) => {
|
|
19
19
|
const env = (0, use_remotion_environment_1.useRemotionEnvironment)();
|
|
20
|
+
const initialSampleRate = (0, react_1.useRef)(sampleRate);
|
|
21
|
+
if (sampleRate !== initialSampleRate.current) {
|
|
22
|
+
throw new Error(`Changing the AudioContext sample rate dynamically is not supported. The sample rate was initialized with ${initialSampleRate.current} Hz, but ${sampleRate} Hz was passed later.`);
|
|
23
|
+
}
|
|
20
24
|
const context = (0, react_1.useMemo)(() => {
|
|
21
25
|
if (env.isRendering) {
|
|
22
26
|
return null;
|
|
@@ -33,7 +37,7 @@ const useSingletonAudioContext = ({ logLevel, latencyHint, audioEnabled, }) => {
|
|
|
33
37
|
// By default, this can end up being 44100Hz.
|
|
34
38
|
// Playing a 48000Hz file in a 44100Hz context, such as https://remotion.media/video.mp4 in a @remotion/media tag
|
|
35
39
|
// we observe some issues that seem to go away when we set the sample rate to 48000 with Sony LinkBuds Bluetooth headphones.
|
|
36
|
-
sampleRate
|
|
40
|
+
sampleRate,
|
|
37
41
|
});
|
|
38
42
|
const gainNode = audioContext.createGain();
|
|
39
43
|
gainNode.connect(audioContext.destination);
|
|
@@ -79,7 +83,7 @@ const useSingletonAudioContext = ({ logLevel, latencyHint, audioEnabled, }) => {
|
|
|
79
83
|
resume,
|
|
80
84
|
suspend,
|
|
81
85
|
};
|
|
82
|
-
}, [logLevel, latencyHint, env.isRendering, audioEnabled]);
|
|
86
|
+
}, [logLevel, latencyHint, env.isRendering, audioEnabled, sampleRate]);
|
|
83
87
|
return context;
|
|
84
88
|
};
|
|
85
89
|
exports.useSingletonAudioContext = useSingletonAudioContext;
|
|
@@ -1,7 +1,49 @@
|
|
|
1
1
|
import type { EffectsProp } from '../effects/effect-types.js';
|
|
2
|
+
import type { CanvasImageCanvasProps } from './props.js';
|
|
3
|
+
export declare const canvasImageSchema: {
|
|
4
|
+
readonly hidden: import("../sequence-field-schema.js").SequenceFieldSchema;
|
|
5
|
+
readonly 'style.translate': {
|
|
6
|
+
readonly type: "translate";
|
|
7
|
+
readonly step: 1;
|
|
8
|
+
readonly default: "0px 0px";
|
|
9
|
+
readonly description: "Offset";
|
|
10
|
+
};
|
|
11
|
+
readonly 'style.scale': {
|
|
12
|
+
readonly type: "number";
|
|
13
|
+
readonly min: 0.05;
|
|
14
|
+
readonly max: 100;
|
|
15
|
+
readonly step: 0.01;
|
|
16
|
+
readonly default: 1;
|
|
17
|
+
readonly description: "Scale";
|
|
18
|
+
};
|
|
19
|
+
readonly 'style.rotate': {
|
|
20
|
+
readonly type: "rotation";
|
|
21
|
+
readonly step: 1;
|
|
22
|
+
readonly default: "0deg";
|
|
23
|
+
readonly description: "Rotation";
|
|
24
|
+
};
|
|
25
|
+
readonly 'style.opacity': {
|
|
26
|
+
readonly type: "number";
|
|
27
|
+
readonly min: 0;
|
|
28
|
+
readonly max: 1;
|
|
29
|
+
readonly step: 0.01;
|
|
30
|
+
readonly default: 1;
|
|
31
|
+
readonly description: "Opacity";
|
|
32
|
+
};
|
|
33
|
+
readonly fit: {
|
|
34
|
+
readonly type: "enum";
|
|
35
|
+
readonly default: "fill";
|
|
36
|
+
readonly description: "Fit";
|
|
37
|
+
readonly variants: {
|
|
38
|
+
readonly fill: {};
|
|
39
|
+
readonly contain: {};
|
|
40
|
+
readonly cover: {};
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
2
44
|
export declare const CanvasImage: import("react").ComponentType<Pick<import("../Sequence.js").SequenceProps, "hidden" | "name" | "durationInFrames" | "from" | "showInTimeline"> & {
|
|
3
45
|
readonly stack?: string;
|
|
4
|
-
} & {
|
|
46
|
+
} & CanvasImageCanvasProps & {
|
|
5
47
|
readonly src: string;
|
|
6
48
|
readonly width?: number;
|
|
7
49
|
readonly height?: number;
|
|
@@ -15,4 +57,5 @@ export declare const CanvasImage: import("react").ComponentType<Pick<import("../
|
|
|
15
57
|
readonly maxRetries?: number;
|
|
16
58
|
readonly delayRenderRetries?: number;
|
|
17
59
|
readonly delayRenderTimeoutInMilliseconds?: number;
|
|
60
|
+
readonly _remotionInternalDocumentationLink?: string;
|
|
18
61
|
} & import("react").RefAttributes<HTMLCanvasElement>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CanvasImage = void 0;
|
|
3
|
+
exports.CanvasImage = exports.canvasImageSchema = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const calculate_image_fit_js_1 = require("../calculate-image-fit.js");
|
|
@@ -8,15 +8,15 @@ const run_effect_chain_js_1 = require("../effects/run-effect-chain.js");
|
|
|
8
8
|
const use_effect_chain_state_js_1 = require("../effects/use-effect-chain-state.js");
|
|
9
9
|
const use_memoized_effects_js_1 = require("../effects/use-memoized-effects.js");
|
|
10
10
|
const enable_sequence_stack_traces_js_1 = require("../enable-sequence-stack-traces.js");
|
|
11
|
-
const Img_js_1 = require("../Img.js");
|
|
12
11
|
const prefetch_js_1 = require("../prefetch.js");
|
|
13
12
|
const sequence_field_schema_js_1 = require("../sequence-field-schema.js");
|
|
14
13
|
const Sequence_js_1 = require("../Sequence.js");
|
|
15
14
|
const SequenceContext_js_1 = require("../SequenceContext.js");
|
|
15
|
+
const truncate_src_for_label_js_1 = require("../truncate-src-for-label.js");
|
|
16
16
|
const use_buffer_state_js_1 = require("../use-buffer-state.js");
|
|
17
17
|
const use_delay_render_js_1 = require("../use-delay-render.js");
|
|
18
18
|
const wrap_in_schema_js_1 = require("../wrap-in-schema.js");
|
|
19
|
-
|
|
19
|
+
exports.canvasImageSchema = {
|
|
20
20
|
fit: {
|
|
21
21
|
type: 'enum',
|
|
22
22
|
default: 'fill',
|
|
@@ -65,14 +65,14 @@ const loadImage = ({ src, signal, }) => {
|
|
|
65
65
|
const imageWidth = image.naturalWidth || image.width;
|
|
66
66
|
const imageHeight = image.naturalHeight || image.height;
|
|
67
67
|
if (imageWidth <= 0 || imageHeight <= 0) {
|
|
68
|
-
settle(() => reject(new Error(`Could not determine dimensions for <CanvasImage> with src="${(0,
|
|
68
|
+
settle(() => reject(new Error(`Could not determine dimensions for <CanvasImage> with src="${(0, truncate_src_for_label_js_1.truncateSrcForLabel)(src)}"`)));
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
71
|
settle(() => resolve({ element: image, width: imageWidth, height: imageHeight }));
|
|
72
72
|
});
|
|
73
73
|
};
|
|
74
74
|
image.onerror = () => {
|
|
75
|
-
settle(() => reject(new Error(`Could not load <CanvasImage> with src="${(0,
|
|
75
|
+
settle(() => reject(new Error(`Could not load <CanvasImage> with src="${(0, truncate_src_for_label_js_1.truncateSrcForLabel)(src)}"`)));
|
|
76
76
|
};
|
|
77
77
|
signal.addEventListener('abort', onAbort, { once: true });
|
|
78
78
|
if (signal.aborted) {
|
|
@@ -86,7 +86,7 @@ const loadImage = ({ src, signal, }) => {
|
|
|
86
86
|
function exponentialBackoff(errorCount) {
|
|
87
87
|
return 1000 * 2 ** (errorCount - 1);
|
|
88
88
|
}
|
|
89
|
-
const CanvasImageContent = (0, react_1.forwardRef)(({ src, width, height, fit = 'fill', effects, controls, onError, className, style, id, pauseWhenLoading, maxRetries = 2, delayRenderRetries, delayRenderTimeoutInMilliseconds, }, ref) => {
|
|
89
|
+
const CanvasImageContent = (0, react_1.forwardRef)(({ src, width, height, fit = 'fill', effects, controls, onError, className, style, id, pauseWhenLoading, maxRetries = 2, delayRenderRetries, delayRenderTimeoutInMilliseconds, ...canvasProps }, ref) => {
|
|
90
90
|
var _a;
|
|
91
91
|
const { delayRender, continueRender, cancelRender } = (0, use_delay_render_js_1.useDelayRender)();
|
|
92
92
|
const { delayPlayback } = (0, use_buffer_state_js_1.useBufferState)();
|
|
@@ -119,7 +119,7 @@ const CanvasImageContent = (0, react_1.forwardRef)(({ src, width, height, fit =
|
|
|
119
119
|
}
|
|
120
120
|
const isPremounting = Boolean(sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.premounting);
|
|
121
121
|
const isPostmounting = Boolean(sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.postmounting);
|
|
122
|
-
const handle = delayRender(`Rendering <CanvasImage> with src="${(0,
|
|
122
|
+
const handle = delayRender(`Rendering <CanvasImage> with src="${(0, truncate_src_for_label_js_1.truncateSrcForLabel)(actualSrc)}"`, {
|
|
123
123
|
retries: delayRenderRetries !== null && delayRenderRetries !== void 0 ? delayRenderRetries : undefined,
|
|
124
124
|
timeoutInMilliseconds: delayRenderTimeoutInMilliseconds !== null && delayRenderTimeoutInMilliseconds !== void 0 ? delayRenderTimeoutInMilliseconds : undefined,
|
|
125
125
|
});
|
|
@@ -182,7 +182,7 @@ const CanvasImageContent = (0, react_1.forwardRef)(({ src, width, height, fit =
|
|
|
182
182
|
if (errorCount <= maxRetries) {
|
|
183
183
|
const backoff = exponentialBackoff(errorCount);
|
|
184
184
|
// eslint-disable-next-line no-console
|
|
185
|
-
console.warn(`Could not load <CanvasImage> with src="${(0,
|
|
185
|
+
console.warn(`Could not load <CanvasImage> with src="${(0, truncate_src_for_label_js_1.truncateSrcForLabel)(actualSrc)}", retrying in ${backoff}ms`);
|
|
186
186
|
timeoutId = setTimeout(() => {
|
|
187
187
|
if (!cancelled) {
|
|
188
188
|
attemptLoad();
|
|
@@ -228,20 +228,20 @@ const CanvasImageContent = (0, react_1.forwardRef)(({ src, width, height, fit =
|
|
|
228
228
|
sourceCanvas,
|
|
229
229
|
width,
|
|
230
230
|
]);
|
|
231
|
-
return ((0, jsx_runtime_1.jsx)("canvas", { ref: canvasRef, width: width, height: height, className: className, style: style, id: id }));
|
|
231
|
+
return ((0, jsx_runtime_1.jsx)("canvas", { ...canvasProps, ref: canvasRef, width: width, height: height, className: className, style: style, id: id }));
|
|
232
232
|
});
|
|
233
233
|
CanvasImageContent.displayName = 'CanvasImageContent';
|
|
234
|
-
const CanvasImageInner = (0, react_1.forwardRef)(({ src, width, height, fit, effects = [], className, style, id, onError, pauseWhenLoading, maxRetries, delayRenderRetries, delayRenderTimeoutInMilliseconds, durationInFrames, from, hidden, name, showInTimeline, stack, _experimentalControls: controls, }, ref) => {
|
|
234
|
+
const CanvasImageInner = (0, react_1.forwardRef)(({ src, width, height, fit, effects = [], className, style, id, onError, pauseWhenLoading, maxRetries, delayRenderRetries, delayRenderTimeoutInMilliseconds, durationInFrames, from, hidden, name, showInTimeline, stack, _experimentalControls: controls, _remotionInternalDocumentationLink, ...canvasProps }, ref) => {
|
|
235
235
|
if (!src) {
|
|
236
236
|
throw new Error('No "src" prop was passed to <CanvasImage>.');
|
|
237
237
|
}
|
|
238
238
|
const memoizedEffectDefinitions = (0, use_memoized_effects_js_1.useMemoizedEffectDefinitions)(effects);
|
|
239
|
-
return ((0, jsx_runtime_1.jsx)(Sequence_js_1.Sequence, { layout: "none", from: from !== null && from !== void 0 ? from : 0, durationInFrames: durationInFrames !== null && durationInFrames !== void 0 ? durationInFrames : Infinity, hidden: hidden, showInTimeline: showInTimeline !== null && showInTimeline !== void 0 ? showInTimeline : true, name: name !== null && name !== void 0 ? name : '<CanvasImage>', _experimentalControls: controls, _remotionInternalEffects: memoizedEffectDefinitions, _remotionInternalIsMedia: { type: 'image', src }, _remotionInternalStack: stack, children: (0, jsx_runtime_1.jsx)(CanvasImageContent, { ref: ref, src: src, width: width, height: height, fit: fit, effects: effects, controls: controls, className: className, style: style, id: id, onError: onError, pauseWhenLoading: pauseWhenLoading, maxRetries: maxRetries, delayRenderRetries: delayRenderRetries, delayRenderTimeoutInMilliseconds: delayRenderTimeoutInMilliseconds }) }));
|
|
239
|
+
return ((0, jsx_runtime_1.jsx)(Sequence_js_1.Sequence, { layout: "none", from: from !== null && from !== void 0 ? from : 0, durationInFrames: durationInFrames !== null && durationInFrames !== void 0 ? durationInFrames : Infinity, hidden: hidden, showInTimeline: showInTimeline !== null && showInTimeline !== void 0 ? showInTimeline : true, name: name !== null && name !== void 0 ? name : '<CanvasImage>', _remotionInternalDocumentationLink: _remotionInternalDocumentationLink !== null && _remotionInternalDocumentationLink !== void 0 ? _remotionInternalDocumentationLink : 'https://www.remotion.dev/docs/canvasimage', _experimentalControls: controls, _remotionInternalEffects: memoizedEffectDefinitions, _remotionInternalIsMedia: { type: 'image', src }, _remotionInternalStack: stack, children: (0, jsx_runtime_1.jsx)(CanvasImageContent, { ref: ref, src: src, width: width, height: height, fit: fit, effects: effects, controls: controls, className: className, style: style, id: id, onError: onError, pauseWhenLoading: pauseWhenLoading, maxRetries: maxRetries, delayRenderRetries: delayRenderRetries, delayRenderTimeoutInMilliseconds: delayRenderTimeoutInMilliseconds, ...canvasProps }) }));
|
|
240
240
|
});
|
|
241
241
|
/*
|
|
242
242
|
* @description Renders a static image to a `<canvas>` and applies Remotion effects.
|
|
243
243
|
* @see [Documentation](https://www.remotion.dev/docs/canvasimage)
|
|
244
244
|
*/
|
|
245
|
-
exports.CanvasImage = (0, wrap_in_schema_js_1.wrapInSchema)(CanvasImageInner, canvasImageSchema);
|
|
245
|
+
exports.CanvasImage = (0, wrap_in_schema_js_1.wrapInSchema)(CanvasImageInner, exports.canvasImageSchema);
|
|
246
246
|
exports.CanvasImage.displayName = 'CanvasImage';
|
|
247
247
|
(0, enable_sequence_stack_traces_js_1.addSequenceStackTraces)(exports.CanvasImage);
|
|
@@ -8,7 +8,8 @@ type CanvasImageSequenceProps = Pick<SequenceProps, 'durationInFrames' | 'from'
|
|
|
8
8
|
*/
|
|
9
9
|
readonly stack?: string;
|
|
10
10
|
};
|
|
11
|
-
export type
|
|
11
|
+
export type CanvasImageCanvasProps = Omit<React.CanvasHTMLAttributes<HTMLCanvasElement>, 'children' | 'height' | 'onError' | 'width'>;
|
|
12
|
+
export type CanvasImageProps = CanvasImageSequenceProps & CanvasImageCanvasProps & {
|
|
12
13
|
readonly src: string;
|
|
13
14
|
readonly width?: number;
|
|
14
15
|
readonly height?: number;
|
|
@@ -22,5 +23,9 @@ export type CanvasImageProps = CanvasImageSequenceProps & {
|
|
|
22
23
|
readonly maxRetries?: number;
|
|
23
24
|
readonly delayRenderRetries?: number;
|
|
24
25
|
readonly delayRenderTimeoutInMilliseconds?: number;
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated For internal use only.
|
|
28
|
+
*/
|
|
29
|
+
readonly _remotionInternalDocumentationLink?: string;
|
|
25
30
|
};
|
|
26
31
|
export {};
|
|
@@ -32,8 +32,9 @@ const solidSchema = {
|
|
|
32
32
|
description: 'Height',
|
|
33
33
|
},
|
|
34
34
|
...sequence_field_schema_js_1.sequenceVisualStyleSchema,
|
|
35
|
+
hidden: sequence_field_schema_js_1.hiddenField,
|
|
35
36
|
};
|
|
36
|
-
const SolidInner = ({ color, width, height, effects = [], className, style, overrideId,
|
|
37
|
+
const SolidInner = ({ color, width, height, effects = [], className, style, overrideId, reference, }) => {
|
|
37
38
|
const { delayRender, continueRender, cancelRender } = (0, use_delay_render_js_1.useDelayRender)();
|
|
38
39
|
const [outputCanvas, setOutputCanvas] = (0, react_1.useState)(null);
|
|
39
40
|
const memoizedEffects = (0, use_memoized_effects_js_1.useMemoizedEffects)({
|
|
@@ -52,13 +53,13 @@ const SolidInner = ({ color, width, height, effects = [], className, style, over
|
|
|
52
53
|
const chainState = (0, use_effect_chain_state_js_1.useEffectChainState)();
|
|
53
54
|
const canvasRef = (0, react_1.useCallback)((canvas) => {
|
|
54
55
|
setOutputCanvas(canvas);
|
|
55
|
-
if (typeof
|
|
56
|
-
|
|
56
|
+
if (typeof reference === 'function') {
|
|
57
|
+
reference(canvas);
|
|
57
58
|
}
|
|
58
|
-
else if (
|
|
59
|
-
|
|
59
|
+
else if (reference) {
|
|
60
|
+
reference.current = canvas;
|
|
60
61
|
}
|
|
61
|
-
}, [
|
|
62
|
+
}, [reference]);
|
|
62
63
|
// Fill source and run effect chain on every frame / color change.
|
|
63
64
|
(0, react_1.useEffect)(() => {
|
|
64
65
|
if (!outputCanvas || !sourceCanvas) {
|
|
@@ -118,7 +119,11 @@ const SolidOuter = (0, react_1.forwardRef)(({ effects = [], _experimentalControl
|
|
|
118
119
|
var _a;
|
|
119
120
|
props;
|
|
120
121
|
const memoizedEffectDefinitions = (0, use_memoized_effects_js_1.useMemoizedEffectDefinitions)(effects);
|
|
121
|
-
|
|
122
|
+
const actualRef = (0, react_1.useRef)(null);
|
|
123
|
+
(0, react_1.useImperativeHandle)(ref, () => {
|
|
124
|
+
return actualRef.current;
|
|
125
|
+
}, []);
|
|
126
|
+
return ((0, jsx_runtime_1.jsx)(Sequence_js_1.Sequence, { layout: "none", from: from, hidden: hidden, showInTimeline: showInTimeline, _experimentalControls: controls, _remotionInternalEffects: memoizedEffectDefinitions, durationInFrames: durationInFrames, name: name !== null && name !== void 0 ? name : '<Solid>', _remotionInternalRefForOutline: actualRef, _remotionInternalDocumentationLink: name === undefined ? 'https://www.remotion.dev/docs/solid' : undefined, ...props, children: (0, jsx_runtime_1.jsx)(SolidInner, { reference: actualRef, overrideId: (_a = controls === null || controls === void 0 ? void 0 : controls.overrideId) !== null && _a !== void 0 ? _a : null, color: color, height: height, width: width, className: className, style: style, effects: effects }) }));
|
|
122
127
|
});
|
|
123
128
|
exports.Solid = (0, wrap_in_schema_js_1.wrapInSchema)(SolidOuter, solidSchema);
|
|
124
129
|
exports.Solid.displayName = 'Solid';
|
|
@@ -11,8 +11,8 @@ export type EffectApplyParams<P, S> = {
|
|
|
11
11
|
readonly gpuDevice: AnyGpuDevice | null;
|
|
12
12
|
/**
|
|
13
13
|
* When `true`, WebGL `texImage2D` uploads use `UNPACK_FLIP_Y_WEBGL` so DOM-style
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* canvas sources match clip-space UVs. Set by `runEffectChain` — `false` for
|
|
15
|
+
* `ImageBitmap` bridges from WebGL, which are already oriented for upload.
|
|
16
16
|
*/
|
|
17
17
|
readonly flipSourceY: boolean;
|
|
18
18
|
};
|