mirror of
https://github.com/denoland/deno.git
synced 2024-11-22 15:06:54 -05:00
refactor(cli,core,ext,rt): remove some unnecessary clone
or malloc
(#17274)
This commit is contained in:
parent
4e6b78cb43
commit
896dd56b7a
24 changed files with 86 additions and 72 deletions
|
@ -71,7 +71,7 @@ pub struct IgnoredCompilerOptions {
|
||||||
impl fmt::Display for IgnoredCompilerOptions {
|
impl fmt::Display for IgnoredCompilerOptions {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let mut codes = self.items.clone();
|
let mut codes = self.items.clone();
|
||||||
codes.sort();
|
codes.sort_unstable();
|
||||||
if let Some(specifier) = &self.maybe_specifier {
|
if let Some(specifier) = &self.maybe_specifier {
|
||||||
write!(f, "Unsupported compiler options in \"{}\".\n The following options were ignored:\n {}", specifier, codes.join(", "))
|
write!(f, "Unsupported compiler options in \"{}\".\n The following options were ignored:\n {}", specifier, codes.join(", "))
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
|
use std::collections::BTreeMap;
|
||||||
|
use std::io::Write;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use deno_core::anyhow::Context;
|
use deno_core::anyhow::Context;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
|
@ -6,9 +9,6 @@ use deno_core::serde::Deserialize;
|
||||||
use deno_core::serde::Serialize;
|
use deno_core::serde::Serialize;
|
||||||
use deno_core::serde_json;
|
use deno_core::serde_json;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use std::collections::BTreeMap;
|
|
||||||
use std::io::Write;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
use crate::args::config_file::LockConfig;
|
use crate::args::config_file::LockConfig;
|
||||||
use crate::args::ConfigFile;
|
use crate::args::ConfigFile;
|
||||||
|
|
|
@ -329,11 +329,11 @@ impl CliOptions {
|
||||||
// if a location is set, then the ascii serialization of the location is
|
// if a location is set, then the ascii serialization of the location is
|
||||||
// used, unless the origin is opaque, and then no storage origin is set, as
|
// used, unless the origin is opaque, and then no storage origin is set, as
|
||||||
// we can't expect the origin to be reproducible
|
// we can't expect the origin to be reproducible
|
||||||
let storage_origin = location.origin().ascii_serialization();
|
let storage_origin = location.origin();
|
||||||
if storage_origin == "null" {
|
if storage_origin.is_tuple() {
|
||||||
None
|
Some(storage_origin.ascii_serialization())
|
||||||
} else {
|
} else {
|
||||||
Some(storage_origin)
|
None
|
||||||
}
|
}
|
||||||
} else if let Some(config_file) = &self.maybe_config_file {
|
} else if let Some(config_file) = &self.maybe_config_file {
|
||||||
// otherwise we will use the path to the config file
|
// otherwise we will use the path to the config file
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use super::Result;
|
|
||||||
use std::sync::atomic::{AtomicU16, Ordering};
|
use std::sync::atomic::{AtomicU16, Ordering};
|
||||||
use std::{collections::HashMap, path::Path, process::Command, time::Duration};
|
use std::{collections::HashMap, path::Path, process::Command, time::Duration};
|
||||||
|
|
||||||
|
use super::Result;
|
||||||
|
|
||||||
pub use test_util::{parse_wrk_output, WrkOutput as HttpBenchmarkResult};
|
pub use test_util::{parse_wrk_output, WrkOutput as HttpBenchmarkResult};
|
||||||
// Some of the benchmarks in this file have been renamed. In case the history
|
// Some of the benchmarks in this file have been renamed. In case the history
|
||||||
// somehow gets messed up:
|
// somehow gets messed up:
|
||||||
|
@ -27,7 +29,7 @@ pub fn benchmark(
|
||||||
let mut res = HashMap::new();
|
let mut res = HashMap::new();
|
||||||
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
|
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
|
||||||
let http_dir = manifest_dir.join("bench").join("http");
|
let http_dir = manifest_dir.join("bench").join("http");
|
||||||
for entry in std::fs::read_dir(http_dir.clone())? {
|
for entry in std::fs::read_dir(&http_dir)? {
|
||||||
let entry = entry?;
|
let entry = entry?;
|
||||||
let pathbuf = entry.path();
|
let pathbuf = entry.path();
|
||||||
let path = pathbuf.to_str().unwrap();
|
let path = pathbuf.to_str().unwrap();
|
||||||
|
|
|
@ -571,7 +571,7 @@ pub async fn create_graph_and_maybe_check(
|
||||||
&graph.roots,
|
&graph.roots,
|
||||||
Arc::new(RwLock::new(graph_data)),
|
Arc::new(RwLock::new(graph_data)),
|
||||||
&cache,
|
&cache,
|
||||||
ps.npm_resolver.clone(),
|
&ps.npm_resolver,
|
||||||
check::CheckOptions {
|
check::CheckOptions {
|
||||||
type_check_mode: ps.options.type_check_mode(),
|
type_check_mode: ps.options.type_check_mode(),
|
||||||
debug: ps.options.log_level() == Some(log::Level::Debug),
|
debug: ps.options.log_level() == Some(log::Level::Debug),
|
||||||
|
|
|
@ -5,8 +5,6 @@ use std::collections::VecDeque;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use crate::cache::NodeAnalysisCache;
|
|
||||||
use crate::deno_std::CURRENT_STD_URL;
|
|
||||||
use deno_ast::CjsAnalysis;
|
use deno_ast::CjsAnalysis;
|
||||||
use deno_ast::MediaType;
|
use deno_ast::MediaType;
|
||||||
use deno_ast::ModuleSpecifier;
|
use deno_ast::ModuleSpecifier;
|
||||||
|
@ -36,6 +34,8 @@ use deno_runtime::deno_node::NODE_GLOBAL_THIS_NAME;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
|
use crate::cache::NodeAnalysisCache;
|
||||||
|
use crate::deno_std::CURRENT_STD_URL;
|
||||||
use crate::file_fetcher::FileFetcher;
|
use crate::file_fetcher::FileFetcher;
|
||||||
use crate::npm::NpmPackageReference;
|
use crate::npm::NpmPackageReference;
|
||||||
use crate::npm::NpmPackageReq;
|
use crate::npm::NpmPackageReq;
|
||||||
|
|
|
@ -210,7 +210,7 @@ impl NpmResolutionPackage {
|
||||||
pub struct NpmResolution {
|
pub struct NpmResolution {
|
||||||
api: RealNpmRegistryApi,
|
api: RealNpmRegistryApi,
|
||||||
snapshot: RwLock<NpmResolutionSnapshot>,
|
snapshot: RwLock<NpmResolutionSnapshot>,
|
||||||
update_sempahore: tokio::sync::Semaphore,
|
update_semaphore: tokio::sync::Semaphore,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Debug for NpmResolution {
|
impl std::fmt::Debug for NpmResolution {
|
||||||
|
@ -230,7 +230,7 @@ impl NpmResolution {
|
||||||
Self {
|
Self {
|
||||||
api,
|
api,
|
||||||
snapshot: RwLock::new(initial_snapshot.unwrap_or_default()),
|
snapshot: RwLock::new(initial_snapshot.unwrap_or_default()),
|
||||||
update_sempahore: tokio::sync::Semaphore::new(1),
|
update_semaphore: tokio::sync::Semaphore::new(1),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ impl NpmResolution {
|
||||||
package_reqs: Vec<NpmPackageReq>,
|
package_reqs: Vec<NpmPackageReq>,
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
// only allow one thread in here at a time
|
// only allow one thread in here at a time
|
||||||
let _permit = self.update_sempahore.acquire().await.unwrap();
|
let _permit = self.update_semaphore.acquire().await.unwrap();
|
||||||
let snapshot = self.snapshot.read().clone();
|
let snapshot = self.snapshot.read().clone();
|
||||||
|
|
||||||
let snapshot = self
|
let snapshot = self
|
||||||
|
@ -255,7 +255,7 @@ impl NpmResolution {
|
||||||
package_reqs: HashSet<NpmPackageReq>,
|
package_reqs: HashSet<NpmPackageReq>,
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
// only allow one thread in here at a time
|
// only allow one thread in here at a time
|
||||||
let _permit = self.update_sempahore.acquire().await.unwrap();
|
let _permit = self.update_semaphore.acquire().await.unwrap();
|
||||||
let snapshot = self.snapshot.read().clone();
|
let snapshot = self.snapshot.read().clone();
|
||||||
|
|
||||||
let has_removed_package = !snapshot
|
let has_removed_package = !snapshot
|
||||||
|
|
|
@ -132,7 +132,7 @@ impl std::fmt::Display for NpmPackageReq {
|
||||||
|
|
||||||
impl NpmPackageReq {
|
impl NpmPackageReq {
|
||||||
pub fn from_str(text: &str) -> Result<Self, AnyError> {
|
pub fn from_str(text: &str) -> Result<Self, AnyError> {
|
||||||
// probably should do something more targetted in the future
|
// probably should do something more targeted in the future
|
||||||
let reference = NpmPackageReference::from_str(&format!("npm:{}", text))?;
|
let reference = NpmPackageReference::from_str(&format!("npm:{}", text))?;
|
||||||
Ok(reference.req)
|
Ok(reference.req)
|
||||||
}
|
}
|
||||||
|
|
|
@ -448,7 +448,7 @@ impl ProcState {
|
||||||
&roots,
|
&roots,
|
||||||
graph_data,
|
graph_data,
|
||||||
&check_cache,
|
&check_cache,
|
||||||
self.npm_resolver.clone(),
|
&self.npm_resolver,
|
||||||
options,
|
options,
|
||||||
)?;
|
)?;
|
||||||
if !check_result.diagnostics.is_empty() {
|
if !check_result.diagnostics.is_empty() {
|
||||||
|
|
|
@ -161,14 +161,13 @@ impl ModuleLoader for EmbeddedModuleLoader {
|
||||||
_maybe_referrer: Option<ModuleSpecifier>,
|
_maybe_referrer: Option<ModuleSpecifier>,
|
||||||
_is_dynamic: bool,
|
_is_dynamic: bool,
|
||||||
) -> Pin<Box<deno_core::ModuleSourceFuture>> {
|
) -> Pin<Box<deno_core::ModuleSourceFuture>> {
|
||||||
let module_specifier = module_specifier.clone();
|
let is_data_uri = get_source_from_data_url(module_specifier).ok();
|
||||||
|
|
||||||
let is_data_uri = get_source_from_data_url(&module_specifier).ok();
|
|
||||||
let module = self
|
let module = self
|
||||||
.eszip
|
.eszip
|
||||||
.get_module(module_specifier.as_str())
|
.get_module(module_specifier.as_str())
|
||||||
.ok_or_else(|| type_error("Module not found"));
|
.ok_or_else(|| type_error("Module not found"));
|
||||||
|
|
||||||
|
let module_specifier = module_specifier.clone();
|
||||||
async move {
|
async move {
|
||||||
if let Some((source, _)) = is_data_uri {
|
if let Some((source, _)) = is_data_uri {
|
||||||
return Ok(deno_core::ModuleSource {
|
return Ok(deno_core::ModuleSource {
|
||||||
|
|
|
@ -58,7 +58,7 @@ pub fn check(
|
||||||
roots: &[(ModuleSpecifier, ModuleKind)],
|
roots: &[(ModuleSpecifier, ModuleKind)],
|
||||||
graph_data: Arc<RwLock<GraphData>>,
|
graph_data: Arc<RwLock<GraphData>>,
|
||||||
cache: &TypeCheckCache,
|
cache: &TypeCheckCache,
|
||||||
npm_resolver: NpmPackageResolver,
|
npm_resolver: &NpmPackageResolver,
|
||||||
options: CheckOptions,
|
options: CheckOptions,
|
||||||
) -> Result<CheckResult, AnyError> {
|
) -> Result<CheckResult, AnyError> {
|
||||||
let check_js = options.ts_config.get_check_js();
|
let check_js = options.ts_config.get_check_js();
|
||||||
|
|
|
@ -183,5 +183,5 @@ pub async fn run(flags: Flags, repl_flags: ReplFlags) -> Result<i32, AnyError> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(repl_session.worker.get_exit_code())
|
Ok(repl_session.worker.exit_code())
|
||||||
}
|
}
|
||||||
|
|
8
cli/tools/vendor/test.rs
vendored
8
cli/tools/vendor/test.rs
vendored
|
@ -242,7 +242,7 @@ impl VendorTestBuilder {
|
||||||
let import_map = files.remove(&output_dir.join("import_map.json"));
|
let import_map = files.remove(&output_dir.join("import_map.json"));
|
||||||
let mut files = files
|
let mut files = files
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(path, text)| (path_to_string(path), text.clone()))
|
.map(|(path, text)| (path_to_string(path), text.to_string()))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
files.sort_by(|a, b| a.0.cmp(&b.0));
|
files.sort_by(|a, b| a.0.cmp(&b.0));
|
||||||
|
@ -293,7 +293,11 @@ fn make_path(text: &str) -> PathBuf {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn path_to_string(path: &Path) -> String {
|
fn path_to_string<P>(path: P) -> String
|
||||||
|
where
|
||||||
|
P: AsRef<Path>,
|
||||||
|
{
|
||||||
|
let path = path.as_ref();
|
||||||
// inverse of the function above
|
// inverse of the function above
|
||||||
let path = path.to_string_lossy();
|
let path = path.to_string_lossy();
|
||||||
if cfg!(windows) {
|
if cfg!(windows) {
|
||||||
|
|
|
@ -100,7 +100,7 @@ impl CliMainWorker {
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(self.worker.get_exit_code())
|
Ok(self.worker.exit_code())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn run_for_watcher(self) -> Result<(), AnyError> {
|
pub async fn run_for_watcher(self) -> Result<(), AnyError> {
|
||||||
|
|
|
@ -1,13 +1,5 @@
|
||||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use crate::RcLike;
|
|
||||||
use crate::Resource;
|
|
||||||
use futures::future::FusedFuture;
|
|
||||||
use futures::future::Future;
|
|
||||||
use futures::future::TryFuture;
|
|
||||||
use futures::task::Context;
|
|
||||||
use futures::task::Poll;
|
|
||||||
use pin_project::pin_project;
|
|
||||||
use std::any::type_name;
|
use std::any::type_name;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
@ -18,6 +10,16 @@ use std::io;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
use futures::future::FusedFuture;
|
||||||
|
use futures::future::Future;
|
||||||
|
use futures::future::TryFuture;
|
||||||
|
use futures::task::Context;
|
||||||
|
use futures::task::Poll;
|
||||||
|
use pin_project::pin_project;
|
||||||
|
|
||||||
|
use crate::RcLike;
|
||||||
|
use crate::Resource;
|
||||||
|
|
||||||
use self::internal as i;
|
use self::internal as i;
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
use std::option::Option;
|
||||||
|
use std::os::raw::c_void;
|
||||||
|
|
||||||
|
use log::debug;
|
||||||
|
use v8::fast_api::FastFunction;
|
||||||
|
use v8::MapFnTo;
|
||||||
|
|
||||||
use crate::error::is_instance_of_error;
|
use crate::error::is_instance_of_error;
|
||||||
use crate::modules::get_asserted_module_type_from_assertions;
|
use crate::modules::get_asserted_module_type_from_assertions;
|
||||||
use crate::modules::parse_import_assertions;
|
use crate::modules::parse_import_assertions;
|
||||||
|
@ -9,11 +16,6 @@ use crate::modules::ModuleMap;
|
||||||
use crate::ops::OpCtx;
|
use crate::ops::OpCtx;
|
||||||
use crate::runtime::SnapshotOptions;
|
use crate::runtime::SnapshotOptions;
|
||||||
use crate::JsRuntime;
|
use crate::JsRuntime;
|
||||||
use log::debug;
|
|
||||||
use std::option::Option;
|
|
||||||
use std::os::raw::c_void;
|
|
||||||
use v8::fast_api::FastFunction;
|
|
||||||
use v8::MapFnTo;
|
|
||||||
|
|
||||||
pub fn external_references(
|
pub fn external_references(
|
||||||
ops: &[OpCtx],
|
ops: &[OpCtx],
|
||||||
|
|
|
@ -1,18 +1,20 @@
|
||||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
use std::borrow::Cow;
|
||||||
|
use std::collections::HashSet;
|
||||||
|
use std::fmt;
|
||||||
|
use std::fmt::Debug;
|
||||||
|
use std::fmt::Display;
|
||||||
|
use std::fmt::Formatter;
|
||||||
|
|
||||||
|
use anyhow::Error;
|
||||||
|
|
||||||
use crate::runtime::GetErrorClassFn;
|
use crate::runtime::GetErrorClassFn;
|
||||||
use crate::runtime::JsRealm;
|
use crate::runtime::JsRealm;
|
||||||
use crate::runtime::JsRuntime;
|
use crate::runtime::JsRuntime;
|
||||||
use crate::source_map::apply_source_map;
|
use crate::source_map::apply_source_map;
|
||||||
use crate::source_map::get_source_line;
|
use crate::source_map::get_source_line;
|
||||||
use crate::url::Url;
|
use crate::url::Url;
|
||||||
use anyhow::Error;
|
|
||||||
use std::borrow::Cow;
|
|
||||||
use std::collections::HashSet;
|
|
||||||
use std::fmt;
|
|
||||||
use std::fmt::Debug;
|
|
||||||
use std::fmt::Display;
|
|
||||||
use std::fmt::Formatter;
|
|
||||||
|
|
||||||
/// A generic wrapper that can encapsulate any concrete error type.
|
/// A generic wrapper that can encapsulate any concrete error type.
|
||||||
// TODO(ry) Deprecate AnyError and encourage deno_core::anyhow::Error instead.
|
// TODO(ry) Deprecate AnyError and encourage deno_core::anyhow::Error instead.
|
||||||
|
|
|
@ -12,7 +12,7 @@ fn main() -> Result<(), Error> {
|
||||||
println!("Usage: target/examples/debug/fs_module_loader <path_to_module>");
|
println!("Usage: target/examples/debug/fs_module_loader <path_to_module>");
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
let main_url = args[1].clone();
|
let main_url = &args[1];
|
||||||
println!("Run {}", main_url);
|
println!("Run {}", main_url);
|
||||||
|
|
||||||
let mut js_runtime = JsRuntime::new(RuntimeOptions {
|
let mut js_runtime = JsRuntime::new(RuntimeOptions {
|
||||||
|
@ -24,7 +24,7 @@ fn main() -> Result<(), Error> {
|
||||||
.enable_all()
|
.enable_all()
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
let main_module = deno_core::resolve_path(&main_url)?;
|
let main_module = deno_core::resolve_path(main_url)?;
|
||||||
|
|
||||||
let future = async move {
|
let future = async move {
|
||||||
let mod_id = js_runtime.load_main_module(&main_module, None).await?;
|
let mod_id = js_runtime.load_main_module(&main_module, None).await?;
|
||||||
|
|
|
@ -97,7 +97,7 @@ fn main() -> Result<(), Error> {
|
||||||
println!("Usage: target/examples/debug/ts_module_loader <path_to_module>");
|
println!("Usage: target/examples/debug/ts_module_loader <path_to_module>");
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
let main_url = args[1].clone();
|
let main_url = &args[1];
|
||||||
println!("Run {}", main_url);
|
println!("Run {}", main_url);
|
||||||
|
|
||||||
let mut js_runtime = JsRuntime::new(RuntimeOptions {
|
let mut js_runtime = JsRuntime::new(RuntimeOptions {
|
||||||
|
@ -105,7 +105,7 @@ fn main() -> Result<(), Error> {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
let main_module = resolve_path(&main_url)?;
|
let main_module = resolve_path(main_url)?;
|
||||||
|
|
||||||
let future = async move {
|
let future = async move {
|
||||||
let mod_id = js_runtime.load_main_module(&main_module, None).await?;
|
let mod_id = js_runtime.load_main_module(&main_module, None).await?;
|
||||||
|
|
|
@ -529,7 +529,7 @@ where
|
||||||
let exports = v8::Object::new(scope);
|
let exports = v8::Object::new(scope);
|
||||||
|
|
||||||
let mut env_shared = EnvShared::new(napi_wrap);
|
let mut env_shared = EnvShared::new(napi_wrap);
|
||||||
let cstr = CString::new(path.clone()).unwrap();
|
let cstr = CString::new(&*path).unwrap();
|
||||||
env_shared.filename = cstr.as_ptr();
|
env_shared.filename = cstr.as_ptr();
|
||||||
std::mem::forget(cstr);
|
std::mem::forget(cstr);
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
// NOTE to all: use **cached** prepared statements when interfacing with SQLite.
|
// NOTE to all: use **cached** prepared statements when interfacing with SQLite.
|
||||||
|
|
||||||
|
use std::fmt;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::include_js_files;
|
use deno_core::include_js_files;
|
||||||
use deno_core::op;
|
use deno_core::op;
|
||||||
|
@ -10,8 +13,6 @@ use deno_core::OpState;
|
||||||
use rusqlite::params;
|
use rusqlite::params;
|
||||||
use rusqlite::Connection;
|
use rusqlite::Connection;
|
||||||
use rusqlite::OptionalExtension;
|
use rusqlite::OptionalExtension;
|
||||||
use std::fmt;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
pub use rusqlite;
|
pub use rusqlite;
|
||||||
|
|
||||||
|
|
|
@ -266,16 +266,16 @@ async fn server(
|
||||||
future::ready({
|
future::ready({
|
||||||
match (req.method(), req.uri().path()) {
|
match (req.method(), req.uri().path()) {
|
||||||
(&http::Method::GET, path) if path.starts_with("/ws/") => {
|
(&http::Method::GET, path) if path.starts_with("/ws/") => {
|
||||||
handle_ws_request(req, inspector_map.clone())
|
handle_ws_request(req, Rc::clone(&inspector_map))
|
||||||
}
|
}
|
||||||
(&http::Method::GET, "/json/version") => {
|
(&http::Method::GET, "/json/version") => {
|
||||||
handle_json_version_request(json_version_response.clone())
|
handle_json_version_request(json_version_response.clone())
|
||||||
}
|
}
|
||||||
(&http::Method::GET, "/json") => {
|
(&http::Method::GET, "/json") => {
|
||||||
handle_json_request(inspector_map.clone())
|
handle_json_request(Rc::clone(&inspector_map))
|
||||||
}
|
}
|
||||||
(&http::Method::GET, "/json/list") => {
|
(&http::Method::GET, "/json/list") => {
|
||||||
handle_json_request(inspector_map.clone())
|
handle_json_request(Rc::clone(&inspector_map))
|
||||||
}
|
}
|
||||||
_ => http::Response::builder()
|
_ => http::Response::builder()
|
||||||
.status(http::StatusCode::NOT_FOUND)
|
.status(http::StatusCode::NOT_FOUND)
|
||||||
|
|
|
@ -211,7 +211,7 @@ async fn op_open_async(
|
||||||
"Deno.open()",
|
"Deno.open()",
|
||||||
)?;
|
)?;
|
||||||
let std_file = tokio::task::spawn_blocking(move || {
|
let std_file = tokio::task::spawn_blocking(move || {
|
||||||
open_options.open(path.clone()).map_err(|err| {
|
open_options.open(&path).map_err(|err| {
|
||||||
Error::new(err.kind(), format!("{}, open '{}'", err, path.display()))
|
Error::new(err.kind(), format!("{}, open '{}'", err, path.display()))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use crate::inspector_server::InspectorServer;
|
use std::pin::Pin;
|
||||||
use crate::js;
|
use std::rc::Rc;
|
||||||
use crate::ops;
|
use std::sync::atomic::AtomicI32;
|
||||||
use crate::ops::io::Stdio;
|
use std::sync::atomic::Ordering::Relaxed;
|
||||||
use crate::permissions::Permissions;
|
use std::sync::Arc;
|
||||||
use crate::BootstrapOptions;
|
use std::task::Context;
|
||||||
|
use std::task::Poll;
|
||||||
|
|
||||||
use deno_broadcast_channel::InMemoryBroadcastChannel;
|
use deno_broadcast_channel::InMemoryBroadcastChannel;
|
||||||
use deno_cache::CreateCache;
|
use deno_cache::CreateCache;
|
||||||
use deno_cache::SqliteBackedCache;
|
use deno_cache::SqliteBackedCache;
|
||||||
|
@ -31,13 +33,13 @@ use deno_node::RequireNpmResolver;
|
||||||
use deno_tls::rustls::RootCertStore;
|
use deno_tls::rustls::RootCertStore;
|
||||||
use deno_web::BlobStore;
|
use deno_web::BlobStore;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use std::pin::Pin;
|
|
||||||
use std::rc::Rc;
|
use crate::inspector_server::InspectorServer;
|
||||||
use std::sync::atomic::AtomicI32;
|
use crate::js;
|
||||||
use std::sync::atomic::Ordering::Relaxed;
|
use crate::ops;
|
||||||
use std::sync::Arc;
|
use crate::ops::io::Stdio;
|
||||||
use std::task::Context;
|
use crate::permissions::Permissions;
|
||||||
use std::task::Poll;
|
use crate::BootstrapOptions;
|
||||||
|
|
||||||
pub type FormatJsErrorFn = dyn Fn(&JsError) -> String + Sync + Send;
|
pub type FormatJsErrorFn = dyn Fn(&JsError) -> String + Sync + Send;
|
||||||
|
|
||||||
|
@ -458,7 +460,7 @@ impl MainWorker {
|
||||||
|
|
||||||
/// Return exit code set by the executed code (either in main worker
|
/// Return exit code set by the executed code (either in main worker
|
||||||
/// or one of child web workers).
|
/// or one of child web workers).
|
||||||
pub fn get_exit_code(&self) -> i32 {
|
pub fn exit_code(&self) -> i32 {
|
||||||
self.exit_code.get()
|
self.exit_code.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue