@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.
Files changed (46) hide show
  1. package/README.md +47 -8
  2. package/dist/ArchiveViewer-K5qK0zfS.js +123 -0
  3. package/dist/ArchiveViewer-K5qK0zfS.js.map +1 -0
  4. package/dist/CsvViewer-Bac6RzAt.js +140 -0
  5. package/dist/CsvViewer-Bac6RzAt.js.map +1 -0
  6. package/dist/{DrawioViewer-Dp8cxp-x.js → DrawioViewer-CWjYMKPU.js} +52 -47
  7. package/dist/DrawioViewer-CWjYMKPU.js.map +1 -0
  8. package/dist/EpubViewer-CIk5aFlK.js +160 -0
  9. package/dist/EpubViewer-CIk5aFlK.js.map +1 -0
  10. package/dist/IpynbViewer-Zns7tk61.js +180 -0
  11. package/dist/IpynbViewer-Zns7tk61.js.map +1 -0
  12. package/dist/MermaidViewer-VsEYlFWq.js +136 -0
  13. package/dist/MermaidViewer-VsEYlFWq.js.map +1 -0
  14. package/dist/PsdViewer-BUVVVD90.js +118 -0
  15. package/dist/PsdViewer-BUVVVD90.js.map +1 -0
  16. package/dist/TiffViewer-5AjGk4zd.js +139 -0
  17. package/dist/TiffViewer-5AjGk4zd.js.map +1 -0
  18. package/dist/Viewer3D-CAZ50vDp.js +74 -0
  19. package/dist/Viewer3D-CAZ50vDp.js.map +1 -0
  20. package/dist/filex.js +1 -1
  21. package/dist/filex.umd.cjs +91 -92
  22. package/dist/filex.umd.cjs.map +1 -1
  23. package/dist/index-DiSDAgAg.js +35167 -0
  24. package/dist/index-DiSDAgAg.js.map +1 -0
  25. package/dist/index.d.ts +1 -0
  26. package/dist/style.css +1 -1
  27. package/package.json +4 -4
  28. package/dist/ArchiveViewer-C1FprACN.js +0 -99
  29. package/dist/ArchiveViewer-C1FprACN.js.map +0 -1
  30. package/dist/CsvViewer-bn2id_EW.js +0 -131
  31. package/dist/CsvViewer-bn2id_EW.js.map +0 -1
  32. package/dist/DrawioViewer-Dp8cxp-x.js.map +0 -1
  33. package/dist/EpubViewer-CYapMdP6.js +0 -143
  34. package/dist/EpubViewer-CYapMdP6.js.map +0 -1
  35. package/dist/IpynbViewer-SjHOXBkc.js +0 -171
  36. package/dist/IpynbViewer-SjHOXBkc.js.map +0 -1
  37. package/dist/MermaidViewer-BdfTJ2ne.js +0 -127
  38. package/dist/MermaidViewer-BdfTJ2ne.js.map +0 -1
  39. package/dist/PsdViewer-C7Sknaxs.js +0 -109
  40. package/dist/PsdViewer-C7Sknaxs.js.map +0 -1
  41. package/dist/TiffViewer-C4gmMB4q.js +0 -130
  42. package/dist/TiffViewer-C4gmMB4q.js.map +0 -1
  43. package/dist/Viewer3D-BdxyRN7v.js +0 -60
  44. package/dist/Viewer3D-BdxyRN7v.js.map +0 -1
  45. package/dist/index-BWP1wNya.js +0 -25361
  46. package/dist/index-BWP1wNya.js.map +0 -1
package/README.md CHANGED
@@ -27,6 +27,28 @@ import '@brftech/filex';
27
27
  <script type="module" src="https://cdn.jsdelivr.net/npm/@brftech/filex/dist/filex.js"></script>
28
28
  ```
29
29
 
30
+ ## Styles
31
+
32
+ **No CSS import, no `<link>`.** The bundle carries the explorer's stylesheet
33
+ inside the JavaScript and appends it to `<head>` once, the first time an
34
+ element mounts — so the two lines above are all a page needs, whether they
35
+ come from a CDN or a bundler. It is `@brftech/filex-core`'s sheet byte for
36
+ byte, which is what keeps this distribution and the Vue one looking the same.
37
+
38
+ A `style.css` is published as well, for a host that would rather serve the
39
+ sheet itself:
40
+
41
+ ```html
42
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@brftech/filex/dist/style.css">
43
+ ```
44
+
45
+ The look is the `--fe-*` custom properties; set them on any scope above the
46
+ element (`:root`, a wrapper div) and the explorer follows. The element
47
+ deliberately has **no shadow root** for exactly this reason — the host page's
48
+ tokens, dark mode and fonts reach inside. The consequence is that a host
49
+ cannot fill a slot in it either, so the product mark in the top bar comes from
50
+ `config.brand` (`{ name, markUrl }`).
51
+
30
52
  ## Use
31
53
 
32
54
  ### Plain HTML
@@ -39,14 +61,19 @@ import '@brftech/filex';
39
61
  ></filex-explorer>
40
62
 
41
63
  <script type="module">
42
- import '@brftech/filex';
43
64
  const el = document.querySelector('filex-explorer');
65
+ // ⚠ Configure BEFORE the element is registered. A static `import` would be
66
+ // hoisted above these lines, mount the explorer with no credentials and
67
+ // spend its first listing on a request that can only fail.
44
68
  el.config = {
69
+ apiBase: 'https://files.example.com',
45
70
  auth: { kind: 'bearer', token: '<jwt>' },
46
71
  rootPath: 'main://projects/acme',
47
72
  };
48
- el.addEventListener('error', (e) => console.error(e.detail));
49
- el.addEventListener('share-created', (e) => navigator.clipboard.writeText(e.detail.url));
73
+ // ⚠ The payload is e.detail[0] — see Events below.
74
+ el.addEventListener('error', (e) => console.error(e.detail[0].message));
75
+ el.addEventListener('share-created', (e) => navigator.clipboard.writeText(e.detail[0].url));
76
+ await import('@brftech/filex'); // registers <filex-explorer>
50
77
  </script>
51
78
  ```
52
79
 
@@ -102,9 +129,9 @@ Simple attributes are auto-parsed into the underlying `config` prop:
102
129
  | `locale` | `config.locale` (`tr` / `en`) |
103
130
  | `theme` | `config.theme` (`light` / `dark` / `auto`) |
104
131
  | `trash-visible` | `config.trashVisible` |
105
- | `sidenav` | `config.sideNav` — the navigation panel (Upload · Recent / Starred / Shared with me / Trash · storages). Present or `="true"` is on, `="false"` off; absent keeps the default, which is on. |
132
+ | `sidenav` | `config.sideNav` — the navigation panel (the "+ New" menu · Home / Shared with me / Recent / Starred / Trash · the tags in use · the storages this caller can reach). Present or `="true"` is on, `="false"` off; absent keeps the default, which is on. |
106
133
  | `connections` | `config.connections` — the panel's "How to connect" and "API keys" entries. Default on, except under `ui-profile="simple"` where it is off. ⚠ "API keys" is additionally dropped when the caller is an **app** token — see `config.callerKind` below. |
