@remotion/gif 3.3.37 → 3.3.38
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.js +2 -1
- package/dist/GifForDevelopment.js +5 -3
- package/dist/GifForRendering.js +4 -3
- package/dist/get-gif-duration-in-seconds.js +4 -3
- package/dist/gif-cache.d.ts +2 -1
- package/dist/gif-cache.js +3 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/preload-gif.d.ts +4 -0
- package/dist/preload-gif.js +37 -0
- package/dist/resolve-gif-source.d.ts +1 -0
- package/dist/resolve-gif-source.js +7 -0
- package/package.json +3 -3
- package/dist/ts-schema-binary-parser/index.d.ts +0 -4
- package/dist/ts-schema-binary-parser/index.js +0 -46
- package/dist/ts-schema-binary-parser/types.d.ts +0 -7
- package/dist/ts-schema-binary-parser/types.js +0 -2
package/dist/Gif.js
CHANGED
|
@@ -6,7 +6,8 @@ const remotion_1 = require("remotion");
|
|
|
6
6
|
const GifForDevelopment_1 = require("./GifForDevelopment");
|
|
7
7
|
const GifForRendering_1 = require("./GifForRendering");
|
|
8
8
|
const Gif = (props) => {
|
|
9
|
-
|
|
9
|
+
const env = remotion_1.Internals.useRemotionEnvironment();
|
|
10
|
+
if (env === 'rendering') {
|
|
10
11
|
return (0, jsx_runtime_1.jsx)(GifForRendering_1.GifForRendering, { ...props });
|
|
11
12
|
}
|
|
12
13
|
return (0, jsx_runtime_1.jsx)(GifForDevelopment_1.GifForDevelopment, { ...props });
|
|
@@ -8,11 +8,13 @@ const canvas_1 = require("./canvas");
|
|
|
8
8
|
const gif_cache_1 = require("./gif-cache");
|
|
9
9
|
const is_cors_error_1 = require("./is-cors-error");
|
|
10
10
|
const react_tools_1 = require("./react-tools");
|
|
11
|
+
const resolve_gif_source_1 = require("./resolve-gif-source");
|
|
11
12
|
const useCurrentGifIndex_1 = require("./useCurrentGifIndex");
|
|
12
13
|
exports.GifForDevelopment = (0, react_1.forwardRef)(({ src, width, height, onError, loopBehavior = 'loop', onLoad, fit = 'fill', ...props }, ref) => {
|
|
13
|
-
const resolvedSrc =
|
|
14
|
+
const resolvedSrc = (0, resolve_gif_source_1.resolveGifSource)(src);
|
|
14
15
|
const [state, update] = (0, react_1.useState)(() => {
|
|
15
|
-
|
|
16
|
+
var _a;
|
|
17
|
+
const parsedGif = (_a = gif_cache_1.volatileGifCache.get(resolvedSrc)) !== null && _a !== void 0 ? _a : gif_cache_1.manuallyManagedGifCache.get(resolvedSrc);
|
|
16
18
|
if (parsedGif === undefined) {
|
|
17
19
|
return {
|
|
18
20
|
delays: [],
|
|
@@ -39,7 +41,7 @@ exports.GifForDevelopment = (0, react_1.forwardRef)(({ src, width, height, onErr
|
|
|
39
41
|
var _a;
|
|
40
42
|
(_a = currentOnLoad.current) === null || _a === void 0 ? void 0 : _a.call(currentOnLoad, parsed);
|
|
41
43
|
update(parsed);
|
|
42
|
-
gif_cache_1.
|
|
44
|
+
gif_cache_1.volatileGifCache.set(resolvedSrc, parsed);
|
|
43
45
|
done = true;
|
|
44
46
|
(0, remotion_1.continueRender)(newHandle);
|
|
45
47
|
(0, remotion_1.continueRender)(id);
|
package/dist/GifForRendering.js
CHANGED
|
@@ -8,11 +8,12 @@ const canvas_1 = require("./canvas");
|
|
|
8
8
|
const gif_cache_1 = require("./gif-cache");
|
|
9
9
|
const is_cors_error_1 = require("./is-cors-error");
|
|
10
10
|
const react_tools_1 = require("./react-tools");
|
|
11
|
+
const resolve_gif_source_1 = require("./resolve-gif-source");
|
|
11
12
|
const useCurrentGifIndex_1 = require("./useCurrentGifIndex");
|
|
12
13
|
exports.GifForRendering = (0, react_1.forwardRef)(({ src, width, height, onLoad, onError, loopBehavior = 'loop', fit = 'fill', ...props }, ref) => {
|
|
13
|
-
const resolvedSrc =
|
|
14
|
+
const resolvedSrc = (0, resolve_gif_source_1.resolveGifSource)(src);
|
|
14
15
|
const [state, update] = (0, react_1.useState)(() => {
|
|
15
|
-
const parsedGif = gif_cache_1.
|
|
16
|
+
const parsedGif = gif_cache_1.volatileGifCache.get(resolvedSrc);
|
|
16
17
|
if (parsedGif === undefined) {
|
|
17
18
|
return {
|
|
18
19
|
delays: [],
|
|
@@ -40,7 +41,7 @@ exports.GifForRendering = (0, react_1.forwardRef)(({ src, width, height, onLoad,
|
|
|
40
41
|
var _a;
|
|
41
42
|
(_a = currentOnLoad.current) === null || _a === void 0 ? void 0 : _a.call(currentOnLoad, parsed);
|
|
42
43
|
update(parsed);
|
|
43
|
-
gif_cache_1.
|
|
44
|
+
gif_cache_1.volatileGifCache.set(resolvedSrc, parsed);
|
|
44
45
|
done = true;
|
|
45
46
|
(0, remotion_1.continueRender)(newHandle);
|
|
46
47
|
(0, remotion_1.continueRender)(id);
|
|
@@ -8,22 +8,23 @@ const calcDuration = (parsed) => {
|
|
|
8
8
|
return (parsed.delays.reduce((sum, delay) => sum + delay, 0) / 1000);
|
|
9
9
|
};
|
|
10
10
|
const getGifDurationInSeconds = async (src) => {
|
|
11
|
+
var _a;
|
|
11
12
|
const resolvedSrc = new URL(src, window.location.origin).href;
|
|
12
|
-
const inCache = gif_cache_1.
|
|
13
|
+
const inCache = (_a = gif_cache_1.volatileGifCache.get(resolvedSrc)) !== null && _a !== void 0 ? _a : gif_cache_1.manuallyManagedGifCache.get(resolvedSrc);
|
|
13
14
|
if (inCache) {
|
|
14
15
|
return calcDuration(inCache);
|
|
15
16
|
}
|
|
16
17
|
if (remotion_1.Internals.getRemotionEnvironment() === 'rendering') {
|
|
17
18
|
const renderingParsed = (0, react_tools_1.parseWithWorker)(resolvedSrc);
|
|
18
19
|
const resolved = await renderingParsed.prom;
|
|
19
|
-
gif_cache_1.
|
|
20
|
+
gif_cache_1.volatileGifCache.set(resolvedSrc, resolved);
|
|
20
21
|
return calcDuration(resolved);
|
|
21
22
|
}
|
|
22
23
|
const parsed = await (0, react_tools_1.parseGif)({
|
|
23
24
|
src: resolvedSrc,
|
|
24
25
|
controller: new AbortController(),
|
|
25
26
|
});
|
|
26
|
-
gif_cache_1.
|
|
27
|
+
gif_cache_1.volatileGifCache.set(resolvedSrc, parsed);
|
|
27
28
|
return calcDuration(parsed);
|
|
28
29
|
};
|
|
29
30
|
exports.getGifDurationInSeconds = getGifDurationInSeconds;
|
package/dist/gif-cache.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { LRUMap } from 'lru_map';
|
|
2
2
|
import type { GifState } from './props';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const volatileGifCache: LRUMap<string, GifState>;
|
|
4
|
+
export declare const manuallyManagedGifCache: Map<string, GifState>;
|
package/dist/gif-cache.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.manuallyManagedGifCache = exports.volatileGifCache = void 0;
|
|
4
4
|
const lru_map_1 = require("lru_map");
|
|
5
|
-
exports.
|
|
5
|
+
exports.volatileGifCache = new lru_map_1.LRUMap(30);
|
|
6
|
+
exports.manuallyManagedGifCache = new Map();
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Gif = exports.getGifDurationInSeconds = void 0;
|
|
3
|
+
exports.preloadGif = exports.Gif = exports.getGifDurationInSeconds = void 0;
|
|
4
4
|
var get_gif_duration_in_seconds_1 = require("./get-gif-duration-in-seconds");
|
|
5
5
|
Object.defineProperty(exports, "getGifDurationInSeconds", { enumerable: true, get: function () { return get_gif_duration_in_seconds_1.getGifDurationInSeconds; } });
|
|
6
6
|
var Gif_1 = require("./Gif");
|
|
7
7
|
Object.defineProperty(exports, "Gif", { enumerable: true, get: function () { return Gif_1.Gif; } });
|
|
8
|
+
var preload_gif_1 = require("./preload-gif");
|
|
9
|
+
Object.defineProperty(exports, "preloadGif", { enumerable: true, get: function () { return preload_gif_1.preloadGif; } });
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.preloadGif = void 0;
|
|
4
|
+
const gif_cache_1 = require("./gif-cache");
|
|
5
|
+
const react_tools_1 = require("./react-tools");
|
|
6
|
+
const resolve_gif_source_1 = require("./resolve-gif-source");
|
|
7
|
+
const preloadGif = (src) => {
|
|
8
|
+
const resolvedSrc = (0, resolve_gif_source_1.resolveGifSource)(src);
|
|
9
|
+
if (gif_cache_1.volatileGifCache.has(resolvedSrc)) {
|
|
10
|
+
return {
|
|
11
|
+
waitUntilDone: () => Promise.resolve(),
|
|
12
|
+
free: () => gif_cache_1.volatileGifCache.delete(resolvedSrc),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
if (gif_cache_1.manuallyManagedGifCache.has(resolvedSrc)) {
|
|
16
|
+
return {
|
|
17
|
+
waitUntilDone: () => Promise.resolve(),
|
|
18
|
+
free: () => gif_cache_1.manuallyManagedGifCache.delete(resolvedSrc),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const { prom, cancel } = (0, react_tools_1.parseWithWorker)(resolvedSrc);
|
|
22
|
+
let deleted = false;
|
|
23
|
+
prom.then((p) => {
|
|
24
|
+
if (!deleted) {
|
|
25
|
+
gif_cache_1.manuallyManagedGifCache.set(resolvedSrc, p);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
waitUntilDone: () => prom.then(() => undefined),
|
|
30
|
+
free: () => {
|
|
31
|
+
cancel();
|
|
32
|
+
deleted = true;
|
|
33
|
+
gif_cache_1.manuallyManagedGifCache.delete(resolvedSrc);
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
exports.preloadGif = preloadGif;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const resolveGifSource: (src: string) => string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveGifSource = void 0;
|
|
4
|
+
const resolveGifSource = (src) => {
|
|
5
|
+
return new URL(src, typeof window === 'undefined' ? undefined : window.location.origin).href;
|
|
6
|
+
};
|
|
7
|
+
exports.resolveGifSource = resolveGifSource;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/gif",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.38",
|
|
4
4
|
"description": "Gif component for remotion",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"repository": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"js-binary-schema-parser": "^2.0.3",
|
|
25
25
|
"lru_map": "0.4.1",
|
|
26
|
-
"remotion": "3.3.
|
|
26
|
+
"remotion": "3.3.38"
|
|
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": "ac58695e452e58deb5c010f09bcc94d036930e6c"
|
|
57
57
|
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { CondFunction, ParseFun, Result, Stream } from './types';
|
|
2
|
-
export declare const parse: (stream: Stream, schema: any, result?: Result, parent?: Result) => Result;
|
|
3
|
-
export declare const conditional: (schema: any, conditionFunc: CondFunction) => (stream: any, result: Result, parent: Result, _parse: ParseFun) => void;
|
|
4
|
-
export declare const loop: (schema: any, continueFunc: any) => (stream: any, result: any, parent: any, parse: any) => {}[];
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loop = exports.conditional = exports.parse = void 0;
|
|
4
|
-
const parse = (stream, schema, result = {}, parent = result) => {
|
|
5
|
-
if (Array.isArray(schema)) {
|
|
6
|
-
schema.forEach((partSchema) => (0, exports.parse)(stream, partSchema, result, parent));
|
|
7
|
-
}
|
|
8
|
-
else if (typeof schema === 'function') {
|
|
9
|
-
schema(stream, result, parent, exports.parse);
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
const key = Object.keys(schema)[0];
|
|
13
|
-
if (Array.isArray(schema[key])) {
|
|
14
|
-
parent[key] = {};
|
|
15
|
-
(0, exports.parse)(stream, schema[key], result, parent[key]);
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
parent[key] = schema[key](stream, result, parent, exports.parse);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return result;
|
|
22
|
-
};
|
|
23
|
-
exports.parse = parse;
|
|
24
|
-
const conditional = (schema, conditionFunc) => (stream, result, parent, _parse) => {
|
|
25
|
-
if (conditionFunc(stream, result, parent)) {
|
|
26
|
-
_parse(stream, schema, result, parent);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
exports.conditional = conditional;
|
|
30
|
-
const loop = (schema, continueFunc) => (stream, result, parent, parse) => {
|
|
31
|
-
const arr = [];
|
|
32
|
-
let lastStreamPos = stream.pos;
|
|
33
|
-
while (continueFunc(stream, result, parent)) {
|
|
34
|
-
const newParent = {};
|
|
35
|
-
parse(stream, schema, result, newParent);
|
|
36
|
-
// cases when whole file is parsed but no termination is there and stream position is not getting updated as well
|
|
37
|
-
// it falls into infinite recursion, null check to avoid the same
|
|
38
|
-
if (stream.pos === lastStreamPos) {
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
lastStreamPos = stream.pos;
|
|
42
|
-
arr.push(newParent);
|
|
43
|
-
}
|
|
44
|
-
return arr;
|
|
45
|
-
};
|
|
46
|
-
exports.loop = loop;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare type Schema = SchemaFun | Schema[] | SchemaFun[] | Record<string, Schema>;
|
|
2
|
-
export declare type Stream = unknown;
|
|
3
|
-
export declare type Result = Record<string, unknown>;
|
|
4
|
-
export declare type CondFunction = (a: Stream, b: Result, c: unknown) => boolean;
|
|
5
|
-
export declare type ParseFun = (a: Stream, b: Schema, c: Result | undefined, d: Result | undefined) => Result;
|
|
6
|
-
declare type SchemaFun = (stream: Stream, res: Result, parent: Result | undefined, parseFn: ParseFun) => void;
|
|
7
|
-
export {};
|