Skip to content

Commit

Permalink
update wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
crowlKats committed Jan 8, 2025
1 parent 8d193b1 commit 78550ef
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ deno_doc = { path = "../", default-features = false }
import_map.workspace = true
serde.workspace = true
indexmap = "2.6.0"
deno_error = { version = "0.5.3", features = ["url"] }

console_error_panic_hook = "0.1.7"
js-sys = "=0.3.69"
Expand Down
20 changes: 14 additions & 6 deletions lib/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ use deno_doc::html::UrlResolveKind;
use deno_doc::html::UsageComposerEntry;
use deno_doc::html::UsageToMd;
use deno_doc::DocParser;
use deno_graph::source::CacheSetting;
use deno_graph::source::LoadFuture;
use deno_graph::source::LoadOptions;
use deno_graph::source::LoadResponse;
use deno_graph::source::Loader;
use deno_graph::source::ResolveError;
use deno_graph::source::Resolver;
use deno_graph::source::{CacheSetting, LoadError};
use deno_graph::BuildOptions;
use deno_graph::CapturingModuleAnalyzer;
use deno_graph::GraphKind;
Expand All @@ -25,6 +25,7 @@ use indexmap::IndexMap;
use serde::Serialize;
use std::ffi::c_void;
use std::rc::Rc;
use std::sync::Arc;
use wasm_bindgen::prelude::*;
use wasm_bindgen_futures::JsFuture;

Expand Down Expand Up @@ -83,7 +84,11 @@ impl Loader for JsLoader {
};
response
.map(|value| serde_wasm_bindgen::from_value(value).unwrap())
.map_err(|_| anyhow!("load rejected or errored"))
.map_err(|_| {
LoadError::Other(Arc::new(deno_error::JsErrorBox::generic(
"load rejected or errored",
)))
})
};
Box::pin(f)
}
Expand All @@ -108,7 +113,7 @@ impl Resolver for ImportMapResolver {
self
.0
.resolve(specifier, &referrer_range.specifier)
.map_err(|err| ResolveError::Other(err.into()))
.map_err(|err| ResolveError::ImportMap(err))
}
}

Expand Down Expand Up @@ -137,12 +142,15 @@ impl Resolver for JsResolver {
let value = match self.resolve.call2(&this, &arg0, &arg1) {
Ok(value) => value,
Err(_) => {
return Err(Other(anyhow!("JavaScript resolve() function threw.")))
return Err(Other(deno_error::JsErrorBox::generic(
"JavaScript resolve() function threw.",
)))
}
};
let value: String = serde_wasm_bindgen::from_value(value)
.map_err(|err| anyhow!("{}", err))?;
ModuleSpecifier::parse(&value).map_err(|err| Other(err.into()))
.map_err(|err| deno_error::JsErrorBox::generic(err.to_string()))?;
ModuleSpecifier::parse(&value)
.map_err(|err| Other(deno_error::JsErrorBox::from_err(err)))
}
}

Expand Down

0 comments on commit 78550ef

Please sign in to comment.