2025-01-01 04:12:39 +09:00
|
|
|
// Copyright 2018-2025 the Deno authors. MIT license.
|
2022-09-22 11:17:02 -04:00
|
|
|
|
2022-09-13 11:59:01 -04:00
|
|
|
use std::path::Path;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
|
2023-07-01 21:07:57 -04:00
|
|
|
use deno_npm::NpmPackageCacheFolderId;
|
2023-04-06 18:46:44 -04:00
|
|
|
use deno_npm::NpmPackageId;
|
2025-01-09 19:01:47 -05:00
|
|
|
use node_resolver::NpmPackageFolderResolver;
|
2025-01-09 12:10:07 -05:00
|
|
|
use url::Url;
|
|
|
|
|
2025-01-09 14:04:52 -05:00
|
|
|
use crate::sync::MaybeSend;
|
|
|
|
use crate::sync::MaybeSync;
|
|
|
|
|
2025-01-09 12:10:07 -05:00
|
|
|
#[allow(clippy::disallowed_types)]
|
2025-01-10 14:48:43 -05:00
|
|
|
pub type NpmPackageFsResolverRc =
|
2025-01-09 12:10:07 -05:00
|
|
|
crate::sync::MaybeArc<dyn NpmPackageFsResolver>;
|
2022-09-13 11:59:01 -04:00
|
|
|
|
2023-02-22 14:15:25 -05:00
|
|
|
/// Part of the resolution that interacts with the file system.
|
2025-01-09 19:01:47 -05:00
|
|
|
pub trait NpmPackageFsResolver:
|
|
|
|
NpmPackageFolderResolver + MaybeSend + MaybeSync
|
|
|
|
{
|
2023-03-12 23:32:59 -04:00
|
|
|
/// The local node_modules folder if it is applicable to the implementation.
|
2024-09-30 09:33:32 -04:00
|
|
|
fn node_modules_path(&self) -> Option<&Path>;
|
2023-03-12 23:32:59 -04:00
|
|
|
|
2024-07-09 12:15:03 -04:00
|
|
|
fn maybe_package_folder(&self, package_id: &NpmPackageId) -> Option<PathBuf>;
|
|
|
|
|
2023-07-01 21:07:57 -04:00
|
|
|
fn resolve_package_cache_folder_id_from_specifier(
|
|
|
|
&self,
|
2025-01-09 12:10:07 -05:00
|
|
|
specifier: &Url,
|
2025-01-08 14:52:32 -08:00
|
|
|
) -> Result<Option<NpmPackageCacheFolderId>, std::io::Error>;
|
2022-09-13 11:59:01 -04:00
|
|
|
}
|