|
@@ -1,15 +1,16 @@
|
|
#![allow(non_snake_case)]
|
|
#![allow(non_snake_case)]
|
|
|
|
|
|
|
|
+#[cfg(not(target_arch = "wasm32"))]
|
|
|
|
+use crate::fs_cache::PathMapFn;
|
|
|
|
+
|
|
use crate::IncrementalRenderer;
|
|
use crate::IncrementalRenderer;
|
|
|
|
+use crate::memory_cache::InMemoryCache;
|
|
|
|
|
|
use std::{
|
|
use std::{
|
|
path::{Path, PathBuf},
|
|
path::{Path, PathBuf},
|
|
- sync::Arc,
|
|
|
|
time::Duration,
|
|
time::Duration,
|
|
};
|
|
};
|
|
|
|
|
|
-use super::fs_cache::PathMapFn;
|
|
|
|
-use super::memory_cache::InMemoryCache;
|
|
|
|
|
|
|
|
/// A configuration for the incremental renderer.
|
|
/// A configuration for the incremental renderer.
|
|
#[derive(Clone)]
|
|
#[derive(Clone)]
|
|
@@ -17,9 +18,11 @@ pub struct IncrementalRendererConfig {
|
|
static_dir: PathBuf,
|
|
static_dir: PathBuf,
|
|
memory_cache_limit: usize,
|
|
memory_cache_limit: usize,
|
|
invalidate_after: Option<Duration>,
|
|
invalidate_after: Option<Duration>,
|
|
- map_path: Option<PathMapFn>,
|
|
|
|
clear_cache: bool,
|
|
clear_cache: bool,
|
|
pre_render: bool,
|
|
pre_render: bool,
|
|
|
|
+
|
|
|
|
+ #[cfg(not(target_arch = "wasm32"))]
|
|
|
|
+ map_path: Option<PathMapFn>,
|
|
}
|
|
}
|
|
|
|
|
|
impl Default for IncrementalRendererConfig {
|
|
impl Default for IncrementalRendererConfig {
|
|
@@ -35,9 +38,10 @@ impl IncrementalRendererConfig {
|
|
static_dir: PathBuf::from("./static"),
|
|
static_dir: PathBuf::from("./static"),
|
|
memory_cache_limit: 10000,
|
|
memory_cache_limit: 10000,
|
|
invalidate_after: None,
|
|
invalidate_after: None,
|
|
- map_path: None,
|
|
|
|
clear_cache: true,
|
|
clear_cache: true,
|
|
pre_render: false,
|
|
pre_render: false,
|
|
|
|
+ #[cfg(not(target_arch = "wasm32"))]
|
|
|
|
+ map_path: None,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -49,8 +53,9 @@ impl IncrementalRendererConfig {
|
|
|
|
|
|
/// Set a mapping from the route to the file path. This will override the default mapping configured with `static_dir`.
|
|
/// Set a mapping from the route to the file path. This will override the default mapping configured with `static_dir`.
|
|
/// The function should return the path to the folder to store the index.html file in.
|
|
/// The function should return the path to the folder to store the index.html file in.
|
|
|
|
+ #[cfg(not(target_arch = "wasm32"))]
|
|
pub fn map_path<F: Fn(&str) -> PathBuf + Send + Sync + 'static>(mut self, map_path: F) -> Self {
|
|
pub fn map_path<F: Fn(&str) -> PathBuf + Send + Sync + 'static>(mut self, map_path: F) -> Self {
|
|
- self.map_path = Some(Arc::new(map_path));
|
|
|
|
|
|
+ self.map_path = Some(std::sync::Arc::new(map_path));
|
|
self
|
|
self
|
|
}
|
|
}
|
|
|
|
|