@flyfish-group/file-viewer3 1.0.6 → 1.0.8
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 +66 -7
- package/dist/components/CadViewer.js +1 -1
- package/dist/components/CodeViewer.js +1 -1
- package/dist/components/ImageViewer.js +1 -1
- package/dist/components/MarkdownViewer.js +1 -1
- package/dist/components/OfdViewer.js +1 -1
- package/dist/components/PdfView.js +1 -1
- package/dist/components/PptxRender.js +1 -1
- package/dist/components/XlsxTable.js +1 -1
- package/dist/components/_plugin-vue_export-helper.js +1 -1
- package/dist/components/asyncToGenerator.js +1 -1
- package/dist/components/chunk.js +1 -1
- package/dist/components/dist.js +1 -1
- package/dist/components/docx-preview.js +1 -1
- package/dist/components/jszip.min.js +1 -1
- package/dist/components/objectSpread2.js +1 -1
- package/dist/components/ofd.js +1 -1
- package/dist/components/use.js +1 -1
- package/dist/components/worker-ref.js +1 -1
- package/dist/components/wrapAsyncGenerator.js +1 -1
- package/dist/file-viewer3.css +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/src/package/common/type.d.ts +16 -5
- package/dist/src/package/components/FileViewer/FileViewer.vue.d.ts +12 -0
- package/dist/src/package/index.d.ts +4 -1
- package/dist/worker/pptx.worker.js +1 -1
- package/dist/worker/sheet.worker.js +1 -1
- package/package.json +2 -1
|
@@ -1,28 +1,39 @@
|
|
|
1
1
|
import { App } from 'vue';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* 渲染器返回的 Vue 包装实例。
|
|
4
|
+
*
|
|
5
|
+
* Vue3 渲染器直接返回 `App`,少量兼容渲染器会返回只暴露 `$el`
|
|
6
|
+
* 与 `unmount()` 的轻量包装对象。
|
|
4
7
|
*/
|
|
5
8
|
export interface AppWrapper {
|
|
6
9
|
$el: Node;
|
|
7
10
|
unmount(): void;
|
|
8
11
|
}
|
|
9
12
|
/**
|
|
10
|
-
*
|
|
13
|
+
* 任意渲染器挂载完成后返回的可卸载实例。
|
|
11
14
|
*/
|
|
12
15
|
export type Rendered = App | AppWrapper;
|
|
13
16
|
/**
|
|
14
|
-
*
|
|
17
|
+
* 组件可接受的本地二进制来源。
|
|
18
|
+
*
|
|
19
|
+
* 对外接入时最推荐传入带正确文件名的 `File`。如果业务侧拿到的是
|
|
20
|
+
* `Blob` 或 `ArrayBuffer`,请先包装成 `new File([...], 'demo.pdf')`,
|
|
21
|
+
* 这样渲染器才能通过扩展名选择正确的预览链路。
|
|
15
22
|
*/
|
|
16
23
|
export type FileRef = File | Blob | ArrayBuffer;
|
|
17
24
|
/**
|
|
18
|
-
*
|
|
25
|
+
* 文件处理逻辑,用于声明具体格式的异步渲染器。
|
|
26
|
+
*
|
|
27
|
+
* 渲染器只在命中文件扩展名时被按需加载,避免 PDF、OFD、CAD、Office
|
|
28
|
+
* 等重型依赖进入无关格式的首屏路径。
|
|
29
|
+
*
|
|
19
30
|
* @param buffer 二进制缓存
|
|
20
31
|
* @param target 目标dom
|
|
21
32
|
* @param type 目标扩展名。部分渲染器会用它选择语言、容错策略或格式提示。
|
|
22
33
|
*/
|
|
23
34
|
export type FileHandler = (buffer: ArrayBuffer, target: HTMLDivElement, type?: string) => Promise<Rendered>;
|
|
24
35
|
/**
|
|
25
|
-
*
|
|
36
|
+
* 文件处理器组合。
|
|
26
37
|
*/
|
|
27
38
|
export interface FileHandlerComposite {
|
|
28
39
|
accepts: Array<string>;
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { FileRef } from '../../common/type';
|
|
2
2
|
type __VLS_Props = {
|
|
3
|
+
/**
|
|
4
|
+
* 本地二进制输入。优先级高于 `url`。
|
|
5
|
+
*
|
|
6
|
+
* 推荐传入带正确扩展名的 `File`;如果业务侧只有 Blob 或 ArrayBuffer,
|
|
7
|
+
* 请先包装成 `new File([...], 'demo.pdf')`,保证格式识别稳定。
|
|
8
|
+
*/
|
|
3
9
|
file?: FileRef;
|
|
10
|
+
/**
|
|
11
|
+
* 远端文件地址。组件会在浏览器内下载该地址,再根据路径里的扩展名选择渲染器。
|
|
12
|
+
*
|
|
13
|
+
* 目标资源必须允许浏览器访问;鉴权或无扩展名下载接口建议由宿主侧先取回,
|
|
14
|
+
* 再通过 `file` 参数传入。
|
|
15
|
+
*/
|
|
4
16
|
url?: string;
|
|
5
17
|
};
|
|
6
18
|
declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { default as FileViewer } from './components/FileViewer';
|
|
2
2
|
import { App } from 'vue';
|
|
3
3
|
declare interface FileViewerInstaller {
|
|
4
|
+
/**
|
|
5
|
+
* 全局注册 `<file-viewer>` 组件。
|
|
6
|
+
*/
|
|
4
7
|
install(app: App): void;
|
|
5
8
|
}
|
|
6
9
|
/**
|
|
7
|
-
*
|
|
10
|
+
* Vue3 插件安装器。
|
|
8
11
|
*/
|
|
9
12
|
declare class Installer implements FileViewerInstaller {
|
|
10
13
|
private installed;
|