1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-22 06:09:25 -05:00

reorg: move JS ops implementations to cli/js/ops/, part 1 (#4264)

Following JS ops were moved to separate files in cli/js/ops directory:
- compiler
- dispatch_json
- dispatch_minimal
- errors
- fetch
- fs_events
- os
- random
- repl
- resources
- runtime_compiler
- runtime
- tty
This commit is contained in:
Bartek Iwańczuk 2020-03-08 13:09:22 +01:00 committed by GitHub
parent b9037c86ed
commit 1b6f831875
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
57 changed files with 304 additions and 213 deletions

View file

@ -1,5 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync, sendAsync } from "./dispatch_json.ts"; import { sendSync, sendAsync } from "./ops/dispatch_json.ts";
/** Synchronously changes the permission of a specific file/directory of /** Synchronously changes the permission of a specific file/directory of
* specified path. Ignores the process's umask. * specified path. Ignores the process's umask.

View file

@ -1,5 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync, sendAsync } from "./dispatch_json.ts"; import { sendSync, sendAsync } from "./ops/dispatch_json.ts";
/** Synchronously change owner of a regular file or directory. Linux/Mac OS /** Synchronously change owner of a regular file or directory. Linux/Mac OS
* only at the moment. * only at the moment.

View file

@ -4,8 +4,8 @@
// compiler within Deno. // compiler within Deno.
import { DiagnosticItem } from "./diagnostics.ts"; import { DiagnosticItem } from "./diagnostics.ts";
import { sendAsync } from "./dispatch_json.ts";
import * as util from "./util.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 /** A specific subset TypeScript compiler options that can be supported by
* the Deno TypeScript compiler. */ * the Deno TypeScript compiler. */
@ -300,7 +300,7 @@ export interface TranspileOnlyResult {
* Many of the options related to type checking and emitting * Many of the options related to type checking and emitting
* type declaration files will have no impact on the output. * type declaration files will have no impact on the output.
*/ */
export function transpileOnly( export async function transpileOnly(
sources: Record<string, string>, sources: Record<string, string>,
options?: CompilerOptions options?: CompilerOptions
): Promise<Record<string, TranspileOnlyResult>> { ): Promise<Record<string, TranspileOnlyResult>> {
@ -309,7 +309,8 @@ export function transpileOnly(
sources, sources,
options: options ? JSON.stringify(options) : undefined options: options ? JSON.stringify(options) : undefined
}; };
return sendAsync("op_transpile", payload).then(result => JSON.parse(result)); const result = await runtimeCompilerOps.transpile(payload);
return JSON.parse(result);
} }
/** Takes a root module name, any optionally a record set of sources. Resolves /** Takes a root module name, any optionally a record set of sources. Resolves
@ -339,7 +340,7 @@ export function transpileOnly(
* @param options An optional object of options to send to the compiler. This is * @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. * a subset of ts.CompilerOptions which can be supported by Deno.
*/ */
export function compile( export async function compile(
rootName: string, rootName: string,
sources?: Record<string, string>, sources?: Record<string, string>,
options?: CompilerOptions options?: CompilerOptions
@ -355,7 +356,8 @@ export function compile(
sources: !!sources, sources: !!sources,
options options
}); });
return sendAsync("op_compile", payload).then(result => JSON.parse(result)); const result = await runtimeCompilerOps.compile(payload);
return JSON.parse(result);
} }
/** Takes a root module name, and optionally a record set of sources. Resolves /** Takes a root module name, and optionally a record set of sources. Resolves
@ -386,7 +388,7 @@ export function compile(
* @param options An optional object of options to send to the compiler. This is * @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. * a subset of ts.CompilerOptions which can be supported by Deno.
*/ */
export function bundle( export async function bundle(
rootName: string, rootName: string,
sources?: Record<string, string>, sources?: Record<string, string>,
options?: CompilerOptions options?: CompilerOptions
@ -402,5 +404,6 @@ export function bundle(
sources: !!sources, sources: !!sources,
options options
}); });
return sendAsync("op_compile", payload).then(result => JSON.parse(result)); const result = await runtimeCompilerOps.compile(payload);
return JSON.parse(result);
} }

View file

