remotion 4.0.245 → 4.0.247
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/bunfig.toml +1 -1
- package/dist/cjs/animated-image/AnimatedImage.d.ts +2 -0
- package/dist/cjs/animated-image/AnimatedImage.js +99 -0
- package/dist/cjs/animated-image/canvas.d.ts +16 -0
- package/dist/cjs/animated-image/canvas.js +122 -0
- package/dist/cjs/animated-image/decode-image.d.ts +16 -0
- package/dist/cjs/animated-image/decode-image.js +144 -0
- package/dist/cjs/animated-image/index.d.ts +1 -0
- package/dist/cjs/animated-image/index.js +5 -0
- package/dist/cjs/animated-image/props.d.ts +13 -0
- package/dist/cjs/animated-image/props.js +2 -0
- package/dist/cjs/animated-image/resolve-image-source.d.ts +1 -0
- package/dist/cjs/animated-image/resolve-image-source.js +8 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/index.mjs +783 -433
- package/dist/esm/version.mjs +1 -1
- package/package.json +4 -5
- package/dist/cjs/use-media-tag-volume.d.ts +0 -2
- package/dist/cjs/use-media-tag-volume.js +0 -31
package/bunfig.toml
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
[test]
|
|
2
|
-
|
|
2
|
+
preload = "./happydom.ts"
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AnimatedImage = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const cancel_render_js_1 = require("../cancel-render.js");
|
|
7
|
+
const delay_render_js_1 = require("../delay-render.js");
|
|
8
|
+
const use_current_frame_js_1 = require("../use-current-frame.js");
|
|
9
|
+
const use_video_config_js_1 = require("../use-video-config.js");
|
|
10
|
+
const canvas_1 = require("./canvas");
|
|
11
|
+
const decode_image_js_1 = require("./decode-image.js");
|
|
12
|
+
const resolve_image_source_1 = require("./resolve-image-source");
|
|
13
|
+
exports.AnimatedImage = (0, react_1.forwardRef)(({ src, width, height, onError, loopBehavior = 'loop', playbackRate = 1, fit = 'fill', ...props }, canvasRef) => {
|
|
14
|
+
const mountState = (0, react_1.useRef)({ isMounted: true });
|
|
15
|
+
(0, react_1.useEffect)(() => {
|
|
16
|
+
const { current } = mountState;
|
|
17
|
+
current.isMounted = true;
|
|
18
|
+
return () => {
|
|
19
|
+
current.isMounted = false;
|
|
20
|
+
};
|
|
21
|
+
}, []);
|
|
22
|
+
const resolvedSrc = (0, resolve_image_source_1.resolveAnimatedImageSource)(src);
|
|
23
|
+
const [imageDecoder, setImageDecoder] = (0, react_1.useState)(null);
|
|
24
|
+
const [decodeHandle] = (0, react_1.useState)(() => (0, delay_render_js_1.delayRender)(`Rendering <AnimatedImage/> with src="${resolvedSrc}"`));
|
|
25
|
+
const frame = (0, use_current_frame_js_1.useCurrentFrame)();
|
|
26
|
+
const { fps } = (0, use_video_config_js_1.useVideoConfig)();
|
|
27
|
+
const currentTime = frame / playbackRate / fps;
|
|
28
|
+
const currentTimeRef = (0, react_1.useRef)(currentTime);
|
|
29
|
+
currentTimeRef.current = currentTime;
|
|
30
|
+
const ref = (0, react_1.useRef)(null);
|
|
31
|
+
(0, react_1.useImperativeHandle)(canvasRef, () => {
|
|
32
|
+
var _a;
|
|
33
|
+
const c = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.getCanvas();
|
|
34
|
+
if (!c) {
|
|
35
|
+
throw new Error('Canvas ref is not set');
|
|
36
|
+
}
|
|
37
|
+
return c;
|
|
38
|
+
}, []);
|
|
39
|
+
const [initialLoopBehavior] = (0, react_1.useState)(() => loopBehavior);
|
|
40
|
+
(0, react_1.useEffect)(() => {
|
|
41
|
+
const controller = new AbortController();
|
|
42
|
+
(0, decode_image_js_1.decodeImage)({
|
|
43
|
+
resolvedSrc,
|
|
44
|
+
signal: controller.signal,
|
|
45
|
+
currentTime: currentTimeRef.current,
|
|
46
|
+
initialLoopBehavior,
|
|
47
|
+
})
|
|
48
|
+
.then((d) => {
|
|
49
|
+
setImageDecoder(d);
|
|
50
|
+
(0, delay_render_js_1.continueRender)(decodeHandle);
|
|
51
|
+
})
|
|
52
|
+
.catch((err) => {
|
|
53
|
+
if (err.name === 'AbortError') {
|
|
54
|
+
(0, delay_render_js_1.continueRender)(decodeHandle);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (onError) {
|
|
58
|
+
onError === null || onError === void 0 ? void 0 : onError(err);
|
|
59
|
+
(0, delay_render_js_1.continueRender)(decodeHandle);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
(0, cancel_render_js_1.cancelRender)(err);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
return () => {
|
|
66
|
+
controller.abort();
|
|
67
|
+
};
|
|
68
|
+
}, [resolvedSrc, decodeHandle, onError, initialLoopBehavior]);
|
|
69
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
70
|
+
if (!imageDecoder) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const delay = (0, delay_render_js_1.delayRender)(`Rendering frame at ${currentTime} of <AnimatedImage src="${src}"/>`);
|
|
74
|
+
imageDecoder
|
|
75
|
+
.getFrame(currentTime, loopBehavior)
|
|
76
|
+
.then((videoFrame) => {
|
|
77
|
+
var _a, _b;
|
|
78
|
+
if (mountState.current.isMounted) {
|
|
79
|
+
if (videoFrame === null) {
|
|
80
|
+
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.clear();
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
(_b = ref.current) === null || _b === void 0 ? void 0 : _b.draw(videoFrame.frame);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
(0, delay_render_js_1.continueRender)(delay);
|
|
87
|
+
})
|
|
88
|
+
.catch((err) => {
|
|
89
|
+
if (onError) {
|
|
90
|
+
onError(err);
|
|
91
|
+
(0, delay_render_js_1.continueRender)(delay);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
(0, cancel_render_js_1.cancelRender)(err);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}, [currentTime, imageDecoder, loopBehavior, onError, src]);
|
|
98
|
+
return ((0, jsx_runtime_1.jsx)(canvas_1.Canvas, { ref: ref, width: width, height: height, fit: fit, ...props }));
|
|
99
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { AnimatedImageFillMode } from './props';
|
|
3
|
+
type Props = {
|
|
4
|
+
readonly width?: number;
|
|
5
|
+
readonly height?: number;
|
|
6
|
+
readonly fit: AnimatedImageFillMode;
|
|
7
|
+
readonly className?: string;
|
|
8
|
+
readonly style?: React.CSSProperties;
|
|
9
|
+
};
|
|
10
|
+
export type AnimatedImageCanvasRef = {
|
|
11
|
+
readonly draw: (imageData: VideoFrame) => void;
|
|
12
|
+
readonly getCanvas: () => HTMLCanvasElement | null;
|
|
13
|
+
clear: () => void;
|
|
14
|
+
};
|
|
15
|
+
export declare const Canvas: React.ForwardRefExoticComponent<Props & React.RefAttributes<AnimatedImageCanvasRef>>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,122 @@
|
|
|
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.Canvas = void 0;
|
|
27
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
|
+
const calcArgs = (fit, frameSize, canvasSize) => {
|
|
30
|
+
switch (fit) {
|
|
31
|
+
case 'fill': {
|
|
32
|
+
return [
|
|
33
|
+
0,
|
|
34
|
+
0,
|
|
35
|
+
frameSize.width,
|
|
36
|
+
frameSize.height,
|
|
37
|
+
0,
|
|
38
|
+
0,
|
|
39
|
+
canvasSize.width,
|
|
40
|
+
canvasSize.height,
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
case 'contain': {
|
|
44
|
+
const ratio = Math.min(canvasSize.width / frameSize.width, canvasSize.height / frameSize.height);
|
|
45
|
+
const centerX = (canvasSize.width - frameSize.width * ratio) / 2;
|
|
46
|
+
const centerY = (canvasSize.height - frameSize.height * ratio) / 2;
|
|
47
|
+
return [
|
|
48
|
+
0,
|
|
49
|
+
0,
|
|
50
|
+
frameSize.width,
|
|
51
|
+
frameSize.height,
|
|
52
|
+
centerX,
|
|
53
|
+
centerY,
|
|
54
|
+
frameSize.width * ratio,
|
|
55
|
+
frameSize.height * ratio,
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
case 'cover': {
|
|
59
|
+
const ratio = Math.max(canvasSize.width / frameSize.width, canvasSize.height / frameSize.height);
|
|
60
|
+
const centerX = (canvasSize.width - frameSize.width * ratio) / 2;
|
|
61
|
+
const centerY = (canvasSize.height - frameSize.height * ratio) / 2;
|
|
62
|
+
return [
|
|
63
|
+
0,
|
|
64
|
+
0,
|
|
65
|
+
frameSize.width,
|
|
66
|
+
frameSize.height,
|
|
67
|
+
centerX,
|
|
68
|
+
centerY,
|
|
69
|
+
frameSize.width * ratio,
|
|
70
|
+
frameSize.height * ratio,
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
default:
|
|
74
|
+
throw new Error('Unknown fit: ' + fit);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const CanvasRefForwardingFunction = ({ width, height, fit, className, style }, ref) => {
|
|
78
|
+
const canvasRef = (0, react_1.useRef)(null);
|
|
79
|
+
const draw = (0, react_1.useCallback)((imageData) => {
|
|
80
|
+
var _a;
|
|
81
|
+
const canvas = canvasRef.current;
|
|
82
|
+
const canvasWidth = width !== null && width !== void 0 ? width : imageData.displayWidth;
|
|
83
|
+
const canvasHeight = height !== null && height !== void 0 ? height : imageData.displayHeight;
|
|
84
|
+
if (!canvas) {
|
|
85
|
+
throw new Error('Canvas ref is not set');
|
|
86
|
+
}
|
|
87
|
+
const ctx = (_a = canvasRef.current) === null || _a === void 0 ? void 0 : _a.getContext('2d');
|
|
88
|
+
if (!ctx) {
|
|
89
|
+
throw new Error('Could not get 2d context');
|
|
90
|
+
}
|
|
91
|
+
canvas.width = canvasWidth;
|
|
92
|
+
canvas.height = canvasHeight;
|
|
93
|
+
ctx.drawImage(imageData, ...calcArgs(fit, {
|
|
94
|
+
height: imageData.displayHeight,
|
|
95
|
+
width: imageData.displayWidth,
|
|
96
|
+
}, {
|
|
97
|
+
width: canvasWidth,
|
|
98
|
+
height: canvasHeight,
|
|
99
|
+
}));
|
|
100
|
+
}, [fit, height, width]);
|
|
101
|
+
(0, react_1.useImperativeHandle)(ref, () => {
|
|
102
|
+
return {
|
|
103
|
+
draw,
|
|
104
|
+
getCanvas: () => {
|
|
105
|
+
if (!canvasRef.current) {
|
|
106
|
+
throw new Error('Canvas ref is not set');
|
|
107
|
+
}
|
|
108
|
+
return canvasRef.current;
|
|
109
|
+
},
|
|
110
|
+
clear: () => {
|
|
111
|
+
var _a;
|
|
112
|
+
const ctx = (_a = canvasRef.current) === null || _a === void 0 ? void 0 : _a.getContext('2d');
|
|
113
|
+
if (!ctx) {
|
|
114
|
+
throw new Error('Could not get 2d context');
|
|
115
|
+
}
|
|
116
|
+
ctx.clearRect(0, 0, canvasRef.current.width, canvasRef.current.height);
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
}, [draw]);
|
|
120
|
+
return (0, jsx_runtime_1.jsx)("canvas", { ref: canvasRef, className: className, style: style });
|
|
121
|
+
};
|
|
122
|
+
exports.Canvas = react_1.default.forwardRef(CanvasRefForwardingFunction);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { RemotionAnimatedImageLoopBehavior } from './props';
|
|
2
|
+
export type AnimatedImageCacheItem = {
|
|
3
|
+
timeInSeconds: number;
|
|
4
|
+
frameIndex: number;
|
|
5
|
+
frame: VideoFrame | null;
|
|
6
|
+
};
|
|
7
|
+
export type RemotionImageDecoder = {
|
|
8
|
+
getFrame: (i: number, loopBehavior: RemotionAnimatedImageLoopBehavior) => Promise<AnimatedImageCacheItem | null>;
|
|
9
|
+
frameCount: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const decodeImage: ({ resolvedSrc, signal, currentTime, initialLoopBehavior, }: {
|
|
12
|
+
resolvedSrc: string;
|
|
13
|
+
signal: AbortSignal;
|
|
14
|
+
currentTime: number;
|
|
15
|
+
initialLoopBehavior: RemotionAnimatedImageLoopBehavior;
|
|
16
|
+
}) => Promise<RemotionImageDecoder>;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decodeImage = void 0;
|
|
4
|
+
const CACHE_SIZE = 5;
|
|
5
|
+
const getActualTime = ({ loopBehavior, durationFound, timeInSec, }) => {
|
|
6
|
+
return loopBehavior === 'loop'
|
|
7
|
+
? durationFound
|
|
8
|
+
? timeInSec % durationFound
|
|
9
|
+
: timeInSec
|
|
10
|
+
: Math.min(timeInSec, durationFound || Infinity);
|
|
11
|
+
};
|
|
12
|
+
const decodeImage = async ({ resolvedSrc, signal, currentTime, initialLoopBehavior, }) => {
|
|
13
|
+
if (typeof ImageDecoder === 'undefined') {
|
|
14
|
+
throw new Error('Your browser does not support the WebCodecs ImageDecoder API.');
|
|
15
|
+
}
|
|
16
|
+
const res = await fetch(resolvedSrc, { signal });
|
|
17
|
+
const { body } = res;
|
|
18
|
+
if (!body) {
|
|
19
|
+
throw new Error('Got no body');
|
|
20
|
+
}
|
|
21
|
+
const decoder = new ImageDecoder({
|
|
22
|
+
data: body,
|
|
23
|
+
type: res.headers.get('Content-Type') || 'image/gif',
|
|
24
|
+
});
|
|
25
|
+
await decoder.completed;
|
|
26
|
+
const { selectedTrack } = decoder.tracks;
|
|
27
|
+
if (!selectedTrack) {
|
|
28
|
+
throw new Error('No selected track');
|
|
29
|
+
}
|
|
30
|
+
const cache = [];
|
|
31
|
+
let durationFound = null;
|
|
32
|
+
const getFrameByIndex = async (frameIndex) => {
|
|
33
|
+
const foundInCache = cache.find((c) => c.frameIndex === frameIndex);
|
|
34
|
+
if (foundInCache && foundInCache.frame) {
|
|
35
|
+
return foundInCache;
|
|
36
|
+
}
|
|
37
|
+
const frame = await decoder.decode({
|
|
38
|
+
frameIndex,
|
|
39
|
+
completeFramesOnly: true,
|
|
40
|
+
});
|
|
41
|
+
if (foundInCache) {
|
|
42
|
+
foundInCache.frame = frame.image;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
cache.push({
|
|
46
|
+
frame: frame.image,
|
|
47
|
+
frameIndex,
|
|
48
|
+
timeInSeconds: frame.image.timestamp / 1000000,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
frame: frame.image,
|
|
53
|
+
frameIndex,
|
|
54
|
+
timeInSeconds: frame.image.timestamp / 1000000,
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
const clearCache = (closeToTimeInSec) => {
|
|
58
|
+
const itemsInCache = cache.filter((c) => c.frame);
|
|
59
|
+
const sortByClosestToCurrentTime = itemsInCache.sort((a, b) => {
|
|
60
|
+
const aDiff = Math.abs(a.timeInSeconds - closeToTimeInSec);
|
|
61
|
+
const bDiff = Math.abs(b.timeInSeconds - closeToTimeInSec);
|
|
62
|
+
return aDiff - bDiff;
|
|
63
|
+
});
|
|
64
|
+
for (let i = 0; i < sortByClosestToCurrentTime.length; i++) {
|
|
65
|
+
if (i < CACHE_SIZE) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
const item = sortByClosestToCurrentTime[i];
|
|
69
|
+
item.frame = null;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const ensureFrameBeforeAndAfter = async ({ timeInSec, loopBehavior, }) => {
|
|
73
|
+
const actualTimeInSec = getActualTime({
|
|
74
|
+
durationFound,
|
|
75
|
+
loopBehavior,
|
|
76
|
+
timeInSec,
|
|
77
|
+
});
|
|
78
|
+
const framesBefore = cache.filter((c) => c.timeInSeconds <= actualTimeInSec);
|
|
79
|
+
const biggestIndex = framesBefore
|
|
80
|
+
.map((c) => c.frameIndex)
|
|
81
|
+
.reduce((a, b) => Math.max(a, b), 0);
|
|
82
|
+
let i = biggestIndex;
|
|
83
|
+
while (true) {
|
|
84
|
+
const f = await getFrameByIndex(i);
|
|
85
|
+
i++;
|
|
86
|
+
if (!f.frame) {
|
|
87
|
+
throw new Error('No frame found');
|
|
88
|
+
}
|
|
89
|
+
if (!f.frame.duration) {
|
|
90
|
+
throw new Error('Frame has no duration');
|
|
91
|
+
}
|
|
92
|
+
if (i === selectedTrack.frameCount && durationFound === null) {
|
|
93
|
+
const duration = (f.frame.timestamp + f.frame.duration) / 1000000;
|
|
94
|
+
durationFound = duration;
|
|
95
|
+
}
|
|
96
|
+
if (f.timeInSeconds > actualTimeInSec || i === selectedTrack.frameCount) {
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// If close to end, also cache first frame for smooth wrap around
|
|
101
|
+
if (selectedTrack.frameCount - biggestIndex < 3 &&
|
|
102
|
+
loopBehavior === 'loop') {
|
|
103
|
+
await getFrameByIndex(0);
|
|
104
|
+
}
|
|
105
|
+
clearCache(actualTimeInSec);
|
|
106
|
+
};
|
|
107
|
+
// Twice because might be over total duration
|
|
108
|
+
await ensureFrameBeforeAndAfter({
|
|
109
|
+
timeInSec: currentTime,
|
|
110
|
+
loopBehavior: initialLoopBehavior,
|
|
111
|
+
});
|
|
112
|
+
await ensureFrameBeforeAndAfter({
|
|
113
|
+
timeInSec: currentTime,
|
|
114
|
+
loopBehavior: initialLoopBehavior,
|
|
115
|
+
});
|
|
116
|
+
const getFrame = async (timeInSec, loopBehavior) => {
|
|
117
|
+
if (durationFound !== null &&
|
|
118
|
+
timeInSec > durationFound &&
|
|
119
|
+
loopBehavior === 'clear-after-finish') {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
const actualTimeInSec = getActualTime({
|
|
123
|
+
loopBehavior,
|
|
124
|
+
durationFound,
|
|
125
|
+
timeInSec,
|
|
126
|
+
});
|
|
127
|
+
await ensureFrameBeforeAndAfter({ timeInSec: actualTimeInSec, loopBehavior });
|
|
128
|
+
const itemsInCache = cache.filter((c) => c.frame);
|
|
129
|
+
const closest = itemsInCache.reduce((a, b) => {
|
|
130
|
+
const aDiff = Math.abs(a.timeInSeconds - actualTimeInSec);
|
|
131
|
+
const bDiff = Math.abs(b.timeInSeconds - actualTimeInSec);
|
|
132
|
+
return aDiff < bDiff ? a : b;
|
|
133
|
+
});
|
|
134
|
+
if (!closest.frame) {
|
|
135
|
+
throw new Error('No frame found');
|
|
136
|
+
}
|
|
137
|
+
return closest;
|
|
138
|
+
};
|
|
139
|
+
return {
|
|
140
|
+
getFrame,
|
|
141
|
+
frameCount: selectedTrack.frameCount,
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
exports.decodeImage = decodeImage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AnimatedImage } from './AnimatedImage';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AnimatedImage = void 0;
|
|
4
|
+
var AnimatedImage_1 = require("./AnimatedImage");
|
|
5
|
+
Object.defineProperty(exports, "AnimatedImage", { enumerable: true, get: function () { return AnimatedImage_1.AnimatedImage; } });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type RemotionAnimatedImageLoopBehavior = 'loop' | 'pause-after-finish' | 'clear-after-finish';
|
|
2
|
+
export type RemotionAnimatedImageProps = {
|
|
3
|
+
src: string;
|
|
4
|
+
width?: number;
|
|
5
|
+
height?: number;
|
|
6
|
+
onError?: (error: Error) => void;
|
|
7
|
+
fit?: AnimatedImageFillMode;
|
|
8
|
+
playbackRate?: number;
|
|
9
|
+
style?: React.CSSProperties;
|
|
10
|
+
loopBehavior?: RemotionAnimatedImageLoopBehavior;
|
|
11
|
+
id?: string;
|
|
12
|
+
};
|
|
13
|
+
export type AnimatedImageFillMode = 'contain' | 'cover' | 'fill';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const resolveAnimatedImageSource: (src: string) => string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveAnimatedImageSource = void 0;
|
|
4
|
+
const resolveAnimatedImageSource = (src) => {
|
|
5
|
+
return new URL(src, typeof window === 'undefined' ? undefined : window.origin)
|
|
6
|
+
.href;
|
|
7
|
+
};
|
|
8
|
+
exports.resolveAnimatedImageSource = resolveAnimatedImageSource;
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -68,6 +68,7 @@ export type BundleState = {
|
|
|
68
68
|
compositionDefaultCodec: Codec;
|
|
69
69
|
};
|
|
70
70
|
export * from './AbsoluteFill.js';
|
|
71
|
+
export * from './animated-image/index.js';
|
|
71
72
|
export { Artifact } from './Artifact.js';
|
|
72
73
|
export * from './audio/index.js';
|
|
73
74
|
export { cancelRender } from './cancel-render.js';
|
package/dist/cjs/index.js
CHANGED
|
@@ -25,6 +25,7 @@ const Null_js_1 = require("./Null.js");
|
|
|
25
25
|
const Sequence_js_1 = require("./Sequence.js");
|
|
26
26
|
(0, multiple_versions_warning_js_1.checkMultipleRemotionVersions)();
|
|
27
27
|
__exportStar(require("./AbsoluteFill.js"), exports);
|
|
28
|
+
__exportStar(require("./animated-image/index.js"), exports);
|
|
28
29
|
var Artifact_js_1 = require("./Artifact.js");
|
|
29
30
|
Object.defineProperty(exports, "Artifact", { enumerable: true, get: function () { return Artifact_js_1.Artifact; } });
|
|
30
31
|
__exportStar(require("./audio/index.js"), exports);
|
package/dist/cjs/version.d.ts
CHANGED
package/dist/cjs/version.js
CHANGED