27 lines
748 B
JavaScript
27 lines
748 B
JavaScript
if (!('Deno' in globalThis)) {
|
|
throw new Error('This module requires Deno to run');
|
|
}
|
|
/**
|
|
* The main entrypoint when using Deno as the runtime
|
|
*/
|
|
import { IRuntime, RunTimeType } from '../common/runtime.ts';
|
|
import DenoTerminalIO from './terminal_io.ts';
|
|
import DenoFileIO from './file_io.ts';
|
|
|
|
import * as node_process from 'node:process';
|
|
|
|
const DenoRuntime: IRuntime = {
|
|
name: RunTimeType.Deno,
|
|
file: DenoFileIO,
|
|
term: DenoTerminalIO,
|
|
onEvent: (eventName: string, handler) =>
|
|
globalThis.addEventListener(eventName, handler),
|
|
onExit: (cb: () => void): void => {
|
|
globalThis.addEventListener('onbeforeunload', cb);
|
|
globalThis.onbeforeunload = cb;
|
|
},
|
|
exit: (code?: number) => node_process.exit(code),
|
|
};
|
|
|
|
export default DenoRuntime;
|