@brftech/filex 0.40.0 → 0.41.1
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 +47 -8
- package/dist/ArchiveViewer-K5qK0zfS.js +123 -0
- package/dist/ArchiveViewer-K5qK0zfS.js.map +1 -0
- package/dist/CsvViewer-Bac6RzAt.js +140 -0
- package/dist/CsvViewer-Bac6RzAt.js.map +1 -0
- package/dist/{DrawioViewer-Dp8cxp-x.js → DrawioViewer-CWjYMKPU.js} +52 -47
- package/dist/DrawioViewer-CWjYMKPU.js.map +1 -0
- package/dist/EpubViewer-CIk5aFlK.js +160 -0
- package/dist/EpubViewer-CIk5aFlK.js.map +1 -0
- package/dist/IpynbViewer-Zns7tk61.js +180 -0
- package/dist/IpynbViewer-Zns7tk61.js.map +1 -0
- package/dist/MermaidViewer-VsEYlFWq.js +136 -0
- package/dist/MermaidViewer-VsEYlFWq.js.map +1 -0
- package/dist/PsdViewer-BUVVVD90.js +118 -0
- package/dist/PsdViewer-BUVVVD90.js.map +1 -0
- package/dist/TiffViewer-5AjGk4zd.js +139 -0
- package/dist/TiffViewer-5AjGk4zd.js.map +1 -0
- package/dist/Viewer3D-CAZ50vDp.js +74 -0
- package/dist/Viewer3D-CAZ50vDp.js.map +1 -0
- package/dist/filex.js +1 -1
- package/dist/filex.umd.cjs +91 -92
- package/dist/filex.umd.cjs.map +1 -1
- package/dist/index-DiSDAgAg.js +35167 -0
- package/dist/index-DiSDAgAg.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/style.css +1 -1
- package/package.json +4 -4
- package/dist/ArchiveViewer-C1FprACN.js +0 -99
- package/dist/ArchiveViewer-C1FprACN.js.map +0 -1
- package/dist/CsvViewer-bn2id_EW.js +0 -131
- package/dist/CsvViewer-bn2id_EW.js.map +0 -1
- package/dist/DrawioViewer-Dp8cxp-x.js.map +0 -1
- package/dist/EpubViewer-CYapMdP6.js +0 -143
- package/dist/EpubViewer-CYapMdP6.js.map +0 -1
- package/dist/IpynbViewer-SjHOXBkc.js +0 -171
- package/dist/IpynbViewer-SjHOXBkc.js.map +0 -1
- package/dist/MermaidViewer-BdfTJ2ne.js +0 -127
- package/dist/MermaidViewer-BdfTJ2ne.js.map +0 -1
- package/dist/PsdViewer-C7Sknaxs.js +0 -109
- package/dist/PsdViewer-C7Sknaxs.js.map +0 -1
- package/dist/TiffViewer-C4gmMB4q.js +0 -130
- package/dist/TiffViewer-C4gmMB4q.js.map +0 -1
- package/dist/Viewer3D-BdxyRN7v.js +0 -60
- package/dist/Viewer3D-BdxyRN7v.js.map +0 -1
- package/dist/index-BWP1wNya.js +0 -25361
- package/dist/index-BWP1wNya.js.map +0 -1
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { f as J } from "./useViewerFetch-czqbd2Lj.js";
|
|
2
|
-
import { d as R, o as U, h as D, w as q, a as t, c as a, e as o, t as d, F as m, k as C, i as E, f as p, l as z } from "./index-BWP1wNya.js";
|
|
3
|
-
const G = { class: "filex-viewer-ipynb" }, K = { class: "filex-viewer-ipynb__pane" }, P = {
|
|
4
|
-
key: 0,
|
|
5
|
-
class: "filex-viewer-fallback"
|
|
6
|
-
}, Q = {
|
|
7
|
-
key: 1,
|
|
8
|
-
class: "filex-viewer-fallback"
|
|
9
|
-
}, W = { key: 2 }, X = ["data-type"], Y = { class: "filex-viewer-ipynb__exec" }, Z = { class: "filex-viewer-ipynb__src hljs" }, ee = ["innerHTML"], te = { key: 1 }, ae = {
|
|
10
|
-
key: 0,
|
|
11
|
-
class: "filex-viewer-ipynb__outputs"
|
|
12
|
-
}, ne = ["src", "alt"], re = ["innerHTML"], le = ["data-type"], ie = ["innerHTML"], se = {
|
|
13
|
-
key: 1,
|
|
14
|
-
class: "filex-viewer-ipynb__md-raw"
|
|
15
|
-
}, ue = {
|
|
16
|
-
key: 2,
|
|
17
|
-
class: "filex-viewer-ipynb__src"
|
|
18
|
-
}, de = /* @__PURE__ */ R({
|
|
19
|
-
__name: "IpynbViewer",
|
|
20
|
-
props: {
|
|
21
|
-
url: {},
|
|
22
|
-
ext: {},
|
|
23
|
-
t: { type: Function },
|
|
24
|
-
authHeaders: { type: Function },
|
|
25
|
-
authCredentials: {}
|
|
26
|
-
},
|
|
27
|
-
setup(F) {
|
|
28
|
-
const u = F, _ = p([]), M = p("python"), f = p(null), y = p(!0), w = p(/* @__PURE__ */ new Map()), k = p(/* @__PURE__ */ new Map());
|
|
29
|
-
let v = 0, x = null, g = null;
|
|
30
|
-
async function N() {
|
|
31
|
-
if (g !== null) return g || null;
|
|
32
|
-
try {
|
|
33
|
-
const e = await import(
|
|
34
|
-
/* @vite-ignore */
|
|
35
|
-
"./index-Bj3s2pEM.js"
|
|
36
|
-
), n = e.default ?? e;
|
|
37
|
-
return g = new n({ html: !1, linkify: !0, breaks: !0 }), g;
|
|
38
|
-
} catch {
|
|
39
|
-
return g = !1, null;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function s(e) {
|
|
43
|
-
return Array.isArray(e) ? e.join("") : e ?? "";
|
|
44
|
-
}
|
|
45
|
-
async function H() {
|
|
46
|
-
var i, h, S, j;
|
|
47
|
-
y.value = !0, f.value = null, _.value = [], w.value = /* @__PURE__ */ new Map(), k.value = /* @__PURE__ */ new Map();
|
|
48
|
-
const e = ++v;
|
|
49
|
-
let n;
|
|
50
|
-
try {
|
|
51
|
-
n = await J({
|
|
52
|
-
url: u.url,
|
|
53
|
-
headers: await ((i = u.authHeaders) == null ? void 0 : i.call(u)) ?? {},
|
|
54
|
-
credentials: u.authCredentials
|
|
55
|
-
});
|
|
56
|
-
} catch (l) {
|
|
57
|
-
f.value = l instanceof Error ? l.message : "fetch failed", y.value = !1;
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
if (e !== v) return;
|
|
61
|
-
let r;
|
|
62
|
-
try {
|
|
63
|
-
r = JSON.parse(n);
|
|
64
|
-
} catch {
|
|
65
|
-
f.value = "Invalid notebook JSON", y.value = !1;
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
if (_.value = Array.isArray(r.cells) ? r.cells : [], M.value = ((S = (h = r.metadata) == null ? void 0 : h.kernelspec) == null ? void 0 : S.language) || "python", x = await z(), e !== v) return;
|
|
69
|
-
if (x) {
|
|
70
|
-
const l = x.default ?? x, b = (j = l.getLanguage) != null && j.call(l, M.value) ? M.value : null;
|
|
71
|
-
_.value.forEach((A, $) => {
|
|
72
|
-
if (A.cell_type === "code") {
|
|
73
|
-
const B = s(A.source);
|
|
74
|
-
try {
|
|
75
|
-
const O = b ? l.highlight(B, { language: b, ignoreIllegals: !0 }) : l.highlightAuto(B);
|
|
76
|
-
w.value.set($, O.value);
|
|
77
|
-
} catch {
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
const c = await N();
|
|
83
|
-
e === v && (c && _.value.forEach((l, b) => {
|
|
84
|
-
if (l.cell_type === "markdown")
|
|
85
|
-
try {
|
|
86
|
-
k.value.set(b, c.render(s(l.source)));
|
|
87
|
-
} catch {
|
|
88
|
-
}
|
|
89
|
-
}), y.value = !1);
|
|
90
|
-
}
|
|
91
|
-
function T(e) {
|
|
92
|
-
var n;
|
|
93
|
-
return e ? e.output_type === "stream" ? s(e.text) : e.output_type === "error" ? [e.ename, e.evalue, ...e.traceback || []].filter(Boolean).join(`
|
|
94
|
-
`) : (e.output_type === "execute_result" || e.output_type === "display_data") && (n = e.data) != null && n["text/plain"] ? s(e.data["text/plain"]) : null : null;
|
|
95
|
-
}
|
|
96
|
-
function L(e) {
|
|
97
|
-
if (!(e != null && e.data)) return null;
|
|
98
|
-
if (e.data["image/png"]) return `data:image/png;base64,${e.data["image/png"]}`;
|
|
99
|
-
if (e.data["image/jpeg"]) return `data:image/jpeg;base64,${e.data["image/jpeg"]}`;
|
|
100
|
-
if (e.data["image/svg+xml"]) {
|
|
101
|
-
const n = s(e.data["image/svg+xml"]);
|
|
102
|
-
return `data:image/svg+xml;utf8,${encodeURIComponent(n)}`;
|
|
103
|
-
}
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
function I(e) {
|
|
107
|
-
return e != null && e.data && e.data["text/html"] ? s(e.data["text/html"]).replace(/<script[\s\S]*?<\/script>/gi, "") : null;
|
|
108
|
-
}
|
|
109
|
-
U(H), D(() => {
|
|
110
|
-
v++;
|
|
111
|
-
}), q(() => u.url, H);
|
|
112
|
-
function V(e, n) {
|
|
113
|
-
return u.t ? u.t(e) : n;
|
|
114
|
-
}
|
|
115
|
-
return (e, n) => (t(), a("div", G, [
|
|
116
|
-
o("div", K, [
|
|
117
|
-
f.value ? (t(), a("div", P, [
|
|
118
|
-
n[0] || (n[0] = o("span", { class: "filex-viewer-fallback__icon" }, "📓", -1)),
|
|
119
|
-
o("p", null, d(f.value), 1)
|
|
120
|
-
])) : y.value ? (t(), a("div", Q, [
|
|
121
|
-
n[1] || (n[1] = o("span", { class: "filex-viewer-fallback__icon" }, "⏳", -1)),
|
|
122
|
-
o("p", null, d(V("viewer.loading", "Loading…")), 1)
|
|
123
|
-
])) : (t(), a("div", W, [
|
|
124
|
-
(t(!0), a(m, null, C(_.value, (r, c) => (t(), a("div", {
|
|
125
|
-
key: c,
|
|
126
|
-
class: "filex-viewer-ipynb__cell",
|
|
127
|
-
"data-type": r.cell_type
|
|
128
|
-
}, [
|
|
129
|
-
r.cell_type === "code" ? (t(), a(m, { key: 0 }, [
|
|
130
|
-
o("div", Y, " In [" + d(r.execution_count ?? " ") + "]: ", 1),
|
|
131
|
-
o("pre", Z, [
|
|
132
|
-
w.value.get(c) ? (t(), a("code", {
|
|
133
|
-
key: 0,
|
|
134
|
-
innerHTML: w.value.get(c)
|
|
135
|
-
}, null, 8, ee)) : (t(), a("code", te, d(s(r.source)), 1))
|
|
136
|
-
]),
|
|
137
|
-
r.outputs && r.outputs.length ? (t(), a("div", ae, [
|
|
138
|
-
(t(!0), a(m, null, C(r.outputs, (i, h) => (t(), a(m, { key: h }, [
|
|
139
|
-
L(i) ? (t(), a("img", {
|
|
140
|
-
key: 0,
|
|
141
|
-
src: L(i) || "",
|
|
142
|
-
class: "filex-viewer-ipynb__img",
|
|
143
|
-
alt: `output ${h}`
|
|
144
|
-
}, null, 8, ne)) : I(i) ? (t(), a("div", {
|
|
145
|
-
key: 1,
|
|
146
|
-
class: "filex-viewer-ipynb__html",
|
|
147
|
-
innerHTML: I(i)
|
|
148
|
-
}, null, 8, re)) : T(i) ? (t(), a("pre", {
|
|
149
|
-
key: 2,
|
|
150
|
-
class: "filex-viewer-ipynb__out",
|
|
151
|
-
"data-type": i.output_type
|
|
152
|
-
}, d(T(i)), 9, le)) : E("", !0)
|
|
153
|
-
], 64))), 128))
|
|
154
|
-
])) : E("", !0)
|
|
155
|
-
], 64)) : r.cell_type === "markdown" ? (t(), a(m, { key: 1 }, [
|
|
156
|
-
k.value.get(c) ? (t(), a("div", {
|
|
157
|
-
key: 0,
|
|
158
|
-
class: "filex-viewer-ipynb__md",
|
|
159
|
-
innerHTML: k.value.get(c)
|
|
160
|
-
}, null, 8, ie)) : (t(), a("pre", se, d(s(r.source)), 1))
|
|
161
|
-
], 64)) : (t(), a("pre", ue, d(s(r.source)), 1))
|
|
162
|
-
], 8, X))), 128))
|
|
163
|
-
]))
|
|
164
|
-
])
|
|
165
|
-
]));
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
export {
|
|
169
|
-
de as default
|
|
170
|
-
};
|
|
171
|
-
//# sourceMappingURL=IpynbViewer-SjHOXBkc.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IpynbViewer-SjHOXBkc.js","sources":["../../core/src/viewers/IpynbViewer.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * IpynbViewer — Jupyter notebook (.ipynb JSON) renderer.\n *\n * Pure-JS render — no peer dependency required:\n * - code cells → `<pre><code>` (highlight.js when available)\n * - markdown cells → markdown-it when available, plain `<pre>` otherwise\n * - output cells → text (stream / display_data 'text/plain'),\n * images (display_data 'image/png' base64),\n * HTML (display_data 'text/html', sanitized via\n * element-only insertion — no script tags)\n *\n * Source list / output count counters at the top so a 200-cell\n * notebook doesn't surprise the user.\n */\nimport { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';\nimport { fetchViewerText } from '../composables/useViewerFetch';\nimport { ensureHighlight } from '../composables/useMonacoLoader';\n\nconst props = defineProps<{\n url: string;\n ext: string;\n t?: (key: string) => string;\n authHeaders?: () => Record<string, string> | Promise<Record<string, string>>;\n authCredentials?: RequestCredentials;\n}>();\n\ninterface Cell {\n cell_type: 'code' | 'markdown' | 'raw' | string;\n source: string | string[];\n outputs?: any[];\n execution_count?: number | null;\n metadata?: Record<string, unknown>;\n}\n\ninterface Notebook {\n cells: Cell[];\n metadata?: { kernelspec?: { language?: string; name?: string } };\n}\n\nconst cells = ref<Cell[]>([]);\nconst language = ref<string>('python');\nconst error = ref<string | null>(null);\nconst loading = ref(true);\nconst renderedSources = ref<Map<number, string>>(new Map());\nconst renderedMarkdown = ref<Map<number, string>>(new Map());\n\nlet renderToken = 0;\nlet highlight: any = null;\nlet mdRenderer: any = null;\n\nasync function ensureMd(): Promise<any | null> {\n if (mdRenderer !== null) return mdRenderer || null;\n try {\n const mod = await import(/* @vite-ignore */ 'markdown-it');\n const Md = (mod as any).default ?? mod;\n mdRenderer = new Md({ html: false, linkify: true, breaks: true });\n return mdRenderer;\n } catch {\n mdRenderer = false;\n return null;\n }\n}\n\nfunction joinSource(source: string | string[]): string {\n return Array.isArray(source) ? source.join('') : (source ?? '');\n}\n\nasync function load(): Promise<void> {\n loading.value = true;\n error.value = null;\n cells.value = [];\n renderedSources.value = new Map();\n renderedMarkdown.value = new Map();\n const myToken = ++renderToken;\n\n let raw: string;\n try {\n raw = await fetchViewerText({\n url: props.url,\n headers: (await props.authHeaders?.()) ?? {},\n credentials: props.authCredentials,\n });\n } catch (err) {\n error.value = err instanceof Error ? err.message : 'fetch failed';\n loading.value = false;\n return;\n }\n\n if (myToken !== renderToken) return;\n\n let nb: Notebook;\n try {\n nb = JSON.parse(raw);\n } catch (err) {\n error.value = 'Invalid notebook JSON';\n loading.value = false;\n return;\n }\n cells.value = Array.isArray(nb.cells) ? nb.cells : [];\n language.value = nb.metadata?.kernelspec?.language || 'python';\n\n // Best-effort hljs highlight per code cell.\n highlight = (await ensureHighlight()) as any;\n if (myToken !== renderToken) return;\n if (highlight) {\n const hljs = highlight.default ?? highlight;\n const langOk = hljs.getLanguage?.(language.value) ? language.value : null;\n cells.value.forEach((cell, idx) => {\n if (cell.cell_type === 'code') {\n const text = joinSource(cell.source);\n try {\n const result = langOk\n ? hljs.highlight(text, { language: langOk, ignoreIllegals: true })\n : hljs.highlightAuto(text);\n renderedSources.value.set(idx, result.value);\n } catch {\n /* leave unrendered */\n }\n }\n });\n }\n\n const md = await ensureMd();\n if (myToken !== renderToken) return;\n if (md) {\n cells.value.forEach((cell, idx) => {\n if (cell.cell_type === 'markdown') {\n try {\n renderedMarkdown.value.set(idx, md.render(joinSource(cell.source)));\n } catch {\n /* leave plain */\n }\n }\n });\n }\n\n loading.value = false;\n}\n\nfunction outputText(out: any): string | null {\n if (!out) return null;\n if (out.output_type === 'stream') {\n return joinSource(out.text);\n }\n if (out.output_type === 'error') {\n return [out.ename, out.evalue, ...(out.traceback || [])]\n .filter(Boolean)\n .join('\\n');\n }\n if (out.output_type === 'execute_result' || out.output_type === 'display_data') {\n if (out.data?.['text/plain']) {\n return joinSource(out.data['text/plain']);\n }\n }\n return null;\n}\n\nfunction outputImage(out: any): string | null {\n if (!out?.data) return null;\n if (out.data['image/png']) return `data:image/png;base64,${out.data['image/png']}`;\n if (out.data['image/jpeg']) return `data:image/jpeg;base64,${out.data['image/jpeg']}`;\n if (out.data['image/svg+xml']) {\n const svg = joinSource(out.data['image/svg+xml']);\n return `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`;\n }\n return null;\n}\n\nfunction outputHtml(out: any): string | null {\n if (!out?.data) return null;\n if (out.data['text/html']) {\n const html = joinSource(out.data['text/html']);\n // Strip <script> for safety — outputs from arbitrary notebooks.\n return html.replace(/<script[\\s\\S]*?<\\/script>/gi, '');\n }\n return null;\n}\n\nonMounted(load);\nonBeforeUnmount(() => {\n renderToken++;\n});\nwatch(() => props.url, load);\n\nconst stats = computed(() => {\n const codeCount = cells.value.filter((c) => c.cell_type === 'code').length;\n const mdCount = cells.value.filter((c) => c.cell_type === 'markdown').length;\n return { code: codeCount, md: mdCount, total: cells.value.length };\n});\n\nfunction tt(key: string, fallback: string): string {\n return props.t ? props.t(key) : fallback;\n}\n</script>\n\n<template>\n <div class=\"filex-viewer-ipynb\">\n <div class=\"filex-viewer-ipynb__pane\">\n <div v-if=\"error\" class=\"filex-viewer-fallback\">\n <span class=\"filex-viewer-fallback__icon\">📓</span>\n <p>{{ error }}</p>\n </div>\n <div v-else-if=\"loading\" class=\"filex-viewer-fallback\">\n <span class=\"filex-viewer-fallback__icon\">⏳</span>\n <p>{{ tt('viewer.loading', 'Loading…') }}</p>\n </div>\n <div v-else>\n <div\n v-for=\"(cell, idx) in cells\"\n :key=\"idx\"\n class=\"filex-viewer-ipynb__cell\"\n :data-type=\"cell.cell_type\"\n >\n <template v-if=\"cell.cell_type === 'code'\">\n <div class=\"filex-viewer-ipynb__exec\">\n In [{{ cell.execution_count ?? ' ' }}]:\n </div>\n <pre class=\"filex-viewer-ipynb__src hljs\"><code\n v-if=\"renderedSources.get(idx)\"\n v-html=\"renderedSources.get(idx)\"\n /><code v-else>{{ joinSource(cell.source) }}</code></pre>\n <div v-if=\"cell.outputs && cell.outputs.length\" class=\"filex-viewer-ipynb__outputs\">\n <template v-for=\"(out, j) in cell.outputs\" :key=\"j\">\n <img\n v-if=\"outputImage(out)\"\n :src=\"outputImage(out) || ''\"\n class=\"filex-viewer-ipynb__img\"\n :alt=\"`output ${j}`\"\n />\n <div\n v-else-if=\"outputHtml(out)\"\n class=\"filex-viewer-ipynb__html\"\n v-html=\"outputHtml(out)\"\n />\n <pre\n v-else-if=\"outputText(out)\"\n class=\"filex-viewer-ipynb__out\"\n :data-type=\"out.output_type\"\n >{{ outputText(out) }}</pre>\n </template>\n </div>\n </template>\n\n <template v-else-if=\"cell.cell_type === 'markdown'\">\n <div\n v-if=\"renderedMarkdown.get(idx)\"\n class=\"filex-viewer-ipynb__md\"\n v-html=\"renderedMarkdown.get(idx)\"\n />\n <pre v-else class=\"filex-viewer-ipynb__md-raw\">{{ joinSource(cell.source) }}</pre>\n </template>\n\n <template v-else>\n <pre class=\"filex-viewer-ipynb__src\">{{ joinSource(cell.source) }}</pre>\n </template>\n </div>\n </div>\n </div>\n </div>\n</template>\n\n<style>\n/* ⚠ NOT `scoped`, deliberately. Vue's scoped styles compile to\n `.cls[data-v-HASH]`, and in the web-component build the hash baked into\n this CSS does not match the one Vue stamps onto the DOM — so every rule\n here silently stopped applying. Measured in the desktop app: the share\n dialog had `position: static`, no background and no radius, i.e. raw\n unstyled HTML, in EVERY embedded surface.\n Safe to drop: every selector below is prefixed (fx-/fe-/filex-), so\n there is nothing here that can leak into a host page. */\n.filex-viewer-ipynb {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n min-height: 70vh;\n background: var(--fe-bg, #fff);\n color: var(--fe-text, #1a1e27);\n}\n.filex-viewer-ipynb__bar {\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 8px 12px;\n background: var(--fe-bg-elev, #f7f8fa);\n border-bottom: 1px solid var(--fe-border, #e2e6ed);\n font-size: 12px;\n color: var(--fe-text-muted, #5a6475);\n}\n.filex-viewer-ipynb__lang {\n font-family: var(--fe-font-mono, monospace);\n text-transform: uppercase;\n letter-spacing: 0.04em;\n}\n.filex-viewer-ipynb__pane {\n flex: 1;\n overflow: auto;\n padding: 16px 24px;\n}\n.filex-viewer-ipynb__cell {\n border: 1px solid var(--fe-border, #e2e6ed);\n border-radius: 6px;\n margin-bottom: 16px;\n overflow: hidden;\n}\n.filex-viewer-ipynb__cell[data-type=\"code\"] {\n background: var(--fe-bg-elev, #f7f8fa);\n}\n.filex-viewer-ipynb__exec {\n padding: 4px 12px;\n font-family: var(--fe-font-mono, monospace);\n font-size: 11px;\n color: var(--fe-text-muted, #5a6475);\n background: rgba(0, 0, 0, 0.04);\n}\n.filex-viewer-ipynb__src {\n margin: 0;\n padding: 12px;\n font-family: var(--fe-font-mono, monospace);\n font-size: 12px;\n line-height: 1.5;\n white-space: pre;\n overflow-x: auto;\n}\n.filex-viewer-ipynb__outputs {\n border-top: 1px dashed var(--fe-border, #e2e6ed);\n background: var(--fe-bg, #fff);\n padding: 8px 12px;\n}\n.filex-viewer-ipynb__out {\n margin: 0;\n padding: 4px 0;\n font-family: var(--fe-font-mono, monospace);\n font-size: 12px;\n white-space: pre-wrap;\n word-wrap: break-word;\n}\n.filex-viewer-ipynb__out[data-type=\"error\"] {\n color: var(--fe-danger, #dc2626);\n}\n.filex-viewer-ipynb__img {\n display: block;\n max-width: 100%;\n height: auto;\n margin: 8px 0;\n}\n.filex-viewer-ipynb__html {\n font-size: 13px;\n}\n.filex-viewer-ipynb__md {\n padding: 12px 16px;\n font-size: 14px;\n line-height: 1.6;\n}\n.filex-viewer-ipynb__md-raw {\n padding: 12px;\n margin: 0;\n font-family: var(--fe-font-mono, monospace);\n font-size: 12px;\n white-space: pre-wrap;\n}\n.filex-viewer-fallback {\n text-align: center;\n padding: 32px;\n color: var(--fe-text-muted, #5a6475);\n}\n.filex-viewer-fallback__icon {\n font-size: 48px;\n display: block;\n margin-bottom: 12px;\n}\n</style>\n"],"names":["props","__props","cells","ref","language","error","loading","renderedSources","renderedMarkdown","renderToken","highlight","mdRenderer","ensureMd","mod","Md","joinSource","source","load","myToken","raw","fetchViewerText","_a","err","nb","_c","_b","ensureHighlight","hljs","langOk","_d","cell","idx","text","result","md","outputText","out","outputImage","svg","outputHtml","onMounted","onBeforeUnmount","watch","tt","key","fallback","_openBlock","_createElementBlock","_hoisted_1","_createElementVNode","_hoisted_2","_hoisted_3","_cache","_hoisted_4","_hoisted_5","_Fragment","_renderList","_hoisted_7","_hoisted_8","_hoisted_10","_toDisplayString","_hoisted_11","j","_hoisted_14","_hoisted_16","_hoisted_17"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,UAAMA,IAAQC,GAqBRC,IAAQC,EAAY,EAAE,GACtBC,IAAWD,EAAY,QAAQ,GAC/BE,IAAQF,EAAmB,IAAI,GAC/BG,IAAUH,EAAI,EAAI,GAClBI,IAAkBJ,EAAyB,oBAAI,KAAK,GACpDK,IAAmBL,EAAyB,oBAAI,KAAK;AAE3D,QAAIM,IAAc,GACdC,IAAiB,MACjBC,IAAkB;AAEtB,mBAAeC,IAAgC;AAC7C,UAAID,MAAe,KAAM,QAAOA,KAAc;AAC9C,UAAI;AACF,cAAME,IAAM,MAAM;AAAA;AAAA,UAA0B;AAAA,QAAA,GACtCC,IAAMD,EAAY,WAAWA;AACnC,eAAAF,IAAa,IAAIG,EAAG,EAAE,MAAM,IAAO,SAAS,IAAM,QAAQ,IAAM,GACzDH;AAAA,MACT,QAAQ;AACN,eAAAA,IAAa,IACN;AAAA,MACT;AAAA,IACF;AAEA,aAASI,EAAWC,GAAmC;AACrD,aAAO,MAAM,QAAQA,CAAM,IAAIA,EAAO,KAAK,EAAE,IAAKA,KAAU;AAAA,IAC9D;AAEA,mBAAeC,IAAsB;;AACnC,MAAAX,EAAQ,QAAQ,IAChBD,EAAM,QAAQ,MACdH,EAAM,QAAQ,CAAA,GACdK,EAAgB,4BAAY,IAAA,GAC5BC,EAAiB,4BAAY,IAAA;AAC7B,YAAMU,IAAU,EAAET;AAElB,UAAIU;AACJ,UAAI;AACF,QAAAA,IAAM,MAAMC,EAAgB;AAAA,UAC1B,KAAKpB,EAAM;AAAA,UACX,SAAU,QAAMqB,IAAArB,EAAM,gBAAN,gBAAAqB,EAAA,KAAArB,OAA0B,CAAA;AAAA,UAC1C,aAAaA,EAAM;AAAA,QAAA,CACpB;AAAA,MACH,SAASsB,GAAK;AACZ,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AK,QAAQ,UAAxCgB,KAAAC,EAmBM,OAnBNc,IAmBM;AAAA,iBAlBJf,EAAA,EAAA,GAAAC,EAiBWQ,WAjBkBzB,EAAK,SAAO,CAAvBM,GAAK0B,wBAA0BA,KAAC;AAAA,kBAExCzB,EAAYD,CAAG,UADvBW,EAKE,OAAA;AAAA;oBAHC,KAAKV,EAAYD,CAAG,KAAA;AAAA,oBACrB,OAAM;AAAA,oBACL,eAAe0B,CAAC;AAAA,kBAAA,mBAGNvB,EAAWH,CAAG,UAD3BW,EAIE,OAAA;AAAA;oBAFA,OAAM;AAAA,oBACN,WAAQR,EAAWH,CAAG;AAAA,kBAAA,mBAGXD,EAAWC,CAAG,UAD3BW,EAI4B,OAAA;AAAA;oBAF1B,OAAM;AAAA,oBACL,aAAWX,EAAI;AAAA,kBAAA,GACdwB,EAAAzB,EAAWC,CAAG,CAAA,GAAA,GAAA2B,EAAA;;;sBAKHjC,EAAK,cAAS,mBAAnCiB,EAOWQ,GAAA,EAAA,KAAA,KAAA;AAAA,cALD/C,EAAA,MAAiB,IAAIuB,CAAG,UADhCgB,EAIE,OAAA;AAAA;gBAFA,OAAM;AAAA,gBACN,WAAQvC,EAAA,MAAiB,IAAIuB,CAAG;AAAA,cAAA,oBAElCe,KAAAC,EAAkF,OAAlFiB,IAAkFJ,EAAhC7C,EAAWe,EAAK,MAAM,CAAA,GAAA,CAAA;AAAA,YAAA,WAIxEgB,KAAAC,EAAwE,OAAxEkB,IAAwEL,EAAhC7C,EAAWe,EAAK,MAAM,CAAA,GAAA,CAAA;AAAA,UAAA;;;;;;"}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { d as L, o as T, h as V, a as h, c as x, e as u, t as k, i as $, j as H, v as Y, n as q, f as c } from "./index-BWP1wNya.js";
|
|
2
|
-
import { f as z } from "./useViewerFetch-czqbd2Lj.js";
|
|
3
|
-
const F = { class: "filex-viewer-mermaid" }, K = {
|
|
4
|
-
key: 0,
|
|
5
|
-
class: "filex-viewer-fallback"
|
|
6
|
-
}, N = {
|
|
7
|
-
key: 1,
|
|
8
|
-
class: "filex-viewer-fallback"
|
|
9
|
-
}, X = /* @__PURE__ */ L({
|
|
10
|
-
__name: "MermaidViewer",
|
|
11
|
-
props: {
|
|
12
|
-
url: {},
|
|
13
|
-
mime: {},
|
|
14
|
-
ext: {},
|
|
15
|
-
t: { type: Function },
|
|
16
|
-
authHeaders: { type: Function },
|
|
17
|
-
authCredentials: {}
|
|
18
|
-
},
|
|
19
|
-
setup(M) {
|
|
20
|
-
const n = M, d = c(null), r = c(null), o = c(!0), m = c(1), v = c(0), y = c(0);
|
|
21
|
-
let w = !1, l = null, f = 0, i = null;
|
|
22
|
-
async function P() {
|
|
23
|
-
var e, t;
|
|
24
|
-
if (i) return i;
|
|
25
|
-
try {
|
|
26
|
-
const a = await import(
|
|
27
|
-
/* @vite-ignore */
|
|
28
|
-
"mermaid"
|
|
29
|
-
);
|
|
30
|
-
return i = a.default ?? a, (t = i.initialize) == null || t.call(i, {
|
|
31
|
-
startOnLoad: !1,
|
|
32
|
-
securityLevel: "strict",
|
|
33
|
-
theme: (e = window.matchMedia) != null && e.call(window, "(prefers-color-scheme: dark)").matches ? "dark" : "default"
|
|
34
|
-
}), i;
|
|
35
|
-
} catch {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
async function C() {
|
|
40
|
-
var g;
|
|
41
|
-
o.value = !0, r.value = null;
|
|
42
|
-
const e = ++f, t = await P();
|
|
43
|
-
if (e !== f) return;
|
|
44
|
-
if (!t) {
|
|
45
|
-
r.value = n.t ? n.t("viewer.peer_not_installed") : "Mermaid viewer requires `mermaid` — install or use download.", o.value = !1;
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
let a;
|
|
49
|
-
try {
|
|
50
|
-
a = await z({
|
|
51
|
-
url: n.url,
|
|
52
|
-
headers: await ((g = n.authHeaders) == null ? void 0 : g.call(n)) ?? {},
|
|
53
|
-
credentials: n.authCredentials
|
|
54
|
-
});
|
|
55
|
-
} catch (s) {
|
|
56
|
-
r.value = s instanceof Error ? s.message : "fetch failed", o.value = !1;
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
if (e === f)
|
|
60
|
-
try {
|
|
61
|
-
const s = `filex-mermaid-${Date.now()}`, { svg: E } = await t.render(s, a);
|
|
62
|
-
if (e !== f) return;
|
|
63
|
-
if (d.value) {
|
|
64
|
-
d.value.innerHTML = E;
|
|
65
|
-
const p = d.value.querySelector("svg");
|
|
66
|
-
p && (p.style.maxWidth = "100%", p.style.height = "auto");
|
|
67
|
-
}
|
|
68
|
-
} catch (s) {
|
|
69
|
-
r.value = s instanceof Error ? s.message : "render failed";
|
|
70
|
-
} finally {
|
|
71
|
-
o.value = !1;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
function D(e) {
|
|
75
|
-
if (!e.ctrlKey && !e.metaKey) return;
|
|
76
|
-
e.preventDefault();
|
|
77
|
-
const a = -e.deltaY > 0 ? 1.1 : 1 / 1.1;
|
|
78
|
-
m.value = Math.max(0.2, Math.min(8, m.value * a));
|
|
79
|
-
}
|
|
80
|
-
function S(e) {
|
|
81
|
-
var t, a;
|
|
82
|
-
w = !0, l = { x: e.clientX, y: e.clientY, tx: v.value, ty: y.value }, (a = (t = e.target).setPointerCapture) == null || a.call(t, e.pointerId);
|
|
83
|
-
}
|
|
84
|
-
function b(e) {
|
|
85
|
-
!w || !l || (v.value = l.tx + (e.clientX - l.x), y.value = l.ty + (e.clientY - l.y));
|
|
86
|
-
}
|
|
87
|
-
function _() {
|
|
88
|
-
w = !1, l = null;
|
|
89
|
-
}
|
|
90
|
-
T(C), V(() => {
|
|
91
|
-
f++;
|
|
92
|
-
});
|
|
93
|
-
function B(e, t) {
|
|
94
|
-
return n.t ? n.t(e) : t;
|
|
95
|
-
}
|
|
96
|
-
return (e, t) => (h(), x("div", F, [
|
|
97
|
-
u("div", {
|
|
98
|
-
class: "filex-viewer-mermaid__pane",
|
|
99
|
-
onWheel: D,
|
|
100
|
-
onPointerdown: S,
|
|
101
|
-
onPointermove: b,
|
|
102
|
-
onPointerup: _,
|
|
103
|
-
onPointercancel: _
|
|
104
|
-
}, [
|
|
105
|
-
r.value ? (h(), x("div", K, [
|
|
106
|
-
t[0] || (t[0] = u("span", { class: "filex-viewer-fallback__icon" }, "📊", -1)),
|
|
107
|
-
u("p", null, k(r.value), 1)
|
|
108
|
-
])) : o.value ? (h(), x("div", N, [
|
|
109
|
-
t[1] || (t[1] = u("span", { class: "filex-viewer-fallback__icon" }, "⏳", -1)),
|
|
110
|
-
u("p", null, k(B("viewer.loading", "Loading…")), 1)
|
|
111
|
-
])) : $("", !0),
|
|
112
|
-
H(u("div", {
|
|
113
|
-
ref_key: "surface",
|
|
114
|
-
ref: d,
|
|
115
|
-
class: "filex-viewer-mermaid__surface",
|
|
116
|
-
style: q({ transform: `translate(${v.value}px, ${y.value}px) scale(${m.value})` })
|
|
117
|
-
}, null, 4), [
|
|
118
|
-
[Y, !o.value && !r.value]
|
|
119
|
-
])
|
|
120
|
-
], 32)
|
|
121
|
-
]));
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
export {
|
|
125
|
-
X as default
|
|
126
|
-
};
|
|
127
|
-
//# sourceMappingURL=MermaidViewer-BdfTJ2ne.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MermaidViewer-BdfTJ2ne.js","sources":["../../core/src/viewers/MermaidViewer.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * MermaidViewer — render a `.mmd` / `.mermaid` source file.\n *\n * Lazy-imports the `mermaid` library (~150 KB gzipped). Source text is\n * fetched from `props.url` (with the auth headers from PreviewModal),\n * then rendered to SVG via `mermaid.render('id', src)`. The resulting\n * SVG node is inserted into a wrapper that supports pan + scale via\n * pure CSS transforms (no extra panzoom dep).\n */\nimport { onBeforeUnmount, onMounted, ref } from 'vue';\nimport { fetchViewerText } from '../composables/useViewerFetch';\n\nconst props = defineProps<{\n url: string;\n mime?: string;\n ext: string;\n t?: (key: string) => string;\n authHeaders?: () => Record<string, string> | Promise<Record<string, string>>;\n authCredentials?: RequestCredentials;\n}>();\n\nconst surface = ref<HTMLDivElement | null>(null);\nconst error = ref<string | null>(null);\nconst loading = ref(true);\nconst scale = ref(1);\nconst tx = ref(0);\nconst ty = ref(0);\n\nlet dragging = false;\nlet dragStart: { x: number; y: number; tx: number; ty: number } | null = null;\nlet renderToken = 0;\n\nlet cachedMermaid: any = null;\nasync function ensureMermaid(): Promise<any | null> {\n if (cachedMermaid) return cachedMermaid;\n try {\n const mod = await import(/* @vite-ignore */ 'mermaid');\n cachedMermaid = mod.default ?? mod;\n cachedMermaid.initialize?.({\n startOnLoad: false,\n securityLevel: 'strict',\n theme: window.matchMedia?.('(prefers-color-scheme: dark)').matches\n ? 'dark'\n : 'default',\n });\n return cachedMermaid;\n } catch {\n return null;\n }\n}\n\nasync function load(): Promise<void> {\n loading.value = true;\n error.value = null;\n const myToken = ++renderToken;\n\n const mermaid = await ensureMermaid();\n if (myToken !== renderToken) return;\n if (!mermaid) {\n error.value = props.t\n ? props.t('viewer.peer_not_installed')\n : 'Mermaid viewer requires `mermaid` — install or use download.';\n loading.value = false;\n return;\n }\n\n let src: string;\n try {\n src = await fetchViewerText({\n url: props.url,\n headers: (await props.authHeaders?.()) ?? {},\n credentials: props.authCredentials,\n });\n } catch (err) {\n error.value = err instanceof Error ? err.message : 'fetch failed';\n loading.value = false;\n return;\n }\n\n if (myToken !== renderToken) return;\n\n try {\n const id = `filex-mermaid-${Date.now()}`;\n const { svg } = await mermaid.render(id, src);\n if (myToken !== renderToken) return;\n if (surface.value) {\n surface.value.innerHTML = svg;\n const svgEl = surface.value.querySelector('svg');\n if (svgEl) {\n svgEl.style.maxWidth = '100%';\n svgEl.style.height = 'auto';\n }\n }\n } catch (err) {\n error.value = err instanceof Error ? err.message : 'render failed';\n } finally {\n loading.value = false;\n }\n}\n\nfunction zoomIn(): void {\n scale.value = Math.min(8, scale.value * 1.25);\n}\nfunction zoomOut(): void {\n scale.value = Math.max(0.2, scale.value / 1.25);\n}\nfunction reset(): void {\n scale.value = 1;\n tx.value = 0;\n ty.value = 0;\n}\n\nfunction onWheel(ev: WheelEvent): void {\n if (!ev.ctrlKey && !ev.metaKey) return;\n ev.preventDefault();\n const delta = -ev.deltaY;\n const factor = delta > 0 ? 1.1 : 1 / 1.1;\n scale.value = Math.max(0.2, Math.min(8, scale.value * factor));\n}\n\nfunction onPointerDown(ev: PointerEvent): void {\n dragging = true;\n dragStart = { x: ev.clientX, y: ev.clientY, tx: tx.value, ty: ty.value };\n (ev.target as HTMLElement).setPointerCapture?.(ev.pointerId);\n}\nfunction onPointerMove(ev: PointerEvent): void {\n if (!dragging || !dragStart) return;\n tx.value = dragStart.tx + (ev.clientX - dragStart.x);\n ty.value = dragStart.ty + (ev.clientY - dragStart.y);\n}\nfunction onPointerUp(): void {\n dragging = false;\n dragStart = null;\n}\n\nonMounted(load);\nonBeforeUnmount(() => {\n renderToken++;\n});\n\nfunction tt(key: string, fallback: string): string {\n return props.t ? props.t(key) : fallback;\n}\n</script>\n\n<template>\n <div class=\"filex-viewer-mermaid\">\n <div\n class=\"filex-viewer-mermaid__pane\"\n @wheel=\"onWheel\"\n @pointerdown=\"onPointerDown\"\n @pointermove=\"onPointerMove\"\n @pointerup=\"onPointerUp\"\n @pointercancel=\"onPointerUp\"\n >\n <div\n v-if=\"error\"\n class=\"filex-viewer-fallback\"\n >\n <span class=\"filex-viewer-fallback__icon\">📊</span>\n <p>{{ error }}</p>\n </div>\n <div\n v-else-if=\"loading\"\n class=\"filex-viewer-fallback\"\n >\n <span class=\"filex-viewer-fallback__icon\">⏳</span>\n <p>{{ tt('viewer.loading', 'Loading…') }}</p>\n </div>\n <div\n v-show=\"!loading && !error\"\n ref=\"surface\"\n class=\"filex-viewer-mermaid__surface\"\n :style=\"{ transform: `translate(${tx}px, ${ty}px) scale(${scale})` }\"\n />\n </div>\n </div>\n</template>\n\n<style>\n/* ⚠ NOT `scoped`, deliberately. Vue's scoped styles compile to\n `.cls[data-v-HASH]`, and in the web-component build the hash baked into\n this CSS does not match the one Vue stamps onto the DOM — so every rule\n here silently stopped applying. Measured in the desktop app: the share\n dialog had `position: static`, no background and no radius, i.e. raw\n unstyled HTML, in EVERY embedded surface.\n Safe to drop: every selector below is prefixed (fx-/fe-/filex-), so\n there is nothing here that can leak into a host page. */\n.filex-viewer-mermaid {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n min-height: 70vh;\n background: var(--fe-bg, #fff);\n color: var(--fe-text, #1a1e27);\n}\n.filex-viewer-mermaid__bar {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 8px 12px;\n background: var(--fe-bg-elev, #f7f8fa);\n border-bottom: 1px solid var(--fe-border, #e2e6ed);\n font-size: 13px;\n}\n.filex-viewer-mermaid__zoom {\n min-width: 50px;\n text-align: center;\n font-variant-numeric: tabular-nums;\n font-size: 12px;\n}\n.filex-viewer-mermaid__pane {\n flex: 1;\n overflow: hidden;\n position: relative;\n cursor: grab;\n background: var(--fe-bg-elev, #f7f8fa);\n touch-action: none;\n}\n.filex-viewer-mermaid__pane:active {\n cursor: grabbing;\n}\n.filex-viewer-mermaid__surface {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n transform-origin: center center;\n transition: transform 0.05s linear;\n user-select: none;\n}\n.filex-viewer-mermaid__surface svg {\n max-width: 90%;\n max-height: 90%;\n}\n.filex-viewer-fallback {\n text-align: center;\n padding: 32px;\n color: var(--fe-text-muted, #5a6475);\n width: 100%;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n}\n.filex-viewer-fallback__icon {\n font-size: 48px;\n display: block;\n margin-bottom: 12px;\n}\n.filex-viewer-btn {\n border: 1px solid var(--fe-border, #e2e6ed);\n background: var(--fe-bg, #fff);\n color: var(--fe-text, #1a1e27);\n padding: 4px 10px;\n border-radius: 4px;\n cursor: pointer;\n font: inherit;\n font-size: 12px;\n}\n.filex-viewer-btn:hover:not(:disabled) {\n background: var(--fe-bg-hover, #edf0f5);\n}\n</style>\n"],"names":["props","__props","surface","ref","error","loading","scale","tx","ty","dragging","dragStart","renderToken","cachedMermaid","ensureMermaid","mod","_b","_a","load","myToken","mermaid","src","fetchViewerText","err","id","svg","svgEl","onWheel","ev","factor","onPointerDown","onPointerMove","onPointerUp","onMounted","onBeforeUnmount","tt","key","fallback","_openBlock","_createElementBlock","_hoisted_1","_createElementVNode","_hoisted_2","_cache","_hoisted_3","_normalizeStyle","_vShow"],"mappings":";;;;;;;;;;;;;;;;;;;AAaA,UAAMA,IAAQC,GASRC,IAAUC,EAA2B,IAAI,GACzCC,IAAQD,EAAmB,IAAI,GAC/BE,IAAUF,EAAI,EAAI,GAClBG,IAAQH,EAAI,CAAC,GACbI,IAAKJ,EAAI,CAAC,GACVK,IAAKL,EAAI,CAAC;AAEhB,QAAIM,IAAW,IACXC,IAAqE,MACrEC,IAAc,GAEdC,IAAqB;AACzB,mBAAeC,IAAqC;;AAClD,UAAID,EAAe,QAAOA;AAC1B,UAAI;AACF,cAAME,IAAM,MAAM;AAAA;AAAA,UAA0B;AAAA,QAAA;AAC5C,eAAAF,IAAgBE,EAAI,WAAWA,IAC/BC,IAAAH,EAAc,eAAd,QAAAG,EAAA,KAAAH,GAA2B;AAAA,UACzB,aAAa;AAAA,UACb,eAAe;AAAA,UACf,QAAOI,IAAA,OAAO,eAAP,QAAAA,EAAA,aAAoB,gCAAgC,UACvD,SACA;AAAA,QAAA,IAECJ;AAAA,MACT,QAAQ;AACN,eAAO;AAAA,MACT;AAAA,IACF;AAEA,mBAAeK,IAAsB;;AACnC,MAAAZ,EAAQ,QAAQ,IAChBD,EAAM,QAAQ;AACd,YAAMc,IAAU,EAAEP,GAEZQ,IAAU,MAAMN,EAAA;AACtB,UAAIK,MAAYP,EAAa;AAC7B,UAAI,CAACQ,GAAS;AACZ,QAAAf,EAAM,QAAQJ,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AA,GAAA,CAAA;AAAA,QAAA;UAEVM,EAKE,OAAA;AAAA,mBAHI;AAAA,UAAJ,KAAItC;AAAA,UACJ,OAAM;AAAA,UACL,OAAK0C,EAAA,EAAA,WAAA,aAA4BrC,EAAA,KAAE,OAAOC,EAAA,KAAE,aAAaF,EAAA,KAAK,KAAA;AAAA,QAAA;UAHtD,CAAAuC,GAAA,CAAAxC,EAAA,UAAYD,EAAA,KAAK;AAAA,QAAA;;;;;"}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { d as B, o as E, h as S, w as A, a as m, c as p, e as i, t as x, i as I, j as V, v as L, f as o } from "./index-BWP1wNya.js";
|
|
2
|
-
import { a as T } from "./useViewerFetch-czqbd2Lj.js";
|
|
3
|
-
const F = { class: "filex-viewer-psd" }, H = { class: "filex-viewer-psd__pane" }, N = {
|
|
4
|
-
key: 0,
|
|
5
|
-
class: "filex-viewer-fallback"
|
|
6
|
-
}, j = {
|
|
7
|
-
key: 1,
|
|
8
|
-
class: "filex-viewer-fallback"
|
|
9
|
-
}, U = /* @__PURE__ */ B({
|
|
10
|
-
__name: "PsdViewer",
|
|
11
|
-
props: {
|
|
12
|
-
url: {},
|
|
13
|
-
mime: {},
|
|
14
|
-
ext: {},
|
|
15
|
-
t: { type: Function },
|
|
16
|
-
authHeaders: { type: Function },
|
|
17
|
-
authCredentials: {}
|
|
18
|
-
},
|
|
19
|
-
setup(D) {
|
|
20
|
-
const a = D, f = o(null), w = o([]), s = o(null), l = o(!0), b = o({ width: 0, height: 0 });
|
|
21
|
-
let u = 0, c = null;
|
|
22
|
-
async function C() {
|
|
23
|
-
if (c) return c;
|
|
24
|
-
try {
|
|
25
|
-
return c = await import(
|
|
26
|
-
/* @vite-ignore */
|
|
27
|
-
"./index-UFULWo35.js"
|
|
28
|
-
), c;
|
|
29
|
-
} catch {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
function g(t, e) {
|
|
34
|
-
if (t && Array.isArray(t.children))
|
|
35
|
-
for (const n of t.children)
|
|
36
|
-
e.push({
|
|
37
|
-
index: e.length,
|
|
38
|
-
name: n.name ?? "(unnamed)",
|
|
39
|
-
hidden: !!n.hidden
|
|
40
|
-
}), n.children && g(n, e);
|
|
41
|
-
}
|
|
42
|
-
async function _() {
|
|
43
|
-
var n;
|
|
44
|
-
l.value = !0, s.value = null, w.value = [];
|
|
45
|
-
const t = ++u, e = await C();
|
|
46
|
-
if (t === u) {
|
|
47
|
-
if (!e) {
|
|
48
|
-
s.value = a.t ? a.t("viewer.peer_not_installed") : "PSD viewer requires `ag-psd` — install or use download.", l.value = !1;
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
try {
|
|
52
|
-
const d = await T({
|
|
53
|
-
url: a.url,
|
|
54
|
-
headers: await ((n = a.authHeaders) == null ? void 0 : n.call(a)) ?? {},
|
|
55
|
-
credentials: a.authCredentials
|
|
56
|
-
});
|
|
57
|
-
if (t !== u) return;
|
|
58
|
-
const r = e.readPsd(d, {
|
|
59
|
-
skipLayerImageData: !1,
|
|
60
|
-
skipCompositeImageData: !1,
|
|
61
|
-
skipThumbnail: !0
|
|
62
|
-
});
|
|
63
|
-
b.value = { width: r.width, height: r.height };
|
|
64
|
-
const y = r.canvas;
|
|
65
|
-
if (y && f.value) {
|
|
66
|
-
const h = f.value;
|
|
67
|
-
h.width = r.width, h.height = r.height;
|
|
68
|
-
const v = h.getContext("2d");
|
|
69
|
-
v == null || v.drawImage(y, 0, 0);
|
|
70
|
-
} else
|
|
71
|
-
throw new Error("PSD has no composite image (skipCompositeImageData?)");
|
|
72
|
-
const k = [];
|
|
73
|
-
g(r, k), w.value = k;
|
|
74
|
-
} catch (d) {
|
|
75
|
-
s.value = d instanceof Error ? d.message : "PSD decode failed";
|
|
76
|
-
} finally {
|
|
77
|
-
l.value = !1;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
E(_), S(() => {
|
|
82
|
-
u++;
|
|
83
|
-
}), A(() => a.url, _);
|
|
84
|
-
function P(t, e) {
|
|
85
|
-
return a.t ? a.t(t) : e;
|
|
86
|
-
}
|
|
87
|
-
return (t, e) => (m(), p("div", F, [
|
|
88
|
-
i("div", H, [
|
|
89
|
-
s.value ? (m(), p("div", N, [
|
|
90
|
-
e[0] || (e[0] = i("span", { class: "filex-viewer-fallback__icon" }, "🎨", -1)),
|
|
91
|
-
i("p", null, x(s.value), 1)
|
|
92
|
-
])) : l.value ? (m(), p("div", j, [
|
|
93
|
-
e[1] || (e[1] = i("span", { class: "filex-viewer-fallback__icon" }, "⏳", -1)),
|
|
94
|
-
i("p", null, x(P("viewer.loading", "Loading…")), 1)
|
|
95
|
-
])) : I("", !0),
|
|
96
|
-
V(i("canvas", {
|
|
97
|
-
ref_key: "canvasEl",
|
|
98
|
-
ref: f
|
|
99
|
-
}, null, 512), [
|
|
100
|
-
[L, !l.value && !s.value]
|
|
101
|
-
])
|
|
102
|
-
])
|
|
103
|
-
]));
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
export {
|
|
107
|
-
U as default
|
|
108
|
-
};
|
|
109
|
-
//# sourceMappingURL=PsdViewer-C7Sknaxs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PsdViewer-C7Sknaxs.js","sources":["../../core/src/viewers/PsdViewer.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * PsdViewer — Photoshop document preview via `ag-psd`.\n *\n * Lazy-imports `ag-psd` (~150 KB). Renders the flattened composite to\n * a canvas via `psd.canvas`. A simple layer panel toggles the rendered\n * preview (V1: just lists names + visibility; full composite swap on\n * toggle requires re-rendering with `applyOpacity`/`composite` logic\n * — left as TODO for V2 since `ag-psd` doesn't ship a composite\n * pipeline of its own).\n */\nimport { onBeforeUnmount, onMounted, ref, watch } from 'vue';\nimport { fetchViewerArrayBuffer } from '../composables/useViewerFetch';\n\nconst props = defineProps<{\n url: string;\n mime?: string;\n ext: string;\n t?: (key: string) => string;\n authHeaders?: () => Record<string, string> | Promise<Record<string, string>>;\n authCredentials?: RequestCredentials;\n}>();\n\ninterface FlatLayer {\n index: number;\n name: string;\n hidden: boolean;\n}\n\nconst canvasEl = ref<HTMLCanvasElement | null>(null);\nconst layers = ref<FlatLayer[]>([]);\nconst error = ref<string | null>(null);\nconst loading = ref(true);\nconst showLayerPanel = ref(false);\nconst dims = ref<{ width: number; height: number }>({ width: 0, height: 0 });\nconst scale = ref(1);\n\nlet renderToken = 0;\n\nlet agPsd: any = null;\nasync function ensureAgPsd(): Promise<any | null> {\n if (agPsd) return agPsd;\n try {\n const mod = await import(/* @vite-ignore */ 'ag-psd');\n agPsd = mod;\n return agPsd;\n } catch {\n return null;\n }\n}\n\nfunction flattenLayers(node: any, list: FlatLayer[]): void {\n if (!node) return;\n if (Array.isArray(node.children)) {\n for (const child of node.children) {\n list.push({\n index: list.length,\n name: child.name ?? '(unnamed)',\n hidden: !!child.hidden,\n });\n if (child.children) flattenLayers(child, list);\n }\n }\n}\n\nasync function load(): Promise<void> {\n loading.value = true;\n error.value = null;\n layers.value = [];\n const myToken = ++renderToken;\n\n const lib = await ensureAgPsd();\n if (myToken !== renderToken) return;\n if (!lib) {\n error.value = props.t\n ? props.t('viewer.peer_not_installed')\n : 'PSD viewer requires `ag-psd` — install or use download.';\n loading.value = false;\n return;\n }\n\n try {\n const buf = await fetchViewerArrayBuffer({\n url: props.url,\n headers: (await props.authHeaders?.()) ?? {},\n credentials: props.authCredentials,\n });\n if (myToken !== renderToken) return;\n const psd = lib.readPsd(buf, {\n skipLayerImageData: false,\n skipCompositeImageData: false,\n skipThumbnail: true,\n });\n dims.value = { width: psd.width, height: psd.height };\n\n const composite = psd.canvas;\n if (composite && canvasEl.value) {\n const target = canvasEl.value;\n target.width = psd.width;\n target.height = psd.height;\n const ctx = target.getContext('2d');\n ctx?.drawImage(composite, 0, 0);\n } else {\n throw new Error('PSD has no composite image (skipCompositeImageData?)');\n }\n\n const flat: FlatLayer[] = [];\n flattenLayers(psd, flat);\n layers.value = flat;\n } catch (err) {\n error.value = err instanceof Error ? err.message : 'PSD decode failed';\n } finally {\n loading.value = false;\n }\n}\n\nfunction zoomIn(): void {\n scale.value = Math.min(8, scale.value * 1.25);\n}\nfunction zoomOut(): void {\n scale.value = Math.max(0.1, scale.value / 1.25);\n}\nfunction reset(): void {\n scale.value = 1;\n}\n\nonMounted(load);\nonBeforeUnmount(() => {\n renderToken++;\n});\nwatch(() => props.url, load);\n\nfunction tt(key: string, fallback: string): string {\n return props.t ? props.t(key) : fallback;\n}\n</script>\n\n<template>\n <div class=\"filex-viewer-psd\">\n <div class=\"filex-viewer-psd__pane\">\n <div v-if=\"error\" class=\"filex-viewer-fallback\">\n <span class=\"filex-viewer-fallback__icon\">🎨</span>\n <p>{{ error }}</p>\n </div>\n <div v-else-if=\"loading\" class=\"filex-viewer-fallback\">\n <span class=\"filex-viewer-fallback__icon\">⏳</span>\n <p>{{ tt('viewer.loading', 'Loading…') }}</p>\n </div>\n <canvas\n v-show=\"!loading && !error\"\n ref=\"canvasEl\"\n />\n </div>\n </div>\n</template>\n\n<style>\n/* ⚠ NOT `scoped`, deliberately. Vue's scoped styles compile to\n `.cls[data-v-HASH]`, and in the web-component build the hash baked into\n this CSS does not match the one Vue stamps onto the DOM — so every rule\n here silently stopped applying. Measured in the desktop app: the share\n dialog had `position: static`, no background and no radius, i.e. raw\n unstyled HTML, in EVERY embedded surface.\n Safe to drop: every selector below is prefixed (fx-/fe-/filex-), so\n there is nothing here that can leak into a host page. */\n.filex-viewer-psd {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n min-height: 70vh;\n background: var(--fe-bg, #fff);\n}\n.filex-viewer-psd__bar {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 8px 12px;\n background: var(--fe-bg-elev, #f7f8fa);\n border-bottom: 1px solid var(--fe-border, #e2e6ed);\n font-size: 13px;\n}\n.filex-viewer-spacer { flex: 1; }\n.filex-viewer-psd__dim {\n font-size: 12px;\n color: var(--fe-text-muted, #5a6475);\n}\n.filex-viewer-psd__zoom {\n min-width: 50px;\n text-align: center;\n font-variant-numeric: tabular-nums;\n font-size: 12px;\n}\n.filex-viewer-psd__main {\n flex: 1;\n display: flex;\n min-height: 0;\n}\n.filex-viewer-psd__layers {\n width: 240px;\n border-right: 1px solid var(--fe-border, #e2e6ed);\n overflow-y: auto;\n padding: 8px 0;\n background: var(--fe-bg-elev, #f7f8fa);\n}\n.filex-viewer-psd__layers ul {\n list-style: none;\n margin: 0;\n padding: 0;\n}\n.filex-viewer-psd__layers li {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 4px 12px;\n font-size: 12px;\n}\n.filex-viewer-psd__layer-vis {\n width: 14px;\n text-align: center;\n color: var(--fe-text-muted, #5a6475);\n}\n.filex-viewer-psd__layer-vis[data-hidden=\"1\"] { color: var(--fe-border-strong, #c7ced9); }\n.filex-viewer-psd__layer-name {\n flex: 1;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.filex-viewer-psd__pane {\n flex: 1;\n overflow: auto;\n padding: 16px;\n background: #2a2d33;\n display: flex;\n align-items: flex-start;\n justify-content: flex-start;\n}\n.filex-viewer-psd__pane canvas {\n background: #fff\n repeating-conic-gradient(#e0e0e0 0% 25%, transparent 0% 50%) 50% / 16px 16px;\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);\n}\n.filex-viewer-fallback {\n text-align: center;\n padding: 32px;\n color: #c8cdd6;\n margin: auto;\n}\n.filex-viewer-fallback__icon {\n font-size: 48px;\n display: block;\n margin-bottom: 12px;\n}\n.filex-viewer-btn {\n border: 1px solid var(--fe-border, #e2e6ed);\n background: var(--fe-bg, #fff);\n color: var(--fe-text, #1a1e27);\n padding: 4px 10px;\n border-radius: 4px;\n cursor: pointer;\n font: inherit;\n font-size: 12px;\n}\n.filex-viewer-btn:hover:not(:disabled) {\n background: var(--fe-bg-hover, #edf0f5);\n}\n.filex-viewer-btn.is-active {\n background: var(--fe-bg-selected, #dfe8ff);\n border-color: var(--fe-primary, #3b82f6);\n}\n</style>\n"],"names":["props","__props","canvasEl","ref","layers","error","loading","dims","renderToken","agPsd","ensureAgPsd","flattenLayers","node","list","child","load","myToken","lib","buf","fetchViewerArrayBuffer","_a","psd","composite","target","ctx","flat","err","onMounted","onBeforeUnmount","watch","tt","key","fallback","_openBlock","_createElementBlock","_hoisted_1","_createElementVNode","_hoisted_2","_hoisted_3","_cache","_hoisted_4","_vShow"],"mappings":";;;;;;;;;;;;;;;;;;;AAcA,UAAMA,IAAQC,GAeRC,IAAWC,EAA8B,IAAI,GAC7CC,IAASD,EAAiB,EAAE,GAC5BE,IAAQF,EAAmB,IAAI,GAC/BG,IAAUH,EAAI,EAAI,GAElBI,IAAOJ,EAAuC,EAAE,OAAO,GAAG,QAAQ,GAAG;AAG3E,QAAIK,IAAc,GAEdC,IAAa;AACjB,mBAAeC,IAAmC;AAChD,UAAID,EAAO,QAAOA;AAClB,UAAI;AAEF,eAAAA,IADY,MAAM;AAAA;AAAA,UAA0B;AAAA,QAAA,GAErCA;AAAA,MACT,QAAQ;AACN,eAAO;AAAA,MACT;AAAA,IACF;AAEA,aAASE,EAAcC,GAAWC,GAAyB;AACzD,UAAKD,KACD,MAAM,QAAQA,EAAK,QAAQ;AAC7B,mBAAWE,KAASF,EAAK;AACvB,UAAAC,EAAK,KAAK;AAAA,YACR,OAAOA,EAAK;AAAA,YACZ,MAAMC,EAAM,QAAQ;AAAA,YACpB,QAAQ,CAAC,CAACA,EAAM;AAAA,UAAA,CACjB,GACGA,EAAM,YAAUH,EAAcG,GAAOD,CAAI;AAAA,IAGnD;AAEA,mBAAeE,IAAsB;;AACnC,MAAAT,EAAQ,QAAQ,IAChBD,EAAM,QAAQ,MACdD,EAAO,QAAQ,CAAA;AACf,YAAMY,IAAU,EAAER,GAEZS,IAAM,MAAMP,EAAA;AAClB,UAAIM,MAAYR,GAChB;AAAA,YAAI,CAACS,GAAK;AACR,UAAAZ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G,IAAIC;AAAA,IAClC;sBAIEC,EAAA,GAAAC,EAeM,OAfNC,GAeM;AAAA,MAdJC,EAaM,OAbNC,GAaM;AAAA,QAZOhC,EAAA,SAAX4B,EAAA,GAAAC,EAGM,OAHNI,GAGM;AAAA,UAFJC,EAAA,CAAA,MAAAA,EAAA,CAAA,IAAAH,EAAmD,QAAA,EAA7C,OAAM,8BAAA,GAA8B,MAAE,EAAA;AAAA,UAC5CA,EAAkB,aAAZ/B,EAAA,KAAK,GAAA,CAAA;AAAA,QAAA,MAEGC,EAAA,SAAhB2B,KAAAC,EAGM,OAHNM,GAGM;AAAA,UAFJD,EAAA,CAAA,MAAAA,EAAA,CAAA,IAAAH,EAAkD,QAAA,EAA5C,OAAM,8BAAA,GAA8B,KAAC,EAAA;AAAA,UAC3CA,EAA6C,aAAvCN,EAAE,kBAAA,UAAA,CAAA,GAAA,CAAA;AAAA,QAAA;UAEVM,EAGE,UAAA;AAAA,mBADI;AAAA,UAAJ,KAAIlC;AAAA,QAAA;UADK,CAAAuC,GAAA,CAAAnC,EAAA,UAAYD,EAAA,KAAK;AAAA,QAAA;;;;;"}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { d as U, o as V, h as M, w as N, a as h, c as p, e as i, t as b, i as C, j as A, v as H, f as d, g as L } from "./index-BWP1wNya.js";
|
|
2
|
-
import { a as R } from "./useViewerFetch-czqbd2Lj.js";
|
|
3
|
-
const j = { class: "filex-viewer-tiff" }, q = { class: "filex-viewer-tiff__pane" }, G = {
|
|
4
|
-
key: 0,
|
|
5
|
-
class: "filex-viewer-fallback"
|
|
6
|
-
}, P = {
|
|
7
|
-
key: 1,
|
|
8
|
-
class: "filex-viewer-fallback"
|
|
9
|
-
}, z = {
|
|
10
|
-
key: 2,
|
|
11
|
-
class: "filex-viewer-tiff__pager"
|
|
12
|
-
}, J = ["disabled"], K = { class: "filex-viewer-tiff__pages" }, O = ["disabled"], X = /* @__PURE__ */ U({
|
|
13
|
-
__name: "TiffViewer",
|
|
14
|
-
props: {
|
|
15
|
-
url: {},
|
|
16
|
-
mime: {},
|
|
17
|
-
ext: {},
|
|
18
|
-
t: { type: Function },
|
|
19
|
-
authHeaders: { type: Function },
|
|
20
|
-
authCredentials: {}
|
|
21
|
-
},
|
|
22
|
-
setup(F) {
|
|
23
|
-
const t = F, _ = d(null), o = d(null), c = d(!0), n = d(0), r = d(0), I = d({ width: 0, height: 0 });
|
|
24
|
-
let u = null, l = null, f = 0;
|
|
25
|
-
async function B() {
|
|
26
|
-
if (u) return u;
|
|
27
|
-
try {
|
|
28
|
-
const a = await import(
|
|
29
|
-
/* @vite-ignore */
|
|
30
|
-
"./UTIF-DSbsvqXu.js"
|
|
31
|
-
).then((e) => e.U);
|
|
32
|
-
return u = a.default ?? a, u;
|
|
33
|
-
} catch {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
async function y() {
|
|
38
|
-
var v;
|
|
39
|
-
c.value = !0, o.value = null, l = null, n.value = 0, r.value = 0;
|
|
40
|
-
const a = ++f, e = await B();
|
|
41
|
-
if (a === f) {
|
|
42
|
-
if (!e) {
|
|
43
|
-
o.value = t.t ? t.t("viewer.peer_not_installed") : "TIFF viewer requires `utif` — install or use download.", c.value = !1;
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
try {
|
|
47
|
-
const s = await R({
|
|
48
|
-
url: t.url,
|
|
49
|
-
headers: await ((v = t.authHeaders) == null ? void 0 : v.call(t)) ?? {},
|
|
50
|
-
credentials: t.authCredentials
|
|
51
|
-
});
|
|
52
|
-
if (a !== f) return;
|
|
53
|
-
if (l = e.decode(s), r.value = (l == null ? void 0 : l.length) ?? 0, r.value === 0)
|
|
54
|
-
throw new Error("No pages decoded");
|
|
55
|
-
w();
|
|
56
|
-
} catch (s) {
|
|
57
|
-
o.value = s instanceof Error ? s.message : "TIFF decode failed";
|
|
58
|
-
} finally {
|
|
59
|
-
c.value = !1;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function w() {
|
|
64
|
-
if (!u || !l || !_.value) return;
|
|
65
|
-
const a = Math.max(0, Math.min(n.value, l.length - 1)), e = l[a];
|
|
66
|
-
try {
|
|
67
|
-
u.decodeImage(void 0, e);
|
|
68
|
-
} catch {
|
|
69
|
-
}
|
|
70
|
-
const v = u.toRGBA8(e), s = e.width, g = e.height;
|
|
71
|
-
I.value = { width: s, height: g };
|
|
72
|
-
const m = _.value;
|
|
73
|
-
m.width = s, m.height = g;
|
|
74
|
-
const x = m.getContext("2d");
|
|
75
|
-
if (!x) return;
|
|
76
|
-
const k = x.createImageData(s, g);
|
|
77
|
-
k.data.set(v), x.putImageData(k, 0, 0);
|
|
78
|
-
}
|
|
79
|
-
function D() {
|
|
80
|
-
n.value < r.value - 1 && (n.value++, w());
|
|
81
|
-
}
|
|
82
|
-
function T() {
|
|
83
|
-
n.value > 0 && (n.value--, w());
|
|
84
|
-
}
|
|
85
|
-
V(y), M(() => {
|
|
86
|
-
f++, l = null;
|
|
87
|
-
}), N(() => t.url, y);
|
|
88
|
-
const E = L(() => (t.t && t.t("viewer.page_n_of_m") || "Page {n} of {m}").replace("{n}", String(n.value + 1)).replace("{m}", String(r.value)));
|
|
89
|
-
function S(a, e) {
|
|
90
|
-
return t.t ? t.t(a) : e;
|
|
91
|
-
}
|
|
92
|
-
return (a, e) => (h(), p("div", j, [
|
|
93
|
-
i("div", q, [
|
|
94
|
-
o.value ? (h(), p("div", G, [
|
|
95
|
-
e[0] || (e[0] = i("span", { class: "filex-viewer-fallback__icon" }, "🖼️", -1)),
|
|
96
|
-
i("p", null, b(o.value), 1)
|
|
97
|
-
])) : c.value ? (h(), p("div", P, [
|
|
98
|
-
e[1] || (e[1] = i("span", { class: "filex-viewer-fallback__icon" }, "⏳", -1)),
|
|
99
|
-
i("p", null, b(S("viewer.loading", "Loading…")), 1)
|
|
100
|
-
])) : C("", !0),
|
|
101
|
-
A(i("canvas", {
|
|
102
|
-
ref_key: "canvasEl",
|
|
103
|
-
ref: _,
|
|
104
|
-
style: { imageRendering: "pixelated" }
|
|
105
|
-
}, null, 512), [
|
|
106
|
-
[H, !c.value && !o.value]
|
|
107
|
-
]),
|
|
108
|
-
!c.value && !o.value && r.value > 1 ? (h(), p("div", z, [
|
|
109
|
-
i("button", {
|
|
110
|
-
type: "button",
|
|
111
|
-
class: "filex-viewer-btn",
|
|
112
|
-
disabled: n.value === 0,
|
|
113
|
-
onClick: T
|
|
114
|
-
}, "‹", 8, J),
|
|
115
|
-
i("span", K, b(E.value), 1),
|
|
116
|
-
i("button", {
|
|
117
|
-
type: "button",
|
|
118
|
-
class: "filex-viewer-btn",
|
|
119
|
-
disabled: n.value >= r.value - 1,
|
|
120
|
-
onClick: D
|
|
121
|
-
}, "›", 8, O)
|
|
122
|
-
])) : C("", !0)
|
|
123
|
-
])
|
|
124
|
-
]));
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
export {
|
|
128
|
-
X as default
|
|
129
|
-
};
|
|
130
|
-
//# sourceMappingURL=TiffViewer-C4gmMB4q.js.map
|