0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-02-15 01:57:09 -05:00
Commit graph

13123 commits

Author SHA1 Message Date
David Sherret
408d581fc1
chore: fix lockfile on main (#27978)
Every time I run `cargo test` or whatever the lockfile changes to this.
2025-02-05 19:03:45 +00:00
Bartek Iwańczuk
f08ca6414b
feat(lint): add JavaScript plugin support (#27203)
This commit adds an unstable lint plugin API.

Plugins are specified in the `deno.json` file under
`lint.plugins` option like so:

```
{
  "lint": {
    "plugins": [
      "./plugins/my-plugin.ts",
      "jsr:@deno/lint-plugin1",
      "npm:@deno/lint-plugin2"
    ]
  }
}
```

The API is considered unstable and might be subject
to changes in the future.

Plugin API was modelled after ESLint API for the 
most part, but there are no guarantees for compatibility.
The AST format exposed to plugins is closely modelled
after the AST that `typescript-eslint` uses.

Lint plugins use the visitor pattern and can add
diagnostics like so:

```
export default {
  name: "lint-plugin",
  rules: {
    "plugin-rule": {
      create(context) {
        return {
          Identifier(node) {
            if (node.name === "a") {
              context.report({
                node,
                message: "should be b",
                fix(fixer) {
                  return fixer.replaceText(node, "_b");
                },
              });
            }
          },
        };
      },
    },
  },
} satisfies Deno.lint.Plugin;
```

Besides reporting errors (diagnostics) plugins can provide
automatic fixes that use text replacement to apply changes.

---------

Co-authored-by: Marvin Hagemeister <marvin@deno.com>
Co-authored-by: David Sherret <dsherret@gmail.com>
2025-02-05 16:59:24 +01:00
HasanAlrimawi
8a07d38a53
chore: move bench test to spec test (#27970) 2025-02-05 10:49:10 -05:00
Hajime-san
1eb4142143
feat(ext/canvas): enhance createImageBitmap specification compliance (#25517) 2025-02-05 04:10:11 -08:00
Nathan Whitaker
b440d2d4f7
feat(outdated): interactive update (#27812)
interactively select which packages to upgrade. a future improvement
could be to add a way to select the version as well, though not sure how
valuable that would be.
2025-02-04 15:41:56 -08:00
Divy Srivastava
28834a89bb
fix(ext/node): implement SQLite Session API (#27909)
https://nodejs.org/api/sqlite.html#class-session

---------

Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
2025-02-04 21:59:13 +05:30
snek
98339cf327
fix(ext/napi): napi_is_buffer tests for ArrayBufferView (#27956)
use correct type check

Fixes: https://github.com/denoland/deno/issues/27951
2025-02-04 14:30:40 +00:00
Divy Srivastava
c2832d70a1
fix(ext/sqlite): add sourceSQL and expandedSQL getters (#27921) 2025-02-04 17:38:41 +05:30
Divy Srivastava
441b1d307f
fix(ext/node): handle non-ws upgrade headers (#27931) 2025-02-04 17:35:48 +05:30
Yoshiya Hinosawa
4405f47a4f
refactor(ext/fetch): do not share error instance (#27941) 2025-02-04 13:38:07 +09:00
Divy Srivastava
f28bbcced5
fix(ext/node): expose brotli stream APIs (#27943)
Fixes https://github.com/denoland/deno/issues/27170
2025-02-04 07:47:02 +05:30
David Sherret
61faa32920
perf: node resolution cache (#27838)
This adds a cache for node resolution, which makes repeat lookups about
15x faster.
2025-02-03 20:25:10 -05:00
David Sherret
073caf5fe9
refactor: extract out utf16 map from lsp to cli::util module (#27950) 2025-02-03 20:24:26 -05:00
Nathan Whitaker
108b6a8bfb
fix(lsp): ignore a few more diagnostics for ambient modules (#27949)
Missed a few resolution errors
2025-02-03 16:13:14 -08:00
David Sherret
e46860a2fd
feat(compile): support sloppy imports (#27944)
Closes https://github.com/denoland/deno/issues/26102
2025-02-03 13:08:08 -05:00
Alvaro Parker
41fa8df197
feat(bench): add --permit-no-files (#27048)
This PR adds the `--permit-no-files` cli options to the `bench`
subcommand. This will cause `deno bench --permit-no-files` to not return
an error when no bench files where found.
2025-02-03 16:18:09 +00:00
Divy Srivastava
b5c3f4f782
fix(ext/node): support read-only database in node:sqlite (#27930)
Implements the `readOnly` option for `DatabaseSync`.

Permissions:
`--allow-read=test.db --allow-write=test.db` => all works
`--allow-read=test.db` => only `readOnly` dbs work, cannot create new db
2025-02-03 16:41:45 +05:30
Divy Srivastava
7107c358a1
fix(ext/node): set process fields on own instance (#27927)
Ref https://github.com/denoland/deno/pull/27891#issuecomment-2626286689

```
% deno eval 'console.log(Object.getOwnPropertyNames(process))'
[
  "_events",
  "_eventsCount",
  "_maxListeners",
  "versions",
  "stdin",
  "stdout",
  "stderr"
]

% target/debug/deno eval 'console.log(Object.getOwnPropertyNames(process))'
[
  "_events",
  "_eventsCount",
  "_maxListeners",
  "release",
  "arch",
  "report",
  "title",
  "argv",
  "argv0",
  "chdir",
  "config",
  "cpuUsage",
  "cwd",
  "env",
  "execArgv",
  "exit",
  "abort",
  "reallyExit",
  "_exiting",
  "exitCode",
  "mainModule",
  "nextTick",
  "dlopen",
  "pid",
  "ppid",
  "platform",
  "setSourceMapsEnabled",
  "hrtime",
  "_kill",
  "kill",
  "memoryUsage",
  "stderr",
  "stdin",
  "stdout",
  "version",
  "versions",
  "emitWarning",
  "binding",
  "umask",
  "getgid",
  "getuid",
  "getegid",
  "geteuid",
  "getBuiltinModule",
  "_eval",
  "execPath",
  "uptime",
  "allowedNodeEnvironmentFlags",
  "features",
  "noDeprecation"
]
```
2025-02-03 16:39:04 +05:30
Bartek Iwańczuk
8bdcbec5d7
fix(publish): correct coloring in --help (#27939) 2025-02-03 01:41:09 +00:00
Divy Srivastava
3c56e6c7cd
fix(ext/node): enforce -RW perms on node:sqlite (#27928)
require RW permission on the database path except when using in-memory
mode.
2025-02-02 15:49:39 +05:30
Rano | Ranadeep
540fe7d9e4
fix(node): resolve module as maybe CJS when it's missing a file extension (#27904) 2025-02-01 13:12:17 -05:00
David Sherret
9cbcb84295
fix(node): show directory import and missing extension suggestions (#27905)
Shows directory import and missing extension suggestions in error
messages similar but not exactly to node.

Closes #26802

Co-authored-by: Hajime-san <Hajime-san@users.noreply.github.com>
2025-02-01 13:07:23 -05:00
Divy Srivastava
7d19668255
fix(ext/node): throw RangeError when sqlite INTEGER is too large (#27907)
Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
2025-02-01 13:19:53 +05:30
Nayeem Rahman
9da6a20e57
Revert "fix(lsp): silence debug error for 'move to a new file' action (#27780)" (#27903) 2025-02-01 02:53:24 +00:00
David Sherret
8971064546
feat: TypeScript 5.7 (#27857)
Co-authored-by: Kenta Moriuchi <moriken@kimamass.com>
2025-01-31 16:07:42 -05:00
Timothy
8d824182be
docs: Temporal plaintime docs link (#27879) 2025-01-31 12:23:38 -08:00
Bartek Iwańczuk
1ef341c397
ci: update release template (#27901) 2025-01-31 14:02:24 -05:00
David Sherret
d5c105b30e
chore: fix some broken pty tests on windows (#27899)
These have been failing locally for some time.
2025-01-31 12:08:29 -05:00
Yoshiya Hinosawa
7643bb71a6
chore: update std in test util (#27892) 2025-01-31 08:52:32 -05:00
Divy Srivastava
1cbaee9f52
fix(ext/node): sqlite bind support bigint values (#27890) 2025-01-31 18:31:05 +05:30
Divy Srivastava
b8a878cfc2
fix(cli): Fix panic in load_native_certs (#27863)
Fixes https://github.com/denoland/deno/issues/27528

Can't really trigger the panic myself hence no test.
2025-01-31 18:29:37 +05:30
Yoshiya Hinosawa
1cecc0a8b0
fix(ext/node): support proxy http request (#27871) 2025-01-31 21:46:54 +09:00
Divy Srivastava
057f257052
fix(ext/node): represent sqlite blob as Uint8Array (#27889) 2025-01-31 17:53:48 +05:30
Divy Srivastava
08cc22105f
fix(ext/node): set process.env as own property (#27891)
Fixes `gcp-metadata@6.1.1`

```
% deno eval "import 'npm:gcp-metadata@6.1.1'" # main
error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'GOOGLE_SDK_NODE_LOGGING')
    at Object.log (file:///Users/divy/Library/Caches/deno/npm/registry.npmjs.org/google-logging-utils/0.0.2/build/src/logging-utils.js:356:36)
    at Object.<anonymous> (file:///Users/divy/Library/Caches/deno/npm/registry.npmjs.org/gcp-metadata/6.1.1/build/src/index.js:52:20)
    at Object.<anonymous> (file:///Users/divy/Library/Caches/deno/npm/registry.npmjs.org/gcp-metadata/6.1.1/build/src/index.js:409:4)
    at Module._compile (node:module:745:34)
    at loadMaybeCjs (node:module:770:10)
    at Object.Module._extensions..js (node:module:755:12)
    at Module.load (node:module:662:32)
    at Function.Module._load (node:module:534:12)
    at Module.require (node:module:681:19)
    at require (node:module:812:16)

% target/debug/deno eval "import 'npm:gcp-metadata@6.1.1'" # this PR
```

---------

Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2025-01-31 11:38:26 +05:30
denobot
d9db0b35e0
chore: forward v2.1.9 release commit to main (#27888)
This is the release commit being forwarded back to main for 2.1.9

Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2025-01-31 03:02:00 +01:00
Nathan Whitaker
bac8171c40
perf(crypto): use ring for asm implementations of sha256/sha512 (#27885)
Currently we are using the pure rust backend of `sha2`, which has subpar
performance compared to asm implementations. We already depend on
`ring`, so just use that instead of `sha2` for sha256/sha512 digests.

This also speeds up things like S3 uploads, which calculate sha digests
of the uploaded objects. On my local machine, this speeds up uploading a
100MB file (to a localhost s3 provider via`@aws-sdk/client-s3`) by about
2x

<details>

<summary>Benchmark:</summary>

```ts
import { createHmac } from "node:crypto";

for (
  const size of [1, 10, 100, 1_000, 10_000, 100_000, 1_000_000, 10_000_000]
) {
  const input = "a".repeat(size);
  Deno.bench({
    name: `sha256-${size}`,
    fn() {
      const _hash = createHmac("sha256", input).update(input).digest();
    },
  });
  Deno.bench({
    name: `sha512-${size}`,
    fn() {
      const _hash = createHmac("sha512", input).update(input).digest();
    },
  });
}
```

</details>

<details>

<summary>Results (arm64 macOS):</summary>

```
--- sha256-1 ---
../../deno/target/release/deno         2.527 µs    1.240 times faster
/Users/nathanwhit/.deno/bin/deno       3.132 µs    
--- sha512-1 ---
../../deno/target/release/deno         3.364 µs    1.071 times faster
/Users/nathanwhit/.deno/bin/deno       3.603 µs    
--- sha256-10 ---
../../deno/target/release/deno         3.060 µs    1.027 times faster
/Users/nathanwhit/.deno/bin/deno       3.144 µs    
--- sha512-10 ---
../../deno/target/release/deno         3.583 µs    1.047 times faster
/Users/nathanwhit/.deno/bin/deno       3.751 µs    
--- sha256-100 ---
../../deno/target/release/deno         3.695 µs    1.244 times faster
/Users/nathanwhit/.deno/bin/deno       4.598 µs    
--- sha512-100 ---
../../deno/target/release/deno         3.386 µs    1.188 times faster
/Users/nathanwhit/.deno/bin/deno       4.021 µs    
--- sha256-1000 ---
../../deno/target/release/deno         4.007 µs    3.230 times faster
/Users/nathanwhit/.deno/bin/deno      12.944 µs    
--- sha512-1000 ---
../../deno/target/release/deno         6.463 µs    1.466 times faster
/Users/nathanwhit/.deno/bin/deno       9.477 µs    
--- sha256-10000 ---
../../deno/target/release/deno        11.674 µs    6.981 times faster
/Users/nathanwhit/.deno/bin/deno      81.493 µs    
--- sha512-10000 ---
../../deno/target/release/deno        31.250 µs    1.740 times faster
/Users/nathanwhit/.deno/bin/deno      54.364 µs    
--- sha256-100000 ---
../../deno/target/release/deno        82.800 µs    9.393 times faster
/Users/nathanwhit/.deno/bin/deno     777.719 µs    
--- sha512-100000 ---
../../deno/target/release/deno       269.726 µs    1.851 times faster
/Users/nathanwhit/.deno/bin/deno     499.243 µs    
--- sha256-1000000 ---
../../deno/target/release/deno       808.662 µs    9.427 times faster
/Users/nathanwhit/.deno/bin/deno       7.623 ms    
--- sha512-1000000 ---
../../deno/target/release/deno         2.672 ms    1.795 times faster
/Users/nathanwhit/.deno/bin/deno       4.795 ms    
--- sha256-10000000 ---
../../deno/target/release/deno         7.823 ms    9.868 times faster
/Users/nathanwhit/.deno/bin/deno      77.201 ms    
--- sha512-10000000 ---
../../deno/target/release/deno        26.197 ms    1.846 times faster
/Users/nathanwhit/.deno/bin/deno      48.356 ms    
```

</details>

<details>

<summary>Results (x86_64 linux):</summary>

```
--- sha256-1 ---
/home/nathanwhit/.deno/bin/deno             10.726 µs    1.229 times faster
../../../deno/target/release-lite/deno      13.184 µs    
--- sha512-1 ---
/home/nathanwhit/.deno/bin/deno             13.177 µs    1.051 times faster
../../../deno/target/release-lite/deno      13.845 µs    
--- sha256-10 ---
/home/nathanwhit/.deno/bin/deno             13.156 µs    1.047 times faster
../../../deno/target/release-lite/deno      13.780 µs    
--- sha512-10 ---
/home/nathanwhit/.deno/bin/deno             14.386 µs    1.029 times faster
../../../deno/target/release-lite/deno      14.807 µs    
--- sha256-100 ---
/home/nathanwhit/.deno/bin/deno             14.580 µs    1.083 times faster
../../../deno/target/release-lite/deno      15.789 µs    
--- sha512-100 ---
/home/nathanwhit/.deno/bin/deno             13.477 µs    1.131 times faster
../../../deno/target/release-lite/deno      15.238 µs    
--- sha256-1000 ---
../../../deno/target/release-lite/deno      17.208 µs    1.116 times faster
/home/nathanwhit/.deno/bin/deno             19.198 µs    
--- sha512-1000 ---
../../../deno/target/release-lite/deno      21.168 µs    1.026 times faster
/home/nathanwhit/.deno/bin/deno             21.717 µs    
--- sha256-10000 ---
../../../deno/target/release-lite/deno      33.586 µs    1.990 times faster
/home/nathanwhit/.deno/bin/deno             66.837 µs    
--- sha512-10000 ---
../../../deno/target/release-lite/deno      53.338 µs    1.009 times faster
/home/nathanwhit/.deno/bin/deno             53.817 µs    
--- sha256-100000 ---
../../../deno/target/release-lite/deno     168.238 µs    3.063 times faster
/home/nathanwhit/.deno/bin/deno            515.354 µs    
--- sha512-100000 ---
../../../deno/target/release-lite/deno     383.311 µs    1.036 times faster
/home/nathanwhit/.deno/bin/deno            397.122 µs    
--- sha256-1000000 ---
../../../deno/target/release-lite/deno       1.474 ms    3.471 times faster
/home/nathanwhit/.deno/bin/deno              5.115 ms    
--- sha512-1000000 ---
../../../deno/target/release-lite/deno       3.658 ms    1.057 times faster
/home/nathanwhit/.deno/bin/deno              3.865 ms    
--- sha256-10000000 ---
../../../deno/target/release-lite/deno      16.438 ms    3.136 times faster
/home/nathanwhit/.deno/bin/deno             51.556 ms    
--- sha512-10000000 ---
../../../deno/target/release-lite/deno      37.128 ms    1.056 times faster
/home/nathanwhit/.deno/bin/deno             39.220 ms    
```

</details>
2025-01-30 23:38:14 +00:00
denobot
1b7719c5d6
chore: forward v2.1.8 release commit to main (#27882)
This is the release commit being forwarded back to main for 2.1.8

Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2025-01-30 21:09:06 +01:00
Marvin Hagemeister
c44b05cab5
feat(task): add support for task wildcards (#27007)
This PR adds support for passing wildcard tasks. All matched tasks are
sorted in case they have dependencies. Tasks already in the dependency
tree will be pruned so that every task only runs once.

```json
{
  "tasks": {
    "foo-1": "echo 'foo-1'",
    "foo-2": "echo 'foo-2'"
  }
}
```

```sh
$ deno task "foo-*"
Task foo-1 echo 'foo-1'
foo-1
Task foo-2 echo 'foo-2'
foo-2
```

The changes in the PR look a little bigger than they really are due to
formatting. For the most part, I've only needed to hoist up the task
matching logic.

Closes https://github.com/denoland/deno/issues/26944
Closes https://github.com/denoland/deno/issues/21530

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2025-01-30 14:37:10 +01:00
Divy Srivastava
5c2fc88ba6
fix(core): Fix create_stack_trace from empty trace (#27873)
Fixes https://github.com/denoland/deno/issues/27849
2025-01-30 18:12:44 +05:30
Cyan
e6dda60d5c
feat: implement process.cpuUsage (Deno.cpuUsage) (#27217) 2025-01-30 17:23:05 +05:30
Nathan Whitaker
b7456fed70
fix(lsp): ignore errors on ambient module imports (#27855)
This makes it so imports of ambient modules (e.g. `$app/environment` in
svelte, any virtual module in vite, or other module provided by a
bundler) don't error in the LSP.

The way this works is that when we request diagnostics from TSC, we also
respond with the list of ambient modules. Then, in the diagnostics code,
we save diagnostics (produced by deno) that may be invalidated as an
ambient module and wait to publish the diagnostics until we've received
the ambient modules from TSC.

The actual ambient modules you get from TSC can contain globs, e.g.
`*.css`. So when we get new ambient modules, we compile them all into a
regex and check erroring imports against that regex. Ambient modules
should change rarely, so in most cases we should be using a pre-compiled
regex, which executes in linear time (wrt the specifier length).

TODO:
- Ideally we should only publish once, right now we publish with the
filtered specifiers and then the TSC ones
- deno check (#27633)
2025-01-30 00:25:32 +00:00
Nayeem Rahman
0dd334b512
feat(check/lsp): support "compilerOptions.rootDirs" (#27844) 2025-01-30 00:20:25 +00:00
David Sherret
b39ae6f0d3
fix(init): correct dev task for --lib (#27860) 2025-01-29 16:53:13 +00:00
Divy Srivastava
79fa6028d1
fix(ext/node): implement crypto.hash (#27858)
Implement
[`crypto.hash`](https://nodejs.org/api/crypto.html#cryptohashalgorithm-data-outputencoding)
- one-shot version of `createHash`

Fixes #24945
2025-01-29 20:49:43 +05:30
snek
0098fddb10
feat(unstable): WebTransport (#27431)
Initial implementation of WebTransport client and server!

This is very unstable because the interface should eventually shift to
use hyper (h3 is on the [2025
roadmap](https://hyper.rs/contrib/roadmap/)) instead of manually messing
with the the protocol, which will enable integration with
Deno.serveHttp/etc and allow WebTransport over h2. This will also let us
expose multiplexing.

WebTransport stats will be a followup due to their complexity.

Fixes: https://github.com/denoland/deno/issues/9017
2025-01-29 14:39:12 +00:00
David Sherret
7528c7909c
fix(check): better handling of TypeScript in npm packages for type checking (#27853)
1. Allows resolving to `.ts` files for type checking.
2. Probes for `.ts` files to use for type checking.

To emphasize, this is only for type checking.
2025-01-28 20:32:37 +00:00
Bartek Iwańczuk
a5a1cce50d
feat(ext/cache): support lscache (#27628)
This commit adds support for lscache backend for
the Web cache API.

The cache cab be configured using `DENO_CACHE_LSC_ENDPOINT`
env var.
2025-01-28 18:51:06 +00:00
snek
02ed300525
feat(node:http): add http information support (#27381)
Implements some client and server events to improve compat.

Fixes: https://github.com/denoland/deno/issues/27239
2025-01-28 17:37:53 +00:00
Phil Hawksworth
d2b1fc21f5
docs: jsdocs for URL web API (#27850)
Adds references and examples to the documentation of the URL properties
which surface here:

https://docs.deno.com/api/web/~/URL

  `./tools/lint.js`
  `./tools/format.js`

---------

Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
2025-01-28 16:54:23 +00:00
David Sherret
4648fc4570
fix(check): compiler options from workspace members (#27785)
Co-authored-by: Nayeem Rahman <nayeemrmn99@gmail.com>
2025-01-28 10:49:58 -05:00