This commit changes global `setTimeout` and `setInterval` APIs (along
their `clear*` counterparts) to use Node.js APIs instead of the Web
APIs.
For real world usage we expect no difference in code and behavior,
unless user relies on following checks:
```
const id = setTimeout(...);
if (typeof id === "number") {
// ...
}
```
In which case the conditional should be changed to `if (id)`
This reverts commit 5eccca8717.
Turns out this extension requires `ext/fetch` to be merged in `ext/web`
first, so reverting for now to keep `main` green.
This commit deprecated `deno_broadcast_channel` crate and merges it into
`deno_web`.
This will allow us to limit number of crates we need to publish and
(maybe) improve compile and link times.
The actual `ext/broadcast_channel` directory will be removed in a follow
up PR, once a new version is published and points to deno_web crate.
This commit deprecated `deno_console` crate and merges it into
`deno_web`.
This will allow us to limit number of crates we need to publish and
(maybe) improve compile and link times.
The actual `ext/console` directory will be removed in a follow up PR,
once a new version is published and points to `deno_web` crate.
---------
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit deprecated `deno_cache` crate and merges it into `deno_web`.
This will allow us to limit number of crates we need to publish and
(maybe) improve compile and link times.
The actual `ext/cache` directory will be removed in a follow up PR, once
a new version is published and points to `deno_web` crate.
---------
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit deprecated `deno_url` crate and merges it into `deno_web`.
This will allow us to limit number of crates we need to publish and
(maybe) improve compile and link times.
The actual `ext/url` directory will be removed in a follow up PR, once a
new version is published and points to `deno_web` crate.
This commit repurposes `--unstable-node-globals` flag that was
deprecated
in https://github.com/denoland/deno/pull/29887 to switch out timers
implemention that is used.
Ie. using this flag cause `setTimeout`, `setInterval`, `clearTimeout`
and `clearInterval` globals to use functions from `node:timers`
module instead of the Web version.
This is also enabled using `DENO_COMPAT=1` env var.
TODO:
<s>make typechecking be conditional depending on this, most likely
requires
changes in our TS fork.</s> This has been deferred until Deno 3
Towards https://github.com/denoland/deno/issues/29703
---------
Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
This commit updates V8 to version 14.0.0. This update brings
changes to Temporal support too, which is close to being stabilized.
---------
Co-authored-by: snek <snek@deno.com>
This commit adds `Deno.test.beforeAll`, `Deno.test.beforeEach`,
`Deno.test.afterAll` and `Deno.test.afterEach` APIs.
These APIs can be used to perform setup and teardown for test cases.
The API is similar to the Vitest API: https://vitest.dev/api/#setup-and-teardown,
with the main difference being that that `before*` hooks don't return a cleanup
function.
This is not a full-fledged and fully correct `require`/CJS support
for `node:worker_threads`, but unlocks certain scenarios that
were not working at all previously.
This commits adds `DENO_AUTO_SERVE` env var, that when specified
makes `deno run` behave like `deno serve` if the entrypoint satisfies
the `Deno.ServeDefaultExport` interface.
This removes the additional arguments on the function returned by
`Module.wrap`.
Allow libraries that overwrite this behavior (like `v8-code-cache`) to
work correctly.
---------
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit removes "WorkerGlobalScope" global from the "global
middleware" that we use to provide different set of globals to
user code and npm packages.
This is done, by renaming "WebWorkerType" to "WorkerThreadType"
and introducing a "Node" variant - this variant is used when creating
a worker using "node:worker_threads" module. This worker does
not have a "WorkerGlobalScope" (because it's not a Web Worker)
and the regular Web Worker created using "new Worker" does have
it.
Ref https://github.com/denoland/deno/pull/27217
> `op_runtime_cpu_usage` can be optimized by accepting a `&mut [u32]`
instead of returning a serde tuple but it can be done as a follow up.
Accept a `&mut [u32]` instead of serde tuple for `op_runtime_cpu_usage`
and `op_runtime_memory_usage`
---------
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
implement lazy(?) mode. an unconfigured jsruntime is created if
DENO_UNSTABLE_CONTROL_SOCK is present, and later passed into deno_runtime to be
configured and used.
This commit adds "deno_features" crate that contains definitions of all
unstable features in Deno.
Based on these definitions, both Rust and JS code is generated ensuring
that the two are always in sync.
In addition some of flag handling was rewritten to use the generated
definitions, instead of hand rolling these flag definitions.
---------
Co-authored-by: snek <snek@deno.com>
`import.meta.log` enables basic log filtering through
`env_logger`/`DENO_LOG`. Log levels are supported, and filenames can
also be used. for example: `DENO_LOG=ext:deno_http::00_serve.ts=warn`
This patches Temporal to support the `getTimeZoneTransition` method on
`ZonedDateTime`.
See https://github.com/denoland/deno/issues/27731.
Co-authored-by: printfn <printfn@users.noreply.github.com>
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>
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
A QUIC endpoint is a UDP socket which multiplexes QUIC sessions, which
may be initiated in either direction. This PR exposes endpoints and
moves things around as needed.
Now that endpoints can be reused between client connections, we have a
way to share tls tickets between them and allow 0rtt. This interface
currently works by conditionally returning a promise.
Also cleaned up the rust op names, fixed some lingering problems in the
data transmission, and switched to explicit error types.