set the required environment variable for manganis support
This commit is contained in:
1 parent
663296ae45
commit
e004c1722f
20 files changed
+99
-190
No files matched your search
Generated
-6
@@ -2592,7 +2592,6 @@ dependencies = [
|
|||||||
"futures-util",
|
"futures-util",
|
||||||
"global-hotkey",
|
"global-hotkey",
|
||||||
"infer 0.11.0",
|
"infer 0.11.0",
|
||||||
"manganis-cli-support",
|
|
||||||
"minify-js",
|
"minify-js",
|
||||||
"muda",
|
"muda",
|
||||||
"objc",
|
"objc",
|
||||||
@@ -2672,7 +2671,6 @@ dependencies = [
|
|||||||
"http 0.2.11",
|
"http 0.2.11",
|
||||||
"http-body-util",
|
"http-body-util",
|
||||||
"hyper 0.14.28",
|
"hyper 0.14.28",
|
||||||
"manganis-cli-support",
|
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"pin-project",
|
"pin-project",
|
||||||
"salvo",
|
"salvo",
|
||||||
@@ -6136,7 +6134,6 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "manganis"
|
name = "manganis"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/DioxusLabs/collect-assets?rev=94ea6f7#94ea6f728b3d135b5160f2c119c6e797049e4b2c"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"manganis-macro",
|
"manganis-macro",
|
||||||
]
|
]
|
||||||
@@ -6144,7 +6141,6 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "manganis-cli-support"
|
name = "manganis-cli-support"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/DioxusLabs/collect-assets?rev=94ea6f7#94ea6f728b3d135b5160f2c119c6e797049e4b2c"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cargo-lock 9.0.0",
|
"cargo-lock 9.0.0",
|
||||||
@@ -6170,7 +6166,6 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "manganis-common"
|
name = "manganis-common"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/DioxusLabs/collect-assets?rev=94ea6f7#94ea6f728b3d135b5160f2c119c6e797049e4b2c"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"base64 0.21.6",
|
"base64 0.21.6",
|
||||||
@@ -6185,7 +6180,6 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "manganis-macro"
|
name = "manganis-macro"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
source = "git+https://github.com/DioxusLabs/collect-assets?rev=94ea6f7#94ea6f728b3d135b5160f2c119c6e797049e4b2c"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.21.6",
|
"base64 0.21.6",
|
||||||
"manganis-cli-support",
|
"manganis-cli-support",
|
||||||
|
|||||||
+7
-5
@@ -98,11 +98,13 @@ thiserror = "1.0.40"
|
|||||||
prettyplease = { package = "prettier-please", version = "0.2", features = [
|
prettyplease = { package = "prettier-please", version = "0.2", features = [
|
||||||
"verbatim",
|
"verbatim",
|
||||||
] }
|
] }
|
||||||
manganis-cli-support = { git = "https://github.com/DioxusLabs/collect-assets", rev = "94ea6f7", features = [
|
# manganis-cli-support = { git = "https://github.com/DioxusLabs/collect-assets", rev = "94ea6f7", features = [
|
||||||
"webp",
|
# "webp",
|
||||||
"html",
|
# "html",
|
||||||
] }
|
# ] }
|
||||||
manganis = { git = "https://github.com/DioxusLabs/collect-assets", rev = "94ea6f7" }
|
# manganis = { git = "https://github.com/DioxusLabs/collect-assets", rev = "94ea6f7" }
|
||||||
|
manganis-cli-support = { path = "/Users/evanalmloff/Desktop/Github/assets/cli-support" }
|
||||||
|
manganis = { path = "/Users/evanalmloff/Desktop/Github/assets" }
|
||||||
|
|
||||||
|
|
||||||
# This is a "virtual package"
|
# This is a "virtual package"
|
||||||
|
|||||||
@@ -12,17 +12,14 @@ pub fn asset_manifest(crate_config: &CrateConfig) -> AssetManifest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Create a head file that contains all of the imports for assets that the user project uses
|
/// Create a head file that contains all of the imports for assets that the user project uses
|
||||||
pub fn create_assets_head(config: &CrateConfig) -> Result<()> {
|
pub fn create_assets_head(config: &CrateConfig, manifest: &AssetManifest) -> Result<()> {
|
||||||
let manifest = asset_manifest(config);
|
|
||||||
let mut file = File::create(config.out_dir.join("__assets_head.html"))?;
|
let mut file = File::create(config.out_dir.join("__assets_head.html"))?;
|
||||||
file.write_all(manifest.head().as_bytes())?;
|
file.write_all(manifest.head().as_bytes())?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Process any assets collected from the binary
|
/// Process any assets collected from the binary
|
||||||
pub(crate) fn process_assets(config: &CrateConfig) -> anyhow::Result<()> {
|
pub(crate) fn process_assets(config: &CrateConfig, manifest: &AssetManifest) -> anyhow::Result<()> {
|
||||||
let manifest = asset_manifest(config);
|
|
||||||
|
|
||||||
let static_asset_output_dir = PathBuf::from(
|
let static_asset_output_dir = PathBuf::from(
|
||||||
config
|
config
|
||||||
.dioxus_config
|
.dioxus_config
|
||||||
|
|||||||
+25
-13
@@ -9,7 +9,7 @@ use dioxus_cli_config::CrateConfig;
|
|||||||
use dioxus_cli_config::ExecutableType;
|
use dioxus_cli_config::ExecutableType;
|
||||||
use indicatif::{ProgressBar, ProgressStyle};
|
use indicatif::{ProgressBar, ProgressStyle};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use serde::Serialize;
|
use manganis_cli_support::{AssetManifest, ManganisSupportGuard};
|
||||||
use std::{
|
use std::{
|
||||||
fs::{copy, create_dir_all, File},
|
fs::{copy, create_dir_all, File},
|
||||||
io::Read,
|
io::Read,
|
||||||
@@ -23,10 +23,11 @@ lazy_static! {
|
|||||||
static ref PROGRESS_BARS: indicatif::MultiProgress = indicatif::MultiProgress::new();
|
static ref PROGRESS_BARS: indicatif::MultiProgress = indicatif::MultiProgress::new();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct BuildResult {
|
pub struct BuildResult {
|
||||||
pub warnings: Vec<Diagnostic>,
|
pub warnings: Vec<Diagnostic>,
|
||||||
pub elapsed_time: u128,
|
pub elapsed_time: u128,
|
||||||
|
pub assets: Option<AssetManifest>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build(config: &CrateConfig, _: bool, skip_assets: bool) -> Result<BuildResult> {
|
pub fn build(config: &CrateConfig, _: bool, skip_assets: bool) -> Result<BuildResult> {
|
||||||
@@ -47,7 +48,8 @@ pub fn build(config: &CrateConfig, _: bool, skip_assets: bool) -> Result<BuildRe
|
|||||||
..
|
..
|
||||||
} = config;
|
} = config;
|
||||||
|
|
||||||
let _gaurd = WebAssetConfigDropGuard::new();
|
let _guard = WebAssetConfigDropGuard::new();
|
||||||
|
let _manganis_support = ManganisSupportGuard::default();
|
||||||
|
|
||||||
// start to build the assets
|
// start to build the assets
|
||||||
let ignore_files = build_assets(config)?;
|
let ignore_files = build_assets(config)?;
|
||||||
@@ -261,13 +263,18 @@ pub fn build(config: &CrateConfig, _: bool, skip_assets: bool) -> Result<BuildRe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !skip_assets {
|
let assets = if !skip_assets {
|
||||||
process_assets(config)?;
|
let assets = asset_manifest(config);
|
||||||
}
|
process_assets(config, &assets)?;
|
||||||
|
Some(assets)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
Ok(BuildResult {
|
Ok(BuildResult {
|
||||||
warnings: warning_messages,
|
warnings: warning_messages,
|
||||||
elapsed_time: t_start.elapsed().as_millis(),
|
elapsed_time: t_start.elapsed().as_millis(),
|
||||||
|
assets,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,6 +288,7 @@ pub fn build_desktop(
|
|||||||
let t_start = std::time::Instant::now();
|
let t_start = std::time::Instant::now();
|
||||||
let ignore_files = build_assets(config)?;
|
let ignore_files = build_assets(config)?;
|
||||||
let _guard = dioxus_cli_config::__private::save_config(config);
|
let _guard = dioxus_cli_config::__private::save_config(config);
|
||||||
|
let _manganis_support = ManganisSupportGuard::default();
|
||||||
|
|
||||||
let mut cmd = subprocess::Exec::cmd("cargo")
|
let mut cmd = subprocess::Exec::cmd("cargo")
|
||||||
.env("CARGO_TARGET_DIR", &config.target_dir)
|
.env("CARGO_TARGET_DIR", &config.target_dir)
|
||||||
@@ -394,12 +402,16 @@ pub fn build_desktop(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !skip_assets {
|
let assets = if !skip_assets {
|
||||||
|
let assets = asset_manifest(config);
|
||||||
// Collect assets
|
// Collect assets
|
||||||
process_assets(config)?;
|
process_assets(config, &assets)?;
|
||||||
// Create the __assets_head.html file for bundling
|
// Create the __assets_head.html file for bundling
|
||||||
create_assets_head(config)?;
|
create_assets_head(config, &assets)?;
|
||||||
}
|
Some(assets)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
log::info!(
|
log::info!(
|
||||||
"🚩 Build completed: [./{}]",
|
"🚩 Build completed: [./{}]",
|
||||||
@@ -411,6 +423,7 @@ pub fn build_desktop(
|
|||||||
Ok(BuildResult {
|
Ok(BuildResult {
|
||||||
warnings: warning_messages,
|
warnings: warning_messages,
|
||||||
elapsed_time: t_start.elapsed().as_millis(),
|
elapsed_time: t_start.elapsed().as_millis(),
|
||||||
|
assets,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -470,7 +483,7 @@ fn prettier_build(cmd: subprocess::Exec) -> anyhow::Result<Vec<Diagnostic>> {
|
|||||||
Ok(warning_messages)
|
Ok(warning_messages)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn gen_page(config: &CrateConfig, serve: bool, skip_assets: bool) -> String {
|
pub fn gen_page(config: &CrateConfig, manifest: Option<&AssetManifest>, serve: bool) -> String {
|
||||||
let _gaurd = WebAssetConfigDropGuard::new();
|
let _gaurd = WebAssetConfigDropGuard::new();
|
||||||
|
|
||||||
let crate_root = crate_root().unwrap();
|
let crate_root = crate_root().unwrap();
|
||||||
@@ -515,8 +528,7 @@ pub fn gen_page(config: &CrateConfig, serve: bool, skip_assets: bool) -> String
|
|||||||
{
|
{
|
||||||
style_str.push_str("<link rel=\"stylesheet\" href=\"/{base_path}/tailwind.css\">\n");
|
style_str.push_str("<link rel=\"stylesheet\" href=\"/{base_path}/tailwind.css\">\n");
|
||||||
}
|
}
|
||||||
if !skip_assets {
|
if let Some(manifest) = manifest {
|
||||||
let manifest = asset_manifest(config);
|
|
||||||
style_str.push_str(&manifest.head());
|
style_str.push_str(&manifest.head());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,12 +52,10 @@ impl Build {
|
|||||||
// #[cfg(feature = "plugin")]
|
// #[cfg(feature = "plugin")]
|
||||||
// let _ = PluginManager::on_build_start(&crate_config, &platform);
|
// let _ = PluginManager::on_build_start(&crate_config, &platform);
|
||||||
|
|
||||||
match platform {
|
let build_result = match platform {
|
||||||
Platform::Web => {
|
Platform::Web => crate::builder::build(&crate_config, false, self.build.skip_assets)?,
|
||||||
crate::builder::build(&crate_config, false, self.build.skip_assets)?;
|
|
||||||
}
|
|
||||||
Platform::Desktop => {
|
Platform::Desktop => {
|
||||||
crate::builder::build_desktop(&crate_config, false, self.build.skip_assets)?;
|
crate::builder::build_desktop(&crate_config, false, self.build.skip_assets)?
|
||||||
}
|
}
|
||||||
Platform::Fullstack => {
|
Platform::Fullstack => {
|
||||||
// Fullstack mode must be built with web configs on the desktop (server) binary as well as the web binary
|
// Fullstack mode must be built with web configs on the desktop (server) binary as well as the web binary
|
||||||
@@ -87,12 +85,12 @@ impl Build {
|
|||||||
};
|
};
|
||||||
let _gaurd =
|
let _gaurd =
|
||||||
FullstackServerEnvGuard::new(self.build.force_debug, self.build.release);
|
FullstackServerEnvGuard::new(self.build.force_debug, self.build.release);
|
||||||
crate::builder::build_desktop(&desktop_config, false, self.build.skip_assets)?;
|
crate::builder::build_desktop(&desktop_config, false, self.build.skip_assets)?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
let temp = gen_page(&crate_config, false, self.build.skip_assets);
|
let temp = gen_page(&crate_config, build_result.assets.as_ref(), false);
|
||||||
|
|
||||||
let mut file = std::fs::File::create(
|
let mut file = std::fs::File::create(
|
||||||
crate_config
|
crate_config
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use dioxus_cli_config::Platform;
|
use dioxus_cli_config::Platform;
|
||||||
|
use manganis_cli_support::AssetManifest;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::{fs::create_dir_all, io::Write, path::PathBuf};
|
use std::{fs::create_dir_all, io::Write, path::PathBuf};
|
||||||
@@ -47,9 +48,6 @@ impl Serve {
|
|||||||
|
|
||||||
match platform {
|
match platform {
|
||||||
Platform::Web => {
|
Platform::Web => {
|
||||||
// generate dev-index page
|
|
||||||
Serve::regen_dev_page(&crate_config, self.serve.skip_assets)?;
|
|
||||||
|
|
||||||
// start the develop server
|
// start the develop server
|
||||||
server::web::startup(
|
server::web::startup(
|
||||||
self.serve.port,
|
self.serve.port,
|
||||||
@@ -69,8 +67,11 @@ impl Serve {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn regen_dev_page(crate_config: &CrateConfig, skip_assets: bool) -> Result<()> {
|
pub fn regen_dev_page(
|
||||||
let serve_html = gen_page(crate_config, true, skip_assets);
|
crate_config: &CrateConfig,
|
||||||
|
manifest: Option<&AssetManifest>,
|
||||||
|
) -> anyhow::Result<()> {
|
||||||
|
let serve_html = gen_page(crate_config, manifest, true);
|
||||||
|
|
||||||
let dist_path = crate_config
|
let dist_path = crate_config
|
||||||
.crate_dir
|
.crate_dir
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
let _dioxus_config = DioxusConfig::load(Some(bin.clone()))
|
let _dioxus_config = DioxusConfig::load(Some(bin.clone()))
|
||||||
.map_err(|e| anyhow!("Failed to load Dioxus config because: {e}"))?
|
.map_err(|e| anyhow!("Failed to load Dioxus config because: {e}"))?
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
log::warn!("You appear to be creating a Dioxus project from scratch; we will use the default config");
|
log::info!("You appear to be creating a Dioxus project from scratch; we will use the default config");
|
||||||
DioxusConfig::default()
|
DioxusConfig::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -111,6 +111,9 @@ pub async fn serve(
|
|||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let first_build_result = crate::builder::build(&config, false, skip_assets)?;
|
let first_build_result = crate::builder::build(&config, false, skip_assets)?;
|
||||||
|
|
||||||
|
// generate dev-index page
|
||||||
|
Serve::regen_dev_page(&config, first_build_result.assets.as_ref())?;
|
||||||
|
|
||||||
log::info!("🚀 Starting development server...");
|
log::info!("🚀 Starting development server...");
|
||||||
|
|
||||||
// WS Reload Watching
|
// WS Reload Watching
|
||||||
@@ -448,7 +451,7 @@ fn build(config: &CrateConfig, reload_tx: &Sender<()>, skip_assets: bool) -> Res
|
|||||||
// change the websocket reload state to true;
|
// change the websocket reload state to true;
|
||||||
// the page will auto-reload.
|
// the page will auto-reload.
|
||||||
if config.dioxus_config.web.watcher.reload_html {
|
if config.dioxus_config.web.watcher.reload_html {
|
||||||
let _ = Serve::regen_dev_page(config, skip_assets);
|
let _ = Serve::regen_dev_page(config, result.assets.as_ref());
|
||||||
}
|
}
|
||||||
let _ = reload_tx.send(());
|
let _ = reload_tx.send(());
|
||||||
Ok(result)
|
Ok(result)
|
||||||
|
|||||||
@@ -52,8 +52,6 @@ crossbeam-channel = "0.5.8"
|
|||||||
tao = { version = "0.24.0", features = ["rwh_05"] }
|
tao = { version = "0.24.0", features = ["rwh_05"] }
|
||||||
|
|
||||||
[target.'cfg(any(target_os = "windows",target_os = "macos",target_os = "linux",target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))'.dependencies]
|
[target.'cfg(any(target_os = "windows",target_os = "macos",target_os = "linux",target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))'.dependencies]
|
||||||
# This is only for debug mode, and it appears mobile does not support some packages this uses
|
|
||||||
manganis-cli-support = { workspace = true, optional = true, features = ["webp", "html"] }
|
|
||||||
rfd = "0.12"
|
rfd = "0.12"
|
||||||
global-hotkey = "0.4.1"
|
global-hotkey = "0.4.1"
|
||||||
muda = "0.11.3"
|
muda = "0.11.3"
|
||||||
@@ -73,7 +71,6 @@ fullscreen = ["wry/fullscreen"]
|
|||||||
transparent = ["wry/transparent"]
|
transparent = ["wry/transparent"]
|
||||||
devtools = ["wry/devtools"]
|
devtools = ["wry/devtools"]
|
||||||
hot-reload = ["dioxus-hot-reload"]
|
hot-reload = ["dioxus-hot-reload"]
|
||||||
collect-assets = ["manganis-cli-support"]
|
|
||||||
gnu = []
|
gnu = []
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
|
|||||||
@@ -81,11 +81,6 @@ impl<P: 'static> App<P> {
|
|||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Copy over any assets we find
|
|
||||||
// todo - re-enable this when we have a faster way of copying assets
|
|
||||||
#[cfg(feature = "collect-assets")]
|
|
||||||
crate::collect_assets::copy_assets();
|
|
||||||
|
|
||||||
// Set the event converter
|
// Set the event converter
|
||||||
dioxus_html::set_event_converter(Box::new(crate::events::SerializedHtmlEventConverter));
|
dioxus_html::set_event_converter(Box::new(crate::events::SerializedHtmlEventConverter));
|
||||||
|
|
||||||
|
|||||||
@@ -1,60 +0,0 @@
|
|||||||
pub fn copy_assets() {
|
|
||||||
#[cfg(all(
|
|
||||||
debug_assertions,
|
|
||||||
any(
|
|
||||||
target_os = "windows",
|
|
||||||
target_os = "macos",
|
|
||||||
target_os = "linux",
|
|
||||||
target_os = "dragonfly",
|
|
||||||
target_os = "freebsd",
|
|
||||||
target_os = "netbsd",
|
|
||||||
target_os = "openbsd"
|
|
||||||
)
|
|
||||||
))]
|
|
||||||
{
|
|
||||||
// The CLI will copy assets to the current working directory
|
|
||||||
if std::env::var_os("DIOXUS_ACTIVE").is_some() {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
use manganis_cli_support::AssetManifest;
|
|
||||||
use manganis_cli_support::AssetManifestExt;
|
|
||||||
use manganis_cli_support::Config;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
let config = Config::current();
|
|
||||||
let asset_location = config.assets_serve_location();
|
|
||||||
let asset_location = PathBuf::from(asset_location);
|
|
||||||
let _ = std::fs::remove_dir_all(&asset_location);
|
|
||||||
|
|
||||||
println!("Finding assets... (Note: if you run a dioxus desktop application with the CLI. This process will be significantly faster.)");
|
|
||||||
let manifest = AssetManifest::load();
|
|
||||||
let has_assets = manifest
|
|
||||||
.packages()
|
|
||||||
.iter()
|
|
||||||
.any(|package| !package.assets().is_empty());
|
|
||||||
|
|
||||||
if has_assets {
|
|
||||||
println!("Copying and optimizing assets...");
|
|
||||||
manifest.copy_static_assets_to(&asset_location).unwrap();
|
|
||||||
println!("Copied assets to {}", asset_location.display());
|
|
||||||
} else {
|
|
||||||
println!("No assets found");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[cfg(not(all(
|
|
||||||
debug_assertions,
|
|
||||||
any(
|
|
||||||
target_os = "windows",
|
|
||||||
target_os = "macos",
|
|
||||||
target_os = "linux",
|
|
||||||
target_os = "dragonfly",
|
|
||||||
target_os = "freebsd",
|
|
||||||
target_os = "netbsd",
|
|
||||||
target_os = "openbsd"
|
|
||||||
)
|
|
||||||
)))]
|
|
||||||
{
|
|
||||||
println!(
|
|
||||||
"Skipping assets in release mode. You compile assets with the dioxus-cli in release mode"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -22,9 +22,6 @@ mod shortcut;
|
|||||||
mod waker;
|
mod waker;
|
||||||
mod webview;
|
mod webview;
|
||||||
|
|
||||||
#[cfg(feature = "collect-assets")]
|
|
||||||
mod collect_assets;
|
|
||||||
|
|
||||||
// mobile shortcut is only supported on mobile platforms
|
// mobile shortcut is only supported on mobile platforms
|
||||||
#[cfg(any(target_os = "ios", target_os = "android"))]
|
#[cfg(any(target_os = "ios", target_os = "android"))]
|
||||||
mod mobile_shortcut;
|
mod mobile_shortcut;
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ fn module_loader(root_id: &str, headless: bool) -> String {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the assset directory, following tauri/cargo-bundles directory discovery approach
|
/// Get the asset directory, following tauri/cargo-bundles directory discovery approach
|
||||||
///
|
///
|
||||||
/// Defaults to the current directory if no asset directory is found, which is useful for development when the app
|
/// Defaults to the current directory if no asset directory is found, which is useful for development when the app
|
||||||
/// isn't bundled.
|
/// isn't bundled.
|
||||||
|
|||||||
@@ -67,9 +67,6 @@ dioxus-hot-reload = { workspace = true }
|
|||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
web-sys = { version = "0.3.61", features = ["Window", "Document", "Element", "HtmlDocument", "Storage", "console"] }
|
web-sys = { version = "0.3.61", features = ["Window", "Document", "Element", "HtmlDocument", "Storage", "console"] }
|
||||||
|
|
||||||
[target.'cfg(any(target_os = "windows",target_os = "macos",target_os = "linux",target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))'.dependencies]
|
|
||||||
# This is only for debug mode, and it appears mobile does not support some packages this uses
|
|
||||||
manganis-cli-support = { workspace = true, features = ["webp", "html"] }
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["hot-reload"]
|
default = ["hot-reload"]
|
||||||
|
|||||||
Vendored
+47
@@ -0,0 +1,47 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>dioxus | ⛺</title>
|
||||||
|
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="main"></div>
|
||||||
|
<script type="module">
|
||||||
|
import init from "/./assets/dioxus/name.js";
|
||||||
|
init("/./assets/dioxus/name_bg.wasm").then(wasm => {
|
||||||
|
if (wasm.__wbindgen_start == undefined) {
|
||||||
|
wasm.main();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html><script>// Dioxus-CLI
|
||||||
|
// https://github.com/DioxusLabs/dioxus/tree/master/packages/cli
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
var protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||||
|
var url = protocol + '//' + window.location.host + '/_dioxus/ws';
|
||||||
|
var poll_interval = 8080;
|
||||||
|
var reload_upon_connect = () => {
|
||||||
|
window.setTimeout(
|
||||||
|
() => {
|
||||||
|
var ws = new WebSocket(url);
|
||||||
|
ws.onopen = () => window.location.reload();
|
||||||
|
ws.onclose = reload_upon_connect;
|
||||||
|
},
|
||||||
|
poll_interval);
|
||||||
|
};
|
||||||
|
|
||||||
|
var ws = new WebSocket(url);
|
||||||
|
ws.onmessage = (ev) => {
|
||||||
|
if (ev.data == "reload") {
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ws.onclose = reload_upon_connect;
|
||||||
|
})()
|
||||||
|
</script>
|
||||||
@@ -276,9 +276,6 @@ where
|
|||||||
fn serve_static_assets(mut self, assets_path: impl Into<std::path::PathBuf>) -> Self {
|
fn serve_static_assets(mut self, assets_path: impl Into<std::path::PathBuf>) -> Self {
|
||||||
use tower_http::services::{ServeDir, ServeFile};
|
use tower_http::services::{ServeDir, ServeFile};
|
||||||
|
|
||||||
// Copy over any assets we find
|
|
||||||
crate::collect_assets::copy_assets();
|
|
||||||
|
|
||||||
let assets_path = assets_path.into();
|
let assets_path = assets_path.into();
|
||||||
|
|
||||||
// Serve all files in dist folder except index.html
|
// Serve all files in dist folder except index.html
|
||||||
|
|||||||
@@ -241,9 +241,6 @@ impl DioxusRouterExt for Router {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn serve_static_assets(mut self, assets_path: impl Into<std::path::PathBuf>) -> Self {
|
fn serve_static_assets(mut self, assets_path: impl Into<std::path::PathBuf>) -> Self {
|
||||||
// Copy over any assets we find
|
|
||||||
crate::collect_assets::copy_assets();
|
|
||||||
|
|
||||||
let assets_path = assets_path.into();
|
let assets_path = assets_path.into();
|
||||||
|
|
||||||
// Serve all files in dist folder except index.html
|
// Serve all files in dist folder except index.html
|
||||||
|
|||||||
@@ -187,9 +187,6 @@ pub fn serve_dioxus_application<P: Clone + serde::Serialize + Send + Sync + 'sta
|
|||||||
// Serve the dist folder and the index.html file
|
// Serve the dist folder and the index.html file
|
||||||
let serve_dir = warp::fs::dir(cfg.assets_path);
|
let serve_dir = warp::fs::dir(cfg.assets_path);
|
||||||
|
|
||||||
// Copy over any assets we find
|
|
||||||
crate::collect_assets::copy_assets();
|
|
||||||
|
|
||||||
connect_hot_reload()
|
connect_hot_reload()
|
||||||
// First register the server functions
|
// First register the server functions
|
||||||
.or(register_server_fns(server_fn_route))
|
.or(register_server_fns(server_fn_route))
|
||||||
|
|||||||
@@ -1,61 +0,0 @@
|
|||||||
#[cfg(any(feature = "axum", feature = "warp", feature = "salvo"))]
|
|
||||||
pub fn copy_assets() {
|
|
||||||
#[cfg(all(
|
|
||||||
debug_assertions,
|
|
||||||
any(
|
|
||||||
target_os = "windows",
|
|
||||||
target_os = "macos",
|
|
||||||
target_os = "linux",
|
|
||||||
target_os = "dragonfly",
|
|
||||||
target_os = "freebsd",
|
|
||||||
target_os = "netbsd",
|
|
||||||
target_os = "openbsd"
|
|
||||||
)
|
|
||||||
))]
|
|
||||||
{
|
|
||||||
// The CLI will copy assets to the current working directory
|
|
||||||
if std::env::var_os("DIOXUS_ACTIVE").is_some() {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
use manganis_cli_support::AssetManifest;
|
|
||||||
use manganis_cli_support::AssetManifestExt;
|
|
||||||
use manganis_cli_support::Config;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
let config = Config::current();
|
|
||||||
let asset_location = config.assets_serve_location();
|
|
||||||
let asset_location = PathBuf::from(asset_location);
|
|
||||||
let _ = std::fs::remove_dir_all(&asset_location);
|
|
||||||
|
|
||||||
println!("Finding assets... (Note: if you run a dioxus desktop application with the CLI. This process will be significantly faster.)");
|
|
||||||
let manifest = AssetManifest::load();
|
|
||||||
let has_assets = manifest
|
|
||||||
.packages()
|
|
||||||
.iter()
|
|
||||||
.any(|package| !package.assets().is_empty());
|
|
||||||
|
|
||||||
if has_assets {
|
|
||||||
println!("Copying and optimizing assets...");
|
|
||||||
manifest.copy_static_assets_to(&asset_location).unwrap();
|
|
||||||
println!("Copied assets to {}", asset_location.display());
|
|
||||||
} else {
|
|
||||||
println!("No assets found");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[cfg(not(all(
|
|
||||||
debug_assertions,
|
|
||||||
any(
|
|
||||||
target_os = "windows",
|
|
||||||
target_os = "macos",
|
|
||||||
target_os = "linux",
|
|
||||||
target_os = "dragonfly",
|
|
||||||
target_os = "freebsd",
|
|
||||||
target_os = "netbsd",
|
|
||||||
target_os = "openbsd"
|
|
||||||
)
|
|
||||||
)))]
|
|
||||||
{
|
|
||||||
println!(
|
|
||||||
"Skipping assets in release mode. You compile assets with the dioxus-cli in release mode"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -14,7 +14,6 @@ pub mod router;
|
|||||||
mod adapters;
|
mod adapters;
|
||||||
#[cfg(feature = "ssr")]
|
#[cfg(feature = "ssr")]
|
||||||
pub use adapters::*;
|
pub use adapters::*;
|
||||||
mod collect_assets;
|
|
||||||
mod hooks;
|
mod hooks;
|
||||||
#[cfg(all(debug_assertions, feature = "hot-reload", feature = "ssr"))]
|
#[cfg(all(debug_assertions, feature = "hot-reload", feature = "ssr"))]
|
||||||
mod hot_reload;
|
mod hot_reload;
|
||||||
|
|||||||
Reference in new issue
Block a user