@file-viewer/vue3 3.1.1 → 3.2.0

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 (33) hide show
  1. package/README.en.md +3 -425
  2. package/README.md +3 -428
  3. package/dist/components/export.js +78 -78
  4. package/dist/components/export2.js +377 -357
  5. package/dist/components/fit.js +153 -93
  6. package/dist/components/image.js +49 -53
  7. package/dist/components/objectSpread2.js +6 -6
  8. package/dist/components/print-mask.js +4 -12
  9. package/dist/components/printMask.js +2 -5
  10. package/dist/index.mjs +1838 -1602
  11. package/dist/src/package/browser/printLayout.d.ts +0 -4
  12. package/dist/src/package/common/type.d.ts +6 -172
  13. package/dist/src/package/components/FileViewer/FileViewer.vue.d.ts +7 -5
  14. package/dist/src/package/components/FileViewer/ShadowFileViewer.vue.d.ts +7 -5
  15. package/dist/src/package/components/FileViewer/exportDocumentTemplate.d.ts +0 -8
  16. package/dist/src/package/components/FileViewer/hooks/useLoading.d.ts +2 -8
  17. package/dist/src/package/components/FileViewer/hooks/useViewerDocumentFeatures.d.ts +0 -6
  18. package/dist/src/package/components/FileViewer/hooks/useViewerLifecycle.d.ts +0 -6
  19. package/dist/src/package/components/FileViewer/hooks/useViewerPresentation.d.ts +0 -6
  20. package/dist/src/package/components/FileViewer/hooks/useViewerPreviewLifecycle.d.ts +0 -6
  21. package/dist/src/package/components/FileViewer/hooks/useViewerPublicApi.d.ts +0 -6
  22. package/dist/src/package/components/FileViewer/hooks/useViewerRenderSurface.d.ts +2 -8
  23. package/dist/src/package/components/FileViewer/hooks/useViewerSourceLoading.d.ts +1 -7
  24. package/dist/src/package/components/FileViewer/hooks/useViewerToolbar.d.ts +0 -6
  25. package/dist/src/package/components/FileViewer/hooks/useViewerViewState.d.ts +0 -6
  26. package/dist/src/package/components/FileViewer/hooks/useViewerZoom.d.ts +3 -8
  27. package/dist/src/package/components/FileViewer/index.d.ts +1 -1
  28. package/dist/src/package/components/FileViewer/rendererBridge.d.ts +0 -8
  29. package/dist/src/package/index.d.ts +6 -10
  30. package/dist/src/package/native.d.ts +1 -8
  31. package/dist/src/package/vendors/nestedRender.d.ts +0 -7
  32. package/dist/vue3.css +1 -1
  33. package/package.json +53 -25
