ew-viewer 0.0.0-stage → 0.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,32 @@
1
+ # Changelog
2
+
3
+ English | [简体中文](./CHANGELOG.zh-CN.md)
4
+
5
+ All notable changes to `ew-viewer` are documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [0.0.1] - 2026-11-29
8
+
9
+ First public release, extracted from the legacy `ewViewer` plugin.
10
+
11
+ ### Added
12
+
13
+ - Options: `img`, `container`, `previewMode`, `isClickOutside`, `showCloseBtn`, `closeTime`, `zoomOnWheeling`, `autoSize`, `minImageRatio` / `maxImageRatio`, `imageRatio`, `showToolBar`, `currentImageIndex`, `autoOpen`, `loop`, `interval`, `minRotate` / `maxRotate`, `zIndex` and 12 icon options.
14
+ - Methods: `viewImage()`, `open()`, `close()`, `update()` and `destroy()`.
15
+ - Seamless sliding carousel: slides sit on a flex track with cloned first/last slides, and the track is silently repositioned after crossing the boundary.
16
+ - ESM, CJS and IIFE builds plus `d.ts`, and a standalone `style.css`.
17
+
18
+ ### Changed
19
+
20
+ - Styles are no longer injected at runtime. Import `ew-viewer/style.css` (or link `dist/style.css`) yourself; the `injectStyle` / `styleNonce` options and the injected `<style>` element were removed.
21
+ - `destroy()` now performs a full teardown: it unbinds `window` listeners and clears every timer.
22
+ - Image measuring loads once and is aligned by index, instead of matching by load order.
23
+ - Multiple instances in one container each keep their own root node; events are detected through `data-ew-role` instead of className matching.
24
+ - Flipping is a simple toggle.
25
+ - Switching images animates along the track instead of fading in and out.
26
+
27
+ ### Fixed
28
+
29
+ - The image array no longer grows on every `update()`.
30
+ - Rotation, flip and size state no longer mismatch when images finish loading out of order.
31
+ - Calling fullscreen no longer throws when no image node is rendered.
32
+ - Carousel timers are cleared on `destroy()`, and `close()` no longer conflicts with the carousel timer.
@@ -0,0 +1,32 @@
1
+ # 更新日志
2
+
3
+ [English](./CHANGELOG.md) | 简体中文
4
+
5
+ `ew-viewer` 的重要变更都记录在这里。格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
6
+
7
+ ## [0.0.1] - 2026-11-29
8
+
9
+ 首次公开发布,从旧的 `ewViewer` 插件拆分而来。
10
+
11
+ ### 新增
12
+
13
+ - 选项:`img`、`container`、`previewMode`、`isClickOutside`、`showCloseBtn`、`closeTime`、`zoomOnWheeling`、`autoSize`、`minImageRatio` / `maxImageRatio`、`imageRatio`、`showToolBar`、`currentImageIndex`、`autoOpen`、`loop`、`interval`、`minRotate` / `maxRotate`、`zIndex` 以及 12 个图标选项。
14
+ - 方法:`viewImage()`、`open()`、`close()`、`update()`、`destroy()`。
15
+ - 无缝滑动轮播:图片放在 flex 轨道上,首尾各有一个克隆位,越界后轨道无声归位。
16
+ - ESM / CJS / IIFE 三种产物 + `d.ts`,样式单独输出为 `style.css`。
17
+
18
+ ### 变更
19
+
20
+ - 样式不再运行时注入,需要自行引入 `ew-viewer/style.css`(或外链 `dist/style.css`),移除 `injectStyle` / `styleNonce` 选项与注入的 `<style>` 标签。
21
+ - `destroy()` 变为完整销毁:解绑 `window` 监听并清空全部定时器。
22
+ - 图片测量改为一次性加载并按**下标**对齐,不再依赖加载顺序。
23
+ - 同容器多实例各自持有根节点,事件判定改用 `data-ew-role`。
24
+ - 翻转简化为 toggle。
25
+ - 切图改为沿轨道滑动,不再是淡入淡出。
26
+
27
+ ### 修复
28
+
29
+ - `update()` 不再让图片数组无限增长。
30
+ - 乱序加载时旋转、翻转、尺寸状态不再错位。
31
+ - 没有渲染出图片节点时调用全屏不再抛错。
32
+ - `destroy()` 会清理轮播定时器,`close()` 不再与轮播定时器互相覆盖。
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 eveningwater
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,124 @@
1
- # Temporary Holding Version
1
+ # ew-viewer
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ English | [简体中文](./README.zh-CN.md)
4
+
5
+ A lightweight image preview plugin: zoom, rotate, flip, fullscreen, thumbnails and carousel. No third-party UI dependency; one peer dependency, `@ew-color-picker/utils@^2.0.18`.
6
+
7
+ Release notes live in [CHANGELOG.md](./CHANGELOG.md).
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm i ew-viewer
13
+ # or
14
+ pnpm add ew-viewer
15
+ ```
16
+
17
+ ## Quick start
18
+
19
+ ### ESM
20
+
21
+ ```ts
22
+ import "ew-viewer/style.css";
23
+ import EWViewer from "ew-viewer";
24
+
25
+ const viewer = new EWViewer({
26
+ img: ["https://example.com/a.png", "https://example.com/b.png"],
27
+ previewMode: "img",
28
+ });
29
+
30
+ // open the first image
31
+ viewer.viewImage();
32
+ // open the second image
33
+ viewer.viewImage(1);
34
+ // destroy (unbind listeners, clear timers, remove nodes)
35
+ viewer.destroy();
36
+ ```
37
+
38
+ You can also pass a URL, an `img` element or an array directly:
39
+
40
+ ```ts
41
+ new EWViewer("https://example.com/a.png").viewImage();
42
+ new EWViewer(document.querySelector("img")!).viewImage();
43
+ new EWViewer([img1, img2]).viewImage();
44
+ ```
45
+
46
+ ### CDN
47
+
48
+ ```html
49
+ <link rel="stylesheet" href="https://unpkg.com/ew-viewer/dist/style.css" />
50
+ <script src="https://unpkg.com/ew-viewer/dist/index.iife.js"></script>
51
+ <script>
52
+ new EWViewer({ img: ["/a.png", "/b.png"] }).viewImage();
53
+ </script>
54
+ ```
55
+
56
+ ESM and CJS builds keep `@ew-color-picker/utils` external (installed once, shared with `ew-color-picker`); the IIFE build inlines it and exposes the `EWViewer` global.
57
+
58
+ ### Styles
59
+
60
+ The package does **not** inject styles at runtime, so you need to import the CSS yourself:
61
+
62
+ ```ts
63
+ import "ew-viewer/style.css";
64
+ ```
65
+
66
+ With the CDN build, use the `<link>` shown above to load `dist/style.css`. Import it once per document: it is shared by all instances and is not removed by `destroy()`.
67
+
68
+ ## Options
69
+
70
+ | Option | Type | Default | Description |
71
+ | --- | --- | --- | --- |
72
+ | `img` | `string \| HTMLImageElement \| (string \| HTMLImageElement)[]` | - | Image URL or element |
73
+ | `container` | `HTMLElement \| string` | `document.body` | Mount container of the viewer |
74
+ | `previewMode` | `'bg' \| 'img'` | `'bg'` | Render as background image or `<img>` |
75
+ | `isClickOutside` | `boolean` | `true` | Close when clicking the mask |
76
+ | `showCloseBtn` | `boolean` | `true` | Show the close button |
77
+ | `closeTime` | `number` | `200` | Open/close animation delay (ms) |
78
+ | `zoomOnWheeling` | `boolean` | `true` | Enable wheel zoom |
79
+ | `autoSize` | `boolean` | `true` | Recalculate size on window resize |
80
+ | `minImageRatio` / `maxImageRatio` | `number` | `0.1` / `1` | Zoom ratio range |
81
+ | `imageRatio` | `number` | `0.9` | Initial zoom ratio |
82
+ | `showToolBar` | `boolean` | `true` | Show the toolbar |
83
+ | `currentImageIndex` | `number` | `0` | Initial image index |
84
+ | `autoOpen` | `boolean` | `false` | Open automatically after render |
85
+ | `loop` | `boolean` | `true` | Loop head to tail; switching slides, seamless at both ends |
86
+ | `interval` | `number` | `5000` | Carousel interval (ms) |
87
+ | `minRotate` / `maxRotate` | `number` | `-Infinity` / `Infinity` | Rotation limits |
88
+ | `zoomInIcon` and 12 icon options | `string` | Built-in SVG | Custom icon HTML |
89
+ | `zIndex` | `number` | `2000` | Viewer z-index, also configurable via the `--ew-viewer-z-index` CSS variable |
90
+
91
+ ## Methods
92
+
93
+ | Method | Description |
94
+ | --- | --- |
95
+ | `viewImage(index?)` | Open the viewer at a given index |
96
+ | `open(time?)` | Show the viewer |
97
+ | `close(time?)` | Close the viewer and reset rotation/flip |
98
+ | `update()` | Rebuild the viewer with the latest constructor options |
99
+ | `destroy()` | Fully destroy; safe to call repeatedly |
100
+
101
+ ## Differences from the legacy plugin
102
+
103
+ - **New** `zIndex` option.
104
+ - Runtime style injection and the `injectStyle` / `styleNonce` options were removed; styles are imported statically via `ew-viewer/style.css`.
105
+ - `destroy()` now means a full teardown: it unbinds `window` listeners and clears every timer.
106
+ - Image measuring loads once and aligns by **index**, fixing size/rotation mismatches from out-of-order loading and the array growing on every `update()`.
107
+ - Multiple instances in one container no longer overwrite each other; event detection uses `data-ew-role` instead of className matching.
108
+ - Flipping is a simple toggle, same behaviour as before.
109
+ - Switching images now slides along a track: cloned slides at both ends are silently reset after crossing the boundary, giving a seamless loop.
110
+ - Class names are unchanged; styles now come from the static `style.css`, so there is no injected `<style>` tag anymore.
111
+
112
+ ## FAQ
113
+
114
+ **Import fails under SSR / Node?**
115
+ All DOM access happens inside the constructor and instance methods. `new EWViewer()` requires a browser; elsewhere it logs a warning and returns early.
116
+
117
+ **CSP blocks inline styles?**
118
+ The package no longer inserts a `<style>` tag — just `import "ew-viewer/style.css"` or link `dist/style.css`, and it is CSP-friendly out of the box.
119
+
120
+ **Multiple instances in one container?**
121
+ Each instance owns its own root node; `destroy()` only removes its own node.
122
+
123
+ **Do I need to install `@ew-color-picker/utils`?**
124
+ Yes, it is a peer dependency (>= `2.0.18`, which provides `createConsoleLogger` and `on(el, type, fn, { signal })` unbinding). npm 7+ and pnpm 8+ install peer dependencies automatically; projects already using `ew-color-picker` share the same copy.
@@ -0,0 +1,124 @@
1
+ # ew-viewer
2
+
3
+ [English](./README.md) | 简体中文
4
+
5
+ 轻量图片预览插件:缩放、旋转、翻转、全屏、缩略图与自动轮播。无第三方 UI 依赖;有一个 peer 依赖 `@ew-color-picker/utils@^2.0.18`。
6
+
7
+ 更新记录见 [CHANGELOG.zh-CN.md](./CHANGELOG.zh-CN.md)。
8
+
9
+ ## 安装
10
+
11
+ ```bash
12
+ npm i ew-viewer
13
+ # 或
14
+ pnpm add ew-viewer
15
+ ```
16
+
17
+ ## 快速开始
18
+
19
+ ### ESM
20
+
21
+ ```ts
22
+ import "ew-viewer/style.css";
23
+ import EWViewer from "ew-viewer";
24
+
25
+ const viewer = new EWViewer({
26
+ img: ["https://example.com/a.png", "https://example.com/b.png"],
27
+ previewMode: "img",
28
+ });
29
+
30
+ // 打开第 0 张
31
+ viewer.viewImage();
32
+ // 打开第 1 张
33
+ viewer.viewImage(1);
34
+ // 销毁(解绑监听、清定时器、移除节点)
35
+ viewer.destroy();
36
+ ```
37
+
38
+ 也可以直接传地址、`img` 元素或数组:
39
+
40
+ ```ts
41
+ new EWViewer("https://example.com/a.png").viewImage();
42
+ new EWViewer(document.querySelector("img")!).viewImage();
43
+ new EWViewer([img1, img2]).viewImage();
44
+ ```
45
+
46
+ ### CDN
47
+
48
+ ```html
49
+ <link rel="stylesheet" href="https://unpkg.com/ew-viewer/dist/style.css" />
50
+ <script src="https://unpkg.com/ew-viewer/dist/index.iife.js"></script>
51
+ <script>
52
+ new EWViewer({ img: ["/a.png", "/b.png"] }).viewImage();
53
+ </script>
54
+ ```
55
+
56
+ ESM / CJS 产物把 `@ew-color-picker/utils` 保持为外部依赖(只装一份,与 `ew-color-picker` 共用);IIFE 产物内联它,并暴露 `EWViewer` 全局变量。
57
+
58
+ ### 样式
59
+
60
+ 包内不做运行时样式注入,需要由使用方自行引入一份 CSS:
61
+
62
+ ```ts
63
+ import "ew-viewer/style.css";
64
+ ```
65
+
66
+ CDN 场景用上面的 `<link>` 引入 `dist/style.css`。样式只在文档中引入一次即可,多实例共享,`destroy()` 不会移除它。
67
+
68
+ ## 选项
69
+
70
+ | 选项 | 类型 | 默认 | 说明 |
71
+ | --- | --- | --- | --- |
72
+ | `img` | `string \| HTMLImageElement \| (string \| HTMLImageElement)[]` | - | 图片地址或元素 |
73
+ | `container` | `HTMLElement \| string` | `document.body` | 预览层挂载容器 |
74
+ | `previewMode` | `'bg' \| 'img'` | `'bg'` | 背景图渲染或 `<img>` 渲染 |
75
+ | `isClickOutside` | `boolean` | `true` | 点击遮罩是否关闭 |
76
+ | `showCloseBtn` | `boolean` | `true` | 是否显示关闭按钮 |
77
+ | `closeTime` | `number` | `200` | 打开/关闭动画延时(ms) |
78
+ | `zoomOnWheeling` | `boolean` | `true` | 是否允许滚轮缩放 |
79
+ | `autoSize` | `boolean` | `true` | 窗口 resize 时是否重算尺寸 |
80
+ | `minImageRatio` / `maxImageRatio` | `number` | `0.1` / `1` | 缩放比例区间 |
81
+ | `imageRatio` | `number` | `0.9` | 初始缩放比例 |
82
+ | `showToolBar` | `boolean` | `true` | 是否显示工具栏 |
83
+ | `currentImageIndex` | `number` | `0` | 初始图片下标 |
84
+ | `autoOpen` | `boolean` | `false` | 渲染完是否自动打开 |
85
+ | `loop` | `boolean` | `true` | 首尾是否循环;切换为轨道滑动过渡,首尾无缝衔接 |
86
+ | `interval` | `number` | `5000` | 自动轮播间隔(ms) |
87
+ | `minRotate` / `maxRotate` | `number` | `-Infinity` / `Infinity` | 旋转角度边界 |
88
+ | `zoomInIcon` 等 12 个图标项 | `string` | 内置 SVG | 自定义图标 HTML |
89
+ | `zIndex` | `number` | `2000` | 预览层层级,也可用 CSS 变量 `--ew-viewer-z-index` 覆盖 |
90
+
91
+ ## 方法
92
+
93
+ | 方法 | 说明 |
94
+ | --- | --- |
95
+ | `viewImage(index?)` | 打开指定下标的图片 |
96
+ | `open(time?)` | 显示预览层 |
97
+ | `close(time?)` | 关闭预览层并重置旋转/翻转 |
98
+ | `update()` | 用构造时的参数重建预览层 |
99
+ | `destroy()` | 完整销毁,可重复调用 |
100
+
101
+ ## 与旧版插件的差异
102
+
103
+ - **新增** `zIndex` 选项。
104
+ - 移除运行时样式注入与 `injectStyle` / `styleNonce` 选项,样式改为静态引入 `ew-viewer/style.css`。
105
+ - `destroy()` 语义从“仅移除节点”变为“完整销毁”:解绑 `window` 监听、清理全部定时器。
106
+ - 图片测量改为一次性加载并按**下标**对齐,修复乱序加载导致宽高/旋转错位、以及数组随 `update()` 无限增长的问题。
107
+ - 同容器多实例不再互相覆盖,事件判定改用 `data-ew-role` 而非 className 字符串匹配。
108
+ - 翻转简化为 toggle,行为与原来一致。
109
+ - 切图从淡入淡出改为轨道滑动:首尾各放一个克隆位,越过边界后无声归位,实现无缝循环轮播。
110
+ - 类名保持不变;样式改由静态 `style.css` 提供,不再有注入的 style 标签。
111
+
112
+ ## 常见问题
113
+
114
+ **SSR / Node 环境导入报错?**
115
+ 包内所有 DOM 访问都在构造与实例方法中,未触碰 `window`;但 `new EWViewer()` 需要浏览器环境,非浏览器环境会 `warn` 并直接返回。
116
+
117
+ **CSP 禁止内联样式?**
118
+ 包内不再插入 `<style>` 标签,直接 `import "ew-viewer/style.css"` 或外链 `dist/style.css` 即可,天然满足 CSP。
119
+
120
+ **同一容器多个实例?**
121
+ 每个实例持有自己的根节点,互不替换;`destroy()` 只移除自己的节点。
122
+
123
+ **需要自己安装 `@ew-color-picker/utils` 吗?**
124
+ 需要,它是 peer 依赖(>= `2.0.18`,提供 `createConsoleLogger` 与 `on(el, type, fn, { signal })` 解绑)。npm 7+ / pnpm 8+ 会自动安装 peer 依赖;已经用了 `ew-color-picker` 的项目共用同一份。
@@ -0,0 +1,15 @@
1
+ /** 以下图标工厂均返回 SVG 字符串,class 后缀用于自定义样式 */
2
+ export declare const addIcon: (className?: string) => string;
3
+ export declare const reduceIcon: (className?: string) => string;
4
+ export declare const closeIcon: (className?: string) => string;
5
+ export declare const oneToOneIcon: (className?: string) => string;
6
+ export declare const flipRightIcon: (className?: string) => string;
7
+ export declare const flipLeftIcon: (className?: string) => string;
8
+ export declare const rotateLeftIcon: (className?: string) => string;
9
+ export declare const rotateRightIcon: (className?: string) => string;
10
+ export declare const arrowLeftIcon: (className?: string) => string;
11
+ export declare const arrowRightIcon: (className?: string) => string;
12
+ export declare const resetIcon: (className?: string) => string;
13
+ export declare const fullscreenIcon: (className?: string) => string;
14
+ export declare const playIcon: (className?: string) => string;
15
+ export declare const pauseIcon: (className?: string) => string;
package/dist/index.cjs ADDED
@@ -0,0 +1,33 @@
1
+ "use strict";var S=Object.defineProperty;var L=(n,e,t)=>e in n?S(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var o=(n,e,t)=>L(n,typeof e!="symbol"?e+"":e,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("@ew-color-picker/utils"),d=s.createConsoleLogger({prefix:"ew-viewer",timestamp:!1}),E=n=>`<svg t="1697700092492" class="add-icon${n}" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="900" width="78" height="78"><path d="M560.064 149.952a48 48 0 0 0-96 0V464H150.016a48 48 0 0 0 0 96H464v313.984a48 48 0 0 0 96 0V560h314.048a48 48 0 0 0 0-96H560V149.952z" p-id="901" fill="#ffffff"></path></svg>`,M=n=>`<svg t="1697700199963" class="reduce-icon${n}" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1256" width="78" height="78"><path d="M922.048 512a48 48 0 0 0-48-48H149.952a48 48 0 1 0 0 96h724.096a48 48 0 0 0 48-48z" p-id="1257" fill="#ffffff"></path></svg>`,P=n=>`<svg t="1690189203554" class="close-icon${n}" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2272" fill="currentColor"><path d="M504.224 470.288l207.84-207.84a16 16 0 0 1 22.608 0l11.328 11.328a16 16 0 0 1 0 22.624l-207.84 207.824 207.84 207.84a16 16 0 0 1 0 22.608l-11.328 11.328a16 16 0 0 1-22.624 0l-207.824-207.84-207.84 207.84a16 16 0 0 1-22.608 0l-11.328-11.328a16 16 0 0 1 0-22.624l207.84-207.824-207.84-207.84a16 16 0 0 1 0-22.608l11.328-11.328a16 16 0 0 1 22.624 0l207.824 207.84z" p-id="2273"></path></svg>`,O=n=>`<svg t="1697700658302" class="one-to-one-icon${n}" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7084" width="78" height="78"><path d="M904.405333 149.333333v725.333334h-85.333333V250.346667l-66.24 33.152L714.666667 207.146667 830.336 149.333333h74.069333z m-608 0v725.333334h-85.333333V250.346667L144.853333 283.498667 106.666667 207.146667 222.336 149.333333h74.069333z m288 448v106.666667h-106.666666v-106.666667h106.666666z m0-277.333333v106.666667h-106.666666v-106.666667h106.666666z" fill="#ffffff" p-id="7085"></path></svg>`,F=n=>`<svg t="1697712563708" class="arrow-up-down-icon${n}" viewBox="0 0 1088 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="20575" width="78" height="78"><path d="M513.344 253.504V768H323.968l244.416 255.424L825.344 768H640V253.504h185.344L566.848 6.72 319.424 253.504h193.92z" fill="#ffffff" p-id="20576"></path></svg>`,N=n=>`<svg t="1697712627137" class="arrow-left-right-icon${n}" viewBox="0 0 1088 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="21609" width="78" height="78"><path d="M320 576h516.224v183.296l246.4-244.48-246.4-256.832L832 448H320l-7.296-190.08L65.92 516.48l246.784 247.424L320 576z" fill="#ffffff" p-id="21610"></path></svg>`,H=n=>`<svg t="1697712701928" class="flip-left-icon${n}" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="25120" width="78" height="78"><path d="M672 418H144c-17.7 0-32 14.3-32 32v414c0 17.7 14.3 32 32 32h528c17.7 0 32-14.3 32-32V450c0-17.7-14.3-32-32-32z m-44 402H188V494h440v326z" p-id="25121" fill="#ffffff"></path><path d="M819.3 328.5c-78.8-100.7-196-153.6-314.6-154.2l-0.2-64c0-6.5-7.6-10.1-12.6-6.1l-128 101c-4 3.1-3.9 9.1 0 12.3L492 318.6c5.1 4 12.7 0.4 12.6-6.1v-63.9c12.9 0.1 25.9 0.9 38.8 2.5 42.1 5.2 82.1 18.2 119 38.7 38.1 21.2 71.2 49.7 98.4 84.3 27.1 34.7 46.7 73.7 58.1 115.8 11 40.7 14 82.7 8.9 124.8-0.7 5.4-1.4 10.8-2.4 16.1h74.9c14.8-103.6-11.3-213-81-302.3z" p-id="25122" fill="#ffffff"></path></svg>`,B=n=>`<svg t="1697712744122" class="flip-right-icon${n}" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="25323" width="78" height="78"><path d="M480.5 251.2c13-1.6 25.9-2.4 38.8-2.5v63.9c0 6.5 7.5 10.1 12.6 6.1L660 217.6c4-3.2 4-9.2 0-12.3l-128-101c-5.1-4-12.6-0.4-12.6 6.1l-0.2 64c-118.6 0.5-235.8 53.4-314.6 154.2-69.6 89.2-95.7 198.6-81.1 302.4h74.9c-0.9-5.3-1.7-10.7-2.4-16.1-5.1-42.1-2.1-84.1 8.9-124.8 11.4-42.2 31-81.1 58.1-115.8 27.2-34.7 60.3-63.2 98.4-84.3 37-20.6 76.9-33.6 119.1-38.8z" p-id="25324" fill="#ffffff"></path><path d="M880 418H352c-17.7 0-32 14.3-32 32v414c0 17.7 14.3 32 32 32h528c17.7 0 32-14.3 32-32V450c0-17.7-14.3-32-32-32z m-44 402H396V494h440v326z" p-id="25325" fill="#ffffff"></path></svg>`,D=n=>`<svg t="1697787947316" class="arrow-left-icon${n}" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="900" width="78" height="78"><path d="M290.56 550.464a54.4 54.4 0 0 1 0-76.928l379.52-379.52a48 48 0 1 1 67.84 67.904L387.84 512l350.08 350.08a48 48 0 1 1-67.84 67.84L290.56 550.464z" p-id="901" fill="#ffffff"></path></svg>`,V=n=>`<svg t="1697772815002" class="arrow-right-icon${n}" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="900" width="78" height="78"><path d="M733.44 550.464a54.4 54.4 0 0 0 0-76.928l-379.52-379.52A48 48 0 0 0 286.08 161.92L636.16 512l-350.08 350.08a48 48 0 1 0 67.84 67.84l379.52-379.456z" p-id="901" fill="#ffffff"></path></svg>`,A=n=>`<svg t="1697773227169" class="reset-icon${n}" viewBox="0 0 1278 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2019" width="78" height="78"><path d="M1272.447024 472.907505l-150.052574 149.245613a32.021415 32.021415 0 0 1-44.681788 0L928.777033 472.906505c-17.717123-20.478986-5.895708-27.925618 6.45368-39.716035h136.525243A441.782135 441.782135 0 0 0 253.257466 304.732828L178.791151 275.257287a521.555187 521.555187 0 0 1 973.731808 157.934183h113.56338a26.653681 26.653681 0 0 1 6.360685 39.716035zM202.713967 440.946087l150.022575 149.556598a26.622682 26.622682 0 0 1-6.45468 39.717034H216.366292a442.247112 442.247112 0 0 0 789.701915 120.700026l75.213278 29.787526A521.555187 521.555187 0 0 1 134.513343 630.219719h-118.994111c-12.411386-11.791416-24.170804-19.238048-6.453681-39.717034l148.935629-149.556598a32.641385 32.641385 0 0 1 44.712787 0z" fill="#ffffff" p-id="2020"></path></svg>`,W=n=>`<svg t="1697787617768" class="fullscreen-icon${n}" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3046" width="78" height="78"><path d="M213.333333 213.333333h213.333334V128H170.666667a42.666667 42.666667 0 0 0-42.666667 42.666667v256h85.333333V213.333333zM170.666667 896h256v-85.333333H213.333333v-213.333334H128v256a42.666667 42.666667 0 0 0 42.666667 42.666667z m725.333333-42.666667v-256h-85.333333v213.333334h-213.333334v85.333333h256a42.666667 42.666667 0 0 0 42.666667-42.666667zM597.333333 213.333333h213.333334v213.333334h85.333333V170.666667a42.666667 42.666667 0 0 0-42.666667-42.666667h-256v85.333333z" fill="#ffffff" p-id="3047"></path></svg>`,q=n=>`<svg t="1697800175999" class="play-icon${n}" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9820" width="78" height="78"><path d="M852.5 533.9L279 864.7c-11.9 6.9-27.2 2.8-34.1-9.1-2.2-3.8-3.3-8.1-3.3-12.5V181.5c0-13.8 11.2-24.9 24.9-24.9 4.4 0 8.7 1.2 12.5 3.3l573.4 330.8c11.9 6.9 16 22.1 9.1 34.1-2.1 3.8-5.2 6.9-9 9.1z" p-id="9821" fill="#ffffff"></path></svg>`,Y=n=>`<svg t="1697799289205" class="pause-icon${n}" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8597" width="78" height="78"><path d="M209.645253 863.934444l201.049992 0 0-703.866842L209.645253 160.067602 209.645253 863.934444zM611.804588 863.934444l201.113437 0 0-703.866842L611.804588 160.067602 611.804588 863.934444z" p-id="8598" fill="#ffffff"></path></svg>`;function Z(n){const e=document.createElement("div");return e.innerHTML=n,e.firstElementChild}function g(n,e){return s.isBoolean(n)&&n&&s.isString(e)&&e?e:""}const X=450,U=new Set(["mask","content","footer","title","toolbar","thumb","close"]),j={isClickOutside:!0,previewMode:"bg",showCloseBtn:!0,showCloseBtnIcon:P(s.handleClassName("ew-viewer-close-icon")),closeTime:200,zoomOnWheeling:!0,autoSize:!0,minImageRatio:.1,maxImageRatio:1,showToolBar:!0,zoomInIcon:E(s.handleClassName("ew-viewer-zoom-in-icon")),zoomOutIcon:M(s.handleClassName("ew-viewer-zoom-out-icon")),oneToOneIcon:O(s.handleClassName("ew-viewer-one-to-one-icon")),currentImageIndex:0,autoOpen:!1,flipLeftIcon:N(s.handleClassName("ew-viewer-flip-left-icon")),flipRightIcon:F(s.handleClassName("ew-viewer-flip-right-icon")),rotateLeftIcon:H(s.handleClassName("ew-viewer-rotate-left-icon")),rotateRightIcon:B(s.handleClassName("ew-viewer-rotate-right-icon")),resetIcon:A(s.handleClassName("ew-viewer-reset-icon")),prevIcon:D(s.handleClassName("ew-viewer-prev-icon")),nextIcon:V(s.handleClassName("ew-viewer-next-icon")),fullscreenIcon:W(s.handleClassName("ew-viewer-fullscreen-icon")),playIcon:q(s.handleClassName("ew-viewer-play-icon")),pauseIcon:Y(s.handleClassName("ew-viewer-pause-icon")),minRotate:-1/0,maxRotate:1/0,loop:!0,zIndex:2e3};function b(n,e){if(!e)return s.extend({},n);const t=e,i={};return Object.keys(t).forEach(a=>{t[a]!==void 0&&(i[a]=t[a])}),s.extend({},n,i)}function _(n){if(s.isString(n))return n.trim()||null;if(s.isDom(n)){const e=n;return(e.getAttribute?.("src")??e.src)||null}return null}function G(n){return new Promise(e=>{const t=new Image;t.onload=()=>e({naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight,scaleWidth:0,scaleHeight:0,scaleX:0,scaleY:0,rotate:0}),t.onerror=()=>e(null),t.src=n})}function x(n){const e=Number(n);return s.isValidNumber(e)&&e>0&&e<=1?e:.9}function y(n){return n.fullscreenElement||n.webkitFullscreenElement||n.mozFullScreenElement||n.msFullscreenElement||null}function C(n){return n?.closest?.("[data-ew-role]")?.getAttribute("data-ew-role")??null}class R{constructor(e){o(this,"config",b(j));o(this,"options");o(this,"imageDataList",[]);o(this,"imageStyle",[]);o(this,"currentImageIndex",0);o(this,"computedImageRatio",.9);o(this,"wheeling",!1);o(this,"isClickZoomIn",!1);o(this,"isClickZoomOut",!1);o(this,"isClickOneToOne",!1);o(this,"fullScreenStatus",!1);o(this,"isPlaying",!1);o(this,"$dom",{});o(this,"ac",null);o(this,"timers",new Set);o(this,"carouselTimer",null);o(this,"rafId",null);o(this,"pendingOpen",null);o(this,"seq",0);o(this,"slidePos",1);o(this,"handleRootClick",e=>{const t=C(e.target);if(t!=="fullscreen"){if(this.fullScreenStatus){this.exitFullscreen(),this.fullScreenStatus=!1;return}this.config.isClickOutside&&t!==null&&U.has(t)&&this.close()}});o(this,"handleResize",()=>{if(this.rafId===null){if(typeof requestAnimationFrame!="function"){this.setImageStyle();return}this.rafId=requestAnimationFrame(()=>{this.rafId=null,this.setImageStyle()})}});o(this,"handleWheel",e=>{e.preventDefault(),!this.wheeling&&(this.wheeling=!0,this.setTimer(()=>{this.wheeling=!1},150),this.viewedImageHandler(e.deltaY<0))});o(this,"handleThumbClick",e=>{e.stopPropagation();const t=e.target;if(!t?.className?.includes?.("ew-viewer-thumb-img"))return;const i=Number(t.getAttribute("data-index"));s.isValidNumber(i)&&(this.currentImageIndex=i,this.changeThumbImage(),this.slideTo(i),this.setImageStyle())});o(this,"handleToolbarClick",e=>{const t=this.currentMeta();if(!t)return;const{minRotate:i,maxRotate:a}=this.config;switch(C(e.target)){case"zoom-in":if(this.isClickZoomIn)return;this.isClickZoomIn=!0,this.setTimer(()=>{this.isClickZoomIn=!1},50),this.viewedImageHandler(!0);break;case"zoom-out":if(this.isClickZoomOut)return;this.isClickZoomOut=!0,this.setTimer(()=>{this.isClickZoomOut=!1},50),this.viewedImageHandler(!1);break;case"one-to-one":{if(this.isClickOneToOne)return;this.isClickOneToOne=!0,this.setTimer(()=>{this.isClickOneToOne=!1},50),this.viewedImageHandler(this.computedImageRatio===1?.5:1);break}case"rotate-left":t.rotate-=90,s.isNumber(i)&&i!==-1/0&&t.rotate<=i&&(t.rotate=i),this.setImageStyle();break;case"rotate-right":t.rotate+=90,s.isNumber(a)&&a!==1/0&&t.rotate>=a&&(t.rotate=a),this.setImageStyle();break;case"flip-horizontal":t.scaleX=t.scaleX===-1?0:-1,this.setImageStyle();break;case"flip-vertical":t.scaleY=t.scaleY===-1?0:-1,this.setImageStyle();break;case"reset":this.resetImage();break;case"prev":this.manualGo(-1);break;case"next":this.manualGo(1);break;case"fullscreen":this.fullScreenStatus=!this.fullScreenStatus,this.fullScreenStatus?this.requestFullscreen():this.exitFullscreen();break;case"play":this.togglePlay();break}});if(!s.isBrowser){d.warn("EWViewer 只能在浏览器环境中使用");return}this.computedImageRatio=x(this.config.imageRatio),this.reload(e)}reload(e){const t=++this.seq;this.init(e).then(i=>{t!==this.seq||!i||this.render()})}async resolveImages(e){const t=e.map(_).filter(l=>!!l);if(t.length===0)return d.warn("传入的图片地址不合法"),!1;const i=await Promise.all(t.map(G)),a=[],r=[];if(i.forEach((l,u)=>{if(!l){d.warn(`图片加载失败,已忽略:${t[u]}`);return}a.push(t[u]),r.push(l)}),a.length===0)return!1;this.imageDataList=a,this.imageStyle=r;const h=this.config.currentImageIndex;return this.currentImageIndex=s.isValidNumber(h)&&h>=0&&h<a.length?h:0,!0}async init(e){if(s.isString(e)||s.isDom(e))return this.resolveImages([e]);if(Array.isArray(e))return this.resolveImages(e);if(s.isObject(e)){const{img:t,...i}=e;return this.config=b(this.config,i),this.validateRatio(),this.computedImageRatio=x(this.config.imageRatio),t==null?(d.warn("未提供 img 参数"),!1):this.resolveImages(Array.isArray(t)?t:[t])}return d.warn("传入的参数不合法"),!1}validateRatio(){const{minImageRatio:e,maxImageRatio:t}=this.config;this.rangeRation(e)||(this.config.minImageRatio=.1,d.warn("minImageRatio 应在 0 到 1 之间")),this.rangeRation(t)||(this.config.maxImageRatio=1,d.warn("maxImageRatio 应在 0 到 1 之间")),this.config.minImageRatio>this.config.maxImageRatio&&d.warn("minImageRatio 不应大于 maxImageRatio")}rangeRation(e){return s.isNumber(e)?e>=0&&e<=1:!1}async render(){this.teardown();const e=s.checkContainer(this.config.container),t=this.currentMeta();if(!e||!t)return;const{previewMode:i,showCloseBtn:a,showCloseBtnIcon:r,showToolBar:h}=this.config,l=this.imageDataList[this.currentImageIndex]??"",u=`${Math.floor(this.computedImageRatio*100)}%`,c=this.imageDataList.length>1,f=`
2
+ <div class="ew-viewer-zoom-in" data-ew-role="zoom-in">${this.config.zoomInIcon}</div>
3
+ <div class="ew-viewer-zoom-out" data-ew-role="zoom-out">${this.config.zoomOutIcon}</div>
4
+ <div class="ew-viewer-one-to-one" data-ew-role="one-to-one">${this.config.oneToOneIcon}</div>
5
+ <div class="ew-viewer-reset" data-ew-role="reset">${this.config.resetIcon}</div>
6
+ <div class="ew-viewer-fullscreen" data-ew-role="fullscreen">${this.config.fullscreenIcon}</div>
7
+ ${g(c,`<div class="ew-viewer-prev" data-ew-role="prev">${this.config.prevIcon}</div>`)}
8
+ ${g(c,`<div class="ew-viewer-play" data-ew-role="play">${this.isPlaying?this.config.pauseIcon:this.config.playIcon}</div>`)}
9
+ ${g(c,`<div class="ew-viewer-next" data-ew-role="next">${this.config.nextIcon}</div>`)}
10
+ <div class="ew-viewer-rotate-left" data-ew-role="rotate-left">${this.config.rotateLeftIcon}</div>
11
+ <div class="ew-viewer-rotate-right" data-ew-role="rotate-right">${this.config.rotateRightIcon}</div>
12
+ <div class="ew-viewer-flip-horizontal" data-ew-role="flip-horizontal">${this.config.flipLeftIcon}</div>
13
+ <div class="ew-viewer-flip-vertical" data-ew-role="flip-vertical">${this.config.flipRightIcon}</div>
14
+ `,v=(p,w,k=!1)=>`
15
+ <div class="ew-viewer-img-box${s.handleClassName(w===this.currentImageIndex?"show":"")}" data-index="${w}" data-ew-role="image"${k?' data-clone="true"':""}>
16
+ ${i==="bg"?`<div class="ew-viewer-bg-img" style="background-image:url(${p});"></div>`:`<img src="${p}" class="ew-viewer-img" />`}
17
+ </div>`,I=this.imageDataList.map((p,w)=>v(p,w)).join(""),$=`<div class="ew-viewer-track">
18
+ ${g(c,v(this.imageDataList[this.imageDataList.length-1],this.imageDataList.length-1,!0))}
19
+ ${I}
20
+ ${g(c,v(this.imageDataList[0],0,!0))}
21
+ </div>`,z=this.imageDataList.map((p,w)=>`<img src="${p}" class="ew-viewer-thumb-img${s.handleClassName(w===this.currentImageIndex?"active":"")}" data-index="${w}"/>`).join(""),m=Z(`<div class="ew-viewer hidden">
22
+ <div class="ew-viewer-mask" data-ew-role="mask">
23
+ <div class="ew-viewer-content" data-ew-role="content">${$}</div>
24
+ <div class="ew-viewer-tooltip-ratio hidden" data-ew-role="tooltip">${u}</div>
25
+ <div class="ew-viewer-footer" data-ew-role="footer">
26
+ <div class="ew-viewer-title" data-ew-role="title">${this.getImageNameFromURL(l)}(${t.naturalWidth} x ${t.naturalHeight})</div>
27
+ ${g(h,`<div class="ew-viewer-button" data-ew-role="toolbar">${f}</div>`)}
28
+ ${g(c,`<div class="ew-viewer-thumb" data-ew-role="thumb">${z}</div>`)}
29
+ </div>
30
+ ${g(a,`<span class="ew-viewer-close-btn" data-ew-role="close">${r}</span>`)}
31
+ </div>
32
+ </div>`);if(!m)return;s.isValidNumber(this.config.zIndex)&&m.style.setProperty("--ew-viewer-z-index",`${this.config.zIndex}`),e.appendChild(m),this.$dom.$el=m,this.$dom.$viewerContentElement=s.$(".ew-viewer-content",m),this.$dom.$viewerTrackElement=s.$(".ew-viewer-track",m),this.$dom.$viewerRatioTooltipElement=s.$(".ew-viewer-tooltip-ratio",m),this.$dom.$viewerToolbarElement=s.$(".ew-viewer-button",m),this.$dom.$viewerThumbElement=s.$(".ew-viewer-thumb",m),this.$dom.$viewerTitleElement=s.$(".ew-viewer-title",m),this.slidePos=this.indexToPos(this.currentImageIndex),this.setTrackPosition(this.slidePos,!1),this.bindEvent();const T=this.pendingOpen;this.pendingOpen=null,T?this.open(T.time):this.config.autoOpen&&this.open()}bindEvent(){const e=this.$dom.$el;if(!e)return;this.ac=new AbortController;const{signal:t}=this.ac;s.on(e,"click",this.handleRootClick,{signal:t}),this.config.autoSize&&s.on(window,"resize",this.handleResize,{signal:t}),this.config.zoomOnWheeling&&s.on(e,"wheel",this.handleWheel,{signal:t});const i=this.$dom.$viewerToolbarElement;i&&s.on(i,"click",this.handleToolbarClick,{signal:t});const a=this.$dom.$viewerThumbElement;a&&s.on(a,"click",this.handleThumbClick,{signal:t})}currentMeta(){return this.imageStyle[this.currentImageIndex]??null}get interval(){const e=Number(this.config.interval);return s.isValidNumber(e)&&e>0?e:5e3}setTimer(e,t){const i=setTimeout(()=>{this.timers.delete(i),e()},t);return this.timers.add(i),i}clearTimers(){this.timers.forEach(e=>clearTimeout(e)),this.timers.clear()}teardown(){this.ac?.abort(),this.ac=null,this.clearTimers(),this.carouselTimer=null,this.rafId!==null&&(typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(this.rafId),this.rafId=null),this.$dom.$el?.remove(),this.$dom={}}stopCarousel(){this.carouselTimer!==null&&(clearTimeout(this.carouselTimer),this.timers.delete(this.carouselTimer),this.carouselTimer=null)}indexToPos(e){return this.imageDataList.length>1?e+1:0}setTrackPosition(e,t){const i=this.$dom.$viewerTrackElement;if(!i)return;this.slidePos=e;const r=`translate3d(${e===0?"0":`${-e*100}%`}, 0, 0)`;if(t){i.style.removeProperty("transition"),i.style.transform=r;return}i.style.transition="none",i.style.transform=r,i.offsetWidth,i.style.removeProperty("transition")}slideTo(e,t){const i=this.imageDataList.length;if(i<=1)return;this.slidePos===0?this.setTrackPosition(i,!1):this.slidePos===i+1&&this.setTrackPosition(1,!1);let a=e+1;t!==void 0&&t>0&&e===0?a=i+1:t!==void 0&&t<0&&e===i-1&&(a=0),this.setTrackPosition(a,!0),this.setTimer(()=>{this.slidePos===0?this.setTrackPosition(i,!1):this.slidePos===i+1&&this.setTrackPosition(1,!1)},X+50)}startCarousel(){this.stopCarousel();const e=()=>{this.go(1),this.carouselTimer=this.setTimer(e,this.interval)};this.carouselTimer=this.setTimer(e,this.interval)}go(e){const t=this.imageDataList.length;if(t===0)return;const i=this.currentImageIndex;let a=this.currentImageIndex+e;const r=this.config.loop||this.isPlaying;a<0&&(a=r?t-1:0),a>t-1&&(a=r?0:t-1),this.currentImageIndex=a,this.changeThumbImage(),this.setImageStyle(),a!==i&&this.slideTo(a,e)}manualGo(e){this.go(e),this.isPlaying&&this.startCarousel()}togglePlay(){this.isPlaying=!this.isPlaying;const e=this.$dom.$viewerToolbarElement,t=e?s.$(".ew-viewer-play",e):null;t&&(t.innerHTML=this.isPlaying?this.config.pauseIcon:this.config.playIcon),this.isPlaying?this.startCarousel():this.stopCarousel()}imageSize(e,t){const{offsetWidth:i,offsetHeight:a}=t,r=e.naturalWidth/e.naturalHeight;let h=i,l=a;return a*r>i?l=i/r:h=a*r,{width:Math.min(h*this.computedImageRatio,e.naturalWidth),height:Math.min(l*this.computedImageRatio,e.naturalHeight)}}scaleImageCallback(){const e=this.$dom.$viewerContentElement,t=this.currentMeta();if(!e||!t)return;const{width:i,height:a}=this.imageSize(t,e);t.scaleWidth=i,t.scaleHeight=a;const r=this.$dom.$viewerRatioTooltipElement;r&&(r.textContent=`${Math.floor(this.computedImageRatio*100)}%`)}async setImageStyle(e=!0){const t=this.$dom.$viewerContentElement,i=this.currentMeta();if(!t||!i)return;e&&this.scaleImageCallback();const a=this.$dom.$viewerTrackElement;(a?[...a.children]:[]).forEach(l=>{const u=Number(l.getAttribute("data-index")),c=this.imageStyle[u],f=l.firstElementChild;if(!c||!f)return;u===this.currentImageIndex?s.addClass(l,"show"):s.removeClass(l,"show");const{width:v,height:I}=this.imageSize(c,t);f.style.width=`${v}px`,f.style.height=`${I}px`,this.config.previewMode==="bg"&&(f.style.backgroundSize=`${v}px ${I}px`),f.style.removeProperty("transform");const $=`${c.rotate!==0?`rotate(${c.rotate}deg)`:""} ${c.scaleX!==0?`scaleX(${c.scaleX})`:""} ${c.scaleY!==0?`scaleY(${c.scaleY})`:""}`.trim();$&&(f.style.transform=$)});const h=this.$dom.$viewerTitleElement;if(h){const l=this.imageDataList[this.currentImageIndex]??"";h.innerHTML=`${this.getImageNameFromURL(l)}(${i.naturalWidth} x ${i.naturalHeight})`}}getImageNameFromURL(e){return s.isString(e)?decodeURIComponent(e.replace(/^.*\//,"").replace(/[?&#].*$/,"")):""}computedImageRatioHandler(e){const{minImageRatio:t,maxImageRatio:i}=this.config,a=e?1:-1,r=this.computedImageRatio+a*(Math.floor(Math.random()*100)/1e3);this.computedImageRatio=Math.max(t,Math.min(r,i))}viewedImageHandler(e){s.isBoolean(e)?this.computedImageRatioHandler(e):this.computedImageRatio=e,this.toggleTooltip(!0),this.setTimer(()=>this.toggleTooltip(!1),1e3),this.setImageStyle()}changeThumbImage(){const e=this.$dom.$viewerThumbElement;if(!e)return;[...e.children].forEach(i=>{Number(i.getAttribute("data-index"))===this.currentImageIndex?s.addClass(i,"active"):s.removeClass(i,"active")})}getFullscreenTarget(){const e=this.$dom.$viewerContentElement;return e?s.$(".ew-viewer-img-box.show",e):null}requestFullscreen(){const t=this.getFullscreenTarget()?.ownerDocument??document;if(y(t))return;const i=t.documentElement;typeof i.requestFullscreen=="function"?i.requestFullscreen():typeof i.webkitRequestFullscreen=="function"?i.webkitRequestFullscreen():typeof i.mozRequestFullScreen=="function"?i.mozRequestFullScreen():typeof i.msRequestFullscreen=="function"&&i.msRequestFullscreen()}exitFullscreen(){const t=this.getFullscreenTarget()?.ownerDocument??document;y(t)&&(typeof t.exitFullscreen=="function"?t.exitFullscreen():typeof t.webkitExitFullscreen=="function"?t.webkitExitFullscreen():typeof t.mozCancelFullScreen=="function"?t.mozCancelFullScreen():typeof t.msExitFullscreen=="function"&&t.msExitFullscreen())}resetImage(){this.computedImageRatio=x(this.config.imageRatio);const e=this.currentMeta();e&&(e.rotate=0,e.scaleX=0,e.scaleY=0,this.setImageStyle())}toggleTooltip(e){const t=this.$dom.$viewerRatioTooltipElement;t&&this.setTimer(()=>{s.addClass(t,e?"show":"hidden"),s.removeClass(t,e?"hidden":"show")},100)}baseToggle(e,t){const{closeTime:i}=this.config,a=this.$dom.$el;a&&this.setTimer(()=>{s.addClass(a,e?"show":"hidden"),s.removeClass(a,e?"hidden":"show")},t||i)}async close(e){this.resetImage(),this.stopCarousel(),this.isPlaying=!1,this.baseToggle(!1,e)}viewImage(e){s.isNumber(e)&&e>=0&&e<=this.imageDataList.length-1&&(this.currentImageIndex=e),this.open()}open(e){if(!this.$dom.$el){this.pendingOpen={time:e};return}this.changeThumbImage(),this.setTrackPosition(this.indexToPos(this.currentImageIndex),!1),this.setImageStyle(),this.baseToggle(!0,e)}update(){this.options&&this.reload(this.options)}destroy(){this.teardown(),this.isPlaying=!1,this.fullScreenStatus=!1,this.pendingOpen=null}}exports.EWViewer=R;exports.default=R;
33
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/internal/utils.ts","../src/icons.ts","../src/internal/template.ts","../src/viewer.ts"],"sourcesContent":["import { createConsoleLogger } from \"@ew-color-picker/utils\";\n\nexport {\n $,\n addClass,\n checkContainer,\n extend,\n handleClassName,\n isBoolean,\n isBrowser,\n isDom,\n isNumber,\n isObject,\n isString,\n isValidNumber,\n on,\n removeClass,\n} from \"@ew-color-picker/utils\";\n\nexport const logger = createConsoleLogger({\n prefix: \"ew-viewer\",\n timestamp: false,\n});\n","/** 以下图标工厂均返回 SVG 字符串,class 后缀用于自定义样式 */\n\nexport const addIcon = (className?: string) => `<svg t=\"1697700092492\" class=\"add-icon${className}\" viewBox=\"0 0 1024 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" p-id=\"900\" width=\"78\" height=\"78\"><path d=\"M560.064 149.952a48 48 0 0 0-96 0V464H150.016a48 48 0 0 0 0 96H464v313.984a48 48 0 0 0 96 0V560h314.048a48 48 0 0 0 0-96H560V149.952z\" p-id=\"901\" fill=\"#ffffff\"></path></svg>`;\nexport const reduceIcon = (className?: string) => `<svg t=\"1697700199963\" class=\"reduce-icon${className}\" viewBox=\"0 0 1024 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" p-id=\"1256\" width=\"78\" height=\"78\"><path d=\"M922.048 512a48 48 0 0 0-48-48H149.952a48 48 0 1 0 0 96h724.096a48 48 0 0 0 48-48z\" p-id=\"1257\" fill=\"#ffffff\"></path></svg>`;\nexport const closeIcon = (className?: string) => `<svg t=\"1690189203554\" class=\"close-icon${className}\" viewBox=\"0 0 1024 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" p-id=\"2272\" fill=\"currentColor\"><path d=\"M504.224 470.288l207.84-207.84a16 16 0 0 1 22.608 0l11.328 11.328a16 16 0 0 1 0 22.624l-207.84 207.824 207.84 207.84a16 16 0 0 1 0 22.608l-11.328 11.328a16 16 0 0 1-22.624 0l-207.824-207.84-207.84 207.84a16 16 0 0 1-22.608 0l-11.328-11.328a16 16 0 0 1 0-22.624l207.84-207.824-207.84-207.84a16 16 0 0 1 0-22.608l11.328-11.328a16 16 0 0 1 22.624 0l207.824 207.84z\" p-id=\"2273\"></path></svg>`;\nexport const oneToOneIcon = (className?: string) => `<svg t=\"1697700658302\" class=\"one-to-one-icon${className}\" viewBox=\"0 0 1024 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" p-id=\"7084\" width=\"78\" height=\"78\"><path d=\"M904.405333 149.333333v725.333334h-85.333333V250.346667l-66.24 33.152L714.666667 207.146667 830.336 149.333333h74.069333z m-608 0v725.333334h-85.333333V250.346667L144.853333 283.498667 106.666667 207.146667 222.336 149.333333h74.069333z m288 448v106.666667h-106.666666v-106.666667h106.666666z m0-277.333333v106.666667h-106.666666v-106.666667h106.666666z\" fill=\"#ffffff\" p-id=\"7085\"></path></svg>`;\nexport const flipRightIcon = (className?: string) => `<svg t=\"1697712563708\" class=\"arrow-up-down-icon${className}\" viewBox=\"0 0 1088 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" p-id=\"20575\" width=\"78\" height=\"78\"><path d=\"M513.344 253.504V768H323.968l244.416 255.424L825.344 768H640V253.504h185.344L566.848 6.72 319.424 253.504h193.92z\" fill=\"#ffffff\" p-id=\"20576\"></path></svg>`;\nexport const flipLeftIcon = (className?: string) => `<svg t=\"1697712627137\" class=\"arrow-left-right-icon${className}\" viewBox=\"0 0 1088 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" p-id=\"21609\" width=\"78\" height=\"78\"><path d=\"M320 576h516.224v183.296l246.4-244.48-246.4-256.832L832 448H320l-7.296-190.08L65.92 516.48l246.784 247.424L320 576z\" fill=\"#ffffff\" p-id=\"21610\"></path></svg>`;\nexport const rotateLeftIcon = (className?: string) => `<svg t=\"1697712701928\" class=\"flip-left-icon${className}\" viewBox=\"0 0 1024 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" p-id=\"25120\" width=\"78\" height=\"78\"><path d=\"M672 418H144c-17.7 0-32 14.3-32 32v414c0 17.7 14.3 32 32 32h528c17.7 0 32-14.3 32-32V450c0-17.7-14.3-32-32-32z m-44 402H188V494h440v326z\" p-id=\"25121\" fill=\"#ffffff\"></path><path d=\"M819.3 328.5c-78.8-100.7-196-153.6-314.6-154.2l-0.2-64c0-6.5-7.6-10.1-12.6-6.1l-128 101c-4 3.1-3.9 9.1 0 12.3L492 318.6c5.1 4 12.7 0.4 12.6-6.1v-63.9c12.9 0.1 25.9 0.9 38.8 2.5 42.1 5.2 82.1 18.2 119 38.7 38.1 21.2 71.2 49.7 98.4 84.3 27.1 34.7 46.7 73.7 58.1 115.8 11 40.7 14 82.7 8.9 124.8-0.7 5.4-1.4 10.8-2.4 16.1h74.9c14.8-103.6-11.3-213-81-302.3z\" p-id=\"25122\" fill=\"#ffffff\"></path></svg>`;\nexport const rotateRightIcon = (className?: string) => `<svg t=\"1697712744122\" class=\"flip-right-icon${className}\" viewBox=\"0 0 1024 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" p-id=\"25323\" width=\"78\" height=\"78\"><path d=\"M480.5 251.2c13-1.6 25.9-2.4 38.8-2.5v63.9c0 6.5 7.5 10.1 12.6 6.1L660 217.6c4-3.2 4-9.2 0-12.3l-128-101c-5.1-4-12.6-0.4-12.6 6.1l-0.2 64c-118.6 0.5-235.8 53.4-314.6 154.2-69.6 89.2-95.7 198.6-81.1 302.4h74.9c-0.9-5.3-1.7-10.7-2.4-16.1-5.1-42.1-2.1-84.1 8.9-124.8 11.4-42.2 31-81.1 58.1-115.8 27.2-34.7 60.3-63.2 98.4-84.3 37-20.6 76.9-33.6 119.1-38.8z\" p-id=\"25324\" fill=\"#ffffff\"></path><path d=\"M880 418H352c-17.7 0-32 14.3-32 32v414c0 17.7 14.3 32 32 32h528c17.7 0 32-14.3 32-32V450c0-17.7-14.3-32-32-32z m-44 402H396V494h440v326z\" p-id=\"25325\" fill=\"#ffffff\"></path></svg>`;\nexport const arrowLeftIcon = (className?: string) => `<svg t=\"1697787947316\" class=\"arrow-left-icon${className}\" viewBox=\"0 0 1024 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" p-id=\"900\" width=\"78\" height=\"78\"><path d=\"M290.56 550.464a54.4 54.4 0 0 1 0-76.928l379.52-379.52a48 48 0 1 1 67.84 67.904L387.84 512l350.08 350.08a48 48 0 1 1-67.84 67.84L290.56 550.464z\" p-id=\"901\" fill=\"#ffffff\"></path></svg>`;\nexport const arrowRightIcon = (className?: string) => `<svg t=\"1697772815002\" class=\"arrow-right-icon${className}\" viewBox=\"0 0 1024 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" p-id=\"900\" width=\"78\" height=\"78\"><path d=\"M733.44 550.464a54.4 54.4 0 0 0 0-76.928l-379.52-379.52A48 48 0 0 0 286.08 161.92L636.16 512l-350.08 350.08a48 48 0 1 0 67.84 67.84l379.52-379.456z\" p-id=\"901\" fill=\"#ffffff\"></path></svg>`;\nexport const resetIcon = (className?: string) => `<svg t=\"1697773227169\" class=\"reset-icon${className}\" viewBox=\"0 0 1278 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" p-id=\"2019\" width=\"78\" height=\"78\"><path d=\"M1272.447024 472.907505l-150.052574 149.245613a32.021415 32.021415 0 0 1-44.681788 0L928.777033 472.906505c-17.717123-20.478986-5.895708-27.925618 6.45368-39.716035h136.525243A441.782135 441.782135 0 0 0 253.257466 304.732828L178.791151 275.257287a521.555187 521.555187 0 0 1 973.731808 157.934183h113.56338a26.653681 26.653681 0 0 1 6.360685 39.716035zM202.713967 440.946087l150.022575 149.556598a26.622682 26.622682 0 0 1-6.45468 39.717034H216.366292a442.247112 442.247112 0 0 0 789.701915 120.700026l75.213278 29.787526A521.555187 521.555187 0 0 1 134.513343 630.219719h-118.994111c-12.411386-11.791416-24.170804-19.238048-6.453681-39.717034l148.935629-149.556598a32.641385 32.641385 0 0 1 44.712787 0z\" fill=\"#ffffff\" p-id=\"2020\"></path></svg>`;\nexport const fullscreenIcon = (className?: string) => `<svg t=\"1697787617768\" class=\"fullscreen-icon${className}\" viewBox=\"0 0 1024 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" p-id=\"3046\" width=\"78\" height=\"78\"><path d=\"M213.333333 213.333333h213.333334V128H170.666667a42.666667 42.666667 0 0 0-42.666667 42.666667v256h85.333333V213.333333zM170.666667 896h256v-85.333333H213.333333v-213.333334H128v256a42.666667 42.666667 0 0 0 42.666667 42.666667z m725.333333-42.666667v-256h-85.333333v213.333334h-213.333334v85.333333h256a42.666667 42.666667 0 0 0 42.666667-42.666667zM597.333333 213.333333h213.333334v213.333334h85.333333V170.666667a42.666667 42.666667 0 0 0-42.666667-42.666667h-256v85.333333z\" fill=\"#ffffff\" p-id=\"3047\"></path></svg>`;\nexport const playIcon = (className?: string) => `<svg t=\"1697800175999\" class=\"play-icon${className}\" viewBox=\"0 0 1024 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" p-id=\"9820\" width=\"78\" height=\"78\"><path d=\"M852.5 533.9L279 864.7c-11.9 6.9-27.2 2.8-34.1-9.1-2.2-3.8-3.3-8.1-3.3-12.5V181.5c0-13.8 11.2-24.9 24.9-24.9 4.4 0 8.7 1.2 12.5 3.3l573.4 330.8c11.9 6.9 16 22.1 9.1 34.1-2.1 3.8-5.2 6.9-9 9.1z\" p-id=\"9821\" fill=\"#ffffff\"></path></svg>`;\nexport const pauseIcon = (className?: string) => `<svg t=\"1697799289205\" class=\"pause-icon${className}\" viewBox=\"0 0 1024 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" p-id=\"8597\" width=\"78\" height=\"78\"><path d=\"M209.645253 863.934444l201.049992 0 0-703.866842L209.645253 160.067602 209.645253 863.934444zM611.804588 863.934444l201.113437 0 0-703.866842L611.804588 160.067602 611.804588 863.934444z\" p-id=\"8598\" fill=\"#ffffff\"></path></svg>`;\n","import { isBoolean, isString } from \"./utils\";\n\n/** 把 HTML 字符串转成首个元素节点(自动跳过空白文本节点) */\nexport function createElement<T extends HTMLElement = HTMLElement>(\n html: string\n): T | null {\n const wrapper = document.createElement(\"div\");\n wrapper.innerHTML = html;\n return wrapper.firstElementChild as T | null;\n}\n\n/** 条件为真时返回模板字符串,否则返回空串 */\nexport function handleTemplate(condition?: boolean, template?: string): string {\n return isBoolean(condition) && condition && isString(template) && template\n ? template\n : \"\";\n}\n","import {\n $,\n addClass,\n checkContainer,\n extend,\n handleClassName,\n isBoolean,\n isBrowser,\n isDom,\n isNumber,\n isObject,\n isString,\n isValidNumber,\n logger,\n on,\n removeClass,\n} from \"./internal/utils\";\nimport {\n addIcon,\n arrowLeftIcon,\n arrowRightIcon,\n closeIcon,\n flipLeftIcon,\n flipRightIcon,\n fullscreenIcon,\n oneToOneIcon,\n pauseIcon,\n playIcon,\n reduceIcon,\n resetIcon,\n rotateLeftIcon,\n rotateRightIcon,\n} from \"./icons\";\nimport { createElement, handleTemplate } from \"./internal/template\";\nimport type {\n EWViewerDocument,\n EWViewerOptions,\n EWViewerOptionsUnion,\n EWViewerParamItem,\n ImageMeta,\n} from \"./types\";\n\n/** 滑动过渡时长(ms),与 viewer.css 中 .ew-viewer-track 的 transition 保持一致 */\nconst SLIDE_DURATION = 450;\nconst CLOSE_ROLES = new Set([\n \"mask\",\n \"content\",\n \"footer\",\n \"title\",\n \"toolbar\",\n \"thumb\",\n \"close\",\n]);\n\n/** 内部使用的补全配置,所有字段在构造时都有确定值 */\ninterface ViewerConfig {\n container?: HTMLElement | string;\n isClickOutside: boolean;\n previewMode: \"bg\" | \"img\";\n showCloseBtn: boolean;\n showCloseBtnIcon: string;\n closeTime: number;\n zoomOnWheeling: boolean;\n autoSize: boolean;\n minImageRatio: number;\n maxImageRatio: number;\n showToolBar: boolean;\n zoomInIcon: string;\n zoomOutIcon: string;\n oneToOneIcon: string;\n currentImageIndex: number;\n autoOpen: boolean;\n flipLeftIcon: string;\n flipRightIcon: string;\n rotateLeftIcon: string;\n rotateRightIcon: string;\n resetIcon: string;\n prevIcon: string;\n nextIcon: string;\n fullscreenIcon: string;\n playIcon: string;\n pauseIcon: string;\n minRotate: number;\n maxRotate: number;\n loop: boolean;\n imageRatio?: number;\n interval?: number;\n zIndex: number;\n}\n\nconst DEFAULT_CONFIG: ViewerConfig = {\n isClickOutside: true,\n previewMode: \"bg\",\n showCloseBtn: true,\n showCloseBtnIcon: closeIcon(handleClassName(\"ew-viewer-close-icon\")),\n closeTime: 200,\n zoomOnWheeling: true,\n autoSize: true,\n minImageRatio: 0.1,\n maxImageRatio: 1,\n showToolBar: true,\n zoomInIcon: addIcon(handleClassName(\"ew-viewer-zoom-in-icon\")),\n zoomOutIcon: reduceIcon(handleClassName(\"ew-viewer-zoom-out-icon\")),\n oneToOneIcon: oneToOneIcon(handleClassName(\"ew-viewer-one-to-one-icon\")),\n currentImageIndex: 0,\n autoOpen: false,\n flipLeftIcon: flipLeftIcon(handleClassName(\"ew-viewer-flip-left-icon\")),\n flipRightIcon: flipRightIcon(handleClassName(\"ew-viewer-flip-right-icon\")),\n rotateLeftIcon: rotateLeftIcon(handleClassName(\"ew-viewer-rotate-left-icon\")),\n rotateRightIcon: rotateRightIcon(\n handleClassName(\"ew-viewer-rotate-right-icon\")\n ),\n resetIcon: resetIcon(handleClassName(\"ew-viewer-reset-icon\")),\n prevIcon: arrowLeftIcon(handleClassName(\"ew-viewer-prev-icon\")),\n nextIcon: arrowRightIcon(handleClassName(\"ew-viewer-next-icon\")),\n fullscreenIcon: fullscreenIcon(handleClassName(\"ew-viewer-fullscreen-icon\")),\n playIcon: playIcon(handleClassName(\"ew-viewer-play-icon\")),\n pauseIcon: pauseIcon(handleClassName(\"ew-viewer-pause-icon\")),\n minRotate: -Infinity,\n maxRotate: Infinity,\n loop: true,\n zIndex: 2000,\n};\n\n/** 合并配置,忽略值为 undefined 的键,避免用户显式传 undefined 时覆盖默认值 */\nfunction mergeConfig<T extends object>(base: T, patch?: object | null): T {\n if (!patch) {\n return extend({}, base) as T;\n }\n const source = patch as Record<string, unknown>;\n const defined: Record<string, unknown> = {};\n Object.keys(source).forEach((key) => {\n if (source[key] !== undefined) {\n defined[key] = source[key];\n }\n });\n return extend({}, base, defined) as T;\n}\n\n/** 把图片入参统一成 src 字符串 */\nfunction toImageSource(item: EWViewerParamItem): string | null {\n if (isString(item)) {\n return item.trim() || null;\n }\n if (isDom(item)) {\n const el = item as HTMLImageElement;\n const src = el.getAttribute?.(\"src\") ?? el.src;\n return src || null;\n }\n return null;\n}\n\n/** 加载图片并读取原始尺寸;加载失败返回 null,作为“无效图片”的唯一判定入口 */\nfunction measure(src: string): Promise<ImageMeta | null> {\n return new Promise((resolve) => {\n const img = new Image();\n img.onload = () =>\n resolve({\n naturalWidth: img.naturalWidth,\n naturalHeight: img.naturalHeight,\n scaleWidth: 0,\n scaleHeight: 0,\n scaleX: 0,\n scaleY: 0,\n rotate: 0,\n });\n img.onerror = () => resolve(null);\n img.src = src;\n });\n}\n\nfunction normalizeRatio(value?: number): number {\n const ratio = Number(value);\n return isValidNumber(ratio) && ratio > 0 && ratio <= 1 ? ratio : 0.9;\n}\n\nfunction fullscreenElementOf(doc: EWViewerDocument): Element | null {\n return (\n doc.fullscreenElement ||\n doc.webkitFullscreenElement ||\n doc.mozFullScreenElement ||\n doc.msFullscreenElement ||\n null\n );\n}\n\n/** 通过 data-ew-role 定位事件来源,替代原来的 className 字符串匹配 */\nfunction roleOf(target: EventTarget | null): string | null {\n const el = target as HTMLElement | null;\n const owner = el?.closest?.(\"[data-ew-role]\") as HTMLElement | null;\n return owner?.getAttribute(\"data-ew-role\") ?? null;\n}\n\nclass EWViewer {\n config: ViewerConfig = mergeConfig(DEFAULT_CONFIG);\n options?: EWViewerOptionsUnion;\n imageDataList: string[] = [];\n imageStyle: ImageMeta[] = [];\n currentImageIndex = 0;\n computedImageRatio = 0.9;\n wheeling = false;\n isClickZoomIn = false;\n isClickZoomOut = false;\n isClickOneToOne = false;\n fullScreenStatus = false;\n isPlaying = false;\n $dom: Record<string, HTMLElement | null> = {};\n\n private ac: AbortController | null = null;\n private timers = new Set<ReturnType<typeof setTimeout>>();\n private carouselTimer: ReturnType<typeof setTimeout> | null = null;\n private rafId: number | null = null;\n private pendingOpen: { time?: number } | null = null;\n private seq = 0;\n /** 轨道位移位置:0 为首图前置克隆位,1 ~ n 为真实图片,n + 1 为尾图后继克隆位 */\n private slidePos = 1;\n\n constructor(options: EWViewerOptionsUnion) {\n if (!isBrowser) {\n logger.warn(\"EWViewer 只能在浏览器环境中使用\");\n return;\n }\n this.computedImageRatio = normalizeRatio(this.config.imageRatio);\n this.reload(options);\n }\n\n /** 依次完成“解析入参 → 注入样式 → 渲染”,并用序号丢弃过期的异步结果 */\n private reload(options: EWViewerOptionsUnion) {\n const token = ++this.seq;\n void this.init(options).then((ok) => {\n if (token !== this.seq || !ok) {\n return;\n }\n void this.render();\n });\n }\n\n private async resolveImages(items: EWViewerParamItem[]): Promise<boolean> {\n const sources = items\n .map(toImageSource)\n .filter((item): item is string => !!item);\n if (sources.length === 0) {\n logger.warn(\"传入的图片地址不合法\");\n return false;\n }\n const metas = await Promise.all(sources.map(measure));\n const list: string[] = [];\n const styles: ImageMeta[] = [];\n metas.forEach((meta, index) => {\n if (!meta) {\n logger.warn(`图片加载失败,已忽略:${sources[index]}`);\n return;\n }\n list.push(sources[index]);\n styles.push(meta);\n });\n if (list.length === 0) {\n return false;\n }\n this.imageDataList = list;\n this.imageStyle = styles;\n const index = this.config.currentImageIndex;\n this.currentImageIndex =\n isValidNumber(index) && index >= 0 && index < list.length ? index : 0;\n return true;\n }\n\n /** 解析入参:字符串 / img 元素 / 数组 / 配置对象,返回是否拿到可用图片 */\n async init(options: EWViewerOptionsUnion): Promise<boolean> {\n if (isString(options) || isDom(options)) {\n return this.resolveImages([options as EWViewerParamItem]);\n }\n if (Array.isArray(options)) {\n return this.resolveImages(options as EWViewerParamItem[]);\n }\n if (isObject(options)) {\n const { img, ...rest } = options as EWViewerOptions;\n this.config = mergeConfig(this.config, rest);\n this.validateRatio();\n this.computedImageRatio = normalizeRatio(this.config.imageRatio);\n if (img === undefined || img === null) {\n logger.warn(\"未提供 img 参数\");\n return false;\n }\n return this.resolveImages(Array.isArray(img) ? img : [img]);\n }\n logger.warn(\"传入的参数不合法\");\n return false;\n }\n\n private validateRatio() {\n const { minImageRatio, maxImageRatio } = this.config;\n if (!this.rangeRation(minImageRatio)) {\n this.config.minImageRatio = 0.1;\n logger.warn(\"minImageRatio 应在 0 到 1 之间\");\n }\n if (!this.rangeRation(maxImageRatio)) {\n this.config.maxImageRatio = 1;\n logger.warn(\"maxImageRatio 应在 0 到 1 之间\");\n }\n if (this.config.minImageRatio > this.config.maxImageRatio) {\n logger.warn(\"minImageRatio 不应大于 maxImageRatio\");\n }\n }\n\n rangeRation(ratio?: number) {\n if (!isNumber(ratio)) {\n return false;\n }\n return ratio >= 0 && ratio <= 1;\n }\n\n async render(): Promise<void> {\n this.teardown();\n const container = checkContainer(this.config.container);\n const meta = this.currentMeta();\n if (!container || !meta) {\n return;\n }\n const {\n previewMode,\n showCloseBtn,\n showCloseBtnIcon,\n showToolBar,\n } = this.config;\n const currentImage = this.imageDataList[this.currentImageIndex] ?? \"\";\n const ratioText = `${Math.floor(this.computedImageRatio * 100)}%`;\n const hasMultiple = this.imageDataList.length > 1;\n\n const zoomButtonTemplate = `\n <div class=\"ew-viewer-zoom-in\" data-ew-role=\"zoom-in\">${\n this.config.zoomInIcon\n }</div>\n <div class=\"ew-viewer-zoom-out\" data-ew-role=\"zoom-out\">${\n this.config.zoomOutIcon\n }</div>\n <div class=\"ew-viewer-one-to-one\" data-ew-role=\"one-to-one\">${\n this.config.oneToOneIcon\n }</div>\n <div class=\"ew-viewer-reset\" data-ew-role=\"reset\">${\n this.config.resetIcon\n }</div>\n <div class=\"ew-viewer-fullscreen\" data-ew-role=\"fullscreen\">${\n this.config.fullscreenIcon\n }</div>\n ${handleTemplate(\n hasMultiple,\n `<div class=\"ew-viewer-prev\" data-ew-role=\"prev\">${this.config.prevIcon}</div>`\n )}\n ${handleTemplate(\n hasMultiple,\n `<div class=\"ew-viewer-play\" data-ew-role=\"play\">${\n this.isPlaying ? this.config.pauseIcon : this.config.playIcon\n }</div>`\n )}\n ${handleTemplate(\n hasMultiple,\n `<div class=\"ew-viewer-next\" data-ew-role=\"next\">${this.config.nextIcon}</div>`\n )}\n <div class=\"ew-viewer-rotate-left\" data-ew-role=\"rotate-left\">${\n this.config.rotateLeftIcon\n }</div>\n <div class=\"ew-viewer-rotate-right\" data-ew-role=\"rotate-right\">${\n this.config.rotateRightIcon\n }</div>\n <div class=\"ew-viewer-flip-horizontal\" data-ew-role=\"flip-horizontal\">${\n this.config.flipLeftIcon\n }</div>\n <div class=\"ew-viewer-flip-vertical\" data-ew-role=\"flip-vertical\">${\n this.config.flipRightIcon\n }</div>\n `;\n\n const slideTemplate = (item: string, index: number, clone = false) => `\n <div class=\"ew-viewer-img-box${handleClassName(\n index === this.currentImageIndex ? \"show\" : \"\"\n )}\" data-index=\"${index}\" data-ew-role=\"image\"${\n clone ? ' data-clone=\"true\"' : \"\"\n }>\n ${\n previewMode === \"bg\"\n ? `<div class=\"ew-viewer-bg-img\" style=\"background-image:url(${item});\"></div>`\n : `<img src=\"${item}\" class=\"ew-viewer-img\" />`\n }\n </div>`;\n\n const imgListTemplate = this.imageDataList\n .map((item, index) => slideTemplate(item, index))\n .join(\"\");\n // 首尾各放一个克隆位,配合轨道位移实现无缝循环\n const trackTemplate = `<div class=\"ew-viewer-track\">\n ${handleTemplate(\n hasMultiple,\n slideTemplate(\n this.imageDataList[this.imageDataList.length - 1],\n this.imageDataList.length - 1,\n true\n )\n )}\n ${imgListTemplate}\n ${handleTemplate(\n hasMultiple,\n slideTemplate(this.imageDataList[0], 0, true)\n )}\n </div>`;\n\n const imgThumbListTemplate = this.imageDataList\n .map(\n (item, index) =>\n `<img src=\"${item}\" class=\"ew-viewer-thumb-img${handleClassName(\n index === this.currentImageIndex ? \"active\" : \"\"\n )}\" data-index=\"${index}\"/>`\n )\n .join(\"\");\n\n const root = createElement<HTMLElement>(`<div class=\"ew-viewer hidden\">\n <div class=\"ew-viewer-mask\" data-ew-role=\"mask\">\n <div class=\"ew-viewer-content\" data-ew-role=\"content\">${trackTemplate}</div>\n <div class=\"ew-viewer-tooltip-ratio hidden\" data-ew-role=\"tooltip\">${ratioText}</div>\n <div class=\"ew-viewer-footer\" data-ew-role=\"footer\">\n <div class=\"ew-viewer-title\" data-ew-role=\"title\">${this.getImageNameFromURL(\n currentImage\n )}(${meta.naturalWidth} x ${meta.naturalHeight})</div>\n ${handleTemplate(\n showToolBar,\n `<div class=\"ew-viewer-button\" data-ew-role=\"toolbar\">${zoomButtonTemplate}</div>`\n )}\n ${handleTemplate(\n hasMultiple,\n `<div class=\"ew-viewer-thumb\" data-ew-role=\"thumb\">${imgThumbListTemplate}</div>`\n )}\n </div>\n ${handleTemplate(\n showCloseBtn,\n `<span class=\"ew-viewer-close-btn\" data-ew-role=\"close\">${showCloseBtnIcon}</span>`\n )}\n </div>\n </div>`);\n if (!root) {\n return;\n }\n if (isValidNumber(this.config.zIndex)) {\n root.style.setProperty(\"--ew-viewer-z-index\", `${this.config.zIndex}`);\n }\n container.appendChild(root);\n\n // 只在本次创建的根节点内查询,避免同容器多实例互相命中\n this.$dom.$el = root;\n this.$dom.$viewerContentElement = $(\".ew-viewer-content\", root);\n this.$dom.$viewerTrackElement = $(\".ew-viewer-track\", root);\n this.$dom.$viewerRatioTooltipElement = $(\".ew-viewer-tooltip-ratio\", root);\n this.$dom.$viewerToolbarElement = $(\".ew-viewer-button\", root);\n this.$dom.$viewerThumbElement = $(\".ew-viewer-thumb\", root);\n this.$dom.$viewerTitleElement = $(\".ew-viewer-title\", root);\n\n this.slidePos = this.indexToPos(this.currentImageIndex);\n this.setTrackPosition(this.slidePos, false);\n\n this.bindEvent();\n\n const pending = this.pendingOpen;\n this.pendingOpen = null;\n if (pending) {\n this.open(pending.time);\n } else if (this.config.autoOpen) {\n this.open();\n }\n }\n\n private bindEvent() {\n const el = this.$dom.$el;\n if (!el) {\n return;\n }\n this.ac = new AbortController();\n const { signal } = this.ac;\n on(el, \"click\", this.handleRootClick, { signal });\n if (this.config.autoSize) {\n on(window, \"resize\", this.handleResize, { signal });\n }\n if (this.config.zoomOnWheeling) {\n on(el, \"wheel\", this.handleWheel, { signal });\n }\n const toolbar = this.$dom.$viewerToolbarElement;\n if (toolbar) {\n on(toolbar, \"click\", this.handleToolbarClick, { signal });\n }\n const thumb = this.$dom.$viewerThumbElement;\n if (thumb) {\n on(thumb, \"click\", this.handleThumbClick, { signal });\n }\n }\n\n private handleRootClick = (e: Event) => {\n const role = roleOf(e.target);\n if (role === \"fullscreen\") {\n return;\n }\n if (this.fullScreenStatus) {\n this.exitFullscreen();\n this.fullScreenStatus = false;\n return;\n }\n if (this.config.isClickOutside && role !== null && CLOSE_ROLES.has(role)) {\n this.close();\n }\n };\n\n private handleResize = () => {\n if (this.rafId !== null) {\n return;\n }\n if (typeof requestAnimationFrame !== \"function\") {\n this.setImageStyle();\n return;\n }\n this.rafId = requestAnimationFrame(() => {\n this.rafId = null;\n this.setImageStyle();\n });\n };\n\n private handleWheel = (e: Event) => {\n e.preventDefault();\n if (this.wheeling) {\n return;\n }\n this.wheeling = true;\n this.setTimer(() => {\n this.wheeling = false;\n }, 150);\n this.viewedImageHandler((e as WheelEvent).deltaY < 0);\n };\n\n private handleThumbClick = (e: Event) => {\n e.stopPropagation();\n const target = e.target as HTMLElement | null;\n if (!target?.className?.includes?.(\"ew-viewer-thumb-img\")) {\n return;\n }\n const index = Number(target.getAttribute(\"data-index\"));\n if (!isValidNumber(index)) {\n return;\n }\n this.currentImageIndex = index;\n this.changeThumbImage();\n this.slideTo(index);\n this.setImageStyle();\n };\n\n private handleToolbarClick = (e: Event) => {\n const meta = this.currentMeta();\n if (!meta) {\n return;\n }\n const { minRotate, maxRotate } = this.config;\n switch (roleOf(e.target)) {\n case \"zoom-in\":\n if (this.isClickZoomIn) {\n return;\n }\n this.isClickZoomIn = true;\n this.setTimer(() => {\n this.isClickZoomIn = false;\n }, 50);\n this.viewedImageHandler(true);\n break;\n case \"zoom-out\":\n if (this.isClickZoomOut) {\n return;\n }\n this.isClickZoomOut = true;\n this.setTimer(() => {\n this.isClickZoomOut = false;\n }, 50);\n this.viewedImageHandler(false);\n break;\n case \"one-to-one\": {\n if (this.isClickOneToOne) {\n return;\n }\n this.isClickOneToOne = true;\n this.setTimer(() => {\n this.isClickOneToOne = false;\n }, 50);\n this.viewedImageHandler(this.computedImageRatio === 1 ? 0.5 : 1);\n break;\n }\n case \"rotate-left\":\n meta.rotate -= 90;\n if (isNumber(minRotate) && minRotate !== -Infinity && meta.rotate <= minRotate) {\n meta.rotate = minRotate;\n }\n this.setImageStyle();\n break;\n case \"rotate-right\":\n meta.rotate += 90;\n if (\n isNumber(maxRotate) &&\n maxRotate !== Infinity &&\n meta.rotate >= maxRotate\n ) {\n meta.rotate = maxRotate;\n }\n this.setImageStyle();\n break;\n case \"flip-horizontal\":\n meta.scaleX = meta.scaleX === -1 ? 0 : -1;\n this.setImageStyle();\n break;\n case \"flip-vertical\":\n meta.scaleY = meta.scaleY === -1 ? 0 : -1;\n this.setImageStyle();\n break;\n case \"reset\":\n this.resetImage();\n break;\n case \"prev\":\n this.manualGo(-1);\n break;\n case \"next\":\n this.manualGo(1);\n break;\n case \"fullscreen\":\n this.fullScreenStatus = !this.fullScreenStatus;\n if (this.fullScreenStatus) {\n this.requestFullscreen();\n } else {\n this.exitFullscreen();\n }\n break;\n case \"play\":\n this.togglePlay();\n break;\n default:\n break;\n }\n };\n\n private currentMeta(): ImageMeta | null {\n return this.imageStyle[this.currentImageIndex] ?? null;\n }\n\n private get interval() {\n const value = Number(this.config.interval);\n return isValidNumber(value) && value > 0 ? value : 5000;\n }\n\n private setTimer(fn: () => void, ms: number) {\n const id = setTimeout(() => {\n this.timers.delete(id);\n fn();\n }, ms);\n this.timers.add(id);\n return id;\n }\n\n private clearTimers() {\n this.timers.forEach((id) => clearTimeout(id));\n this.timers.clear();\n }\n\n private teardown() {\n this.ac?.abort();\n this.ac = null;\n this.clearTimers();\n this.carouselTimer = null;\n if (this.rafId !== null) {\n if (typeof cancelAnimationFrame === \"function\") {\n cancelAnimationFrame(this.rafId);\n }\n this.rafId = null;\n }\n this.$dom.$el?.remove();\n this.$dom = {};\n }\n\n private stopCarousel() {\n if (this.carouselTimer === null) {\n return;\n }\n clearTimeout(this.carouselTimer);\n this.timers.delete(this.carouselTimer);\n this.carouselTimer = null;\n }\n\n /** 真实下标对应的轨道位置:多图时前面有首图克隆位,单图没有克隆位 */\n private indexToPos(index: number) {\n return this.imageDataList.length > 1 ? index + 1 : 0;\n }\n\n /** 把轨道整体平移到指定位置;animate 为 false 时无声跳转,用于首尾无缝衔接 */\n private setTrackPosition(pos: number, animate: boolean) {\n const track = this.$dom.$viewerTrackElement;\n if (!track) {\n return;\n }\n this.slidePos = pos;\n const offset = pos === 0 ? \"0\" : `${-pos * 100}%`;\n const transform = `translate3d(${offset}, 0, 0)`;\n if (animate) {\n track.style.removeProperty(\"transition\");\n track.style.transform = transform;\n return;\n }\n track.style.transition = \"none\";\n track.style.transform = transform;\n void track.offsetWidth;\n track.style.removeProperty(\"transition\");\n }\n\n /** 滑到指定下标;delta 用于判断是否走了首尾循环,从而选择克隆位作为落点 */\n private slideTo(index: number, delta?: number) {\n const length = this.imageDataList.length;\n if (length <= 1) {\n return;\n }\n // 若上一次还停在克隆位,先无声归位,避免这次滑动跨越整条轨道\n if (this.slidePos === 0) {\n this.setTrackPosition(length, false);\n } else if (this.slidePos === length + 1) {\n this.setTrackPosition(1, false);\n }\n let pos = index + 1;\n if (delta !== undefined && delta > 0 && index === 0) {\n pos = length + 1;\n } else if (delta !== undefined && delta < 0 && index === length - 1) {\n pos = 0;\n }\n this.setTrackPosition(pos, true);\n // 动画结束后把克隆位换回真实位,视觉上完全一致但位移基准归位\n this.setTimer(() => {\n if (this.slidePos === 0) {\n this.setTrackPosition(length, false);\n } else if (this.slidePos === length + 1) {\n this.setTrackPosition(1, false);\n }\n }, SLIDE_DURATION + 50);\n }\n\n private startCarousel() {\n this.stopCarousel();\n const step = () => {\n this.go(1);\n this.carouselTimer = this.setTimer(step, this.interval);\n };\n this.carouselTimer = this.setTimer(step, this.interval);\n }\n\n private go(delta: number) {\n const length = this.imageDataList.length;\n if (length === 0) {\n return;\n }\n const prevIndex = this.currentImageIndex;\n let index = this.currentImageIndex + delta;\n const loop = this.config.loop || this.isPlaying;\n if (index < 0) {\n index = loop ? length - 1 : 0;\n }\n if (index > length - 1) {\n index = loop ? 0 : length - 1;\n }\n this.currentImageIndex = index;\n this.changeThumbImage();\n void this.setImageStyle();\n if (index !== prevIndex) {\n this.slideTo(index, delta);\n }\n }\n\n private manualGo(delta: number) {\n this.go(delta);\n if (this.isPlaying) {\n this.startCarousel();\n }\n }\n\n private togglePlay() {\n this.isPlaying = !this.isPlaying;\n const toolbar = this.$dom.$viewerToolbarElement;\n const playButton = toolbar\n ? ($(\".ew-viewer-play\", toolbar) as HTMLElement | null)\n : null;\n if (playButton) {\n playButton.innerHTML = this.isPlaying\n ? this.config.pauseIcon\n : this.config.playIcon;\n }\n if (this.isPlaying) {\n this.startCarousel();\n } else {\n this.stopCarousel();\n }\n }\n\n /** 按当前缩放比例计算某张图片在预览区内的显示尺寸 */\n private imageSize(meta: ImageMeta, contentEl: HTMLElement) {\n const { offsetWidth: width, offsetHeight: height } = contentEl;\n const imgAspectRatio = meta.naturalWidth / meta.naturalHeight;\n let resizeWidth = width;\n let resizeHeight = height;\n if (height * imgAspectRatio > width) {\n resizeHeight = width / imgAspectRatio;\n } else {\n resizeWidth = height * imgAspectRatio;\n }\n return {\n width: Math.min(\n resizeWidth * this.computedImageRatio,\n meta.naturalWidth\n ),\n height: Math.min(\n resizeHeight * this.computedImageRatio,\n meta.naturalHeight\n ),\n };\n }\n\n private scaleImageCallback() {\n const contentEl = this.$dom.$viewerContentElement;\n const meta = this.currentMeta();\n if (!contentEl || !meta) {\n return;\n }\n const { width, height } = this.imageSize(meta, contentEl);\n meta.scaleWidth = width;\n meta.scaleHeight = height;\n const tooltip = this.$dom.$viewerRatioTooltipElement;\n if (tooltip) {\n tooltip.textContent = `${Math.floor(this.computedImageRatio * 100)}%`;\n }\n }\n\n async setImageStyle(status = true) {\n const contentEl = this.$dom.$viewerContentElement;\n const meta = this.currentMeta();\n if (!contentEl || !meta) {\n return;\n }\n if (status) {\n this.scaleImageCallback();\n }\n const track = this.$dom.$viewerTrackElement;\n const boxes = track ? ([...track.children] as HTMLElement[]) : [];\n boxes.forEach((box) => {\n const index = Number(box.getAttribute(\"data-index\"));\n const item = this.imageStyle[index];\n const img = box.firstElementChild as HTMLElement | null;\n if (!item || !img) {\n return;\n }\n if (index === this.currentImageIndex) {\n addClass(box, \"show\");\n } else {\n removeClass(box, \"show\");\n }\n const { width, height } = this.imageSize(item, contentEl);\n img.style.width = `${width}px`;\n img.style.height = `${height}px`;\n if (this.config.previewMode === \"bg\") {\n img.style.backgroundSize = `${width}px ${height}px`;\n }\n img.style.removeProperty(\"transform\");\n const transform = `${\n item.rotate !== 0 ? `rotate(${item.rotate}deg)` : \"\"\n } ${item.scaleX !== 0 ? `scaleX(${item.scaleX})` : \"\"} ${\n item.scaleY !== 0 ? `scaleY(${item.scaleY})` : \"\"\n }`.trim();\n if (transform) {\n img.style.transform = transform;\n }\n });\n const titleEl = this.$dom.$viewerTitleElement;\n if (titleEl) {\n const currentImage = this.imageDataList[this.currentImageIndex] ?? \"\";\n titleEl.innerHTML = `${this.getImageNameFromURL(currentImage)}(${\n meta.naturalWidth\n } x ${meta.naturalHeight})`;\n }\n }\n\n getImageNameFromURL(url: string) {\n return isString(url)\n ? decodeURIComponent(url.replace(/^.*\\//, \"\").replace(/[?&#].*$/, \"\"))\n : \"\";\n }\n\n computedImageRatioHandler(status: boolean) {\n const { minImageRatio, maxImageRatio } = this.config;\n const delta = status ? 1 : -1;\n const ratio =\n this.computedImageRatio +\n delta * (Math.floor(Math.random() * 100) / 1000);\n this.computedImageRatio = Math.max(\n minImageRatio,\n Math.min(ratio, maxImageRatio)\n );\n }\n\n viewedImageHandler(value: boolean | number) {\n if (isBoolean(value)) {\n this.computedImageRatioHandler(value);\n } else {\n this.computedImageRatio = value;\n }\n this.toggleTooltip(true);\n this.setTimer(() => this.toggleTooltip(false), 1000);\n void this.setImageStyle();\n }\n\n changeThumbImage() {\n const thumbEl = this.$dom.$viewerThumbElement;\n if (!thumbEl) {\n return;\n }\n const children = [...thumbEl.children] as HTMLImageElement[];\n children.forEach((item) => {\n const index = Number(item.getAttribute(\"data-index\"));\n if (index === this.currentImageIndex) {\n addClass(item, \"active\");\n } else {\n removeClass(item, \"active\");\n }\n });\n }\n\n private getFullscreenTarget(): HTMLElement | null {\n const contentEl = this.$dom.$viewerContentElement;\n if (!contentEl) {\n return null;\n }\n return $(\".ew-viewer-img-box.show\", contentEl) as HTMLElement | null;\n }\n\n requestFullscreen() {\n const target = this.getFullscreenTarget();\n const doc = (target?.ownerDocument ?? document) as EWViewerDocument;\n if (fullscreenElementOf(doc)) {\n return;\n }\n const root = doc.documentElement;\n if (typeof root.requestFullscreen === \"function\") {\n void root.requestFullscreen();\n } else if (typeof root.webkitRequestFullscreen === \"function\") {\n root.webkitRequestFullscreen();\n } else if (typeof root.mozRequestFullScreen === \"function\") {\n root.mozRequestFullScreen();\n } else if (typeof root.msRequestFullscreen === \"function\") {\n root.msRequestFullscreen();\n }\n }\n\n exitFullscreen() {\n const target = this.getFullscreenTarget();\n const doc = (target?.ownerDocument ?? document) as EWViewerDocument;\n if (!fullscreenElementOf(doc)) {\n return;\n }\n if (typeof doc.exitFullscreen === \"function\") {\n void doc.exitFullscreen();\n } else if (typeof doc.webkitExitFullscreen === \"function\") {\n doc.webkitExitFullscreen();\n } else if (typeof doc.mozCancelFullScreen === \"function\") {\n doc.mozCancelFullScreen();\n } else if (typeof doc.msExitFullscreen === \"function\") {\n doc.msExitFullscreen();\n }\n }\n\n resetImage() {\n this.computedImageRatio = normalizeRatio(this.config.imageRatio);\n const meta = this.currentMeta();\n if (!meta) {\n return;\n }\n meta.rotate = 0;\n meta.scaleX = 0;\n meta.scaleY = 0;\n void this.setImageStyle();\n }\n\n toggleTooltip(status: boolean) {\n const tooltip = this.$dom.$viewerRatioTooltipElement;\n if (!tooltip) {\n return;\n }\n this.setTimer(() => {\n addClass(tooltip, status ? \"show\" : \"hidden\");\n removeClass(tooltip, status ? \"hidden\" : \"show\");\n }, 100);\n }\n\n baseToggle(status: boolean, time?: number) {\n const { closeTime } = this.config;\n const el = this.$dom.$el;\n if (!el) {\n return;\n }\n this.setTimer(\n () => {\n addClass(el, status ? \"show\" : \"hidden\");\n removeClass(el, status ? \"hidden\" : \"show\");\n },\n time || closeTime\n );\n }\n\n async close(time?: number) {\n this.resetImage();\n this.stopCarousel();\n this.isPlaying = false;\n this.baseToggle(false, time);\n }\n\n viewImage(index?: number) {\n if (\n isNumber(index) &&\n index >= 0 &&\n index <= this.imageDataList.length - 1\n ) {\n this.currentImageIndex = index;\n }\n this.open();\n }\n\n open(time?: number) {\n if (!this.$dom.$el) {\n this.pendingOpen = { time };\n return;\n }\n this.changeThumbImage();\n this.setTrackPosition(this.indexToPos(this.currentImageIndex), false);\n void this.setImageStyle();\n this.baseToggle(true, time);\n }\n\n /** 用最新入参重建整个预览层 */\n update() {\n if (!this.options) {\n return;\n }\n this.reload(this.options);\n }\n\n /** 完整销毁:解绑监听、清空定时器、移除节点,可重复调用 */\n destroy() {\n this.teardown();\n this.isPlaying = false;\n this.fullScreenStatus = false;\n this.pendingOpen = null;\n }\n}\n\nexport default EWViewer;\n\nexport type InstanceViewer = InstanceType<typeof EWViewer>;\n"],"names":["logger","createConsoleLogger","addIcon","className","reduceIcon","closeIcon","oneToOneIcon","flipRightIcon","flipLeftIcon","rotateLeftIcon","rotateRightIcon","arrowLeftIcon","arrowRightIcon","resetIcon","fullscreenIcon","playIcon","pauseIcon","createElement","html","wrapper","handleTemplate","condition","template","isBoolean","isString","SLIDE_DURATION","CLOSE_ROLES","DEFAULT_CONFIG","handleClassName","mergeConfig","base","patch","extend","source","defined","key","toImageSource","item","isDom","el","measure","src","resolve","img","normalizeRatio","value","ratio","isValidNumber","fullscreenElementOf","doc","roleOf","target","EWViewer","options","__publicField","role","index","meta","minRotate","maxRotate","isNumber","isBrowser","token","ok","items","sources","metas","list","styles","isObject","rest","minImageRatio","maxImageRatio","container","checkContainer","previewMode","showCloseBtn","showCloseBtnIcon","showToolBar","currentImage","ratioText","hasMultiple","zoomButtonTemplate","slideTemplate","clone","imgListTemplate","trackTemplate","imgThumbListTemplate","root","$","pending","signal","on","toolbar","thumb","fn","ms","id","pos","animate","track","transform","delta","length","step","prevIndex","loop","playButton","contentEl","width","height","imgAspectRatio","resizeWidth","resizeHeight","tooltip","status","box","addClass","removeClass","titleEl","url","thumbEl","time","closeTime"],"mappings":"0TAmBaA,EAASC,EAAAA,oBAAoB,CACxC,OAAQ,YACR,UAAW,EACb,CAAC,ECpBYC,EAAWC,GAAuB,yCAAyCA,CAAS,uSACpFC,EAAcD,GAAuB,4CAA4CA,CAAS,sPAC1FE,EAAaF,GAAuB,2CAA2CA,CAAS,2fACxFG,EAAg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viewer';
3
+ export type { EWViewerDocument, EWViewerOptions, EWViewerOptionsUnion, EWViewerParam, EWViewerParamItem, ImageMeta, } from './types';