930ce20870
This commit deprecates `window` global and adds deprecation notice on each use of `window`. We decided to proceed with removal of `window` global variable in Deno 2.0. There's a lot of code in the wild that uses pattern like this: ``` if (typeof window !== "undefined) { ... } ``` to check if the code is being run in browser. However, this check passes fine in Deno and most often libraries that do this check try to access some browser API that is not available in Deno, or use DOM APIs (which are also not available in Deno). This situation has occurred multiple times already and it's unfeasible to expect the whole ecosystem to migrate to new check (and even if that happened there's a ton of code that's already shipped and won't change). The migration is straightfoward - replace all usages of `window` with `globalThis` or `self`. When Deno encounters use of `window` global it will now issue a warning, steering users towards required changes: ``` Warning ├ Use of deprecated "window" API. │ ├ This API will be removed in Deno 2.0. Make sure to upgrade to a stable API before then. │ ├ Suggestion: Use `globalThis` or `self` instead. │ ├ Suggestion: You can provide `window` in the current scope with: `const window = globalThis`. │ └ Stack trace: └─ at file:///Users/ib/dev/deno/foo.js:7:1 ``` Ref https://github.com/denoland/deno/issues/13367. |
||
---|---|---|
.. | ||
examples | ||
js | ||
ops | ||
permissions | ||
Cargo.toml | ||
clippy.toml | ||
colors.rs | ||
errors.rs | ||
fmt_errors.rs | ||
fs_util.rs | ||
inspector_server.rs | ||
js.rs | ||
lib.rs | ||
README.md | ||
shared.rs | ||
snapshot.rs | ||
tokio_util.rs | ||
web_worker.rs | ||
worker.rs | ||
worker_bootstrap.rs |
deno_runtime
crate
This is a slim version of the Deno CLI which removes typescript integration and various tooling (like lint and doc). Basically only JavaScript execution with Deno's operating system bindings (ops).
Stability
This crate is built using battle-tested modules that were originally in the
deno
crate, however the API of this crate is subject to rapid and breaking
changes.
MainWorker
The main API of this crate is MainWorker
. MainWorker
is a structure
encapsulating deno_core::JsRuntime
with a set of ops used to implement Deno
namespace.
When creating a MainWorker
implementors must call MainWorker::bootstrap
to
prepare JS runtime for use.
MainWorker
is highly configurable and allows to customize many of the
runtime's properties:
- module loading implementation
- error formatting
- support for source maps
- support for V8 inspector and Chrome Devtools debugger
- HTTP client user agent, CA certificate
- random number generator seed
Worker
Web API
deno_runtime
comes with support for Worker
Web API. The Worker
API is
implemented using WebWorker
structure.
When creating a new instance of MainWorker
implementors must provide a
callback function that is used when creating a new instance of Worker
.
All WebWorker
instances are descendents of MainWorker
which is responsible
for setting up communication with child worker. Each WebWorker
spawns a new OS
thread that is dedicated solely to that worker.