Skip to content

Commit

Permalink
remove OffscreenCanvas @ts-ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
rwv committed Nov 17, 2023
1 parent 999e7f1 commit 839bbf5
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 9 deletions.
2 changes: 0 additions & 2 deletions src/utils/scan-renderer/canvas-scan/create-noise-blob.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { getNoiseSVG } from './noise-svg'

export async function createNoiseBlob(noise: number, height: number, width: number): Promise<Blob> {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const canvas = new OffscreenCanvas(width, height)
const ctx = canvas.getContext('2d')
if (!ctx) {
Expand Down
2 changes: 0 additions & 2 deletions src/utils/scan-renderer/canvas-scan/feature-detect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ export function featureDetect(): boolean {
}

// check OffscreenCanvas.prototype
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const offscreenCanvasProto = OffscreenCanvasRenderingContext2D.prototype
for (const method of canvasMethods) {
if (!(method in offscreenCanvasProto)) {
Expand Down
5 changes: 2 additions & 3 deletions src/utils/scan-renderer/canvas-scan/scan-canvas.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ScanConfig } from './types'

export async function scanCanvas(
canvas_: HTMLCanvasElement | OffscreenCanvas,
canvas: HTMLCanvasElement | OffscreenCanvas,
page: Blob,
config: ScanConfig,
noise: Blob,
Expand All @@ -12,8 +12,7 @@ export async function scanCanvas(
}

// Note: Hack to get around TS error
const canvas = canvas_ as HTMLCanvasElement
const ctx = canvas.getContext('2d') as CanvasRenderingContext2D
const ctx = canvas.getContext('2d') as CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D
if (!ctx) {
throw new Error('Canvas not supported')
}
Expand Down
2 changes: 0 additions & 2 deletions src/utils/scan-renderer/canvas-scan/scan.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ export interface WorkerMessage {
onmessage = async (e: MessageEvent<WorkerMessage>) => {
const { page, config, noise } = e.data
// disable eslint ban ts-ignore
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const canvas = new OffscreenCanvas(1000, 1000)
await scanCanvas(canvas, page, config, noise)
const blob = await canvas.convertToBlob({ type: config.output_format })
Expand Down

0 comments on commit 839bbf5

Please sign in to comment.