@av-pi-studio/workbench 0.0.122 → 0.0.124
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 +16 -4
- package/dist/chunks/{BinaryFallbackViewer-EznEIpRC.js → BinaryFallbackViewer-ua5VmtNP.js} +1 -1
- package/dist/chunks/{ChatPanel-DgJlK-yP.js → ChatPanel-9mV7jLOD.js} +3 -3
- package/dist/chunks/{CodeView-klpk8qD0.js → CodeView--Yo9YYpl.js} +2 -2
- package/dist/chunks/{FilePanel-Beg5Fs8X.js → FilePanel-CBNc1csX.js} +2 -2
- package/dist/chunks/HtmlViewer-BjvrS29T.js +539 -0
- package/dist/chunks/{ImageViewer-BLrsKWwI.js → ImageViewer-DQFVe58O.js} +1 -1
- package/dist/chunks/{MarkdownFileViewer-DxJJlrsv.js → MarkdownFileViewer-BEaGxGyd.js} +4 -4
- package/dist/chunks/{ModelProvidersPanel-C3TXoq1L.js → ModelProvidersPanel-CUdM6FMu.js} +2 -2
- package/dist/chunks/{MoleculeViewerPanel-BAWs5F2j.js → MoleculeViewerPanel-DhkadYBP.js} +3 -3
- package/dist/chunks/{PdfViewer-B_kiY-Tw.js → PdfViewer-PKAEVwco.js} +2 -2
- package/dist/chunks/{SaveFileButton-Bsz3wG4a.js → SaveFileButton-qwf_ewMX.js} +1 -1
- package/dist/chunks/SettingsDialog-ChDFOPih.js +454 -0
- package/dist/chunks/{SkillsPanel-BB5_yrcx.js → SkillsPanel-DP72YesV.js} +1 -1
- package/dist/chunks/{TerminalPanel-DgH4re05.js → TerminalPanel-BKnfLGNl.js} +1 -1
- package/dist/chunks/{TextViewer-BiwFYLLc.js → TextViewer-ZT99BjEP.js} +2 -2
- package/dist/chunks/{VideoViewer-BSGjTTQR.js → VideoViewer-C_gj8A0b.js} +1 -1
- package/dist/chunks/{ViewersPanel-BYHmKfOh.js → ViewersPanel-CTRov7NQ.js} +1 -1
- package/dist/chunks/external-link-BsgjS-QP.js +24 -0
- package/dist/chunks/{href-resolution-AtzN0oCd.js → href-resolution-AG-Co7Sm.js} +1 -1
- package/dist/chunks/index-CitLJdIo.js +7415 -0
- package/dist/chunks/{markdown-CypQ7TkY.js → markdown-CVWWeRbe.js} +97 -90
- package/dist/chunks/{use-file-download-zheHRdGQ.js → use-file-download-DbQCEsRG.js} +1 -1
- package/dist/chunks/{use-file-watch-CyVeSj2A.js → use-file-watch-CrgiCMCF.js} +1 -1
- package/dist/chunks/{use-provider-auth-list-jNjjSAD_.js → use-provider-auth-list-Bcdz9-zE.js} +1 -1
- package/dist/features/connection/ConnectionBar.d.ts +4 -0
- package/dist/features/connection/DaemonSwitcher.d.ts +16 -0
- package/dist/features/connection/daemon-switcher-presentation.d.ts +69 -0
- package/dist/features/connection/outdated-daemon.d.ts +17 -0
- package/dist/features/connection/use-outdated-daemon-notice.d.ts +26 -0
- package/dist/features/daemons/DaemonForm.d.ts +18 -0
- package/dist/features/daemons/DaemonsScreen.d.ts +17 -0
- package/dist/features/daemons/connect-current.d.ts +19 -0
- package/dist/features/daemons/daemon-form-actions.d.ts +27 -0
- package/dist/features/daemons/daemon-form.d.ts +103 -0
- package/dist/features/daemons/daemon-lifecycle.d.ts +58 -0
- package/dist/features/daemons/daemon-presentation.d.ts +46 -0
- package/dist/features/daemons/daemons-screen-actions.d.ts +37 -0
- package/dist/features/daemons/daemons-screen-view.d.ts +62 -0
- package/dist/features/daemons/daemons-store.d.ts +30 -0
- package/dist/features/daemons/use-daemon-lifecycle.d.ts +3 -0
- package/dist/features/daemons/use-daemons.d.ts +8 -0
- package/dist/features/files/preview-mounts.d.ts +25 -0
- package/dist/features/sessions/RenameSessionDialog.d.ts +8 -0
- package/dist/features/sessions/rename-title.d.ts +6 -0
- package/dist/features/sessions/session-actions.d.ts +6 -5
- package/dist/hooks/use-connection.d.ts +17 -5
- package/dist/host/browser-files.d.ts +2 -2
- package/dist/host/browser-host.d.ts +6 -1
- package/dist/host/types.d.ts +149 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/connection/connect-failure.d.ts +14 -0
- package/dist/lib/connection/connection-store.d.ts +7 -1
- package/dist/stores/session-rename-store.d.ts +13 -0
- package/dist/styles.css +1 -1
- package/dist/timeline/FileLink.d.ts +4 -2
- package/dist/timeline/external-href.d.ts +9 -0
- package/package.json +4 -4
- package/dist/chunks/HtmlViewer-KGQcSEm3.js +0 -490
- package/dist/chunks/SettingsDialog-AHnoT7nN.js +0 -471
- package/dist/chunks/index-QzeFcHmH.js +0 -6261
|
@@ -1,490 +0,0 @@
|
|
|
1
|
-
import { jsx as w, jsxs as m } from "react/jsx-runtime";
|
|
2
|
-
import { useState as P, useMemo as S } from "react";
|
|
3
|
-
import { useQueryClient as ie, useQuery as ae } from "@tanstack/react-query";
|
|
4
|
-
import { EmptyState as N, Spinner as j, Button as I, Switch as ce } from "@av-pi-studio/ui-library";
|
|
5
|
-
import { u as le, C as ue } from "./CodeView-klpk8qD0.js";
|
|
6
|
-
import { n as de, H as G, _ as fe, Q as X, u as D, i as me, r as R, $ as pe } from "./index-QzeFcHmH.js";
|
|
7
|
-
import { p as he, S as ge } from "./href-resolution-AtzN0oCd.js";
|
|
8
|
-
import { S as we } from "./SaveFileButton-Bsz3wG4a.js";
|
|
9
|
-
const O = {
|
|
10
|
-
maxCount: 64,
|
|
11
|
-
maxBytesPerAsset: 2 * 1024 * 1024,
|
|
12
|
-
// 2 MiB
|
|
13
|
-
maxBytesTotal: 16 * 1024 * 1024
|
|
14
|
-
// 16 MiB — base64 inflates raw bytes ~33%; this cap keeps the
|
|
15
|
-
// assembled `srcdoc` string off the main thread as a multi-hundred-MB allocation.
|
|
16
|
-
};
|
|
17
|
-
function F(n, t, e) {
|
|
18
|
-
return !(n >= O.maxCount || e > O.maxBytesPerAsset || t + e > O.maxBytesTotal);
|
|
19
|
-
}
|
|
20
|
-
function Y(n) {
|
|
21
|
-
return n === "" || n.startsWith("#") ? "unsupported" : n.startsWith("//") || ge.test(n) ? "external" : null;
|
|
22
|
-
}
|
|
23
|
-
function ve(n, t, e) {
|
|
24
|
-
return e !== null && t === e ? n : t;
|
|
25
|
-
}
|
|
26
|
-
function J(n, t, e, s, o = null) {
|
|
27
|
-
const r = n.trim(), c = Y(r);
|
|
28
|
-
if (c) return { kind: "skip", raw: n, reason: c };
|
|
29
|
-
const i = he(r);
|
|
30
|
-
let p;
|
|
31
|
-
if (i.startsWith("/") ? p = i : i === "~" || i.startsWith("~/") ? p = o !== null ? de(i, o) : null : p = G(i, t), !p) return { kind: "skip", raw: n, reason: "unsupported" };
|
|
32
|
-
const h = fe(p);
|
|
33
|
-
return h !== e && !h.startsWith(`${e}/`) ? { kind: "skip", raw: n, reason: "outside-workspace" } : { kind: "local", raw: n, path: h, context: s };
|
|
34
|
-
}
|
|
35
|
-
const xe = {
|
|
36
|
-
css: "text/css",
|
|
37
|
-
js: "text/javascript",
|
|
38
|
-
mjs: "text/javascript",
|
|
39
|
-
html: "text/html",
|
|
40
|
-
htm: "text/html",
|
|
41
|
-
json: "application/json",
|
|
42
|
-
png: "image/png",
|
|
43
|
-
jpg: "image/jpeg",
|
|
44
|
-
jpeg: "image/jpeg",
|
|
45
|
-
gif: "image/gif",
|
|
46
|
-
webp: "image/webp",
|
|
47
|
-
svg: "image/svg+xml",
|
|
48
|
-
ico: "image/x-icon",
|
|
49
|
-
bmp: "image/bmp",
|
|
50
|
-
avif: "image/avif",
|
|
51
|
-
mp4: "video/mp4",
|
|
52
|
-
webm: "video/webm",
|
|
53
|
-
mov: "video/quicktime",
|
|
54
|
-
m4v: "video/x-m4v",
|
|
55
|
-
ogv: "video/ogg",
|
|
56
|
-
mp3: "audio/mpeg",
|
|
57
|
-
wav: "audio/wav",
|
|
58
|
-
oga: "audio/ogg",
|
|
59
|
-
ogg: "audio/ogg",
|
|
60
|
-
m4a: "audio/mp4",
|
|
61
|
-
woff: "font/woff",
|
|
62
|
-
woff2: "font/woff2",
|
|
63
|
-
ttf: "font/ttf",
|
|
64
|
-
otf: "font/otf",
|
|
65
|
-
eot: "application/vnd.ms-fontobject"
|
|
66
|
-
};
|
|
67
|
-
function be(n) {
|
|
68
|
-
const t = n.lastIndexOf("/"), e = n.lastIndexOf(".");
|
|
69
|
-
return e <= t ? "application/octet-stream" : xe[n.slice(e + 1).toLowerCase()] ?? "application/octet-stream";
|
|
70
|
-
}
|
|
71
|
-
function ye(n) {
|
|
72
|
-
let t = "";
|
|
73
|
-
for (let s = 0; s < n.length; s += 32768)
|
|
74
|
-
t += String.fromCharCode(...n.subarray(s, s + 32768));
|
|
75
|
-
return btoa(t);
|
|
76
|
-
}
|
|
77
|
-
function K(n, t) {
|
|
78
|
-
return `data:${n};base64,${ye(t)}`;
|
|
79
|
-
}
|
|
80
|
-
const M = /<([a-zA-Z][a-zA-Z0-9]*)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*)(\s*\/?>)/g, V = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+))/g;
|
|
81
|
-
function ee(n) {
|
|
82
|
-
const t = /* @__PURE__ */ new Map();
|
|
83
|
-
V.lastIndex = 0;
|
|
84
|
-
let e;
|
|
85
|
-
for (; e = V.exec(n); ) {
|
|
86
|
-
const s = e[1].toLowerCase();
|
|
87
|
-
t.has(s) || t.set(s, e[2] ?? e[3] ?? e[4] ?? "");
|
|
88
|
-
}
|
|
89
|
-
return t;
|
|
90
|
-
}
|
|
91
|
-
function te(n, t) {
|
|
92
|
-
switch (n) {
|
|
93
|
-
case "link": {
|
|
94
|
-
const e = t.get("rel") ?? "";
|
|
95
|
-
return /(^|\s)stylesheet(\s|$)/i.test(e) ? t.has("href") ? [{ name: "href", context: "style", multi: !1 }] : [] : [];
|
|
96
|
-
}
|
|
97
|
-
case "script":
|
|
98
|
-
return t.has("src") ? [{ name: "src", context: "script", multi: !1 }] : [];
|
|
99
|
-
case "img": {
|
|
100
|
-
const e = [];
|
|
101
|
-
return t.has("src") && e.push({ name: "src", context: "image", multi: !1 }), t.has("srcset") && e.push({ name: "srcset", context: "image", multi: !0 }), e;
|
|
102
|
-
}
|
|
103
|
-
case "source": {
|
|
104
|
-
const e = [];
|
|
105
|
-
return t.has("src") && e.push({ name: "src", context: "media", multi: !1 }), t.has("srcset") && e.push({ name: "srcset", context: "media", multi: !0 }), e;
|
|
106
|
-
}
|
|
107
|
-
case "video": {
|
|
108
|
-
const e = [];
|
|
109
|
-
return t.has("src") && e.push({ name: "src", context: "media", multi: !1 }), t.has("poster") && e.push({ name: "poster", context: "media", multi: !1 }), e;
|
|
110
|
-
}
|
|
111
|
-
case "audio":
|
|
112
|
-
return t.has("src") ? [{ name: "src", context: "media", multi: !1 }] : [];
|
|
113
|
-
default:
|
|
114
|
-
return [];
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
function ne(n) {
|
|
118
|
-
return n.split(",").map((t) => t.trim()).filter((t) => t !== "").map((t) => {
|
|
119
|
-
const e = t.search(/\s/);
|
|
120
|
-
return e === -1 ? { url: t, descriptor: "" } : { url: t.slice(0, e), descriptor: t.slice(e).trim() };
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
function _e(n) {
|
|
124
|
-
return n.map((t) => t.descriptor ? `${t.url} ${t.descriptor}` : t.url).join(", ");
|
|
125
|
-
}
|
|
126
|
-
function $(n, t, e) {
|
|
127
|
-
Y(t.trim()) || n.has(t) || n.set(t, { raw: t, context: e });
|
|
128
|
-
}
|
|
129
|
-
function ke(n) {
|
|
130
|
-
const t = /* @__PURE__ */ new Map();
|
|
131
|
-
M.lastIndex = 0;
|
|
132
|
-
let e;
|
|
133
|
-
for (; e = M.exec(n); ) {
|
|
134
|
-
const s = e[1].toLowerCase(), o = ee(e[2] ?? "");
|
|
135
|
-
for (const r of te(s, o)) {
|
|
136
|
-
const c = o.get(r.name) ?? "";
|
|
137
|
-
if (r.multi)
|
|
138
|
-
for (const i of ne(c)) $(t, i.url, r.context);
|
|
139
|
-
else
|
|
140
|
-
$(t, c, r.context);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return [...t.values()];
|
|
144
|
-
}
|
|
145
|
-
function Se(n, t) {
|
|
146
|
-
let e = !1;
|
|
147
|
-
const s = ne(n).map((o) => {
|
|
148
|
-
const r = t[o.url];
|
|
149
|
-
return r === void 0 ? o : (e = !0, { url: r, descriptor: o.descriptor });
|
|
150
|
-
});
|
|
151
|
-
return e ? _e(s) : null;
|
|
152
|
-
}
|
|
153
|
-
function Ee(n, t) {
|
|
154
|
-
return Object.keys(t).length === 0 ? n : (M.lastIndex = 0, n.replace(M, (e, s, o, r) => {
|
|
155
|
-
const c = ee(o), i = te(s.toLowerCase(), c);
|
|
156
|
-
if (i.length === 0) return e;
|
|
157
|
-
const p = new Map(i.map((u) => [u.name, u]));
|
|
158
|
-
let h = !1;
|
|
159
|
-
const A = o.replace(
|
|
160
|
-
V,
|
|
161
|
-
(u, d, a, x, y) => {
|
|
162
|
-
const b = p.get(d.toLowerCase());
|
|
163
|
-
if (!b) return u;
|
|
164
|
-
const g = a ?? x ?? y ?? "", E = b.multi ? Se(g, t) : t[g] ?? null;
|
|
165
|
-
return E === null ? u : (h = !0, `${d}="${E}"`);
|
|
166
|
-
}
|
|
167
|
-
);
|
|
168
|
-
return h ? `<${s}${A}${r}` : e;
|
|
169
|
-
}));
|
|
170
|
-
}
|
|
171
|
-
const z = /url\(\s*(?:"([^"]*)"|'([^']*)'|([^'")\s]*))\s*\)/gi, q = /@font-face\s*\{[^}]*\}/gi;
|
|
172
|
-
function se(n, t, e) {
|
|
173
|
-
return n ?? t ?? e ?? "";
|
|
174
|
-
}
|
|
175
|
-
function Le(n) {
|
|
176
|
-
const t = [];
|
|
177
|
-
q.lastIndex = 0;
|
|
178
|
-
let e;
|
|
179
|
-
for (; e = q.exec(n); ) t.push([e.index, e.index + e[0].length]);
|
|
180
|
-
return t;
|
|
181
|
-
}
|
|
182
|
-
function Ae(n) {
|
|
183
|
-
const t = Le(n), e = /* @__PURE__ */ new Map();
|
|
184
|
-
z.lastIndex = 0;
|
|
185
|
-
let s;
|
|
186
|
-
for (; s = z.exec(n); ) {
|
|
187
|
-
const o = se(s[1], s[2], s[3]), r = t.some(
|
|
188
|
-
([c, i]) => s.index >= c && s.index < i
|
|
189
|
-
) ? "font" : "image";
|
|
190
|
-
$(e, o, r);
|
|
191
|
-
}
|
|
192
|
-
return [...e.values()];
|
|
193
|
-
}
|
|
194
|
-
function Ce(n, t) {
|
|
195
|
-
return Object.keys(t).length === 0 ? n : (z.lastIndex = 0, n.replace(z, (e, s, o, r) => {
|
|
196
|
-
const c = t[se(s, o, r)];
|
|
197
|
-
return c === void 0 ? e : `url("${c}")`;
|
|
198
|
-
}));
|
|
199
|
-
}
|
|
200
|
-
const Ne = Object.freeze(["allow-scripts"]), Te = "https://pi-studio-preview.invalid/", Be = "default-src 'none'; img-src data:; style-src 'unsafe-inline' data:; script-src 'unsafe-inline' data:; font-src data:; media-src data:", Re = `<script>(function(){document.addEventListener("click",function(e){var a=e.target&&e.target.closest&&e.target.closest('a[href^="#"]');if(!a)return;var frag=a.getAttribute("href").slice(1);e.preventDefault();if(!frag){window.scrollTo(0,0);return;}var el=document.getElementById(frag)||document.getElementsByName(frag)[0];if(el)el.scrollIntoView();},true);})();<\/script>`, He = /<head(\s[^>]*)?>/i, Me = /<html(\s[^>]*)?>/i, ze = /<base[\s/>]/i;
|
|
201
|
-
function Pe(n, t) {
|
|
202
|
-
const e = Ee(n, t.assets ?? {}), s = [];
|
|
203
|
-
t.blockRemote && s.push(
|
|
204
|
-
`<meta http-equiv="Content-Security-Policy" content="${Be}">`
|
|
205
|
-
), ze.test(e) || (s.push(`<base href="${Te}">`), s.push(Re));
|
|
206
|
-
const o = s.join("");
|
|
207
|
-
if (o === "") return e;
|
|
208
|
-
const r = He.exec(e);
|
|
209
|
-
if (r) {
|
|
210
|
-
const i = r.index + r[0].length;
|
|
211
|
-
return e.slice(0, i) + o + e.slice(i);
|
|
212
|
-
}
|
|
213
|
-
const c = Me.exec(e);
|
|
214
|
-
if (c) {
|
|
215
|
-
const i = c.index + c[0].length;
|
|
216
|
-
return e.slice(0, i) + `<head>${o}</head>` + e.slice(i);
|
|
217
|
-
}
|
|
218
|
-
return `<head>${o}</head>` + e;
|
|
219
|
-
}
|
|
220
|
-
const Q = 6;
|
|
221
|
-
async function W(n, t, e) {
|
|
222
|
-
let s = 0;
|
|
223
|
-
async function o() {
|
|
224
|
-
for (; s < n.length; ) {
|
|
225
|
-
const r = n[s];
|
|
226
|
-
s += 1, await e(r);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
await Promise.all(Array.from({ length: Math.min(t, n.length) }, o));
|
|
230
|
-
}
|
|
231
|
-
function U(n) {
|
|
232
|
-
const t = /* @__PURE__ */ new Map();
|
|
233
|
-
for (const e of n) {
|
|
234
|
-
const s = t.get(e.path);
|
|
235
|
-
s ? s.push(e) : t.set(e.path, [e]);
|
|
236
|
-
}
|
|
237
|
-
return t;
|
|
238
|
-
}
|
|
239
|
-
async function je(n, t) {
|
|
240
|
-
const e = {}, s = [];
|
|
241
|
-
let o = 0, r = 0, c = !1;
|
|
242
|
-
const i = [];
|
|
243
|
-
for (const u of n)
|
|
244
|
-
u.kind === "skip" ? s.push({ raw: u.raw, reason: u.reason }) : i.push(u);
|
|
245
|
-
function p(u, d) {
|
|
246
|
-
for (const a of u) s.push({ raw: a.raw, reason: d });
|
|
247
|
-
}
|
|
248
|
-
async function h(u, d) {
|
|
249
|
-
if (c) {
|
|
250
|
-
p(d, "over-cap");
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
let a;
|
|
254
|
-
try {
|
|
255
|
-
a = await t.fetchBytes(u);
|
|
256
|
-
} catch {
|
|
257
|
-
p(d, "fetch-failed");
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
if (!F(o, r, a.byteLength)) {
|
|
261
|
-
c = !0, p(d, "over-cap");
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
if (o += 1, r += a.byteLength, d[0].context !== "style") {
|
|
265
|
-
const f = K(be(u), a);
|
|
266
|
-
for (const k of d) e[k.raw] = f;
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
const x = new TextDecoder().decode(a), y = X(u), b = Ae(x).map(
|
|
270
|
-
(f) => J(f.raw, y, t.root, f.context, t.homeDir)
|
|
271
|
-
), g = [];
|
|
272
|
-
for (const f of b)
|
|
273
|
-
f.kind === "skip" ? s.push({ raw: f.raw, reason: f.reason }) : g.push(f);
|
|
274
|
-
const E = U(g);
|
|
275
|
-
await W(
|
|
276
|
-
[...E.entries()],
|
|
277
|
-
Q,
|
|
278
|
-
([f, k]) => h(f, k)
|
|
279
|
-
);
|
|
280
|
-
const T = {};
|
|
281
|
-
for (const f of g) {
|
|
282
|
-
const k = e[f.raw];
|
|
283
|
-
k !== void 0 && (T[f.raw] = k);
|
|
284
|
-
}
|
|
285
|
-
const C = Ce(x, T), L = new TextEncoder().encode(C), _ = L.byteLength - a.byteLength;
|
|
286
|
-
if (_ > 0 && !F(o - 1, r - a.byteLength, L.byteLength)) {
|
|
287
|
-
c = !0, p(d, "over-cap");
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
r += _;
|
|
291
|
-
const B = K("text/css", L);
|
|
292
|
-
for (const f of d) e[f.raw] = B;
|
|
293
|
-
}
|
|
294
|
-
const A = U(i);
|
|
295
|
-
return await W(
|
|
296
|
-
[...A.entries()],
|
|
297
|
-
Q,
|
|
298
|
-
([u, d]) => h(u, d)
|
|
299
|
-
), { assets: e, skipped: s };
|
|
300
|
-
}
|
|
301
|
-
const Ie = "piwb-HtmlViewer_wrap_zVa2Y", Oe = "piwb-HtmlViewer_toolbar_BJS-C", Ve = "piwb-HtmlViewer_modeToggle_vtj-V", $e = "piwb-HtmlViewer_controls_7oQnM", De = "piwb-HtmlViewer_switchLabel_lI99i", Fe = "piwb-HtmlViewer_streamedNote_Dbx4P", Ke = "piwb-HtmlViewer_skippedNote_ITPaJ", qe = "piwb-HtmlViewer_skippedToggle_X2Aij", Qe = "piwb-HtmlViewer_skippedList_cCdE1", We = "piwb-HtmlViewer_body_Ub6gT", Ue = "piwb-HtmlViewer_frame_feA57", Ze = "piwb-HtmlViewer_tooLarge_W3dLq", v = {
|
|
302
|
-
wrap: Ie,
|
|
303
|
-
toolbar: Oe,
|
|
304
|
-
modeToggle: Ve,
|
|
305
|
-
controls: $e,
|
|
306
|
-
switchLabel: De,
|
|
307
|
-
streamedNote: Fe,
|
|
308
|
-
skippedNote: Ke,
|
|
309
|
-
skippedToggle: qe,
|
|
310
|
-
skippedList: Qe,
|
|
311
|
-
body: We,
|
|
312
|
-
frame: Ue,
|
|
313
|
-
tooLarge: Ze
|
|
314
|
-
}, Ge = Ne.join(" "), Z = Object.freeze({}), Xe = Object.freeze([]), re = {
|
|
315
|
-
external: "external",
|
|
316
|
-
"outside-workspace": "outside workspace",
|
|
317
|
-
unsupported: "unsupported",
|
|
318
|
-
"over-cap": "over cap",
|
|
319
|
-
"fetch-failed": "not found"
|
|
320
|
-
};
|
|
321
|
-
function Ye(n) {
|
|
322
|
-
const t = /* @__PURE__ */ new Map();
|
|
323
|
-
for (const e of n) {
|
|
324
|
-
const s = re[e.reason];
|
|
325
|
-
t.set(s, (t.get(s) ?? 0) + 1);
|
|
326
|
-
}
|
|
327
|
-
return [...t.entries()].map(([e, s]) => `${s} ${e}`).join(", ");
|
|
328
|
-
}
|
|
329
|
-
function Je(n) {
|
|
330
|
-
let t = 2166136261;
|
|
331
|
-
for (let e = 0; e < n.length; e++)
|
|
332
|
-
t ^= n.charCodeAt(e), t = Math.imul(t, 16777619);
|
|
333
|
-
return (t >>> 0).toString(16);
|
|
334
|
-
}
|
|
335
|
-
function H(n) {
|
|
336
|
-
return `${(n / (1024 * 1024)).toFixed(1)} MB`;
|
|
337
|
-
}
|
|
338
|
-
function lt({ path: n, workspaceCwd: t }) {
|
|
339
|
-
const e = le(n), [s, o] = P("preview"), [r, c] = P(!1), [i, p] = P(!1), h = ie(), A = D((l) => l.client), u = D((l) => l.daemon), d = me(), a = e.kind === "inline" || e.kind === "streamed" ? e.content : null, x = S(() => {
|
|
340
|
-
const l = G(n, t);
|
|
341
|
-
return l ? X(l) : null;
|
|
342
|
-
}, [n, t]), y = S(
|
|
343
|
-
() => x !== null ? ve(x, t, d) : null,
|
|
344
|
-
[x, t, d]
|
|
345
|
-
), b = S(() => a === null || x === null || y === null ? [] : ke(a).map(
|
|
346
|
-
(l) => J(l.raw, x, y, l.context, d)
|
|
347
|
-
), [a, x, y, d]), g = S(() => b.some((l) => l.kind === "local"), [b]), E = S(
|
|
348
|
-
() => b.flatMap(
|
|
349
|
-
(l) => l.kind === "skip" ? [{ raw: l.raw, reason: l.reason }] : []
|
|
350
|
-
),
|
|
351
|
-
[b]
|
|
352
|
-
), T = S(
|
|
353
|
-
() => g && a !== null ? Je(a) : "",
|
|
354
|
-
[a, g]
|
|
355
|
-
), C = ae({
|
|
356
|
-
queryKey: R.htmlAssetBundle(n, T),
|
|
357
|
-
queryFn: () => y === null ? Promise.resolve({ assets: {}, skipped: [] }) : je(b, { root: y, homeDir: d, fetchBytes: async (oe) => {
|
|
358
|
-
if (!A || !u) throw new Error("not connected");
|
|
359
|
-
return (await pe(u).download(oe)).bytes;
|
|
360
|
-
} }),
|
|
361
|
-
enabled: g,
|
|
362
|
-
// Immutable per (path, content hash) — a change is only ever observed via a new key
|
|
363
|
-
// (document edited) or an explicit Reload invalidation, never a background refetch.
|
|
364
|
-
staleTime: 1 / 0
|
|
365
|
-
}), L = g ? C.data?.assets ?? Z : Z, _ = g ? C.data?.skipped ?? Xe : E, B = S(() => a === null ? null : Pe(a, { assets: L, blockRemote: r }), [a, L, r]);
|
|
366
|
-
function f() {
|
|
367
|
-
h.invalidateQueries({ queryKey: R.fileRead(n) }), h.invalidateQueries({ queryKey: R.fileDownload(n) }), h.invalidateQueries({ queryKey: R.htmlAssetBundleByPath(n) });
|
|
368
|
-
}
|
|
369
|
-
switch (e.kind) {
|
|
370
|
-
case "loading":
|
|
371
|
-
return /* @__PURE__ */ m(N, { children: [
|
|
372
|
-
/* @__PURE__ */ w(j, { size: "sm" }),
|
|
373
|
-
" Loading..."
|
|
374
|
-
] });
|
|
375
|
-
case "streaming":
|
|
376
|
-
return /* @__PURE__ */ m(N, { children: [
|
|
377
|
-
/* @__PURE__ */ w(j, { size: "sm" }),
|
|
378
|
-
" Streaming ",
|
|
379
|
-
H(e.size),
|
|
380
|
-
" file..."
|
|
381
|
-
] });
|
|
382
|
-
case "stream-error":
|
|
383
|
-
case "error":
|
|
384
|
-
return /* @__PURE__ */ m(N, { children: [
|
|
385
|
-
"Error: ",
|
|
386
|
-
e.message
|
|
387
|
-
] });
|
|
388
|
-
case "too-large":
|
|
389
|
-
return /* @__PURE__ */ w(N, { children: /* @__PURE__ */ m("div", { className: v.tooLarge, children: [
|
|
390
|
-
/* @__PURE__ */ m("div", { children: [
|
|
391
|
-
H(e.size),
|
|
392
|
-
" — too large to display (display ceiling is",
|
|
393
|
-
" ",
|
|
394
|
-
H(e.maxDisplayBytes),
|
|
395
|
-
")."
|
|
396
|
-
] }),
|
|
397
|
-
/* @__PURE__ */ w(we, { path: n })
|
|
398
|
-
] }) });
|
|
399
|
-
}
|
|
400
|
-
if (a === null || B === null) return null;
|
|
401
|
-
if (g && C.data === void 0)
|
|
402
|
-
return /* @__PURE__ */ m(N, { children: [
|
|
403
|
-
/* @__PURE__ */ w(j, { size: "sm" }),
|
|
404
|
-
" Loading assets..."
|
|
405
|
-
] });
|
|
406
|
-
const k = n.split("/").pop() || n;
|
|
407
|
-
return /* @__PURE__ */ m("div", { className: v.wrap, children: [
|
|
408
|
-
/* @__PURE__ */ m("div", { className: v.toolbar, children: [
|
|
409
|
-
/* @__PURE__ */ m("div", { className: v.modeToggle, children: [
|
|
410
|
-
/* @__PURE__ */ w(
|
|
411
|
-
I,
|
|
412
|
-
{
|
|
413
|
-
size: "xs",
|
|
414
|
-
variant: s === "preview" ? "default" : "ghost",
|
|
415
|
-
onClick: () => o("preview"),
|
|
416
|
-
children: "Preview"
|
|
417
|
-
}
|
|
418
|
-
),
|
|
419
|
-
/* @__PURE__ */ w(
|
|
420
|
-
I,
|
|
421
|
-
{
|
|
422
|
-
size: "xs",
|
|
423
|
-
variant: s === "source" ? "default" : "ghost",
|
|
424
|
-
onClick: () => o("source"),
|
|
425
|
-
children: "Source"
|
|
426
|
-
}
|
|
427
|
-
)
|
|
428
|
-
] }),
|
|
429
|
-
/* @__PURE__ */ m("div", { className: v.controls, children: [
|
|
430
|
-
/* @__PURE__ */ m("label", { className: v.switchLabel, children: [
|
|
431
|
-
/* @__PURE__ */ w(
|
|
432
|
-
ce,
|
|
433
|
-
{
|
|
434
|
-
checked: r,
|
|
435
|
-
onCheckedChange: c,
|
|
436
|
-
"aria-label": "Block remote resources"
|
|
437
|
-
}
|
|
438
|
-
),
|
|
439
|
-
"Block remote resources"
|
|
440
|
-
] }),
|
|
441
|
-
/* @__PURE__ */ w(I, { size: "xs", variant: "ghost", onClick: f, children: "Reload" })
|
|
442
|
-
] })
|
|
443
|
-
] }),
|
|
444
|
-
e.kind === "streamed" ? /* @__PURE__ */ m("div", { className: v.streamedNote, children: [
|
|
445
|
-
H(e.size),
|
|
446
|
-
" file streamed"
|
|
447
|
-
] }) : null,
|
|
448
|
-
_.length > 0 ? /* @__PURE__ */ m("div", { className: v.skippedNote, children: [
|
|
449
|
-
/* @__PURE__ */ m(
|
|
450
|
-
"button",
|
|
451
|
-
{
|
|
452
|
-
type: "button",
|
|
453
|
-
className: v.skippedToggle,
|
|
454
|
-
onClick: () => p((l) => !l),
|
|
455
|
-
children: [
|
|
456
|
-
_.length,
|
|
457
|
-
" reference",
|
|
458
|
-
_.length === 1 ? "" : "s",
|
|
459
|
-
" not inlined (",
|
|
460
|
-
Ye(_),
|
|
461
|
-
")"
|
|
462
|
-
]
|
|
463
|
-
}
|
|
464
|
-
),
|
|
465
|
-
i ? /* @__PURE__ */ w("ul", { className: v.skippedList, children: _.map((l) => /* @__PURE__ */ m("li", { children: [
|
|
466
|
-
l.raw,
|
|
467
|
-
" — ",
|
|
468
|
-
re[l.reason]
|
|
469
|
-
] }, l.raw)) }) : null
|
|
470
|
-
] }) : null,
|
|
471
|
-
/* @__PURE__ */ m("div", { className: v.body, children: [
|
|
472
|
-
/* @__PURE__ */ w(
|
|
473
|
-
"iframe",
|
|
474
|
-
{
|
|
475
|
-
sandbox: Ge,
|
|
476
|
-
srcDoc: B,
|
|
477
|
-
referrerPolicy: "no-referrer",
|
|
478
|
-
allow: "",
|
|
479
|
-
className: v.frame,
|
|
480
|
-
style: s === "preview" ? void 0 : { display: "none" },
|
|
481
|
-
title: k
|
|
482
|
-
}
|
|
483
|
-
),
|
|
484
|
-
s === "source" ? /* @__PURE__ */ w(ue, { path: n, content: a }) : null
|
|
485
|
-
] })
|
|
486
|
-
] });
|
|
487
|
-
}
|
|
488
|
-
export {
|
|
489
|
-
lt as HtmlViewer
|
|
490
|
-
};
|