refactor: remove dispatch_json.js from cli/rt and cli/tsc (#7521)

Instead use Deno.core.jsonOpSync and Deno.core.jsonOpAsync
This commit is contained in:
Bartek Iwańczuk 2020-09-16 22:22:43 +02:00 committed by GitHub
parent 104aebdfb5
commit 6c4da0e429
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 177 additions and 373 deletions

View file

@ -17,9 +17,8 @@
delete Object.prototype.__proto__;
((window) => {
const core = Deno.core;
const core = window.Deno.core;
const { assert, log, notImplemented } = window.__bootstrap.util;
const dispatchJson = window.__bootstrap.dispatchJson;
const util = window.__bootstrap.util;
const errorStack = window.__bootstrap.errorStack;
const errors = window.__bootstrap.errors.errors;
@ -78,7 +77,7 @@ delete Object.prototype.__proto__;
}
function opNow() {
const res = dispatchJson.sendSync("op_now");
const res = core.jsonOpSync("op_now");
return res.seconds * 1e3 + res.subsecNanos / 1e6;
}
@ -1252,7 +1251,7 @@ delete Object.prototype.__proto__;
}
function opCompilerRespond(msg) {
dispatchJson.sendSync("op_compiler_respond", msg);
core.jsonOpSync("op_compiler_respond", msg);
}
async function tsCompilerOnMessage(msg) {
@ -1292,21 +1291,12 @@ delete Object.prototype.__proto__;
}
}
// TODO(bartlomieju): temporary solution, must be fixed when moving
// dispatches to separate crates
function initOps() {
const opsMap = core.ops();
for (const [_name, opId] of Object.entries(opsMap)) {
core.setAsyncHandler(opId, dispatchJson.asyncMsgFromRust);
}
}
function runtimeStart(source) {
initOps();
core.ops();
// 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 = dispatchJson.sendSync("op_start");
const s = core.jsonOpSync("op_start");
util.setLogDebug(s.debugFlag, source);
errorStack.setPrepareStackTrace(Error);
return s;