@ -7,9 +7,9 @@ import {
} from "./compiler_sourcefile.ts"; } from "./compiler_sourcefile.ts";
import { normalizeString, CHAR_FORWARD_SLASH } from "./compiler_util.ts"; import { normalizeString, CHAR_FORWARD_SLASH } from "./compiler_util.ts";
import { cwd } from "./dir.ts"; import { cwd } from "./dir.ts";
import { sendAsync, sendSync } from "./dispatch_json.ts";
import { assert } from "./util.ts"; import { assert } from "./util.ts";
import * as util 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. */ /** Resolve a path to the final path segment passed. */
function resolvePath(...pathSegments: string[]): string { function resolvePath(...pathSegments: string[]): string {
@ -68,7 +68,7 @@ export function resolveModules(
referrer?: string referrer?: string
): string[] { ): string[] {
util.log("compiler_imports::resolveModules", { specifiers, referrer }); util.log("compiler_imports::resolveModules", { specifiers, referrer });
return sendSync("op_resolve_modules", { specifiers, referrer }); return compilerOps.resolveModules(specifiers, referrer);
} }
/** Ops to Rust to fetch modules meta data. */ /** Ops to Rust to fetch modules meta data. */
@ -77,10 +77,7 @@ function fetchSourceFiles(
referrer?: string referrer?: string
): Promise<SourceFileJson[]> { ): Promise<SourceFileJson[]> {
util.log("compiler_imports::fetchSourceFiles", { specifiers, referrer }); util.log("compiler_imports::fetchSourceFiles", { specifiers, referrer });
return sendAsync("op_fetch_source_files", { return compilerOps.fetchSourceFiles(specifiers, referrer);
specifiers,
referrer
});
} }
/** Given a filename, determine the media type based on extension. Used when /** Given a filename, determine the media type based on extension. Used when

View file

@ -5,9 +5,8 @@ import { CompilerOptions } from "./compiler_api.ts";
import { buildBundle } from "./compiler_bundler.ts"; import { buildBundle } from "./compiler_bundler.ts";
import { ConfigureResponse, Host } from "./compiler_host.ts"; import { ConfigureResponse, Host } from "./compiler_host.ts";
import { SourceFile } from "./compiler_sourcefile.ts"; import { SourceFile } from "./compiler_sourcefile.ts";
import { sendSync } from "./dispatch_json.ts"; import { atob, TextEncoder } from "./web/text_encoding.ts";
import { atob, TextDecoder, TextEncoder } from "./web/text_encoding.ts"; import * as compilerOps from "./ops/compiler.ts";
import { core } from "./core.ts";
import * as util from "./util.ts"; import * as util from "./util.ts";
import { assert } from "./util.ts"; import { assert } from "./util.ts";
import { writeFileSync } from "./write_file.ts"; import { writeFileSync } from "./write_file.ts";
@ -70,36 +69,21 @@ function cache(
if (emittedFileName.endsWith(".map")) { if (emittedFileName.endsWith(".map")) {
// Source Map // Source Map
sendSync("op_cache", { compilerOps.cache(".map", moduleId, contents);
extension: ".map",
moduleId,
contents
});
} else if ( } else if (
emittedFileName.endsWith(".js") || emittedFileName.endsWith(".js") ||
emittedFileName.endsWith(".json") emittedFileName.endsWith(".json")
) { ) {
// Compiled JavaScript // Compiled JavaScript
sendSync("op_cache", { compilerOps.cache(".js", moduleId, contents);
extension: ".js",
moduleId,
contents
});
} else { } else {
assert(false, `Trying to cache unhandled file type "${emittedFileName}"`); assert(false, `Trying to cache unhandled file type "${emittedFileName}"`);
} }
} }
const encoder = new TextEncoder();
const decoder = new TextDecoder();
/** Retrieve an asset from Rust. */ /** Retrieve an asset from Rust. */
export function getAsset(name: string): string { export function getAsset(name: string): string {
const opId = core.ops()["op_fetch_asset"]; return compilerOps.getAsset(name);
// We really don't want to depend on JSON dispatch during snapshotting, so
// this op exchanges strings with Rust as raw byte arrays.
const sourceCodeBytes = core.dispatch(opId, encoder.encode(name));
return decoder.decode(sourceCodeBytes!);
} }
/** Generates a `writeFile` function which can be passed to the compiler `Host` /** Generates a `writeFile` function which can be passed to the compiler `Host`

View file

@ -1,5 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync, sendAsync } from "./dispatch_json.ts"; import { sendSync, sendAsync } from "./ops/dispatch_json.ts";
/** Synchronously copies the contents and permissions of one file to another /** Synchronously copies the contents and permissions of one file to another
* specified path, by default creating a new file if needed, else overwriting. * specified path, by default creating a new file if needed, else overwriting.

View file

@ -21,7 +21,7 @@ export {
DiagnosticMessageChain DiagnosticMessageChain
} from "./diagnostics.ts"; } from "./diagnostics.ts";
export { chdir, cwd } from "./dir.ts"; export { chdir, cwd } from "./dir.ts";
export { applySourceMap } from "./error_stack.ts"; export { applySourceMap, formatDiagnostics } from "./ops/errors.ts";
export { errors } from "./errors.ts"; export { errors } from "./errors.ts";
export { FileInfo } from "./file_info.ts"; export { FileInfo } from "./file_info.ts";
export { export {
@ -39,12 +39,10 @@ export {
writeSync, writeSync,
seek, seek,
seekSync, seekSync,
close,
OpenOptions, OpenOptions,
OpenMode OpenMode
} from "./files.ts"; } from "./files.ts";
export { formatDiagnostics } from "./format_error.ts"; export { FsEvent, fsEvents } from "./ops/fs_events.ts";
export { FsEvent, fsEvents } from "./fs_events.ts";
export { export {
EOF, EOF,
copy, copy,
@ -72,7 +70,7 @@ export {
makeTempFile, makeTempFile,
MakeTempOptions MakeTempOptions
} from "./make_temp.ts"; } from "./make_temp.ts";
export { metrics, Metrics } from "./metrics.ts"; export { metrics, Metrics } from "./ops/runtime.ts";
export { mkdirSync, mkdir, MkdirOptions } from "./mkdir.ts"; export { mkdirSync, mkdir, MkdirOptions } from "./mkdir.ts";
export { export {
Addr, Addr,
@ -94,7 +92,7 @@ export {
hostname, hostname,
loadavg, loadavg,
osRelease osRelease
} from "./os.ts"; } from "./ops/os.ts";
export { export {
permissions, permissions,
PermissionName, PermissionName,
@ -117,13 +115,13 @@ export { readlinkSync, readlink } from "./read_link.ts";
export { realpathSync, realpath } from "./realpath.ts"; export { realpathSync, realpath } from "./realpath.ts";
export { removeSync, remove, RemoveOptions } from "./remove.ts"; export { removeSync, remove, RemoveOptions } from "./remove.ts";
export { renameSync, rename } from "./rename.ts"; export { renameSync, rename } from "./rename.ts";
export { resources } from "./resources.ts"; export { resources, close } from "./ops/resources.ts";
export { signal, signals, SignalStream } from "./signals.ts"; export { signal, signals, SignalStream } from "./signals.ts";
export { statSync, lstatSync, stat, lstat } from "./stat.ts"; export { statSync, lstatSync, stat, lstat } from "./stat.ts";
export { symlinkSync, symlink } from "./symlink.ts"; export { symlinkSync, symlink } from "./symlink.ts";
export { connectTLS, listenTLS } from "./tls.ts"; export { connectTLS, listenTLS } from "./tls.ts";
export { truncateSync, truncate } from "./truncate.ts"; export { truncateSync, truncate } from "./truncate.ts";
export { isatty, setRaw } from "./tty.ts"; export { isatty, setRaw } from "./ops/tty.ts";
export { utimeSync, utime } from "./utime.ts"; export { utimeSync, utime } from "./utime.ts";
export { version } from "./version.ts"; export { version } from "./version.ts";
export { writeFileSync, writeFile, WriteFileOptions } from "./write_file.ts"; export { writeFileSync, writeFile, WriteFileOptions } from "./write_file.ts";

View file

@ -1,5 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync } from "./dispatch_json.ts"; import { sendSync } from "./ops/dispatch_json.ts";
/** /**
* **UNSTABLE**: maybe needs permissions. * **UNSTABLE**: maybe needs permissions.

View file

@ -1,6 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import * as minimal from "./dispatch_minimal.ts"; import * as minimal from "./ops/dispatch_minimal.ts";
import * as json from "./dispatch_json.ts"; import * as json from "./ops/dispatch_json.ts";
import { AsyncHandler } from "./plugins.ts"; import { AsyncHandler } from "./plugins.ts";
const PLUGIN_ASYNC_HANDLER_MAP: Map<number, AsyncHandler> = new Map(); const PLUGIN_ASYNC_HANDLER_MAP: Map<number, AsyncHandler> = new Map();

View file

@ -1,60 +1,10 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
// Some of the code here is adapted directly from V8 and licensed under a BSD // Some of the code here is adapted directly from V8 and licensed under a BSD
// style license available here: https://github.com/v8/v8/blob/24886f2d1c565287d33d71e4109a53bf0b54b75c/LICENSE.v8 // style license available here: https://github.com/v8/v8/blob/24886f2d1c565287d33d71e4109a53bf0b54b75c/LICENSE.v8
import { sendSync } from "./dispatch_json.ts"; import { applySourceMap, Location } from "./ops/errors.ts";
import { assert } from "./util.ts"; import { assert } from "./util.ts";
import { exposeForTest } from "./internals.ts"; import { exposeForTest } from "./internals.ts";
export 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. */
line: number;
/** The column number in the file. It is assumed to be 1-indexed. */
column: number;
}
/** 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({
* location: "file://my/module.ts",
* line: 5,
* column: 15
* });
* console.log(`${orig.filename}:${orig.line}:${orig.column}`);
*
*/
export function applySourceMap(location: Location): Location {
const { filename, line, column } = location;
// On this side, line/column are 1 based, but in the source maps, they are
// 0 based, so we have to convert back and forth
const res = sendSync("op_apply_source_map", {
filename,
line: line - 1,
column: column - 1
});
return {
filename: res.filename,
line: res.line + 1,
column: res.column + 1
};
}
/** Mutate the call site so that it returns the location, instead of its /** Mutate the call site so that it returns the location, instead of its
* original location. * original location.
*/ */

