@remotion/gif 3.3.36 → 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 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
- if (remotion_1.Internals.getRemotionEnvironment() === 'rendering') {
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 = new URL(src, typeof window === 'undefined' ? undefined : window.location.origin).href;
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.gifCache.get(resolvedSrc);
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.gifCache.set(resolvedSrc, parsed);
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);
@@ -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 = new URL(src, window.location.origin).href;
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.gifCache.get(resolvedSrc);
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.gifCache.set(resolvedSrc, parsed);
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.gifCache.get(resolvedSrc);
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.gifCache.set(resolvedSrc, resolved);
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.gifCache.set(resolvedSrc, parsed);
27
+ gif_cache_1.volatileGifCache.set(resolvedSrc, parsed);
27
28
  return calcDuration(parsed);
28
29
  };
29
30
  exports.getGifDurationInSeconds = getGifDurationInSeconds;
@@ -1,3 +1,4 @@
1
1
  import { LRUMap } from 'lru_map';
2
2
  import type { GifState } from './props';
3
- export declare const gifCache: LRUMap<string, GifState>;
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.gifCache = void 0;
3
+ exports.manuallyManagedGifCache = exports.volatileGifCache = void 0;
4
4
  const lru_map_1 = require("lru_map");
5
- exports.gifCache = new lru_map_1.LRUMap(30);
5
+ exports.volatileGifCache = new lru_map_1.LRUMap(30);
6
+ exports.manuallyManagedGifCache = new Map();
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { getGifDurationInSeconds } from './get-gif-duration-in-seconds';
2
2
  export { Gif } from './Gif';
3
+ export { preloadGif } from './preload-gif';
3
4
  export { GifFillMode, RemotionGifProps } from './props';
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,4 @@
1
+ export declare const preloadGif: (src: string) => {
2
+ waitUntilDone: () => Promise<void>;
3
+ free: () => void;
4
+ };
@@ -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.36",
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.36"
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": "623bf1e883e7b26b9d02458037c930ccbe8857e4"
56
+ "gitHead": "ac58695e452e58deb5c010f09bcc94d036930e6c"
57
57
  }