file-viewer3 1.0.1 → 1.0.6

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 CHANGED
@@ -135,3 +135,13 @@ var context = {
135
135
  4. 具体请参考demo代码,原理是基于`iframe`跨域通信机制。
136
136
 
137
137
  ![image-20230228161454443](/Users/wangyu/Library/Application Support/typora-user-images/image-20230228161454443.png)
138
+
139
+
140
+
141
+ ## 更新日志
142
+
143
+ #### [feature]`v1.0.6` `2022年4月23日`
144
+
145
+ 1. 解决部分pdf字体不显示的问题
146
+ 2. 增加pdf预览初始缩放大小,自动适配页面。调整pdf预览缩放下限为0.5
147
+ 3. demo增加url预览模式,在请求参数中添加`url=文件地址`,可自动拉取并渲染文件
@@ -1,5 +1,5 @@
1
1
  import { defineComponent as Ee, ref as Ve, watch as yt, nextTick as wt, onMounted as Fe, onUnmounted as Me, openBlock as ft, createElementBlock as St, renderSlot as Ye, computed as We, createBlock as Xe, unref as Tt, withCtx as qe, Fragment as He, renderList as Ue } from "vue";
2
- import { _ as Be } from "./index-59c602ca.mjs";
2
+ import { _ as Be } from "./index.js";
3
3
  /*!
4
4
  * Viewer.js v1.11.3
5
5
  * https://fengyuanchen.github.io/viewerjs
@@ -2,7 +2,7 @@ var Y = Object.defineProperty;
2
2
  var ee = (o, n, t) => n in o ? Y(o, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[n] = t;
3
3
  var O = (o, n, t) => (ee(o, typeof n != "symbol" ? n + "" : n, t), t);
4
4
  import { defineComponent as te, computed as ne, openBlock as ie, createElementBlock as se, unref as re } from "vue";
5
- import { _ as le } from "./index-59c602ca.mjs";
5
+ import { _ as le } from "./index.js";
6
6
  function F() {
7
7
  return {
8
8
  async: !1,
@@ -17,9 +17,10 @@ var Ue = (W, E, l) => (Fr(W, E, "read from private field"), l ? l.call(W) : E.ge
17
17
  }
18
18
  });
19
19
  import { defineComponent, ref, onMounted, openBlock, createElementBlock, createElementVNode, pushScopeId, popScopeId } from "vue";
20
- import { a as getAugmentedNamespace, c as commonjsGlobal } from "./_commonjsHelpers-92157f1b.mjs";
21
- import { c as commonjsRequire } from "./_commonjs-dynamic-modules-bed80856.mjs";
22
- import { _ as _export_sfc } from "./index-59c602ca.mjs";
20
+ import { a as getAugmentedNamespace, c as commonjsGlobal } from "./_commonjsHelpers.js";
21
+ import { c as commonjsRequire } from "./_commonjs-dynamic-modules.js";
22
+ import { r as refWorker } from "./worker-ref.js";
23
+ import { _ as _export_sfc } from "./index.js";
23
24
  var pdfExports$1 = {}, pdf$1 = {
24
25
  get exports() {
25
26
  return pdfExports$1;
@@ -21566,10 +21567,11 @@ var pdfExports = requirePdf(), pdf_viewerExports = {}, pdf_viewer = {
21566
21567
  })()
21567
21568
  ));
21568
21569
  })(pdf_viewer);
21569
- function WorkerWrapper() {
21570
- return new Worker("" + new URL("assets/pdf.worker-909112bf.js", import.meta.url).href);
21571
- }
21572
- const pdf = "", _withScopeId = (W) => (pushScopeId("data-v-4396b257"), W = W(), popScopeId(), W), _hoisted_1 = { class: "container" }, _hoisted_2 = { class: "pdf_down" }, _hoisted_3 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("div", {
21570
+ const pdf = "", PDFWorker = {
21571
+ create() {
21572
+ return refWorker("pptx.worker.js").defaults(() => new Worker(new URL("" + new URL("../worker/pdf.worker.js", import.meta.url).href, self.location), { type: "module" }));
21573
+ }
21574
+ }, _withScopeId = (W) => (pushScopeId("data-v-9bad3887"), W = W(), popScopeId(), W), _hoisted_1 = { class: "container" }, _hoisted_2 = { class: "pdf_down" }, _hoisted_3 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("div", {
21573
21575
  id: "viewer",
21574
21576
  class: "pdfViewer"
21575
21577
  }, null, -1)), _hoisted_4 = [
@@ -21588,7 +21590,7 @@ const pdf = "", _withScopeId = (W) => (pushScopeId("data-v-4396b257"), W = W(),
21588
21590
  //pdf放大系数
21589
21591
  pdf_scale: 1
21590
21592
  };
21591
- !pdfExports.GlobalWorkerOptions.workerPort && typeof window < "u" && "Worker" in window && (pdfExports.GlobalWorkerOptions.workerPort = new WorkerWrapper()), (() => {
21593
+ !pdfExports.GlobalWorkerOptions.workerPort && typeof window < "u" && "Worker" in window && (pdfExports.GlobalWorkerOptions.workerPort = PDFWorker.create()), (() => {
21592
21594
  async function k() {
21593
21595
  if (!l.value)
21594
21596
  return;
@@ -21606,11 +21608,14 @@ const pdf = "", _withScopeId = (W) => (pushScopeId("data-v-4396b257"), W = W(),
21606
21608
  l10n: new pdf_viewerExports.GenericL10n("zh-CN")
21607
21609
  });
21608
21610
  R.setViewer(n), m.on("pagesinit", () => {
21609
- n.currentScaleValue = "1";
21611
+ var r;
21612
+ const d = (r = n.getPageView(0)) == null ? void 0 : r.viewport;
21613
+ (d == null ? void 0 : d.width) > window.innerWidth ? n.currentScaleValue = "0.5" : n.currentScaleValue = "1";
21610
21614
  });
21611
21615
  const a = await pdfExports.getDocument({
21612
21616
  data: E.data,
21613
- // cMapUrl: resolve('pdfjs-dist/cmaps/'),
21617
+ cMapUrl: `https://npm.onmicrosoft.cn/pdfjs-dist@${pdfExports.version}/cmaps/`,
21618
+ useWorkerFetch: !0,
21614
21619
  cMapPacked: !0,
21615
21620
  enableXfa: !0
21616
21621
  }).promise;
@@ -21629,7 +21634,7 @@ const pdf = "", _withScopeId = (W) => (pushScopeId("data-v-4396b257"), W = W(),
21629
21634
  if (!p.viewer)
21630
21635
  return;
21631
21636
  const k = p.viewer.currentScale;
21632
- k <= 1 || (p.viewer.currentScale = k - 0.1);
21637
+ k <= 0.5 || (p.viewer.currentScale = k - 0.1);
21633
21638
  }
21634
21639
  return (k, m) => (openBlock(), createElementBlock("div", _hoisted_1, [
21635
21640
  createElementVNode("div", _hoisted_2, [
@@ -21649,7 +21654,7 @@ const pdf = "", _withScopeId = (W) => (pushScopeId("data-v-4396b257"), W = W(),
21649
21654
  }, _hoisted_4, 512)
21650
21655
  ]));
21651
21656
  }
21652
- }), PdfView_vue_vue_type_style_index_0_scoped_4396b257_lang = "", PdfView = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-4396b257"]]);
21657
+ }), PdfView_vue_vue_type_style_index_0_scoped_9bad3887_lang = "", PdfView = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-9bad3887"]]);
21653
21658
  export {
21654
21659
  PdfView as default
21655
21660
  };