From b0b6ba9d8be11499320c62d2db1a11dbe2e39fd3 Mon Sep 17 00:00:00 2001 From: James Prevett Date: Tue, 5 Nov 2024 21:02:47 -0600 Subject: [PATCH] Fix build --- src/dsp.ts | 7 ++++--- src/framebuffer.ts | 22 +++++++++++++--------- src/index.ts | 6 +++--- tsconfig.json | 5 ++--- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/dsp.ts b/src/dsp.ts index 234e302..152cf23 100644 --- a/src/dsp.ts +++ b/src/dsp.ts @@ -1,11 +1,12 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ -/* eslint-disable @typescript-eslint/no-explicit-any */ + +import type { DeviceFile } from '@zenfs/core'; interface DspOptions { audioContext?: AudioContext; } -// I inline worker, so no seperate file is needed. +// I inline worker, so no separate file is needed. const workletUrl = URL.createObjectURL( new Blob( [ @@ -74,7 +75,7 @@ export const dsp = (options: DspOptions = {}) => { name: 'dsp', isBuffered: false, read() {}, - write(writeOptions: any = {}, data: ArrayLike) { + write(file: DeviceFile, data: ArrayLike) { if (data?.length) { new Uint8Array(audioBuffer).set(data); dsp.port?.postMessage(new Float32Array(audioBuffer)); diff --git a/src/framebuffer.ts b/src/framebuffer.ts index e114dfb..bf22fd6 100644 --- a/src/framebuffer.ts +++ b/src/framebuffer.ts @@ -1,23 +1,27 @@ -/* eslint-disable @typescript-eslint/no-unused-vars */ -/* eslint-disable @typescript-eslint/no-explicit-any */ +import { Errno, ErrnoError, type DeviceFile } from '@zenfs/core'; interface FramebufferOptions { canvas?: HTMLCanvasElement; } -export function framebuffer(options: FramebufferOptions = {}) { - if (!options.canvas) { - options.canvas = document.createElement('canvas'); - document.body.appendChild(options.canvas); +export function framebuffer({ canvas }: FramebufferOptions = {}) { + if (!canvas) { + canvas = document.createElement('canvas'); + document.body.appendChild(canvas); } - const ctx = options.canvas.getContext('2d'); + const ctx = canvas.getContext('2d'); + + if (!ctx) { + throw new ErrnoError(Errno.EIO, 'Could not get context from canvas whilst initializing frame buffer.'); + } + return { name: 'framebuffer', isBuffered: false, read() {}, - write(writeOptions: any = {}, data: ArrayLike) { + write(file: DeviceFile, data: ArrayLike) { if (data?.length) { - const imageData = new ImageData(new Uint8ClampedArray(data), options.canvas.width, options.canvas.height); + const imageData = new ImageData(new Uint8ClampedArray(data), canvas.width, canvas.height); ctx.putImageData(imageData, 0, 0); } }, diff --git a/src/index.ts b/src/index.ts index 26b6e93..057123a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,3 @@ -export { framebuffer } from './framebuffer.ts'; -export { dsp } from './dsp.ts'; -export { input } from './input.ts'; +export { framebuffer } from './framebuffer.js'; +export { dsp } from './dsp.js'; +export { input } from './input.js'; diff --git a/tsconfig.json b/tsconfig.json index 005886c..05985a6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,9 +6,8 @@ "lib": ["ESNext", "ESNext.Disposable", "dom"], "moduleResolution": "NodeNext", "declaration": true, - "strict": false, - "allowImportingTsExtensions": true, - "noEmit": true + "strict": true, + "noEmit": false }, "include": ["src/**/*.ts"], "exclude": ["node_modules"]