Repository navigation
chore/bump deps and improve fs #2580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2c15af4
feat(utoo-web): improve fs error translation, support cjs extension, …
xusd320 a6380a5
chore: bump tokio-fs-ext to 0.7.4 and update next.js submodule
xusd320 cce0b17
fix(wasm): export error constants from rust to ensure consistency wit…
xusd320 a1b91f1
chore(wasm): add duration logging for build tasks
xusd320 3bf88c3
chore(wasm): remove AlreadyExists error mapping and dedupe cjs extens…
xusd320 6755d32
feat(utoo-wasm): optimize tokio runtime usage
xusd320 8688954
chore(utoo-web): simplify cjs loader logic
xusd320 09c8f97
chore: update tokio-fs-ext to 0.7.7
xusd320 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,55 @@ | ||
| use std::io; | ||
| use wasm_bindgen::prelude::*; | ||
|
|
||
| // Helper macro to define constants and their JS getters (exported as functions) | ||
| macro_rules! define_error_consts { | ||
| ($($name:ident, $fn_name:ident = $val:expr),* $(,)?) => { | ||
| $( | ||
| // Internal Rust constant | ||
| pub const $name: &str = $val; | ||
|
|
||
| // Exported JS function returning the string | ||
| #[wasm_bindgen(js_name = $name)] | ||
| pub fn $fn_name() -> String { | ||
| $name.to_string() | ||
| } | ||
| )* | ||
| }; | ||
| } | ||
|
|
||
| define_error_consts! { | ||
| ERR_NOT_FOUND, err_not_found = "NotFoundError", | ||
| ERR_KEY_ALREADY_EXISTS, err_key_already_exists = "NoModificationAllowedError", | ||
| ERR_NOT_ALLOWED, err_not_allowed = "NotAllowedError", | ||
| ERR_NO_MODIFICATION_ALLOWED, err_no_modification_allowed = "NoModificationAllowedError", | ||
| ERR_TYPE_MISMATCH, err_type_mismatch = "TypeMismatchError", | ||
| ERR_QUOTA_EXCEEDED, err_quota_exceeded = "QuotaExceededError", | ||
| ERR_INVALID_STATE, err_invalid_state = "InvalidStateError", | ||
| ERR_ABORT, err_abort = "AbortError", | ||
| } | ||
|
|
||
| pub fn to_js_error<E>(e: E) -> JsError | ||
| where | ||
| E: Into<anyhow::Error>, | ||
| { | ||
| JsError::new(&format!("{:#?}", e.into())) | ||
| let err = e.into(); | ||
|
|
||
| if let Some(io_err) = err.downcast_ref::<io::Error>() { | ||
| let prefix = match io_err.kind() { | ||
| io::ErrorKind::NotFound => ERR_NOT_FOUND, | ||
| io::ErrorKind::PermissionDenied => ERR_NOT_ALLOWED, | ||
| io::ErrorKind::WouldBlock => ERR_NO_MODIFICATION_ALLOWED, | ||
| io::ErrorKind::InvalidData => ERR_TYPE_MISMATCH, | ||
| io::ErrorKind::StorageFull => ERR_QUOTA_EXCEEDED, | ||
| io::ErrorKind::InvalidInput => ERR_INVALID_STATE, | ||
| io::ErrorKind::Interrupted => ERR_ABORT, | ||
| _ => "", | ||
| }; | ||
|
|
||
| if !prefix.is_empty() { | ||
| return JsError::new(&format!("{}: {}", prefix, io_err)); | ||
| } | ||
| } | ||
|
|
||
| JsError::new(&format!("{:#?}", err)) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule next.js
updated
from 73f429 to ae2d1a
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.