0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-10-31 09:14:20 -04:00
Commit graph

3862 commits

Author SHA1 Message Date
Yusuke Tanaka
2c96f64fa7
fix(cli): skip removing the latter part if @ appears at the beginning (#16244)
This commit prevents panics that `deno compile` command ran into under certain
conditions from occurring. Such conditions are as follows.

- the target file name begins with `@`, OR
- the stem part of the target file name is equal to one of
["main", "index", "mod", "index"] && the parent directory name starts with `@`

Fixes #16243
2022-10-12 11:32:52 +09:00
Marcos Casagrande
0cd05d7377
fix(ext/fetch): fix illegal header regex (#16236)
This PR fixes invalid header parsing which is flaky because `g` flag is
being used in the regex, which keeps track of `lastIndex`

```javascript
try {
  new Headers([["x", "\u0000x"]]);  // error
} catch(e) {}
new Headers([["x", "\u0000x"]]); // no error
```

This issue affects `Response` & `Request` constructors as well
2022-10-10 12:06:50 -04:00
sigmaSd
70ad6717df
fix sparse array inspection (#16204)
fix https://github.com/denoland/deno/issues/16202
2022-10-10 10:22:21 -04:00
Luke Channings
a2488ae792
fix(npm): support compiling on linux/aarch64 (#16208)
Changes introduced in #13633 have broken the ability to compile for
linux/aarch64 - specifically the use of a `i8` as a char type, which is
an `u8` on linux/aarch64.

This PR:
- Replaces instances of `i8` with the architecture-aware wrapper type
`c_char`
- Skips the use of `--export-dynamic-symbol` on linux-aarch64, because
the target environments often rely on older libc/binutils versions
2022-10-10 07:59:31 +05:30
Luca Casonato
3b6b75bb46
feat(core): improve resource read & write traits (#16115)
This commit introduces two new buffer wrapper types to `deno_core`. The
main benefit of these new wrappers is that they can wrap a number of
different underlying buffer types. This allows for a more flexible read
and write API on resources that will require less copying of data
between different buffer representations.

- `BufView` is a read-only view onto a buffer. It can be backed by
`ZeroCopyBuf`, `Vec<u8>`, and `bytes::Bytes`.
- `BufViewMut` is a read-write view onto a buffer. It can be cheaply
converted into a `BufView`. It can be backed by `ZeroCopyBuf` or
`Vec<u8>`.

Both new buffer views have a cursor. This means that the start point of
the view can be constrained to write / read from just a slice of the
view. Only the start point of the slice can be adjusted. The end point
is fixed. To adjust the end point, the underlying buffer needs to be
truncated.

Readable resources have been changed to better cater to resources that
do not support BYOB reads. The basic `read` method now returns a
`BufView` instead of taking a `ZeroCopyBuf` to fill. This allows the
operation to return buffers that the resource has already allocated,
instead of forcing the caller to allocate the buffer. BYOB reads are
still very useful for resources that support them, so a new `read_byob`
method has been added that takes a `BufViewMut` to fill. `op_read`
attempts to use `read_byob` if the resource supports it, which falls
back to `read` and performs an additional copy if it does not. For
Rust->JS reads this change should have no impact, but for Rust->Rust
reads, this allows the caller to avoid an additional copy in many
scenarios. This combined with the support for `BufView` to be backed by
`bytes::Bytes` allows us to avoid one data copy when piping from a
`fetch` response into an `ext/http` response.

Writable resources have been changed to take a `BufView` instead of a
`ZeroCopyBuf` as an argument. This allows for less copying of data in
certain scenarios, as described above. Additionally a new
`Resource::write_all` method has been added that takes a `BufView` and
continually attempts to write the resource until the entire buffer has
been written. Certain resources like files can override this method to
provide a more efficient `write_all` implementation.
2022-10-09 14:49:25 +00:00
Divy Srivastava
a622c5df27
perf(ext/crypto): optimize getRandomValues (#16212) 2022-10-09 15:38:38 +05:30
李瑞丰
206aa19137
chore(napi_sym): fix readme path (#16203) 2022-10-08 19:32:34 +05:30
Divy Srivastava
e136bd86b3
perf(napi): optimize primitive napi functions (#16163)
This optimization applies on `napi_get_undefined`, `napi_get_null` &
`napi_get_boolean`.

```
# main

benchmark               time (avg)             (min … max)       p75       p99      p995
---------------------------------------------------------- -----------------------------
warmup              482.55 ps/iter   (462.5 ps … 15.67 ns)    475 ps    525 ps  829.1 ps
napi_get_undefined   25.07 ns/iter   (24.03 ns … 36.87 ns)  25.37 ns  27.09 ns  34.85 ns
```

```
# This patch

benchmark               time (avg)             (min … max)       p75       p99      p995
---------------------------------------------------------- -----------------------------
warmup              484.78 ps/iter    (462.5 ps … 14.4 ns)    475 ps  554.1 ps  583.3 ps
napi_get_undefined   15.52 ns/iter   (15.35 ns … 22.14 ns)  15.41 ns  17.18 ns  20.02 ns
```
2022-10-07 16:24:01 +05:30
Divy Srivastava
be80c57b3c
chore(napi): Add README explainer for cli/napi_sym and cli/napi (#16187) 2022-10-07 12:56:36 +05:30
Colin Ihrig
c27234888f
fix(napi): move napi symbols file (#16179)
The current location was causing failures during v1.26.1 publication.

<!--
Before submitting a PR, please read http://deno.land/manual/contributing

1. Give the PR a descriptive title.

  Examples of good title:
    - fix(std/http): Fix race condition in server
    - docs(console): Update docstrings
    - feat(doc): Handle nested reexports

  Examples of bad title:
    - fix #7123
    - update docs
    - fix bugs

2. Ensure there is a related issue and it is referenced in the PR text.
3. Ensure there are tests that cover the changes.
4. Ensure `cargo test` passes.
5. Ensure `./tools/format.js` passes without changing files.
6. Ensure `./tools/lint.js` passes.
-->
2022-10-07 09:21:43 +05:30
Divy Srivastava
5a1ea586b4
refactor(napi): simplify napi_value interface (#16170) 2022-10-07 09:21:08 +05:30
denobot
afeacb8328
chore: forward v1.26.1 release commit to main (#16178)
This is the release commit being forwarded back to main for 1.26.1

Please ensure:
- [x] Everything looks ok in the PR
- [x] The release has been published

To make edits to this PR:
```shell
git fetch upstream forward_v1.26.1 && git checkout -b forward_v1.26.1 upstream/forward_v1.26.1
```

Don't need this PR? Close it.

cc @cjihrig

Co-authored-by: cjihrig <cjihrig@users.noreply.github.com>
2022-10-06 16:49:40 -04:00
Divy Srivastava
cd1c63ad71
fix(build): don't export all symbols to dynamic symbol table (#16171)
Currently, we use `-rdynamic` for exporting Node API symbols to the
symbol table. `-rdynamic` will export *all* symbols, that means
previously unused functions will not be optimized away introducing a lot
of binary bloat. 

This patch uses `-exported_symbol` and `--export-dynamic-symbol` link
flags (not as universal as `-rdynamic`) to only mark Node API symbols to
be put in the dynamic symbol table.
2022-10-06 21:20:00 +05:30
David Sherret
9102ba9b0f
fix(node): add dns/promises and stream/consumers (#16169) 2022-10-05 19:33:52 -04:00
Divy Srivastava
0b016a7fb8
feat(npm): implement Node API (#13633)
This PR implements the NAPI for loading native modules into Deno. 

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: DjDeveloper <43033058+DjDeveloperr@users.noreply.github.com>
Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
2022-10-05 19:36:44 +05:30
Marcos Casagrande
3a3a848406
fix(ext/cache): prevent cache insert if body is not fully written (#16138) 2022-10-05 16:31:24 +05:30
ayame113
b5425ae2d3
fix(ext/flash): Avoid sending Content-Length when status code is 204 (#15901)
Currently Content-Length is sent when the status code is 204. However,
according to the spec, this should not be sent.
Modify the if statement below to prevent the Content-Length from being
sent.
2022-10-05 12:21:59 +05:30
Bartek Iwańczuk
b312503f8f
refactor: remove old Node compat code (#16142)
This code was introduced in 808f797633 and
was needed for "compat mode". Since "compat mode" was removed in v1.26, this
code is no longer needed.
2022-10-04 17:53:23 +02:00
Marcos Casagrande
569287b15b
perf(ext/fetch): consume body using ops (#16038)
This commit adds a fast path to `Request` and `Response` that
make consuming request bodies much faster when using `Body#text`,
`Body#arrayBuffer`, and `Body#blob`, if the body is a FastStream.
Because the response bodies for `fetch` are FastStream, this speeds up
consuming `fetch` response bodies significantly.
2022-10-04 15:48:50 +02:00
Bartek Iwańczuk
0b4a6c4d08
chore: remove 'fix_exotic_specifier' test (#16143)
It's a test that's been flaky for a week, and after offline discussion,
we're no longer sure what it's testing.
2022-10-04 14:24:35 +02:00
Filip Skokan
0d042d8e54
fix(ext/crypto): interoperable import/export (#16153)
This PR updates RSA key import/export to a state which is interoperable
with other implementations.

For RSA the only OID in and out is `rsaEncryption`.
For EC the only OID in and out is `id-ecpublickey` (fixed in #16152).

see https://github.com/w3c/webcrypto/issues/307#issuecomment-995813032
see https://github.com/w3c/webcrypto/issues/307
see https://github.com/w3c/webcrypto/pull/305
see https://github.com/nodejs/node/pull/42816
2022-10-04 17:37:59 +05:30
Filip Skokan
aa710aac98
fix(ext/crypto): ecdh spki key import/export roundtrip (#16152) 2022-10-04 17:09:41 +05:30
Aurélien Bertron
8d20784f7a
fix(ext/crypto): deriveBits for ECDH not taking length into account (#16128)
Fixes #16047
2022-10-03 23:10:34 -07:00
Bartek Iwańczuk
fde938116d
feat(unstable): add support for npm specifier cli arguments for 'deno cache' (#16141)
This commit adds support for npm specifier in "deno cache" subcommand.

```
$ deno cache --unstable npm:vite npm:chalk https://deno.land/std/http/file_server.ts
```

Besides downloading requested npm package(s), it will also download
necessary code from "std/node/".
2022-10-03 23:26:42 +02:00
Bartek Iwańczuk
5b097fd7e5
fix(npm): better error is version is specified after subpath (#16131) 2022-10-03 19:10:53 +02:00
Bartek Iwańczuk
8e1b2fca59
fix(npm): panic on invalid package name (#16123) 2022-10-03 17:45:01 +02:00
Hirotaka Tagawa / wafuwafu13
a4a628dc6f
docs(fs): add default info of OpenOptions (#16104) 2022-10-03 17:22:40 +02:00
Satya Rohith
eacd6a7f29
chore(ext/cache): make helper functions public (#16117) 2022-10-03 10:52:54 +05:30
Marcos Casagrande
e2990be264
fix(ext/cache): close resource on error (#16129) 2022-10-03 09:48:59 +05:30
李瑞丰
b3444e0d3b
fix(ext/crypto): fix importKey error when leading zeroes (#16009)
Co-authored-by: Jason <m.jason.liu@outlook.com>
2022-10-03 09:37:25 +05:30
Marcos Casagrande
a55b194638
fix(ext/cache): acquire reader lock before async op (#16126) 2022-10-02 01:21:48 +02:00
Bartek Iwańczuk
048c06f84f
fix(npm): handle json files in require (#16125) 2022-10-01 22:21:19 +02:00
sigmaSd
a6618dc01c
lsp: use deno:/asset instead of deno:asset (#16023)
Make offering "virtual documents" via the lsp easier to parse. `deno:`
can be ambiguous to parse by editors (can conflict with linux paths)

Neovim recently landed a PR https://github.com/neovim/neovim/pull/19797
that allows it to parse `scheme:/` this PR should make deno lsp work
correctly in neovim
2022-10-01 20:02:25 +02:00
David Sherret
ecfafda9d8
perf: node cjs & esm analysis cache (#16097)
This commit adds a cache for CJS and ESM analysis that is backed by an
SQLite file.

The connection to the DB is lazily created on first use, so shouldn't
have impact on the startup time.

Benched with running Vite

Deno v1.26:
```
$ deno task dev
Warning deno task is unstable and may drastically change in the future
Task dev deno run -A --unstable --node-modules-dir npm:vite

  VITE v3.1.4  ready in 961 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
```

This branch:
```
../deno/target/release/deno task dev
Warning deno task is unstable and may drastically change in the future
Task dev deno run -A --unstable --node-modules-dir npm:vite

  VITE v3.1.4  ready in 330 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
```

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-10-01 12:15:56 +02:00
skanehira
1058d1868f
test(cli): add test cases (#16091)
Fixes: https://github.com/denoland/deno/issues/16090
2022-09-30 14:02:44 -04:00
Marcos Casagrande
927f4e2e83
fix(ext/fetch): Body#bodyUsed for static body (#16080)
This fixes a bug where `Body#bodyUsed` incorrectly returns `false`
for a body that has actually already been consumed, after `Body#body`
is called.
2022-09-29 17:38:04 +02:00
Yoshiya Hinosawa
15ea624790
refactor(cli): use shared sys kind parser in flags.rs (#16087) 2022-09-29 19:34:16 +09:00
ayame113
691e36ac50
chore(ext/flash): Enabling disabled windows tests (#16081) 2022-09-29 10:34:26 +05:30
denobot
d8827514ff
1.26.0
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-09-29 00:10:44 +02:00
Kitson Kelly
cfbcb3b613
chore: improve JSDoc for built-in APIs (#16048)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-09-28 22:21:08 +02:00
Divy Srivastava
e2828ad762
fix(ext/flash): reregister socket on partial read on Windows (#16076) 2022-09-28 20:52:24 +02:00
David Sherret
fcb20ab952
chore: fix flaky integration::lint::compact (#16075) 2022-09-28 13:52:10 -04:00
Divy Srivastava
e64af6260a
feat(ext/flash): add reuseport option on Linux (#16022) 2022-09-28 23:16:29 +05:30
David Sherret
d677ba67f5
feat(npm): functionality to support child_process.fork (#15891) 2022-09-28 13:04:16 -04:00
Brenley Dueck
23125b275f
feat(lint): add --compact flag for terse output (#15926) 2022-09-28 18:47:48 +02:00
Guilherme Bernal
6c55772f0d
feat(core): add Deno.core.setPromiseHooks (#15475) 2022-09-28 16:09:33 +02:00
Bartek Iwańczuk
b8e3f4c71d
feat: Stabilize Deno.hostname() API (#15932) 2022-09-28 15:36:06 +02:00
Luca Casonato
70bc0eb72b
feat(unstable): Deno.setRaw -> Deno.stdin.setRaw (#15797)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-09-28 15:03:56 +02:00
Yoshiya Hinosawa
fa9e7aab6d
feat: add --allow-sys permission flag (#16028) 2022-09-28 21:46:50 +09:00
Satya Rohith
b312279e58
feat: implement Web Cache API (#15829) 2022-09-28 17:41:12 +05:30