mirror of
https://github.com/redstrate/Auracite.git
synced 2025-04-20 19:57:46 +00:00
Begin working on WebAssembly support
It now compiles, but lacks a way to actually download anything.
This commit is contained in:
parent
0e769682bd
commit
6ac3f5ced7
5 changed files with 53 additions and 30 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -92,9 +92,11 @@ dependencies = [
|
|||
name = "auracite"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"clap",
|
||||
"clap_derive",
|
||||
"downloader",
|
||||
"getrandom",
|
||||
"minijinja",
|
||||
"regex",
|
||||
"scraper",
|
||||
|
@ -523,8 +525,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"js-sys",
|
||||
"libc",
|
||||
"wasi",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
16
Cargo.toml
16
Cargo.toml
|
@ -4,6 +4,9 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
description = "Export your FFXIV character in portable, generic formats"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[dependencies]
|
||||
# Used to scrape the Lodestone HTML pages
|
||||
scraper = "0.20"
|
||||
|
@ -19,9 +22,6 @@ regex = "1.11"
|
|||
clap = { version = "4.5", features = ["derive"] }
|
||||
clap_derive = "4.5"
|
||||
|
||||
# Download HTML pages, images, etc
|
||||
downloader = "0.2"
|
||||
|
||||
# Used to generate the HTML page to easily preview your exported data
|
||||
minijinja = "2.0"
|
||||
|
||||
|
@ -29,3 +29,13 @@ minijinja = "2.0"
|
|||
# Needs my fork for allowing server shutdown
|
||||
# TODO: upstream this or poke upstream to add this
|
||||
touche = { git = "https://github.com/redstrate/touche" }
|
||||
|
||||
# Not used directly by us, but to disable the "std" feature and is used by the scraper crate.
|
||||
ahash = { version = "0.8.0", default-features = false }
|
||||
|
||||
# Ditto, but used by the ahash crate.
|
||||
getrandom = { version = "0.2", features = ["js"] }
|
||||
|
||||
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
||||
# Download HTML pages, images, etc
|
||||
downloader = "0.2"
|
|
@ -1,25 +1,35 @@
|
|||
#[cfg(not(target_family = "wasm"))]
|
||||
use downloader::{Download, Downloader};
|
||||
use std::path::Path;
|
||||
|
||||
pub fn download(url: &str, path: &Path) -> Result<(), ()> {
|
||||
let mut downloader = Downloader::builder().build().unwrap();
|
||||
|
||||
let mut dl = Download::new(url);
|
||||
dl = dl.file_name(path);
|
||||
|
||||
if !path.exists() {
|
||||
let result = downloader.download(&[dl]).unwrap();
|
||||
|
||||
for r in result {
|
||||
return match r {
|
||||
Err(e) => {
|
||||
println!("Error: {}", e.to_string());
|
||||
Err(())
|
||||
}
|
||||
Ok(s) => Ok(()),
|
||||
};
|
||||
}
|
||||
#[cfg(target_family = "wasm")]
|
||||
{
|
||||
// TODO: Implement
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Ok(())
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
{
|
||||
let mut downloader = Downloader::builder().build().unwrap();
|
||||
|
||||
let mut dl = Download::new(url);
|
||||
dl = dl.file_name(path);
|
||||
|
||||
if !path.exists() {
|
||||
let result = downloader.download(&[dl]).unwrap();
|
||||
|
||||
for r in result {
|
||||
return match r {
|
||||
Err(e) => {
|
||||
println!("Error: {}", e.to_string());
|
||||
Err(())
|
||||
}
|
||||
Ok(s) => Ok(()),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
4
src/lib.rs
Normal file
4
src/lib.rs
Normal file
|
@ -0,0 +1,4 @@
|
|||
pub mod data;
|
||||
pub mod downloader;
|
||||
pub mod html;
|
||||
pub mod parser;
|
11
src/main.rs
11
src/main.rs
|
@ -1,11 +1,6 @@
|
|||
mod data;
|
||||
mod downloader;
|
||||
mod html;
|
||||
mod parser;
|
||||
|
||||
use crate::downloader::download;
|
||||
use crate::html::write_html;
|
||||
use crate::parser::{parse_lodestone, parse_search};
|
||||
use auracite::downloader::download;
|
||||
use auracite::html::write_html;
|
||||
use auracite::parser::{parse_lodestone, parse_search};
|
||||
use clap::Parser;
|
||||
use serde::Deserialize;
|
||||
use std::convert::Infallible;
|
||||
|
|
Loading…
Add table
Reference in a new issue