summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/build.rs4
-rw-r--r--cli/compilers/ts.rs6
-rw-r--r--cli/flags.rs150
-rw-r--r--cli/js.rs1
-rw-r--r--cli/js/compiler.ts25
-rw-r--r--cli/js/compiler/bootstrap.ts2
-rw-r--r--cli/js/compiler/host.ts18
-rw-r--r--cli/js/deno.ts43
-rw-r--r--cli/js/deno_unstable.ts26
-rw-r--r--cli/js/globals_unstable.ts5
-rw-r--r--cli/js/lib.deno.ns.d.ts1172
-rw-r--r--cli/js/lib.deno.unstable.d.ts1192
-rw-r--r--cli/js/net.ts52
-rw-r--r--cli/js/net_unstable.ts79
-rw-r--r--cli/js/ops/runtime.ts17
-rw-r--r--cli/js/runtime_main.ts43
-rw-r--r--cli/js/runtime_worker.ts32
-rw-r--r--cli/lib.rs28
-rw-r--r--cli/ops/runtime.rs15
-rw-r--r--cli/tests/integration_tests.rs34
-rw-r--r--cli/tests/unstable.js3
-rw-r--r--cli/tests/unstable.out1
-rw-r--r--cli/tests/unstable.ts1
-rw-r--r--cli/tests/unstable_disabled.out5
-rw-r--r--cli/tests/unstable_disabled_js.out1
-rw-r--r--cli/tests/unstable_enabled.out1
-rw-r--r--cli/tests/unstable_enabled_js.out1
-rw-r--r--std/examples/chat/server_test.ts9
-rw-r--r--std/fs/empty_dir_test.ts3
-rw-r--r--std/fs/exists_test.ts3
-rw-r--r--std/fs/expand_glob_test.ts2
-rw-r--r--std/http/file_server_test.ts19
-rw-r--r--std/http/racing_server_test.ts3
-rwxr-xr-xtools/benchmark.py2
-rwxr-xr-xtools/http_benchmark.py9
35 files changed, 1658 insertions, 1349 deletions
diff --git a/cli/build.rs b/cli/build.rs
index 2ea00a25d..5cf4b02e2 100644
--- a/cli/build.rs
+++ b/cli/build.rs
@@ -95,6 +95,10 @@ fn main() {
"lib.deno.ns.d.ts".to_string(),
c.join("js/lib.deno.ns.d.ts"),
);
+ custom_libs.insert(
+ "lib.deno.unstable.d.ts".to_string(),
+ c.join("js/lib.deno.unstable.d.ts"),
+ );
runtime_isolate.register_op(
"op_fetch_asset",
deno_typescript::op_fetch_asset(custom_libs),
diff --git a/cli/compilers/ts.rs b/cli/compilers/ts.rs
index 0560ad292..bad2be5b2 100644
--- a/cli/compilers/ts.rs
+++ b/cli/compilers/ts.rs
@@ -175,6 +175,7 @@ fn req(
out_file: Option<PathBuf>,
target: &str,
bundle: bool,
+ unstable: bool,
) -> Buf {
let j = match (compiler_config.path, compiler_config.content) {
(Some(config_path), Some(config_data)) => json!({
@@ -183,6 +184,7 @@ fn req(
"rootNames": root_names,
"outFile": out_file,
"bundle": bundle,
+ "unstable": unstable,
"configPath": config_path,
"config": str::from_utf8(&config_data).unwrap(),
}),
@@ -192,6 +194,7 @@ fn req(
"rootNames": root_names,
"outFile": out_file,
"bundle": bundle,
+ "unstable": unstable,
}),
};
@@ -290,6 +293,7 @@ impl TsCompiler {
out_file,
"main",
true,
+ global_state.flags.unstable,
);
let msg = execute_in_thread(global_state.clone(), req_msg).await?;
@@ -371,6 +375,7 @@ impl TsCompiler {
None,
target,
false,
+ global_state.flags.unstable,
);
let ts_compiler = self.clone();
@@ -655,6 +660,7 @@ pub fn runtime_compile<S: BuildHasher>(
"sources": sources,
"options": options,
"bundle": bundle,
+ "unstable": global_state.flags.unstable,
})
.to_string()
.into_boxed_str()
diff --git a/cli/flags.rs b/cli/flags.rs
index eac617c44..c1cc2c443 100644
--- a/cli/flags.rs
+++ b/cli/flags.rs
@@ -90,34 +90,33 @@ pub struct Flags {
pub argv: Vec<String>,
pub subcommand: DenoSubcommand,
- pub log_level: Option<Level>,
- pub version: bool,
- pub reload: bool,
- pub config_path: Option<String>,
- pub import_map_path: Option<String>,
- pub allow_read: bool,
- pub read_whitelist: Vec<PathBuf>,
- pub cache_blacklist: Vec<String>,
- pub allow_write: bool,
- pub write_whitelist: Vec<PathBuf>,
- pub allow_net: bool,
- pub net_whitelist: Vec<String>,
pub allow_env: bool,
- pub allow_run: bool,
- pub allow_plugin: bool,
pub allow_hrtime: bool,
- pub no_prompts: bool,
- pub no_remote: bool,
+ pub allow_net: bool,
+ pub allow_plugin: bool,
+ pub allow_read: bool,
+ pub allow_run: bool,
+ pub allow_write: bool,
+ pub cache_blacklist: Vec<String>,
+ pub ca_file: Option<String>,
pub cached_only: bool,
+ pub config_path: Option<String>,
+ pub import_map_path: Option<String>,
pub inspect: Option<SocketAddr>,
pub inspect_brk: Option<SocketAddr>,
- pub seed: Option<u64>,
- pub v8_flags: Option<Vec<String>>,
- pub unstable: bool,
-
pub lock: Option<String>,
pub lock_write: bool,
- pub ca_file: Option<String>,
+ pub log_level: Option<Level>,
+ pub net_whitelist: Vec<String>,
+ pub no_prompts: bool,
+ pub no_remote: bool,
+ pub read_whitelist: Vec<PathBuf>,
+ pub reload: bool,
+ pub seed: Option<u64>,
+ pub unstable: bool,
+ pub v8_flags: Option<Vec<String>>,
+ pub version: bool,
+ pub write_whitelist: Vec<PathBuf>,
}
fn join_paths(whitelist: &[PathBuf], d: &str) -> String {
@@ -330,7 +329,8 @@ If the flag is set, restrict these messages to errors.",
.after_help(ENV_VARIABLES_HELP)
}
-fn types_parse(flags: &mut Flags, _matches: &clap::ArgMatches) {
+fn types_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
+ unstable_arg_parse(flags, matches);
flags.subcommand = DenoSubcommand::Types;
}
@@ -348,6 +348,7 @@ fn fmt_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
fn install_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
permission_args_parse(flags, matches);
ca_file_arg_parse(flags, matches);
+ unstable_arg_parse(flags, matches);
let root = if matches.is_present("root") {
let install_root = matches.value_of("root").unwrap();
@@ -416,6 +417,7 @@ fn repl_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
v8_flags_arg_parse(flags, matches);
ca_file_arg_parse(flags, matches);
inspect_arg_parse(flags, matches);
+ unstable_arg_parse(flags, matches);
flags.subcommand = DenoSubcommand::Repl;
flags.allow_net = true;
flags.allow_env = true;
@@ -430,6 +432,7 @@ fn eval_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
v8_flags_arg_parse(flags, matches);
ca_file_arg_parse(flags, matches);
inspect_arg_parse(flags, matches);
+ unstable_arg_parse(flags, matches);
flags.allow_net = true;
flags.allow_env = true;
flags.allow_run = true;
@@ -447,6 +450,7 @@ fn eval_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
fn info_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
ca_file_arg_parse(flags, matches);
+ unstable_arg_parse(flags, matches);
flags.subcommand = DenoSubcommand::Info {
file: matches.value_of("file").map(|f| f.to_string()),
@@ -576,6 +580,8 @@ fn upgrade_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
fn doc_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
reload_arg_parse(flags, matches);
+ unstable_arg_parse(flags, matches);
+
let source_file = matches.value_of("source_file").map(String::from);
let json = matches.is_present("json");
let filter = matches.value_of("filter").map(String::from);
@@ -588,6 +594,7 @@ fn doc_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
fn types_subcommand<'a, 'b>() -> App<'a, 'b> {
SubCommand::with_name("types")
+ .arg(unstable_arg())
.about("Print runtime TypeScript declarations")
.long_about(
"Print runtime TypeScript declarations.
@@ -628,6 +635,7 @@ fn repl_subcommand<'a, 'b>() -> App<'a, 'b> {
.about("Read Eval Print Loop")
.arg(v8_flags_arg())
.arg(ca_file_arg())
+ .arg(unstable_arg())
}
fn install_subcommand<'a, 'b>() -> App<'a, 'b> {
@@ -656,6 +664,7 @@ fn install_subcommand<'a, 'b>() -> App<'a, 'b> {
.allow_hyphen_values(true)
)
.arg(ca_file_arg())
+ .arg(unstable_arg())
.about("Install script as an executable")
.long_about(
"Installs a script as an executable in the installation root's bin directory.
@@ -713,6 +722,7 @@ fn completions_subcommand<'a, 'b>() -> App<'a, 'b> {
fn eval_subcommand<'a, 'b>() -> App<'a, 'b> {
inspect_args(SubCommand::with_name("eval"))
.arg(ca_file_arg())
+ .arg(unstable_arg())
.about("Eval script")
.long_about(
"Evaluate JavaScript from the command line.
@@ -760,6 +770,7 @@ TypeScript compiler cache: Subdirectory containing TS compiler output.",
)
.arg(Arg::with_name("file").takes_value(true).required(false))
.arg(ca_file_arg())
+ .arg(unstable_arg())
}
fn cache_subcommand<'a, 'b>() -> App<'a, 'b> {
@@ -816,6 +827,7 @@ and is used to replace the current executable.",
fn doc_subcommand<'a, 'b>() -> App<'a, 'b> {
SubCommand::with_name("doc")
+ .arg(unstable_arg())
.about("Show documentation for a module")
.long_about(
"Show documentation for a module.
@@ -1648,6 +1660,19 @@ mod tests {
}
#[test]
+ fn types_unstable() {
+ let r = flags_from_vec_safe(svec!["deno", "types", "--unstable"]);
+ assert_eq!(
+ r.unwrap(),
+ Flags {
+ unstable: true,
+ subcommand: DenoSubcommand::Types,
+ ..Flags::default()
+ }
+ );
+ }
+
+ #[test]
fn cache() {
let r = flags_from_vec_safe(svec!["deno", "cache", "script.ts"]);
assert_eq!(
@@ -1662,6 +1687,22 @@ mod tests {
}
#[test]
+ fn cache_unstable() {
+ let r =
+ flags_from_vec_safe(svec!["deno", "cache", "--unstable", "script.ts"]);
+ assert_eq!(
+ r.unwrap(),
+ Flags {
+ unstable: true,
+ subcommand: DenoSubcommand::Cache {
+ files: svec!["script.ts"],
+ },
+ ..Flags::default()
+ }
+ );
+ }
+
+ #[test]
fn info() {
let r = flags_from_vec_safe(svec!["deno", "info", "script.ts"]);
assert_eq!(
@@ -1729,6 +1770,34 @@ mod tests {
}
#[test]
+ fn eval_unstable() {
+ let r = flags_from_vec_safe(svec![
+ "deno",
+ "eval",
+ "--unstable",
+ "'console.log(\"hello\")'"
+ ]);
+ assert_eq!(
+ r.unwrap(),
+ Flags {
+ unstable: true,
+ subcommand: DenoSubcommand::Eval {
+ code: "'console.log(\"hello\")'".to_string(),
+ as_typescript: false,
+ },
+ allow_net: true,
+ allow_env: true,
+ allow_run: true,
+ allow_read: true,
+ allow_write: true,
+ allow_plugin: true,
+ allow_hrtime: true,
+ ..Flags::default()
+ }
+ );
+ }
+
+ #[test]
fn eval_typescript() {
let r = flags_from_vec_safe(svec![
"deno",
@@ -1799,6 +1868,26 @@ mod tests {
}
#[test]
+ fn repl_unstable() {
+ let r = flags_from_vec_safe(svec!["deno", "repl", "--unstable"]);
+ assert_eq!(
+ r.unwrap(),
+ Flags {
+ unstable: true,
+ subcommand: DenoSubcommand::Repl,
+ allow_net: true,
+ allow_env: true,
+ allow_run: true,
+ allow_read: true,
+ allow_write: true,
+ allow_plugin: true,
+ allow_hrtime: true,
+ ..Flags::default()
+ }
+ );
+ }
+
+ #[test]
fn allow_read_whitelist() {
use tempfile::TempDir;
let temp_dir = TempDir::new().expect("tempdir fail").path().to_path_buf();
@@ -1918,6 +2007,23 @@ mod tests {
}
#[test]
+ fn bundle_unstable() {
+ let r =
+ flags_from_vec_safe(svec!["deno", "bundle", "--unstable", "source.ts"]);
+ assert_eq!(
+ r.unwrap(),
+ Flags {
+ unstable: true,
+ subcommand: DenoSubcommand::Bundle {
+ source_file: "source.ts".to_string(),
+ out_file: None,
+ },
+ ..Flags::default()
+ }
+ );
+ }
+
+ #[test]
fn bundle_with_output() {
let r =
flags_from_vec_safe(svec!["deno", "bundle", "source.ts", "bundle.js"]);
diff --git a/cli/js.rs b/cli/js.rs
index 6b4cb2eac..2985d2568 100644
--- a/cli/js.rs
+++ b/cli/js.rs
@@ -20,6 +20,7 @@ pub static DENO_NS_LIB: &str = include_str!("js/lib.deno.ns.d.ts");
pub static SHARED_GLOBALS_LIB: &str =
include_str!("js/lib.deno.shared_globals.d.ts");
pub static WINDOW_LIB: &str = include_str!("js/lib.deno.window.d.ts");
+pub static UNSTABLE_NS_LIB: &str = include_str!("js/lib.deno.unstable.d.ts");
#[test]
fn cli_snapshot() {
diff --git a/cli/js/compiler.ts b/cli/js/compiler.ts
index da9b62472..385b76eec 100644
--- a/cli/js/compiler.ts
+++ b/cli/js/compiler.ts
@@ -51,7 +51,8 @@ interface CompilerRequestCompile {
// options: ts.CompilerOptions;
configPath?: string;
config?: string;
- bundle?: boolean;
+ unstable: boolean;
+ bundle: boolean;
outFile?: string;
}
@@ -60,6 +61,7 @@ interface CompilerRequestRuntimeCompile {
target: CompilerHostTarget;
rootName: string;
sources?: Record<string, string>;
+ unstable?: boolean;
bundle?: boolean;
options?: string;
}
@@ -90,7 +92,15 @@ type RuntimeBundleResult = [undefined | DiagnosticItem[], string];
async function compile(
request: CompilerRequestCompile
): Promise<CompileResult> {
- const { bundle, config, configPath, outFile, rootNames, target } = request;
+ const {
+ bundle,
+ config,
+ configPath,
+ outFile,
+ rootNames,
+ target,
+ unstable,
+ } = request;
util.log(">>> compile start", {
rootNames,
type: CompilerRequestType[request.type],
@@ -116,6 +126,7 @@ async function compile(
bundle,
target,
writeFile,
+ unstable,
}));
let diagnostics: readonly ts.Diagnostic[] | undefined;
@@ -185,7 +196,7 @@ async function compile(
async function runtimeCompile(
request: CompilerRequestRuntimeCompile
): Promise<RuntimeCompileResult | RuntimeBundleResult> {
- const { rootName, sources, options, bundle, target } = request;
+ const { bundle, options, rootName, sources, target, unstable } = request;
util.log(">>> runtime compile start", {
rootName,
@@ -259,6 +270,14 @@ async function runtimeCompile(
if (convertedOptions) {
compilerOptions.push(convertedOptions);
}
+ if (unstable) {
+ compilerOptions.push({
+ lib: [
+ "deno.unstable",
+ ...((convertedOptions && convertedOptions.lib) || ["deno.window"]),
+ ],
+ });
+ }
if (bundle) {
compilerOptions.push(defaultBundlerOptions);
}
diff --git a/cli/js/compiler/bootstrap.ts b/cli/js/compiler/bootstrap.ts
index 63de783cf..5f9dfad92 100644
--- a/cli/js/compiler/bootstrap.ts
+++ b/cli/js/compiler/bootstrap.ts
@@ -20,6 +20,7 @@ ts.libMap.set("deno.ns", "lib.deno.ns.d.ts");
ts.libMap.set("deno.window", "lib.deno.window.d.ts");
ts.libMap.set("deno.worker", "lib.deno.worker.d.ts");
ts.libMap.set("deno.shared_globals", "lib.deno.shared_globals.d.ts");
+ts.libMap.set("deno.unstable", "lib.deno.unstable.d.ts");
// this pre-populates the cache at snapshot time of our library files, so they
// are available in the future when needed.
@@ -30,6 +31,7 @@ host.getSourceFile(
`${ASSETS}/lib.deno.shared_globals.d.ts`,
ts.ScriptTarget.ESNext
);
+host.getSourceFile(`${ASSETS}/lib.deno.unstable.d.ts`, ts.ScriptTarget.ESNext);
export const TS_SNAPSHOT_PROGRAM = ts.createProgram({
rootNames: [`${ASSETS}/bootstrap.ts`],
diff --git a/cli/js/compiler/host.ts b/cli/js/compiler/host.ts
index 70e712ffe..afe184d3e 100644
--- a/cli/js/compiler/host.ts
+++ b/cli/js/compiler/host.ts
@@ -14,9 +14,8 @@ export enum CompilerHostTarget {
export interface CompilerHostOptions {
bundle?: boolean;
-
target: CompilerHostTarget;
-
+ unstable?: boolean;
writeFile: WriteFileCallback;
}
@@ -146,13 +145,26 @@ export class Host implements ts.CompilerHost {
/* Deno specific APIs */
- constructor({ bundle = false, target, writeFile }: CompilerHostOptions) {
+ constructor({
+ bundle = false,
+ target,
+ unstable,
+ writeFile,
+ }: CompilerHostOptions) {
this.#target = target;
this.#writeFile = writeFile;
if (bundle) {
// options we need to change when we are generating a bundle
Object.assign(this.#options, defaultBundlerOptions);
}
+ if (unstable) {
+ this.#options.lib = [
+ target === CompilerHostTarget.Worker
+ ? "lib.deno.worker.d.ts"
+ : "lib.deno.window.d.ts",
+ "lib.deno.unstable.d.ts",
+ ];
+ }
}
configure(path: string, configurationText: string): ConfigureResponse {
diff --git a/cli/js/deno.ts b/cli/js/deno.ts
index 95db91f96..c60ebdae3 100644
--- a/cli/js/deno.ts
+++ b/cli/js/deno.ts
@@ -11,7 +11,6 @@ export {
export { build } from "./build.ts";
export { chmodSync, chmod } from "./ops/fs/chmod.ts";
export { chownSync, chown } from "./ops/fs/chown.ts";
-export { transpileOnly, compile, bundle } from "./compiler/api.ts";
export { customInspect, inspect } from "./web/console.ts";
export { copyFileSync, copyFile } from "./ops/fs/copy_file.ts";
export {
@@ -20,8 +19,7 @@ export {
DiagnosticItem,
DiagnosticMessageChain,
} from "./diagnostics.ts";
-export { chdir, cwd } from "./ops/fs/dir.ts";
-export { applySourceMap, formatDiagnostics } from "./ops/errors.ts";
+export { chdir } from "./ops/fs/dir.ts";
export { errors } from "./errors.ts";
export {
File,
@@ -51,7 +49,6 @@ export {
Closer,
Seeker,
} from "./io.ts";
-export { linkSync, link } from "./ops/fs/link.ts";
export {
makeTempDirSync,
makeTempDir,
@@ -61,34 +58,8 @@ export {
} from "./ops/fs/make_temp.ts";
export { metrics, Metrics } from "./ops/runtime.ts";
export { mkdirSync, mkdir, MkdirOptions } from "./ops/fs/mkdir.ts";
-export {
- connect,
- listen,
- listenDatagram,
- DatagramConn,
- Listener,
- Conn,
- ShutdownMode,
- shutdown,
-} from "./net.ts";
-export {
- dir,
- env,
- exit,
- execPath,
- hostname,
- loadavg,
- osRelease,
-} from "./ops/os.ts";
-export {
- permissions,
- PermissionName,
- PermissionState,
- PermissionStatus,
- Permissions,
-} from "./permissions.ts";
-export { openPlugin } from "./ops/plugins.ts";
-export { kill } from "./ops/process.ts";
+export { connect, listen, Listener, Conn } from "./net.ts";
+export { dir, env, exit, execPath, hostname } from "./ops/os.ts";
export { run, RunOptions, Process, ProcessStatus } from "./process.ts";
export { DirEntry, readDirSync, readDir } from "./ops/fs/read_dir.ts";
export { readFileSync, readFile } from "./read_file.ts";
@@ -98,14 +69,10 @@ export { realPathSync, realPath } from "./ops/fs/real_path.ts";
export { removeSync, remove, RemoveOptions } from "./ops/fs/remove.ts";
export { renameSync, rename } from "./ops/fs/rename.ts";
export { resources, close } from "./ops/resources.ts";
-export { signal, signals, Signal, SignalStream } from "./signals.ts";
export { FileInfo, statSync, lstatSync, stat, lstat } from "./ops/fs/stat.ts";
-export { symlinkSync, symlink } from "./ops/fs/symlink.ts";
-export { connectTls, listenTls, startTls } from "./tls.ts";
+export { connectTls, listenTls } from "./tls.ts";
export { truncateSync, truncate } from "./ops/fs/truncate.ts";
-export { isatty, setRaw } from "./ops/tty.ts";
-export { umask } from "./ops/fs/umask.ts";
-export { utimeSync, utime } from "./ops/fs/utime.ts";
+export { isatty } from "./ops/tty.ts";
export { version } from "./version.ts";
export { writeFileSync, writeFile, WriteFileOptions } from "./write_file.ts";
export { writeTextFileSync, writeTextFile } from "./write_text_file.ts";
diff --git a/cli/js/deno_unstable.ts b/cli/js/deno_unstable.ts
new file mode 100644
index 000000000..1f4baefdc
--- /dev/null
+++ b/cli/js/deno_unstable.ts
@@ -0,0 +1,26 @@
+// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+
+// This module exports unstable Deno APIs.
+
+export { umask } from "./ops/fs/umask.ts";
+export { linkSync, link } from "./ops/fs/link.ts";
+export { symlinkSync, symlink } from "./ops/fs/symlink.ts";
+export { dir, loadavg, osRelease } from "./ops/os.ts";
+export { openPlugin } from "./ops/plugins.ts";
+export { transpileOnly, compile, bundle } from "./compiler/api.ts";
+export { applySourceMap, formatDiagnostics } from "./ops/errors.ts";
+export { signal, signals, Signal, SignalStream } from "./signals.ts";
+export { setRaw } from "./ops/tty.ts";
+export { utimeSync, utime } from "./ops/fs/utime.ts";
+export { ShutdownMode, shutdown } from "./net.ts";
+export { listen, listenDatagram, connect } from "./net_unstable.ts";
+export { cwd } from "./ops/fs/dir.ts";
+export { startTls } from "./tls.ts";
+export { kill } from "./ops/process.ts";
+export {
+ permissions,
+ PermissionName,
+ PermissionState,
+ PermissionStatus,
+ Permissions,
+} from "./permissions.ts";
diff --git a/cli/js/globals_unstable.ts b/cli/js/globals_unstable.ts
new file mode 100644
index 000000000..872f135a3
--- /dev/null
+++ b/cli/js/globals_unstable.ts
@@ -0,0 +1,5 @@
+// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+
+export const unstableMethods = {};
+
+export const unstableProperties = {};
diff --git a/cli/js/lib.deno.ns.d.ts b/cli/js/lib.deno.ns.d.ts
index c1a175da4..f2c9fa4bb 100644
--- a/cli/js/lib.deno.ns.d.ts
+++ b/cli/js/lib.deno.ns.d.ts
@@ -75,21 +75,6 @@ declare namespace Deno {
* */
export function test(name: string, fn: () => void | Promise<void>): void;
- /** Returns an array containing the 1, 5, and 15 minute load averages. The
- * load average is a measure of CPU and IO utilization of the last one, five,
- * and 15 minute periods expressed as a fractional number. Zero means there
- * is no load. On Windows, the three values are always the same and represent
- * the current load, not the 1, 5 and 15 minute load averages.
- *
- * console.log(Deno.loadavg()); // e.g. [ 0.71, 0.44, 0.44 ]
- *
- * Requires `allow-env` permission.
- *
- * **Unstable** There are questions around which permission this needs. And
- * maybe should be renamed (loadAverage?)
- */
- export function loadavg(): number[];
-
/** Get the `hostname` of the machine the Deno process is running on.
*
* console.log(Deno.hostname());
@@ -98,17 +83,6 @@ declare namespace Deno {
*/
export function hostname(): string;
- /** Returns the release version of the Operating System.
- *
- * console.log(Deno.osRelease());
- *
- * Requires `allow-env` permission.
- *
- * **Unstable** new API maybe move to Deno.build or Deno.versions? Depends on
- * sys-info, which we don't necessarally want to depend on.
- */
- export function osRelease(): string;
-
/** Exit the Deno process with optional exit code. If no exit code is supplied
* then Deno will exit with return code of 0.
*
@@ -146,173 +120,6 @@ declare namespace Deno {
toObject(): { [index: string]: string };
};
- /** **UNSTABLE** */
- export type DirKind =
- | "home"
- | "cache"
- | "config"
- | "executable"
- | "data"
- | "data_local"
- | "audio"
- | "desktop"
- | "document"
- | "download"
- | "font"
- | "picture"
- | "public"
- | "template"
- | "tmp"
- | "video";
-
- /**
- * **UNSTABLE**: Currently under evaluation to decide if method name `dir` and
- * parameter type alias name `DirKind` should be renamed.
- *
- * Returns the user and platform specific directories.
- *
- * const homeDirectory = Deno.dir("home");
- *
- * Requires `allow-env` permission.
- *
- * Returns `null` if there is no applicable directory or if any other error
- * occurs.
- *
- * Argument values: `"home"`, `"cache"`, `"config"`, `"executable"`, `"data"`,
- * `"data_local"`, `"audio"`, `"desktop"`, `"document"`, `"download"`,
- * `"font"`, `"picture"`, `"public"`, `"template"`, `"tmp"`, `"video"`
- *
- * `"home"`
- *
- * |Platform | Value | Example |
- * | ------- | -----------------------------------------| -----------------------|
- * | Linux | `$HOME` | /home/alice |
- * | macOS | `$HOME` | /Users/alice |
- * | Windows | `{FOLDERID_Profile}` | C:\Users\Alice |
- *
- * `"cache"`
- *
- * |Platform | Value | Example |
- * | ------- | ----------------------------------- | ---------------------------- |
- * | Linux | `$XDG_CACHE_HOME` or `$HOME`/.cache | /home/alice/.cache |
- * | macOS | `$HOME`/Library/Caches | /Users/Alice/Library/Caches |
- * | Windows | `{FOLDERID_LocalAppData}` | C:\Users\Alice\AppData\Local |
- *
- * `"config"`
- *
- * |Platform | Value | Example |
- * | ------- | ------------------------------------- | -------------------------------- |
- * | Linux | `$XDG_CONFIG_HOME` or `$HOME`/.config | /home/alice/.config |
- * | macOS | `$HOME`/Library/Preferences | /Users/Alice/Library/Preferences |
- * | Windows | `{FOLDERID_RoamingAppData}` | C:\Users\Alice\AppData\Roaming |
- *
- * `"executable"`
- *
- * |Platform | Value | Example |
- * | ------- | --------------------------------------------------------------- | -----------------------|
- * | Linux | `XDG_BIN_HOME` or `$XDG_DATA_HOME`/../bin or `$HOME`/.local/bin | /home/alice/.local/bin |
- * | macOS | - | - |
- * | Windows | - | - |
- *
- * `"data"`
- *
- * |Platform | Value | Example |
- * | ------- | ---------------------------------------- | ---------------------------------------- |
- * | Linux | `$XDG_DATA_HOME` or `$HOME`/.local/share | /home/alice/.local/share |
- * | macOS | `$HOME`/Library/Application Support | /Users/Alice/Library/Application Support |
- * | Windows | `{FOLDERID_RoamingAppData}` | C:\Users\Alice\AppData\Roaming |
- *
- * `"data_local"`
- *
- * |Platform | Value | Example |
- * | ------- | ---------------------------------------- | ---------------------------------------- |
- * | Linux | `$XDG_DATA_HOME` or `$HOME`/.local/share | /home/alice/.local/share |
- * | macOS | `$HOME`/Library/Application Support | /Users/Alice/Library/Application Support |
- * | Windows | `{FOLDERID_LocalAppData}` | C:\Users\Alice\AppData\Local |
- *
- * `"audio"`
- *
- * |Platform | Value | Example |
- * | ------- | ------------------ | -------------------- |
- * | Linux | `XDG_MUSIC_DIR` | /home/alice/Music |
- * | macOS | `$HOME`/Music | /Users/Alice/Music |
- * | Windows | `{FOLDERID_Music}` | C:\Users\Alice\Music |
- *
- * `"desktop"`
- *
- * |Platform | Value | Example |
- * | ------- | -------------------- | ---------------------- |
- * | Linux | `XDG_DESKTOP_DIR` | /home/alice/Desktop |
- * | macOS | `$HOME`/Desktop | /Users/Alice/Desktop |
- * | Windows | `{FOLDERID_Desktop}` | C:\Users\Alice\Desktop |
- *
- * `"document"`
- *
- * |Platform | Value | Example |
- * | ------- | ---------------------- | ------------------------ |
- * | Linux | `XDG_DOCUMENTS_DIR` | /home/alice/Documents |
- * | macOS | `$HOME`/Documents | /Users/Alice/Documents |
- * | Windows | `{FOLDERID_Documents}` | C:\Users\Alice\Documents |
- *
- * `"download"`
- *
- * |Platform | Value | Example |
- * | ------- | ---------------------- | ------------------------ |
- * | Linux | `XDG_DOWNLOAD_DIR` | /home/alice/Downloads |
- * | macOS | `$HOME`/Downloads | /Users/Alice/Downloads |
- * | Windows | `{FOLDERID_Downloads}` | C:\Users\Alice\Downloads |
- *
- * `"font"`
- *
- * |Platform | Value | Example |
- * | ------- | ---------------------------------------------------- | ------------------------------ |
- * | Linux | `$XDG_DATA_HOME`/fonts or `$HOME`/.local/share/fonts | /home/alice/.local/share/fonts |
- * | macOS | `$HOME/Library/Fonts` | /Users/Alice/Library/Fonts |
- * | Windows | – | – |
- *
- * `"picture"`
- *
- * |Platform | Value | Example |
- * | ------- | --------------------- | ----------------------- |
- * | Linux | `XDG_PICTURES_DIR` | /home/alice/Pictures |
- * | macOS | `$HOME`/Pictures | /Users/Alice/Pictures |
- * | Windows | `{FOLDERID_Pictures}` | C:\Users\Alice\Pictures |
- *
- * `"public"`
- *
- * |Platform | Value | Example |
- * | ------- | --------------------- | ------------------- |
- * | Linux | `XDG_PUBLICSHARE_DIR` | /home/alice/Public |
- * | macOS | `$HOME`/Public | /Users/Alice/Public |
- * | Windows | `{FOLDERID_Public}` | C:\Users\Public |
- *
- * `"template"`
- *
- * |Platform | Value | Example |
- * | ------- | ---------------------- | ---------------------------------------------------------- |
- * | Linux | `XDG_TEMPLATES_DIR` | /home/alice/Templates |
- * | macOS | – | – |
- * | Windows | `{FOLDERID_Templates}` | C:\Users\Alice\AppData\Roaming\Microsoft\Windows\Templates |
- *
- * `"tmp"`
- *
- * |Platform | Value | Example |
- * | ------- | ---------------------- | ---------------------------------------------------------- |
- * | Linux | `TMPDIR` | /tmp |
- * | macOS | `TMPDIR` | /tmp |
- * | Windows | `{TMP}` | C:\Users\Alice\AppData\Local\Temp |
- *
- * `"video"`
- *
- * |Platform | Value | Example |
- * | ------- | ------------------- | --------------------- |
- * | Linux | `XDG_VIDEOS_DIR` | /home/alice/Videos |
- * | macOS | `$HOME`/Movies | /Users/Alice/Movies |
- * | Windows | `{FOLDERID_Videos}` | C:\Users\Alice\Videos |
- *
- */
- export function dir(kind: DirKind): string | null;
-
/**
* Returns the path to the current deno executable.
*
@@ -323,21 +130,6 @@ declare namespace Deno {
export function execPath(): string;
/**
- * **UNSTABLE**: Currently under evaluation to decide if explicit permission is
- * required to get the value of the current working directory.
- *
- * Return a string representing the current working directory.
- *
- * If the current directory can be reached via multiple paths (due to symbolic
- * links), `cwd()` may return any one of them.
- *
- * const currentWorkingDirectory = Deno.cwd();
- *
- * Throws `Deno.errors.NotFound` if directory not available.
- */
- export function cwd(): string;
-
- /**
* Change the current working directory to the specified path.
*
* Deno.chdir("/home/userA");
@@ -352,21 +144,6 @@ declare namespace Deno {
*/
export function chdir(directory: string): void;
- /**
- * **UNSTABLE**: New API, yet to be vetted. This API is under consideration to
- * determine if permissions are required to call it.
- *
- * Retrieve the process umask. If `mask` is provided, sets the process umask.
- * This call always returns what the umask was before the call.
- *
- * console.log(Deno.umask()); // e.g. 18 (0o022)
- * const prevUmaskValue = Deno.umask(0o077); // e.g. 18 (0o022)
- * console.log(Deno.umask()); // e.g. 63 (0o077)
- *
- * NOTE: This API is not implemented on Windows
- */
- export function umask(mask?: number): number;
-
export enum SeekMode {
Start = 0,
Current = 1,
@@ -811,18 +588,6 @@ declare namespace Deno {
*/
export function isatty(rid: number): boolean;
- /** **UNSTABLE**: new API, yet to be vetted
- *
- * Set TTY to be under raw mode or not. In raw mode, characters are read and
- * returned as is, without being processed. All special processing of
- * characters by the terminal is disabled, including echoing input characters.
- * Reading from a TTY device in raw mode is faster than reading from a TTY
- * device in canonical mode.
- *
- * Deno.setRaw(myTTY.rid, true);
- */
- export function setRaw(rid: number, mode: boolean): void;
-
/** A variable-sized buffer of bytes with `read()` and `write()` methods.
*
* Deno.Buffer is almost always used with some I/O like files and sockets. It
@@ -1168,36 +933,6 @@ declare namespace Deno {
*/
export function chown(path: string, uid: number, gid: number): Promise<void>;
- /** **UNSTABLE**: needs investigation into high precision time.
- *
- * Synchronously changes the access (`atime`) and modification (`mtime`) times
- * of a file system object referenced by `path`. Given times are either in
- * seconds (UNIX epoch time) or as `Date` objects.
- *
- * Deno.utimeSync("myfile.txt", 1556495550, new Date());
- *
- * Requires `allow-write` permission. */
- export function utimeSync(
- path: string,
- atime: number | Date,
- mtime: number | Date
- ): void;
-
- /** **UNSTABLE**: needs investigation into high precision time.
- *
- * Changes the access (`atime`) and modification (`mtime`) times of a file
- * system object referenced by `path`. Given times are either in seconds
- * (UNIX epoch time) or as `Date` objects.
- *
- * await Deno.utime("myfile.txt", 1556495550, new Date());
- *
- * Requires `allow-write` permission. */
- export function utime(
- path: string,
- atime: number | Date,
- mtime: number | Date
- ): Promise<void>;
-
export interface RemoveOptions {
/** Defaults to `false`. If set to `true`, path will be removed even if
* it's a non-empty directory. */
@@ -1495,62 +1230,6 @@ declare namespace Deno {
* Requires `allow-read` permission. */
export function statSync(path: string): FileInfo;
- /** Synchronously creates `newpath` as a hard link to `oldpath`.
- *
- * Deno.linkSync("old/name", "new/name");
- *
- * Requires `allow-read` and `allow-write` permissions. */
- export function linkSync(oldpath: string, newpath: string): void;
-
- /** Creates `newpath` as a hard link to `oldpath`.
- *
- * **UNSTABLE**: needs security review.
- *
- * await Deno.link("old/name", "new/name");
- *
- * Requires `allow-read` and `allow-write` permissions. */
- export function link(oldpath: string, newpath: string): Promise<void>;
-
- /** **UNSTABLE**: `type` argument type may be changed to `"dir" | "file"`.
- *
- * **UNSTABLE**: needs security review.
- *
- * Creates `newpath` as a symbolic link to `oldpath`.
- *
- * The type argument can be set to `dir` or `file`. This argument is only
- * available on Windows and ignored on other platforms.
- *
- * NOTE: This function is not yet implemented on Windows.
- *
- * Deno.symlinkSync("old/name", "new/name");
- *
- * Requires `allow-read` and `allow-write` permissions. */
- export function symlinkSync(
- oldpath: string,
- newpath: string,
- type?: string
- ): void;
-
- /** **UNSTABLE**: `type` argument may be changed to `"dir" | "file"`
- *
- * **UNSTABLE**: needs security review.
- *
- * Creates `newpath` as a symbolic link to `oldpath`.
- *
- * The type argument can be set to `dir` or `file`. This argument is only
- * available on Windows and ignored on other platforms.
- *
- * NOTE: This function is not yet implemented on Windows.
- *
- * await Deno.symlink("old/name", "new/name");
- *
- * Requires `allow-read` and `allow-write` permissions. */
- export function symlink(
- oldpath: string,
- newpath: string,
- type?: string
- ): Promise<void>;
-
/** Options for writing to a file. */
export interface WriteFileOptions {
/** Defaults to `false`. If set to `true`, will append to a file instead of
@@ -1618,42 +1297,6 @@ declare namespace Deno {
*/
export function writeTextFile(path: string, data: string): Promise<void>;
- /** **UNSTABLE**: Should not have same name as `window.location` type. */
- interface Location {
- /** The full url for the module, e.g. `file://some/file.ts` or
- * `https://some/file.ts`. */
- fileName: string;
- /** The line number in the file. It is assumed to be 1-indexed. */
- lineNumber: number;
- /** The column number in the file. It is assumed to be 1-indexed. */
- columnNumber: number;
- }
-
- /** UNSTABLE: new API, yet to be vetted.
- *
- * Given a current location in a module, lookup the source location and return
- * it.
- *
- * When Deno transpiles code, it keep source maps of the transpiled code. This
- * function can be used to lookup the original location. This is
- * automatically done when accessing the `.stack` of an error, or when an
- * uncaught error is logged. This function can be used to perform the lookup
- * for creating better error handling.
- *
- * **Note:** `line` and `column` are 1 indexed, which matches display
- * expectations, but is not typical of most index numbers in Deno.
- *
- * An example:
- *
- * const orig = Deno.applySourceMap({
- * fileName: "file://my/module.ts",
- * lineNumber: 5,
- * columnNumber: 15
- * });
- * console.log(`${orig.filename}:${orig.line}:${orig.column}`);
- */
- export function applySourceMap(location: Location): Location;
-
/** A set of error constructors that are raised by Deno APIs. */
export const errors: {
NotFound: ErrorConstructor;
@@ -1676,110 +1319,6 @@ declare namespace Deno {
Busy: ErrorConstructor;
};
- /** The name of a "powerful feature" which needs permission.
- *
- * See: https://w3c.github.io/permissions/#permission-registry
- *
- * Note that the definition of `PermissionName` in the above spec is swapped
- * out for a set of Deno permissions which are not web-compatible. */
- export type PermissionName =
- | "run"
- | "read"
- | "write"
- | "net"
- | "env"
- | "plugin"
- | "hrtime";
-
- /** The current status of the permission.
- *
- * See: https://w3c.github.io/permissions/#status-of-a-permission */
- export type PermissionState = "granted" | "denied" | "prompt";
-
- export interface RunPermissionDescriptor {
- name: "run";
- }
-
- export interface ReadPermissionDescriptor {
- name: "read";
- path?: string;
- }
-
- export interface WritePermissionDescriptor {
- name: "write";
- path?: string;
- }
-
- export interface NetPermissionDescriptor {
- name: "net";
- url?: string;
- }
-
- export interface EnvPermissionDescriptor {
- name: "env";
- }
-
- export interface PluginPermissionDescriptor {
- name: "plugin";
- }
-
- export interface HrtimePermissionDescriptor {
- name: "hrtime";
- }
-
- /** Permission descriptors which define a permission and can be queried,
- * requested, or revoked.
- *
- * See: https://w3c.github.io/permissions/#permission-descriptor */
- export type PermissionDescriptor =
- | RunPermissionDescriptor
- | ReadPermissionDescriptor
- | WritePermissionDescriptor
- | NetPermissionDescriptor
- | EnvPermissionDescriptor
- | PluginPermissionDescriptor
- | HrtimePermissionDescriptor;
-
- export class Permissions {
- /** Resolves to the current status of a permission.
- *
- * const status = await Deno.permissions.query({ name: "read", path: "/etc" });
- * if (status.state === "granted") {
- * data = await Deno.readFile("/etc/passwd");
- * }
- */
- query(desc: PermissionDescriptor): Promise<PermissionStatus>;
-
- /** Revokes a permission, and resolves to the state of the permission.
- *
- * const status = await Deno.permissions.revoke({ name: "run" });
- * assert(status.state !== "granted")
- */
- revoke(desc: PermissionDescriptor): Promise<PermissionStatus>;
-
- /** Requests the permission, and resolves to the state of the permission.
- *
- * const status = await Deno.permissions.request({ name: "env" });
- * if (status.state === "granted") {
- * console.log(Deno.homeDir());
- * } else {
- * console.log("'env' permission is denied.");
- * }
- */
- request(desc: PermissionDescriptor): Promise<PermissionStatus>;
- }
-
- /** **UNSTABLE**: maybe move to `navigator.permissions` to match web API. It
- * could look like `navigator.permissions.query({ name: Deno.symbols.read })`.
- */
- export const permissions: Permissions;
-
- /** see: https://w3c.github.io/permissions/#permissionstatus */
- export class PermissionStatus {
- state: PermissionState;
- constructor(state: PermissionState);
- }
-
/** Synchronously truncates or extends the specified file, to reach the
* specified `len`. If `len` is not specified then the entire file contents
* are truncated.
@@ -1813,23 +1352,6 @@ declare namespace Deno {
* Requires `allow-write` permission. */
export function truncate(name: string, len?: number): Promise<void>;
- /** **UNSTABLE**: new API, yet to be vetted.
- *
- * Open and initalize a plugin.
- *
- * const rid = Deno.openPlugin("./path/to/some/plugin.so");
- * const opId = Deno.core.ops()["some_op"];
- * const response = Deno.core.dispatch(opId, new Uint8Array([1,2,3,4]));
- * console.log(`Response from plugin ${response}`);
- *
- * Requires `allow-plugin` permission.
- *
- * The plugin system is not stable and will change in the future, hence the
- * lack of docs. For now take a look at the example
- * https://github.com/denoland/deno/tree/master/test_plugin
- */
- export function openPlugin(filename: string): number;
-
export interface NetAddr {
transport: "tcp" | "udp";
hostname: string;
@@ -1842,51 +1364,6 @@ declare namespace Deno {
}
export type Addr = NetAddr | UnixAddr;
- /** **UNSTABLE**: Maybe remove `ShutdownMode` entirely.
- *
- * Corresponds to `SHUT_RD`, `SHUT_WR`, `SHUT_RDWR` on POSIX-like systems.
- *
- * See: http://man7.org/linux/man-pages/man2/shutdown.2.html */
- export enum ShutdownMode {
- Read = 0,
- Write,
- ReadWrite, // TODO(ry) panics on ReadWrite.
- }
-
- /** **UNSTABLE**: Both the `how` parameter and `ShutdownMode` enum are under
- * consideration for removal.
- *
- * Shutdown socket send and receive operations.
- *
- * Matches behavior of POSIX shutdown(3).
- *
- * const listener = Deno.listen({ port: 80 });
- * const conn = await listener.accept();
- * Deno.shutdown(conn.rid, Deno.ShutdownMode.Write);
- */
- export function shutdown(rid: number, how: ShutdownMode): Promise<void>;
-
- /** **UNSTABLE**: new API, yet to be vetted.
- *
- * A generic transport listener for message-oriented protocols. */
- export interface DatagramConn extends AsyncIterable<[Uint8Array, Addr]> {
- /** **UNSTABLE**: new API, yet to be vetted.
- *
- * Waits for and resolves to the next message to the `UDPConn`. */
- receive(p?: Uint8Array): Promise<[Uint8Array, Addr]>;
- /** UNSTABLE: new API, yet to be vetted.
- *
- * Sends a message to the target. */
- send(p: Uint8Array, addr: Addr): Promise<void>;
- /** UNSTABLE: new API, yet to be vetted.
- *
- * Close closes the socket. Any pending message promises will be rejected
- * with errors. */
- close(): void;
- /** Return the address of the `UDPConn`. */
- readonly addr: Addr;
- [Symbol.asyncIterator](): AsyncIterableIterator<[Uint8Array, Addr]>;
- }
/** A generic network listener for stream-oriented protocols. */
export interface Listener extends AsyncIterable<Conn> {
@@ -1925,10 +1402,6 @@ declare namespace Deno {
hostname?: string;
}
- export interface UnixListenOptions {
- /** A Path to the Unix Socket. */
- path: string;
- }
/** Listen announces on the local transport address.
*
* const listener1 = Deno.listen({ port: 80 })
@@ -1940,47 +1413,6 @@ declare namespace Deno {
export function listen(
options: ListenOptions & { transport?: "tcp" }
): Listener;
- /** Listen announces on the local transport address.
- *
- * const listener = Deno.listen({ path: "/foo/bar.sock", transport: "unix" })
- *
- * Requires `allow-read` and `allow-write` permission. */
- export function listen(
- options: UnixListenOptions & { transport: "unix" }
- ): Listener;
-
- /** **UNSTABLE**: new API
- *
- * Listen announces on the local transport address.
- *
- * const listener1 = Deno.listenDatagram({
- * port: 80,
- * transport: "udp"
- * });
- * const listener2 = Deno.listenDatagram({
- * hostname: "golang.org",
- * port: 80,
- * transport: "udp"
- * });
- *
- * Requires `allow-net` permission. */
- export function listenDatagram(
- options: ListenOptions & { transport: "udp" }
- ): DatagramConn;
-
- /** **UNSTABLE**: new API
- *
- * Listen announces on the local transport address.
- *
- * const listener = Deno.listenDatagram({
- * address: "/foo/bar.sock",
- * transport: "unixpacket"
- * });
- *
- * Requires `allow-read` and `allow-write` permission. */
- export function listenDatagram(
- options: UnixListenOptions & { transport: "unixpacket" }
- ): DatagramConn;
export interface ListenTlsOptions extends ListenOptions {
/** Server certificate file. */
@@ -2008,11 +1440,6 @@ declare namespace Deno {
transport?: "tcp";
}
- export interface UnixConnectOptions {
- transport: "unix";
- path: string;
- }
-
/**
* Connects to the hostname (default is "127.0.0.1") and port on the named
* transport (default is "tcp"), and resolves to the connection (`Conn`).
@@ -2024,9 +1451,7 @@ declare namespace Deno {
* const conn5 = await Deno.connect({ path: "/foo/bar.sock", transport: "unix" });
*
* Requires `allow-net` permission for "tcp" and `allow-read` for unix. */
- export function connect(
- options: ConnectOptions | UnixConnectOptions
- ): Promise<Conn>;
+ export function connect(options: ConnectOptions): Promise<Conn>;
export interface ConnectTlsOptions {
/** The port to connect to. */
@@ -2052,33 +1477,6 @@ declare namespace Deno {
*/
export function connectTls(options: ConnectTlsOptions): Promise<Conn>;
- export interface StartTlsOptions {
- /** A literal IP address or host name that can be resolved to an IP address.
- * If not specified, defaults to `127.0.0.1`. */
- hostname?: string;
- /** Server certificate file. */
- certFile?: string;
- }
-
- /** **UNSTABLE**: new API, yet to be vetted.
- *
- * Start TLS handshake from an existing connection using
- * an optional cert file, hostname (default is "127.0.0.1"). The
- * cert file is optional and if not included Mozilla's root certificates will
- * be used (see also https://github.com/ctz/webpki-roots for specifics)
- * Using this function requires that the other end of the connection is
- * prepared for TLS handshake.
- *
- * const conn = await Deno.connect({ port: 80, hostname: "127.0.0.1" });
- * const tlsConn = await Deno.startTls(conn, { certFile: "./certs/my_custom_root_CA.pem", hostname: "127.0.0.1", port: 80 });
- *
- * Requires `allow-net` permission.
- */
- export function startTls(
- conn: Conn,
- options?: StartTlsOptions
- ): Promise<Conn>;
-
export interface Metrics {
opsDispatched: number;
opsDispatchedSync: number;
@@ -2171,28 +1569,6 @@ declare namespace Deno {
* the stream to `/dev/null`. */
type ProcessStdio = "inherit" | "piped" | "null";
- /** **UNSTABLE**: The `signo` argument may change to require the Deno.Signal
- * enum.
- *
- * Send a signal to process under given `pid`. This functionality currently
- * only works on Linux and Mac OS.
- *
- * If `pid` is negative, the signal will be sent to the process group
- * identified by `pid`.
- *
- * const p = Deno.run({
- * cmd: ["python", "-c", "from time import sleep; sleep(10000)"]
- * });
- *
- * Deno.kill(p.pid, Deno.Signal.SIGINT);
- *
- * Throws Error (not yet implemented) on Windows
- *
- * Requires `allow-run` permission. */
- export function kill(pid: number, signo: number): void;
-
- /** **UNSTABLE**: There are some issues to work out with respect to when and
- * how the process should be closed. */
export class Process {
readonly rid: number;
readonly pid: number;
@@ -2271,78 +1647,6 @@ declare namespace Deno {
* Requires `allow-run` permission. */
export function run(opt: RunOptions): Process;
- enum LinuxSignal {
- SIGHUP = 1,
- SIGINT = 2,
- SIGQUIT = 3,
- SIGILL = 4,
- SIGTRAP = 5,
- SIGABRT = 6,
- SIGBUS = 7,
- SIGFPE = 8,
- SIGKILL = 9,
- SIGUSR1 = 10,
- SIGSEGV = 11,
- SIGUSR2 = 12,
- SIGPIPE = 13,
- SIGALRM = 14,
- SIGTERM = 15,
- SIGSTKFLT = 16,
- SIGCHLD = 17,
- SIGCONT = 18,
- SIGSTOP = 19,
- SIGTSTP = 20,
- SIGTTIN = 21,
- SIGTTOU = 22,
- SIGURG = 23,
- SIGXCPU = 24,
- SIGXFSZ = 25,
- SIGVTALRM = 26,
- SIGPROF = 27,
- SIGWINCH = 28,
- SIGIO = 29,
- SIGPWR = 30,
- SIGSYS = 31,
- }
- enum MacOSSignal {
- SIGHUP = 1,
- SIGINT = 2,
- SIGQUIT = 3,
- SIGILL = 4,
- SIGTRAP = 5,
- SIGABRT = 6,
- SIGEMT = 7,
- SIGFPE = 8,
- SIGKILL = 9,
- SIGBUS = 10,
- SIGSEGV = 11,
- SIGSYS = 12,
- SIGPIPE = 13,
- SIGALRM = 14,
- SIGTERM = 15,
- SIGURG = 16,
- SIGSTOP = 17,
- SIGTSTP = 18,
- SIGCONT = 19,
- SIGCHLD = 20,
- SIGTTIN = 21,
- SIGTTOU = 22,
- SIGIO = 23,
- SIGXCPU = 24,
- SIGXFSZ = 25,
- SIGVTALRM = 26,
- SIGPROF = 27,
- SIGWINCH = 28,
- SIGINFO = 29,
- SIGUSR1 = 30,
- SIGUSR2 = 31,
- }
-
- /** **UNSTABLE**: make platform independent.
- *
- * Signals numbers. This is platform dependent. */
- export const Signal: typeof MacOSSignal | typeof LinuxSignal;
-
interface InspectOptions {
depth?: number;
}
@@ -2399,385 +1703,6 @@ declare namespace Deno {
/** Version related information. */
export const version: Version;
- /** The log category for a diagnostic message. */
- export enum DiagnosticCategory {
- Log = 0,
- Debug = 1,
- Info = 2,
- Error = 3,
- Warning = 4,
- Suggestion = 5,
- }
-
- export interface DiagnosticMessageChain {
- message: string;
- category: DiagnosticCategory;
- code: number;
- next?: DiagnosticMessageChain[];
- }
-
- export interface DiagnosticItem {
- /** A string message summarizing the diagnostic. */
- message: string;
- /** An ordered array of further diagnostics. */
- messageChain?: DiagnosticMessageChain;
- /** Information related to the diagnostic. This is present when there is a
- * suggestion or other additional diagnostic information */
- relatedInformation?: DiagnosticItem[];
- /** The text of the source line related to the diagnostic. */
- sourceLine?: string;
- /** The line number that is related to the diagnostic. */
- lineNumber?: number;
- /** The name of the script resource related to the diagnostic. */
- scriptResourceName?: string;
- /** The start position related to the diagnostic. */
- startPosition?: number;
- /** The end position related to the diagnostic. */
- endPosition?: number;
- /** The category of the diagnostic. */
- category: DiagnosticCategory;
- /** A number identifier. */
- code: number;
- /** The the start column of the sourceLine related to the diagnostic. */
- startColumn?: number;
- /** The end column of the sourceLine related to the diagnostic. */
- endColumn?: number;
- }
-
- export interface Diagnostic {
- /** An array of diagnostic items. */
- items: DiagnosticItem[];
- }
-
- /** **UNSTABLE**: new API, yet to be vetted.
- *
- * Format an array of diagnostic items and return them as a single string in a
- * user friendly format.
- *
- * const [diagnostics, result] = Deno.compile("file_with_compile_issues.ts");
- * console.table(diagnostics); // Prints raw diagnostic data
- * console.log(Deno.formatDiagnostics(diagnostics)); // User friendly output of diagnostics
- *
- * @param items An array of diagnostic items to format
- */
- export function formatDiagnostics(items: DiagnosticItem[]): string;
-
- /** **UNSTABLE**: new API, yet to be vetted.
- *
- * A specific subset TypeScript compiler options that can be supported by the
- * Deno TypeScript compiler. */
- export interface CompilerOptions {
- /** Allow JavaScript files to be compiled. Defaults to `true`. */
- allowJs?: boolean;
- /** Allow default imports from modules with no default export. This does not
- * affect code emit, just typechecking. Defaults to `false`. */
- allowSyntheticDefaultImports?: boolean;
- /** Allow accessing UMD globals from modules. Defaults to `false`. */
- allowUmdGlobalAccess?: boolean;
- /** Do not report errors on unreachable code. Defaults to `false`. */
- allowUnreachableCode?: boolean;
- /** Do not report errors on unused labels. Defaults to `false` */
- allowUnusedLabels?: boolean;
- /** Parse in strict mode and emit `"use strict"` for each source file.
- * Defaults to `true`. */
- alwaysStrict?: boolean;
- /** Base directory to resolve non-relative module names. Defaults to
- * `undefined`. */
- baseUrl?: string;
- /** Report errors in `.js` files. Use in conjunction with `allowJs`. Defaults
- * to `false`. */
- checkJs?: boolean;
- /** Generates corresponding `.d.ts` file. Defaults to `false`. */
- declaration?: boolean;
- /** Output directory for generated declaration files. */
- declarationDir?: string;
- /** Generates a source map for each corresponding `.d.ts` file. Defaults to
- * `false`. */
- declarationMap?: boolean;
- /** Provide full support for iterables in `for..of`, spread and
- * destructuring when targeting ES5 or ES3. Defaults to `false`. */
- downlevelIteration?: boolean;
- /** Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.
- * Defaults to `false`. */
- emitBOM?: boolean;
- /** Only emit `.d.ts` declaration files. Defaults to `false`. */
- emitDeclarationOnly?: boolean;
- /** Emit design-type metadata for decorated declarations in source. See issue
- * [microsoft/TypeScript#2577](https://github.com/Microsoft/TypeScript/issues/2577)
- * for details. Defaults to `false`. */
- emitDecoratorMetadata?: boolean;
- /** Emit `__importStar` and `__importDefault` helpers for runtime babel
- * ecosystem compatibility and enable `allowSyntheticDefaultImports` for type
- * system compatibility. Defaults to `true`. */
- esModuleInterop?: boolean;
- /** Enables experimental support for ES decorators. Defaults to `false`. */
- experimentalDecorators?: boolean;
- /** Emit a single file with source maps instead of having a separate file.
- * Defaults to `false`. */
- inlineSourceMap?: boolean;
- /** Emit the source alongside the source maps within a single file; requires
- * `inlineSourceMap` or `sourceMap` to be set. Defaults to `false`. */
- inlineSources?: boolean;
- /** Perform additional checks to ensure that transpile only would be safe.
- * Defaults to `false`. */
- isolatedModules?: boolean;
- /** Support JSX in `.tsx` files: `"react"`, `"preserve"`, `"react-native"`.
- * Defaults to `"react"`. */
- jsx?: "react" | "preserve" | "react-native";
- /** Specify the JSX factory function to use when targeting react JSX emit,
- * e.g. `React.createElement` or `h`. Defaults to `React.createElement`. */
- jsxFactory?: string;
- /** Resolve keyof to string valued property names only (no numbers or
- * symbols). Defaults to `false`. */
- keyofStringsOnly?: string;
- /** Emit class fields with ECMAScript-standard semantics. Defaults to `false`.
- * Does not apply to `"esnext"` target. */
- useDefineForClassFields?: boolean;
- /** List of library files to be included in the compilation. If omitted,
- * then the Deno main runtime libs are used. */
- lib?: string[];
- /** The locale to use to show error messages. */
- locale?: string;
- /** Specifies the location where debugger should locate map files instead of
- * generated locations. Use this flag if the `.map` files will be located at
- * run-time in a different location than the `.js` files. The location
- * specified will be embedded in the source map to direct the debugger where
- * the map files will be located. Defaults to `undefined`. */
- mapRoot?: string;
- /** Specify the module format for the emitted code. Defaults to
- * `"esnext"`. */
- module?:
- | "none"
- | "commonjs"
- | "amd"
- | "system"
- | "umd"
- | "es6"
- | "es2015"
- | "esnext";
- /** Do not generate custom helper functions like `__extends` in compiled
- * output. Defaults to `false`. */
- noEmitHelpers?: boolean;
- /** Report errors for fallthrough cases in switch statement. Defaults to
- * `false`. */
- noFallthroughCasesInSwitch?: boolean;
- /** Raise error on expressions and declarations with an implied any type.
- * Defaults to `true`. */
- noImplicitAny?: boolean;
- /** Report an error when not all code paths in function return a value.
- * Defaults to `false`. */
- noImplicitReturns?: boolean;
- /** Raise error on `this` expressions with an implied `any` type. Defaults to
- * `true`. */
- noImplicitThis?: boolean;
- /** Do not emit `"use strict"` directives in module output. Defaults to
- * `false`. */
- noImplicitUseStrict?: boolean;
- /** Do not add triple-slash references or module import targets to the list of
- * compiled files. Defaults to `false`. */
- noResolve?: boolean;
- /** Disable strict checking of generic signatures in function types. Defaults
- * to `false`. */
- noStrictGenericChecks?: boolean;
- /** Report errors on unused locals. Defaults to `false`. */
- noUnusedLocals?: boolean;
- /** Report errors on unused parameters. Defaults to `false`. */
- noUnusedParameters?: boolean;
- /** Redirect output structure to the directory. This only impacts
- * `Deno.compile` and only changes the emitted file names. Defaults to
- * `undefined`. */
- outDir?: string;
- /** List of path mapping entries for module names to locations relative to the
- * `baseUrl`. Defaults to `undefined`. */
- paths?: Record<string, string[]>;
- /** Do not erase const enum declarations in generated code. Defaults to
- * `false`. */
- preserveConstEnums?: boolean;
- /** Remove all comments except copy-right header comments beginning with
- * `/*!`. Defaults to `true`. */
- removeComments?: boolean;
- /** Include modules imported with `.json` extension. Defaults to `true`. */
- resolveJsonModule?: boolean;
- /** Specifies the root directory of input files. Only use to control the
- * output directory structure with `outDir`. Defaults to `undefined`. */
- rootDir?: string;
- /** List of _root_ folders whose combined content represent the structure of
- * the project at runtime. Defaults to `undefined`. */
- rootDirs?: string[];
- /** Generates corresponding `.map` file. Defaults to `false`. */
- sourceMap?: boolean;
- /** Specifies the location where debugger should locate TypeScript files
- * instead of source locations. Use this flag if the sources will be located
- * at run-time in a different location than that at design-time. The location
- * specified will be embedded in the sourceMap to direct the debugger where
- * the source files will be located. Defaults to `undefined`. */
- sourceRoot?: string;
- /** Enable all strict type checking options. Enabling `strict` enables
- * `noImplicitAny`, `noImplicitThis`, `alwaysStrict`, `strictBindCallApply`,
- * `strictNullChecks`, `strictFunctionTypes` and
- * `strictPropertyInitialization`. Defaults to `true`. */
- strict?: boolean;
- /** Enable stricter checking of the `bind`, `call`, and `apply` methods on
- * functions. Defaults to `true`. */
- strictBindCallApply?: boolean;
- /** Disable bivariant parameter checking for function types. Defaults to
- * `true`. */
- strictFunctionTypes?: boolean;
- /** Ensure non-undefined class properties are initialized in the constructor.
- * This option requires `strictNullChecks` be enabled in order to take effect.
- * Defaults to `true`. */
- strictPropertyInitialization?: boolean;
- /** In strict null checking mode, the `null` and `undefined` values are not in
- * the domain of every type and are only assignable to themselves and `any`
- * (the one exception being that `undefined` is also assignable to `void`). */
- strictNullChecks?: boolean;
- /** Suppress excess property checks for object literals. Defaults to
- * `false`. */
- suppressExcessPropertyErrors?: boolean;
- /** Suppress `noImplicitAny` errors for indexing objects lacking index
- * signatures. */
- suppressImplicitAnyIndexErrors?: boolean;
- /** Specify ECMAScript target version. Defaults to `esnext`. */
- target?:
- | "es3"
- | "es5"
- | "es6"
- | "es2015"
- | "es2016"
- | "es2017"
- | "es2018"
- | "es2019"
- | "es2020"
- | "esnext";
- /** List of names of type definitions to include. Defaults to `undefined`.
- *
- * The type definitions are resolved according to the normal Deno resolution
- * irrespective of if sources are provided on the call. Like other Deno
- * modules, there is no "magical" resolution. For example:
- *
- * Deno.compile(
- * "./foo.js",
- * undefined,
- * {
- * types: [ "./foo.d.ts", "https://deno.land/x/example/types.d.ts" ]
- * }
- * );
- */
- types?: string[];
- }
-
- /** **UNSTABLE**: new API, yet to be vetted.
- *
- * The results of a transpile only command, where the `source` contains the
- * emitted source, and `map` optionally contains the source map. */
- export interface TranspileOnlyResult {
- source: string;
- map?: string;
- }
-
- /** **UNSTABLE**: new API, yet to be vetted.
- *
- * Takes a set of TypeScript sources and resolves to a map where the key was
- * the original file name provided in sources and the result contains the
- * `source` and optionally the `map` from the transpile operation. This does no
- * type checking and validation, it effectively "strips" the types from the
- * file.
- *
- * const results = await Deno.transpileOnly({
- * "foo.ts": `const foo: string = "foo";`
- * });
- *
- * @param sources A map where the key is the filename and the value is the text
- * to transpile. The filename is only used in the transpile and
- * not resolved, for example to fill in the source name in the
- * source map.
- * @param options An option object of options to send to the compiler. This is
- * a subset of ts.CompilerOptions which can be supported by Deno.
- * Many of the options related to type checking and emitting
- * type declaration files will have no impact on the output.
- */
- export function transpileOnly(
- sources: Record<string, string>,
- options?: CompilerOptions
- ): Promise<Record<string, TranspileOnlyResult>>;
-
- /** **UNSTABLE**: new API, yet to be vetted.
- *
- * Takes a root module name, and optionally a record set of sources. Resolves
- * with a compiled set of modules and possibly diagnostics if the compiler
- * encountered any issues. If just a root name is provided, the modules
- * will be resolved as if the root module had been passed on the command line.
- *
- * If sources are passed, all modules will be resolved out of this object, where
- * the key is the module name and the value is the content. The extension of
- * the module name will be used to determine the media type of the module.
- *
- * const [ maybeDiagnostics1, output1 ] = await Deno.compile("foo.ts");
- *
- * const [ maybeDiagnostics2, output2 ] = await Deno.compile("/foo.ts", {
- * "/foo.ts": `export * from "./bar.ts";`,
- * "/bar.ts": `export const bar = "bar";`
- * });
- *
- * @param rootName The root name of the module which will be used as the
- * "starting point". If no `sources` is specified, Deno will
- * resolve the module externally as if the `rootName` had been
- * specified on the command line.
- * @param sources An optional key/value map of sources to be used when resolving
- * modules, where the key is the module name, and the value is
- * the source content. The extension of the key will determine
- * the media type of the file when processing. If supplied,
- * Deno will not attempt to resolve any modules externally.
- * @param options An optional object of options to send to the compiler. This is
- * a subset of ts.CompilerOptions which can be supported by Deno.
- */
- export function compile(
- rootName: string,
- sources?: Record<string, string>,
- options?: CompilerOptions
- ): Promise<[DiagnosticItem[] | undefined, Record<string, string>]>;
-
- /** **UNSTABLE**: new API, yet to be vetted.
- *
- * `bundle()` is part the compiler API. A full description of this functionality
- * can be found in the [manual](https://deno.land/std/manual.md#denobundle).
- *
- * Takes a root module name, and optionally a record set of sources. Resolves
- * with a single JavaScript string (and bundle diagnostics if issues arise with
- * the bundling) that is like the output of a `deno bundle` command. If just
- * a root name is provided, the modules will be resolved as if the root module
- * had been passed on the command line.
- *
- * If sources are passed, all modules will be resolved out of this object, where
- * the key is the module name and the value is the content. The extension of the
- * module name will be used to determine the media type of the module.
- *
- * // equivalent to "deno bundle foo.ts" from the command line
- * const [ maybeDiagnostics1, output1 ] = await Deno.bundle("foo.ts");
- *
- * const [ maybeDiagnostics2, output2 ] = await Deno.bundle("/foo.ts", {
- * "/foo.ts": `export * from "./bar.ts";`,
- * "/bar.ts": `export const bar = "bar";`
- * });
- *
- * @param rootName The root name of the module which will be used as the
- * "starting point". If no `sources` is specified, Deno will
- * resolve the module externally as if the `rootName` had been
- * specified on the command line.
- * @param sources An optional key/value map of sources to be used when resolving
- * modules, where the key is the module name, and the value is
- * the source content. The extension of the key will determine
- * the media type of the file when processing. If supplied,
- * Deno will not attempt to resolve any modules externally.
- * @param options An optional object of options to send to the compiler. This is
- * a subset of ts.CompilerOptions which can be supported by Deno.
- */
- export function bundle(
- rootName: string,
- sources?: Record<string, string>,
- options?: CompilerOptions
- ): Promise<[DiagnosticItem[] | undefined, string]>;
-
/** Returns the script arguments to the program. If for example we run a
* program:
*
@@ -2789,101 +1714,6 @@ declare namespace Deno {
*/
export const args: string[];
- /** **UNSTABLE**: new API, yet to be vetted.
- *
- * Represents the stream of signals, implements both `AsyncIterator` and
- * `PromiseLike`. */
- export class SignalStream
- implements AsyncIterableIterator<void>, PromiseLike<void> {
- constructor(signal: typeof Deno.Signal);
- then<T, S>(
- f: (v: void) => T | Promise<T>,
- g?: (v: void) => S | Promise<S>
- ): Promise<T | S>;
- next(): Promise<IteratorResult<void>>;
- [Symbol.asyncIterator](): AsyncIterableIterator<void>;
- dispose(): void;
- }
-
- /** **UNSTABLE**: new API, yet to be vetted.
- *
- * Returns the stream of the given signal number. You can use it as an async
- * iterator.
- *
- * for await (const _ of Deno.signal(Deno.Signal.SIGTERM)) {
- * console.log("got SIGTERM!");
- * }
- *
- * You can also use it as a promise. In this case you can only receive the
- * first one.
- *
- * await Deno.signal(Deno.Signal.SIGTERM);
- * console.log("SIGTERM received!")
- *
- * If you want to stop receiving the signals, you can use `.dispose()` method
- * of the signal stream object.
- *
- * const sig = Deno.signal(Deno.Signal.SIGTERM);
- * setTimeout(() => { sig.dispose(); }, 5000);
- * for await (const _ of sig) {
- * console.log("SIGTERM!")
- * }
- *
- * The above for-await loop exits after 5 seconds when `sig.dispose()` is
- * called.
- *
- * NOTE: This functionality is not yet implemented on Windows.
- */
- export function signal(signo: number): SignalStream;
-
- /** **UNSTABLE**: new API, yet to be vetted. */
- export const signals: {
- /** Returns the stream of SIGALRM signals.
- *
- * This method is the shorthand for `Deno.signal(Deno.Signal.SIGALRM)`. */
- alarm: () => SignalStream;
- /** Returns the stream of SIGCHLD signals.
- *
- * This method is the shorthand for `Deno.signal(Deno.Signal.SIGCHLD)`. */
- child: () => SignalStream;
- /** Returns the stream of SIGHUP signals.
- *
- * This method is the shorthand for `Deno.signal(Deno.Signal.SIGHUP)`. */
- hungup: () => SignalStream;
- /** Returns the stream of SIGINT signals.
- *
- * This method is the shorthand for `Deno.signal(Deno.Signal.SIGINT)`. */
- interrupt: () => SignalStream;
- /** Returns the stream of SIGIO signals.
- *
- * This method is the shorthand for `Deno.signal(Deno.Signal.SIGIO)`. */
- io: () => SignalStream;
- /** Returns the stream of SIGPIPE signals.
- *
- * This method is the shorthand for `Deno.signal(Deno.Signal.SIGPIPE)`. */
- pipe: () => SignalStream;
- /** Returns the stream of SIGQUIT signals.
- *
- * This method is the shorthand for `Deno.signal(Deno.Signal.SIGQUIT)`. */
- quit: () => SignalStream;
- /** Returns the stream of SIGTERM signals.
- *
- * This method is the shorthand for `Deno.signal(Deno.Signal.SIGTERM)`. */
- terminate: () => SignalStream;
- /** Returns the stream of SIGUSR1 signals.
- *
- * This method is the shorthand for `Deno.signal(Deno.Signal.SIGUSR1)`. */
- userDefined1: () => SignalStream;
- /** Returns the stream of SIGUSR2 signals.
- *
- * This method is the shorthand for `Deno.signal(Deno.Signal.SIGUSR2)`. */
- userDefined2: () => SignalStream;
- /** Returns the stream of SIGWINCH signals.
- *
- * This method is the shorthand for `Deno.signal(Deno.Signal.SIGWINCH)`. */
- windowChange: () => SignalStream;
- };
-
/** A symbol which can be used as a key for a custom method which will be
* called when `Deno.inspect()` is called, or when the object is logged to
* the console. */
diff --git a/cli/js/lib.deno.unstable.d.ts b/cli/js/lib.deno.unstable.d.ts
new file mode 100644
index 000000000..88b9f002c
--- /dev/null
+++ b/cli/js/lib.deno.unstable.d.ts
@@ -0,0 +1,1192 @@
+// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+
+/// <reference no-default-lib="true" />
+/// <reference lib="deno.ns" />
+
+declare namespace Deno {
+ /**
+ * **UNSTABLE**: New API, yet to be vetted. This API is under consideration to
+ * determine if permissions are required to call it.
+ *
+ * Retrieve the process umask. If `mask` is provided, sets the process umask.
+ * This call always returns what the umask was before the call.
+ *
+ * console.log(Deno.umask()); // e.g. 18 (0o022)
+ * const prevUmaskValue = Deno.umask(0o077); // e.g. 18 (0o022)
+ * console.log(Deno.umask()); // e.g. 63 (0o077)
+ *
+ * NOTE: This API is not implemented on Windows
+ */
+ export function umask(mask?: number): number;
+
+ /** Synchronously creates `newpath` as a hard link to `oldpath`.
+ *
+ * Deno.linkSync("old/name", "new/name");
+ *
+ * Requires `allow-read` and `allow-write` permissions. */
+ export function linkSync(oldpath: string, newpath: string): void;
+
+ /** Creates `newpath` as a hard link to `oldpath`.
+ *
+ * **UNSTABLE**: needs security review.
+ *
+ * await Deno.link("old/name", "new/name");
+ *
+ * Requires `allow-read` and `allow-write` permissions. */
+ export function link(oldpath: string, newpath: string): Promise<void>;
+
+ /** **UNSTABLE**: `type` argument type may be changed to `"dir" | "file"`.
+ *
+ * **UNSTABLE**: needs security review.
+ *
+ * Creates `newpath` as a symbolic link to `oldpath`.
+ *
+ * The type argument can be set to `dir` or `file`. This argument is only
+ * available on Windows and ignored on other platforms.
+ *
+ * NOTE: This function is not yet implemented on Windows.
+ *
+ * Deno.symlinkSync("old/name", "new/name");
+ *
+ * Requires `allow-read` and `allow-write` permissions. */
+ export function symlinkSync(
+ oldpath: string,
+ newpath: string,
+ type?: string
+ ): void;
+
+ /** **UNSTABLE**: `type` argument may be changed to `"dir" | "file"`
+ *
+ * **UNSTABLE**: needs security review.
+ *
+ * Creates `newpath` as a symbolic link to `oldpath`.
+ *
+ * The type argument can be set to `dir` or `file`. This argument is only
+ * available on Windows and ignored on other platforms.
+ *
+ * NOTE: This function is not yet implemented on Windows.
+ *
+ * await Deno.symlink("old/name", "new/name");
+ *
+ * Requires `allow-read` and `allow-write` permissions. */
+ export function symlink(
+ oldpath: string,
+ newpath: string,
+ type?: string
+ ): Promise<void>;
+
+ /** **UNSTABLE** */
+ export type DirKind =
+ | "home"
+ | "cache"
+ | "config"
+ | "executable"
+ | "data"
+ | "data_local"
+ | "audio"
+ | "desktop"
+ | "document"
+ | "download"
+ | "font"
+ | "picture"
+ | "public"
+ | "template"
+ | "tmp"
+ | "video";
+
+ /**
+ * **UNSTABLE**: Currently under evaluation to decide if method name `dir` and
+ * parameter type alias name `DirKind` should be renamed.
+ *
+ * Returns the user and platform specific directories.
+ *
+ * const homeDirectory = Deno.dir("home");
+ *
+ * Requires `allow-env` permission.
+ *
+ * Returns `null` if there is no applicable directory or if any other error
+ * occurs.
+ *
+ * Argument values: `"home"`, `"cache"`, `"config"`, `"executable"`, `"data"`,
+ * `"data_local"`, `"audio"`, `"desktop"`, `"document"`, `"download"`,
+ * `"font"`, `"picture"`, `"public"`, `"template"`, `"tmp"`, `"video"`
+ *
+ * `"home"`
+ *
+ * |Platform | Value | Example |
+ * | ------- | -----------------------------------------| -----------------------|
+ * | Linux | `$HOME` | /home/alice |
+ * | macOS | `$HOME` | /Users/alice |
+ * | Windows | `{FOLDERID_Profile}` | C:\Users\Alice |
+ *
+ * `"cache"`
+ *
+ * |Platform | Value | Example |
+ * | ------- | ----------------------------------- | ---------------------------- |
+ * | Linux | `$XDG_CACHE_HOME` or `$HOME`/.cache | /home/alice/.cache |
+ * | macOS | `$HOME`/Library/Caches | /Users/Alice/Library/Caches |
+ * | Windows | `{FOLDERID_LocalAppData}` | C:\Users\Alice\AppData\Local |
+ *
+ * `"config"`
+ *
+ * |Platform | Value | Example |
+ * | ------- | ------------------------------------- | -------------------------------- |
+ * | Linux | `$XDG_CONFIG_HOME` or `$HOME`/.config | /home/alice/.config |
+ * | macOS | `$HOME`/Library/Preferences | /Users/Alice/Library/Preferences |
+ * | Windows | `{FOLDERID_RoamingAppData}` | C:\Users\Alice\AppData\Roaming |
+ *
+ * `"executable"`
+ *
+ * |Platform | Value | Example |
+ * | ------- | --------------------------------------------------------------- | -----------------------|
+ * | Linux | `XDG_BIN_HOME` or `$XDG_DATA_HOME`/../bin or `$HOME`/.local/bin | /home/alice/.local/bin |
+ * | macOS | - | - |
+ * | Windows | - | - |
+ *
+ * `"data"`
+ *
+ * |Platform | Value | Example |
+ * | ------- | ---------------------------------------- | ---------------------------------------- |
+ * | Linux | `$XDG_DATA_HOME` or `$HOME`/.local/share | /home/alice/.local/share |
+ * | macOS | `$HOME`/Library/Application Support | /Users/Alice/Library/Application Support |
+ * | Windows | `{FOLDERID_RoamingAppData}` | C:\Users\Alice\AppData\Roaming |
+ *
+ * `"data_local"`
+ *
+ * |Platform | Value | Example |
+ * | ------- | ---------------------------------------- | ---------------------------------------- |
+ * | Linux | `$XDG_DATA_HOME` or `$HOME`/.local/share | /home/alice/.local/share |
+ * | macOS | `$HOME`/Library/Application Support | /Users/Alice/Library/Application Support |
+ * | Windows | `{FOLDERID_LocalAppData}` | C:\Users\Alice\AppData\Local |
+ *
+ * `"audio"`
+ *
+ * |Platform | Value | Example |
+ * | ------- | ------------------ | -------------------- |
+ * | Linux | `XDG_MUSIC_DIR` | /home/alice/Music |
+ * | macOS | `$HOME`/Music | /Users/Alice/Music |
+ * | Windows | `{FOLDERID_Music}` | C:\Users\Alice\Music |
+ *
+ * `"desktop"`
+ *
+ * |Platform | Value | Example |
+ * | ------- | -------------------- | ---------------------- |
+ * | Linux | `XDG_DESKTOP_DIR` | /home/alice/Desktop |
+ * | macOS | `$HOME`/Desktop | /Users/Alice/Desktop |
+ * | Windows | `{FOLDERID_Desktop}` | C:\Users\Alice\Desktop |
+ *
+ * `"document"`
+ *
+ * |Platform | Value | Example |
+ * | ------- | ---------------------- | ------------------------ |
+ * | Linux | `XDG_DOCUMENTS_DIR` | /home/alice/Documents |
+ * | macOS | `$HOME`/Documents | /Users/Alice/Documents |
+ * | Windows | `{FOLDERID_Documents}` | C:\Users\Alice\Documents |
+ *
+ * `"download"`
+ *
+ * |Platform | Value | Example |
+ * | ------- | ---------------------- | ------------------------ |
+ * | Linux | `XDG_DOWNLOAD_DIR` | /home/alice/Downloads |
+ * | macOS | `$HOME`/Downloads | /Users/Alice/Downloads |
+ * | Windows | `{FOLDERID_Downloads}` | C:\Users\Alice\Downloads |
+ *
+ * `"font"`
+ *
+ * |Platform | Value | Example |
+ * | ------- | ---------------------------------------------------- | ------------------------------ |
+ * | Linux | `$XDG_DATA_HOME`/fonts or `$HOME`/.local/share/fonts | /home/alice/.local/share/fonts |
+ * | macOS | `$HOME/Library/Fonts` | /Users/Alice/Library/Fonts |
+ * | Windows | – | – |
+ *
+ * `"picture"`
+ *
+ * |Platform | Value | Example |
+ * | ------- | --------------------- | ----------------------- |
+ * | Linux | `XDG_PICTURES_DIR` | /home/alice/Pictures |
+ * | macOS | `$HOME`/Pictures | /Users/Alice/Pictures |
+ * | Windows | `{FOLDERID_Pictures}` | C:\Users\Alice\Pictures |
+ *
+ * `"public"`
+ *
+ * |Platform | Value | Example |
+ * | ------- | --------------------- | ------------------- |
+ * | Linux | `XDG_PUBLICSHARE_DIR` | /home/alice/Public |
+ * | macOS | `$HOME`/Public | /Users/Alice/Public |
+ * | Windows | `{FOLDERID_Public}` | C:\Users\Public |
+ *
+ * `"template"`
+ *
+ * |Platform | Value | Example |
+ * | ------- | ---------------------- | ---------------------------------------------------------- |
+ * | Linux | `XDG_TEMPLATES_DIR` | /home/alice/Templates |
+ * | macOS | – | – |
+ * | Windows | `{FOLDERID_Templates}` | C:\Users\Alice\AppData\Roaming\Microsoft\Windows\Templates |
+ *
+ * `"tmp"`
+ *
+ * |Platform | Value | Example |
+ * | ------- | ---------------------- | ---------------------------------------------------------- |
+ * | Linux | `TMPDIR` | /tmp |
+ * | macOS | `TMPDIR` | /tmp |
+ * | Windows | `{TMP}` | C:\Users\Alice\AppData\Local\Temp |
+ *
+ * `"video"`
+ *
+ * |Platform | Value | Example |
+ * | ------- | ------------------- | --------------------- |
+ * | Linux | `XDG_VIDEOS_DIR` | /home/alice/Videos |
+ * | macOS | `$HOME`/Movies | /Users/Alice/Movies |
+ * | Windows | `{FOLDERID_Videos}` | C:\Users\Alice\Videos |
+ *
+ */
+ export function dir(kind: DirKind): string | null;
+
+ /** Returns an array containing the 1, 5, and 15 minute load averages. The
+ * load average is a measure of CPU and IO utilization of the last one, five,
+ * and 15 minute periods expressed as a fractional number. Zero means there
+ * is no load. On Windows, the three values are always the same and represent
+ * the current load, not the 1, 5 and 15 minute load averages.
+ *
+ * console.log(Deno.loadavg()); // e.g. [ 0.71, 0.44, 0.44 ]
+ *
+ * Requires `allow-env` permission.
+ *
+ * **Unstable** There are questions around which permission this needs. And
+ * maybe should be renamed (loadAverage?)
+ */
+ export function loadavg(): number[];
+
+ /** Returns the release version of the Operating System.
+ *
+ * console.log(Deno.osRelease());
+ *
+ * Requires `allow-env` permission.
+ *
+ * **Unstable** new API maybe move to Deno.build or Deno.versions? Depends on
+ * sys-info, which we don't necessarally want to depend on.
+ */
+ export function osRelease(): string;
+
+ /** **UNSTABLE**: new API, yet to be vetted.
+ *
+ * Open and initalize a plugin.
+ *
+ * const rid = Deno.openPlugin("./path/to/some/plugin.so");
+ * const opId = Deno.core.ops()["some_op"];
+ * const response = Deno.core.dispatch(opId, new Uint8Array([1,2,3,4]));
+ * console.log(`Response from plugin ${response}`);
+ *
+ * Requires `allow-plugin` permission.
+ *
+ * The plugin system is not stable and will change in the future, hence the
+ * lack of docs. For now take a look at the example
+ * https://github.com/denoland/deno/tree/master/test_plugin
+ */
+ export function openPlugin(filename: string): number;
+
+ /** The log category for a diagnostic message. */
+ export enum DiagnosticCategory {
+ Log = 0,
+ Debug = 1,
+ Info = 2,
+ Error = 3,
+ Warning = 4,
+ Suggestion = 5,
+ }
+
+ export interface DiagnosticMessageChain {
+ message: string;
+ category: DiagnosticCategory;
+ code: number;
+ next?: DiagnosticMessageChain[];
+ }
+
+ export interface DiagnosticItem {
+ /** A string message summarizing the diagnostic. */
+ message: string;
+ /** An ordered array of further diagnostics. */
+ messageChain?: DiagnosticMessageChain;
+ /** Information related to the diagnostic. This is present when there is a
+ * suggestion or other additional diagnostic information */
+ relatedInformation?: DiagnosticItem[];
+ /** The text of the source line related to the diagnostic. */
+ sourceLine?: string;
+ /** The line number that is related to the diagnostic. */
+ lineNumber?: number;
+ /** The name of the script resource related to the diagnostic. */
+ scriptResourceName?: string;
+ /** The start position related to the diagnostic. */
+ startPosition?: number;
+ /** The end position related to the diagnostic. */
+ endPosition?: number;
+ /** The category of the diagnostic. */
+ category: DiagnosticCategory;
+ /** A number identifier. */
+ code: number;
+ /** The the start column of the sourceLine related to the diagnostic. */
+ startColumn?: number;
+ /** The end column of the sourceLine related to the diagnostic. */
+ endColumn?: number;
+ }
+
+ export interface Diagnostic {
+ /** An array of diagnostic items. */
+ items: DiagnosticItem[];
+ }
+
+ /** **UNSTABLE**: new API, yet to be vetted.
+ *
+ * Format an array of diagnostic items and return them as a single string in a
+ * user friendly format.
+ *
+ * const [diagnostics, result] = Deno.compile("file_with_compile_issues.ts");
+ * console.table(diagnostics); // Prints raw diagnostic data
+ * console.log(Deno.formatDiagnostics(diagnostics)); // User friendly output of diagnostics
+ *
+ * @param items An array of diagnostic items to format
+ */
+ export function formatDiagnostics(items: DiagnosticItem[]): string;
+
+ /** **UNSTABLE**: new API, yet to be vetted.
+ *
+ * A specific subset TypeScript compiler options that can be supported by the
+ * Deno TypeScript compiler. */
+ export interface CompilerOptions {
+ /** Allow JavaScript files to be compiled. Defaults to `true`. */
+ allowJs?: boolean;
+ /** Allow default imports from modules with no default export. This does not
+ * affect code emit, just typechecking. Defaults to `false`. */
+ allowSyntheticDefaultImports?: boolean;
+ /** Allow accessing UMD globals from modules. Defaults to `false`. */
+ allowUmdGlobalAccess?: boolean;
+ /** Do not report errors on unreachable code. Defaults to `false`. */
+ allowUnreachableCode?: boolean;
+ /** Do not report errors on unused labels. Defaults to `false` */
+ allowUnusedLabels?: boolean;
+ /** Parse in strict mode and emit `"use strict"` for each source file.
+ * Defaults to `true`. */
+ alwaysStrict?: boolean;
+ /** Base directory to resolve non-relative module names. Defaults to
+ * `undefined`. */
+ baseUrl?: string;
+ /** Report errors in `.js` files. Use in conjunction with `allowJs`. Defaults
+ * to `false`. */
+ checkJs?: boolean;
+ /** Generates corresponding `.d.ts` file. Defaults to `false`. */
+ declaration?: boolean;
+ /** Output directory for generated declaration files. */
+ declarationDir?: string;
+ /** Generates a source map for each corresponding `.d.ts` file. Defaults to
+ * `false`. */
+ declarationMap?: boolean;
+ /** Provide full support for iterables in `for..of`, spread and
+ * destructuring when targeting ES5 or ES3. Defaults to `false`. */
+ downlevelIteration?: boolean;
+ /** Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.
+ * Defaults to `false`. */
+ emitBOM?: boolean;
+ /** Only emit `.d.ts` declaration files. Defaults to `false`. */
+ emitDeclarationOnly?: boolean;
+ /** Emit design-type metadata for decorated declarations in source. See issue
+ * [microsoft/TypeScript#2577](https://github.com/Microsoft/TypeScript/issues/2577)
+ * for details. Defaults to `false`. */
+ emitDecoratorMetadata?: boolean;
+ /** Emit `__importStar` and `__importDefault` helpers for runtime babel
+ * ecosystem compatibility and enable `allowSyntheticDefaultImports` for type
+ * system compatibility. Defaults to `true`. */
+ esModuleInterop?: boolean;
+ /** Enables experimental support for ES decorators. Defaults to `false`. */
+ experimentalDecorators?: boolean;
+ /** Emit a single file with source maps instead of having a separate file.
+ * Defaults to `false`. */
+ inlineSourceMap?: boolean;
+ /** Emit the source alongside the source maps within a single file; requires
+ * `inlineSourceMap` or `sourceMap` to be set. Defaults to `false`. */
+ inlineSources?: boolean;
+ /** Perform additional checks to ensure that transpile only would be safe.
+ * Defaults to `false`. */
+ isolatedModules?: boolean;
+ /** Support JSX in `.tsx` files: `"react"`, `"preserve"`, `"react-native"`.
+ * Defaults to `"react"`. */
+ jsx?: "react" | "preserve" | "react-native";
+ /** Specify the JSX factory function to use when targeting react JSX emit,
+ * e.g. `React.createElement` or `h`. Defaults to `React.createElement`. */
+ jsxFactory?: string;
+ /** Resolve keyof to string valued property names only (no numbers or
+ * symbols). Defaults to `false`. */
+ keyofStringsOnly?: string;
+ /** Emit class fields with ECMAScript-standard semantics. Defaults to `false`.
+ * Does not apply to `"esnext"` target. */
+ useDefineForClassFields?: boolean;
+ /** List of library files to be included in the compilation. If omitted,
+ * then the Deno main runtime libs are used. */
+ lib?: string[];
+ /** The locale to use to show error messages. */
+ locale?: string;
+ /** Specifies the location where debugger should locate map files instead of
+ * generated locations. Use this flag if the `.map` files will be located at
+ * run-time in a different location than the `.js` files. The location
+ * specified will be embedded in the source map to direct the debugger where
+ * the map files will be located. Defaults to `undefined`. */
+ mapRoot?: string;
+ /** Specify the module format for the emitted code. Defaults to
+ * `"esnext"`. */
+ module?:
+ | "none"
+ | "commonjs"
+ | "amd"
+ | "system"
+ | "umd"
+ | "es6"
+ | "es2015"
+ | "esnext";
+ /** Do not generate custom helper functions like `__extends` in compiled
+ * output. Defaults to `false`. */
+ noEmitHelpers?: boolean;
+ /** Report errors for fallthrough cases in switch statement. Defaults to
+ * `false`. */
+ noFallthroughCasesInSwitch?: boolean;
+ /** Raise error on expressions and declarations with an implied any type.
+ * Defaults to `true`. */
+ noImplicitAny?: boolean;
+ /** Report an error when not all code paths in function return a value.
+ * Defaults to `false`. */
+ noImplicitReturns?: boolean;
+ /** Raise error on `this` expressions with an implied `any` type. Defaults to
+ * `true`. */
+ noImplicitThis?: boolean;
+ /** Do not emit `"use strict"` directives in module output. Defaults to
+ * `false`. */
+ noImplicitUseStrict?: boolean;
+ /** Do not add triple-slash references or module import targets to the list of
+ * compiled files. Defaults to `false`. */
+ noResolve?: boolean;
+ /** Disable strict checking of generic signatures in function types. Defaults
+ * to `false`. */
+ noStrictGenericChecks?: boolean;
+ /** Report errors on unused locals. Defaults to `false`. */
+ noUnusedLocals?: boolean;
+ /** Report errors on unused parameters. Defaults to `false`. */
+ noUnusedParameters?: boolean;
+ /** Redirect output structure to the directory. This only impacts
+ * `Deno.compile` and only changes the emitted file names. Defaults to
+ * `undefined`. */
+ outDir?: string;
+ /** List of path mapping entries for module names to locations relative to the
+ * `baseUrl`. Defaults to `undefined`. */
+ paths?: Record<string, string[]>;
+ /** Do not erase const enum declarations in generated code. Defaults to
+ * `false`. */
+ preserveConstEnums?: boolean;
+ /** Remove all comments except copy-right header comments beginning with
+ * `/*!`. Defaults to `true`. */
+ removeComments?: boolean;
+ /** Include modules imported with `.json` extension. Defaults to `true`. */
+ resolveJsonModule?: boolean;
+ /** Specifies the root directory of input files. Only use to control the
+ * output directory structure with `outDir`. Defaults to `undefined`. */
+ rootDir?: string;
+ /** List of _root_ folders whose combined content represent the structure of
+ * the project at runtime. Defaults to `undefined`. */
+ rootDirs?: string[];
+ /** Generates corresponding `.map` file. Defaults to `false`. */
+ sourceMap?: boolean;
+ /** Specifies the location where debugger should locate TypeScript files
+ * instead of source locations. Use this flag if the sources will be located
+ * at run-time in a different location than that at design-time. The location
+ * specified will be embedded in the sourceMap to direct the debugger where
+ * the source files will be located. Defaults to `undefined`. */
+ sourceRoot?: string;
+ /** Enable all strict type checking options. Enabling `strict` enables
+ * `noImplicitAny`, `noImplicitThis`, `alwaysStrict`, `strictBindCallApply`,
+ * `strictNullChecks`, `strictFunctionTypes` and
+ * `strictPropertyInitialization`. Defaults to `true`. */
+ strict?: boolean;
+ /** Enable stricter checking of the `bind`, `call`, and `apply` methods on
+ * functions. Defaults to `true`. */
+ strictBindCallApply?: boolean;
+ /** Disable bivariant parameter checking for function types. Defaults to
+ * `true`. */
+ strictFunctionTypes?: boolean;
+ /** Ensure non-undefined class properties are initialized in the constructor.
+ * This option requires `strictNullChecks` be enabled in order to take effect.
+ * Defaults to `true`. */
+ strictPropertyInitialization?: boolean;
+ /** In strict null checking mode, the `null` and `undefined` values are not in
+ * the domain of every type and are only assignable to themselves and `any`
+ * (the one exception being that `undefined` is also assignable to `void`). */
+ strictNullChecks?: boolean;
+ /** Suppress excess property checks for object literals. Defaults to
+ * `false`. */
+ suppressExcessPropertyErrors?: boolean;
+ /** Suppress `noImplicitAny` errors for indexing objects lacking index
+ * signatures. */
+ suppressImplicitAnyIndexErrors?: boolean;
+ /** Specify ECMAScript target version. Defaults to `esnext`. */
+ target?:
+ | "es3"
+ | "es5"
+ | "es6"
+ | "es2015"
+ | "es2016"
+ | "es2017"
+ | "es2018"
+ | "es2019"
+ | "es2020"
+ | "esnext";
+ /** List of names of type definitions to include. Defaults to `undefined`.
+ *
+ * The type definitions are resolved according to the normal Deno resolution
+ * irrespective of if sources are provided on the call. Like other Deno
+ * modules, there is no "magical" resolution. For example:
+ *
+ * Deno.compile(
+ * "./foo.js",
+ * undefined,
+ * {
+ * types: [ "./foo.d.ts", "https://deno.land/x/example/types.d.ts" ]
+ * }
+ * );
+ */
+ types?: string[];
+ }
+
+ /** **UNSTABLE**: new API, yet to be vetted.
+ *
+ * The results of a transpile only command, where the `source` contains the
+ * emitted source, and `map` optionally contains the source map. */
+ export interface TranspileOnlyResult {
+ source: string;
+ map?: string;
+ }
+
+ /** **UNSTABLE**: new API, yet to be vetted.
+ *
+ * Takes a set of TypeScript sources and resolves to a map where the key was
+ * the original file name provided in sources and the result contains the
+ * `source` and optionally the `map` from the transpile operation. This does no
+ * type checking and validation, it effectively "strips" the types from the
+ * file.
+ *
+ * const results = await Deno.transpileOnly({
+ * "foo.ts": `const foo: string = "foo";`
+ * });
+ *
+ * @param sources A map where the key is the filename and the value is the text
+ * to transpile. The filename is only used in the transpile and
+ * not resolved, for example to fill in the source name in the
+ * source map.
+ * @param options An option object of options to send to the compiler. This is
+ * a subset of ts.CompilerOptions which can be supported by Deno.
+ * Many of the options related to type checking and emitting
+ * type declaration files will have no impact on the output.
+ */
+ export function transpileOnly(
+ sources: Record<string, string>,
+ options?: CompilerOptions
+ ): Promise<Record<string, TranspileOnlyResult>>;
+
+ /** **UNSTABLE**: new API, yet to be vetted.
+ *
+ * Takes a root module name, and optionally a record set of sources. Resolves
+ * with a compiled set of modules and possibly diagnostics if the compiler
+ * encountered any issues. If just a root name is provided, the modules
+ * will be resolved as if the root module had been passed on the command line.
+ *
+ * If sources are passed, all modules will be resolved out of this object, where
+ * the key is the module name and the value is the content. The extension of
+ * the module name will be used to determine the media type of the module.
+ *
+ * const [ maybeDiagnostics1, output1 ] = await Deno.compile("foo.ts");
+ *
+ * const [ maybeDiagnostics2, output2 ] = await Deno.compile("/foo.ts", {
+ * "/foo.ts": `export * from "./bar.ts";`,
+ * "/bar.ts": `export const bar = "bar";`
+ * });
+ *
+ * @param rootName The root name of the module which will be used as the
+ * "starting point". If no `sources` is specified, Deno will
+ * resolve the module externally as if the `rootName` had been
+ * specified on the command line.
+ * @param sources An optional key/value map of sources to be used when resolving
+ * modules, where the key is the module name, and the value is
+ * the source content. The extension of the key will determine
+ * the media type of the file when processing. If supplied,
+ * Deno will not attempt to resolve any modules externally.
+ * @param options An optional object of options to send to the compiler. This is
+ * a subset of ts.CompilerOptions which can be supported by Deno.
+ */
+ export function compile(
+ rootName: string,
+ sources?: Record<string, string>,
+ options?: CompilerOptions
+ ): Promise<[DiagnosticItem[] | undefined, Record<string, string>]>;
+
+ /** **UNSTABLE**: new API, yet to be vetted.
+ *
+ * `bundle()` is part the compiler API. A full description of this functionality
+ * can be found in the [manual](https://deno.land/std/manual.md#denobundle).
+ *
+ * Takes a root module name, and optionally a record set of sources. Resolves
+ * with a single JavaScript string (and bundle diagnostics if issues arise with
+ * the bundling) that is like the output of a `deno bundle` command. If just
+ * a root name is provided, the modules will be resolved as if the root module
+ * had been passed on the command line.
+ *
+ * If sources are passed, all modules will be resolved out of this object, where
+ * the key is the module name and the value is the content. The extension of the
+ * module name will be used to determine the media type of the module.
+ *
+ * // equivalent to "deno bundle foo.ts" from the command line
+ * const [ maybeDiagnostics1, output1 ] = await Deno.bundle("foo.ts");
+ *
+ * const [ maybeDiagnostics2, output2 ] = await Deno.bundle("/foo.ts", {
+ * "/foo.ts": `export * from "./bar.ts";`,
+ * "/bar.ts": `export const bar = "bar";`
+ * });
+ *
+ * @param rootName The root name of the module which will be used as the
+ * "starting point". If no `sources` is specified, Deno will
+ * resolve the module externally as if the `rootName` had been
+ * specified on the command line.
+ * @param sources An optional key/value map of sources to be used when resolving
+ * modules, where the key is the module name, and the value is
+ * the source content. The extension of the key will determine
+ * the media type of the file when processing. If supplied,
+ * Deno will not attempt to resolve any modules externally.
+ * @param options An optional object of options to send to the compiler. This is
+ * a subset of ts.CompilerOptions which can be supported by Deno.
+ */
+ export function bundle(
+ rootName: string,
+ sources?: Record<string, string>,
+ options?: CompilerOptions
+ ): Promise<[DiagnosticItem[] | undefined, string]>;
+
+ /** **UNSTABLE**: Should not have same name as `window.location` type. */
+ interface Location {
+ /** The full url for the module, e.g. `file://some/file.ts` or
+ * `https://some/file.ts`. */
+ fileName: string;
+ /** The line number in the file. It is assumed to be 1-indexed. */
+ lineNumber: number;
+ /** The column number in the file. It is assumed to be 1-indexed. */
+ columnNumber: number;
+ }
+
+ /** UNSTABLE: new API, yet to be vetted.
+ *
+ * Given a current location in a module, lookup the source location and return
+ * it.
+ *
+ * When Deno transpiles code, it keep source maps of the transpiled code. This
+ * function can be used to lookup the original location. This is
+ * automatically done when accessing the `.stack` of an error, or when an
+ * uncaught error is logged. This function can be used to perform the lookup
+ * for creating better error handling.
+ *
+ * **Note:** `line` and `column` are 1 indexed, which matches display
+ * expectations, but is not typical of most index numbers in Deno.
+ *
+ * An example:
+ *
+ * const orig = Deno.applySourceMap({
+ * fileName: "file://my/module.ts",
+ * lineNumber: 5,
+ * columnNumber: 15
+ * });
+ * console.log(`${orig.filename}:${orig.line}:${orig.column}`);
+ */
+ export function applySourceMap(location: Location): Location;
+
+ enum LinuxSignal {
+ SIGHUP = 1,
+ SIGINT = 2,
+ SIGQUIT = 3,
+ SIGILL = 4,
+ SIGTRAP = 5,
+ SIGABRT = 6,
+ SIGBUS = 7,
+ SIGFPE = 8,
+ SIGKILL = 9,
+ SIGUSR1 = 10,
+ SIGSEGV = 11,
+ SIGUSR2 = 12,
+ SIGPIPE = 13,
+ SIGALRM = 14,
+ SIGTERM = 15,
+ SIGSTKFLT = 16,
+ SIGCHLD = 17,
+ SIGCONT = 18,
+ SIGSTOP = 19,
+ SIGTSTP = 20,
+ SIGTTIN = 21,
+ SIGTTOU = 22,
+ SIGURG = 23,
+ SIGXCPU = 24,
+ SIGXFSZ = 25,
+ SIGVTALRM = 26,
+ SIGPROF = 27,
+ SIGWINCH = 28,
+ SIGIO = 29,
+ SIGPWR = 30,
+ SIGSYS = 31,
+ }
+ enum MacOSSignal {
+ SIGHUP = 1,
+ SIGINT = 2,
+ SIGQUIT = 3,
+ SIGILL = 4,
+ SIGTRAP = 5,
+ SIGABRT = 6,
+ SIGEMT = 7,
+ SIGFPE = 8,
+ SIGKILL = 9,
+ SIGBUS = 10,
+ SIGSEGV = 11,
+ SIGSYS = 12,
+ SIGPIPE = 13,
+ SIGALRM = 14,
+ SIGTERM = 15,
+ SIGURG = 16,
+ SIGSTOP = 17,
+ SIGTSTP = 18,
+ SIGCONT = 19,
+ SIGCHLD = 20,
+ SIGTTIN = 21,
+ SIGTTOU = 22,
+ SIGIO = 23,
+ SIGXCPU = 24,
+ SIGXFSZ = 25,
+ SIGVTALRM = 26,
+ SIGPROF = 27,
+ SIGWINCH = 28,
+ SIGINFO = 29,
+ SIGUSR1 = 30,
+ SIGUSR2 = 31,
+ }
+
+ /** **UNSTABLE**: make platform independent.
+ *
+ * Signals numbers. This is platform dependent. */
+ export const Signal: typeof MacOSSignal | typeof LinuxSignal;
+
+ /** **UNSTABLE**: new API, yet to be vetted.
+ *
+ * Represents the stream of signals, implements both `AsyncIterator` and
+ * `PromiseLike`. */
+ export class SignalStream
+ implements AsyncIterableIterator<void>, PromiseLike<void> {
+ constructor(signal: typeof Deno.Signal);
+ then<T, S>(
+ f: (v: void) => T | Promise<T>,
+ g?: (v: void) => S | Promise<S>
+ ): Promise<T | S>;
+ next(): Promise<IteratorResult<void>>;
+ [Symbol.asyncIterator](): AsyncIterableIterator<void>;
+ dispose(): void;
+ }
+
+ /** **UNSTABLE**: new API, yet to be vetted.
+ *
+ * Returns the stream of the given signal number. You can use it as an async
+ * iterator.
+ *
+ * for await (const _ of Deno.signal(Deno.Signal.SIGTERM)) {
+ * console.log("got SIGTERM!");
+ * }
+ *
+ * You can also use it as a promise. In this case you can only receive the
+ * first one.
+ *
+ * await Deno.signal(Deno.Signal.SIGTERM);
+ * console.log("SIGTERM received!")
+ *
+ * If you want to stop receiving the signals, you can use `.dispose()` method
+ * of the signal stream object.
+ *
+ * const sig = Deno.signal(Deno.Signal.SIGTERM);
+ * setTimeout(() => { sig.dispose(); }, 5000);
+ * for await (const _ of sig) {
+ * console.log("SIGTERM!")
+ * }
+ *
+ * The above for-await loop exits after 5 seconds when `sig.dispose()` is
+ * called.
+ *
+ * NOTE: This functionality is not yet implemented on Windows.
+ */
+ export function signal(signo: number): SignalStream;
+
+ /** **UNSTABLE**: new API, yet to be vetted. */
+ export const signals: {
+ /** Returns the stream of SIGALRM signals.
+ *
+ * This method is the shorthand for `Deno.signal(Deno.Signal.SIGALRM)`. */
+ alarm: () => SignalStream;
+ /** Returns the stream of SIGCHLD signals.
+ *
+ * This method is the shorthand for `Deno.signal(Deno.Signal.SIGCHLD)`. */
+ child: () => SignalStream;
+ /** Returns the stream of SIGHUP signals.
+ *
+ * This method is the shorthand for `Deno.signal(Deno.Signal.SIGHUP)`. */
+ hungup: () => SignalStream;
+ /** Returns the stream of SIGINT signals.
+ *
+ * This method is the shorthand for `Deno.signal(Deno.Signal.SIGINT)`. */
+ interrupt: () => SignalStream;
+ /** Returns the stream of SIGIO signals.
+ *
+ * This method is the shorthand for `Deno.signal(Deno.Signal.SIGIO)`. */
+ io: () => SignalStream;
+ /** Returns the stream of SIGPIPE signals.
+ *
+ * This method is the shorthand for `Deno.signal(Deno.Signal.SIGPIPE)`. */
+ pipe: () => SignalStream;
+ /** Returns the stream of SIGQUIT signals.
+ *
+ * This method is the shorthand for `Deno.signal(Deno.Signal.SIGQUIT)`. */
+ quit: () => SignalStream;
+ /** Returns the stream of SIGTERM signals.
+ *
+ * This method is the shorthand for `Deno.signal(Deno.Signal.SIGTERM)`. */
+ terminate: () => SignalStream;
+ /** Returns the stream of SIGUSR1 signals.
+ *
+ * This method is the shorthand for `Deno.signal(Deno.Signal.SIGUSR1)`. */
+ userDefined1: () => SignalStream;
+ /** Returns the stream of SIGUSR2 signals.
+ *
+ * This method is the shorthand for `Deno.signal(Deno.Signal.SIGUSR2)`. */
+ userDefined2: () => SignalStream;
+ /** Returns the stream of SIGWINCH signals.
+ *
+ * This method is the shorthand for `Deno.signal(Deno.Signal.SIGWINCH)`. */
+ windowChange: () => SignalStream;
+ };
+
+ /** **UNSTABLE**: new API, yet to be vetted
+ *
+ * Set TTY to be under raw mode or not. In raw mode, characters are read and
+ * returned as is, without being processed. All special processing of
+ * characters by the terminal is disabled, including echoing input characters.
+ * Reading from a TTY device in raw mode is faster than reading from a TTY
+ * device in canonical mode.
+ *
+ * Deno.setRaw(myTTY.rid, true);
+ */
+ export function setRaw(rid: number, mode: boolean): void;
+
+ /** **UNSTABLE**: needs investigation into high precision time.
+ *
+ * Synchronously changes the access (`atime`) and modification (`mtime`) times
+ * of a file system object referenced by `path`. Given times are either in
+ * seconds (UNIX epoch time) or as `Date` objects.
+ *
+ * Deno.utimeSync("myfile.txt", 1556495550, new Date());
+ *
+ * Requires `allow-write` permission. */
+ export function utimeSync(
+ path: string,
+ atime: number | Date,
+ mtime: number | Date
+ ): void;
+
+ /** **UNSTABLE**: needs investigation into high precision time.
+ *
+ * Changes the access (`atime`) and modification (`mtime`) times of a file
+ * system object referenced by `path`. Given times are either in seconds
+ * (UNIX epoch time) or as `Date` objects.
+ *
+ * await Deno.utime("myfile.txt", 1556495550, new Date());
+ *
+ * Requires `allow-write` permission. */
+ export function utime(
+ path: string,
+ atime: number | Date,
+ mtime: number | Date
+ ): Promise<void>;
+
+ /** **UNSTABLE**: Maybe remove `ShutdownMode` entirely.
+ *
+ * Corresponds to `SHUT_RD`, `SHUT_WR`, `SHUT_RDWR` on POSIX-like systems.
+ *
+ * See: http://man7.org/linux/man-pages/man2/shutdown.2.html */
+ export enum ShutdownMode {
+ Read = 0,
+ Write,
+ ReadWrite, // TODO(ry) panics on ReadWrite.
+ }
+
+ /** **UNSTABLE**: Both the `how` parameter and `ShutdownMode` enum are under
+ * consideration for removal.
+ *
+ * Shutdown socket send and receive operations.
+ *
+ * Matches behavior of POSIX shutdown(3).
+ *
+ * const listener = Deno.listen({ port: 80 });
+ * const conn = await listener.accept();
+ * Deno.shutdown(conn.rid, Deno.ShutdownMode.Write);
+ */
+ export function shutdown(rid: number, how: ShutdownMode): Promise<void>;
+
+ /** **UNSTABLE**:: new API, yet to be vetted.
+ *
+ * A generic transport listener for message-oriented protocols. */
+ export interface DatagramConn extends AsyncIterable<[Uint8Array, Addr]> {
+ /** **UNSTABLE**: new API, yet to be vetted.
+ *
+ * Waits for and resolves to the next message to the `UDPConn`. */
+ receive(p?: Uint8Array): Promise<[Uint8Array, Addr]>;
+ /** UNSTABLE: new API, yet to be vetted.
+ *
+ * Sends a message to the target. */
+ send(p: Uint8Array, addr: Addr): Promise<void>;
+ /** UNSTABLE: new API, yet to be vetted.
+ *
+ * Close closes the socket. Any pending message promises will be rejected
+ * with errors. */
+ close(): void;
+ /** Return the address of the `UDPConn`. */
+ readonly addr: Addr;
+ [Symbol.asyncIterator](): AsyncIterableIterator<[Uint8Array, Addr]>;
+ }
+
+ export interface UnixListenOptions {
+ /** A Path to the Unix Socket. */
+ path: string;
+ }
+
+ /** **UNSTABLE**: new API, yet to be vetted.
+ *
+ * Listen announces on the local transport address.
+ *
+ * const listener = Deno.listen({ path: "/foo/bar.sock", transport: "unix" })
+ *
+ * Requires `allow-read` and `allow-write` permission. */
+ export function listen(
+ options: UnixListenOptions & { transport: "unix" }
+ ): Listener;
+
+ /** **UNSTABLE**: new API
+ *
+ * Listen announces on the local transport address.
+ *
+ * const listener1 = Deno.listenDatagram({
+ * port: 80,
+ * transport: "udp"
+ * });
+ * const listener2 = Deno.listenDatagram({
+ * hostname: "golang.org",
+ * port: 80,
+ * transport: "udp"
+ * });
+ *
+ * Requires `allow-net` permission. */
+ export function listenDatagram(
+ options: ListenOptions & { transport: "udp" }
+ ): DatagramConn;
+
+ /** **UNSTABLE**: new API
+ *
+ * Listen announces on the local transport address.
+ *
+ * const listener = Deno.listenDatagram({
+ * address: "/foo/bar.sock",
+ * transport: "unixpacket"
+ * });
+ *
+ * Requires `allow-read` and `allow-write` permission. */
+ export function listenDatagram(
+ options: UnixListenOptions & { transport: "unixpacket" }
+ ): DatagramConn;
+
+ export interface UnixConnectOptions {
+ transport: "unix";
+ path: string;
+ }
+
+ /**
+ * Connects to the hostname (default is "127.0.0.1") and port on the named
+ * transport (default is "tcp"), and resolves to the connection (`Conn`).
+ *
+ * const conn1 = await Deno.connect({ port: 80 });
+ * const conn2 = await Deno.connect({ hostname: "192.0.2.1", port: 80 });
+ * const conn3 = await Deno.connect({ hostname: "[2001:db8::1]", port: 80 });
+ * const conn4 = await Deno.connect({ hostname: "golang.org", port: 80, transport: "tcp" });
+ * const conn5 = await Deno.connect({ path: "/foo/bar.sock", transport: "unix" });
+ *
+ * Requires `allow-net` permission for "tcp" and `allow-read` for unix. */
+ export function connect(
+ options: ConnectOptions | UnixConnectOptions
+ ): Promise<Conn>;
+
+ /**
+ * **UNSTABLE**: Currently under evaluation to decide if explicit permission is
+ * required to get the value of the current working directory.
+ *
+ * Return a string representing the current working directory.
+ *
+ * If the current directory can be reached via multiple paths (due to symbolic
+ * links), `cwd()` may return any one of them.
+ *
+ * const currentWorkingDirectory = Deno.cwd();
+ *
+ * Throws `Deno.errors.NotFound` if directory not available.
+ */
+ export function cwd(): string;
+
+ export interface StartTlsOptions {
+ /** A literal IP address or host name that can be resolved to an IP address.
+ * If not specified, defaults to `127.0.0.1`. */
+ hostname?: string;
+ /** Server certificate file. */
+ certFile?: string;
+ }
+
+ /** **UNSTABLE**: new API, yet to be vetted.
+ *
+ * Start TLS handshake from an existing connection using
+ * an optional cert file, hostname (default is "127.0.0.1"). The
+ * cert file is optional and if not included Mozilla's root certificates will
+ * be used (see also https://github.com/ctz/webpki-roots for specifics)
+ * Using this function requires that the other end of the connection is
+ * prepared for TLS handshake.
+ *
+ * const conn = await Deno.connect({ port: 80, hostname: "127.0.0.1" });
+ * const tlsConn = await Deno.startTls(conn, { certFile: "./certs/my_custom_root_CA.pem", hostname: "127.0.0.1", port: 80 });
+ *
+ * Requires `allow-net` permission.
+ */
+ export function startTls(
+ conn: Conn,
+ options?: StartTlsOptions
+ ): Promise<Conn>;
+
+ /** **UNSTABLE**: The `signo` argument may change to require the Deno.Signal
+ * enum.
+ *
+ * Send a signal to process under given `pid`. This functionality currently
+ * only works on Linux and Mac OS.
+ *
+ * If `pid` is negative, the signal will be sent to the process group
+ * identified by `pid`.
+ *
+ * const p = Deno.run({
+ * cmd: ["python", "-c", "from time import sleep; sleep(10000)"]
+ * });
+ *
+ * Deno.kill(p.pid, Deno.Signal.SIGINT);
+ *
+ * Throws Error (not yet implemented) on Windows
+ *
+ * Requires `allow-run` permission. */
+ export function kill(pid: number, signo: number): void;
+
+ /** The name of a "powerful feature" which needs permission.
+ *
+ * See: https://w3c.github.io/permissions/#permission-registry
+ *
+ * Note that the definition of `PermissionName` in the above spec is swapped
+ * out for a set of Deno permissions which are not web-compatible. */
+ export type PermissionName =
+ | "run"
+ | "read"
+ | "write"
+ | "net"
+ | "env"
+ | "plugin"
+ | "hrtime";
+
+ /** The current status of the permission.
+ *
+ * See: https://w3c.github.io/permissions/#status-of-a-permission */
+ export type PermissionState = "granted" | "denied" | "prompt";
+
+ export interface RunPermissionDescriptor {
+ name: "run";
+ }
+
+ export interface ReadPermissionDescriptor {
+ name: "read";
+ path?: string;
+ }
+
+ export interface WritePermissionDescriptor {
+ name: "write";
+ path?: string;
+ }
+
+ export interface NetPermissionDescriptor {
+ name: "net";
+ url?: string;
+ }
+
+ export interface EnvPermissionDescriptor {
+ name: "env";
+ }
+
+ export interface PluginPermissionDescriptor {
+ name: "plugin";
+ }
+
+ export interface HrtimePermissionDescriptor {
+ name: "hrtime";
+ }
+
+ /** Permission descriptors which define a permission and can be queried,
+ * requested, or revoked.
+ *
+ * See: https://w3c.github.io/permissions/#permission-descriptor */
+ export type PermissionDescriptor =
+ | RunPermissionDescriptor
+ | ReadPermissionDescriptor
+ | WritePermissionDescriptor
+ | NetPermissionDescriptor
+ | EnvPermissionDescriptor
+ | PluginPermissionDescriptor
+ | HrtimePermissionDescriptor;
+
+ export class Permissions {
+ /** Resolves to the current status of a permission.
+ *
+ * const status = await Deno.permissions.query({ name: "read", path: "/etc" });
+ * if (status.state === "granted") {
+ * data = await Deno.readFile("/etc/passwd");
+ * }
+ */
+ query(desc: PermissionDescriptor): Promise<PermissionStatus>;
+
+ /** Revokes a permission, and resolves to the state of the permission.
+ *
+ * const status = await Deno.permissions.revoke({ name: "run" });
+ * assert(status.state !== "granted")
+ */
+ revoke(desc: PermissionDescriptor): Promise<PermissionStatus>;
+
+ /** Requests the permission, and resolves to the state of the permission.
+ *
+ * const status = await Deno.permissions.request({ name: "env" });
+ * if (status.state === "granted") {
+ * console.log(Deno.homeDir());
+ * } else {
+ * console.log("'env' permission is denied.");
+ * }
+ */
+ request(desc: PermissionDescriptor): Promise<PermissionStatus>;
+ }
+
+ /** **UNSTABLE**: maybe move to `navigator.permissions` to match web API. It
+ * could look like `navigator.permissions.query({ name: Deno.symbols.read })`.
+ */
+ export const permissions: Permissions;
+
+ /** see: https://w3c.github.io/permissions/#permissionstatus */
+ export class PermissionStatus {
+ state: PermissionState;
+ constructor(state: PermissionState);
+ }
+}
diff --git a/cli/js/net.ts b/cli/js/net.ts
index b06a4189a..5094351b2 100644
--- a/cli/js/net.ts
+++ b/cli/js/net.ts
@@ -48,6 +48,7 @@ export class ConnImpl implements Conn {
close(this.rid);
}
+ // TODO(lucacasonato): make this unavailable in stable
closeWrite(): void {
netOps.shutdown(this.rid, netOps.ShutdownMode.Write);
}
@@ -141,59 +142,22 @@ export interface Conn extends Reader, Writer, Closer {
export interface ListenOptions {
port: number;
hostname?: string;
- transport?: "tcp" | "udp";
-}
-
-export interface UnixListenOptions {
- transport: "unix" | "unixpacket";
- path: string;
+ transport?: "tcp";
}
export function listen(
options: ListenOptions & { transport?: "tcp" }
): Listener;
-export function listen(
- options: UnixListenOptions & { transport: "unix" }
-): Listener;
-export function listen(options: ListenOptions | UnixListenOptions): Listener {
- let res;
-
- if (options.transport === "unix") {
- res = netOps.listen(options);
- } else {
- res = netOps.listen({
- transport: "tcp",
- hostname: "127.0.0.1",
- ...(options as ListenOptions),
- });
- }
+export function listen(options: ListenOptions): Listener {
+ const res = netOps.listen({
+ transport: "tcp",
+ hostname: "127.0.0.1",
+ ...(options as ListenOptions),
+ });
return new ListenerImpl(res.rid, res.localAddr);
}
-export function listenDatagram(
- options: ListenOptions & { transport: "udp" }
-): DatagramConn;
-export function listenDatagram(
- options: UnixListenOptions & { transport: "unixpacket" }
-): DatagramConn;
-export function listenDatagram(
- options: ListenOptions | UnixListenOptions
-): DatagramConn {
- let res;
- if (options.transport === "unixpacket") {
- res = netOps.listen(options);
- } else {
- res = netOps.listen({
- transport: "udp",
- hostname: "127.0.0.1",
- ...(options as ListenOptions),
- });
- }
-
- return new DatagramImpl(res.rid, res.localAddr);
-}
-
export interface ConnectOptions {
port: number;
hostname?: string;
diff --git a/cli/js/net_unstable.ts b/cli/js/net_unstable.ts
new file mode 100644
index 000000000..24c1d619d
--- /dev/null
+++ b/cli/js/net_unstable.ts
@@ -0,0 +1,79 @@
+import * as netOps from "./ops/net.ts";
+import {
+ Listener,
+ DatagramConn,
+ ListenerImpl,
+ DatagramImpl,
+ ConnectOptions,
+ Conn,
+ ConnImpl,
+ listen as stableListen,
+ connect as stableConnect,
+} from "./net.ts";
+
+export interface ListenOptions {
+ port: number;
+ hostname?: string;
+ transport?: "tcp" | "udp";
+}
+
+export interface UnixListenOptions {
+ transport: "unix" | "unixpacket";
+ path: string;
+}
+
+export function listen(
+ options: ListenOptions & { transport?: "tcp" }
+): Listener;
+export function listen(
+ options: UnixListenOptions & { transport: "unix" }
+): Listener;
+export function listen(options: ListenOptions | UnixListenOptions): Listener {
+ if (options.transport === "unix") {
+ const res = netOps.listen(options);
+ return new ListenerImpl(res.rid, res.localAddr);
+ } else {
+ return stableListen(options as ListenOptions & { transport?: "tcp" });
+ }
+}
+
+export function listenDatagram(
+ options: ListenOptions & { transport: "udp" }
+): DatagramConn;
+export function listenDatagram(
+ options: UnixListenOptions & { transport: "unixpacket" }
+): DatagramConn;
+export function listenDatagram(
+ options: ListenOptions | UnixListenOptions
+): DatagramConn {
+ let res;
+ if (options.transport === "unixpacket") {
+ res = netOps.listen(options);
+ } else {
+ res = netOps.listen({
+ transport: "udp",
+ hostname: "127.0.0.1",
+ ...(options as ListenOptions),
+ });
+ }
+
+ return new DatagramImpl(res.rid, res.localAddr);
+}
+
+export interface UnixConnectOptions {
+ transport: "unix";
+ path: string;
+}
+
+export async function connect(options: UnixConnectOptions): Promise<Conn>;
+export async function connect(options: ConnectOptions): Promise<Conn>;
+export async function connect(
+ options: ConnectOptions | UnixConnectOptions
+): Promise<Conn> {
+ if (options.transport === "unix") {
+ const res = await netOps.connect(options);
+ return new ConnImpl(res.rid, res.remoteAddr!, res.localAddr!);
+ } else {
+ return stableConnect(options as ConnectOptions);
+ }
+}
diff --git a/cli/js/ops/runtime.ts b/cli/js/ops/runtime.ts
index 247f0576d..a64c1f8f6 100644
--- a/cli/js/ops/runtime.ts
+++ b/cli/js/ops/runtime.ts
@@ -3,20 +3,19 @@
import { sendSync } from "./dispatch_json.ts";
export interface Start {
- cwd: string;
- pid: number;
args: string[];
- location: string; // Absolute URL.
- repl: boolean;
+ cwd: string;
debugFlag: boolean;
- depsFlag: boolean;
- typesFlag: boolean;
- versionFlag: boolean;
denoVersion: string;
- v8Version: string;
- tsVersion: string;
+ location: string; // Absolute URL.
noColor: boolean;
+ pid: number;
+ repl: boolean;
target: string;
+ tsVersion: string;
+ unstableFlag: boolean;
+ v8Version: string;
+ versionFlag: boolean;
}
export function opStart(): Start {
diff --git a/cli/js/runtime_main.ts b/cli/js/runtime_main.ts
index 6c6617be0..b2ed5d52b 100644
--- a/cli/js/runtime_main.ts
+++ b/cli/js/runtime_main.ts
@@ -7,7 +7,8 @@
// - `bootstrapMainRuntime` - must be called once, when Isolate is created.
// It sets up runtime by providing globals for `WindowScope` and adds `Deno` global.
-import * as Deno from "./deno.ts";
+import * as denoNs from "./deno.ts";
+import * as denoUnstableNs from "./deno_unstable.ts";
import * as csprng from "./ops/get_random_values.ts";
import { exit } from "./ops/os.ts";
import {
@@ -19,6 +20,7 @@ import {
eventTargetProperties,
setEventTargetData,
} from "./globals.ts";
+import { unstableMethods, unstableProperties } from "./globals_unstable.ts";
import { internalObject, internalSymbol } from "./internals.ts";
import { setSignals } from "./signals.ts";
import { replLoop } from "./repl.ts";
@@ -31,7 +33,7 @@ import { log, immutableDefine } from "./util.ts";
// Add internal object to Deno object.
// This is not exposed as part of the Deno types.
// @ts-ignore
-Deno[internalSymbol] = internalObject;
+denoNs[internalSymbol] = internalObject;
let windowIsClosing = false;
@@ -96,29 +98,44 @@ export function bootstrapMainRuntime(): void {
}
});
- const s = runtime.start();
+ const {
+ args,
+ cwd,
+ location,
+ noColor,
+ pid,
+ repl,
+ unstableFlag,
+ } = runtime.start();
- const location = new LocationImpl(s.location);
- immutableDefine(globalThis, "location", location);
+ const location_ = new LocationImpl(location);
+ immutableDefine(globalThis, "location", location_);
Object.freeze(globalThis.location);
- Object.defineProperties(Deno, {
- pid: readOnly(s.pid),
- noColor: readOnly(s.noColor),
- args: readOnly(Object.freeze(s.args)),
+ Object.defineProperties(denoNs, {
+ pid: readOnly(pid),
+ noColor: readOnly(noColor),
+ args: readOnly(Object.freeze(args)),
});
+
+ if (unstableFlag) {
+ Object.defineProperties(globalThis, unstableMethods);
+ Object.defineProperties(globalThis, unstableProperties);
+ Object.assign(denoNs, denoUnstableNs);
+ }
+
// Setup `Deno` global - we're actually overriding already
// existing global `Deno` with `Deno` namespace from "./deno.ts".
- immutableDefine(globalThis, "Deno", Deno);
+ immutableDefine(globalThis, "Deno", denoNs);
Object.freeze(globalThis.Deno);
Object.freeze(globalThis.Deno.core);
Object.freeze(globalThis.Deno.core.sharedQueue);
setSignals();
- log("cwd", s.cwd);
- log("args", Deno.args);
+ log("cwd", cwd);
+ log("args", args);
- if (s.repl) {
+ if (repl) {
replLoop();
}
}
diff --git a/cli/js/runtime_worker.ts b/cli/js/runtime_worker.ts
index 0e6e84da8..1e456f016 100644
--- a/cli/js/runtime_worker.ts
+++ b/cli/js/runtime_worker.ts
@@ -17,7 +17,9 @@ import {
eventTargetProperties,
setEventTargetData,
} from "./globals.ts";
-import * as Deno from "./deno.ts";
+import { unstableMethods, unstableProperties } from "./globals_unstable.ts";
+import * as denoNs from "./deno.ts";
+import * as denoUnstableNs from "./deno_unstable.ts";
import * as webWorkerOps from "./ops/web_worker.ts";
import { LocationImpl } from "./web/location.ts";
import { log, assert, immutableDefine } from "./util.ts";
@@ -32,7 +34,7 @@ import { setSignals } from "./signals.ts";
// Add internal object to Deno object.
// This is not exposed as part of the Deno types.
// @ts-ignore
-Deno[internalSymbol] = internalObject;
+denoNs[internalSymbol] = internalObject;
const encoder = new TextEncoder();
@@ -136,21 +138,31 @@ export function bootstrapWorkerRuntime(
Object.defineProperties(globalThis, eventTargetProperties);
Object.defineProperties(globalThis, { name: readOnly(name) });
setEventTargetData(globalThis);
- const s = runtime.start(internalName ?? name);
+ const { location, unstableFlag, pid, noColor, args } = runtime.start(
+ internalName ?? name
+ );
- const location = new LocationImpl(s.location);
- immutableDefine(globalThis, "location", location);
+ const location_ = new LocationImpl(location);
+ immutableDefine(globalThis, "location", location_);
Object.freeze(globalThis.location);
+ if (unstableFlag) {
+ Object.defineProperties(globalThis, unstableMethods);
+ Object.defineProperties(globalThis, unstableProperties);
+ }
+
if (useDenoNamespace) {
- Object.defineProperties(Deno, {
- pid: readOnly(s.pid),
- noColor: readOnly(s.noColor),
- args: readOnly(Object.freeze(s.args)),
+ if (unstableFlag) {
+ Object.assign(denoNs, denoUnstableNs);
+ }
+ Object.defineProperties(denoNs, {
+ pid: readOnly(pid),
+ noColor: readOnly(noColor),
+ args: readOnly(Object.freeze(args)),
});
// Setup `Deno` global - we're actually overriding already
// existing global `Deno` with `Deno` namespace from "./deno.ts".
- immutableDefine(globalThis, "Deno", Deno);
+ immutableDefine(globalThis, "Deno", denoNs);
Object.freeze(globalThis.Deno);
Object.freeze(globalThis.Deno.core);
Object.freeze(globalThis.Deno.core.sharedQueue);
diff --git a/cli/lib.rs b/cli/lib.rs
index 9d35710ab..fc37ff2af 100644
--- a/cli/lib.rs
+++ b/cli/lib.rs
@@ -253,13 +253,23 @@ async fn print_file_info(
Ok(())
}
-fn get_types() -> String {
- format!(
- "{}\n{}\n{}",
- crate::js::DENO_NS_LIB,
- crate::js::SHARED_GLOBALS_LIB,
- crate::js::WINDOW_LIB
- )
+fn get_types(unstable: bool) -> String {
+ if unstable {
+ format!(
+ "{}\n{}\n{}\n{}",
+ crate::js::DENO_NS_LIB,
+ crate::js::SHARED_GLOBALS_LIB,
+ crate::js::WINDOW_LIB,
+ crate::js::UNSTABLE_NS_LIB,
+ )
+ } else {
+ format!(
+ "{}\n{}\n{}",
+ crate::js::DENO_NS_LIB,
+ crate::js::SHARED_GLOBALS_LIB,
+ crate::js::WINDOW_LIB,
+ )
+ }
}
async fn info_command(
@@ -409,7 +419,7 @@ async fn doc_command(
let doc_parser = doc::DocParser::new(loader);
let parse_result = if source_file == "--builtin" {
- doc_parser.parse_source("lib.deno.d.ts", get_types().as_str())
+ doc_parser.parse_source("lib.deno.d.ts", get_types(flags.unstable).as_str())
} else {
let module_specifier =
ModuleSpecifier::resolve_url_or_path(&source_file).unwrap();
@@ -598,7 +608,7 @@ pub fn main() {
return;
}
DenoSubcommand::Types => {
- let types = get_types();
+ let types = get_types(flags.unstable);
if let Err(e) = write_to_stdout_ignore_sigpipe(types.as_bytes()) {
eprintln!("{}", e);
std::process::exit(1);
diff --git a/cli/ops/runtime.rs b/cli/ops/runtime.rs
index 96bf451ed..0d92b0692 100644
--- a/cli/ops/runtime.rs
+++ b/cli/ops/runtime.rs
@@ -24,18 +24,19 @@ fn op_start(
Ok(JsonOp::Sync(json!({
// TODO(bartlomieju): `cwd` field is not used in JS, remove?
- "cwd": &env::current_dir().unwrap(),
- "pid": std::process::id(),
"args": gs.flags.argv.clone(),
- "repl": gs.flags.subcommand == DenoSubcommand::Repl,
- "location": state.main_module.to_string(),
+ "cwd": &env::current_dir().unwrap(),
"debugFlag": gs.flags.log_level.map_or(false, |l| l == log::Level::Debug),
- "versionFlag": gs.flags.version,
- "v8Version": version::v8(),
"denoVersion": version::DENO,
- "tsVersion": version::TYPESCRIPT,
+ "location": state.main_module.to_string(),
"noColor": !colors::use_color(),
+ "pid": std::process::id(),
+ "repl": gs.flags.subcommand == DenoSubcommand::Repl,
"target": env!("TARGET"),
+ "tsVersion": version::TYPESCRIPT,
+ "unstableFlag": gs.flags.unstable,
+ "v8Version": version::v8(),
+ "versionFlag": gs.flags.version,
})))
}
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs
index abf7ba372..fb2d7e73b 100644
--- a/cli/tests/integration_tests.rs
+++ b/cli/tests/integration_tests.rs
@@ -273,6 +273,7 @@ fn js_unit_tests() {
let mut deno = util::deno_cmd()
.current_dir(util::root_path())
.arg("run")
+ .arg("--unstable")
.arg("--reload")
.arg("-A")
.arg("cli/js/tests/unit_test_runner.ts")
@@ -952,8 +953,9 @@ itest_ignore!(_024_import_no_ext_with_headers {
output: "024_import_no_ext_with_headers.ts.out",
});
+// TODO(lucacasonato): remove --unstable when permissions goes stable
itest!(_025_hrtime {
- args: "run --allow-hrtime --reload 025_hrtime.ts",
+ args: "run --allow-hrtime --unstable --reload 025_hrtime.ts",
output: "025_hrtime.ts.out",
});
@@ -1158,13 +1160,16 @@ itest!(_055_import_wasm_via_network {
http_server: true,
});
+// TODO(lucacasonato): remove --unstable when cwd goes stable
itest!(_056_make_temp_file_write_perm {
- args: "run --allow-write=./subdir/ 056_make_temp_file_write_perm.ts",
+ args:
+ "run --allow-write=./subdir/ --unstable 056_make_temp_file_write_perm.ts",
output: "056_make_temp_file_write_perm.out",
});
+// TODO(lucacasonato): remove --unstable when permissions goes stable
itest!(_057_revoke_permissions {
- args: "test -A 057_revoke_permissions.ts",
+ args: "test -A --unstable 057_revoke_permissions.ts",
output: "057_revoke_permissions.out",
});
@@ -1575,11 +1580,26 @@ itest!(top_level_for_await_ts {
output: "top_level_for_await.out",
});
-itest!(unstable {
- args: "run unstable.js",
+itest!(unstable_disabled {
+ args: "run --reload unstable.ts",
check_stderr: true,
- exit_code: 70,
- output: "unstable.out",
+ exit_code: 1,
+ output: "unstable_disabled.out",
+});
+
+itest!(unstable_enabled {
+ args: "run --reload --unstable unstable.ts",
+ output: "unstable_enabled.out",
+});
+
+itest!(unstable_disabled_js {
+ args: "run --reload unstable.js",
+ output: "unstable_disabled_js.out",
+});
+
+itest!(unstable_enabled_js {
+ args: "run --reload --unstable unstable.ts",
+ output: "unstable_enabled_js.out",
});
itest!(_053_import_compression {
diff --git a/cli/tests/unstable.js b/cli/tests/unstable.js
index e6f2274cd..a9894be3e 100644
--- a/cli/tests/unstable.js
+++ b/cli/tests/unstable.js
@@ -1,2 +1 @@
-// This program should require the --unstable flag
-Deno.openPlugin("foo");
+console.log(Deno.loadavg);
diff --git a/cli/tests/unstable.out b/cli/tests/unstable.out
deleted file mode 100644
index 31fead7d9..000000000
--- a/cli/tests/unstable.out
+++ /dev/null
@@ -1 +0,0 @@
-Unstable API 'Deno.openPlugin'. The --unstable flag must be provided.
diff --git a/cli/tests/unstable.ts b/cli/tests/unstable.ts
new file mode 100644
index 000000000..a9894be3e
--- /dev/null
+++ b/cli/tests/unstable.ts
@@ -0,0 +1 @@
+console.log(Deno.loadavg);
diff --git a/cli/tests/unstable_disabled.out b/cli/tests/unstable_disabled.out
new file mode 100644
index 000000000..ca88df9c8
--- /dev/null
+++ b/cli/tests/unstable_disabled.out
@@ -0,0 +1,5 @@
+[WILDCARD]
+error TS2339: Property 'loadavg' does not exist on type 'typeof Deno'.
+console.log(Deno.loadavg);
+ ~~~~~~~
+ at [WILDCARD]/cli/tests/unstable.ts:1:18
diff --git a/cli/tests/unstable_disabled_js.out b/cli/tests/unstable_disabled_js.out
new file mode 100644
index 000000000..417b7b537
--- /dev/null
+++ b/cli/tests/unstable_disabled_js.out
@@ -0,0 +1 @@
+undefined
diff --git a/cli/tests/unstable_enabled.out b/cli/tests/unstable_enabled.out
new file mode 100644
index 000000000..b4cedce14
--- /dev/null
+++ b/cli/tests/unstable_enabled.out
@@ -0,0 +1 @@
+[Function: loadavg]
diff --git a/cli/tests/unstable_enabled_js.out b/cli/tests/unstable_enabled_js.out
new file mode 100644
index 000000000..b4cedce14
--- /dev/null
+++ b/cli/tests/unstable_enabled_js.out
@@ -0,0 +1 @@
+[Function: loadavg]
diff --git a/std/examples/chat/server_test.ts b/std/examples/chat/server_test.ts
index 1aba4208a..76b1f1bf5 100644
--- a/std/examples/chat/server_test.ts
+++ b/std/examples/chat/server_test.ts
@@ -9,7 +9,14 @@ const { test } = Deno;
async function startServer(): Promise<Deno.Process> {
const server = Deno.run({
- cmd: [Deno.execPath(), "--allow-net", "--allow-read", "server.ts"],
+ // TODO(lucacasonato): remove unstable once possible
+ cmd: [
+ Deno.execPath(),
+ "--allow-net",
+ "--allow-read",
+ "--unstable",
+ "server.ts",
+ ],
cwd: "examples/chat",
stdout: "piped",
});
diff --git a/std/fs/empty_dir_test.ts b/std/fs/empty_dir_test.ts
index b3be1f617..254cf590f 100644
--- a/std/fs/empty_dir_test.ts
+++ b/std/fs/empty_dir_test.ts
@@ -203,7 +203,8 @@ for (const s of scenes) {
);
try {
- const args = [Deno.execPath(), "run"];
+ // TODO(lucacasonato): remove unstable when stabilized
+ const args = [Deno.execPath(), "run", "--unstable"];
if (s.read) {
args.push("--allow-read");
diff --git a/std/fs/exists_test.ts b/std/fs/exists_test.ts
index 04c58d8d6..191289d88 100644
--- a/std/fs/exists_test.ts
+++ b/std/fs/exists_test.ts
@@ -112,7 +112,8 @@ for (const s of scenes) {
let title = `test ${s.async ? "exists" : "existsSync"}("testdata/${s.file}")`;
title += ` ${s.read ? "with" : "without"} --allow-read`;
Deno.test(`[fs] existsPermission ${title}`, async function (): Promise<void> {
- const args = [Deno.execPath(), "run"];
+ // TODO(lucacasonato): remove unstable when stabilized
+ const args = [Deno.execPath(), "run", "--unstable"];
if (s.read) {
args.push("--allow-read");
diff --git a/std/fs/expand_glob_test.ts b/std/fs/expand_glob_test.ts
index 4a1adc308..697c8bf98 100644
--- a/std/fs/expand_glob_test.ts
+++ b/std/fs/expand_glob_test.ts
@@ -115,7 +115,7 @@ Deno.test("expandGlobIncludeDirs", async function (): Promise<void> {
Deno.test("expandGlobPermError", async function (): Promise<void> {
const exampleUrl = new URL("testdata/expand_wildcard.js", import.meta.url);
const p = run({
- cmd: [execPath(), exampleUrl.toString()],
+ cmd: [execPath(), "--unstable", exampleUrl.toString()],
stdin: "null",
stdout: "piped",
stderr: "piped",
diff --git a/std/http/file_server_test.ts b/std/http/file_server_test.ts
index 8be35621c..d471c1519 100644
--- a/std/http/file_server_test.ts
+++ b/std/http/file_server_test.ts
@@ -12,6 +12,7 @@ async function startFileServer(): Promise<void> {
cmd: [
Deno.execPath(),
"run",
+ "--unstable",
"--allow-read",
"--allow-net",
"http/file_server.ts",
@@ -105,7 +106,14 @@ test("serveWithUnorthodoxFilename", async function (): Promise<void> {
test("servePermissionDenied", async function (): Promise<void> {
const deniedServer = Deno.run({
- cmd: [Deno.execPath(), "run", "--allow-net", "http/file_server.ts"],
+ // TODO(lucacasonato): remove unstable when stabilized
+ cmd: [
+ Deno.execPath(),
+ "run",
+ "--unstable",
+ "--allow-net",
+ "http/file_server.ts",
+ ],
stdout: "piped",
stderr: "piped",
});
@@ -132,7 +140,14 @@ test("servePermissionDenied", async function (): Promise<void> {
test("printHelp", async function (): Promise<void> {
const helpProcess = Deno.run({
- cmd: [Deno.execPath(), "run", "http/file_server.ts", "--help"],
+ // TODO(lucacasonato): remove unstable when stabilized
+ cmd: [
+ Deno.execPath(),
+ "run",
+ "--unstable",
+ "http/file_server.ts",
+ "--help",
+ ],
stdout: "piped",
});
assert(helpProcess.stdout != null);
diff --git a/std/http/racing_server_test.ts b/std/http/racing_server_test.ts
index 90961f7f8..845e5a490 100644
--- a/std/http/racing_server_test.ts
+++ b/std/http/racing_server_test.ts
@@ -6,7 +6,8 @@ const { connect, run, test } = Deno;
let server: Deno.Process;
async function startServer(): Promise<void> {
server = run({
- cmd: [Deno.execPath(), "run", "-A", "http/racing_server.ts"],
+ // TODO(lucacasonato): remove unstable when stabilized
+ cmd: [Deno.execPath(), "run", "--unstable", "-A", "http/racing_server.ts"],
stdout: "piped",
});
// Once racing server is ready it will write to its stdout.
diff --git a/tools/benchmark.py b/tools/benchmark.py
index 031da263b..a921feaf8 100755
--- a/tools/benchmark.py
+++ b/tools/benchmark.py
@@ -213,7 +213,7 @@ def bundle_benchmark(deno_exe):
for name, url in bundles.items():
# bundle
path = name + ".bundle.js"
- run([deno_exe, "bundle", url, path])
+ run([deno_exe, "bundle", "--unstable", url, path])
# get size of bundle
assert os.path.exists(path)
sizes[name] = os.path.getsize(path)
diff --git a/tools/http_benchmark.py b/tools/http_benchmark.py
index fba11ba32..a4576695c 100755
--- a/tools/http_benchmark.py
+++ b/tools/http_benchmark.py
@@ -35,7 +35,11 @@ def get_port(port=None):
def deno_tcp(deno_exe):
port = get_port()
deno_cmd = [
- deno_exe, "run", "--allow-net", "tools/deno_tcp.ts",
+ # TODO(lucacasonato): remove unstable when stabilized
+ deno_exe,
+ "run",
+ "--allow-net",
+ "tools/deno_tcp.ts",
server_addr(port)
]
print "http_benchmark testing DENO tcp."
@@ -45,7 +49,8 @@ def deno_tcp(deno_exe):
def deno_http(deno_exe):
port = get_port()
deno_cmd = [
- deno_exe, "run", "--allow-net", "std/http/http_bench.ts",
+ deno_exe, "run", "--allow-net", "--reload", "--unstable",
+ "std/http/http_bench.ts",
server_addr(port)
]
print "http_benchmark testing DENO using net/http."