feat: improve native

This commit is contained in:
DarkSky
2026-02-01 20:15:34 +08:00
parent 948951d461
commit 059d3aa04a
8 changed files with 101 additions and 57 deletions
+3 -4
View File
@@ -1,7 +1,6 @@
use affine_common::doc_loader::Doc;
use affine_common::{doc_loader::Doc, napi_utils::map_napi_err};
use napi::{
Env, Result, Task,
anyhow::anyhow,
Env, Result, Status, Task,
bindgen_prelude::{AsyncTask, Buffer},
};
@@ -54,7 +53,7 @@ impl Task for AsyncParseDocResponse {
type JsValue = ParsedDoc;
fn compute(&mut self) -> Result<Self::Output> {
let doc = Doc::new(&self.file_path, &self.doc).map_err(|e| anyhow!(e))?;
let doc = map_napi_err(Doc::new(&self.file_path, &self.doc), Status::GenericFailure)?;
Ok(Document { inner: doc })
}