@jacktea/img-viewer 0.1.3
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/LICENSE +25 -0
- package/README.md +42 -0
- package/THIRD_PARTY_NOTICES.md +44 -0
- package/dist/components/file-info.d.ts +28 -0
- package/dist/components/file-info.d.ts.map +1 -0
- package/dist/components/magnifier.d.ts +31 -0
- package/dist/components/magnifier.d.ts.map +1 -0
- package/dist/components/toolbar.d.ts +60 -0
- package/dist/components/toolbar.d.ts.map +1 -0
- package/dist/components/viewer-carousel.d.ts +43 -0
- package/dist/components/viewer-carousel.d.ts.map +1 -0
- package/dist/components/viewer-gallery.d.ts +27 -0
- package/dist/components/viewer-gallery.d.ts.map +1 -0
- package/dist/components/viewer-single.d.ts +36 -0
- package/dist/components/viewer-single.d.ts.map +1 -0
- package/dist/components/viewer-slideshow.d.ts +28 -0
- package/dist/components/viewer-slideshow.d.ts.map +1 -0
- package/dist/core/format-converter.d.ts +29 -0
- package/dist/core/format-converter.d.ts.map +1 -0
- package/dist/core/image-loader.d.ts +42 -0
- package/dist/core/image-loader.d.ts.map +1 -0
- package/dist/core/native-wasm-codecs.d.ts +25 -0
- package/dist/core/native-wasm-codecs.d.ts.map +1 -0
- package/dist/core/progressive-loader.d.ts +22 -0
- package/dist/core/progressive-loader.d.ts.map +1 -0
- package/dist/core/transform.d.ts +52 -0
- package/dist/core/transform.d.ts.map +1 -0
- package/dist/i18n.d.ts +49 -0
- package/dist/i18n.d.ts.map +1 -0
- package/dist/img-viewer.d.ts +107 -0
- package/dist/img-viewer.d.ts.map +1 -0
- package/dist/img-viewer.js +1547 -0
- package/dist/img-viewer.umd.cjs +40 -0
- package/dist/index-CMLQoJq1.js +1733 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/types.d.ts +153 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +30 -0
- package/third_party/licenses/libde265-LGPL-3.0-or-later.txt +871 -0
- package/third_party/licenses/libheif-LGPL-3.0-or-later.txt +871 -0
- package/third_party/licenses/libraw-CDDL-1.0.txt +340 -0
- package/third_party/licenses/libraw-LGPL-2.1.txt +458 -0
- package/third_party/licenses/libtiff-license.txt +23 -0
- package/third_party/licenses/zlib-license.txt +22 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jacktea/img-viewer - 图片预览组件
|
|
3
|
+
*
|
|
4
|
+
* 支持多种预览模式,本地/远程文件加载,格式自动转换
|
|
5
|
+
*/
|
|
6
|
+
export { ImgViewerElement } from './img-viewer';
|
|
7
|
+
export { configureNativeWasm, getNativeWasmOptions, resetNativeWasmOptions, type NativeWasmCodec, type NativeWasmOptions, } from './core/native-wasm-codecs';
|
|
8
|
+
export type { ImageSource, ViewMode, ViewerConfig, TransformState, MagnifierConfig, LoadedImage, LoadingState, ViewerEventMap, ToolbarConfig, ToolbarItem, ToolbarPosition, ToolbarMode, DecoderType, DecoderConfig, } from './types';
|
|
9
|
+
export { DEFAULT_CONFIG, DEFAULT_TRANSFORM, NATIVE_IMAGE_TYPES } from './types';
|
|
10
|
+
export type { ThemeName } from './types';
|
|
11
|
+
export type { I18nMessages, LocaleName } from './i18n';
|
|
12
|
+
export { getMessages, registerLocale } from './i18n';
|
|
13
|
+
import { ImgViewerElement } from './img-viewer';
|
|
14
|
+
/**
|
|
15
|
+
* 手动注册自定义元素(使用自定义标签名)
|
|
16
|
+
*/
|
|
17
|
+
export declare function defineImgViewer(tagName?: string): void;
|
|
18
|
+
declare global {
|
|
19
|
+
interface HTMLElementTagNameMap {
|
|
20
|
+
'img-viewer': ImgViewerElement;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,KAAK,eAAe,EACpB,KAAK,iBAAiB,GACvB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,eAAe,EACf,WAAW,EACX,YAAY,EACZ,cAAc,EACd,aAAa,EACb,WAAW,EACX,eAAe,EACf,WAAW,EACX,WAAW,EACX,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAGhF,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGzC,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAGrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAMhD;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,MAAqB,GAAG,IAAI,CAIpE;AAGD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,YAAY,EAAE,gBAAgB,CAAC;KAChC;CACF"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jacktea/img-viewer - 图片预览组件类型定义
|
|
3
|
+
*/
|
|
4
|
+
import type { LocaleName } from './i18n';
|
|
5
|
+
/** 主题名 */
|
|
6
|
+
export type ThemeName = 'dark' | 'light' | 'auto';
|
|
7
|
+
/** 图片来源 */
|
|
8
|
+
export interface ImageSource {
|
|
9
|
+
/** 来源类型 */
|
|
10
|
+
type: 'file' | 'url' | 'base64';
|
|
11
|
+
/**
|
|
12
|
+
* 数据:
|
|
13
|
+
* - file: File 对象
|
|
14
|
+
* - url: 图片 URL 字符串
|
|
15
|
+
* - base64: base64 编码字符串
|
|
16
|
+
*/
|
|
17
|
+
data: File | string;
|
|
18
|
+
/** 可选的文件名 */
|
|
19
|
+
name?: string;
|
|
20
|
+
/** 可选的 MIME 类型 */
|
|
21
|
+
mimeType?: string;
|
|
22
|
+
}
|
|
23
|
+
/** 预览模式 */
|
|
24
|
+
export type ViewMode = 'single' | 'carousel' | 'slideshow' | 'gallery';
|
|
25
|
+
/** 原生 wasm 解码模式 */
|
|
26
|
+
export type DecoderType = 'auto' | 'rgba8' | 'rgba16';
|
|
27
|
+
/** 解码配置 */
|
|
28
|
+
export interface DecoderConfig {
|
|
29
|
+
/**
|
|
30
|
+
* 解码模式:
|
|
31
|
+
* - auto: 使用 rgba8 解码
|
|
32
|
+
* - rgba8: 强制 8-bit 解码
|
|
33
|
+
* - rgba16: 优先 16-bit 解码
|
|
34
|
+
*/
|
|
35
|
+
type: DecoderType;
|
|
36
|
+
/**
|
|
37
|
+
* 当 type='rgba16' 且 16-bit 解码失败时,是否回退到 rgba8。
|
|
38
|
+
* 默认 true。
|
|
39
|
+
*/
|
|
40
|
+
fallbackToRgba8: boolean;
|
|
41
|
+
}
|
|
42
|
+
/** 变换状态 */
|
|
43
|
+
export interface TransformState {
|
|
44
|
+
/** 旋转角度 (0, 90, 180, 270) */
|
|
45
|
+
rotation: number;
|
|
46
|
+
/** 水平翻转 */
|
|
47
|
+
flipX: boolean;
|
|
48
|
+
/** 垂直翻转 */
|
|
49
|
+
flipY: boolean;
|
|
50
|
+
/** 缩放比例 */
|
|
51
|
+
scale: number;
|
|
52
|
+
/** X 轴偏移 */
|
|
53
|
+
offsetX: number;
|
|
54
|
+
/** Y 轴偏移 */
|
|
55
|
+
offsetY: number;
|
|
56
|
+
}
|
|
57
|
+
/** 放大镜配置 */
|
|
58
|
+
export interface MagnifierConfig {
|
|
59
|
+
/** 是否启用 */
|
|
60
|
+
enabled: boolean;
|
|
61
|
+
/** 放大倍率,默认 2 */
|
|
62
|
+
zoom: number;
|
|
63
|
+
/** 镜片半径(px),默认 80 */
|
|
64
|
+
radius: number;
|
|
65
|
+
}
|
|
66
|
+
/** 工具栏按钮项 */
|
|
67
|
+
export type ToolbarItem = 'rotateLeft' | 'rotateRight' | 'flipX' | 'flipY' | 'zoomIn' | 'zoomOut' | 'reset' | 'prev' | 'next' | 'fullscreen' | 'download' | 'magnifier' | 'info' | 'mode';
|
|
68
|
+
/** 工具栏位置 */
|
|
69
|
+
export type ToolbarPosition = 'top' | 'bottom';
|
|
70
|
+
/** 工具栏显示模式 */
|
|
71
|
+
export type ToolbarMode = 'fixed' | 'float';
|
|
72
|
+
/** 工具栏配置 */
|
|
73
|
+
export interface ToolbarConfig {
|
|
74
|
+
items: ToolbarItem[];
|
|
75
|
+
/** 工具栏位置,默认 'bottom' */
|
|
76
|
+
position?: ToolbarPosition;
|
|
77
|
+
/** 工具栏显示模式,默认 'fixed' */
|
|
78
|
+
mode?: ToolbarMode;
|
|
79
|
+
}
|
|
80
|
+
/** 查看器配置 */
|
|
81
|
+
export interface ViewerConfig {
|
|
82
|
+
/** 预览模式,默认 'single' */
|
|
83
|
+
mode: ViewMode;
|
|
84
|
+
/** 只读模式(禁止复制、下载),默认 false */
|
|
85
|
+
readonly: boolean;
|
|
86
|
+
/** 放大镜配置 */
|
|
87
|
+
magnifier: MagnifierConfig;
|
|
88
|
+
/** 幻灯片/轮播自动播放,默认 false */
|
|
89
|
+
autoPlay: boolean;
|
|
90
|
+
/** 自动播放间隔(ms),默认 3000 */
|
|
91
|
+
interval: number;
|
|
92
|
+
/** 是否显示工具栏,默认 true */
|
|
93
|
+
showToolbar: boolean;
|
|
94
|
+
/** 工具栏配置 */
|
|
95
|
+
toolbar: ToolbarConfig;
|
|
96
|
+
/** 是否启用渐进式加载,默认 true */
|
|
97
|
+
progressiveLoading: boolean;
|
|
98
|
+
/** 渐进式加载阈值(字节),默认 1MB */
|
|
99
|
+
progressiveThreshold: number;
|
|
100
|
+
/** 主题,默认 'dark' */
|
|
101
|
+
theme: ThemeName;
|
|
102
|
+
/** 语言,默认 'zh-CN' */
|
|
103
|
+
locale: LocaleName | string;
|
|
104
|
+
/** 解码配置 */
|
|
105
|
+
decoder: DecoderConfig;
|
|
106
|
+
}
|
|
107
|
+
/** 图片加载状态 */
|
|
108
|
+
export type LoadingState = 'idle' | 'loading' | 'loaded' | 'error';
|
|
109
|
+
/** 内部使用 - 已加载的图片 */
|
|
110
|
+
export interface LoadedImage {
|
|
111
|
+
/** 原始来源 */
|
|
112
|
+
source: ImageSource;
|
|
113
|
+
/** 可显示的 blob URL */
|
|
114
|
+
blobUrl: string;
|
|
115
|
+
/** 图片宽度 */
|
|
116
|
+
width: number;
|
|
117
|
+
/** 图片高度 */
|
|
118
|
+
height: number;
|
|
119
|
+
/** 文件大小(字节) */
|
|
120
|
+
size: number;
|
|
121
|
+
/** 文件名 */
|
|
122
|
+
name: string;
|
|
123
|
+
/** 是否经过格式转换 */
|
|
124
|
+
converted: boolean;
|
|
125
|
+
}
|
|
126
|
+
/** 查看器事件 */
|
|
127
|
+
export interface ViewerEventMap {
|
|
128
|
+
'image-load': CustomEvent<{
|
|
129
|
+
index: number;
|
|
130
|
+
image: LoadedImage;
|
|
131
|
+
}>;
|
|
132
|
+
'image-error': CustomEvent<{
|
|
133
|
+
index: number;
|
|
134
|
+
error: Error;
|
|
135
|
+
}>;
|
|
136
|
+
'image-change': CustomEvent<{
|
|
137
|
+
index: number;
|
|
138
|
+
image: LoadedImage;
|
|
139
|
+
}>;
|
|
140
|
+
'mode-change': CustomEvent<{
|
|
141
|
+
mode: ViewMode;
|
|
142
|
+
}>;
|
|
143
|
+
'transform-change': CustomEvent<{
|
|
144
|
+
transform: TransformState;
|
|
145
|
+
}>;
|
|
146
|
+
}
|
|
147
|
+
/** 默认配置 */
|
|
148
|
+
export declare const DEFAULT_CONFIG: ViewerConfig;
|
|
149
|
+
/** 默认变换状态 */
|
|
150
|
+
export declare const DEFAULT_TRANSFORM: TransformState;
|
|
151
|
+
/** 浏览器原生支持的图片 MIME 类型 */
|
|
152
|
+
export declare const NATIVE_IMAGE_TYPES: Set<string>;
|
|
153
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEzC,UAAU;AACV,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAClD,WAAW;AACX,MAAM,WAAW,WAAW;IAC1B,WAAW;IACX,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;IAChC;;;;;OAKG;IACH,IAAI,EAAE,IAAI,GAAG,MAAM,CAAC;IACpB,aAAa;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,WAAW;AACX,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,CAAC;AAEvE,mBAAmB;AACnB,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEtD,WAAW;AACX,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,IAAI,EAAE,WAAW,CAAC;IAClB;;;OAGG;IACH,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,WAAW;AACX,MAAM,WAAW,cAAc;IAC7B,6BAA6B;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW;IACX,KAAK,EAAE,OAAO,CAAC;IACf,WAAW;IACX,KAAK,EAAE,OAAO,CAAC;IACf,WAAW;IACX,KAAK,EAAE,MAAM,CAAC;IACd,YAAY;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY;IACZ,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,YAAY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+
"name": "@jacktea/img-viewer",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/img-viewer.umd.cjs",
|
|
7
|
+
"module": "dist/img-viewer.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/img-viewer.js",
|
|
13
|
+
"require": "./dist/img-viewer.umd.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./style.css": "./dist/style.css"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"LICENSE",
|
|
20
|
+
"THIRD_PARTY_NOTICES.md",
|
|
21
|
+
"third_party/licenses"
|
|
22
|
+
],
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@webtoon/psd": "^0.4.0"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"dev": "vite build --watch",
|
|
28
|
+
"build": "vite build && tsc --emitDeclarationOnly --outDir dist"
|
|
29
|
+
}
|
|
30
|
+
}
|