@lazycatcloud/vue-media-preview 0.1.3 → 0.1.5
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/README.md +1 -0
- package/dist/components/MediaPreview.vue.d.ts +1 -1
- package/dist/components/video/VideoControls.vue.d.ts +3 -0
- package/dist/components/video/VideoQualityMenu.vue.d.ts +17 -0
- package/dist/core/resources/image/gif.d.ts +4 -0
- package/dist/core/resources/image/types.d.ts +16 -0
- package/dist/core/resources/imageResource.d.ts +3 -9
- package/dist/core/video/captureVideoFrame.d.ts +3 -1
- package/dist/core/video/frameTransition.d.ts +8 -0
- package/dist/core/video/source/types.d.ts +19 -1
- package/dist/index.d.ts +1 -0
- package/dist/renderers/ImageCanvasRenderer.vue.d.ts +4 -0
- package/dist/renderers/image/AnimatedImageLayer.vue.d.ts +17 -0
- package/dist/vue-media-preview.cjs +2 -2
- package/dist/vue-media-preview.css +1 -1
- package/dist/vue-media-preview.js +1711 -1476
- package/docs/testing.md +4 -0
- package/docs/vue-media-preview.md +20 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,6 +22,7 @@ Demo 内置 48 个日期分组条目,复用 16 份图片、视频和实况素
|
|
|
22
22
|
|
|
23
23
|
- **容器展开 / 共享元素转场**:图片从卡片的位置、裁切和圆角连续展开到完整预览;关闭时收回当前图片对应的卡片。
|
|
24
24
|
- **Canvas 图片**:当前画面优先,再预取邻页;下载可取消并有并发、流量和像素保护,原图状态以真实解码结果为准。
|
|
25
|
+
- **GIF 动画**:按文件头识别 GIF,在当前页使用原生图片层播放,沿用缩放、平移和旋转;切页与转场期间保留静态 Canvas,播放地址随缓存资源释放。
|
|
25
26
|
- **三页翻页轨道**:当前项及相邻两项,拖动跟手,松手根据距离和速度翻页或回弹,首尾有阻尼。
|
|
26
27
|
- **海量列表**:日期分组虚拟时间线、分页事件、按 ID 定位收回;列表追加/重排保留当前媒体,删除当前项切到邻项。
|
|
27
28
|
- **手势**:单击工具栏、双击缩放、双指缩放(适屏大小的 1–16 倍,越界阻尼与松手回弹)、放大后平移、越过水平边缘切页并同步缩回 1 倍、适配比例下拉关闭;图片和内联视频均支持缩放。
|
|
@@ -117,10 +117,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_WithDefaults<__VLS
|
|
|
117
117
|
kind: "unavailable";
|
|
118
118
|
};
|
|
119
119
|
}>>> & {
|
|
120
|
+
onChange?: ((index: number) => any) | undefined;
|
|
120
121
|
onError?: ((error: Error, media: PreviewMedia) => any) | undefined;
|
|
121
122
|
onReady?: ((index: number, quality: "full" | "thumbnail" | "screen") => any) | undefined;
|
|
122
123
|
onOriginalState?: ((media: PreviewMedia, status: OriginalStatus, reason: string) => any) | undefined;
|
|
123
|
-
onChange?: ((index: number) => any) | undefined;
|
|
124
124
|
onClose?: (() => any) | undefined;
|
|
125
125
|
onOpen?: ((index: number) => any) | undefined;
|
|
126
126
|
onClosing?: (() => any) | undefined;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import type { VideoQualityState } from "../../core/video/source/types";
|
|
1
2
|
import type { useVideoPlayback } from "../../core/video/useVideoPlayback";
|
|
2
3
|
type __VLS_Props = {
|
|
3
4
|
playback: ReturnType<typeof useVideoPlayback>;
|
|
4
5
|
fullscreen: boolean;
|
|
5
6
|
canFullscreen: boolean;
|
|
7
|
+
quality: VideoQualityState;
|
|
8
|
+
visible: boolean;
|
|
6
9
|
};
|
|
7
10
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_TypePropsToOption<__VLS_Props>, unknown, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
8
11
|
fullscreen: () => void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { VideoQualityState } from "../../core/video/source/types";
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
quality: Exclude<VideoQualityState, {
|
|
4
|
+
kind: "unavailable";
|
|
5
|
+
}>;
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_TypePropsToOption<__VLS_Props>, unknown, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<__VLS_Props>>>, {}, {}>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
10
|
+
type __VLS_TypePropsToOption<T> = {
|
|
11
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
12
|
+
type: import('vue').PropType<Required<T>[K]>;
|
|
13
|
+
} : {
|
|
14
|
+
type: import('vue').PropType<T[K]>;
|
|
15
|
+
required: true;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AnimatedImageResource } from "./types";
|
|
2
|
+
/** Asset URLs and response MIME types do not reliably identify the file format. */
|
|
3
|
+
export declare function isGif(signature: Uint8Array): boolean;
|
|
4
|
+
export declare function prepareGifResource(image: HTMLImageElement, blob: Blob, signal: AbortSignal): Promise<AnimatedImageResource>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Geometry and still pixels also serve snapshots and shared-element transitions. */
|
|
2
|
+
export interface StaticImageResource {
|
|
3
|
+
image: HTMLImageElement;
|
|
4
|
+
source: HTMLImageElement | ImageBitmap;
|
|
5
|
+
motionSource: HTMLImageElement | ImageBitmap;
|
|
6
|
+
bytes: number;
|
|
7
|
+
dispose: () => void;
|
|
8
|
+
}
|
|
9
|
+
export interface AnimatedImageResource extends StaticImageResource {
|
|
10
|
+
animation: {
|
|
11
|
+
kind: "gif";
|
|
12
|
+
url: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/** Custom static loaders keep their existing contract. */
|
|
16
|
+
export type ImageResource = StaticImageResource | AnimatedImageResource;
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
source: HTMLImageElement | ImageBitmap;
|
|
5
|
-
motionSource: HTMLImageElement | ImageBitmap;
|
|
6
|
-
bytes: number;
|
|
7
|
-
dispose: () => void;
|
|
8
|
-
}
|
|
9
|
-
export declare function imageElementResource(image: HTMLImageElement): ImageResource;
|
|
1
|
+
import type { ImageResource, StaticImageResource } from "./image/types";
|
|
2
|
+
export type { ImageResource } from "./image/types";
|
|
3
|
+
export declare function imageElementResource(image: HTMLImageElement): StaticImageResource;
|
|
10
4
|
/** Blob decoding avoids Chromium's scale-dependent lazy JPEG decode during drawImage. */
|
|
11
5
|
export declare function prepareImageResource(image: HTMLImageElement, blob: Blob, signal: AbortSignal): Promise<ImageResource>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { PreviewSize } from "../types";
|
|
2
|
-
/**
|
|
2
|
+
/** Copy object-fit:contain pixels without changing playback. */
|
|
3
|
+
export declare function drawVideoFrame(video: HTMLVideoElement, canvas: HTMLCanvasElement, size: PreviewSize): void;
|
|
4
|
+
/** Snapshot before pausing for the preview's closing transition. */
|
|
3
5
|
export declare function captureVideoFrame(video: HTMLVideoElement, size: PreviewSize): HTMLCanvasElement;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PreviewSize } from "../types";
|
|
2
|
+
/** Keep the last visible frame across source replacement, without pausing playback. */
|
|
3
|
+
export declare function createVideoFrameTransition(video: () => HTMLVideoElement, canvas: () => HTMLCanvasElement, size: () => PreviewSize): {
|
|
4
|
+
active: import("vue").Ref<boolean>;
|
|
5
|
+
run: (change: () => void) => void;
|
|
6
|
+
clear: () => void;
|
|
7
|
+
snapshot: () => HTMLCanvasElement;
|
|
8
|
+
};
|
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
import type { PreviewMedia } from "../../types";
|
|
2
|
+
export interface VideoQualityOption {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
}
|
|
6
|
+
/** Empty activeId means that the selected quality option has not taken effect yet. */
|
|
7
|
+
export type VideoQualityState = {
|
|
8
|
+
kind: "unavailable";
|
|
9
|
+
} | {
|
|
10
|
+
kind: "fixed";
|
|
11
|
+
label: string;
|
|
12
|
+
} | {
|
|
13
|
+
kind: "available";
|
|
14
|
+
options: readonly VideoQualityOption[];
|
|
15
|
+
selectedId: string;
|
|
16
|
+
activeId: string;
|
|
17
|
+
select: (id: string) => void;
|
|
18
|
+
};
|
|
2
19
|
/** Hosts own transport; the component owns playback and the effective timeline. */
|
|
3
|
-
export type VideoSourceLoader = (video: HTMLVideoElement, media: PreviewMedia, reportError: (error: Error) => void, reportDuration: (seconds: number) => void) => () => void;
|
|
20
|
+
export type VideoSourceLoader = (video: HTMLVideoElement, media: PreviewMedia, reportError: (error: Error) => void, reportDuration: (seconds: number) => void, reportQuality: (quality: VideoQualityState) => void) => () => void;
|
|
4
21
|
export interface VideoSourceObserver {
|
|
5
22
|
error: (error: Error) => void;
|
|
6
23
|
duration: (seconds: number) => void;
|
|
24
|
+
quality: (quality: VideoQualityState) => void;
|
|
7
25
|
reset: () => void;
|
|
8
26
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -17,3 +17,4 @@ export type { ImageResource } from "./core/resources/imageResource";
|
|
|
17
17
|
export type { TimelineGroup, VirtualTimelineHandle } from "./core/timeline/layout";
|
|
18
18
|
export { nativeVideoSource } from "./core/video/useVideoSource";
|
|
19
19
|
export type { VideoSourceLoader } from "./core/video/useVideoSource";
|
|
20
|
+
export type { VideoQualityOption, VideoQualityState } from "./core/video/source/types";
|
|
@@ -4,6 +4,7 @@ import type { RetainedPreviewFrame, PreviewMedia, PreviewViewportCore } from "..
|
|
|
4
4
|
type __VLS_Props = {
|
|
5
5
|
media: PreviewMedia;
|
|
6
6
|
core: PreviewViewportCore;
|
|
7
|
+
active?: boolean;
|
|
7
8
|
quality?: ImageQuality;
|
|
8
9
|
rendering?: boolean;
|
|
9
10
|
requestVersion?: number;
|
|
@@ -20,6 +21,7 @@ declare function captureFrame(): {
|
|
|
20
21
|
};
|
|
21
22
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<__VLS_Props>, {
|
|
22
23
|
quality: string;
|
|
24
|
+
active: boolean;
|
|
23
25
|
initialImage: () => InitialImage;
|
|
24
26
|
rendering: boolean;
|
|
25
27
|
loadEnabled: boolean;
|
|
@@ -37,6 +39,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_WithDefaults<__V
|
|
|
37
39
|
originalState: (status: OriginalStatus, reason: string) => void;
|
|
38
40
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<__VLS_Props>, {
|
|
39
41
|
quality: string;
|
|
42
|
+
active: boolean;
|
|
40
43
|
initialImage: () => InitialImage;
|
|
41
44
|
rendering: boolean;
|
|
42
45
|
loadEnabled: boolean;
|
|
@@ -50,6 +53,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_WithDefaults<__V
|
|
|
50
53
|
onReady?: ((quality: "full" | "thumbnail" | "screen") => any) | undefined;
|
|
51
54
|
onOriginalState?: ((status: OriginalStatus, reason: string) => any) | undefined;
|
|
52
55
|
}, {
|
|
56
|
+
active: boolean;
|
|
53
57
|
quality: ImageQuality;
|
|
54
58
|
rendering: boolean;
|
|
55
59
|
requestVersion: number;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PreviewViewportCore } from "../../core/types";
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
core: PreviewViewportCore;
|
|
4
|
+
src: string;
|
|
5
|
+
title: string;
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_TypePropsToOption<__VLS_Props>, unknown, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<__VLS_Props>>>, {}, {}>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
10
|
+
type __VLS_TypePropsToOption<T> = {
|
|
11
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
12
|
+
type: import('vue').PropType<Required<T>[K]>;
|
|
13
|
+
} : {
|
|
14
|
+
type: import('vue').PropType<T[K]>;
|
|
15
|
+
required: true;
|
|
16
|
+
};
|
|
17
|
+
};
|