@work-zhanguo/light-file-preview 0.0.5 → 0.0.7

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 (39) hide show
  1. package/README.md +3 -1
  2. package/dist/{DocxRenderer-B8Ed3qFw.js → DocxRenderer-DogNhBLd.js} +2 -2
  3. package/dist/PdfRenderer-Due2M5cA.js +57 -0
  4. package/dist/{SheetRenderer-C9AKQiKN.js → SheetRenderer-D4Y1dYZX.js} +2 -2
  5. package/dist/{TextRenderer-W4uPsa5O.js → TextRenderer-KUhpnf63.js} +14 -14
  6. package/dist/{UnsupportedRenderer-BpyBTIIE.js → UnsupportedRenderer-8vWx7yB8.js} +1 -1
  7. package/dist/_commonjs-dynamic-modules-C74YT1gS.js +32 -0
  8. package/dist/{docx-preview-B2OPGnfm.js → docx-preview-BV-bQyiM.js} +729 -721
  9. package/dist/{index-BlBE9ZR-.js → index-BNN8UXSN.js} +86 -85
  10. package/dist/light-file-preview.js +1 -1
  11. package/dist/light-file-preview.umd.cjs +158 -161
  12. package/dist/{marked.esm-toXckLRC.js → marked.esm-CRmQbSOC.js} +15 -15
  13. package/dist/pdf-BiKi76Et.js +15320 -0
  14. package/dist/{purify.es-D5dazAgD.js → purify.es-CCmmh-Lt.js} +10 -10
  15. package/dist/standalone/light-file-preview.iife.js +160 -163
  16. package/dist/standalone/style.css +1 -1
  17. package/dist/style.css +1 -1
  18. package/dist/{text-CcxmtFce.js → text-Bqxn_tMI.js} +5 -5
  19. package/dist/vue2/{DocxRenderer-IkLQeCjg.js → DocxRenderer-B9neMid7.js} +3 -3
  20. package/dist/vue2/PdfRenderer-iEictZ1C.js +57 -0
  21. package/dist/vue2/{SheetRenderer-CuAyFgj9.js → SheetRenderer-KITfWM9E.js} +3 -3
  22. package/dist/vue2/{TextRenderer-Bxqs7APd.js → TextRenderer-B8_BjhwJ.js} +14 -14
  23. package/dist/vue2/{UnsupportedRenderer-Cs2uPl_6.js → UnsupportedRenderer-WZYKdRc9.js} +1 -1
  24. package/dist/vue2/_commonjs-dynamic-modules-C74YT1gS.js +32 -0
  25. package/dist/vue2/{docx-preview-B2OPGnfm.js → docx-preview-BV-bQyiM.js} +729 -721
  26. package/dist/vue2/light-file-preview-vue2.js +1 -1
  27. package/dist/vue2/light-file-preview-vue2.umd.cjs +160 -163
  28. package/dist/vue2/{marked.esm-toXckLRC.js → marked.esm-CRmQbSOC.js} +15 -15
  29. package/dist/vue2/pdf-BiKi76Et.js +15320 -0
  30. package/dist/vue2/{purify.es-D5dazAgD.js → purify.es-CCmmh-Lt.js} +10 -10
  31. package/dist/vue2/{text-CcxmtFce.js → text-Bqxn_tMI.js} +5 -5
  32. package/dist/vue2/{vue2-CzAkhodr.js → vue2-C2dNeAAJ.js} +119 -118
  33. package/dist/vue2/{xlsx-CZNBZqms.js → xlsx-j9Zzywas.js} +82 -82
  34. package/dist/{xlsx-CZNBZqms.js → xlsx-j9Zzywas.js} +82 -82
  35. package/package.json +2 -2
  36. package/dist/PdfRenderer-CYtwJLrP.js +0 -57
  37. package/dist/pdf-B2JYpzlX.js +0 -14597
  38. package/dist/vue2/PdfRenderer-DmgMRpqS.js +0 -57
  39. package/dist/vue2/pdf-B2JYpzlX.js +0 -14597
