Commit graph

163 commits

Author SHA1 Message Date
Matt Mastracci 3487fde236
perf(core) Reduce copying and cloning in extension initialization (#18252)
Follow-up to #18210:

* we are passing the generated `cfg` object into the state function
rather than passing individual config fields
 * reduce cloning dramatically by making the state_fn `FnOnce`
 * `take` for `ExtensionBuilder` to avoid more unnecessary copies
 * renamed `config` to `options`
2023-03-17 22:15:27 +00:00
Matt Mastracci e55b448730
feat(core) deno_core::extension! macro to simplify extension registration (#18210)
This implements two macros to simplify extension registration and centralize a lot of the boilerplate as a base for future improvements:

* `deno_core::ops!` registers a block of `#[op]`s, optionally with type
parameters, useful for places where we share lists of ops
* `deno_core::extension!` is used to register an extension, and creates
two methods that can be used at runtime/snapshot generation time:
`init_ops` and `init_ops_and_esm`.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-03-17 18:22:15 +00:00
Bartek Iwańczuk 3f031ad9af
BREAKING(ext/fs): FileInfo.dev is defined on Windows (#18237)
Addresses feedback from
https://github.com/denoland/deno/pull/18073#issuecomment-1471480385.

Reverts changes to `FileInfo` fields that are not available on Windows
making them `null`. Only `FileInfo.dev` is non-null.
2023-03-17 00:14:56 +01:00
denobot 33b85a2b8e
chore: forward v1.31.3 release commit to main (#18222)
Co-authored-by: kt3k <kt3k@users.noreply.github.com>
2023-03-16 17:09:26 +09:00
Bartek Iwańczuk 48a0b7f98f
feat(fs): support FileInfo.dev on Windows (#18073)
This commit adds support for retrieving `dev` information
when stating files on Windows.

Additionally `Deno.FileInfo` interfaces was changed to always
return 0 for fields that we don't retrieve information for on Windows.

Closes https://github.com/denoland/deno/issues/18053

---------

Co-authored-by: David Sherret <dsherret@gmail.com>
2023-03-16 02:35:13 +01:00
David Sherret fb021d7cef
refactor: remove usages of map_or / map_or_else (#18212)
These methods are confusing because the arguments are backwards. I feel
like they should have never been added to `Option<T>` and that clippy
should suggest rewriting to
`map(...).unwrap_or(...)`/`map(...).unwrap_or_else(|| ...)`

https://github.com/rust-lang/rfcs/issues/1025
2023-03-15 17:46:36 -04:00
ud2 3db03abf88
fix(ext/fs): retry if file already exists in makeTempFile (#17787)
Closes #17781.
2023-03-13 20:54:34 +01:00
denobot 857393d934
chore: forward v1.31.2 release commit to main (#18114)
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2023-03-10 17:39:29 +09:00
Bartek Iwańczuk d1685b120b
refactor(core): remove RuntimeOptions::extensions_with_js (#18099)
This commit removes "deno_core::RuntimeOptions::extensions_with_js".

Now it's embedders' responsibility to properly register extensions
that will not contains JavaScript sources when running from an existing
snapshot.

Prerequisite for https://github.com/denoland/deno/pull/18080
2023-03-09 19:22:27 -05:00
Bartek Iwańczuk 8f207c0f3f
refactor: Split extension registration for runtime and snapshotting (#18095)
This commit splits "<ext_name>::init" functions into "init_ops" and
"init_ops_and_esm". That way we don't have to construct list of
ESM sources on each startup if we're running with a snapshot.

In a follow up commit "deno_core" will be changed to not have a split
between "extensions" and "extensions_with_js" - it will be embedders'
responsibility to pass appropriately configured extensions.

Prerequisite for https://github.com/denoland/deno/pull/18080
2023-03-09 14:56:19 +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 b32a6f8ad2
refactor(core): don't use Result in ExtensionBuilder::state (#18066)
There's no point for this API to expect result. If something fails it should
result in a panic during build time to signal to embedder that setup is
wrong.
2023-03-07 22:37:37 +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