2023-01-02 16:00:42 -05:00
|
|
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
2020-07-19 13:49:44 -04:00
|
|
|
|
2023-02-07 14:22:46 -05:00
|
|
|
const core = globalThis.Deno.core;
|
|
|
|
const ops = core.ops;
|
2023-02-07 16:09:50 -05:00
|
|
|
import * as timers from "internal:deno_web/02_timers.js";
|
|
|
|
import * as httpClient from "internal:deno_fetch/22_http_client.js";
|
|
|
|
import * as console from "internal:deno_console/02_console.js";
|
|
|
|
import * as ffi from "internal:deno_ffi/00_ffi.js";
|
|
|
|
import * as net from "internal:deno_net/01_net.js";
|
|
|
|
import * as tls from "internal:deno_net/02_tls.js";
|
|
|
|
import * as http from "internal:deno_http/01_http.js";
|
|
|
|
import * as flash from "internal:deno_flash/01_http.js";
|
refactor(core): include_js_files! 'dir' option doesn't change specifiers (#18019)
This commit changes "include_js_files!" macro from "deno_core"
in a way that "dir" option doesn't cause specifiers to be rewritten
to include it.
Example:
```
include_js_files! {
dir "js",
"hello.js",
}
```
The above definition required embedders to use:
`import ... from "internal:<ext_name>/js/hello.js"`.
But with this change, the "js" directory in which the files are stored
is an implementation detail, which for embedders results in:
`import ... from "internal:<ext_name>/hello.js"`.
The directory the files are stored in, is an implementation detail and
in some cases might result in a significant size difference for the
snapshot. As an example, in "deno_node" extension, we store the
source code in "polyfills" directory; which resulted in each specifier
to look like "internal:deno_node/polyfills/<module_name>", but with
this change it's "internal:deno_node/<module_name>".
Given that "deno_node" has over 100 files, many of them having
several import specifiers to the same extension, this change removes
10 characters from each import specifier.
2023-03-04 21:31:38 -05:00
|
|
|
import * as build from "internal:runtime/01_build.js";
|
|
|
|
import * as errors from "internal:runtime/01_errors.js";
|
|
|
|
import * as version from "internal:runtime/01_version.ts";
|
|
|
|
import * as permissions from "internal:runtime/10_permissions.js";
|
2023-03-04 19:39:48 -05:00
|
|
|
import * as io from "internal:deno_io/12_io.js";
|
refactor(core): include_js_files! 'dir' option doesn't change specifiers (#18019)
This commit changes "include_js_files!" macro from "deno_core"
in a way that "dir" option doesn't cause specifiers to be rewritten
to include it.
Example:
```
include_js_files! {
dir "js",
"hello.js",
}
```
The above definition required embedders to use:
`import ... from "internal:<ext_name>/js/hello.js"`.
But with this change, the "js" directory in which the files are stored
is an implementation detail, which for embedders results in:
`import ... from "internal:<ext_name>/hello.js"`.
The directory the files are stored in, is an implementation detail and
in some cases might result in a significant size difference for the
snapshot. As an example, in "deno_node" extension, we store the
source code in "polyfills" directory; which resulted in each specifier
to look like "internal:deno_node/polyfills/<module_name>", but with
this change it's "internal:deno_node/<module_name>".
Given that "deno_node" has over 100 files, many of them having
several import specifiers to the same extension, this change removes
10 characters from each import specifier.
2023-03-04 21:31:38 -05:00
|
|
|
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";
|
2023-02-07 14:22:46 -05:00
|
|
|
// TODO(bartlomieju): this is funky we have two `http` imports
|
refactor(core): include_js_files! 'dir' option doesn't change specifiers (#18019)
This commit changes "include_js_files!" macro from "deno_core"
in a way that "dir" option doesn't cause specifiers to be rewritten
to include it.
Example:
```
include_js_files! {
dir "js",
"hello.js",
}
```
The above definition required embedders to use:
`import ... from "internal:<ext_name>/js/hello.js"`.
But with this change, the "js" directory in which the files are stored
is an implementation detail, which for embedders results in:
`import ... from "internal:<ext_name>/hello.js"`.
The directory the files are stored in, is an implementation detail and
in some cases might result in a significant size difference for the
snapshot. As an example, in "deno_node" extension, we store the
source code in "polyfills" directory; which resulted in each specifier
to look like "internal:deno_node/polyfills/<module_name>", but with
this change it's "internal:deno_node/<module_name>".
Given that "deno_node" has over 100 files, many of them having
several import specifiers to the same extension, this change removes
10 characters from each import specifier.
2023-03-04 21:31:38 -05:00
|
|
|
import * as httpRuntime from "internal:runtime/40_http.js";
|
2022-11-10 16:03:28 -05:00
|
|
|
|
2023-02-07 14:22:46 -05:00
|
|
|
const denoNs = {
|
|
|
|
metrics: core.metrics,
|
|
|
|
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,
|
|
|
|
watchFs: fsEvents.watchFs,
|
|
|
|
chmodSync: fs.chmodSync,
|
|
|
|
chmod: fs.chmod,
|
|
|
|
chown: fs.chown,
|
|
|
|
chownSync: fs.chownSync,
|
|
|
|
copyFileSync: fs.copyFileSync,
|
|
|
|
cwd: fs.cwd,
|
|
|
|
makeTempDirSync: fs.makeTempDirSync,
|
|
|
|
makeTempDir: fs.makeTempDir,
|
|
|
|
makeTempFileSync: fs.makeTempFileSync,
|
|
|
|
makeTempFile: fs.makeTempFile,
|
|
|
|
memoryUsage: () => ops.op_runtime_memory_usage(),
|
|
|
|
mkdirSync: fs.mkdirSync,
|
|
|
|
mkdir: fs.mkdir,
|
|
|
|
chdir: fs.chdir,
|
|
|
|
copyFile: fs.copyFile,
|
|
|
|
readDirSync: fs.readDirSync,
|
|
|
|
readDir: fs.readDir,
|
|
|
|
readLinkSync: fs.readLinkSync,
|
|
|
|
readLink: fs.readLink,
|
|
|
|
realPathSync: fs.realPathSync,
|
|
|
|
realPath: fs.realPath,
|
|
|
|
removeSync: fs.removeSync,
|
|
|
|
remove: fs.remove,
|
|
|
|
renameSync: fs.renameSync,
|
|
|
|
rename: fs.rename,
|
|
|
|
version: version.version,
|
|
|
|
build: build.build,
|
|
|
|
statSync: fs.statSync,
|
|
|
|
lstatSync: fs.lstatSync,
|
|
|
|
stat: fs.stat,
|
|
|
|
lstat: fs.lstat,
|
|
|
|
truncateSync: fs.truncateSync,
|
|
|
|
truncate: fs.truncate,
|
|
|
|
ftruncateSync: fs.ftruncateSync,
|
|
|
|
ftruncate: fs.ftruncate,
|
|
|
|
futime: fs.futime,
|
|
|
|
futimeSync: fs.futimeSync,
|
|
|
|
errors: errors.errors,
|
|
|
|
// TODO(kt3k): Remove this export at v2
|
|
|
|
// See https://github.com/denoland/deno/issues/9294
|
|
|
|
customInspect: console.customInspect,
|
|
|
|
inspect: console.inspect,
|
|
|
|
env: os.env,
|
|
|
|
exit: os.exit,
|
|
|
|
execPath: os.execPath,
|
|
|
|
Buffer: buffer.Buffer,
|
|
|
|
readAll: buffer.readAll,
|
|
|
|
readAllSync: buffer.readAllSync,
|
|
|
|
writeAll: buffer.writeAll,
|
|
|
|
writeAllSync: buffer.writeAllSync,
|
|
|
|
copy: io.copy,
|
|
|
|
iter: io.iter,
|
|
|
|
iterSync: io.iterSync,
|
|
|
|
SeekMode: io.SeekMode,
|
|
|
|
read: io.read,
|
|
|
|
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,
|
|
|
|
connect: net.connect,
|
|
|
|
listen: net.listen,
|
|
|
|
loadavg: os.loadavg,
|
|
|
|
connectTls: tls.connectTls,
|
|
|
|
listenTls: tls.listenTls,
|
|
|
|
startTls: tls.startTls,
|
|
|
|
shutdown: net.shutdown,
|
|
|
|
fstatSync: fs.fstatSync,
|
|
|
|
fstat: fs.fstat,
|
|
|
|
fsyncSync: fs.fsyncSync,
|
|
|
|
fsync: fs.fsync,
|
|
|
|
fdatasyncSync: fs.fdatasyncSync,
|
|
|
|
fdatasync: fs.fdatasync,
|
|
|
|
symlink: fs.symlink,
|
|
|
|
symlinkSync: fs.symlinkSync,
|
|
|
|
link: fs.link,
|
|
|
|
linkSync: fs.linkSync,
|
|
|
|
permissions: permissions.permissions,
|
|
|
|
Permissions: permissions.Permissions,
|
|
|
|
PermissionStatus: permissions.PermissionStatus,
|
|
|
|
// TODO(bartlomieju): why is this not in one of extensions?
|
|
|
|
serveHttp: httpRuntime.serveHttp,
|
|
|
|
resolveDns: net.resolveDns,
|
|
|
|
upgradeWebSocket: http.upgradeWebSocket,
|
|
|
|
utime: fs.utime,
|
|
|
|
utimeSync: fs.utimeSync,
|
|
|
|
kill: process.kill,
|
|
|
|
addSignalListener: signals.addSignalListener,
|
|
|
|
removeSignalListener: signals.removeSignalListener,
|
|
|
|
refTimer: timers.refTimer,
|
|
|
|
unrefTimer: timers.unrefTimer,
|
|
|
|
osRelease: os.osRelease,
|
|
|
|
osUptime: os.osUptime,
|
|
|
|
hostname: os.hostname,
|
|
|
|
systemMemoryInfo: os.systemMemoryInfo,
|
|
|
|
networkInterfaces: os.networkInterfaces,
|
|
|
|
consoleSize: tty.consoleSize,
|
|
|
|
gid: os.gid,
|
|
|
|
uid: os.uid,
|
2023-02-13 13:25:00 -05:00
|
|
|
Command: spawn.Command,
|
|
|
|
// TODO(bartlomieju): why is this exported?
|
|
|
|
ChildProcess: spawn.ChildProcess,
|
2023-02-07 14:22:46 -05:00
|
|
|
};
|
2020-07-19 13:49:44 -04:00
|
|
|
|
2023-02-07 14:22:46 -05:00
|
|
|
const denoNsUnstable = {
|
|
|
|
listenDatagram: net.listenDatagram,
|
|
|
|
umask: fs.umask,
|
|
|
|
HttpClient: httpClient.HttpClient,
|
|
|
|
createHttpClient: httpClient.createHttpClient,
|
|
|
|
// TODO(bartlomieju): why is it needed?
|
|
|
|
http,
|
|
|
|
dlopen: ffi.dlopen,
|
|
|
|
UnsafeCallback: ffi.UnsafeCallback,
|
|
|
|
UnsafePointer: ffi.UnsafePointer,
|
|
|
|
UnsafePointerView: ffi.UnsafePointerView,
|
|
|
|
UnsafeFnPointer: ffi.UnsafeFnPointer,
|
|
|
|
flock: fs.flock,
|
|
|
|
flockSync: fs.flockSync,
|
|
|
|
funlock: fs.funlock,
|
|
|
|
funlockSync: fs.funlockSync,
|
|
|
|
upgradeHttp: http.upgradeHttp,
|
|
|
|
upgradeHttpRaw: flash.upgradeHttpRaw,
|
|
|
|
};
|
|
|
|
|
|
|
|
export { denoNs, denoNsUnstable };
|