use std::collections::HashMap;
use crate::models::ImportRelation;
#[derive(Debug, Clone)]
pub(crate) struct ExternalImportBinding {
pub(crate) module: String,
pub(crate) callee_name: String,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum LocalCallResolution {
Named,
DefaultExport,
}
#[derive(Debug, Clone)]
pub(crate) struct LocalCallBinding {
pub(crate) candidate_files: Vec<String>,
pub(crate) callee_name: String,
pub(crate) resolution: LocalCallResolution,
}
impl LocalCallBinding {
pub(crate) fn named(candidate_files: Vec<String>, callee_name: String) -> Self {
Self {
candidate_files,
callee_name,
resolution: LocalCallResolution::Named,
}
}
pub(crate) fn default_export(candidate_files: Vec<String>, local_alias: String) -> Self {
Self {
candidate_files,
callee_name: local_alias,
resolution: LocalCallResolution::DefaultExport,
}
}
pub(crate) fn is_default_export(&self) -> bool {
self.resolution == LocalCallResolution::DefaultExport
}
}
#[derive(Debug, Clone, Default)]
pub(crate) struct ImportBindings {
pub(crate) bare: HashMap<String, ExternalImportBinding>,
pub(crate) local_bare: HashMap<String, LocalCallBinding>,
pub(crate) local_member: HashMap<String, Vec<String>>,
pub(crate) bare_wildcard_modules: Vec<String>,
pub(crate) member: HashMap<String, String>,
pub(crate) external_roots: HashMap<String, ExternalRootBinding>,
pub(crate) csharp_local_namespaces: Vec<String>,
pub(crate) dart_local_import_files: Vec<String>,
pub(crate) elixir_local_import_files: Vec<String>,
pub(crate) shell_source_files: Vec<String>,
pub(crate) objc_import_files: Vec<String>,
}
#[derive(Debug, Clone)]
pub(crate) struct ExternalRootBinding {
pub(crate) module: String,
pub(crate) module_from_qualifier: bool,
}
#[derive(Debug, Clone, Default)]
pub(crate) struct ExtractedImports {
pub(crate) imports: Vec<ImportRelation>,
pub(crate) bindings: ImportBindings,
}
#[derive(Debug, Clone)]
pub(crate) struct ExternalCallTarget {
pub(crate) module: String,
pub(crate) callee_name: String,
}
pub(in crate::index::import_resolution) const JS_BUILTIN_MODULES: &[&str] = &[
"assert",
"assert/strict",
"async_hooks",
"buffer",
"child_process",
"cluster",
"console",
"constants",
"crypto",
"dgram",
"diagnostics_channel",
"dns",
"dns/promises",
"domain",
"events",
"fs",
"fs/promises",
"http",
"http2",
"https",
"inspector",
"inspector/promises",
"net",
"module",
"os",
"path",
"path/posix",
"path/win32",
"perf_hooks",
"process",
"punycode",
"querystring",
"readline",
"readline/promises",
"repl",
"sea",
"stream",
"stream/consumers",
"stream/iter",
"stream/promises",
"stream/web",
"string_decoder",
"sqlite",
"sys",
"timers",
"timers/promises",
"test",
"test/reporters",
"tls",
"trace_events",
"tty",
"url",
"util",
"util/types",
"v8",
"vm",
"wasi",
"worker_threads",
"zlib",
"zlib/iter",
];