diff --git a/cli/build.rs b/cli/build.rs index c737c1f6d1..3baafb522c 100644 --- a/cli/build.rs +++ b/cli/build.rs @@ -342,6 +342,7 @@ fn create_cli_snapshot(snapshot_path: PathBuf) { deno_broadcast_channel::InMemoryBroadcastChannel::default(), false, // No --unstable. ), + deno_io::init(Default::default()), deno_node::init::(None), // No --unstable. deno_node::init_polyfill(), deno_ffi::init::(false), @@ -351,7 +352,6 @@ fn create_cli_snapshot(snapshot_path: PathBuf) { ), deno_napi::init::(), deno_http::init(), - deno_io::init(Default::default()), deno_flash::init::(false), // No --unstable ]; diff --git a/ext/io/12_io.js b/ext/io/12_io.js index b9ff1190b1..d1f3b8b1bc 100644 --- a/ext/io/12_io.js +++ b/ext/io/12_io.js @@ -7,6 +7,10 @@ const core = globalThis.Deno.core; const ops = core.ops; const primordials = globalThis.__bootstrap.primordials; +import { + readableStreamForRid, + writableStreamForRid, +} from "internal:deno_web/06_streams.js"; const { Uint8Array, ArrayPrototypePush, @@ -221,6 +225,105 @@ async function readAllInnerSized(r, size, options) { } } +class Stdin { + #readable; + + constructor() { + } + + get rid() { + return 0; + } + + read(p) { + return read(this.rid, p); + } + + readSync(p) { + return readSync(this.rid, p); + } + + close() { + core.close(this.rid); + } + + get readable() { + if (this.#readable === undefined) { + this.#readable = readableStreamForRid(this.rid); + } + return this.#readable; + } + + setRaw(mode, options = {}) { + const cbreak = !!(options.cbreak ?? false); + ops.op_stdin_set_raw(mode, cbreak); + } +} + +class Stdout { + #writable; + + constructor() { + } + + get rid() { + return 1; + } + + write(p) { + return write(this.rid, p); + } + + writeSync(p) { + return writeSync(this.rid, p); + } + + close() { + core.close(this.rid); + } + + get writable() { + if (this.#writable === undefined) { + this.#writable = writableStreamForRid(this.rid); + } + return this.#writable; + } +} + +class Stderr { + #writable; + + constructor() { + } + + get rid() { + return 2; + } + + write(p) { + return write(this.rid, p); + } + + writeSync(p) { + return writeSync(this.rid, p); + } + + close() { + core.close(this.rid); + } + + get writable() { + if (this.#writable === undefined) { + this.#writable = writableStreamForRid(this.rid); + } + return this.#writable; + } +} + +const stdin = new Stdin(); +const stdout = new Stdout(); +const stderr = new Stderr(); + export { copy, iter, @@ -233,6 +336,9 @@ export { readAllSyncSized, readSync, SeekMode, + stderr, + stdin, + stdout, write, writeSync, }; diff --git a/ext/node/lib.rs b/ext/node/lib.rs index 444dffeec5..a1fa9408a3 100644 --- a/ext/node/lib.rs +++ b/ext/node/lib.rs @@ -365,6 +365,7 @@ pub fn init_polyfill() -> Extension { Extension::builder(env!("CARGO_PKG_NAME")) .esm(esm_files) .esm_entry_point("internal:deno_node/module_all.ts") + .dependencies(vec!["deno_io"]) .ops(vec![ crypto::op_node_create_hash::decl(), crypto::op_node_hash_update::decl(), diff --git a/ext/node/polyfills/_process/streams.mjs b/ext/node/polyfills/_process/streams.mjs index da6895dbb7..dbb9552fa8 100644 --- a/ext/node/polyfills/_process/streams.mjs +++ b/ext/node/polyfills/_process/streams.mjs @@ -11,7 +11,7 @@ import { import { Duplex, Readable, Writable } from "internal:deno_node/stream.ts"; import { isWindows } from "internal:deno_node/_util/os.ts"; import { fs as fsConstants } from "internal:deno_node/internal_binding/constants.ts"; -import * as files from "internal:runtime/40_files.js"; +import * as io from "internal:deno_io/12_io.js"; // https://github.com/nodejs/node/blob/00738314828074243c9a52a228ab4c68b04259ef/lib/internal/bootstrap/switches/is_main_thread.js#L41 export function createWritableStdioStream(writer, name) { @@ -140,7 +140,7 @@ function _guessStdinType(fd) { const _read = function (size) { const p = Buffer.alloc(size || 16 * 1024); - files.stdin?.read(p).then((length) => { + io.stdin?.read(p).then((length) => { this.push(length === null ? null : p.slice(0, length)); }, (error) => { this.destroy(error); @@ -151,7 +151,7 @@ const _read = function (size) { // https://github.com/nodejs/node/blob/v18.12.1/lib/internal/bootstrap/switches/is_main_thread.js#L189 /** Create process.stdin */ export const initStdin = () => { - const fd = files.stdin?.rid; + const fd = io.stdin?.rid; let stdin; const stdinType = _guessStdinType(fd); @@ -210,8 +210,8 @@ export const initStdin = () => { } } - stdin.on("close", () => files.stdin?.close()); - stdin.fd = files.stdin?.rid ?? -1; + stdin.on("close", () => io.stdin?.close()); + stdin.fd = io.stdin?.rid ?? -1; Object.defineProperty(stdin, "isTTY", { enumerable: true, configurable: true, @@ -221,7 +221,7 @@ export const initStdin = () => { }); stdin._isRawMode = false; stdin.setRawMode = (enable) => { - files.stdin?.setRaw?.(enable); + io.stdin?.setRaw?.(enable); stdin._isRawMode = enable; return stdin; }; diff --git a/ext/node/polyfills/process.ts b/ext/node/polyfills/process.ts index eaff978c2c..02701dbddb 100644 --- a/ext/node/polyfills/process.ts +++ b/ext/node/polyfills/process.ts @@ -38,7 +38,7 @@ import { runNextTicks, } from "internal:deno_node/_next_tick.ts"; import { isWindows } from "internal:deno_node/_util/os.ts"; -import * as files from "internal:runtime/40_files.js"; +import * as io from "internal:deno_io/12_io.js"; // TODO(kt3k): This should be set at start up time export let arch = ""; @@ -755,13 +755,13 @@ internals.__bootstrapNodeProcess = function ( /** https://nodejs.org/api/process.html#process_process_stderr */ stderr = process.stderr = createWritableStdioStream( - files.stderr, + io.stderr, "stderr", ); /** https://nodejs.org/api/process.html#process_process_stdout */ stdout = process.stdout = createWritableStdioStream( - files.stdout, + io.stdout, "stdout", ); diff --git a/runtime/build.rs b/runtime/build.rs index df8e5acab9..efcdb8f71f 100644 --- a/runtime/build.rs +++ b/runtime/build.rs @@ -203,15 +203,12 @@ mod startup_snapshot { "13_buffer.js", "30_fs.js", "30_os.js", - "40_files.js", "40_fs_events.js", "40_http.js", "40_process.js", - "40_read_file.js", "40_signals.js", "40_spawn.js", "40_tty.js", - "40_write_file.js", "41_prompt.js", "90_deno_ns.js", "98_global_scope.js", diff --git a/runtime/js/30_fs.js b/runtime/js/30_fs.js index eaf83b5434..a7936085ef 100644 --- a/runtime/js/30_fs.js +++ b/runtime/js/30_fs.js @@ -4,16 +4,26 @@ const core = globalThis.Deno.core; const ops = core.ops; const primordials = globalThis.__bootstrap.primordials; const { + ArrayPrototypeFilter, Date, DatePrototype, + Error, + Function, MathTrunc, + ObjectEntries, ObjectPrototypeIsPrototypeOf, + ObjectValues, SymbolAsyncIterator, SymbolIterator, - Function, - ObjectEntries, Uint32Array, } = primordials; +import { read, readSync, write, writeSync } from "internal:deno_io/12_io.js"; +import * as abortSignal from "internal:deno_web/03_abort_signal.js"; +import { + readableStreamForRid, + ReadableStreamPrototype, + writableStreamForRid, +} from "internal:deno_web/06_streams.js"; import { pathFromURL } from "internal:runtime/06_util.js"; import { build } from "internal:runtime/01_build.js"; @@ -503,6 +513,322 @@ async function funlock(rid) { await core.opAsync("op_funlock_async", rid); } +function seekSync( + rid, + offset, + whence, +) { + return ops.op_seek_sync({ rid, offset, whence }); +} + +function seek( + rid, + offset, + whence, +) { + return core.opAsync("op_seek_async", { rid, offset, whence }); +} + +function openSync( + path, + options, +) { + if (options) checkOpenOptions(options); + const mode = options?.mode; + const rid = ops.op_open_sync( + pathFromURL(path), + options, + mode, + ); + + return new FsFile(rid); +} + +async function open( + path, + options, +) { + if (options) checkOpenOptions(options); + const mode = options?.mode; + const rid = await core.opAsync( + "op_open_async", + pathFromURL(path), + options, + mode, + ); + + return new FsFile(rid); +} + +function createSync(path) { + return openSync(path, { + read: true, + write: true, + truncate: true, + create: true, + }); +} + +function create(path) { + return open(path, { + read: true, + write: true, + truncate: true, + create: true, + }); +} + +class FsFile { + #rid = 0; + + #readable; + #writable; + + constructor(rid) { + this.#rid = rid; + } + + get rid() { + return this.#rid; + } + + write(p) { + return write(this.rid, p); + } + + writeSync(p) { + return writeSync(this.rid, p); + } + + truncate(len) { + return ftruncate(this.rid, len); + } + + truncateSync(len) { + return ftruncateSync(this.rid, len); + } + + read(p) { + return read(this.rid, p); + } + + readSync(p) { + return readSync(this.rid, p); + } + + seek(offset, whence) { + return seek(this.rid, offset, whence); + } + + seekSync(offset, whence) { + return seekSync(this.rid, offset, whence); + } + + stat() { + return fstat(this.rid); + } + + statSync() { + return fstatSync(this.rid); + } + + close() { + core.close(this.rid); + } + + get readable() { + if (this.#readable === undefined) { + this.#readable = readableStreamForRid(this.rid); + } + return this.#readable; + } + + get writable() { + if (this.#writable === undefined) { + this.#writable = writableStreamForRid(this.rid); + } + return this.#writable; + } +} + +function checkOpenOptions(options) { + if ( + ArrayPrototypeFilter( + ObjectValues(options), + (val) => val === true, + ).length === 0 + ) { + throw new Error("OpenOptions requires at least one option to be true"); + } + + if (options.truncate && !options.write) { + throw new Error("'truncate' option requires 'write' option"); + } + + const createOrCreateNewWithoutWriteOrAppend = + (options.create || options.createNew) && + !(options.write || options.append); + + if (createOrCreateNewWithoutWriteOrAppend) { + throw new Error( + "'create' or 'createNew' options require 'write' or 'append' option", + ); + } +} + +const File = FsFile; + +function readFileSync(path) { + return ops.op_readfile_sync(pathFromURL(path)); +} + +async function readFile(path, options) { + let cancelRid; + let abortHandler; + if (options?.signal) { + options.signal.throwIfAborted(); + cancelRid = ops.op_cancel_handle(); + abortHandler = () => core.tryClose(cancelRid); + options.signal[abortSignal.add](abortHandler); + } + + try { + const read = await core.opAsync( + "op_readfile_async", + pathFromURL(path), + cancelRid, + ); + return read; + } finally { + if (options?.signal) { + options.signal[abortSignal.remove](abortHandler); + + // always throw the abort error when aborted + options.signal.throwIfAborted(); + } + } +} + +function readTextFileSync(path) { + return ops.op_readfile_text_sync(pathFromURL(path)); +} + +async function readTextFile(path, options) { + let cancelRid; + let abortHandler; + if (options?.signal) { + options.signal.throwIfAborted(); + cancelRid = ops.op_cancel_handle(); + abortHandler = () => core.tryClose(cancelRid); + options.signal[abortSignal.add](abortHandler); + } + + try { + const read = await core.opAsync( + "op_readfile_text_async", + pathFromURL(path), + cancelRid, + ); + return read; + } finally { + if (options?.signal) { + options.signal[abortSignal.remove](abortHandler); + + // always throw the abort error when aborted + options.signal.throwIfAborted(); + } + } +} + +function writeFileSync( + path, + data, + options = {}, +) { + options.signal?.throwIfAborted(); + ops.op_write_file_sync( + pathFromURL(path), + options.mode, + options.append ?? false, + options.create ?? true, + options.createNew ?? false, + data, + ); +} + +async function writeFile( + path, + data, + options = {}, +) { + let cancelRid; + let abortHandler; + if (options.signal) { + options.signal.throwIfAborted(); + cancelRid = ops.op_cancel_handle(); + abortHandler = () => core.tryClose(cancelRid); + options.signal[abortSignal.add](abortHandler); + } + try { + if (ObjectPrototypeIsPrototypeOf(ReadableStreamPrototype, data)) { + const file = await open(path, { + mode: options.mode, + append: options.append ?? false, + create: options.create ?? true, + createNew: options.createNew ?? false, + write: true, + }); + await data.pipeTo(file.writable, { + signal: options.signal, + }); + } else { + await core.opAsync( + "op_write_file_async", + pathFromURL(path), + options.mode, + options.append ?? false, + options.create ?? true, + options.createNew ?? false, + data, + cancelRid, + ); + } + } finally { + if (options.signal) { + options.signal[abortSignal.remove](abortHandler); + + // always throw the abort error when aborted + options.signal.throwIfAborted(); + } + } +} + +function writeTextFileSync( + path, + data, + options = {}, +) { + const encoder = new TextEncoder(); + return writeFileSync(path, encoder.encode(data), options); +} + +function writeTextFile( + path, + data, + options = {}, +) { + if (ObjectPrototypeIsPrototypeOf(ReadableStreamPrototype, data)) { + return writeFile( + path, + data.pipeThrough(new TextEncoderStream()), + options, + ); + } else { + const encoder = new TextEncoder(); + return writeFile(path, encoder.encode(data), options); + } +} + export { chdir, chmod, @@ -511,11 +837,15 @@ export { chownSync, copyFile, copyFileSync, + create, + createSync, cwd, fdatasync, fdatasyncSync, + File, flock, flockSync, + FsFile, fstat, fstatSync, fsync, @@ -536,16 +866,24 @@ export { makeTempFileSync, mkdir, mkdirSync, + open, + openSync, readDir, readDirSync, + readFile, + readFileSync, readLink, readLinkSync, + readTextFile, + readTextFileSync, realPath, realPathSync, remove, removeSync, rename, renameSync, + seek, + seekSync, stat, statSync, symlink, @@ -555,4 +893,8 @@ export { umask, utime, utimeSync, + writeFile, + writeFileSync, + writeTextFile, + writeTextFileSync, }; diff --git a/runtime/js/40_files.js b/runtime/js/40_files.js deleted file mode 100644 index 5fc5e6c62e..0000000000 --- a/runtime/js/40_files.js +++ /dev/null @@ -1,299 +0,0 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. - -const core = globalThis.Deno.core; -const ops = core.ops; -import { read, readSync, write, writeSync } from "internal:deno_io/12_io.js"; -import { - fstat, - fstatSync, - ftruncate, - ftruncateSync, -} from "internal:runtime/30_fs.js"; -import { pathFromURL } from "internal:runtime/06_util.js"; -import { - readableStreamForRid, - writableStreamForRid, -} from "internal:deno_web/06_streams.js"; -const primordials = globalThis.__bootstrap.primordials; -const { - ArrayPrototypeFilter, - Error, - ObjectValues, -} = primordials; - -function seekSync( - rid, - offset, - whence, -) { - return ops.op_seek_sync({ rid, offset, whence }); -} - -function seek( - rid, - offset, - whence, -) { - return core.opAsync("op_seek_async", { rid, offset, whence }); -} - -function openSync( - path, - options, -) { - if (options) checkOpenOptions(options); - const mode = options?.mode; - const rid = ops.op_open_sync( - pathFromURL(path), - options, - mode, - ); - - return new FsFile(rid); -} - -async function open( - path, - options, -) { - if (options) checkOpenOptions(options); - const mode = options?.mode; - const rid = await core.opAsync( - "op_open_async", - pathFromURL(path), - options, - mode, - ); - - return new FsFile(rid); -} - -function createSync(path) { - return openSync(path, { - read: true, - write: true, - truncate: true, - create: true, - }); -} - -function create(path) { - return open(path, { - read: true, - write: true, - truncate: true, - create: true, - }); -} - -class FsFile { - #rid = 0; - - #readable; - #writable; - - constructor(rid) { - this.#rid = rid; - } - - get rid() { - return this.#rid; - } - - write(p) { - return write(this.rid, p); - } - - writeSync(p) { - return writeSync(this.rid, p); - } - - truncate(len) { - return ftruncate(this.rid, len); - } - - truncateSync(len) { - return ftruncateSync(this.rid, len); - } - - read(p) { - return read(this.rid, p); - } - - readSync(p) { - return readSync(this.rid, p); - } - - seek(offset, whence) { - return seek(this.rid, offset, whence); - } - - seekSync(offset, whence) { - return seekSync(this.rid, offset, whence); - } - - stat() { - return fstat(this.rid); - } - - statSync() { - return fstatSync(this.rid); - } - - close() { - core.close(this.rid); - } - - get readable() { - if (this.#readable === undefined) { - this.#readable = readableStreamForRid(this.rid); - } - return this.#readable; - } - - get writable() { - if (this.#writable === undefined) { - this.#writable = writableStreamForRid(this.rid); - } - return this.#writable; - } -} - -class Stdin { - #readable; - - constructor() { - } - - get rid() { - return 0; - } - - read(p) { - return read(this.rid, p); - } - - readSync(p) { - return readSync(this.rid, p); - } - - close() { - core.close(this.rid); - } - - get readable() { - if (this.#readable === undefined) { - this.#readable = readableStreamForRid(this.rid); - } - return this.#readable; - } - - setRaw(mode, options = {}) { - const cbreak = !!(options.cbreak ?? false); - ops.op_stdin_set_raw(mode, cbreak); - } -} - -class Stdout { - #writable; - - constructor() { - } - - get rid() { - return 1; - } - - write(p) { - return write(this.rid, p); - } - - writeSync(p) { - return writeSync(this.rid, p); - } - - close() { - core.close(this.rid); - } - - get writable() { - if (this.#writable === undefined) { - this.#writable = writableStreamForRid(this.rid); - } - return this.#writable; - } -} - -class Stderr { - #writable; - - constructor() { - } - - get rid() { - return 2; - } - - write(p) { - return write(this.rid, p); - } - - writeSync(p) { - return writeSync(this.rid, p); - } - - close() { - core.close(this.rid); - } - - get writable() { - if (this.#writable === undefined) { - this.#writable = writableStreamForRid(this.rid); - } - return this.#writable; - } -} - -const stdin = new Stdin(); -const stdout = new Stdout(); -const stderr = new Stderr(); - -function checkOpenOptions(options) { - if ( - ArrayPrototypeFilter( - ObjectValues(options), - (val) => val === true, - ).length === 0 - ) { - throw new Error("OpenOptions requires at least one option to be true"); - } - - if (options.truncate && !options.write) { - throw new Error("'truncate' option requires 'write' option"); - } - - const createOrCreateNewWithoutWriteOrAppend = - (options.create || options.createNew) && - !(options.write || options.append); - - if (createOrCreateNewWithoutWriteOrAppend) { - throw new Error( - "'create' or 'createNew' options require 'write' or 'append' option", - ); - } -} - -const File = FsFile; -export { - create, - createSync, - File, - FsFile, - open, - openSync, - seek, - seekSync, - stderr, - stdin, - stdout, -}; diff --git a/runtime/js/40_process.js b/runtime/js/40_process.js index 0854f402a8..bb224ae9c9 100644 --- a/runtime/js/40_process.js +++ b/runtime/js/40_process.js @@ -2,7 +2,7 @@ const core = globalThis.Deno.core; const ops = core.ops; -import { FsFile } from "internal:runtime/40_files.js"; +import { FsFile } from "internal:runtime/30_fs.js"; import { readAll } from "internal:deno_io/12_io.js"; import { pathFromURL } from "internal:runtime/06_util.js"; import { assert } from "internal:deno_web/00_infra.js"; diff --git a/runtime/js/40_read_file.js b/runtime/js/40_read_file.js deleted file mode 100644 index dd4f6e67ae..0000000000 --- a/runtime/js/40_read_file.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. - -const core = globalThis.Deno.core; -const ops = core.ops; -import { pathFromURL } from "internal:runtime/06_util.js"; -import * as abortSignal from "internal:deno_web/03_abort_signal.js"; - -function readFileSync(path) { - return ops.op_readfile_sync(pathFromURL(path)); -} - -async function readFile(path, options) { - let cancelRid; - let abortHandler; - if (options?.signal) { - options.signal.throwIfAborted(); - cancelRid = ops.op_cancel_handle(); - abortHandler = () => core.tryClose(cancelRid); - options.signal[abortSignal.add](abortHandler); - } - - try { - const read = await core.opAsync( - "op_readfile_async", - pathFromURL(path), - cancelRid, - ); - return read; - } finally { - if (options?.signal) { - options.signal[abortSignal.remove](abortHandler); - - // always throw the abort error when aborted - options.signal.throwIfAborted(); - } - } -} - -function readTextFileSync(path) { - return ops.op_readfile_text_sync(pathFromURL(path)); -} - -async function readTextFile(path, options) { - let cancelRid; - let abortHandler; - if (options?.signal) { - options.signal.throwIfAborted(); - cancelRid = ops.op_cancel_handle(); - abortHandler = () => core.tryClose(cancelRid); - options.signal[abortSignal.add](abortHandler); - } - - try { - const read = await core.opAsync( - "op_readfile_text_async", - pathFromURL(path), - cancelRid, - ); - return read; - } finally { - if (options?.signal) { - options.signal[abortSignal.remove](abortHandler); - - // always throw the abort error when aborted - options.signal.throwIfAborted(); - } - } -} - -export { readFile, readFileSync, readTextFile, readTextFileSync }; diff --git a/runtime/js/40_write_file.js b/runtime/js/40_write_file.js deleted file mode 100644 index 89d670a651..0000000000 --- a/runtime/js/40_write_file.js +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -const core = globalThis.Deno.core; -const ops = core.ops; -const primordials = globalThis.__bootstrap.primordials; -import * as abortSignal from "internal:deno_web/03_abort_signal.js"; -import { pathFromURL } from "internal:runtime/06_util.js"; -import { open } from "internal:runtime/40_files.js"; -import { ReadableStreamPrototype } from "internal:deno_web/06_streams.js"; -const { ObjectPrototypeIsPrototypeOf } = primordials; - -function writeFileSync( - path, - data, - options = {}, -) { - options.signal?.throwIfAborted(); - ops.op_write_file_sync( - pathFromURL(path), - options.mode, - options.append ?? false, - options.create ?? true, - options.createNew ?? false, - data, - ); -} - -async function writeFile( - path, - data, - options = {}, -) { - let cancelRid; - let abortHandler; - if (options.signal) { - options.signal.throwIfAborted(); - cancelRid = ops.op_cancel_handle(); - abortHandler = () => core.tryClose(cancelRid); - options.signal[abortSignal.add](abortHandler); - } - try { - if (ObjectPrototypeIsPrototypeOf(ReadableStreamPrototype, data)) { - const file = await open(path, { - mode: options.mode, - append: options.append ?? false, - create: options.create ?? true, - createNew: options.createNew ?? false, - write: true, - }); - await data.pipeTo(file.writable, { - signal: options.signal, - }); - } else { - await core.opAsync( - "op_write_file_async", - pathFromURL(path), - options.mode, - options.append ?? false, - options.create ?? true, - options.createNew ?? false, - data, - cancelRid, - ); - } - } finally { - if (options.signal) { - options.signal[abortSignal.remove](abortHandler); - - // always throw the abort error when aborted - options.signal.throwIfAborted(); - } - } -} - -function writeTextFileSync( - path, - data, - options = {}, -) { - const encoder = new TextEncoder(); - return writeFileSync(path, encoder.encode(data), options); -} - -function writeTextFile( - path, - data, - options = {}, -) { - if (ObjectPrototypeIsPrototypeOf(ReadableStreamPrototype, data)) { - return writeFile( - path, - data.pipeThrough(new TextEncoderStream()), - options, - ); - } else { - const encoder = new TextEncoder(); - return writeFile(path, encoder.encode(data), options); - } -} - -export { writeFile, writeFileSync, writeTextFile, writeTextFileSync }; diff --git a/runtime/js/41_prompt.js b/runtime/js/41_prompt.js index 9fca3bc8fe..66598f7552 100644 --- a/runtime/js/41_prompt.js +++ b/runtime/js/41_prompt.js @@ -2,7 +2,7 @@ const core = globalThis.Deno.core; const primordials = globalThis.__bootstrap.primordials; import { isatty } from "internal:runtime/40_tty.js"; -import { stdin } from "internal:runtime/40_files.js"; +import { stdin } from "internal:deno_io/12_io.js"; const { ArrayPrototypePush, StringPrototypeCharCodeAt, Uint8Array } = primordials; const LF = StringPrototypeCharCodeAt("\n", 0); diff --git a/runtime/js/90_deno_ns.js b/runtime/js/90_deno_ns.js index a76eb5bde7..39a1def90d 100644 --- a/runtime/js/90_deno_ns.js +++ b/runtime/js/90_deno_ns.js @@ -18,13 +18,10 @@ import * as io from "internal:deno_io/12_io.js"; import * as buffer from "internal:runtime/13_buffer.js"; import * as fs from "internal:runtime/30_fs.js"; import * as os from "internal:runtime/30_os.js"; -import * as files from "internal:runtime/40_files.js"; import * as fsEvents from "internal:runtime/40_fs_events.js"; import * as process from "internal:runtime/40_process.js"; -import * as readFile from "internal:runtime/40_read_file.js"; import * as signals from "internal:runtime/40_signals.js"; import * as tty from "internal:runtime/40_tty.js"; -import * as writeFile from "internal:runtime/40_write_file.js"; import * as spawn from "internal:runtime/40_spawn.js"; // TODO(bartlomieju): this is funky we have two `http` imports import * as httpRuntime from "internal:runtime/40_http.js"; @@ -34,14 +31,14 @@ const denoNs = { Process: process.Process, run: process.run, isatty: tty.isatty, - writeFileSync: writeFile.writeFileSync, - writeFile: writeFile.writeFile, - writeTextFileSync: writeFile.writeTextFileSync, - writeTextFile: writeFile.writeTextFile, - readTextFile: readFile.readTextFile, - readTextFileSync: readFile.readTextFileSync, - readFile: readFile.readFile, - readFileSync: readFile.readFileSync, + writeFileSync: fs.writeFileSync, + writeFile: fs.writeFile, + writeTextFileSync: fs.writeTextFileSync, + writeTextFile: fs.writeTextFile, + readTextFile: fs.readTextFile, + readTextFileSync: fs.readTextFileSync, + readFile: fs.readFile, + readFileSync: fs.readFileSync, watchFs: fsEvents.watchFs, chmodSync: fs.chmodSync, chmod: fs.chmod, @@ -101,17 +98,17 @@ const denoNs = { readSync: io.readSync, write: io.write, writeSync: io.writeSync, - File: files.File, - FsFile: files.FsFile, - open: files.open, - openSync: files.openSync, - create: files.create, - createSync: files.createSync, - stdin: files.stdin, - stdout: files.stdout, - stderr: files.stderr, - seek: files.seek, - seekSync: files.seekSync, + File: fs.File, + FsFile: fs.FsFile, + open: fs.open, + openSync: fs.openSync, + create: fs.create, + createSync: fs.createSync, + stdin: io.stdin, + stdout: io.stdout, + stderr: io.stderr, + seek: fs.seek, + seekSync: fs.seekSync, connect: net.connect, listen: net.listen, loadavg: os.loadavg,