Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
james-pre committed Nov 6, 2024
1 parent 255cce4 commit b0b6ba9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
7 changes: 4 additions & 3 deletions src/dsp.ts
Original file line number Diff line number Diff line change
@@ -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(
[
Expand Down Expand Up @@ -74,7 +75,7 @@ export const dsp = (options: DspOptions = {}) => {
name: 'dsp',
isBuffered: false,
read() {},
write(writeOptions: any = {}, data: ArrayLike<number>) {
write(file: DeviceFile, data: ArrayLike<number>) {
if (data?.length) {
new Uint8Array(audioBuffer).set(data);
dsp.port?.postMessage(new Float32Array(audioBuffer));
Expand Down
22 changes: 13 additions & 9 deletions src/framebuffer.ts
Original file line number Diff line number Diff line change
@@ -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<number>) {
write(file: DeviceFile, data: ArrayLike<number>) {
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);
}
},
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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';
5 changes: 2 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down

0 comments on commit b0b6ba9

Please sign in to comment.