Commit graph

3129 commits

Author SHA1 Message Date
VishnuJin d9b130410b
feat(compat) preload Node.js built-in modules in global vars REPL (#13127)
This commit adds preloading of built-in Node.js modules in
the REPL if running with "deno repl --compat --unstable".
2022-01-03 20:10:17 +01:00
Sean Michael Wykes 340764adec
fix(ext/crypto): use forgiving base64 encoding for JWK (#13240)
Implements "forgiving" in JWK decode passing suitable config to base64::decode_config
2022-01-03 17:54:45 +05:30
Sean Michael Wykes 9a42d65fc7
feat(ext/crypto): support AES-CTR encrypt/decrypt (#13177)
Fixes #13201.
2022-01-03 12:27:28 +01:00
Bartek Iwańczuk a721c34c19
chore: update std submodule to efa94f2 (#13260) 2022-01-02 14:04:40 +01:00
Kitson Kelly 2e72893fa2
fix(lsp): better handling of folders in registry completions (#13250) 2022-01-02 16:27:19 +11:00
Kitson Kelly 0ae46a975c
fix(lsp): properly generate data URLs for completion items (#13246) 2022-01-02 16:25:42 +11:00
Steven Guerrero 39a6c94071
feat(test): Add support for "deno test --compat" (#13235) 2021-12-30 17:18:30 +01:00
Bartek Iwańczuk 1adf8ee545
fix(core): inspector works if no "Runtime.runIfWaitingForDebugger" message is sent (#13191)
This commit changes flow in inspector code to no longer require 
"Runtime.runIfWaitingForDebugger" message to complete a handshake.

Even though clients like Chrome DevTools always send this message on startup,
it is against the protocol to require this message to start an inspector
session.

Instead "Runtime.runIfWaitingForDebugger" is required only when running with
"--inspect-brk" flag, which matches behavior of Node.js.
2021-12-30 16:47:58 +01:00
Leo Kettmeir 167982be9e
feat: output cause on JS runtime errors (#13209) 2021-12-29 19:34:13 +01:00
Aaron O'Mullan 42777f2541
cleanup(cli/lsp): use op Extensions (#13225) 2021-12-29 15:22:00 +01: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 6d017d42aa
fix(lsp): add code lens for tests just using named functions (#13218)
Fixes: #13216
2021-12-29 14:00:24 +11:00
David Sherret 7ebbda7fd7
fix(coverage): use only string byte indexes and 0-indexed line numbers (#13190) 2021-12-23 20:02:54 -05:00
Kitson Kelly 37dbe5249c
fix(cli): include JSON modules in bundle (#13188)
Fixes #13150
2021-12-24 09:38:20 +11:00
Zach de2df20d57
fix(ext/console): map basic css color keywords to ansi (#13175) 2021-12-23 13:06:24 +01:00
Bartek Iwańczuk 9391ba1098
chore: merge v1.17.1 into main (#13184) 2021-12-22 22:20:17 +01:00
Kitson Kelly 8547a37132
chore: update deno_graph and deno_doc (#13173) 2021-12-22 14:25:06 +01:00
David Sherret ac06797fa8
chore(tests): remove pty_complete_imports test for deleting the cwd (#13164) 2021-12-21 12:21:07 -05:00
Bartek Iwańczuk aca41a472a
refactor: Cleanup core/modules.rs (#13149) 2021-12-21 15:53:46 +01:00
Bartek Iwańczuk 907cef563e
refactor: cleanup cli/main.rs (#13160) 2021-12-21 15:49:27 +01:00
Kitson Kelly b5fdfb9d25
feat(lsp): supply accept header when fetching registry config (#13159)
Closes #13153
2021-12-21 13:40:22 +11:00
Bartek Iwańczuk 1eb78731eb
refactor: Use dedicated flags structures (#13148) 2021-12-20 22:29:02 +01:00
Luca Casonato 17d81ad2ef
chore: add custom panic message (#13145) 2021-12-20 14:49:05 +01:00
Jesper van den Ende 0888ba7a8d
feat(lsp): add code lens for debugging tests (#13138)
Closes: #13130
2021-12-20 16:00:38 +11:00
Divy Srivastava 6de53b631f
refactor: use once_cell instead of lazy_static (#13135) 2021-12-18 16:14:42 -05:00
Bartek Iwańczuk 3db18bf9e6
refactor(repl): factor out ReplEditor and ReplSession (#13131) 2021-12-18 02:18:17 +01:00
Bartek Iwańczuk f3cd9a94b5
fix: inspector prompts (#13123)
This commit fixes prompts printed to the terminal when
running with "--inspect" or "--inspect-brk" flags.

When debugger disconnects error is no longer printed as
users don't care about the reason debugger did disconnect.

A message suggesting to go to "chrome://inspect" is printed
if debugger is active.

Additionally and information that process is waiting for
debugger to connect is printed if running with "--inspect-brk"
flag.
2021-12-17 18:43:25 +01:00
Nayeem Rahman ca1fbdd636
fix(cli/tools/coverage): Split sources by char index (#13114) 2021-12-17 17:17:35 +01:00
David Sherret 5d8baf054e
fix(repl): support assertions on import & export declarations (#13121) 2021-12-17 11:00:27 -05:00
Bartek Iwańczuk e133d37e37
chore: add codeblocks for lib.deno.shared_globals.d.ts (#13117) 2021-12-17 02:36:03 +01:00
Bartek Iwańczuk 5f11f87495
v1.17.0 2021-12-16 19:24:16 +01:00
Bartek Iwańczuk e0cba6b19b
chore: release crates for v1.17.0 (#13112) 2021-12-16 18:51:23 +01:00
Sean Michael Wykes 60faf7a0ed
feat(ext/crypto): support importing ECSDA and ECDH (#13088)
Co-authored-by: Luca Casonato <hello@lcas.dev>
2021-12-16 17:28:43 +01:00
Andreu Botella 8efe829fca
feat(fetch): support abort reasons in fetch (#13106) 2021-12-16 12:58:24 +01:00
Andreu Botella 01a6b66034
feat: support abort reasons in Deno APIs and WebSocketStream (#13066) 2021-12-16 12:57:26 +01:00
Nayeem Rahman 9ffc7edc23
refactor(cli): use GraphData for check and emit (#12960) 2021-12-16 21:45:41 +11:00
Kitson Kelly e28fb70aee
fix(lsp): provide diagnostics for import assertions (#13105)
Fixes: #13099
2021-12-16 14:53:17 +11:00
Jesper van den Ende 0f53b82cd2
fix(test): wait for inspector session in side modules (#13065)
This commit fixes inspector integration with "deno test" subcommand
by waiting for inspector sessions to connect if "--inspect-brk" flag
is passed.

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2021-12-16 00:38:27 +01:00
Jesper van den Ende 5a3ded6611
feat(watch): support watching external files (#13087) 2021-12-15 16:04:43 -05:00
Bartek Iwańczuk d8e7e3fbe3
chore: update cli/Cargo.toml (#13096) 2021-12-15 20:57:43 +01:00
David Sherret 6c324acf23
feat: REPL import specifier auto-completions (#13078) 2021-12-15 13:23:43 -05:00
Bartek Iwańczuk a1f0796fcc
feat: Add support for import assertions and JSON modules (#12866)
This commit adds proper support for import assertions and JSON modules.

Implementation of "core/modules.rs" was changed to account for multiple possible
module types, instead of always assuming that the code is an "ES module". In
effect "ModuleMap" now has knowledge about each modules' type (stored via
"ModuleType" enum). Module loading pipeline now stores information about
expected module type for each request and validates that expected type matches
discovered module type based on file's "MediaType".

Relevant tests were added to "core/modules.rs" and integration tests,
additionally multiple WPT tests were enabled.

There are still some rough edges in the implementation and not all WPT were
enabled, due to:
a) unclear BOM handling in source code by "FileFetcher"
b) design limitation of Deno's "FileFetcher" that doesn't download the same
module multiple times in a single run

Co-authored-by: Kitson Kelly <me@kitsonkelly.com>
2021-12-15 19:22:36 +01:00
Elias Sjögreen ee49cce726
feat(ext/ffi): implement UnsafePointer and UnsafePointerView (#12828) 2021-12-15 15:41:49 +01:00
Ben Noordhuis 4d176b7b7c
fix(ext/net): make unix and tcp identical on close (#13075)
std/http/server knows how to handle "Listener has been closed"
exceptions but not "operation canceled" errors.

Make "unix" listen sockets throw the same exception as "tcp" listen
sockets when the socket is closed and has a pending accept operation.

There is still a discrepancy when multiple accept requests are posted
but that's probably a less visible issue and something for another day.

Fixes #13033
2021-12-14 23:27:04 +01:00
Kitson Kelly e8d7b430ce
chore: updates to support deno_graph API changes (#13080) 2021-12-15 07:39:20 +11:00
Luca Casonato b220a58d1a
feat(ext/crypto): support exporting RSA JWKs (#13081)
This commit adds support for exporting RSA JWKs in the Web Crypto API.
It also does some minor fixes for RSA JWK imports.

Co-authored-by: Sean Michael Wykes <sean.wykes@nascent.com.br>
2021-12-14 17:02:14 +01:00
David Sherret c9d32e0581
fix(lsp): handle import specifier not having a trailing quote (#13074)
* fix(lsp): handle import specifier not having a trailing quote

* clean up

* Add test.
2021-12-13 16:28:35 -05:00
Kitson Kelly a54fc7a129
feat(lsp): improve registry completion suggestions (#13023)
Resolves #10051
2021-12-14 06:24:11 +11:00
Yoshiya Hinosawa 308813ae29
fix(ext/web): set location undefined when --location is not specified (#13046) 2021-12-14 00:35:59 +09:00
Jesper van den Ende a2b4d13540
docs: Fix typo in EmitOptions (#13062) 2021-12-13 13:26:03 +01:00
Bartek Iwańczuk 0dec9b4381
fix: op_set_exit_code (#13034)
Fixes "op_set_exit_code" by sharing a single "Arc" between
all workers (via "op state") instead of having a "global" value stored in
"deno_runtime" crate. As a consequence setting an exit code is always
scoped to a tree of workers, instead of being overridable if there are
multiple worker tree (like in "deno test --jobs" subcommand).

Refactored "cli/main.rs" functions to return "Result<i32, AnyError>" instead
of "Result<(), AnyError>" so they can return exit code.
2021-12-11 15:56:45 +01:00
Bartek Iwańczuk 13d7d57227
feat(watcher): clear screen on each restart (#12613)
This commit adds automatic clearing of terminal screen after
restarting execution on file change.
2021-12-11 01:12:25 +01:00
VishnuJin 2bdb528eb8
feat(repl): add --unsafe-ignore-certificate-errors flag (#13045) 2021-12-10 15:47:55 +01:00
Luca Casonato 6f8f1cc244
tests: deflake crypto InvalidIntializationVector (#13040)
Use fixed data that is known to error as the test intends.
2021-12-10 11:47:21 +01: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 616ff1d482
chore: place @deprecated tag after documentation block (#13037) 2021-12-10 11:05:50 +11:00
Kitson Kelly 345f0fbe5c
feat(cli): update to TypeScript 4.5 (#12410)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2021-12-10 09:12:21 +11:00
Kitson Kelly 2347e60934
feat(lsp): registry suggestion cache respects cache headers (#13010)
Fixes #9931
2021-12-09 22:16:17 +11:00
Yoshiya Hinosawa 69ad5f0e78
feat(ext/timers): add refTimer, unrefTimer API (#12953) 2021-12-09 17:00:55 +09:00
David Sherret 1507b8c984
fix: upgrade swc fixing many bundling and --no-check bugs (#13025) 2021-12-08 19:12:14 -05:00
WenheLI b51b0c834b
feat(cli): use deno fmt for lock and coverage files (#13018) 2021-12-07 19:21:04 -05:00
Yoshiya Hinosawa 5c0636888c
fix(ext/timers): fix flakiness of httpConnAutoCloseDelayedOnUpgrade test (#13017) 2021-12-08 02:50:35 +09:00
Andreu Botella 33da15ae5a
refactor(timers): refactor timers to use one async op per timer (#12862)
This change also makes the timers implementation closer to the spec, and
sets up the stage to implement AbortSignal.timeout() (whatwg/dom#1032).

Fixes #8965
Fixes #10974
Fixes #11398
2021-12-07 13:39:58 +01:00
Bartek Iwańczuk 5027826a64
build: pin dependencies in cli crate (#12967) 2021-12-07 01:43:09 +01:00
Ryan Dahl a2f1357fe8
chore: upgrade to rustls 0.20 (#12488)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Bert Belder <bertbelder@gmail.com>
2021-12-07 00:48:11 +01:00
Divy Srivastava d31378726e
feat(ext/crypto): implement unwrapKey (#12539) 2021-12-05 04:55:11 +01:00
Bartek Iwańczuk c59f90d01f
chore: upgrade to Rust 1.57.0 (#12968) 2021-12-04 14:19:06 +01:00
Luca Casonato 72e9720e91
chore: merge v1.16.4 into main (#12984) 2021-12-04 01:26:54 +01:00
Ryan Dahl 084caffc08
refactor: cli doesn't need to depend on deno_tls (#12952)
also move create_http_client to deno_fetch
2021-12-01 11:13:11 -05:00
KnorpelSenf 4c36fa1fdf
chore: Fix typo in no-pending-ops error message (#12948) 2021-12-01 15:22:11 +01:00
Andreu Botella 9a10668694
fix(test): Improve reliability of deno test's op sanitizer with timers (#12934)
Although not easy to replicate in the wild, the `deno test` op sanitizer
can fail when there are intervals that started before a test runs, since
the op sanitizer can end up running in the time between the timer op for
an interval's run resolves and the op for the next run starts.

This change fixes that by adding a new macrotask callback that will run
after the timer macrotask queue has drained. This ensures that there is
a timer op if there are any timers which are unresolved by the time the
op sanitizer runs.
2021-11-30 01:27:30 +01:00
Kitson Kelly 18a63dd977
feat: add --no-check=remote flag (#12766)
Closes #11970
2021-11-30 09:23:30 +11:00
Zheyu Zhang bd989143e1
refactor(cli): simplify lint/format resolver logic (#12898) 2021-11-29 09:17:57 -05:00
Andreu Botella 4a13c320d7
fix(workers): Make worker.terminate() not immediately kill the isolate (#12831)
Due to a bug in V8, terminating an isolate while a module with top-level
await is being evaluated would crash the process. This change makes it
so calling `worker.terminate()` will signal the worker to terminate at
the next iteration of the event loop, and it schedules a proper
termination of the worker's isolate after 2 seconds.
2021-11-29 13:37:44 +01:00
Bartek Iwańczuk 5178e093ed
Revert "fix(test): Improve reliability of deno test's op sanitizer with timers (#12908)" (#12929)
This reverts commit d335343a79.
2021-11-29 12:07:47 +01:00
Michael Busby 6c09e02304
feat(ext/net): enable sending to broadcast address (#12860)
You can now send UDP datagrams to the broadcast address.
2021-11-29 11:14:46 +01:00
Andreu Botella d335343a79
fix(test): Improve reliability of deno test's op sanitizer with timers (#12908)
Although not easy to replicate in the wild, the `deno test` op sanitizer
can fail when there are intervals that started before a test runs, since
the op sanitizer can end up running in the time between the timer op for
an interval's run resolves and the op for the next run starts.

This change fixes that by adding a new macrotask callback that will run
after the timer macrotask queue has drained. This ensures that there is
a timer op if there are any timers which are unresolved by the time the
op sanitizer runs.
2021-11-28 16:40:38 +01:00
Andreu Botella 1974eb1021
fix(websocket): bad rid on WebSocketStream abort(#12913)
Fix a bad resource ID error when aborting a WebSocketStream immediately
after its creation.
2021-11-28 12:25:49 +01:00
Ben Noordhuis 993a1dd41a
feat(runtime): add op_set_exit_code (#12911)
Set the exit code to use if none is provided to Deno.exit(), or when
Deno exits naturally.

Needed for process.exitCode Node compat. Paves the way for #12888.
2021-11-28 00:45:38 +01:00
Yury Selivanov 1d3f734e18
feat(ext/net): ALPN support in Deno.connectTls() (#12786) 2021-11-26 19:59:53 +01:00
Andreu Botella d763633781
feat(etc/fetch): Support WebAssembly.instantiateStreaming for file fetches (#12901)
Fetching of local files, added in #12545, returns a response with no
headers, including the `Content-Type` header. This currently makes it
not work with the WebAssembly streaming APIs, which require the response
to have a content type of `application/wasm`.

Since the only way to obtain a `Response` object with a non-empty `url`
field is via `fetch()`, this change changes the content type requirement
to only apply to responses whose url has the `file:` scheme.
2021-11-26 19:52:41 +11:00
David Sherret 6a780543a4
refactor(repl): move rustyline sync channel communication into struct (#12900) 2021-11-25 14:05:12 -05:00
Ben Noordhuis 47cf7b0b2e
fix(cli): fix slow test, unbreak ci (#12897)
Reduce the number of iterations from 1,024 to 128.

On my big bruiser of a desktop machine it already takes up close to a
minute to complete when nothing else is running so no way it's going to
finish in the allotted time on the CI.

The fact that the test used to pass may be indicative of a performance
regression somewhere but it's not clear to me when or where that would
have been introduced.

Fixes #12887.
2021-11-25 14:25:22 +01:00
Bartek Iwańczuk 1193d46485
tests: add 'await' to all invocations of 'assertRejects' (#12893) 2021-11-25 02:23:03 +01:00
Bartek Iwańczuk e68a241946
chore: upgrade lspower to 1.4.0 (#12894) 2021-11-25 12:10:12 +11:00
Bert Belder c6f3493f18
chore: merge v1.16.3 into main (#12892) 2021-11-24 15:56:18 -08:00
David Sherret adc5974333
fix(lsp): lsp should respect include/exclude files in format config (#12876) 2021-11-24 15:14:19 -05:00
Bartek Iwańczuk 1117d2db39
compat: support compat mode in REPL (#12882)
This commit introduces "ProcState::maybe_resolver" field, which
stores a single instance of resolver for the whole lifetime of the
process, instead of creating these resolvers for each creation
of module graph. As a result, this resolver can be used in fallback
case where graph is not constructed (REPL, loading modules using
"require") unifying resolution logic.
2021-11-24 16:55:10 +01:00
Bartek Iwańczuk 1a51f2392d
chore: speed up compat tests (#12884)
This commit speeds up compat tests by using local copy of "deno_std"
instead of downloading it from https://deno.land for each test.
Additionally type checking is skipped.
2021-11-24 12:24:13 +01:00
David Sherret 0f90b4665a
chore(lsp): fix possible race condition with tests expecting 3 publishDiagnostics messages (#12868)
The tests expect 3 publish notifications. It was possible for less than 3 to occur if two or more tasks set the diagnostics in the collection, exited the lock at the same time, then called `publish_diagnostics`
2021-11-23 20:04:27 -05:00
Zheyu Zhang fd6d0e309c
fix(cli/compile): skip bundling for pre-bundled code (#12687) 2021-11-23 23:59:17 +01:00
Nayeem Rahman 63fc73c491
refactor(cli): deduplicate source cache for redirected specifiers (#12795) 2021-11-24 08:30:52 +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
Bartek Iwańczuk d2c53e7f10
tests: remove 'fmt_check_tests_dir' test (#12875) 2021-11-23 18:36:13 +01:00
igorsaux 3f8c3b8568
fix(lsp): normalize urls in did_change_watched_files (#12873) 2021-11-23 12:32:40 -05:00
Bartek Iwańczuk bedb2adfb0
refactor: remove "unitTest" wrapper from cli/tests/unit (#12750) 2021-11-23 17:45:18 +01:00
David Sherret 51e3db956a
fix(cli): config file should resolve paths relative to the config file (#12867)
* Add `specifier_to_file_path` to support converting a ModuleSpecifier with a unix-style path to a PathBuf on Windows.
2021-11-23 10:38:11 -05:00
Bartek Iwańczuk d8afd56838
feat(test): Add more overloads for "Deno.test" (#12749)
This commit adds 4 more overloads to "Deno.test()" API.

```
// Deno.test(function testName() { });
export function test(fn: (t: TestContext) => void | Promise<void>): void;

// Deno.test("test name", { only: true }, function() { });
export function test(
  name: string,
  options: Omit<TestDefinition, "name">,
  fn: (t: TestContext) => void | Promise<void>,
): void;

// Deno.test({ name: "test name" }, function() { });
export function test(
  options: Omit<TestDefinition, "fn">,
  fn: (t: TestContext) => void | Promise<void>,
): void;

// Deno.test({ only: true }, function testName() { });
export function test(
  options: Omit<TestDefinition, "fn" | "name">,
  fn: (t: TestContext) => void | Promise<void>,
): void;
```
2021-11-23 14:57:51 +01:00
Luca Casonato ae34f8fa10
fix: support "other" event type in FSWatcher (#12836)
This commit adds support for "other" events in `FSWatcher`. Flags on
events are now exposed via the `flag` property  on `FsEvent`.
2021-11-23 11:30:24 +01:00
Kitson Kelly 210300d049
feat(lsp): add type definition provider (#12789) 2021-11-23 11:09:19 +11:00