View file

@ -10,11 +10,12 @@ import {
SyncWriter, SyncWriter,
SyncSeeker SyncSeeker
} from "./io.ts"; } from "./io.ts";
import { sendAsyncMinimal, sendSyncMinimal } from "./dispatch_minimal.ts"; import { sendAsyncMinimal, sendSyncMinimal } from "./ops/dispatch_minimal.ts";
import { import {
sendSync as sendSyncJson, sendSync as sendSyncJson,
sendAsync as sendAsyncJson sendAsync as sendAsyncJson
} from "./dispatch_json.ts"; } from "./ops/dispatch_json.ts";
import { close } from "./ops/resources.ts";
import { OPS_CACHE } from "./runtime.ts"; import { OPS_CACHE } from "./runtime.ts";
// This is done because read/write are extremely performance sensitive. // This is done because read/write are extremely performance sensitive.
@ -241,11 +242,6 @@ export async function seek(
return await sendAsyncJson("op_seek", { rid, offset, whence }); return await sendAsyncJson("op_seek", { rid, offset, whence });
} }
/** Close the given resource ID. */
export function close(rid: number): void {
sendSyncJson("op_close", { rid });
}
/** The Deno abstraction for reading and writing files. */ /** The Deno abstraction for reading and writing files. */
export class File export class File
implements implements

View file

