filens-preview 0.2.0 → 0.3.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.
- package/README.md +60 -13
- package/dist/all-in-one/THIRD-PARTY-NOTICES.txt +969 -0
- package/dist/all-in-one/archive/7zz.wasm +0 -0
- package/dist/all-in-one/assets/archive-worker-Cy3bEdVg.js +2 -0
- package/dist/all-in-one/filens.js +70557 -64591
- package/dist/all-in-one/index.html +12 -3
- package/dist/index.d.ts +5 -0
- package/dist/split/THIRD-PARTY-NOTICES.txt +969 -0
- package/dist/split/archive/7zz.wasm +0 -0
- package/dist/split/assets/archive-worker-Cy3bEdVg.js +2 -0
- package/dist/split/assets/{iwork-worker-DiTOJG8f.js → iwork-worker-B9KPoDW3.js} +17 -17
- package/dist/split/chunks/archive-B4jVwD9o.js +921 -0
- package/dist/split/chunks/{cad-Cyh8aipO.js → cad-DMg-lGJX.js} +1 -1
- package/dist/split/chunks/{core-gp02JQ3r.js → core--zVW212C.js} +4205 -3760
- package/dist/split/chunks/{diagram-rxvArV-1.js → diagram-CDwCA6LZ.js} +2 -2
- package/dist/split/chunks/{docx-ecvZsSWm.js → docx-CuQfFJqr.js} +2 -2
- package/dist/split/chunks/{ebook-5FyKWZ8s.js → ebook-CLlJ8KX3.js} +2 -2
- package/dist/split/chunks/{iwork-DlaehzuR.js → iwork-dNVC0X8j.js} +39 -39
- package/dist/split/chunks/media-runtime-gcsBQMuo.js +48 -0
- package/dist/split/chunks/{mindmap-D9lNNDoa.js → mindmap-g0-VoK-K.js} +2 -2
- package/dist/split/chunks/{model3d-BtFT01ZH.js → model3d-1G1CC52V.js} +3 -3
- package/dist/split/chunks/{panorama-Ci6DK6sa.js → panorama-D7GVivtM.js} +246 -234
- package/dist/split/chunks/{vendor-DvWhw-zP.js → vendor-DPFNKNkh.js} +28487 -23383
- package/dist/split/chunks/{xlsx-VJTu9XNS.js → xlsx-Co26yo-R.js} +2 -2
- package/dist/split/filens.js +2714 -2483
- package/dist/split/index.html +12 -3
- package/package.json +2 -2
- package/dist/split/chunks/archive-_cUUL2-3.js +0 -731
- package/dist/split/chunks/media-runtime-DwW7eq4g.js +0 -48
|
@@ -0,0 +1,921 @@
|
|
|
1
|
+
var Y = Object.defineProperty;
|
|
2
|
+
var q = (n, e, t) => e in n ? Y(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var E = (n, e, t) => q(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { G as ee } from "./vendor-DPFNKNkh.js";
|
|
5
|
+
import { c as te, l as re, m as V, p as B, s as F, A as C, n as O, o as ne, q as D, t as ie, P as A, u as oe } from "./core--zVW212C.js";
|
|
6
|
+
const H = [
|
|
7
|
+
{
|
|
8
|
+
extensions: ["rar"],
|
|
9
|
+
family: "archive",
|
|
10
|
+
driverId: "archive",
|
|
11
|
+
targetFormat: "rar",
|
|
12
|
+
contentTypes: ["application/vnd.rar", "application/x-rar-compressed"]
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
extensions: ["7z"],
|
|
16
|
+
family: "archive",
|
|
17
|
+
driverId: "archive",
|
|
18
|
+
targetFormat: "7z",
|
|
19
|
+
contentTypes: ["application/x-7z-compressed"]
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
extensions: ["zip", "jar", "war", "ear", "apk"],
|
|
23
|
+
family: "archive",
|
|
24
|
+
driverId: "archive",
|
|
25
|
+
targetFormat: "zip",
|
|
26
|
+
contentTypes: ["application/zip", "application/x-zip-compressed", "application/java-archive", "application/vnd.android.package-archive"]
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
extensions: ["tar"],
|
|
30
|
+
family: "archive",
|
|
31
|
+
driverId: "archive",
|
|
32
|
+
targetFormat: "tar",
|
|
33
|
+
contentTypes: ["application/x-tar"]
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
extensions: ["tgz", "gz"],
|
|
37
|
+
family: "archive",
|
|
38
|
+
driverId: "archive",
|
|
39
|
+
targetFormat: "gz",
|
|
40
|
+
contentTypes: ["application/gzip", "application/x-gzip"]
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
class se {
|
|
44
|
+
constructor(e, t = {}) {
|
|
45
|
+
E(this, "listeners", {
|
|
46
|
+
loading: /* @__PURE__ */ new Set(),
|
|
47
|
+
rendered: /* @__PURE__ */ new Set(),
|
|
48
|
+
error: /* @__PURE__ */ new Set(),
|
|
49
|
+
statechange: /* @__PURE__ */ new Set(),
|
|
50
|
+
warnings: /* @__PURE__ */ new Set()
|
|
51
|
+
});
|
|
52
|
+
E(this, "root");
|
|
53
|
+
E(this, "options");
|
|
54
|
+
E(this, "archiveStack", []);
|
|
55
|
+
E(this, "activeEntry", null);
|
|
56
|
+
E(this, "entryPreviewHost", null);
|
|
57
|
+
E(this, "entryPreviewer", null);
|
|
58
|
+
E(this, "entryPreviewUnsubscribes", []);
|
|
59
|
+
E(this, "entryObjectUrl", null);
|
|
60
|
+
E(this, "loadController", null);
|
|
61
|
+
E(this, "entryController", null);
|
|
62
|
+
E(this, "renderVersion", 0);
|
|
63
|
+
E(this, "state", {
|
|
64
|
+
loading: !1,
|
|
65
|
+
error: null,
|
|
66
|
+
family: "archive",
|
|
67
|
+
warnings: [],
|
|
68
|
+
capabilities: {
|
|
69
|
+
archiveBrowse: !0,
|
|
70
|
+
search: !0,
|
|
71
|
+
download: !0
|
|
72
|
+
},
|
|
73
|
+
route: "/",
|
|
74
|
+
entries: []
|
|
75
|
+
});
|
|
76
|
+
this.host = e, this.options = t, this.root = document.createElement("div"), this.root.className = "archivev-preview", this.host.replaceChildren(this.root);
|
|
77
|
+
}
|
|
78
|
+
async load(e, t) {
|
|
79
|
+
var o, s, c, d;
|
|
80
|
+
this.stopLoad();
|
|
81
|
+
const r = new AbortController(), i = r.signal;
|
|
82
|
+
this.loadController = r;
|
|
83
|
+
const a = () => r.abort();
|
|
84
|
+
(o = t.signal) == null || o.addEventListener("abort", a, { once: !0 }), i.addEventListener("abort", () => {
|
|
85
|
+
var h;
|
|
86
|
+
(h = t.signal) == null || h.removeEventListener("abort", a), this.loadController === r && (this.stopLoad(), this.state = { ...this.state, loading: !1, error: null, warnings: [], route: "/", entries: [] }, this.emit("statechange", this.state));
|
|
87
|
+
}, { once: !0 }), this.state = {
|
|
88
|
+
...this.state,
|
|
89
|
+
loading: !0,
|
|
90
|
+
error: null,
|
|
91
|
+
title: t.descriptor.name,
|
|
92
|
+
warnings: [],
|
|
93
|
+
route: "/",
|
|
94
|
+
entries: []
|
|
95
|
+
}, this.archiveStack = [], this.emit("loading", this.state), this.emit("statechange", this.state);
|
|
96
|
+
try {
|
|
97
|
+
(s = t.signal) != null && s.aborted && r.abort(), b(i);
|
|
98
|
+
const { bytes: h, volumes: l } = await ve(e, { ...t, signal: i });
|
|
99
|
+
b(i);
|
|
100
|
+
const m = t.descriptor.name ?? "archive", u = M(m, ((c = t.route) == null ? void 0 : c.sourceFormat) ?? t.descriptor.extension), v = await _(
|
|
101
|
+
h,
|
|
102
|
+
u,
|
|
103
|
+
m,
|
|
104
|
+
i,
|
|
105
|
+
this.options,
|
|
106
|
+
this.options.containerContext ?? re(),
|
|
107
|
+
t.descriptor.password,
|
|
108
|
+
l
|
|
109
|
+
);
|
|
110
|
+
b(i), this.archiveStack = [v], this.state = {
|
|
111
|
+
...this.state,
|
|
112
|
+
loading: !1,
|
|
113
|
+
error: null
|
|
114
|
+
}, this.setRoute("/"), this.emit("rendered", this.state), this.emit("statechange", this.state);
|
|
115
|
+
} catch (h) {
|
|
116
|
+
if (i.aborted) {
|
|
117
|
+
(d = t.signal) != null && d.aborted && b(i);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
this.stopLoad();
|
|
121
|
+
const l = h instanceof Error ? h : new Error(String(h));
|
|
122
|
+
throw this.state.loading = !1, this.state.error = l.message, this.emit("error", l), this.emit("statechange", this.state), l;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
destroy() {
|
|
126
|
+
this.stopLoad(), this.state = { ...this.state, loading: !1, error: null, warnings: [], route: "/", entries: [] }, this.root.parentElement === this.host && this.host.replaceChildren();
|
|
127
|
+
for (const e of Object.values(this.listeners)) e.clear();
|
|
128
|
+
}
|
|
129
|
+
stopLoad() {
|
|
130
|
+
const e = this.loadController;
|
|
131
|
+
this.loadController = null, e == null || e.abort(), this.closeEntryPreview(!1), this.archiveStack = [], this.renderVersion++, this.root.replaceChildren();
|
|
132
|
+
}
|
|
133
|
+
getState() {
|
|
134
|
+
return {
|
|
135
|
+
...this.state,
|
|
136
|
+
warnings: this.state.warnings.slice(),
|
|
137
|
+
entries: this.state.entries.slice()
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
on(e, t) {
|
|
141
|
+
return this.listeners[e].add(t), () => {
|
|
142
|
+
this.listeners[e].delete(t);
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
render() {
|
|
146
|
+
var l, m;
|
|
147
|
+
const e = ++this.renderVersion, t = () => e === this.renderVersion && !!(this.loadController && !this.loadController.signal.aborted), r = document.createElement("div");
|
|
148
|
+
r.className = "archivev-summary", r.appendChild(this.createBreadcrumbs(t));
|
|
149
|
+
const i = document.createElement("span");
|
|
150
|
+
i.className = "archivev-item-count", i.textContent = `${this.state.entries.length} item${this.state.entries.length === 1 ? "" : "s"}`, r.appendChild(i);
|
|
151
|
+
const a = document.createElement("div");
|
|
152
|
+
a.className = "archivev-toolbar";
|
|
153
|
+
const o = document.createElement("button");
|
|
154
|
+
o.type = "button", o.className = "archivev-button", o.textContent = "Up", o.disabled = !he(this.state.route), o.addEventListener("click", () => {
|
|
155
|
+
t() && this.navigateUp();
|
|
156
|
+
});
|
|
157
|
+
const s = document.createElement("button");
|
|
158
|
+
s.type = "button", s.className = "archivev-button", s.textContent = "Root", s.disabled = this.state.route === "/", s.addEventListener("click", () => {
|
|
159
|
+
t() && this.setRoute("/");
|
|
160
|
+
});
|
|
161
|
+
const c = document.createElement("button");
|
|
162
|
+
if (c.type = "button", c.className = "archivev-button", c.textContent = this.entryController ? "Back to archive" : "Back", c.disabled = !this.entryController && this.archiveStack.length <= 1, c.addEventListener("click", () => {
|
|
163
|
+
t() && (this.entryController ? this.closeEntryPreview() : this.popArchive());
|
|
164
|
+
}), a.append(c, o, s), this.activeEntry && typeof URL.createObjectURL == "function") {
|
|
165
|
+
this.entryObjectUrl ?? (this.entryObjectUrl = URL.createObjectURL(new Blob([k(this.activeEntry.source)], {
|
|
166
|
+
type: this.activeEntry.contentType ?? "application/octet-stream"
|
|
167
|
+
})));
|
|
168
|
+
const u = document.createElement("a");
|
|
169
|
+
u.className = "archivev-button", u.textContent = ((m = (l = this.options).translate) == null ? void 0 : m.call(l, "Download attachment")) ?? "Download attachment", u.href = this.entryObjectUrl, u.download = this.activeEntry.name.split("/").pop() ?? "attachment.bin", a.append(u);
|
|
170
|
+
}
|
|
171
|
+
if (this.activeEntry && this.entryPreviewHost) {
|
|
172
|
+
this.root.replaceChildren(r, a, this.entryPreviewHost);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const d = document.createElement("table");
|
|
176
|
+
d.className = "archivev-table", d.appendChild(ye());
|
|
177
|
+
const h = document.createElement("tbody");
|
|
178
|
+
for (const u of this.state.entries) {
|
|
179
|
+
const v = document.createElement("tr");
|
|
180
|
+
v.className = "archivev-row", v.tabIndex = 0, v.dataset.type = u.type;
|
|
181
|
+
const y = document.createElement("td");
|
|
182
|
+
y.className = "archivev-name", y.textContent = u.name, y.dataset.type = u.type, v.appendChild(y);
|
|
183
|
+
const p = document.createElement("td");
|
|
184
|
+
p.className = "archivev-type", p.textContent = u.type, v.appendChild(p);
|
|
185
|
+
const g = document.createElement("td");
|
|
186
|
+
g.className = "archivev-size", g.textContent = u.type === "directory" ? "" : we(u.size ?? 0), v.appendChild(g);
|
|
187
|
+
const w = document.createElement("td");
|
|
188
|
+
w.className = "archivev-modified", w.textContent = u.modified ? new Date(u.modified).toLocaleString() : "", v.appendChild(w), v.addEventListener("click", () => {
|
|
189
|
+
t() && this.activateEntry(u);
|
|
190
|
+
}), v.addEventListener("keydown", (f) => {
|
|
191
|
+
t() && (f.key === "Enter" || f.key === " ") && (f.preventDefault(), this.activateEntry(u));
|
|
192
|
+
}), h.appendChild(v);
|
|
193
|
+
}
|
|
194
|
+
d.appendChild(h), this.root.replaceChildren(r, a, d);
|
|
195
|
+
}
|
|
196
|
+
createBreadcrumbs(e) {
|
|
197
|
+
const t = document.createElement("nav");
|
|
198
|
+
t.className = "archivev-breadcrumbs", t.setAttribute("aria-label", "Archive path");
|
|
199
|
+
const r = L(this.state.route), i = this.entryController !== null;
|
|
200
|
+
this.archiveStack.forEach((s, c) => {
|
|
201
|
+
c > 0 && t.appendChild(T());
|
|
202
|
+
const d = document.createElement("button");
|
|
203
|
+
d.type = "button", d.className = "archivev-breadcrumb", d.textContent = s.label;
|
|
204
|
+
const h = c === this.archiveStack.length - 1;
|
|
205
|
+
d.disabled = h && r === "/" && !i, d.addEventListener("click", () => {
|
|
206
|
+
e() && (h ? this.setRoute("/") : this.popToArchive(c));
|
|
207
|
+
}), t.appendChild(d);
|
|
208
|
+
});
|
|
209
|
+
const a = r === "/" ? [] : r.slice(1, -1).split("/").filter(Boolean);
|
|
210
|
+
let o = "/";
|
|
211
|
+
for (const s of a) {
|
|
212
|
+
o = G(o, `${s}/`), t.appendChild(T());
|
|
213
|
+
const c = document.createElement("button");
|
|
214
|
+
c.type = "button", c.className = "archivev-breadcrumb", c.textContent = s, c.disabled = o === r && !i;
|
|
215
|
+
const d = o;
|
|
216
|
+
c.addEventListener("click", () => {
|
|
217
|
+
e() && this.setRoute(d);
|
|
218
|
+
}), t.appendChild(c);
|
|
219
|
+
}
|
|
220
|
+
if (this.activeEntry) {
|
|
221
|
+
t.appendChild(T());
|
|
222
|
+
const s = document.createElement("span");
|
|
223
|
+
s.className = "archivev-breadcrumb-current", s.textContent = this.activeEntry.name.split("/").pop() ?? this.activeEntry.name, t.appendChild(s);
|
|
224
|
+
}
|
|
225
|
+
return t;
|
|
226
|
+
}
|
|
227
|
+
activateEntry(e) {
|
|
228
|
+
if (e.type === "directory") {
|
|
229
|
+
this.setRoute(G(this.state.route, e.name));
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
if (pe(e.name)) {
|
|
233
|
+
this.openNestedArchive(e.name);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
this.openEntryPreview(e.name);
|
|
237
|
+
}
|
|
238
|
+
async openEntryPreview(e) {
|
|
239
|
+
const t = this.findCurrentEntry(e), r = this.archiveStack[this.archiveStack.length - 1];
|
|
240
|
+
if (!t || !r)
|
|
241
|
+
return;
|
|
242
|
+
const i = this.startEntryOperation();
|
|
243
|
+
if (!i) return;
|
|
244
|
+
const a = i.signal, o = () => this.entryController === i && !a.aborted;
|
|
245
|
+
this.state = { ...this.state, loading: !0, error: null }, this.emit("loading", this.state), this.emit("statechange", this.state), this.render();
|
|
246
|
+
try {
|
|
247
|
+
const s = await x(t.read(a), a);
|
|
248
|
+
b(a), this.activeEntry = {
|
|
249
|
+
name: e,
|
|
250
|
+
source: s,
|
|
251
|
+
contentType: ge(e, void 0)
|
|
252
|
+
}, this.entryPreviewHost = document.createElement("div"), this.entryPreviewHost.className = "archivev-entry-preview", this.render();
|
|
253
|
+
const c = this.options.previewerFactory;
|
|
254
|
+
if (c) {
|
|
255
|
+
const d = c(this.entryPreviewHost, {
|
|
256
|
+
...this.options,
|
|
257
|
+
containerContext: V(r.containerContext),
|
|
258
|
+
resourceResolver: this.createEntryResourceResolver(r, t.name, a)
|
|
259
|
+
});
|
|
260
|
+
this.entryPreviewer = d, this.entryPreviewUnsubscribes = [
|
|
261
|
+
d.on("error", (h) => {
|
|
262
|
+
o() && this.setEntryPreviewError(h);
|
|
263
|
+
}),
|
|
264
|
+
d.on("warnings", (h) => {
|
|
265
|
+
o() && (this.state = { ...this.state, warnings: h }, this.emit("warnings", h), this.emit("statechange", this.state));
|
|
266
|
+
})
|
|
267
|
+
], await x(d.preview(s, {
|
|
268
|
+
name: e,
|
|
269
|
+
extension: K(e),
|
|
270
|
+
contentType: this.activeEntry.contentType
|
|
271
|
+
}), a), b(a);
|
|
272
|
+
} else
|
|
273
|
+
this.renderFallbackEntryPreview(this.entryPreviewHost, s, e, this.activeEntry.contentType);
|
|
274
|
+
this.state = {
|
|
275
|
+
...this.state,
|
|
276
|
+
loading: !1,
|
|
277
|
+
error: null
|
|
278
|
+
}, this.emit("statechange", this.state);
|
|
279
|
+
} catch (s) {
|
|
280
|
+
if (!o()) return;
|
|
281
|
+
if (B(s) === "password_cancelled") {
|
|
282
|
+
this.closeEntryPreview();
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
const c = s instanceof Error ? s : new Error(String(s));
|
|
286
|
+
this.setEntryPreviewError(c);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
setEntryPreviewError(e) {
|
|
290
|
+
var i;
|
|
291
|
+
if (B(e) === "password_cancelled") {
|
|
292
|
+
this.closeEntryPreview();
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
this.state = { ...this.state, loading: !1, error: null };
|
|
296
|
+
const t = this.entryPreviewHost ?? this.root;
|
|
297
|
+
(i = t.querySelector(".archivev-entry-error")) == null || i.remove();
|
|
298
|
+
const r = document.createElement("p");
|
|
299
|
+
r.className = "archivev-entry-error", r.setAttribute("role", "alert"), r.textContent = e.message, t.append(r), this.emit("statechange", this.state);
|
|
300
|
+
}
|
|
301
|
+
closeEntryPreview(e = !0) {
|
|
302
|
+
var r, i, a;
|
|
303
|
+
const t = this.entryController;
|
|
304
|
+
this.entryController = null, t == null || t.abort(), this.entryPreviewUnsubscribes.splice(0).forEach((o) => o()), (r = this.entryPreviewer) == null || r.destroy(), this.entryPreviewer = null;
|
|
305
|
+
for (const o of ((i = this.entryPreviewHost) == null ? void 0 : i.querySelectorAll("audio, video")) ?? []) {
|
|
306
|
+
const s = o;
|
|
307
|
+
s.pause(), s.removeAttribute("src"), s.load();
|
|
308
|
+
}
|
|
309
|
+
(a = this.entryPreviewHost) == null || a.replaceChildren(), this.entryPreviewHost = null, this.activeEntry = null, this.entryObjectUrl && (URL.revokeObjectURL(this.entryObjectUrl), this.entryObjectUrl = null), e && this.loadController && !this.loadController.signal.aborted && (this.state = { ...this.state, loading: !1, error: null, warnings: [] }, this.render(), this.emit("statechange", this.state));
|
|
310
|
+
}
|
|
311
|
+
startEntryOperation() {
|
|
312
|
+
var i;
|
|
313
|
+
this.closeEntryPreview(!1);
|
|
314
|
+
const e = (i = this.loadController) == null ? void 0 : i.signal;
|
|
315
|
+
if (!e || e.aborted) return null;
|
|
316
|
+
const t = new AbortController(), r = () => t.abort();
|
|
317
|
+
return this.entryController = t, e.addEventListener("abort", r, { once: !0 }), t.signal.addEventListener("abort", () => e.removeEventListener("abort", r), { once: !0 }), t;
|
|
318
|
+
}
|
|
319
|
+
popToArchive(e) {
|
|
320
|
+
e < 0 || e >= this.archiveStack.length - 1 || (this.closeEntryPreview(!1), this.archiveStack.splice(e + 1), this.setRoute("/"));
|
|
321
|
+
}
|
|
322
|
+
navigateUp() {
|
|
323
|
+
const e = de(this.state.route);
|
|
324
|
+
e !== this.state.route && this.setRoute(e);
|
|
325
|
+
}
|
|
326
|
+
setRoute(e) {
|
|
327
|
+
this.entryController && this.closeEntryPreview(!1);
|
|
328
|
+
const t = this.archiveStack[this.archiveStack.length - 1];
|
|
329
|
+
if (!t)
|
|
330
|
+
return;
|
|
331
|
+
const r = L(e);
|
|
332
|
+
t.listings ?? (t.listings = /* @__PURE__ */ new Map());
|
|
333
|
+
let i = t.listings.get(r);
|
|
334
|
+
if (!i) {
|
|
335
|
+
const a = r === "/" ? t.entries : (t.directories ?? (t.directories = ue(t.entries))).get(r.slice(1)) ?? [];
|
|
336
|
+
i = me(a, r), t.listings.set(r, i);
|
|
337
|
+
}
|
|
338
|
+
this.state = {
|
|
339
|
+
...this.state,
|
|
340
|
+
loading: !1,
|
|
341
|
+
error: null,
|
|
342
|
+
warnings: [],
|
|
343
|
+
route: r,
|
|
344
|
+
entries: i.map((a) => ({ ...a }))
|
|
345
|
+
}, this.render(), this.emit("statechange", this.state);
|
|
346
|
+
}
|
|
347
|
+
findCurrentEntry(e) {
|
|
348
|
+
const t = this.archiveStack[this.archiveStack.length - 1];
|
|
349
|
+
if (!t)
|
|
350
|
+
return;
|
|
351
|
+
const r = this.state.route === "/" ? "" : this.state.route.slice(1);
|
|
352
|
+
return t.entries.find((i) => i.type === "file" && i.name === `${r}${e}`);
|
|
353
|
+
}
|
|
354
|
+
createEntryResourceResolver(e, t, r) {
|
|
355
|
+
const i = this.options.resourceResolver, a = t.slice(0, t.lastIndexOf("/") + 1), o = e.resources ?? (e.resources = new Map(e.entries.filter((s) => s.type === "file").map((s) => [P(s.name), s])));
|
|
356
|
+
return async (s) => {
|
|
357
|
+
b(r);
|
|
358
|
+
const c = s.source ?? s.name;
|
|
359
|
+
if (c && !/^[a-z][a-z\d+.-]*:/i.test(c)) {
|
|
360
|
+
const h = (/^[\\/]/.test(c) ? void 0 : o.get(P(a + c))) ?? o.get(P(c));
|
|
361
|
+
if (h) {
|
|
362
|
+
const l = await x(h.read(r), r);
|
|
363
|
+
return b(r), {
|
|
364
|
+
source: l,
|
|
365
|
+
warnings: []
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
return i ? x(Promise.resolve(i(s)), r) : void 0;
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
renderFallbackEntryPreview(e, t, r, i) {
|
|
373
|
+
const a = K(r), o = i ?? "";
|
|
374
|
+
if (o.startsWith("image/")) {
|
|
375
|
+
this.entryObjectUrl = URL.createObjectURL(new Blob([k(t)], { type: o }));
|
|
376
|
+
const c = document.createElement("img");
|
|
377
|
+
c.className = "archivev-entry-image", c.alt = r, c.src = this.entryObjectUrl, e.replaceChildren(c);
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
if (o === "application/pdf" || a === "pdf") {
|
|
381
|
+
this.entryObjectUrl = URL.createObjectURL(new Blob([k(t)], { type: "application/pdf" }));
|
|
382
|
+
const c = document.createElement("iframe");
|
|
383
|
+
c.className = "archivev-entry-frame", c.title = r, c.src = this.entryObjectUrl, e.replaceChildren(c);
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
if (o.startsWith("audio/") || o.startsWith("video/")) {
|
|
387
|
+
this.entryObjectUrl = URL.createObjectURL(new Blob([k(t)], { type: o }));
|
|
388
|
+
const c = document.createElement(o.startsWith("audio/") ? "audio" : "video");
|
|
389
|
+
c.className = "archivev-entry-media", c.controls = !0, c.src = this.entryObjectUrl, e.replaceChildren(c);
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
const s = document.createElement("pre");
|
|
393
|
+
s.className = "archivev-entry-text", s.textContent = new TextDecoder().decode(t), e.replaceChildren(s);
|
|
394
|
+
}
|
|
395
|
+
async openNestedArchive(e) {
|
|
396
|
+
const t = this.archiveStack[this.archiveStack.length - 1];
|
|
397
|
+
if (!t)
|
|
398
|
+
return;
|
|
399
|
+
const r = this.state.route === "/" ? "" : this.state.route.replace(/^\//, ""), i = t.entries.find((s) => s.type === "file" && s.name === `${r}${e}`);
|
|
400
|
+
if (!i)
|
|
401
|
+
return;
|
|
402
|
+
const a = this.startEntryOperation();
|
|
403
|
+
if (!a) return;
|
|
404
|
+
const o = a.signal;
|
|
405
|
+
this.state = {
|
|
406
|
+
...this.state,
|
|
407
|
+
loading: !0,
|
|
408
|
+
error: null
|
|
409
|
+
}, this.emit("loading", this.state), this.emit("statechange", this.state), this.render();
|
|
410
|
+
try {
|
|
411
|
+
const s = F(i.name, t.entries.filter((y) => y.type === "file")), c = (s == null ? void 0 : s.primary) ?? i, d = c.name.split("/").pop() ?? c.name, h = V(t.containerContext), l = await x(c.read(o), o), m = [];
|
|
412
|
+
let u = l.byteLength;
|
|
413
|
+
for (const y of (s == null ? void 0 : s.files.slice(1)) ?? []) {
|
|
414
|
+
if (u + (y.size ?? 0) > C.maxBytes) throw new Error("Archive volumes exceed the preview input size limit.");
|
|
415
|
+
const p = await x(y.read(o), o);
|
|
416
|
+
if (u += p.byteLength, u > C.maxBytes) throw new Error("Archive volumes exceed the preview input size limit.");
|
|
417
|
+
m.push({ name: y.name.split("/").pop(), bytes: p });
|
|
418
|
+
}
|
|
419
|
+
b(o);
|
|
420
|
+
const v = await _(
|
|
421
|
+
l,
|
|
422
|
+
M(d),
|
|
423
|
+
d,
|
|
424
|
+
o,
|
|
425
|
+
this.options,
|
|
426
|
+
h,
|
|
427
|
+
void 0,
|
|
428
|
+
m
|
|
429
|
+
);
|
|
430
|
+
b(o), this.closeEntryPreview(!1), this.archiveStack.push(v), this.state = {
|
|
431
|
+
...this.state,
|
|
432
|
+
loading: !1,
|
|
433
|
+
error: null
|
|
434
|
+
}, this.setRoute("/"), this.emit("rendered", this.state);
|
|
435
|
+
} catch (s) {
|
|
436
|
+
if (o.aborted) return;
|
|
437
|
+
if (B(s) === "password_cancelled") {
|
|
438
|
+
this.closeEntryPreview();
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
const c = s instanceof Error ? s : new Error(String(s));
|
|
442
|
+
this.setEntryPreviewError(c);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
popArchive() {
|
|
446
|
+
this.archiveStack.length <= 1 || (this.archiveStack.pop(), this.setRoute("/"));
|
|
447
|
+
}
|
|
448
|
+
emit(e, t) {
|
|
449
|
+
for (const r of this.listeners[e])
|
|
450
|
+
r(t);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
function Re() {
|
|
454
|
+
return {
|
|
455
|
+
id: "archive",
|
|
456
|
+
family: "archive",
|
|
457
|
+
supports: (n) => Q(W(n)),
|
|
458
|
+
createSession: (n, e) => new se(n, e)
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
function Ne(n = te()) {
|
|
462
|
+
const e = new Set(H.flatMap((t) => t.extensions));
|
|
463
|
+
return [
|
|
464
|
+
...H,
|
|
465
|
+
...n.filter((t) => !t.extensions.some((r) => e.has(r)))
|
|
466
|
+
];
|
|
467
|
+
}
|
|
468
|
+
async function _(n, e, t, r, i, a, o, s = []) {
|
|
469
|
+
b(r);
|
|
470
|
+
const c = (h) => {
|
|
471
|
+
if (h.length > A.maxEntries) throw new Error("Archive contains too many entries.");
|
|
472
|
+
return { label: t, containerContext: a, entries: h.map((l) => ({
|
|
473
|
+
...l,
|
|
474
|
+
read: (m = r) => D(() => l.read(m), l.size, a, m)
|
|
475
|
+
})) };
|
|
476
|
+
}, d = F(t, [{ name: t, bytes: n }, ...s]);
|
|
477
|
+
if (e === "rar" || e === "7z" || d) {
|
|
478
|
+
const { runArchiveWorker: h } = await Promise.resolve().then(() => Le), l = (d == null ? void 0 : d.primary) ?? { name: t, bytes: n }, m = (d == null ? void 0 : d.format) ?? e, u = {
|
|
479
|
+
bytes: l.bytes,
|
|
480
|
+
format: m,
|
|
481
|
+
...d ? { name: l.name, volumes: d.files.slice(1) } : {}
|
|
482
|
+
};
|
|
483
|
+
let v = o;
|
|
484
|
+
const y = await O(async (p) => {
|
|
485
|
+
const g = await h({ ...u, password: p }, r);
|
|
486
|
+
return v = p, g;
|
|
487
|
+
}, i, t, r, o);
|
|
488
|
+
return c(y.entries.map((p) => ({
|
|
489
|
+
name: p.directory ? `${p.path.replace(/\/+$/, "")}/` : p.path,
|
|
490
|
+
type: p.directory ? "directory" : "file",
|
|
491
|
+
size: p.directory ? void 0 : p.size,
|
|
492
|
+
modified: p.modified,
|
|
493
|
+
encrypted: p.encrypted,
|
|
494
|
+
read: (g = r) => O(async (w) => (await h({ ...u, entry: p, password: w }, g)).bytes, i, `${t} › ${p.path}`, g, v)
|
|
495
|
+
})).sort(R));
|
|
496
|
+
}
|
|
497
|
+
if (X(e)) {
|
|
498
|
+
const h = await x(ne(n, {
|
|
499
|
+
password: o,
|
|
500
|
+
signal: r,
|
|
501
|
+
maxEntryBytes: A.maxEntryBytes
|
|
502
|
+
}).catch((l) => {
|
|
503
|
+
throw l instanceof Error && /multi.?volume|multi.?disk/i.test(l.message) ? new Error("Archive volumes are missing. Select the .zip file and all .z01, .z02 parts together.") : l;
|
|
504
|
+
}), r);
|
|
505
|
+
return b(r), c([...h.values()].map((l) => ({
|
|
506
|
+
name: l.name,
|
|
507
|
+
type: l.directory ? "directory" : "file",
|
|
508
|
+
size: l.directory ? void 0 : l.size,
|
|
509
|
+
modified: l.modified,
|
|
510
|
+
encrypted: l.encrypted,
|
|
511
|
+
read: (m = r) => O((u) => l.bytes(u, m), i, `${t} › ${l.name}`, m, o)
|
|
512
|
+
})).sort(R));
|
|
513
|
+
}
|
|
514
|
+
if (e === "tar")
|
|
515
|
+
return c(Z(n));
|
|
516
|
+
if (e === "gz" || e === "tgz") {
|
|
517
|
+
const h = await D(() => ce(n), void 0, a, r);
|
|
518
|
+
if (b(r), e === "tgz" || le(h))
|
|
519
|
+
return c(Z(h));
|
|
520
|
+
const l = t.replace(/\.gz$/i, "") || "file";
|
|
521
|
+
return c([{ name: l, type: "file", size: h.byteLength, read: async () => h.slice() }]);
|
|
522
|
+
}
|
|
523
|
+
throw new Error(`Archive preview does not support ${e || "unknown"} files.`);
|
|
524
|
+
}
|
|
525
|
+
function Z(n) {
|
|
526
|
+
const e = [], t = /* @__PURE__ */ new Map();
|
|
527
|
+
let r = /* @__PURE__ */ new Map(), i;
|
|
528
|
+
for (let a = 0; a + 512 <= n.byteLength; ) {
|
|
529
|
+
if (e.length > A.maxEntries) throw new Error("Archive contains too many entries.");
|
|
530
|
+
const o = n.subarray(a, a + 512);
|
|
531
|
+
if (o.every((f) => f === 0)) break;
|
|
532
|
+
if (!J(o)) throw new Error("Invalid TAR header checksum.");
|
|
533
|
+
const s = String.fromCharCode(o[156] ?? 0), c = ["x", "g", "L", "K"].includes(s), d = (f) => r.get(f) ?? t.get(f), h = c ? void 0 : d("size"), l = h ? $(h, !0) : I(o, 124, 12);
|
|
534
|
+
if (!Number.isSafeInteger(l) || l < 0) throw new Error("Invalid TAR entry size.");
|
|
535
|
+
const m = a + 512, u = m + Math.ceil(l / 512) * 512;
|
|
536
|
+
if (!Number.isSafeInteger(u) || u > n.byteLength) throw new Error("Truncated TAR entry.");
|
|
537
|
+
if (c) {
|
|
538
|
+
const f = n.subarray(m, m + l);
|
|
539
|
+
if (s === "L") {
|
|
540
|
+
const z = f.indexOf(0);
|
|
541
|
+
i = new TextDecoder().decode(z < 0 ? f : f.subarray(0, z));
|
|
542
|
+
} else if (s !== "K") {
|
|
543
|
+
const z = ae(f);
|
|
544
|
+
for (const [N, U] of z)
|
|
545
|
+
s === "g" ? U ? t.set(N, U) : t.delete(N) : r.set(N, U);
|
|
546
|
+
}
|
|
547
|
+
a = u;
|
|
548
|
+
continue;
|
|
549
|
+
}
|
|
550
|
+
const v = j(o, 345, 155), y = j(o, 0, 100), p = P(d("path") || i || (v ? `${v}/${y}` : y)), g = d("mtime"), w = g ? $(g, !1) : I(o, 136, 12);
|
|
551
|
+
if (r = /* @__PURE__ */ new Map(), i = void 0, p && (s === "\0" || s === "0" || s === "5")) {
|
|
552
|
+
const f = s === "5", z = f ? `${p.replace(/\/+$/, "")}/` : p;
|
|
553
|
+
e.push({
|
|
554
|
+
name: z,
|
|
555
|
+
type: f ? "directory" : "file",
|
|
556
|
+
size: f ? void 0 : l,
|
|
557
|
+
modified: g || w > 0 ? w * 1e3 : void 0,
|
|
558
|
+
read: async () => f ? new Uint8Array() : n.slice(m, m + l)
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
a = u;
|
|
562
|
+
}
|
|
563
|
+
return e.sort(R);
|
|
564
|
+
}
|
|
565
|
+
function ae(n) {
|
|
566
|
+
const e = /* @__PURE__ */ new Map(), t = new TextDecoder();
|
|
567
|
+
for (let r = 0; r < n.length; ) {
|
|
568
|
+
const i = n.indexOf(32, r);
|
|
569
|
+
if (i < 0) throw new Error("Invalid TAR extended header length.");
|
|
570
|
+
const a = $(t.decode(n.subarray(r, i)), !0), o = r + a;
|
|
571
|
+
if (o <= i + 1 || o > n.length || n[o - 1] !== 10) throw new Error("Truncated TAR extended header.");
|
|
572
|
+
const s = t.decode(n.subarray(i + 1, o - 1)), c = s.indexOf("=");
|
|
573
|
+
if (c <= 0) throw new Error("Invalid TAR extended header field.");
|
|
574
|
+
e.set(s.slice(0, c), s.slice(c + 1)), r = o;
|
|
575
|
+
}
|
|
576
|
+
return e;
|
|
577
|
+
}
|
|
578
|
+
function $(n, e) {
|
|
579
|
+
const t = Number(n);
|
|
580
|
+
if (!(e ? /^\d+$/ : /^-?\d+(?:\.\d+)?$/).test(n) || !Number.isFinite(t) || e && !Number.isSafeInteger(t))
|
|
581
|
+
throw new Error("Invalid TAR extended header number.");
|
|
582
|
+
return t;
|
|
583
|
+
}
|
|
584
|
+
async function ce(n) {
|
|
585
|
+
const e = [];
|
|
586
|
+
let t = 0;
|
|
587
|
+
const r = new ee((o) => {
|
|
588
|
+
if (t += o.byteLength, t > A.maxEntryBytes) throw new Error("Expanded GZIP exceeds the preview size limit.");
|
|
589
|
+
e.push(o);
|
|
590
|
+
});
|
|
591
|
+
for (let o = 0; o < n.length; o += 4096)
|
|
592
|
+
r.push(n.subarray(o, o + 4096), o + 4096 >= n.length);
|
|
593
|
+
const i = new Uint8Array(t);
|
|
594
|
+
let a = 0;
|
|
595
|
+
for (const o of e)
|
|
596
|
+
i.set(o, a), a += o.byteLength;
|
|
597
|
+
return i;
|
|
598
|
+
}
|
|
599
|
+
function le(n) {
|
|
600
|
+
return n.byteLength >= 512 && !n.subarray(0, 512).every((e) => e === 0) && J(n.subarray(0, 512));
|
|
601
|
+
}
|
|
602
|
+
function J(n) {
|
|
603
|
+
const e = I(n, 148, 8);
|
|
604
|
+
let t = 0;
|
|
605
|
+
for (let r = 0; r < 512; r += 1)
|
|
606
|
+
t += r >= 148 && r < 156 ? 32 : n[r] ?? 0;
|
|
607
|
+
return e === t;
|
|
608
|
+
}
|
|
609
|
+
function j(n, e, t) {
|
|
610
|
+
const r = n.subarray(e, e + t), i = r.indexOf(0);
|
|
611
|
+
return new TextDecoder().decode(i >= 0 ? r.subarray(0, i) : r).trim();
|
|
612
|
+
}
|
|
613
|
+
function I(n, e, t) {
|
|
614
|
+
const r = j(n, e, t).replace(/^0+/, "").trim();
|
|
615
|
+
return r ? Number.parseInt(r, 8) : 0;
|
|
616
|
+
}
|
|
617
|
+
function L(n) {
|
|
618
|
+
const e = String(n || "/").trim().replace(/\\/g, "/");
|
|
619
|
+
if (!e || e === "/")
|
|
620
|
+
return "/";
|
|
621
|
+
const t = e.replace(/^\/+/, "").replace(/\/+$/, "");
|
|
622
|
+
return t ? `/${t}/` : "/";
|
|
623
|
+
}
|
|
624
|
+
function he(n) {
|
|
625
|
+
return L(n) !== "/";
|
|
626
|
+
}
|
|
627
|
+
function de(n) {
|
|
628
|
+
const e = L(n);
|
|
629
|
+
if (e === "/")
|
|
630
|
+
return "/";
|
|
631
|
+
const r = e.replace(/^\/|\/$/g, "").split("/").filter(Boolean);
|
|
632
|
+
return r.pop(), r.length ? `/${r.join("/")}/` : "/";
|
|
633
|
+
}
|
|
634
|
+
function G(n, e) {
|
|
635
|
+
const t = L(n), r = t === "/" ? "" : t.replace(/^\/|\/$/g, ""), i = String(e).replace(/\\/g, "/").replace(/\/+$/g, "").replace(/^\/+/, ""), a = [r, i].filter(Boolean).join("/");
|
|
636
|
+
return a ? `/${a}/` : "/";
|
|
637
|
+
}
|
|
638
|
+
function ue(n) {
|
|
639
|
+
const e = /* @__PURE__ */ new Map();
|
|
640
|
+
for (const t of n) {
|
|
641
|
+
let r = "";
|
|
642
|
+
for (let i = t.name.indexOf("/"); i >= 0; i = t.name.indexOf("/", i + 1)) {
|
|
643
|
+
const a = t.name.slice(0, i + 1), o = e.has(a);
|
|
644
|
+
o || e.set(a, []), r && (!o || i === t.name.length - 1) && e.get(r).push(t), r = a;
|
|
645
|
+
}
|
|
646
|
+
r && !t.name.endsWith("/") && e.get(r).push(t);
|
|
647
|
+
}
|
|
648
|
+
return e;
|
|
649
|
+
}
|
|
650
|
+
function me(n, e) {
|
|
651
|
+
const t = L(e), r = t === "/" ? "" : t.slice(1), i = new Map(n.map((o) => [o.name, o])), a = /* @__PURE__ */ new Map();
|
|
652
|
+
for (const o of n) {
|
|
653
|
+
if (r && !o.name.startsWith(r))
|
|
654
|
+
continue;
|
|
655
|
+
const s = r ? o.name.slice(r.length) : o.name;
|
|
656
|
+
if (!s)
|
|
657
|
+
continue;
|
|
658
|
+
const c = s.split("/", 1)[0] ?? s;
|
|
659
|
+
if (!c)
|
|
660
|
+
continue;
|
|
661
|
+
const d = s.length > c.length, h = d ? `${c}/` : c;
|
|
662
|
+
if (!a.has(h)) {
|
|
663
|
+
if (d) {
|
|
664
|
+
const l = i.get(`${r}${h}`);
|
|
665
|
+
a.set(h, {
|
|
666
|
+
name: h,
|
|
667
|
+
type: "directory",
|
|
668
|
+
modified: l == null ? void 0 : l.modified
|
|
669
|
+
});
|
|
670
|
+
continue;
|
|
671
|
+
}
|
|
672
|
+
a.set(h, {
|
|
673
|
+
name: h,
|
|
674
|
+
type: "file",
|
|
675
|
+
size: o.size,
|
|
676
|
+
modified: o.modified
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
return [...a.values()].sort(R);
|
|
681
|
+
}
|
|
682
|
+
function M(n, e) {
|
|
683
|
+
const t = String(n).trim().toLowerCase().split(/[?#]/, 1)[0] ?? "";
|
|
684
|
+
if (t.endsWith(".tar.gz") || t.endsWith(".tgz")) return "tgz";
|
|
685
|
+
const r = /\.(7z|zip)\.\d{3,}$/.exec(t);
|
|
686
|
+
return r ? r[1] : /\.[r-y]\d{2}$/.test(t) ? "rar" : /\.z\d{2,}$/.test(t) ? "zip" : W(e || t.split(".").pop());
|
|
687
|
+
}
|
|
688
|
+
function pe(n) {
|
|
689
|
+
return ie(n) || Q(M(n));
|
|
690
|
+
}
|
|
691
|
+
async function ve(n, e) {
|
|
692
|
+
b(e.signal);
|
|
693
|
+
const t = e.descriptor.archiveVolumes ?? [];
|
|
694
|
+
if (t.length >= C.maxVolumes) throw new Error("Archive contains too many volumes.");
|
|
695
|
+
const r = e.descriptor.name ?? "archive", i = [{ name: r, source: n }, ...t], a = (l) => l instanceof Blob ? l.size : typeof l == "string" ? 0 : l.byteLength;
|
|
696
|
+
if (i.reduce((l, m) => l + a(m.source), 0) > C.maxBytes) throw new Error("Archive volumes exceed the preview input size limit.");
|
|
697
|
+
const o = F(r, i);
|
|
698
|
+
if (t.length && (!o || o.files.length !== i.length)) throw new Error("Archive volumes do not belong to the same archive.");
|
|
699
|
+
const s = async (l) => new Uint8Array(await fe(l.source, e)), c = await s(i[0]);
|
|
700
|
+
let d = c.byteLength;
|
|
701
|
+
const h = [];
|
|
702
|
+
for (const l of t) {
|
|
703
|
+
const m = a(l.source);
|
|
704
|
+
if (d + m > C.maxBytes) throw new Error("Archive volumes exceed the preview input size limit.");
|
|
705
|
+
const u = await s(l);
|
|
706
|
+
if (d += u.byteLength, d > C.maxBytes) throw new Error("Archive volumes exceed the preview input size limit.");
|
|
707
|
+
h.push({ name: l.name, bytes: u });
|
|
708
|
+
}
|
|
709
|
+
return { bytes: c, volumes: h };
|
|
710
|
+
}
|
|
711
|
+
function Q(n) {
|
|
712
|
+
return X(n) || ["tar", "tgz", "gz", "rar", "7z"].includes(n);
|
|
713
|
+
}
|
|
714
|
+
function X(n) {
|
|
715
|
+
return ["zip", "jar", "war", "ear", "apk"].includes(n);
|
|
716
|
+
}
|
|
717
|
+
async function fe(n, e) {
|
|
718
|
+
const t = e.signal;
|
|
719
|
+
if (b(t), typeof n == "string") {
|
|
720
|
+
const r = (a) => {
|
|
721
|
+
var o;
|
|
722
|
+
(o = a.body) == null || o.cancel().catch(() => {
|
|
723
|
+
});
|
|
724
|
+
}, i = await x(fetch(n, { signal: t }), t, r);
|
|
725
|
+
try {
|
|
726
|
+
if (b(t), !i.ok)
|
|
727
|
+
throw new Error(`Failed to load archive source: ${i.status} ${i.statusText}`.trim());
|
|
728
|
+
return await x(i.arrayBuffer(), t);
|
|
729
|
+
} catch (a) {
|
|
730
|
+
throw r(i), a;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
if (ArrayBuffer.isView(n)) {
|
|
734
|
+
const r = new Uint8Array(n.buffer, n.byteOffset, n.byteLength), i = new Uint8Array(r.byteLength);
|
|
735
|
+
return i.set(r), i.buffer;
|
|
736
|
+
}
|
|
737
|
+
return n instanceof ArrayBuffer ? n.slice(0) : n instanceof Blob ? x(n.arrayBuffer(), t) : new TextEncoder().encode(String(n)).buffer;
|
|
738
|
+
}
|
|
739
|
+
function b(n) {
|
|
740
|
+
if (n != null && n.aborted) throw new DOMException("Archive preview aborted.", "AbortError");
|
|
741
|
+
}
|
|
742
|
+
function x(n, e, t) {
|
|
743
|
+
return e ? new Promise((r, i) => {
|
|
744
|
+
let a = !1;
|
|
745
|
+
const o = () => {
|
|
746
|
+
a || (a = !0, e.removeEventListener("abort", o), i(new DOMException("Archive preview aborted.", "AbortError")));
|
|
747
|
+
};
|
|
748
|
+
e.addEventListener("abort", o, { once: !0 }), e.aborted && o(), n.then((s) => {
|
|
749
|
+
if (a) {
|
|
750
|
+
t == null || t(s);
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
753
|
+
a = !0, e.removeEventListener("abort", o), r(s);
|
|
754
|
+
}, (s) => {
|
|
755
|
+
a || (a = !0, e.removeEventListener("abort", o), i(s));
|
|
756
|
+
}).catch(() => {
|
|
757
|
+
});
|
|
758
|
+
}) : n;
|
|
759
|
+
}
|
|
760
|
+
function ye() {
|
|
761
|
+
const n = document.createElement("thead"), e = document.createElement("tr");
|
|
762
|
+
for (const t of ["Name", "Type", "Size", "Modified"]) {
|
|
763
|
+
const r = document.createElement("th");
|
|
764
|
+
r.textContent = t, e.appendChild(r);
|
|
765
|
+
}
|
|
766
|
+
return n.appendChild(e), n;
|
|
767
|
+
}
|
|
768
|
+
function T() {
|
|
769
|
+
const n = document.createElement("span");
|
|
770
|
+
return n.className = "archivev-breadcrumb-separator", n.textContent = "›", n.setAttribute("aria-hidden", "true"), n;
|
|
771
|
+
}
|
|
772
|
+
function K(n) {
|
|
773
|
+
const t = (n.toLowerCase().split(/[?#]/, 1)[0] ?? "").split(/[\\/]/).pop() ?? "", r = t.lastIndexOf(".");
|
|
774
|
+
return r >= 0 ? t.slice(r + 1) : "";
|
|
775
|
+
}
|
|
776
|
+
function R(n, e) {
|
|
777
|
+
return n.type !== e.type ? n.type === "directory" ? -1 : 1 : n.name.localeCompare(e.name);
|
|
778
|
+
}
|
|
779
|
+
function we(n) {
|
|
780
|
+
if (n < 1024)
|
|
781
|
+
return `${n} B`;
|
|
782
|
+
const e = ["KB", "MB", "GB", "TB"];
|
|
783
|
+
let t = n / 1024, r = 0;
|
|
784
|
+
for (; t >= 1024 && r < e.length - 1; )
|
|
785
|
+
t /= 1024, r += 1;
|
|
786
|
+
return `${t.toFixed(t >= 10 ? 0 : 1)} ${e[r]}`;
|
|
787
|
+
}
|
|
788
|
+
function W(n) {
|
|
789
|
+
return String(n ?? "").trim().replace(/^\./, "").toLowerCase();
|
|
790
|
+
}
|
|
791
|
+
function P(n) {
|
|
792
|
+
const e = String(n ?? "");
|
|
793
|
+
if (!/[\\%?#:]|(?:^|\/)\.\.?(?:\/|$)|\/\/|^\/|\/$|^\s|\s$/.test(e)) return e;
|
|
794
|
+
const t = e.trim().replace(/\\/g, "/").replace(/^[a-z]+:\/\/[^/]+\//i, "").replace(/^[a-z]:\//i, "").replace(/^\/+/, "").split(/[?#]/)[0] ?? "", r = [];
|
|
795
|
+
for (const i of t.split("/"))
|
|
796
|
+
if (!(!i || i === ".")) {
|
|
797
|
+
if (i === "..") {
|
|
798
|
+
r.pop();
|
|
799
|
+
continue;
|
|
800
|
+
}
|
|
801
|
+
r.push(be(i));
|
|
802
|
+
}
|
|
803
|
+
return r.join("/");
|
|
804
|
+
}
|
|
805
|
+
function k(n) {
|
|
806
|
+
const e = new Uint8Array(n.byteLength);
|
|
807
|
+
return e.set(n), e.buffer;
|
|
808
|
+
}
|
|
809
|
+
function be(n) {
|
|
810
|
+
try {
|
|
811
|
+
return decodeURIComponent(n);
|
|
812
|
+
} catch {
|
|
813
|
+
return n;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
function ge(n, e, t = !1) {
|
|
817
|
+
var a;
|
|
818
|
+
const r = t ? n : P(n), i = W((a = r.split("?")[0]) == null ? void 0 : a.split(".").pop());
|
|
819
|
+
return (e == null ? void 0 : e[r]) ?? (e == null ? void 0 : e[i]) ?? Ee(i);
|
|
820
|
+
}
|
|
821
|
+
function Ee(n) {
|
|
822
|
+
return {
|
|
823
|
+
aac: "audio/aac",
|
|
824
|
+
avif: "image/avif",
|
|
825
|
+
bin: "application/octet-stream",
|
|
826
|
+
bmp: "image/bmp",
|
|
827
|
+
css: "text/css",
|
|
828
|
+
gif: "image/gif",
|
|
829
|
+
flac: "audio/flac",
|
|
830
|
+
gltf: "model/gltf+json",
|
|
831
|
+
html: "text/html",
|
|
832
|
+
jpeg: "image/jpeg",
|
|
833
|
+
jpg: "image/jpeg",
|
|
834
|
+
json: "application/json",
|
|
835
|
+
ktx2: "image/ktx2",
|
|
836
|
+
m4a: "audio/mp4",
|
|
837
|
+
m4v: "video/mp4",
|
|
838
|
+
mov: "video/quicktime",
|
|
839
|
+
mp3: "audio/mpeg",
|
|
840
|
+
mp4: "video/mp4",
|
|
841
|
+
obj: "model/obj",
|
|
842
|
+
oga: "audio/ogg",
|
|
843
|
+
ogg: "audio/ogg",
|
|
844
|
+
ogv: "video/ogg",
|
|
845
|
+
opus: "audio/ogg",
|
|
846
|
+
pdf: "application/pdf",
|
|
847
|
+
png: "image/png",
|
|
848
|
+
svg: "image/svg+xml",
|
|
849
|
+
txt: "text/plain",
|
|
850
|
+
wav: "audio/wav",
|
|
851
|
+
webm: "video/webm",
|
|
852
|
+
webp: "image/webp",
|
|
853
|
+
xhtml: "application/xhtml+xml"
|
|
854
|
+
}[n];
|
|
855
|
+
}
|
|
856
|
+
function xe(n) {
|
|
857
|
+
return new Worker(
|
|
858
|
+
"" + new URL("../assets/archive-worker-Cy3bEdVg.js", import.meta.url).href,
|
|
859
|
+
{
|
|
860
|
+
name: n == null ? void 0 : n.name
|
|
861
|
+
}
|
|
862
|
+
);
|
|
863
|
+
}
|
|
864
|
+
const Ce = () => new URL("../archive/7zz.wasm", import.meta.url).href, S = /* @__PURE__ */ new Map();
|
|
865
|
+
function ze(n) {
|
|
866
|
+
const e = S.get(n);
|
|
867
|
+
if (e) return e;
|
|
868
|
+
const t = fetch(n).then(async (r) => {
|
|
869
|
+
var a;
|
|
870
|
+
if (!r.ok) throw new Error(`Unable to load the archive engine (${r.status}).`);
|
|
871
|
+
const i = (a = r.headers.get("content-type")) == null ? void 0 : a.split(";", 1)[0];
|
|
872
|
+
return typeof WebAssembly.compileStreaming == "function" && i === "application/wasm" ? WebAssembly.compileStreaming(r) : WebAssembly.compile(await r.arrayBuffer());
|
|
873
|
+
});
|
|
874
|
+
return S.set(n, t), t.catch(() => {
|
|
875
|
+
S.get(n) === t && S.delete(n);
|
|
876
|
+
}), t;
|
|
877
|
+
}
|
|
878
|
+
function Ae(n, e) {
|
|
879
|
+
var t, r;
|
|
880
|
+
if (e == null || e.throwIfAborted(), /^(blob|data):/.test(import.meta.url) || ((t = globalThis.location) == null ? void 0 : t.protocol) === "file:")
|
|
881
|
+
throw new Error("RAR, 7z and multi-volume ZIP need separate archive engine files. Use filens preview FILE --mode serve, or deploy the archive assets over HTTP(S).");
|
|
882
|
+
if (1 + (((r = n.volumes) == null ? void 0 : r.length) ?? 0) > C.maxVolumes || n.bytes.byteLength + (n.volumes ?? []).reduce((i, a) => i + a.bytes.byteLength, 0) > C.maxBytes)
|
|
883
|
+
throw new Error("Archive volumes exceed the preview input limit.");
|
|
884
|
+
return new Promise((i, a) => {
|
|
885
|
+
const o = new xe();
|
|
886
|
+
let s = !1;
|
|
887
|
+
const c = (l, m) => {
|
|
888
|
+
s || (s = !0, clearTimeout(h), e == null || e.removeEventListener("abort", d), o.terminate(), m ? a(m) : i(l));
|
|
889
|
+
}, d = () => c(void 0, new DOMException("Archive preview aborted.", "AbortError")), h = setTimeout(() => c(void 0, new Error("Archive processing exceeded the preview time limit.")), 6e4);
|
|
890
|
+
e == null || e.addEventListener("abort", d, { once: !0 }), o.onmessage = (l) => {
|
|
891
|
+
const { result: m, error: u } = l.data;
|
|
892
|
+
c(m, u ? u.code === "password_required" || u.code === "password_invalid" ? new oe(u.code) : new Error(u.message) : void 0);
|
|
893
|
+
}, o.onerror = () => c(void 0, new Error("The archive WASM worker could not be loaded or stopped unexpectedly.")), o.onmessageerror = () => c(void 0, new Error("The archive worker returned an invalid response.")), (async () => {
|
|
894
|
+
var g;
|
|
895
|
+
const l = Ce(), m = await ze(l);
|
|
896
|
+
if (s) return;
|
|
897
|
+
const u = n.bytes.slice(), v = (g = n.volumes) == null ? void 0 : g.map((w) => ({ name: w.name, bytes: w.bytes.slice() })), y = {
|
|
898
|
+
...n,
|
|
899
|
+
bytes: u,
|
|
900
|
+
volumes: v,
|
|
901
|
+
wasmUrl: l,
|
|
902
|
+
maxEntries: A.maxEntries,
|
|
903
|
+
maxEntryBytes: A.maxEntryBytes
|
|
904
|
+
}, p = [u.buffer, ...(v ?? []).map((w) => w.bytes.buffer)];
|
|
905
|
+
try {
|
|
906
|
+
o.postMessage({ ...y, wasmModule: m }, p);
|
|
907
|
+
} catch (w) {
|
|
908
|
+
if (!(w instanceof DOMException) || w.name !== "DataCloneError") throw w;
|
|
909
|
+
o.postMessage(y, p);
|
|
910
|
+
}
|
|
911
|
+
})().catch((l) => c(void 0, l instanceof Error ? l : new Error(String(l))));
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
const Le = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
915
|
+
__proto__: null,
|
|
916
|
+
runArchiveWorker: Ae
|
|
917
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
918
|
+
export {
|
|
919
|
+
Re as a,
|
|
920
|
+
Ne as c
|
|
921
|
+
};
|