mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-10 06:34:20 +00:00
Extract some simple cleanups from 2779 (#2966)
* Chore: remove random old test fixture from CLI * nuke oidc * remove weird useless desktop example * remove lua globals vscode setting for cli * remove cli testcase * hoist deps in core-macro * we dont need prettyplease * add hoisted dependencies * hoist more despt * rename rsx_rosetta to dioxus_rsx_rosetta * drop cache thrashing when listening for features * drop flag from mobile dep * drop cli-config warning * hoist more deps * clippy... * we dont use the tools module... * bump lock
This commit is contained in:
parent
983fcfc616
commit
f0d814fede
29 changed files with 1171 additions and 1250 deletions
1788
Cargo.lock
generated
1788
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
35
Cargo.toml
35
Cargo.toml
|
@ -84,7 +84,7 @@ dioxus-liveview = { path = "packages/liveview", version = "0.6.0-alpha.0" }
|
|||
dioxus-autofmt = { path = "packages/autofmt", version = "0.6.0-alpha.0" }
|
||||
dioxus-check = { path = "packages/check", version = "0.6.0-alpha.0" }
|
||||
dioxus-rsx = { path = "packages/rsx", version = "0.6.0-alpha.0" }
|
||||
rsx-rosetta = { path = "packages/rsx-rosetta", version = "0.6.0-alpha.0" }
|
||||
dioxus-rsx-rosetta = { path = "packages/rsx-rosetta", version = "0.6.0-alpha.0" }
|
||||
dioxus-signals = { path = "packages/signals", version = "0.6.0-alpha.0" }
|
||||
dioxus-cli-config = { path = "packages/cli-config", version = "0.6.0-alpha.0", default-features = false}
|
||||
generational-box = { path = "packages/generational-box", version = "0.6.0-alpha.0" }
|
||||
|
@ -147,12 +147,39 @@ once_cell = "1.17.1"
|
|||
uuid = "1.9.1"
|
||||
convert_case = "0.6.0"
|
||||
tokio-tungstenite = { version = "0.23.1" }
|
||||
|
||||
# cli, cli-config
|
||||
gloo-timers = "0.3.0"
|
||||
fluent-uri = { version = "0.2.0", features = ["serde"] }
|
||||
internment = { version = "0.7.0" }
|
||||
proc-macro2-diagnostics = { version = "0.10", default-features = false }
|
||||
env_logger = "0.11.0"
|
||||
tracing-subscriber = "0.3.17"
|
||||
chrono = { version = "0.4.34" }
|
||||
gloo = { version = "0.8.0" }
|
||||
gloo-utils = { version = "0.1.6" }
|
||||
rustversion = "1.0.17"
|
||||
rand = "0.8.5"
|
||||
longest-increasing-subsequence = "0.1.0"
|
||||
trybuild = "1.0"
|
||||
js-sys = "0.3.56"
|
||||
web-sys = { version = "0.3.56", default-features = false }
|
||||
dirs = "5.0.1"
|
||||
|
||||
cargo-config2 = "0.1.26"
|
||||
criterion = { version = "0.5" }
|
||||
|
||||
# desktop
|
||||
wry = { version = "0.43.0", default-features = false }
|
||||
tao = { version = "0.30.0", features = ["rwh_05"] }
|
||||
webbrowser = "1.0.1"
|
||||
infer = "0.16.0"
|
||||
dunce = "1.0.2"
|
||||
urlencoding = "2.1.2"
|
||||
global-hotkey = "0.6.0"
|
||||
rfd = { version = "0.14", default-features = false }
|
||||
muda = "0.14.0"
|
||||
cocoa = "0.26"
|
||||
core-foundation = "0.10.0"
|
||||
objc = { version = "0.2.7", features = ["exception"] }
|
||||
objc_id = "0.1.1"
|
||||
|
||||
[profile.dev.package.dioxus-core-macro]
|
||||
opt-level = 3
|
||||
|
|
|
@ -1,13 +1,3 @@
|
|||
// warn if the "read-config" feature is enabled, but the DIOXUS_CONFIG environment variable is not set
|
||||
// This means that some library is trying to access the crate's configuration, but the dioxus CLI was not used to build the application.
|
||||
|
||||
fn main() {
|
||||
built::write_built_file().expect("Failed to acquire build-time information");
|
||||
|
||||
println!("cargo:rerun-if-env-changed=DIOXUS_CONFIG");
|
||||
let dioxus_config = std::env::var("DIOXUS_CONFIG");
|
||||
let built_with_dioxus = dioxus_config.is_ok();
|
||||
if cfg!(feature = "read-config") && !built_with_dioxus {
|
||||
println!("cargo:warning=A library is trying to access the crate's configuration, but the dioxus CLI was not used to build the application. Information about the Dioxus CLI is available at https://dioxuslabs.com/learn/0.5/CLI/installation");
|
||||
}
|
||||
}
|
||||
|
|
6
packages/cli/.vscode/settings.json
vendored
6
packages/cli/.vscode/settings.json
vendored
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"Lua.diagnostics.globals": [
|
||||
"plugin_logger",
|
||||
"PLUGIN_DOWNLOADER"
|
||||
]
|
||||
}
|
|
@ -89,7 +89,7 @@ brotli = "6.0.0"
|
|||
|
||||
dioxus-autofmt = { workspace = true }
|
||||
dioxus-check = { workspace = true }
|
||||
rsx-rosetta = { workspace = true }
|
||||
dioxus-rsx-rosetta = { workspace = true }
|
||||
dioxus-rsx = { workspace = true, features = ["serde"]}
|
||||
dioxus-html = { workspace = true, features = ["hot-reload-context"] }
|
||||
dioxus-core = { workspace = true, features = ["serialize"] }
|
||||
|
|
|
@ -50,7 +50,7 @@ impl Translate {
|
|||
}
|
||||
|
||||
pub fn convert_html_to_formatted_rsx(dom: &Dom, component: bool) -> String {
|
||||
let callbody = rsx_rosetta::rsx_from_html(dom);
|
||||
let callbody = dioxus_rsx_rosetta::rsx_from_html(dom);
|
||||
|
||||
match component {
|
||||
true => write_callbody_with_icon_section(callbody),
|
||||
|
@ -61,7 +61,7 @@ pub fn convert_html_to_formatted_rsx(dom: &Dom, component: bool) -> String {
|
|||
fn write_callbody_with_icon_section(mut callbody: CallBody) -> String {
|
||||
let mut svgs = vec![];
|
||||
|
||||
rsx_rosetta::collect_svgs(&mut callbody.body.roots, &mut svgs);
|
||||
dioxus_rsx_rosetta::collect_svgs(&mut callbody.body.roots, &mut svgs);
|
||||
|
||||
let mut out = write_component_body(dioxus_autofmt::write_block_out(&callbody).unwrap());
|
||||
|
||||
|
@ -130,12 +130,3 @@ fn determine_input(file: Option<String>, raw: Option<String>) -> Result<String>
|
|||
|
||||
Ok(buffer.trim().to_string())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn generates_svgs() {
|
||||
let st = include_str!("../../tests/svg.html");
|
||||
|
||||
let out = convert_html_to_formatted_rsx(&html_parser::Dom::parse(st).unwrap(), true);
|
||||
|
||||
println!("{}", out);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ pub mod error;
|
|||
pub mod metadata;
|
||||
pub mod serve;
|
||||
pub mod settings;
|
||||
pub mod tools;
|
||||
pub mod tracer;
|
||||
|
||||
pub(crate) use cli::*;
|
||||
|
|
|
@ -1,369 +0,0 @@
|
|||
use std::{
|
||||
fs::{create_dir_all, File},
|
||||
io::{ErrorKind, Read, Write},
|
||||
path::{Path, PathBuf},
|
||||
process::Command,
|
||||
};
|
||||
|
||||
use anyhow::Context;
|
||||
use flate2::read::GzDecoder;
|
||||
use futures_util::StreamExt;
|
||||
use tar::Archive;
|
||||
use tokio::io::AsyncWriteExt;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum Tool {
|
||||
Sass,
|
||||
Tailwind,
|
||||
}
|
||||
|
||||
pub fn app_path() -> PathBuf {
|
||||
let data_local = dirs::data_local_dir().unwrap();
|
||||
let dioxus_dir = data_local.join("dioxus");
|
||||
if !dioxus_dir.is_dir() {
|
||||
create_dir_all(&dioxus_dir).unwrap();
|
||||
}
|
||||
dioxus_dir
|
||||
}
|
||||
|
||||
pub fn temp_path() -> PathBuf {
|
||||
let app_path = app_path();
|
||||
let temp_path = app_path.join("temp");
|
||||
if !temp_path.is_dir() {
|
||||
create_dir_all(&temp_path).unwrap();
|
||||
}
|
||||
temp_path
|
||||
}
|
||||
|
||||
pub fn clone_repo(dir: &Path, url: &str) -> anyhow::Result<()> {
|
||||
let target_dir = dir.parent().unwrap();
|
||||
let dir_name = dir.file_name().unwrap();
|
||||
|
||||
let mut cmd = Command::new("git");
|
||||
let cmd = cmd.current_dir(target_dir);
|
||||
let res = cmd.arg("clone").arg(url).arg(dir_name).output();
|
||||
if let Err(err) = res {
|
||||
if ErrorKind::NotFound == err.kind() {
|
||||
tracing::warn!("Git program not found. Hint: Install git or check $PATH.");
|
||||
return Err(err.into());
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn tools_path() -> PathBuf {
|
||||
let app_path = app_path();
|
||||
let temp_path = app_path.join("tools");
|
||||
if !temp_path.is_dir() {
|
||||
create_dir_all(&temp_path).unwrap();
|
||||
}
|
||||
temp_path
|
||||
}
|
||||
|
||||
#[allow(clippy::should_implement_trait)]
|
||||
impl Tool {
|
||||
/// from str to tool enum
|
||||
pub fn from_str(name: &str) -> Option<Self> {
|
||||
match name {
|
||||
"sass" => Some(Self::Sass),
|
||||
"tailwindcss" => Some(Self::Tailwind),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// get current tool name str
|
||||
pub fn name(&self) -> &str {
|
||||
match self {
|
||||
Self::Sass => "sass",
|
||||
Self::Tailwind => "tailwindcss",
|
||||
}
|
||||
}
|
||||
|
||||
/// get tool bin dir path
|
||||
pub fn bin_path(&self) -> &str {
|
||||
match self {
|
||||
Self::Sass => ".",
|
||||
Self::Tailwind => ".",
|
||||
}
|
||||
}
|
||||
|
||||
/// get target platform
|
||||
pub fn target_platform(&self) -> &str {
|
||||
match self {
|
||||
Self::Sass => {
|
||||
if cfg!(target_os = "windows") {
|
||||
"windows"
|
||||
} else if cfg!(target_os = "macos") {
|
||||
"macos"
|
||||
} else if cfg!(target_os = "linux") {
|
||||
"linux"
|
||||
} else {
|
||||
panic!("unsupported platformm");
|
||||
}
|
||||
}
|
||||
Self::Tailwind => {
|
||||
if cfg!(target_os = "windows") {
|
||||
"windows"
|
||||
} else if cfg!(target_os = "macos") {
|
||||
"macos"
|
||||
} else if cfg!(target_os = "linux") {
|
||||
"linux"
|
||||
} else {
|
||||
panic!("unsupported platformm");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// get tool version
|
||||
pub fn tool_version(&self) -> &str {
|
||||
match self {
|
||||
Self::Sass => "1.51.0",
|
||||
Self::Tailwind => "v3.1.6",
|
||||
}
|
||||
}
|
||||
|
||||
/// get tool package download url
|
||||
pub fn download_url(&self) -> String {
|
||||
match self {
|
||||
Self::Sass => {
|
||||
format!(
|
||||
"https://github.com/sass/dart-sass/releases/download/{version}/dart-sass-{version}-{target}-x64.{extension}",
|
||||
version = self.tool_version(),
|
||||
target = self.target_platform(),
|
||||
extension = self.extension()
|
||||
)
|
||||
}
|
||||
Self::Tailwind => {
|
||||
let windows_extension = match self.target_platform() {
|
||||
"windows" => ".exe",
|
||||
_ => "",
|
||||
};
|
||||
format!(
|
||||
"https://github.com/tailwindlabs/tailwindcss/releases/download/{version}/tailwindcss-{target}-x64{optional_ext}",
|
||||
version = self.tool_version(),
|
||||
target = self.target_platform(),
|
||||
optional_ext = windows_extension
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// get package extension name
|
||||
pub fn extension(&self) -> &str {
|
||||
match self {
|
||||
Self::Sass => {
|
||||
if cfg!(target_os = "windows") {
|
||||
"zip"
|
||||
} else {
|
||||
"tar.gz"
|
||||
}
|
||||
}
|
||||
Self::Tailwind => "bin",
|
||||
}
|
||||
}
|
||||
|
||||
/// check tool state
|
||||
pub fn is_installed(&self) -> bool {
|
||||
tools_path().join(self.name()).is_dir()
|
||||
}
|
||||
|
||||
/// get download temp path
|
||||
pub fn temp_out_path(&self) -> PathBuf {
|
||||
temp_path().join(format!("{}-tool.tmp", self.name()))
|
||||
}
|
||||
|
||||
/// start to download package
|
||||
pub async fn download_package(&self) -> anyhow::Result<PathBuf> {
|
||||
let download_url = self.download_url();
|
||||
let temp_out = self.temp_out_path();
|
||||
let mut file = tokio::fs::File::create(&temp_out)
|
||||
.await
|
||||
.context("failed creating temporary output file")?;
|
||||
|
||||
let resp = reqwest::get(download_url).await.unwrap();
|
||||
|
||||
let mut res_bytes = resp.bytes_stream();
|
||||
while let Some(chunk_res) = res_bytes.next().await {
|
||||
let chunk = chunk_res.context("error reading chunk from download")?;
|
||||
let _ = file.write(chunk.as_ref()).await;
|
||||
}
|
||||
// tracing::info!("temp file path: {:?}", temp_out);
|
||||
Ok(temp_out)
|
||||
}
|
||||
|
||||
/// start to install package
|
||||
pub async fn install_package(&self) -> anyhow::Result<()> {
|
||||
let temp_path = self.temp_out_path();
|
||||
let tool_path = tools_path();
|
||||
|
||||
let dir_name = match self {
|
||||
Self::Sass => "dart-sass".to_string(),
|
||||
Self::Tailwind => self.name().to_string(),
|
||||
};
|
||||
|
||||
if self.extension() == "tar.gz" {
|
||||
let tar_gz = File::open(temp_path)?;
|
||||
let tar = GzDecoder::new(tar_gz);
|
||||
let mut archive = Archive::new(tar);
|
||||
archive.unpack(&tool_path)?;
|
||||
std::fs::rename(tool_path.join(dir_name), tool_path.join(self.name()))?;
|
||||
} else if self.extension() == "zip" {
|
||||
// decompress the `zip` file
|
||||
extract_zip(&temp_path, &tool_path)?;
|
||||
std::fs::rename(tool_path.join(dir_name), tool_path.join(self.name()))?;
|
||||
} else if self.extension() == "bin" {
|
||||
let bin_path = match self.target_platform() {
|
||||
"windows" => tool_path.join(&dir_name).join(self.name()).join(".exe"),
|
||||
_ => tool_path.join(&dir_name).join(self.name()),
|
||||
};
|
||||
// Manually creating tool directory because we directly download the binary via Github
|
||||
std::fs::create_dir(tool_path.join(dir_name))?;
|
||||
|
||||
let mut final_file = std::fs::File::create(&bin_path)?;
|
||||
let mut temp_file = File::open(&temp_path)?;
|
||||
let mut content = Vec::new();
|
||||
|
||||
temp_file.read_to_end(&mut content)?;
|
||||
final_file.write_all(&content)?;
|
||||
|
||||
if self.target_platform() == "linux" {
|
||||
// This code does not update permissions idk why
|
||||
// let mut perms = final_file.metadata()?.permissions();
|
||||
// perms.set_mode(0o744);
|
||||
|
||||
// Adding to the binary execution rights with "chmod"
|
||||
let mut command = Command::new("chmod");
|
||||
|
||||
let _ = command
|
||||
.args(vec!["+x", bin_path.to_str().unwrap()])
|
||||
.stdout(std::process::Stdio::inherit())
|
||||
.stderr(std::process::Stdio::inherit())
|
||||
.output()?;
|
||||
}
|
||||
|
||||
std::fs::remove_file(&temp_path)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn call(&self, command: &str, args: Vec<&str>) -> anyhow::Result<Vec<u8>> {
|
||||
let bin_path = tools_path().join(self.name()).join(self.bin_path());
|
||||
|
||||
let command_file = match self {
|
||||
Tool::Sass => {
|
||||
if cfg!(target_os = "windows") {
|
||||
format!("{}.bat", command)
|
||||
} else {
|
||||
command.to_string()
|
||||
}
|
||||
}
|
||||
Tool::Tailwind => {
|
||||
if cfg!(target_os = "windows") {
|
||||
format!("{}.exe", command)
|
||||
} else {
|
||||
command.to_string()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if !bin_path.join(&command_file).is_file() {
|
||||
return Err(anyhow::anyhow!("Command file not found."));
|
||||
}
|
||||
|
||||
let mut command = Command::new(bin_path.join(&command_file).to_str().unwrap());
|
||||
|
||||
let output = command
|
||||
.args(&args[..])
|
||||
.stdout(std::process::Stdio::inherit())
|
||||
.stderr(std::process::Stdio::inherit())
|
||||
.output()?;
|
||||
Ok(output.stdout)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn extract_zip(file: &Path, target: &Path) -> anyhow::Result<()> {
|
||||
let zip_file = std::fs::File::open(file)?;
|
||||
let mut zip = zip::ZipArchive::new(zip_file)?;
|
||||
|
||||
if !target.exists() {
|
||||
std::fs::create_dir_all(target)?;
|
||||
}
|
||||
|
||||
for i in 0..zip.len() {
|
||||
let mut zip_entry = zip.by_index(i)?;
|
||||
|
||||
// check for dangerous paths
|
||||
// see https://docs.rs/zip/latest/zip/read/struct.ZipFile.html#warnings
|
||||
let Some(enclosed_name) = zip_entry.enclosed_name() else {
|
||||
return Err(anyhow::anyhow!(
|
||||
"Refusing to unpack zip entry with potentially dangerous path: zip={} entry={:?}",
|
||||
file.display(),
|
||||
zip_entry.name()
|
||||
));
|
||||
};
|
||||
|
||||
let output_path = target.join(enclosed_name);
|
||||
if zip_entry.is_dir() {
|
||||
std::fs::create_dir_all(output_path)?;
|
||||
} else {
|
||||
// create parent dirs if needed
|
||||
if let Some(parent) = output_path.parent() {
|
||||
std::fs::create_dir_all(parent)?;
|
||||
}
|
||||
|
||||
// extract file
|
||||
let mut target_file = if !output_path.exists() {
|
||||
std::fs::File::create(output_path)?
|
||||
} else {
|
||||
std::fs::File::open(output_path)?
|
||||
};
|
||||
let _num = std::io::copy(&mut zip_entry, &mut target_file)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use tempfile::tempdir;
|
||||
|
||||
#[test]
|
||||
fn test_extract_zip() -> anyhow::Result<()> {
|
||||
let path = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap())
|
||||
.join("tests/fixtures/test.zip");
|
||||
let temp_dir = tempdir()?;
|
||||
let temp_path = temp_dir.path();
|
||||
|
||||
extract_zip(path.as_path(), temp_path)?;
|
||||
|
||||
let expected_files = vec!["file1.txt", "file2.txt", "dir/file3.txt"];
|
||||
for file in expected_files {
|
||||
let path = temp_path.join(file);
|
||||
assert!(path.exists(), "File not found: {:?}", path);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_extract_zip_dangerous_path() -> anyhow::Result<()> {
|
||||
let path = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap())
|
||||
.join("tests/fixtures/dangerous.zip");
|
||||
let temp_dir = tempdir()?;
|
||||
let temp_path = temp_dir.path();
|
||||
|
||||
let result = extract_zip(path.as_path(), temp_path);
|
||||
|
||||
let err = result.unwrap_err();
|
||||
assert!(err
|
||||
.to_string()
|
||||
.contains("Refusing to unpack zip entry with potentially dangerous path: zip="));
|
||||
assert!(err.to_string().contains("entry=\"/etc/passwd\""));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
BIN
packages/cli/tests/fixtures/dangerous.zip
vendored
BIN
packages/cli/tests/fixtures/dangerous.zip
vendored
Binary file not shown.
BIN
packages/cli/tests/fixtures/test.zip
vendored
BIN
packages/cli/tests/fixtures/test.zip
vendored
Binary file not shown.
|
@ -1,4 +0,0 @@
|
|||
//! Test that autoformatting works on files/folders/etc
|
||||
|
||||
#[tokio::test]
|
||||
async fn formats() {}
|
|
@ -1,4 +0,0 @@
|
|||
#[test]
|
||||
fn ready() {
|
||||
println!("Compiled successfully!")
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
<div>
|
||||
<svg class="h-5 w-5 text-gray-500" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z"
|
||||
clip-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
<svg class="h-5 w-5 text-gray-500" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z"
|
||||
clip-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
<svg class="h-5 w-5 text-gray-500" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z"
|
||||
clip-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
<svg class="h-5 w-5 text-gray-500" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z"
|
||||
clip-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
|
@ -1,48 +0,0 @@
|
|||
<section class="text-gray-600 body-font">
|
||||
<div class="container px-5 py-24 mx-auto">
|
||||
<div class="flex flex-wrap -mx-4 -mb-10 text-center">
|
||||
<div class="sm:w-1/2 mb-10 px-4">
|
||||
<div class="rounded-lg h-64 overflow-hidden">
|
||||
<img
|
||||
alt="content"
|
||||
class="object-cover object-center h-full w-full"
|
||||
src="https://dummyimage.com/1201x501"
|
||||
/>
|
||||
</div>
|
||||
<h2 class="title-font text-2xl font-medium text-gray-900 mt-6 mb-3">
|
||||
Buy YouTube Videos
|
||||
</h2>
|
||||
<p class="leading-relaxed text-base">
|
||||
Williamsburg occupy sustainable snackwave gochujang. Pinterest
|
||||
cornhole brunch, slow-carb neutra irony.
|
||||
</p>
|
||||
<button
|
||||
class="flex mx-auto mt-6 text-white bg-indigo-500 border-0 py-2 px-5 focus:outline-none hover:bg-indigo-600 rounded"
|
||||
>
|
||||
Button
|
||||
</button>
|
||||
</div>
|
||||
<div class="sm:w-1/2 mb-10 px-4">
|
||||
<div class="rounded-lg h-64 overflow-hidden">
|
||||
<img
|
||||
alt="content"
|
||||
class="object-cover object-center h-full w-full"
|
||||
src="https://dummyimage.com/1202x502"
|
||||
/>
|
||||
</div>
|
||||
<h2 class="title-font text-2xl font-medium text-gray-900 mt-6 mb-3">
|
||||
The Catalyzer
|
||||
</h2>
|
||||
<p class="leading-relaxed text-base">
|
||||
Williamsburg occupy sustainable snackwave gochujang. Pinterest
|
||||
cornhole brunch, slow-carb neutra irony.
|
||||
</p>
|
||||
<button
|
||||
class="flex mx-auto mt-6 text-white bg-indigo-500 border-0 py-2 px-5 focus:outline-none hover:bg-indigo-600 rounded"
|
||||
>
|
||||
Button
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
|
@ -13,20 +13,18 @@ keywords = ["dom", "ui", "gui", "react"]
|
|||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
proc-macro2 = { version = "1.0" }
|
||||
proc-macro2 = { workspace = true }
|
||||
quote = { workspace = true }
|
||||
syn = { workspace = true, features = ["full", "extra-traits", "visit"] }
|
||||
dioxus-rsx = { workspace = true }
|
||||
convert_case = { workspace = true }
|
||||
prettyplease = "0.2.15"
|
||||
|
||||
# testing
|
||||
[dev-dependencies]
|
||||
dioxus = { workspace = true }
|
||||
dioxus-html = { workspace = true, features = ["serialize"]}
|
||||
rustversion = "1.0"
|
||||
rustversion = { workspace = true }
|
||||
tokio = { workspace = true, features = ["full", "time"] }
|
||||
trybuild = "1.0"
|
||||
trybuild = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
|
|
@ -3,9 +3,6 @@ use syn::parse::{Parse, ParseStream};
|
|||
use syn::spanned::Spanned;
|
||||
use syn::{parse_quote, Expr, Lit, Meta, Token, Type};
|
||||
|
||||
const FORMATTED_TYPE_START: &str = "static TY_AFTER_HERE:";
|
||||
const FORMATTED_TYPE_END: &str = "= unreachable!();";
|
||||
|
||||
/// Attempts to convert the given literal to a string.
|
||||
/// Converts ints and floats to their base 10 counterparts.
|
||||
///
|
||||
|
@ -29,20 +26,8 @@ pub fn format_type_string(ty: &Type) -> String {
|
|||
let ty_unformatted = ty.into_token_stream().to_string();
|
||||
let ty_unformatted = ty_unformatted.trim();
|
||||
|
||||
// This should always be valid syntax.
|
||||
// Not Rust code, but syntax, which is the only thing that `syn` cares about.
|
||||
let Ok(file_unformatted) = syn::parse_file(&format!(
|
||||
"{FORMATTED_TYPE_START}{ty_unformatted}{FORMATTED_TYPE_END}"
|
||||
)) else {
|
||||
return ty_unformatted.to_string();
|
||||
};
|
||||
|
||||
let file_formatted = prettyplease::unparse(&file_unformatted);
|
||||
|
||||
let file_trimmed = file_formatted.trim();
|
||||
let start_removed = file_trimmed.trim_start_matches(FORMATTED_TYPE_START);
|
||||
let end_removed = start_removed.trim_end_matches(FORMATTED_TYPE_END);
|
||||
let ty_formatted = end_removed.trim();
|
||||
// simply remove all whitespace
|
||||
let ty_formatted = ty_unformatted.replace(' ', "");
|
||||
|
||||
ty_formatted.to_string()
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ keywords = ["dom", "ui", "gui", "react"]
|
|||
|
||||
[dependencies]
|
||||
rustc-hash = { workspace = true }
|
||||
longest-increasing-subsequence = "0.1.0"
|
||||
longest-increasing-subsequence = { workspace = true }
|
||||
futures-util = { workspace = true, default-features = false, features = [
|
||||
"alloc",
|
||||
"std",
|
||||
|
@ -20,9 +20,9 @@ slab = { workspace = true }
|
|||
slotmap = { workspace = true }
|
||||
futures-channel = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
serde = { version = "1", features = ["derive"], optional = true }
|
||||
serde = {workspace = true, optional = true, features = ["derive"] }
|
||||
generational-box = { workspace = true }
|
||||
rustversion = "1.0.17"
|
||||
rustversion = { workspace = true }
|
||||
const_format = { workspace = true }
|
||||
warnings = { workspace = true }
|
||||
manganis = { workspace = true, default-features = false, optional = true }
|
||||
|
@ -33,10 +33,10 @@ tracing-fluent-assertions = "0.3.0"
|
|||
dioxus = { workspace = true }
|
||||
dioxus-html = { workspace = true, features = ["serialize"] }
|
||||
pretty_assertions = "1.3.0"
|
||||
rand = "0.8.5"
|
||||
rand = { workspace = true }
|
||||
dioxus-ssr = { workspace = true }
|
||||
reqwest = { workspace = true}
|
||||
tracing-subscriber = "0.3.18"
|
||||
tracing-subscriber = { workspace = true }
|
||||
|
||||
[dev-dependencies.web-sys]
|
||||
version = "0.3.56"
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
fn main() {
|
||||
// Warn the user if they enabled the launch feature without any renderers
|
||||
if feature_enabled("launch") {
|
||||
if feature_enabled("third-party-renderer") {
|
||||
return;
|
||||
}
|
||||
|
||||
let liveview_renderers = ["liveview", "server"];
|
||||
let fullstack_renderers = ["server"];
|
||||
let client_renderers = ["desktop", "mobile", "web"];
|
||||
let client_renderer_selected = client_renderers
|
||||
.iter()
|
||||
.any(|renderer| feature_enabled(renderer));
|
||||
if feature_enabled("fullstack") {
|
||||
let server_fullstack_enabled = fullstack_renderers
|
||||
.iter()
|
||||
.any(|renderer| feature_enabled(renderer));
|
||||
if !server_fullstack_enabled && !client_renderer_selected {
|
||||
println!("cargo:warning=You have enabled the launch and fullstack features, but have not enabled any renderers. The application will not be able to launch. Try enabling one of the following renderers: {} for the server or one of the following renderers: {} for the client.", fullstack_renderers.join(", "), client_renderers.join(", "));
|
||||
}
|
||||
}
|
||||
|
||||
if feature_enabled("liveview") {
|
||||
let server_selected = liveview_renderers
|
||||
.iter()
|
||||
.any(|renderer| feature_enabled(renderer));
|
||||
if !server_selected {
|
||||
println!("cargo:warning=You have enabled the launch and liveview features, but have not enabled any liveview renderers. The application will not be able to launch. Try enabling one of the following renderers: {}", liveview_renderers.join(", "));
|
||||
}
|
||||
}
|
||||
|
||||
if !client_renderer_selected {
|
||||
println!("cargo:warning=You have enabled the launch feature, but have not enabled any client renderers. The application will not be able to launch. Try enabling one of the following renderers: {}, fullstack or liveview", client_renderers.join(", "));
|
||||
}
|
||||
}
|
||||
|
||||
if feature_enabled("axum") {
|
||||
println!("cargo:warning=The axum feature has been renamed to server and will be removed in a future release. Please update your code to use server feature instead.");
|
||||
}
|
||||
}
|
||||
|
||||
fn feature_enabled(feature: &str) -> bool {
|
||||
let feature = "CARGO_FEATURE_".to_owned() + &feature.to_uppercase().replace('-', "_");
|
||||
println!("cargo:rerun-if-env-changed={}", feature);
|
||||
std::env::var(feature).is_ok()
|
||||
}
|
|
@ -9,7 +9,7 @@ publish = false
|
|||
[dependencies]
|
||||
wasm-bindgen = { workspace = true }
|
||||
dioxus-autofmt = { workspace = true }
|
||||
rsx-rosetta = { workspace = true }
|
||||
dioxus-rsx-rosetta = { workspace = true }
|
||||
html_parser = { workspace = true }
|
||||
syn ={ workspace = true }
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ pub fn translate_rsx(contents: String, _component: bool) -> String {
|
|||
// Ensure we're loading valid HTML
|
||||
let dom = html_parser::Dom::parse(&contents).unwrap();
|
||||
|
||||
let callbody = rsx_rosetta::rsx_from_html(&dom);
|
||||
let callbody = dioxus_rsx_rosetta::rsx_from_html(&dom);
|
||||
|
||||
// Convert the HTML to RSX
|
||||
dioxus_autofmt::write_block_out(&callbody).unwrap()
|
||||
|
|
|
@ -10,7 +10,7 @@ keywords = ["dom", "ui", "gui", "react"]
|
|||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
dioxus-desktop = { workspace = true, features = ["tokio_runtime"] }
|
||||
dioxus-desktop = { workspace = true }
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "rsx-rosetta"
|
||||
name = "dioxus-rsx-rosetta"
|
||||
version = { workspace = true }
|
||||
edition = "2021"
|
||||
authors = ["Jonathan Kelley"]
|
||||
|
@ -22,11 +22,6 @@ quote = { workspace = true }
|
|||
syn = { workspace = true, features = ["full"] }
|
||||
convert_case = { workspace = true }
|
||||
|
||||
# [features]
|
||||
# default = ["html"]
|
||||
|
||||
# eventually more output options
|
||||
|
||||
[dev-dependencies]
|
||||
pretty_assertions = "1.2.1"
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ fn main() {
|
|||
|
||||
let dom = Dom::parse(html).unwrap();
|
||||
|
||||
let body = rsx_rosetta::rsx_from_html(&dom);
|
||||
let body = dioxus_rsx_rosetta::rsx_from_html(&dom);
|
||||
|
||||
let out = dioxus_autofmt::write_block_out(&body).unwrap();
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ fn h_tags_translate() {
|
|||
|
||||
let dom = Dom::parse(html).unwrap();
|
||||
|
||||
let body = rsx_rosetta::rsx_from_html(&dom);
|
||||
let body = dioxus_rsx_rosetta::rsx_from_html(&dom);
|
||||
|
||||
let out = dioxus_autofmt::write_block_out(&body).unwrap();
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ fn raw_attribute() {
|
|||
|
||||
let dom = Dom::parse(html).unwrap();
|
||||
|
||||
let body = rsx_rosetta::rsx_from_html(&dom);
|
||||
let body = dioxus_rsx_rosetta::rsx_from_html(&dom);
|
||||
|
||||
let out = dioxus_autofmt::write_block_out(&body).unwrap();
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ fn simple_elements() {
|
|||
|
||||
let dom = Dom::parse(html).unwrap();
|
||||
|
||||
let body = rsx_rosetta::rsx_from_html(&dom);
|
||||
let body = dioxus_rsx_rosetta::rsx_from_html(&dom);
|
||||
|
||||
let out = dioxus_autofmt::write_block_out(&body).unwrap();
|
||||
|
||||
|
@ -48,7 +48,7 @@ fn deeply_nested() {
|
|||
|
||||
let dom = Dom::parse(html).unwrap();
|
||||
|
||||
let body = rsx_rosetta::rsx_from_html(&dom);
|
||||
let body = dioxus_rsx_rosetta::rsx_from_html(&dom);
|
||||
|
||||
let out = dioxus_autofmt::write_block_out(&body).unwrap();
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ fn web_components_translate() {
|
|||
|
||||
let dom = Dom::parse(html).unwrap();
|
||||
|
||||
let body = rsx_rosetta::rsx_from_html(&dom);
|
||||
let body = dioxus_rsx_rosetta::rsx_from_html(&dom);
|
||||
|
||||
let out = dioxus_autofmt::write_block_out(&body).unwrap();
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ description = "Server function macros for Dioxus"
|
|||
proc-macro2 = "^1.0.63"
|
||||
quote = "^1.0.26"
|
||||
syn = { workspace = true, features = ["full"] }
|
||||
convert_case = { workspace = true }
|
||||
server_fn_macro = "0.6.11"
|
||||
|
||||
[lib]
|
||||
|
|
|
@ -30,7 +30,7 @@ tokio = { version = "1", features = ["full"] }
|
|||
tracing-subscriber = "0.3.17"
|
||||
simple_logger = "4.2.0"
|
||||
reqwest = { workspace = true }
|
||||
rand = "0.8"
|
||||
rand = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
|
Loading…
Reference in a new issue