23 lines
636 B
TypeScript
23 lines
636 B
TypeScript
import { Environment } from './types';
|
|
|
|
export function createBrowserEnv(): Environment {
|
|
const fetch = window.fetch;
|
|
if (!fetch) throw new Error('fetch - missing fetch implementation for browser environment');
|
|
|
|
const readFile = () => {
|
|
throw new Error('readFile - filesystem not available for browser environment');
|
|
};
|
|
|
|
return {
|
|
Canvas: HTMLCanvasElement,
|
|
CanvasRenderingContext2D,
|
|
Image: HTMLImageElement,
|
|
ImageData,
|
|
Video: HTMLVideoElement,
|
|
createCanvasElement: () => document.createElement('canvas'),
|
|
createImageElement: () => document.createElement('img'),
|
|
fetch,
|
|
readFile,
|
|
};
|
|
}
|