summaryrefslogtreecommitdiff
path: root/cli/cache.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2022-05-17 19:50:31 +0200
committerGitHub <noreply@github.com>2022-05-17 13:50:31 -0400
commitf57aac77ff9ce514730504066daca0a61a959d32 (patch)
tree34be59895172b93a255c933d0f2e579dbf3a3ccc /cli/cache.rs
parent9766399a3fefcab322051b4a7af41f9d40d79150 (diff)
BREAKING: Remove unstable Deno.emit and Deno.formatDiagnostics APIs (#14463)
Diffstat (limited to 'cli/cache.rs')
-rw-r--r--cli/cache.rs105
1 files changed, 0 insertions, 105 deletions
diff --git a/cli/cache.rs b/cli/cache.rs
index 8a6499f56..eb6ae26ca 100644
--- a/cli/cache.rs
+++ b/cli/cache.rs
@@ -5,7 +5,6 @@ use crate::errors::get_error_class_name;
use crate::file_fetcher::FileFetcher;
use deno_core::error::AnyError;
-use deno_core::futures::future;
use deno_core::futures::FutureExt;
use deno_core::serde::Deserialize;
use deno_core::serde::Serialize;
@@ -16,7 +15,6 @@ use deno_graph::source::LoadFuture;
use deno_graph::source::LoadResponse;
use deno_graph::source::Loader;
use deno_runtime::permissions::Permissions;
-use std::collections::HashMap;
use std::sync::Arc;
#[derive(Debug, Deserialize, Serialize)]
@@ -248,106 +246,3 @@ impl CacherLoader for FetchCacher {
self
}
}
-
-/// An in memory cache that is used by the runtime `Deno.emit()` API to provide
-/// the same behavior as the disk cache when sources are provided.
-#[derive(Debug)]
-pub struct MemoryCacher {
- sources: HashMap<String, Arc<String>>,
- declarations: HashMap<ModuleSpecifier, String>,
- emits: HashMap<ModuleSpecifier, String>,
- maps: HashMap<ModuleSpecifier, String>,
- build_infos: HashMap<ModuleSpecifier, String>,
- versions: HashMap<ModuleSpecifier, String>,
-}
-
-impl MemoryCacher {
- pub fn new(sources: HashMap<String, Arc<String>>) -> Self {
- Self {
- sources,
- declarations: HashMap::default(),
- emits: HashMap::default(),
- maps: HashMap::default(),
- build_infos: HashMap::default(),
- versions: HashMap::default(),
- }
- }
-}
-
-impl Loader for MemoryCacher {
- fn load(
- &mut self,
- specifier: &ModuleSpecifier,
- _is_dynamic: bool,
- ) -> LoadFuture {
- let mut specifier_str = specifier.to_string();
- if !self.sources.contains_key(&specifier_str) {
- specifier_str = specifier_str.replace("file:///", "/");
- if !self.sources.contains_key(&specifier_str) {
- specifier_str = specifier_str[3..].to_string();
- }
- }
- let response =
- self
- .sources
- .get(&specifier_str)
- .map(|c| LoadResponse::Module {
- specifier: specifier.clone(),
- maybe_headers: None,
- content: c.to_owned(),
- });
- Box::pin(future::ready(Ok(response)))
- }
-}
-
-impl Cacher for MemoryCacher {
- fn get(
- &self,
- cache_type: CacheType,
- specifier: &ModuleSpecifier,
- ) -> Option<String> {
- match cache_type {
- CacheType::Declaration => self.declarations.get(specifier).cloned(),
- CacheType::Emit => self.emits.get(specifier).cloned(),
- CacheType::SourceMap => self.maps.get(specifier).cloned(),
- CacheType::TypeScriptBuildInfo => {
- self.build_infos.get(specifier).cloned()
- }
- CacheType::Version => self.versions.get(specifier).cloned(),
- }
- }
-
- fn set(
- &mut self,
- cache_type: CacheType,
- specifier: &ModuleSpecifier,
- value: String,
- ) -> Result<(), AnyError> {
- match cache_type {
- CacheType::Declaration => {
- self.declarations.insert(specifier.clone(), value)
- }
- CacheType::Emit => self.emits.insert(specifier.clone(), value),
- CacheType::SourceMap => self.maps.insert(specifier.clone(), value),
- CacheType::TypeScriptBuildInfo => {
- self.build_infos.insert(specifier.clone(), value)
- }
- CacheType::Version => self.versions.insert(specifier.clone(), value),
- };
- Ok(())
- }
-}
-
-impl CacherLoader for MemoryCacher {
- fn as_cacher(&self) -> &dyn Cacher {
- self
- }
-
- fn as_mut_loader(&mut self) -> &mut dyn Loader {
- self
- }
-
- fn as_mut_cacher(&mut self) -> &mut dyn Cacher {
- self
- }
-}