From caa94f0ba60fdfef78e30de44acbf815c30b3f3d Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 3 Jan 2026 22:53:44 +0100 Subject: [PATCH] fix(types): align file buffers for convex deploy --- src/lib/uploadFiles.test.ts | 6 +++--- src/lib/uploadFiles.ts | 6 +++--- tsconfig.json | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib/uploadFiles.test.ts b/src/lib/uploadFiles.test.ts index d562b882..9fc2d0ba 100644 --- a/src/lib/uploadFiles.test.ts +++ b/src/lib/uploadFiles.test.ts @@ -66,7 +66,7 @@ describe('expandFiles', () => { 'SKILL.md': strToU8('hello'), 'docs/readme.txt': strToU8('doc'), }) - const zipFile = new File([zip], 'pack.zip', { type: 'application/zip' }) + const zipFile = new File([zip.buffer], 'pack.zip', { type: 'application/zip' }) const result = await expandFiles([zipFile]) expect(result.map((file) => file.name)).toEqual(['SKILL.md', 'docs/readme.txt']) }) @@ -77,14 +77,14 @@ describe('expandFiles', () => { { name: 'notes.txt', content: 'yo' }, ]) const tgz = gzipSync(tar) - const tgzFile = new File([tgz], 'bundle.tgz', { type: 'application/gzip' }) + const tgzFile = new File([tgz.buffer], 'bundle.tgz', { type: 'application/gzip' }) const result = await expandFiles([tgzFile]) expect(result.map((file) => file.name)).toEqual(['SKILL.md', 'notes.txt']) }) it('expands .gz single files', async () => { const gz = gzipSync(strToU8('content')) - const gzFile = new File([gz], 'skill.md.gz', { type: 'application/gzip' }) + const gzFile = new File([gz.buffer], 'skill.md.gz', { type: 'application/gzip' }) const result = await expandFiles([gzFile]) expect(result.map((file) => file.name)).toEqual(['skill.md']) }) diff --git a/src/lib/uploadFiles.ts b/src/lib/uploadFiles.ts index 2d17e521..cde526b4 100644 --- a/src/lib/uploadFiles.ts +++ b/src/lib/uploadFiles.ts @@ -26,7 +26,7 @@ export async function expandFiles(selected: File[]) { for (const [path, data] of Object.entries(entries)) { if (!path || path.endsWith('/')) continue expanded.push( - new File([data], normalizePath(path), { + new File([data.buffer], normalizePath(path), { type: guessContentType(path), }), ) @@ -37,7 +37,7 @@ export async function expandFiles(selected: File[]) { const unpacked = gunzipSync(new Uint8Array(await readArrayBuffer(file))) for (const entry of untar(unpacked)) { expanded.push( - new File([entry.data], normalizePath(entry.path), { + new File([entry.data.buffer], normalizePath(entry.path), { type: guessContentType(entry.path), }), ) @@ -47,7 +47,7 @@ export async function expandFiles(selected: File[]) { if (lower.endsWith('.gz')) { const unpacked = gunzipSync(new Uint8Array(await readArrayBuffer(file))) const name = file.name.replace(/\.gz$/i, '') - expanded.push(new File([unpacked], name, { type: guessContentType(name) })) + expanded.push(new File([unpacked.buffer], name, { type: guessContentType(name) })) continue } expanded.push(file) diff --git a/tsconfig.json b/tsconfig.json index 79684923..5c4b5f52 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,7 @@ "jsx": "react-jsx", "module": "ESNext", "lib": ["ES2022", "DOM", "DOM.Iterable"], - "types": ["vite/client"], + "types": ["vite/client", "vitest/globals"], /* Bundler mode */ "moduleResolution": "bundler",