@ -1,11 +0,0 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { DiagnosticItem } from "./diagnostics.ts";
import { sendSync } from "./dispatch_json.ts";
/**
* Format an array of diagnostic items and return them as a single string.
* @param items An array of diagnostic items to format
*/
export function formatDiagnostics(items: DiagnosticItem[]): string {
return sendSync("op_format_diagnostic", { items });
}

View file

@ -1,5 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync, sendAsync } from "./dispatch_json.ts"; import { sendSync, sendAsync } from "./ops/dispatch_json.ts";
/** Creates `newname` as a hard link to `oldname`. /** Creates `newname` as a hard link to `oldname`.
* *

View file

@ -1,5 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync, sendAsync } from "./dispatch_json.ts"; import { sendSync, sendAsync } from "./ops/dispatch_json.ts";
export interface MakeTempOptions { export interface MakeTempOptions {
/** Directory where the temporary directory should be created (defaults to /** Directory where the temporary directory should be created (defaults to

View file

@ -1,5 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync, sendAsync } from "./dispatch_json.ts"; import { sendSync, sendAsync } from "./ops/dispatch_json.ts";
// TODO(ry) The complexity in argument parsing is to support deprecated forms of // TODO(ry) The complexity in argument parsing is to support deprecated forms of
// mkdir and mkdirSync. // mkdir and mkdirSync.

View file

@ -1,7 +1,8 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { EOF, Reader, Writer, Closer } from "./io.ts"; import { EOF, Reader, Writer, Closer } from "./io.ts";
import { read, write, close } from "./files.ts"; import { read, write } from "./files.ts";
import { sendSync, sendAsync } from "./dispatch_json.ts"; import { close } from "./ops/resources.ts";
import { sendSync, sendAsync } from "./ops/dispatch_json.ts";
export type Transport = "tcp" | "udp"; export type Transport = "tcp" | "udp";
// TODO support other types: // TODO support other types:

55
cli/js/ops/compiler.ts Normal file
View file

@ -0,0 +1,55 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendAsync, sendSync } from "./dispatch_json.ts";
import { TextDecoder, TextEncoder } from "../web/text_encoding.ts";
import { core } from "../core.ts";
/** Ops to Rust to resolve modules' URLs. */
export function resolveModules(
specifiers: string[],
referrer?: string
): string[] {
return sendSync("op_resolve_modules", { specifiers, referrer });
}
/** Ops to Rust to fetch modules meta data. */
export function fetchSourceFiles(
specifiers: string[],
referrer?: string
): Promise<
Array<{
url: string;
filename: string;
mediaType: number;
sourceCode: string;
}>
> {
return sendAsync("op_fetch_source_files", {
specifiers,
referrer
});
}
const encoder = new TextEncoder();
const decoder = new TextDecoder();
/** This op is also used during snapshotting */
export function getAsset(name: string): string {
const opId = core.ops()["op_fetch_asset"];
// We really don't want to depend on JSON dispatch during snapshotting, so
// this op exchanges strings with Rust as raw byte arrays.
const sourceCodeBytes = core.dispatch(opId, encoder.encode(name));
return decoder.decode(sourceCodeBytes!);
}
export function cache(
extension: string,
moduleId: string,
contents: string
): void {
sendSync("op_cache", {
extension,
moduleId,
contents
});
}

View file

@ -1,9 +1,9 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import * as util from "./util.ts"; import * as util from "../util.ts";
import { TextEncoder, TextDecoder } from "./web/text_encoding.ts"; import { TextEncoder, TextDecoder } from "../web/text_encoding.ts";
import { core } from "./core.ts"; import { core } from "../core.ts";
import { OPS_CACHE } from "./runtime.ts"; import { OPS_CACHE } from "../runtime.ts";
import { ErrorKind, getErrorClass } from "./errors.ts"; import { ErrorKind, getErrorClass } from "../errors.ts";
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
type Ok = any; type Ok = any;

View file

@ -1,8 +1,8 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import * as util from "./util.ts"; import * as util from "../util.ts";
import { core } from "./core.ts"; import { core } from "../core.ts";
import { TextDecoder } from "./web/text_encoding.ts"; import { TextDecoder } from "../web/text_encoding.ts";
import { ErrorKind, errors, getErrorClass } from "./errors.ts"; import { ErrorKind, errors, getErrorClass } from "../errors.ts";
const promiseTableMin = new Map<number, util.Resolvable<RecordMinimal>>(); const promiseTableMin = new Map<number, util.Resolvable<RecordMinimal>>();
// Note it's important that promiseId starts at 1 instead of 0, because sync // Note it's important that promiseId starts at 1 instead of 0, because sync

61
cli/js/ops/errors.ts Normal file
View file

@ -0,0 +1,61 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { DiagnosticItem } from "../diagnostics.ts";
import { sendSync } from "./dispatch_json.ts";
/**
* Format an array of diagnostic items and return them as a single string.
* @param items An array of diagnostic items to format
*/
export function formatDiagnostics(items: DiagnosticItem[]): string {
return sendSync("op_format_diagnostic", { items });
}
export 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. */
line: number;
/** The column number in the file. It is assumed to be 1-indexed. */
column: number;
}
/** 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({
* location: "file://my/module.ts",
* line: 5,
* column: 15
* });
* console.log(`${orig.filename}:${orig.line}:${orig.column}`);
*
*/
export function applySourceMap(location: Location): Location {
const { filename, line, column } = location;
// On this side, line/column are 1 based, but in the source maps, they are
// 0 based, so we have to convert back and forth
const res = sendSync("op_apply_source_map", {
filename,
line: line - 1,
column: column - 1
});
return {
filename: res.filename,
line: res.line + 1,
column: res.column + 1
};
}

