summaryrefslogtreecommitdiff
path: root/cli/js/ops
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/ops
parent53adde866dd399aa2509d14508642fce37afb8f5 (diff)
Port internal TS code to JS (#6793)
Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
Diffstat (limited to 'cli/js/ops')
-rw-r--r--cli/js/ops/dispatch_json.ts94
-rw-r--r--cli/js/ops/dispatch_minimal.ts121
-rw-r--r--cli/js/ops/errors.ts23
-rw-r--r--cli/js/ops/fetch.ts28
-rw-r--r--cli/js/ops/fs/chmod.ts12
-rw-r--r--cli/js/ops/fs/chown.ts20
-rw-r--r--cli/js/ops/fs/copy_file.ts24
-rw-r--r--cli/js/ops/fs/dir.ts11
-rw-r--r--cli/js/ops/fs/link.ts11
-rw-r--r--cli/js/ops/fs/make_temp.ts25
-rw-r--r--cli/js/ops/fs/mkdir.ts38
-rw-r--r--cli/js/ops/fs/open.ts31
-rw-r--r--cli/js/ops/fs/read_dir.ts34
-rw-r--r--cli/js/ops/fs/read_link.ts11
-rw-r--r--cli/js/ops/fs/real_path.ts11
-rw-r--r--cli/js/ops/fs/remove.ts28
-rw-r--r--cli/js/ops/fs/rename.ts11
-rw-r--r--cli/js/ops/fs/seek.ts20
-rw-r--r--cli/js/ops/fs/stat.ts108
-rw-r--r--cli/js/ops/fs/symlink.ts23
-rw-r--r--cli/js/ops/fs/sync.ts19
-rw-r--r--cli/js/ops/fs/truncate.ts27
-rw-r--r--cli/js/ops/fs/umask.ts7
-rw-r--r--cli/js/ops/fs/utime.ts33
-rw-r--r--cli/js/ops/fs_events.ts44
-rw-r--r--cli/js/ops/get_random_values.ts25
-rw-r--r--cli/js/ops/idna.ts12
-rw-r--r--cli/js/ops/io.ts50
-rw-r--r--cli/js/ops/net.ts86
-rw-r--r--cli/js/ops/os.ts45
-rw-r--r--cli/js/ops/permissions.ts22
-rw-r--r--cli/js/ops/plugins.ts7
-rw-r--r--cli/js/ops/process.ts43
-rw-r--r--cli/js/ops/repl.ts11
-rw-r--r--cli/js/ops/resources.ts18
-rw-r--r--cli/js/ops/runtime.ts45
-rw-r--r--cli/js/ops/runtime_compiler.ts37
-rw-r--r--cli/js/ops/signal.ts23
-rw-r--r--cli/js/ops/timers.ts20
-rw-r--r--cli/js/ops/tls.ts79
-rw-r--r--cli/js/ops/tty.ts15
-rw-r--r--cli/js/ops/web_worker.ts11
-rw-r--r--cli/js/ops/worker_host.ts36
43 files changed, 0 insertions, 1399 deletions
diff --git a/cli/js/ops/dispatch_json.ts b/cli/js/ops/dispatch_json.ts
deleted file mode 100644
index cf6f5c095..000000000
--- a/cli/js/ops/dispatch_json.ts
+++ /dev/null
@@ -1,94 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import * as util from "../util.ts";
-import { core } from "../core.ts";
-import { ErrorKind, getErrorClass } from "../errors.ts";
-
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-type Ok = any;
-
-interface JsonError {
- kind: ErrorKind;
- message: string;
-}
-
-interface JsonResponse {
- ok?: Ok;
- err?: JsonError;
- promiseId?: number; // Only present in async messages.
-}
-
-// Using an object without a prototype because `Map` was causing GC problems.
-const promiseTable: Record<
- number,
- util.Resolvable<JsonResponse>
-> = Object.create(null);
-let _nextPromiseId = 1;
-
-function nextPromiseId(): number {
- return _nextPromiseId++;
-}
-
-function decode(ui8: Uint8Array): JsonResponse {
- return JSON.parse(core.decode(ui8));
-}
-
-function encode(args: object): Uint8Array {
- return core.encode(JSON.stringify(args));
-}
-
-function unwrapResponse(res: JsonResponse): Ok {
- if (res.err != null) {
- throw new (getErrorClass(res.err.kind))(res.err.message);
- }
- util.assert(res.ok != null);
- return res.ok;
-}
-
-export function asyncMsgFromRust(resUi8: Uint8Array): void {
- const res = decode(resUi8);
- util.assert(res.promiseId != null);
-
- const promise = promiseTable[res.promiseId!];
- util.assert(promise != null);
- delete promiseTable[res.promiseId!];
- promise.resolve(res);
-}
-
-export function sendSync(
- opName: string,
- args: object = {},
- ...zeroCopy: Uint8Array[]
-): Ok {
- util.log("sendSync", opName);
- const argsUi8 = encode(args);
- const resUi8 = core.dispatchByName(opName, argsUi8, ...zeroCopy);
- util.assert(resUi8 != null);
- const res = decode(resUi8);
- util.assert(res.promiseId == null);
- return unwrapResponse(res);
-}
-
-export async function sendAsync(
- opName: string,
- args: object = {},
- ...zeroCopy: Uint8Array[]
-): Promise<Ok> {
- util.log("sendAsync", opName);
- const promiseId = nextPromiseId();
- args = Object.assign(args, { promiseId });
- const promise = util.createResolvable<Ok>();
- const argsUi8 = encode(args);
- const buf = core.dispatchByName(opName, argsUi8, ...zeroCopy);
- if (buf != null) {
- // Sync result.
- const res = decode(buf);
- promise.resolve(res);
- } else {
- // Async result.
- promiseTable[promiseId] = promise;
- }
-
- const res = await promise;
- return unwrapResponse(res);
-}
diff --git a/cli/js/ops/dispatch_minimal.ts b/cli/js/ops/dispatch_minimal.ts
deleted file mode 100644
index cc1d97e20..000000000
--- a/cli/js/ops/dispatch_minimal.ts
+++ /dev/null
@@ -1,121 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import * as util from "../util.ts";
-import { core } from "../core.ts";
-import { TextDecoder } from "../web/text_encoding.ts";
-import { ErrorKind, errors, getErrorClass } from "../errors.ts";
-
-// Using an object without a prototype because `Map` was causing GC problems.
-const promiseTableMin: Record<
- number,
- util.Resolvable<RecordMinimal>
-> = Object.create(null);
-
-// Note it's important that promiseId starts at 1 instead of 0, because sync
-// messages are indicated with promiseId 0. If we ever add wrap around logic for
-// overflows, this should be taken into account.
-let _nextPromiseId = 1;
-
-const decoder = new TextDecoder();
-
-function nextPromiseId(): number {
- return _nextPromiseId++;
-}
-
-export interface RecordMinimal {
- promiseId: number;
- arg: number;
- result: number;
- err?: {
- kind: ErrorKind;
- message: string;
- };
-}
-
-export function recordFromBufMinimal(ui8: Uint8Array): RecordMinimal {
- const header = ui8.subarray(0, 12);
- const buf32 = new Int32Array(
- header.buffer,
- header.byteOffset,
- header.byteLength / 4,
- );
- const promiseId = buf32[0];
- const arg = buf32[1];
- const result = buf32[2];
- let err;
-
- if (arg < 0) {
- const kind = result as ErrorKind;
- const message = decoder.decode(ui8.subarray(12));
- err = { kind, message };
- } else if (ui8.length != 12) {
- throw new errors.InvalidData("BadMessage");
- }
-
- return {
- promiseId,
- arg,
- result,
- err,
- };
-}
-
-function unwrapResponse(res: RecordMinimal): number {
- if (res.err != null) {
- throw new (getErrorClass(res.err.kind))(res.err.message);
- }
- return res.result;
-}
-
-const scratch32 = new Int32Array(3);
-const scratchBytes = new Uint8Array(
- scratch32.buffer,
- scratch32.byteOffset,
- scratch32.byteLength,
-);
-util.assert(scratchBytes.byteLength === scratch32.length * 4);
-
-export function asyncMsgFromRust(ui8: Uint8Array): void {
- const record = recordFromBufMinimal(ui8);
- const { promiseId } = record;
- const promise = promiseTableMin[promiseId];
- delete promiseTableMin[promiseId];
- util.assert(promise);
- promise.resolve(record);
-}
-
-export async function sendAsyncMinimal(
- opName: string,
- arg: number,
- zeroCopy: Uint8Array,
-): Promise<number> {
- const promiseId = nextPromiseId(); // AKA cmdId
- scratch32[0] = promiseId;
- scratch32[1] = arg;
- scratch32[2] = 0; // result
- const promise = util.createResolvable<RecordMinimal>();
- const buf = core.dispatchByName(opName, scratchBytes, zeroCopy);
- if (buf != null) {
- const record = recordFromBufMinimal(buf);
- // Sync result.
- promise.resolve(record);
- } else {
- // Async result.
- promiseTableMin[promiseId] = promise;
- }
-
- const res = await promise;
- return unwrapResponse(res);
-}
-
-export function sendSyncMinimal(
- opName: string,
- arg: number,
- zeroCopy: Uint8Array,
-): number {
- scratch32[0] = 0; // promiseId 0 indicates sync
- scratch32[1] = arg;
- const res = core.dispatchByName(opName, scratchBytes, zeroCopy)!;
- const resRecord = recordFromBufMinimal(res);
- return unwrapResponse(resRecord);
-}
diff --git a/cli/js/ops/errors.ts b/cli/js/ops/errors.ts
deleted file mode 100644
index 002ca699e..000000000
--- a/cli/js/ops/errors.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import type { DiagnosticItem } from "../diagnostics.ts";
-import { sendSync } from "./dispatch_json.ts";
-
-export function formatDiagnostics(items: DiagnosticItem[]): string {
- return sendSync("op_format_diagnostic", { items });
-}
-
-export interface Location {
- fileName: string;
- lineNumber: number;
- columnNumber: number;
-}
-
-export function applySourceMap(location: Location): Location {
- const res = sendSync("op_apply_source_map", location);
- return {
- fileName: res.fileName,
- lineNumber: res.lineNumber,
- columnNumber: res.columnNumber,
- };
-}
diff --git a/cli/js/ops/fetch.ts b/cli/js/ops/fetch.ts
deleted file mode 100644
index e349b9de5..000000000
--- a/cli/js/ops/fetch.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendAsync } from "./dispatch_json.ts";
-
-interface FetchRequest {
- url: string;
- method: string | null;
- headers: Array<[string, string]>;
-}
-
-export interface FetchResponse {
- bodyRid: number;
- status: number;
- statusText: string;
- headers: Array<[string, string]>;
-}
-
-export function fetch(
- args: FetchRequest,
- body?: ArrayBufferView,
-): Promise<FetchResponse> {
- let zeroCopy;
- if (body != null) {
- zeroCopy = new Uint8Array(body.buffer, body.byteOffset, body.byteLength);
- }
-
- return sendAsync("op_fetch", args, ...(zeroCopy ? [zeroCopy] : []));
-}
diff --git a/cli/js/ops/fs/chmod.ts b/cli/js/ops/fs/chmod.ts
deleted file mode 100644
index a2236935b..000000000
--- a/cli/js/ops/fs/chmod.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-import { pathFromURL } from "../../util.ts";
-
-export function chmodSync(path: string | URL, mode: number): void {
- sendSync("op_chmod", { path: pathFromURL(path), mode });
-}
-
-export async function chmod(path: string | URL, mode: number): Promise<void> {
- await sendAsync("op_chmod", { path: pathFromURL(path), mode });
-}
diff --git a/cli/js/ops/fs/chown.ts b/cli/js/ops/fs/chown.ts
deleted file mode 100644
index 054b61f6c..000000000
--- a/cli/js/ops/fs/chown.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-import { pathFromURL } from "../../util.ts";
-
-export function chownSync(
- path: string | URL,
- uid: number | null,
- gid: number | null,
-): void {
- sendSync("op_chown", { path: pathFromURL(path), uid, gid });
-}
-
-export async function chown(
- path: string | URL,
- uid: number | null,
- gid: number | null,
-): Promise<void> {
- await sendAsync("op_chown", { path: pathFromURL(path), uid, gid });
-}
diff --git a/cli/js/ops/fs/copy_file.ts b/cli/js/ops/fs/copy_file.ts
deleted file mode 100644
index d2d2d5688..000000000
--- a/cli/js/ops/fs/copy_file.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-import { pathFromURL } from "../../util.ts";
-
-export function copyFileSync(
- fromPath: string | URL,
- toPath: string | URL,
-): void {
- sendSync("op_copy_file", {
- from: pathFromURL(fromPath),
- to: pathFromURL(toPath),
- });
-}
-
-export async function copyFile(
- fromPath: string | URL,
- toPath: string | URL,
-): Promise<void> {
- await sendAsync("op_copy_file", {
- from: pathFromURL(fromPath),
- to: pathFromURL(toPath),
- });
-}
diff --git a/cli/js/ops/fs/dir.ts b/cli/js/ops/fs/dir.ts
deleted file mode 100644
index dbf468c62..000000000
--- a/cli/js/ops/fs/dir.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync } from "../dispatch_json.ts";
-
-export function cwd(): string {
- return sendSync("op_cwd");
-}
-
-export function chdir(directory: string): void {
- sendSync("op_chdir", { directory });
-}
diff --git a/cli/js/ops/fs/link.ts b/cli/js/ops/fs/link.ts
deleted file mode 100644
index 05ff358ef..000000000
--- a/cli/js/ops/fs/link.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-
-export function linkSync(oldpath: string, newpath: string): void {
- sendSync("op_link", { oldpath, newpath });
-}
-
-export async function link(oldpath: string, newpath: string): Promise<void> {
- await sendAsync("op_link", { oldpath, newpath });
-}
diff --git a/cli/js/ops/fs/make_temp.ts b/cli/js/ops/fs/make_temp.ts
deleted file mode 100644
index 3996744d1..000000000
--- a/cli/js/ops/fs/make_temp.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-
-export interface MakeTempOptions {
- dir?: string;
- prefix?: string;
- suffix?: string;
-}
-
-export function makeTempDirSync(options: MakeTempOptions = {}): string {
- return sendSync("op_make_temp_dir", options);
-}
-
-export function makeTempDir(options: MakeTempOptions = {}): Promise<string> {
- return sendAsync("op_make_temp_dir", options);
-}
-
-export function makeTempFileSync(options: MakeTempOptions = {}): string {
- return sendSync("op_make_temp_file", options);
-}
-
-export function makeTempFile(options: MakeTempOptions = {}): Promise<string> {
- return sendAsync("op_make_temp_file", options);
-}
diff --git a/cli/js/ops/fs/mkdir.ts b/cli/js/ops/fs/mkdir.ts
deleted file mode 100644
index 790b2ad05..000000000
--- a/cli/js/ops/fs/mkdir.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-
-export interface MkdirOptions {
- recursive?: boolean;
- mode?: number;
-}
-
-interface MkdirArgs {
- path: string;
- recursive: boolean;
- mode?: number;
-}
-
-function mkdirArgs(path: string, options?: MkdirOptions): MkdirArgs {
- const args: MkdirArgs = { path, recursive: false };
- if (options != null) {
- if (typeof options.recursive == "boolean") {
- args.recursive = options.recursive;
- }
- if (options.mode) {
- args.mode = options.mode;
- }
- }
- return args;
-}
-
-export function mkdirSync(path: string, options?: MkdirOptions): void {
- sendSync("op_mkdir", mkdirArgs(path, options));
-}
-
-export async function mkdir(
- path: string,
- options?: MkdirOptions,
-): Promise<void> {
- await sendAsync("op_mkdir", mkdirArgs(path, options));
-}
diff --git a/cli/js/ops/fs/open.ts b/cli/js/ops/fs/open.ts
deleted file mode 100644
index f2cad5988..000000000
--- a/cli/js/ops/fs/open.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-import { pathFromURL } from "../../util.ts";
-
-export interface OpenOptions {
- read?: boolean;
- write?: boolean;
- append?: boolean;
- truncate?: boolean;
- create?: boolean;
- createNew?: boolean;
- /** Permissions to use if creating the file (defaults to `0o666`, before
- * the process's umask).
- * It's an error to specify mode without also setting create or createNew to `true`.
- * Ignored on Windows. */
- mode?: number;
-}
-
-export function openSync(path: string | URL, options: OpenOptions): number {
- const mode: number | undefined = options?.mode;
- return sendSync("op_open", { path: pathFromURL(path), options, mode });
-}
-
-export function open(
- path: string | URL,
- options: OpenOptions,
-): Promise<number> {
- const mode: number | undefined = options?.mode;
- return sendAsync("op_open", { path: pathFromURL(path), options, mode });
-}
diff --git a/cli/js/ops/fs/read_dir.ts b/cli/js/ops/fs/read_dir.ts
deleted file mode 100644
index 6ffe6116e..000000000
--- a/cli/js/ops/fs/read_dir.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-import { pathFromURL } from "../../util.ts";
-
-export interface DirEntry {
- name: string;
- isFile: boolean;
- isDirectory: boolean;
- isSymlink: boolean;
-}
-
-interface ReadDirResponse {
- entries: DirEntry[];
-}
-
-function res(response: ReadDirResponse): DirEntry[] {
- return response.entries;
-}
-
-export function readDirSync(path: string | URL): Iterable<DirEntry> {
- return res(sendSync("op_read_dir", { path: pathFromURL(path) }))[
- Symbol.iterator
- ]();
-}
-
-export function readDir(path: string | URL): AsyncIterable<DirEntry> {
- const array = sendAsync("op_read_dir", { path: pathFromURL(path) }).then(res);
- return {
- async *[Symbol.asyncIterator](): AsyncIterableIterator<DirEntry> {
- yield* await array;
- },
- };
-}
diff --git a/cli/js/ops/fs/read_link.ts b/cli/js/ops/fs/read_link.ts
deleted file mode 100644
index 33fef7e36..000000000
--- a/cli/js/ops/fs/read_link.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-
-export function readLinkSync(path: string): string {
- return sendSync("op_read_link", { path });
-}
-
-export function readLink(path: string): Promise<string> {
- return sendAsync("op_read_link", { path });
-}
diff --git a/cli/js/ops/fs/real_path.ts b/cli/js/ops/fs/real_path.ts
deleted file mode 100644
index c424d99bc..000000000
--- a/cli/js/ops/fs/real_path.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-
-export function realPathSync(path: string): string {
- return sendSync("op_realpath", { path });
-}
-
-export function realPath(path: string): Promise<string> {
- return sendAsync("op_realpath", { path });
-}
diff --git a/cli/js/ops/fs/remove.ts b/cli/js/ops/fs/remove.ts
deleted file mode 100644
index 24e23986c..000000000
--- a/cli/js/ops/fs/remove.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-import { pathFromURL } from "../../util.ts";
-
-export interface RemoveOptions {
- recursive?: boolean;
-}
-
-export function removeSync(
- path: string | URL,
- options: RemoveOptions = {},
-): void {
- sendSync("op_remove", {
- path: pathFromURL(path),
- recursive: !!options.recursive,
- });
-}
-
-export async function remove(
- path: string | URL,
- options: RemoveOptions = {},
-): Promise<void> {
- await sendAsync("op_remove", {
- path: pathFromURL(path),
- recursive: !!options.recursive,
- });
-}
diff --git a/cli/js/ops/fs/rename.ts b/cli/js/ops/fs/rename.ts
deleted file mode 100644
index f0789d3eb..000000000
--- a/cli/js/ops/fs/rename.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-
-export function renameSync(oldpath: string, newpath: string): void {
- sendSync("op_rename", { oldpath, newpath });
-}
-
-export async function rename(oldpath: string, newpath: string): Promise<void> {
- await sendAsync("op_rename", { oldpath, newpath });
-}
diff --git a/cli/js/ops/fs/seek.ts b/cli/js/ops/fs/seek.ts
deleted file mode 100644
index 4f97514ed..000000000
--- a/cli/js/ops/fs/seek.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-import type { SeekMode } from "../../io.ts";
-
-export function seekSync(
- rid: number,
- offset: number,
- whence: SeekMode,
-): number {
- return sendSync("op_seek", { rid, offset, whence });
-}
-
-export function seek(
- rid: number,
- offset: number,
- whence: SeekMode,
-): Promise<number> {
- return sendAsync("op_seek", { rid, offset, whence });
-}
diff --git a/cli/js/ops/fs/stat.ts b/cli/js/ops/fs/stat.ts
deleted file mode 100644
index f444190fd..000000000
--- a/cli/js/ops/fs/stat.ts
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-import { build } from "../../build.ts";
-import { pathFromURL } from "../../util.ts";
-
-export interface FileInfo {
- size: number;
- mtime: Date | null;
- atime: Date | null;
- birthtime: Date | null;
- dev: number | null;
- ino: number | null;
- mode: number | null;
- nlink: number | null;
- uid: number | null;
- gid: number | null;
- rdev: number | null;
- blksize: number | null;
- blocks: number | null;
- isFile: boolean;
- isDirectory: boolean;
- isSymlink: boolean;
-}
-
-export interface StatResponse {
- isFile: boolean;
- isDirectory: boolean;
- isSymlink: boolean;
- size: number;
- mtime: number | null;
- atime: number | null;
- birthtime: number | null;
- // Unix only members
- dev: number;
- ino: number;
- mode: number;
- nlink: number;
- uid: number;
- gid: number;
- rdev: number;
- blksize: number;
- blocks: number;
-}
-
-// @internal
-export function parseFileInfo(response: StatResponse): FileInfo {
- const unix = build.os === "darwin" || build.os === "linux";
- return {
- isFile: response.isFile,
- isDirectory: response.isDirectory,
- isSymlink: response.isSymlink,
- size: response.size,
- mtime: response.mtime != null ? new Date(response.mtime) : null,
- atime: response.atime != null ? new Date(response.atime) : null,
- birthtime: response.birthtime != null ? new Date(response.birthtime) : null,
- // Only non-null if on Unix
- dev: unix ? response.dev : null,
- ino: unix ? response.ino : null,
- mode: unix ? response.mode : null,
- nlink: unix ? response.nlink : null,
- uid: unix ? response.uid : null,
- gid: unix ? response.gid : null,
- rdev: unix ? response.rdev : null,
- blksize: unix ? response.blksize : null,
- blocks: unix ? response.blocks : null,
- };
-}
-
-export function fstatSync(rid: number): FileInfo {
- return parseFileInfo(sendSync("op_fstat", { rid }));
-}
-
-export async function fstat(rid: number): Promise<FileInfo> {
- return parseFileInfo(await sendAsync("op_fstat", { rid }));
-}
-
-export async function lstat(path: string | URL): Promise<FileInfo> {
- const res = await sendAsync("op_stat", {
- path: pathFromURL(path),
- lstat: true,
- });
- return parseFileInfo(res);
-}
-
-export function lstatSync(path: string | URL): FileInfo {
- const res = sendSync("op_stat", {
- path: pathFromURL(path),
- lstat: true,
- });
- return parseFileInfo(res);
-}
-
-export async function stat(path: string | URL): Promise<FileInfo> {
- const res = await sendAsync("op_stat", {
- path: pathFromURL(path),
- lstat: false,
- });
- return parseFileInfo(res);
-}
-
-export function statSync(path: string | URL): FileInfo {
- const res = sendSync("op_stat", {
- path: pathFromURL(path),
- lstat: false,
- });
- return parseFileInfo(res);
-}
diff --git a/cli/js/ops/fs/symlink.ts b/cli/js/ops/fs/symlink.ts
deleted file mode 100644
index d96e05f24..000000000
--- a/cli/js/ops/fs/symlink.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-
-export interface SymlinkOptions {
- type: "file" | "dir";
-}
-
-export function symlinkSync(
- oldpath: string,
- newpath: string,
- options?: SymlinkOptions,
-): void {
- sendSync("op_symlink", { oldpath, newpath, options });
-}
-
-export async function symlink(
- oldpath: string,
- newpath: string,
- options?: SymlinkOptions,
-): Promise<void> {
- await sendAsync("op_symlink", { oldpath, newpath, options });
-}
diff --git a/cli/js/ops/fs/sync.ts b/cli/js/ops/fs/sync.ts
deleted file mode 100644
index 7f208b8bd..000000000
--- a/cli/js/ops/fs/sync.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-
-export function fdatasyncSync(rid: number): void {
- sendSync("op_fdatasync", { rid });
-}
-
-export async function fdatasync(rid: number): Promise<void> {
- await sendAsync("op_fdatasync", { rid });
-}
-
-export function fsyncSync(rid: number): void {
- sendSync("op_fsync", { rid });
-}
-
-export async function fsync(rid: number): Promise<void> {
- await sendAsync("op_fsync", { rid });
-}
diff --git a/cli/js/ops/fs/truncate.ts b/cli/js/ops/fs/truncate.ts
deleted file mode 100644
index d18e5d9d9..000000000
--- a/cli/js/ops/fs/truncate.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-
-function coerceLen(len?: number): number {
- if (len == null || len < 0) {
- return 0;
- }
-
- return len;
-}
-
-export function ftruncateSync(rid: number, len?: number): void {
- sendSync("op_ftruncate", { rid, len: coerceLen(len) });
-}
-
-export async function ftruncate(rid: number, len?: number): Promise<void> {
- await sendAsync("op_ftruncate", { rid, len: coerceLen(len) });
-}
-
-export function truncateSync(path: string, len?: number): void {
- sendSync("op_truncate", { path, len: coerceLen(len) });
-}
-
-export async function truncate(path: string, len?: number): Promise<void> {
- await sendAsync("op_truncate", { path, len: coerceLen(len) });
-}
diff --git a/cli/js/ops/fs/umask.ts b/cli/js/ops/fs/umask.ts
deleted file mode 100644
index fbc94091e..000000000
--- a/cli/js/ops/fs/umask.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync } from "../dispatch_json.ts";
-
-export function umask(mask?: number): number {
- return sendSync("op_umask", { mask });
-}
diff --git a/cli/js/ops/fs/utime.ts b/cli/js/ops/fs/utime.ts
deleted file mode 100644
index bbc023ae9..000000000
--- a/cli/js/ops/fs/utime.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "../dispatch_json.ts";
-
-function toSecondsFromEpoch(v: number | Date): number {
- return v instanceof Date ? Math.trunc(v.valueOf() / 1000) : v;
-}
-
-export function utimeSync(
- path: string,
- atime: number | Date,
- mtime: number | Date,
-): void {
- sendSync("op_utime", {
- path,
- // TODO(ry) split atime, mtime into [seconds, nanoseconds] tuple
- atime: toSecondsFromEpoch(atime),
- mtime: toSecondsFromEpoch(mtime),
- });
-}
-
-export async function utime(
- path: string,
- atime: number | Date,
- mtime: number | Date,
-): Promise<void> {
- await sendAsync("op_utime", {
- path,
- // TODO(ry) split atime, mtime into [seconds, nanoseconds] tuple
- atime: toSecondsFromEpoch(atime),
- mtime: toSecondsFromEpoch(mtime),
- });
-}
diff --git a/cli/js/ops/fs_events.ts b/cli/js/ops/fs_events.ts
deleted file mode 100644
index ffe19b4d7..000000000
--- a/cli/js/ops/fs_events.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "./dispatch_json.ts";
-import { close } from "./resources.ts";
-
-export interface FsEvent {
- kind: "any" | "access" | "create" | "modify" | "remove";
- paths: string[];
-}
-
-interface FsWatcherOptions {
- recursive: boolean;
-}
-
-class FsWatcher implements AsyncIterableIterator<FsEvent> {
- readonly rid: number;
-
- constructor(paths: string[], options: FsWatcherOptions) {
- const { recursive } = options;
- this.rid = sendSync("op_fs_events_open", { recursive, paths });
- }
-
- next(): Promise<IteratorResult<FsEvent>> {
- return sendAsync("op_fs_events_poll", {
- rid: this.rid,
- });
- }
-
- return(value?: FsEvent): Promise<IteratorResult<FsEvent>> {
- close(this.rid);
- return Promise.resolve({ value, done: true });
- }
-
- [Symbol.asyncIterator](): AsyncIterableIterator<FsEvent> {
- return this;
- }
-}
-
-export function watchFs(
- paths: string | string[],
- options: FsWatcherOptions = { recursive: true },
-): AsyncIterableIterator<FsEvent> {
- return new FsWatcher(Array.isArray(paths) ? paths : [paths], options);
-}
diff --git a/cli/js/ops/get_random_values.ts b/cli/js/ops/get_random_values.ts
deleted file mode 100644
index 5a45a79d7..000000000
--- a/cli/js/ops/get_random_values.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync } from "./dispatch_json.ts";
-import { assert } from "../util.ts";
-
-export function getRandomValues<
- T extends
- | Int8Array
- | Uint8Array
- | Uint8ClampedArray
- | Int16Array
- | Uint16Array
- | Int32Array
- | Uint32Array,
->(typedArray: T): T {
- assert(typedArray !== null, "Input must not be null");
- assert(typedArray.length <= 65536, "Input must not be longer than 65536");
- const ui8 = new Uint8Array(
- typedArray.buffer,
- typedArray.byteOffset,
- typedArray.byteLength,
- );
- sendSync("op_get_random_values", {}, ui8);
- return typedArray;
-}
diff --git a/cli/js/ops/idna.ts b/cli/js/ops/idna.ts
deleted file mode 100644
index 59a9af030..000000000
--- a/cli/js/ops/idna.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-/** https://url.spec.whatwg.org/#idna */
-
-import { sendSync } from "./dispatch_json.ts";
-
-export function domainToAscii(
- domain: string,
- { beStrict = false }: { beStrict?: boolean } = {},
-): string {
- return sendSync("op_domain_to_ascii", { domain, beStrict });
-}
diff --git a/cli/js/ops/io.ts b/cli/js/ops/io.ts
deleted file mode 100644
index 355a09ae0..000000000
--- a/cli/js/ops/io.ts
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendAsyncMinimal, sendSyncMinimal } from "./dispatch_minimal.ts";
-
-export function readSync(rid: number, buffer: Uint8Array): number | null {
- if (buffer.length === 0) {
- return 0;
- }
-
- const nread = sendSyncMinimal("op_read", rid, buffer);
- if (nread < 0) {
- throw new Error("read error");
- }
-
- return nread === 0 ? null : nread;
-}
-
-export async function read(
- rid: number,
- buffer: Uint8Array,
-): Promise<number | null> {
- if (buffer.length === 0) {
- return 0;
- }
-
- const nread = await sendAsyncMinimal("op_read", rid, buffer);
- if (nread < 0) {
- throw new Error("read error");
- }
-
- return nread === 0 ? null : nread;
-}
-
-export function writeSync(rid: number, data: Uint8Array): number {
- const result = sendSyncMinimal("op_write", rid, data);
- if (result < 0) {
- throw new Error("write error");
- }
-
- return result;
-}
-
-export async function write(rid: number, data: Uint8Array): Promise<number> {
- const result = await sendAsyncMinimal("op_write", rid, data);
- if (result < 0) {
- throw new Error("write error");
- }
-
- return result;
-}
diff --git a/cli/js/ops/net.ts b/cli/js/ops/net.ts
deleted file mode 100644
index 1dfa92bd1..000000000
--- a/cli/js/ops/net.ts
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "./dispatch_json.ts";
-
-export interface NetAddr {
- transport: "tcp" | "udp";
- hostname: string;
- port: number;
-}
-
-export interface UnixAddr {
- transport: "unix" | "unixpacket";
- path: string;
-}
-
-export type Addr = NetAddr | UnixAddr;
-
-export enum ShutdownMode {
- // See http://man7.org/linux/man-pages/man2/shutdown.2.html
- // Corresponding to SHUT_RD, SHUT_WR, SHUT_RDWR
- Read = 0,
- Write = 1,
- ReadWrite, // unused
-}
-
-export function shutdown(rid: number, how: ShutdownMode): Promise<void> {
- sendSync("op_shutdown", { rid, how });
- return Promise.resolve();
-}
-
-interface AcceptResponse {
- rid: number;
- localAddr: Addr;
- remoteAddr: Addr;
-}
-
-export function accept(
- rid: number,
- transport: string,
-): Promise<AcceptResponse> {
- return sendAsync("op_accept", { rid, transport });
-}
-
-export type ListenRequest = Addr;
-
-interface ListenResponse {
- rid: number;
- localAddr: Addr;
-}
-
-export function listen(args: ListenRequest): ListenResponse {
- return sendSync("op_listen", args);
-}
-
-interface ConnectResponse {
- rid: number;
- localAddr: Addr;
- remoteAddr: Addr;
-}
-
-export type ConnectRequest = Addr;
-
-export function connect(args: ConnectRequest): Promise<ConnectResponse> {
- return sendAsync("op_connect", args);
-}
-
-interface ReceiveResponse {
- size: number;
- remoteAddr: Addr;
-}
-
-export function receive(
- rid: number,
- transport: string,
- zeroCopy: Uint8Array,
-): Promise<ReceiveResponse> {
- return sendAsync("op_datagram_receive", { rid, transport }, zeroCopy);
-}
-
-export type SendRequest = {
- rid: number;
-} & Addr;
-
-export function send(args: SendRequest, zeroCopy: Uint8Array): Promise<number> {
- return sendAsync("op_datagram_send", args, zeroCopy);
-}
diff --git a/cli/js/ops/os.ts b/cli/js/ops/os.ts
deleted file mode 100644
index 50234ee4b..000000000
--- a/cli/js/ops/os.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync } from "./dispatch_json.ts";
-
-export function loadavg(): number[] {
- return sendSync("op_loadavg");
-}
-
-export function hostname(): string {
- return sendSync("op_hostname");
-}
-
-export function osRelease(): string {
- return sendSync("op_os_release");
-}
-
-export function exit(code = 0): never {
- sendSync("op_exit", { code });
- throw new Error("Code not reachable");
-}
-
-function setEnv(key: string, value: string): void {
- sendSync("op_set_env", { key, value });
-}
-
-function getEnv(key: string): string | undefined {
- return sendSync("op_get_env", { key })[0];
-}
-
-function deleteEnv(key: string): void {
- sendSync("op_delete_env", { key });
-}
-
-export const env = {
- get: getEnv,
- toObject(): Record<string, string> {
- return sendSync("op_env");
- },
- set: setEnv,
- delete: deleteEnv,
-};
-
-export function execPath(): string {
- return sendSync("op_exec_path");
-}
diff --git a/cli/js/ops/permissions.ts b/cli/js/ops/permissions.ts
deleted file mode 100644
index 74b9ba0f0..000000000
--- a/cli/js/ops/permissions.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync } from "./dispatch_json.ts";
-import type { PermissionState } from "../permissions.ts";
-
-interface PermissionRequest {
- name: string;
- url?: string;
- path?: string;
-}
-
-export function query(desc: PermissionRequest): PermissionState {
- return sendSync("op_query_permission", desc).state;
-}
-
-export function revoke(desc: PermissionRequest): PermissionState {
- return sendSync("op_revoke_permission", desc).state;
-}
-
-export function request(desc: PermissionRequest): PermissionState {
- return sendSync("op_request_permission", desc).state;
-}
diff --git a/cli/js/ops/plugins.ts b/cli/js/ops/plugins.ts
deleted file mode 100644
index 787fd799b..000000000
--- a/cli/js/ops/plugins.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync } from "./dispatch_json.ts";
-
-export function openPlugin(filename: string): number {
- return sendSync("op_open_plugin", { filename });
-}
diff --git a/cli/js/ops/process.ts b/cli/js/ops/process.ts
deleted file mode 100644
index 86a0c9a71..000000000
--- a/cli/js/ops/process.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "./dispatch_json.ts";
-import { assert } from "../util.ts";
-
-export function kill(pid: number, signo: number): void {
- sendSync("op_kill", { pid, signo });
-}
-
-interface RunStatusResponse {
- gotSignal: boolean;
- exitCode: number;
- exitSignal: number;
-}
-
-export function runStatus(rid: number): Promise<RunStatusResponse> {
- return sendAsync("op_run_status", { rid });
-}
-
-interface RunRequest {
- cmd: string[];
- cwd?: string;
- env?: Array<[string, string]>;
- stdin: string;
- stdout: string;
- stderr: string;
- stdinRid: number;
- stdoutRid: number;
- stderrRid: number;
-}
-
-interface RunResponse {
- rid: number;
- pid: number;
- stdinRid: number | null;
- stdoutRid: number | null;
- stderrRid: number | null;
-}
-
-export function run(request: RunRequest): RunResponse {
- assert(request.cmd.length > 0);
- return sendSync("op_run", request);
-}
diff --git a/cli/js/ops/repl.ts b/cli/js/ops/repl.ts
deleted file mode 100644
index 1781aa089..000000000
--- a/cli/js/ops/repl.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "./dispatch_json.ts";
-
-export function startRepl(historyFile: string): number {
- return sendSync("op_repl_start", { historyFile });
-}
-
-export function readline(rid: number, prompt: string): Promise<string> {
- return sendAsync("op_repl_readline", { rid, prompt });
-}
diff --git a/cli/js/ops/resources.ts b/cli/js/ops/resources.ts
deleted file mode 100644
index ffcdb553e..000000000
--- a/cli/js/ops/resources.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync } from "./dispatch_json.ts";
-
-export type ResourceMap = Record<number, string>;
-
-export function resources(): ResourceMap {
- const res = sendSync("op_resources") as Array<[number, string]>;
- const resources: ResourceMap = {};
- for (const resourceTuple of res) {
- resources[resourceTuple[0]] = resourceTuple[1];
- }
- return resources;
-}
-
-export function close(rid: number): void {
- sendSync("op_close", { rid });
-}
diff --git a/cli/js/ops/runtime.ts b/cli/js/ops/runtime.ts
deleted file mode 100644
index 09208df6d..000000000
--- a/cli/js/ops/runtime.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync } from "./dispatch_json.ts";
-
-export interface Start {
- args: string[];
- cwd: string;
- debugFlag: boolean;
- denoVersion: string;
- noColor: boolean;
- pid: number;
- ppid: number;
- repl: boolean;
- target: string;
- tsVersion: string;
- unstableFlag: boolean;
- v8Version: string;
- versionFlag: boolean;
-}
-
-export function opStart(): Start {
- return sendSync("op_start");
-}
-
-export function opMainModule(): string {
- return sendSync("op_main_module");
-}
-
-export interface Metrics {
- opsDispatched: number;
- opsDispatchedSync: number;
- opsDispatchedAsync: number;
- opsDispatchedAsyncUnref: number;
- opsCompleted: number;
- opsCompletedSync: number;
- opsCompletedAsync: number;
- opsCompletedAsyncUnref: number;
- bytesSentControl: number;
- bytesSentData: number;
- bytesReceived: number;
-}
-
-export function metrics(): Metrics {
- return sendSync("op_metrics");
-}
diff --git a/cli/js/ops/runtime_compiler.ts b/cli/js/ops/runtime_compiler.ts
deleted file mode 100644
index ed439de4a..000000000
--- a/cli/js/ops/runtime_compiler.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendAsync } from "./dispatch_json.ts";
-import type { DiagnosticItem } from "../diagnostics.ts";
-
-interface CompileRequest {
- rootName: string;
- sources?: Record<string, string>;
- options?: string;
- bundle: boolean;
-}
-
-interface CompileResponse {
- diagnostics: DiagnosticItem[];
- output?: string;
- emitMap?: Record<string, Record<string, string>>;
-}
-
-export function compile(request: CompileRequest): Promise<CompileResponse> {
- return sendAsync("op_compile", request);
-}
-
-interface TranspileRequest {
- sources: Record<string, string>;
- options?: string;
-}
-
-export interface TranspileOnlyResult {
- source: string;
- map?: string;
-}
-
-export function transpile(
- request: TranspileRequest,
-): Promise<Record<string, TranspileOnlyResult>> {
- return sendAsync("op_transpile", request);
-}
diff --git a/cli/js/ops/signal.ts b/cli/js/ops/signal.ts
deleted file mode 100644
index 15093a3c4..000000000
--- a/cli/js/ops/signal.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "./dispatch_json.ts";
-
-interface BindSignalResponse {
- rid: number;
-}
-
-interface PollSignalResponse {
- done: boolean;
-}
-
-export function bindSignal(signo: number): BindSignalResponse {
- return sendSync("op_signal_bind", { signo });
-}
-
-export function pollSignal(rid: number): Promise<PollSignalResponse> {
- return sendAsync("op_signal_poll", { rid });
-}
-
-export function unbindSignal(rid: number): void {
- sendSync("op_signal_unbind", { rid });
-}
diff --git a/cli/js/ops/timers.ts b/cli/js/ops/timers.ts
deleted file mode 100644
index 2fdbd6851..000000000
--- a/cli/js/ops/timers.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync, sendAsync } from "./dispatch_json.ts";
-
-interface NowResponse {
- seconds: number;
- subsecNanos: number;
-}
-
-export function stopGlobalTimer(): void {
- sendSync("op_global_timer_stop");
-}
-
-export async function startGlobalTimer(timeout: number): Promise<void> {
- await sendAsync("op_global_timer", { timeout });
-}
-
-export function now(): NowResponse {
- return sendSync("op_now");
-}
diff --git a/cli/js/ops/tls.ts b/cli/js/ops/tls.ts
deleted file mode 100644
index 291fe3dd9..000000000
--- a/cli/js/ops/tls.ts
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendAsync, sendSync } from "./dispatch_json.ts";
-
-export interface ConnectTLSRequest {
- transport: "tcp";
- hostname: string;
- port: number;
- certFile?: string;
-}
-
-interface EstablishTLSResponse {
- rid: number;
- localAddr: {
- hostname: string;
- port: number;
- transport: "tcp";
- };
- remoteAddr: {
- hostname: string;
- port: number;
- transport: "tcp";
- };
-}
-
-export function connectTls(
- args: ConnectTLSRequest,
-): Promise<EstablishTLSResponse> {
- return sendAsync("op_connect_tls", args);
-}
-
-interface AcceptTLSResponse {
- rid: number;
- localAddr: {
- hostname: string;
- port: number;
- transport: "tcp";
- };
- remoteAddr: {
- hostname: string;
- port: number;
- transport: "tcp";
- };
-}
-
-export function acceptTLS(rid: number): Promise<AcceptTLSResponse> {
- return sendAsync("op_accept_tls", { rid });
-}
-
-export interface ListenTLSRequest {
- port: number;
- hostname: string;
- transport: "tcp";
- certFile: string;
- keyFile: string;
-}
-
-interface ListenTLSResponse {
- rid: number;
- localAddr: {
- hostname: string;
- port: number;
- transport: "tcp";
- };
-}
-
-export function listenTls(args: ListenTLSRequest): ListenTLSResponse {
- return sendSync("op_listen_tls", args);
-}
-
-export interface StartTLSRequest {
- rid: number;
- hostname: string;
- certFile?: string;
-}
-
-export function startTls(args: StartTLSRequest): Promise<EstablishTLSResponse> {
- return sendAsync("op_start_tls", args);
-}
diff --git a/cli/js/ops/tty.ts b/cli/js/ops/tty.ts
deleted file mode 100644
index f9da7bd0d..000000000
--- a/cli/js/ops/tty.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync } from "./dispatch_json.ts";
-
-export function consoleSize(rid: number): [number, number] {
- return sendSync("op_console_size", { rid });
-}
-
-export function isatty(rid: number): boolean {
- return sendSync("op_isatty", { rid });
-}
-
-export function setRaw(rid: number, mode: boolean): void {
- sendSync("op_set_raw", { rid, mode });
-}
diff --git a/cli/js/ops/web_worker.ts b/cli/js/ops/web_worker.ts
deleted file mode 100644
index 329323e2e..000000000
--- a/cli/js/ops/web_worker.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import { sendSync } from "./dispatch_json.ts";
-
-export function postMessage(data: Uint8Array): void {
- sendSync("op_worker_post_message", {}, data);
-}
-
-export function close(): void {
- sendSync("op_worker_close");
-}
diff --git a/cli/js/ops/worker_host.ts b/cli/js/ops/worker_host.ts
deleted file mode 100644
index d5adfc3d5..000000000
--- a/cli/js/ops/worker_host.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-/* eslint-disable @typescript-eslint/no-explicit-any */
-import { sendAsync, sendSync } from "./dispatch_json.ts";
-
-interface CreateWorkerResponse {
- id: number;
-}
-
-export function createWorker(
- specifier: string,
- hasSourceCode: boolean,
- sourceCode: string,
- useDenoNamespace: boolean,
- name?: string,
-): CreateWorkerResponse {
- return sendSync("op_create_worker", {
- specifier,
- hasSourceCode,
- sourceCode,
- name,
- useDenoNamespace,
- });
-}
-
-export function hostTerminateWorker(id: number): void {
- sendSync("op_host_terminate_worker", { id });
-}
-
-export function hostPostMessage(id: number, data: Uint8Array): void {
- sendSync("op_host_post_message", { id }, data);
-}
-
-export function hostGetMessage(id: number): Promise<any> {
- return sendAsync("op_host_get_message", { id });
-}