mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 09:31:22 -05:00
reorg: cli/js/compiler/, move more API to cli/js/web/ (#4310)
- moves compiler implementation to "cli/js/compiler/" directory - moves more APIs to "cli/js/web": * "console.ts" * "console_table.ts" * "performance.ts" * "timers.ts" * "workers.ts" - removes some dead code from "cli/js/"
This commit is contained in:
parent
94f4c6807a
commit
99a0c6df79
28 changed files with 83 additions and 89 deletions
|
@ -11,23 +11,23 @@
|
|||
// to properly setup runtime.
|
||||
|
||||
// NOTE: this import has side effects!
|
||||
import "./ts_global.d.ts";
|
||||
import "./compiler/ts_global.d.ts";
|
||||
|
||||
import { TranspileOnlyResult } from "./compiler_api.ts";
|
||||
import { TS_SNAPSHOT_PROGRAM } from "./compiler_bootstrap.ts";
|
||||
import { setRootExports } from "./compiler_bundler.ts";
|
||||
import { TranspileOnlyResult } from "./compiler/api.ts";
|
||||
import { TS_SNAPSHOT_PROGRAM } from "./compiler/bootstrap.ts";
|
||||
import { setRootExports } from "./compiler/bundler.ts";
|
||||
import {
|
||||
CompilerHostTarget,
|
||||
defaultBundlerOptions,
|
||||
defaultRuntimeCompileOptions,
|
||||
defaultTranspileOptions,
|
||||
Host
|
||||
} from "./compiler_host.ts";
|
||||
} from "./compiler/host.ts";
|
||||
import {
|
||||
processImports,
|
||||
processLocalImports,
|
||||
resolveModules
|
||||
} from "./compiler_imports.ts";
|
||||
} from "./compiler/imports.ts";
|
||||
import {
|
||||
createWriteFile,
|
||||
CompilerRequestType,
|
||||
|
@ -36,7 +36,7 @@ import {
|
|||
WriteFileState,
|
||||
processConfigureResponse,
|
||||
base64ToUint8Array
|
||||
} from "./compiler_util.ts";
|
||||
} from "./compiler/util.ts";
|
||||
import { Diagnostic, DiagnosticItem } from "./diagnostics.ts";
|
||||
import { fromTypeScriptDiagnostic } from "./diagnostics_util.ts";
|
||||
import { assert } from "./util.ts";
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
// This file contains the runtime APIs which will dispatch work to the internal
|
||||
// compiler within Deno.
|
||||
|
||||
import { DiagnosticItem } from "./diagnostics.ts";
|
||||
import * as util from "./util.ts";
|
||||
import * as runtimeCompilerOps from "./ops/runtime_compiler.ts";
|
||||
import { DiagnosticItem } from "../diagnostics.ts";
|
||||
import * as util from "../util.ts";
|
||||
import * as runtimeCompilerOps from "../ops/runtime_compiler.ts";
|
||||
|
||||
/** A specific subset TypeScript compiler options that can be supported by
|
||||
* the Deno TypeScript compiler. */
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
import { CompilerHostTarget, Host } from "./compiler_host.ts";
|
||||
import { ASSETS } from "./compiler_sourcefile.ts";
|
||||
import { getAsset } from "./compiler_util.ts";
|
||||
import { CompilerHostTarget, Host } from "./host.ts";
|
||||
import { ASSETS } from "./sourcefile.ts";
|
||||
import { getAsset } from "./util.ts";
|
||||
|
||||
// NOTE: target doesn't really matter here,
|
||||
// this is in fact a mock host created just to
|
|
@ -1,12 +1,8 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
import { SYSTEM_LOADER } from "./compiler_bootstrap.ts";
|
||||
import {
|
||||
commonPath,
|
||||
normalizeString,
|
||||
CHAR_FORWARD_SLASH
|
||||
} from "./compiler_util.ts";
|
||||
import { assert } from "./util.ts";
|
||||
import { SYSTEM_LOADER } from "./bootstrap.ts";
|
||||
import { commonPath, normalizeString, CHAR_FORWARD_SLASH } from "./util.ts";
|
||||
import { assert } from "../util.ts";
|
||||
|
||||
/** Local state of what the root exports are of a root module. */
|
||||
let rootExports: string[] | undefined;
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
import { ASSETS, MediaType, SourceFile } from "./compiler_sourcefile.ts";
|
||||
import { OUT_DIR, WriteFileCallback, getAsset } from "./compiler_util.ts";
|
||||
import { cwd } from "./ops/fs/dir.ts";
|
||||
import { assert, notImplemented } from "./util.ts";
|
||||
import * as util from "./util.ts";
|
||||
import { ASSETS, MediaType, SourceFile } from "./sourcefile.ts";
|
||||
import { OUT_DIR, WriteFileCallback, getAsset } from "./util.ts";
|
||||
import { cwd } from "../ops/fs/dir.ts";
|
||||
import { assert, notImplemented } from "../util.ts";
|
||||
import * as util from "../util.ts";
|
||||
|
||||
/** Specifies the target that the host should use to inform the TypeScript
|
||||
* compiler of what types should be used to validate the program against. */
|
|
@ -1,15 +1,11 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
import {
|
||||
MediaType,
|
||||
SourceFile,
|
||||
SourceFileJson
|
||||
} from "./compiler_sourcefile.ts";
|
||||
import { normalizeString, CHAR_FORWARD_SLASH } from "./compiler_util.ts";
|
||||
import { cwd } from "./ops/fs/dir.ts";
|
||||
import { assert } from "./util.ts";
|
||||
import * as util from "./util.ts";
|
||||
import * as compilerOps from "./ops/compiler.ts";
|
||||
import { MediaType, SourceFile, SourceFileJson } from "./sourcefile.ts";
|
||||
import { normalizeString, CHAR_FORWARD_SLASH } from "./util.ts";
|
||||
import { cwd } from "../ops/fs/dir.ts";
|
||||
import { assert } from "../util.ts";
|
||||
import * as util from "../util.ts";
|
||||
import * as compilerOps from "../ops/compiler.ts";
|
||||
|
||||
/** Resolve a path to the final path segment passed. */
|
||||
function resolvePath(...pathSegments: string[]): string {
|
|
@ -1,10 +1,7 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
import {
|
||||
getMappedModuleName,
|
||||
parseTypeDirectives
|
||||
} from "./compiler_type_directives.ts";
|
||||
import { assert, log } from "./util.ts";
|
||||
import { getMappedModuleName, parseTypeDirectives } from "./type_directives.ts";
|
||||
import { assert, log } from "../util.ts";
|
||||
|
||||
// Warning! The values in this enum are duplicated in `cli/msg.rs`
|
||||
// Update carefully!
|
|
@ -1,15 +1,15 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
import { bold, cyan, yellow } from "./colors.ts";
|
||||
import { CompilerOptions } from "./compiler_api.ts";
|
||||
import { buildBundle } from "./compiler_bundler.ts";
|
||||
import { ConfigureResponse, Host } from "./compiler_host.ts";
|
||||
import { SourceFile } from "./compiler_sourcefile.ts";
|
||||
import { atob, TextEncoder } from "./web/text_encoding.ts";
|
||||
import * as compilerOps from "./ops/compiler.ts";
|
||||
import * as util from "./util.ts";
|
||||
import { assert } from "./util.ts";
|
||||
import { writeFileSync } from "./write_file.ts";
|
||||
import { bold, cyan, yellow } from "../colors.ts";
|
||||
import { CompilerOptions } from "./api.ts";
|
||||
import { buildBundle } from "./bundler.ts";
|
||||
import { ConfigureResponse, Host } from "./host.ts";
|
||||
import { SourceFile } from "./sourcefile.ts";
|
||||
import { atob, TextEncoder } from "../web/text_encoding.ts";
|
||||
import * as compilerOps from "../ops/compiler.ts";
|
||||
import * as util from "../util.ts";
|
||||
import { assert } from "../util.ts";
|
||||
import { writeFileSync } from "../write_file.ts";
|
||||
|
||||
/** Type for the write fall callback that allows delegation from the compiler
|
||||
* host on writing files. */
|
|
@ -11,8 +11,8 @@ export {
|
|||
export { build, OperatingSystem, Arch } 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 { inspect } from "./console.ts";
|
||||
export { transpileOnly, compile, bundle } from "./compiler/api.ts";
|
||||
export { inspect } from "./web/console.ts";
|
||||
export { copyFileSync, copyFile } from "./ops/fs/copy_file.ts";
|
||||
export {
|
||||
Diagnostic,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
import * as blob from "./web/blob.ts";
|
||||
import * as consoleTypes from "./console.ts";
|
||||
import * as consoleTypes from "./web/console.ts";
|
||||
import * as customEvent from "./web/custom_event.ts";
|
||||
import * as domTypes from "./web/dom_types.ts";
|
||||
import * as domFile from "./web/dom_file.ts";
|
||||
|
@ -11,11 +11,11 @@ import * as formData from "./web/form_data.ts";
|
|||
import * as fetchTypes from "./web/fetch.ts";
|
||||
import * as headers from "./web/headers.ts";
|
||||
import * as textEncoding from "./web/text_encoding.ts";
|
||||
import * as timers from "./timers.ts";
|
||||
import * as timers from "./web/timers.ts";
|
||||
import * as url from "./web/url.ts";
|
||||
import * as urlSearchParams from "./web/url_search_params.ts";
|
||||
import * as workers from "./workers.ts";
|
||||
import * as performanceUtil from "./performance.ts";
|
||||
import * as workers from "./web/workers.ts";
|
||||
import * as performanceUtil from "./web/performance.ts";
|
||||
import * as request from "./web/request.ts";
|
||||
|
||||
// These imports are not exposed and therefore are fine to just import the
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
export default undefined;
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
import { exit } from "./ops/os.ts";
|
||||
import { core } from "./core.ts";
|
||||
import { stringifyArgs } from "./console.ts";
|
||||
import { stringifyArgs } from "./web/console.ts";
|
||||
import { startRepl, readline } from "./ops/repl.ts";
|
||||
import { close } from "./ops/resources.ts";
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
import { internalSymbol } from "./internals.ts";
|
||||
import { customInspect } from "./console.ts";
|
||||
import { customInspect } from "./web/console.ts";
|
||||
|
||||
/** Special Deno related symbols. */
|
||||
export const symbols = {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
import { red, green, bgRed, gray, italic } from "./colors.ts";
|
||||
import { exit } from "./ops/os.ts";
|
||||
import { Console } from "./console.ts";
|
||||
import { Console } from "./web/console.ts";
|
||||
|
||||
function formatDuration(time = 0): string {
|
||||
const timeStr = `(${time}ms)`;
|
||||
|
|
8
cli/js/web/README.md
Normal file
8
cli/js/web/README.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
# Deno Web APIs
|
||||
|
||||
This directory facilities Web APIs that are available in Deno.
|
||||
|
||||
Please note, that some of implementations might not be completely aligned with
|
||||
specification.
|
||||
|
||||
Some of the Web APIs are using ops under the hood, eg. `console`, `performance`.
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
import { isTypedArray } from "./util.ts";
|
||||
import { TypedArray } from "./types.ts";
|
||||
import { TextEncoder } from "./web/text_encoding.ts";
|
||||
import { File, stdout } from "./files.ts";
|
||||
import { isTypedArray } from "../util.ts";
|
||||
import { TypedArray } from "../types.ts";
|
||||
import { TextEncoder } from "./text_encoding.ts";
|
||||
import { File, stdout } from "../files.ts";
|
||||
import { cliTable } from "./console_table.ts";
|
||||
import { exposeForTest } from "./internals.ts";
|
||||
import { exposeForTest } from "../internals.ts";
|
||||
|
||||
type ConsoleContext = Set<unknown>;
|
||||
type ConsoleOptions = Partial<{
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright Joyent, Inc. and other Node contributors. MIT license.
|
||||
// Forked from Node's lib/internal/cli_table.js
|
||||
|
||||
import { TextEncoder } from "./web/text_encoding.ts";
|
||||
import { hasOwnProperty } from "./util.ts";
|
||||
import { TextEncoder } from "./text_encoding.ts";
|
||||
import { hasOwnProperty } from "../util.ts";
|
||||
|
||||
const encoder = new TextEncoder();
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
import * as domTypes from "./dom_types.ts";
|
||||
import { DomIterableMixin } from "./dom_iterable.ts";
|
||||
import { requiredArguments } from "../util.ts";
|
||||
import { customInspect } from "../console.ts";
|
||||
import { customInspect } from "./console.ts";
|
||||
|
||||
// From node-fetch
|
||||
// Copyright (c) 2016 David Frank. MIT License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
import { now as opNow } from "./ops/timers.ts";
|
||||
import { now as opNow } from "../ops/timers.ts";
|
||||
|
||||
export class Performance {
|
||||
/** Returns a current time from Deno's start in milliseconds.
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
import { assert } from "./util.ts";
|
||||
import { startGlobalTimer, stopGlobalTimer } from "./ops/timers.ts";
|
||||
import { RBTree } from "./rbtree.ts";
|
||||
import { assert } from "../util.ts";
|
||||
import { startGlobalTimer, stopGlobalTimer } from "../ops/timers.ts";
|
||||
import { RBTree } from "../rbtree.ts";
|
||||
|
||||
const { console } = globalThis;
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
import * as urlSearchParams from "./url_search_params.ts";
|
||||
import * as domTypes from "./dom_types.ts";
|
||||
import { getRandomValues } from "../ops/get_random_values.ts";
|
||||
import { customInspect } from "../console.ts";
|
||||
import { customInspect } from "./console.ts";
|
||||
|
||||
interface URLParts {
|
||||
protocol: string;
|
||||
|
|
|
@ -5,15 +5,15 @@ import {
|
|||
hostTerminateWorker,
|
||||
hostPostMessage,
|
||||
hostGetMessage
|
||||
} from "./ops/worker_host.ts";
|
||||
import { log } from "./util.ts";
|
||||
import { TextDecoder, TextEncoder } from "./web/text_encoding.ts";
|
||||
} from "../ops/worker_host.ts";
|
||||
import { log } from "../util.ts";
|
||||
import { TextDecoder, TextEncoder } from "./text_encoding.ts";
|
||||
/*
|
||||
import { blobURLMap } from "./web/url.ts";
|
||||
import { blobBytesWeakMap } from "./web/blob.ts";
|
||||
*/
|
||||
import { Event } from "./web/event.ts";
|
||||
import { EventTarget } from "./web/event_target.ts";
|
||||
import { Event } from "./event.ts";
|
||||
import { EventTarget } from "./event_target.ts";
|
||||
|
||||
const encoder = new TextEncoder();
|
||||
const decoder = new TextDecoder();
|
|
@ -389,7 +389,6 @@ mod tests {
|
|||
assert_eq!(actual.message, "TypeError: baz");
|
||||
// Because this is accessing the live bundle, this test might be more fragile
|
||||
assert_eq!(actual.frames.len(), 1);
|
||||
assert_eq!(actual.frames[0].script_name, "$deno$/io.ts");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
[WILDCARD]dispatch_json.ts:[WILDCARD]
|
||||
at unwrapResponse ($deno$/ops/dispatch_json.ts:[WILDCARD])
|
||||
at sendSync ($deno$/ops/dispatch_json.ts:[WILDCARD])
|
||||
at resolveModules ($deno$/compiler_imports.ts:[WILDCARD])
|
||||
at processImports ($deno$/compiler_imports.ts:[WILDCARD])
|
||||
at processImports ($deno$/compiler_imports.ts:[WILDCARD])
|
||||
at resolveModules ($deno$/compiler/imports.ts:[WILDCARD])
|
||||
at processImports ($deno$/compiler/imports.ts:[WILDCARD])
|
||||
at processImports ($deno$/compiler/imports.ts:[WILDCARD])
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
[WILDCARD]dispatch_json.ts:[WILDCARD]
|
||||
at unwrapResponse ($deno$/ops/dispatch_json.ts:[WILDCARD])
|
||||
at sendSync ($deno$/ops/dispatch_json.ts:[WILDCARD])
|
||||
at resolveModules ($deno$/compiler_imports.ts:[WILDCARD])
|
||||
at processImports ($deno$/compiler_imports.ts:[WILDCARD])
|
||||
at processImports ($deno$/compiler_imports.ts:[WILDCARD])
|
||||
at resolveModules ($deno$/compiler/imports.ts:[WILDCARD])
|
||||
at processImports ($deno$/compiler/imports.ts:[WILDCARD])
|
||||
at processImports ($deno$/compiler/imports.ts:[WILDCARD])
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
[WILDCARD]dispatch_json.ts:[WILDCARD]
|
||||
at unwrapResponse ($deno$/ops/dispatch_json.ts:[WILDCARD])
|
||||
at sendSync ($deno$/ops/dispatch_json.ts:[WILDCARD])
|
||||
at resolveModules ($deno$/compiler_imports.ts:[WILDCARD])
|
||||
at processImports ($deno$/compiler_imports.ts:[WILDCARD])
|
||||
at processImports ($deno$/compiler_imports.ts:[WILDCARD])
|
||||
at resolveModules ($deno$/compiler/imports.ts:[WILDCARD])
|
||||
at processImports ($deno$/compiler/imports.ts:[WILDCARD])
|
||||
at processImports ($deno$/compiler/imports.ts:[WILDCARD])
|
||||
|
|
Loading…
Add table
Reference in a new issue