Commit graph

462 commits

Author SHA1 Message Date
William Perron 943b0980c7
feat(cli/ops): add the sleep_sync op (#7974) 2020-10-15 21:06:31 -04:00
Bartek Iwańczuk 135053486c
fix: top-level-await module execution (#7946)
This commit changes implementation of top-level-await in "deno_core".

Previously promise returned from module evaluation was not awaited,
leading to out-of-order execution of modules that have TLA. It's been
fixed by changing "JsRuntime::mod_evaluate" to be an async function
that resolves when the promise returned from module evaluation also
resolves. When waiting for promise resolution event loop is polled
repeatedly, until there are no more dynamic imports or pending
ops.
2020-10-14 14:04:09 +02:00
Bartek Iwańczuk 0bd3cea0ff
refactor(cli): rename GlobalState to ProgramState (#7914) 2020-10-13 13:35:35 +02:00
Kitson Kelly 26639b3bac
chore(cli): remove dead code (#7941) 2020-10-12 22:25:25 +11:00
Bartek Iwańczuk 527628e186
reland JsRuntime/Worker is not a Future (#7924) 2020-10-11 13:20:40 +02:00
Ryan Dahl 08bb8b3d53
Fix 100% CPU idling problem by reverting #7672 (#7911)
* Revert "refactor: Worker is not a Future (#7895)"

This reverts commit f4357f0ff9.

* Revert "refactor(core): JsRuntime is not a Future (#7855)"

This reverts commit d8879feb8c.

* Revert "fix(core): module execution with top level await (#7672)"

This reverts commit c7c7677825.
2020-10-10 11:41:11 +02:00
Bartek Iwańczuk f4357f0ff9
refactor: Worker is not a Future (#7895)
This commit rewrites deno::Worker to not implement Future
trait.

Instead there are two separate methods:
- Worker::poll_event_loop() - does single tick of event loop
- Worker::run_event_loop() - runs event loop to completion

Additionally some cleanup to Worker's field visibility was done.
2020-10-09 19:08:10 +02:00
Bartek Iwańczuk 9b70f2f345
refactor: rename isolate to js_runtime (#7858)
This commit renames occurrences of "isolate" variable name
to "js_runtime". This was outstanding debt after renaming
deno_core::CoreIsolate to JsRuntime.
2020-10-07 17:20:20 +02:00
Nayeem Rahman c226d3af25
fix(cli/ops/fs): Don't force Windows paths separate paths with forward slash (#7833) 2020-10-07 14:05:43 +02:00
Bartek Iwańczuk c7c7677825
fix(core): module execution with top level await (#7672)
This commit fixes implementation of top level await in "deno_core".

Previously promise returned from module execution was ignored causing to execute
modules out-of-order.

With this commit promise returned from module execution is stored on "JsRuntime"
and event loop is polled until the promise resolves.
2020-10-06 10:18:22 +02:00
Casper Beyer 4c779b5e8c
refactor(repl): use an inspector session (#7763)
This ports the REPL over to Rust and makes use of an inspector session to run a REPL on top of any isolate which lets make full use of rustylines various things like validators and completors without having to introduce a bunch of hard to test internal ops and glue code.

An accidental but good side effect of this is that the multiple line input we previously had is now an editable multi-line input prompt that is correctly stored in the history as a single entry.
2020-10-02 01:14:55 +02:00
Bartek Iwańczuk 45d4fd44c9
refactor: move op state registration to workers (#7696) 2020-09-28 12:14:11 +02:00
Bartek Iwańczuk e1beebc71a
refactor: factor out check_unstable op helper (#7695) 2020-09-26 20:26:51 +02:00
Bartek Iwańczuk ff785bc35a
refactor: use JsRuntime to implement TSC (#7691)
This commits removes "CompilerWorker" in favor of
using "JsRuntime".

"cli/ops/compiler.rs" has been removed in favor of inline
registration of ops in "cli/tsc.rs"
2020-09-26 16:33:25 +02:00
Bartek Iwańczuk dd1cd4d952
fix: clearing timers race condition (#7617) 2020-09-22 19:33:29 +02:00
Bartek Iwańczuk 92edc36442
refactor: use futures and serde_json from deno_core (#7614) 2020-09-21 18:36:37 +02:00
tokiedokie c4ed3fb7e7
chore: add copyright (#7593) 2020-09-21 08:26:41 -04:00
Bartek Iwańczuk b657d743a2
refactor: remove CliState, use OpState, add CliModuleLoader (#7588)
- remove "CliState.workers" and "CliState.next_worker_id", instead
store them on "OpState" using type aliases.
- remove "CliState.global_timer" and "CliState.start_time", instead
store them on "OpState" using type aliases.
- remove "CliState.is_internal", instead pass it to Worker::new
- move "CliState::permissions" to "OpState"
- move "CliState::main_module" to "OpState"
- move "CliState::global_state" to "OpState"
- move "CliState::check_unstable()" to "GlobalState"
- change "cli_state()" to "global_state()"
- change "deno_core::ModuleLoader" trait to pass "OpState" to callbacks
- rename "CliState" to "CliModuleLoader"
2020-09-20 01:17:35 +02:00
Bartek Iwańczuk f44522eac9
refactor: move fields from CliState to OpState (#7558)
- move rng to OpState
- move GlobalTimer to OpState
- move Metrics to OpState
2020-09-18 20:39:47 +02:00
Bartek Iwańczuk 7845740637
refactor: deno_fetch op crate (#7524) 2020-09-18 09:20:55 -04:00
Bartek Iwańczuk 6453cb7567
refactor: Move URL to op_crates/web (#7544) 2020-09-17 19:13:20 +02:00
Bartek Iwańczuk bda9379385
refactor: move op_resources and op_close to deno_core (#7539)
Moves op_close and op_resources to deno_core::ops and exports them.
Adds serde dependency to deno_core and reexports it.

Moves JS implementation of those ops to Deno.core and reexports them in Deno.
2020-09-17 18:09:50 +02:00
Ryan Dahl 46bf660e36
refactor: make fetch use op_fetch_read instead of op_read (#7529) 2020-09-17 16:11:55 +02:00
Ryan Dahl 104aebdfb5
Re-export deno_core::url (#7525)
Also re-exports deno_core::futures and deno_core::serde_json but these are not yet used in the CLI.
2020-09-16 14:28:07 -04:00
Ryan Dahl c3ef358c01 Remove unnecessary extern statements 2020-09-16 13:29:42 -04:00
Ryan Dahl 0cb64cef76 Remove unnecessary serde_derive dependency 2020-09-16 13:29:42 -04:00
Ryan Dahl 0715803b7f
Remove http_client from CliState, store in OpState directly (#7497) 2020-09-15 16:15:01 -04:00
Ryan Dahl 70f070706d
Rename deno::state::State to deno::state::CliState (#7480) 2020-09-14 21:22:32 -04:00
Bert Belder f5b40c918c
refactor: use the 'anyhow' crate instead of 'ErrBox' (#7476) 2020-09-15 01:50:52 +02:00
Luca Casonato daa780e2cf
fix(WebSocket): no panic on failed connect + handle promise rejection via error event (#7437) 2020-09-13 11:52:20 +02:00
Kitson Kelly 10fbfcbc79
refactor: improve tsc diagnostics (#7420) 2020-09-12 11:53:57 +02:00
Bartek Iwańczuk 0d1f626edd
refactor(core): JsRuntime initialization (#7415)
Removes:
- "deno_core::StartupData"
- "deno_core::Script"
- "deno_core::OwnedScript"

Changes to "JsRuntime":
- remove "new_with_loader()"
- remove "with_heap_limits()"
- rename "IsolateOptions" to "RuntimeOptions" and make public
- "JsRuntime::new()" takes "RuntimeOptions" as a single param
2020-09-11 15:18:49 +02:00
Ryan Dahl 7c2e7c6608
Use gotham-like state for ops (#7385)
Provides a concrete state type that can be dynamically added. This is necessary for op crates.
* renames BasicState to OpState
* async ops take `Rc<RefCell<OpState>>`
* sync ops take `&mut OpState`
* removes `OpRegistry`, `OpRouter` traits
* `get_error_class_fn` moved to OpState
* ResourceTable moved to OpState
2020-09-10 09:57:45 -04:00
Akshat Agarwal c1b4ff61c9
feat(unstable): Add Deno.systemMemoryInfo() (#7350)
Co-authored-by: marcopacini <pacinim88@gmail.com>
Co-authored-by: Casper Beyer <caspervonb@pm.me>
2020-09-10 10:38:17 +02:00
Bartek Iwańczuk f57a2c1e85
refactor(core): rename CoreIsolate to JsRuntime (#7373)
deno_core/
- rename core_isolate.rs to runtime.rs
- rename CoreIsolate to JsRuntime
- rename JSError to JsError
- rename JSStackFrame to JsStackFrame

cli/
- update references from deno_core::CoreIsolate to deno_core::JsRuntime
- rename deno_core::JSError to deno_core::JsError
- rename fmt_errors::JSError to fmt_errors::JsError
2020-09-06 21:44:29 +02:00
Bert Belder c821e8f2f1
Move JSON ops to deno_core (#7336) 2020-09-06 02:34:02 +02:00
crowlKats 8c880d3261
feat: Implement WebSocket API (#7051) 2020-09-05 10:39:25 -04:00
Casper Beyer 87e513ffc5
fix: use millisecond precision for Deno.futime and Deno.utime (#7299) 2020-09-01 10:03:07 -04:00
Casper Beyer 94d38eee4c
replace utime crate with filetime (#7268) 2020-08-31 22:24:17 -04:00
Casper Beyer 32de714dc7
feat(unstable): add Deno.futime and Deno.futimeSync (#7266) 2020-08-31 14:29:43 -04:00
Bartek Iwańczuk 7e946858a4
refactor: migrate ops to new dispatch wrapper (#7118) 2020-08-28 17:08:24 +02:00
Bert Belder c8b5f1e454
Simplify ErrBox-to-class mapping & hook it up to core json ops (#7195) 2020-08-26 18:48:04 +02:00
Bert Belder aead9dc91e
Remove some more unnecessary 'to_string()' calls (#7190) 2020-08-26 01:13:20 +02:00
Bert Belder 9bfb0df805
refactor: remove OpError, use ErrBox everywhere (#7187)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2020-08-26 00:22:15 +02:00
Bert Belder 27f4aeb924
Make Rc/Arc wrapper around State/GlobalState visible (#7104) 2020-08-19 02:01:48 +02:00
Nayeem Rahman 015fa0bd41
refactor: permissions (#7074) 2020-08-18 16:29:32 -04:00
Bert Belder f6e9150b33
Async op dispatcher support with 'stateful_json_op_(a)sync()' (#7095)
Closes: #7020
2020-08-18 20:50:52 +02:00
Ryan Dahl f5a4f1fdc0
Undo JsonOpDispatcher and OpDispatcher traits (#7023)
This reverts commit f83d672ffa.
This reverts commit d51972377c.
2020-08-12 16:44:58 +02:00
Nayeem Rahman 52c1017a74
feat: Stabilize Deno.mainModule (#6993) 2020-08-10 16:41:51 -04:00
Bartek Iwańczuk 59ca66a207
Encode op errors as strings instead of numbers (#6977) 2020-08-07 16:47:18 -04:00
Luca Casonato ce7808baf0
feat(cli): custom http client for fetch (#6918) 2020-08-05 20:44:03 +02:00
Bartek Iwańczuk b449964d1a
refactor: remove more compiler runtime code (#6841) 2020-07-23 15:29:36 +02:00
Ryan Dahl 2460689b1a
Remove deno_typescript (#6813) 2020-07-20 19:49:57 -04:00
Luca Casonato 071a6e284a
Share reqwest client between fetch calls (#6792) 2020-07-18 15:05:08 -04:00
Gurwinder Singh f83d672ffa
refactor: new trait JsonOpDispatcher (#6742) 2020-07-14 14:22:02 -04:00
Gurwinder Singh d51972377c
refactor: Make OpDispatcher a trait (#6736) 2020-07-13 16:19:51 -04:00
Nayeem Rahman 69e0886362
fix(URL): Implement spec-compliant host parsing (#6689) 2020-07-10 15:51:24 -04:00
Sebastien Filion 1bcc35b84a
feat(unstable): add Deno.consoleSize (#6520) 2020-07-10 10:07:12 -04:00
Maayan Hanin edb7a0eead
fix(cli): panic when stdio is null on windows (#6528)
Fixes: #6409
2020-07-09 21:06:51 +02:00
Valentin Anger be7e0f2d49
BREAKING(core): Remove control slice from ops (#6048) 2020-07-08 11:23:50 -04:00
uki00a a2bf61d1ae
feat(unstable): Deno.ppid (#6539) 2020-07-08 10:35:45 -04:00
dubiousjim 6b78729ba8
feat: Deno.chown() make uid, gid args optional (#4612) 2020-07-06 13:15:13 +02:00
Casper Beyer aeadf8189a
fix(cli): change seek offset type from i32 to i64 (#6518) 2020-06-27 15:58:35 -04:00
Bert Belder 0c735ebdc7
Fix clippy warning (#6503) 2020-06-26 20:16:49 +02:00
Casper Beyer e278c90d8a
feat(unstable): add Deno.fdatasyncSync and fdatasync (#6403) 2020-06-26 08:36:35 -04:00
Luca Casonato 4102a19585
fix: panic when process stdio rid is 0 or invalid (#6405) 2020-06-25 12:38:19 -04:00
Casper Beyer 6b3be01a00
feat(unstable): add Deno.fstatSync and fstat (#6425) 2020-06-22 08:58:52 -04:00
Casper Beyer 40866d7cd5
feat(unstable): add Deno.fsyncSync and fsync (#6411) 2020-06-21 09:29:44 -04:00
Ryan Dahl 0a81ec6b1e
Remove Deno.dir and dirs dependency (#6385) 2020-06-20 23:49:27 -04:00
Casper Beyer 86f92e04c7
feat(unstable): add Deno.ftruncate and ftruncateSync (#6243) 2020-06-20 09:46:10 -04:00
Bartek Iwańczuk 826a3135b4
refactor(compiler): split code paths for compile and bundle (#6304)
* refactor "compile" and "runtimeCompile" in "compiler.ts" and factor out
separate methods for "compile" and "bundle" operations

* remove noisy debug output from "compiler.ts"
 
* provide "Serialize" implementations for enums in "msg.rs"

* rename "analyze_dependencies_and_references" to "pre_process_file" and
move it to "tsc.rs"

* refactor ModuleGraph to use more concrete types and properly annotate
locations where errors occur

* remove dead code from "file_fetcher.rs" - "SourceFile.types_url" is no
longer needed, as type reference parsing is done in "ModuleGraph"

* remove unneeded field "source_path" from ".meta" files stored for
compiled source file (towards #6080)
2020-06-19 12:27:15 +02:00
Peter Evers fc850b11e5
unixpacket should also return byte length on send (#6291) 2020-06-15 12:20:45 -04:00
Kermit Xuan 77545219a6
fix: DatagramConn.send should return bytes sent (#6265) 2020-06-13 10:14:31 -04:00
Ryan Dahl e9424bf6b5
Revert "feat: add Deno.osName()" (#6261)
Deno.build.os provides the same functionality

This reverts commit 6ccf9037a6.
2020-06-12 09:53:53 -04:00
Rubin Bhandari 6ccf9037a6
feat: add Deno.osName() (#5714) 2020-06-11 13:11:26 -04:00
John Gardner ca5b5ba530
feat: Add Deno.mainModule (#6180) 2020-06-10 23:00:29 -04:00
Ryan Dahl 54c3f8e27f
fix udp BorrowMutError (#6221) 2020-06-10 11:26:28 -04:00
Casper Beyer 1e0808d501
fix: Deno.readSync on stdin (#6126)
Currently sync operations on stdin are failing because tokio::Stdin
cannot be converted to a std::File.

This commit replaces tokio::stdin with a raw file descriptor 
wrapped in a std::fs::File which can be converted to a 
tokio::File and back again making the synchronous version 
of op_read actually work.
2020-06-09 18:29:12 +02:00
Tuan Le 878f306a39
feat(cli): Add Deno.env.delete() (#5859) 2020-06-09 14:58:30 +02:00
Nayeem Rahman 44251ce8ea
fix(cli/js/web/worker): Disable relative module specifiers (#5266) 2020-06-09 14:33:52 +02:00
Valentin Anger becbb56b19
feat(core): Ops can take several zero copy buffers (#4788) 2020-06-01 14:20:47 -04:00
uki00a 64bd2768f7
fix(#4850): Deno.remove() fails to remove unix socket (#5967) 2020-05-30 14:48:26 -04:00
Ryan Dahl dad551a3a7
upgrade: Rust crates (#5959) 2020-05-30 11:35:44 +02:00
Ryan Dahl d4b05dd89e
refactor: Split isolate and state using safe get_slot() (#5929) 2020-05-29 17:41:39 -04:00
Nayeem Rahman 8e39275429
fix(cli/permissions): Fix CWD and exec path leaks (#5642) 2020-05-29 17:27:43 +02:00
Valentin Anger b7f0b073bb
Add unstable checks for unix transport (#5818)
Also remove the unix example from the stable documentation
to stay in line with the `Deno.listen` one
2020-05-24 09:43:40 -04:00
Ali Hasani 6072755ead
Implement Deno.symlink() for windows (#5533) 2020-05-19 00:46:02 +02:00
Ali Hasani c3ec16535f
Make Deno.remove() work with directory symlinks on windows (#5488) 2020-05-18 14:50:44 +02:00
Bartek Iwańczuk 9d63772fe5
refactor: rewrite TS dependency analysis in Rust (#5029)
This commit completely overhauls how module analysis is 
performed in TS compiler by moving the logic to Rust.

In the current setup module analysis is performed using 
"ts.preProcessFile" API in a special TS compiler worker 
running on a separate thread.

"ts.preProcessFile" allowed us to build a lot of functionality
in CLI including X-TypeScript-Types header support 
and @deno-types directive support. Unfortunately at the 
same time complexity of the ops required to perform 
supporting tasks exploded and caused some hidden 
permission escapes.

This PR introduces "ModuleGraphLoader" which can parse
source and load recursively all dependent source files; as 
well as declaration files. All dependencies used in TS 
compiler and now fetched and collected upfront in Rust 
before spinning up TS compiler.

To achieve feature parity with existing APIs this commit 
includes a lot of changes:

* add "ModuleGraphLoader"
  - can fetch local and remote sources
  - parses source code using SWC and extracts imports, exports, file references, special 
     headers
  - this struct inherited all of the hidden complexity and cruft from TS version and requires 
     several follow up PRs
* rewrite cli/tsc.rs to perform module analysis upfront and send all required source code to 
  TS worker in one message
* remove op_resolve_modules and op_fetch_source_files from cli/ops/compiler.rs
* run TS worker on the same thread
2020-05-18 12:59:29 +02:00
Yiyu Lin c4fe58d8df
Return error if more than one listener calls WorkerHandle::get_event() (#5461) 2020-05-17 06:50:38 +02:00
Yiyu Lin 0b9942da84
fix some unwrap() in Rust (#5485) 2020-05-16 09:41:32 -04:00
Yiyu Lin 871a0c9c0e
fix some clippy warning (#5462) 2020-05-15 15:26:16 -04:00
Kevin (Kun) "Kassimo" Qian 7de86ab605
cli: don't panic on Deno.close invalid argument (#5320) 2020-05-14 06:59:56 -04:00
Bert Belder 3cccadcf0f
Change plugin interface to prevent segfaults when unloading plugin (#5210)
Fixes: #3473
Closes: #5193
2020-05-11 22:39:13 +02:00
Bartek Iwańczuk 32aeec9630
refactor: check permissions in SourceFileFetcher (#5011)
This PR hot-fixes permission escapes in dynamic imports, workers
and runtime compiler APIs.

"permissions" parameter was added to public APIs of SourceFileFetcher
and appropriate permission checks are performed during loading of
local and remote files.
2020-05-11 13:13:27 +02:00
Ryan Dahl b8364a2636
BREAKING: make Deno.hostname unstable (#5108) 2020-05-09 12:44:35 -04:00
Bartek Iwańczuk f9f10229a4
refactor: Remove cli::compilers module (#5138)
This PR removes "cli/compilers/" directory.

"cli/compilers/ts.rs" has been renamed to "cli/tsc.rs"
2020-05-08 16:18:00 +02:00
Bartek Iwańczuk aca21dad1b
BREAKING: make Worker.deno unstable (#5128)
This commit makes "Worker.deno" option unstable.

Added new manual entry "docs/runtime/workers.md".

Removed stale workers tests.
2020-05-07 21:15:59 +02:00
Bartek Iwańczuk 2b66b8a03e
BREAKING: Remove support for .wasm imports (#5135)
Importing .wasm files is non-standardized therefore deciding to
support current functionality past 1.0 release is risky.

Besides that .wasm import posed many challenges in our codebase
due to complex interactions with TS compiler which spawned
thread for each encountered .wasm import.

This commit removes:
- cli/compilers/wasm.rs
- cli/compilers/wasm_wrap.js
- two integration tests related to .wasm imports
2020-05-07 20:43:27 +02:00
Ryan Dahl 221221cc97
BREAKING: execPath should require allow-read (#5109) 2020-05-06 15:51:33 -04:00
Bartek Iwańczuk cf5a39a361
refactor(ts): remove op_cache (#5071)
This PR removes op_cache and refactors how Deno interacts with TS compiler.

Ultimate goal is to completely sandbox TS compiler worker; it should operate on
simple request -> response basis. With this commit TS compiler no longer
caches compiled sources as they are generated but rather collects all sources
and sends them back to Rust when compilation is done.

Additionally "Diagnostic" and its children got refactored to use "Deserialize" trait
instead of manually implementing JSON deserialization.
2020-05-05 18:23:15 +02:00
Ryan Dahl 6c02b061ce
stabilize Deno.cwd and require --allow-read (#5068) 2020-05-04 14:23:06 -04:00
Ryan Dahl 191c59a591
Rename DenoPermissions, add abs path asserts (#5076) 2020-05-04 14:10:59 -04:00
Ryan Dahl bbbf9f299c
Deno.chdir should require allow-read not allow-write (#5033) 2020-05-02 18:33:43 -04:00
Bartek Iwańczuk 2872b362ff
BREAKING: disallow static import of local modules from remote modules (#5050)
This commit changes module loading logic to disallow statically import
local module (file:// scheme) from remote modules (http://, https://
schemes).
2020-05-02 15:51:08 +02:00
Bartek Iwańczuk de2c042482
BREAKING: remove support for JSON imports (#5037)
This commit removes support for importing JSON files as modules.

This change is dictated by security; browsers rolled back on this
support as well.
2020-05-02 00:32:05 +02:00
Bartek Iwańczuk 6661e7e287
BREAKING: remove window.location and self.location (#5034)
This commit removes "location" global available on "window",
"globalThis" and "self".
2020-05-01 20:15:28 +02:00
Luca Casonato 80e2211141
Unstable methods should not appear in runtime or d.ts (#4957)
Co-authored-by: Kitson Kelly <me@kitsonkelly.com>
2020-04-30 11:23:40 -04:00
Bert Belder 3e6ea62841
BREAKING: Include limited metadata in 'DirEntry' objects (#4941)
This change is to prevent needed a separate stat syscall for each file
when using readdir.

For consistency, this PR also modifies std's `WalkEntry` interface to
extend `DirEntry` with an additional `path` field.
2020-04-29 16:00:31 -04:00
Brayden 2337fca277
Make Deno.isatty stable (#4937) 2020-04-29 12:43:34 +02:00
Bartek Iwańczuk 1b6181e434
refactor: factor out datagram from Deno.listen(), make it unstable (#4968)
This commit changes Deno.listen() API by factoring out datagram listeners to Deno.listenDatagram(). New Deno.listenDatagram() is unstable.
2020-04-28 21:46:39 +02:00
Ali Hasani 47c2f034e9
BREAKING: address renamed to path in UnixAddr UnixConnectOptions UnixListenOptions (#4959) 2020-04-28 12:37:59 -04:00
Ryan Dahl e0ca60e770
BREAKING: Use LLVM target triple for Deno.build (#4948)
Deno.build.os values have changed to correspond to standard LLVM target triples
"win" -> "windows"
"mac" -> "darwin"
2020-04-28 12:35:23 -04:00
Bartek Iwańczuk f7ab19b1b7
mark Deno.startTls as unstable (#4965) 2020-04-28 18:01:13 +02:00
Luca Casonato 30dc9bb748
Make shutdown unstable and async (#4940) 2020-04-28 01:36:47 -04:00
Luca Casonato 15099cc016
Make Deno.kill unstable (#4950) 2020-04-27 23:36:43 -04:00
Ali Hasani 22b1a302f4
make utime unstable (#4955) 2020-04-27 21:14:47 -04:00
Ryan Dahl f2d5e6f58a
loadavg and osRelease made unstable (#4938) 2020-04-27 18:00:19 -04:00
Luca Casonato 95a08857f1
Make unix sockets require allow-write (#4939) 2020-04-27 16:56:24 -04:00
Brayden a1974cbe43
Mark Deno.umask unstable (#4935) 2020-04-27 16:07:57 -04:00
Bert Belder ee4e6a1ef9
Rename FileInfo time fields and represent them as Date objects (#4932)
This patch also increases the resolution of reported file times to
sub-millisecond precision.
2020-04-27 21:13:32 +02:00
Ryan Dahl 62976a1c94
signal APIs should require --unstable (#4926) 2020-04-27 13:38:23 -04:00
Ryan Dahl dd0b25e313
Make Deno.setRaw and Deno.isatty unstable (#4925) 2020-04-27 10:54:55 -04:00
Ryan Dahl 3e9b0da346
Make Deno.dir unstable (#4924) 2020-04-27 16:53:56 +02:00
Ryan Dahl 4036be2ab2
Make runtime compile ops unstable (#4912) 2020-04-27 09:59:34 -04:00
Ryan Dahl 0c47cd6785
introduce unstable flag, make a few things unstable (#4892) 2020-04-25 09:31:54 -04:00
Ryan Dahl f8d83361cd
chdir should require --allow-write (#4889) 2020-04-24 19:55:33 -04:00
Bartek Iwańczuk 1378df3364
remove bootstrap methods from global scope after bootstrapping (#4869) 2020-04-25 01:03:45 +02:00
Bartek Iwańczuk 4a8d25646a
BREAKING CHANGE: remove Deno.OpenMode (#4884)
This commit removes Deno.OpenMode along with overloaded variants
of Deno.open() and Deno.openSync() that used OpenMode.
2020-04-25 00:45:55 +02:00
Ryan Dahl d8711155ca
Rename deno_core::Isolate to deno_core::CoreIsolate (#4851) 2020-04-23 11:51:07 +02:00
Ryan Dahl cc1720132a
Move resource_table from deno::State to deno_core::Isolate (#4834) 2020-04-21 09:48:44 -04:00
Ryan Dahl 6e5f3453f8
Remove core/plugin.rs (#4824)
This simplifies the plugin interface in order to deliver op crates with a similar API
2020-04-20 10:27:15 -04:00
Ryan Dahl c1ec042a00
Modify op dispatcher to include &mut Isolate argument (#4821)
- Removes unnecessary RwLock and Rc around the op registry table
- Preparation to move resource_table to deno_core::Isolate.
- Towards #3453, #4222
2020-04-19 23:54:46 -04:00
Ryan Dahl 4d2b9cd37a
Fix Op definitions (#4814) 2020-04-18 20:05:13 -04:00
EnokMan 47617e60d5
feat: startTLS (#4773) 2020-04-18 11:21:20 -04:00
Bartek Iwańczuk 41f836dc91
replace block_on in net interfaces (#4796) 2020-04-17 18:45:34 +02:00
Bartek Iwańczuk d359789c52
feat: support Deno namespace in Worker API (#4784) 2020-04-16 23:40:29 +02:00
Bartek Iwańczuk 0c48470b35
remove more calls to futures::executor::block_on (#4775) 2020-04-16 16:29:28 +02:00
Bartek Iwańczuk aab26d226e
remove calls to futures::executor::block_on (#4760) 2020-04-15 23:14:28 -04:00
Ryan Dahl fab0204cbf
Make writeSync, readSync, seekSync, openSync, isatty proper synchronous syscalls (#4762) 2020-04-15 20:43:19 -04:00
Bartek Iwańczuk e08ece2d2c
fix(worker): make worker name spec compliant (#4746) 2020-04-14 17:41:06 +02:00
Nayeem Rahman 0ea6eb83a9
refactor(core/js_error): Align JSStackFrame with CallSite (#4715)
Renames and adds missing fields to JSStackFrame from CallSite. Fixes #4705.

Cleans up base changes for line and column numbers.
2020-04-13 10:54:16 -04:00
gewoonwoutje 2feb661b85
Replace panic with invalid_utf8 OpError (#4704)
Co-authored-by: Wout Elstgeest <w.elstgeest@inepro.com>
2020-04-10 22:14:16 -04:00
Bartek Iwańczuk be71885628
implement Worker.terminate() and self.close() (#4684) 2020-04-10 00:15:17 +02:00
Kitson Kelly f527407287
clippy (#4618) 2020-04-03 22:41:16 -04:00
dubiousjim 6f9c78979d
Properly handle invalid utf8 in paths (#4609) 2020-04-03 13:47:57 -04:00
dubiousjim c5c3abc517
adjust docs for Deno.seek (#4610) 2020-04-03 13:45:44 -04:00
dubiousjim d4d0b5d90c
Properly track isFile, isSymlink, isDirectory (#4541)
* Properly track isFile, isSymlink, isDirectory

These don't exhaust all the possibilities, so none of them should be
defined as "neither of the others".

* empty
2020-03-31 13:46:25 -04:00
Ryan Dahl 2874664e91
feat: Support Inspector / Chrome Devtools (#4484)
This is a first pass implementation which is still missing several important
features:
- support for --inspect-brk (#4503)
- support for source maps (#4501)
- support for piping console.log to devtools console (#4502)

Co-authored-by: Bert Belder <bertbelder@gmail.com>
Co-authored-by: Matt Harrison <mt.harrison86@gmail.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2020-03-27 16:09:51 -04:00
João Souto 70a5034431
feat: Support Unix Domain Sockets (#4176) 2020-03-23 18:02:51 -04:00
Akshat Agarwal b8a5c29bf8
BREAKING CHANGE Rename Deno.run's args to cmd (#4444)
This is to avoid confusion with Deno.args which does not include the 
executable to be run.
2020-03-21 17:44:18 -04:00
dubiousjim 77a44163fb
chmod should throw on Windows (#4446) 2020-03-20 16:03:04 -04:00
dubiousjim 1c6f177d19
use prebuilt "not implemented" error (#4442) 2020-03-20 12:10:02 -04:00
dubiousjim 69303e2149
refactor: move code from fs.rs into ops/fs.rs (#4428)
This a complex boring PR that shifts around code (primarily) in cli/fs.rs and
cli/ops/fs.rs. The gain of this refactoring is to ease the way for #4188 and
#4017, and also to avoid some future development pain.

Mostly there is no change in functionality. Except:
* squashed bugs where op_utime and op_chown weren't using `resolve_from_cwd`
* eliminated the use of the external `remove_dir_all` crate.
* op_chmod now only queries metadata to verify file/dir exists on Windows (it
  will already fail on Unix if it doesn't)
* op_chown now verifies the file/dir's existence on Windows like chmod does.
2020-03-20 09:46:26 -04:00
Kitson Kelly da8cb408c8
Provide compiled JSON to TypeScript compiler. (#4404)
Fixes #4101

Previously, we would just provide the raw JSON to the TypeScript
compiler worker, but TypeScript does not transform JSON.  This caused
a problem when emitting a bundle, that the JSON would just be "inlined"
into the output, instead of being transformed into a module.

This fixes this problem by providing the compiled JSON to the TypeScript
compiler, so TypeScript just sees JSON as a "normal" TypeScript module.
2020-03-18 12:39:53 -04:00
dubiousjim f9557a4ff6
Add mode option to open/create (#4289) 2020-03-16 15:02:41 -04:00
Gurwinder Singh 8077ade741
refactor: remove an unsafe and some boxing (#4398) 2020-03-16 10:46:31 -07:00
dubiousjim 6cc40b0865
BREAKING CHANGE FileInfo.len renamed to FileName.size (#4338) 2020-03-14 22:57:42 -04:00
Ryan Dahl 3ac642c183
upgrade: Rust 1.42.0 (#4331) 2020-03-12 18:07:57 +01:00
João Souto fb5c31416d
Add waker to StreamResource to fix hang on close bugs (#4293) 2020-03-11 18:19:24 -04:00
dubiousjim a28fa2415f
support permission mode in mkdir (#4286) 2020-03-11 16:14:23 -04:00
Nayeem Rahman 55119aaee2
refactor(cli/js/net): Cleanup iterable APIs (#4236)
Listener and UDPConn are AsyncIterables instead of AsyncIterators.
The [Symbol.asyncIterator]()s are defined as generators and the
next() methods are gone.

"Listener/Socket has been closed" errors are now BadResource.
2020-03-10 15:14:22 -04:00
dubiousjim 8078d976d2
Add Deno.umask (#4290) 2020-03-10 15:11:27 -04:00
Bartek Iwańczuk 88b77da25c
refactor: remove cli/ops/files.rs (#4246)
* "op_close" - moved to "cli/ops/resources.rs"
* "op_seek", "op_open" - moved to "cli/ops/fs.rs"

Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
2020-03-07 13:20:27 +01:00
dubiousjim acf0958e94
Rename name/filename arguments to path (#4227)
There's a lot of variation in doc comments and internal code about
whether the first parameter to file system calls is `path` or `name` or
`filename`. For consistency, have made it always be `path`.
2020-03-06 11:29:23 -05:00
Ryan Dahl afea9b2edd
fix: call unwatch when dropping FsEventsResource (#4266) 2020-03-05 20:01:08 -05:00
Ryan Dahl 54a1688868
Allow BadResource errors to take a custom message (#4251) 2020-03-05 08:30:41 -05:00
Bert Belder 5d3dfa4cf6
Remove unnecessary macro from cli/ops/tty.rs (#4254)
It contains a clippy issue, and there's no need for this macro anyway.
2020-03-04 15:54:09 -08:00
Bert Belder eafd40feab
Do not convert exceptions to JSON and back (#4214) 2020-03-02 14:20:16 -08:00
Bartek Iwańczuk ff5bba3be8
feat: update metrics to track different op types (#4221) 2020-03-02 19:13:36 +01:00
Bartek Iwańczuk cfe4369ded
refactor: rename structures related to Modules (#4217)
* rename structures related to ES Modules; add "Modules" prefix
* remove unneeded Unpin trait requirement for "ModuleLoader"
2020-03-02 19:12:49 +01:00
bartOssh 4a47ffa5c4
seek should return cursor position (#4211) 2020-03-02 11:44:46 -05:00
dubiousjim 6cd46fa3ef
Cleanup comments and internal variables (#4205) 2020-03-02 10:19:42 -05:00
ecyrbe 2a594bd3b2
feat(std/node): add os.tmpdir() implementation (#4213) 2020-03-01 19:05:04 -05:00
Bartek Iwańczuk fa5f3aa600
replace impl Future with poll_fn for net.rs, process.rs, tls.rs (#4158) 2020-02-27 21:08:21 +01:00
Bartek Iwańczuk daf7617f42
rewrite normalize_path (#4143)
Rewrite "normalize_path()" to remove all intermediate components from the path, ie. "./" and "../". It's very similar in functionality to fs::canonicalize(), however "normalize_path() doesn't resolve symlinks.
2020-02-26 22:11:52 +01:00
Bartek Iwańczuk 7fff2d2d1e
remove Read/Write futures, use poll_fn instead (#4150) 2020-02-26 22:06:20 +01:00
Kevin (Kun) "Kassimo" Qian 5946808f66
tty: Deno.setRaw(rid, mode) to turn on/off raw mode (#3958) 2020-02-26 01:01:24 -05:00
Ryan Dahl f47f3f9672
Remove _async from method names since _sync are gone (#4128) 2020-02-25 20:42:00 +01:00
Nayeem Rahman 14e7e1e3af
fix: Resolve makeTemp* paths from CWD (#4104) 2020-02-25 09:23:23 -05:00
Ryan Dahl 91b606aaae
Clean up how we use opIds (#4118) 2020-02-25 09:14:27 -05:00
Kitson Kelly 2b7e28b591
feat: Add Deno.formatDiagnostics (#4032) 2020-02-24 14:48:14 -05:00
ecyrbe fb08cf7005
Add missing node os.release() implementation (#4065) 2020-02-24 08:35:45 -05:00
Bartek Iwańczuk 4e1abb4f3a
refactor: use OpError instead of ErrBox for errors in ops (#4058)
To better reflect changes in error types in JS from #3662 this PR changes 
default error type used in ops from "ErrBox" to "OpError".

"OpError" is a type that can be sent over to JSON; it has all 
information needed to construct error in JavaScript. That
made "GetErrorKind" trait useless and so it was removed altogether.

To provide compatibility with previous use of "ErrBox" an implementation of
"From<ErrBox> for OpError" was added, however, it is an escape hatch and
ops implementors should strive to use "OpError" directly.
2020-02-23 14:51:29 -05:00
Kevin (Kun) "Kassimo" Qian e9fff02e96
fetch: proper error for unsupported protocol (#4085) 2020-02-23 09:45:02 -05:00
ecyrbe fb98556d56
feat(std/node): add os.loadavg() (#4075) 2020-02-22 18:46:52 -05:00
Bartek Iwańczuk bd640bc7e6
feat: Deno.fsEvents() (#3452) 2020-02-21 13:21:51 -05:00
hazæ41 08686cbc3a
feat: support UDP sockets (#3946) 2020-02-21 11:26:54 -05:00
Bartek Iwańczuk dd8a109481
refactor: remove unneeded ErrorKinds (#3936) 2020-02-21 10:36:13 -05:00
Bartek Iwańczuk 742a16b506
refactor: rewrite file_fetcher to use async fns, lift blocking call (#4037) 2020-02-19 17:51:10 -05:00
Kitson Kelly 046bbb2691
Support loading additional TS lib files (#3863)
Fixes #3726

This PR provides support for referencing other lib files (like lib.dom.d.ts that are not
used by default in Deno.
2020-02-19 00:34:11 -05:00
Bartek Iwańczuk 3d5bed35e0
refactor: remove run_worker_loop (#4028)
* remove run_worker_loop, impl poll for WebWorker
* store JoinHandle to worker thread
2020-02-18 14:47:11 -05:00
Kevin (Kun) "Kassimo" Qian 08dcf6bff7
feat: Deno.makeTempFile (#4024) 2020-02-18 14:45:59 -05:00
Bartek Iwańczuk 302debebb3
refactor: cleanup cli/lib.rs (#4006)
* rename methods on Worker related to module loading
* reorganize cli/lib.rs
* remove cli/progress.rs and cli/shell.rs
2020-02-18 10:08:18 -05:00
geoFlux 2e7d449623
feat: add --cert flag for http client (#3972) 2020-02-17 11:59:51 -05:00
Ben Noordhuis 503d8bfef2
fix: skip non-UTF-8 dir entries in Deno.readDir() (#4004)
Example:

		$ python2 -c 'open("\x80\x7F", "w")'

		$ deno eval 'Deno.readDirSync(".")'
		thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', cli/ops/fs.rs:373:16
		note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
		fatal runtime error: failed to initiate panic, error 5
		Aborted (core dumped)

Before this commit they made deno panic, now they are silently skipped.
Not ideal but arguably better than panicking.

No test because what characters are and aren't allowed in filenames is
highly file system-dependent.

Closes #3950
2020-02-15 10:37:05 -05:00
Bartek Iwańczuk a0f015b1a3
refactor: replace Arc<Box<..>> with Rc<..> (#3996) 2020-02-15 01:18:36 +01:00
Bartek Iwańczuk e0bcecee60
refactor: Remove atomics from metrics (#3968)
* replace "AtomicUsize" with "u64" for field type on "Metrics"
* move "compiler_starts" field from "Metrics" to "GlobalState"
2020-02-11 17:23:40 +01:00
Bartek Iwańczuk 79b3bc05d6
workers: basic event loop (#3828)
* establish basic event loop for workers
* make "self.close()" inside worker
* remove "runWorkerMessageLoop() - instead manually call global function 
  in Rust when message arrives. This is done in preparation for structured clone
* refactor "WorkerChannel" and use distinct structs for internal 
  and external channels;  "WorkerChannelsInternal" and "WorkerHandle"
* move "State.worker_channels_internal" to "Worker.internal_channels"
* add "WorkerEvent" enum for child->host communication; 
  currently "Message(Buf)" and  "Error(ErrBox)" variants are supported
* add tests for nested workers
* add tests for worker throwing error on startup
2020-02-11 10:04:59 +01:00
Andy Finch 1abd408770
No longer require aligned buffer for shared queue (#3935)
Fixes: #3925
2020-02-09 10:54:16 -08:00