@libshub/gif-tools 1.0.0 → 1.0.1
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.
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type CSSProperties } from 'react';
|
|
2
|
+
import './GifPlayer.css';
|
|
3
|
+
export interface GifPlayerRef {
|
|
4
|
+
play: () => void;
|
|
5
|
+
pause: () => void;
|
|
6
|
+
toggle: () => void;
|
|
7
|
+
reset: () => void;
|
|
8
|
+
reload: () => void;
|
|
9
|
+
isPlaying: () => boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface GifPlayerProps {
|
|
12
|
+
src: string;
|
|
13
|
+
width?: number | string;
|
|
14
|
+
height?: number | string;
|
|
15
|
+
className?: string;
|
|
16
|
+
style?: CSSProperties;
|
|
17
|
+
autoPlay?: boolean;
|
|
18
|
+
showControls?: boolean;
|
|
19
|
+
debug?: boolean;
|
|
20
|
+
/** 未设置则无限循环;1 播放一次;N 播放 N 次后触发 onEnd */
|
|
21
|
+
loopCount?: number;
|
|
22
|
+
onPlay?: () => void;
|
|
23
|
+
onPause?: () => void;
|
|
24
|
+
onEnd?: () => void;
|
|
25
|
+
onLoaded?: (decodeTimeMs: number) => void;
|
|
26
|
+
onError?: (error: Error) => void;
|
|
27
|
+
}
|
|
28
|
+
export declare const GifPlayer: import("react").ForwardRefExoticComponent<GifPlayerProps & import("react").RefAttributes<GifPlayerRef>>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { LoadedGif } from './types';
|
|
2
|
+
interface LoadGifResourceOptions {
|
|
3
|
+
/** reload 等场景:不复用进行中的请求,直接发起新 fetch */
|
|
4
|
+
skipPending?: boolean;
|
|
5
|
+
}
|
|
6
|
+
interface LoadGifResult {
|
|
7
|
+
gif: LoadedGif;
|
|
8
|
+
decodeTimeMs: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function loadGifResource(src: string, options?: LoadGifResourceOptions): Promise<LoadGifResult>;
|
|
11
|
+
export declare function releaseGifResource(src: string): void;
|
|
12
|
+
export declare function clearGifResourceCache(): void;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ParsedFrame } from 'gifuct-js';
|
|
2
|
+
export interface LoadedGif {
|
|
3
|
+
frames: ParsedFrame[];
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}
|
|
7
|
+
export interface CreateGifOptions {
|
|
8
|
+
loopCount?: number;
|
|
9
|
+
onEnd?: () => void;
|
|
10
|
+
onPlay?: () => void;
|
|
11
|
+
onPause?: () => void;
|
|
12
|
+
onLoaded?: (decodeTimeMs: number) => void;
|
|
13
|
+
/** reload 等场景:不复用进行中的请求,直接发起新 fetch */
|
|
14
|
+
skipPending?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface GifController {
|
|
17
|
+
play: () => void;
|
|
18
|
+
pause: () => void;
|
|
19
|
+
reset: () => void;
|
|
20
|
+
destroy: () => void;
|
|
21
|
+
isPlaying: () => boolean;
|
|
22
|
+
getCompletedLoops: () => number;
|
|
23
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libshub/gif-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"module": "./dist/gif-tools.es.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"dev": "vite",
|
|
28
|
-
"build": "tsc -p tsconfig.lib.json
|
|
28
|
+
"build": "vite build && tsc -p tsconfig.lib.json",
|
|
29
29
|
"lint": "eslint .",
|
|
30
30
|
"preview": "vite preview"
|
|
31
31
|
},
|
|
@@ -52,4 +52,4 @@
|
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"gifuct-js": "^2.1.2"
|
|
54
54
|
}
|
|
55
|
-
}
|
|
55
|
+
}
|