1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00
Commit graph

608 commits

Author SHA1 Message Date
Bartek Iwańczuk
2d5b19277b
chore: upgrade deno_core (#22782) 2024-03-08 00:06:28 +01:00
Nathan Whitaker
9df917c0be
chore: upgrade deno_core (#22725)
<!--
Before submitting a PR, please read
https://docs.deno.com/runtime/manual/references/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.
7. Open as a draft PR if your work is still in progress. The CI won't
run
   all steps, but you can add '[ci]' to a commit message to force it to.
8. If you would like to run the benchmarks on the CI, add the 'ci-bench'
label.
-->
2024-03-06 15:08:10 -08:00
Matt Mastracci
736b91edd0
perf(cli): use new deno_core timers (#22569)
Improves #19100 

Fixes #20356

Replaces #20428



Changes made in deno_core to support this:

 - [x] Errors must be handled in setTimeout callbacks
 - [x] Microtask ordering is not-quite-right
 - [x] Timer cancellation must be checked right before dispatch
 - [x] Timer sanitizer
 - [x] Move high-res timer to deno_core
 - [x] Timers need opcall tracing
2024-03-01 11:15:18 -07:00
Matt Mastracci
96cfe82664
perf(cli): reduce overhead in test registration (#22552)
- Removes the origin call, since all origins are the same for an isolate
(ie: the main module)
- Collects the `TestDescription`s and sends them all at the same time
inside of an Arc, allowing us to (later on) re-use these instead of
cloning.

Needs a follow-up pass to remove all the cloning, but that's a thread
that is pretty long to pull

---------

Signed-off-by: Matt Mastracci <matthew@mastracci.com>
2024-02-27 20:30:17 -07:00
Satya Rohith
47dee65e4a
fix(ext/node): set correct process.argv0 (#22555) 2024-02-23 17:30:29 +01:00
Asher Gomez
c1fac11dfa
feat(fs): Deno.FsFile.{isTerminal,setRaw}() (#22234)
Closes #22229.

---------

Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
2024-02-18 07:27:44 -07:00
Divy Srivastava
b72f0be27c
chore: add DENO_FUTURE env var (#22318)
Closes https://github.com/denoland/deno/issues/22315

```
~> DENO_FUTURE=1 target/debug/deno

> globalThis.window
undefined
```
2024-02-15 04:50:17 +00:00
Bartek Iwańczuk
6c15dc3f06
chore: remove op_spawn_child test (#22314)
This test is not needed because the op is not available to user code
anymore.

This brings number of ops exposed to user code down to 15.
2024-02-07 04:44:51 +01:00
Bartek Iwańczuk
edab1bb927
chore: don't expose FFI ops to user code (#22313)
This commit removes some not really necessary FFI tests and in effect
removes them from being accessible from the user code.

This lowers the number of ops accessible to user code to 16.
2024-02-07 04:15:11 +01:00
Bartek Iwańczuk
043fee48fd
chore: upgrade deno_core to 0.259.0 (#22311)
This update brings number of ops available to user code down to 45.
2024-02-07 02:16:08 +01:00
Leo Kettmeir
1007358768
refactor: move ImageData to web extension (#22295)
Signed-off-by: Leo Kettmeir <crowlkats@toaxl.com>
2024-02-07 01:11:15 +01:00
Bartek Iwańczuk
89ae2d88b8
chore: remove unneeded benchmark (#22300)
Brings down the number of ops available to user code to 49.
2024-02-07 01:00:18 +01:00
Leo Kettmeir
c8b2af8ed1
refactor: use web utils and lazy load utils from core (#22289) 2024-02-06 22:28:32 +01:00
Bartek Iwańczuk
7c111da5f6
fix: Support Symbol.metadata (#22282)
This commit adds support for "Symbol.metadata" which was 
omitted when adding support for the Decorators Proposal.

Closes https://github.com/denoland/deno/issues/22111
2024-02-06 14:57:25 +01:00
Divy Srivastava
e568cb8bf8
chore(ws): remove unused op_ws_send_pong (#22283) 2024-02-06 13:37:20 +01:00
Bartek Iwańczuk
28576db10e
refactor: don't expose some ops (#22281)
This commit brings down the number of ops exposed to user
code to 51.
2024-02-06 02:47:10 +01:00
Bartek Iwańczuk
6853633f7d
refactor: don't expose worker ops to user code (#22276) 2024-02-06 00:58:06 +01:00
Bartek Iwańczuk
b94dabdb81
refactor: don't expose ops to user code (#22273)
Brings the number of ops exposed to user code down to 58.
2024-02-06 00:26:36 +01:00
Matt Mastracci
2c621f5894
refactor(cli): Move op descriptions into Rust and prepare for op import (#22271)
This moves the op sanitizer descriptions into Rust code and prepares for
eventual op import from `ext:core/ops`. We cannot import these ops from
`ext:core/ops` as the testing infrastructure ops are not always present.

Changes:
- Op descriptions live in `cli` code and are currently accessible via an
op for the older sanitizer code
 - `phf` dep moved to workspace root so we can use it here
- `ops.op_XXX` changed to to `op_XXX` to prepare for op imports later
on.
2024-02-05 20:26:59 +00:00
Matt Mastracci
56f58a047e
chore: bump deno core (#22243)
Migrations:

- Error registration no longer required for Interrupted or BadResource
(these are core exception)
 - `include_js_files!`/`ExtensionFileSource` changes
2024-02-04 17:03:14 -07:00
Bartek Iwańczuk
8edb36fea4
fix(jupyter): ensure op is available (#22240)
Closes https://github.com/denoland/deno/issues/22231
2024-02-02 20:20:18 +00:00
Asher Gomez
3f4639c330
docs: point to new "Deno 1.x to 2.x Migration Guide" (#22199)
Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-02-02 02:32:46 +01:00
Bartek Iwańczuk
95e4741f00
refactor: migrate runtime/ and ext/canvas/ to virtual ops module (#22196) 2024-01-31 23:17:49 +01:00
Bartek Iwańczuk
13a91a69f8
refactor: remove imported ops from Deno.core.ops (#22194)
This commit adds a list of ops to `runtime/99_main.js` that are
currently relying on getting them from `Deno.core.ops`. All ops that are not
present in the list are removed from `Deno.core.ops` on startup (they are
imported from "virtual op module" - `ext:core/ops`) making them effectively
inaccessible to user code.

This change lowers the number of ops exposed to user code from 650 to
around 260. This number should be gradually decreased in follow-up PRs.
2024-01-31 22:39:56 +01:00
Bartek Iwańczuk
345423cf76
refactor: Use virtul ops module (#22175)
Follow up to #22157.

This leaves us with 4 usages of `ensureFastOps()` in `deno` itself.
There's also about 150 usages of `Deno.core.ops.<op_name>` left as well.
2024-01-29 22:02:26 +01:00
Bartek Iwańczuk
462ce14a78
refactor: migrate extensions to virtual ops module (#22135)
First pass of migrating away from `Deno.core.ensureFastOps()`.

A few "tricky" ones have been left for a follow up.
2024-01-26 23:46:46 +01:00
Bartek Iwańczuk
942fb5e038
chore: upgrade deno_core (#22124)
Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2024-01-26 14:04:07 -05:00
Bartek Iwańczuk
9e0495baa7
fix: make deprecation warnings less verbose (#22128)
This commit makes deprecation warnings less verbose by default.

Only a single warnings is issued per deprecated API use.

`DENO_VERBOSE_WARNINGS` env var can be provided to enable more detailed
logging for each use of API including a stack trace.

https://github.com/denoland/deno/assets/13602871/9c036c84-0044-4cb6-9c8e-deb641f43712
2024-01-26 16:41:16 +01:00
Bartek Iwańczuk
0b0fb94ce2
fix(fs): instanceof check for Deno.FsFile (#22121)
Regression caused by https://github.com/denoland/deno/pull/22072.

I added a relevant test so we don't regress again.

Fixes https://github.com/denoland/deno/issues/22115
2024-01-25 23:51:29 +01:00
Bartek Iwańczuk
174bb70eda
fix: don't use public rid accessors in internal APIs (#22091)
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2024-01-25 00:45:19 +01:00
Asher Gomez
8dd71b6f1d
fix: don't call .rid in Deno.FsWatcher.close() (#22090)
Otherwise, a deprecation warning will be printed.
2024-01-24 23:05:22 +00:00
Bartek Iwańczuk
801ed74118
revert: Remove deprecations of file sync APIs (#22085)
- `Deno.FsFile.dataSync` -> `Deno.FsFile.syncData`
- `Deno.FsFile.dataSyncSync` -> `Deno.FsFile.syncDataSync`

Also marks these APIs as unstable
2024-01-24 23:38:18 +01:00
Bartek Iwańczuk
fb24b004ba
chore: improve deprecation hint for Deno.isatty() (#22086) 2024-01-24 20:09:19 +00:00
Bartek Iwańczuk
8e67bf829a
Revert "feat: deprecate window global (#22057)" (#22084)
This reverts commit 930ce20870.

This is producing false-positives that are not actionable to users.
We're gonna address this in another release.
2024-01-24 20:43:31 +01:00
Asher Gomez
547468e625
feat: deprecate Deno.FsWatcher.rid (#22074)
For removal in Deno v2. I've also updated the deprecation of
`Deno.FsWatcher.return()`, which, to be clear, I'm not in favour of
deprecating. I mention this in #15499. Either way, it's safe to merge
this PR, then decide against the deprecation.
2024-01-24 18:57:28 +01:00
Asher Gomez
48c19d0bab
feat: deprecate Deno.fstat() and Deno.fstatSync() (#22068)
For removal in Deno v2.
2024-01-24 18:53:20 +01:00
Asher Gomez
f5097d9d3b
feat: Deno.FsFile.{utime,utimeSync}() and deprecate Deno.{futime,futimeSync} (#22070)
For removal in Deno v2.

---------

Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-01-24 17:26:49 +01:00
Asher Gomez
a5a973e93c
feat: deprecate Deno.write() and Deno.writeSync() (#22064)
For removal in Deno v2.
2024-01-24 16:36:13 +01:00
Bartek Iwańczuk
50eaeabefb
feat: Change deprecation warning formatting (#22080)
Removes weird "frame like" characters and simplifies the output:

```
warning: Use of deprecated "Deno.isatty()" API. This API will be removed in Deno 2.

Stack trace:
  at file:///Users/ib/dev/deno/foo.js:2:8

hint: Use `stdStream.isTerminal()` instead.

warning: Use of deprecated "Deno.isatty()" API. This API will be removed in Deno 2.

Stack trace:
  at file:///Users/ib/dev/deno/foo.js:7:8

hint: Use `stdStream.isTerminal()` instead.

```

https://github.com/denoland/deno/assets/13602871/7a6e24bf-44ec-4dbf-ac96-2af1db9f2ab9
2024-01-24 16:35:47 +01:00
Asher Gomez
62786cfebb
feat: deprecate Deno.close() (#22066)
For removal in Deno v2.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-01-24 15:59:55 +01:00
Asher Gomez
4af121687c
feat: deprecate Deno.ftruncate() and Deno.ftruncateSync() (#22069)
For removal in Deno 2.0.
2024-01-24 15:12:22 +01:00
Bartek Iwańczuk
064a6c048a
feat: Add warnings for more deprecated APIs (#21992)
Follow up to https://github.com/denoland/deno/pull/21939 that adds
deprecation warnings to more `Deno` APIs:

- `Deno.copy()`
- `Deno.iter()`
- `Deno.iterSync()`
- `new Deno.Buffer()`
- `Deno.readAll()`
- `Deno.readAllSync()`
- `Deno.writeAll()`
- `Deno.writeAllSync()`
- `Deno.FsWatcher.return`
- `Deno.serveHttp()`
- `Deno.metrics()`

---------

Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2024-01-24 14:57:54 +01:00
Bartek Iwańczuk
930ce20870
feat: deprecate window global (#22057)
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.
2024-01-24 14:20:51 +01:00
Asher Gomez
aac0ad32bd
feat: deprecate Deno.FsFile constructor and Deno.FsFile.rid (#22072) 2024-01-24 13:36:35 +01:00
Asher Gomez
c98ab51746
feat: deprecate Deno.read() and Deno.readSync() (#22063)
For removal in Deno v2.
2024-01-24 09:42:03 +05:30
Asher Gomez
ea48bee3f7
feat: deprecate Deno.seek() and Deno.seekSync() (#22065)
For removal in Deno v2.
2024-01-24 09:39:56 +05:30
Asher Gomez
4c5ce90883
chore: update Deno.{fsync,fsyncSync}() deprecation notices (#22071)
To align with other deprecations.
2024-01-24 09:38:59 +05:30
Asher Gomez
5a4d69354c
feat: deprecate Deno.shutdown() (#22067)
For removal in Deno v2.

---------

Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-01-24 03:47:48 +01:00
Asher Gomez
947ce41e99
feat: deprecate Deno.resources() (#22059)
Most uses of `Deno.resources()` within tests, as they previously checked
for leaked resources. This is not needed as the test runner does this
automatically. Other internal uses of this API have been replaced with
the internal `Deno[Deno.internal].core.resources()`.
2024-01-24 00:27:29 +01:00
Asher Gomez
4eedac3604
feat: Deno.{stdin,stdout,stderr}.isTerminal(), deprecate Deno.isatty() (#22011)
This change:
1. Implements `Deno.stdin.isTerminal()`, `Deno.stdout.isTerminal()` and
`Deno.stderr.isTerminal()`.
2. Deprecates `Deno.isatty()` for removal in Deno v2, in favour of the
above instance methods.
3. Replaces use of `Deno.isatty()` with the above instance methods.

Related #21995

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2024-01-24 00:01:56 +01:00
Asher Gomez
5aa25f08be
feat: Add deprecation warning for Deno.customInspect (#22027)
This change sets the removal version of `Deno.customInspect` for Deno
v2.

Towards #22021

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-01-23 21:46:59 +00:00
Asher Gomez
6238b0a457
refactor: port more ops to ensureFastOps() (#22046) 2024-01-23 17:34:53 +05:30
Asher Gomez
7e4145df25
refactor: set removal version for Deno.RequestEvent, Deno.HttpConn and Deno.serveHttp() (#22034)
This change:
1. Sets the removal version for `Deno.RequestEvent`, `Deno.HttpConn` and
`Deno.serveHttp()` for Deno v2. I thought it might be worth calling
`warnOnDeprecatedApi()` within `Deno.Request` and `Deno.HttpConn`
methods, but I thought just having it called within `Deno.serveHttp()`
might be sufficient.
2. Removes some possibly unneeded related benchmarks.

Towards #22021
2024-01-23 03:24:03 +00:00
Bartek Iwańczuk
71551c80a1
feat(unstable): remove Deno.upgradeHttp API (#21856)
Closes https://github.com/denoland/deno/issues/21828.

This API is a huge footgun. And given that "Deno.serveHttp" is a
deprecated API that is discouraged to use (use "Deno.serve()" 
instead); it makes no sense to keep this API around.

This is a step towards fully migrating to Hyper 1.
2024-01-22 21:35:39 +00:00
Leo Kettmeir
8f76762793
feat(web): ImageBitmap (#21898) 2024-01-22 12:08:01 +01:00
Divy Srivastava
40febd9dd1
feat:: External webgpu surfaces / BYOW (#21835)
This PR contains the implementation of the External webgpu surfaces /
BYOW proposal. BYOW stands for "Bring your own window".

Closes #21713 

Adds `Deno.UnsafeWindowSurface` ( `--unstable-webgpu` API) to the `Deno`
namespace:

```typescript
class UnsafeWindowSurface {
  constructor(
    system: "cocoa" | "x11" | "win32",
    winHandle: Deno.PointerValue,
    displayHandle: Deno.PointerValue | null
  );
  
  getContext(type: "webgpu"): GPUCanvasContext;

  present(): void;
}
```

For the initial pass, I've opted to support the three major windowing
systems. The parameters correspond to the table below:
| system                      | winHandle  | displayHandle |
| -----------------     | ----------   | ------- |
| "cocoa" (macOS)    | `NSView*`       | - |
| "win32" (Windows) | `HWND`         | `HINSTANCE` |
| "x11" (Linux)            | Xlib `Window` | Xlib `Display*` |

Ecosystem support:

- [x] deno_sdl2 (sdl2) -
[mod.ts#L1209](7e177bc652/mod.ts (L1209))
- [x] dwm (glfw) - https://github.com/deno-windowing/dwm/issues/29
- [ ] pane (winit)

<details>
<summary>Example</summary>

```typescript
// A simple clear screen pass, colors based on mouse position.

import { EventType, WindowBuilder } from "https://deno.land/x/sdl2@0.7.0/mod.ts";

const window = new WindowBuilder("sdl2 + deno + webgpu", 640, 480).build();
const [system, windowHandle, displayHandle] = window.rawHandle();

const adapter = await navigator.gpu.requestAdapter();
const device = await adapter.requestDevice();

const context = Deno.createWindowSurface(system, windowHandle, displayHandle);

context.configure({
  device: device,
  format: "bgra8unorm",
  height: 480,
  width: 640,
});

let r = 0.0;
let g = 0.0;
let b = 0.0;

for (const event of window.events()) {
  if (event.type === EventType.Quit) {
    break;
  } else if (event.type === EventType.Draw) {
    const textureView = context.getCurrentTexture().createView();

    const renderPassDescriptor: GPURenderPassDescriptor = {
      colorAttachments: [
        {
          view: textureView,
          clearValue: { r, g, b, a: 1.0 },
          loadOp: "clear",
          storeOp: "store",
        },
      ],
    };

    const commandEncoder = device.createCommandEncoder();
    const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
    passEncoder.end();

    device.queue.submit([commandEncoder.finish()]);
    Deno.presentGPUCanvasContext(context);
  }

  if (event.type === EventType.MouseMotion) {
    r = event.x / 640;
    g = event.y / 480;
    b = 1.0 - r - g;
  }
}
```

You can find more examples in the linked tracking issue.

</details>

---------

Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
2024-01-19 22:49:14 +05:30
Bartek Iwańczuk
c62615bfe5
feat: Start warning on each use of a deprecated API (#21939)
This commit introduces deprecation warnings for "Deno.*" APIs.

This is gonna be quite noisy, but should tremendously help with user
code updates to ensure
smooth migration to Deno 2.0. The warning is printed at each unique call
site to help quickly
identify where code needs to be adjusted. There's some stack frame
filtering going on to
remove frames that are not useful to the user and would only cause
confusion.

The warning can be silenced using "--quiet" flag or
"DENO_NO_DEPRECATION_WARNINGS" env var.

"Deno.run()" API is now using this warning. Other deprecated APIs will
start warning
in follow up PRs.

Example:

```js
import { runEcho as runEcho2 } from "http://localhost:4545/run/warn_on_deprecated_api/mod.ts";

const p = Deno.run({
  cmd: [
    Deno.execPath(),
    "eval",
    "console.log('hello world')",
  ],
});
await p.status();
p.close();

async function runEcho() {
  const p = Deno.run({
    cmd: [
      Deno.execPath(),
      "eval",
      "console.log('hello world')",
    ],
  });
  await p.status();
  p.close();
}

await runEcho();
await runEcho();

for (let i = 0; i < 10; i++) {
  await runEcho();
}

await runEcho2();

```

```
$ deno run --allow-read foo.js
Warning
├ Use of deprecated "Deno.run()" API.
│
├ This API will be removed in Deno 2.0. Make sure to upgrade to a stable API before then.
│
├ Suggestion: Use "Deno.Command()" API instead.
│
└ Stack trace:
  └─ at file:///Users/ib/dev/deno/foo.js:3:16

hello world
Warning
├ Use of deprecated "Deno.run()" API.
│
├ This API will be removed in Deno 2.0. Make sure to upgrade to a stable API before then.
│
├ Suggestion: Use "Deno.Command()" API instead.
│
└ Stack trace:
  ├─ at runEcho (file:///Users/ib/dev/deno/foo.js:8:18)
  └─ at file:///Users/ib/dev/deno/foo.js:13:7

hello world
Warning
├ Use of deprecated "Deno.run()" API.
│
├ This API will be removed in Deno 2.0. Make sure to upgrade to a stable API before then.
│
├ Suggestion: Use "Deno.Command()" API instead.
│
└ Stack trace:
  ├─ at runEcho (file:///Users/ib/dev/deno/foo.js:8:18)
  └─ at file:///Users/ib/dev/deno/foo.js:14:7

hello world
Warning
├ Use of deprecated "Deno.run()" API.
│
├ This API will be removed in Deno 2.0. Make sure to upgrade to a stable API before then.
│
├ Suggestion: Use "Deno.Command()" API instead.
│
└ Stack trace:
  ├─ at runEcho (file:///Users/ib/dev/deno/foo.js:8:18)
  └─ at file:///Users/ib/dev/deno/foo.js:17:9

hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
Warning
├ Use of deprecated "Deno.run()" API.
│
├ This API will be removed in Deno 2.0. Make sure to upgrade to a stable API before then.
│
├ Suggestion: Use "Deno.Command()" API instead.
│
├ Suggestion: It appears this API is used by a remote dependency.
│             Try upgrading to the latest version of that dependency.
│
└ Stack trace:
  ├─ at runEcho (http://localhost:4545/run/warn_on_deprecated_api/mod.ts:2:18)
  └─ at file:///Users/ib/dev/deno/foo.js:20:7

hello world

```

Closes #21839
2024-01-18 23:30:49 +00:00
Bartek Iwańczuk
5143b9e7d3
feat(unstable): add Temporal API support (#21738)
This commit adds support for [Stage 3 Temporal API
proposal](https://tc39.es/proposal-temporal/docs/).

The API is available when `--unstable-temporal` flag is passed.

---------

Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: David Sherret <dsherret@gmail.com>
Co-authored-by: Kenta Moriuchi <moriken@kimamass.com>
2024-01-15 01:26:57 +01:00
Bartek Iwańczuk
7471587d29
feat: "rejectionhandled" Web event and "rejectionHandled" Node event (#21875)
This commit adds support for "rejectionhandled" Web Event and
"rejectionHandled" Node event.

```js
import process from "node:process";

process.on("rejectionHandled", (promise) => {
  console.log("rejectionHandled", reason, promise);
});

window.addEventListener("rejectionhandled", (event) => {
  console.log("rejectionhandled", event.reason, event.promise);
});
```

---------

Co-authored-by: Matt Mastracci <matthew@mastracci.com>
2024-01-12 22:10:42 +00:00
Divy Srivastava
9268df5f34
fix(web): use rustyline for prompt (#21893)
Workaround until https://github.com/kkawakam/rustyline/pull/759
2024-01-11 22:05:55 +01:00
Kenta Moriuchi
515a34b4de
refactor: use core.ensureFastOps() (#21888) 2024-01-10 15:37:25 -07:00
Bartek Iwańczuk
d1706c2ac9
refactor: split runtime/98_global_scope.js (#21785) 2024-01-06 14:40:26 +01:00
Divy Srivastava
9f86705fa6
chore(ext/webgpu): include GPUCanvasContext in snapshot (#21773)
Part 1 of #21713 

Changes:

- Remove `.present()` and add a `presentGPUCanvasContext` (not exposed
yet to users)
- Move lazy load logic to `00_init.js`. This can be used to use webgpu
on-demand from future code (OffScreenCanvas)
2024-01-05 19:55:01 +05:30
Kenta Moriuchi
b2cd254c35
fix: strict type check for cross realms (#21669)
Deno v1.39 introduces `vm.runInNewContext`. This may cause problems when
using `Object.prototype.isPrototypeOf` to check built-in types.

```js
import vm from "node:vm";

const err = new Error();
const crossErr = vm.runInNewContext(`new Error()`);

console.assert( !(crossErr instanceof Error) );
console.assert( Object.getPrototypeOf(err) !== Object.getPrototypeOf(crossErr) );
```

This PR changes to check using internal slots solves them.

---

current: 

```
> import vm from "node:vm";
undefined
> vm.runInNewContext(`new Error("message")`)
Error {}
> vm.runInNewContext(`new Date("2018-12-10T02:26:59.002Z")`)
Date {}
```

this PR:

```
> import vm from "node:vm";
undefined
> vm.runInNewContext(`new Error("message")`)
Error: message
    at <anonymous>:1:1
> vm.runInNewContext(`new Date("2018-12-10T02:26:59.002Z")`)
2018-12-10T02:26:59.002Z
```

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-01-04 09:42:38 +05:30
Divy Srivastava
b21462355a
Revert "fix(runtime): Make native modal keyboard interaction consistent with browsers" (#21739)
Reverts denoland/deno#18453

Fixes https://github.com/denoland/deno/issues/21602
https://github.com/denoland/deno/issues/21631
https://github.com/denoland/deno/issues/21641

Reasons for revert:
- alert() and confirm() swallowed ^C with raw mode.
- prompt() did not re-raise the interrupt signal from rustyline. 
- Default 'Y' on confirm() is a bad default and breaking change.

cc @lionel-rowe
2024-01-02 09:36:05 +05:30
David Sherret
7e72f3af61
chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
Divy Srivastava
a7b21760fc
chore(runtime): internalize pipe fd for ext/node (#21570)
Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-12-30 05:32:30 +00:00
Bartek Iwańczuk
f85d65e066
chore: update deno_core to 0.240.0 (#21726) 2023-12-28 19:30:07 +00:00
Matt Mastracci
0efe438f7c
perf: remove opAsync (#21690)
`opAsync` requires a lookup by name on each async call. This is a
mechanical translation of all opAsync calls to ensureFastOps.

The `opAsync` API on Deno.core will be removed at a later time.
2023-12-27 02:30:26 +01:00
Divy Srivastava
81a6504e67
refactor: setup child process pipe in Rust (#21579)
Avoid passing the fd into JS and back into Rust. Instead we setup the
child's end of the pipe directly using a special Rust op.
2023-12-15 11:50:05 +01:00
lionel-rowe
346d812709
fix(runtime): Make native modal keyboard interaction consistent with browsers (#18453)
Fixes https://github.com/denoland/deno/issues/18223.
Fixes https://github.com/denoland/deno/issues/21477

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: David Sherret <dsherret@gmail.com>
2023-12-13 11:31:12 +01:00
Divy Srivastava
5a91a065b8
fix: implement child_process IPC (#21490)
This PR implements the Node child_process IPC functionality in Deno on
Unix systems.

For `fd > 2` a duplex unix pipe is set up between the parent and child
processes. Currently implements data passing via the channel in the JSON
serialization format.
2023-12-13 11:14:16 +01:00
Leo Kettmeir
393abed387
feat: bring back WebGPU (#20812)
Signed-off-by: Leo Kettmeir <crowlkats@toaxl.com>
Co-authored-by: Kenta Moriuchi <moriken@kimamass.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-12-09 01:19:16 +01:00
Julien Cayzac
ca64771257
fix(unstable): Honor granular unstable flags in js runtime (#21466)
This fixes #21434 for `BroadcastChannel` and `WebSocketStream`.
`--unstable` still enable both, but granular unstable flags now also
work:

* `--unstable-net` now enables `WebSocketStream`.
* `--unstable-broadcast-channel` now enables `BroadcastChannel`.
* Additionally, there are now tests for all granular unstable flags.
Since `unsafe-proto` already had tests, so I didn't add any for this
one.

It also introduces a map to keep track of granular unstable ids without
having to sync multiple places.
2023-12-08 14:24:49 +01:00
Divy Srivastava
c5c5dea90d
chore: use primordials in 40_testing.js (#21422)
This commit brings back usage of primordials in "40_testing.js" by
turning it back into an ES module and using new "lazy loading" functionality
of ES modules coming from "deno_core".

The same approach was applied to "40_jupyter.js".

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-12-08 08:33:25 +01:00
Bartek Iwańczuk
c1fc7b2cd5
refactor: pull 'core', 'internals', 'primordials' from ES module (#21462)
This commit refactors how we access "core", "internals" and
"primordials" objects coming from `deno_core`, in our internal JavaScript code.

Instead of capturing them from "globalThis.__bootstrap" namespace, we
import them from recently added "ext:core/mod.js" file.
2023-12-07 14:21:01 +01:00
Matt Mastracci
9314928990
chore: bump deno_core and update tests (#21467)
Landing changes required for
https://github.com/denoland/deno_core/pull/359

We needed to update 99_main.js and a whole load of tests.

API changes:

- setPromiseRejectCallback becomes setUnhandledPromiseRejectionHandler.
The function is now called from eventLoopTick.
- The promiseRejectMacrotaskCallback no longer exists, as this is
automatically handled in eventLoopTick.
- ops.op_dispatch_exception now takes a second parameter: in_promise.
The preferred way to call this op is now reportUnhandledException or
reportUnhandledPromiseRejection.
2023-12-06 17:02:52 -07:00
David Sherret
1ac370632f
fix: display unstable flags at bottom of help text (#21468)
Moves the unstable flags to be at the bottom of the help text. They were
previously all over the place for some reason.
2023-12-06 09:22:30 -05:00
Jamie
8c0fb9003d
feat(ext/web): add ImageData Web API (#21183)
Fixes #19288

Adds the `ImageData` Web API. 

This would be beneficial to projects using `ImageData` as a convenient
transport layer for pixel data. This is common in Web Assembly projects
that manipulate images. Having this global available in Deno would
improve compatibility of existing JS libraries.

**References**
- [MDN ImageData Web
API](https://developer.mozilla.org/en-US/docs/Web/API/ImageData)
- [whatwg HTML Standard Canvas
Spec](https://html.spec.whatwg.org/multipage/canvas.html#pixel-manipulation)
2023-12-06 14:20:28 +01:00
David Sherret
a4ec7dfae0
feat(unstable): --unstable-unsafe-proto (#21313)
Closes https://github.com/denoland/deno/issues/21276
2023-11-25 11:41:21 -05:00
Divy Srivastava
89424f8e4a
perf: move "cli/js/40_testing.js" out of main snapshot (#21212)
Closes https://github.com/denoland/deno/issues/21136

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-11-25 04:46:16 +01:00
Kenta Moriuchi
c806fbdabe
fix(ext,runtime): add missing custom inspections (#21219) 2023-11-19 09:13:38 +01:00
Divy Srivastava
7f3902b41f
perf: static bootstrap options in snapshot (#21213)
Closes https://github.com/denoland/deno/issues/21133
2023-11-15 13:25:55 +01:00
Yoshiya Hinosawa
c67de43ff3
fix(runtime): fix Deno.noColor when stdout is not tty (#21208) 2023-11-15 14:10:12 +09:00
Divy Srivastava
1ef617e8f3
perf: lazy bootstrap options - first pass (#21164)
Move most runtime options to be lazily loaded. Constant options will be
covered in a different PR.

Towards https://github.com/denoland/deno/issues/21133
2023-11-13 04:52:59 +00:00
Divy Srivastava
9f2e56ba96
chore: use internal namespace in 40_testing.js (#21141)
Towards #21136 

- [x] assign serializePermissions, setTimeout and setExitHandler APIs to
internal namespace
- [x] remove usage of assert
2023-11-10 14:34:41 +00:00
Matt Mastracci
9010b8df53
perf: remove knowledge of promise IDs from deno (#21132)
We can move all promise ID knowledge to deno_core, allowing us to better
experiment with promise implementation in deno_core.

`{un,}refOpPromise(promise)` is equivalent to
`{un,}refOp(promise[promiseIdSymbol])`
2023-11-09 13:57:26 -07:00
Bartek Iwańczuk
24c3c96958
feat: granular --unstable-* flags (#20968)
This commit adds granular `--unstable-*` flags:
- "--unstable-broadcast-channel"
- "--unstable-ffi"
- "--unstable-fs"
- "--unstable-http"
- "--unstable-kv"
- "--unstable-net"
- "--unstable-worker-options"
- "--unstable-cron"

These flags are meant to replace a "catch-all" flag - "--unstable", that
gives a binary control whether unstable features are enabled or not. The
downside of this flag that allowing eg. Deno KV API also enables the FFI
API (though the latter is still gated with a permission).

These flags can also be specified in `deno.json` file under `unstable`
key.

Currently, "--unstable" flag works the same way - I will open a follow
up PR that will print a warning when using "--unstable" and suggest to use
concrete "--unstable-*" flag instead. We plan to phase out "--unstable"
completely in Deno 2.
2023-11-01 23:15:08 +01:00
Luca Casonato
d42f154312
feat: disposable Deno resources (#20845)
This commit implements Symbol.dispose and Symbol.asyncDispose for
the relevant resources.

Closes #20839

---------

Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-11-01 20:26:12 +01:00
Igor Zinkovsky
01d3e0f317
feat(cron) implement Deno.cron() (#21019)
This PR adds unstable `Deno.cron` API to trigger execution of cron jobs.

* State: All cron state is in memory. Cron jobs are scheduled according
to the cron schedule expression and the current time. No state is
persisted to disk.
* Time zone: Cron expressions specify time in UTC.
* Overlapping executions: not permitted. If the next scheduled execution
time occurs while the same cron job is still executing, the scheduled
execution is skipped.
* Retries: failed jobs are automatically retried until they succeed or
until retry threshold is reached. Retry policy can be optionally
specified using `options.backoffSchedule`.
2023-11-01 11:57:55 -07:00
Leo Kettmeir
39716183ac
feat(ext/web): EventSource (#14730)
Closes #10298

---------

Co-authored-by: Aapo Alasuutari <aapo.alasuutari@gmail.com>
2023-10-31 18:16:27 +01:00
Bartek Iwańczuk
dfc254cd57
fix: define window.name (#20804)
Closes https://github.com/denoland/deno/issues/20750

This matches what browsers do:
https://developer.mozilla.org/en-US/docs/Web/API/Window/name

In the future we might want to change the behavior to actually update
the process name, but that needs a bit of discussion regarding if
it needs a permission flag (that would make polyfiling `process.title`
setter really easy too).
2023-10-08 22:12:59 +00:00
Bartek Iwańczuk
0bd53fd52d
fix(jupyter): more robust Deno.jupyter namespace (#20710) 2023-09-28 16:51:44 +02:00
Bartek Iwańczuk
46a4bd5178
feat(unstable): add Deno.jupyter.broadcast API (#20656)
Closes https://github.com/denoland/deno/issues/20591

---------

Co-authored-by: Kyle Kelley <rgbkrk@gmail.com>
2023-09-27 02:21:06 +02:00
Matt Mastracci
365d1ac7c2
chore: bump deno_core + cargo update (#20636)
```
    Updating aes-gcm v0.10.2 -> v0.10.3
    Updating aho-corasick v1.1.0 -> v1.1.1
    Updating curve25519-dalek v4.1.0 -> v4.1.1
    Updating deno_core v0.214.0 -> v0.215.0
    Updating deno_ops v0.90.0 -> v0.91.0
    Updating deno_unsync v0.2.1 -> v0.3.0
    Updating md-5 v0.10.5 -> v0.10.6
    Updating rustix v0.38.13 -> v0.38.14
    Updating rustls-webpki v0.101.5 -> v0.101.6
    Updating serde_v8 v0.123.0 -> v0.124.0
    Updating sha1 v0.10.5 -> v0.10.6
    Updating smallvec v1.11.0 -> v1.11.1
    Updating tokio-util v0.7.8 -> v0.7.9
    Updating v8 v0.76.0 -> v0.77.0
    Updating winapi-util v0.1.5 -> v0.1.6
```
2023-09-22 19:51:59 +00:00
David Sherret
6dc8682b9a
feat: explicit resource management in TypeScript (#20506)
This adds support for `using` and `await using` declarations in
TypeScript only. We need to wait for v8 to support it for this to work
in JS.
2023-09-14 18:08:59 +00:00
Matt Mastracci
c272d26ae8
chore(cli): remove atty crate (#20275)
Removes a crate with an outstanding vulnerability.
2023-08-25 07:43:07 -06:00
Matt Mastracci
4380a09a05
feat(ext/node): eagerly bootstrap node (#20153)
To fix bugs around detection of when node emulation is required, we will
just eagerly initialize it. The improvements we make to reduce the
impact of the startup time:

 - [x] Process stdin/stdout/stderr are lazily created
 - [x] node.js global proxy no longer allocates on each access check
- [x] Process checks for `beforeExit` listeners before doing expensive
shutdown work
- [x] Process should avoid adding global event handlers until listeners
are added

Benchmarking this PR (`89de7e1ff`) vs main (`41cad2179`)

```
12:36 $ third_party/prebuilt/mac/hyperfine --warmup 100 -S none './deno-41cad2179 run ./empty.js' './deno-89de7e1ff run ./empty.js'
Benchmark 1: ./deno-41cad2179 run ./empty.js
  Time (mean ± σ):      24.3 ms ±   1.6 ms    [User: 16.2 ms, System: 6.0 ms]
  Range (min … max):    21.1 ms …  29.1 ms    115 runs
 
Benchmark 2: ./deno-89de7e1ff run ./empty.js
  Time (mean ± σ):      24.0 ms ±   1.4 ms    [User: 16.3 ms, System: 5.6 ms]
  Range (min … max):    21.3 ms …  28.6 ms    126 runs
```

Fixes https://github.com/denoland/deno/issues/20142
Fixes https://github.com/denoland/deno/issues/15826
Fixes https://github.com/denoland/deno/issues/20028
2023-08-16 04:36:36 +09:00
await-ovo
41cad2179f
fix(runtime): navigator.userAgent in web worker (#20129)
Fixes https://github.com/denoland/deno/issues/20079

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-08-15 17:04:36 +02:00
Asher Gomez
6fb7e8d93b
feat(permissions): add "--deny-*" flags (#19070)
This commit adds new "--deny-*" permission flags. These are complimentary to
"--allow-*" flags.

These flags can be used to restrict access to certain resources, even if they
were granted using "--allow-*" flags or the "--allow-all" ("-A") flag.

Eg. specifying "--allow-read --deny-read" will result in a permission error,
while "--allow-read --deny-read=/etc" will allow read access to all FS but the
"/etc" directory.

Runtime permissions APIs ("Deno.permissions") were adjusted as well, mainly
by adding, a new "PermissionStatus.partial" field. This field denotes that
while permission might be granted to requested resource, it's only partial (ie.
a "--deny-*" flag was specified that excludes some of the requested resources).
Eg. specifying "--allow-read=foo/ --deny-read=foo/bar" and then querying for
permissions like "Deno.permissions.query({ name: "read", path: "foo/" })"
will return "PermissionStatus { state: "granted", onchange: null, partial: true }",
denoting that some of the subpaths don't have read access.

Closes #18804.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Nayeem Rahman <nayeemrmn99@gmail.com>
2023-08-03 13:19:19 +02:00
Ricardo Iván Vieitez Parra
98403691d1
fix: call setIsTrusted for generated events (MessageEvent) (#19919)
This addresses issue #19918.

## Issue description

Event messages have the wrong isTrusted value when they are not
triggered by user interaction, which differs from the browser. In
particular, all MessageEvents created by Deno have isTrusted set to
false, even though it should be true.

This is my first ever contribution to Deno, so I might be missing
something.
2023-07-31 23:22:07 +02:00
Luca Casonato
e511022c74
feat(ext/node): properly segregate node globals (#19307)
Code run within Deno-mode and Node-mode should have access to a
slightly different set of globals. Previously this was done through a
compile time code-transform for Node-mode, but this is not ideal and has
many edge cases, for example Node's globalThis having a different
identity than Deno's globalThis.

This commit makes the `globalThis` of the entire runtime a semi-proxy.
This proxy returns a different set of globals depending on the caller's
mode. This is not a full proxy, because it is shadowed by "real"
properties on globalThis. This is done to avoid the overhead of a full
proxy for all globalThis operations.

The globals between Deno-mode and Node-mode are now properly segregated.
This means that code running in Deno-mode will not have access to Node's
globals, and vice versa. Deleting a managed global in Deno-mode will
NOT delete the corresponding global in Node-mode, and vice versa.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Aapo Alasuutari <aapo.alasuutari@gmail.com>
2023-07-19 10:30:04 +02:00
David Sherret
b03d82e5d3
fix(tsc): more informative diagnostic when Deno does not exist (#19825)
Also improved the diagnostic when using something like `Deno.openKv` and
it doesn't exist.
2023-07-13 23:29:51 +00:00
Bartek Iwańczuk
6d0c658023
fix: move Deno.serve to stable namespace (#19718)
This was missed in #19141
2023-07-04 23:04:26 +00:00
Luca Casonato
476e4ed03c
fix(ext/kv): expose Deno.AtomicOperation (#19674) 2023-07-01 09:24:15 +02:00
Bartek Iwańczuk
0434e04177
feat: add more Deno.errors classes (#19514)
This commit adds following new error classes:
- `Deno.errors.NotADirectory`
- `Deno.errors.FilesystemLoop`
- `Deno.errors.IsADirectory`
- `Deno.errors.NetworkUnreachable`

Closes https://github.com/denoland/deno/issues/19408
2023-06-29 01:46:16 +02:00
Bartek Iwańczuk
5ef225853c
perf: don't run microtask checkpoint if macrotask callback did no work (#19492)
Most of the time there's no firing timers, nor pending promise
rejections, so it's wasteful to run microtask checkpoint 
additionally twice on each tick of the event loop.

Closes https://github.com/denoland/deno/issues/18871
Ref https://github.com/denoland/deno/issues/19451
2023-06-14 16:21:06 +02:00
David Sherret
3b69d238cd
feat(runtime): add WorkerLogLevel (#19316)
This is not really used yet, but provides some infrastructure for doing
more fine grained logging in JS. I will add warn messages in a future
PR.
2023-05-30 15:34:50 +00:00
Bartek Iwańczuk
0bb5bbc7a0
fix(node): fire 'unhandledrejection' event when using node: or npm: imports (#19235)
This commit fixes emitting "unhandledrejection" event when there are
"node:" or "npm:" imports. 

Before this commit the Node "unhandledRejection" event was emitted
using a regular listener for Web "unhandledrejection" event. This
listener was installed before any user listener had a chance to be 
installed which effectively prevent emitting "unhandledrejection" 
events to user code.

Closes https://github.com/denoland/deno/issues/16928
2023-05-24 15:40:41 +02:00
David Sherret
ffa020f43a
fix(runtime): JS debug log to stderr (#19217)
Debug logs should all go to stderr.
2023-05-22 18:17:31 +00:00
Nayeem Rahman
2ba9ccc1ab
fix(runtime): ChildProcess::kill() doesn't require additional perms (#15339)
Fixes #15217.
2023-05-11 14:53:45 +02:00
David Sherret
30628288ce
perf: lazily retrieve ppid (#18940)
This is very apparent on Windows.

Before: 45.74ms (Hello world)
After: 33.92ms

Closes #18939
2023-05-01 18:21:27 +00:00
Kenta Moriuchi
6728ad4203
fix(core): Use primordials for methods (#18839)
I would like to get this change into Deno before merging
https://github.com/denoland/deno_lint/pull/1152
2023-05-01 15:30:02 +02:00
Leo Kettmeir
b31cf9fde6
refactor(webidl): move prefix & context out of converters options bag (#18931) 2023-05-01 10:47:13 +00:00
Leo Kettmeir
59825a95b4
refactor: remove ext/console/01_colors.js (#18927) 2023-04-30 09:11:37 +00:00
Leo Kettmeir
9c8ebce3dc
refactor: merge Deno & Node inspectors (#18691) 2023-04-30 07:24:13 +00:00
Bartek Iwańczuk
683dbd7f3b
Revert "refactor: don't expose Deno[Deno.internal].core namespace" (#18881)
Also conditionally disabled one test if there's not enough space on
device.
2023-04-28 00:37:03 +02:00
Bartek Iwańczuk
14aaa73c02
refactor: don't expose Deno[Deno.internal].core namespace (#18816) 2023-04-26 19:57:38 +02:00
Kenta Moriuchi
f086ec57b4
fix(core): Use safe primordials wrappers (#18687) 2023-04-14 22:23:28 +02:00
Bartek Iwańczuk
51d3fb78ad
refactor: remove "ext/flash" (#18578)
With https://github.com/denoland/deno/pull/18568 landed we no longer
need "ext/flash". 

This commit removes "deno_flash" extension completely.

This should have some impact on the binary and snapshot size.

Closes https://github.com/denoland/deno/issues/17356
2023-04-03 19:01:02 +02:00
Bartek Iwańczuk
2846bbe0a3
refactor: "Deno.serve()" API uses "Deno.serveHttp()" internally (#18568)
This commit changes implementation of "Deno.serve()" API to use
"Deno.serveHttp()" under the hood. This change will allow us to
remove the "flash" server implementation, bringing stability to the
"Deno.serve()" API.

"cli/tests/unit/flash_test.ts" was renamed to "serve_test.ts".

Closes https://github.com/denoland/deno/issues/15574
Closes https://github.com/denoland/deno/issues/15504
Closes https://github.com/denoland/deno/issues/15646
Closes https://github.com/denoland/deno/issues/15909
Closes https://github.com/denoland/deno/issues/15911
Closes https://github.com/denoland/deno/issues/16828
Closes https://github.com/denoland/deno/issues/18046
Closes https://github.com/denoland/deno/issues/15869
2023-04-03 17:44:18 +02:00
Kenta Moriuchi
03edd48edd
chore: Turn back on dlintPreferPrimordials (#17715)
Closes #17709
2023-04-02 19:41:41 +02:00
David Sherret
6fb6b0c1f3
chore: restore pty tests and make them run on the Linux CI (#18424)
1. Rewrites the tests to be more back and forth rather than getting the
output all at once (which I believe was causing the hangs on linux and
maybe mac)
2. Runs the pty tests on the linux ci.
3. Fixes a bunch of tests that were just wrong.
4. Adds timeouts on the pty tests.
2023-03-28 21:49:00 +00:00
Bartek Iwańczuk
e5b2815b39
Reland "refactor: remove Deno[Deno.internal].nodeUnstable namespace" (#18475)
This reverts commit 357bcfcf79.
2023-03-28 14:44:22 +02:00
Bartek Iwańczuk
795ecfa146
refactor(runtime): manual serialization of bootstrap data (#18448)
This commit changes how data required to bootstrap main and worker
runtime is serialized. 

Instead of relying on serde_v8 and using JSON object,
we're doing manual serialization to a "v8::Array". This limits number 
of V8 strings that need to be serialized by 16. 

It also made it clear that some data could be obtained during
snapshotting instead of during bootstrap.
2023-03-28 10:27:17 +02:00
Bartek Iwańczuk
357bcfcf79
Revert "refactor: remove Deno[Deno.internal].nodeUnstable namespace (… (#18458)
…#18449)"

This reverts commit d1a9c4cd7c.

Appears this made CI very flaky on macOS, but I can't repeat it locally
yet
2023-03-27 14:25:17 +00:00
Bartek Iwańczuk
d1a9c4cd7c
refactor: remove Deno[Deno.internal].nodeUnstable namespace (#18449)
Since we can preserve ops in the snapshot these days, we no longer
need to have "Deno[Deno.internal].nodeUnstable" namespace.

Instead, various built-in Node.js modules can use appropriate APIs
directly.
2023-03-27 02:15:08 +02:00
Ryan Dahl
f9c8d98b77
Revert "refactor: rename Deno.openKv() to Deno.kv() (#18349)" (#18362)
This reverts commit 50b793c9ed.
2023-03-22 20:23:36 +01:00
Ryan Dahl
50b793c9ed
refactor: rename Deno.openKv() to Deno.kv() (#18349) 2023-03-22 10:02:40 -04:00
Heyang Zhou
92ebf4afe5
feat(ext/kv): key-value store (#18232)
This commit adds unstable "Deno.openKv()" API that allows to open
a key-value database at a specified path.

---------

Co-authored-by: Luca Casonato <hello@lcas.dev>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-03-22 12:13:24 +08: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
Kenta Moriuchi
521cb4ca9b
fix(rumtime): Add Deno. prefix for registered symbols (#18086) 2023-03-09 04:09:40 +00:00
Bartek Iwańczuk
0f9df73349
perf: don't add unload event listener (#18082)
This commit changes how "unload" event is handled - before
this commit an event listener was added unconditionally in
the runtime bootstrapping function, which for some reason was
very expensive (0.3ms). Instead of adding an event listener,
a check was added to "dispatchEvent" function that performs
the same action (so it's only called if there's an event dispatched).
2023-03-09 01:08:54 +00: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
9eb987e46c
perf: move setting up Deno namespace to snapshot time (#18067)
No need to do it on startup every time.
2023-03-08 09:50:54 +05:30
Bartek Iwańczuk
76d085ff6a
perf: move runtime bootstrap code to snapshot time (#18062)
This commit moves some of the code from "99_main.js" to
be executed during the snapshot time instead of on each
worker bootstrap. These should minimally help with startup
time benchmark.
2023-03-07 16:11:54 +01:00
Bartek Iwańczuk
fe368b72c1
refactor: Add "deno_fs" extension crate (#18040)
This commit factors out APIs related to file system from "runtime/"
to a separate "deno_fs" extension crate.
2023-03-07 18:13:44 +09:00
Bartek Iwańczuk
76b173b60c
refactor: move "pathFromURL" to deno_web extension (#18037)
This API is required by several extensions like "ext/node", "ext/ffi"
and also FS APIs that we want to move to a separate crate. Because 
of that "pathFromURL" API was moved to "deno_web" extension so
other extension crates can rely on it.
2023-03-05 22:46:37 +00:00
Bartek Iwańczuk
5f34c9be91
refactor: move definition of Deno.build from "runtime" to "core" (#18036)
We use information about build in several extension crates like
"ext/node" or "runtime/". In an effort to move "fs" APIs to a separate 
crate it is a prerequisite to have this information available outside 
of the "runtime/" crate.

This commit moves definition of "build" object to "Deno.core" that is 
later forwarded to "Deno.build".
2023-03-05 22:18:13 +00:00
Bartek Iwańczuk
de0d148d93
refactor(runtime): merge "spawn" into "process" (#18022)
This commit merges "runtime/js/40_spawn.js" into
"runtime/js/40_process.js", and "runtime::ops::spawn" 
into "runtime::ops::process".

It makes little sense to have them separated given that we want to
factor out these APIs into a separate extension crate.
2023-03-05 12:19:34 +00:00
Bartek Iwańczuk
888ceac7fd
refactor(runtime): remove 40_files.js, 40_write_file.js and 40_read_file.js (#18018)
JavaScript APIs from "runtime/js/40_files.js" combined abstractions
for stdio streams ("Stdout", "Stderr", "Stdin") and file system file
("File", "FsFile"). APIs from "runtime/js/40_read_file.js" and 
"runtime/js/40_write_file.js" were implemented using ops from 
"runtime/ops/fs.rs".

This file was removed and relevant APIs were moved to "deno_io/12_io.js"
and "runtime/js/30_fs.js".

This work is meant to enable factoring out "deno_fs" crate.
2023-03-05 03:37:37 +00:00
Bartek Iwańczuk
17574f1ef7
refactor: remove unused 40_diagnostics.js file (#18021)
This file was not used anywhere - even though it exposed an unstable
"Deno.DiagnosticCategory" API. Seems like a left over from when we
had "Deno.emit" API.
2023-03-05 03:04:08 +00: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
Bartek Iwańczuk
7afa3aceb0
refactor(runtime): factor out deno_io extension crate (#18001)
This is a prerequisite to factor out FS ops to a separate crate.
2023-03-05 00:39:48 +00:00
Kenta Moriuchi
55833cf799
fix(core): introduce SafeRegExp to primordials (#17592) 2023-03-01 08:14:16 +09:00
Divy Srivastava
da781280b8
fix(core): remove async op inlining optimization (#17899)
Runtime generation of async op wrappers contributed to increased startup
time and core became unusable with
`--disallow-code-generation-from-strings` flag. The optimization only
affects very small microbenchmarks so this revert will not cause any
regressions.
2023-02-23 19:50:15 +00:00
Bartek Iwańczuk
4c6db7aa14
perf(core, runtime): Further improve startup time (#17860)
This commit further improves startup time by:

- no relying on "JsRuntime::execute_script" for runtime bootstrapping,
this is instead done using V8 APIs directly
- registering error classes during the snapshot time, instead of on
startup

Further improvements can be made, mainly around removing 
"core.initializeAsyncOps()" which takes around 2ms.

This commit should result in ~1ms startup time improvement.
2023-02-22 06:25:31 +05:30
Bartek Iwańczuk
4c2380af5c
test: add unit tests from std/node (#17794)
Adds two test files: "cli/tests/unit_node/process_test.ts" and
"cli/tests/unit_node/child_process_test.ts"

---------

Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2023-02-16 14:30:14 +01:00
Bartek Iwańczuk
d47147fb6a
feat(ext/node): embed std/node into the snapshot (#17724)
This commit moves "deno_std/node" in "ext/node" crate. The code is
transpiled and snapshotted during the build process.

During the first pass a minimal amount of work was done to create the
snapshot, a lot of code in "ext/node" depends on presence of "Deno"
global. This code will be gradually fixed in the follow up PRs to migrate
it to import relevant APIs from "internal:" modules.

Currently the code from snapshot is not used in any way, and all
Node/npm compatibility still uses code from 
"https://deno.land/std/node" (or from the location specified by 
"DENO_NODE_COMPAT_URL"). This will also be handled in a follow 
up PRs.

---------

Co-authored-by: crowlkats <crowlkats@toaxl.com>
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2023-02-14 17:38:45 +01:00
Bartek Iwańczuk
201737c518
feat: stabilize Deno.osUptime() (#17554)
This commit stabilizes "Deno.osUptime()" API. The "--unstable" flag is
no longer required to use this API.
2023-02-14 12:35:38 +01:00