Skip to content

Commit bcf8bde

Browse files
fix: resolve all TypeScript errors
- Add undefined checks for tool content - Remove duplicate property definitions in filetype-categories - Fix type mismatches in video converter - Handle SharedArrayBuffer conversion properly
1 parent fbf109c commit bcf8bde

3 files changed

Lines changed: 27 additions & 12 deletions

File tree

app/tools/avif-to-jpg/page.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import { toolContent } from '@/lib/tool-content';
66
export default function Page() {
77
const content = toolContent["avif-to-jpg"];
88

9+
if (!content) {
10+
return <div>Tool content not found</div>;
11+
}
12+
913
return (
1014
<ToolPageTemplate
1115
tool={content.tool}

lib/convert/video.ts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,12 @@ export async function convertVideo(
4343

4444
// Set up progress callback
4545
if (options.onProgress) {
46-
ff.on('progress', (event) => {
47-
options.onProgress?.(event);
46+
ff.on('progress', (event: any) => {
47+
// Convert FFmpeg progress event to expected format
48+
options.onProgress?.({
49+
ratio: event.progress || 0,
50+
time: event.time || 0
51+
});
4852
});
4953
}
5054

@@ -128,6 +132,11 @@ export async function convertVideo(
128132
// Read output file
129133
const data = await ff.readFile(outputName);
130134

135+
// Ensure we have a Uint8Array
136+
if (!(data instanceof Uint8Array)) {
137+
throw new Error('Unexpected output format from FFmpeg');
138+
}
139+
131140
console.log(`Output file size: ${data.length} bytes`);
132141

133142
// Cleanup
@@ -141,8 +150,18 @@ export async function convertVideo(
141150
console.warn('Cleanup error:', cleanupErr);
142151
}
143152

144-
// Return the Uint8Array buffer
145-
return data instanceof Uint8Array ? data.buffer : data;
153+
// Return the ArrayBuffer (handle both ArrayBuffer and SharedArrayBuffer)
154+
const buffer = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
155+
156+
// Ensure we return an ArrayBuffer, not SharedArrayBuffer
157+
if (buffer instanceof SharedArrayBuffer) {
158+
const ab = new ArrayBuffer(buffer.byteLength);
159+
const view = new Uint8Array(ab);
160+
view.set(new Uint8Array(buffer));
161+
return ab;
162+
}
163+
164+
return buffer;
146165
}
147166

148167
export async function cleanupFFmpeg() {

lib/filetype-categories.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ export const extensionToCategory: Record<string, FileCategory> = {
309309
'stl': 'cad',
310310
'obj': 'cad',
311311
'fbx': 'cad',
312-
'3ds': 'cad',
313312
'dae': 'cad',
314313
'blend': 'cad',
315314
'max': 'cad',
@@ -332,13 +331,11 @@ export const extensionToCategory: Record<string, FileCategory> = {
332331
'topojson': 'gis',
333332
'osm': 'gis',
334333
'gml': 'gis',
335-
'gdb': 'gis',
336334
'mxd': 'gis',
337335
'qgs': 'gis',
338336
'qgz': 'gis',
339337
'tab': 'gis',
340338
'shx': 'gis',
341-
'dbf': 'gis',
342339
'prj': 'gis',
343340
'sbn': 'gis',
344341
'sbx': 'gis',
@@ -350,7 +347,6 @@ export const extensionToCategory: Record<string, FileCategory> = {
350347
'dylib': 'plugin',
351348
'vst': 'plugin',
352349
'vst3': 'plugin',
353-
'au': 'plugin',
354350
'aax': 'plugin',
355351
'component': 'plugin',
356352
'plugin': 'plugin',
@@ -454,8 +450,6 @@ export const extensionToCategory: Record<string, FileCategory> = {
454450
'toast': 'disk',
455451
'sparseimage': 'disk',
456452
'sparsebundle': 'disk',
457-
'dmg': 'disk',
458-
'cdr': 'disk',
459453
'wim': 'disk',
460454
'swm': 'disk',
461455
'esd': 'disk',
@@ -485,12 +479,10 @@ export const extensionToCategory: Record<string, FileCategory> = {
485479
// Data Files
486480
'dat': 'data',
487481
'data': 'data',
488-
'sav': 'data',
489482
'save': 'data',
490483
'rdata': 'data',
491484
'mat': 'data',
492485
'sas7bdat': 'data',
493-
'sav': 'data',
494486
'dta': 'data',
495487
'por': 'data',
496488
'sas': 'data',

0 commit comments

Comments
 (0)