@veltra/desktop 1.8.4 → 1.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,6 +6,7 @@ import { bem } from "@veltra/utils";
|
|
|
6
6
|
import { createPluginRegistration } from "@embedpdf/core";
|
|
7
7
|
import { EmbedPDF } from "@embedpdf/core/vue";
|
|
8
8
|
import { usePdfiumEngine } from "@embedpdf/engines/vue";
|
|
9
|
+
import rawPdfiumWasmUrl from "@embedpdf/pdfium/pdfium.wasm?url";
|
|
9
10
|
import { DocumentContent, DocumentManagerPluginPackage } from "@embedpdf/plugin-document-manager/vue";
|
|
10
11
|
import { RenderLayer, RenderPluginPackage } from "@embedpdf/plugin-render/vue";
|
|
11
12
|
import { ScrollPluginPackage, Scroller } from "@embedpdf/plugin-scroll/vue";
|
|
@@ -23,7 +24,8 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
23
24
|
const emit = __emit;
|
|
24
25
|
const cls = bem("file-viewer");
|
|
25
26
|
const attrs = useAttrs();
|
|
26
|
-
const
|
|
27
|
+
const pdfiumWasmUrl = new URL(rawPdfiumWasmUrl, import.meta.url).href;
|
|
28
|
+
const { engine, isLoading, error } = usePdfiumEngine({ wasmUrl: pdfiumWasmUrl });
|
|
27
29
|
const pdfUrl = shallowRef("");
|
|
28
30
|
let revoke;
|
|
29
31
|
/** 当前文档的 zoom API(由 PdfZoomBridge 注入) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdf-previewer.js","names":["_openBlock","_createElementBlock","_mergeProps","_unref","_normalizeClass","_createBlock","_withCtx","PdfZoomBridge","_createCommentVNode","_createVNode","PdfViewportScroll","_createElementVNode","_normalizeStyle"],"sources":["../../../../src/components/file-viewer/previewers/pdf-previewer.vue"],"sourcesContent":["<template>\n <div :class=\"cls.e('pdf')\" v-bind=\"attrs\">\n <div v-if=\"!engine || isLoading\" :class=\"cls.e('loading')\">正在加载 PDF 引擎…</div>\n <EmbedPDF v-else-if=\"pdfUrl\" :engine=\"engine\" :plugins=\"plugins\" v-slot=\"{ activeDocumentId }\">\n <PdfZoomBridge\n v-if=\"activeDocumentId\"\n :document-id=\"activeDocumentId\"\n @zoom-change=\"onZoomChange\"\n />\n <DocumentContent\n v-if=\"activeDocumentId\"\n :document-id=\"activeDocumentId\"\n v-slot=\"{ isLoaded }\"\n >\n <Viewport v-if=\"isLoaded\" :document-id=\"activeDocumentId\" :class=\"cls.e('pdf-viewport')\">\n <PdfViewportScroll>\n <ZoomGestureWrapper :document-id=\"activeDocumentId\" :enable-wheel=\"true\">\n <Scroller :document-id=\"activeDocumentId\">\n <template #default=\"{ page }\">\n <div\n :class=\"cls.e('pdf-page')\"\n :style=\"{ width: page.width + 'px', height: page.height + 'px' }\"\n >\n <RenderLayer :document-id=\"activeDocumentId\" :page-index=\"page.pageIndex\" />\n </div>\n </template>\n </Scroller>\n </ZoomGestureWrapper>\n </PdfViewportScroll>\n </Viewport>\n </DocumentContent>\n </EmbedPDF>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { createPluginRegistration } from '@embedpdf/core'\nimport { EmbedPDF } from '@embedpdf/core/vue'\nimport { usePdfiumEngine } from '@embedpdf/engines/vue'\nimport {\n DocumentContent,\n DocumentManagerPluginPackage\n} from '@embedpdf/plugin-document-manager/vue'\nimport { RenderLayer, RenderPluginPackage } from '@embedpdf/plugin-render/vue'\nimport { ScrollPluginPackage, Scroller } from '@embedpdf/plugin-scroll/vue'\nimport { ViewportPluginPackage, Viewport } from '@embedpdf/plugin-viewport/vue'\nimport {\n ZoomGestureWrapper,\n ZoomMode,\n ZoomPluginPackage,\n type ZoomScope\n} from '@embedpdf/plugin-zoom/vue'\nimport { bem } from '@veltra/utils'\nimport { computed, onBeforeUnmount, shallowRef, useAttrs, watch } from 'vue'\n\nimport type { FileViewerItem } from '../../../types/file-viewer'\nimport { toBlobUrl } from '../helper'\nimport PdfViewportScroll from './pdf-viewport-scroll.vue'\nimport PdfZoomBridge from './pdf-zoom-bridge.vue'\n\ndefineOptions({ name: 'UFileViewerPdfPreviewer', inheritAttrs: false })\n\nconst props = defineProps<{ file: FileViewerItem }>()\n\nconst emit = defineEmits<{\n (e: 'error', err: unknown): void\n (e: 'zoom-change', level: number): void\n}>()\n\nconst cls = bem('file-viewer')\nconst attrs = useAttrs()\n\nconst { engine, isLoading, error } = usePdfiumEngine()\n\nconst pdfUrl = shallowRef<string>('')\nlet revoke: (() => void) | undefined\n\n/** 当前文档的 zoom API(由 PdfZoomBridge 注入) */\nlet zoomScope: ZoomScope | null = null\n\nfunction load() {\n revoke?.()\n const r = toBlobUrl(props.file.src, props.file.mime ?? 'application/pdf')\n pdfUrl.value = r.url\n revoke = r.revoke\n}\n\nconst plugins = computed(() => {\n if (!pdfUrl.value) return []\n return [\n createPluginRegistration(DocumentManagerPluginPackage, {\n initialDocuments: [{ url: pdfUrl.value }]\n }),\n createPluginRegistration(ViewportPluginPackage, { viewportGap: 0 }),\n createPluginRegistration(ScrollPluginPackage, { defaultBufferSize: 2 }),\n createPluginRegistration(RenderPluginPackage),\n createPluginRegistration(ZoomPluginPackage, {\n defaultZoomLevel: ZoomMode.FitPage,\n minZoom: 0.5,\n maxZoom: 3,\n zoomStep: 0.1\n })\n ]\n})\n\nfunction onZoomChange(payload: { level: number; scope: ZoomScope | null }) {\n zoomScope = payload.scope\n emit('zoom-change', payload.level)\n}\n\nfunction zoomIn() {\n zoomScope?.zoomIn()\n}\n\nfunction zoomOut() {\n zoomScope?.zoomOut()\n}\n\nfunction resetZoom() {\n zoomScope?.requestZoom(ZoomMode.FitPage)\n}\n\nwatch(\n () => props.file,\n () => load(),\n { immediate: true }\n)\n\nwatch(error, (err) => {\n if (err) emit('error', err)\n})\n\nonBeforeUnmount(() => {\n revoke?.()\n pdfUrl.value = ''\n zoomScope = null\n})\n\ndefineExpose({ zoomIn, zoomOut, resetZoom })\n</script>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"pdf-previewer.js","names":["_openBlock","_createElementBlock","_mergeProps","_unref","_normalizeClass","_createBlock","_withCtx","PdfZoomBridge","_createCommentVNode","_createVNode","PdfViewportScroll","_createElementVNode","_normalizeStyle"],"sources":["../../../../src/components/file-viewer/previewers/pdf-previewer.vue"],"sourcesContent":["<template>\n <div :class=\"cls.e('pdf')\" v-bind=\"attrs\">\n <div v-if=\"!engine || isLoading\" :class=\"cls.e('loading')\">正在加载 PDF 引擎…</div>\n <EmbedPDF v-else-if=\"pdfUrl\" :engine=\"engine\" :plugins=\"plugins\" v-slot=\"{ activeDocumentId }\">\n <PdfZoomBridge\n v-if=\"activeDocumentId\"\n :document-id=\"activeDocumentId\"\n @zoom-change=\"onZoomChange\"\n />\n <DocumentContent\n v-if=\"activeDocumentId\"\n :document-id=\"activeDocumentId\"\n v-slot=\"{ isLoaded }\"\n >\n <Viewport v-if=\"isLoaded\" :document-id=\"activeDocumentId\" :class=\"cls.e('pdf-viewport')\">\n <PdfViewportScroll>\n <ZoomGestureWrapper :document-id=\"activeDocumentId\" :enable-wheel=\"true\">\n <Scroller :document-id=\"activeDocumentId\">\n <template #default=\"{ page }\">\n <div\n :class=\"cls.e('pdf-page')\"\n :style=\"{ width: page.width + 'px', height: page.height + 'px' }\"\n >\n <RenderLayer :document-id=\"activeDocumentId\" :page-index=\"page.pageIndex\" />\n </div>\n </template>\n </Scroller>\n </ZoomGestureWrapper>\n </PdfViewportScroll>\n </Viewport>\n </DocumentContent>\n </EmbedPDF>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { createPluginRegistration } from '@embedpdf/core'\nimport { EmbedPDF } from '@embedpdf/core/vue'\nimport { usePdfiumEngine } from '@embedpdf/engines/vue'\nimport rawPdfiumWasmUrl from '@embedpdf/pdfium/pdfium.wasm?url'\nimport {\n DocumentContent,\n DocumentManagerPluginPackage\n} from '@embedpdf/plugin-document-manager/vue'\nimport { RenderLayer, RenderPluginPackage } from '@embedpdf/plugin-render/vue'\nimport { ScrollPluginPackage, Scroller } from '@embedpdf/plugin-scroll/vue'\nimport { ViewportPluginPackage, Viewport } from '@embedpdf/plugin-viewport/vue'\nimport {\n ZoomGestureWrapper,\n ZoomMode,\n ZoomPluginPackage,\n type ZoomScope\n} from '@embedpdf/plugin-zoom/vue'\nimport { bem } from '@veltra/utils'\nimport { computed, onBeforeUnmount, shallowRef, useAttrs, watch } from 'vue'\n\nimport type { FileViewerItem } from '../../../types/file-viewer'\nimport { toBlobUrl } from '../helper'\nimport PdfViewportScroll from './pdf-viewport-scroll.vue'\nimport PdfZoomBridge from './pdf-zoom-bridge.vue'\n\ndefineOptions({ name: 'UFileViewerPdfPreviewer', inheritAttrs: false })\n\nconst props = defineProps<{ file: FileViewerItem }>()\n\nconst emit = defineEmits<{\n (e: 'error', err: unknown): void\n (e: 'zoom-change', level: number): void\n}>()\n\nconst cls = bem('file-viewer')\nconst attrs = useAttrs()\n\n// wasm 经 `?url` 导入由消费方构建工具随产物本地分发,替换默认 jsdelivr CDN 地址(离线环境不可达);\n// pdfium worker 由 blob: URL 创建,其内部无法解析相对路径,须先转为绝对地址\nconst pdfiumWasmUrl = new URL(rawPdfiumWasmUrl, import.meta.url).href\n\nconst { engine, isLoading, error } = usePdfiumEngine({ wasmUrl: pdfiumWasmUrl })\n\nconst pdfUrl = shallowRef<string>('')\nlet revoke: (() => void) | undefined\n\n/** 当前文档的 zoom API(由 PdfZoomBridge 注入) */\nlet zoomScope: ZoomScope | null = null\n\nfunction load() {\n revoke?.()\n const r = toBlobUrl(props.file.src, props.file.mime ?? 'application/pdf')\n pdfUrl.value = r.url\n revoke = r.revoke\n}\n\nconst plugins = computed(() => {\n if (!pdfUrl.value) return []\n return [\n createPluginRegistration(DocumentManagerPluginPackage, {\n initialDocuments: [{ url: pdfUrl.value }]\n }),\n createPluginRegistration(ViewportPluginPackage, { viewportGap: 0 }),\n createPluginRegistration(ScrollPluginPackage, { defaultBufferSize: 2 }),\n createPluginRegistration(RenderPluginPackage),\n createPluginRegistration(ZoomPluginPackage, {\n defaultZoomLevel: ZoomMode.FitPage,\n minZoom: 0.5,\n maxZoom: 3,\n zoomStep: 0.1\n })\n ]\n})\n\nfunction onZoomChange(payload: { level: number; scope: ZoomScope | null }) {\n zoomScope = payload.scope\n emit('zoom-change', payload.level)\n}\n\nfunction zoomIn() {\n zoomScope?.zoomIn()\n}\n\nfunction zoomOut() {\n zoomScope?.zoomOut()\n}\n\nfunction resetZoom() {\n zoomScope?.requestZoom(ZoomMode.FitPage)\n}\n\nwatch(\n () => props.file,\n () => load(),\n { immediate: true }\n)\n\nwatch(error, (err) => {\n if (err) emit('error', err)\n})\n\nonBeforeUnmount(() => {\n revoke?.()\n pdfUrl.value = ''\n zoomScope = null\n})\n\ndefineExpose({ zoomIn, zoomOut, resetZoom })\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;EA+DA,MAAM,QAAQ;EAEd,MAAM,OAAO;EAKb,MAAM,MAAM,IAAI,aAAa;EAC7B,MAAM,QAAQ,SAAS;EAIvB,MAAM,gBAAgB,IAAI,IAAI,kBAAkB,YAAY,GAAG,CAAC,CAAC;EAEjE,MAAM,EAAE,QAAQ,WAAW,UAAU,gBAAgB,EAAE,SAAS,cAAc,CAAC;EAE/E,MAAM,SAAS,WAAmB,EAAE;EACpC,IAAI;;EAGJ,IAAI,YAA8B;EAElC,SAAS,OAAO;GACd,SAAS;GACT,MAAM,IAAI,UAAU,MAAM,KAAK,KAAK,MAAM,KAAK,QAAQ,iBAAiB;GACxE,OAAO,QAAQ,EAAE;GACjB,SAAS,EAAE;EACb;EAEA,MAAM,UAAU,eAAe;GAC7B,IAAI,CAAC,OAAO,OAAO,OAAO,CAAC;GAC3B,OAAO;IACL,yBAAyB,8BAA8B,EACrD,kBAAkB,CAAC,EAAE,KAAK,OAAO,MAAM,CAAC,EAC1C,CAAC;IACD,yBAAyB,uBAAuB,EAAE,aAAa,EAAE,CAAC;IAClE,yBAAyB,qBAAqB,EAAE,mBAAmB,EAAE,CAAC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AnBf,eAAa;;KAGd,SAAAG,SAeW,EAjBD,eAAQ,CAEF,YAAhBN,UAAA,GAAAK,YAeWF,MAAA,QAAA,GAAA;;MAfgB,eAAa;MAAmB,OAAKC,eAAED,MAAA,GAAA,CAAG,CAAC,EAAC,cAAA,CAAA;;MACrE,SAAAG,cAaoB,CAbpBG,YAaoBC,aAAA,MAAA;OAZlB,SAAAJ,cAWqB,CAXrBG,YAWqBN,MAAA,kBAAA,GAAA;QAXA,eAAa;QAAmB,gBAAc;;QACjE,SAAAG,cASW,CATXG,YASWN,MAAA,QAAA,GAAA,EATA,eAAa,iBAAgB,GAAA;SAC3B,SAAOG,SAMV,EANc,WAAI,CACxBK,mBAKM,OAAA;UAJH,OAAKP,eAAED,MAAA,GAAA,CAAG,CAAC,EAAC,UAAA,CAAA;UACZ,OAAKS,eAAA;WAAA,OAAW,KAAK,QAAK;WAAA,QAAiB,KAAK,SAAM;UAAA,CAAA;SAEvD,GAAA,CAAAH,YAA4EN,MAAA,WAAA,GAAA;UAA9D,eAAa;UAAmB,cAAY,KAAK"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veltra/desktop",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.5",
|
|
4
4
|
"homepage": "https://github.com/cabinet-fe/ultra-ui#readme",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/cabinet-fe/ultra-ui/issues"
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@embedpdf/core": "^2.15.1",
|
|
48
48
|
"@embedpdf/engines": "^2.15.1",
|
|
49
|
+
"@embedpdf/pdfium": "2.15.1",
|
|
49
50
|
"@embedpdf/plugin-document-manager": "^2.15.1",
|
|
50
51
|
"@embedpdf/plugin-render": "^2.15.1",
|
|
51
52
|
"@embedpdf/plugin-scroll": "^2.15.1",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
import { createPluginRegistration } from '@embedpdf/core'
|
|
38
38
|
import { EmbedPDF } from '@embedpdf/core/vue'
|
|
39
39
|
import { usePdfiumEngine } from '@embedpdf/engines/vue'
|
|
40
|
+
import rawPdfiumWasmUrl from '@embedpdf/pdfium/pdfium.wasm?url'
|
|
40
41
|
import {
|
|
41
42
|
DocumentContent,
|
|
42
43
|
DocumentManagerPluginPackage
|
|
@@ -70,7 +71,11 @@ const emit = defineEmits<{
|
|
|
70
71
|
const cls = bem('file-viewer')
|
|
71
72
|
const attrs = useAttrs()
|
|
72
73
|
|
|
73
|
-
|
|
74
|
+
// wasm 经 `?url` 导入由消费方构建工具随产物本地分发,替换默认 jsdelivr CDN 地址(离线环境不可达);
|
|
75
|
+
// pdfium worker 由 blob: URL 创建,其内部无法解析相对路径,须先转为绝对地址
|
|
76
|
+
const pdfiumWasmUrl = new URL(rawPdfiumWasmUrl, import.meta.url).href
|
|
77
|
+
|
|
78
|
+
const { engine, isLoading, error } = usePdfiumEngine({ wasmUrl: pdfiumWasmUrl })
|
|
74
79
|
|
|
75
80
|
const pdfUrl = shallowRef<string>('')
|
|
76
81
|
let revoke: (() => void) | undefined
|