Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Sycamore to v0.6.0 #10

Merged
merged 4 commits into from
Sep 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,3 @@ members = [
"examples/basic",
"examples/i18n"
]

# Needed until Sycamore #230 is released
[patch.crates-io]
sycamore = { git = "https://github.com/arctic-hen7/sycamore", branch = "router-clone-stable" }
sycamore-router = { git = "https://github.com/arctic-hen7/sycamore", branch = "router-clone-stable" }
4 changes: 2 additions & 2 deletions docs/src/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Set up a library project with `cargo`, and add the following to the `[dependenci

```toml
perseus = { path = "../../packages/perseus" }
sycamore = { version = "0.5.1", features = ["ssr"] }
sycamore-router = "0.5.1"
sycamore = { version = "0.6.0", features = ["ssr"] }
sycamore-router = "0.6.0"
# You only need these for pages that take properties
serde = { version = "1", features = ["derive"] }
serde_json = "1"
Expand Down
4 changes: 2 additions & 2 deletions docs/src/tutorials/first_app/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ You should now have an `src/` directory and a `Cargo.toml` file, which is what w
# Perseus itself, which we (amazingly) need for a Perseus app
perseus = "0.1"
# Sycamore, the library Perseus depends on for lower-leve reactivity primitivity
sycamore = { version = "0.5.1", features = ["ssr"] }
sycamore-router = "0.5.1"
sycamore = { version = "0.6.0", features = ["ssr"] }
sycamore-router = "0.6.0"
# Serde, which lets you work with representations of data, like JSON
serde = { version = "1", features = ["derive"] }
serde_json = "1"
Expand Down
4 changes: 2 additions & 2 deletions examples/basic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ edition = "2018"

[dependencies]
perseus = { path = "../../packages/perseus" }
sycamore = { version = "0.5", features = ["ssr"] }
sycamore-router = "0.5"
sycamore = { version = "0.6", features = ["ssr"] }
sycamore-router = "0.6"
serde = { version = "1", features = ["derive"] }
serde_json = "1" # Possibly don't need?

Expand Down
9 changes: 2 additions & 7 deletions examples/cli/.perseus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ edition = "2018"
app = { package = "perseus-example-cli", path = "../" }

perseus = { path = "../../../packages/perseus" }
sycamore = { version = "0.5", features = ["ssr"] }
sycamore-router = "0.5"
sycamore = { version = "0.6", features = ["ssr"] }
sycamore-router = "0.6"
web-sys = { version = "0.3", features = ["Headers", "Request", "RequestInit", "RequestMode", "Response", "ReadableStream", "Window"] }
wasm-bindgen = { version = "0.2", features = ["serde-serialize"] }
serde = { version = "1", features = ["derive"] }
Expand All @@ -31,8 +31,3 @@ crate-type = ["cdylib", "rlib"]
[[bin]]
name = "perseus-internal"
path = "src/bin/build.rs"

# Needed until Sycamore #230 is released (becomes relevant when excluded from user's workspaces)
[patch.crates-io]
sycamore = { git = "https://github.com/arctic-hen7/sycamore", branch = "router-clone-stable" }
sycamore-router = { git = "https://github.com/arctic-hen7/sycamore", branch = "router-clone-stable" }
2 changes: 1 addition & 1 deletion examples/cli/.perseus/bonnie.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is temporary until the CLI is ready!

version="0.3.1"
version="0.3.2"

