filens-preview 0.3.0 → 0.3.2
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 +13 -7
- package/dist/all-in-one/THIRD-PARTY-NOTICES.txt +870 -0
- package/dist/all-in-one/filens.js +5069 -114897
- package/dist/index.d.ts +2 -0
- package/dist/split/THIRD-PARTY-NOTICES.txt +870 -0
- package/dist/split/chunks/archive-haip2eOP.js +1 -0
- package/dist/split/chunks/browser-video-session-C_14e_mG.js +1 -0
- package/dist/split/chunks/cad-5oTkbaDV.js +7 -0
- package/dist/split/chunks/core-EjELrtsP.js +17 -0
- package/dist/split/chunks/diagram-BRcdlitF.js +1 -0
- package/dist/split/chunks/docx-I39iDYpR.js +1 -0
- package/dist/split/chunks/ebook-BRfadCGl.js +5 -0
- package/dist/split/chunks/index-C4jdVbDq.js +1 -0
- package/dist/split/chunks/index-DkF8PBGR.js +1 -0
- package/dist/split/chunks/iwork-DXq9Adf7.js +4 -0
- package/dist/split/chunks/media-runtime-B6322raw.js +1 -0
- package/dist/split/chunks/mindmap-CyR3TRfx.js +1 -0
- package/dist/split/chunks/model3d-BEt6INTt.js +55 -0
- package/dist/split/chunks/mp4box.all-Bw_Tlr0T-D0URDfA1.js +1 -0
- package/dist/split/chunks/panorama-ChsqnvWC.js +973 -0
- package/dist/split/chunks/pdf-Dzzffz3p.js +12 -0
- package/dist/split/chunks/vendor-C1aIdQ-w.js +4115 -0
- package/dist/split/chunks/xlsx-CITQo0Od.js +3 -0
- package/dist/split/converter-image.wasm +0 -0
- package/dist/split/filens.js +2 -5012
- package/package.json +1 -1
- package/dist/split/chunks/archive-B4jVwD9o.js +0 -921
- package/dist/split/chunks/cad-DMg-lGJX.js +0 -2405
- package/dist/split/chunks/core--zVW212C.js +0 -14627
- package/dist/split/chunks/diagram-CDwCA6LZ.js +0 -654
- package/dist/split/chunks/docx-CuQfFJqr.js +0 -299
- package/dist/split/chunks/ebook-CLlJ8KX3.js +0 -623
- package/dist/split/chunks/iwork-dNVC0X8j.js +0 -772
- package/dist/split/chunks/media-runtime-gcsBQMuo.js +0 -48
- package/dist/split/chunks/mindmap-g0-VoK-K.js +0 -560
- package/dist/split/chunks/model3d-1G1CC52V.js +0 -5093
- package/dist/split/chunks/panorama-D7GVivtM.js +0 -5972
- package/dist/split/chunks/pdf-CecYOWld.js +0 -17898
- package/dist/split/chunks/vendor-DPFNKNkh.js +0 -59575
- package/dist/split/chunks/xlsx-Co26yo-R.js +0 -818
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
var A = Object.defineProperty;
|
|
2
|
-
var H = (o, s, t) => s in o ? A(o, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[s] = t;
|
|
3
|
-
var v = (o, s, t) => H(o, typeof s != "symbol" ? s + "" : s, t);
|
|
4
|
-
import { am as j, an as k } from "./vendor-DPFNKNkh.js";
|
|
5
|
-
import { h as R, i as B, y as E, f as U, a as T, k as W, v as _, c as z, b as I } from "./core--zVW212C.js";
|
|
6
|
-
const x = /* @__PURE__ */ new WeakMap();
|
|
7
|
-
async function X(o, s) {
|
|
8
|
-
var r, c;
|
|
9
|
-
const t = /* @__PURE__ */ new Map(), n = o.fontTablePart;
|
|
10
|
-
if (!(n != null && n.path) || !((r = n._package) != null && r.load)) return t;
|
|
11
|
-
try {
|
|
12
|
-
const f = await n._package.load(n.path), h = (c = s.defaultView) == null ? void 0 : c.DOMParser;
|
|
13
|
-
if (!f || !h) return t;
|
|
14
|
-
const w = new h().parseFromString(f, "application/xml");
|
|
15
|
-
if (w.getElementsByTagName("parsererror").length) return t;
|
|
16
|
-
const d = (m, a) => {
|
|
17
|
-
var g;
|
|
18
|
-
return (g = [...m.attributes].find((C) => C.localName === a)) == null ? void 0 : g.value;
|
|
19
|
-
};
|
|
20
|
-
for (const m of [...w.getElementsByTagNameNS("*", "font")]) {
|
|
21
|
-
const a = d(m, "name");
|
|
22
|
-
if (!a) continue;
|
|
23
|
-
const g = (C) => {
|
|
24
|
-
const F = [...m.children].find((L) => L.localName === C);
|
|
25
|
-
return F ? d(F, "val") : void 0;
|
|
26
|
-
};
|
|
27
|
-
t.set(a.toLowerCase(), {
|
|
28
|
-
...R(g("family")),
|
|
29
|
-
...B(g("panose1")),
|
|
30
|
-
...R(void 0, g("pitch"))
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
} catch {
|
|
34
|
-
}
|
|
35
|
-
return t;
|
|
36
|
-
}
|
|
37
|
-
function O(o, s, t = /* @__PURE__ */ new Map(), n) {
|
|
38
|
-
var F, L, P, u;
|
|
39
|
-
const r = /* @__PURE__ */ new Map();
|
|
40
|
-
for (const e of ((F = o.fontTablePart) == null ? void 0 : F.fonts) ?? [])
|
|
41
|
-
e.name && r.set(e.name.toLowerCase(), {
|
|
42
|
-
fontFamily: e.name,
|
|
43
|
-
traits: { ...R(e.family, e.pitch), ...t.get(e.name.toLowerCase()) },
|
|
44
|
-
embedded: (L = e.embedFontRefs) != null && L.length ? !0 : void 0
|
|
45
|
-
});
|
|
46
|
-
const c = [], f = /* @__PURE__ */ new WeakSet(), h = (e) => {
|
|
47
|
-
if (!e || typeof e != "object" || f.has(e)) return;
|
|
48
|
-
if (f.add(e), Array.isArray(e)) {
|
|
49
|
-
e.forEach(h);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
const i = e;
|
|
53
|
-
if (typeof i["font-family"] == "string") {
|
|
54
|
-
const l = x.get(i) ?? i["font-family"];
|
|
55
|
-
x.set(i, l), c.push({ values: i, stack: l });
|
|
56
|
-
for (const p of E(l))
|
|
57
|
-
r.has(p.toLowerCase()) || r.set(p.toLowerCase(), { fontFamily: p });
|
|
58
|
-
}
|
|
59
|
-
for (const [l, p] of Object.entries(i))
|
|
60
|
-
l !== "parent" && !l.startsWith("_") && h(p);
|
|
61
|
-
};
|
|
62
|
-
h((P = o.documentPart) == null ? void 0 : P.body), h((u = o.stylesPart) == null ? void 0 : u.styles);
|
|
63
|
-
for (const e of o.parts ?? [])
|
|
64
|
-
for (const i of ["body", "styles", "domNumberings", "notes", "comments"]) h(e[i]);
|
|
65
|
-
const w = c.filter(({ stack: e }) => !/[()]/.test(e) && !E(e).some((i) => {
|
|
66
|
-
var l;
|
|
67
|
-
return (l = r.get(i.toLowerCase())) == null ? void 0 : l.embedded;
|
|
68
|
-
})), d = new Set(w.flatMap(({ stack: e }) => E(e).map((i) => i.toLowerCase()))), m = new Map(n == null ? void 0 : n.references.map((e) => {
|
|
69
|
-
var i;
|
|
70
|
-
return [(i = e.fontFamily) == null ? void 0 : i.toLowerCase(), e];
|
|
71
|
-
}));
|
|
72
|
-
for (const [e, i] of r) {
|
|
73
|
-
const l = m.get(e);
|
|
74
|
-
l && d.has(e) && r.set(e, { ...i, ...l });
|
|
75
|
-
}
|
|
76
|
-
const a = [...r.values()].filter((e) => d.has(e.fontFamily.toLowerCase())), g = [
|
|
77
|
-
...(n ? U({ ...n, references: a }, s) : T(a, s, { substitute: !0 })).fonts,
|
|
78
|
-
...T([...r.values()].filter((e) => !d.has(e.fontFamily.toLowerCase())), s).fonts
|
|
79
|
-
], C = new Map(g.map((e) => {
|
|
80
|
-
var i;
|
|
81
|
-
return [(i = e.fontFamily) == null ? void 0 : i.toLowerCase(), e.resolvedFontFamily];
|
|
82
|
-
}));
|
|
83
|
-
for (const { values: e, stack: i } of w) {
|
|
84
|
-
const p = E(i).map((b) => C.get(b.toLowerCase())).filter((b) => !!b);
|
|
85
|
-
e["font-family"] = W(i, (b) => {
|
|
86
|
-
var D;
|
|
87
|
-
return (D = r.get(b.toLowerCase())) == null ? void 0 : D.traits;
|
|
88
|
-
}, p);
|
|
89
|
-
}
|
|
90
|
-
return {
|
|
91
|
-
fonts: g,
|
|
92
|
-
references: [...r.values()],
|
|
93
|
-
loadingReferences: a,
|
|
94
|
-
warnings: [.../* @__PURE__ */ new Set([..._(g), ...(n == null ? void 0 : n.warnings) ?? []])]
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
const V = [
|
|
98
|
-
{
|
|
99
|
-
extensions: ["docx"],
|
|
100
|
-
family: "flow",
|
|
101
|
-
driverId: "docx",
|
|
102
|
-
targetFormat: "docx"
|
|
103
|
-
}
|
|
104
|
-
];
|
|
105
|
-
class $ {
|
|
106
|
-
constructor(s, t = {}) {
|
|
107
|
-
v(this, "listeners", {
|
|
108
|
-
loading: /* @__PURE__ */ new Set(),
|
|
109
|
-
rendered: /* @__PURE__ */ new Set(),
|
|
110
|
-
error: /* @__PURE__ */ new Set(),
|
|
111
|
-
statechange: /* @__PURE__ */ new Set(),
|
|
112
|
-
warnings: /* @__PURE__ */ new Set()
|
|
113
|
-
});
|
|
114
|
-
v(this, "root");
|
|
115
|
-
v(this, "documentHost");
|
|
116
|
-
v(this, "loadController", null);
|
|
117
|
-
v(this, "state");
|
|
118
|
-
v(this, "fontLoading");
|
|
119
|
-
v(this, "fontReferences", []);
|
|
120
|
-
v(this, "refreshDocumentFonts");
|
|
121
|
-
this.host = s, this.root = document.createElement("div"), this.root.className = "docxv-preview", this.documentHost = document.createElement("div"), this.documentHost.className = "docxv-document", this.root.replaceChildren(this.documentHost), this.host.replaceChildren(this.root), this.state = {
|
|
122
|
-
loading: !1,
|
|
123
|
-
error: null,
|
|
124
|
-
family: "flow",
|
|
125
|
-
warnings: [],
|
|
126
|
-
capabilities: {
|
|
127
|
-
search: !0,
|
|
128
|
-
print: !0,
|
|
129
|
-
download: !0
|
|
130
|
-
},
|
|
131
|
-
scale: t.initialScale ?? 1,
|
|
132
|
-
scrollTop: 0
|
|
133
|
-
}, this.fontLoading = I(this, s.ownerDocument, t);
|
|
134
|
-
}
|
|
135
|
-
async load(s, t) {
|
|
136
|
-
var d, m, a, g, C, F, L, P;
|
|
137
|
-
this.stopLoad(), this.fontLoading.reset(t.signal, ((d = t.route) == null ? void 0 : d.targetFormat) ?? t.descriptor.extension ?? "docx");
|
|
138
|
-
const n = new AbortController();
|
|
139
|
-
this.loadController = n;
|
|
140
|
-
const r = n.signal, c = document.createElement("div");
|
|
141
|
-
c.className = "docxv-document", this.documentHost = c;
|
|
142
|
-
let f = c;
|
|
143
|
-
this.root.replaceChildren(c), this.root.scrollTop = 0;
|
|
144
|
-
const h = /* @__PURE__ */ new Set(), w = () => n.abort();
|
|
145
|
-
r.addEventListener("abort", () => {
|
|
146
|
-
var u;
|
|
147
|
-
(u = t.signal) == null || u.removeEventListener("abort", w);
|
|
148
|
-
for (const e of h) URL.revokeObjectURL(e);
|
|
149
|
-
h.clear(), f.replaceChildren(), f.remove(), this.loadController === n && (this.loadController = null, this.state.loading = !1, this.state.fonts = [], this.state.warnings = [], this.emit("statechange", this.state));
|
|
150
|
-
}, { once: !0 }), (m = t.signal) == null || m.addEventListener("abort", w, { once: !0 }), this.state = {
|
|
151
|
-
...this.state,
|
|
152
|
-
loading: !0,
|
|
153
|
-
error: null,
|
|
154
|
-
title: t.descriptor.name,
|
|
155
|
-
fonts: [],
|
|
156
|
-
warnings: []
|
|
157
|
-
}, this.emit("loading", this.state), this.emit("statechange", this.state);
|
|
158
|
-
try {
|
|
159
|
-
(a = t.signal) != null && a.aborted && n.abort(), S(r);
|
|
160
|
-
const u = await J(s, { ...t, signal: r });
|
|
161
|
-
if (r.aborted) {
|
|
162
|
-
(g = t.signal) != null && g.aborted && S(r);
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
const e = { breakPages: !0, ignoreLastRenderedPageBreak: !1, className: "docx" }, i = await j(u, e);
|
|
166
|
-
if (r.aborted) {
|
|
167
|
-
(C = t.signal) != null && C.aborted && S(r);
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
G(i, r, h);
|
|
171
|
-
const l = await X(i, this.host.ownerDocument);
|
|
172
|
-
if (r.aborted) {
|
|
173
|
-
(F = t.signal) != null && F.aborted && S(r);
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
const p = O(i, this.host.ownerDocument, l);
|
|
177
|
-
if (await k(i, c, void 0, e), r.aborted) {
|
|
178
|
-
(L = t.signal) != null && L.aborted && S(r);
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
this.state.loading = !1, this.state.error = null, this.state.fonts = p.fonts, this.fontReferences = p.loadingReferences, this.state.warnings = p.warnings, this.refreshDocumentFonts = async (b) => {
|
|
182
|
-
if (r.aborted || this.loadController !== n) return;
|
|
183
|
-
const D = O(i, this.host.ownerDocument, l, b);
|
|
184
|
-
if (b.loaded.length || b.relayout) {
|
|
185
|
-
const y = this.host.ownerDocument.createElement("div");
|
|
186
|
-
y.className = "docxv-document", y.style.visibility = "hidden", this.root.appendChild(y);
|
|
187
|
-
try {
|
|
188
|
-
if (await k(i, y, void 0, e), r.aborted || this.loadController !== n) return;
|
|
189
|
-
const M = this.root.scrollTop, N = this.root.scrollLeft;
|
|
190
|
-
y.style.visibility = "", f = this.documentHost = y, this.root.replaceChildren(y), this.root.scrollTop = M, this.root.scrollLeft = N;
|
|
191
|
-
} finally {
|
|
192
|
-
f !== y && y.remove();
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
r.aborted || this.loadController !== n || (this.fontReferences = D.loadingReferences, this.state.fonts = D.fonts, this.state.warnings = D.warnings, this.emit("warnings", this.state.warnings), this.emit("rendered", this.getState()), this.emit("statechange", this.getState()));
|
|
196
|
-
}, this.state.warnings.length && this.emit("warnings", this.state.warnings), this.emit("rendered", this.state), this.emit("statechange", this.state);
|
|
197
|
-
} catch (u) {
|
|
198
|
-
if (r.aborted) {
|
|
199
|
-
(P = t.signal) != null && P.aborted && S(r);
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
this.stopLoad();
|
|
203
|
-
const e = u instanceof Error ? u : new Error(String(u));
|
|
204
|
-
throw this.state.loading = !1, this.state.error = e.message, this.emit("error", e), this.emit("statechange", this.state), e;
|
|
205
|
-
} finally {
|
|
206
|
-
r.aborted && c.replaceChildren();
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
destroy() {
|
|
210
|
-
this.fontLoading.destroy(), this.stopLoad(), this.state.loading = !1, this.state.fonts = [], this.state.warnings = [], this.documentHost.replaceChildren(), this.root.replaceChildren(), this.root.parentElement === this.host && this.host.replaceChildren();
|
|
211
|
-
for (const s of Object.values(this.listeners)) s.clear();
|
|
212
|
-
}
|
|
213
|
-
stopLoad() {
|
|
214
|
-
this.refreshDocumentFonts = void 0, this.fontReferences = [];
|
|
215
|
-
const s = this.loadController;
|
|
216
|
-
this.loadController = null, s == null || s.abort();
|
|
217
|
-
}
|
|
218
|
-
getState() {
|
|
219
|
-
var s;
|
|
220
|
-
return {
|
|
221
|
-
...this.state,
|
|
222
|
-
fonts: (s = this.state.fonts) == null ? void 0 : s.map((t) => ({ ...t, classification: t.classification ? { ...t.classification } : void 0 })),
|
|
223
|
-
warnings: [...this.state.warnings],
|
|
224
|
-
scrollTop: this.root.scrollTop
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
getFontReferences() {
|
|
228
|
-
return this.fontReferences;
|
|
229
|
-
}
|
|
230
|
-
async refreshFonts(s) {
|
|
231
|
-
var t;
|
|
232
|
-
await ((t = this.refreshDocumentFonts) == null ? void 0 : t.call(this, s));
|
|
233
|
-
}
|
|
234
|
-
on(s, t) {
|
|
235
|
-
return this.listeners[s].add(t), () => {
|
|
236
|
-
this.listeners[s].delete(t);
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
emit(s, t) {
|
|
240
|
-
for (const n of this.listeners[s])
|
|
241
|
-
n(t);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
function Z() {
|
|
245
|
-
return {
|
|
246
|
-
id: "docx",
|
|
247
|
-
family: "flow",
|
|
248
|
-
supports: (o) => q(o) === "docx",
|
|
249
|
-
createSession: (o, s) => new $(o, s)
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
function tt(o = z()) {
|
|
253
|
-
return [
|
|
254
|
-
...V,
|
|
255
|
-
...o.filter((s) => !s.extensions.includes("docx"))
|
|
256
|
-
];
|
|
257
|
-
}
|
|
258
|
-
async function J(o, s) {
|
|
259
|
-
if (o instanceof Blob) return o;
|
|
260
|
-
if (typeof o == "string") {
|
|
261
|
-
const t = await fetch(o, { signal: s.signal });
|
|
262
|
-
if (!t.ok)
|
|
263
|
-
throw new Error(`Failed to load DOCX source: ${t.status} ${t.statusText}`.trim());
|
|
264
|
-
return t.arrayBuffer();
|
|
265
|
-
}
|
|
266
|
-
return ArrayBuffer.isView(o) ? new Uint8Array(o.buffer, o.byteOffset, o.byteLength).slice().buffer : o.slice(0);
|
|
267
|
-
}
|
|
268
|
-
function q(o) {
|
|
269
|
-
return o.trim().replace(/^\./, "").toLowerCase();
|
|
270
|
-
}
|
|
271
|
-
function S(o) {
|
|
272
|
-
if (o.aborted) throw new DOMException("DOCX preview aborted.", "AbortError");
|
|
273
|
-
}
|
|
274
|
-
function G(o, s, t) {
|
|
275
|
-
for (const n of ["loadDocumentImage", "loadNumberingImage", "loadFont"]) {
|
|
276
|
-
const r = o[n];
|
|
277
|
-
if (!r) continue;
|
|
278
|
-
const c = /* @__PURE__ */ new Map();
|
|
279
|
-
o[n] = (...f) => {
|
|
280
|
-
if (s.aborted) return Promise.reject(new DOMException("DOCX preview aborted.", "AbortError"));
|
|
281
|
-
const h = n === "loadDocumentImage" ? f[1] ?? o.documentPart : void 0, w = n === "loadFont" ? JSON.stringify(f.slice(0, 2)) : String(f[0]);
|
|
282
|
-
let d = c.get(h);
|
|
283
|
-
d || c.set(h, d = /* @__PURE__ */ new Map());
|
|
284
|
-
let m = d.get(w);
|
|
285
|
-
return m || (m = Promise.resolve(r.apply(o, f)).then((a) => {
|
|
286
|
-
if (a != null && a.startsWith("blob:")) {
|
|
287
|
-
if (s.aborted)
|
|
288
|
-
return URL.revokeObjectURL(a), null;
|
|
289
|
-
t.add(a);
|
|
290
|
-
}
|
|
291
|
-
return a;
|
|
292
|
-
}), d.set(w, m)), m;
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
export {
|
|
297
|
-
tt as a,
|
|
298
|
-
Z as c
|
|
299
|
-
};
|