mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
Revert "Reland "refactor(core): cleanup feature flags for js source i… (#19611)
…nclusion" (#19519)"
This reverts commit 28a4f3d0f5
.
This change causes failures when used outside Deno repo:
```
============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.
Platform: linux x86_64
Version: 1.34.3+b37b286
Args: ["/opt/hostedtoolcache/deno/0.0.0-b37b286f7fa68d5656f7c180f6127bdc38cf2cf5/x64/deno", "test", "--doc", "--unstable", "--allow-all", "--coverage=./cov"]
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Failed to read "/home/runner/work/deno/deno/core/00_primordials.js"
Caused by:
No such file or directory (os error 2)', core/runtime/jsruntime.rs:699:8
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
This commit is contained in:
parent
c7d38e593f
commit
ad3c494b46
33 changed files with 326 additions and 290 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -972,7 +972,6 @@ dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bytes",
|
"bytes",
|
||||||
"deno_ast",
|
"deno_ast",
|
||||||
"deno_core",
|
|
||||||
"deno_ops",
|
"deno_ops",
|
||||||
"futures",
|
"futures",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
|
|
|
@ -19,7 +19,7 @@ deno_core::extension!(
|
||||||
);
|
);
|
||||||
|
|
||||||
fn setup() -> Vec<Extension> {
|
fn setup() -> Vec<Extension> {
|
||||||
vec![bench_setup::init_ext()]
|
vec![bench_setup::init_ops()]
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
|
|
|
@ -27,8 +27,8 @@ harness = false
|
||||||
path = "./bench/lsp_bench_standalone.rs"
|
path = "./bench/lsp_bench_standalone.rs"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
deno_runtime = { workspace = true, features = ["exclude_js_main_from_snapshot"] }
|
deno_runtime = { workspace = true, features = ["snapshot_from_snapshot", "include_js_files_for_snapshotting"] }
|
||||||
deno_core = { workspace = true, features = ["runtime_js_sources"] }
|
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
|
||||||
lazy-regex.workspace = true
|
lazy-regex.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
|
@ -41,14 +41,14 @@ winres.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "dep_graph", "module_specifier", "proposal", "react", "sourcemap", "transforms", "typescript", "view", "visit"] }
|
deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "dep_graph", "module_specifier", "proposal", "react", "sourcemap", "transforms", "typescript", "view", "visit"] }
|
||||||
deno_core = { workspace = true, features = ["exclude_js_sources"] }
|
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
|
||||||
deno_doc = "=0.63.1"
|
deno_doc = "=0.63.1"
|
||||||
deno_emit = "=0.24.0"
|
deno_emit = "=0.24.0"
|
||||||
deno_graph = "=0.49.0"
|
deno_graph = "=0.49.0"
|
||||||
deno_lint = { version = "=0.47.0", features = ["docs"] }
|
deno_lint = { version = "=0.47.0", features = ["docs"] }
|
||||||
deno_lockfile.workspace = true
|
deno_lockfile.workspace = true
|
||||||
deno_npm.workspace = true
|
deno_npm.workspace = true
|
||||||
deno_runtime = { workspace = true, features = ["dont_create_runtime_snapshot"] }
|
deno_runtime = { workspace = true, features = ["dont_create_runtime_snapshot", "include_js_files_for_snapshotting"] }
|
||||||
deno_semver.workspace = true
|
deno_semver.workspace = true
|
||||||
deno_task_shell = "=0.12.0"
|
deno_task_shell = "=0.12.0"
|
||||||
eszip = "=0.44.0"
|
eszip = "=0.44.0"
|
||||||
|
|
48
cli/build.rs
48
cli/build.rs
|
@ -266,7 +266,11 @@ mod ts {
|
||||||
cargo_manifest_dir: env!("CARGO_MANIFEST_DIR"),
|
cargo_manifest_dir: env!("CARGO_MANIFEST_DIR"),
|
||||||
snapshot_path,
|
snapshot_path,
|
||||||
startup_snapshot: None,
|
startup_snapshot: None,
|
||||||
extensions: vec![deno_tsc::init_ext(op_crate_libs, build_libs, path_dts)],
|
extensions: vec![deno_tsc::init_ops_and_esm(
|
||||||
|
op_crate_libs,
|
||||||
|
build_libs,
|
||||||
|
path_dts,
|
||||||
|
)],
|
||||||
|
|
||||||
// NOTE(bartlomieju): Compressing the TSC snapshot in debug build took
|
// NOTE(bartlomieju): Compressing the TSC snapshot in debug build took
|
||||||
// ~45s on M1 MacBook Pro; without compression it took ~1s.
|
// ~45s on M1 MacBook Pro; without compression it took ~1s.
|
||||||
|
@ -318,7 +322,7 @@ deno_core::extension!(
|
||||||
customizer = |ext: &mut deno_core::ExtensionBuilder| {
|
customizer = |ext: &mut deno_core::ExtensionBuilder| {
|
||||||
ext.esm(vec![ExtensionFileSource {
|
ext.esm(vec![ExtensionFileSource {
|
||||||
specifier: "ext:cli/runtime/js/99_main.js",
|
specifier: "ext:cli/runtime/js/99_main.js",
|
||||||
code: ExtensionFileSourceCode::LoadAtRuntime(
|
code: ExtensionFileSourceCode::LoadedFromFsDuringSnapshot(
|
||||||
std::path::PathBuf::from(deno_runtime::js::PATH_FOR_99_MAIN_JS),
|
std::path::PathBuf::from(deno_runtime::js::PATH_FOR_99_MAIN_JS),
|
||||||
),
|
),
|
||||||
}]);
|
}]);
|
||||||
|
@ -331,42 +335,42 @@ fn create_cli_snapshot(snapshot_path: PathBuf) -> CreateSnapshotOutput {
|
||||||
// `runtime/worker.rs`, `runtime/web_worker.rs` and `runtime/build.rs`!
|
// `runtime/worker.rs`, `runtime/web_worker.rs` and `runtime/build.rs`!
|
||||||
let fs = Arc::new(deno_fs::RealFs);
|
let fs = Arc::new(deno_fs::RealFs);
|
||||||
let extensions: Vec<Extension> = vec![
|
let extensions: Vec<Extension> = vec![
|
||||||
deno_webidl::deno_webidl::init_ext(),
|
deno_webidl::deno_webidl::init_ops(),
|
||||||
deno_console::deno_console::init_ext(),
|
deno_console::deno_console::init_ops(),
|
||||||
deno_url::deno_url::init_ext(),
|
deno_url::deno_url::init_ops(),
|
||||||
deno_web::deno_web::init_ext::<PermissionsContainer>(
|
deno_web::deno_web::init_ops::<PermissionsContainer>(
|
||||||
deno_web::BlobStore::default(),
|
deno_web::BlobStore::default(),
|
||||||
Default::default(),
|
Default::default(),
|
||||||
),
|
),
|
||||||
deno_fetch::deno_fetch::init_ext::<PermissionsContainer>(Default::default()),
|
deno_fetch::deno_fetch::init_ops::<PermissionsContainer>(Default::default()),
|
||||||
deno_cache::deno_cache::init_ext::<SqliteBackedCache>(None),
|
deno_cache::deno_cache::init_ops::<SqliteBackedCache>(None),
|
||||||
deno_websocket::deno_websocket::init_ext::<PermissionsContainer>(
|
deno_websocket::deno_websocket::init_ops::<PermissionsContainer>(
|
||||||
"".to_owned(),
|
"".to_owned(),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
deno_webstorage::deno_webstorage::init_ext(None),
|
deno_webstorage::deno_webstorage::init_ops(None),
|
||||||
deno_crypto::deno_crypto::init_ext(None),
|
deno_crypto::deno_crypto::init_ops(None),
|
||||||
deno_broadcast_channel::deno_broadcast_channel::init_ext(
|
deno_broadcast_channel::deno_broadcast_channel::init_ops(
|
||||||
deno_broadcast_channel::InMemoryBroadcastChannel::default(),
|
deno_broadcast_channel::InMemoryBroadcastChannel::default(),
|
||||||
false, // No --unstable.
|
false, // No --unstable.
|
||||||
),
|
),
|
||||||
deno_ffi::deno_ffi::init_ext::<PermissionsContainer>(false),
|
deno_ffi::deno_ffi::init_ops::<PermissionsContainer>(false),
|
||||||
deno_net::deno_net::init_ext::<PermissionsContainer>(
|
deno_net::deno_net::init_ops::<PermissionsContainer>(
|
||||||
None, false, // No --unstable.
|
None, false, // No --unstable.
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
deno_tls::deno_tls::init_ext(),
|
deno_tls::deno_tls::init_ops(),
|
||||||
deno_kv::deno_kv::init_ext(
|
deno_kv::deno_kv::init_ops(
|
||||||
SqliteDbHandler::<PermissionsContainer>::new(None),
|
SqliteDbHandler::<PermissionsContainer>::new(None),
|
||||||
false, // No --unstable.
|
false, // No --unstable.
|
||||||
),
|
),
|
||||||
deno_napi::deno_napi::init_ext::<PermissionsContainer>(),
|
deno_napi::deno_napi::init_ops::<PermissionsContainer>(),
|
||||||
deno_http::deno_http::init_ext::<DefaultHttpPropertyExtractor>(),
|
deno_http::deno_http::init_ops::<DefaultHttpPropertyExtractor>(),
|
||||||
deno_io::deno_io::init_ext(Default::default()),
|
deno_io::deno_io::init_ops(Default::default()),
|
||||||
deno_fs::deno_fs::init_ext::<PermissionsContainer>(false, fs.clone()),
|
deno_fs::deno_fs::init_ops::<PermissionsContainer>(false, fs.clone()),
|
||||||
deno_node::deno_node::init_ext::<PermissionsContainer>(None, fs),
|
deno_node::deno_node::init_ops::<PermissionsContainer>(None, fs),
|
||||||
cli::init_ext(),
|
cli::init_ops_and_esm(), // NOTE: This needs to be init_ops_and_esm!
|
||||||
];
|
];
|
||||||
|
|
||||||
create_snapshot(CreateSnapshotOptions {
|
create_snapshot(CreateSnapshotOptions {
|
||||||
|
|
|
@ -3236,7 +3236,7 @@ fn op_script_version(
|
||||||
/// server.
|
/// server.
|
||||||
fn js_runtime(performance: Arc<Performance>) -> JsRuntime {
|
fn js_runtime(performance: Arc<Performance>) -> JsRuntime {
|
||||||
JsRuntime::new(RuntimeOptions {
|
JsRuntime::new(RuntimeOptions {
|
||||||
extensions: vec![deno_tsc::init_ext(performance)],
|
extensions: vec![deno_tsc::init_ops(performance)],
|
||||||
startup_snapshot: Some(tsc::compiler_snapshot()),
|
startup_snapshot: Some(tsc::compiler_snapshot()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
|
|
|
@ -12,7 +12,7 @@ pub mod bench;
|
||||||
pub mod testing;
|
pub mod testing;
|
||||||
|
|
||||||
pub fn cli_exts(npm_resolver: Arc<CliNpmResolver>) -> Vec<Extension> {
|
pub fn cli_exts(npm_resolver: Arc<CliNpmResolver>) -> Vec<Extension> {
|
||||||
vec![deno_cli::init_ext(npm_resolver)]
|
vec![deno_cli::init_ops(npm_resolver)]
|
||||||
}
|
}
|
||||||
|
|
||||||
deno_core::extension!(deno_cli,
|
deno_core::extension!(deno_cli,
|
||||||
|
|
|
@ -447,7 +447,7 @@ async fn bench_specifier(
|
||||||
.create_custom_worker(
|
.create_custom_worker(
|
||||||
specifier.clone(),
|
specifier.clone(),
|
||||||
PermissionsContainer::new(permissions),
|
PermissionsContainer::new(permissions),
|
||||||
vec![ops::bench::deno_bench::init_ext(sender.clone())],
|
vec![ops::bench::deno_bench::init_ops(sender.clone())],
|
||||||
Default::default(),
|
Default::default(),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
|
@ -936,7 +936,7 @@ pub async fn test_specifier(
|
||||||
.create_custom_worker(
|
.create_custom_worker(
|
||||||
specifier.clone(),
|
specifier.clone(),
|
||||||
PermissionsContainer::new(permissions),
|
PermissionsContainer::new(permissions),
|
||||||
vec![ops::testing::deno_test::init_ext(sender.clone())],
|
vec![ops::testing::deno_test::init_ops(sender.clone())],
|
||||||
Stdio {
|
Stdio {
|
||||||
stdin: StdioPipe::Inherit,
|
stdin: StdioPipe::Inherit,
|
||||||
stdout,
|
stdout,
|
||||||
|
|
|
@ -122,7 +122,7 @@ fn get_asset_texts_from_new_runtime() -> Result<Vec<AssetText>, AnyError> {
|
||||||
// the assets are stored within the typescript isolate, so take them out of there
|
// the assets are stored within the typescript isolate, so take them out of there
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
startup_snapshot: Some(compiler_snapshot()),
|
startup_snapshot: Some(compiler_snapshot()),
|
||||||
extensions: vec![deno_cli_tsc::init_ext()],
|
extensions: vec![deno_cli_tsc::init_ops()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
let global = runtime
|
let global = runtime
|
||||||
|
@ -787,7 +787,7 @@ pub fn exec(request: Request) -> Result<Response, AnyError> {
|
||||||
|
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
startup_snapshot: Some(compiler_snapshot()),
|
startup_snapshot: Some(compiler_snapshot()),
|
||||||
extensions: vec![deno_cli_tsc::init_ext(
|
extensions: vec![deno_cli_tsc::init_ops(
|
||||||
request,
|
request,
|
||||||
root_map,
|
root_map,
|
||||||
remapped_specifiers,
|
remapped_specifiers,
|
||||||
|
|
|
@ -34,14 +34,6 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
(() => {
|
(() => {
|
||||||
// Provide bootstrap namespace
|
|
||||||
globalThis.__bootstrap ??= {};
|
|
||||||
const key = Symbol.for("00_primordials.js");
|
|
||||||
if (globalThis.__bootstrap[key]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
globalThis.__bootstrap[key] = true;
|
|
||||||
|
|
||||||
const primordials = {};
|
const primordials = {};
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -305,7 +297,6 @@
|
||||||
ArrayPrototypeJoin,
|
ArrayPrototypeJoin,
|
||||||
ArrayPrototypeMap,
|
ArrayPrototypeMap,
|
||||||
FunctionPrototypeCall,
|
FunctionPrototypeCall,
|
||||||
ObjectAssign,
|
|
||||||
ObjectDefineProperty,
|
ObjectDefineProperty,
|
||||||
ObjectFreeze,
|
ObjectFreeze,
|
||||||
ObjectPrototypeIsPrototypeOf,
|
ObjectPrototypeIsPrototypeOf,
|
||||||
|
@ -619,5 +610,6 @@
|
||||||
ObjectSetPrototypeOf(primordials, null);
|
ObjectSetPrototypeOf(primordials, null);
|
||||||
ObjectFreeze(primordials);
|
ObjectFreeze(primordials);
|
||||||
|
|
||||||
ObjectAssign(globalThis.__bootstrap, { primordials });
|
// Provide bootstrap namespace
|
||||||
|
globalThis.__bootstrap = { primordials };
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -38,13 +38,6 @@
|
||||||
URIError,
|
URIError,
|
||||||
setQueueMicrotask,
|
setQueueMicrotask,
|
||||||
} = window.__bootstrap.primordials;
|
} = window.__bootstrap.primordials;
|
||||||
|
|
||||||
const key = SymbolFor("01_core.js");
|
|
||||||
if (globalThis.__bootstrap[key]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
globalThis.__bootstrap[key] = true;
|
|
||||||
|
|
||||||
const { ops, asyncOps } = window.Deno.core;
|
const { ops, asyncOps } = window.Deno.core;
|
||||||
|
|
||||||
const build = {
|
const build = {
|
||||||
|
|
|
@ -14,15 +14,8 @@
|
||||||
ArrayPrototypePush,
|
ArrayPrototypePush,
|
||||||
ArrayPrototypeMap,
|
ArrayPrototypeMap,
|
||||||
ArrayPrototypeJoin,
|
ArrayPrototypeJoin,
|
||||||
SymbolFor,
|
|
||||||
} = window.__bootstrap.primordials;
|
} = window.__bootstrap.primordials;
|
||||||
|
|
||||||
const key = SymbolFor("02_error.js");
|
|
||||||
if (globalThis.__bootstrap[key]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
globalThis.__bootstrap[key] = true;
|
|
||||||
|
|
||||||
// Keep in sync with `cli/fmt_errors.rs`.
|
// Keep in sync with `cli/fmt_errors.rs`.
|
||||||
function formatLocation(cse) {
|
function formatLocation(cse) {
|
||||||
if (cse.isNative) {
|
if (cse.isNative) {
|
||||||
|
|
|
@ -16,12 +16,7 @@ path = "lib.rs"
|
||||||
[features]
|
[features]
|
||||||
default = ["v8_use_custom_libcxx"]
|
default = ["v8_use_custom_libcxx"]
|
||||||
v8_use_custom_libcxx = ["v8/use_custom_libcxx"]
|
v8_use_custom_libcxx = ["v8/use_custom_libcxx"]
|
||||||
# Enable to exclude extension!() JS sources from the binary (e.g. if they are already snapshotted).
|
include_js_files_for_snapshotting = []
|
||||||
exclude_js_sources = []
|
|
||||||
# Read extension!() JS sources at 'runtime' instead of statically including them. They will be read
|
|
||||||
# from their `CARGO_MANIFEST_DIR`-based paths, so it should only to be used in build and dev scripts
|
|
||||||
# where these paths are available. Overrides `exclude_js_sources`.
|
|
||||||
runtime_js_sources = ["exclude_js_sources"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
|
@ -49,8 +44,6 @@ v8.workspace = true
|
||||||
name = "http_bench_json_ops"
|
name = "http_bench_json_ops"
|
||||||
path = "examples/http_bench_json_ops/main.rs"
|
path = "examples/http_bench_json_ops/main.rs"
|
||||||
|
|
||||||
[dev-dependencies]
|
|
||||||
deno_core = { workspace = true, features = ["runtime_js_sources"] }
|
|
||||||
|
|
||||||
# These dependencies are only used for the 'http_bench_*_ops' examples.
|
# These dependencies are only used for the 'http_bench_*_ops' examples.
|
||||||
|
[dev-dependencies]
|
||||||
deno_ast.workspace = true
|
deno_ast.workspace = true
|
||||||
|
|
|
@ -17,10 +17,10 @@ pub enum ExtensionFileSourceCode {
|
||||||
/// snapshot, the other the static string in the `Extension`.
|
/// snapshot, the other the static string in the `Extension`.
|
||||||
IncludedInBinary(&'static str),
|
IncludedInBinary(&'static str),
|
||||||
|
|
||||||
/// Source code is loaded from a file on disk at 'runtime'. It's meant to be
|
// Source code is loaded from a file on disk. It's meant to be used if the
|
||||||
/// used in build and dev scripts using the `runtime_js_sources` feature,
|
// embedder is creating snapshots. Files will be loaded from the filesystem
|
||||||
/// likely to create snapshots.
|
// during the build time and they will only be present in the V8 snapshot.
|
||||||
LoadAtRuntime(PathBuf),
|
LoadedFromFsDuringSnapshot(PathBuf),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
@ -45,7 +45,7 @@ impl ExtensionFileSource {
|
||||||
);
|
);
|
||||||
Ok(ModuleCode::from_static(code))
|
Ok(ModuleCode::from_static(code))
|
||||||
}
|
}
|
||||||
ExtensionFileSourceCode::LoadAtRuntime(path) => {
|
ExtensionFileSourceCode::LoadedFromFsDuringSnapshot(path) => {
|
||||||
let msg = || format!("Failed to read \"{}\"", path.display());
|
let msg = || format!("Failed to read \"{}\"", path.display());
|
||||||
let s = std::fs::read_to_string(path).with_context(msg)?;
|
let s = std::fs::read_to_string(path).with_context(msg)?;
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
|
@ -168,6 +168,7 @@ macro_rules! ops {
|
||||||
/// * bounds: a comma-separated list of additional type bounds, eg: `bounds = [ P::MyAssociatedType: MyTrait ]`
|
/// * bounds: a comma-separated list of additional type bounds, eg: `bounds = [ P::MyAssociatedType: MyTrait ]`
|
||||||
/// * ops: a comma-separated list of [`OpDecl`]s to provide, eg: `ops = [ op_foo, op_bar ]`
|
/// * ops: a comma-separated list of [`OpDecl`]s to provide, eg: `ops = [ op_foo, op_bar ]`
|
||||||
/// * esm: a comma-separated list of ESM module filenames (see [`include_js_files`]), eg: `esm = [ dir "dir", "my_file.js" ]`
|
/// * esm: a comma-separated list of ESM module filenames (see [`include_js_files`]), eg: `esm = [ dir "dir", "my_file.js" ]`
|
||||||
|
/// * esm_setup_script: see [`ExtensionBuilder::esm_setup_script`]
|
||||||
/// * js: a comma-separated list of JS filenames (see [`include_js_files`]), eg: `js = [ dir "dir", "my_file.js" ]`
|
/// * js: a comma-separated list of JS filenames (see [`include_js_files`]), eg: `js = [ dir "dir", "my_file.js" ]`
|
||||||
/// * config: a structure-like definition for configuration parameters which will be required when initializing this extension, eg: `config = { my_param: Option<usize> }`
|
/// * config: a structure-like definition for configuration parameters which will be required when initializing this extension, eg: `config = { my_param: Option<usize> }`
|
||||||
/// * middleware: an [`OpDecl`] middleware function with the signature `fn (OpDecl) -> OpDecl`
|
/// * middleware: an [`OpDecl`] middleware function with the signature `fn (OpDecl) -> OpDecl`
|
||||||
|
@ -184,8 +185,8 @@ macro_rules! extension {
|
||||||
$(, ops = [ $( $(#[$m:meta])* $( $op:ident )::+ $( < $( $op_param:ident ),* > )? ),+ $(,)? ] )?
|
$(, ops = [ $( $(#[$m:meta])* $( $op:ident )::+ $( < $( $op_param:ident ),* > )? ),+ $(,)? ] )?
|
||||||
$(, esm_entry_point = $esm_entry_point:literal )?
|
$(, esm_entry_point = $esm_entry_point:literal )?
|
||||||
$(, esm = [ $( dir $dir_esm:literal , )? $( $esm:literal ),* $(,)? ] )?
|
$(, esm = [ $( dir $dir_esm:literal , )? $( $esm:literal ),* $(,)? ] )?
|
||||||
|
$(, esm_setup_script = $esm_setup_script:expr )?
|
||||||
$(, js = [ $( dir $dir_js:literal , )? $( $js:literal ),* $(,)? ] )?
|
$(, js = [ $( dir $dir_js:literal , )? $( $js:literal ),* $(,)? ] )?
|
||||||
$(, force_include_js_sources $($force_include_js_sources:block)? )? // dummy variable
|
|
||||||
$(, options = { $( $options_id:ident : $options_type:ty ),* $(,)? } )?
|
$(, options = { $( $options_id:ident : $options_type:ty ),* $(,)? } )?
|
||||||
$(, middleware = $middleware_fn:expr )?
|
$(, middleware = $middleware_fn:expr )?
|
||||||
$(, state = $state_fn:expr )?
|
$(, state = $state_fn:expr )?
|
||||||
|
@ -210,15 +211,21 @@ macro_rules! extension {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
fn with_js(ext: &mut $crate::ExtensionBuilder) {
|
fn with_js(ext: &mut $crate::ExtensionBuilder) {
|
||||||
ext.esm(
|
$( ext.esm(
|
||||||
$crate::include_js_files!( $name $( force_include_js_sources $($force_include_js_sources)?, )? $( $( dir $dir_esm , )? $( $esm , )* )? )
|
$crate::include_js_files!( $name $( dir $dir_esm , )? $( $esm , )* )
|
||||||
);
|
); )?
|
||||||
|
$(
|
||||||
|
ext.esm(vec![ExtensionFileSource {
|
||||||
|
specifier: "ext:setup",
|
||||||
|
code: ExtensionFileSourceCode::IncludedInBinary($esm_setup_script),
|
||||||
|
}]);
|
||||||
|
)?
|
||||||
$(
|
$(
|
||||||
ext.esm_entry_point($esm_entry_point);
|
ext.esm_entry_point($esm_entry_point);
|
||||||
)?
|
)?
|
||||||
ext.js(
|
$( ext.js(
|
||||||
$crate::include_js_files!( $name $( force_include_js_sources $($force_include_js_sources)?, )? $( $( dir $dir_js , )? $( $js , )* )? )
|
$crate::include_js_files!( $name $( dir $dir_js , )? $( $js , )* )
|
||||||
);
|
); )?
|
||||||
}
|
}
|
||||||
|
|
||||||
// If ops were specified, add those ops to the extension.
|
// If ops were specified, add those ops to the extension.
|
||||||
|
@ -278,7 +285,7 @@ macro_rules! extension {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn init_ext $( < $( $param : $type + 'static ),+ > )? ( $( $( $options_id : $options_type ),* )? ) -> $crate::Extension
|
pub fn init_ops_and_esm $( < $( $param : $type + 'static ),+ > )? ( $( $( $options_id : $options_type ),* )? ) -> $crate::Extension
|
||||||
$( where $( $bound : $bound_type ),+ )?
|
$( where $( $bound : $bound_type ),+ )?
|
||||||
{
|
{
|
||||||
let mut ext = Self::ext();
|
let mut ext = Self::ext();
|
||||||
|
@ -289,6 +296,17 @@ macro_rules! extension {
|
||||||
Self::with_customizer(&mut ext);
|
Self::with_customizer(&mut ext);
|
||||||
ext.take()
|
ext.take()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn init_ops $( < $( $param : $type + 'static ),+ > )? ( $( $( $options_id : $options_type ),* )? ) -> $crate::Extension
|
||||||
|
$( where $( $bound : $bound_type ),+ )?
|
||||||
|
{
|
||||||
|
let mut ext = Self::ext();
|
||||||
|
Self::with_ops $( ::< $( $param ),+ > )?(&mut ext);
|
||||||
|
Self::with_state_and_middleware $( ::< $( $param ),+ > )?(&mut ext, $( $( $options_id , )* )? );
|
||||||
|
Self::with_customizer(&mut ext);
|
||||||
|
ext.take()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -331,8 +349,8 @@ macro_rules! extension {
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Extension {
|
pub struct Extension {
|
||||||
pub(crate) name: &'static str,
|
pub(crate) name: &'static str,
|
||||||
js_files: Vec<ExtensionFileSource>,
|
js_files: Option<Vec<ExtensionFileSource>>,
|
||||||
esm_files: Vec<ExtensionFileSource>,
|
esm_files: Option<Vec<ExtensionFileSource>>,
|
||||||
esm_entry_point: Option<&'static str>,
|
esm_entry_point: Option<&'static str>,
|
||||||
ops: Option<Vec<OpDecl>>,
|
ops: Option<Vec<OpDecl>>,
|
||||||
opstate_fn: Option<Box<OpStateFn>>,
|
opstate_fn: Option<Box<OpStateFn>>,
|
||||||
|
@ -388,12 +406,12 @@ impl Extension {
|
||||||
|
|
||||||
/// returns JS source code to be loaded into the isolate (either at snapshotting,
|
/// returns JS source code to be loaded into the isolate (either at snapshotting,
|
||||||
/// or at startup). as a vector of a tuple of the file name, and the source code.
|
/// or at startup). as a vector of a tuple of the file name, and the source code.
|
||||||
pub fn get_js_sources(&self) -> &Vec<ExtensionFileSource> {
|
pub fn get_js_sources(&self) -> Option<&Vec<ExtensionFileSource>> {
|
||||||
&self.js_files
|
self.js_files.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_esm_sources(&self) -> &Vec<ExtensionFileSource> {
|
pub fn get_esm_sources(&self) -> Option<&Vec<ExtensionFileSource>> {
|
||||||
&self.esm_files
|
self.esm_files.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_esm_entry_point(&self) -> Option<&'static str> {
|
pub fn get_esm_entry_point(&self) -> Option<&'static str> {
|
||||||
|
@ -514,11 +532,13 @@ impl ExtensionBuilder {
|
||||||
|
|
||||||
/// Consume the [`ExtensionBuilder`] and return an [`Extension`].
|
/// Consume the [`ExtensionBuilder`] and return an [`Extension`].
|
||||||
pub fn take(self) -> Extension {
|
pub fn take(self) -> Extension {
|
||||||
|
let js_files = Some(self.js);
|
||||||
|
let esm_files = Some(self.esm);
|
||||||
let ops = Some(self.ops);
|
let ops = Some(self.ops);
|
||||||
let deps = Some(self.deps);
|
let deps = Some(self.deps);
|
||||||
Extension {
|
Extension {
|
||||||
js_files: self.js,
|
js_files,
|
||||||
esm_files: self.esm,
|
esm_files,
|
||||||
esm_entry_point: self.esm_entry_point,
|
esm_entry_point: self.esm_entry_point,
|
||||||
ops,
|
ops,
|
||||||
opstate_fn: self.state,
|
opstate_fn: self.state,
|
||||||
|
@ -533,11 +553,13 @@ impl ExtensionBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build(&mut self) -> Extension {
|
pub fn build(&mut self) -> Extension {
|
||||||
|
let js_files = Some(std::mem::take(&mut self.js));
|
||||||
|
let esm_files = Some(std::mem::take(&mut self.esm));
|
||||||
let ops = Some(std::mem::take(&mut self.ops));
|
let ops = Some(std::mem::take(&mut self.ops));
|
||||||
let deps = Some(std::mem::take(&mut self.deps));
|
let deps = Some(std::mem::take(&mut self.deps));
|
||||||
Extension {
|
Extension {
|
||||||
js_files: std::mem::take(&mut self.js),
|
js_files,
|
||||||
esm_files: std::mem::take(&mut self.esm),
|
esm_files,
|
||||||
esm_entry_point: self.esm_entry_point.take(),
|
esm_entry_point: self.esm_entry_point.take(),
|
||||||
ops,
|
ops,
|
||||||
opstate_fn: self.state.take(),
|
opstate_fn: self.state.take(),
|
||||||
|
@ -586,58 +608,54 @@ impl ExtensionBuilder {
|
||||||
/// - "ext:my_extension/js/01_hello.js"
|
/// - "ext:my_extension/js/01_hello.js"
|
||||||
/// - "ext:my_extension/js/02_goodbye.js"
|
/// - "ext:my_extension/js/02_goodbye.js"
|
||||||
/// ```
|
/// ```
|
||||||
#[cfg(all(
|
#[cfg(not(feature = "include_js_files_for_snapshotting"))]
|
||||||
feature = "exclude_js_sources",
|
|
||||||
not(feature = "runtime_js_sources"),
|
|
||||||
))]
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! include_js_files {
|
macro_rules! include_js_files {
|
||||||
($name:ident $(dir $dir:literal,)? $($file:literal,)*) => {
|
($name:ident dir $dir:literal, $($file:literal,)+) => {
|
||||||
vec![]
|
vec![
|
||||||
|
$($crate::ExtensionFileSource {
|
||||||
|
specifier: concat!("ext:", stringify!($name), "/", $file),
|
||||||
|
code: $crate::ExtensionFileSourceCode::IncludedInBinary(
|
||||||
|
include_str!(concat!($dir, "/", $file)
|
||||||
|
)),
|
||||||
|
},)+
|
||||||
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
($name:ident force_include_js_sources $($dummy:block)?, $($file:literal,)*) => {
|
($name:ident $($file:literal,)+) => {
|
||||||
vec![$($crate::include_js_file!($name $file)),*]
|
vec![
|
||||||
};
|
$($crate::ExtensionFileSource {
|
||||||
|
specifier: concat!("ext:", stringify!($name), "/", $file),
|
||||||
($name:ident force_include_js_sources $($dummy:block)?, dir $dir:literal, $($file:literal,)*) => {
|
code: $crate::ExtensionFileSourceCode::IncludedInBinary(
|
||||||
vec![$($crate::include_js_file!($name dir $dir, $file)),*]
|
include_str!($file)
|
||||||
|
),
|
||||||
|
},)+
|
||||||
|
]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(all(
|
#[cfg(feature = "include_js_files_for_snapshotting")]
|
||||||
feature = "exclude_js_sources",
|
|
||||||
not(feature = "runtime_js_sources"),
|
|
||||||
)))]
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! include_js_files {
|
macro_rules! include_js_files {
|
||||||
($name:ident $(force_include_js_sources $($dummy:block)?,)? $($file:literal,)*) => {
|
($name:ident dir $dir:literal, $($file:literal,)+) => {
|
||||||
vec![$($crate::include_js_file!($name $file)),*]
|
vec![
|
||||||
|
$($crate::ExtensionFileSource {
|
||||||
|
specifier: concat!("ext:", stringify!($name), "/", $file),
|
||||||
|
code: $crate::ExtensionFileSourceCode::LoadedFromFsDuringSnapshot(
|
||||||
|
std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join($dir).join($file)
|
||||||
|
),
|
||||||
|
},)+
|
||||||
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
($name:ident $(force_include_js_sources $($dummy:block)?,)? dir $dir:literal, $($file:literal,)*) => {
|
($name:ident $($file:literal,)+) => {
|
||||||
vec![$($crate::include_js_file!($name dir $dir, $file)),*]
|
vec![
|
||||||
};
|
$($crate::ExtensionFileSource {
|
||||||
}
|
specifier: concat!("ext:", stringify!($name), "/", $file),
|
||||||
|
code: $crate::ExtensionFileSourceCode::LoadedFromFsDuringSnapshot(
|
||||||
#[cfg(not(feature = "runtime_js_sources"))]
|
std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join($file)
|
||||||
#[macro_export]
|
),
|
||||||
macro_rules! include_js_file {
|
},)+
|
||||||
($ext_name:ident $(dir $dir:literal,)? $file:literal) => {
|
]
|
||||||
$crate::ExtensionFileSource {
|
|
||||||
specifier: concat!("ext:", stringify!($ext_name), "/", $file),
|
|
||||||
code: $crate::ExtensionFileSourceCode::IncludedInBinary(include_str!(concat!($($dir, "/",)? $file))),
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "runtime_js_sources")]
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! include_js_file {
|
|
||||||
($ext_name:ident $(dir $dir:literal,)? $file:literal) => {
|
|
||||||
$crate::ExtensionFileSource {
|
|
||||||
specifier: concat!("ext:", stringify!($ext_name), "/", $file),
|
|
||||||
code: $crate::ExtensionFileSourceCode::LoadAtRuntime(std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))$(.join($dir))?.join($file)),
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,6 +119,7 @@ impl ExtModuleLoader {
|
||||||
extensions
|
extensions
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|e| e.get_esm_sources())
|
.flat_map(|e| e.get_esm_sources())
|
||||||
|
.flatten()
|
||||||
.map(|s| (s.specifier.to_string(), s.clone())),
|
.map(|s| (s.specifier.to_string(), s.clone())),
|
||||||
);
|
);
|
||||||
ExtModuleLoader {
|
ExtModuleLoader {
|
||||||
|
@ -178,6 +179,29 @@ impl ModuleLoader for ExtModuleLoader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Drop for ExtModuleLoader {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
let sources = self.sources.get_mut();
|
||||||
|
let used_specifiers = self.used_specifiers.get_mut();
|
||||||
|
let unused_modules: Vec<_> = sources
|
||||||
|
.iter()
|
||||||
|
.filter(|(k, _)| !used_specifiers.contains(k.as_str()))
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
if !unused_modules.is_empty() {
|
||||||
|
let mut msg =
|
||||||
|
"Following modules were passed to ExtModuleLoader but never used:\n"
|
||||||
|
.to_string();
|
||||||
|
for m in unused_modules {
|
||||||
|
msg.push_str(" - ");
|
||||||
|
msg.push_str(m.0);
|
||||||
|
msg.push('\n');
|
||||||
|
}
|
||||||
|
panic!("{}", msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Basic file system module loader.
|
/// Basic file system module loader.
|
||||||
///
|
///
|
||||||
/// Note that this loader will **block** event loop
|
/// Note that this loader will **block** event loop
|
||||||
|
|
|
@ -342,7 +342,7 @@ fn test_mods() {
|
||||||
deno_core::extension!(test_ext, ops = [op_test]);
|
deno_core::extension!(test_ext, ops = [op_test]);
|
||||||
|
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
extensions: vec![test_ext::init_ext()],
|
extensions: vec![test_ext::init_ops()],
|
||||||
module_loader: Some(loader),
|
module_loader: Some(loader),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
|
@ -505,7 +505,7 @@ impl JsRuntime {
|
||||||
maybe_load_callback: Option<ExtModuleLoaderCb>,
|
maybe_load_callback: Option<ExtModuleLoaderCb>,
|
||||||
) -> JsRuntime {
|
) -> JsRuntime {
|
||||||
let init_mode = InitMode::from_options(&options);
|
let init_mode = InitMode::from_options(&options);
|
||||||
let (op_state, ops) = Self::create_opstate(&mut options);
|
let (op_state, ops) = Self::create_opstate(&mut options, init_mode);
|
||||||
let op_state = Rc::new(RefCell::new(op_state));
|
let op_state = Rc::new(RefCell::new(op_state));
|
||||||
|
|
||||||
// Collect event-loop middleware
|
// Collect event-loop middleware
|
||||||
|
@ -844,7 +844,8 @@ impl JsRuntime {
|
||||||
for extension in &extensions {
|
for extension in &extensions {
|
||||||
let maybe_esm_entry_point = extension.get_esm_entry_point();
|
let maybe_esm_entry_point = extension.get_esm_entry_point();
|
||||||
|
|
||||||
for file_source in extension.get_esm_sources() {
|
if let Some(esm_files) = extension.get_esm_sources() {
|
||||||
|
for file_source in esm_files {
|
||||||
self
|
self
|
||||||
.load_side_module(
|
.load_side_module(
|
||||||
&ModuleSpecifier::parse(file_source.specifier)?,
|
&ModuleSpecifier::parse(file_source.specifier)?,
|
||||||
|
@ -852,18 +853,21 @@ impl JsRuntime {
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(entry_point) = maybe_esm_entry_point {
|
if let Some(entry_point) = maybe_esm_entry_point {
|
||||||
esm_entrypoints.push(entry_point);
|
esm_entrypoints.push(entry_point);
|
||||||
}
|
}
|
||||||
|
|
||||||
for file_source in extension.get_js_sources() {
|
if let Some(js_files) = extension.get_js_sources() {
|
||||||
|
for file_source in js_files {
|
||||||
realm.execute_script(
|
realm.execute_script(
|
||||||
self.v8_isolate(),
|
self.v8_isolate(),
|
||||||
file_source.specifier,
|
file_source.specifier,
|
||||||
file_source.load()?,
|
file_source.load()?,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if extension.is_core {
|
if extension.is_core {
|
||||||
self.init_cbs(realm);
|
self.init_cbs(realm);
|
||||||
|
@ -880,16 +884,6 @@ impl JsRuntime {
|
||||||
panic!("{} not present in the module map", specifier)
|
panic!("{} not present in the module map", specifier)
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
{
|
|
||||||
let module_map_rc = self.module_map.clone();
|
|
||||||
let module_map = module_map_rc.borrow();
|
|
||||||
let handle = module_map.handles.get(mod_id).unwrap().clone();
|
|
||||||
let mut scope = realm.handle_scope(self.v8_isolate());
|
|
||||||
let handle = v8::Local::new(&mut scope, handle);
|
|
||||||
if handle.get_status() == v8::ModuleStatus::Evaluated {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let receiver = self.mod_evaluate(mod_id);
|
let receiver = self.mod_evaluate(mod_id);
|
||||||
self.run_event_loop(false).await?;
|
self.run_event_loop(false).await?;
|
||||||
receiver
|
receiver
|
||||||
|
@ -973,11 +967,20 @@ impl JsRuntime {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initializes ops of provided Extensions
|
/// Initializes ops of provided Extensions
|
||||||
fn create_opstate(options: &mut RuntimeOptions) -> (OpState, Vec<OpDecl>) {
|
fn create_opstate(
|
||||||
|
options: &mut RuntimeOptions,
|
||||||
|
init_mode: InitMode,
|
||||||
|
) -> (OpState, Vec<OpDecl>) {
|
||||||
// Add built-in extension
|
// Add built-in extension
|
||||||
|
if init_mode == InitMode::FromSnapshot {
|
||||||
options
|
options
|
||||||
.extensions
|
.extensions
|
||||||
.insert(0, crate::ops_builtin::core::init_ext());
|
.insert(0, crate::ops_builtin::core::init_ops());
|
||||||
|
} else {
|
||||||
|
options
|
||||||
|
.extensions
|
||||||
|
.insert(0, crate::ops_builtin::core::init_ops_and_esm());
|
||||||
|
}
|
||||||
|
|
||||||
let ops = Self::collect_ops(&mut options.extensions);
|
let ops = Self::collect_ops(&mut options.extensions);
|
||||||
|
|
||||||
|
|
|
@ -250,7 +250,7 @@ mod tests {
|
||||||
test: &'static str,
|
test: &'static str,
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
extensions: vec![testing::init_ext()],
|
extensions: vec![testing::init_ops_and_esm()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
runtime
|
runtime
|
||||||
|
|
|
@ -57,9 +57,12 @@ pub fn create_snapshot(
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|e| vec![e.get_esm_sources(), e.get_js_sources()])
|
.flat_map(|e| vec![e.get_esm_sources(), e.get_js_sources()])
|
||||||
.flatten()
|
.flatten()
|
||||||
|
.flatten()
|
||||||
{
|
{
|
||||||
use crate::ExtensionFileSourceCode;
|
use crate::ExtensionFileSourceCode;
|
||||||
if let ExtensionFileSourceCode::LoadAtRuntime(path) = &source.code {
|
if let ExtensionFileSourceCode::LoadedFromFsDuringSnapshot(path) =
|
||||||
|
&source.code
|
||||||
|
{
|
||||||
files_loaded_during_snapshot.push(path.clone());
|
files_loaded_during_snapshot.push(path.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ fn setup(mode: Mode) -> (JsRuntime, Arc<AtomicUsize>) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
extensions: vec![test_ext::init_ext(mode, dispatch_count.clone())],
|
extensions: vec![test_ext::init_ops(mode, dispatch_count.clone())],
|
||||||
get_error_class_fn: Some(&|error| {
|
get_error_class_fn: Some(&|error| {
|
||||||
crate::error::get_custom_error_class(error).unwrap()
|
crate::error::get_custom_error_class(error).unwrap()
|
||||||
}),
|
}),
|
||||||
|
@ -515,7 +515,7 @@ async fn test_error_builder() {
|
||||||
|
|
||||||
deno_core::extension!(test_ext, ops = [op_err]);
|
deno_core::extension!(test_ext, ops = [op_err]);
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
extensions: vec![test_ext::init_ext()],
|
extensions: vec![test_ext::init_ops()],
|
||||||
get_error_class_fn: Some(&get_error_class_name),
|
get_error_class_fn: Some(&get_error_class_name),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
@ -1114,7 +1114,7 @@ async fn test_error_context() {
|
||||||
|
|
||||||
deno_core::extension!(test_ext, ops = [op_err_sync, op_err_async]);
|
deno_core::extension!(test_ext, ops = [op_err_sync, op_err_async]);
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
extensions: vec![test_ext::init_ext()],
|
extensions: vec![test_ext::init_ops()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1274,7 +1274,7 @@ async fn test_async_opstate_borrow() {
|
||||||
state = |state| state.put(InnerState(42))
|
state = |state| state.put(InnerState(42))
|
||||||
);
|
);
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
extensions: vec![test_ext::init_ext()],
|
extensions: vec![test_ext::init_ops()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1305,7 +1305,7 @@ async fn test_sync_op_serialize_object_with_numbers_as_keys() {
|
||||||
ops = [op_sync_serialize_object_with_numbers_as_keys]
|
ops = [op_sync_serialize_object_with_numbers_as_keys]
|
||||||
);
|
);
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
extensions: vec![test_ext::init_ext()],
|
extensions: vec![test_ext::init_ops()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1347,7 +1347,7 @@ async fn test_async_op_serialize_object_with_numbers_as_keys() {
|
||||||
ops = [op_async_serialize_object_with_numbers_as_keys]
|
ops = [op_async_serialize_object_with_numbers_as_keys]
|
||||||
);
|
);
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
extensions: vec![test_ext::init_ext()],
|
extensions: vec![test_ext::init_ops()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1383,7 +1383,7 @@ async fn test_set_macrotask_callback_set_next_tick_callback() {
|
||||||
|
|
||||||
deno_core::extension!(test_ext, ops = [op_async_sleep]);
|
deno_core::extension!(test_ext, ops = [op_async_sleep]);
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
extensions: vec![test_ext::init_ext()],
|
extensions: vec![test_ext::init_ops()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1438,7 +1438,7 @@ fn test_has_tick_scheduled() {
|
||||||
|
|
||||||
deno_core::extension!(test_ext, ops = [op_macrotask, op_next_tick]);
|
deno_core::extension!(test_ext, ops = [op_macrotask, op_next_tick]);
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
extensions: vec![test_ext::init_ext()],
|
extensions: vec![test_ext::init_ops()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1578,7 +1578,7 @@ async fn test_set_promise_reject_callback() {
|
||||||
|
|
||||||
deno_core::extension!(test_ext, ops = [op_promise_reject]);
|
deno_core::extension!(test_ext, ops = [op_promise_reject]);
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
extensions: vec![test_ext::init_ext()],
|
extensions: vec![test_ext::init_ops()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1717,7 +1717,7 @@ async fn test_set_promise_reject_callback_top_level_await() {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
extensions: vec![test_ext::init_ext()],
|
extensions: vec![test_ext::init_ops()],
|
||||||
module_loader: Some(Rc::new(ModsLoader)),
|
module_loader: Some(Rc::new(ModsLoader)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
@ -1742,7 +1742,7 @@ fn test_op_return_serde_v8_error() {
|
||||||
|
|
||||||
deno_core::extension!(test_ext, ops = [op_err]);
|
deno_core::extension!(test_ext, ops = [op_err]);
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
extensions: vec![test_ext::init_ext()],
|
extensions: vec![test_ext::init_ops()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
assert!(runtime
|
assert!(runtime
|
||||||
|
@ -1767,7 +1767,7 @@ fn test_op_high_arity() {
|
||||||
|
|
||||||
deno_core::extension!(test_ext, ops = [op_add_4]);
|
deno_core::extension!(test_ext, ops = [op_add_4]);
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
extensions: vec![test_ext::init_ext()],
|
extensions: vec![test_ext::init_ops()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
let r = runtime
|
let r = runtime
|
||||||
|
@ -1790,7 +1790,7 @@ fn test_op_disabled() {
|
||||||
|
|
||||||
deno_core::extension!(test_ext, ops_fn = ops);
|
deno_core::extension!(test_ext, ops_fn = ops);
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
extensions: vec![test_ext::init_ext()],
|
extensions: vec![test_ext::init_ops()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
let err = runtime
|
let err = runtime
|
||||||
|
@ -1817,7 +1817,7 @@ fn test_op_detached_buffer() {
|
||||||
|
|
||||||
deno_core::extension!(test_ext, ops = [op_sum_take, op_boomerang]);
|
deno_core::extension!(test_ext, ops = [op_sum_take, op_boomerang]);
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
extensions: vec![test_ext::init_ext()],
|
extensions: vec![test_ext::init_ops()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1886,7 +1886,7 @@ fn test_op_unstable_disabling() {
|
||||||
middleware = |op| if op.is_unstable { op.disable() } else { op }
|
middleware = |op| if op.is_unstable { op.disable() } else { op }
|
||||||
);
|
);
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
extensions: vec![test_ext::init_ext()],
|
extensions: vec![test_ext::init_ops()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
runtime
|
runtime
|
||||||
|
@ -1934,7 +1934,7 @@ fn js_realm_init() {
|
||||||
|
|
||||||
deno_core::extension!(test_ext, ops = [op_test]);
|
deno_core::extension!(test_ext, ops = [op_test]);
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
extensions: vec![test_ext::init_ext()],
|
extensions: vec![test_ext::init_ops()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
let realm = runtime.create_realm().unwrap();
|
let realm = runtime.create_realm().unwrap();
|
||||||
|
@ -1963,7 +1963,7 @@ fn js_realm_init_snapshot() {
|
||||||
deno_core::extension!(test_ext, ops = [op_test]);
|
deno_core::extension!(test_ext, ops = [op_test]);
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
startup_snapshot: Some(Snapshot::Boxed(snapshot)),
|
startup_snapshot: Some(Snapshot::Boxed(snapshot)),
|
||||||
extensions: vec![test_ext::init_ext()],
|
extensions: vec![test_ext::init_ops()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
let realm = runtime.create_realm().unwrap();
|
let realm = runtime.create_realm().unwrap();
|
||||||
|
@ -1993,7 +1993,7 @@ fn js_realm_sync_ops() {
|
||||||
|
|
||||||
deno_core::extension!(test_ext, ops = [op_test]);
|
deno_core::extension!(test_ext, ops = [op_test]);
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
extensions: vec![test_ext::init_ext()],
|
extensions: vec![test_ext::init_ops()],
|
||||||
get_error_class_fn: Some(&|error| {
|
get_error_class_fn: Some(&|error| {
|
||||||
crate::error::get_custom_error_class(error).unwrap()
|
crate::error::get_custom_error_class(error).unwrap()
|
||||||
}),
|
}),
|
||||||
|
@ -2041,7 +2041,7 @@ async fn js_realm_async_ops() {
|
||||||
|
|
||||||
deno_core::extension!(test_ext, ops = [op_test]);
|
deno_core::extension!(test_ext, ops = [op_test]);
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
extensions: vec![test_ext::init_ext()],
|
extensions: vec![test_ext::init_ops()],
|
||||||
get_error_class_fn: Some(&|error| {
|
get_error_class_fn: Some(&|error| {
|
||||||
crate::error::get_custom_error_class(error).unwrap()
|
crate::error::get_custom_error_class(error).unwrap()
|
||||||
}),
|
}),
|
||||||
|
@ -2118,7 +2118,7 @@ async fn js_realm_gc() {
|
||||||
|
|
||||||
deno_core::extension!(test_ext, ops = [op_pending]);
|
deno_core::extension!(test_ext, ops = [op_pending]);
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
extensions: vec![test_ext::init_ext()],
|
extensions: vec![test_ext::init_ops()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2165,7 +2165,7 @@ async fn js_realm_ref_unref_ops() {
|
||||||
|
|
||||||
deno_core::extension!(test_ext, ops = [op_pending]);
|
deno_core::extension!(test_ext, ops = [op_pending]);
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
extensions: vec![test_ext::init_ext()],
|
extensions: vec![test_ext::init_ops()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2265,7 +2265,7 @@ fn duplicate_op_names() {
|
||||||
|
|
||||||
deno_core::extension!(test_ext, ops = [a::op_test, op_test]);
|
deno_core::extension!(test_ext, ops = [a::op_test, op_test]);
|
||||||
JsRuntime::new(RuntimeOptions {
|
JsRuntime::new(RuntimeOptions {
|
||||||
extensions: vec![test_ext::init_ext()],
|
extensions: vec![test_ext::init_ops()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2284,7 +2284,7 @@ fn ops_in_js_have_proper_names() {
|
||||||
|
|
||||||
deno_core::extension!(test_ext, ops = [op_test_sync, op_test_async]);
|
deno_core::extension!(test_ext, ops = [op_test_sync, op_test_async]);
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
extensions: vec![test_ext::init_ext()],
|
extensions: vec![test_ext::init_ops()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ use crate::ops::*;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::OpState;
|
use deno_core::OpState;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
use std::convert::From;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
|
|
@ -1034,7 +1034,7 @@ mod tests {
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
extensions: vec![test_ext::init_ext()],
|
extensions: vec![test_ext::init_ops()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@ use deno_core::ExtensionFileSourceCode;
|
||||||
|
|
||||||
fn setup() -> Vec<Extension> {
|
fn setup() -> Vec<Extension> {
|
||||||
vec![
|
vec![
|
||||||
deno_webidl::deno_webidl::init_ext(),
|
deno_webidl::deno_webidl::init_ops_and_esm(),
|
||||||
deno_url::deno_url::init_ext(),
|
deno_url::deno_url::init_ops_and_esm(),
|
||||||
Extension::builder("bench_setup")
|
Extension::builder("bench_setup")
|
||||||
.esm(vec![ExtensionFileSource {
|
.esm(vec![ExtensionFileSource {
|
||||||
specifier: "ext:bench_setup/setup",
|
specifier: "ext:bench_setup/setup",
|
||||||
|
|
|
@ -24,10 +24,13 @@ impl deno_web::TimersPermission for Permissions {
|
||||||
|
|
||||||
fn setup() -> Vec<Extension> {
|
fn setup() -> Vec<Extension> {
|
||||||
vec![
|
vec![
|
||||||
deno_webidl::deno_webidl::init_ext(),
|
deno_webidl::deno_webidl::init_ops_and_esm(),
|
||||||
deno_url::deno_url::init_ext(),
|
deno_url::deno_url::init_ops_and_esm(),
|
||||||
deno_console::deno_console::init_ext(),
|
deno_console::deno_console::init_ops_and_esm(),
|
||||||
deno_web::deno_web::init_ext::<Permissions>(BlobStore::default(), None),
|
deno_web::deno_web::init_ops_and_esm::<Permissions>(
|
||||||
|
BlobStore::default(),
|
||||||
|
None,
|
||||||
|
),
|
||||||
Extension::builder("bench_setup")
|
Extension::builder("bench_setup")
|
||||||
.esm(vec![ExtensionFileSource {
|
.esm(vec![ExtensionFileSource {
|
||||||
specifier: "ext:bench_setup/setup",
|
specifier: "ext:bench_setup/setup",
|
||||||
|
|
|
@ -22,10 +22,10 @@ impl deno_web::TimersPermission for Permissions {
|
||||||
|
|
||||||
fn setup() -> Vec<Extension> {
|
fn setup() -> Vec<Extension> {
|
||||||
vec![
|
vec![
|
||||||
deno_webidl::deno_webidl::init_ext(),
|
deno_webidl::deno_webidl::init_ops_and_esm(),
|
||||||
deno_url::deno_url::init_ext(),
|
deno_url::deno_url::init_ops_and_esm(),
|
||||||
deno_console::deno_console::init_ext(),
|
deno_console::deno_console::init_ops_and_esm(),
|
||||||
deno_web::deno_web::init_ext::<Permissions>(BlobStore::default(), None),
|
deno_web::deno_web::init_ops_and_esm::<Permissions>(BlobStore::default(), None),
|
||||||
Extension::builder("bench_setup")
|
Extension::builder("bench_setup")
|
||||||
.esm(vec![
|
.esm(vec![
|
||||||
ExtensionFileSource {
|
ExtensionFileSource {
|
||||||
|
|
|
@ -11,7 +11,7 @@ use deno_core::ExtensionFileSourceCode;
|
||||||
|
|
||||||
fn setup() -> Vec<Extension> {
|
fn setup() -> Vec<Extension> {
|
||||||
vec![
|
vec![
|
||||||
deno_webidl::deno_webidl::init_ext(),
|
deno_webidl::deno_webidl::init_ops_and_esm(),
|
||||||
Extension::builder("deno_webidl_bench")
|
Extension::builder("deno_webidl_bench")
|
||||||
.esm(vec![ExtensionFileSource {
|
.esm(vec![ExtensionFileSource {
|
||||||
specifier: "ext:deno_webidl_bench/setup.js",
|
specifier: "ext:deno_webidl_bench/setup.js",
|
||||||
|
|
|
@ -14,8 +14,15 @@ description = "Provides the deno runtime library"
|
||||||
docsrs = []
|
docsrs = []
|
||||||
# A feature that disables creation of startup snapshot during in the build script.
|
# A feature that disables creation of startup snapshot during in the build script.
|
||||||
dont_create_runtime_snapshot = []
|
dont_create_runtime_snapshot = []
|
||||||
# Enable to exclude `js/99_main.js` from the generated snapshot.
|
# A feature that changes how startup snapshot is generated, that allows
|
||||||
exclude_js_main_from_snapshot = []
|
# extending it in embedder crates.
|
||||||
|
snapshot_from_snapshot = []
|
||||||
|
# A feature that disables embedding of the JavaScript source files in the binary.
|
||||||
|
# With this feature enabled, the sources must be consumed during build time,
|
||||||
|
# by creating a startup snapshot.
|
||||||
|
include_js_files_for_snapshotting = [
|
||||||
|
"deno_core/include_js_files_for_snapshotting",
|
||||||
|
]
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "deno_runtime"
|
name = "deno_runtime"
|
||||||
|
@ -34,7 +41,7 @@ deno_ast.workspace = true
|
||||||
deno_broadcast_channel.workspace = true
|
deno_broadcast_channel.workspace = true
|
||||||
deno_cache.workspace = true
|
deno_cache.workspace = true
|
||||||
deno_console.workspace = true
|
deno_console.workspace = true
|
||||||
deno_core = { workspace = true, features = ["runtime_js_sources"] }
|
deno_core.workspace = true
|
||||||
deno_crypto.workspace = true
|
deno_crypto.workspace = true
|
||||||
deno_fetch.workspace = true
|
deno_fetch.workspace = true
|
||||||
deno_ffi.workspace = true
|
deno_ffi.workspace = true
|
||||||
|
|
|
@ -264,22 +264,22 @@ mod startup_snapshot {
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(not(feature = "exclude_js_main_from_snapshot"))]
|
#[cfg(not(feature = "snapshot_from_snapshot"))]
|
||||||
deno_core::extension!(
|
deno_core::extension!(
|
||||||
runtime_main,
|
runtime_main,
|
||||||
deps = [runtime],
|
deps = [runtime],
|
||||||
customizer = |ext: &mut deno_core::ExtensionBuilder| {
|
customizer = |ext: &mut deno_core::ExtensionBuilder| {
|
||||||
ext.esm(vec![ExtensionFileSource {
|
ext.esm(vec![ExtensionFileSource {
|
||||||
specifier: "ext:runtime_main/js/99_main.js",
|
specifier: "ext:runtime_main/js/99_main.js",
|
||||||
code: ExtensionFileSourceCode::LoadAtRuntime(PathBuf::from(
|
code: deno_core::ExtensionFileSourceCode::IncludedInBinary(
|
||||||
"js/99_main.js",
|
include_str!("js/99_main.js"),
|
||||||
)),
|
),
|
||||||
}]);
|
}]);
|
||||||
ext.esm_entry_point("ext:runtime_main/js/99_main.js");
|
ext.esm_entry_point("ext:runtime_main/js/99_main.js");
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "exclude_js_main_from_snapshot")]
|
#[cfg(feature = "snapshot_from_snapshot")]
|
||||||
deno_core::extension!(
|
deno_core::extension!(
|
||||||
runtime_main,
|
runtime_main,
|
||||||
deps = [runtime],
|
deps = [runtime],
|
||||||
|
@ -294,45 +294,47 @@ mod startup_snapshot {
|
||||||
// `runtime/worker.rs`, `runtime/web_worker.rs` and `cli/build.rs`!
|
// `runtime/worker.rs`, `runtime/web_worker.rs` and `cli/build.rs`!
|
||||||
let fs = std::sync::Arc::new(deno_fs::RealFs);
|
let fs = std::sync::Arc::new(deno_fs::RealFs);
|
||||||
let extensions: Vec<Extension> = vec![
|
let extensions: Vec<Extension> = vec![
|
||||||
deno_webidl::deno_webidl::init_ext(),
|
deno_webidl::deno_webidl::init_ops_and_esm(),
|
||||||
deno_console::deno_console::init_ext(),
|
deno_console::deno_console::init_ops_and_esm(),
|
||||||
deno_url::deno_url::init_ext(),
|
deno_url::deno_url::init_ops_and_esm(),
|
||||||
deno_web::deno_web::init_ext::<Permissions>(
|
deno_web::deno_web::init_ops_and_esm::<Permissions>(
|
||||||
deno_web::BlobStore::default(),
|
deno_web::BlobStore::default(),
|
||||||
Default::default(),
|
Default::default(),
|
||||||
),
|
),
|
||||||
deno_fetch::deno_fetch::init_ext::<Permissions>(Default::default()),
|
deno_fetch::deno_fetch::init_ops_and_esm::<Permissions>(
|
||||||
deno_cache::deno_cache::init_ext::<SqliteBackedCache>(None),
|
Default::default(),
|
||||||
deno_websocket::deno_websocket::init_ext::<Permissions>(
|
),
|
||||||
|
deno_cache::deno_cache::init_ops_and_esm::<SqliteBackedCache>(None),
|
||||||
|
deno_websocket::deno_websocket::init_ops_and_esm::<Permissions>(
|
||||||
"".to_owned(),
|
"".to_owned(),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
deno_webstorage::deno_webstorage::init_ext(None),
|
deno_webstorage::deno_webstorage::init_ops_and_esm(None),
|
||||||
deno_crypto::deno_crypto::init_ext(None),
|
deno_crypto::deno_crypto::init_ops_and_esm(None),
|
||||||
deno_broadcast_channel::deno_broadcast_channel::init_ext(
|
deno_broadcast_channel::deno_broadcast_channel::init_ops_and_esm(
|
||||||
deno_broadcast_channel::InMemoryBroadcastChannel::default(),
|
deno_broadcast_channel::InMemoryBroadcastChannel::default(),
|
||||||
false, // No --unstable.
|
false, // No --unstable.
|
||||||
),
|
),
|
||||||
deno_ffi::deno_ffi::init_ext::<Permissions>(false),
|
deno_ffi::deno_ffi::init_ops_and_esm::<Permissions>(false),
|
||||||
deno_net::deno_net::init_ext::<Permissions>(
|
deno_net::deno_net::init_ops_and_esm::<Permissions>(
|
||||||
None, false, // No --unstable.
|
None, false, // No --unstable.
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
deno_tls::deno_tls::init_ext(),
|
deno_tls::deno_tls::init_ops_and_esm(),
|
||||||
deno_kv::deno_kv::init_ext(
|
deno_kv::deno_kv::init_ops_and_esm(
|
||||||
deno_kv::sqlite::SqliteDbHandler::<Permissions>::new(None),
|
deno_kv::sqlite::SqliteDbHandler::<Permissions>::new(None),
|
||||||
false, // No --unstable
|
false, // No --unstable
|
||||||
),
|
),
|
||||||
deno_napi::deno_napi::init_ext::<Permissions>(),
|
deno_napi::deno_napi::init_ops_and_esm::<Permissions>(),
|
||||||
deno_http::deno_http::init_ext::<DefaultHttpPropertyExtractor>(),
|
deno_http::deno_http::init_ops_and_esm::<DefaultHttpPropertyExtractor>(),
|
||||||
deno_io::deno_io::init_ext(Default::default()),
|
deno_io::deno_io::init_ops_and_esm(Default::default()),
|
||||||
deno_fs::deno_fs::init_ext::<Permissions>(false, fs.clone()),
|
deno_fs::deno_fs::init_ops_and_esm::<Permissions>(false, fs.clone()),
|
||||||
runtime::init_ext(),
|
runtime::init_ops_and_esm(),
|
||||||
// FIXME(bartlomieju): these extensions are specified last, because they
|
// FIXME(bartlomieju): these extensions are specified last, because they
|
||||||
// depend on `runtime`, even though it should be other way around
|
// depend on `runtime`, even though it should be other way around
|
||||||
deno_node::deno_node::init_ext::<Permissions>(None, fs),
|
deno_node::deno_node::init_ops_and_esm::<Permissions>(None, fs),
|
||||||
runtime_main::init_ext(),
|
runtime_main::init_ops_and_esm(),
|
||||||
];
|
];
|
||||||
|
|
||||||
let output = create_snapshot(CreateSnapshotOptions {
|
let output = create_snapshot(CreateSnapshotOptions {
|
||||||
|
|
|
@ -26,7 +26,7 @@ async fn main() -> Result<(), AnyError> {
|
||||||
PermissionsContainer::allow_all(),
|
PermissionsContainer::allow_all(),
|
||||||
WorkerOptions {
|
WorkerOptions {
|
||||||
module_loader: Rc::new(FsModuleLoader),
|
module_loader: Rc::new(FsModuleLoader),
|
||||||
extensions: vec![hello_runtime::init_ext()],
|
extensions: vec![hello_runtime::init_ops_and_esm()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -28,7 +28,7 @@ async fn main() -> Result<(), AnyError> {
|
||||||
PermissionsContainer::allow_all(),
|
PermissionsContainer::allow_all(),
|
||||||
WorkerOptions {
|
WorkerOptions {
|
||||||
module_loader: Rc::new(FsModuleLoader),
|
module_loader: Rc::new(FsModuleLoader),
|
||||||
extensions: vec![hello_runtime::init_ext()],
|
extensions: vec![hello_runtime::init_ops()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -14,8 +14,9 @@ pub fn deno_isolate_init() -> Snapshot {
|
||||||
Snapshot::Static(RUNTIME_SNAPSHOT)
|
Snapshot::Static(RUNTIME_SNAPSHOT)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Depends on LTO to be excluded from production binaries if unused.
|
#[cfg(not(feature = "include_js_files_for_snapshotting"))]
|
||||||
pub static SOURCE_CODE_FOR_99_MAIN_JS: &str = include_str!("js/99_main.js");
|
pub static SOURCE_CODE_FOR_99_MAIN_JS: &str = include_str!("js/99_main.js");
|
||||||
|
|
||||||
|
#[cfg(feature = "include_js_files_for_snapshotting")]
|
||||||
pub static PATH_FOR_99_MAIN_JS: &str =
|
pub static PATH_FOR_99_MAIN_JS: &str =
|
||||||
concat!(env!("CARGO_MANIFEST_DIR"), "/js/99_main.js");
|
concat!(env!("CARGO_MANIFEST_DIR"), "/js/99_main.js");
|
||||||
|
|
|
@ -398,14 +398,14 @@ impl WebWorker {
|
||||||
// `runtime/build.rs`, `runtime/worker.rs` and `cli/build.rs`!
|
// `runtime/build.rs`, `runtime/worker.rs` and `cli/build.rs`!
|
||||||
let mut extensions: Vec<Extension> = vec![
|
let mut extensions: Vec<Extension> = vec![
|
||||||
// Web APIs
|
// Web APIs
|
||||||
deno_webidl::deno_webidl::init_ext(),
|
deno_webidl::deno_webidl::init_ops(),
|
||||||
deno_console::deno_console::init_ext(),
|
deno_console::deno_console::init_ops(),
|
||||||
deno_url::deno_url::init_ext(),
|
deno_url::deno_url::init_ops(),
|
||||||
deno_web::deno_web::init_ext::<PermissionsContainer>(
|
deno_web::deno_web::init_ops::<PermissionsContainer>(
|
||||||
options.blob_store.clone(),
|
options.blob_store.clone(),
|
||||||
Some(main_module.clone()),
|
Some(main_module.clone()),
|
||||||
),
|
),
|
||||||
deno_fetch::deno_fetch::init_ext::<PermissionsContainer>(
|
deno_fetch::deno_fetch::init_ops::<PermissionsContainer>(
|
||||||
deno_fetch::Options {
|
deno_fetch::Options {
|
||||||
user_agent: options.bootstrap.user_agent.clone(),
|
user_agent: options.bootstrap.user_agent.clone(),
|
||||||
root_cert_store_provider: options.root_cert_store_provider.clone(),
|
root_cert_store_provider: options.root_cert_store_provider.clone(),
|
||||||
|
@ -416,57 +416,57 @@ impl WebWorker {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
deno_cache::deno_cache::init_ext::<SqliteBackedCache>(create_cache),
|
deno_cache::deno_cache::init_ops::<SqliteBackedCache>(create_cache),
|
||||||
deno_websocket::deno_websocket::init_ext::<PermissionsContainer>(
|
deno_websocket::deno_websocket::init_ops::<PermissionsContainer>(
|
||||||
options.bootstrap.user_agent.clone(),
|
options.bootstrap.user_agent.clone(),
|
||||||
options.root_cert_store_provider.clone(),
|
options.root_cert_store_provider.clone(),
|
||||||
options.unsafely_ignore_certificate_errors.clone(),
|
options.unsafely_ignore_certificate_errors.clone(),
|
||||||
),
|
),
|
||||||
deno_webstorage::deno_webstorage::init_ext(None).disable(),
|
deno_webstorage::deno_webstorage::init_ops(None).disable(),
|
||||||
deno_crypto::deno_crypto::init_ext(options.seed),
|
deno_crypto::deno_crypto::init_ops(options.seed),
|
||||||
deno_broadcast_channel::deno_broadcast_channel::init_ext(
|
deno_broadcast_channel::deno_broadcast_channel::init_ops(
|
||||||
options.broadcast_channel.clone(),
|
options.broadcast_channel.clone(),
|
||||||
unstable,
|
unstable,
|
||||||
),
|
),
|
||||||
deno_ffi::deno_ffi::init_ext::<PermissionsContainer>(unstable),
|
deno_ffi::deno_ffi::init_ops::<PermissionsContainer>(unstable),
|
||||||
deno_net::deno_net::init_ext::<PermissionsContainer>(
|
deno_net::deno_net::init_ops::<PermissionsContainer>(
|
||||||
options.root_cert_store_provider.clone(),
|
options.root_cert_store_provider.clone(),
|
||||||
unstable,
|
unstable,
|
||||||
options.unsafely_ignore_certificate_errors.clone(),
|
options.unsafely_ignore_certificate_errors.clone(),
|
||||||
),
|
),
|
||||||
deno_tls::deno_tls::init_ext(),
|
deno_tls::deno_tls::init_ops(),
|
||||||
deno_kv::deno_kv::init_ext(
|
deno_kv::deno_kv::init_ops(
|
||||||
SqliteDbHandler::<PermissionsContainer>::new(None),
|
SqliteDbHandler::<PermissionsContainer>::new(None),
|
||||||
unstable,
|
unstable,
|
||||||
),
|
),
|
||||||
deno_napi::deno_napi::init_ext::<PermissionsContainer>(),
|
deno_napi::deno_napi::init_ops::<PermissionsContainer>(),
|
||||||
deno_http::deno_http::init_ext::<DefaultHttpPropertyExtractor>(),
|
deno_http::deno_http::init_ops::<DefaultHttpPropertyExtractor>(),
|
||||||
deno_io::deno_io::init_ext(Some(options.stdio)),
|
deno_io::deno_io::init_ops(Some(options.stdio)),
|
||||||
deno_fs::deno_fs::init_ext::<PermissionsContainer>(
|
deno_fs::deno_fs::init_ops::<PermissionsContainer>(
|
||||||
unstable,
|
unstable,
|
||||||
options.fs.clone(),
|
options.fs.clone(),
|
||||||
),
|
),
|
||||||
deno_node::deno_node::init_ext::<PermissionsContainer>(
|
deno_node::deno_node::init_ops::<PermissionsContainer>(
|
||||||
options.npm_resolver,
|
options.npm_resolver,
|
||||||
options.fs,
|
options.fs,
|
||||||
),
|
),
|
||||||
// Runtime ops that are always initialized for WebWorkers
|
// Runtime ops that are always initialized for WebWorkers
|
||||||
ops::web_worker::deno_web_worker::init_ext(),
|
ops::web_worker::deno_web_worker::init_ops(),
|
||||||
ops::runtime::deno_runtime::init_ext(main_module.clone()),
|
ops::runtime::deno_runtime::init_ops(main_module.clone()),
|
||||||
ops::worker_host::deno_worker_host::init_ext(
|
ops::worker_host::deno_worker_host::init_ops(
|
||||||
options.create_web_worker_cb.clone(),
|
options.create_web_worker_cb.clone(),
|
||||||
options.preload_module_cb.clone(),
|
options.preload_module_cb.clone(),
|
||||||
options.pre_execute_module_cb.clone(),
|
options.pre_execute_module_cb.clone(),
|
||||||
options.format_js_error_fn.clone(),
|
options.format_js_error_fn.clone(),
|
||||||
),
|
),
|
||||||
ops::fs_events::deno_fs_events::init_ext(),
|
ops::fs_events::deno_fs_events::init_ops(),
|
||||||
ops::os::deno_os_worker::init_ext(),
|
ops::os::deno_os_worker::init_ops(),
|
||||||
ops::permissions::deno_permissions::init_ext(),
|
ops::permissions::deno_permissions::init_ops(),
|
||||||
ops::process::deno_process::init_ext(),
|
ops::process::deno_process::init_ops(),
|
||||||
ops::signal::deno_signal::init_ext(),
|
ops::signal::deno_signal::init_ops(),
|
||||||
ops::tty::deno_tty::init_ext(),
|
ops::tty::deno_tty::init_ops(),
|
||||||
ops::http::deno_http_runtime::init_ext(),
|
ops::http::deno_http_runtime::init_ops(),
|
||||||
deno_permissions_web_worker::init_ext(
|
deno_permissions_web_worker::init_ops(
|
||||||
permissions,
|
permissions,
|
||||||
unstable,
|
unstable,
|
||||||
enable_testing_features,
|
enable_testing_features,
|
||||||
|
|
|
@ -225,14 +225,14 @@ impl MainWorker {
|
||||||
// `runtime/build.rs`, `runtime/web_worker.rs` and `cli/build.rs`!
|
// `runtime/build.rs`, `runtime/web_worker.rs` and `cli/build.rs`!
|
||||||
let mut extensions = vec![
|
let mut extensions = vec![
|
||||||
// Web APIs
|
// Web APIs
|
||||||
deno_webidl::deno_webidl::init_ext(),
|
deno_webidl::deno_webidl::init_ops(),
|
||||||
deno_console::deno_console::init_ext(),
|
deno_console::deno_console::init_ops(),
|
||||||
deno_url::deno_url::init_ext(),
|
deno_url::deno_url::init_ops(),
|
||||||
deno_web::deno_web::init_ext::<PermissionsContainer>(
|
deno_web::deno_web::init_ops::<PermissionsContainer>(
|
||||||
options.blob_store.clone(),
|
options.blob_store.clone(),
|
||||||
options.bootstrap.location.clone(),
|
options.bootstrap.location.clone(),
|
||||||
),
|
),
|
||||||
deno_fetch::deno_fetch::init_ext::<PermissionsContainer>(
|
deno_fetch::deno_fetch::init_ops::<PermissionsContainer>(
|
||||||
deno_fetch::Options {
|
deno_fetch::Options {
|
||||||
user_agent: options.bootstrap.user_agent.clone(),
|
user_agent: options.bootstrap.user_agent.clone(),
|
||||||
root_cert_store_provider: options.root_cert_store_provider.clone(),
|
root_cert_store_provider: options.root_cert_store_provider.clone(),
|
||||||
|
@ -243,60 +243,60 @@ impl MainWorker {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
deno_cache::deno_cache::init_ext::<SqliteBackedCache>(create_cache),
|
deno_cache::deno_cache::init_ops::<SqliteBackedCache>(create_cache),
|
||||||
deno_websocket::deno_websocket::init_ext::<PermissionsContainer>(
|
deno_websocket::deno_websocket::init_ops::<PermissionsContainer>(
|
||||||
options.bootstrap.user_agent.clone(),
|
options.bootstrap.user_agent.clone(),
|
||||||
options.root_cert_store_provider.clone(),
|
options.root_cert_store_provider.clone(),
|
||||||
options.unsafely_ignore_certificate_errors.clone(),
|
options.unsafely_ignore_certificate_errors.clone(),
|
||||||
),
|
),
|
||||||
deno_webstorage::deno_webstorage::init_ext(
|
deno_webstorage::deno_webstorage::init_ops(
|
||||||
options.origin_storage_dir.clone(),
|
options.origin_storage_dir.clone(),
|
||||||
),
|
),
|
||||||
deno_crypto::deno_crypto::init_ext(options.seed),
|
deno_crypto::deno_crypto::init_ops(options.seed),
|
||||||
deno_broadcast_channel::deno_broadcast_channel::init_ext(
|
deno_broadcast_channel::deno_broadcast_channel::init_ops(
|
||||||
options.broadcast_channel.clone(),
|
options.broadcast_channel.clone(),
|
||||||
unstable,
|
unstable,
|
||||||
),
|
),
|
||||||
deno_ffi::deno_ffi::init_ext::<PermissionsContainer>(unstable),
|
deno_ffi::deno_ffi::init_ops::<PermissionsContainer>(unstable),
|
||||||
deno_net::deno_net::init_ext::<PermissionsContainer>(
|
deno_net::deno_net::init_ops::<PermissionsContainer>(
|
||||||
options.root_cert_store_provider.clone(),
|
options.root_cert_store_provider.clone(),
|
||||||
unstable,
|
unstable,
|
||||||
options.unsafely_ignore_certificate_errors.clone(),
|
options.unsafely_ignore_certificate_errors.clone(),
|
||||||
),
|
),
|
||||||
deno_tls::deno_tls::init_ext(),
|
deno_tls::deno_tls::init_ops(),
|
||||||
deno_kv::deno_kv::init_ext(
|
deno_kv::deno_kv::init_ops(
|
||||||
SqliteDbHandler::<PermissionsContainer>::new(
|
SqliteDbHandler::<PermissionsContainer>::new(
|
||||||
options.origin_storage_dir.clone(),
|
options.origin_storage_dir.clone(),
|
||||||
),
|
),
|
||||||
unstable,
|
unstable,
|
||||||
),
|
),
|
||||||
deno_napi::deno_napi::init_ext::<PermissionsContainer>(),
|
deno_napi::deno_napi::init_ops::<PermissionsContainer>(),
|
||||||
deno_http::deno_http::init_ext::<DefaultHttpPropertyExtractor>(),
|
deno_http::deno_http::init_ops::<DefaultHttpPropertyExtractor>(),
|
||||||
deno_io::deno_io::init_ext(Some(options.stdio)),
|
deno_io::deno_io::init_ops(Some(options.stdio)),
|
||||||
deno_fs::deno_fs::init_ext::<PermissionsContainer>(
|
deno_fs::deno_fs::init_ops::<PermissionsContainer>(
|
||||||
unstable,
|
unstable,
|
||||||
options.fs.clone(),
|
options.fs.clone(),
|
||||||
),
|
),
|
||||||
deno_node::deno_node::init_ext::<PermissionsContainer>(
|
deno_node::deno_node::init_ops::<PermissionsContainer>(
|
||||||
options.npm_resolver,
|
options.npm_resolver,
|
||||||
options.fs,
|
options.fs,
|
||||||
),
|
),
|
||||||
// Ops from this crate
|
// Ops from this crate
|
||||||
ops::runtime::deno_runtime::init_ext(main_module.clone()),
|
ops::runtime::deno_runtime::init_ops(main_module.clone()),
|
||||||
ops::worker_host::deno_worker_host::init_ext(
|
ops::worker_host::deno_worker_host::init_ops(
|
||||||
options.create_web_worker_cb.clone(),
|
options.create_web_worker_cb.clone(),
|
||||||
options.web_worker_preload_module_cb.clone(),
|
options.web_worker_preload_module_cb.clone(),
|
||||||
options.web_worker_pre_execute_module_cb.clone(),
|
options.web_worker_pre_execute_module_cb.clone(),
|
||||||
options.format_js_error_fn.clone(),
|
options.format_js_error_fn.clone(),
|
||||||
),
|
),
|
||||||
ops::fs_events::deno_fs_events::init_ext(),
|
ops::fs_events::deno_fs_events::init_ops(),
|
||||||
ops::os::deno_os::init_ext(exit_code.clone()),
|
ops::os::deno_os::init_ops(exit_code.clone()),
|
||||||
ops::permissions::deno_permissions::init_ext(),
|
ops::permissions::deno_permissions::init_ops(),
|
||||||
ops::process::deno_process::init_ext(),
|
ops::process::deno_process::init_ops(),
|
||||||
ops::signal::deno_signal::init_ext(),
|
ops::signal::deno_signal::init_ops(),
|
||||||
ops::tty::deno_tty::init_ext(),
|
ops::tty::deno_tty::init_ops(),
|
||||||
ops::http::deno_http_runtime::init_ext(),
|
ops::http::deno_http_runtime::init_ops(),
|
||||||
deno_permissions_worker::init_ext(
|
deno_permissions_worker::init_ops(
|
||||||
permissions,
|
permissions,
|
||||||
unstable,
|
unstable,
|
||||||
enable_testing_features,
|
enable_testing_features,
|
||||||
|
|
Loading…
Reference in a new issue