Commit graph

462 commits

Author SHA1 Message Date
Bartek Iwańczuk 8d5c0112fb
feat: don't require --unstable flag for npm programs (#16520)
This PR adds copies of several unstable APIs that are available
in "Deno[Deno.internal].nodeUnstable" namespace.

These copies do not perform unstable check (ie. don't require
"--unstable" flag to be present). Otherwise they work exactly
the same, including permission checks.

These APIs are not meant to be used by users directly and
can change at any time.

Copies of following APIs are available in that namespace:
- Deno.spawnChild
- Deno.spawn
- Deno.spawnSync
- Deno.serve
- Deno.upgradeHttpRaw
- Deno.listenDatagram
2022-11-10 22:03:28 +01:00
David Sherret d677ba67f5
feat(npm): functionality to support child_process.fork (#15891) 2022-09-28 13:04:16 -04:00
Nayeem Rahman 22a4998e29
refactor: allocate IDs for tests (#14729) 2022-07-15 13:09:22 -04:00
Nayeem Rahman f0dd751190
refactor(bench): Allocate IDs for benches (#14757) 2022-05-30 19:58:44 +02:00
Bartek Iwańczuk f57aac77ff
BREAKING: Remove unstable Deno.emit and Deno.formatDiagnostics APIs (#14463) 2022-05-17 13:50:31 -04:00
Andreu Botella 3e7afb8918
chore(runtime): Make some ops in ext and runtime infallible. (#14589)
Co-authored-by: Aaron O'Mullan <aaron.omullan@gmail.com>
2022-05-13 10:36:31 +02:00
Bartek Iwańczuk 3f08a40412
refactor: add core.formatLocationFilename, remove op_format_filename (#14474)
This commit moves "op_format_location" to "core/ops_builtin.rs"
and removes "Deno.core.createPrepareStackTrace" in favor of
"Deno.core.prepareStackTrace".

Co-authored-by: Aaron O'Mullan <aaron.omullan@gmail.com>
2022-05-03 19:45:57 +02:00
David Sherret de33017a8b
fix(test): actually capture stdout and stderr in workers (#14435) 2022-05-01 14:44:55 -04:00
David Sherret 58eab0e2b3
fix(test): capture worker stdout and stderr in test output (#14410) 2022-04-26 19:00:04 -04:00
David Sherret a1b4aa2ae6
fix(test): capture inherited stdout and stderr for subprocesses in test output (#14395) 2022-04-26 14:46:49 -04:00
Bartek Iwańczuk 9c5928b5aa
fix: panic when trying to pledge permissions before restoring previous pledge (#14306)
This commit fixes and edge case, where testing/benching code could pledge new
permission set before restoring the previous pledge.

Appropriate panics were added and tests that assert that process is killed
in case of "recursive pledge".
2022-04-17 17:47:24 +02:00
Nayeem Rahman 8b31fc23cd
refactor: Move source map lookups to core (#14274)
The following transformations gradually faced by "JsError" have all been 
moved up front to "JsError::from_v8_exception()": 

- finding the first non-"deno:" source line; 
- moving "JsError::script_resource_name" etc. into the first error stack 
in case of syntax errors; 
- source mapping "JsError::script_resource_name" etc. when wrapping 
the error even though the frame locations are source mapped earlier; 
- removing "JsError::{script_resource_name,line_number,start_column,end_column}"
entirely in favour of "js_error.frames.get(0)". 

We also no longer pass a js-side callback to "core/02_error.js" from cli. 
I avoided doing this on previous occasions because the source map lookups 
were in an awkward place.
2022-04-15 16:08:09 +02:00
Bartek Iwańczuk 244926e83c
feat(test): format user code output (#14271)
This commit changes "deno test" to better denote user output coming
from test cases.

This is done by printing "---- output ----" and "---- output end ----"
markers if an output is produced. The output from "console" and
"Deno.core.print" is captured, as well as direct writes to "Deno.stdout"
and "Deno.stderr".

To achieve that new APIs were added to "deno_core" crate, that allow
to replace an existing resource with a different one (while keeping resource
ids intact). Resources for stdout and stderr are replaced by pipes.

Co-authored-by: David Sherret <dsherret@gmail.com>
2022-04-15 14:24:41 +02:00
Bartek Iwańczuk 8ae17026cb
feat: Add "deno check" subcommand for type checking (#14072)
This commit adds new "deno check" subcommand.
Currently it is an alias for "deno cache" with the difference that remote
modules don't emit TS diagnostics by default.

Prints warning for "deno run" subcommand if "--check" flag is not present
and there's no "--no-check" flag. Adds "DENO_FUTURE_CHECK" env
variable that allows to opt into new behavior now.
2022-04-11 01:12:51 +02:00
Bartek Iwańczuk 381d565acf
refactor(flags): rename CheckFlag to TypecheckMode (#14111) 2022-03-29 03:48:29 +02:00
Bartek Iwańczuk b82ded84d3
fix(bench): require --unstable flag in JavaScript (#14091) 2022-03-23 16:33:42 +01:00
Aaron O'Mullan bd481bf095
feat(ops): optional OpState (#13954) 2022-03-16 00:33:46 +01:00
Aaron O'Mullan 88d0f01948
feat(ops): custom arity (#13949)
Also cleanup & drop ignored wildcard op-args
2022-03-14 23:38:53 +01:00
Divy Srivastava b4e42953e1
feat(core): codegen ops (#13861)
Co-authored-by: Aaron O'Mullan <aaron.omullan@gmail.com>
2022-03-14 18:44:15 +01:00
Bartek Iwańczuk 09ae512ccb
feat: "deno bench" subcommand (#13713)
This commit adds "deno bench" subcommand and "Deno.bench()"
API that allows to register bench cases. 

The API is modelled after "Deno.test()" and "deno test" subcommand.

Currently the output is rudimentary and bench cases and not
subject to "ops" and "resource" sanitizers.

Co-authored-by: evan <github@evan.lol>
2022-03-11 23:07:02 +01:00
Bartek Iwańczuk 85cb6f2563
refactor(test): use tokio::sync::mpsc::unbounded_channel (#13881)
This causes to block one less thread when running "deno test"
subcommand.
2022-03-09 01:34:31 +01:00
Kitson Kelly 7d356250e8
refactor: integrate deno_graph breaking changes (#13495)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-02-01 09:33:57 +11:00
David Sherret eda6e58520
refactor: upgrade to import_map v0.6 (#13368) 2022-01-13 18:17:56 -05:00
David Sherret f12164646b
refactor: move transpiling to deno_ast (#13332) 2022-01-13 11:58:00 -05:00
juju 50e8ab8a86
feat(cli): add ignore directives to bundled code (#13309)
This commit adds lint and fmt ignore directives to bundled
code as well as a comment stating that the code was bundled
and shouldn't be edited manually.
2022-01-12 13:05:06 +01:00
Ryan Dahl 1fb5858009
chore: update copyright to 2022 (#13306)
Co-authored-by: Erfan Safari <erfanshield@outlook.com>
2022-01-07 22:09:52 -05:00
Aaron O'Mullan 4208199490
cleanup(cli): use op Extensions (#13223)
Enabling op-middleware for overrides in lieu of imperative .replace_op() etc...

Impacts #13219,  #12938, #13122
2021-12-29 14:30:08 +01:00
Kitson Kelly 8547a37132
chore: update deno_graph and deno_doc (#13173) 2021-12-22 14:25:06 +01:00
Nayeem Rahman 9ffc7edc23
refactor(cli): use GraphData for check and emit (#12960) 2021-12-16 21:45:41 +11:00
David Sherret f530189c50
fix(watch): mitigate race condition between file write by other process and watch read (#13038) 2021-12-09 20:24:37 -05:00
Kitson Kelly 18a63dd977
feat: add --no-check=remote flag (#12766)
Closes #11970
2021-11-30 09:23:30 +11:00
Nayeem Rahman 7413c96985
fix(cli): don't cache .tsbuildinfo unless emitting (#12830)
Fixes #12755
Fixes #12807
Fixes #12832
2021-11-24 08:20:30 +11:00
Ryan Dahl b2036a4db7
refactor: re-export anyhow from deno_core (#12777) 2021-11-16 09:02:28 -05:00
Kitson Kelly f5eb177f50
feat(cli): support React 17 JSX transforms (#12631)
Closes #8440
2021-11-09 12:26:39 +11:00
Ryan Dahl 7c2abb9d57
fix: Deno.emit crashes with BorrowMutError (#12627)
Warn on await_holding_refcell_ref clippy rule to avoid this in the future.

Fixes #12453
2021-11-03 09:27:36 -04:00
Bartek Iwańczuk 61e9beaa7b
feat: Stabilize Deno.TestDefinition.permissions (#12078) 2021-10-31 19:45:37 +01:00
Nayeem Rahman 7a22df9b76
fix(runtime/ops/worker_host): move permission arg parsing to Rust (#12297) 2021-10-13 13:04:44 -04:00
Kitson Kelly a7baf5f2bb
refactor: integrate deno_graph into CLI (#12369) 2021-10-11 08:26:22 +11:00
Leo K 77a00ce1fb
chore: various op cleanup (#12329) 2021-10-05 22:38:27 +02:00
Ryan Dahl 01da1d0adc
refactor: Rename ProgramState to ProcState (#12204)
Move Arc into struct
2021-09-24 11:10:42 -04:00
Nayeem Rahman 75ca013f07
fix(cli/fmt_errors): Abbreviate long data URLs in stack traces (#12127)
Co-authored-by: Mike White <mike.white@auctane.com>
2021-09-18 15:40:04 +02:00
Bartek Iwańczuk d236f432b8
refactor: use import_map crate (#11974)
Removes ImportMap implementation from "cli/" and instead
uses "import_map" crate
2021-09-11 03:38:24 +02:00
David Sherret 2c2e3ec1ca
refactor(lsp): use deno_ast and cache swc ASTs (#11780) 2021-09-07 10:39:32 -04:00
Casper Beyer b9a965c607
refactor(cli): introduce module specifier test modes (#11769)
This commit merges the two vectors of specifiers into a single one introducing
the concept of a "TestMode" which is a tri-state enum specifying how a specifier
is to be tested (as documentation, as an executable module or as both).

This is determined during the collection phase and determines how a specifier
will be executed based on how the specifier was collected (directly or not) and
if it has an eligible media_type when fetched.

For example "deno test README.md" is marked as documentation because, while it
is a direct inclusion it is not an executable media type therefore will only
have the fenced code blocks that can be parsed from it tested.
2021-08-26 21:21:58 +02:00
Casper Beyer 69ca44d8e2
refactor(cli/tools/test_runner): split reporter into distinct stages (#11395)
This splits up the reporter into smaller functions, one for each
distinct event that happens during the testing process.
2021-07-14 21:05:16 +02:00
David Sherret 7fc0e8ec8c
chore: use parking_lot for synchronization primitives to align with tokio (#11289)
parking_lot is already transitively used in tokio via the "full" cargo feature
2021-07-06 23:48:01 -04:00
Kitson Kelly a5eb2dfc93
fix(#10761): graph errors reported as diagnostics for Deno.emit() (#10767)
Fixes #10761
2021-06-22 07:27:32 +10:00
Kitson Kelly 281c4cd8fc
feat(cli): support "types" when type checking (#10999)
Fixes #10677
2021-06-22 07:18:32 +10:00
Luca Casonato 5151afa123
fix: static import permissions in dynamic imports
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2021-05-17 09:45:54 +02:00
Casper Beyer b0e30dbbc6
refactor(cli/ops): don't pass ops through json (#10629) 2021-05-14 14:25:50 +02:00
Aaron O'Mullan d5f39fd121
cleanup(ops): remove unused ZeroCopyBuf arg-types (#10530) 2021-05-08 14:37:42 +02:00
Satya Rohith 89b61b5d05
fix(cli): give context when failed to load import map (#10478) 2021-05-04 14:27:20 +02:00
Casper Beyer abaec7a88e
fix(cli/tools/test): print module tests originate from (#10428) 2021-04-30 11:56:47 -04:00
Casper Beyer c455c28b83
feat(test): run test modules in parallel (#9815)
This commit adds support for running test in parallel.

Entire test runner functionality has been rewritten
from JavaScript to Rust and a set of ops was added to support reporting in Rust.

A new "--jobs" flag was added to "deno test" that allows to configure 
how many threads will be used. When given no value it defaults to 2.
2021-04-28 20:17:04 +02:00
Casper Beyer f3751e498f
feat(cli): add test permissions to Deno.test (#10188)
This commits adds adds "permissions" option to the test definitions 
which allows tests to run with different permission sets than 
the process's permission.

The change will only be in effect within the test function, once the 
test has completed the original process permission set is restored.

Test permissions cannot exceed the process's permission.
You can only narrow or drop permissions, failure to acquire a 
permission results in an error being thrown and the test case will fail.
2021-04-25 23:38:59 +02:00
Nayeem Rahman fb1ccc3d88
refactor(cli): rename Deno.emit() bundle options to "module" and "classic" (#10332) 2021-04-26 06:54:57 +10:00
Aaron O'Mullan 06cd451d20
cleanup(cli): use runtime's reg_sync() and reg_async() (#10241) 2021-04-18 16:03:46 +02:00
Aaron O'Mullan 46b1c653c0
refactor(deno): remove concept of bin & json ops (#10145) 2021-04-12 15:55:05 -04:00
crowlKats fefe93c91b
feat(runtime/permissions): prompt fallback (#9376)
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2021-04-12 11:15:43 +09:00
Aaron O'Mullan 058579da56
refactor(ops): remove variadic buffers (#9944) 2021-04-02 09:47:57 -04:00
Nayeem Rahman ebd2047de4
feat(cli/source_map): Use top user frame for error source lines (#9604)
This commit changes formatting of JS errors; by not showing 
source lines for internal code. Where possible, instead using 
the top stack frame associated with user code i.e. the first 
location that is colourful and not a "deno:" URL.
2021-02-26 12:40:05 +01:00
Luca Casonato 9d70ea2e9f
feat(unstable): per op metrics (#9240) 2021-02-21 19:20:31 +01:00
Ryan Dahl c7dabc99ee
Make ModuleSpecifier a type alias, not wrapper struct (#9531) 2021-02-17 13:47:18 -05:00
Bartek Iwańczuk f6d6b24506
feat: support loading import map from URL (#9519)
This commit adds support for loading import maps from URLs,
both remote and local.

This feature is supported in CLI flag as well as in runtime
compiler API.
2021-02-17 14:32:57 +01:00
Kitson Kelly 7e9028b532
feat(cli): Deno.emit supports bundling as IIFE (#9291)
Closes #9204
2021-02-16 12:02:00 +11:00
Yoshiya Hinosawa fc162162a1
fix(cli): fix panic in Deno.emit (#9302) 2021-01-29 10:33:58 +09:00
Nayeem Rahman 81d73f2987
fix(cli): Check permissions for Deno.emit() (#9139) 2021-01-18 08:58:23 +11:00
Yusuke Tanaka d8fd71afdf
chore: update copyright to 2021 (#9092) 2021-01-11 18:13:41 +01:00
Luca Casonato 39bbbbce70
fix: use inline source maps when present in js (#8995) 2021-01-06 00:10:36 +01:00
Kitson Kelly 012f99bd9a
refactor(cli): runtime compiler APIs consolidated to Deno.emit() (#8799)
Closes: #4752
2021-01-01 08:43:54 +11:00
Kitson Kelly 8011eced14
feat(lsp): add cache command (#8911) 2020-12-30 15:17:17 +11:00
Bartek Iwańczuk 2e74f164b6
refactor: deno_runtime crate (#8640)
This commit moves Deno JS runtime, ops, permissions and
inspector implementation to new "deno_runtime" crate located
in "runtime/" directory.

Details in "runtime/README.md".

Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
2020-12-13 19:45:53 +01:00
Bartek Iwańczuk 31935c6b8d
refactor(cli): more options on Worker (#8724) 2020-12-12 00:36:18 +01:00
Bartek Iwańczuk 65e72b68ac
refactor(cli): decouple ops from ProgramState and Flags (#8659)
This commit does major refactor of "Worker" and "WebWorker",
in order to decouple them from "ProgramState" and "Flags".
The main points of interest are "create_main_worker()" and
"create_web_worker_callback()" functions which are responsible
for creating "Worker" and "WebWorker" in CLI context.
As a result it is now possible to factor out common "runtime"
functionality into a separate crate.
2020-12-11 18:49:26 +01:00
Steven Guerrero 43a35b005f
perf: use minimal op with performance.now() (#8619) 2020-12-07 08:27:25 -05:00
Bartek Iwańczuk c0ccbcdaee
refactor(cli): Reorganize worker code, use stronger memory ordering (#8638) 2020-12-07 04:30:40 +01:00
Bartek Iwańczuk f49d955601
fix(compile): disable source mapping of errors (#8581)
This commit disables source mapping of errors
for standalone binaries. Since applying source
maps relies on using file fetcher infrastructure
it's not feasible to use it for standalone binaries
that are not supposed to use that infrastructure.
2020-12-01 23:33:44 +01:00
Marcus Hultman c7276e15e5
feat(unstable): add cbreak option to setRaw (#8383) 2020-11-30 11:08:03 -05:00
Kitson Kelly e2858d0bbb
chore: clippy future cleanups (#8514) 2020-11-28 06:47:35 +11:00
William Perron 59f10b3604
fix(cli/ops/net): add write permissions for unixpackets datagrams & unix socket (#8511)
Fixes #7781
2020-11-27 13:43:39 -05:00
Bartek Iwańczuk 85a5a081b2
refactor(cli): reorganize main.rs and split workers (#8495)
Factored out "init_v8_flags", "init_logger" and 
"get_subcommand" from "main" function.

Also "Worker" was removed in favor of moving 
logic to "MainWorker" and "WebWorker" respectively.
2020-11-26 15:17:45 +01:00
Bartek Iwańczuk 8d0b1b40f5
fix(websocket): set User-Agent header (#8502) 2020-11-26 15:12:08 +01:00
crowlKats a837fb9a07
fix(cli/websocket): set User-Agent header (#8470) 2020-11-26 13:58:50 +01:00
crowlKats d40b0711a7
fix(websocket): Fix PermissionDenied error being caught in constructor (#8402) 2020-11-25 15:17:46 +01:00
crowlKats a08d2eee2b
add canary versioning (#8480) 2020-11-25 05:30:14 -05:00
Nayeem Rahman 14877f7fe2
feat(unstable): Add deno test --no-run (#8093)
This commit adds new flag to "deno test" subcommand
called "--no-run" that allows to preload, cache an type
check.
2020-11-22 14:06:51 +01:00
Bartek Iwańczuk 91f293442d
refactor(cli): worker event serialization (#8438)
This commit simplifies code responsible for serialization
of web worker events. Instead of using "PrettyJsError"
it's enough to downcast to "deno_core::JsError", making
the code less specific to cli/ implementation.
2020-11-20 13:25:18 +01:00
Bartek Iwańczuk e582796f42
refactor(cli): rename fmt_errors::JsError to PrettyJsError (#8435)
This commit renames "fmt_errors::JsError" to "PrettyJsError"
to avoid confusion with "deno_core::JsError".

Consequently "CoreJsError" aliases to "deno_core::JsError"
were removed.

Additionally source mapping step has been removed from
"PrettyJsError::create" to better separate domains.
2020-11-19 20:37:22 +01:00
Bartek Iwańczuk 636af2850c
refactor(cli): rename fs module to fs_util (#8380)
This commit renames "fs" module in "cli/" to "fs_util". This is purely
cosmetic change; there were a few places which aliased "crate::fs"
to "deno_fs" which was very confusing with "fs" module in ops.
2020-11-16 20:48:50 +01:00
Divy Srivastava d5661f677e
refactor: deno_crypto op crate (#7956)
This commit factors out "deno_crypto" op crate.

"rand" crate dependency was consequently moved to 
"deno_crypto" crate and reexported.
2020-11-13 22:01:57 +01:00
Bartek Iwańczuk a269dffe17
chore: remove dead code (#8298) 2020-11-08 23:35:36 +01:00
Kitson Kelly d672e1405d
refactor(cli): cleanup compiler snapshot and tsc/module_graph (#8220) 2020-11-03 06:41:20 +11:00
Kitson Kelly fdcc78500c
refactor(cli): migrate runtime compile/bundle to new infrastructure (#8192)
Fixes #8060
2020-11-02 13:51:56 +11:00
Nayeem Rahman 6be6c517d0
fix(cli/fmt): Strip "\\?\" prefix when displaying Windows paths (#8135) 2020-10-30 03:19:03 +01:00
Elias Sjögreen 305a9c04ba
feat(unstable): add Deno.systemCpuInfo() (#7774) 2020-10-26 10:54:27 -04:00
Bartek Iwańczuk 57cad53945
refactor(cli): rewrite Deno.transpileOnly() to use SWC (#8090)
Co-authored-by: Kitson Kelly <me@kitsonkelly.com>
2020-10-26 14:03:03 +01:00
Kitson Kelly 7e2c7fb6c5
refactor(cli): migrate run and cache to new infrastructure (#7996)
Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
2020-10-23 11:50:15 +11:00
nerix 0a2f0fe7f2
fix(cli/rt/websockets): Only add Sec-WebSocket-Protocol if it's not empty (#7936) 2020-10-22 17:09:44 +02:00
Casper Beyer dfe19c5c75
feat: stabilize Deno.fsync and Deno.fdatasync (#8038) 2020-10-20 09:52:10 -04:00
Nayeem Rahman 7aba07cc77
fix(cli/worker): Print error stacks from the origin Worker (#7987)
Fixes #4728
2020-10-20 15:05:42 +11:00