summaryrefslogtreecommitdiff
path: root/cli/js/runtime.ts
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-07-19 19:49:44 +0200
committerGitHub <noreply@github.com>2020-07-19 19:49:44 +0200
commitfa61956f03491101b6ef64423ea2f1f73af26a73 (patch)
treec3800702071ca78aa4dd71bdd0a59a9bbe460bdd /cli/js/runtime.ts
parent53adde866dd399aa2509d14508642fce37afb8f5 (diff)
Port internal TS code to JS (#6793)
Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
Diffstat (limited to 'cli/js/runtime.ts')
-rw-r--r--cli/js/runtime.ts44
1 files changed, 0 insertions, 44 deletions
diff --git a/cli/js/runtime.ts b/cli/js/runtime.ts
deleted file mode 100644
index a260dfebe..000000000
--- a/cli/js/runtime.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-// 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, opStart } from "./ops/runtime.ts";
-import { handleTimerMacrotask } from "./web/timers.ts";
-
-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 {
- const opsMap = core.ops();
- for (const [name, opId] of Object.entries(opsMap)) {
- core.setAsyncHandler(opId, getAsyncHandler(name));
- }
- core.setMacrotaskCallback(handleTimerMacrotask);
-}
-
-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 = opStart();
- setVersions(s.denoVersion, s.v8Version, s.tsVersion);
- setBuildInfo(s.target);
- util.setLogDebug(s.debugFlag, source);
- setPrepareStackTrace(Error);
- return s;
-}