@@ -1,4 +1,4 @@
1
- import { defineComponent as V, defineAsyncComponent as h, ref as U, computed as w, watch as Z, onBeforeUnmount as H, openBlock as s, createBlock as x, Teleport as K, createElementBlock as d, normalizeClass as q, createCommentVNode as y, createElementVNode as l, toDisplayString as E, createVNode as z, Transition as X, withCtx as $, Fragment as G, unref as k, reactive as I, createApp as A, h as F } from "vue";
1
+ import { defineComponent as V, defineAsyncComponent as h, ref as U, computed as w, watch as Z, onBeforeUnmount as H, openBlock as s, createBlock as x, Teleport as K, createElementBlock as v, normalizeClass as q, createCommentVNode as y, createElementVNode as a, toDisplayString as E, createVNode as z, Transition as X, withCtx as $, Fragment as G, unref as k, reactive as A, createApp as F, h as M } from "vue";
2
2
  const g = {
3
3
  image: ["png", "jpg", "jpeg", "gif", "webp", "bmp", "svg"],
4
4
  pdf: ["pdf"],
@@ -22,26 +22,27 @@ function W(e) {
22
22
  try {
23
23
  const t = new URL(e, window.location.href);
24
24
  return t.pathname = t.pathname.split("/").map((o) => encodeURIComponent(decodeURIComponent(o))).join("/"), t.toString();
25
- } catch {
26
- return e.split("/").map((t) => encodeURIComponent(decodeURIComponent(t))).join("/");
25
+ } catch (t) {
26
+ return e.split("/").map((o) => encodeURIComponent(decodeURIComponent(o))).join("/");
27
27
  }
28
28
  }
29
- function P(e, t) {
29
+ function I(e, t) {
30
+ var i;
30
31
  if (typeof e == "string") {
31
- const u = W(e), p = e.split("/"), c = t ?? p[p.length - 1] ?? "unknown";
32
+ const p = W(e), d = e.split("/"), l = (i = t != null ? t : d[d.length - 1]) != null ? i : "unknown";
32
33
  return {
33
34
  source: e,
34
- src: u,
35
- name: decodeURIComponent(c.split("?")[0].split("#")[0]),
36
- extension: S(c)
35
+ src: p,
36
+ name: decodeURIComponent(l.split("?")[0].split("#")[0]),
37
+ extension: S(l)
37
38
  };
38
39
  }
39
- const o = URL.createObjectURL(e), r = t ?? ("name" in e && typeof e.name == "string" ? e.name : "blob");
40
+ const o = URL.createObjectURL(e), c = t != null ? t : "name" in e && typeof e.name == "string" ? e.name : "blob";
40
41
  return {
41
42
  source: e,
42
43
  src: o,
43
- name: r,
44
- extension: S(r),
44
+ name: c,
45
+ extension: S(c),
45
46
  cleanup: () => URL.revokeObjectURL(o)
46
47
  };
47
48
  }
@@ -52,7 +53,7 @@ function Y(e, t) {
52
53
  const ee = ["aria-modal"], te = {
53
54
  key: 0,
54
55
  class: "lfp-toolbar"
55
- }, oe = { class: "lfp-toolbar__meta" }, ne = { class: "lfp-title" }, ae = { class: "lfp-badge" }, le = { class: "lfp-toolbar__actions" }, se = { class: "lfp-content" }, ie = {
56
+ }, oe = { class: "lfp-toolbar__meta" }, ne = { class: "lfp-title" }, le = { class: "lfp-badge" }, ae = { class: "lfp-toolbar__actions" }, se = { class: "lfp-content" }, ie = {
56
57
  key: 0,
57
58
  class: "lfp-loading"
58
59
  }, re = {
@@ -76,125 +77,125 @@ const ee = ["aria-modal"], te = {
76
77
  },
77
78
  emits: ["update:visible", "error"],
78
79
  setup(e, { emit: t }) {
79
- const o = h(() => import("./PdfRenderer-CYtwJLrP.js")), r = h(() => import("./TextRenderer-W4uPsa5O.js")), u = h(() => import("./DocxRenderer-B8Ed3qFw.js")), p = h(() => import("./SheetRenderer-C9AKQiKN.js")), c = h(() => import("./UnsupportedRenderer-BpyBTIIE.js")), a = e, N = t, f = U(null), D = U(!1), L = U(""), n = U(P(a.source, a.fileName)), m = w(() => Q(n.value.name)), M = w(() => a.fileName || n.value.name || a.dialogTitle), b = w(() => a.mode === "dialog"), O = w(() => b.value ? a.visible : !0), T = w(() => m.value === "image" ? "img" : m.value === "video" ? "video" : m.value === "audio" ? "audio" : null);
80
+ const o = h(() => import("./PdfRenderer-Due2M5cA.js")), c = h(() => import("./TextRenderer-KUhpnf63.js")), i = h(() => import("./DocxRenderer-DogNhBLd.js")), p = h(() => import("./SheetRenderer-D4Y1dYZX.js")), d = h(() => import("./UnsupportedRenderer-8vWx7yB8.js")), l = e, D = t, f = U(null), j = U(!1), L = U(""), n = U(I(l.source, l.fileName)), m = w(() => Q(n.value.name)), N = w(() => l.fileName || n.value.name || l.dialogTitle), b = w(() => l.mode === "dialog"), O = w(() => b.value ? l.visible : !0), T = w(() => m.value === "image" ? "img" : m.value === "video" ? "video" : m.value === "audio" ? "audio" : null);
80
81
  Z(
81
- () => [a.source, a.fileName],
82
+ () => [l.source, l.fileName],
82
83
  () => {
83
- var i;
84
- (i = f.value) == null || i.call(f), n.value = P(a.source, a.fileName), f.value = n.value.cleanup ?? null, L.value = "";
84
+ var r, u;
85
+ (r = f.value) == null || r.call(f), n.value = I(l.source, l.fileName), f.value = (u = n.value.cleanup) != null ? u : null, L.value = "";
85
86
  },
86
87
  { immediate: !0 }
87
88
  ), H(() => {
88
- var i;
89
- (i = f.value) == null || i.call(f);
89
+ var r;
90
+ (r = f.value) == null || r.call(f);
90
91
  });
91
- function j() {
92
- N("update:visible", !1);
93
- }
94
92
  function B() {
93
+ D("update:visible", !1);
94
+ }
95
+ function P() {
95
96
  Y(n.value.src, n.value.name);
96
97
  }
97
- function R(i) {
98
- L.value = i.message, N("error", i);
98
+ function R(r) {
99
+ L.value = r.message, D("error", r);
99
100
  }
100
- function _(i) {
101
- D.value = i;
101
+ function _(r) {
102
+ j.value = r;
102
103
  }
103
- return (i, v) => (s(), x(K, {
104
+ return (r, u) => (s(), x(K, {
104
105
  to: "body",
105
106
  disabled: !b.value
106
107
  }, [
107
- O.value ? (s(), d("div", {
108
+ O.value ? (s(), v("div", {
108
109
  key: 0,
109
110
  class: q(["lfp-wrapper", { "is-dialog": b.value }])
110
111
  }, [
111
- b.value ? (s(), d("div", {
112
+ b.value ? (s(), v("div", {
112
113
  key: 0,
113
114
  class: "lfp-backdrop",
114
- onClick: j
115
+ onClick: B
115
116
  })) : y("", !0),
116
- l("section", {
117
+ a("section", {
117
118
  class: "lfp-panel",
118
119
  role: "dialog",
119
120
  "aria-modal": b.value ? "true" : "false"
120
121
  }, [
121
- e.showToolbar ? (s(), d("header", te, [
122
- l("div", oe, [
123
- l("strong", ne, E(M.value), 1),
124
- l("span", ae, E(m.value), 1)
122
+ e.showToolbar ? (s(), v("header", te, [
123
+ a("div", oe, [
124
+ a("strong", ne, E(N.value), 1),
125
+ a("span", le, E(m.value), 1)
125
126
  ]),
126
- l("div", le, [
127
- l("button", {
127
+ a("div", ae, [
128
+ a("button", {
128
129
  class: "lfp-button lfp-icon-button",
129
130
  type: "button",
130
131
  "aria-label": "Download",
131
132
  title: "Download",
132
- onClick: B
133
- }, [...v[0] || (v[0] = [
134
- l("svg", {
133
+ onClick: P
134
+ }, [...u[0] || (u[0] = [
135
+ a("svg", {
135
136
  viewBox: "0 0 24 24",
136
137
  "aria-hidden": "true"
137
138
  }, [
138
- l("path", { d: "M12 3.5a1 1 0 0 1 1 1V12l2.8-2.8a1 1 0 1 1 1.4 1.42l-4.5 4.48a1 1 0 0 1-1.4 0l-4.5-4.48a1 1 0 0 1 1.4-1.42L11 12V4.5a1 1 0 0 1 1-1Zm-7 13a1 1 0 0 1 1 1v.75c0 .41.34.75.75.75h10.5a.75.75 0 0 0 .75-.75v-.75a1 1 0 1 1 2 0v.75A2.75 2.75 0 0 1 17.25 21H6.75A2.75 2.75 0 0 1 4 18.25v-.75a1 1 0 0 1 1-1Z" })
139
+ a("path", { d: "M12 3.5a1 1 0 0 1 1 1V12l2.8-2.8a1 1 0 1 1 1.4 1.42l-4.5 4.48a1 1 0 0 1-1.4 0l-4.5-4.48a1 1 0 0 1 1.4-1.42L11 12V4.5a1 1 0 0 1 1-1Zm-7 13a1 1 0 0 1 1 1v.75c0 .41.34.75.75.75h10.5a.75.75 0 0 0 .75-.75v-.75a1 1 0 1 1 2 0v.75A2.75 2.75 0 0 1 17.25 21H6.75A2.75 2.75 0 0 1 4 18.25v-.75a1 1 0 0 1 1-1Z" })
139
140
  ], -1)
140
141
  ])]),
141
- b.value ? (s(), d("button", {
142
+ b.value ? (s(), v("button", {
142
143
  key: 0,
143
144
  class: "lfp-button lfp-button is-ghost lfp-icon-button",
144
145
  type: "button",
145
146
  "aria-label": "Close",
146
147
  title: "Close",
147
- onClick: j
148
- }, [...v[1] || (v[1] = [
149
- l("svg", {
148
+ onClick: B
149
+ }, [...u[1] || (u[1] = [
150
+ a("svg", {
150
151
  viewBox: "0 0 24 24",
151
152
  "aria-hidden": "true"
152
153
  }, [
153
- l("path", { d: "M6.7 5.3a1 1 0 0 1 1.4 0L12 9.17l3.9-3.88a1 1 0 1 1 1.4 1.42L13.4 10.6l3.9 3.89a1 1 0 0 1-1.4 1.42L12 12.03l-3.9 3.88a1 1 0 0 1-1.4-1.42l3.9-3.89-3.9-3.89a1 1 0 0 1 0-1.42Z" })
154
+ a("path", { d: "M6.7 5.3a1 1 0 0 1 1.4 0L12 9.17l3.9-3.88a1 1 0 1 1 1.4 1.42L13.4 10.6l3.9 3.89a1 1 0 0 1-1.4 1.42L12 12.03l-3.9 3.88a1 1 0 0 1-1.4-1.42l3.9-3.89-3.9-3.89a1 1 0 0 1 0-1.42Z" })
154
155
  ], -1)
155
156
  ])])) : y("", !0)
156
157
  ])
157
158
  ])) : y("", !0),
158
- l("div", se, [
159
+ a("div", se, [
159
160
  z(X, { name: "lfp-fade" }, {
160
161
  default: $(() => [
161
- D.value ? (s(), d("div", ie, [
162
- v[2] || (v[2] = l("span", { class: "lfp-spinner" }, null, -1)),
163
- l("span", null, E(e.loadingText), 1)
162
+ j.value ? (s(), v("div", ie, [
163
+ u[2] || (u[2] = a("span", { class: "lfp-spinner" }, null, -1)),
164
+ a("span", null, E(e.loadingText), 1)
164
165
  ])) : y("", !0)
165
166
  ]),
166
167
  _: 1
167
168
  }),
168
- L.value ? (s(), d("div", re, [
169
- l("p", null, E(L.value), 1),
170
- l("button", {
169
+ L.value ? (s(), v("div", re, [
170
+ a("p", null, E(L.value), 1),
171
+ a("button", {
171
172
  class: "lfp-button lfp-icon-button",
172
173
  type: "button",
173
174
  "aria-label": "Download",
174
175
  title: "Download",
175
- onClick: B
176
- }, [...v[3] || (v[3] = [
177
- l("svg", {
176
+ onClick: P
177
+ }, [...u[3] || (u[3] = [
178
+ a("svg", {
178
179
  viewBox: "0 0 24 24",
179
180
  "aria-hidden": "true"
180
181
  }, [
181
- l("path", { d: "M12 3.5a1 1 0 0 1 1 1V12l2.8-2.8a1 1 0 1 1 1.4 1.42l-4.5 4.48a1 1 0 0 1-1.4 0l-4.5-4.48a1 1 0 0 1 1.4-1.42L11 12V4.5a1 1 0 0 1 1-1Zm-7 13a1 1 0 0 1 1 1v.75c0 .41.34.75.75.75h10.5a.75.75 0 0 0 .75-.75v-.75a1 1 0 1 1 2 0v.75A2.75 2.75 0 0 1 17.25 21H6.75A2.75 2.75 0 0 1 4 18.25v-.75a1 1 0 0 1 1-1Z" })
182
+ a("path", { d: "M12 3.5a1 1 0 0 1 1 1V12l2.8-2.8a1 1 0 1 1 1.4 1.42l-4.5 4.48a1 1 0 0 1-1.4 0l-4.5-4.48a1 1 0 0 1 1.4-1.42L11 12V4.5a1 1 0 0 1 1-1Zm-7 13a1 1 0 0 1 1 1v.75c0 .41.34.75.75.75h10.5a.75.75 0 0 0 .75-.75v-.75a1 1 0 1 1 2 0v.75A2.75 2.75 0 0 1 17.25 21H6.75A2.75 2.75 0 0 1 4 18.25v-.75a1 1 0 0 1 1-1Z" })
182
183
  ], -1)
183
184
  ])])
184
- ])) : (s(), d(G, { key: 1 }, [
185
- T.value === "img" ? (s(), d("img", {
185
+ ])) : (s(), v(G, { key: 1 }, [
186
+ T.value === "img" ? (s(), v("img", {
186
187
  key: n.value.src,
187
188
  class: "lfp-image",
188
189
  src: n.value.src,
189
190
  alt: n.value.name,
190
191
  loading: "lazy"
191
- }, null, 8, ue)) : T.value === "video" ? (s(), d("video", {
192
+ }, null, 8, ue)) : T.value === "video" ? (s(), v("video", {
192
193
  key: n.value.src,
193
194
  class: "lfp-media",
194
195
  src: n.value.src,
195
196
  controls: "",
196
197
  preload: "metadata"
197
- }, null, 8, ce)) : T.value === "audio" ? (s(), d("audio", {
198
+ }, null, 8, ce)) : T.value === "audio" ? (s(), v("audio", {
198
199
  key: n.value.src,
199
200
  class: "lfp-audio",
200
201
  src: n.value.src,
@@ -202,31 +203,31 @@ const ee = ["aria-modal"], te = {
202
203
  preload: "metadata"
203
204
  }, null, 8, de)) : m.value === "pdf" ? (s(), x(k(o), {
204
205
  key: n.value.src,
205
- source: typeof a.source == "string" ? n.value.src : a.source,
206
+ source: typeof l.source == "string" ? n.value.src : l.source,
206
207
  scale: e.pdfScale,
207
208
  onLoading: _,
208
209
  onError: R
209
- }, null, 8, ["source", "scale"])) : m.value === "docx" ? (s(), x(k(u), {
210
+ }, null, 8, ["source", "scale"])) : m.value === "docx" ? (s(), x(k(i), {
210
211
  key: n.value.src,
211
- source: typeof a.source == "string" ? n.value.src : a.source,
212
+ source: typeof l.source == "string" ? n.value.src : l.source,
212
213
  onLoading: _,
213
214
  onError: R
214
215
  }, null, 8, ["source"])) : m.value === "sheet" ? (s(), x(k(p), {
215
216
  key: n.value.src,
216
- source: typeof a.source == "string" ? n.value.src : a.source,
217
+ source: typeof l.source == "string" ? n.value.src : l.source,
217
218
  "max-cols": e.maxSheetCols,
218
219
  "max-rows": e.maxSheetRows,
219
220
  onLoading: _,
220
221
  onError: R
221
- }, null, 8, ["source", "max-cols", "max-rows"])) : m.value === "text" ? (s(), x(k(r), {
222
+ }, null, 8, ["source", "max-cols", "max-rows"])) : m.value === "text" ? (s(), x(k(c), {
222
223
  key: n.value.src,
223
- source: typeof a.source == "string" ? n.value.src : a.source,
224
+ source: typeof l.source == "string" ? n.value.src : l.source,
224
225
  encoding: e.textEncoding,
225
226
  extension: n.value.extension,
226
227
  "max-bytes": e.maxTextBytes,
227
228
  onLoading: _,
228
229
  onError: R
229
- }, null, 8, ["source", "encoding", "extension", "max-bytes"])) : (s(), x(k(c), {
230
+ }, null, 8, ["source", "encoding", "extension", "max-bytes"])) : (s(), x(k(d), {
230
231
  key: 7,
231
232
  "file-name": n.value.name,
232
233
  src: n.value.src
@@ -238,7 +239,7 @@ const ee = ["aria-modal"], te = {
238
239
  ], 8, ["disabled"]));
239
240
  }
240
241
  });
241
- function pe(e) {
242
+ function ve(e) {
242
243
  if (typeof e == "string") {
243
244
  const t = document.querySelector(e);
244
245
  if (!t)
@@ -247,36 +248,36 @@ function pe(e) {
247
248
  }
248
249
  return e;
249
250
  }
250
- function me(e, t) {
251
- const o = I({ ...t }), r = pe(e), u = A({
252
- render: () => F(C, o)
251
+ function pe(e, t) {
252
+ const o = A({ ...t }), c = ve(e), i = F({
253
+ render: () => M(C, o)
253
254
  });
254
- return u.mount(r), {
255
+ return i.mount(c), {
255
256
  update(p) {
256
257
  Object.assign(o, p);
257
258
  },
258
259
  unmount() {
259
- u.unmount();
260
+ i.unmount();
260
261
  }
261
262
  };
262
263
  }
263
- function ve(e) {
264
+ function me(e) {
264
265
  const t = document.createElement("div");
265
266
  document.body.append(t);
266
267
  let o;
267
- const r = e["onUpdate:visible"], u = I({
268
+ const c = e["onUpdate:visible"], i = A({
268
269
  visible: !0,
269
270
  mode: "dialog",
270
271
  ...e,
271
- "onUpdate:visible"(c) {
272
- r == null || r(c), u.visible = c, c || queueMicrotask(() => o.unmount());
272
+ "onUpdate:visible"(d) {
273
+ c == null || c(d), i.visible = d, d || queueMicrotask(() => o.unmount());
273
274
  }
274
- }), p = A({
275
- render: () => F(C, u)
275
+ }), p = F({
276
+ render: () => M(C, i)
276
277
  });
277
278
  return p.mount(t), o = {
278
- update(c) {
279
- Object.assign(u, c);
279
+ update(d) {
280
+ Object.assign(i, d);
280
281
  },
281
282
  unmount() {
282
283
  p.unmount(), t.remove();
@@ -285,10 +286,10 @@ function ve(e) {
285
286
  }
286
287
  function ge() {
287
288
  const e = {
288
- mount: me,
289
- openDialog: ve
289
+ mount: pe,
290
+ openDialog: me
290
291
  };
291
- return typeof window < "u" && (window.LightFilePreview = e), e;
292
+ return typeof window != "undefined" && (window.LightFilePreview = e), e;
292
293
  }
293
294
  const be = {
294
295
  install(e) {
@@ -299,6 +300,6 @@ export {
299
300
  C as _,
300
301
  Y as d,
301
302
  be as i,
302
- ve as o,
303
+ me as o,
303
304
  ge as r
304
305
  };
@@ -1,4 +1,4 @@
1
- import { _ as i, i as r, o, r as l } from "./index-BlBE9ZR-.js";
1
+ import { _ as i, i as r, o, r as l } from "./index-BNN8UXSN.js";
2
2
  export {
3
3
  i as FilePreview,
4
4
  r as default,