mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-11-22 12:34:39 +00:00
feat: move and compile tinymist crate for wasm32 target (#2027)
Some checks are pending
tinymist::auto_tag / auto-tag (push) Waiting to run
tinymist::ci / Duplicate Actions Detection (push) Waiting to run
tinymist::ci / Check Clippy, Formatting, Completion, Documentation, and Tests (Linux) (push) Waiting to run
tinymist::ci / Check Minimum Rust version and Tests (Windows) (push) Waiting to run
tinymist::ci / prepare-build (push) Waiting to run
tinymist::ci / announce (push) Blocked by required conditions
tinymist::ci / build (push) Blocked by required conditions
tinymist::gh_pages / build-gh-pages (push) Waiting to run
Some checks are pending
tinymist::auto_tag / auto-tag (push) Waiting to run
tinymist::ci / Duplicate Actions Detection (push) Waiting to run
tinymist::ci / Check Clippy, Formatting, Completion, Documentation, and Tests (Linux) (push) Waiting to run
tinymist::ci / Check Minimum Rust version and Tests (Windows) (push) Waiting to run
tinymist::ci / prepare-build (push) Waiting to run
tinymist::ci / announce (push) Blocked by required conditions
tinymist::ci / build (push) Blocked by required conditions
tinymist::gh_pages / build-gh-pages (push) Waiting to run
This commit is contained in:
parent
79f68dc94d
commit
ce5ab81760
56 changed files with 1558 additions and 1122 deletions
|
|
@ -69,6 +69,7 @@ sha2 = { version = "0.10" }
|
|||
hex = { version = "0.4" }
|
||||
|
||||
[features]
|
||||
local-registry = ["tinymist-world/system"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -34,13 +34,16 @@ impl CompletionPair<'_, '_, '_> {
|
|||
.iter()
|
||||
.map(|(spec, desc)| (spec, desc.clone()))
|
||||
.collect();
|
||||
// local_packages to references and add them to the packages
|
||||
let local_packages_refs = self.worker.ctx.local_packages();
|
||||
packages.extend(
|
||||
local_packages_refs
|
||||
.iter()
|
||||
.map(|spec| (spec, Some(eco_format!("{} v{}", spec.name, spec.version)))),
|
||||
);
|
||||
#[cfg(feature = "http-registry")]
|
||||
{
|
||||
// local_packages to references and add them to the packages
|
||||
let local_packages_refs = self.worker.ctx.local_packages();
|
||||
packages.extend(
|
||||
local_packages_refs
|
||||
.iter()
|
||||
.map(|spec| (spec, Some(eco_format!("{} v{}", spec.name, spec.version)))),
|
||||
);
|
||||
}
|
||||
|
||||
packages.sort_by_key(|(spec, _)| (&spec.namespace, &spec.name, Reverse(spec.version)));
|
||||
if !all_versions {
|
||||
|
|
|
|||
|
|
@ -672,7 +672,7 @@ impl SharedContext {
|
|||
}
|
||||
|
||||
/// Get the local packages and their descriptions.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[cfg(feature = "local-registry")]
|
||||
pub fn local_packages(&self) -> EcoVec<PackageSpec> {
|
||||
crate::package::list_package_by_namespace(&self.world.registry, eco_format!("local"))
|
||||
.into_iter()
|
||||
|
|
@ -681,7 +681,7 @@ impl SharedContext {
|
|||
}
|
||||
|
||||
/// Get the local packages and their descriptions.
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[cfg(not(feature = "local-registry"))]
|
||||
pub fn local_packages(&self) -> EcoVec<PackageSpec> {
|
||||
eco_vec![]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,14 +43,14 @@ pub fn path_res_to_url(path: PathResolution) -> anyhow::Result<Url> {
|
|||
}
|
||||
|
||||
/// Convert a URL to a path.
|
||||
pub fn url_to_path(uri: Url) -> PathBuf {
|
||||
pub fn url_to_path(uri: &Url) -> PathBuf {
|
||||
if uri.scheme() == "file" {
|
||||
// typst converts an empty path to `Path::new("/")`, which is undesirable.
|
||||
if !uri.has_host() && uri.path() == "/" {
|
||||
return PathBuf::from("/untitled/nEoViM-BuG");
|
||||
}
|
||||
|
||||
return url_to_file_path(&uri);
|
||||
return url_to_file_path(uri);
|
||||
}
|
||||
|
||||
if uri.scheme() == "untitled" {
|
||||
|
|
@ -67,7 +67,7 @@ pub fn url_to_path(uri: Url) -> PathBuf {
|
|||
return Path::new(String::from_utf8_lossy(&bytes).as_ref()).clean();
|
||||
}
|
||||
|
||||
url_to_file_path(&uri)
|
||||
url_to_file_path(uri)
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
|
|
@ -114,7 +114,7 @@ mod test {
|
|||
assert_eq!(uri.scheme(), "untitled");
|
||||
assert_eq!(uri.path(), "test");
|
||||
|
||||
let path = url_to_path(uri);
|
||||
let path = url_to_path(&uri);
|
||||
assert_eq!(path, Path::new("/untitled/test").clean());
|
||||
}
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ mod test {
|
|||
fn unnamed_buffer() {
|
||||
// https://github.com/neovim/nvim-lspconfig/pull/2226
|
||||
let uri = EMPTY_URL.clone();
|
||||
let path = url_to_path(uri);
|
||||
let path = url_to_path(&uri);
|
||||
assert_eq!(path, Path::new("/untitled/nEoViM-BuG"));
|
||||
|
||||
let uri2 = path_to_url(&path).unwrap();
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ pub fn check_package(ctx: &mut LocalContext, spec: &PackageInfo) -> StrResult<()
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[cfg(feature = "local-registry")]
|
||||
/// Get the packages in namespaces and their descriptions.
|
||||
pub fn list_package_by_namespace(
|
||||
registry: &tinymist_world::package::registry::HttpRegistry,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue