@remotion/gif 3.2.22 → 3.2.24

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
@@ -1,2 +1,3 @@
1
+ /// <reference types="react" />
1
2
  import type { RemotionGifProps } from './props';
2
3
  export declare const Gif: (props: RemotionGifProps) => JSX.Element;
@@ -31,6 +31,7 @@ exports.GifForDevelopment = (0, react_1.forwardRef)(({ src, width, height, onErr
31
31
  currentOnError.current = onError;
32
32
  (0, react_1.useEffect)(() => {
33
33
  let done = false;
34
+ let aborted = false;
34
35
  const { prom, cancel } = (0, react_tools_1.parseWithWorker)(resolvedSrc);
35
36
  const newHandle = (0, remotion_1.delayRender)('Loading <Gif /> with src=' + resolvedSrc);
36
37
  prom
@@ -44,6 +45,10 @@ exports.GifForDevelopment = (0, react_1.forwardRef)(({ src, width, height, onErr
44
45
  (0, remotion_1.continueRender)(id);
45
46
  })
46
47
  .catch((err) => {
48
+ if (aborted) {
49
+ (0, remotion_1.continueRender)(newHandle);
50
+ return;
51
+ }
47
52
  if (currentOnError.current) {
48
53
  currentOnError.current(err);
49
54
  }
@@ -53,6 +58,7 @@ exports.GifForDevelopment = (0, react_1.forwardRef)(({ src, width, height, onErr
53
58
  });
54
59
  return () => {
55
60
  if (!done) {
61
+ aborted = true;
56
62
  cancel();
57
63
  }
58
64
  (0, remotion_1.continueRender)(newHandle);
@@ -63,7 +69,7 @@ exports.GifForDevelopment = (0, react_1.forwardRef)(({ src, width, height, onErr
63
69
  if ((0, is_cors_error_1.isCorsError)(error)) {
64
70
  throw new Error(`Failed to render GIF with source ${src}: "${error.message}". You must enable CORS for this URL.`);
65
71
  }
66
- throw new Error(`Failed to render GIF with source ${src}: "${error.message}". Render with --log=verbose to see the full stack.`);
72
+ throw new Error(`Failed to render GIF with source ${src}: "${error.message}".`);
67
73
  }
68
74
  const index = (0, useCurrentGifIndex_1.useCurrentGifIndex)(state.delays);
69
75
  return ((0, jsx_runtime_1.jsx)(canvas_1.Canvas, { fit: fit, index: index, frames: state.frames, width: width, height: height, ...props, ref: ref }));
@@ -33,6 +33,7 @@ exports.GifForRendering = (0, react_1.forwardRef)(({ src, width, height, onLoad,
33
33
  (0, react_1.useEffect)(() => {
34
34
  const controller = new AbortController();
35
35
  let done = false;
36
+ let aborted = false;
36
37
  const newHandle = (0, remotion_1.delayRender)('Loading <Gif /> with src=' + resolvedSrc);
37
38
  (0, react_tools_1.parseGif)({ controller, src: resolvedSrc })
38
39
  .then((parsed) => {
@@ -45,6 +46,10 @@ exports.GifForRendering = (0, react_1.forwardRef)(({ src, width, height, onLoad,
45
46
  (0, remotion_1.continueRender)(id);
46
47
  })
47
48
  .catch((err) => {
49
+ if (aborted) {
50
+ (0, remotion_1.continueRender)(newHandle);
51
+ return;
52
+ }
48
53
  if (currentOnError.current) {
49
54
  currentOnError.current(err);
50
55
  }
@@ -54,6 +59,7 @@ exports.GifForRendering = (0, react_1.forwardRef)(({ src, width, height, onLoad,
54
59
  });
55
60
  return () => {
56
61
  if (!done) {
62
+ aborted = true;
57
63
  controller.abort();
58
64
  }
59
65
  (0, remotion_1.continueRender)(newHandle);
package/dist/canvas.js CHANGED
@@ -67,7 +67,7 @@ exports.Canvas = (0, react_1.forwardRef)(({ index, frames, width, height, fit, c
67
67
  const size = (0, use_element_size_1.useElementSize)(canvasRef);
68
68
  (0, react_1.useImperativeHandle)(ref, () => {
69
69
  return canvasRef.current;
70
- });
70
+ }, []);
71
71
  (0, react_1.useEffect)(() => {
72
72
  var _a;
73
73
  if (!size) {
@@ -8,11 +8,8 @@ const parseGif = async ({ src, controller, }) => {
8
8
  return (0, parse_generate_1.generate)(raw);
9
9
  };
10
10
  exports.parseGif = parseGif;
11
- let worker = null;
12
11
  const parseWithWorker = (src) => {
13
- if (!worker) {
14
- worker = (0, worker_1.makeWorker)();
15
- }
12
+ const worker = (0, worker_1.makeWorker)();
16
13
  let handler = null;
17
14
  const prom = new Promise((resolve, reject) => {
18
15
  handler = (e) => {
@@ -35,6 +32,7 @@ const parseWithWorker = (src) => {
35
32
  cancel: () => {
36
33
  worker.postMessage({ src, type: 'cancel' });
37
34
  worker.removeEventListener('message', handler);
35
+ worker.terminate();
38
36
  },
39
37
  };
40
38
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/gif",
3
- "version": "3.2.22",
3
+ "version": "3.2.24",
4
4
  "description": "Gif component for remotion",
5
5
  "sideEffects": false,
6
6
  "repository": {
@@ -21,8 +21,9 @@
21
21
  "watch": "tsc -w"
22
22
  },
23
23
  "dependencies": {
24
+ "gifuct-js": "2.1.2",
24
25
  "lru_map": "0.4.1",
25
- "remotion": "3.2.22"
26
+ "remotion": "3.2.24"
26
27
  },
27
28
  "devDependencies": {
28
29
  "@jonny/eslint-config": "3.0.266",
@@ -30,14 +31,13 @@
30
31
  "@types/react": "18.0.1",
31
32
  "@types/react-dom": "18.0.0",
32
33
  "eslint": "8.13.0",
33
- "gifuct-js": "2.1.2",
34
34
  "jest": "^27.2.4",
35
35
  "prettier": "2.6.2",
36
36
  "prettier-plugin-organize-imports": "^2.3.4",
37
37
  "react": "18.0.0",
38
38
  "react-dom": "18.0.0",
39
39
  "typescript": "^4.7.0",
40
- "webpack": "5.72.0"
40
+ "webpack": "5.74.0"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "react": ">=16.8.0",
@@ -54,5 +54,5 @@
54
54
  "publishConfig": {
55
55
  "access": "public"
56
56
  },
57
- "gitHead": "1c35638566717760bb394e0748b088cea15faff4"
57
+ "gitHead": "1f11ef8d122eadb6d6f6aa0570ffc4936d43a886"
58
58
  }
@@ -1 +0,0 @@
1
- export declare const getGifDurationInSeconds: (src: string) => Promise<number>;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getGifDurationInSeconds = void 0;
4
- const remotion_1 = require("remotion");
5
- const react_tools_1 = require("./react-tools");
6
- const getGifDurationInSeconds = async (src) => {
7
- const resolvedSrc = new URL(src, window.location.origin).href;
8
- if (remotion_1.Internals.getRemotionEnvironment() === 'rendering') {
9
- const renderingParsed = (0, react_tools_1.parseWithWorker)(resolvedSrc);
10
- return ((await renderingParsed.prom).delays.reduce((sum, delay) => sum + delay, 0) / 1000);
11
- }
12
- const parsed = await (0, react_tools_1.parseGif)({
13
- src: resolvedSrc,
14
- controller: new AbortController(),
15
- });
16
- return (parsed.delays.reduce((sum, delay) => sum + delay, 0) / 1000);
17
- };
18
- exports.getGifDurationInSeconds = getGifDurationInSeconds;