@@ -6,56 +6,80 @@ var t = (e, t) => {
6
6
  }, n = (e, t) => {
7
7
  let n = document.createElement("a");
8
8
  n.href = e, n.download = t, n.rel = "noopener", n.target = "_blank", document.body.appendChild(n), n.click(), n.remove();
9
- }, r = (e, t) => {
9
+ }, r = /* @__PURE__ */ "display.position.top.right.bottom.left.box-sizing.width.height.min-width.min-height.max-width.max-height.margin-top.margin-right.margin-bottom.margin-left.padding-top.padding-right.padding-bottom.padding-left.border-top.border-right.border-bottom.border-left.border-radius.transform.transform-origin.vertical-align.float.clear.opacity.visibility.z-index.align-self.justify-self.flex-grow.flex-shrink.flex-basis.order.grid-area".split("."), i = (e, t) => {
10
10
  let n = Array.from(e.querySelectorAll("canvas"));
11
- Array.from(t.querySelectorAll("canvas")).forEach((t, r) => {
12
- let i = n[r];
13
- if (i) try {
14
- let n = e.ownerDocument.createElement("img");
15
- n.src = i.toDataURL("image/png"), n.alt = "rendered canvas", n.style.maxWidth = "100%", n.style.display = "block", n.style.margin = "0 auto", t.replaceWith(n);
11
+ Array.from(t.querySelectorAll("canvas")).forEach((e, t) => {
12
+ var i;
13
+ let a = n[t];
14
+ if (a) try {
15
+ let t = e.ownerDocument.createElement("img");
16
+ t.src = a.toDataURL("image/png"), t.alt = a.getAttribute("aria-label") || "rendered canvas", t.className = e.className, t.id = e.id, t.style.cssText = e.style.cssText;
17
+ let n = (i = a.ownerDocument.defaultView) == null ? void 0 : i.getComputedStyle(a);
18
+ if (n) for (let i of r) {
19
+ let r = n.getPropertyValue(i);
20
+ r && t.style.setProperty(i, r, e.style.getPropertyPriority(i));
21
+ }
22
+ (!t.style.width || t.style.width === "auto") && (t.style.width = `${a.width}px`), (!t.style.height || t.style.height === "auto") && (t.style.height = `${a.height}px`), e.replaceWith(t);
16
23
  } catch (e) {}
17
24
  });
18
- }, i = (e) => new Promise((t) => {
19
- let n = e || globalThis.window;
20
- if (!n || typeof n.requestAnimationFrame != "function") {
21
- (n != null && n.setTimeout ? n.setTimeout.bind(n) : globalThis.setTimeout.bind(globalThis))(() => t(), 0);
22
- return;
25
+ }, a = (e) => new Promise((t) => {
26
+ var n, r;
27
+ let i = e || globalThis.window, a = ((n = i == null ? void 0 : i.setTimeout) == null ? void 0 : n.bind(i)) || globalThis.setTimeout.bind(globalThis), o = ((r = i == null ? void 0 : i.clearTimeout) == null ? void 0 : r.bind(i)) || globalThis.clearTimeout.bind(globalThis), s, c, l = !1, u = () => {
28
+ var e;
29
+ l || (l = !0, c !== void 0 && o(c), s !== void 0 && ((e = i == null ? void 0 : i.cancelAnimationFrame) == null || e.call(i, s)), t());
30
+ };
31
+ if (c = a(u, i != null && i.requestAnimationFrame ? 250 : 0), !l && i != null && i.requestAnimationFrame) try {
32
+ s = i.requestAnimationFrame(() => {
33
+ if (!l) try {
34
+ s = i.requestAnimationFrame(u);
35
+ } catch (e) {
36
+ u();
37
+ }
38
+ });
39
+ } catch (e) {
40
+ u();
41
+ }
42
+ }), o = (e, t) => e.complete ? Promise.resolve() : new Promise((n) => {
43
+ let r = !1, i = () => {
44
+ r || (r = !0, clearTimeout(a), e.removeEventListener("load", i), e.removeEventListener("error", i), n());
45
+ }, a = setTimeout(i, t);
46
+ if (e.addEventListener("load", i, { once: !0 }), e.addEventListener("error", i, { once: !0 }), e.complete) i();
47
+ else if (typeof e.decode == "function") try {
48
+ e.decode().then(i, () => {
49
+ e.complete && i();
50
+ });
51
+ } catch (t) {
52
+ e.complete && i();
23
53
  }
24
- let r = n.requestAnimationFrame.bind(n);
25
- r(() => {
26
- r(() => t());
54
+ }), s = function() {
55
+ var t = e(function* (e, t) {
56
+ if (!(e != null && e.fonts)) return;
57
+ let n;
58
+ try {
59
+ yield Promise.race([e.fonts.ready, new Promise((e) => {
60
+ n = setTimeout(e, t);
61
+ })]);
62
+ } catch (e) {} finally {
63
+ n !== void 0 && clearTimeout(n);
64
+ }
27
65
  });
28
- }), a = function() {
29
- var t = e(function* (t) {
30
- if (!t || typeof t.querySelectorAll != "function") return;
31
- let n = Array.from(t.querySelectorAll("img"));
32
- yield Promise.all(n.map(function() {
33
- var t = e(function* (e) {
34
- if (!e.complete) {
35
- if ("decode" in e) try {
36
- yield e.decode();
37
- return;
38
- } catch (e) {}
39
- yield new Promise((t) => {
40
- e.addEventListener("load", () => t(), { once: !0 }), e.addEventListener("error", () => t(), { once: !0 });
41
- });
42
- }
43
- });
44
- return function(e) {
45
- return t.apply(this, arguments);
46
- };
47
- }()));
66
+ return function(e, n) {
67
+ return t.apply(this, arguments);
68
+ };
69
+ }(), c = function() {
70
+ var t = e(function* (e) {
71
+ e && typeof e.querySelectorAll == "function" && (yield Promise.all(Array.from(e.querySelectorAll("img"), (e) => o(e, 5e3))));
48
72
  });
49
73
  return function(e) {
50
74
  return t.apply(this, arguments);
51
75
  };
52
- }(), o = (e, t) => {
76
+ }(), l = (e, t) => {
53
77
  let n = t || "application/octet-stream", r = globalThis.Buffer;
54
78
  if (r) return `data:${n};base64,${r.from(e).toString("base64")}`;
55
79
  let i = "", a = new Uint8Array(e);
56
80
  for (let e = 0; e < a.length; e += 1) i += String.fromCharCode(a[e]);
57
81
  return `data:${n};base64,${btoa(i)}`;
58
- }, s = function() {
82
+ }, u = function() {
59
83
  var t = e(function* (e) {
60
84
  if (typeof FileReader == "function") try {
61
85
  return yield new Promise((t, n) => {
@@ -63,25 +87,25 @@ var t = (e, t) => {
63
87
  r.onload = () => t(String(r.result || "")), r.onerror = () => n(r.error || /* @__PURE__ */ Error("Failed to read blob")), r.readAsDataURL(e);
64
88
  });
65
89
  } catch (e) {}
66
- return o(yield e.arrayBuffer(), e.type || "application/octet-stream");
90
+ return l(yield e.arrayBuffer(), e.type || "application/octet-stream");
67
91
  });
68
92
  return function(e) {
69
93
  return t.apply(this, arguments);
70
94
  };
71
- }(), c = (e) => {
95
+ }(), d = (e) => {
72
96
  let t = e.match(/blob:[^\s"'<>)\\]+/g) || [];
73
97
  return Array.from(new Set(t));
74
- }, l = function() {
98
+ }, f = function() {
75
99
  var t = e(function* (t) {
76
100
  if (!t.includes("blob:") || typeof fetch != "function") return t;
77
- let n = c(t);
101
+ let n = d(t);
78
102
  if (!n.length) return t;
79
103
  let r = yield Promise.all(n.map(function() {
80
104
  var t = e(function* (e) {
81
105
  try {
82
106
  let t = yield fetch(e);
83
107
  if (!t.ok) return null;
84
- let n = yield s(yield t.blob());
108
+ let n = yield u(yield t.blob());
85
109
  return n ? [e, n] : null;
86
110
  } catch (e) {
87
111
  return null;
@@ -101,58 +125,34 @@ var t = (e, t) => {
101
125
  return function(e) {
102
126
  return t.apply(this, arguments);
103
127
  };
104
- }(), u = function() {
105
- var t = e(function* (t) {
106
- let { document: n } = t;
107
- n.readyState !== "complete" && (yield new Promise((e) => {
108
- t.addEventListener("load", () => e(), { once: !0 }), t.setTimeout(() => e(), 1200);
109
- })), yield Promise.all(Array.from(n.images).map(function() {
110
- var n = e(function* (e) {
111
- if (!e.complete) {
112
- if ("decode" in e) try {
113
- yield e.decode();
114
- return;
115
- } catch (e) {}
116
- yield new Promise((n) => {
117
- e.addEventListener("load", () => n(), { once: !0 }), e.addEventListener("error", () => n(), { once: !0 }), t.setTimeout(() => n(), 1500);
118
- });
119
- }
120
- });
121
- return function(e) {
122
- return n.apply(this, arguments);
123
- };
124
- }())), yield new Promise((e) => {
125
- let n = !1, r, i = () => {
126
- n || (n = !0, r !== void 0 && t.clearTimeout(r), e());
127
- };
128
- r = t.setTimeout(i, 250);
129
- try {
130
- t.requestAnimationFrame(() => {
131
- t.requestAnimationFrame(i);
132
- });
133
- } catch (e) {
134
- i();
135
- }
136
- });
128
+ }(), p = function() {
129
+ var t = e(function* (e) {
130
+ let { document: t } = e;
131
+ t.readyState !== "complete" && (yield new Promise((n) => {
132
+ let r = !1, i = () => {
133
+ r || (r = !0, e.clearTimeout(a), e.removeEventListener("load", i), n());
134
+ }, a = e.setTimeout(i, 1200);
135
+ e.addEventListener("load", i, { once: !0 }), t.readyState === "complete" && i();
136
+ })), yield Promise.all([...Array.from(t.images, (e) => o(e, 1500)), s(t, 1500)]), yield a(e);
137
137
  });
138
138
  return function(e) {
139
139
  return t.apply(this, arguments);
140
140
  };
141
- }(), d = function() {
141
+ }(), m = function() {
142
142
  var t = e(function* (e, t) {
143
143
  return t.mode !== "print" || !(e != null && e.printStyle) ? "" : typeof e.printStyle == "function" ? yield e.printStyle(t) : e.printStyle;
144
144
  });
145
145
  return function(e, n) {
146
146
  return t.apply(this, arguments);
147
147
  };
148
- }(), f = function() {
148
+ }(), h = function() {
149
149
  var t = e(function* (e, t) {
150
150
  var n;
151
- yield (n = t == null ? void 0 : t.beforeSnapshot) == null ? void 0 : n.call(t), yield i(e.ownerDocument.defaultView || void 0), yield a(e);
151
+ yield (n = t == null ? void 0 : t.beforeSnapshot) == null ? void 0 : n.call(t), yield Promise.all([c(e), s(e.ownerDocument, 5e3)]), yield a(e.ownerDocument.defaultView || void 0);
152
152
  });
153
153
  return function(e, n) {
154
154
  return t.apply(this, arguments);
155
155
  };
156
156
  }();
157
157
  //#endregion
158
- export { t as a, i as c, d as i, u as l, f as n, n as o, r, a as s, l as t };
158
+ export { t as a, a as c, m as i, p as l, h as n, n as o, i as r, c as s, f as t };