@remotion/gif 3.3.10 → 3.3.12
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/Gif.d.ts
CHANGED
package/dist/parse-generate.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generate = exports.parse = void 0;
|
|
4
4
|
const gifuct_js_1 = require("gifuct-js");
|
|
5
|
+
const decompress_frames_1 = require("./parser/decompress-frames");
|
|
5
6
|
const validateAndFix = (gif) => {
|
|
6
7
|
let currentGce = null;
|
|
7
8
|
for (const frame of gif.frames) {
|
|
@@ -21,11 +22,12 @@ const parse = (src, { signal, }) => fetch(src, { signal })
|
|
|
21
22
|
})
|
|
22
23
|
.then((buffer) => (0, gifuct_js_1.parseGIF)(buffer))
|
|
23
24
|
.then((gif) => {
|
|
25
|
+
console.log({ gif });
|
|
24
26
|
validateAndFix(gif);
|
|
25
27
|
return gif;
|
|
26
28
|
})
|
|
27
29
|
.then((gif) => Promise.all([
|
|
28
|
-
(0,
|
|
30
|
+
(0, decompress_frames_1.decompressFrames)(gif),
|
|
29
31
|
{ width: gif.lsd.width, height: gif.lsd.height },
|
|
30
32
|
]))
|
|
31
33
|
.then(([frames, options]) => {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decompressFrames = void 0;
|
|
4
|
+
const gifuct_js_1 = require("gifuct-js");
|
|
5
|
+
const decompressFrames = (parsedGif) => {
|
|
6
|
+
return parsedGif.frames
|
|
7
|
+
.filter((f) => {
|
|
8
|
+
return !('application' in f);
|
|
9
|
+
})
|
|
10
|
+
.map((f) => {
|
|
11
|
+
return (0, gifuct_js_1.decompressFrame)(f, parsedGif.gct, false);
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
exports.decompressFrames = decompressFrames;
|
|
@@ -5,21 +5,23 @@ const react_1 = require("react");
|
|
|
5
5
|
const remotion_1 = require("remotion");
|
|
6
6
|
function useCurrentGifIndex(delays) {
|
|
7
7
|
const currentFrame = (0, remotion_1.useCurrentFrame)();
|
|
8
|
-
const videoConfig = remotion_1.
|
|
8
|
+
const videoConfig = (0, remotion_1.useVideoConfig)();
|
|
9
9
|
const duration = (0, react_1.useMemo)(() => {
|
|
10
10
|
if (delays.length !== 0) {
|
|
11
|
-
return delays.reduce((sum, delay) => sum + delay, 0);
|
|
11
|
+
return delays.reduce((sum, delay) => sum + (delay !== null && delay !== void 0 ? delay : 0), 0);
|
|
12
12
|
}
|
|
13
13
|
return 1;
|
|
14
14
|
}, [delays]);
|
|
15
15
|
const index = (0, react_1.useMemo)(() => {
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
if (delays.length === 0) {
|
|
17
|
+
return 0;
|
|
18
|
+
}
|
|
19
|
+
let currentTime = ((currentFrame / videoConfig.fps) * 1000) % duration;
|
|
20
|
+
for (const [i, delay] of delays.entries()) {
|
|
21
|
+
if (currentTime < delay) {
|
|
22
|
+
return i;
|
|
22
23
|
}
|
|
24
|
+
currentTime -= delay;
|
|
23
25
|
}
|
|
24
26
|
return 0;
|
|
25
27
|
}, [delays, duration, currentFrame, videoConfig]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/gif",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.12",
|
|
4
4
|
"description": "Gif component for remotion",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"repository": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"gifuct-js": "2.1.2",
|
|
25
25
|
"lru_map": "0.4.1",
|
|
26
|
-
"remotion": "3.3.
|
|
26
|
+
"remotion": "3.3.12"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@jonny/eslint-config": "3.0.266",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "0c7c54df00df527cd7e395658324102461883e87"
|
|
57
57
|
}
|