107
- | `ui-profile` | `config.uiProfile` — `"standard"` (default), `"simple"` (one pane, list/grid only, no tab strip, no split pane) or `"drive"` (that, plus the Drive-shaped shell: a "+ New" menu, one header search field with its ⌘K palette hint, a Type/Modified/Size filter row, Folders/Files sections in grid, Details/Activity in the info panel, and a storage line). |
134
+ | `ui-profile` | `config.uiProfile` — `"standard"` (default) or `"simple"` (one pane, list/grid only, no tab strip, no split pane, "How to connect"/"API keys" off). Two values, no third: any other string resolves to `"standard"` and logs one console line naming it, so the `"drive"` profile that was **removed** after v0.40.0 no longer reduces anything — pass `"simple"` instead. ⚠⚠ It does **not** decide the look: the "+ New" menu, the one wide header search field with its ⌘K chip, the Type/People/Modified/Size filter row, the Folders/Files sections in grid (replaced by date headings while sorted by Modified), Details/Activity in the info panel and the storage line are what every embed draws now, with no string passed. |
108
135
 
109
136
  For anything richer (auth, custom endpoints, share base, …) set the
110
137
  `config` JS property after element creation. Properties merge on top
@@ -123,10 +150,14 @@ case — see
123
150
 
124
151
  ## Events
125
152
 
126
- Native `CustomEvent`s — listen with `addEventListener`. The original
127
- SFC payload is on `event.detail`.
153
+ Native `CustomEvent`s — listen with `addEventListener`. ⚠ **The SFC payload is
154
+ `event.detail[0]`, not `event.detail`**: Vue dispatches a custom element's emit
155
+ as `new CustomEvent(name, { detail: args })`, where `args` is the emit's
156
+ argument list. `event.detail.url` is therefore `undefined`, and for
157
+ `selection-change` — whose payload is itself an array — `event.detail.length`
158
+ is always `1`.
128
159
 
129
- | Event | Detail shape |
160
+ | Event | Payload — `event.detail[0]` |
130
161
  |---|---|
131
162
  | `error` | `{ message, context? }` |
132
163
  | `share-created` | `{ path, url, pin }` |
@@ -140,6 +171,14 @@ SFC payload is on `event.detail`.
140
171
  pnpm build # vue-tsc + vite lib build → dist/filex.js + dist/style.css
