@devries-cameron20 / t3code Mirror · read-only / commits / 9d17a02782
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 17:00 UTC

feat(web): preview archives, sqlite databases, and decoded images (#21467)

maria committed Oct 26, 2026 at 02:17 UTC 9d17a02782ae93b34f57df7e9c810968901b9fdd
38 files changed +2210 -403
apps/desktop/src/ipc/methods/window.test.ts
+1
@@ -232,6 +232,7 @@ describe("pickProjectFavicon", () => {
232 "gif",
233 "ico",
234 "heic",
235 + "heif",
236 "jpeg",
237 "jpg",
238 "png",
apps/mobile/src/features/threads/fileChipMenu.test.ts
+9 -1
@@ -59,6 +59,14 @@ describe("file chip downloads", () => {
59 ["/tmp/take%2520%23one.mp4:12", "/tmp/take%20#one.mp4", "video/mp4"],
60 ["/tmp/report.pdf", "/tmp/report.pdf", "application/pdf"],
61 ["screens/image.PNG", "/repo/screens/image.PNG", "image/png"],
62 + ["/tmp/archive.zip", "/tmp/archive.zip", "application/zip"],
63 + ["/tmp/archive.jar", "/tmp/archive.jar", "application/java-archive"],
64 + ["/tmp/archive.tar", "/tmp/archive.tar", "application/x-tar"],
65 + ["/tmp/archive.gz", "/tmp/archive.gz", "application/gzip"],
66 + ["/tmp/archive.tgz", "/tmp/archive.tgz", "application/gzip"],
67 + ["/tmp/data.sqlite", "/tmp/data.sqlite", "application/vnd.sqlite3"],
68 + ["/tmp/data.sqlite3", "/tmp/data.sqlite3", "application/vnd.sqlite3"],
69 + ["/tmp/data.db", "/tmp/data.db", "application/vnd.sqlite3"],
70 ])("offers a host download for %s", (href, path, mimeType) => {
71 const target = resolveFileChipTarget(href, "/repo")!;
72 expect(fileChipMenu(target).actions).toContainEqual({
@@ -73,7 +81,7 @@ describe("file chip downloads", () => {
81 });
82
83 it("does not offer downloads the host asset endpoint cannot serve", () => {
76 - for (const href of ["src/app.ts", "/tmp/archive.zip", "/tmp/clip.mp4.txt"]) {
84 + for (const href of ["src/app.ts", "/tmp/archive.7z", "/tmp/clip.mp4.txt"]) {
85 const target = resolveFileChipTarget(href, "/repo")!;
86 expect(fileChipShareSource(target, threadId)).toBeNull();
87 expect(fileChipMenu(target).actions.some(({ id }) => id === "save")).toBe(false);
apps/mobile/src/lib/markdownMedia.ts
+1 -1
@@ -5,7 +5,7 @@ import {
5 import {
6 audioMimeTypeFromExtension,
7 mediaMimeTypeFromExtension,
8 -} from "@t3tools/shared/filePreview";
8 +} from "@t3tools/shared/mediaPreview";
9 import { splitFilePathPosition } from "@t3tools/shared/fileLinks";
10 import { parseMarkdownFileLink } from "@t3tools/shared/markdownLinks";
11 import {
apps/server/src/assets/AssetAccess.test.ts
+33 -5
@@ -223,6 +223,14 @@ describe("AssetAccess", () => {
223 ["report.pdf", "application/pdf"],
224 ["tone.wav", "audio/wav"],
225 ["tone.webm-audio", "audio/webm"],
226 + ["archive.zip", "application/zip"],
227 + ["archive.jar", "application/java-archive"],
228 + ["archive.tar", "application/x-tar"],
229 + ["archive.gz", "application/gzip"],
230 + ["archive.tgz", "application/gzip"],
231 + ["data.sqlite", "application/vnd.sqlite3"],
232 + ["data.sqlite3", "application/vnd.sqlite3"],
233 + ["data.db", "application/vnd.sqlite3"],
234 ] as const) {
235 const filePath = path.join(outside, name);
236 yield* fs.writeFileString(filePath, "media");
@@ -1022,6 +1030,14 @@ describe("AssetAccess", () => {
1030 "otf",
1031 "woff",
1032 "woff2",
1033 + "zip",
1034 + "jar",
1035 + "tar",
1036 + "gz",
1037 + "tgz",
1038 + "sqlite",
1039 + "sqlite3",
1040 + "db",
1041 ]) {
1042 const name = `preview.${extension}`;
1043 const filePath = path.join(assetsDirectory, name);
@@ -1033,7 +1049,11 @@ describe("AssetAccess", () => {
1049 );
1050 const canonicalPath = yield* fileSystem.realPath(filePath);
1051 for (const resource of [
1036 - { _tag: "workspace-file" as const, threadId: ThreadId.make("thread-1"), path: filePath },
1052 + {
1053 + _tag: "workspace-file" as const,
1054 + threadId: ThreadId.make("thread-1"),
1055 + path: filePath,
1056 + },
1057 { _tag: "draft-workspace-file" as const, cwd: root, path: `assets/${name}` },
1058 ]) {
1059 const result = yield* issueAssetUrl({ resource, workspaceRoot: root });
@@ -1162,6 +1182,14 @@ describe("AssetAccess", () => {
1182 ["woff", "font/woff"],
1183 ["woff2", "font/woff2"],
1184 ["weba", "audio/webm"],
1185 + ["zip", "application/zip"],
1186 + ["jar", "application/java-archive"],
1187 + ["tar", "application/x-tar"],
1188 + ["gz", "application/gzip"],
1189 + ["tgz", "application/gzip"],
1190 + ["sqlite", "application/vnd.sqlite3"],
1191 + ["sqlite3", "application/vnd.sqlite3"],
1192 + ["db", "application/vnd.sqlite3"],
1193 ] as const) {
1194 const attachmentId = `thread-1-00000000-0000-4000-8000-000000000001-${extension}`;
1195 const attachmentPath = path.join(config.attachmentsDir, `${attachmentId}.${extension}`);
@@ -1172,7 +1200,7 @@ describe("AssetAccess", () => {
1200 _tag: "attachment",
1201 attachmentId,
1202 fileName: `report.${extension}`,
1175 - mimeType: "application/octet-stream",
1203 + mimeType: "text/html",
1204 disposition: "inline",
1205 },
1206 });
@@ -1196,8 +1224,8 @@ describe("AssetAccess", () => {
1224 const config = yield* ServerConfig.ServerConfig;
1225 const fileSystem = yield* FileSystem.FileSystem;
1226 const path = yield* Path.Path;
1199 - const attachmentId = "thread-1-00000000-0000-4000-8000-000000000002-zip";
1200 - const attachmentPath = path.join(config.attachmentsDir, `${attachmentId}.zip`);
1227 + const attachmentId = "thread-1-00000000-0000-4000-8000-000000000002-7z";
1228 + const attachmentPath = path.join(config.attachmentsDir, `${attachmentId}.7z`);
1229 yield* fileSystem.makeDirectory(config.attachmentsDir, { recursive: true });
1230 yield* fileSystem.writeFile(attachmentPath, new Uint8Array([1, 2, 3]));
1231
@@ -1205,7 +1233,7 @@ describe("AssetAccess", () => {
1233 resource: {
1234 _tag: "attachment",
1235 attachmentId,
1208 - fileName: "archive.zip",
1236 + fileName: "archive.7z",
1237 mimeType: "text/html",
1238 disposition: "inline",
1239 },
apps/web/package.json
+3
@@ -80,7 +80,9 @@
80 "remark-math": "6.0.0",
81 "remark-parse": "catalog:",
82 "saxes": "6.0.0",
83 + "sql.js": "1.15.0",
84 "tailwind-merge": "^3.4.0",
85 + "tiff": "7.1.3",
86 "unbash": "^5.0.0",
87 "unified": "catalog:",
88 "use-sync-external-store": "^1.6.0",
@@ -96,6 +98,7 @@
98 "@types/mdast": "^4.0.4",
99 "@types/react": "catalog:",
100 "@types/react-dom": "catalog:",
101 + "@types/sql.js": "1.4.11",
102 "@types/use-sync-external-store": "^0.0.6",
103 "@vercel/config": "^0.3.0",
104 "@vitejs/plugin-react": "^6.1.2",
apps/web/src/components/ChatMarkdown.tsx
+1 -1
@@ -63,7 +63,7 @@ import {
63 markdownImageSourceFragment,
64 } from "@t3tools/client-runtime/markdown-images";
65 import { mediaUrlReference } from "@t3tools/client-runtime/media-reference";
66 -import { mediaKindFromPath, mediaMimeTypeFromExtension } from "@t3tools/shared/filePreview";
66 +import { mediaKindFromPath, mediaMimeTypeFromExtension } from "@t3tools/shared/mediaPreview";
67 import { InlineAudioPreview } from "./files/InlineAudioPreview";
68 import * as Cause from "effect/Cause";
69 import * as Option from "effect/Option";
apps/web/src/components/chat/composerAttachmentFiles.ts
+1 -1
@@ -12,7 +12,7 @@ import type { ComposerFileAttachment, ComposerImageAttachment } from "../../comp
12 import { isHeicImageFile } from "../../lib/imageCompression";
13 import { isVideoAttachment, videoMimeType } from "../../types";
14 import { isSvgAttachment } from "@t3tools/shared/image";
15 -import { isWorkspaceImagePreviewPath } from "@t3tools/shared/filePreview";
15 +import { isWorkspaceImagePreviewPath } from "@t3tools/shared/mediaPreview";
16
17 type ComposerAttachmentFileKind = "image" | "file" | "unsupported-image";
18
apps/web/src/components/chat/markdownImageGallery.ts
+1 -1
@@ -1,4 +1,4 @@
1 -import { mediaKindFromPath } from "@t3tools/shared/filePreview";
1 +import { mediaKindFromPath } from "@t3tools/shared/mediaPreview";
2 import { mediaUrlReference } from "@t3tools/client-runtime/media-reference";
3 import type { ExpandedImageItem, ExpandedImagePreview } from "./ExpandedImagePreview";
4 import { resolveExternalWebLinkHost } from "./externalLinkContextMenu";
apps/web/src/components/files/AttachmentFilePreview.browser.test.tsx
+475 -7
@@ -1,7 +1,7 @@
1 import { act, render, stubGlobal, type Screen } from "../../../test/render";
2 import { EnvironmentId, ThreadId } from "@t3tools/contracts";
3 import { describe, expect, it, vi } from "vite-plus/test";
4 -import { page } from "vite-plus/test/browser";
4 +import { page, userEvent } from "vite-plus/test/browser";
5 import "~/index.css";
6
7 const { refresh, assetUrlState } = vi.hoisted(() => ({
@@ -25,6 +25,414 @@ import LargeTextViewer from "./LargeTextViewer";
25 import VirtualTablePreview from "./VirtualTablePreview";
26 import { OfficeFilePreview } from "./OfficeFilePreview";
27 import { MermaidFilePreview } from "./MermaidFilePreview";
28 +import JSZip from "jszip";
29 +import { boundedZip } from "./boundedZip";
30 +import BinaryViewer from "./BinaryViewer";
31 +import { decodeImagePreview } from "./decodeImagePreview";
32 +import type { BinaryWorkerResult } from "./binaryPreviewProtocol";
33 +
34 +// Real worker imports and WASM initialization can exceed waitFor's default second
35 +// when the full browser project runs concurrently on CI.
36 +describe("bounded binary previews", () => {
37 + it("preserves length-delimited local and global PAX attributes", async () => {
38 + const encode = (value: string) => new TextEncoder().encode(value);
39 + const block = (name: string, content: Uint8Array, type = "0", size = content.length) => {
40 + const bytes = new Uint8Array(512 + Math.ceil(content.length / 512) * 512);
41 + const write = (offset: number, value: string) => bytes.set(encode(value), offset);
42 + write(0, name);
43 + write(124, size.toString(8).padStart(11, "0") + "\0");
44 + bytes.fill(32, 148, 156);
45 + write(156, type);
46 + write(
47 + 148,
48 + bytes
49 + .subarray(0, 512)
50 + .reduce((sum, byte) => sum + byte, 0)
51 + .toString(8)
52 + .padStart(6, "0") + "\0 ",
53 + );
54 + bytes.set(content, 512);
55 + return bytes;
56 + };
57 + const attributes = (values: Record<string, string>) =>
58 + encode(
59 + Object.entries(values)
60 + .map(([key, value]) => {
61 + const payload = ` ${key}=${value}\n`;
62 + let record = `${encode(payload).length + 1}${payload}`;
63 + while (encode(record).length !== Number.parseInt(record, 10))
64 + record = `${encode(record).length}${payload}`;
65 + return record;
66 + })
67 + .join(""),
68 + );
69 + const chunks = [
70 + block("Global", attributes({ size: "5", mtime: "-86400" }), "g"),
71 + block("Local", attributes({ path: "café\n9 size=1\nname.txt" }), "x"),
72 + block("first.txt", encode("hello"), "0", 0),
73 + block("world.txt", encode("world"), "0", 0),
74 + block("Local", attributes({ size: "3", mtime: "-172800" }), "x"),
75 + block("short.txt", encode("bye"), "0", 0),
76 + block("again.txt", encode("again"), "0", 0),
77 + new Uint8Array(1024),
78 + ];
79 + const bytes = new Uint8Array(chunks.reduce((size, chunk) => size + chunk.length, 0));
80 + let offset = 0;
81 + for (const chunk of chunks) {
82 + bytes.set(chunk, offset);
83 + offset += chunk.length;
84 + }
85 + const worker = new Worker(new URL("./binaryPreview.worker.ts", import.meta.url), {
86 + type: "module",
87 + });
88 + const request = (input: object) =>
89 + new Promise<BinaryWorkerResult>((resolve, reject) => {
90 + worker.addEventListener("message", (event) => resolve(event.data), { once: true });
91 + worker.addEventListener("error", reject, { once: true });
92 + worker.postMessage(input, []);
93 + });
94 + try {
95 + const result = await request({
96 + type: "open",
97 + kind: "archive",
98 + name: "pax.tar",
99 + bytes: bytes.buffer,
100 + });
101 + expect(result.type).toBe("archive");
102 + if (result.type !== "archive") throw new Error("Expected archive");
103 + expect(result.entries.map((entry) => [entry.path, entry.size, entry.modified])).toEqual([
104 + ["café\n9 size=1\nname.txt", 5, "1969-12-31T00:00:00.000Z"],
105 + ["world.txt", 5, "1969-12-31T00:00:00.000Z"],
106 + ["short.txt", 3, "1969-12-30T00:00:00.000Z"],
107 + ["again.txt", 5, "1969-12-31T00:00:00.000Z"],
108 + ]);
109 + const entry = await request({ type: "entry", path: "café\n9 size=1\nname.txt" });
110 + if (entry.type !== "entry") throw new Error("Expected entry");
111 + expect(new TextDecoder().decode(entry.bytes)).toBe("hello");
112 + expect(entry.bytes.buffer.byteLength).toBe(5);
113 + entry.bytes[0] = 0;
114 + const reopened = await request({ type: "entry", path: entry.path });
115 + if (reopened.type !== "entry") throw new Error("Expected entry");
116 + expect(new TextDecoder().decode(reopened.bytes)).toBe("hello");
117 + expect(reopened.bytes.buffer.byteLength).toBe(5);
118 + } finally {
119 + worker.terminate();
120 + }
121 + });
122 +
123 + it("can leave an archive folder with a repeated separator", async () => {
124 + const bytes = new Uint8Array(2048);
125 + const write = (offset: number, value: string) =>
126 + bytes.set(new TextEncoder().encode(value), offset);
127 + write(0, "a//hello.txt");
128 + write(124, "00000000014\0");
129 + bytes.fill(32, 148, 156);
130 + write(156, "0");
131 + write(
132 + 148,
133 + bytes
134 + .subarray(0, 512)
135 + .reduce((sum, byte) => sum + byte, 0)
136 + .toString(8)
137 + .padStart(6, "0") + "\0 ",
138 + );
139 + write(512, "nested hello");
140 + const src = URL.createObjectURL(new Blob([bytes]));
141 + try {
142 + await using screen = await render(<BinaryViewer src={src} name="paths.tar" kind="archive" />);
143 + const child = () => screen.container.querySelector<HTMLButtonElement>("tbody button");
144 + await vi.waitFor(() => expect(child()?.textContent).toBe("a"), 10_000);
145 + await act(() => child()!.click());
146 + await act(() => child()!.click());
147 + await vi.waitFor(() => expect(child()?.textContent).toBe("hello.txt"));
148 + const parent = () =>
149 + screen.container.querySelector<HTMLButtonElement>('[aria-label="Parent folder"]')!;
150 + await act(() => parent().click());
151 + await act(() => parent().click());
152 + expect(parent().disabled).toBe(true);
153 + expect(child()?.textContent).toBe("a");
154 + } finally {
155 + URL.revokeObjectURL(src);
156 + }
157 + });
158 +
159 + it("uses a PAX size override for the following TAR payload and bounds it", async () => {
160 + const archive = (size: string) => {
161 + const header = (name: string, size: number, type: string) => {
162 + const bytes = new Uint8Array(512);
163 + const write = (offset: number, value: string) =>
164 + bytes.set(new TextEncoder().encode(value), offset);
165 + write(0, name);
166 + write(124, size.toString(8).padStart(11, "0") + "\0");
167 + bytes.fill(32, 148, 156);
168 + write(156, type);
169 + write(
170 + 148,
171 + bytes
172 + .reduce((sum, byte) => sum + byte, 0)
173 + .toString(8)
174 + .padStart(6, "0") + "\0 ",
175 + );
176 + return bytes;
177 + };
178 + const payload = ` size=${size}\n`;
179 + let record = `${payload.length + 1}${payload}`;
180 + while (record.length !== Number.parseInt(record, 10)) record = `${record.length}${payload}`;
181 + const bytes = new Uint8Array(3072);
182 + bytes.set(header("PaxHeader", record.length, "x"));
183 + bytes.set(new TextEncoder().encode(record), 512);
184 + bytes.set(header("hello.txt", 0, "0"), 1024);
185 + bytes.set(new TextEncoder().encode("hello"), 1536);
186 + return bytes;
187 + };
188 + for (const size of ["5", "999999999999999999999"]) {
189 + const src = URL.createObjectURL(new Blob([archive(size)]));
190 + try {
191 + await using screen = await render(<BinaryViewer src={src} name="pax.tar" kind="archive" />);
192 + if (size === "5") {
193 + await vi.waitFor(
194 + () =>
195 + expect(screen.container.querySelector("tbody button")?.textContent).toBe("hello.txt"),
196 + 10_000,
197 + );
198 + await act(() =>
199 + screen.container.querySelector<HTMLButtonElement>("tbody button")!.click(),
200 + );
201 + await vi.waitFor(
202 + () => expect(screen.container.querySelector("pre")?.textContent).toBe("hello"),
203 + 10_000,
204 + );
205 + } else {
206 + await vi.waitFor(
207 + () =>
208 + expect(screen.container.querySelector('[role="alert"]')?.textContent).toContain(
209 + "too large or damaged",
210 + ),
211 + 10_000,
212 + );
213 + }
214 + } finally {
215 + URL.revokeObjectURL(src);
216 + }
217 + }
218 + });
219 +
220 + it.each([320, 1280])(
221 + "shows generated SQLite columns and retains picker focus at %i px",
222 + async (width) => {
223 + await page.viewport(width, 800);
224 + const [{ default: initSqlJs }, { default: wasmUrl }] = await Promise.all([
225 + import("sql.js"),
226 + import("sql.js/dist/sql-wasm.wasm?url"),
227 + ]);
228 + const SQL = await initSqlJs({ locateFile: () => wasmUrl });
229 + const database = new SQL.Database();
230 + database.run(
231 + "CREATE TABLE sqliteData (price INTEGER, quantity INTEGER, total INTEGER GENERATED ALWAYS AS (price * quantity) STORED, doubled INTEGER GENERATED ALWAYS AS (price * 2) VIRTUAL); INSERT INTO sqliteData(price, quantity) VALUES (7, 3); CREATE TABLE zzInventory (stock INTEGER); INSERT INTO zzInventory VALUES(42)",
232 + );
233 + const src = URL.createObjectURL(new Blob([new Uint8Array(database.export())]));
234 + database.close();
235 + try {
236 + await using screen = await render(
237 + <BinaryViewer src={src} name="orders.sqlite" kind="sqlite" />,
238 + );
239 + await vi.waitFor(
240 + () =>
241 + expect([...screen.container.querySelectorAll("th")].map((x) => x.textContent)).toEqual([
242 + "price",
243 + "quantity",
244 + "total",
245 + "doubled",
246 + ]),
247 + 10_000,
248 + );
249 + expect([...screen.container.querySelectorAll("td")].map((x) => x.textContent)).toEqual([
250 + "7",
251 + "3",
252 + "21",
253 + "14",
254 + ]);
255 + const trigger = screen.container.querySelector<HTMLButtonElement>('[aria-label="Table"]')!;
256 + await act(() => trigger.focus());
257 + await userEvent.keyboard("{Enter}");
258 + await expect
259 + .element(page.getByRole("option", { name: "zzInventory (1 rows)" }))
260 + .toBeVisible();
261 + await userEvent.keyboard("{ArrowDown}{Enter}");
262 + await vi.waitFor(() =>
263 + expect([...screen.container.querySelectorAll("td")].map((x) => x.textContent)).toEqual([
264 + "42",
265 + ]),
266 + );
267 + await vi.waitFor(() => expect(document.activeElement).toBe(trigger));
268 + await userEvent.keyboard("{Enter}");
269 + await expect
270 + .element(page.getByRole("option", { name: "zzInventory (1 rows)" }))
271 + .toBeVisible();
272 + await userEvent.keyboard("{Escape}");
273 + } finally {
274 + URL.revokeObjectURL(src);
275 + await page.viewport(1280, 800);
276 + }
277 + },
278 + );
279 +
280 + it("reauthorizes a failed image when retry is clicked", async () => {
281 + const image =
282 + 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="2" height="2"/>';
283 + refresh
284 + .mockReset()
285 + .mockResolvedValueOnce("data:image/png;base64,broken")
286 + .mockResolvedValue(image);
287 + await using screen = await render(
288 + <AttachmentFilePreview
289 + name="photo.png"
290 + mimeType="image/png"
291 + sizeBytes={100}
292 + asset={{ environmentId: EnvironmentId.make("test-environment"), attachmentId: "image" }}
293 + />,
294 + );
295 + await vi.waitFor(() =>
296 + expect(screen.container.querySelector('[role="alert"]')?.textContent).toContain(
297 + "Unable to load image.",
298 + ),
299 + );
300 + await act(() =>
301 + screen.container.querySelector<HTMLButtonElement>('[role="alert"] button')!.click(),
302 + );
303 + await vi.waitFor(() =>
304 + expect(screen.container.querySelector("img")?.getAttribute("src")).toBe(image),
305 + );
306 + expect(refresh).toHaveBeenCalledTimes(2);
307 + });
308 +
309 + it("reads a small ZIP64 archive and rejects understated directory counts", async () => {
310 + const zip = new JSZip().file("readme.txt", "hello");
311 + const bytes = await zip.generateAsync({ type: "uint8array" });
312 + const end = bytes.length - 22;
313 + const legacy = new DataView(bytes.buffer);
314 + const extended = new Uint8Array(bytes.length + 76);
315 + extended.set(bytes.subarray(0, end));
316 + extended.set(bytes.subarray(end), end + 76);
317 + const view = new DataView(extended.buffer);
318 + view.setUint32(end, 0x06064b50, true);
319 + view.setBigUint64(end + 4, 44n, true);
320 + view.setBigUint64(end + 24, 1n, true);
321 + view.setBigUint64(end + 32, 1n, true);
322 + view.setBigUint64(end + 40, BigInt(legacy.getUint32(end + 12, true)), true);
323 + view.setBigUint64(end + 48, BigInt(legacy.getUint32(end + 16, true)), true);
324 + view.setUint32(end + 56, 0x07064b50, true);
325 + view.setBigUint64(end + 64, BigInt(end), true);
326 + view.setUint32(end + 72, 1, true);
327 + view.setUint16(end + 76 + 10, 0xffff, true);
328 + expect(
329 + new TextDecoder().decode((await boundedZip(extended.buffer)).get("readme.txt")?.bytes),
330 + ).toBe("hello");
331 +
332 + const redirected = new Uint8Array(extended.length + 56);
333 + redirected.set(extended.subarray(0, end + 56));
334 + redirected.set(extended.subarray(end + 56), end + 112);
335 + const redirect = new DataView(redirected.buffer);
336 + redirect.setUint32(end + 56, 0x06064b50, true);
337 + redirect.setBigUint64(end + 60, 44n, true);
338 + redirect.setBigUint64(end + 104, BigInt(end), true);
339 + await expect(boundedZip(redirected.buffer)).rejects.toThrow("Unsupported ZIP64 directory");
340 +
341 + const commented = new Uint8Array(extended.length + 20);
342 + commented.set(extended);
343 + const comment = new DataView(commented.buffer);
344 + comment.setUint16(extended.length - 2, 20, true);
345 + comment.setUint32(extended.length, 0x07064b50, true);
346 + comment.setBigUint64(extended.length + 8, BigInt(end), true);
347 + comment.setUint32(extended.length + 16, 1, true);
348 + const load = vi.spyOn(JSZip, "loadAsync");
349 + try {
350 + await expect(boundedZip(commented.buffer)).rejects.toThrow("Unsupported ZIP64 directory");
351 + expect(load).not.toHaveBeenCalled();
352 + } finally {
353 + load.mockRestore();
354 + }
355 +
356 + const many = new JSZip();
357 + for (let i = 0; i < 2049; i++) many.file(`file-${i}`, "");
358 + const crowded = await many.generateAsync({ type: "arraybuffer" });
359 + new DataView(crowded).setUint16(crowded.byteLength - 12, 1, true);
360 + await expect(boundedZip(crowded)).rejects.toThrow("more than 2,048 entries");
361 + });
362 +
363 + it("keeps a file and directory with the same basename accessible", async () => {
364 + const bytes = await new JSZip()
365 + .file("foo.txt", "root file")
366 + .file("foo.txt/bar.txt", "child")
367 + .generateAsync({ type: "arraybuffer" });
368 + const src = URL.createObjectURL(new Blob([bytes]));
369 + try {
370 + await using screen = await render(<BinaryViewer src={src} name="names.zip" kind="archive" />);
371 + await vi.waitFor(
372 + () => expect(screen.container.querySelectorAll("tbody button")).toHaveLength(2),
373 + 10_000,
374 + );
375 + const buttons = [...screen.container.querySelectorAll<HTMLButtonElement>("tbody button")];
376 + expect(buttons.map((button) => button.textContent)).toEqual(["foo.txt", "foo.txt"]);
377 + await act(() => buttons[1]!.click());
378 + await vi.waitFor(() => expect(screen.container.textContent).toContain("root file"), 10_000);
379 + } finally {
380 + URL.revokeObjectURL(src);
381 + }
382 + });
383 +
384 + it("keeps WhiteIsZero TIFF brightness and rejects oversized metadata before decoding", async () => {
385 + const tags = [
386 + [256, 2],
387 + [257, 1],
388 + [258, 8],
389 + [259, 1],
390 + [262, 0],
391 + [273, 134],
392 + [277, 1],
393 + [278, 1],
394 + [279, 2],
395 + [284, 1],
396 + ];
397 + const bytes = new ArrayBuffer(136);
398 + const view = new DataView(bytes);
399 + view.setUint16(0, 0x4949);
400 + view.setUint16(2, 42, true);
401 + view.setUint32(4, 8, true);
402 + view.setUint16(8, tags.length, true);
403 + tags.forEach(([tag, value], index) => {
404 + const offset = 10 + index * 12;
405 + view.setUint16(offset, tag!, true);
406 + view.setUint16(offset + 2, 4, true);
407 + view.setUint32(offset + 4, 1, true);
408 + view.setUint32(offset + 8, value!, true);
409 + });
410 + view.setUint8(135, 255);
411 + const src = URL.createObjectURL(new Blob([bytes]));
412 + try {
413 + const blob = await decodeImagePreview(src, false, new AbortController().signal);
414 + const bitmap = await createImageBitmap(blob);
415 + const canvas = new OffscreenCanvas(2, 1);
416 + const context = canvas.getContext("2d")!;
417 + context.drawImage(bitmap, 0, 0);
418 + expect([...context.getImageData(0, 0, 2, 1).data]).toEqual([
419 + 255, 255, 255, 255, 0, 0, 0, 255,
420 + ]);
421 + bitmap.close();
422 + } finally {
423 + URL.revokeObjectURL(src);
424 + }
425 + view.setUint32(14, 1_000_000, true);
426 + const invalid = URL.createObjectURL(new Blob([bytes]));
427 + try {
428 + await expect(
429 + decodeImagePreview(invalid, false, new AbortController().signal),
430 + ).rejects.toThrow("metadata");
431 + } finally {
432 + URL.revokeObjectURL(invalid);
433 + }
434 + });
435 +});
436 import { OFFICE_PREVIEW_MAX_COLUMNS, type OfficeWorkerResult } from "./officePreviewProtocol";
437
438 describe("large text preview recovery", () => {
@@ -235,8 +643,9 @@ describe("large text preview recovery", () => {
643 await using screen = await render(
644 <LargeTextViewer src={src} name="latin.txt" delimiter={null} />,
645 );
238 - await vi.waitFor(() =>
239 - expect(screen.container.querySelector('[role="alert"]')).not.toBeNull(),
646 + await vi.waitFor(
647 + () => expect(screen.container.querySelector('[role="alert"]')).not.toBeNull(),
648 + 10_000,
649 );
650 } finally {
651 URL.revokeObjectURL(src);
@@ -265,7 +674,7 @@ describe("large text preview recovery", () => {
674 <LargeTextViewer src={src} name="log.txt" delimiter={null} />
675 </div>,
676 );
268 - await vi.waitFor(() => expect(screen.container.textContent).toContain("current-40"));
677 + await vi.waitFor(() => expect(screen.container.textContent).toContain("current-40"), 10_000);
678 expect(screen.container.textContent).not.toContain("old-");
679 } finally {
680 URL.revokeObjectURL(src);
@@ -417,11 +826,15 @@ describe("large text preview recovery", () => {
826 await using screen = await render(
827 <LargeTextViewer name="log.txt" text={"bad\0text"} delimiter={null} />,
828 );
420 - await vi.waitFor(() =>
421 - expect(screen.container.textContent).toContain("This file contains binary data."),
829 + await vi.waitFor(
830 + () => expect(screen.container.textContent).toContain("This file contains binary data."),
831 + 10_000,
832 );
833 await screen.rerender(<LargeTextViewer name="log.txt" text="" delimiter={null} />);
424 - await vi.waitFor(() => expect(screen.container.textContent).toContain("This file is empty."));
834 + await vi.waitFor(
835 + () => expect(screen.container.textContent).toContain("This file is empty."),
836 + 10_000,
837 + );
838 expect(screen.container.querySelector('[role="alert"]')).toBeNull();
839 });
840
@@ -1776,6 +2189,61 @@ it("copies every indexed line rather than the mounted preview rows", async () =>
2189 expect(screen.container.querySelector('[role="alert"]')).toBeNull();
2190 });
2191
2192 +it.each(["archive", "sqlite"] as const)(
2193 + "reauthorizes and retries a failed %s attachment",
2194 + async (kind) => {
2195 + const bad = URL.createObjectURL(new Blob(["invalid"]));
2196 + let bytes: Uint8Array<ArrayBuffer>;
2197 + if (kind === "archive")
2198 + bytes = new Uint8Array(
2199 + await new JSZip().file("recovered.txt", "ok").generateAsync({ type: "uint8array" }),
2200 + );
2201 + else {
2202 + const [{ default: initSqlJs }, { default: wasmUrl }] = await Promise.all([
2203 + import("sql.js"),
2204 + import("sql.js/dist/sql-wasm.wasm?url"),
2205 + ]);
2206 + const SQL = await initSqlJs({ locateFile: () => wasmUrl });
2207 + const database = new SQL.Database();
2208 + database.run(
2209 + "CREATE TABLE recovered (value TEXT); INSERT INTO recovered VALUES('retry succeeded')",
2210 + );
2211 + bytes = new Uint8Array(database.export());
2212 + database.close();
2213 + }
2214 + const good = URL.createObjectURL(new Blob([bytes]));
2215 + refresh.mockReset().mockResolvedValueOnce(bad).mockResolvedValue(good);
2216 + try {
2217 + await using screen = await render(
2218 + <AttachmentFilePreview
2219 + name={kind === "archive" ? "retry.zip" : "retry.sqlite"}
2220 + mimeType="application/octet-stream"
2221 + sizeBytes={bytes.length}
2222 + asset={{ environmentId: EnvironmentId.make("test"), attachmentId: "retry" }}
2223 + />,
2224 + );
2225 + await vi.waitFor(
2226 + () => expect(screen.container.querySelector('[role="alert"] button')).not.toBeNull(),
2227 + 10_000,
2228 + );
2229 + await act(() =>
2230 + screen.container.querySelector<HTMLButtonElement>('[role="alert"] button')!.click(),
2231 + );
2232 + await vi.waitFor(
2233 + () =>
2234 + expect(screen.container.textContent).toContain(
2235 + kind === "archive" ? "recovered.txt" : "retry succeeded",
2236 + ),
2237 + 10_000,
2238 + );
2239 + expect(refresh).toHaveBeenCalledTimes(2);
2240 + } finally {
2241 + URL.revokeObjectURL(bad);
2242 + URL.revokeObjectURL(good);
2243 + }
2244 + },
2245 +);
2246 +
2247 it("loads a font attachment through the lazy preview", async () => {
2248 const { default: fontUrl } =
2249 await import("../../../node_modules/@betteroffice/fonts/assets/Carlito-Regular.ttf?url");
apps/web/src/components/files/AttachmentFilePreview.tsx
+17 -9
@@ -23,6 +23,8 @@ import { useCopyToClipboard } from "~/hooks/useCopyToClipboard";
23 import { useClientSettings, updateClientSettings } from "~/hooks/useSettings";
24 import { cn } from "~/lib/utils";
25
26 +import { BinaryFilePreview } from "./BinaryFilePreview";
27 +import { PreviewImage } from "./PreviewImage";
28 import { AudioPreview } from "./AudioPreview";
29 import { BrowserDocumentFrame } from "./BrowserDocumentFrame";
30 import { DelimitedTablePreview } from "./DelimitedTablePreview";
@@ -284,6 +286,14 @@ export function AttachmentFilePreview(props: {
286 ) : (
287 <ReadOnlySourcePreview name={props.name} text={content.text} />
288 )
289 + ) : kind === "archive" || kind === "sqlite" ? (
290 + <BinaryFilePreview
291 + key={revision}
292 + src={url}
293 + name={props.name}
294 + kind={kind}
295 + onRetry={() => setRevision((value) => value + 1)}
296 + />
297 ) : kind === "font" ? (
298 <Suspense fallback={<FileSurfaceLoading />}>
299 <FontFilePreview src={url} name={props.name} />
@@ -319,15 +329,13 @@ export function AttachmentFilePreview(props: {
329 />
330 </div>
331 ) : kind === "image" ? (
322 - // oxlint-disable-next-line t3code/require-centered-scroll-gutter -- The image is capped at max-h-full max-w-full, so this never scrolls.
323 - <div className="flex min-h-0 flex-1 items-center justify-center overflow-auto p-4">
324 - <img
325 - src={url}
326 - alt={props.name}
327 - className="max-h-full max-w-full object-contain"
328 - onError={() => setError("Unable to load image.")}
329 - />
330 - </div>
332 + <PreviewImage
333 + key={url}
334 + src={url}
335 + name={props.name}
336 + mimeType={props.mimeType}
337 + onError={() => setError("Unable to load image.")}
338 + />
339 ) : (
340 <div className="flex min-h-0 flex-1 flex-col items-center justify-center gap-1 px-6 text-center">
341 <p className="text-sm font-medium">No preview for this file</p>
apps/web/src/components/files/BinaryFilePreview.tsx new
+18
@@ -0,0 +1,18 @@
1 +import { lazy, Suspense } from "react";
2 +
3 +import { FileSurfaceLoading } from "./fileSurfaceChrome";
4 +
5 +const BinaryViewer = lazy(() => import("./BinaryViewer"));
6 +
7 +export function BinaryFilePreview(props: {
8 + readonly src: string;
9 + readonly name: string;
10 + readonly kind: "archive" | "sqlite";
11 + readonly onRetry?: () => void;
12 +}) {
13 + return (
14 + <Suspense fallback={<FileSurfaceLoading />}>
15 + <BinaryViewer key={props.src} {...props} />
16 + </Suspense>
17 + );
18 +}
apps/web/src/components/files/BinaryViewer.tsx new
+393
@@ -0,0 +1,393 @@
1 +/* oxlint-disable react/no-array-index-key -- Read-only cells retain their database row and column positions. */
2 +import {
3 + decodeFilePreviewText,
4 + filePreviewKind,
5 + hostPreviewMimeTypeFromExtension,
6 +} from "@t3tools/shared/filePreview";
7 +import { formatAttachmentSize } from "@t3tools/client-runtime/state/attachments";
8 +import { ChevronLeftIcon, ChevronRightIcon, FileIcon, FolderIcon } from "lucide-react";
9 +import { lazy, Suspense, useEffect, useRef, useState } from "react";
10 +
11 +import {
12 + Select,
13 + SelectTrigger,
14 + SelectValue,
15 + SelectPopup,
16 + SelectItem,
17 +} from "~/components/ui/select";
18 +
19 +import {
20 + FileSurfaceAction,
21 + FileSurfaceFailure,
22 + FileSurfaceLoading,
23 + FileSurfaceNotice,
24 +} from "./fileSurfaceChrome";
25 +import {
26 + SQLITE_PAGE_SIZE,
27 + type BinaryWorkerRequest,
28 + type BinaryWorkerResult,
29 +} from "./binaryPreviewProtocol";
30 +import { PreviewImage } from "./PreviewImage";
31 +import { readBinaryPreview } from "./readBinaryPreview";
32 +
33 +const SourcePreview = lazy(() => import("./ReadOnlySourcePreview"));
34 +type Archive = Extract<BinaryWorkerResult, { type: "archive" }>;
35 +type Database = Extract<BinaryWorkerResult, { type: "sqlite" }>;
36 +type Rows = Extract<BinaryWorkerResult, { type: "rows" }>;
37 +
38 +function ArchiveFile(props: { readonly path: string; readonly bytes: Uint8Array<ArrayBuffer> }) {
39 + const [url, setUrl] = useState<string | null>(null);
40 + const kind = filePreviewKind({ name: props.path });
41 + const text = (() => {
42 + if (!["text", "markdown", "html", "mermaid"].includes(kind)) return null;
43 + try {
44 + return decodeFilePreviewText(props.bytes);
45 + } catch {
46 + return null;
47 + }
48 + })();
49 + // oxlint-disable-next-line t3code/react-effect-budget -- Create an object URL for the extracted image and revoke it when the entry changes or unmounts.
50 + useEffect(() => {
51 + if (kind !== "image") return;
52 + const extension = props.path.slice(props.path.lastIndexOf("."));
53 + const objectUrl = URL.createObjectURL(
54 + new Blob([props.bytes], {
55 + type: hostPreviewMimeTypeFromExtension(extension) ?? "application/octet-stream",
56 + }),
57 + );
58 + // oxlint-disable-next-line react/set-state-in-effect -- Publish a Blob URL only after registering its cleanup.
59 + setUrl(objectUrl);
60 + return () => URL.revokeObjectURL(objectUrl);
61 + }, [props.bytes, props.path, kind]);
62 + if (kind === "image")
63 + return url ? <PreviewImage key={url} src={url} name={props.path} /> : <FileSurfaceLoading />;
64 + if (!text)
65 + return (
66 + <FileSurfaceFailure message="Only UTF-8 text and images can be opened inside an archive." />
67 + );
68 + return (
69 + <>
70 + {text.truncated ? (
71 + <FileSurfaceNotice>Preview limited to the first 1 MB.</FileSurfaceNotice>
72 + ) : null}
73 + <Suspense fallback={<FileSurfaceLoading />}>
74 + <SourcePreview name={props.path} text={text.text} />
75 + </Suspense>
76 + </>
77 + );
78 +}
79 +
80 +export default function BinaryViewer(props: {
81 + readonly src: string;
82 + readonly name: string;
83 + readonly kind: "archive" | "sqlite";
84 + readonly onRetry?: () => void;
85 +}) {
86 + const [sizeBytes, setSizeBytes] = useState<number | null>(null);
87 + const [archive, setArchive] = useState<Archive | null>(null);
88 + const [database, setDatabase] = useState<Database | null>(null);
89 + const [rows, setRows] = useState<Rows | null>(null);
90 + const [entry, setEntry] = useState<Extract<BinaryWorkerResult, { type: "entry" }> | null>(null);
91 + const [folder, setFolder] = useState("");
92 + const [selectedPath, setSelectedPath] = useState<string | null>(null);
93 + const [selectedTable, setSelectedTable] = useState("");
94 + const [page, setPage] = useState(0);
95 + const [busy, setBusy] = useState(true);
96 + const [error, setError] = useState<string | null>(null);
97 + const workerRef = useRef<Worker | null>(null);
98 + const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
99 + const send = (request: BinaryWorkerRequest) => {
100 + setBusy(true);
101 + setError(null);
102 + if (timerRef.current) clearTimeout(timerRef.current);
103 + timerRef.current = setTimeout(() => {
104 + setError("This file took too long to preview. Close it and try again.");
105 + setBusy(false);
106 + workerRef.current?.terminate();
107 + workerRef.current = null;
108 + }, 15_000);
109 + workerRef.current?.postMessage(request);
110 + };
111 + // oxlint-disable-next-line t3code/react-effect-budget -- Own the binary fetch, archive or database worker, message subscription, and request timeout for this file.
112 + useEffect(() => {
113 + const controller = new AbortController();
114 + const worker = new Worker(new URL("./binaryPreview.worker.ts", import.meta.url), {
115 + type: "module",
116 + });
117 + workerRef.current = worker;
118 + const fail = (message: string) => {
119 + if (controller.signal.aborted) return;
120 + setError(message);
121 + setBusy(false);
122 + controller.abort();
123 + worker.terminate();
124 + workerRef.current = null;
125 + if (timerRef.current) clearTimeout(timerRef.current);
126 + };
127 + timerRef.current = setTimeout(
128 + () => fail("This file took too long to preview. Close it and try again."),
129 + 30_000,
130 + );
131 + worker.addEventListener("error", () =>
132 + fail("Could not load the file viewer. Close it and try again."),
133 + );
134 + worker.addEventListener("message", (event: MessageEvent<BinaryWorkerResult>) => {
135 + if (controller.signal.aborted) return;
136 + if (timerRef.current) clearTimeout(timerRef.current);
137 + const result = event.data;
138 + setBusy(false);
139 + if (result.type === "error") setError(result.message);
140 + else if (result.type === "archive") setArchive(result);
141 + else if (result.type === "entry") setEntry(result);
142 + else if (result.type === "rows") setRows(result);
143 + else {
144 + setDatabase(result);
145 + const table = result.tables[0];
146 + if (table) {
147 + setSelectedTable(table.name);
148 + send({ type: "rows", table: table.name, page: 0 });
149 + }
150 + }
151 + });
152 + void readBinaryPreview(props.src, controller.signal)
153 + .then((bytes) => {
154 + if (!controller.signal.aborted) {
155 + setSizeBytes(bytes.byteLength);
156 + worker.postMessage({ type: "open", name: props.name, kind: props.kind, bytes }, [bytes]);
157 + }
158 + })
159 + .catch((cause: unknown) =>
160 + fail(cause instanceof Error ? cause.message : "Could not read this file."),
161 + );
162 + return () => {
163 + controller.abort();
164 + worker.terminate();
165 + workerRef.current = null;
166 + if (timerRef.current) clearTimeout(timerRef.current);
167 + };
168 + // oxlint-disable-next-line react/exhaustive-effect-dependencies -- One worker owns this keyed file and its message stream.
169 + }, [props.src, props.kind, props.name]);
170 + const table = database?.tables.find((item) => item.name === selectedTable);
171 + const selectPage = (next: number, name = selectedTable) => {
172 + setSelectedTable(name);
173 + setPage(next);
174 + setRows(null);
175 + send({ type: "rows", table: name, page: next });
176 + };
177 + const children = new Map<
178 + string,
179 + { path: string; directory: boolean; size: number; modified: string | null }
180 + >();
181 + for (const item of archive?.entries ?? []) {
182 + if (!item.path.startsWith(folder)) continue;
183 + const rest = item.path.slice(folder.length).replace(/\/$/, "");
184 + if (!rest) continue;
185 + const slash = rest.indexOf("/");
186 + const path = slash < 0 ? item.path.replace(/\/$/, "") : `${folder}${rest.slice(0, slash)}`;
187 + const directory = slash >= 0 || item.directory;
188 + const key = `${path}${directory ? "/" : ""}`;
189 + const previous = children.get(key);
190 + if (previous) previous.size += item.size;
191 + else children.set(key, { path, directory, size: item.size, modified: item.modified });
192 + }
193 + return (
194 + <div className="flex min-h-0 flex-1 flex-col overflow-hidden">
195 + {archive ? (
196 + <div className="flex h-10 shrink-0 items-center gap-2 border-b border-border/60 px-3 text-xs">
197 + <FileSurfaceAction
198 + label={selectedPath ? "Back to archive" : "Parent folder"}
199 + disabled={!selectedPath && !folder}
200 + onPress={() => {
201 + setError(null);
202 + setEntry(null);
203 + if (selectedPath) setSelectedPath(null);
204 + else setFolder(folder.replace(/(?:[^/]+)?\/$/, ""));
205 + }}
206 + >
207 + <ChevronLeftIcon className="size-3.5" />
208 + </FileSurfaceAction>
209 + <span className="min-w-0 flex-1 truncate">
210 + {selectedPath ?? (folder || "Archive contents")}
211 + </span>
212 + <span className="shrink-0 text-muted-foreground">
213 + {archive.entries.length.toLocaleString()} entries
214 + {sizeBytes !== null ? ` · ${formatAttachmentSize(sizeBytes)}` : ""}
215 + </span>
216 + </div>
217 + ) : null}
218 + {database && table ? (
219 + <>
220 + <div className="flex min-h-10 shrink-0 flex-wrap items-center gap-2 border-b border-border/60 px-3 py-1 text-xs">
221 + <div className="min-w-32 flex-1">
222 + <Select
223 + value={selectedTable}
224 + onValueChange={(value) => {
225 + if (!busy && value !== null) selectPage(0, value);
226 + }}
227 + >
228 + <SelectTrigger aria-label="Table" aria-disabled={busy} aria-busy={busy} size="xs">
229 + <SelectValue>
230 + {table.name} ({table.count.toLocaleString()} rows)
231 + </SelectValue>
232 + </SelectTrigger>
233 + <SelectPopup>
234 + {database.tables.map((item) => (
235 + <SelectItem key={item.name} value={item.name}>
236 + {item.name} ({item.count.toLocaleString()} rows)
237 + </SelectItem>
238 + ))}
239 + </SelectPopup>
240 + </Select>
241 + </div>
242 + <FileSurfaceAction
243 + label="Previous rows"
244 + disabled={busy || page === 0}
245 + onPress={() => selectPage(page - 1)}
246 + >
247 + <ChevronLeftIcon className="size-3.5" />
248 + </FileSurfaceAction>
249 + <span className="shrink-0 tabular-nums" aria-live="polite">
250 + {table.count === 0
251 + ? "0 rows"
252 + : `${page * SQLITE_PAGE_SIZE + 1}–${Math.min(table.count, (page + 1) * SQLITE_PAGE_SIZE)} of ${table.count.toLocaleString()}`}
253 + </span>
254 + <FileSurfaceAction
255 + label="Next rows"
256 + disabled={busy || (page + 1) * SQLITE_PAGE_SIZE >= table.count}
257 + onPress={() => selectPage(page + 1)}
258 + >
259 + <ChevronRightIcon className="size-3.5" />
260 + </FileSurfaceAction>
261 + </div>
262 + <div
263 + className="border-b border-border/60 px-3 py-2 text-xs text-muted-foreground tabular-nums"
264 + role="status"
265 + >
266 + {table.count.toLocaleString()} rows · {rows?.columns.length ?? "…"} columns
267 + {sizeBytes !== null ? ` · ${formatAttachmentSize(sizeBytes)}` : ""}
268 + </div>
269 + <FileSurfaceNotice>
270 + Read-only. Up to 50 columns and 1,024 characters per cell. Blob contents are omitted.
271 + </FileSurfaceNotice>
272 + </>
273 + ) : null}
274 + {error ? (
275 + <FileSurfaceFailure
276 + message={error}
277 + {...(props.onRetry ? { onRetry: props.onRetry } : {})}
278 + />
279 + ) : busy ? (
280 + <FileSurfaceLoading />
281 + ) : selectedPath ? (
282 + entry ? (
283 + <ArchiveFile key={entry.path} path={entry.path} bytes={entry.bytes} />
284 + ) : null
285 + ) : archive ? (
286 + <div className="scrollbar-gutter-both min-h-0 flex-1 overflow-auto">
287 + <table
288 + aria-label="Archive entries"
289 + className="w-full border-separate border-spacing-0 text-xs"
290 + >
291 + <thead className="sticky top-0 bg-background text-muted-foreground">
292 + <tr>
293 + <th scope="col" className="px-3 py-2 text-left font-normal">
294 + Name
295 + </th>
296 + <th scope="col" className="px-3 py-2 text-right font-normal">
297 + Size
298 + </th>
299 + <th scope="col" className="px-3 py-2 text-right font-normal">
300 + Modified
301 + </th>
302 + </tr>
303 + </thead>
304 + <tbody>
305 + {[...children.values()]
306 + .sort(
307 + (a, b) =>
308 + Number(b.directory) - Number(a.directory) || a.path.localeCompare(b.path),
309 + )
310 + .map((item) => (
311 + <tr
312 + key={`${item.path}${item.directory ? "/" : ""}`}
313 + className="hover:bg-muted/40"
314 + >
315 + <td className="max-w-0 border-b border-border/60">
316 + <button
317 + type="button"
318 + className="flex w-full items-center gap-2 px-3 py-2 text-left hover:text-primary focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"
319 + onClick={() => {
320 + if (item.directory) setFolder(`${item.path}/`);
321 + else {
322 + setSelectedPath(item.path);
323 + setEntry(null);
324 + send({ type: "entry", path: item.path });
325 + }
326 + }}
327 + >
328 + {item.directory ? (
329 + <FolderIcon className="size-4 shrink-0 text-muted-foreground" />
330 + ) : (
331 + <FileIcon className="size-4 shrink-0 text-muted-foreground" />
332 + )}
333 + <span className="truncate">{item.path.slice(folder.length)}</span>
334 + </button>
335 + </td>
336 + <td className="w-20 border-b border-border/60 px-3 py-2 text-right whitespace-nowrap text-muted-foreground tabular-nums">
337 + {formatAttachmentSize(item.size)}
338 + </td>
339 + <td className="w-28 border-b border-border/60 px-3 py-2 text-right whitespace-nowrap text-muted-foreground">
340 + {item.modified ? new Date(item.modified).toLocaleDateString() : "-"}
341 + </td>
342 + </tr>
343 + ))}
344 + </tbody>
345 + </table>
346 + {children.size === 0 ? (
347 + <p className="p-6 text-xs text-muted-foreground">This folder is empty.</p>
348 + ) : null}
349 + </div>
350 + ) : rows ? (
351 + <div className="scrollbar-gutter-both min-h-0 flex-1 overflow-auto">
352 + <table
353 + aria-label={`${props.name}: ${rows.table}`}
354 + className="min-w-full border-separate border-spacing-0 text-xs"
355 + >
356 + <thead className="sticky top-0 bg-background">
357 + <tr>
358 + {rows.columns.map((name) => (
359 + <th
360 + key={name}
361 + scope="col"
362 + className="border-r border-b border-border/60 px-3 py-2 text-left font-medium whitespace-nowrap"
363 + >
364 + {name}
365 + </th>
366 + ))}
367 + </tr>
368 + </thead>
369 + <tbody>
370 + {rows.rows.map((row, index) => (
371 + <tr key={index} className="even:bg-muted/30">
372 + {row.map((cell, column) => (
373 + <td
374 + key={column}
375 + className="max-w-80 min-w-32 border-r border-b border-border/60 px-3 py-1.5 align-top whitespace-pre-wrap break-words tabular-nums"
376 + >
377 + {cell}
378 + </td>
379 + ))}
380 + </tr>
381 + ))}
382 + </tbody>
383 + </table>
384 + {rows.rows.length === 0 ? (
385 + <p className="p-6 text-xs text-muted-foreground">This table is empty.</p>
386 + ) : null}
387 + </div>
388 + ) : (
389 + <p className="p-6 text-xs text-muted-foreground">This database has no readable tables.</p>
390 + )}
391 + </div>
392 + );
393 +}
apps/web/src/components/files/FilePreviewPanel.tsx
+14 -15
@@ -16,6 +16,7 @@ import {
16 isWorkspaceFontPreviewPath,
17 isWorkspaceVideoPreviewPath,
18 officePreviewKind,
19 + binaryPreviewKind,
20 } from "@t3tools/shared/filePreview";
21 import { useAtomValue } from "@effect/atom-react";
22 import {
@@ -81,6 +82,7 @@ import { AttachmentFilePreview } from "./AttachmentFilePreview";
82 import { AudioPreview } from "./AudioPreview";
83 import { BrowserDocumentFrame, isPdfPreviewFile } from "./BrowserDocumentFrame";
84 import { DelimitedTablePreview } from "./DelimitedTablePreview";
85 +import { PreviewImage } from "./PreviewImage";
86 import FileBrowserPanel from "./FileBrowserPanel";
87 import { FileBreadcrumbs } from "./FileBreadcrumbs";
88 import { breadcrumbPathOf, retainedBreadcrumbTrail, trailChildOf } from "./filePath";
@@ -169,14 +171,16 @@ function WorkspaceImagePreview(props: {
171 readonly workspaceMutationId: string | null;
172 }) {
173 const resource = workspaceAssetResource({
172 - kind: "workspace-file",
174 + kind:
175 + mediaFileReference(props.absolutePath, props.workspaceRoot).relativePath !== undefined
176 + ? "workspace-file"
177 + : "media-file",
178 threadRef: props.threadRef,
179 draft: props.draft,
180 workspaceRoot: props.workspaceRoot,
181 absolutePath: props.absolutePath,
182 });
183 const assetUrl = useAssetUrlState(props.environmentId, resource);
179 - const [failedUrl, setFailedUrl] = useState<string | null>(null);
184 const revisionSuffix =
185 props.workspaceMutationId === null
186 ? ""
@@ -190,7 +194,7 @@ function WorkspaceImagePreview(props: {
194 asset: { environmentId: props.environmentId, resource },
195 };
196
193 - if (assetUrl._tag === "Failure" || (imageUrl !== null && failedUrl === imageUrl)) {
197 + if (assetUrl._tag === "Failure") {
198 return (
199 <MediaActions source={actionsSource}>
200 <div className="flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive">
@@ -201,17 +205,11 @@ function WorkspaceImagePreview(props: {
205 }
206
207 return assetUrl._tag === "Success" && imageUrl !== null ? (
204 - // oxlint-disable-next-line t3code/require-centered-scroll-gutter -- The image is capped at max-h-full max-w-full, so this never scrolls.
205 - <div className="flex min-h-0 flex-1 items-center justify-center overflow-auto p-4">
206 - <MediaActions source={actionsSource}>
207 - <img
208 - className="max-h-full max-w-full object-contain"
209 - src={imageUrl}
210 - alt={props.alt}
211 - onError={() => setFailedUrl(imageUrl)}
212 - />
213 - </MediaActions>
214 - </div>
208 + <MediaActions source={actionsSource}>
209 + <div className="flex min-h-0 flex-1 flex-col overflow-hidden">
210 + <PreviewImage key={imageUrl} src={imageUrl} name={props.alt} />
211 + </div>
212 + </MediaActions>
213 ) : (
214 <div className="flex min-h-0 flex-1 items-center justify-center text-muted-foreground">
215 <Spinner size="lg" />
@@ -1025,7 +1023,8 @@ export default function FilePreviewPanel({
1023 const isPdf = relativePath !== null && isPdfPreviewFile(relativePath);
1024 const isDocument =
1025 relativePath !== null &&
1028 - (officePreviewKind({ name: relativePath }) !== null ||
1026 + (binaryPreviewKind({ name: relativePath }) !== null ||
1027 + officePreviewKind({ name: relativePath }) !== null ||
1028 isWorkspaceFontPreviewPath(relativePath));
1029 const isHtml = relativePath !== null && !isPdf && isBrowserPreviewFile(relativePath);
1030 const isHostFile =
apps/web/src/components/files/PreviewImage.tsx new
+18
@@ -0,0 +1,18 @@
1 +import { lazy, Suspense } from "react";
2 +
3 +import { FileSurfaceLoading } from "./fileSurfaceChrome";
4 +
5 +const PreviewImageContent = lazy(() => import("./PreviewImageContent"));
6 +
7 +export function PreviewImage(props: {
8 + readonly src: string;
9 + readonly name: string;
10 + readonly mimeType?: string;
11 + readonly onError?: () => void;
12 +}) {
13 + return (
14 + <Suspense fallback={<FileSurfaceLoading />}>
15 + <PreviewImageContent {...props} />
16 + </Suspense>
17 + );
18 +}
apps/web/src/components/files/PreviewImageContent.tsx new
+134
@@ -0,0 +1,134 @@
1 +import { useLayoutEffect, useRef, useState } from "react";
2 +import { MaximizeIcon, MinusIcon, PlusIcon, ScanIcon } from "lucide-react";
3 +import { ExpandedImageDialog } from "~/components/chat/ExpandedImageDialog";
4 +import { observeResize } from "~/lib/observeResize";
5 +import { AttachmentImage } from "../media/AttachmentImage";
6 +import { FileSurfaceAction, FileSurfaceFailure } from "./fileSurfaceChrome";
7 +
8 +export default function PreviewImageContent(props: {
9 + readonly src: string;
10 + readonly name: string;
11 + readonly mimeType?: string;
12 + readonly onError?: () => void;
13 +}) {
14 + const [failed, setFailed] = useState(false);
15 + const [expanded, setExpanded] = useState(false);
16 + const [natural, setNatural] = useState({ width: 0, height: 0 });
17 + const [viewport, setViewport] = useState({ width: 0, height: 0 });
18 + const [zoom, setZoom] = useState<number | null>(null);
19 + const ref = useRef<HTMLDivElement>(null);
20 + // oxlint-disable-next-line t3code/react-effect-budget -- Measure the image viewport before paint and observe resizes to keep fit-to-view scaling accurate.
21 + useLayoutEffect(() => {
22 + const node = ref.current;
23 + if (!node) return;
24 + const update = () => setViewport({ width: node.clientWidth, height: node.clientHeight });
25 + update();
26 + return observeResize(node, update);
27 + }, []);
28 + const fit = natural.width
29 + ? Math.min(
30 + 1,
31 + Math.max(1, viewport.width - 32) / natural.width,
32 + Math.max(1, viewport.height - 32) / natural.height,
33 + )
34 + : 1;
35 + const scale = zoom ?? fit;
36 + const changeZoom = (factor: number) => setZoom(Math.max(0.05, Math.min(8, scale * factor)));
37 + if (failed) return <FileSurfaceFailure message="Unable to load image." />;
38 + return (
39 + <>
40 + <div className="flex min-h-10 shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border/60 px-3 py-1 text-xs text-muted-foreground">
41 + <span className="tabular-nums">
42 + {natural.width
43 + ? `${natural.width.toLocaleString()} × ${natural.height.toLocaleString()}`
44 + : "Loading image…"}
45 + </span>
46 + <div className="flex items-center gap-1">
47 + <FileSurfaceAction
48 + label="Zoom out"
49 + disabled={!natural.width || scale <= 0.05}
50 + onPress={() => changeZoom(1 / 1.25)}
51 + >
52 + <MinusIcon className="size-3.5" />
53 + </FileSurfaceAction>
54 + <span className="min-w-10 text-center tabular-nums">{Math.round(scale * 100)}%</span>
55 + <FileSurfaceAction
56 + label="Zoom in"
57 + disabled={!natural.width || scale >= 8}
58 + onPress={() => changeZoom(1.25)}
59 + >
60 + <PlusIcon className="size-3.5" />
61 + </FileSurfaceAction>
62 + <FileSurfaceAction
63 + label="Fit image"
64 + pressed={zoom === null}
65 + onPress={() => setZoom(null)}
66 + >
67 + <ScanIcon className="size-3.5" />
68 + </FileSurfaceAction>
69 + <FileSurfaceAction
70 + label="Actual image size"
71 + pressed={zoom === 1}
72 + onPress={() => setZoom(1)}
73 + >
74 + <MaximizeIcon className="size-3.5" />
75 + </FileSurfaceAction>
76 + </div>
77 + </div>
78 + <div ref={ref} className="min-h-0 flex-1 overflow-auto">
79 + <div
80 + className="flex min-h-full min-w-full items-center justify-center p-4"
81 + style={{
82 + width: natural.width ? natural.width * scale + 32 : undefined,
83 + height: natural.height ? natural.height * scale + 32 : undefined,
84 + }}
85 + >
86 + <button
87 + type="button"
88 + aria-label={`Zoom ${props.name}`}
89 + className="shrink-0 cursor-zoom-in"
90 + onClick={() => setExpanded(true)}
91 + >
92 + <AttachmentImage
93 + name={props.name}
94 + mimeType={props.mimeType}
95 + src={props.src}
96 + alt={props.name}
97 + className="block max-w-none"
98 + style={
99 + natural.width
100 + ? { width: natural.width * scale, height: natural.height * scale }
101 + : { maxWidth: "100%" }
102 + }
103 + onLoad={(event) =>
104 + setNatural({
105 + width: event.currentTarget.naturalWidth,
106 + height: event.currentTarget.naturalHeight,
107 + })
108 + }
109 + onError={() => {
110 + setFailed(true);
111 + props.onError?.();
112 + }}
113 + />
114 + </button>
115 + </div>
116 + </div>
117 + {expanded ? (
118 + <ExpandedImageDialog
119 + preview={{
120 + images: [
121 + {
122 + src: props.src,
123 + name: props.name,
124 + ...(props.mimeType ? { mimeType: props.mimeType } : {}),
125 + },
126 + ],
127 + index: 0,
128 + }}
129 + onClose={() => setExpanded(false)}
130 + />
131 + ) : null}
132 + </>
133 + );
134 +}
apps/web/src/components/files/binaryPreview.worker.ts new
+249
@@ -0,0 +1,249 @@
1 +import type { Database } from "sql.js";
2 +
3 +import { boundedZip } from "./boundedZip";
4 +import {
5 + ARCHIVE_ENTRY_MAX_BYTES,
6 + ARCHIVE_MAX_ENTRIES,
7 + ARCHIVE_MAX_RATIO,
8 + BINARY_PREVIEW_MAX_BYTES,
9 + SQLITE_PAGE_SIZE,
10 + type ArchiveEntry,
11 + type BinaryWorkerRequest,
12 + type BinaryWorkerResult,
13 +} from "./binaryPreviewProtocol";
14 +
15 +let database: Database | null = null;
16 +let tables: string[] = [];
17 +let files = new Map<string, Uint8Array<ArrayBuffer>>();
18 +const reply = (result: BinaryWorkerResult) => self.postMessage(result, { transfer: [] });
19 +const quote = (name: string) => `"${name.replaceAll('"', '""')}"`;
20 +
21 +async function gunzip(bytes: ArrayBuffer) {
22 + const reader = new Blob([bytes])
23 + .stream()
24 + .pipeThrough(new DecompressionStream("gzip"))
25 + .getReader();
26 + const chunks: Uint8Array<ArrayBuffer>[] = [];
27 + let length = 0;
28 + try {
29 + while (true) {
30 + const { value, done } = await reader.read();
31 + if (done) break;
32 + length += value.length;
33 + if (length > BINARY_PREVIEW_MAX_BYTES || length > bytes.byteLength * ARCHIVE_MAX_RATIO)
34 + throw new Error(
35 + "The expanded archive exceeds the preview size or compression ratio limit.",
36 + );
37 + chunks.push(value);
38 + }
39 + } finally {
40 + await reader.cancel();
41 + }
42 + return new Uint8Array(await new Blob(chunks).arrayBuffer());
43 +}
44 +
45 +function tarEntries(bytes: Uint8Array<ArrayBuffer>) {
46 + const entries: ArchiveEntry[] = [];
47 + const text = (offset: number, length: number) =>
48 + new TextDecoder().decode(bytes.subarray(offset, offset + length)).split("\0", 1)[0] ?? "";
49 + const number = (offset: number, length: number) => {
50 + const value = text(offset, length).trim();
51 + if (!/^[0-7]*$/.test(value)) throw new Error("This TAR uses an unsupported numeric format.");
52 + return Number.parseInt(value || "0", 8);
53 + };
54 + let longPath: string | null = null;
55 + const globalPax: Record<string, string> = {};
56 + let localPax: Record<string, string> = {};
57 + let offset = 0;
58 + while (offset + 512 <= bytes.length) {
59 + if (bytes.subarray(offset, offset + 512).every((byte) => byte === 0)) break;
60 + if (entries.length >= ARCHIVE_MAX_ENTRIES)
61 + throw new Error("This archive contains more than 2,048 entries.");
62 + let checksum = 0;
63 + for (let index = 0; index < 512; index++)
64 + checksum += index >= 148 && index < 156 ? 32 : bytes[offset + index]!;
65 + if (checksum !== number(offset + 148, 8)) throw new Error("The TAR header is damaged.");
66 + const type = text(offset + 156, 1);
67 + const metadata = type === "L" || type === "x" || type === "g";
68 + const attributes: Record<string, string> = metadata ? {} : { ...globalPax, ...localPax };
69 + const size = attributes.size ? Number(attributes.size) : number(offset + 124, 12);
70 + if (attributes.size && !/^\d+$/.test(attributes.size))
71 + throw new Error("An archive entry is too large or damaged.");
72 + const prefix =
73 + text(offset + 257, 6) === "ustar" && text(offset + 263, 2) === "00"
74 + ? text(offset + 345, 155)
75 + : "";
76 + const path =
77 + attributes.path || longPath || [prefix, text(offset, 100)].filter(Boolean).join("/");
78 + if (!metadata) {
79 + longPath = null;
80 + localPax = {};
81 + }
82 + if (
83 + path.length > 1024 ||
84 + !Number.isSafeInteger(size) ||
85 + size < 0 ||
86 + size > BINARY_PREVIEW_MAX_BYTES ||
87 + offset + 512 + size > bytes.length
88 + )
89 + throw new Error("An archive entry is too large or damaged.");
90 + const content = bytes.subarray(offset + 512, offset + 512 + size);
91 + if (type === "L") longPath = new TextDecoder().decode(content).replace(/\0.*$/s, "");
92 + else if (type === "x" || type === "g") {
93 + if (size > 65536) throw new Error("Archive metadata is too large.");
94 + for (let cursor = 0; cursor < content.length;) {
95 + const separator = content.indexOf(32, cursor);
96 + if (separator < cursor || separator - cursor > 10)
97 + throw new Error("The TAR metadata is damaged.");
98 + const lengthText = new TextDecoder().decode(content.subarray(cursor, separator));
99 + const length = Number(lengthText);
100 + const end = cursor + length;
101 + if (
102 + !/^[1-9]\d*$/.test(lengthText) ||
103 + !Number.isSafeInteger(length) ||
104 + end > content.length ||
105 + end <= separator + 1 ||
106 + content[end - 1] !== 10
107 + )
108 + throw new Error("The TAR metadata is damaged.");
109 + const record = new TextDecoder().decode(content.subarray(separator + 1, end - 1));
110 + const equals = record.indexOf("=");
111 + if (equals < 1) throw new Error("The TAR metadata is damaged.");
112 + const key = record.slice(0, equals);
113 + const value = record.slice(equals + 1);
114 + if (["path", "size", "mtime"].includes(key)) {
115 + if (type === "x") localPax[key] = value;
116 + else if (value) globalPax[key] = value;
117 + else delete globalPax[key];
118 + }
119 + cursor = end;
120 + }
121 + } else if (type === "" || type === "0" || type === "5") {
122 + if (attributes.mtime && !/^[+-]?\d+(?:\.\d+)?$/.test(attributes.mtime))
123 + throw new Error("The TAR metadata is damaged.");
124 + const modified =
125 + (attributes.mtime ? Number(attributes.mtime) : number(offset + 136, 12)) * 1000;
126 + const date = new Date(modified);
127 + entries.push({
128 + path,
129 + size,
130 + directory: type === "5",
131 + modified: Number.isNaN(date.getTime()) ? null : date.toISOString(),
132 + });
133 + if (type !== "5") files.set(path, content.slice());
134 + }
135 + offset += 512 + Math.ceil(size / 512) * 512;
136 + }
137 + if (entries.length === 0) throw new Error("This archive has no readable entries.");
138 + return entries;
139 +}
140 +
141 +async function handle(input: BinaryWorkerRequest) {
142 + if (input.type === "entry") {
143 + const bytes = files.get(input.path);
144 + if (!bytes) throw new Error("This archive entry is unavailable.");
145 + if (bytes.length > ARCHIVE_ENTRY_MAX_BYTES)
146 + throw new Error("Entry previews are limited to 10 MB.");
147 + reply({ type: "entry", path: input.path, bytes });
148 + return;
149 + }
150 + if (input.type === "rows") {
151 + if (
152 + !database ||
153 + !tables.includes(input.table) ||
154 + !Number.isSafeInteger(input.page) ||
155 + input.page < 0
156 + )
157 + throw new Error("This table is unavailable.");
158 + const columns =
159 + database
160 + .exec(`PRAGMA table_xinfo(${quote(input.table)})`)[0]
161 + ?.values.filter((row) => row[6] !== 1)
162 + .map((row) => String(row[1]))
163 + .slice(0, 50) ?? [];
164 + const fields = columns.map((name) => {
165 + const field = quote(name);
166 + return `CASE WHEN typeof(${field}) = 'blob' THEN '[blob: ' || length(${field}) || ' bytes]' ELSE substr(CAST(${field} AS TEXT), 1, 1024) END`;
167 + });
168 + const result = database.exec(
169 + `SELECT ${fields.join(",")} FROM ${quote(input.table)} LIMIT ${SQLITE_PAGE_SIZE} OFFSET ${input.page * SQLITE_PAGE_SIZE}`,
170 + )[0];
171 + reply({
172 + type: "rows",
173 + table: input.table,
174 + page: input.page,
175 + columns,
176 + rows:
177 + result?.values.map((row) => row.map((cell) => (cell === null ? "NULL" : String(cell)))) ??
178 + [],
179 + });
180 + return;
181 + }
182 + if (input.bytes.byteLength > BINARY_PREVIEW_MAX_BYTES)
183 + throw new Error("Preview limited to files under 50 MB.");
184 + if (input.kind === "sqlite") {
185 + const [{ default: initSqlJs }, { default: wasmUrl }] = await Promise.all([
186 + import("sql.js"),
187 + import("sql.js/dist/sql-wasm.wasm?url"),
188 + ]);
189 + const SQL = await initSqlJs({ locateFile: () => wasmUrl });
190 + database = new SQL.Database(new Uint8Array(input.bytes));
191 + database.run("PRAGMA query_only=ON; PRAGMA trusted_schema=OFF;");
192 + tables =
193 + database
194 + .exec(
195 + "SELECT name FROM sqlite_schema WHERE type='table' AND substr(name, 1, 7) != 'sqlite_' AND sql NOT LIKE 'CREATE VIRTUAL TABLE%' ORDER BY name LIMIT 101",
196 + )[0]
197 + ?.values.map((row) => String(row[0])) ?? [];
198 + if (tables.length > 100) throw new Error("Database previews are limited to 100 tables.");
199 + reply({
200 + type: "sqlite",
201 + tables: tables.map((name) => ({
202 + name,
203 + count: Number(
204 + database!.exec(`SELECT count(*) FROM ${quote(name)}`)[0]?.values[0]?.[0] ?? 0,
205 + ),
206 + })),
207 + });
208 + } else {
209 + files = new Map();
210 + let entries: ArchiveEntry[];
211 + if (
212 + /\.(zip|jar)$/i.test(input.name) ||
213 + (input.bytes.byteLength >= 4 &&
214 + [0x04034b50, 0x06054b50].includes(new DataView(input.bytes).getUint32(0, true)))
215 + ) {
216 + const archive = await boundedZip(input.bytes, BINARY_PREVIEW_MAX_BYTES);
217 + entries = [...archive].map(([path, file]) => {
218 + files.set(path, file.bytes);
219 + return {
220 + path,
221 + size: file.bytes.length,
222 + directory: file.directory,
223 + modified: Number.isNaN(file.date.getTime()) ? null : file.date.toISOString(),
224 + };
225 + });
226 + } else if (/\.(gz|tgz)$/i.test(input.name) || new Uint8Array(input.bytes)[0] === 0x1f) {
227 + const bytes = await gunzip(input.bytes);
228 + if (/\.(tar\.gz|tgz)$/i.test(input.name)) entries = tarEntries(bytes);
229 + else {
230 + const path = input.name.replace(/\.gz$/i, "") || "contents";
231 + if (/\.tar$/i.test(path)) entries = tarEntries(bytes);
232 + else {
233 + files.set(path, bytes);
234 + entries = [{ path, size: bytes.length, directory: false, modified: null }];
235 + }
236 + }
237 + } else entries = tarEntries(new Uint8Array(input.bytes));
238 + reply({ type: "archive", entries });
239 + }
240 +}
241 +
242 +self.addEventListener("message", (event: MessageEvent<BinaryWorkerRequest>) => {
243 + void handle(event.data).catch((cause: unknown) =>
244 + reply({
245 + type: "error",
246 + message: cause instanceof Error ? cause.message : "Could not preview this file.",
247 + }),
248 + );
249 +});
apps/web/src/components/files/binaryPreviewProtocol.ts new
+24
@@ -0,0 +1,24 @@
1 +export const BINARY_PREVIEW_MAX_BYTES = 50 * 1024 * 1024;
2 +export const ARCHIVE_ENTRY_MAX_BYTES = 10 * 1024 * 1024;
3 +export const ARCHIVE_MAX_ENTRIES = 2048;
4 +export const ARCHIVE_MAX_RATIO = 200;
5 +export const SQLITE_PAGE_SIZE = 50;
6 +
7 +export interface ArchiveEntry {
8 + path: string;
9 + size: number;
10 + modified: string | null;
11 + directory: boolean;
12 +}
13 +
14 +export type BinaryWorkerRequest =
15 + | { type: "open"; kind: "archive" | "sqlite"; name: string; bytes: ArrayBuffer }
16 + | { type: "entry"; path: string }
17 + | { type: "rows"; table: string; page: number };
18 +
19 +export type BinaryWorkerResult =
20 + | { type: "error"; message: string }
21 + | { type: "archive"; entries: ArchiveEntry[] }
22 + | { type: "entry"; path: string; bytes: Uint8Array<ArrayBuffer> }
23 + | { type: "sqlite"; tables: { name: string; count: number }[] }
24 + | { type: "rows"; table: string; page: number; columns: string[]; rows: string[][] };
apps/web/src/components/files/boundedZip.ts new
+79
@@ -0,0 +1,79 @@
1 +import JSZip from "jszip";
2 +import { checkZipDirectory } from "./zipDirectory";
3 +
4 +import {
5 + ARCHIVE_MAX_ENTRIES,
6 + ARCHIVE_MAX_RATIO,
7 + BINARY_PREVIEW_MAX_BYTES,
8 +} from "./binaryPreviewProtocol";
9 +
10 +export async function boundedZip(
11 + bytes: ArrayBuffer,
12 + entryLimit = BINARY_PREVIEW_MAX_BYTES,
13 + limits: {
14 + totalLimit?: number;
15 + xmlLimit?: number;
16 + ratioFloor?: number;
17 + markupLimit?: number;
18 + } = {},
19 +) {
20 + if (bytes.byteLength > BINARY_PREVIEW_MAX_BYTES)
21 + throw new Error("Preview limited to files under 50 MB.");
22 + checkZipDirectory(bytes, ARCHIVE_MAX_ENTRIES);
23 + const zip = await JSZip.loadAsync(bytes);
24 + const entries = Object.values(zip.files);
25 + if (entries.length > ARCHIVE_MAX_ENTRIES)
26 + throw new Error("This archive contains more than 2,048 entries.");
27 + const files = new Map<
28 + string,
29 + { bytes: Uint8Array<ArrayBuffer>; date: Date; directory: boolean }
30 + >();
31 + let total = 0;
32 + let markup = 0;
33 + for (const entry of entries) {
34 + if (entry.name.length > 1024) throw new Error("An archive path is too long to preview.");
35 + const chunks: Uint8Array<ArrayBuffer>[] = [];
36 + let length = 0;
37 + await new Promise<void>((resolve, reject) => {
38 + const stream = (
39 + entry as JSZip.JSZipObject & {
40 + internalStream(type: "uint8array"): JSZip.JSZipStreamHelper<Uint8Array<ArrayBuffer>>;
41 + }
42 + ).internalStream("uint8array");
43 + stream
44 + .on("data", (chunk) => {
45 + total += chunk.length;
46 + length += chunk.length;
47 + // Word relationship targets can use arbitrary extensions, so count every part.
48 + if (limits.markupLimit !== undefined)
49 + for (const byte of chunk) if (byte === 0x3c) markup++;
50 + if (
51 + markup > (limits.markupLimit ?? Infinity) ||
52 + total > (limits.totalLimit ?? BINARY_PREVIEW_MAX_BYTES) ||
53 + total >
54 + Math.max(limits.ratioFloor ?? 0, Math.max(1, bytes.byteLength) * ARCHIVE_MAX_RATIO) ||
55 + length > entryLimit ||
56 + (entry.name.endsWith(".xml") && length > (limits.xmlLimit ?? 8 * 1024 * 1024))
57 + ) {
58 + stream.pause();
59 + reject(
60 + new Error(
61 + "The expanded archive exceeds the preview size or compression ratio limit.",
62 + ),
63 + );
64 + } else chunks.push(chunk);
65 + })
66 + .on("error", reject)
67 + .on("end", resolve)
68 + .resume();
69 + });
70 + const content = new Uint8Array(length);
71 + let offset = 0;
72 + for (const chunk of chunks) {
73 + content.set(chunk, offset);
74 + offset += chunk.length;
75 + }
76 + files.set(entry.name, { bytes: content, date: entry.date, directory: entry.dir });
77 + }
78 + return files;
79 +}
apps/web/src/components/files/decodeImagePreview.ts new
+30
@@ -0,0 +1,30 @@
1 +import { readBinaryPreview } from "./readBinaryPreview";
2 +
3 +export async function decodeImagePreview(src: string, heif: boolean, signal: AbortSignal) {
4 + const worker = new Worker(new URL("./imageDecode.worker.ts", import.meta.url), {
5 + type: "module",
6 + });
7 + const controller = new AbortController();
8 + try {
9 + return await new Promise<Blob>((resolve, reject) => {
10 + const fail = (message: string) => reject(new Error(message));
11 + const abort = () => fail("Image decoding cancelled.");
12 + signal.addEventListener("abort", abort, { signal: controller.signal });
13 + if (signal.aborted) return abort();
14 + const timer = setTimeout(() => fail("This image took too long to decode."), 30_000);
15 + controller.signal.addEventListener("abort", () => clearTimeout(timer), { once: true });
16 + worker.addEventListener("error", () => fail("Could not load the image decoder."));
17 + worker.addEventListener("message", (event: MessageEvent<{ blob?: Blob; error?: string }>) => {
18 + if (event.data.blob) resolve(event.data.blob);
19 + else fail(event.data.error ?? "Could not decode this image.");
20 + });
21 + void readBinaryPreview(src, controller.signal).then(
22 + (bytes) => worker.postMessage({ bytes, heif }, [bytes]),
23 + reject,
24 + );
25 + });
26 + } finally {
27 + controller.abort();
28 + worker.terminate();
29 + }
30 +}
apps/web/src/components/files/imageDecode.worker.ts new
+208
@@ -0,0 +1,208 @@
1 +const MAX_PIXELS = 32_000_000;
2 +
3 +function validateTiffMetadata(bytes: ArrayBuffer) {
4 + const view = new DataView(bytes);
5 + if (bytes.byteLength < 8) throw new Error("Invalid TIFF metadata.");
6 + const order = view.getUint16(0);
7 + const littleEndian = order === 0x4949;
8 + if (![0x4949, 0x4d4d].includes(order) || view.getUint16(2, littleEndian) !== 42)
9 + throw new Error("Invalid TIFF metadata.");
10 + const visited = new Set<number>();
11 + let entries = 0;
12 + let allocation = 0;
13 + const inspect = (offset: number, depth: number) => {
14 + if (depth > 8 || visited.has(offset) || offset < 8 || offset + 2 > bytes.byteLength)
15 + throw new Error("Invalid TIFF metadata.");
16 + visited.add(offset);
17 + const count = view.getUint16(offset, littleEndian);
18 + entries += count;
19 + if (entries > 2048 || offset + 2 + count * 12 + 4 > bytes.byteLength)
20 + throw new Error("This TIFF has too much or truncated metadata.");
21 + for (let index = 0; index < count; index++) {
22 + const entry = offset + 2 + index * 12;
23 + const tag = view.getUint16(entry, littleEndian);
24 + const type = view.getUint16(entry + 2, littleEndian);
25 + const values = view.getUint32(entry + 4, littleEndian);
26 + const width = [0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8][type];
27 + if (!width) throw new Error("Unsupported TIFF metadata type.");
28 + const length = values * width;
29 + const start = length > 4 ? view.getUint32(entry + 8, littleEndian) : entry + 8;
30 + // The decoder retains a separate array or string for every tag, including aliases.
31 + allocation += values * Math.max(16, width);
32 + if (start + length > bytes.byteLength || allocation > 8 * 1024 * 1024)
33 + throw new Error("This TIFF has too much or truncated metadata.");
34 + if (tag === 0x8769 || tag === 0x8825) {
35 + if (type !== 4 || values !== 1) throw new Error("Invalid TIFF metadata pointer.");
36 + inspect(view.getUint32(entry + 8, littleEndian), depth + 1);
37 + }
38 + }
39 + };
40 + inspect(view.getUint32(4, littleEndian), 0);
41 +}
42 +
43 +function dimensions(width: number, height: number) {
44 + if (!(width > 0 && height > 0) || width > 16384 || height > 16384 || width > MAX_PIXELS / height)
45 + throw new Error("Image previews are limited to 32 megapixels and 16,384 pixels per side.");
46 +}
47 +
48 +function validateHeif(bytes: ArrayBuffer) {
49 + const view = new DataView(bytes);
50 + let found = false;
51 + let count = 0;
52 + const boxes = (start: number, end: number, depth: number) => {
53 + if (depth > 4) return;
54 + let offset = start;
55 + while (offset + 8 <= end) {
56 + if (++count > 2048) throw new Error("This image has too much metadata.");
57 + let size = view.getUint32(offset);
58 + let header = 8;
59 + if (size === 1) {
60 + if (offset + 16 > end) throw new Error("Invalid HEIF metadata.");
61 + const large = view.getBigUint64(offset + 8);
62 + if (large > BigInt(bytes.byteLength)) throw new Error("Invalid HEIF metadata.");
63 + size = Number(large);
64 + header = 16;
65 + } else if (size === 0) size = end - offset;
66 + if (size < header || offset + size > end) throw new Error("Invalid HEIF metadata.");
67 + const type = view.getUint32(offset + 4);
68 + if (type === 0x69737065) {
69 + if (size < header + 12) throw new Error("Invalid HEIF dimensions.");
70 + dimensions(view.getUint32(offset + header + 4), view.getUint32(offset + header + 8));
71 + found = true;
72 + } else if (type === 0x6d657461 || type === 0x69707270 || type === 0x6970636f)
73 + boxes(offset + header + (type === 0x6d657461 ? 4 : 0), offset + size, depth + 1);
74 + offset += size;
75 + }
76 + };
77 + boxes(0, bytes.byteLength, 0);
78 + if (!found) throw new Error("This HEIF image has no readable dimensions.");
79 +}
80 +
81 +// Count LZW output without building strings before the decoder allocates its strip buffer.
82 +function validateLzw(bytes: Uint8Array, limit: number) {
83 + const lengths = new Uint16Array(4096).fill(1, 0, 256);
84 + let bits = 9;
85 + let bit = 0;
86 + let next = 258;
87 + let previous = 0;
88 + let total = 0;
89 + while (bit + bits <= bytes.length * 8) {
90 + let code = 0;
91 + for (let index = 0; index < bits; index++, bit++)
92 + code = (code << 1) | ((bytes[bit >> 3]! >> (7 - (bit & 7))) & 1);
93 + if (code === 257) return;
94 + if (code === 256) {
95 + bits = 9;
96 + next = 258;
97 + previous = 0;
98 + continue;
99 + }
100 + const length = code < next ? lengths[code]! : code === next && previous ? previous + 1 : 0;
101 + if (!length || (total += length) > limit) throw new Error("Invalid or oversized TIFF strip.");
102 + if (previous) {
103 + if (next >= 4096) throw new Error("Invalid TIFF LZW dictionary.");
104 + lengths[next++] = previous + 1;
105 + if (next === (1 << bits) - 1 && bits < 12) bits++;
106 + }
107 + previous = length;
108 + }
109 + throw new Error("Truncated TIFF strip.");
110 +}
111 +
112 +async function validateTiffStrips(bytes: ArrayBuffer, image: import("tiff").TiffIfd) {
113 + const offsets = image.tiled ? image.tileOffsets : image.stripOffsets;
114 + const counts = image.tiled ? image.tileByteCounts : image.stripByteCounts;
115 + const width = image.tiled ? image.tileWidth! : image.width;
116 + const height = image.tiled ? image.tileHeight! : Math.min(image.rowsPerStrip, image.height);
117 + dimensions(width, height);
118 + const limit = width * height * image.components * (image.bitsPerSample / 8);
119 + if (!offsets?.length || offsets.length > 2048 || counts?.length !== offsets.length)
120 + throw new Error("Unsupported TIFF strip layout.");
121 + let expanded = 0;
122 + for (let index = 0; index < offsets.length; index++) {
123 + const offset = offsets[index]!;
124 + const size = counts[index]!;
125 + if (offset < 0 || size < 1 || offset + size > bytes.byteLength)
126 + throw new Error("Invalid TIFF strip.");
127 + const strip = new Uint8Array(bytes, offset, size);
128 + if (image.compression === 5) validateLzw(strip, limit);
129 + else if (image.compression === 8 || image.compression === 32946) {
130 + const reader = new Blob([strip])
131 + .stream()
132 + .pipeThrough(new DecompressionStream("deflate"))
133 + .getReader();
134 + let length = 0;
135 + try {
136 + while (true) {
137 + const { value, done } = await reader.read();
138 + if (done) break;
139 + if ((length += value.length) > limit) throw new Error("Oversized TIFF strip.");
140 + }
141 + } finally {
142 + await reader.cancel();
143 + }
144 + } else if (image.compression !== 1) throw new Error("This TIFF compression is not supported.");
145 + // Bound repeated strips and padding as well as the visible image dimensions.
146 + expanded += limit;
147 + if (expanded > 256 * 1024 * 1024) throw new Error("This TIFF has too much image data.");
148 + }
149 +}
150 +
151 +async function decode(bytes: ArrayBuffer, heif: boolean) {
152 + if (bytes.byteLength > 50 * 1024 * 1024) throw new Error("Preview limited to files under 50 MB.");
153 + if (heif) {
154 + validateHeif(bytes);
155 + const { heicTo } = await import("heic-to/next");
156 + return await heicTo({ blob: new Blob([bytes]), type: "image/png" });
157 + }
158 + const { decode: decodeTiff } = await import("tiff");
159 + validateTiffMetadata(bytes);
160 + const metadata = decodeTiff(bytes, { ignoreImageData: true, pages: [0] })[0];
161 + if (!metadata) throw new Error("This TIFF has no readable image.");
162 + dimensions(metadata.width, metadata.height);
163 + if (metadata.orientation && metadata.orientation !== 1)
164 + throw new Error("This TIFF orientation is not supported.");
165 + if (
166 + (metadata.tiled && metadata.components > 1) ||
167 + ![1, 2, 3, 4].includes(metadata.components) ||
168 + ![8, 16].includes(metadata.bitsPerSample) ||
169 + ![0, 1, 2, 3].includes(metadata.type)
170 + )
171 + throw new Error("This TIFF color format is not supported.");
172 + await validateTiffStrips(bytes, metadata);
173 + const image = decodeTiff(bytes, { pages: [0] })[0]!;
174 + const rgba = new Uint8ClampedArray(image.width * image.height * 4);
175 + const scale = image.bitsPerSample === 16 ? 257 : 1;
176 + const palette = image.palette;
177 + for (let pixel = 0; pixel < image.width * image.height; pixel++) {
178 + const index = pixel * image.components;
179 + if (palette) {
180 + const color = palette[image.data[index]!] ?? [0, 0, 0];
181 + for (let channel = 0; channel < 3; channel++)
182 + rgba[pixel * 4 + channel] = color[channel]! / 257;
183 + } else if (image.type === 2) {
184 + for (let channel = 0; channel < 3; channel++)
185 + rgba[pixel * 4 + channel] = image.data[index + channel]! / scale;
186 + } else {
187 + const gray = image.data[index]! / scale;
188 + rgba.fill(gray, pixel * 4, pixel * 4 + 3);
189 + }
190 + rgba[pixel * 4 + 3] = image.alpha ? image.data[index + image.components - 1]! / scale : 255;
191 + }
192 + const canvas = new OffscreenCanvas(image.width, image.height);
193 + const context = canvas.getContext("2d");
194 + if (!context) throw new Error("Image decoding is unavailable.");
195 + context.putImageData(new ImageData(rgba, image.width, image.height), 0, 0);
196 + return await canvas.convertToBlob({ type: "image/png" });
197 +}
198 +
199 +self.addEventListener("message", (event: MessageEvent<{ bytes: ArrayBuffer; heif: boolean }>) => {
200 + void decode(event.data.bytes, event.data.heif).then(
201 + (blob) => self.postMessage({ blob }, { transfer: [] }),
202 + (cause: unknown) =>
203 + self.postMessage(
204 + { error: cause instanceof Error ? cause.message : "Could not decode this image." },
205 + { transfer: [] },
206 + ),
207 + );
208 +});
apps/web/src/components/files/readBinaryPreview.ts new
+24
@@ -0,0 +1,24 @@
1 +import { BINARY_PREVIEW_MAX_BYTES } from "./binaryPreviewProtocol";
2 +
3 +export async function readBinaryPreview(src: string, signal: AbortSignal) {
4 + const response = await fetch(src, { signal });
5 + if (!response.ok) throw new Error("The file could not be loaded. Close it and try again.");
6 + if (Number(response.headers.get("content-length")) > BINARY_PREVIEW_MAX_BYTES)
7 + throw new Error("Preview limited to files under 50 MB.");
8 + const reader = response.body?.getReader();
9 + if (!reader) throw new Error("The file is unavailable.");
10 + const chunks: Uint8Array<ArrayBuffer>[] = [];
11 + let size = 0;
12 + try {
13 + while (true) {
14 + const { value, done } = await reader.read();
15 + if (done) break;
16 + size += value.length;
17 + if (size > BINARY_PREVIEW_MAX_BYTES) throw new Error("Preview limited to files under 50 MB.");
18 + chunks.push(value);
19 + }
20 + } finally {
21 + await reader.cancel();
22 + }
23 + return new Blob(chunks).arrayBuffer();
24 +}
apps/web/src/components/media/AttachmentImage.browser.test.tsx new
+109
@@ -0,0 +1,109 @@
1 +import { act, render, type Screen } from "../../../test/render";
2 +import { expect, it, vi } from "vite-plus/test";
3 +import { AttachmentImage } from "./AttachmentImage";
4 +import { decodeImagePreview } from "../files/decodeImagePreview";
5 +
6 +vi.mock("../files/decodeImagePreview", () => ({
7 + decodeImagePreview: vi.fn(),
8 +}));
9 +
10 +const revokeUrl = vi.fn();
11 +const bitmap = new Blob(["png"], { type: "image/png" });
12 +
13 +function setup() {
14 + revokeUrl.mockReset();
15 + vi.mocked(decodeImagePreview).mockReset().mockResolvedValue(bitmap);
16 +}
17 +
18 +function image(screen: Screen) {
19 + const img = screen.container.querySelector("img");
20 + expect(img).not.toBeNull();
21 + return img!;
22 +}
23 +
24 +// Stands in for the browser failing to decode the current source.
25 +async function failDecode(screen: Screen) {
26 + const img = image(screen);
27 + await act(() => {
28 + img.dispatchEvent(new Event("error"));
29 + });
30 + await act(() => vi.dynamicImportSettled());
31 + return img;
32 +}
33 +
34 +function expectDecodeErrorFor(onError: ReturnType<typeof vi.fn>, img: HTMLImageElement) {
35 + expect(onError).toHaveBeenCalledWith(expect.objectContaining({ type: "error", target: img }));
36 +}
37 +
38 +it.each([
39 + { name: "photo.HEIC", mimeType: undefined, heif: true },
40 + { name: "photo.heif", mimeType: undefined, heif: true },
41 + { name: "photo", mimeType: "image/heif", heif: true },
42 + { name: "scan.TIFF", mimeType: undefined, heif: false },
43 + { name: "scan", mimeType: "image/tiff", heif: false },
44 +])(
45 + "converts $name after native decoding fails and releases its preview",
46 + async ({ name, mimeType, heif }) => {
47 + setup();
48 + using _createUrl = vi.spyOn(URL, "createObjectURL").mockReturnValue("blob:jpeg");
49 + using _revokeUrl = vi.spyOn(URL, "revokeObjectURL").mockImplementation(revokeUrl);
50 + await using screen = await render(
51 + <AttachmentImage src="https://environment.test/photo" name={name} mimeType={mimeType} />,
52 + );
53 + expect(decodeImagePreview).not.toHaveBeenCalled();
54 + await failDecode(screen);
55 + expect(image(screen).getAttribute("src")).toBe("blob:jpeg");
56 + expect(decodeImagePreview).toHaveBeenCalledWith(
57 + "https://environment.test/photo",
58 + heif,
59 + expect.any(AbortSignal),
60 + );
61 + await screen.unmount();
62 + expect(revokeUrl).toHaveBeenCalledWith("blob:jpeg");
63 + },
64 +);
65 +
66 +it("leaves PNG errors to the caller without fetching or converting", async () => {
67 + setup();
68 + using _createUrl = vi.spyOn(URL, "createObjectURL").mockReturnValue("blob:jpeg");
69 + using _revokeUrl = vi.spyOn(URL, "revokeObjectURL").mockImplementation(revokeUrl);
70 + const onError = vi.fn();
71 + await using screen = await render(
72 + <AttachmentImage src="blob:png" name="photo.png" onError={onError} />,
73 + );
74 + expectDecodeErrorFor(onError, await failDecode(screen));
75 + expect(decodeImagePreview).not.toHaveBeenCalled();
76 +});
77 +
78 +it("reports failed HEIC conversion through the existing error handler", async () => {
79 + setup();
80 + using _createUrl = vi.spyOn(URL, "createObjectURL").mockReturnValue("blob:jpeg");
81 + using _revokeUrl = vi.spyOn(URL, "revokeObjectURL").mockImplementation(revokeUrl);
82 + const onError = vi.fn();
83 + vi.mocked(decodeImagePreview).mockRejectedValue(new Error("unreadable"));
84 + await using screen = await render(
85 + <AttachmentImage src="blob:heic" name="photo.heif" onError={onError} />,
86 + );
87 + expectDecodeErrorFor(onError, await failDecode(screen));
88 + expect(URL.createObjectURL).not.toHaveBeenCalled();
89 +});
90 +
91 +it("discards an old decode when navigating to a different source", async () => {
92 + setup();
93 + using _createUrl = vi.spyOn(URL, "createObjectURL").mockReturnValue("blob:jpeg");
94 + using _revokeUrl = vi.spyOn(URL, "revokeObjectURL").mockImplementation(revokeUrl);
95 + let finishDecode!: (result: Blob) => void;
96 + vi.mocked(decodeImagePreview).mockReturnValue(
97 + new Promise((resolve) => {
98 + finishDecode = resolve;
99 + }),
100 + );
101 + await using screen = await render(<AttachmentImage src="blob:first" name="photo.heic" />);
102 + await failDecode(screen);
103 + const secondSource = "data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'/>";
104 + await screen.rerender(<AttachmentImage src={secondSource} name="photo.heic" />);
105 + await act(() => finishDecode(bitmap));
106 + expect(image(screen).getAttribute("src")).toBe(secondSource);
107 + expect(URL.createObjectURL).not.toHaveBeenCalled();
108 + expect(vi.mocked(decodeImagePreview).mock.calls[0]?.[2].aborted).toBe(true);
109 +});
apps/web/src/components/media/AttachmentImage.tsx
+22 -26
@@ -5,57 +5,53 @@ import {
5 type ComponentProps,
6 type SyntheticEvent,
7 } from "react";
8 -import {
9 - isHeicImageFile,
10 - MAX_COMPRESSIBLE_SOURCE_BYTES,
11 - prepareImageForAttachment,
12 -} from "../../lib/imageCompression";
8 +import { isHeicImageFile } from "../../lib/imageCompression";
9
10 type AttachmentImageProps = ComponentProps<"img"> & { name: string; mimeType?: string | undefined };
11
12 +// Keep import expressions outside hooks until React Compiler supports them.
13 +const loadImageDecoder = () => import("../files/decodeImagePreview");
14 +
15 export function AttachmentImage({ name, mimeType, ...props }: AttachmentImageProps) {
17 - return isHeicImageFile({ name, type: mimeType ?? "" }) ? (
18 - <HeicImage key={props.src} {...props} name={name} />
16 + const fallback =
17 + isHeicImageFile({ name, type: mimeType ?? "" }) ||
18 + /\.tiff?$/i.test(name) ||
19 + /^image\/tiff$/i.test(mimeType ?? "");
20 + return fallback ? (
21 + <DecodedImage key={props.src} {...props} name={name} mimeType={mimeType} />
22 ) : (
23 <img {...props} />
24 );
25 }
26
24 -function HeicImage({ name, src, onError, ...props }: Omit<AttachmentImageProps, "mimeType">) {
27 +function DecodedImage({ name, mimeType, src, onError, ...props }: AttachmentImageProps) {
28 const [decodeError, setDecodeError] = useState<SyntheticEvent<HTMLImageElement> | null>(null);
29 const [previewUrl, setPreviewUrl] = useState<string>();
27 -
30 const reportError = useEffectEvent((event: SyntheticEvent<HTMLImageElement>) => onError?.(event));
29 -
31 useEffect(() => {
32 if (!decodeError || !src) return;
33 const controller = new AbortController();
34 let objectUrl: string | undefined;
34 - const decode = async () => {
35 - try {
36 - const response = await fetch(src, { signal: controller.signal });
37 - if (!response.ok) return reportError(decodeError);
38 - const blob = await response.blob();
35 + void loadImageDecoder()
36 + .then(async ({ decodeImagePreview }) => {
37 if (controller.signal.aborted) return;
40 - const result = await prepareImageForAttachment(
41 - new File([blob], name, { type: "image/heic" }),
42 - MAX_COMPRESSIBLE_SOURCE_BYTES,
38 + const blob = await decodeImagePreview(
39 + src,
40 + /\.hei[cf]$/i.test(name) || /^image\/hei[cf]$/i.test(mimeType ?? ""),
41 + controller.signal,
42 );
43 if (controller.signal.aborted) return;
45 - if (!result.ok) return reportError(decodeError);
46 - objectUrl = URL.createObjectURL(result.file);
44 + objectUrl = URL.createObjectURL(blob);
45 setPreviewUrl(objectUrl);
48 - } catch {
46 + })
47 + .catch(() => {
48 if (!controller.signal.aborted) reportError(decodeError);
50 - }
51 - };
52 - void decode();
49 + });
50 return () => {
51 controller.abort();
52 if (objectUrl) URL.revokeObjectURL(objectUrl);
53 };
57 - }, [decodeError, name, src]);
58 -
54 + }, [decodeError, name, src, mimeType]);
55 return (
56 <img {...props} src={previewUrl ?? src} onError={decodeError ? onError : setDecodeError} />
57 );
apps/web/src/pierre-icons.test.ts
+12 -1
@@ -1,8 +1,19 @@
1 import { assert, describe, it } from "vite-plus/test";
2
3 -import { resolvePierreIconForEntry, T3_PIERRE_ICONS } from "./pierre-icons";
3 +import {
4 + hasSpecificPierreIconForFileName,
5 + resolvePierreIconForEntry,
6 + T3_PIERRE_ICONS,
7 +} from "./pierre-icons";
8
9 describe("Pierre file icons", () => {
10 + it.each(["photo.heic", "photo.heif", "PHOTO.HEIC", "folder/photo.HEIF"])(
11 + "uses the image icon for %s",
12 + (name) => {
13 + assert.equal(resolvePierreIconForEntry(name, "file")?.token, "image");
14 + assert.isTrue(hasSpecificPierreIconForFileName(name));
15 + },
16 + );
17 it("uses detected types for extensionless files while keeping known filename icons", () => {
18 assert.equal(
19 resolvePierreIconForEntry("custom-script", "file", "text/x-python")?.token,
apps/web/src/pierre-icons.ts
+5 -1
@@ -4,7 +4,7 @@ import {
4 type FileTreeIcons,
5 } from "@pierre/trees";
6 import { VIDEO_FILE_EXTENSIONS } from "@t3tools/shared/video";
7 -import { fileIconPathForMimeType } from "@t3tools/shared/filePreview";
7 +import { fileIconPathForMimeType } from "@t3tools/shared/mediaPreview";
8
9 export interface PierreIconResolution {
10 name: string;
@@ -103,6 +103,8 @@ export const T3_PIERRE_ICONS = {
103 ex: "t3-file-icon-elixir",
104 exs: "t3-file-icon-elixir",
105 hs: "t3-file-icon-haskell",
106 + heic: "file-tree-builtin-image",
107 + heif: "file-tree-builtin-image",
108 lhs: "t3-file-icon-haskell",
109 java: "t3-file-icon-java",
110 kt: "t3-file-icon-kotlin",
@@ -168,6 +170,8 @@ export function resolvePierreIconForEntry(
170 ): PierreIconResolution | null {
171 if (kind === "directory") return null;
172 const icon = completeIconResolver.resolveIcon("file-tree-icon-file", pathValue);
173 + if (icon?.name === "file-tree-builtin-image" && icon.token === undefined)
174 + return { ...icon, token: "image" };
175 return icon?.token === "default" && mimeType
176 ? completeIconResolver.resolveIcon(
177 "file-tree-icon-file",
apps/web/vite.config.ts
+17
@@ -113,7 +113,10 @@ const browserTestProject = {
113 "@betteroffice/xlsx/headless",
114 "fast-xml-parser",
115 "dompurify",
116 + "heic-to/next",
117 "jszip",
118 + "sql.js",
119 + "tiff",
120 ],
121 },
122 test: {
@@ -346,6 +349,20 @@ export default defineConfig(() => {
349 emptyOutDir: true,
350 manifest: true,
351 sourcemap: buildSourcemap,
352 + rolldownOptions: {
353 + output: {
354 + codeSplitting: {
355 + // Preview imports must not fold shared file icons back into main.
356 + groups: [
357 + {
358 + name: "icons",
359 + test: /\/(?:components\/chat\/PierreEntryIcon\.tsx|pierre-icons\.ts|mediaPreview\.ts)$/,
360 + includeDependenciesRecursively: false,
361 + },
362 + ],
363 + },
364 + },
365 + },
366 },
367 worker: { format: "es" },
368 test: {
packages/client-runtime/src/mediaSource.ts
+4 -5
@@ -1,9 +1,9 @@
1 import type { AssetResource, ThreadId } from "@t3tools/contracts";
2 import {
3 - filePreviewKind,
3 + audioMimeTypeFromExtension,
4 mediaMimeType,
5 mediaMimeTypeFromExtension,
6 -} from "@t3tools/shared/filePreview";
6 +} from "@t3tools/shared/mediaPreview";
7
8 import {
9 classifyMarkdownImageSource,
@@ -69,15 +69,14 @@ export function resolveMediaSource(
69 : splitFilePathPosition(classified.path).path;
70 // Local paths have already been decoded. Do not interpret literal #, ?, or % characters again.
71 const basename = fileBasename(path);
72 - if (classified._tag === "WorkspaceFile" && filePreviewKind({ name: basename }) === "audio")
73 - return null;
72 const extensionIndex = basename.lastIndexOf(".");
73 const detectedMimeType =
74 classified._tag === "Direct"
75 ? mediaMimeType(classified.uri)
76 : extensionIndex < 0
77 ? null
80 - : mediaMimeTypeFromExtension(basename.slice(extensionIndex));
78 + : (mediaMimeTypeFromExtension(basename.slice(extensionIndex)) ??
79 + audioMimeTypeFromExtension(basename.slice(extensionIndex)));
80 const mimeType = detectedMimeType ?? (input.imageEmbed ? "image/*" : null);
81 if (mimeType === null || mimeType.startsWith("audio/")) return null;
82 const kind = mimeType.startsWith("video/") ? "video" : "image";
packages/client-runtime/src/projectFaviconCache.ts
+1 -1
@@ -1,5 +1,5 @@
1 import { EnvironmentId } from "@t3tools/contracts";
2 -import { mediaMimeType } from "@t3tools/shared/filePreview";
2 +import { mediaMimeType } from "@t3tools/shared/mediaPreview";
3 import {
4 getProjectFaviconCacheKey,
5 getProjectFaviconResourceKey,
packages/client-runtime/src/state/assets.ts
+1 -1
@@ -7,7 +7,7 @@ import {
7 type ProjectCloneSnapshot,
8 WS_METHODS,
9 } from "@t3tools/contracts";
10 -import { mediaMimeTypeFromExtension } from "@t3tools/shared/filePreview";
10 +import { mediaMimeTypeFromExtension } from "@t3tools/shared/mediaPreview";
11 import { isWindowsAbsolutePath } from "@t3tools/shared/path";
12 import {
13 getProjectFaviconResourceKey,
packages/client-runtime/src/work-log/presentation.ts
+1 -1
@@ -17,7 +17,7 @@ import {
17 import { classifyMarkdownImageSource } from "@t3tools/client-runtime/markdown-images";
18 import { resolveMediaSource } from "@t3tools/client-runtime/media-source";
19 import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
20 -import { isWorkspaceImagePreviewPath } from "@t3tools/shared/filePreview";
20 +import { isWorkspaceImagePreviewPath } from "@t3tools/shared/mediaPreview";
21 import { formatTokens } from "@t3tools/shared/usageFormat";
22 import { classifyToolActivity } from "@t3tools/shared/toolActivity";
23 import { toolOutputIndicatesFailure } from "@t3tools/shared/toolOutput";
packages/client-runtime/src/work-log/toolPresentation.ts
+1 -1
@@ -1,4 +1,4 @@
1 -import { isWorkspaceImagePreviewPath } from "@t3tools/shared/filePreview";
1 +import { isWorkspaceImagePreviewPath } from "@t3tools/shared/mediaPreview";
2 import { COMPUTER_USE_TOOL_SOURCE, dynamicToolSurface } from "@t3tools/shared/toolActivity";
3 import type {
4 ToolActivityIcon,
packages/shared/package.json
+4
@@ -299,6 +299,10 @@
299 "types": "./src/previewViewport.ts",
300 "import": "./src/previewViewport.ts"
301 },
302 + "./mediaPreview": {
303 + "types": "./src/mediaPreview.ts",
304 + "import": "./src/mediaPreview.ts"
305 + },
306 "./filePreview": {
307 "types": "./src/filePreview.ts",
308 "import": "./src/filePreview.ts"
packages/shared/src/filePreview.test.ts
+29 -5
@@ -13,6 +13,29 @@ import {
13 } from "./filePreview.ts";
14
15 describe("workspace file previews", () => {
16 + it.each([
17 + ["zip", "archive", "application/zip"],
18 + ["jar", "archive", "application/java-archive"],
19 + ["tar", "archive", "application/x-tar"],
20 + ["gz", "archive", "application/gzip"],
21 + ["tgz", "archive", "application/gzip"],
22 + ["sqlite", "sqlite", "application/vnd.sqlite3"],
23 + ["sqlite3", "sqlite", "application/vnd.sqlite3"],
24 + ["db", "sqlite", "application/vnd.sqlite3"],
25 + ])("recognizes binary preview %s", (extension, kind, mimeType) => {
26 + const name = `files#draft/sample.${extension.toUpperCase()}`;
27 + expect(filePreviewKind({ name, mimeType: "application/octet-stream" })).toBe(kind);
28 + expect(filePreviewKind({ name: "download", mimeType })).toBe(kind);
29 + expect(isWorkspacePreviewEntryPath(name)).toBe(true);
30 + expect(isWorkspacePreviewEntryPath(`${name}?download=1`)).toBe(false);
31 + expect(hostPreviewMimeTypeFromExtension(`.${extension}`)).toBe(mimeType);
32 + });
33 + it("recognizes compound archives and MIME aliases", () => {
34 + expect(filePreviewKind({ name: "archive.tar.gz" })).toBe("archive");
35 + expect(filePreviewKind({ name: "download", mimeType: "application/x-gzip" })).toBe("archive");
36 + expect(filePreviewKind({ name: "download", mimeType: "application/x-sqlite3" })).toBe("sqlite");
37 + expect(filePreviewKind({ name: "misleading.zip", mimeType: "application/pdf" })).toBe("pdf");
38 + });
39 it.each(["ttf", "otf", "woff", "woff2"])(
40 "previews %s fonts through signed host assets",
41 (extension) => {
@@ -25,7 +48,7 @@ describe("workspace file previews", () => {
48 expect(hostPreviewMimeTypeFromExtension(`.${extension}`)).toBe(`font/${extension}`);
49 expect(isWorkspaceFontPreviewPath(`sample.${extension}?download=1`)).toBe(false);
50 expect(filePreviewKind({ name: `sample.${extension}`, mimeType: "application/zip" })).toBe(
28 - "unsupported",
51 + "archive",
52 );
53 },
54 );
@@ -51,7 +74,7 @@ describe("workspace file previews", () => {
74 expect(isWorkspacePreviewEntryPath(name)).toBe(true);
75 expect(hostPreviewMimeTypeFromExtension(`.${kind}`)).toBe(mimeType);
76 expect(filePreviewKind({ name: "download", mimeType })).toBe(kind);
54 - expect(filePreviewKind({ name, mimeType: "application/zip" })).toBe("unsupported");
77 + expect(filePreviewKind({ name, mimeType: "application/zip" })).toBe("archive");
78 });
79 // regression: #10311 previews classify by the literal filename, not URL-like suffixes
80 it.each([
@@ -67,7 +90,7 @@ describe("workspace file previews", () => {
90 expect(isWorkspacePreviewEntryPath(path)).toBe(false);
91 });
92
70 - it.each(["picture.bmp", "photo.heic", "scan.tif", "scan.TIFF"])(
93 + it.each(["picture.bmp", "photo.heic", "photo.heif", "scan.tif", "scan.TIFF"])(
94 "recognizes image preview path %s",
95 (path) => {
96 expect(isWorkspaceImagePreviewPath(path)).toBe(true);
@@ -132,8 +155,9 @@ describe("attachment preview classification", () => {
155 ["recording.webm-audio", "", "audio"],
156 ["recording.webm", "audio/webm", "audio"],
157 ["payload", "application/problem+json", "text"],
158 + ["archive.zip", "application/zip", "archive"],
159 ["misleading.json", "application/pdf", "pdf"],
136 - ["misleading.pdf", "application/zip", "unsupported"],
160 + ["misleading.pdf", "application/zip", "archive"],
161 ])("classifies %s (%s) as %s", (name, mimeType, expected) => {
162 expect(filePreviewKind({ name, mimeType })).toBe(expected);
163 });
@@ -141,7 +165,7 @@ describe("attachment preview classification", () => {
165 expect(() => decodeFilePreviewText(new Uint8Array([65, 0, 66]))).toThrow("binary");
166 expect(() => decodeFilePreviewText(new Uint8Array([255]))).toThrow("UTF-8");
167 });
144 - it.each(["doc", "xls", "ppt", "odt", "ods", "odp", "epub", "zip", "tar", "gz", "7z", "rar"])(
168 + it.each(["doc", "xls", "ppt", "odt", "ods", "odp", "epub", "7z", "rar"])(
169 "retains the binary fallback for %s, which opencode does not render",
170 (extension) => {
171 expect(filePreviewKind({ name: `sample.${extension}` })).toBe("unsupported");
packages/shared/src/filePreview.ts
+55 -123
@@ -1,24 +1,16 @@
1 +import {
2 + audioMimeTypeFromExtension,
3 + isWorkspaceImagePreviewPath,
4 + mediaMimeTypeFromExtension,
5 +} from "./mediaPreview.ts";
6 +export {
7 + isWorkspaceAudioPreviewPath,
8 + isWorkspaceImagePreviewPath,
9 + mediaKindFromPath,
10 + mediaMimeTypeFromExtension,
11 +} from "./mediaPreview.ts";
12 import { videoMimeType } from "./video.ts";
13
3 -const ICON_EXTENSION_BY_MIME_TYPE: Readonly<Record<string, string>> = {
4 - "image/png": "png",
5 - "image/jpeg": "jpg",
6 - "image/gif": "gif",
7 - "image/webp": "webp",
8 - "application/pdf": "pdf",
9 - "application/zip": "zip",
10 - "application/vnd.sqlite3": "sqlite",
11 - "text/x-python": "py",
12 - "text/javascript": "js",
13 - "text/x-ruby": "rb",
14 - "text/x-shellscript": "sh",
15 -};
16 -
17 -export function fileIconPathForMimeType(path: string, mimeType?: string): string {
18 - const extension = ICON_EXTENSION_BY_MIME_TYPE[mimeType ?? ""];
19 - return extension ? `file.${extension}` : path;
20 -}
21 -
14 export type FilePreviewKind =
15 | "image"
16 | "video"
@@ -28,6 +20,8 @@ export type FilePreviewKind =
20 | "markdown"
21 | "mermaid"
22 | "font"
23 + | "archive"
24 + | "sqlite"
25 | "docx"
26 | "xlsx"
27 | "pptx"
@@ -45,6 +39,8 @@ export function filePreviewKind(
39 const richDocuments = options?.richDocuments !== false;
40 const office = richDocuments ? officePreviewKind(file) : null;
41 if (office) return office;
42 + const binary = binaryPreviewKind(file);
43 + if (binary) return binary;
44 if (mime === "application/pdf") return "pdf";
45 if (mime === "text/html") return "html";
46 if (mime === "text/markdown" || mime === "text/x-markdown") return "markdown";
@@ -93,6 +89,43 @@ export function filePreviewKind(
89 return "unsupported";
90 }
91
92 +const BINARY_MIME_TYPES = new Map([
93 + [".zip", "application/zip"],
94 + [".jar", "application/java-archive"],
95 + [".tar", "application/x-tar"],
96 + [".gz", "application/gzip"],
97 + [".tgz", "application/gzip"],
98 + [".sqlite", "application/vnd.sqlite3"],
99 + [".sqlite3", "application/vnd.sqlite3"],
100 + [".db", "application/vnd.sqlite3"],
101 +]);
102 +
103 +export function binaryPreviewKind(file: {
104 + readonly name: string;
105 + readonly mimeType?: string;
106 +}): "archive" | "sqlite" | null {
107 + const mime = file.mimeType?.split(";", 1)[0]?.trim().toLowerCase() ?? "";
108 + if (["application/vnd.sqlite3", "application/x-sqlite3", "application/x-sqlite"].includes(mime))
109 + return "sqlite";
110 + if (
111 + [
112 + "application/zip",
113 + "application/x-zip-compressed",
114 + "application/java-archive",
115 + "application/x-java-archive",
116 + "application/x-tar",
117 + "application/gzip",
118 + "application/x-gzip",
119 + "application/x-compressed-tar",
120 + ].includes(mime)
121 + )
122 + return "archive";
123 + if (mime && mime !== "application/octet-stream" && mime !== "text/plain") return null;
124 + const extension = file.name.slice(file.name.lastIndexOf(".")).toLowerCase();
125 + const inferred = BINARY_MIME_TYPES.get(extension);
126 + return inferred === "application/vnd.sqlite3" ? "sqlite" : inferred ? "archive" : null;
127 +}
128 +
129 export const FILE_TEXT_PREVIEW_MAX_BYTES = 1024 * 1024;
130
131 const OFFICE_MIME_TYPES = {
@@ -136,56 +169,12 @@ export function decodeFilePreviewText(bytes: Uint8Array, truncated = false) {
169
170 export const WORKSPACE_BROWSER_PREVIEW_EXTENSIONS = [".htm", ".html", ".pdf"] as const;
171
139 -export const WORKSPACE_IMAGE_PREVIEW_EXTENSIONS = [
140 - ".avif",
141 - ".bmp",
142 - ".gif",
143 - ".ico",
144 - ".heic",
145 - ".jpeg",
146 - ".jpg",
147 - ".png",
148 - ".svg",
149 - ".tif",
150 - ".tiff",
151 - ".webp",
152 -] as const;
153 -
154 -const IMAGE_MIME_TYPE_BY_EXTENSION = new Map([
155 - [".avif", "image/avif"],
156 - [".bmp", "image/bmp"],
157 - [".heic", "image/heic"],
158 - [".gif", "image/gif"],
159 - [".ico", "image/x-icon"],
160 - [".jpeg", "image/jpeg"],
161 - [".jpg", "image/jpeg"],
162 - [".png", "image/png"],
163 - [".svg", "image/svg+xml"],
164 - [".tif", "image/tiff"],
165 - [".tiff", "image/tiff"],
166 - [".webp", "image/webp"],
167 -]);
168 -
172 const BROWSER_MIME_TYPE_BY_EXTENSION = new Map([
173 [".htm", "text/html"],
174 [".html", "text/html"],
175 [".pdf", "application/pdf"],
176 ]);
177
175 -const AUDIO_MIME_TYPE_BY_EXTENSION = new Map([
176 - [".mp3", "audio/mpeg"],
177 - [".wav", "audio/wav"],
178 - [".ogg", "audio/ogg"],
179 - [".oga", "audio/ogg"],
180 - [".flac", "audio/flac"],
181 - [".aac", "audio/aac"],
182 - [".m4a", "audio/mp4"],
183 - [".opus", "audio/ogg"],
184 - [".aiff", "audio/aiff"],
185 - [".webm-audio", "audio/webm"],
186 - [".weba", "audio/webm"],
187 -]);
188 -
178 const FONT_MIME_TYPE_BY_EXTENSION = new Map([
179 [".ttf", "font/ttf"],
180 [".otf", "font/otf"],
@@ -197,20 +186,6 @@ export function isWorkspaceFontPreviewPath(path: string): boolean {
186 return /\.(ttf|otf|woff2?)$/i.test(path);
187 }
188
200 -export function audioMimeTypeFromExtension(extension: string): string | null {
201 - if (!/^\.[a-z0-9-]+$/i.test(extension)) return null;
202 - return AUDIO_MIME_TYPE_BY_EXTENSION.get(extension.toLowerCase()) ?? null;
203 -}
204 -
205 -/** Classifies a literal filesystem extension, without URL decoding or suffix removal. */
206 -export function mediaMimeTypeFromExtension(extension: string): string | null {
207 - if (!/^\.[a-z0-9]+$/i.test(extension)) return null;
208 - return (
209 - IMAGE_MIME_TYPE_BY_EXTENSION.get(extension.toLowerCase()) ??
210 - videoMimeType({ name: `media${extension}`, mimeType: "" })
211 - );
212 -}
213 -
189 export function hostPreviewMimeTypeFromExtension(extension: string): string | null {
190 if (!/^\.[a-z0-9-]+$/i.test(extension)) return null;
191 return (
@@ -218,6 +193,7 @@ export function hostPreviewMimeTypeFromExtension(extension: string): string | nu
193 audioMimeTypeFromExtension(extension) ??
194 BROWSER_MIME_TYPE_BY_EXTENSION.get(extension.toLowerCase()) ??
195 FONT_MIME_TYPE_BY_EXTENSION.get(extension.toLowerCase()) ??
196 + BINARY_MIME_TYPES.get(extension.toLowerCase()) ??
197 (Object.hasOwn(OFFICE_MIME_TYPES, extension.toLowerCase().slice(1))
198 ? OFFICE_MIME_TYPES[extension.toLowerCase().slice(1) as OfficePreviewKind]
199 : null) ??
@@ -225,42 +201,6 @@ export function hostPreviewMimeTypeFromExtension(extension: string): string | nu
201 );
202 }
203
228 -/** Classifies an authored media path or URL. Filesystem validation uses the literal extension. */
229 -export function mediaMimeType(path: string): string | null {
230 - const trimmed = path.trim();
231 - const source = trimmed.startsWith("<") && trimmed.endsWith(">") ? trimmed.slice(1, -1) : trimmed;
232 - const dataMimeType = /^data:((?:image|video|audio)\/[\w.+-]+)[;,]/i.exec(source)?.[1];
233 - if (dataMimeType) return dataMimeType.toLowerCase();
234 -
235 - let sourcePath = source.split(/[?#]/, 1)[0] ?? "";
236 - if (/^(?:https?:|file:|\/\/)/i.test(source)) {
237 - try {
238 - sourcePath = new URL(source, "https://media.invalid").pathname;
239 - } catch {
240 - return null;
241 - }
242 - }
243 - try {
244 - sourcePath = decodeURIComponent(sourcePath);
245 - } catch {}
246 - const basename = sourcePath.split(/[\\/]/).at(-1) ?? "";
247 - const extensionIndex = basename.lastIndexOf(".");
248 - return extensionIndex < 0
249 - ? null
250 - : (mediaMimeTypeFromExtension(basename.slice(extensionIndex)) ??
251 - audioMimeTypeFromExtension(basename.slice(extensionIndex)));
252 -}
253 -
254 -export function mediaKindFromPath(path: string): "image" | "video" | "audio" | null {
255 - const mimeType = mediaMimeType(path);
256 - if (mimeType === null) return null;
257 - return mimeType.startsWith("audio/")
258 - ? "audio"
259 - : mimeType.startsWith("video/")
260 - ? "video"
261 - : "image";
262 -}
263 -
204 function hasPreviewExtension(path: string, extensions: ReadonlyArray<string>): boolean {
205 const literalPath = path.toLowerCase();
206 return extensions.some((extension) => literalPath.endsWith(extension));
@@ -270,25 +210,17 @@ export function isWorkspaceBrowserPreviewPath(path: string): boolean {
210 return hasPreviewExtension(path, WORKSPACE_BROWSER_PREVIEW_EXTENSIONS);
211 }
212
273 -export function isWorkspaceImagePreviewPath(path: string): boolean {
274 - return hasPreviewExtension(path, WORKSPACE_IMAGE_PREVIEW_EXTENSIONS);
275 -}
276 -
213 /** File viewers receive literal filesystem paths, not Markdown URLs. */
214 export function isWorkspaceVideoPreviewPath(path: string): boolean {
215 return videoMimeType({ name: path, mimeType: "" }) !== null;
216 }
217
282 -export function isWorkspaceAudioPreviewPath(path: string): boolean {
283 - const extensionIndex = path.lastIndexOf(".");
284 - return extensionIndex >= 0 && audioMimeTypeFromExtension(path.slice(extensionIndex)) !== null;
285 -}
286 -
218 export function isWorkspacePreviewEntryPath(path: string): boolean {
219 return (
220 isWorkspaceBrowserPreviewPath(path) ||
221 isWorkspaceImagePreviewPath(path) ||
222 isWorkspaceFontPreviewPath(path) ||
292 - officePreviewKind({ name: path }) !== null
223 + officePreviewKind({ name: path }) !== null ||
224 + binaryPreviewKind({ name: path }) !== null
225 );
226 }
packages/shared/src/mediaPreview.ts new
+126
@@ -0,0 +1,126 @@
1 +import { videoMimeType } from "./video.ts";
2 +
3 +const ICON_EXTENSION_BY_MIME_TYPE: Readonly<Record<string, string>> = {
4 + "image/png": "png",
5 + "image/jpeg": "jpg",
6 + "image/gif": "gif",
7 + "image/webp": "webp",
8 + "application/pdf": "pdf",
9 + "application/zip": "zip",
10 + "application/vnd.sqlite3": "sqlite",
11 + "text/x-python": "py",
12 + "text/javascript": "js",
13 + "text/x-ruby": "rb",
14 + "text/x-shellscript": "sh",
15 +};
16 +
17 +export function fileIconPathForMimeType(path: string, mimeType?: string): string {
18 + const extension = ICON_EXTENSION_BY_MIME_TYPE[mimeType ?? ""];
19 + return extension ? `file.${extension}` : path;
20 +}
21 +
22 +export const WORKSPACE_IMAGE_PREVIEW_EXTENSIONS = [
23 + ".avif",
24 + ".bmp",
25 + ".gif",
26 + ".ico",
27 + ".heic",
28 + ".heif",
29 + ".jpeg",
30 + ".jpg",
31 + ".png",
32 + ".svg",
33 + ".tif",
34 + ".tiff",
35 + ".webp",
36 +] as const;
37 +
38 +const IMAGE_MIME_TYPE_BY_EXTENSION = new Map([
39 + [".avif", "image/avif"],
40 + [".bmp", "image/bmp"],
41 + [".heic", "image/heic"],
42 + [".heif", "image/heif"],
43 + [".gif", "image/gif"],
44 + [".ico", "image/x-icon"],
45 + [".jpeg", "image/jpeg"],
46 + [".jpg", "image/jpeg"],
47 + [".png", "image/png"],
48 + [".svg", "image/svg+xml"],
49 + [".tif", "image/tiff"],
50 + [".tiff", "image/tiff"],
51 + [".webp", "image/webp"],
52 +]);
53 +
54 +const AUDIO_MIME_TYPE_BY_EXTENSION = new Map([
55 + [".mp3", "audio/mpeg"],
56 + [".wav", "audio/wav"],
57 + [".ogg", "audio/ogg"],
58 + [".oga", "audio/ogg"],
59 + [".flac", "audio/flac"],
60 + [".aac", "audio/aac"],
61 + [".m4a", "audio/mp4"],
62 + [".opus", "audio/ogg"],
63 + [".aiff", "audio/aiff"],
64 + [".webm-audio", "audio/webm"],
65 + [".weba", "audio/webm"],
66 +]);
67 +
68 +export function audioMimeTypeFromExtension(extension: string): string | null {
69 + if (!/^\.[a-z0-9-]+$/i.test(extension)) return null;
70 + return AUDIO_MIME_TYPE_BY_EXTENSION.get(extension.toLowerCase()) ?? null;
71 +}
72 +
73 +/** Classifies a literal filesystem extension, without URL decoding or suffix removal. */
74 +export function mediaMimeTypeFromExtension(extension: string): string | null {
75 + if (!/^\.[a-z0-9]+$/i.test(extension)) return null;
76 + return (
77 + IMAGE_MIME_TYPE_BY_EXTENSION.get(extension.toLowerCase()) ??
78 + videoMimeType({ name: `media${extension}`, mimeType: "" })
79 + );
80 +}
81 +
82 +/** Classifies an authored media path or URL. Filesystem validation uses the literal extension. */
83 +export function mediaMimeType(path: string): string | null {
84 + const trimmed = path.trim();
85 + const source = trimmed.startsWith("<") && trimmed.endsWith(">") ? trimmed.slice(1, -1) : trimmed;
86 + const dataMimeType = /^data:((?:image|video|audio)\/[\w.+-]+)[;,]/i.exec(source)?.[1];
87 + if (dataMimeType) return dataMimeType.toLowerCase();
88 +
89 + let sourcePath = source.split(/[?#]/, 1)[0] ?? "";
90 + if (/^(?:https?:|file:|\/\/)/i.test(source)) {
91 + try {
92 + sourcePath = new URL(source, "https://media.invalid").pathname;
93 + } catch {
94 + return null;
95 + }
96 + }
97 + try {
98 + sourcePath = decodeURIComponent(sourcePath);
99 + } catch {}
100 + const basename = sourcePath.split(/[\\/]/).at(-1) ?? "";
101 + const extensionIndex = basename.lastIndexOf(".");
102 + return extensionIndex < 0
103 + ? null
104 + : (mediaMimeTypeFromExtension(basename.slice(extensionIndex)) ??
105 + audioMimeTypeFromExtension(basename.slice(extensionIndex)));
106 +}
107 +
108 +export function mediaKindFromPath(path: string): "image" | "video" | "audio" | null {
109 + const mimeType = mediaMimeType(path);
110 + if (mimeType === null) return null;
111 + return mimeType.startsWith("audio/")
112 + ? "audio"
113 + : mimeType.startsWith("video/")
114 + ? "video"
115 + : "image";
116 +}
117 +
118 +export function isWorkspaceImagePreviewPath(path: string): boolean {
119 + const literalPath = path.toLowerCase();
120 + return WORKSPACE_IMAGE_PREVIEW_EXTENSIONS.some((extension) => literalPath.endsWith(extension));
121 +}
122 +
123 +export function isWorkspaceAudioPreviewPath(path: string): boolean {
124 + const extensionIndex = path.lastIndexOf(".");
125 + return extensionIndex >= 0 && audioMimeTypeFromExtension(path.slice(extensionIndex)) !== null;
126 +}
packages/shared/src/projectFavicon.ts
+1 -1
@@ -1,4 +1,4 @@
1 -import { WORKSPACE_IMAGE_PREVIEW_EXTENSIONS } from "./filePreview.ts";
1 +import { WORKSPACE_IMAGE_PREVIEW_EXTENSIONS } from "./mediaPreview.ts";
2
3 export const PROJECT_FAVICON_FALLBACK_MARKER = "project-favicon-missing";
4
pnpm-lock.yaml
+74 -196
@@ -1193,9 +1193,15 @@ importers:
1193 saxes:
1194 specifier: 6.0.0
1195 version: 6.0.0
1196 + sql.js:
1197 + specifier: 1.15.0
1198 + version: 1.15.0
1199 tailwind-merge:
1200 specifier: ^3.4.0
1201 version: 3.6.0
1202 + tiff:
1203 + specifier: 7.1.3
1204 + version: 7.1.3
1205 unbash:
1206 specifier: ^5.0.0
1207 version: 5.0.0
@@ -1236,6 +1242,9 @@ importers:
1242 '@types/react-dom':
1243 specifier: 'catalog:'
1244 version: 19.3.0(@types/react@19.3.0)
1245 + '@types/sql.js':
1246 + specifier: 1.4.11
1247 + version: 1.4.11
1248 '@types/use-sync-external-store':
1249 specifier: ^0.0.6
1250 version: 0.0.6
@@ -1298,10 +1307,10 @@ importers:
1307 version: link:../../packages/shared
1308 alchemy:
1309 specifier: 2.0.0-beta.80
1301 - version: 2.0.0-beta.80(patch_hash=bea1b6c0c0b23157fd5f439a1d7feff430f28ac1621ba135d8a13eeec60ccacd)(ed9f72c53f648b6275121476d8becac3)
1310 + version: 2.0.0-beta.80(patch_hash=bea1b6c0c0b23157fd5f439a1d7feff430f28ac1621ba135d8a13eeec60ccacd)(e50ec971fc482761b0a5b8ee3921094f)
1311 drizzle-orm:
1312 specifier: 1.0.0-rc.5-ab785fc
1304 - version: 1.0.0-rc.5-ab785fc(@cloudflare/workers-types@4.20260604.1)(@effect/sql-d1@4.0.0(effect@4.0.5))(@effect/sql-pg@4.0.5(effect@4.0.5))(@effect/sql-sqlite-bun@4.0.0-rc.112(effect@4.0.5))(@effect/sql-sqlite-do@4.0.5(effect@4.0.5))(@electric-sql/pglite@0.3.15)(@libsql/client@0.17.3(bufferutil@4.1.0)(utf-8-validate@6.0.6))(bun-types@1.3.14)(effect@4.0.5)(expo-sqlite@58.0.13(expo@58.0.14)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0))(pg@8.23.0)(zod@4.4.3)
1313 + version: 1.0.0-rc.5-ab785fc(@cloudflare/workers-types@4.20260604.1)(@effect/sql-d1@4.0.0(effect@4.0.5))(@effect/sql-pg@4.0.5(effect@4.0.5))(@effect/sql-sqlite-bun@4.0.0-rc.112(effect@4.0.5))(@effect/sql-sqlite-do@4.0.5(effect@4.0.5))(@electric-sql/pglite@0.3.15)(@libsql/client@0.17.3(bufferutil@4.1.0)(utf-8-validate@6.0.6))(@types/sql.js@1.4.11)(bun-types@1.3.14)(effect@4.0.5)(expo-sqlite@58.0.13(expo@58.0.14)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0))(pg@8.23.0)(sql.js@1.15.0)(zod@4.6.5)
1314 effect:
1315 specifier: 4.0.5
1316 version: 4.0.5
@@ -1335,7 +1344,7 @@ importers:
1344 dependencies:
1345 alchemy:
1346 specifier: 2.0.0-beta.80
1338 - version: 2.0.0-beta.80(patch_hash=bea1b6c0c0b23157fd5f439a1d7feff430f28ac1621ba135d8a13eeec60ccacd)(93312816496722c8e540690c17876476)
1347 + version: 2.0.0-beta.80(patch_hash=bea1b6c0c0b23157fd5f439a1d7feff430f28ac1621ba135d8a13eeec60ccacd)(e50ec971fc482761b0a5b8ee3921094f)
1348 effect:
1349 specifier: 4.0.5
1350 version: 4.0.5
@@ -1369,7 +1378,7 @@ importers:
1378 version: 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
1379 '@oxlint/plugins':
1380 specifier: ^1.63.0
1372 - version: 1.68.0
1381 + version: 1.89.0
1382 effect:
1383 specifier: 4.0.5
1384 version: 4.0.5
@@ -2236,10 +2245,6 @@ packages:
2245 peerDependencies:
2246 zod: ^3.25.76 || ^4.1.8
2247
2239 - '@ai-sdk/provider@3.0.15':
2240 - resolution: {integrity: sha512-XeZW1CcDF2GMbH4wejW6xBRI2QCOgnkVYUnxoeDadB1mf85riL2bMUeDoh+6gJ/r4mjNfzUPW8OjLjvwTP0u1Q==}
2241 - engines: {node: '>=18'}
2242 -
2248 '@ai-sdk/provider@3.0.18':
2249 resolution: {integrity: sha512-IpefF5ssZVOZCD4Wu7zxt6PwZoGT2HLVjxpJ10Bjx6EAmRfLYJPjyrfxb0RYDlwvXnDb9nkQ7Do/oJVDuRFzew==}
2250 engines: {node: '>=18'}
@@ -2887,10 +2892,6 @@ packages:
2892 resolution: {integrity: sha512-EhlfNQtZ+NK22w5BM61ciuiq1m58ed33Wr1Xan//ZRTy6hgjnwyCffRYwzsGXdASJSUJ1guZILsErh1eQcl+zw==}
2893 engines: {node: '>=6.9.0'}
2894
2890 - '@babel/types@7.29.7':
2891 - resolution: {integrity: sha512-4zBIxpPzowiZpusoFkyGVwakdRJUyuH5PxQ/PrqghfdFWWasvnCdPfQXHrenDai+gyLARulZjZowCOj6fjT4pA==}
2892 - engines: {node: '>=6.9.0'}
2893 -
2895 '@babel/types@7.29.8':
2896 resolution: {integrity: sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==}
2897 engines: {node: '>=6.9.0'}
@@ -4638,12 +4639,6 @@ packages:
4639 resolution: {integrity: sha512-WrOw/bcXm0f9qHkumlT1QlArXSTWqaY9sunsDpOk+yCCorCKMxvWT/a3xko4EYHVdeZoh00yI2TydXn6eyICDA==}
4640 engines: {node: '>= 10'}
4641
4641 - '@napi-rs/wasm-runtime@1.1.6':
4642 - resolution: {integrity: sha512-ZLv/JdUfkvOy9eCnnBaGfiO+XimbjebAeO+MRQqD/B+FR1tnRN0tpKSJHRbE8sFfS6aqsXZ67TQjfwfsxULVbg==}
4643 - peerDependencies:
4644 - '@emnapi/core': ^1.7.1
4645 - '@emnapi/runtime': ^1.7.1
4646 -
4642 '@napi-rs/wasm-runtime@1.2.4':
4643 resolution: {integrity: sha512-AJxoUD2/15ESHbvpcyjU274nsAPLuOtPHCk0vKJM5pj//Fg/B1FXNWjPnXTT9PymCYYiHo4zPj0ZomXBKhoy7g==}
4644 engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0}
@@ -5608,10 +5603,6 @@ packages:
5603 cpu: [x64]
5604 os: [win32]
5605
5611 - '@oxlint/plugins@1.68.0':
5612 - resolution: {integrity: sha512-titLmukUt/h8ho7Svlf0xSBjoy2ccZKrXjpXpZCj+v6V4CJccC2KyP45BLSCMx8YIpifMyiDyUptM4+5sruKbQ==}
5613 - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
5614 -
5606 '@oxlint/plugins@1.89.0':
5607 resolution: {integrity: sha512-TJBBNl4KIxbxrSk7gsqlz6iM1kxidfyTizEzfWqXvijF2Ou8/Da58GvjemBVmCmaUamwRij+JwsVc0kpBFuqfg==}
5608 engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
@@ -6614,9 +6605,6 @@ packages:
6605 '@tweenjs/tween.js@23.1.3':
6606 resolution: {integrity: sha512-vJmvvwFxYuGnF2axRtPYocag6Clbb5YS7kLL+SO/TeVFzHqDIWrNKYtcsPMibjDx9O+bu+psAy9NKfWklassUA==}
6607
6617 - '@tybys/wasm-util@0.10.3':
6618 - resolution: {integrity: sha512-F3fo1MYrRJYL3zER0OUOmkutjr1Vp23m7OsSgp7nq4SP6OqX6C/56XFIPAl5bt3zaBRjmW7SGz3u/6LwFpYcOg==}
6619 -
6608 '@tybys/wasm-util@0.10.4':
6609 resolution: {integrity: sha512-W3c4gRigFS0T/Ma4qIYF3GDAc5AQdHb1yL5znJT1Zv1YaD9Kitx656wBjvr19qbiosmZT8lWDM5BEMynUqX65A==}
6610
@@ -6745,6 +6733,9 @@ packages:
6733 '@types/serve-static@2.2.0':
6734 resolution: {integrity: sha512-8mam4H1NHLtu7nmtalF7eyBH14QyOASmcxHhSfEoRyr0nP/YdoesEtU+uSRvMe96TW/HPTtkoKqQLl53N7UXMQ==}
6735
6736 + '@types/sql.js@1.4.11':
6737 + resolution: {integrity: sha512-QXIx38p2ZThJaK9vP5ZdqdlRe1FG9I8SmCZOS7FHfB/2qPAjZwkL7/vlfPg6N/oWHuuOaGg/P/IRwfP2W0kWVQ==}
6738 +
6739 '@types/stats.js@0.17.4':
6740 resolution: {integrity: sha512-jIBvWWShCvlBqBNIZt0KAshWpvSjhkwkEu4ZUcASoAvhmrgAUI2t1dXrjSL4xXVLB4FznPrIsX3nKXFl/Dt4vA==}
6741
@@ -9205,6 +9196,9 @@ packages:
9196 invariant@2.2.4:
9197 resolution: {integrity: sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==}
9198
9199 + iobuffer@6.0.1:
9200 + resolution: {integrity: sha512-SZWYkWNfjIXIBYSDpXDYIgshqtbOPsi4lviawAEceR1Kqk+sHDlcQjWrzNQsii80AyBY0q5c8HCTNjqo74ul+Q==}
9201 +
9202 ioredis@5.11.0:
9203 resolution: {integrity: sha512-EZBErytyVovD8f6pDfG3Kb37N6Y3lmDA9NNj+4+IP13CzzHGeX+OyeRM2Um13khRzoBSzzL+5lVnCX8V2RLeMg==}
9204 engines: {node: '>=12.22.0'}
@@ -9340,9 +9334,6 @@ packages:
9334 jose@6.2.2:
9335 resolution: {integrity: sha512-d7kPDd34KO/YnzaDOlikGpOurfF0ByC2sEV4cANCtdqLlTfBlw2p14O/5d/zv40gJPbIQxfES3nSx1/oYNyuZQ==}
9336
9343 - jose@6.2.3:
9344 - resolution: {integrity: sha512-YYVDInQKFJfR/xa3ojUTl8c2KoTwiL1R5Wg9YCydwH0x0B9grbzlg5HC7mMjCtUJjbQ/YnGEZIhI5tCgfTb4Hw==}
9345 -
9337 js-base64@3.7.8:
9338 resolution: {integrity: sha512-hNngCeKxIUQiEUN3GPJOkz4wF/YvdUdbNL9hsBcMQTkKzboD7T/q3OYOuuPZLUE6dBxSGpwhk5mwuDud7JVAow==}
9339
@@ -9623,9 +9614,6 @@ packages:
9614 magic-string@0.30.21:
9615 resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==}
9616
9626 - magic-string@1.4.1:
9627 - resolution: {integrity: sha512-8lyCu36ErXR0J9uaGKlKQoiLZKmtI63YGLE8G2o9jyRPdr4X47LusSOwgOJOzcVtp81fTAAjxR7BwKz682Jhow==}
9628 -
9617 magic-string@1.4.3:
9618 resolution: {integrity: sha512-z12OxmaPGE0F4xlpGdjuAUckipLpQlTAuAmyGhNoD7ODpYUzvDfvtxUbjM/jwznyP178oju/KDdyi220wNJ0RQ==}
9619
@@ -10039,11 +10027,6 @@ packages:
10027 multitars@1.0.2:
10028 resolution: {integrity: sha512-6GwVw5eLi9sThdtlS4PKwC7yRLaf45pYhIEzKBHdKxi+YOXGKFX8acIniH+Uh/+k9mS2lQOupTccjoe5r0/1IQ==}
10029
10042 - nanoid@3.3.19:
10043 - resolution: {integrity: sha512-Y2tUNy4ouw6tq5oDSKeQYGOyhkUBhNOcGV/02KC+6kd9eDGqdZd++mjMiIDilrBYvjEnCYvVtsuHCuP+okSfug==}
10044 - engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
10045 - hasBin: true
10046 -
10030 nanoid@3.3.20:
10031 resolution: {integrity: sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==}
10032 engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
@@ -10328,9 +10311,6 @@ packages:
10311 resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==}
10312 engines: {node: '>=6'}
10313
10331 - package-manager-detector@1.6.0:
10332 - resolution: {integrity: sha512-61A5ThoTiDG/C8s8UMZwSorAGwMJ0ERVGj2OjoW5pAalsNOg15+iQiPzrLJ4jhZ1HJzmC2PIHT2oEiH3R5fzNA==}
10333 -
10314 package-manager-detector@1.8.0:
10315 resolution: {integrity: sha512-yQA4H19AmPEoMUeavPMDIe1higySl/gH/yaQrkT/s07Qp+7pp2hYz30N3z2l5BkjVkF9Ow6o0wjJamm2y7Sn0A==}
10316
@@ -11202,10 +11182,6 @@ packages:
11182 resolution: {integrity: sha512-LJhUYUvItdQ0LkJTmPeaEObWXAqFyfmP85x0tch/ez9cahmhlBBLbIqDFnvBnUJGagb0JbIQrkBs1wJ+yRYpEw==}
11183 engines: {node: '>= 10.0.0', npm: '>= 3.0.0'}
11184
11205 - source-map-js@1.2.1:
11206 - resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
11207 - engines: {node: '>=0.10.0'}
11208 -
11185 source-map-js@1.2.2:
11186 resolution: {integrity: sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==}
11187 engines: {node: '>=0.10.0'}
@@ -11237,6 +11213,9 @@ packages:
11213 sprintf-js@1.1.3:
11214 resolution: {integrity: sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==}
11215
11216 + sql.js@1.15.0:
11217 + resolution: {integrity: sha512-54VT5h9/VGlLaQan5pX/Zx8k6Vbykwl5hRUtl4h4+VYnaZCTraUs4P1i2WLz21O6oPVp6Gvg+d1OyPo01ZG5ig==}
11218 +
11219 stackframe@1.3.4:
11220 resolution: {integrity: sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw==}
11221
@@ -11410,6 +11389,9 @@ packages:
11389 through@2.3.8:
11390 resolution: {integrity: sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==}
11391
11392 + tiff@7.1.3:
11393 + resolution: {integrity: sha512-YEEq3fT++2pdta/9P/vGG4QRMdZQoe6W6JNaWnIi6NvAsbeNITwFCtmWwL/BZvOi+uo2I3ohyOkD3sZfme+c6g==}
11394 +
11395 timestring@6.0.0:
11396 resolution: {integrity: sha512-wMctrWD2HZZLuIlchlkE2dfXJh7J2KDI9Dwl+2abPYg0mswQHfOAyQW3jJg1pY5VfttSINZuKcXoB3FGypVklA==}
11397 engines: {node: '>=8'}
@@ -11431,10 +11413,6 @@ packages:
11413 resolution: {integrity: sha512-nTv2raKFMzGG6JJp0lpNDsRPdfFE6UHlu2rVEjXo8vkx1ZS3LW2CVXqIaLu8xZlu+6tbFs9V58Qc/Jmk/Ii7wA==}
11414 engines: {node: ^16.14.0 || >= 17.3.0}
11415
11434 - tinyexec@1.2.4:
11435 - resolution: {integrity: sha512-SHf/r48b7vOrjve9PxJo3MN5v5yuyjHvdUcrQffT3WXMUfnGmHDVbC4k3sHJaJTgZCwpUplIaAo5ANtMyp3YHg==}
11436 - engines: {node: '>=18'}
11437 -
11416 tinyexec@1.3.1:
11417 resolution: {integrity: sha512-GCvB3aoys96IuDFBMcTB46JOR6mdMtAToqwiW8JlWhsoh1mhHi/xn9ss/Dg7N555GiJyEt2qzoG/NHCwM6h1EA==}
11418 engines: {node: '>=18'}
@@ -12192,9 +12170,6 @@ packages:
12170 zod@3.25.76:
12171 resolution: {integrity: sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==}
12172
12195 - zod@4.4.3:
12196 - resolution: {integrity: sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==}
12197 -
12173 zod@4.5.4:
12174 resolution: {integrity: sha512-sC95tT5iHHH9gtpj6A81kh+NEaRAUFN+qlUPDUbRfOMvNf5QCBqsb3WgvnpVtK5Y+4UfA6KqufotuTvMGiTlsA==}
12175
@@ -12233,17 +12208,13 @@ snapshots:
12208 optionalDependencies:
12209 typescript: '@tsc-rs/typescript@0.8.0'
12210
12236 - '@ai-sdk/provider-utils@4.0.57(zod@4.4.3)':
12211 + '@ai-sdk/provider-utils@4.0.57(zod@4.6.5)':
12212 dependencies:
12213 '@ai-sdk/provider': 3.0.18
12214 '@standard-schema/spec': 1.1.0
12215 eventsource-parser: 3.1.0
12216 undici: 6.29.0
12242 - zod: 4.4.3
12243 -
12244 - '@ai-sdk/provider@3.0.15':
12245 - dependencies:
12246 - json-schema: 0.4.0
12217 + zod: 4.6.5
12218
12219 '@ai-sdk/provider@3.0.18':
12220 dependencies:
@@ -13145,11 +13116,6 @@ snapshots:
13116 transitivePeerDependencies:
13117 - supports-color
13118
13148 - '@babel/types@7.29.7':
13149 - dependencies:
13150 - '@babel/helper-string-parser': 7.29.7
13151 - '@babel/helper-validator-identifier': 7.29.7
13152 -
13119 '@babel/types@7.29.8':
13120 dependencies:
13121 '@babel/helper-string-parser': 7.29.7
@@ -14809,7 +14775,7 @@ snapshots:
14775 express: 5.2.1(supports-color@8.1.1)
14776 express-rate-limit: 8.5.2(express@5.2.1(supports-color@8.1.1))
14777 hono: 4.13.7
14812 - jose: 6.2.3
14778 + jose: 6.2.2
14779 json-schema-typed: 8.0.2
14780 pkce-challenge: 5.0.1
14781 raw-body: 3.0.2
@@ -14878,13 +14844,6 @@ snapshots:
14844 '@napi-rs/keyring-win32-ia32-msvc': 1.3.0
14845 '@napi-rs/keyring-win32-x64-msvc': 1.3.0
14846
14881 - '@napi-rs/wasm-runtime@1.1.6(@emnapi/core@1.11.2)(@emnapi/runtime@1.11.2)':
14882 - dependencies:
14883 - '@emnapi/core': 1.11.2
14884 - '@emnapi/runtime': 1.11.2
14885 - '@tybys/wasm-util': 0.10.3
14886 - optional: true
14887 -
14847 '@napi-rs/wasm-runtime@1.2.4(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)':
14848 dependencies:
14849 '@emnapi/core': 1.10.0
@@ -14899,6 +14858,13 @@ snapshots:
14858 '@tybys/wasm-util': 0.10.4
14859 optional: true
14860
14861 + '@napi-rs/wasm-runtime@1.2.4(@emnapi/core@1.11.2)(@emnapi/runtime@1.11.2)':
14862 + dependencies:
14863 + '@emnapi/core': 1.11.2
14864 + '@emnapi/runtime': 1.11.2
14865 + '@tybys/wasm-util': 0.10.4
14866 + optional: true
14867 +
14868 '@napi-rs/wasm-runtime@1.2.4(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3)':
14869 dependencies:
14870 '@emnapi/core': 1.11.3
@@ -14920,8 +14886,7 @@ snapshots:
14886
14887 '@noble/hashes@1.8.0': {}
14888
14923 - '@nodable/entities@2.1.1':
14924 - optional: true
14889 + '@nodable/entities@2.1.1': {}
14890
14891 '@nornagon/put@0.0.8': {}
14892
@@ -15258,7 +15223,7 @@ snapshots:
15223 dependencies:
15224 '@emnapi/core': 1.11.2
15225 '@emnapi/runtime': 1.11.2
15261 - '@napi-rs/wasm-runtime': 1.1.6(@emnapi/core@1.11.2)(@emnapi/runtime@1.11.2)
15226 + '@napi-rs/wasm-runtime': 1.2.4(@emnapi/core@1.11.2)(@emnapi/runtime@1.11.2)
15227 optional: true
15228
15229 '@oxc-resolver/binding-win32-arm64-msvc@11.24.2':
@@ -15456,8 +15421,6 @@ snapshots:
15421 '@oxlint/binding-win32-x64-msvc@1.89.0':
15422 optional: true
15423
15459 - '@oxlint/plugins@1.68.0': {}
15460 -
15424 '@oxlint/plugins@1.89.0': {}
15425
15426 '@peculiar/asn1-schema@2.8.0':
@@ -15546,17 +15509,17 @@ snapshots:
15509 commander: 14.0.3
15510 ignore: 7.0.5
15511 ora: 9.4.0
15549 - package-manager-detector: 1.6.0
15512 + package-manager-detector: 1.8.0
15513 picocolors: 1.1.1
15514 prompts: 2.4.2
15552 - tinyexec: 1.2.4
15515 + tinyexec: 1.3.1
15516
15517 '@react-native-ai/apple@0.12.0(patch_hash=2d09870c2848d185cb05b53ed823a46e12dba519324d8dd8e584e28731990f9d)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))':
15518 dependencies:
15556 - '@ai-sdk/provider': 3.0.15
15557 - '@ai-sdk/provider-utils': 4.0.57(zod@4.4.3)
15519 + '@ai-sdk/provider': 3.0.18
15520 + '@ai-sdk/provider-utils': 4.0.57(zod@4.6.5)
15521 react-native: 0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6)
15559 - zod: 4.4.3
15522 + zod: 4.6.5
15523
15524 '@react-native-async-storage/async-storage@3.1.1(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)':
15525 dependencies:
@@ -15755,7 +15718,7 @@ snapshots:
15718 '@react-navigation/core': 7.24.0(react@19.3.0)
15719 escape-string-regexp: 4.0.0
15720 fast-deep-equal: 3.1.3
15758 - nanoid: 3.3.19
15721 + nanoid: 3.3.20
15722 react: 19.3.0
15723 react-native: 0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6)
15724 standard-navigation: 0.0.8(react@19.3.0)
@@ -16165,14 +16128,14 @@ snapshots:
16128 '@babel/plugin-syntax-typescript': 7.29.7(@babel/core@7.29.7(supports-color@8.1.1))
16129 '@babel/template': 7.29.7
16130 '@babel/traverse': 7.29.7(supports-color@8.1.1)
16168 - '@babel/types': 7.29.7
16131 + '@babel/types': 7.29.8
16132 '@tanstack/router-core': 1.171.8
16133 '@tanstack/router-generator': 1.167.12(supports-color@8.1.1)
16134 '@tanstack/router-utils': 1.162.1(supports-color@8.1.1)
16135 '@tanstack/virtual-file-routes': 1.162.0
16136 chokidar: 5.0.0
16137 unplugin: 3.0.0
16175 - zod: 4.4.3
16138 + zod: 4.6.5
16139 optionalDependencies:
16140 '@tanstack/react-router': 1.170.10(react-dom@19.3.0(react@19.3.0))(react@19.3.0)
16141 vite: '@voidzero-dev/vite-plus-core@1.4.0(@tsc-rs/typescript@0.8.0)(@types/node@24.12.4)(@volar/typescript@2.4.28(@tsc-rs/typescript@0.8.0))(esbuild@0.28.2)(jiti@2.7.0)(terser@5.48.0)(unrun@0.2.39)(yaml@2.9.0)'
@@ -16424,11 +16387,6 @@ snapshots:
16387
16388 '@tweenjs/tween.js@23.1.3': {}
16389
16427 - '@tybys/wasm-util@0.10.3':
16428 - dependencies:
16429 - tslib: 2.8.1
16430 - optional: true
16431 -
16390 '@tybys/wasm-util@0.10.4':
16391 dependencies:
16392 tslib: 2.8.1
@@ -16581,6 +16539,11 @@ snapshots:
16539 '@types/http-errors': 2.0.5
16540 '@types/node': 24.12.4
16541
16542 + '@types/sql.js@1.4.11':
16543 + dependencies:
16544 + '@types/emscripten': 1.41.5
16545 + '@types/node': 24.12.4
16546 +
16547 '@types/stats.js@0.17.4': {}
16548
16549 '@types/three@0.180.0':
@@ -17100,7 +17063,7 @@ snapshots:
17063 json-schema-traverse: 1.0.0
17064 require-from-string: 2.0.2
17065
17103 - alchemy@2.0.0-beta.80(patch_hash=bea1b6c0c0b23157fd5f439a1d7feff430f28ac1621ba135d8a13eeec60ccacd)(93312816496722c8e540690c17876476):
17066 + alchemy@2.0.0-beta.80(patch_hash=bea1b6c0c0b23157fd5f439a1d7feff430f28ac1621ba135d8a13eeec60ccacd)(e50ec971fc482761b0a5b8ee3921094f):
17067 dependencies:
17068 '@alchemy.run/cloudflare-runtime': 2.0.0-beta.80(@distilled.cloud/cloudflare@1.0.0-rc.13(effect@4.0.5))(@effect/platform-node@4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6))(@tsc-rs/typescript@0.8.0)(@types/node@24.12.4)(@voidzero-dev/vite-plus-core@1.4.0(@tsc-rs/typescript@0.8.0)(@types/node@24.12.4)(@volar/typescript@2.4.28(@tsc-rs/typescript@0.8.0))(esbuild@0.28.2)(jiti@2.7.0)(terser@5.48.0)(unrun@0.2.39)(yaml@2.9.0))(effect@4.0.5)(rolldown@1.2.5)
17069 '@alchemy.run/floci': 2.0.0-beta.80(effect@4.0.5)
@@ -17143,65 +17106,7 @@ snapshots:
17106 '@effect/sql-pg': 4.0.5(effect@4.0.5)
17107 '@effect/vitest': 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@astrojs/compiler-rs@0.5.1)(@tsc-rs/typescript@0.8.0)(@types/node@24.12.4)(@vitest/browser-playwright@5.0.5)(@vitest/ui@5.0.5)(@volar/typescript@2.4.28(@tsc-rs/typescript@0.8.0))(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(playwright@1.60.0)(terser@5.48.0)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
17108 drizzle-kit: 1.0.0-rc.5-ab785fc
17146 - drizzle-orm: 1.0.0-rc.5-ab785fc(@cloudflare/workers-types@4.20260604.1)(@effect/sql-d1@4.0.0(effect@4.0.5))(@effect/sql-pg@4.0.5(effect@4.0.5))(@effect/sql-sqlite-bun@4.0.0-rc.112(effect@4.0.5))(@effect/sql-sqlite-do@4.0.5(effect@4.0.5))(@electric-sql/pglite@0.3.15)(@libsql/client@0.17.3(bufferutil@4.1.0)(utf-8-validate@6.0.6))(bun-types@1.3.14)(effect@4.0.5)(expo-sqlite@58.0.13(expo@58.0.14)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0))(pg@8.23.0)(zod@4.6.5)
17147 - mongodb: 6.21.0(@aws-sdk/credential-providers@3.1062.0)(socks@2.8.9)
17148 - pg: 8.23.0
17149 - vite: '@voidzero-dev/vite-plus-core@1.4.0(@tsc-rs/typescript@0.8.0)(@types/node@24.12.4)(@volar/typescript@2.4.28(@tsc-rs/typescript@0.8.0))(esbuild@0.28.2)(jiti@2.7.0)(terser@5.48.0)(unrun@0.2.39)(yaml@2.9.0)'
17150 - ws: 8.22.0(bufferutil@4.1.0)(utf-8-validate@6.0.6)
17151 - transitivePeerDependencies:
17152 - - '@types/node'
17153 - - '@types/react'
17154 - - bufferutil
17155 - - hono
17156 - - proxy-agent
17157 - - react-devtools-core
17158 - - typescript
17159 - - utf-8-validate
17160 -
17161 - alchemy@2.0.0-beta.80(patch_hash=bea1b6c0c0b23157fd5f439a1d7feff430f28ac1621ba135d8a13eeec60ccacd)(ed9f72c53f648b6275121476d8becac3):
17162 - dependencies:
17163 - '@alchemy.run/cloudflare-runtime': 2.0.0-beta.80(@distilled.cloud/cloudflare@1.0.0-rc.13(effect@4.0.5))(@effect/platform-node@4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6))(@tsc-rs/typescript@0.8.0)(@types/node@24.12.4)(@voidzero-dev/vite-plus-core@1.4.0(@tsc-rs/typescript@0.8.0)(@types/node@24.12.4)(@volar/typescript@2.4.28(@tsc-rs/typescript@0.8.0))(esbuild@0.28.2)(jiti@2.7.0)(terser@5.48.0)(unrun@0.2.39)(yaml@2.9.0))(effect@4.0.5)(rolldown@1.2.5)
17164 - '@alchemy.run/floci': 2.0.0-beta.80(effect@4.0.5)
17165 - '@alchemy.run/node-utils': 2.0.0-beta.80
17166 - '@alchemy.run/sigil': 0.1.0-alpha.1(@types/react@19.3.0)(react-devtools-core@6.1.5(bufferutil@4.1.0)(utf-8-validate@6.0.6))
17167 - '@distilled.cloud/acme': 1.0.0-rc.13(effect@4.0.5)
17168 - '@distilled.cloud/aws': 1.0.0-rc.13(effect@4.0.5)
17169 - '@distilled.cloud/axiom': 1.0.0-rc.13(effect@4.0.5)
17170 - '@distilled.cloud/cloudflare': 1.0.0-rc.13(effect@4.0.5)
17171 - '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.5)
17172 - '@distilled.cloud/doppler': 1.0.0-rc.13(effect@4.0.5)
17173 - '@distilled.cloud/fly-io': 1.0.0-rc.13(effect@4.0.5)
17174 - '@distilled.cloud/gcp': 1.0.0-rc.13(effect@4.0.5)
17175 - '@distilled.cloud/hetzner': 1.0.0-rc.13(effect@4.0.5)
17176 - '@distilled.cloud/infisical': 1.0.0-rc.13(effect@4.0.5)
17177 - '@distilled.cloud/neon': 1.0.0-rc.13(effect@4.0.5)
17178 - '@distilled.cloud/planetscale': 1.0.0-rc.13(effect@4.0.5)
17179 - '@distilled.cloud/prisma': 1.0.0-rc.13(effect@4.0.5)
17180 - '@distilled.cloud/railway': 1.0.0-rc.13(effect@4.0.5)
17181 - '@distilled.cloud/stripe': 1.0.0-rc.13(effect@4.0.5)
17182 - '@distilled.cloud/zerossl': 1.0.0-rc.13(effect@4.0.5)
17183 - '@effect/sql-d1': 4.0.0(effect@4.0.5)
17184 - '@effect/sql-sqlite-do': 4.0.5(effect@4.0.5)
17185 - '@libsql/client': 0.17.3(bufferutil@4.1.0)(utf-8-validate@6.0.6)
17186 - '@neon/functions': 0.11.0(hono@4.13.7)
17187 - '@octokit/rest': 22.0.1
17188 - '@octokit/webhooks': 14.2.0
17189 - '@types/aws-lambda': 8.10.161
17190 - capnweb: 0.12.0
17191 - effect: 4.0.5
17192 - fflate: 0.8.3
17193 - libsodium-wrappers: 0.8.4
17194 - pathe: 2.0.3
17195 - picomatch: 4.0.7
17196 - rolldown: 1.2.5
17197 - tinyglobby: 0.2.17
17198 - yaml: 2.9.0
17199 - optionalDependencies:
17200 - '@effect/platform-node': 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
17201 - '@effect/sql-pg': 4.0.5(effect@4.0.5)
17202 - '@effect/vitest': 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@astrojs/compiler-rs@0.5.1)(@tsc-rs/typescript@0.8.0)(@types/node@24.12.4)(@vitest/browser-playwright@5.0.5)(@vitest/ui@5.0.5)(@volar/typescript@2.4.28(@tsc-rs/typescript@0.8.0))(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(playwright@1.60.0)(terser@5.48.0)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
17203 - drizzle-kit: 1.0.0-rc.5-ab785fc
17204 - drizzle-orm: 1.0.0-rc.5-ab785fc(@cloudflare/workers-types@4.20260604.1)(@effect/sql-d1@4.0.0(effect@4.0.5))(@effect/sql-pg@4.0.5(effect@4.0.5))(@effect/sql-sqlite-bun@4.0.0-rc.112(effect@4.0.5))(@effect/sql-sqlite-do@4.0.5(effect@4.0.5))(@electric-sql/pglite@0.3.15)(@libsql/client@0.17.3(bufferutil@4.1.0)(utf-8-validate@6.0.6))(bun-types@1.3.14)(effect@4.0.5)(expo-sqlite@58.0.13(expo@58.0.14)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0))(pg@8.23.0)(zod@4.4.3)
17109 + drizzle-orm: 1.0.0-rc.5-ab785fc(@cloudflare/workers-types@4.20260604.1)(@effect/sql-d1@4.0.0(effect@4.0.5))(@effect/sql-pg@4.0.5(effect@4.0.5))(@effect/sql-sqlite-bun@4.0.0-rc.112(effect@4.0.5))(@effect/sql-sqlite-do@4.0.5(effect@4.0.5))(@electric-sql/pglite@0.3.15)(@libsql/client@0.17.3(bufferutil@4.1.0)(utf-8-validate@6.0.6))(@types/sql.js@1.4.11)(bun-types@1.3.14)(effect@4.0.5)(expo-sqlite@58.0.13(expo@58.0.14)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0))(pg@8.23.0)(sql.js@1.15.0)(zod@4.6.5)
17110 mongodb: 6.21.0(@aws-sdk/credential-providers@3.1062.0)(socks@2.8.9)
17111 pg: 8.23.0
17112 vite: '@voidzero-dev/vite-plus-core@1.4.0(@tsc-rs/typescript@0.8.0)(@types/node@24.12.4)(@volar/typescript@2.4.28(@tsc-rs/typescript@0.8.0))(esbuild@0.28.2)(jiti@2.7.0)(terser@5.48.0)(unrun@0.2.39)(yaml@2.9.0)'
@@ -17253,8 +17158,7 @@ snapshots:
17158 normalize-path: 3.0.0
17159 picomatch: 2.3.2
17160
17256 - anynum@1.0.1:
17257 - optional: true
17161 + anynum@1.0.1: {}
17162
17163 app-builder-lib@26.16.1(patch_hash=a28c2dfcfc2b90d6c6247e199e6537391db9ecd941854c650910d607442512d3)(dmg-builder@26.16.1)(electron-builder-squirrel-windows@26.16.1)(supports-color@8.1.1):
17164 dependencies:
@@ -17356,7 +17260,7 @@ snapshots:
17260 http-cache-semantics: 4.2.0
17261 js-yaml: 4.3.2
17262 jsonc-parser: 3.3.1
17359 - magic-string: 1.4.1
17263 + magic-string: 1.4.3
17264 magicast: 0.5.5
17265 mrmime: 2.0.1
17266 neotraverse: 1.0.1
@@ -18167,22 +18071,7 @@ snapshots:
18071 get-tsconfig: 4.14.3
18072 jiti: 2.7.0
18073
18170 - drizzle-orm@1.0.0-rc.5-ab785fc(@cloudflare/workers-types@4.20260604.1)(@effect/sql-d1@4.0.0(effect@4.0.5))(@effect/sql-pg@4.0.5(effect@4.0.5))(@effect/sql-sqlite-bun@4.0.0-rc.112(effect@4.0.5))(@effect/sql-sqlite-do@4.0.5(effect@4.0.5))(@electric-sql/pglite@0.3.15)(@libsql/client@0.17.3(bufferutil@4.1.0)(utf-8-validate@6.0.6))(bun-types@1.3.14)(effect@4.0.5)(expo-sqlite@58.0.13(expo@58.0.14)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0))(pg@8.23.0)(zod@4.4.3):
18171 - optionalDependencies:
18172 - '@cloudflare/workers-types': 4.20260604.1
18173 - '@effect/sql-d1': 4.0.0(effect@4.0.5)
18174 - '@effect/sql-pg': 4.0.5(effect@4.0.5)
18175 - '@effect/sql-sqlite-bun': 4.0.0-rc.112(effect@4.0.5)
18176 - '@effect/sql-sqlite-do': 4.0.5(effect@4.0.5)
18177 - '@electric-sql/pglite': 0.3.15
18178 - '@libsql/client': 0.17.3(bufferutil@4.1.0)(utf-8-validate@6.0.6)
18179 - bun-types: 1.3.14
18180 - effect: 4.0.5
18181 - expo-sqlite: 58.0.13(expo@58.0.14)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
18182 - pg: 8.23.0
18183 - zod: 4.4.3
18184 -
18185 - drizzle-orm@1.0.0-rc.5-ab785fc(@cloudflare/workers-types@4.20260604.1)(@effect/sql-d1@4.0.0(effect@4.0.5))(@effect/sql-pg@4.0.5(effect@4.0.5))(@effect/sql-sqlite-bun@4.0.0-rc.112(effect@4.0.5))(@effect/sql-sqlite-do@4.0.5(effect@4.0.5))(@electric-sql/pglite@0.3.15)(@libsql/client@0.17.3(bufferutil@4.1.0)(utf-8-validate@6.0.6))(bun-types@1.3.14)(effect@4.0.5)(expo-sqlite@58.0.13(expo@58.0.14)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0))(pg@8.23.0)(zod@4.6.5):
18074 + drizzle-orm@1.0.0-rc.5-ab785fc(@cloudflare/workers-types@4.20260604.1)(@effect/sql-d1@4.0.0(effect@4.0.5))(@effect/sql-pg@4.0.5(effect@4.0.5))(@effect/sql-sqlite-bun@4.0.0-rc.112(effect@4.0.5))(@effect/sql-sqlite-do@4.0.5(effect@4.0.5))(@electric-sql/pglite@0.3.15)(@libsql/client@0.17.3(bufferutil@4.1.0)(utf-8-validate@6.0.6))(@types/sql.js@1.4.11)(bun-types@1.3.14)(effect@4.0.5)(expo-sqlite@58.0.13(expo@58.0.14)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0))(pg@8.23.0)(sql.js@1.15.0)(zod@4.6.5):
18075 optionalDependencies:
18076 '@cloudflare/workers-types': 4.20260604.1
18077 '@effect/sql-d1': 4.0.0(effect@4.0.5)
@@ -18191,12 +18080,13 @@ snapshots:
18080 '@effect/sql-sqlite-do': 4.0.5(effect@4.0.5)
18081 '@electric-sql/pglite': 0.3.15
18082 '@libsql/client': 0.17.3(bufferutil@4.1.0)(utf-8-validate@6.0.6)
18083 + '@types/sql.js': 1.4.11
18084 bun-types: 1.3.14
18085 effect: 4.0.5
18086 expo-sqlite: 58.0.13(expo@58.0.14)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
18087 pg: 8.23.0
18088 + sql.js: 1.15.0
18089 zod: 4.6.5
18199 - optional: true
18090
18091 dset@3.1.4: {}
18092
@@ -18938,7 +18828,6 @@ snapshots:
18828 dependencies:
18829 path-expression-matcher: 1.6.2
18830 xml-naming: 0.1.0
18941 - optional: true
18831
18832 fast-xml-parser@5.7.3:
18833 dependencies:
@@ -18946,7 +18835,6 @@ snapshots:
18835 fast-xml-builder: 1.2.0
18836 path-expression-matcher: 1.6.2
18837 strnum: 2.4.2
18949 - optional: true
18838
18839 fastest-levenshtein@1.0.16: {}
18840
@@ -19176,7 +19064,7 @@ snapshots:
19064 es6-error: 4.1.1
19065 matcher: 3.0.0
19066 roarr: 2.15.4
19179 - semver: 7.8.5
19067 + semver: 7.7.4
19068 serialize-error: 7.0.1
19069 optional: true
19070
@@ -19430,6 +19318,8 @@ snapshots:
19318 dependencies:
19319 loose-envify: 1.4.0
19320
19321 + iobuffer@6.0.1: {}
19322 +
19323 ioredis@5.11.0(supports-color@8.1.1):
19324 dependencies:
19325 '@ioredis/commands': 1.10.0
@@ -19543,8 +19433,6 @@ snapshots:
19433
19434 jose@6.2.2: {}
19435
19546 - jose@6.2.3: {}
19547 -
19436 js-base64@3.7.8: {}
19437
19438 js-cookie@3.0.8: {}
@@ -19660,7 +19548,7 @@ snapshots:
19548 tinyglobby: 0.2.17
19549 unbash: 4.0.11
19550 yaml: 2.9.0
19663 - zod: 4.4.3
19551 + zod: 4.6.5
19552
19553 lan-network@0.2.1: {}
19554
@@ -19804,10 +19692,6 @@ snapshots:
19692 dependencies:
19693 '@jridgewell/sourcemap-codec': 1.6.0
19694
19807 - magic-string@1.4.1:
19808 - dependencies:
19809 - '@jridgewell/sourcemap-codec': 1.6.0
19810 -
19695 magic-string@1.4.3:
19696 dependencies:
19697 '@jridgewell/sourcemap-codec': 1.6.0
@@ -19816,7 +19700,7 @@ snapshots:
19700 dependencies:
19701 '@babel/parser': 7.29.8
19702 '@babel/types': 7.29.8
19819 - source-map-js: 1.2.1
19703 + source-map-js: 1.2.2
19704
19705 makeerror@1.0.12:
19706 dependencies:
@@ -20512,8 +20396,6 @@ snapshots:
20396
20397 multitars@1.0.2: {}
20398
20515 - nanoid@3.3.19: {}
20516 -
20399 nanoid@3.3.20: {}
20400
20401 negotiator@0.6.3: {}
@@ -20530,7 +20412,7 @@ snapshots:
20412
20413 node-abi@4.33.0:
20414 dependencies:
20533 - semver: 7.8.5
20415 + semver: 7.7.4
20416
20417 node-addon-api@7.1.1: {}
20418
@@ -20539,7 +20421,7 @@ snapshots:
20421
20422 node-api-version@0.2.1:
20423 dependencies:
20542 - semver: 7.8.5
20424 + semver: 7.7.4
20425
20426 node-fetch-h2@2.3.0:
20427 dependencies:
@@ -20565,7 +20447,7 @@ snapshots:
20447 graceful-fs: 4.2.11
20448 nopt: 9.0.0
20449 proc-log: 6.1.0
20568 - semver: 7.8.5
20450 + semver: 7.7.4
20451 tar: 7.5.22
20452 tinyglobby: 0.2.17
20453 undici: 6.29.0
@@ -20919,8 +20801,6 @@ snapshots:
20801
20802 p-try@2.2.0: {}
20803
20922 - package-manager-detector@1.6.0: {}
20923 -
20804 package-manager-detector@1.8.0: {}
20805
20806 pako@1.0.11: {}
@@ -20953,8 +20833,7 @@ snapshots:
20833
20834 path-exists@3.0.0: {}
20835
20956 - path-expression-matcher@1.6.2:
20957 - optional: true
20836 + path-expression-matcher@1.6.2: {}
20837
20838 path-is-absolute@1.0.1: {}
20839
@@ -22019,8 +21898,6 @@ snapshots:
21898 smart-buffer: 4.2.0
21899 optional: true
21900
22022 - source-map-js@1.2.1: {}
22023 -
21901 source-map-js@1.2.2: {}
21902
21903 source-map-support@0.5.21:
@@ -22049,6 +21926,8 @@ snapshots:
21926 sprintf-js@1.1.3:
21927 optional: true
21928
21929 + sql.js@1.15.0: {}
21930 +
21931 stackframe@1.3.4: {}
21932
21933 stacktrace-parser@0.1.11:
@@ -22132,7 +22011,6 @@ snapshots:
22011 strnum@2.4.2:
22012 dependencies:
22013 anynum: 1.0.1
22135 - optional: true
22014
22015 structured-headers@0.4.1: {}
22016
@@ -22239,6 +22117,11 @@ snapshots:
22117
22118 through@2.3.8: {}
22119
22120 + tiff@7.1.3:
22121 + dependencies:
22122 + fflate: 0.8.3
22123 + iobuffer: 6.0.1
22124 +
22125 timestring@6.0.0: {}
22126
22127 tiny-async-pool@1.3.0:
@@ -22253,8 +22136,6 @@ snapshots:
22136
22137 tinyclip@1.0.3: {}
22138
22256 - tinyexec@1.2.4: {}
22257 -
22139 tinyexec@1.3.1: {}
22140
22141 tinyglobby@0.2.17:
@@ -22892,8 +22773,7 @@ snapshots:
22773
22774 xml-name-validator@5.0.0: {}
22775
22895 - xml-naming@0.1.0:
22896 - optional: true
22776 + xml-naming@0.1.0: {}
22777
22778 xml2js@0.4.23:
22779 dependencies:
@@ -23001,8 +22881,6 @@ snapshots:
22881
22882 zod@3.25.76: {}
22883
23004 - zod@4.4.3: {}
23005 -
22884 zod@4.5.4: {}
22885
22886 zod@4.6.5: {}
third-party-licenses.config.json
+15
@@ -841,6 +841,21 @@
841 "licenseId": "MIT",
842 "copyrights": ["Copyright (c) 2019-present Fabio Spampinato, Andrew Maney"]
843 }
844 + },
845 + {
846 + "name": "sql.js",
847 + "license": "MIT",
848 + "sourceUrl": "https://github.com/sql-js/sql.js"
849 + },
850 + {
851 + "name": "tiff",
852 + "license": "MIT",
853 + "sourceUrl": "https://github.com/image-js/tiff"
854 + },
855 + {
856 + "name": "iobuffer",
857 + "license": "MIT",
858 + "sourceUrl": "https://github.com/image-js/iobuffer"
859 }
860 ]
861 }