Commit graph

550 commits

Author SHA1 Message Date
Kenta Moriuchi 49eb887cc6
refactor(core): Use ObjectHasOwn instead of ObjectPrototypeHasOwnProperty (#18952)
ES2022 `Object.hasOwn` can be used in snapshot, so I migrate to use it.
2023-05-02 12:15:45 +02:00
Leo Kettmeir 59825a95b4
refactor: remove ext/console/01_colors.js (#18927) 2023-04-30 09:11:37 +00:00
Bartek Iwańczuk 142c1ab9fc
fix(ext/websocket): restore op_ws_send_ping (#18891)
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-04-28 16:48:00 +02:00
Bartek Iwańczuk 531754c354
refactor(ext/websocket): use specialized ops (#18819)
Instead of relying on `op_ws_send` to send different kinds of messages,
use specialized ops everywhere.
2023-04-25 13:53:06 +02:00
Nayeem Rahman 6e8618ae0f
refactor(cli): move runTests() and runBenchmarks() to rust (#18563)
Stores the test/bench functions in rust op state during registration.
The functions are wrapped in JS first so that they return a directly
convertible `TestResult`/`BenchResult`. Test steps are still mostly
handled in JS since they are pretty much invoked by the user. Allows
removing a bunch of infrastructure for communicating between JS and
rust. Allows using rust utilities for things like shuffling tests
(`Vec::shuffle`). We can progressively move op and resource sanitization
to rust as well.

Fixes #17122.
Fixes #17312.
2023-04-13 19:43:23 +02:00
Nayeem Rahman e5588d2f1e
fix(test): don't swallow sanitizer errors with permissions (#18550)
Missing `return` from #18246.
2023-04-01 16:20:16 -04:00
Nayeem Rahman 8a4865c379
feat(test): print pending tests on sigint (#18246) 2023-03-25 21:32:11 +02:00
Leo Kettmeir 35196eab27
BREAKING(unstable): remove WebGPU (#18094)
This PR _**temporarily**_ removes WebGPU (which has behind the
`--unstable` flag in Deno), due to performance complications due to its
presence.

It will be brought back in the future; as a point of reference, Chrome
will ship WebGPU to stable on 26/04/2023.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-03-17 00:29:32 +01:00
Bartek Iwańczuk 72fe9bb470
refactor: rename InternalModuleLoader to ExtModuleLoader, use ext: scheme for snapshotted modules (#18041)
This commit renames "deno_core::InternalModuleLoader" to
"ExtModuleLoader" and changes the specifiers used by the 
modules loaded from this loader to "ext:".

"internal:" scheme was really ambiguous and it's more characters than
"ext:", which should result in slightly smaller snapshot size.

Closes https://github.com/denoland/deno/issues/18020
2023-03-08 12:44:54 +01:00
Bartek Iwańczuk b40086fd7d
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-05 02:31:38 +00:00
Leo Kettmeir 49af1ab18d
refactor: remove prefix from include_js_files & use extension name (#17683) 2023-02-07 21:09:50 +00:00
Leo Kettmeir b4aa153097
refactor: Use ES modules for internal runtime code (#17648)
This PR refactors all internal js files (except core) to be written as
ES modules.
`__bootstrap`has been mostly replaced with static imports in form in
`internal:[path to file from repo root]`.
To specify if files are ESM, an `esm` method has been added to
`Extension`, similar to the `js` method.
A new ModuleLoader called `InternalModuleLoader` has been added to
enable the loading of internal specifiers, which is used in all
situations except when a snapshot is only loaded, and not a new one is
created from it.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-02-07 20:22:46 +01:00
Leo Kettmeir 2027d98a8e
feat: allow first arg in test step to be a function (#17096) 2023-01-24 15:41:01 +01:00
Kenta Moriuchi 6da958d7ec
chore: update dlint to v0.37.0 for GitHub Actions (#17295)
Updated third_party dlint to v0.37.0 for GitHub Actions. This PR
includes following changes:
 
* fix(prefer-primordials): Stop using array pattern assignments
* fix(prefer-primordials): Stop using global intrinsics except for
`SharedArrayBuffer`
* feat(guard-for-in): Apply new guard-for-in rule
2023-01-16 17:17:18 +01:00
David Sherret 0ee64ad847
fix: upgrade deno_ast to 0.23 (#17269)
Closes #17172
Closes #15669
Closes #8529
2023-01-04 18:54:54 -05:00
David Sherret 10e4b2e140
chore: update copyright year to 2023 (#17247)
Yearly tradition of creating extra noise in git.
2023-01-02 21:00:42 +00:00
David Sherret 2fab4583ef
fix(test): improve how --fail-fast shuts down when hitting limit (#16956)
Closes #15650
2022-12-05 16:17:49 -05:00
Bartek Iwańczuk 3863aaf8ae
refactor: remove references to Deno.core in bootstrap code (#16937)
Prerequisite for https://github.com/denoland/deno/pull/16881
2022-12-05 17:11:57 +01:00
Luca Casonato 3f79c9b6e5
fix(cli/js): improve resource sanitizer messages (#16798)
This commit improves the guidance for how to close a child process
stdout / stderr to also include guidance for when using
`new Deno.Command()`.
2022-11-25 14:22:23 +01:00
Bartek Iwańczuk d232746928
feat(core): Ability to create snapshots from existing snapshots (#16597)
Co-authored-by: crowlkats <crowlkats@toaxl.com>
2022-11-21 14:36:26 +01:00
Bartek Iwańczuk fa61956f03
Port internal TS code to JS (#6793)
Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
2020-07-19 19:49:44 +02:00
JohannLai d60f9c2549
fix(cli/js/web): IPv6 hostname should be compressed (#6772) 2020-07-16 12:08:29 -04:00
David Sherret cde4dbb351
Use dprint for internal formatting (#6682) 2020-07-14 15:24:17 -04:00
Bartek Iwańczuk 11560387bb
Revert "feat: move unstable Deno.permissions to navigator.permissions… (#6729)
* Revert "feat: move unstable Deno.permissions to navigator.permissions (#6244)"

This reverts commit 202e7fa6ad.
2020-07-13 18:23:24 +02:00
uki00a 4731f4800c
fix(Deno.ppid): improve error message when --unstable is missing (#6717) 2020-07-13 14:00:56 +02:00
Marcos Casagrande 1a96a96e10
feat(cli): add copy argument to Buffer.bytes (#6697) 2020-07-13 00:58:59 -04:00
Nayeem Rahman 63edeb1c36
fix(cli/js/web/url): Implement IPv4 hostname parsing (#6707) 2020-07-13 00:56:45 -04:00
Marcos Casagrande 4aeac64ecd
fix(cli/fetch): fix relative redirect (#6715) 2020-07-13 00:53:36 -04:00
Nayeem Rahman 5ec41cbcc2
feat(Deno.inspect): Add sorted, trailingComma, compact and iterableLimit to InspectOptions (#6591) 2020-07-11 00:52:18 -04:00
Kitson Kelly 40d081d3d9
feat: add performance user timing APIs (#6421) 2020-07-10 22:38:15 -04:00
Nayeem Rahman 69e0886362
fix(URL): Implement spec-compliant host parsing (#6689) 2020-07-10 15:51:24 -04:00
Marcos Casagrande 39dba12a06
fix(cli/buffer): allow Buffer to store MAX_SIZE bytes (#6570) 2020-07-10 11:49:35 -04:00
Sebastien Filion 1bcc35b84a
feat(unstable): add Deno.consoleSize (#6520) 2020-07-10 10:07:12 -04:00
Kitson Kelly 202e7fa6ad
feat: move unstable Deno.permissions to navigator.permissions (#6244) 2020-07-09 05:00:18 -04: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
Marcos Casagrande 231899695d
feat(cli): Add WriteFileOptions to writeTextFile & writeTextFileSync (#6280) 2020-07-08 09:38:22 -04:00
Kitson Kelly 82aabb657a
feat: add --no-check option (#6456)
This commit adds a "--no-check" option to following subcommands:
- "deno cache"
- "deno info"
- "deno run"
- "deno test"

The "--no-check" options allows to skip type checking step and instead 
directly transpiles TS sources to JS sources. 

This solution uses `ts.transpileModule()` API and is just an interim
solution before implementing it fully in Rust.
2020-07-08 11:26:39 +02:00
Marcos Casagrande e4899b6ba4
perf(cli/body): improve .arrayBuffer() speed (#6669) 2020-07-07 22:25:34 -04:00
Sebastien Filion 4534db656d
feat(test): Add support for regex in filter flag (#6343)
Currently, the documentation makes it sound like the test subcommand's filter
flag could accept some kind of pattern matching value like a glob or a regex,
although the function "createFilterFn" accepts a regex as an argument, there's
no way to pass an actual regex value from the CLI.

This commit makes it possible to pass a string that could be cast as regex 
when string matches "^/.*/$".

With this change, a user can use the filter flag as follow:

deno test --filter "/test-.+/"

Also tested that `\` get escaped properly, on MacOS at least, and this is 
also a valid flag:

deno test --filter "/test-\d+/"
2020-07-07 15:13:38 +02:00
Nayeem Rahman 61d9952ff9
fix(cli/js/process): Fix process socket types (#6676) 2020-07-07 12:21:49 +02:00
Stanislav 158ae0bfe9
clean up code in cli/js (#6611) 2020-07-06 21:45:39 -04:00
Ryan Dahl 5c43131be1
Fix definition of URL constructor (#6653) 2020-07-06 17:39:13 -04:00
dubiousjim 6b78729ba8
feat: Deno.chown() make uid, gid args optional (#4612) 2020-07-06 13:15:13 +02:00
Marcos Casagrande 3b4260dc54
fix(cli/fetch): response constructor default properties (#6650) 2020-07-05 21:37:18 -04:00
Kitson Kelly 4f60a0b3bd
chore: improve type safety of cli/js/compiler (#6647) 2020-07-05 20:13:27 -04:00
Marcos Casagrande f85a0ce634
refactor(cli/body): use Deno.Buffer in bufferFromStream (#6632) 2020-07-05 18:05:38 -04:00
Kyle June d52e4007c8
Update timers to ignore Date Override (#6552) 2020-07-04 15:16:27 -04:00
Kitson Kelly 2527a6e296
fix: move ImportMeta to deno.ns lib (#6588) 2020-07-03 12:44:45 +02:00
Casper Beyer 8a14eafaff
doc: add unstable note to Deno.ftruncateSync and ftruncate (#6590) 2020-07-02 09:34:19 -04:00
Marcos Casagrande 89ebe2079b
fix(cli/body): Maximum call stack size exceeded error (#6537) 2020-06-28 10:31:56 -04:00
Marcos Casagrande 6c093c0b5a
fix(cli): Buffer.bytes() ArrayBuffer size (#6511) 2020-06-27 13:52:27 +02:00
Nayeem Rahman d77a55a973
fix(cli/js/process): Fix conditional types for process sockets (#6275) 2020-06-27 13:44:02 +02:00
Maayan Hanin 598a7dcc84
fix(cli/permissions): panic on hostless URLs (#6500) 2020-06-26 17:37:03 -04:00
Casper Beyer e278c90d8a
feat(unstable): add Deno.fdatasyncSync and fdatasync (#6403) 2020-06-26 08:36:35 -04:00
Nayeem Rahman ed0b1d4627
fix(cli/js/web/url): Support UNC paths on Windows (#6418) 2020-06-26 08:34:17 -04:00
Casper Beyer 175867ab76
fix(cli): strings shouldn't be interpreted as file URLs (#6412) 2020-06-26 08:29:34 -04:00
Kitson Kelly 6f09b8de41
Restore stats for incremental compile (#6474) 2020-06-25 15:50:16 +02:00
Bartek Iwańczuk 3cbd1075c7
Incremental compilation for TypeScript (#6428)
This commit adds incremental compilation capabilities to internal TS compiler.

Instead of using "ts.createProgram()" API for compilation step (during deno 
startup), "ts.createIncrementalProgram()" API is used instead.

Thanks to TS' ".tsbuildinfo" file that already stores all necessary metadata
for compilation I was able to remove our own invention that is ".graph" file. 
".tsbuildinfo" file is stored alongside compiled source and is used to 
cache-bust outdated dependencies, facilitated by the "version" field. 
The value for "version" field is computed in Rust during loading of module 
graph and is basically a hash of the file contents.

Please keep in mind that incremental compilation is only used for initial 
compilation (or dynamic imports compilation) - bundling and runtime compiler 
APIs haven't been changed at all.

Due to problems with source map I changed compilation settings to inline 
source map (inlineSourceMap instead of sourceMap).
2020-06-24 16:59:12 +02:00
Nayeem Rahman 3314b46321
fix(cli/js/web/console): Improve string quoting behaviour (#6457) 2020-06-24 09:47:05 -04:00
Kitson Kelly 1d8fc39494
Add ability to output compiler performance information (#6434) 2020-06-24 11:58:23 +02:00
Chris Couzens f6a4146973
fix(cli/web): Support URLSearchParam as Body (#6416)
The following used to fail in Deno despite working in the browser:

```javascript
new Request('http://localhost/', {method: 'POST', body: new URLSearchParams({hello: 'world'})}).text().then(console.log)
```
2020-06-23 23:56:05 -04:00
Casper Beyer 6b3be01a00
feat(unstable): add Deno.fstatSync and fstat (#6425) 2020-06-22 08:58:52 -04:00
Bartek Iwańczuk 79adc7b000
core: add Deno.core.dispatchByName (#6395)
This commit adds alternate dispatch method to core JS API.

"Deno.core.dispatchByName()" works like "Deno.core.dispatch()", 
but takes op name instead of op id as a first argument.
2020-06-21 16:34:43 +02: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
uki00a 345a5b3dff
fix: "deno test" should respect NO_COLOR=true (#6371) 2020-06-19 12:10:31 +02:00
Marcos Casagrande 36ad5e4402
refactor(cli/web): use isTypedArray method (#6369) 2020-06-18 14:39:29 -04:00
Ryan Dahl a2969ecd27
Deno.bundle supports targets < ES2017 (#6346)
This commit provides a "system_loader_es5.js" bundle loader which will be added
to the bundle when the target is < ES2017, which is the minimum target syntax
required for "system_loader.js".

Supports #5913 (via Deno.bundle()) with a couple caveats:

* Allowing "deno bundle" to take a different target is not supported, as we
specifically ignore "target" when passed in a TypeScript config file. This is
because deno bundle is really intended to generate bundles that work in Deno.
It is an unintentional side effect that some bundles are loadable in browsers.

* While a target of "es3" will be accepted, the module loader will still only be
compatible with ES5 or later. Realistically no one should be expecting bundles
generated by Deno to be used on IE8 and prior, and there is just too much
"baggage" to support that at this point.

This is a minor variation of 75bb9d, which exposed some sort of internal V8 bug.
Ref #6358

This is 100% authored by Kitson Kelly. Github might change the author when landing
so I'm leaving this in:
Co-authored-by: Kitson Kelly <me@kitsonkelly.com>
2020-06-18 09:06:48 -04:00
River 2a5af8b36b
fix: decode path properly on win32 (#6351) 2020-06-18 06:10:07 -04:00
Bartek Iwańczuk e60922981b
Revert "Deno.bundle supports targets < ES2017. (#6328)" (#6342)
This reverts commit 75bb9dbdfc.
2020-06-17 19:44:40 +02:00
Kitson Kelly 75bb9dbdfc
Deno.bundle supports targets < ES2017. (#6328)
This commit provides a "system_loader_es5.js" bundle loader which will be added
to the bundle when the target is < ES2017, which is the minimum target syntax
required for "system_loader.js".

Supports #5913 (via Deno.bundle()) with a couple caveats:

* Allowing "deno bundle" to take a different target is not supported, as we
specifically ignore "target" when passed in a TypeScript config file. This is
because deno bundle is really intended to generate bundles that work in Deno.
It is an unintentional side effect that some bundles are loadable in browsers.

* While a target of "es3" will be accepted, the module loader will still only be
compatible with ES5 or later. Realistically no one should be expecting bundles
generated by Deno to be used on IE8 and prior, and there is just too much
"baggage" to support that at this point.
2020-06-17 15:13:02 +02:00
Kermit Xuan 77545219a6
fix: DatagramConn.send should return bytes sent (#6265) 2020-06-13 10:14:31 -04:00
Nayeem Rahman e613bfe47a
feat: Add TestDefinition::only (#5793) 2020-06-12 11:58:04 -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
Chris Knight ca1c2ee822
doc: fix inspect example with correct InspectOptions (#6255) 2020-06-12 14:40:32 +02:00
Rubin Bhandari 6ccf9037a6
feat: add Deno.osName() (#5714) 2020-06-11 13:11:26 -04:00
River 818a801092
feat: URL support in Deno filesystem methods (#5990) 2020-06-11 12:36:20 -04:00
John Gardner ca5b5ba530
feat: Add Deno.mainModule (#6180) 2020-06-10 23:00:29 -04:00
Josh Byrnes 408edbb065
fix(URL): IPv6 hostname support (#5766) 2020-06-10 14:05:10 -04:00
Casper Beyer be8bacaaa4
fix: Remove try-catch from Buffer.readFrom, readFromSync (#6161) 2020-06-10 11:54:54 -04:00
Nayeem Rahman 8f050355ff
fix(cli/js/process): Always return a code in ProcessStatus (#5244) 2020-06-10 11:10:08 -04:00
Bartek Iwańczuk 4b7d3b060e
fix: several regressions in TS compiler (#6177)
This commit fixes several regressions in TS compiler:

* double compilation of same module during same process run

* compilation of JavaScript entry point with non-JS imports

* unexpected skip of emit during compilation

Additional checks were added to ensure "allowJs" setting is 
used in TS compiler if JavaScript has non-JS dependencies.
2020-06-10 16:02:41 +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
Nayeem Rahman b3e189ee4f
fix(cli/js/process): Strengthen socket types based on pipes (#4836) 2020-06-09 13:18:18 +02:00
Peter Indiola 6236252c66
feat(cli/js/net): make rid on listener public (#5571) 2020-06-08 18:24:51 +02:00
Marcos Casagrande d907133944
fix(cli/web/fetch): multipart/form-data request body support for binary files (#5886) 2020-06-08 18:08:26 +02:00
Ryan Dahl 78bfeebad1
Revert "fix: Use # to denote line number in stack traces" (#6119)
This reverts commit c4c6a8dae4

There is some controversy about this change because vscode doesn't interpret the fragments correctly. Needs more discussion before landing.
2020-06-05 11:37:40 -04:00
Andrew Mitchell c4c6a8dae4
fix: Use # to denote line number in stack traces (#6114)
This makes the URLs in stack traces actual URLs to the files.
Before: https://deno.land/std/testing/asserts.ts:138:11
After: https://deno.land/std/testing/asserts.ts#138:11
2020-06-05 08:01:02 -04:00
Chris Knight 1ebd330927
doc: complete unstable documentation and make consistent (#6074) 2020-06-03 13:46:09 -04:00
Marcos Casagrande a1915a0d4f
fix(fetch): Support 101 status code (#6059) 2020-06-03 09:43:11 -04:00
Kitson Kelly 3fe6bc1b82
fix: Better use of @ts-expect-error (#6038) 2020-06-02 00:24:44 -04:00
Valentin Anger becbb56b19
feat(core): Ops can take several zero copy buffers (#4788) 2020-06-01 14:20:47 -04:00
精武陈真 f0ba814a79
fix jsDoc (#5992) 2020-06-01 09:53:43 -04:00
Marcos Casagrande 29db4104c4
fix(cli/web): Body.bodyUsed should use IsReadableStreamDisturbed 2020-06-01 14:37:46 +02:00
Marcos Casagrande 1d3dce9a68
fix(cli/js/web): formData parser for binary files (#6015) 2020-06-01 14:32:08 +02:00
Marcos Casagrande edeeedf401
fix(cli/fetch): set null body for null-body status (#5980) 2020-05-31 19:21:14 -04:00