2020-01-02 15:13:47 -05:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
2019-09-02 17:07:11 -04:00
|
|
|
import * as minimal from "./dispatch_minimal.ts";
|
|
|
|
import * as json from "./dispatch_json.ts";
|
2019-12-05 15:30:20 -05:00
|
|
|
import { AsyncHandler } from "./plugins.ts";
|
2018-09-05 22:13:36 -04:00
|
|
|
|
2019-08-21 20:42:48 -04:00
|
|
|
// These consts are shared with Rust. Update with care.
|
2019-10-01 18:51:05 -04:00
|
|
|
export let OP_READ: number;
|
|
|
|
export let OP_WRITE: number;
|
|
|
|
export let OP_EXIT: number;
|
|
|
|
export let OP_IS_TTY: number;
|
|
|
|
export let OP_ENV: number;
|
|
|
|
export let OP_EXEC_PATH: number;
|
|
|
|
export let OP_UTIME: number;
|
|
|
|
export let OP_SET_ENV: number;
|
2019-10-02 11:55:28 -04:00
|
|
|
export let OP_GET_ENV: number;
|
2019-12-15 00:14:20 -05:00
|
|
|
export let OP_GET_DIR: number;
|
2019-10-01 18:51:05 -04:00
|
|
|
export let OP_START: number;
|
|
|
|
export let OP_APPLY_SOURCE_MAP: number;
|
|
|
|
export let OP_FORMAT_ERROR: number;
|
|
|
|
export let OP_CACHE: number;
|
2020-01-08 09:17:44 -05:00
|
|
|
export let OP_RESOLVE_MODULES: number;
|
2019-10-01 18:51:05 -04:00
|
|
|
export let OP_FETCH_SOURCE_FILES: number;
|
|
|
|
export let OP_OPEN: number;
|
|
|
|
export let OP_CLOSE: number;
|
|
|
|
export let OP_SEEK: number;
|
|
|
|
export let OP_FETCH: number;
|
|
|
|
export let OP_METRICS: number;
|
|
|
|
export let OP_REPL_START: number;
|
|
|
|
export let OP_REPL_READLINE: number;
|
|
|
|
export let OP_ACCEPT: number;
|
2019-10-21 14:38:28 -04:00
|
|
|
export let OP_ACCEPT_TLS: number;
|
2020-01-18 12:35:12 -05:00
|
|
|
export let OP_CONNECT: number;
|
2019-10-01 18:51:05 -04:00
|
|
|
export let OP_SHUTDOWN: number;
|
|
|
|
export let OP_LISTEN: number;
|
2019-10-21 14:38:28 -04:00
|
|
|
export let OP_LISTEN_TLS: number;
|
2019-10-01 18:51:05 -04:00
|
|
|
export let OP_RESOURCES: number;
|
|
|
|
export let OP_GET_RANDOM_VALUES: number;
|
|
|
|
export let OP_GLOBAL_TIMER_STOP: number;
|
|
|
|
export let OP_GLOBAL_TIMER: number;
|
|
|
|
export let OP_NOW: number;
|
2019-10-27 11:22:53 -04:00
|
|
|
export let OP_QUERY_PERMISSION: number;
|
2019-10-01 18:51:05 -04:00
|
|
|
export let OP_REVOKE_PERMISSION: number;
|
2019-11-11 10:33:29 -05:00
|
|
|
export let OP_REQUEST_PERMISSION: number;
|
2019-10-01 18:51:05 -04:00
|
|
|
export let OP_CREATE_WORKER: number;
|
2020-01-17 18:43:53 -05:00
|
|
|
export let OP_HOST_GET_WORKER_LOADED: number;
|
2019-10-01 18:51:05 -04:00
|
|
|
export let OP_HOST_POST_MESSAGE: number;
|
2020-01-17 18:43:53 -05:00
|
|
|
export let OP_HOST_POLL_WORKER: number;
|
|
|
|
export let OP_HOST_CLOSE_WORKER: number;
|
|
|
|
export let OP_HOST_RESUME_WORKER: number;
|
2019-10-01 18:51:05 -04:00
|
|
|
export let OP_HOST_GET_MESSAGE: number;
|
|
|
|
export let OP_WORKER_POST_MESSAGE: number;
|
|
|
|
export let OP_WORKER_GET_MESSAGE: number;
|
|
|
|
export let OP_RUN: number;
|
|
|
|
export let OP_RUN_STATUS: number;
|
|
|
|
export let OP_KILL: number;
|
|
|
|
export let OP_CHDIR: number;
|
|
|
|
export let OP_MKDIR: number;
|
|
|
|
export let OP_CHMOD: number;
|
|
|
|
export let OP_CHOWN: number;
|
|
|
|
export let OP_REMOVE: number;
|
|
|
|
export let OP_COPY_FILE: number;
|
|
|
|
export let OP_STAT: number;
|
2019-11-26 03:40:57 -05:00
|
|
|
export let OP_REALPATH: number;
|
2019-10-01 18:51:05 -04:00
|
|
|
export let OP_READ_DIR: number;
|
|
|
|
export let OP_RENAME: number;
|
|
|
|
export let OP_LINK: number;
|
|
|
|
export let OP_SYMLINK: number;
|
|
|
|
export let OP_READ_LINK: number;
|
|
|
|
export let OP_TRUNCATE: number;
|
|
|
|
export let OP_MAKE_TEMP_DIR: number;
|
|
|
|
export let OP_CWD: number;
|
2020-01-18 12:35:12 -05:00
|
|
|
export let OP_CONNECT_TLS: number;
|
2019-10-01 18:51:05 -04:00
|
|
|
export let OP_HOSTNAME: number;
|
2019-12-05 15:30:20 -05:00
|
|
|
export let OP_OPEN_PLUGIN: number;
|
2020-01-08 09:17:44 -05:00
|
|
|
export let OP_COMPILE: number;
|
|
|
|
export let OP_TRANSPILE: number;
|
2019-12-05 15:30:20 -05:00
|
|
|
|
2020-01-22 14:18:01 -05:00
|
|
|
/** **WARNING:** This is only available during the snapshotting process and is
|
|
|
|
* unavailable at runtime. */
|
|
|
|
export let OP_FETCH_ASSET: number;
|
|
|
|
|
2019-12-05 15:30:20 -05:00
|
|
|
const PLUGIN_ASYNC_HANDLER_MAP: Map<number, AsyncHandler> = new Map();
|
|
|
|
|
|
|
|
export function setPluginAsyncHandler(
|
|
|
|
opId: number,
|
|
|
|
handler: AsyncHandler
|
|
|
|
): void {
|
|
|
|
PLUGIN_ASYNC_HANDLER_MAP.set(opId, handler);
|
|
|
|
}
|
2019-05-03 00:06:43 -04:00
|
|
|
|
2020-01-17 08:26:11 -05:00
|
|
|
export function getAsyncHandler(opName: string): (msg: Uint8Array) => void {
|
|
|
|
switch (opName) {
|
|
|
|
case "OP_WRITE":
|
|
|
|
case "OP_READ":
|
|
|
|
return minimal.asyncMsgFromRust;
|
2019-08-21 20:42:48 -04:00
|
|
|
default:
|
2020-01-17 08:26:11 -05:00
|
|
|
return json.asyncMsgFromRust;
|
2018-08-30 15:35:51 -04:00
|
|
|
}
|
|
|
|
}
|