mirror of
https://github.com/denoland/deno.git
synced 2025-02-16 02:26:08 -05:00
refactor(lsp): make TS host use CLI snapshot (#28062)
This commit changes the TS host implementation in the LSP to use the same snapshot as the runtime worker and web worker use. This is due to upcoming V8 upgrade that might require that all isolates in the same process use the exact same snapshot.
This commit is contained in:
parent
c1a0d63753
commit
795ecfdca6
11 changed files with 349 additions and 314 deletions
|
@ -1194,7 +1194,7 @@ impl CliFactory {
|
|||
serve_port: cli_options.serve_port(),
|
||||
serve_host: cli_options.serve_host(),
|
||||
otel_config: self.cli_options()?.otel_config(),
|
||||
startup_snapshot: crate::js::deno_isolate_init(),
|
||||
startup_snapshot: deno_snapshots::CLI_SNAPSHOT,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
// Copyright 2018-2025 the Deno authors. MIT license.
|
||||
|
||||
use log::debug;
|
||||
|
||||
pub fn deno_isolate_init() -> Option<&'static [u8]> {
|
||||
debug!("Deno isolate init with snapshots.");
|
||||
deno_snapshots::CLI_SNAPSHOT
|
||||
}
|
|
@ -4912,17 +4912,17 @@ fn run_tsc_thread(
|
|||
maybe_inspector_server: Option<Arc<InspectorServer>>,
|
||||
) {
|
||||
let has_inspector_server = maybe_inspector_server.is_some();
|
||||
// Create and setup a JsRuntime based on a snapshot. It is expected that the
|
||||
// supplied snapshot is an isolate that contains the TypeScript language
|
||||
// server.
|
||||
let mut extensions =
|
||||
deno_runtime::snapshot_info::get_extensions_in_snapshot();
|
||||
extensions.push(deno_tsc::init_ops_and_esm(
|
||||
performance,
|
||||
specifier_map,
|
||||
request_rx,
|
||||
));
|
||||
let mut tsc_runtime = JsRuntime::new(RuntimeOptions {
|
||||
extensions: vec![deno_tsc::init_ops_and_esm(
|
||||
performance,
|
||||
specifier_map,
|
||||
request_rx,
|
||||
)],
|
||||
extensions,
|
||||
create_params: create_isolate_create_params(),
|
||||
startup_snapshot: None,
|
||||
startup_snapshot: deno_snapshots::CLI_SNAPSHOT,
|
||||
inspector: has_inspector_server,
|
||||
..Default::default()
|
||||
});
|
||||
|
|
|
@ -9,7 +9,6 @@ mod file_fetcher;
|
|||
mod graph_container;
|
||||
mod graph_util;
|
||||
mod http_util;
|
||||
mod js;
|
||||
mod jsr;
|
||||
mod lsp;
|
||||
mod module_loader;
|
||||
|
|
|
@ -1410,13 +1410,17 @@ pub fn exec(request: Request) -> Result<Response, ExecError> {
|
|||
});
|
||||
let exec_source = format!("globalThis.exec({request_value})");
|
||||
|
||||
let mut extensions =
|
||||
deno_runtime::snapshot_info::get_extensions_in_snapshot();
|
||||
extensions.push(deno_cli_tsc::init_ops_and_esm(
|
||||
request,
|
||||
root_map,
|
||||
remapped_specifiers,
|
||||
));
|
||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||
extensions: vec![deno_cli_tsc::init_ops_and_esm(
|
||||
request,
|
||||
root_map,
|
||||
remapped_specifiers,
|
||||
)],
|
||||
extensions,
|
||||
create_params: create_isolate_create_params(),
|
||||
startup_snapshot: deno_snapshots::CLI_SNAPSHOT,
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
|
@ -1562,47 +1566,6 @@ mod tests {
|
|||
exec(request)
|
||||
}
|
||||
|
||||
// TODO(bartlomieju): this test is segfaulting in V8, saying that there are too
|
||||
// few external references registered. It seems to be a bug in our snapshotting
|
||||
// logic. Because when we create TSC snapshot we register a few ops that
|
||||
// are called during snapshotting time, V8 expects at least as many references
|
||||
// when it starts up. The thing is that these ops are one-off - ie. they will never
|
||||
// be used again after the snapshot is taken. We should figure out a mechanism
|
||||
// to allow removing some of the ops before taking a snapshot.
|
||||
#[ignore]
|
||||
#[tokio::test]
|
||||
async fn test_compiler_snapshot() {
|
||||
let mut js_runtime = JsRuntime::new(RuntimeOptions {
|
||||
startup_snapshot: None,
|
||||
extensions: vec![super::deno_cli_tsc::init_ops_and_esm(
|
||||
Request {
|
||||
check_mode: TypeCheckMode::All,
|
||||
config: Arc::new(TsConfig(json!({}))),
|
||||
debug: false,
|
||||
graph: Arc::new(ModuleGraph::new(GraphKind::TypesOnly)),
|
||||
hash_data: 0,
|
||||
maybe_npm: None,
|
||||
maybe_tsbuildinfo: None,
|
||||
root_names: vec![],
|
||||
},
|
||||
HashMap::new(),
|
||||
HashMap::new(),
|
||||
)],
|
||||
..Default::default()
|
||||
});
|
||||
js_runtime
|
||||
.execute_script(
|
||||
"<anon>",
|
||||
r#"
|
||||
if (!(globalThis.exec)) {
|
||||
throw Error("bad");
|
||||
}
|
||||
console.log(`ts version: ${ts.version}`);
|
||||
"#,
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_create_hash() {
|
||||
let mut state = setup(None, Some(123), None).await;
|
||||
|
|
|
@ -486,7 +486,7 @@ mod tests {
|
|||
RuntimePermissionDescriptorParser::new(crate::sys::CliSys::default()),
|
||||
);
|
||||
let options = WorkerOptions {
|
||||
startup_snapshot: crate::js::deno_isolate_init(),
|
||||
startup_snapshot: deno_snapshots::CLI_SNAPSHOT,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ pub mod ops;
|
|||
pub mod permissions;
|
||||
#[cfg(feature = "snapshot")]
|
||||
pub mod snapshot;
|
||||
pub mod snapshot_info;
|
||||
pub mod tokio_util;
|
||||
#[cfg(feature = "transpile")]
|
||||
pub mod transpile;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
// Copyright 2018-2025 the Deno authors. MIT license.
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
@ -11,254 +9,13 @@ use deno_core::snapshot::*;
|
|||
use deno_core::v8;
|
||||
use deno_core::Extension;
|
||||
use deno_http::DefaultHttpPropertyExtractor;
|
||||
use deno_io::fs::FsError;
|
||||
use deno_permissions::PermissionCheckError;
|
||||
use deno_resolver::npm::DenoInNpmPackageChecker;
|
||||
use deno_resolver::npm::NpmResolver;
|
||||
|
||||
use crate::ops;
|
||||
use crate::ops::bootstrap::SnapshotOptions;
|
||||
use crate::shared::runtime;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Permissions;
|
||||
|
||||
impl deno_websocket::WebSocketPermissions for Permissions {
|
||||
fn check_net_url(
|
||||
&mut self,
|
||||
_url: &deno_core::url::Url,
|
||||
_api_name: &str,
|
||||
) -> Result<(), PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
}
|
||||
|
||||
impl deno_web::TimersPermission for Permissions {
|
||||
fn allow_hrtime(&mut self) -> bool {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
}
|
||||
|
||||
impl deno_fetch::FetchPermissions for Permissions {
|
||||
fn check_net_url(
|
||||
&mut self,
|
||||
_url: &deno_core::url::Url,
|
||||
_api_name: &str,
|
||||
) -> Result<(), PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_read<'a>(
|
||||
&mut self,
|
||||
_p: &'a Path,
|
||||
_api_name: &str,
|
||||
) -> Result<Cow<'a, Path>, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
}
|
||||
|
||||
impl deno_ffi::FfiPermissions for Permissions {
|
||||
fn check_partial_no_path(&mut self) -> Result<(), PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_partial_with_path(
|
||||
&mut self,
|
||||
_path: &str,
|
||||
) -> Result<PathBuf, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
}
|
||||
|
||||
impl deno_napi::NapiPermissions for Permissions {
|
||||
fn check(&mut self, _path: &str) -> Result<PathBuf, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
}
|
||||
|
||||
impl deno_node::NodePermissions for Permissions {
|
||||
fn check_net_url(
|
||||
&mut self,
|
||||
_url: &deno_core::url::Url,
|
||||
_api_name: &str,
|
||||
) -> Result<(), PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
fn check_net(
|
||||
&mut self,
|
||||
_host: (&str, Option<u16>),
|
||||
_api_name: &str,
|
||||
) -> Result<(), PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
fn check_read_path<'a>(
|
||||
&mut self,
|
||||
_path: &'a Path,
|
||||
) -> Result<Cow<'a, Path>, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
fn check_read_with_api_name(
|
||||
&mut self,
|
||||
_p: &str,
|
||||
_api_name: Option<&str>,
|
||||
) -> Result<PathBuf, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
fn query_read_all(&mut self) -> bool {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
fn check_write_with_api_name(
|
||||
&mut self,
|
||||
_p: &str,
|
||||
_api_name: Option<&str>,
|
||||
) -> Result<PathBuf, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
fn check_sys(
|
||||
&mut self,
|
||||
_kind: &str,
|
||||
_api_name: &str,
|
||||
) -> Result<(), PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
}
|
||||
|
||||
impl deno_net::NetPermissions for Permissions {
|
||||
fn check_net<T: AsRef<str>>(
|
||||
&mut self,
|
||||
_host: &(T, Option<u16>),
|
||||
_api_name: &str,
|
||||
) -> Result<(), PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_read(
|
||||
&mut self,
|
||||
_p: &str,
|
||||
_api_name: &str,
|
||||
) -> Result<PathBuf, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_write(
|
||||
&mut self,
|
||||
_p: &str,
|
||||
_api_name: &str,
|
||||
) -> Result<PathBuf, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_write_path<'a>(
|
||||
&mut self,
|
||||
_p: &'a Path,
|
||||
_api_name: &str,
|
||||
) -> Result<Cow<'a, Path>, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
}
|
||||
|
||||
impl deno_fs::FsPermissions for Permissions {
|
||||
fn check_open<'a>(
|
||||
&mut self,
|
||||
_resolved: bool,
|
||||
_read: bool,
|
||||
_write: bool,
|
||||
_path: &'a Path,
|
||||
_api_name: &str,
|
||||
) -> Result<Cow<'a, Path>, FsError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_read(
|
||||
&mut self,
|
||||
_path: &str,
|
||||
_api_name: &str,
|
||||
) -> Result<PathBuf, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_read_all(
|
||||
&mut self,
|
||||
_api_name: &str,
|
||||
) -> Result<(), PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_read_blind(
|
||||
&mut self,
|
||||
_path: &Path,
|
||||
_display: &str,
|
||||
_api_name: &str,
|
||||
) -> Result<(), PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_write(
|
||||
&mut self,
|
||||
_path: &str,
|
||||
_api_name: &str,
|
||||
) -> Result<PathBuf, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_write_partial(
|
||||
&mut self,
|
||||
_path: &str,
|
||||
_api_name: &str,
|
||||
) -> Result<PathBuf, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_write_all(
|
||||
&mut self,
|
||||
_api_name: &str,
|
||||
) -> Result<(), PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_write_blind(
|
||||
&mut self,
|
||||
_path: &Path,
|
||||
_display: &str,
|
||||
_api_name: &str,
|
||||
) -> Result<(), PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_read_path<'a>(
|
||||
&mut self,
|
||||
_path: &'a Path,
|
||||
_api_name: &str,
|
||||
) -> Result<Cow<'a, Path>, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_write_path<'a>(
|
||||
&mut self,
|
||||
_path: &'a Path,
|
||||
_api_name: &str,
|
||||
) -> Result<Cow<'a, Path>, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
}
|
||||
|
||||
impl deno_kv::sqlite::SqliteDbHandlerPermissions for Permissions {
|
||||
fn check_read(
|
||||
&mut self,
|
||||
_path: &str,
|
||||
_api_name: &str,
|
||||
) -> Result<PathBuf, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_write<'a>(
|
||||
&mut self,
|
||||
_path: &'a Path,
|
||||
_api_name: &str,
|
||||
) -> Result<Cow<'a, Path>, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
}
|
||||
use crate::snapshot_info::Permissions;
|
||||
|
||||
pub fn create_runtime_snapshot(
|
||||
snapshot_path: PathBuf,
|
||||
|
@ -267,7 +24,8 @@ pub fn create_runtime_snapshot(
|
|||
custom_extensions: Vec<Extension>,
|
||||
) {
|
||||
// NOTE(bartlomieju): ordering is important here, keep it in sync with
|
||||
// `runtime/worker.rs`, `runtime/web_worker.rs` and `runtime/snapshot.rs`!
|
||||
// `runtime/worker.rs`, `runtime/web_worker.rs`, `runtime/snapshot_info.rs`
|
||||
// and `runtime/snapshot.rs`!
|
||||
let fs = std::sync::Arc::new(deno_fs::RealFs);
|
||||
let mut extensions: Vec<Extension> = vec![
|
||||
deno_telemetry::deno_telemetry::init_ops_and_esm(),
|
||||
|
|
321
runtime/snapshot_info.rs
Normal file
321
runtime/snapshot_info.rs
Normal file
|
@ -0,0 +1,321 @@
|
|||
// Copyright 2018-2025 the Deno authors. MIT license.
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use deno_core::Extension;
|
||||
use deno_http::DefaultHttpPropertyExtractor;
|
||||
use deno_io::fs::FsError;
|
||||
use deno_permissions::PermissionCheckError;
|
||||
use deno_resolver::npm::DenoInNpmPackageChecker;
|
||||
use deno_resolver::npm::NpmResolver;
|
||||
|
||||
use crate::ops;
|
||||
use crate::shared::runtime;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Permissions;
|
||||
|
||||
impl deno_websocket::WebSocketPermissions for Permissions {
|
||||
fn check_net_url(
|
||||
&mut self,
|
||||
_url: &deno_core::url::Url,
|
||||
_api_name: &str,
|
||||
) -> Result<(), PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
}
|
||||
|
||||
impl deno_web::TimersPermission for Permissions {
|
||||
fn allow_hrtime(&mut self) -> bool {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
}
|
||||
|
||||
impl deno_fetch::FetchPermissions for Permissions {
|
||||
fn check_net_url(
|
||||
&mut self,
|
||||
_url: &deno_core::url::Url,
|
||||
_api_name: &str,
|
||||
) -> Result<(), PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_read<'a>(
|
||||
&mut self,
|
||||
_p: &'a Path,
|
||||
_api_name: &str,
|
||||
) -> Result<Cow<'a, Path>, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
}
|
||||
|
||||
impl deno_ffi::FfiPermissions for Permissions {
|
||||
fn check_partial_no_path(&mut self) -> Result<(), PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_partial_with_path(
|
||||
&mut self,
|
||||
_path: &str,
|
||||
) -> Result<PathBuf, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
}
|
||||
|
||||
impl deno_napi::NapiPermissions for Permissions {
|
||||
fn check(&mut self, _path: &str) -> Result<PathBuf, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
}
|
||||
|
||||
impl deno_node::NodePermissions for Permissions {
|
||||
fn check_net_url(
|
||||
&mut self,
|
||||
_url: &deno_core::url::Url,
|
||||
_api_name: &str,
|
||||
) -> Result<(), PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
fn check_net(
|
||||
&mut self,
|
||||
_host: (&str, Option<u16>),
|
||||
_api_name: &str,
|
||||
) -> Result<(), PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
fn check_read_path<'a>(
|
||||
&mut self,
|
||||
_path: &'a Path,
|
||||
) -> Result<Cow<'a, Path>, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
fn check_read_with_api_name(
|
||||
&mut self,
|
||||
_p: &str,
|
||||
_api_name: Option<&str>,
|
||||
) -> Result<PathBuf, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
fn query_read_all(&mut self) -> bool {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
fn check_write_with_api_name(
|
||||
&mut self,
|
||||
_p: &str,
|
||||
_api_name: Option<&str>,
|
||||
) -> Result<PathBuf, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
fn check_sys(
|
||||
&mut self,
|
||||
_kind: &str,
|
||||
_api_name: &str,
|
||||
) -> Result<(), PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
}
|
||||
|
||||
impl deno_net::NetPermissions for Permissions {
|
||||
fn check_net<T: AsRef<str>>(
|
||||
&mut self,
|
||||
_host: &(T, Option<u16>),
|
||||
_api_name: &str,
|
||||
) -> Result<(), PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_read(
|
||||
&mut self,
|
||||
_p: &str,
|
||||
_api_name: &str,
|
||||
) -> Result<PathBuf, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_write(
|
||||
&mut self,
|
||||
_p: &str,
|
||||
_api_name: &str,
|
||||
) -> Result<PathBuf, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_write_path<'a>(
|
||||
&mut self,
|
||||
_p: &'a Path,
|
||||
_api_name: &str,
|
||||
) -> Result<Cow<'a, Path>, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
}
|
||||
|
||||
impl deno_fs::FsPermissions for Permissions {
|
||||
fn check_open<'a>(
|
||||
&mut self,
|
||||
_resolved: bool,
|
||||
_read: bool,
|
||||
_write: bool,
|
||||
_path: &'a Path,
|
||||
_api_name: &str,
|
||||
) -> Result<Cow<'a, Path>, FsError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_read(
|
||||
&mut self,
|
||||
_path: &str,
|
||||
_api_name: &str,
|
||||
) -> Result<PathBuf, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_read_all(
|
||||
&mut self,
|
||||
_api_name: &str,
|
||||
) -> Result<(), PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_read_blind(
|
||||
&mut self,
|
||||
_path: &Path,
|
||||
_display: &str,
|
||||
_api_name: &str,
|
||||
) -> Result<(), PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_write(
|
||||
&mut self,
|
||||
_path: &str,
|
||||
_api_name: &str,
|
||||
) -> Result<PathBuf, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_write_partial(
|
||||
&mut self,
|
||||
_path: &str,
|
||||
_api_name: &str,
|
||||
) -> Result<PathBuf, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_write_all(
|
||||
&mut self,
|
||||
_api_name: &str,
|
||||
) -> Result<(), PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_write_blind(
|
||||
&mut self,
|
||||
_path: &Path,
|
||||
_display: &str,
|
||||
_api_name: &str,
|
||||
) -> Result<(), PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_read_path<'a>(
|
||||
&mut self,
|
||||
_path: &'a Path,
|
||||
_api_name: &str,
|
||||
) -> Result<Cow<'a, Path>, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_write_path<'a>(
|
||||
&mut self,
|
||||
_path: &'a Path,
|
||||
_api_name: &str,
|
||||
) -> Result<Cow<'a, Path>, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
}
|
||||
|
||||
impl deno_kv::sqlite::SqliteDbHandlerPermissions for Permissions {
|
||||
fn check_read(
|
||||
&mut self,
|
||||
_path: &str,
|
||||
_api_name: &str,
|
||||
) -> Result<PathBuf, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
|
||||
fn check_write<'a>(
|
||||
&mut self,
|
||||
_path: &'a Path,
|
||||
_api_name: &str,
|
||||
) -> Result<Cow<'a, Path>, PermissionCheckError> {
|
||||
unreachable!("snapshotting!")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_extensions_in_snapshot() -> Vec<Extension> {
|
||||
// NOTE(bartlomieju): ordering is important here, keep it in sync with
|
||||
// `runtime/worker.rs`, `runtime/web_worker.rs`, `runtime/snapshot_info.rs`
|
||||
// and `runtime/snapshot.rs`!
|
||||
let fs = std::sync::Arc::new(deno_fs::RealFs);
|
||||
vec![
|
||||
deno_telemetry::deno_telemetry::init_ops(),
|
||||
deno_webidl::deno_webidl::init_ops(),
|
||||
deno_console::deno_console::init_ops(),
|
||||
deno_url::deno_url::init_ops(),
|
||||
deno_web::deno_web::init_ops::<Permissions>(
|
||||
Default::default(),
|
||||
Default::default(),
|
||||
),
|
||||
deno_webgpu::deno_webgpu::init_ops(),
|
||||
deno_canvas::deno_canvas::init_ops(),
|
||||
deno_fetch::deno_fetch::init_ops::<Permissions>(Default::default()),
|
||||
deno_cache::deno_cache::init_ops(None),
|
||||
deno_websocket::deno_websocket::init_ops::<Permissions>(
|
||||
"".to_owned(),
|
||||
None,
|
||||
None,
|
||||
),
|
||||
deno_webstorage::deno_webstorage::init_ops(None),
|
||||
deno_crypto::deno_crypto::init_ops(None),
|
||||
deno_broadcast_channel::deno_broadcast_channel::init_ops(
|
||||
deno_broadcast_channel::InMemoryBroadcastChannel::default(),
|
||||
),
|
||||
deno_ffi::deno_ffi::init_ops::<Permissions>(),
|
||||
deno_net::deno_net::init_ops::<Permissions>(None, None),
|
||||
deno_tls::deno_tls::init_ops(),
|
||||
deno_kv::deno_kv::init_ops(
|
||||
deno_kv::sqlite::SqliteDbHandler::<Permissions>::new(None, None),
|
||||
deno_kv::KvConfig::builder().build(),
|
||||
),
|
||||
deno_cron::deno_cron::init_ops(deno_cron::local::LocalCronHandler::new()),
|
||||
deno_napi::deno_napi::init_ops::<Permissions>(),
|
||||
deno_http::deno_http::init_ops::<DefaultHttpPropertyExtractor>(
|
||||
deno_http::Options::default(),
|
||||
),
|
||||
deno_io::deno_io::init_ops(Some(Default::default())),
|
||||
deno_fs::deno_fs::init_ops::<Permissions>(fs.clone()),
|
||||
deno_os::deno_os::init_ops(Default::default()),
|
||||
deno_process::deno_process::init_ops(Default::default()),
|
||||
deno_node::deno_node::init_ops::<
|
||||
Permissions,
|
||||
DenoInNpmPackageChecker,
|
||||
NpmResolver<sys_traits::impls::RealSys>,
|
||||
sys_traits::impls::RealSys,
|
||||
>(None, fs.clone()),
|
||||
runtime::init_ops(),
|
||||
ops::runtime::deno_runtime::init_ops("deno:runtime".parse().unwrap()),
|
||||
ops::worker_host::deno_worker_host::init_ops(
|
||||
Arc::new(|_| unreachable!("not used in snapshot.")),
|
||||
None,
|
||||
),
|
||||
ops::fs_events::deno_fs_events::init_ops(),
|
||||
ops::permissions::deno_permissions::init_ops(),
|
||||
ops::tty::deno_tty::init_ops(),
|
||||
ops::http::deno_http_runtime::init_ops(),
|
||||
ops::bootstrap::deno_bootstrap::init_ops(None),
|
||||
ops::web_worker::deno_web_worker::init_ops(),
|
||||
]
|
||||
}
|
|
@ -489,8 +489,8 @@ impl WebWorker {
|
|||
let create_cache = create_cache_inner(&options);
|
||||
|
||||
// NOTE(bartlomieju): ordering is important here, keep it in sync with
|
||||
// `runtime/worker.rs` and `runtime/snapshot.rs`!
|
||||
|
||||
// `runtime/worker.rs`, `runtime/web_worker.rs`, `runtime/snapshot_info.rs`
|
||||
// and `runtime/snapshot.rs`!
|
||||
let mut extensions = vec![
|
||||
deno_telemetry::deno_telemetry::init_ops_and_esm(),
|
||||
// Web APIs
|
||||
|
|
|
@ -386,7 +386,8 @@ impl MainWorker {
|
|||
let exit_code = ExitCode::default();
|
||||
|
||||
// NOTE(bartlomieju): ordering is important here, keep it in sync with
|
||||
// `runtime/web_worker.rs` and `runtime/snapshot.rs`!
|
||||
// `runtime/worker.rs`, `runtime/web_worker.rs`, `runtime/snapshot_info.rs`
|
||||
// and `runtime/snapshot.rs`!
|
||||
let mut extensions = vec![
|
||||
deno_telemetry::deno_telemetry::init_ops_and_esm(),
|
||||
// Web APIs
|
||||
|
|
Loading…
Add table
Reference in a new issue