28
cli/js/ops/fetch.ts Normal file
View file

@ -0,0 +1,28 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendAsync } from "./dispatch_json.ts";
interface FetchRequest {
url: string;
method: string | null;
headers: Array<[string, string]>;
}
export interface FetchResponse {
bodyRid: number;
status: number;
statusText: string;
headers: Array<[string, string]>;
}
export async function fetch(
args: FetchRequest,
body: ArrayBufferView | undefined
): Promise<FetchResponse> {
let zeroCopy = undefined;
if (body) {
zeroCopy = new Uint8Array(body.buffer, body.byteOffset, body.byteLength);
}
return await sendAsync("op_fetch", args, zeroCopy);
}

View file

@ -1,6 +1,6 @@
// Copyright 2019 the Deno authors. All rights reserved. MIT license. // Copyright 2019 the Deno authors. All rights reserved. MIT license.
import { sendSync, sendAsync } from "./dispatch_json.ts"; import { sendSync, sendAsync } from "./dispatch_json.ts";
import { close } from "./files.ts"; import { close } from "./resources.ts";
export interface FsEvent { export interface FsEvent {
kind: "any" | "access" | "create" | "modify" | "remove"; kind: "any" | "access" | "create" | "modify" | "remove";

View file

@ -1,6 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync } from "./dispatch_json.ts"; import { sendSync } from "./dispatch_json.ts";
import { assert } from "./util.ts"; import { assert } from "../util.ts";
/** Synchronously collects cryptographically secure random values. The /** Synchronously collects cryptographically secure random values. The
* underlying CSPRNG in use is Rust's `rand::rngs::ThreadRng`. * underlying CSPRNG in use is Rust's `rand::rngs::ThreadRng`.

View file

@ -1,7 +1,7 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync } from "./dispatch_json.ts"; import { sendSync } from "./dispatch_json.ts";
import { errors } from "./errors.ts"; import { errors } from "../errors.ts";
import * as util from "./util.ts"; import * as util from "../util.ts";
/** Get the loadavg. /** Get the loadavg.
* Requires the `--allow-env` flag. * Requires the `--allow-env` flag.

11
cli/js/ops/repl.ts Normal file
View file

@ -0,0 +1,11 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync, sendAsync } from "./dispatch_json.ts";
export function startRepl(historyFile: string): number {
return sendSync("op_repl_start", { historyFile });
}
export async function readline(rid: number, prompt: string): Promise<string> {
return sendAsync("op_repl_readline", { rid, prompt });
}

View file

@ -16,3 +16,8 @@ export function resources(): ResourceMap {
} }
return resources; return resources;
} }
/** Close the given resource ID. */
export function close(rid: number): void {
sendSync("op_close", { rid });
}

View file

@ -1,6 +1,34 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync } from "./dispatch_json.ts"; import { sendSync } from "./dispatch_json.ts";
// TODO(bartlomieju): these two types are duplicated
// in `cli/js/build.ts` - deduplicate
export type OperatingSystem = "mac" | "win" | "linux";
export type Arch = "x64" | "arm64";
export interface Start {
cwd: string;
pid: number;
args: string[];
location: string; // Absolute URL.
repl: boolean;
debugFlag: boolean;
depsFlag: boolean;
typesFlag: boolean;
versionFlag: boolean;
denoVersion: string;
v8Version: string;
tsVersion: string;
noColor: boolean;
os: OperatingSystem;
arch: Arch;
}
export function start(): Start {
return sendSync("op_start");
}
export interface Metrics { export interface Metrics {
opsDispatched: number; opsDispatched: number;
opsDispatchedSync: number; opsDispatchedSync: number;

View file

@ -0,0 +1,23 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendAsync } from "./dispatch_json.ts";
interface CompileRequest {
rootName: string;
sources?: Record<string, string>;
options?: string;
bundle: boolean;
}
export async function compile(request: CompileRequest): Promise<string> {
return sendAsync("op_compile", request);
}
interface TranspileRequest {
sources: Record<string, string>;
options?: string;
}
export async function transpile(request: TranspileRequest): Promise<string> {
return sendAsync("op_transpile", request);
}

View file

@ -1,5 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync } from "./dispatch_json.ts"; import { sendSync } from "./ops/dispatch_json.ts";
interface NowResponse { interface NowResponse {
seconds: number; seconds: number;

View file

@ -1,5 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync } from "./dispatch_json.ts"; import { sendSync } from "./ops/dispatch_json.ts";
/** Permissions as granted by the caller /** Permissions as granted by the caller
* See: https://w3c.github.io/permissions/#permission-registry * See: https://w3c.github.io/permissions/#permission-registry

View file

@ -1,4 +1,4 @@
import { sendSync } from "./dispatch_json.ts"; import { sendSync } from "./ops/dispatch_json.ts";
import { core } from "./core.ts"; import { core } from "./core.ts";
export interface AsyncHandler { export interface AsyncHandler {

View file

@ -1,6 +1,7 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync, sendAsync } from "./dispatch_json.ts"; import { sendSync, sendAsync } from "./ops/dispatch_json.ts";
import { File, close } from "./files.ts"; import { File } from "./files.ts";
import { close } from "./ops/resources.ts";
import { ReadCloser, WriteCloser } from "./io.ts"; import { ReadCloser, WriteCloser } from "./io.ts";
import { readAll } from "./buffer.ts"; import { readAll } from "./buffer.ts";
import { assert, unreachable } from "./util.ts"; import { assert, unreachable } from "./util.ts";

View file

@ -1,5 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync, sendAsync } from "./dispatch_json.ts"; import { sendSync, sendAsync } from "./ops/dispatch_json.ts";
import { FileInfo, FileInfoImpl } from "./file_info.ts"; import { FileInfo, FileInfoImpl } from "./file_info.ts";
import { StatResponse } from "./stat.ts"; import { StatResponse } from "./stat.ts";

View file

@ -1,5 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync, sendAsync } from "./dispatch_json.ts"; import { sendSync, sendAsync } from "./ops/dispatch_json.ts";
/** Returns the destination of the named symbolic link. /** Returns the destination of the named symbolic link.
* *

View file

@ -1,5 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync, sendAsync } from "./dispatch_json.ts"; import { sendSync, sendAsync } from "./ops/dispatch_json.ts";
/** Returns absolute normalized path with symbolic links resolved synchronously. /** Returns absolute normalized path with symbolic links resolved synchronously.
* *

View file

@ -1,5 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync, sendAsync } from "./dispatch_json.ts"; import { sendSync, sendAsync } from "./ops/dispatch_json.ts";
export interface RemoveOptions { export interface RemoveOptions {
/** Defaults to `false`. If set to `true`, path will be removed even if /** Defaults to `false`. If set to `true`, path will be removed even if

View file

@ -1,5 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync, sendAsync } from "./dispatch_json.ts"; import { sendSync, sendAsync } from "./ops/dispatch_json.ts";
/** Synchronously renames (moves) `oldpath` to `newpath`. If `newpath` already /** Synchronously renames (moves) `oldpath` to `newpath`. If `newpath` already
* exists and is not a directory, `renameSync()` replaces it. OS-specific * exists and is not a directory, `renameSync()` replaces it. OS-specific

View file

@ -1,9 +1,9 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { close } from "./files.ts"; import { exit } from "./ops/os.ts";
import { exit } from "./os.ts";
import { core } from "./core.ts"; import { core } from "./core.ts";
import { stringifyArgs } from "./console.ts"; import { stringifyArgs } from "./console.ts";
import { sendSync, sendAsync } from "./dispatch_json.ts"; import { startRepl, readline } from "./ops/repl.ts";
import { close } from "./ops/resources.ts";
/** /**
* REPL logging. * REPL logging.
@ -41,15 +41,6 @@ const replCommands = {
} }
}; };
function startRepl(historyFile: string): number {
return sendSync("op_repl_start", { historyFile });
}
// @internal
export async function readline(rid: number, prompt: string): Promise<string> {
return sendAsync("op_repl_readline", { rid, prompt });
}
// Error messages that allow users to continue input // Error messages that allow users to continue input
// instead of throwing an error to REPL // instead of throwing an error to REPL
// ref: https://github.com/v8/v8/blob/master/src/message-template.h // ref: https://github.com/v8/v8/blob/master/src/message-template.h

View file

@ -1,32 +1,13 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { core } from "./core.ts"; import { core } from "./core.ts";
import * as dispatch from "./dispatch.ts"; import * as dispatch from "./dispatch.ts";
import { sendSync } from "./dispatch_json.ts";
import { assert } from "./util.ts"; import { assert } from "./util.ts";
import * as util from "./util.ts"; import * as util from "./util.ts";
import { OperatingSystem, Arch } from "./build.ts";
import { setBuildInfo } from "./build.ts"; import { setBuildInfo } from "./build.ts";
import { setVersions } from "./version.ts"; import { setVersions } from "./version.ts";
import { setLocation } from "./web/location.ts"; import { setLocation } from "./web/location.ts";
import { setPrepareStackTrace } from "./error_stack.ts"; import { setPrepareStackTrace } from "./error_stack.ts";
import { Start, start as startOp } from "./ops/runtime.ts";
interface Start {
cwd: string;
pid: number;
args: string[];
location: string; // Absolute URL.
repl: boolean;
debugFlag: boolean;
depsFlag: boolean;
typesFlag: boolean;
versionFlag: boolean;
denoVersion: string;
v8Version: string;
tsVersion: string;
noColor: boolean;
os: OperatingSystem;
arch: Arch;
}
export let OPS_CACHE: { [name: string]: number }; export let OPS_CACHE: { [name: string]: number };
@ -49,7 +30,7 @@ export function start(preserveDenoNamespace = true, source?: string): Start {
// First we send an empty `Start` message to let the privileged side know we // First we send an empty `Start` message to let the privileged side know we
// are ready. The response should be a `StartRes` message containing the CLI // are ready. The response should be a `StartRes` message containing the CLI
// args and other info. // args and other info.
const s = sendSync("op_start"); const s = startOp();
setVersions(s.denoVersion, s.v8Version, s.tsVersion); setVersions(s.denoVersion, s.v8Version, s.tsVersion);
setBuildInfo(s.os, s.arch); setBuildInfo(s.os, s.arch);

View file

@ -9,7 +9,7 @@
import * as Deno from "./deno.ts"; import * as Deno from "./deno.ts";
import * as domTypes from "./web/dom_types.ts"; import * as domTypes from "./web/dom_types.ts";
import * as csprng from "./get_random_values.ts"; import * as csprng from "./ops/get_random_values.ts";
import { import {
readOnly, readOnly,
writable, writable,

View file

@ -16,7 +16,7 @@ import {
windowOrWorkerGlobalScopeProperties, windowOrWorkerGlobalScopeProperties,
eventTargetProperties eventTargetProperties
} from "./globals.ts"; } from "./globals.ts";
import { sendSync } from "./dispatch_json.ts"; import { sendSync } from "./ops/dispatch_json.ts";
import { log } from "./util.ts"; import { log } from "./util.ts";
import { TextEncoder } from "./web/text_encoding.ts"; import { TextEncoder } from "./web/text_encoding.ts";
import * as runtime from "./runtime.ts"; import * as runtime from "./runtime.ts";

View file

@ -1,6 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { Signal } from "./process.ts"; import { Signal } from "./process.ts";
import { sendSync, sendAsync } from "./dispatch_json.ts"; import { sendSync, sendAsync } from "./ops/dispatch_json.ts";
import { build } from "./build.ts"; import { build } from "./build.ts";
/** /**

View file

@ -1,5 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync, sendAsync } from "./dispatch_json.ts"; import { sendSync, sendAsync } from "./ops/dispatch_json.ts";
import { FileInfo, FileInfoImpl } from "./file_info.ts"; import { FileInfo, FileInfoImpl } from "./file_info.ts";
/** @internal */ /** @internal */

View file

@ -1,5 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync, sendAsync } from "./dispatch_json.ts"; import { sendSync, sendAsync } from "./ops/dispatch_json.ts";
import * as util from "./util.ts"; import * as util from "./util.ts";
import { build } from "./build.ts"; import { build } from "./build.ts";

