Skip to content

Commit 5d12915

Browse files
Potential fix for pull request finding 'Unused variable, import, function or class'
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
1 parent 5d79e3c commit 5d12915

1 file changed

Lines changed: 0 additions & 48 deletions

File tree

‎userscript/source/ocr-client.ts‎

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -274,54 +274,6 @@ async function LoadImageElement(BrowserWindow: typeof window, SourceUrl: string)
274274
return ImageElement
275275
}
276276

277-
async function RasterizeSvgDataUrlToPngDataUrl(
278-
BrowserWindow: typeof window,
279-
HostElement: HTMLElement,
280-
SourceUrl: string,
281-
): Promise<string> {
282-
const { Width, Height } = GetSvgRasterSize(BrowserWindow, HostElement)
283-
const CacheKey = `${Width}x${Height}__${SourceUrl}`
284-
285-
const Cached = RasterizedSvgCache.get(CacheKey)
286-
if (Cached) return Cached
287-
288-
const Pending = (async () => {
289-
const SvgMarkup = DecodeSvgDataUrl(BrowserWindow, SourceUrl)
290-
const PreparedSvgMarkup = PrepareSvgMarkupForRasterize(BrowserWindow, SvgMarkup, Width, Height)
291-
292-
const SvgBlobUrl = BrowserWindow.URL.createObjectURL(
293-
new BrowserWindow.Blob([PreparedSvgMarkup], { type: 'image/svg+xml' })
294-
)
295-
296-
try {
297-
const ImageElement = await LoadImageElement(BrowserWindow, SvgBlobUrl)
298-
299-
const Canvas = BrowserWindow.document.createElement('canvas')
300-
Canvas.width = Width
301-
Canvas.height = Height
302-
303-
const Context2D = Canvas.getContext('2d', { willReadFrequently: true })
304-
if (!Context2D) throw new Error('2D context unavailable')
305-
306-
Context2D.clearRect(0, 0, Width, Height)
307-
Context2D.drawImage(ImageElement, 0, 0, Width, Height)
308-
309-
return Canvas.toDataURL('image/png')
310-
} finally {
311-
BrowserWindow.URL.revokeObjectURL(SvgBlobUrl)
312-
}
313-
})()
314-
315-
RasterizedSvgCache.set(CacheKey, Pending)
316-
317-
try {
318-
return await Pending
319-
} catch (ErrorValue) {
320-
RasterizedSvgCache.delete(CacheKey)
321-
throw ErrorValue
322-
}
323-
}
324-
325277
function IsSvgMimeType(MimeType: string | null): boolean {
326278
return typeof MimeType === 'string' && /^image\/svg\+xml(?:\s*;|$)/i.test(MimeType)
327279
}

0 commit comments

Comments
 (0)