@flyfish-group/file-viewer3 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +1 -1
  2. package/dist/components/index.js +55 -52
  3. package/dist/components/worker-ref.js +8 -8
  4. package/dist/index.d.ts +47 -0
  5. package/dist/index.umd.js +2 -2
  6. package/dist/src/package/index.d.ts +3 -0
  7. package/package.json +1 -1
  8. package/dist/components/utils.d.ts +0 -3
  9. package/dist/main.d.ts +0 -0
  10. package/dist/package/common/type.d.ts +0 -30
  11. package/dist/package/common/util.d.ts +0 -5
  12. package/dist/package/common/worker-ref.d.ts +0 -12
  13. package/dist/package/components/FileViewer/FileViewer.vue.d.ts +0 -18
  14. package/dist/package/components/FileViewer/index.d.ts +0 -2
  15. package/dist/package/components/FileViewer/util.d.ts +0 -2
  16. package/dist/package/index.d.ts +0 -12
  17. package/dist/package/use/index.d.ts +0 -1
  18. package/dist/package/use/worker.d.ts +0 -24
  19. package/dist/package/vendors/docx/index.d.ts +0 -4
  20. package/dist/package/vendors/image/ImageViewer.vue.d.ts +0 -15
  21. package/dist/package/vendors/image/index.d.ts +0 -4
  22. package/dist/package/vendors/md/MarkdownViewer.vue.d.ts +0 -15
  23. package/dist/package/vendors/md/index.d.ts +0 -4
  24. package/dist/package/vendors/mp4/index.d.ts +0 -4
  25. package/dist/package/vendors/pdf/PdfView.vue.d.ts +0 -15
  26. package/dist/package/vendors/pdf/index.d.ts +0 -1
  27. package/dist/package/vendors/pdf/worker/index.d.ts +0 -4
  28. package/dist/package/vendors/pptx/PptxRender.vue.d.ts +0 -87
  29. package/dist/package/vendors/pptx/index.d.ts +0 -6
  30. package/dist/package/vendors/pptx/options.d.ts +0 -39
  31. package/dist/package/vendors/pptx/support/chart.d.ts +0 -4
  32. package/dist/package/vendors/pptx/worker/index.d.ts +0 -4
  33. package/dist/package/vendors/renders.d.ts +0 -3
  34. package/dist/package/vendors/text/CodeViewer.vue.d.ts +0 -15
  35. package/dist/package/vendors/text/index.d.ts +0 -6
  36. package/dist/package/vendors/xlsx/XlsxTable.vue.d.ts +0 -17
  37. package/dist/package/vendors/xlsx/index.d.ts +0 -5
  38. package/dist/package/vendors/xlsx/render.d.ts +0 -6
  39. package/dist/package/vendors/xlsx/util.d.ts +0 -8
  40. package/dist/package/vendors/xlsx/worker/index.d.ts +0 -6
  41. package/dist/package/vendors/xlsx/worker/xls/SheetJsModel.d.ts +0 -36
  42. package/dist/package/vendors/xlsx/worker/xls/index.d.ts +0 -4
  43. package/dist/package/vendors/xlsx/worker/xls/sheet.worker.d.ts +0 -1
  44. package/dist/package/vendors/xlsx/worker/xlsx/ExcelJsModel.d.ts +0 -39
  45. package/dist/package/vendors/xlsx/worker/xlsx/color.d.ts +0 -2
  46. package/dist/package/vendors/xlsx/worker/xlsx/context.d.ts +0 -7
  47. package/dist/package/vendors/xlsx/worker/xlsx/index.d.ts +0 -4
  48. package/dist/package/vendors/xlsx/worker/xlsx/util.d.ts +0 -10
  49. package/dist/package/vendors/xlsx/worker/xlsx/xlsx.worker.d.ts +0 -2
package/README.md CHANGED
@@ -59,7 +59,7 @@ npm run lint
59
59
  如果您使用了flyfish的私库,请使用以下命令安装依赖即可。
60
60
 
61
61
  ```
62
- npm install --save file-viewer3
62
+ npm install --save @flyfish-group/file-viewer3
63
63
  ```