View file

@ -1,6 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { red, green, bgRed, gray, italic } from "./colors.ts"; import { red, green, bgRed, gray, italic } from "./colors.ts";
import { exit } from "./os.ts"; import { exit } from "./ops/os.ts";
import { Console } from "./console.ts"; import { Console } from "./console.ts";
function formatDuration(time = 0): string { function formatDuration(time = 0): string {

View file

@ -1,6 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { assert } from "./util.ts"; import { assert } from "./util.ts";
import { sendSync, sendAsync } from "./dispatch_json.ts"; import { sendSync, sendAsync } from "./ops/dispatch_json.ts";
import { RBTree } from "./rbtree.ts"; import { RBTree } from "./rbtree.ts";
const { console } = globalThis; const { console } = globalThis;

View file

@ -1,5 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendAsync, sendSync } from "./dispatch_json.ts"; import { sendAsync, sendSync } from "./ops/dispatch_json.ts";
import { Listener, Transport, Conn, ConnImpl, ListenerImpl } from "./net.ts"; import { Listener, Transport, Conn, ConnImpl, ListenerImpl } from "./net.ts";
// TODO(ry) There are many configuration options to add... // TODO(ry) There are many configuration options to add...

View file

@ -1,5 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync, sendAsync } from "./dispatch_json.ts"; import { sendSync, sendAsync } from "./ops/dispatch_json.ts";
function coerceLen(len?: number): number { function coerceLen(len?: number): number {
if (!len) { if (!len) {

View file

@ -1,5 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync, sendAsync } from "./dispatch_json.ts"; import { sendSync, sendAsync } from "./ops/dispatch_json.ts";
function toSecondsFromEpoch(v: number | Date): number { function toSecondsFromEpoch(v: number | Date): number {
return v instanceof Date ? v.valueOf() / 1000 : v; return v instanceof Date ? v.valueOf() / 1000 : v;

View file

@ -10,12 +10,13 @@ import { TextDecoder, TextEncoder } from "./text_encoding.ts";
import { DenoBlob, bytesSymbol as blobBytesSymbol } from "./blob.ts"; import { DenoBlob, bytesSymbol as blobBytesSymbol } from "./blob.ts";
import { Headers } from "./headers.ts"; import { Headers } from "./headers.ts";
import * as io from "../io.ts"; import * as io from "../io.ts";
import { read, close } from "../files.ts"; import { read } from "../files.ts";
import { close } from "../ops/resources.ts";
import { Buffer } from "../buffer.ts"; import { Buffer } from "../buffer.ts";
import { FormData } from "./form_data.ts"; import { FormData } from "./form_data.ts";
import { URL } from "./url.ts"; import { URL } from "./url.ts";
import { URLSearchParams } from "./url_search_params.ts"; import { URLSearchParams } from "./url_search_params.ts";
import { sendAsync } from "../dispatch_json.ts"; import { fetch as opFetch, FetchResponse } from "../ops/fetch.ts";
function getHeaderValueParams(value: string): Map<string, string> { function getHeaderValueParams(value: string): Map<string, string> {
const params = new Map(); const params = new Map();
@ -439,13 +440,6 @@ export class Response implements domTypes.Response {
} }
} }
interface FetchResponse {
bodyRid: number;
status: number;
statusText: string;
headers: Array<[string, string]>;
}
async function sendFetchReq( async function sendFetchReq(
url: string, url: string,
method: string | null, method: string | null,
@ -457,18 +451,13 @@ async function sendFetchReq(
headerArray = Array.from(headers.entries()); headerArray = Array.from(headers.entries());
} }
let zeroCopy = undefined;
if (body) {
zeroCopy = new Uint8Array(body.buffer, body.byteOffset, body.byteLength);
}
const args = { const args = {
method, method,
url, url,
headers: headerArray headers: headerArray
}; };
return (await sendAsync("op_fetch", args, zeroCopy)) as FetchResponse; return await opFetch(args, body);
} }
/** Fetch a resource from the network. */ /** Fetch a resource from the network. */

View file

@ -1,7 +1,7 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import * as urlSearchParams from "./url_search_params.ts"; import * as urlSearchParams from "./url_search_params.ts";
import * as domTypes from "./dom_types.ts"; import * as domTypes from "./dom_types.ts";
import { getRandomValues } from "../get_random_values.ts"; import { getRandomValues } from "../ops/get_random_values.ts";
import { customInspect } from "../console.ts"; import { customInspect } from "../console.ts";
interface URLParts { interface URLParts {

View file

@ -1,6 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
import { sendAsync, sendSync } from "./dispatch_json.ts"; import { sendAsync, sendSync } from "./ops/dispatch_json.ts";
import { log } from "./util.ts"; import { log } from "./util.ts";
import { TextDecoder, TextEncoder } from "./web/text_encoding.ts"; import { TextDecoder, TextEncoder } from "./web/text_encoding.ts";
/* /*

View file

@ -1,7 +1,7 @@
[WILDCARD]error: Uncaught URIError: relative import path "bad-module.ts" not prefixed with / or ./ or ../ Imported from "[WILDCARD]/error_011_bad_module_specifier.ts" [WILDCARD]error: Uncaught URIError: relative import path "bad-module.ts" not prefixed with / or ./ or ../ Imported from "[WILDCARD]/error_011_bad_module_specifier.ts"
[WILDCARD]dispatch_json.ts:[WILDCARD] [WILDCARD]dispatch_json.ts:[WILDCARD]
at unwrapResponse ($deno$/dispatch_json.ts:[WILDCARD]) at unwrapResponse ($deno$/ops/dispatch_json.ts:[WILDCARD])
at sendSync ($deno$/dispatch_json.ts:[WILDCARD]) at sendSync ($deno$/ops/dispatch_json.ts:[WILDCARD])
at resolveModules ($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])
at processImports ($deno$/compiler_imports.ts:[WILDCARD]) at processImports ($deno$/compiler_imports.ts:[WILDCARD])

View file

@ -1,7 +1,7 @@
[WILDCARD]error: Uncaught URIError: relative import path "bad-module.ts" not prefixed with / or ./ or ../ Imported from "[WILDCARD]/error_012_bad_dynamic_import_specifier.ts" [WILDCARD]error: Uncaught URIError: relative import path "bad-module.ts" not prefixed with / or ./ or ../ Imported from "[WILDCARD]/error_012_bad_dynamic_import_specifier.ts"
[WILDCARD]dispatch_json.ts:[WILDCARD] [WILDCARD]dispatch_json.ts:[WILDCARD]
at unwrapResponse ($deno$/dispatch_json.ts:[WILDCARD]) at unwrapResponse ($deno$/ops/dispatch_json.ts:[WILDCARD])
at sendSync ($deno$/dispatch_json.ts:[WILDCARD]) at sendSync ($deno$/ops/dispatch_json.ts:[WILDCARD])
at resolveModules ($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])
at processImports ($deno$/compiler_imports.ts:[WILDCARD]) at processImports ($deno$/compiler_imports.ts:[WILDCARD])

View file

@ -1,7 +1,7 @@
[WILDCARD]error: Uncaught URIError: relative import path "baz" not prefixed with / or ./ or ../ Imported from "[WILDCARD]/type_definitions/bar.d.ts" [WILDCARD]error: Uncaught URIError: relative import path "baz" not prefixed with / or ./ or ../ Imported from "[WILDCARD]/type_definitions/bar.d.ts"
[WILDCARD]dispatch_json.ts:[WILDCARD] [WILDCARD]dispatch_json.ts:[WILDCARD]
at unwrapResponse ($deno$/dispatch_json.ts:[WILDCARD]) at unwrapResponse ($deno$/ops/dispatch_json.ts:[WILDCARD])
at sendSync ($deno$/dispatch_json.ts:[WILDCARD]) at sendSync ($deno$/ops/dispatch_json.ts:[WILDCARD])
at resolveModules ($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])
at processImports ($deno$/compiler_imports.ts:[WILDCARD]) at processImports ($deno$/compiler_imports.ts:[WILDCARD])

View file

@ -26,8 +26,8 @@ if (parsedArgs._.length === 0) {
const files: Record<string, { content: string }> = {}; const files: Record<string, { content: string }> = {};
for (const filename of parsedArgs._) { for (const filename of parsedArgs._) {
const base = pathBase(filename); const base = pathBase(filename as string);
const content = await Deno.readFile(filename); const content = await Deno.readFile(filename as string);
const contentStr = new TextDecoder().decode(content); const contentStr = new TextDecoder().decode(content);
files[base] = { content: contentStr }; files[base] = { content: contentStr };
} }