[scripts]
build = [
Expand Down
5 changes: 0 additions & 5 deletions examples/cli/.perseus/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,3 @@ app = { package = "perseus-example-cli", path = "../../" }
perseus-actix-web = { path = "../../../../packages/perseus-actix-web" }
actix-web = "3.3"
futures = "0.3"

# Needed until Sycamore #230 is released (becomes relevant when excluded from user's workspaces)
[patch.crates-io]
sycamore = { git = "https://github.com/arctic-hen7/sycamore", branch = "router-clone-stable" }
sycamore-router = { git = "https://github.com/arctic-hen7/sycamore", branch = "router-clone-stable" }
20 changes: 10 additions & 10 deletions examples/cli/.perseus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use perseus::router::{RouteInfo, RouteVerdict};
use perseus::{app_shell, detect_locale, ClientTranslationsManager, DomNode};
use std::cell::RefCell;
use std::rc::Rc;
use sycamore::prelude::template;
use sycamore::rx::{ContextProvider, ContextProviderProps};
use sycamore_router::BrowserRouter;
use sycamore::context::{ContextProvider, ContextProviderProps};
use sycamore::prelude::{template, StateHandle};
use sycamore_router::{HistoryIntegration, Router, RouterProps};
use wasm_bindgen::{prelude::wasm_bindgen, JsValue};

/// The entrypoint into the app itself. This will be compiled to WASM and actually executed, rendering the rest of the app.
Expand Down Expand Up @@ -38,29 +38,29 @@ pub fn run() -> Result<(), JsValue> {
ContextProvider(ContextProviderProps {
value: Rc::clone(&routes),
children: || template! {
BrowserRouter(move |route: RouteVerdict<DomNode>| {
match route {
Router(RouterProps::new(HistoryIntegration::new(), move |route: StateHandle<RouteVerdict<DomNode>>| {
match route.get().as_ref() {
// Perseus' custom routing system is tightly coupled to the template system, and returns exactly what we need for the app shell!
RouteVerdict::Found(RouteInfo {
path,
template_fn,
locale
}) => app_shell(
path,
template_fn,
locale,
path.clone(),
template_fn.clone(),
locale.clone(),
// We give the app shell a translations manager and let it get the `Rc<Translator>` itself (because it can do async safely)
Rc::clone(&translations_manager),
Rc::clone(&error_pages)
),
// If the user is using i18n, then they'll want to detect the locale on any paths missing a locale
// Those all go to the same system that redirects to the appropriate locale
RouteVerdict::LocaleDetection(path) => detect_locale(path, get_locales()),
RouteVerdict::LocaleDetection(path) => detect_locale(path.clone(), get_locales()),
// We handle the 404 for the user for convenience
// To get a translator here, we'd have to go async and dangerously check the URL
RouteVerdict::NotFound => get_error_pages().get_template_for_page("", &404, "not found", None),
}
})
}))
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions examples/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ edition = "2018"

[dependencies]
perseus = { path = "../../packages/perseus" }
sycamore = { version = "0.5", features = ["ssr"] }
sycamore-router = "0.5"
sycamore = { version = "0.6", features = ["ssr"] }
sycamore-router = "0.6"
serde = { version = "1", features = ["derive"] }
serde_json = "1" # Possibly don't need?

Expand Down
4 changes: 2 additions & 2 deletions examples/i18n/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ edition = "2018"
# Perseus itself, which we (amazingly) need for a Perseus app
perseus = { path = "../../packages/perseus" }
# Sycamore, the library Perseus depends on for lower-leve reactivity primitivity
sycamore = { version = "0.5", features = ["ssr"] }
sycamore-router = "0.5"
sycamore = { version = "0.6", features = ["ssr"] }
sycamore-router = "0.6"
# Serde, which lets you work with representations of data, like JSON
serde = { version = "1", features = ["derive"] }
serde_json = "1"
Expand Down
4 changes: 2 additions & 2 deletions examples/showcase/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ edition = "2018"
# Perseus itself, which we (amazingly) need for a Perseus app
perseus = { path = "../../packages/perseus" }
# Sycamore, the library Perseus depends on for lower-leve reactivity primitivity
sycamore = { version = "0.5", features = ["ssr"] }
sycamore-router = "0.5"
sycamore = { version = "0.6", features = ["ssr"] }
sycamore-router = "0.6"
# Serde, which lets you work with representations of data, like JSON
serde = { version = "1", features = ["derive"] }
serde_json = "1"
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus-actix-web/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ urlencoding = "2.1"
serde_json = "1"
error-chain = "0.12"
futures = "0.3"
sycamore = { version = "0.5", features = ["ssr"] }
sycamore = { version = "0.6", features = ["ssr"] }
4 changes: 2 additions & 2 deletions packages/perseus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ categories = ["wasm", "web-programming", "development-tools", "asynchronous", "g
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
sycamore = { version = "0.5", features = ["ssr"] }
sycamore-router = "0.5"
sycamore = { version = "0.6", features = ["ssr"] }
sycamore-router = "0.6"
web-sys = { version = "0.3", features = ["Headers", "Navigator", "Request", "RequestInit", "RequestMode", "Response", "ReadableStream", "Window"] }
wasm-bindgen = { version = "0.2", features = ["serde-serialize"] }
wasm-bindgen-futures = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/router.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::Locales;
use crate::Template;
use std::rc::Rc;
use sycamore::context::use_context;
use sycamore::prelude::GenericNode;
use sycamore::rx::use_context;
use sycamore_router::{Route, RoutePath, Segment};

/// A representation of routes in a Perseus app. This is used internally to match routes. Because this can't be passed directly to
Expand Down
2 changes: 1 addition & 1 deletion packages/perseus/src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use futures::Future;
use std::collections::HashMap;
use std::pin::Pin;
use std::rc::Rc;
use sycamore::context::{ContextProvider, ContextProviderProps};
use sycamore::prelude::{template, GenericNode, Template as SycamoreTemplate};
use sycamore::rx::{ContextProvider, ContextProviderProps};

/// Represents all the different states that can be generated for a single template, allowing amalgamation logic to be run with the knowledge
/// of what did what (rather than blindly working on a vector).
Expand Down
6 changes: 3 additions & 3 deletions packages/perseus/src/translator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ macro_rules! t {
// When there are no arguments to interpolate
($id:expr) => {
{
let translator = ::sycamore::rx::use_context::<Rc<Translator>>();
let translator = ::sycamore::context::use_context::<Rc<Translator>>();
translator.translate($id, None)
}
};
Expand All @@ -28,7 +28,7 @@ macro_rules! t {
$($key:literal: $value:expr),+
}) => {
{
let translator = ::sycamore::rx::use_context::<Rc<Translator>>();
let translator = ::sycamore::context::use_context::<Rc<Translator>>();
let mut args = fluent_bundle::FluentArgs::new();
$(
args.set($key, $value);
Expand All @@ -43,7 +43,7 @@ macro_rules! t {
#[macro_export]
macro_rules! link {
($url:expr) => {{
let translator = ::sycamore::rx::use_context::<Rc<Translator>>();
let translator = ::sycamore::context::use_context::<Rc<Translator>>();
translator.url($url)
}};
}