64
64
 
65
65
  常规情况下,请使用`npm link`的方式进行集成。
@@ -26,7 +26,7 @@ var w = (e, t, n) => new Promise((r, s) => {
26
26
  }, l = (u) => u.done ? r(u.value) : Promise.resolve(u.value).then(o, i);
27
27
  l((n = n.apply(e, t)).next());
28
28
  });
29
- import { defineAsyncComponent as k, createApp as N, createVNode as F, defineComponent as Ue, openBlock as H, createElementBlock as M, toDisplayString as q, ref as B, onMounted as lt, watch as Ee, createElementVNode as ee, Fragment as ut, withDirectives as be, vShow as Re } from "vue";
29
+ import { defineAsyncComponent as k, createApp as N, createVNode as F, defineComponent as Ue, openBlock as H, createElementBlock as M, toDisplayString as q, ref as B, onMounted as lt, watch as be, createElementVNode as ee, Fragment as ut, withDirectives as Ee, vShow as Re } from "vue";
30
30
  const ft = (() => {
31
31
  const e = {
32
32
  module: null,
@@ -82,7 +82,7 @@ function wt(e, t) {
82
82
  return n.mount(t), n;
83
83
  });
84
84
  }
85
- function Et(e) {
85
+ function bt(e) {
86
86
  return w(this, null, function* () {
87
87
  return new Promise((t, n) => {
88
88
  const r = new FileReader();
@@ -93,7 +93,7 @@ function Et(e) {
93
93
  });
94
94
  });
95
95
  }
96
- function bt(e) {
96
+ function Et(e) {
97
97
  return w(this, null, function* () {
98
98
  return new Promise((t, n) => {
99
99
  const r = new FileReader();
@@ -120,7 +120,7 @@ function De(e) {
120
120
  const Rt = k(() => import("./ImageViewer.js"));
121
121
  function St(e, t) {
122
122
  return w(this, null, function* () {
123
- const n = yield bt(e), r = N({
123
+ const n = yield Et(e), r = N({
124
124
  render: () => F(Rt, {
125
125
  image: n
126
126
  }, null)
@@ -167,7 +167,10 @@ function Tt(e, t) {
167
167
  }
168
168
  function Pt(e, t) {
169
169
  const n = document.createElement("video");
170
- n.width = 840, n.height = 480, n.controls = !0;
170
+ n.width = 840, n.height = 480, n.controls = !0, Object.assign(n.style, {
171
+ margin: "40px auto",
172
+ display: "block"
173
+ });
171
174
  const r = document.createElement("source");
172
175
  r.src = URL.createObjectURL(new Blob([e])), n.appendChild(r), t.appendChild(n);
173
176
  }
@@ -213,7 +216,7 @@ const I = (e) => ({
213
216
  },
214
217
  // 图片过滤器
215
218
  {
216
- accepts: ["gif", "jpg", "jpeg", "bmp", "tiff", "tif", "png", "svg"],
219
+ accepts: ["gif", "jpg", "jpeg", "bmp", "tiff", "tif", "png", "svg", "webp"],
217
220
  handler: (e, t) => w(void 0, null, function* () {
218
221
  return St(e, t);
219
222
  })
@@ -560,8 +563,8 @@ function G(e, t, n) {
560
563
  metaTokens: !0,
561
564
  dots: !1,
562
565
  indexes: !1
563
- }, !1, function(d, b) {
564
- return !a.isUndefined(b[d]);
566
+ }, !1, function(d, E) {
567
+ return !a.isUndefined(E[d]);
565
568
  });
566
569
  const r = n.metaTokens, s = n.visitor || f, o = n.dots, i = n.indexes, u = (n.Blob || typeof Blob != "undefined" && Blob) && a.isSpecCompliantForm(t);
567
570
  if (!a.isFunction(s))
@@ -575,9 +578,9 @@ function G(e, t, n) {
575
578
  throw new m("Blob is not supported. Use a Buffer instead.");
576
579
  return a.isArrayBuffer(h) || a.isTypedArray(h) ? u && typeof Blob == "function" ? new Blob([h]) : Buffer.from(h) : h;
577
580
  }
578
- function f(h, d, b) {
581
+ function f(h, d, E) {
579
582
  let S = h;
580
- if (h && !b && typeof h == "object") {
583
+ if (h && !E && typeof h == "object") {
581
584
  if (a.endsWith(d, "{}"))
582
585
  d = r ? d : d.slice(0, -2), h = JSON.stringify(h);
583
586
  else if (a.isArray(h) && hn(h) || (a.isFileList(h) || a.endsWith(d, "[]")) && (S = a.toArray(h)))
@@ -589,14 +592,14 @@ function G(e, t, n) {
589
592
  );
590
593
  }), !1;
591
594
  }
592
- return ie(h) ? !0 : (t.append(Ae(b, d, o), p(h)), !1);
595
+ return ie(h) ? !0 : (t.append(Ae(E, d, o), p(h)), !1);
593
596
  }
594
597
  const c = [], y = Object.assign(mn, {
595
598
  defaultVisitor: f,
596
599
  convertValue: p,
597
600
  isVisitable: ie
598
601
  });
599
- function E(h, d) {
602
+ function b(h, d) {
600
603
  if (!a.isUndefined(h)) {
601
604
  if (c.indexOf(h) !== -1)
602
605
  throw Error("Circular reference detected in " + d.join("."));
@@ -607,13 +610,13 @@ function G(e, t, n) {
607
610
  a.isString(O) ? O.trim() : O,
608
611
  d,
609
612
  y
610
- )) === !0 && E(S, d ? d.concat(O) : [O]);
613
+ )) === !0 && b(S, d ? d.concat(O) : [O]);
611
614
  }), c.pop();
612
615
  }
613
616
  }
614
617
  if (!a.isObject(e))
615
618
  throw new TypeError("data must be an object");
616
- return E(e), t;
619
+ return b(e), t;
617
620
  }
618
621
  function _e(e) {
619
622
  const t = {
@@ -716,11 +719,11 @@ const Te = wn, Qe = {
716
719
  silentJSONParsing: !0,
717
720
  forcedJSONParsing: !0,
718
721
  clarifyTimeoutError: !1
719
- }, En = typeof URLSearchParams != "undefined" ? URLSearchParams : fe, bn = typeof FormData != "undefined" ? FormData : null, Rn = typeof Blob != "undefined" ? Blob : null, Sn = {
722
+ }, bn = typeof URLSearchParams != "undefined" ? URLSearchParams : fe, En = typeof FormData != "undefined" ? FormData : null, Rn = typeof Blob != "undefined" ? Blob : null, Sn = {
720
723
  isBrowser: !0,
721
724
  classes: {
722
- URLSearchParams: En,
723
- FormData: bn,
725
+ URLSearchParams: bn,
726
+ FormData: En,
724
727
  Blob: Rn
725
728
  },
726
729
  protocols: ["http", "https", "file", "blob", "url", "data"]
@@ -1138,8 +1141,8 @@ function Mn(e, t) {
1138
1141
  y += n[c++], c = c % e;
1139
1142
  if (s = (s + 1) % e, s === o && (o = (o + 1) % e), p - i < t)
1140
1143
  return;
1141
- const E = f && p - f;
1142
- return E ? Math.round(y * 1e3 / E) : void 0;
1144
+ const b = f && p - f;
1145
+ return b ? Math.round(y * 1e3 / b) : void 0;
1143
1146
  };
1144
1147
  }
1145
1148
  function Ce(e, t) {
@@ -1173,18 +1176,18 @@ const qn = typeof XMLHttpRequest != "undefined", zn = qn && function(e) {
1173
1176
  if (A.hasStandardBrowserEnv || A.hasStandardBrowserWebWorkerEnv)
1174
1177
  o.setContentType(!1);
1175
1178
  else if ((f = o.getContentType()) !== !1) {
1176
- const [d, ...b] = f ? f.split(";").map((S) => S.trim()).filter(Boolean) : [];
1177
- o.setContentType([d || "multipart/form-data", ...b].join("; "));
1179
+ const [d, ...E] = f ? f.split(";").map((S) => S.trim()).filter(Boolean) : [];
1180
+ o.setContentType([d || "multipart/form-data", ...E].join("; "));
1178
1181
  }
1179
1182
  }
1180
1183
  let c = new XMLHttpRequest();
1181
1184
  if (e.auth) {
1182
- const d = e.auth.username || "", b = e.auth.password ? unescape(encodeURIComponent(e.auth.password)) : "";
1183
- o.set("Authorization", "Basic " + btoa(d + ":" + b));
1185
+ const d = e.auth.username || "", E = e.auth.password ? unescape(encodeURIComponent(e.auth.password)) : "";
1186
+ o.set("Authorization", "Basic " + btoa(d + ":" + E));
1184
1187
  }
1185
1188
  const y = tt(e.baseURL, e.url);
1186
1189
  c.open(e.method.toUpperCase(), Ge(y, e.params, e.paramsSerializer), !0), c.timeout = e.timeout;
1187
- function E() {
1190
+ function b() {
1188
1191
  if (!c)
1189
1192
  return;
1190
1193
  const d = T.from(
@@ -1203,17 +1206,17 @@ const qn = typeof XMLHttpRequest != "undefined", zn = qn && function(e) {
1203
1206
  r(x), p();
1204
1207
  }, S), c = null;
1205
1208
  }
1206
- if ("onloadend" in c ? c.onloadend = E : c.onreadystatechange = function() {
1207
- !c || c.readyState !== 4 || c.status === 0 && !(c.responseURL && c.responseURL.indexOf("file:") === 0) || setTimeout(E);
1209
+ if ("onloadend" in c ? c.onloadend = b : c.onreadystatechange = function() {
1210
+ !c || c.readyState !== 4 || c.status === 0 && !(c.responseURL && c.responseURL.indexOf("file:") === 0) || setTimeout(b);
1208
1211
  }, c.onabort = function() {
1209
1212
  c && (r(new m("Request aborted", m.ECONNABORTED, e, c)), c = null);
1210
1213
  }, c.onerror = function() {
1211
1214
  r(new m("Network Error", m.ERR_NETWORK, e, c)), c = null;
1212
1215
  }, c.ontimeout = function() {
1213
- let b = e.timeout ? "timeout of " + e.timeout + "ms exceeded" : "timeout exceeded";
1216
+ let E = e.timeout ? "timeout of " + e.timeout + "ms exceeded" : "timeout exceeded";
1214
1217
  const S = e.transitional || Qe;
1215
- e.timeoutErrorMessage && (b = e.timeoutErrorMessage), r(new m(
1216
- b,
1218
+ e.timeoutErrorMessage && (E = e.timeoutErrorMessage), r(new m(
1219
+ E,
1217
1220
  S.clarifyTimeoutError ? m.ETIMEDOUT : m.ECONNABORTED,
1218
1221
  e,
1219
1222
  c
@@ -1222,8 +1225,8 @@ const qn = typeof XMLHttpRequest != "undefined", zn = qn && function(e) {
1222
1225
  const d = e.xsrfHeaderName && e.xsrfCookieName && kn.read(e.xsrfCookieName);
1223
1226
  d && o.set(e.xsrfHeaderName, d);
1224
1227
  }
1225
- s === void 0 && o.setContentType(null), "setRequestHeader" in c && a.forEach(o.toJSON(), function(b, S) {
1226
- c.setRequestHeader(S, b);
1228
+ s === void 0 && o.setContentType(null), "setRequestHeader" in c && a.forEach(o.toJSON(), function(E, S) {
1229
+ c.setRequestHeader(S, E);
1227
1230
  }), a.isUndefined(e.withCredentials) || (c.withCredentials = !!e.withCredentials), i && i !== "json" && (c.responseType = e.responseType), typeof e.onDownloadProgress == "function" && c.addEventListener("progress", Ce(e.onDownloadProgress, !0)), typeof e.onUploadProgress == "function" && c.upload && c.upload.addEventListener("progress", Ce(e.onUploadProgress)), (e.cancelToken || e.signal) && (u = (d) => {
1228
1231
  c && (r(!d || d.type ? new v(null, e, c) : d), c.abort(), c = null);
1229
1232
  }, e.cancelToken && e.cancelToken.subscribe(u), e.signal && (e.signal.aborted ? u() : e.signal.addEventListener("abort", u)));
@@ -1484,18 +1487,18 @@ class J {
1484
1487
  return f;
1485
1488
  }
1486
1489
  y = l.length;
1487
- let E = n;
1490
+ let b = n;
1488
1491
  for (c = 0; c < y; ) {
1489
1492
  const h = l[c++], d = l[c++];
1490
1493
  try {
1491
- E = h(E);
1492
- } catch (b) {
1493
- d.call(this, b);
1494
+ b = h(b);
1495
+ } catch (E) {
1496
+ d.call(this, E);
1494
1497
  break;
1495
1498
  }
1496
1499
  }
1497
1500
  try {
1498
- f = Fe.call(this, E);
1501
+ f = Fe.call(this, b);
1499
1502
  } catch (h) {
1500
1503
  return Promise.reject(h);
1501
1504
  }
@@ -1735,13 +1738,13 @@ const Gn = R, Qn = { class: "file-viewer" }, Zn = { class: "name" }, Yn = {
1735
1738
  this.startLoading(l.loading);
1736
1739
  const y = c.substring(c.lastIndexOf("/") + 1);
1737
1740
  try {
1738
- const { data: E } = yield Gn({ url: c, method: "get", responseType: "blob" });
1739
- if (!E)
1741
+ const { data: b } = yield Gn({ url: c, method: "get", responseType: "blob" });
1742
+ if (!b)
1740
1743
  return this.showError("文件下载失败");
1741
- const h = this.wrap(E, y);
1744
+ const h = this.wrap(b, y);
1742
1745
  return this.resolveFile(h);
1743
- } catch (E) {
1744
- this.showError(l.errorLoading(E));
1746
+ } catch (b) {
1747
+ this.showError(l.errorLoading(b));
1745
1748
  } finally {
1746
1749
  this.endLoading();
1747
1750
  }
@@ -1765,10 +1768,10 @@ const Gn = R, Qn = { class: "file-viewer" }, Zn = { class: "name" }, Yn = {
1765
1768
  this.startLoading(l.reading);
1766
1769
  try {
1767
1770
  o.value = y.name && decodeURIComponent(y.name) || "";
1768
- const E = yield Et(y);
1769
- E instanceof ArrayBuffer && (u = yield this.displayResult(E, y));
1770
- } catch (E) {
1771
- console.error(E), this.showError(l.errorReading(E));
1771
+ const b = yield bt(y);
1772
+ b instanceof ArrayBuffer && (u = yield this.displayResult(b, y));
1773
+ } catch (b) {
1774
+ console.error(b), this.showError(l.errorReading(b));
1772
1775
  } finally {
1773
1776
  this.endLoading();
1774
1777
  }
@@ -1776,13 +1779,13 @@ const Gn = R, Qn = { class: "file-viewer" }, Zn = { class: "name" }, Yn = {
1776
1779
  },
1777
1780
  // 展示渲染最终效果
1778
1781
  displayResult(c, y) {
1779
- const { name: E } = y, h = Nt(E), d = i.value;
1782
+ const { name: b } = y, h = Nt(b), d = i.value;
1780
1783
  if (!d)
1781
1784
  return Promise.resolve();
1782
1785
  u && (d.lastChild && d.removeChild(d.lastChild), u.unmount());
1783
- const b = document.createElement("div");
1784
- b.className = "file-render";
1785
- const S = d.appendChild(b);
1786
+ const E = document.createElement("div");
1787
+ E.className = "file-render";
1788
+ const S = d.appendChild(E);
1786
1789
  return new Promise((O, x) => Ft(c, h, S).then(O).catch(x));
1787
1790
  },
1788
1791
  showError(c) {
@@ -1797,14 +1800,14 @@ const Gn = R, Qn = { class: "file-viewer" }, Zn = { class: "name" }, Yn = {
1797
1800
  };
1798
1801
  lt(() => {
1799
1802
  t.file && p.resolveFile(t.file), p.loadFromUrl();
1800
- }), Ee(() => t.url, () => p.loadFromUrl()), Ee(() => t.file, (c) => c && p.resolveFile(c));
1803
+ }), be(() => t.url, () => p.loadFromUrl()), be(() => t.file, (c) => c && p.resolveFile(c));
1801
1804
  })(), (l, u) => (H(), M("div", Qn, [
1802
1805
  ee("div", Zn, q(o.value), 1),
1803
1806
  r.value ? (H(), M("div", Yn, q(r.value), 1)) : (H(), M(ut, { key: 1 }, [
1804
- be(ee("div", { class: "content loading" }, q(s.value), 513), [
1807
+ Ee(ee("div", { class: "content loading" }, q(s.value), 513), [
1805
1808
  [Re, n.value]
1806
1809
  ]),
1807
- be(ee("div", {
1810
+ Ee(ee("div", {
1808
1811
  class: "content",
1809
1812
  ref_key: "output",
1810
1813
  ref: i
@@ -1,21 +1,21 @@
1
1
  var s = Object.defineProperty;
2
2
  var n = (e, r, o) => r in e ? s(e, r, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[r] = o;
3
- var t = (e, r, o) => (n(e, typeof r != "symbol" ? r + "" : r, o), o);
4
- const u = "/node_modules/file-viewer3/dist/worker/";
5
- class w {
3
+ var l = (e, r, o) => (n(e, typeof r != "symbol" ? r + "" : r, o), o);
4
+ const u = "/node_modules/@flyfish-group/file-viewer3/dist/worker/";
5
+ class i {
6
6
  constructor(r) {
7
- t(this, "worker", null);
7
+ l(this, "worker", null);
8
8
  this.worker = r;
9
9
  }
10
10
  defaults(r) {
11
11
  return this.worker || r();
12
12
  }
13
13
  }
14
- function i(e, r = !1) {
14
+ function c(e, r = !1) {
15
15
  let o = null;
16
- const l = `${u}${e}`;
17
- return o = new Worker(new URL(l, import.meta.url), { type: r ? "module" : "classic" }), new w(o);
16
+ const t = `${u}${e}`;
17
+ return o = new Worker(new URL(t, import.meta.url), { type: r ? "module" : "classic" }), new i(o);
18
18
  }
19
19
  export {
20
- i as r
20
+ c as r
21
21
  };
@@ -0,0 +1,47 @@
1
+ import type { App } from 'vue';
2
+ import { ComponentOptionsMixin } from 'vue';
3
+ import { DefineComponent } from 'vue';
4
+ import { ExtractPropTypes } from 'vue';
5
+ import { PropType } from 'vue';
6
+ import { PublicProps } from 'vue';
7
+
8
+ declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
9
+
10
+ declare type __VLS_TypePropsToRuntimeProps<T> = {
11
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
12
+ type: PropType<__VLS_NonUndefinedable<T[K]>>;
13
+ } : {
14
+ type: PropType<T[K]>;
15
+ required: true;
16
+ };
17
+ };
18
+
19
+ declare const _default: Installer;
20
+ export default _default;
21
+
22
+ /**
23
+ * 文件引用,支持三种
24
+ */
25
+ declare type FileRef = File | Blob | ArrayBuffer;
26
+
27
+ export declare const FileViewer: DefineComponent<__VLS_TypePropsToRuntimeProps<{
28
+ file?: FileRef | undefined;
29
+ url?: string | undefined;
30
+ }>, {}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
31
+ file?: FileRef | undefined;
32
+ url?: string | undefined;
33
+ }>>>, {}, {}>;
34
+
35
+ declare interface FileViewerInstaller {
36
+ install(app: App): void;
37
+ }
38
+
39
+ /**
40
+ * 安装器
41
+ */
42
+ declare class Installer implements FileViewerInstaller {
43
+ private installed;
44
+ install(app: App): void;
45
+ }
46
+
47
+ export { }