Skip to content

Commit 77997c6

Browse files
committed
fix lints
1 parent fc09734 commit 77997c6

2 files changed

Lines changed: 21 additions & 10 deletions

File tree

src/plugins/heic-decoder.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function isHEICFile(file: File): boolean {
2222

2323
// Check file extension as fallback
2424
const fileName = file.name.toLowerCase()
25-
return heicExtensions.some(ext => fileName.endsWith(ext))
25+
return heicExtensions.some((ext) => fileName.endsWith(ext))
2626
}
2727

2828
/**
@@ -45,14 +45,18 @@ export async function convertHEIC(
4545
const { toType = 'image/jpeg', quality = 0.92 } = options
4646

4747
// Dynamic import to make heic2any optional
48-
let heic2any: any
48+
type Heic2AnyFunction = (options: {
49+
blob: Blob
50+
toType: string
51+
quality: number
52+
}) => Promise<Blob | Blob[]>
53+
54+
let heic2any: Heic2AnyFunction
4955
try {
50-
heic2any = await import('heic2any')
51-
heic2any = heic2any.default || heic2any
56+
const module = await import('heic2any')
57+
heic2any = (module.default || module) as Heic2AnyFunction
5258
} catch (error) {
53-
throw new Error(
54-
'heic2any is not installed. To enable HEIC support, run: npm install heic2any'
55-
)
59+
throw new Error('heic2any is not installed. To enable HEIC support, run: npm install heic2any')
5660
}
5761

5862
try {
@@ -63,7 +67,14 @@ export async function convertHEIC(
6367
})
6468

6569
// heic2any can return Blob or Blob[]
66-
return Array.isArray(result) ? result[0] : result
70+
if (Array.isArray(result)) {
71+
const firstBlob = result[0]
72+
if (!firstBlob) {
73+
throw new Error('heic2any returned empty array')
74+
}
75+
return firstBlob
76+
}
77+
return result
6778
} catch (error) {
6879
throw new Error(
6980
`Failed to convert HEIC image: ${error instanceof Error ? error.message : 'Unknown error'}`

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@
3535
/* Completeness */
3636
"skipLibCheck": true
3737
},
38-
"include": ["src/**/*", "demo/src/**/*"],
39-
"exclude": ["node_modules", "dist", "tests"]
38+
"include": ["src/**/*"],
39+
"exclude": ["node_modules", "dist", "tests", "demo"]
4040
}

0 commit comments

Comments
 (0)