mirror of
https://github.com/zaphar/kitchen.git
synced 2025-07-22 19:40:14 -04:00
Conditional compilation of typings in preparation
This commit is contained in:
parent
1797963dd0
commit
4bfd04b048
@ -3,6 +3,11 @@ name = "web"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[features]
|
||||
ssr = []
|
||||
web = []
|
||||
default = ["web"]
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
|
@ -15,7 +15,7 @@ use std::collections::BTreeMap;
|
||||
|
||||
use crate::{console_debug, console_error, console_log};
|
||||
|
||||
use reqwasm::http::{self};
|
||||
use reqwasm::http;
|
||||
use sycamore::prelude::*;
|
||||
use web_sys::{window, Storage};
|
||||
|
||||
|
@ -31,10 +31,14 @@ extern "C" {
|
||||
macro_rules! console_log {
|
||||
// Note that this is using the `log` function imported above during
|
||||
// `bare_bones`
|
||||
($($t:tt)*) => {{
|
||||
($($t:tt)*) => {
|
||||
if cfg!(feature="web") {
|
||||
use crate::typings::log;
|
||||
(log(&format_args!($($t)*).to_string()))
|
||||
}}
|
||||
log(&format_args!($($t)*).to_string());
|
||||
} else if cfg!(feature="ssr") {
|
||||
println!($($t)*);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
@ -42,27 +46,43 @@ macro_rules! console_debug {
|
||||
// Note that this is using the `log` function imported above during
|
||||
// `bare_bones`
|
||||
($($t:tt)*) => {{
|
||||
if cfg!(feature="web") {
|
||||
use crate::typings::debug;
|
||||
(debug(&format_args!($($t)*).to_string()))
|
||||
debug(&format_args!($($t)*).to_string());
|
||||
} else if cfg!(feature="ssr") {
|
||||
print!("DEBUG: ");
|
||||
println!($($t)*);
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! console_error {
|
||||
// Note that this is using the `log` function imported above during
|
||||
// Note that this is using the `error` function imported above during
|
||||
// `bare_bones`
|
||||
($($t:tt)*) => {{
|
||||
if cfg!(feature="web")
|
||||
{
|
||||
use crate::typings::error;
|
||||
(error(&format_args!($($t)*).to_string()))
|
||||
error(&format_args!($($t)*).to_string());
|
||||
}else if cfg!(feature="ssr") {
|
||||
print!("ERROR: ");
|
||||
println!($($t)*);
|
||||
};
|
||||
}}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! console_warn {
|
||||
// Note that this is using the `log` function imported above during
|
||||
// Note that this is using the `warn` function imported above during
|
||||
// `bare_bones`
|
||||
($($t:tt)*) => {{
|
||||
if cfg!("web") {
|
||||
use crate::typings::warn;
|
||||
(warn(&format_args!($($t)*).to_string()))
|
||||
} else if cfg!(feature="ssr") {
|
||||
print!("WARN: ");
|
||||
(println!($($t)*))
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user