141
172
  ```
142
173
 
174
+ > ⚠⚠ `sideEffects` in `package.json` has to keep matching **every** file the
175
+ > build emits (`./dist/*.js`, `./dist/*.cjs`), not a list of names. The entry
176
+ > is only a re-export: `customElements.define` and the stylesheet injection
177
+ > live in the hashed chunk beside it, and a list that does not cover the chunk
178
+ > lets a bundler drop it — the element is then never registered, the sheet
179
+ > never injected, and a React or Vite host renders an empty page with no error
180
+ > anywhere. `web/tests/deploy/packageLook.test.ts` is the guard.
181
+
143
182
  ## License
144
183
 
145
184
  MIT
@@ -0,0 +1,123 @@
1
+ import { d as b, o as g, w as L, a as l, c as o, e as i, t as r, u as H, f as M, F as z, m as B, q as C, g as v, h, i as x } from "./index-DiSDAgAg.js";
2
+ const F = { class: "filex-viewer-archive" }, S = {
3
+ key: 0,
4
+ class: "filex-viewer-fallback"
5
+ }, $ = ["innerHTML"], P = {
6
+ key: 1,
7
+ class: "filex-viewer-fallback"
8
+ }, N = ["innerHTML"], E = {
9
+ key: 2,
10
+ class: "filex-viewer-fallback"
11
+ }, I = ["innerHTML"], O = {
12
+ key: 3,
13
+ class: "filex-viewer-archive__pane"
14
+ }, V = { class: "filex-viewer-archive__summary" }, j = { class: "filex-viewer-archive__table" }, A = { class: "filex-viewer-archive__size" }, U = ["data-dir"], q = ["innerHTML"], D = { class: "filex-viewer-archive__size" }, J = /* @__PURE__ */ b({
15
+ __name: "ArchiveViewer",
16
+ props: {
17
+ url: {},
18
+ filePath: {},
19
+ ext: {},
20
+ t: { type: Function },
21
+ authHeaders: { type: Function },
22
+ authCredentials: {},
23
+ archiveListUrl: {}
24
+ },
25
+ setup(m) {
26
+ const t = m, c = v([]), d = v(!0), u = v(null);
27
+ function s(e, a, n) {
28
+ return t.t ? t.t(e, n) : a;
29
+ }
30
+ function _(e) {
31
+ return e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} KB` : e < 1024 * 1024 * 1024 ? `${(e / (1024 * 1024)).toFixed(1)} MB` : `${(e / (1024 * 1024 * 1024)).toFixed(2)} GB`;
32
+ }
33
+ async function f() {
34
+ if (d.value = !0, u.value = null, c.value = [], !t.filePath) {
35
+ u.value = s("viewer.archive.error", "Could not read archive contents."), d.value = !1;
36
+ return;
37
+ }
38
+ try {
39
+ const e = await fetch(t.archiveListUrl || "/api/files/archive/list", {
40
+ method: "POST",
41
+ credentials: t.authCredentials || "same-origin",
42
+ headers: {
43
+ "Content-Type": "application/json",
44
+ ...t.authHeaders ? await t.authHeaders() : {}
45
+ },
46
+ body: JSON.stringify({ path: t.filePath })
47
+ });
48
+ if (!e.ok)
49
+ throw new Error(`${e.status} ${e.statusText}`);
50
+ const a = await e.json();
51
+ c.value = a.entries ?? [];
52
+ } catch (e) {
53
+ u.value = e instanceof Error ? e.message : s("viewer.archive.error", "Could not read archive contents.");
54
+ } finally {
55
+ d.value = !1;
56
+ }
57
+ }
58
+ g(f), L(() => t.filePath, f);
59
+ const y = h(() => c.value.reduce((e, a) => e + (a.size || 0), 0)), p = h(() => c.value.filter((e) => !e.is_dir).length), w = h(() => x({ type: "file", extension: t.ext }));
60
+ function k(e) {
61
+ const a = e.name || "", n = a.lastIndexOf(".");
62
+ return x({
63
+ type: e.is_dir ? "dir" : "file",
64
+ extension: n > 0 ? a.slice(n + 1) : "",
65
+ basename: a
66
+ });
67
+ }
68
+ return (e, a) => (l(), o("div", F, [
69
+ u.value ? (l(), o("div", S, [
70
+ i("span", {
71
+ class: "filex-viewer-fallback__icon",
72
+ "aria-hidden": "true",
73
+ innerHTML: w.value
74
+ }, null, 8, $),
75
+ i("p", null, r(u.value), 1)
76
+ ])) : d.value ? (l(), o("div", P, [
77
+ i("span", {
78
+ class: "filex-viewer-fallback__icon filex-viewer-fallback__icon--spin",
79
+ "aria-hidden": "true",
80
+ innerHTML: H(M)("progress")
81
+ }, null, 8, N),
82
+ i("p", null, r(s("viewer.loading", "Loading…")), 1)
83
+ ])) : c.value.length === 0 ? (l(), o("div", E, [
84
+ i("span", {
85
+ class: "filex-viewer-fallback__icon",
86
+ "aria-hidden": "true",
87
+ innerHTML: w.value
88
+ }, null, 8, I),
89
+ i("p", null, r(s("viewer.archive.empty", "Archive is empty.")), 1)
90
+ ])) : (l(), o("div", O, [
91
+ i("div", V, r(s("viewer.archive.entries", `${p.value} files`, { n: p.value })) + " · " + r(_(y.value)), 1),
92
+ i("table", j, [
93
+ i("thead", null, [
94
+ i("tr", null, [
95
+ i("th", null, r(s("viewer.name", "Name")), 1),
96
+ i("th", A, r(s("viewer.size", "Size")), 1)
97
+ ])
98
+ ]),
99
+ i("tbody", null, [
100
+ (l(!0), o(z, null, B(c.value, (n, T) => (l(), o("tr", {
101
+ key: T,
102
+ "data-dir": n.is_dir ? "1" : "0"
103
+ }, [
104
+ i("td", null, [
105
+ i("span", {
106
+ class: "filex-viewer-archive__icon",
107
+ "aria-hidden": "true",
108
+ innerHTML: k(n)
109
+ }, null, 8, q),
110
+ C(" " + r(n.name), 1)
111
+ ]),
112
+ i("td", D, r(n.is_dir ? "" : _(n.size)), 1)
113
+ ], 8, U))), 128))
114
+ ])
115
+ ])
116
+ ]))
117
+ ]));
118
+ }
119
+ });
120
+ export {
121
+ J as default
122
+ };
123
+ //# sourceMappingURL=ArchiveViewer-K5qK0zfS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArchiveViewer-K5qK0zfS.js","sources":["../../core/src/viewers/ArchiveViewer.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * ArchiveViewer — minimal zip / archive contents preview.\n *\n * Hits the configured archive-list endpoint (`archiveListUrl`, default\n * `POST /api/files/archive/list`) with the adapter-qualified path\n * and renders the member list as a flat table (name, size, mtime).\n * Read-only — extraction is exposed elsewhere (context menu / actions\n * panel). The viewer's job is just \"what's inside?\" so the user can\n * decide whether to extract or download.\n */\nimport { computed, onMounted, ref, watch } from 'vue';\nimport { actionIconSvg } from '../lib/actionIcons'; /* ikon:emoji */\nimport { fileIconTile } from '../lib/fileIcons'; /* ikon:emoji */\n\ninterface ArchiveEntry {\n name: string;\n size: number;\n mtime?: string;\n is_dir?: boolean;\n}\n\nconst props = defineProps<{\n url: string;\n filePath?: string;\n ext: string;\n t?: (key: string, vars?: Record<string, string | number>) => string;\n authHeaders?: () => Record<string, string> | Promise<Record<string, string>>;\n authCredentials?: RequestCredentials;\n /** ⚠ Where to ask. This used to be the literal '/api/files/archive/list',\n * which is the ONE thing an embed cannot assume: with `apiBase` pointing at\n * another origin the request went to the host page instead and 404'd, while\n * every other call in the package honoured the configured base. The default\n * keeps a same-origin install working unchanged. */\n archiveListUrl?: string;\n}>();\n\nconst entries = ref<ArchiveEntry[]>([]);\nconst loading = ref(true);\nconst error = ref<string | null>(null);\n\n/** ⚠ `vars` go THROUGH `t()`, not into a `.replace()` afterwards: `t()` is what\n * picks the singular (`viewer.archive.entries_one`) from the count, and it can\n * only do that if it is told the count. Same shape CsvViewer's helper has. */\nfunction tt(key: string, fallback: string, vars?: Record<string, string | number>): string {\n return props.t ? props.t(key, vars) : fallback;\n}\n\nfunction fmtSize(n: number): string {\n if (n < 1024) return `${n} B`;\n if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`;\n if (n < 1024 * 1024 * 1024) return `${(n / (1024 * 1024)).toFixed(1)} MB`;\n return `${(n / (1024 * 1024 * 1024)).toFixed(2)} GB`;\n}\n\nasync function load(): Promise<void> {\n loading.value = true;\n error.value = null;\n entries.value = [];\n // The viewer is mounted with the resolved file path. Hit the API\n // endpoint with the same adapter-qualified path the preview URL\n // points at — the backend resolves storage + relative path itself.\n if (!props.filePath) {\n error.value = tt('viewer.archive.error', 'Could not read archive contents.');\n loading.value = false;\n return;\n }\n try {\n const res = await fetch(props.archiveListUrl || '/api/files/archive/list', {\n method: 'POST',\n credentials: props.authCredentials || 'same-origin',\n headers: {\n 'Content-Type': 'application/json',\n ...(props.authHeaders ? await props.authHeaders() : {}),\n },\n body: JSON.stringify({ path: props.filePath }),\n });\n if (!res.ok) {\n throw new Error(`${res.status} ${res.statusText}`);\n }\n const body = (await res.json()) as { entries?: ArchiveEntry[] };\n entries.value = body.entries ?? [];\n } catch (err) {\n error.value = err instanceof Error ? err.message : tt('viewer.archive.error', 'Could not read archive contents.');\n } finally {\n loading.value = false;\n }\n}\n\nonMounted(load);\nwatch(() => props.filePath, load);\n\nconst totalSize = computed(() => entries.value.reduce((sum, e) => sum + (e.size || 0), 0));\nconst fileCount = computed(() => entries.value.filter((e) => !e.is_dir).length);\n\n/* === ikon:emoji — the fallback screen's mark ==========================\n * Every viewer opened its \"cannot show this\" / \"still loading\" screen with a\n * 48px colour emoji, one per format, each from whatever emoji font the OS\n * shipped. The format mark is `lib/fileIcons`'s tile — the SAME tile the row\n * the person just clicked is wearing, so the fallback is recognisably about\n * that file — and \"loading\" is the stroked ring, spun by CSS, because no\n * still picture can say \"still going\". */\nconst typeTile = computed(() => fileIconTile({ type: 'file', extension: props.ext }));\n\n/** A row inside the archive, drawn the way the listing draws the same kind. */\nfunction entryTile(e: ArchiveEntry): string {\n const name = e.name || '';\n const dot = name.lastIndexOf('.');\n return fileIconTile({\n type: e.is_dir ? 'dir' : 'file',\n extension: dot > 0 ? name.slice(dot + 1) : '',\n basename: name,\n });\n}\n</script>\n\n<template>\n <div class=\"filex-viewer-archive\">\n <div v-if=\"error\" class=\"filex-viewer-fallback\">\n <!-- eslint-disable-next-line vue/no-v-html -- static markup from lib/fileIcons + lib/actionIcons -->\n <span class=\"filex-viewer-fallback__icon\" aria-hidden=\"true\" v-html=\"typeTile\"></span>\n <p>{{ error }}</p>\n </div>\n <div v-else-if=\"loading\" class=\"filex-viewer-fallback\">\n <!-- eslint-disable-next-line vue/no-v-html -- static markup from lib/fileIcons + lib/actionIcons -->\n <span\n class=\"filex-viewer-fallback__icon filex-viewer-fallback__icon--spin\"\n aria-hidden=\"true\"\n v-html=\"actionIconSvg('progress')\"\n ></span>\n <p>{{ tt('viewer.loading', 'Loading…') }}</p>\n </div>\n <div v-else-if=\"entries.length === 0\" class=\"filex-viewer-fallback\">\n <!-- eslint-disable-next-line vue/no-v-html -- static markup from lib/fileIcons + lib/actionIcons -->\n <span class=\"filex-viewer-fallback__icon\" aria-hidden=\"true\" v-html=\"typeTile\"></span>\n <p>{{ tt('viewer.archive.empty', 'Archive is empty.') }}</p>\n </div>\n <div v-else class=\"filex-viewer-archive__pane\">\n <div class=\"filex-viewer-archive__summary\">\n <!-- ⚠ The count is IN the message (\"{n} files\"). A `{{ fileCount }}`\n printed in front of it read \"3 3 files\". -->\n {{ tt('viewer.archive.entries', `${fileCount} files`, { n: fileCount }) }}\n · {{ fmtSize(totalSize) }}\n </div>\n <table class=\"filex-viewer-archive__table\">\n <thead>\n <tr>\n <th>{{ tt('viewer.name', 'Name') }}</th>\n <th class=\"filex-viewer-archive__size\">{{ tt('viewer.size', 'Size') }}</th>\n </tr>\n </thead>\n <tbody>\n <tr v-for=\"(e, i) in entries\" :key=\"i\" :data-dir=\"e.is_dir ? '1' : '0'\">\n <td>\n <!-- ikon:emoji — the same tile the listing draws for the same\n kind of file, so an archive's contents and the folder it\n came from read as one product. -->\n <!-- eslint-disable-next-line vue/no-v-html -- static markup from lib/fileIcons -->\n <span class=\"filex-viewer-archive__icon\" aria-hidden=\"true\" v-html=\"entryTile(e)\"></span>\n {{ e.name }}\n </td>\n <td class=\"filex-viewer-archive__size\">{{ e.is_dir ? '' : fmtSize(e.size) }}</td>\n </tr>\n </tbody>\n </table>\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-archive {\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-archive__pane {\n flex: 1;\n overflow: auto;\n padding: 16px 20px;\n}\n.filex-viewer-archive__summary {\n font-size: 12px;\n color: var(--fe-text-muted, #5a6475);\n margin-bottom: 12px;\n font-variant-numeric: tabular-nums;\n}\n.filex-viewer-archive__table {\n width: 100%;\n border-collapse: collapse;\n font-size: 13px;\n font-family: var(--fe-font-mono, monospace);\n}\n.filex-viewer-archive__table th,\n.filex-viewer-archive__table td {\n padding: 6px 12px;\n border-bottom: 1px solid var(--fe-border, #e2e6ed);\n text-align: left;\n}\n.filex-viewer-archive__table th {\n background: var(--fe-bg-elev, #f7f8fa);\n font-weight: 600;\n position: sticky;\n top: 0;\n}\n.filex-viewer-archive__size {\n text-align: right;\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n color: var(--fe-text-muted, #5a6475);\n}\n.filex-viewer-archive__icon {\n margin-right: 6px;\n}\n.filex-viewer-archive__table tr[data-dir=\"1\"] {\n color: var(--fe-text-muted, #5a6475);\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","entries","ref","loading","error","tt","key","fallback","vars","fmtSize","n","load","res","body","err","onMounted","watch","totalSize","computed","sum","e","fileCount","typeTile","fileIconTile","entryTile","name","dot","_openBlock","_createElementBlock","_hoisted_1","_hoisted_2","_createElementVNode","_hoisted_4","_unref","actionIconSvg","_hoisted_6","_hoisted_8","_hoisted_9","_toDisplayString","_hoisted_10","_hoisted_11","_Fragment","_renderList","i","_hoisted_14"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,UAAMA,IAAQC,GAeRC,IAAUC,EAAoB,EAAE,GAChCC,IAAUD,EAAI,EAAI,GAClBE,IAAQF,EAAmB,IAAI;AAKrC,aAASG,EAAGC,GAAaC,GAAkBC,GAAgD;AACzF,aAAOT,EAAM,IAAIA,EAAM,EAAEO,GAAKE,CAAI,IAAID;AAAA,IACxC;AAEA,aAASE,EAAQC,GAAmB;AAClC,aAAIA,IAAI,OAAa,GAAGA,CAAC,OACrBA,IAAI,OAAO,OAAa,IAAIA,IAAI,MAAM,QAAQ,CAAC,CAAC,QAChDA,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0BAAA,GAA8BgB,EAAA,KAAS,UAAA,EAAA,GAAeA,EAAA,MAAA,CAAS,CAAA,IAAM,QACxEiB,EAAG7B,EAAQQ,EAAA,KAAS,CAAA,GAAA,CAAA;AAAA,QAExBc,EAoBQ,SApBRQ,GAoBQ;AAAA,UAnBNR,EAKQ,SAAA,MAAA;AAAA,YAJNA,EAGK,MAAA,MAAA;AAAA,cAFHA,EAAwC,cAAjC1B,EAAE,eAAA,MAAA,CAAA,GAAA,CAAA;AAAA,cACT0B,EAA2E,MAA3ES,GAA2EF,EAAjCjC,EAAE,eAAA,MAAA,CAAA,GAAA,CAAA;AAAA,YAAA;;UAGhD0B,EAYQ,SAAA,MAAA;AAAA,aAXNJ,EAAA,EAAA,GAAAC,EAUKa,GAAA,MAAAC,EAVgBzC,EAAA,OAAO,CAAhBmB,GAAGuB,YAAff,EAUK,MAAA;AAAA,cAV0B,KAAKe;AAAA,cAAI,YAAUvB,EAAE,SAAM,MAAA;AAAA,YAAA;cACxDW,EAOK,MAAA,MAAA;AAAA,gBAFHA,EAAyF,QAAA;AAAA,kBAAnF,OAAM;AAAA,kBAA6B,eAAY;AAAA,kBAAO,WAAQP,EAAUJ,CAAC;AAAA,gBAAA;kBAAU,MACzFkB,EAAGlB,EAAE,IAAI,GAAA,CAAA;AAAA,cAAA;cAEXW,EAAiF,MAAjFa,GAAiFN,EAAvClB,EAAE,SAAM,KAAQX,EAAQW,EAAE,IAAI,CAAA,GAAA,CAAA;AAAA,YAAA;;;;;;;"}
@@ -0,0 +1,140 @@
1
+ import { d as S, o as N, w as b, a as n, c as r, e as a, t as v, u as W, f as j, F as k, m as L, k as q, g as d, h as f, i as A } from "./index-DiSDAgAg.js";
2
+ import { f as G } from "./useViewerFetch-czqbd2Lj.js";
3
+ const O = { class: "filex-viewer-csv" }, Z = { class: "filex-viewer-csv__pane" }, z = {
4
+ key: 0,
5
+ class: "filex-viewer-fallback"
6
+ }, J = ["innerHTML"], K = {
7
+ key: 1,
8
+ class: "filex-viewer-fallback"
9
+ }, Q = ["innerHTML"], U = {
10
+ key: 2,
11
+ class: "filex-viewer-csv__table"
12
+ }, X = { class: "filex-viewer-csv__rownum" }, Y = {
13
+ key: 0,
14
+ class: "filex-viewer-csv__pager"
15
+ }, ee = ["disabled"], te = { class: "filex-viewer-csv__pageno" }, le = ["disabled"], C = 100, D = 1e3, ne = /* @__PURE__ */ S({
16
+ __name: "CsvViewer",
17
+ props: {
18
+ url: {},
19
+ ext: {},
20
+ t: { type: Function },
21
+ authHeaders: { type: Function },
22
+ authCredentials: {}
23
+ },
24
+ setup(F) {
25
+ const i = F, u = d([]), _ = d(null), h = d(!0), T = d(!0), M = d(""), o = d(1), m = d(","), w = d("auto");
26
+ let H = 0;
27
+ function P(l) {
28
+ const e = l.split(/\r?\n/).slice(0, 5).join(`
29
+ `), t = (e.match(/\t/g) || []).length, s = (e.match(/;/g) || []).length, c = (e.match(/,/g) || []).length;
30
+ return t > c && t > s ? " " : s > c && s > t ? ";" : ",";
31
+ }
32
+ async function R(l, e) {
33
+ try {
34
+ const t = await import(
35
+ /* @vite-ignore */
36
+ "./papaparse.min-VB1HBwYX.js"
37
+ ).then((y) => y.p);
38
+ return (t.default ?? t).parse(l, {
39
+ delimiter: e,
40
+ skipEmptyLines: !0,
41
+ header: !1
42
+ }).data.slice(0, D);
43
+ } catch {
44
+ return l.split(/\r?\n/).filter((t) => t.length > 0).slice(0, D).map((t) => t.split(e));
45
+ }
46
+ }
47
+ async function g() {
48
+ var s;
49
+ h.value = !0, _.value = null, u.value = [], o.value = 1;
50
+ const l = ++H;
51
+ let e;
52
+ try {
53
+ e = await G({
54
+ url: i.url,
55
+ headers: await ((s = i.authHeaders) == null ? void 0 : s.call(i)) ?? {},
56
+ credentials: i.authCredentials
57
+ });
58
+ } catch (c) {
59
+ _.value = c instanceof Error ? c.message : "fetch failed", h.value = !1;
60
+ return;
61
+ }
62
+ if (l !== H) return;
63
+ i.ext === "tsv" ? m.value = " " : m.value = P(e.slice(0, 4096));
64
+ const t = w.value === "auto" ? m.value : w.value;
65
+ u.value = await R(e, t), h.value = !1;
66
+ }
67
+ N(g), b(() => i.url, g), b(() => w.value, () => {
68
+ u.value.length !== 0 && g();
69
+ });
70
+ const V = f(() => !T.value || u.value.length === 0 ? u.value.length === 0 ? [] : u.value[0].map((l, e) => `Col ${e + 1}`) : u.value[0]), E = f(() => T.value ? u.value.slice(1) : u.value), p = f(() => {
71
+ const l = M.value.trim().toLowerCase();
72
+ return l ? E.value.filter(
73
+ (e) => e.some((t) => (t || "").toLowerCase().includes(l))
74
+ ) : E.value;
75
+ }), x = f(
76
+ () => Math.max(1, Math.ceil(p.value.length / C))
77
+ ), $ = f(() => {
78
+ const l = (o.value - 1) * C;
79
+ return p.value.slice(l, l + C);
80
+ });
81
+ b(M, () => {
82
+ o.value = 1;
83
+ });
84
+ function I(l, e, t) {
85
+ return i.t ? i.t(l, t) : e;
86
+ }
87
+ const B = f(() => A({ type: "file", extension: i.ext }));
88
+ return (l, e) => (n(), r("div", O, [
89
+ a("div", Z, [
90
+ _.value ? (n(), r("div", z, [
91
+ a("span", {
92
+ class: "filex-viewer-fallback__icon",
93
+ "aria-hidden": "true",
94
+ innerHTML: B.value
95
+ }, null, 8, J),
96
+ a("p", null, v(_.value), 1)
97
+ ])) : h.value ? (n(), r("div", K, [
98
+ a("span", {
99
+ class: "filex-viewer-fallback__icon filex-viewer-fallback__icon--spin",
100
+ "aria-hidden": "true",
101
+ innerHTML: W(j)("progress")
102
+ }, null, 8, Q),
103
+ a("p", null, v(I("viewer.loading", "Loading…")), 1)
104
+ ])) : (n(), r("table", U, [
105
+ a("thead", null, [
106
+ a("tr", null, [
107
+ e[2] || (e[2] = a("th", { class: "filex-viewer-csv__rownum" }, "#", -1)),
108
+ (n(!0), r(k, null, L(V.value, (t, s) => (n(), r("th", { key: s }, v(t), 1))), 128))
109
+ ])
110
+ ]),
111
+ a("tbody", null, [
112
+ (n(!0), r(k, null, L($.value, (t, s) => (n(), r("tr", { key: s }, [
113
+ a("td", X, v((o.value - 1) * 100 + s + 1), 1),
114
+ (n(!0), r(k, null, L(t, (c, y) => (n(), r("td", { key: y }, v(c), 1))), 128))
115
+ ]))), 128))
116
+ ])
117
+ ]))
118
+ ]),
119
+ !h.value && !_.value && x.value > 1 ? (n(), r("div", Y, [
120
+ a("button", {
121
+ type: "button",
122
+ class: "filex-viewer-btn",
123
+ disabled: o.value <= 1,
124
+ onClick: e[0] || (e[0] = (t) => o.value--)
125
+ }, "‹", 8, ee),
126
+ a("span", te, v(o.value) + " / " + v(x.value) + " (" + v(I("viewer.csv_rows", `${p.value.length} rows`, { n: p.value.length })) + ")", 1),
127
+ a("button", {
128
+ type: "button",
129
+ class: "filex-viewer-btn",
130
+ disabled: o.value >= x.value,
131
+ onClick: e[1] || (e[1] = (t) => o.value++)
132
+ }, "›", 8, le)
133
+ ])) : q("", !0)
134
+ ]));
135
+ }
136
+ });
137
+ export {
138
+ ne as default
139
+ };
140
+ //# sourceMappingURL=CsvViewer-Bac6RzAt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CsvViewer-Bac6RzAt.js","sources":["../../core/src/viewers/CsvViewer.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * CsvViewer — lightweight CSV / TSV table preview.\n *\n * Lazy-imports `papaparse` when available (best-quality parser — handles\n * embedded quotes, multi-line cells, etc). Falls back to a simple\n * `split` parser when the peer is missing — workable for the trivial\n * \"first 1000 rows\" preview case but loses fidelity on complex files.\n *\n * UX:\n * - first-row-as-header toggle\n * - filter input that case-insensitively matches any cell\n * - 100-rows-per-page pagination\n * - tab vs comma auto-detection (manual override via toolbar)\n */\nimport { computed, onMounted, ref, watch } from 'vue';\nimport { actionIconSvg } from '../lib/actionIcons'; /* ikon:emoji */\nimport { fileIconTile } from '../lib/fileIcons'; /* ikon:emoji */\nimport { fetchViewerText } from '../composables/useViewerFetch';\n\nconst props = defineProps<{\n url: string;\n ext: string;\n t?: (key: string, vars?: Record<string, string | number>) => string;\n authHeaders?: () => Record<string, string> | Promise<Record<string, string>>;\n authCredentials?: RequestCredentials;\n}>();\n\nconst PAGE_SIZE = 100;\nconst ROW_LIMIT = 1000;\n\nconst rows = ref<string[][]>([]);\nconst error = ref<string | null>(null);\nconst loading = ref(true);\nconst firstRowHeader = ref(true);\nconst filter = ref('');\nconst page = ref(1);\nconst detectedDelim = ref<',' | '\\t' | ';'>(',');\nconst userDelim = ref<'auto' | ',' | '\\t' | ';'>('auto');\n\nlet renderToken = 0;\n\nfunction detectDelimiter(sample: string): ',' | '\\t' | ';' {\n const sampleLines = sample.split(/\\r?\\n/).slice(0, 5).join('\\n');\n const tab = (sampleLines.match(/\\t/g) || []).length;\n const semi = (sampleLines.match(/;/g) || []).length;\n const comma = (sampleLines.match(/,/g) || []).length;\n if (tab > comma && tab > semi) return '\\t';\n if (semi > comma && semi > tab) return ';';\n return ',';\n}\n\nasync function parseWith(text: string, delim: string): Promise<string[][]> {\n try {\n const mod = await import(/* @vite-ignore */ 'papaparse');\n const Papa = (mod as any).default ?? mod;\n const result = Papa.parse(text, {\n delimiter: delim,\n skipEmptyLines: true,\n header: false,\n });\n return (result.data as string[][]).slice(0, ROW_LIMIT);\n } catch {\n // Fallback: naive line/column split. Loses quoted-comma support\n // but renders something reasonable.\n return text\n .split(/\\r?\\n/)\n .filter((l) => l.length > 0)\n .slice(0, ROW_LIMIT)\n .map((line) => line.split(delim));\n }\n}\n\nasync function load(): Promise<void> {\n loading.value = true;\n error.value = null;\n rows.value = [];\n page.value = 1;\n const myToken = ++renderToken;\n\n let text: string;\n try {\n text = 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 if (props.ext === 'tsv') {\n detectedDelim.value = '\\t';\n } else {\n detectedDelim.value = detectDelimiter(text.slice(0, 4096));\n }\n\n const delim = userDelim.value === 'auto' ? detectedDelim.value : userDelim.value;\n rows.value = await parseWith(text, delim);\n loading.value = false;\n}\n\nonMounted(load);\nwatch(() => props.url, load);\nwatch(() => userDelim.value, () => {\n if (rows.value.length === 0) return;\n // Re-parse with the new delimiter using the cached source — but we\n // didn't keep it. Cheapest path is a refetch.\n load();\n});\n\nconst headers = computed<string[]>(() => {\n if (!firstRowHeader.value || rows.value.length === 0) {\n if (rows.value.length === 0) return [];\n return rows.value[0].map((_, i) => `Col ${i + 1}`);\n }\n return rows.value[0];\n});\n\nconst dataRows = computed<string[][]>(() => {\n return firstRowHeader.value ? rows.value.slice(1) : rows.value;\n});\n\nconst filtered = computed<string[][]>(() => {\n const q = filter.value.trim().toLowerCase();\n if (!q) return dataRows.value;\n return dataRows.value.filter((r) =>\n r.some((c) => (c || '').toLowerCase().includes(q)),\n );\n});\n\nconst totalPages = computed(() =>\n Math.max(1, Math.ceil(filtered.value.length / PAGE_SIZE)),\n);\n\nconst visibleRows = computed<string[][]>(() => {\n const start = (page.value - 1) * PAGE_SIZE;\n return filtered.value.slice(start, start + PAGE_SIZE);\n});\n\nwatch(filter, () => {\n page.value = 1;\n});\n\nfunction tt(key: string, fallback: string, vars?: Record<string, string | number>): string {\n return props.t ? props.t(key, vars) : fallback;\n}\n\n/* === ikon:emoji — the fallback screen's mark ==========================\n * Every viewer opened its \"cannot show this\" / \"still loading\" screen with a\n * 48px colour emoji, one per format, each from whatever emoji font the OS\n * shipped. The format mark is `lib/fileIcons`'s tile — the SAME tile the row\n * the person just clicked is wearing, so the fallback is recognisably about\n * that file — and \"loading\" is the stroked ring, spun by CSS, because no\n * still picture can say \"still going\". */\nconst typeTile = computed(() => fileIconTile({ type: 'file', extension: props.ext }));\n</script>\n\n<template>\n <div class=\"filex-viewer-csv\">\n <div class=\"filex-viewer-csv__pane\">\n <div v-if=\"error\" class=\"filex-viewer-fallback\">\n <!-- eslint-disable-next-line vue/no-v-html -- static markup from lib/fileIcons + lib/actionIcons -->\n <span class=\"filex-viewer-fallback__icon\" aria-hidden=\"true\" v-html=\"typeTile\"></span>\n <p>{{ error }}</p>\n </div>\n <div v-else-if=\"loading\" class=\"filex-viewer-fallback\">\n <!-- eslint-disable-next-line vue/no-v-html -- static markup from lib/fileIcons + lib/actionIcons -->\n <span\n class=\"filex-viewer-fallback__icon filex-viewer-fallback__icon--spin\"\n aria-hidden=\"true\"\n v-html=\"actionIconSvg('progress')\"\n ></span>\n <p>{{ tt('viewer.loading', 'Loading…') }}</p>\n </div>\n <table v-else class=\"filex-viewer-csv__table\">\n <thead>\n <tr>\n <th class=\"filex-viewer-csv__rownum\">#</th>\n <th v-for=\"(h, i) in headers\" :key=\"i\">{{ h }}</th>\n </tr>\n </thead>\n <tbody>\n <tr v-for=\"(row, ri) in visibleRows\" :key=\"ri\">\n <td class=\"filex-viewer-csv__rownum\">{{ (page - 1) * 100 + ri + 1 }}</td>\n <td v-for=\"(c, ci) in row\" :key=\"ci\">{{ c }}</td>\n </tr>\n </tbody>\n </table>\n </div>\n <div v-if=\"!loading && !error && totalPages > 1\" class=\"filex-viewer-csv__pager\">\n <button\n type=\"button\"\n class=\"filex-viewer-btn\"\n :disabled=\"page <= 1\"\n @click=\"page--\"\n >‹</button>\n <span class=\"filex-viewer-csv__pageno\">{{ page }} / {{ totalPages }} ({{ tt('viewer.csv_rows', `${filtered.length} rows`, { n: filtered.length }) }})</span>\n <button\n type=\"button\"\n class=\"filex-viewer-btn\"\n :disabled=\"page >= totalPages\"\n @click=\"page++\"\n >›</button>\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-csv {\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-csv__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}\n.filex-viewer-csv__check {\n display: flex;\n align-items: center;\n gap: 4px;\n font-size: 12px;\n}\n.filex-viewer-csv__select,\n.filex-viewer-csv__filter {\n border: 1px solid var(--fe-border, #e2e6ed);\n background: var(--fe-bg, #fff);\n color: inherit;\n padding: 4px 8px;\n border-radius: 4px;\n font: inherit;\n font-size: 12px;\n}\n.filex-viewer-csv__filter {\n flex: 0 1 240px;\n}\n.filex-viewer-spacer { flex: 1; }\n.filex-viewer-csv__count {\n font-size: 11px;\n color: var(--fe-text-muted, #5a6475);\n font-variant-numeric: tabular-nums;\n}\n.filex-viewer-csv__pane {\n flex: 1;\n overflow: auto;\n}\n.filex-viewer-csv__table {\n border-collapse: collapse;\n width: max-content;\n min-width: 100%;\n font-size: 12px;\n font-family: var(--fe-font-mono, monospace);\n}\n.filex-viewer-csv__table th,\n.filex-viewer-csv__table td {\n padding: 4px 10px;\n border: 1px solid var(--fe-border, #e2e6ed);\n white-space: nowrap;\n max-width: 320px;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.filex-viewer-csv__table th {\n background: var(--fe-bg-elev, #f7f8fa);\n position: sticky;\n top: 0;\n font-weight: 600;\n text-align: left;\n}\n.filex-viewer-csv__table tbody tr:nth-child(even) {\n background: var(--fe-bg-hover, rgba(0, 0, 0, 0.02));\n}\n.filex-viewer-csv__rownum {\n color: var(--fe-text-muted, #5a6475);\n text-align: right;\n background: var(--fe-bg-elev, #f7f8fa);\n font-variant-numeric: tabular-nums;\n position: sticky;\n left: 0;\n}\n.filex-viewer-csv__pager {\n display: flex;\n justify-content: center;\n align-items: center;\n gap: 8px;\n padding: 6px;\n background: var(--fe-bg-elev, #f7f8fa);\n border-top: 1px solid var(--fe-border, #e2e6ed);\n font-size: 12px;\n}\n.filex-viewer-csv__pageno {\n font-variant-numeric: tabular-nums;\n font-size: 12px;\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.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:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n}\n</style>\n"],"names":["PAGE_SIZE","ROW_LIMIT","props","__props","rows","ref","error","loading","firstRowHeader","filter","page","detectedDelim","userDelim","renderToken","detectDelimiter","sample","sampleLines","tab","semi","comma","parseWith","text","delim","mod","n","l","line","load","myToken","fetchViewerText","_a","err","onMounted","watch","headers","computed","_","i","dataRows","filtered","q","r","c","totalPages","visibleRows","start","tt","key","fallback","vars","typeTile","fileIconTile","_openBlock","_createElementBlock","_hoisted_1","_createElementVNode","_hoisted_2","_hoisted_3","_hoisted_5","_unref","actionIconSvg","_hoisted_7","_cache","_Fragment","_renderList","h","row","ri","_hoisted_8","_toDisplayString","ci","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12"],"mappings":";;;;;;;;;;;;;;qFA4BMA,IAAY,KACZC,IAAY;;;;;;;;;;AATlB,UAAMC,IAAQC,GAWRC,IAAOC,EAAgB,EAAE,GACzBC,IAAQD,EAAmB,IAAI,GAC/BE,IAAUF,EAAI,EAAI,GAClBG,IAAiBH,EAAI,EAAI,GACzBI,IAASJ,EAAI,EAAE,GACfK,IAAOL,EAAI,CAAC,G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A;AAAA,MAAA;;;;"}
@@ -1,9 +1,9 @@
1
- import { f as U } from "./useViewerFetch-czqbd2Lj.js";
2
- import { d as S, f as i, o as B, w as E, h as O, a as d, c as u, e as g, t as C, g as p } from "./index-BWP1wNya.js";
3
- const T = { class: "filex-viewer-drawio" }, $ = {
1
+ import { d as S, g as s, o as T, w as B, j as E, a as c, c as d, e as g, t as O, h as u, i as C } from "./index-DiSDAgAg.js";
2
+ import { f as H } from "./useViewerFetch-czqbd2Lj.js";
3
+ const L = { class: "filex-viewer-drawio" }, M = {
4
4
  key: 0,
5
5
  class: "filex-viewer-fallback"
6
- }, N = ["src"], j = /* @__PURE__ */ S({
6
+ }, $ = ["innerHTML"], j = ["src"], R = /* @__PURE__ */ S({
7
7
  __name: "DrawioViewer",
8
8
  props: {
9
9
  url: {},
@@ -17,51 +17,51 @@ const T = { class: "filex-viewer-drawio" }, $ = {
17
17
  authCredentials: {}
18
18
  },
19
19
  setup(x) {
20
- const e = x, c = i(null), s = i(null), n = i("loading"), f = i(!!e.readOnly || !e.saveUrl), o = p(
20
+ const e = x, f = s(null), i = s(null), n = s("loading"), v = s(!!e.readOnly || !e.saveUrl), o = u(
21
21
  () => e.drawioUrl ? e.drawioUrl.replace(/\/$/, "") : null
22
- ), _ = p(() => {
22
+ ), _ = u(() => {
23
23
  if (!o.value) return "";
24
24
  const a = new URLSearchParams({
25
25
  embed: "1",
26
26
  proto: "json",
27
27
  spin: "1",
28
28
  saveAndExit: "0",
29
- noSaveBtn: f.value ? "1" : "0",
29
+ noSaveBtn: v.value ? "1" : "0",
30
30
  noExitBtn: "1",
31
31
  ui: "kennedy",
32
32
  modified: "unsavedChanges"
33
33
  });
34
34
  return `${o.value}/?${a.toString()}`;
35
35
  });
36
- let v = "";
36
+ let m = "";
37
37
  async function k() {
38
38
  var a;
39
- n.value = "loading", s.value = null;
39
+ n.value = "loading", i.value = null;
40
40
  try {
41
- v = await U({
41
+ m = await H({
42
42
  url: e.url,
43
43
  headers: await ((a = e.authHeaders) == null ? void 0 : a.call(e)) ?? {},
44
44
  credentials: e.authCredentials
45
45
  });
46
- } catch (t) {
47
- s.value = t instanceof Error ? t.message : "fetch failed", n.value = "error";
46
+ } catch (r) {
47
+ i.value = r instanceof Error ? r.message : "fetch failed", n.value = "error";
48
48
  }
49
49
  }
50
50
  function b(a) {
51
- var t, r;
52
- (r = (t = c.value) == null ? void 0 : t.contentWindow) == null || r.postMessage(JSON.stringify(a), "*");
51
+ var r, t;
52
+ (t = (r = f.value) == null ? void 0 : r.contentWindow) == null || t.postMessage(JSON.stringify(a), "*");
53
53
  }
54
- async function m(a) {
55
- var t;
54
+ async function h(a) {
55
+ var r;
56
56
  if (e.saveUrl) {
57
57
  n.value = "saving";
58
58
  try {
59
- const r = {
59
+ const t = {
60
60
  "Content-Type": "application/json",
61
- ...await ((t = e.authHeaders) == null ? void 0 : t.call(e)) ?? {}
61
+ ...await ((r = e.authHeaders) == null ? void 0 : r.call(e)) ?? {}
62
62
  }, l = await fetch(e.saveUrl, {
63
63
  method: "POST",
64
- headers: r,
64
+ headers: t,
65
65
  credentials: e.authCredentials || "same-origin",
66
66
  body: JSON.stringify({ path: e.filePath, content: a })
67
67
  });
@@ -70,71 +70,76 @@ const T = { class: "filex-viewer-drawio" }, $ = {
70
70
  n.value = "saved", setTimeout(() => {
71
71
  n.value === "saved" && (n.value = "ready");
72
72
  }, 2500);
73
- } catch (r) {
74
- s.value = r instanceof Error ? r.message : "save failed", n.value = "error";
73
+ } catch (t) {
74
+ i.value = t instanceof Error ? t.message : "save failed", n.value = "error";
75
75
  }
76
76
  }
77
77
  }
78
78
  function w(a) {
79
79
  if (typeof a.data != "string" || a.data.length === 0) return;
80
- const t = a.data[0];
81
- if (t !== "{" && t !== "<") return;
82
- let r;
80
+ const r = a.data[0];
81
+ if (r !== "{" && r !== "<") return;
82
+ let t;
83
83
  try {
84
- r = JSON.parse(a.data);
84
+ t = JSON.parse(a.data);
85
85
  } catch {
86
86
  return;
87
87
  }
88
- if (!(!r || typeof r != "object"))
89
- switch (r.event) {
88
+ if (!(!t || typeof t != "object"))
89
+ switch (t.event) {
90
90
  case "init":
91
91
  b({
92
92
  action: "load",
93
- xml: v,
93
+ xml: m,
94
94
  autosave: 0
95
95
  }), n.value = "ready";
96
96
  break;
97
97
  case "save":
98
- typeof r.xml == "string" && m(r.xml);
98
+ typeof t.xml == "string" && h(t.xml);
99
99
  break;
100
100
  case "export":
101
101
  break;
102
102
  case "autosave":
103
- typeof r.xml == "string" && !f.value && m(r.xml);
103
+ typeof t.xml == "string" && !v.value && h(t.xml);
104
104
  break;
105
105
  }
106
106
  }
107
- function h() {
107
+ function y() {
108
108
  if (!o.value) {
109
- s.value = y("viewer.drawio.disabled", "diagrams.net is not configured for this filex instance."), n.value = "error";
109
+ i.value = p("viewer.drawio.disabled", "diagrams.net is not configured for this filex instance."), n.value = "error";
110
110
  return;
111
111
  }
112
- s.value === y("viewer.drawio.disabled", "diagrams.net is not configured for this filex instance.") && (s.value = null, n.value = "loading"), k();
112
+ i.value === p("viewer.drawio.disabled", "diagrams.net is not configured for this filex instance.") && (i.value = null, n.value = "loading"), k();
113
113
  }
114
- B(() => {
115
- window.addEventListener("message", w), h();
116
- }), E(() => e.drawioUrl, h), O(() => {
114
+ T(() => {
115
+ window.addEventListener("message", w), y();
116
+ }), B(() => e.drawioUrl, y), E(() => {
117
117
  window.removeEventListener("message", w);
118
118
  });
119
- function y(a, t) {
120
- return e.t ? e.t(a) : t;
119
+ function p(a, r) {
120
+ return e.t ? e.t(a) : r;
121
121
  }
122
- return (a, t) => (d(), u("div", T, [
123
- s.value ? (d(), u("div", $, [
124
- t[0] || (t[0] = g("span", { class: "filex-viewer-fallback__icon" }, "📐", -1)),
125
- g("p", null, C(s.value), 1)
126
- ])) : (d(), u("iframe", {
122
+ const U = u(() => C({ type: "file", extension: e.ext }));
123
+ return (a, r) => (c(), d("div", L, [
124
+ i.value ? (c(), d("div", M, [
125
+ g("span", {
126
+ class: "filex-viewer-fallback__icon",
127
+ "aria-hidden": "true",
128
+ innerHTML: U.value
129
+ }, null, 8, $),
130
+ g("p", null, O(i.value), 1)
131
+ ])) : (c(), d("iframe", {
127
132
  key: 1,
128
133
  ref_key: "iframeRef",
129
- ref: c,
134
+ ref: f,
130
135
  src: _.value,
131
136
  class: "filex-viewer-drawio__frame",
132
137
  title: "diagrams.net editor"
133
- }, null, 8, N))
138
+ }, null, 8, j))
134
139
  ]));
135
140
  }
136
141
  });
137
142
  export {
138
- j as default
143
+ R as default
139
144
  };
140
- //# sourceMappingURL=DrawioViewer-Dp8cxp-x.js.map
145
+ //# sourceMappingURL=DrawioViewer-CWjYMKPU.js.map