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

@ -1,7 +1,7 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
((window) => {
const { sendAsync } = window.__bootstrap.dispatchJson;
const core = window.Deno.core;
const { close } = window.__bootstrap.resources;
const { requiredArguments } = window.__bootstrap.webUtil;
const CONNECTING = 0;
@ -47,7 +47,7 @@
);
}
sendAsync("op_ws_create", {
core.jsonOpAsync("op_ws_create", {
url: wsURL.href,
protocols: protocols.join("; "),
}).then((create) => {
@ -57,7 +57,7 @@
this.#protocol = create.protocol;
if (this.#readyState === CLOSING) {
sendAsync("op_ws_close", {
core.jsonOpAsync("op_ws_close", {
rid: this.#rid,
}).then(() => {
this.#readyState = CLOSED;
@ -172,7 +172,7 @@
const sendTypedArray = (ta) => {
this.#bufferedAmount += ta.size;
sendAsync("op_ws_send", {
core.jsonOpAsync("op_ws_send", {
rid: this.#rid,
}, ta).then(() => {
this.#bufferedAmount -= ta.size;
@ -198,7 +198,7 @@
const encoder = new TextEncoder();
const d = encoder.encode(string);
this.#bufferedAmount += d.size;
sendAsync("op_ws_send", {
core.jsonOpAsync("op_ws_send", {
rid: this.#rid,
text: string,
}).then(() => {
@ -228,7 +228,7 @@
} else if (this.#readyState === OPEN) {
this.#readyState = CLOSING;
sendAsync("op_ws_close", {
core.jsonOpAsync("op_ws_close", {
rid: this.#rid,
code,
reason,
@ -249,7 +249,10 @@
async #eventLoop() {
if (this.#readyState === OPEN) {
const message = await sendAsync("op_ws_next_event", { rid: this.#rid });
const message = await core.jsonOpAsync(
"op_ws_next_event",
{ rid: this.#rid },
);
if (message.type === "string" || message.type === "binary") {
let data;