1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-22 15:06:54 -05:00
denoland-deno/cli/js/runtime.ts
crowlKats e435c2be15
Remove doc strings from cli/js TS files (#4329)
Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
2020-03-13 10:22:22 +01:00

45 lines
1.4 KiB
TypeScript

// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { core } from "./core.ts";
import * as dispatchMinimal from "./ops/dispatch_minimal.ts";
import * as dispatchJson from "./ops/dispatch_json.ts";
import * as util from "./util.ts";
import { setBuildInfo } from "./build.ts";
import { setVersions } from "./version.ts";
import { setPrepareStackTrace } from "./error_stack.ts";
import { Start, start as startOp } from "./ops/runtime.ts";
export let OPS_CACHE: { [name: string]: number };
function getAsyncHandler(opName: string): (msg: Uint8Array) => void {
switch (opName) {
case "op_write":
case "op_read":
return dispatchMinimal.asyncMsgFromRust;
default:
return dispatchJson.asyncMsgFromRust;
}
}
// TODO(bartlomieju): temporary solution, must be fixed when moving
// dispatches to separate crates
export function initOps(): void {
OPS_CACHE = core.ops();
for (const [name, opId] of Object.entries(OPS_CACHE)) {
core.setAsyncHandler(opId, getAsyncHandler(name));
}
}
export function start(source?: string): Start {
initOps();
// First we send an empty `Start` message to let the privileged side know we
// are ready. The response should be a `StartRes` message containing the CLI
// args and other info.
const s = startOp();
setVersions(s.denoVersion, s.v8Version, s.tsVersion);
setBuildInfo(s.os, s.arch);
util.setLogDebug(s.debugFlag, source);
setPrepareStackTrace(Error);
return s;
}