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

Add Warp integration #86

Merged
merged 11 commits into from
Dec 12, 2021
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ These tasks still need to be done before Perseus can be pushed to v1.0.0.
* [ ] Support custom template hierarchies
* [ ] Pre-built integrations
- [x] Actix Web
- [x] Warp
- [ ] AWS Lambda

### Beyond
Expand Down
2 changes: 1 addition & 1 deletion bonnie.toml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ release.cmd = [
"git checkout stable"
]
release.desc = "creates a new project release and pushes it to github (cargo version must be manually bumped, needs branch 'stable')"
replace-versions.cmd = "find . \\( -name \"*Cargo.toml\" -or -name \"*Cargo.toml.example\" -or -name \"*.md\" \\) -not -name \"CHANGELOG.md\" -not -path \"./target/*\" -not -path \"./website/*\" -not -path \"*.perseus*\" -exec sed -i -e 's/%old_version/%new_version/g' {} \\;"
replace-versions.cmd = "find . \\( -name \"*Cargo.toml\" -or -name \"*Cargo.toml.example\" -or -name \"*.md\" \\) -not -name \"CHANGELOG.md\" -not -path \"./target/*\" -not -path \"./website/*\" -not -path \"*.perseus*\" -or \\( -name \"*Cargo.toml\" -path \"./examples/basic/.perseus/*\" -not -path \"./examples/basic/.perseus/dist/*\" \\) -exec sed -i -e 's/%old_version/%new_version/g' {} \\;"
replace-versions.args = [ "old_version", "new_version" ]

# Publishes each package
Expand Down
2 changes: 2 additions & 0 deletions docs/0.3.x/en-US/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
- [State Amalgamation](/docs/strategies/amalgamation)
- [CLI](/docs/cli)
- [Ejecting](/docs/ejecting)
- [Snooping](/docs/snooping)
- [Testing](/docs/testing/intro)
- [Checkpoints](/docs/testing/checkpoints)
- [Fantoccini Basics](/docs/testing/fantoccini-basics)
Expand All @@ -52,6 +53,7 @@
- [Optimizing Code Size](/docs/deploying/size)
- [Relative Paths](/docs/deploying/relative-paths)
- [Migrating from v0.2.x](/docs/updating)
- [Common Pitfalls and Known Bugs](/docs/pitfalls-and-bugs)

---

Expand Down
3 changes: 2 additions & 1 deletion docs/0.3.x/en-US/advanced/arch.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Architecture

Perseus has five main components:
Perseus has several main components:

- `perseus` -- the core module that defines everything necessary to build a Perseus app if you try hard enough
- `perseus-actix-web` -- an integration that makes it easy to run Perseus on the [Actix Web](https://actix.rs) framework
- `perseus-warp` -- an integration that makes it easy to run Perseus on the [Warp](https://github.com/seanmonstar/warp) framework
- `perseus-cli` -- the command-line interface used to run Perseus apps conveniently
- `perseus-engine` -- an internal crate created by the CLI responsible for building an app
- `perseus-engine-server` -- an internal crate created by the CLI responsible for serving an app and performing runtime logic
Expand Down
4 changes: 1 addition & 3 deletions docs/0.3.x/en-US/hello-world.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ Finally, we tell Perseus what to do if something in your app fails, like if the

</details>

Now, tell Rust that you want to be compiling for WebAssembly by adding that platform as a target. You can do this by running `rustup target add wasm32-unknown-unknown`.

After that's finished, you can install the Perseus CLI with `cargo install perseus-cli --version 0.3.0-beta.18` (you'll need `wasm-pack` to let Perseus build your app, use `cargo install wasm-pack` to install it) to make your life way easier, and deploy your app to <http://localhost:8080> by running `perseus serve` inside the root of your project! This will take a while the first time, because it's got to fetch all your dependencies and build your app.
Now install the Perseus CLI with `cargo install perseus-cli` (you'll need `wasm-pack` to let Perseus build your app, use `cargo install wasm-pack` to install it) to make your life way easier, and deploy your app to <http://localhost:8080> by running `perseus serve` inside the root of your project! This will take a while the first time, because it's got to fetch all your dependencies and build your app.

<details>
<summary>Why do I need a CLI?</summary>
Expand Down
7 changes: 7 additions & 0 deletions docs/0.3.x/en-US/pitfalls-and-bugs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Common Pitfalls and Known Bugs

This document is a list of common pitfalls and known bugs in Perseus, and will be updated regularly. If you're having an issue with Perseus, check through this list to see if your problem already has a solution.

## `perseus serve` fails with no error message on Arch Linux

If you're running Arch Linux or a derivative (e.g. Manjaro), you're very likely to encounter a bug in which `perseus serve` stops with no error messages whatsoever, and your app doesn't build properly. This is tracked by [issue #78](https://github.com/arctic-hen7/perseus/issues/78), and is due to an issue in OpenSSL that causes a segmentation fault in `wasm-pack` (see [this issue](https://github.com/rustwasm/wasm-pack/issues/1079)). Right now, the only solution to this is to downgrade `wasm-pack` by running `cargo install wasm-pack --version "0.9.1"`, which seems to fix the problem.
15 changes: 15 additions & 0 deletions docs/0.3.x/en-US/snooping.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Snooping on the CLI

Most of the time, it's fine to run `perseus serve` and enjoy the results, but sometimes you'll need to delve a little deeper and see some more detailed logs. Then you need `perseus snoop`. This command will run one of the lower-level steps the Perseus CLI runs, but in such a way that you can see everything it does. The time you'll use this the most is when you have a `dbg!()` call in the static generation process (e.g. in the *build state* strategy) and you want to actually see its output, which neither `perseus build` nor `perseus serve` will let you do.

## `perseus snoop build`

This snoops on the static generation process, which is half of what `perseus build` does. You can use this to see the outputs of `dbg!()` calls in your build-time code.

## `perseus snoop wasm-build`

This snoops on the `wasm-pack` call that compiles your app to Wasm. There aren't really any use cases for this outside debugging strange errors, because Perseus calls out to this process without augmenting it in any way, so your code shouldn't impact this really at all (unless you're using some package that can't be compiled to Wasm).

## `perseus snoop serve`

This snoops on the server, which is useful if you're hacking on it, or if you're getting errors from it (e.g. panics in the server will only appear if you run this). Crucially though, this expects to be working with a correct build state, which means **you must run `perseus build` before running this command**, otherwise all sorts of things could happen. If such things do happen, you should run `perseus clean --dist`, and that should solve things.
2 changes: 1 addition & 1 deletion docs/0.3.x/en-US/strategies/request-state.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Note that, just like _build state_, this strategy generates stringified properti
<details>
<summary>How do you get the user's request information?</summary>

[Actix Web](https://actix.rs) (and any other framework worth its salt) automatically passes this information to handlers like Perseus. The slightly difficult thing is then converting this from Actix's custom format to Perseus' (which is just an alias for the [`http`](https://docs.rs/http) module's). This is done in the [`perseus-actix-web`](https://docs.rs/perseus-actix-web) crate.
The web frameworks Perseus supports automatically pass this information to handlers like Perseus. The slightly difficult thing is then converting this from their custom format to Perseus' (which is just an alias for the [`http`](https://docs.rs/http) module's). This is done in the appropriate integration crate.

</details>

Expand Down
4 changes: 2 additions & 2 deletions docs/0.3.x/en-US/what-is-perseus.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

If you're familiar with [NextJS](https://nextjs.org), Perseus is that for Wasm. If you're familiar with [SvelteKit](https://kit.svelte.dev), it's that for [Sycamore](https://github.com/sycamore-rs/sycamore).

If none of that makes any sense, this is the section for you! If you're not in the mood for a lecture, [here's a TL;DR](#summary)!
If none of that makes any sense, this is the section for you! If you're not in the mood for a lecture, there's a TL;DR at the bottom of this page!

### Rust web development

Expand Down Expand Up @@ -60,7 +60,7 @@ To our knowledge, the only other framework in the world right now that supports

## How fast is it?

[Benchmarks show](https://rawgit.com/krausest/js-framework-benchmark/master/webdriver-ts-results/table.html) that [Sycamore](https://sycamore-rs.netlify.app) is slightly faster than [Svelte](https://svelte.dev) in places, one of the fastest JS frameworks ever. Perseus uses it and [Actix Web](https://actix.rs), one of the fastest web servers in the world. Essentially, Perseus is built on the fastest tech and is itself made to be fast.
[Benchmarks show](https://rawgit.com/krausest/js-framework-benchmark/master/webdriver-ts-results/table.html) that [Sycamore](https://sycamore-rs.netlify.app) is slightly faster than [Svelte](https://svelte.dev) in places, one of the fastest JS frameworks ever. Perseus uses it and [Actix Web](https://actix.rs) or [Warp](https://github.com/seanmonstar/warp) (either is supported), some of the fastest web servers in the world. Essentially, Perseus is built on the fastest tech and is itself made to be fast.

The speed of web frameworks is often measured by [Lighthouse](https://developers.google.com/web/tools/lighthouse) scores, which are scores out of 100 (higher is better) that measure a whole host of things, like *total blocking time*, *first contentful paint*, and *time to interactive*. These are then aggregated into a final score and grouped into three brackets: 0-49 (slow), 50-89 (medium), and 90-100 (fast). This website, which is built with Perseus, using [static exporting](:exporting) and [size optimizations](:deploying/size), consistently scores a 100 on desktop and above 90 for mobile. You can see this for yourself [here](https://developers.google.com/speed/pagespeed/insights/?url=https%3A%2F%2Farctic-hen7.github.io%2Fperseus%2Fen-US%2F&tab=desktop) on Google's PageSpeed Insights tool.

Expand Down
3 changes: 2 additions & 1 deletion docs/next/en-US/advanced/arch.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Architecture

Perseus has five main components:
Perseus has several main components:

- `perseus` -- the core module that defines everything necessary to build a Perseus app if you try hard enough
- `perseus-actix-web` -- an integration that makes it easy to run Perseus on the [Actix Web](https://actix.rs) framework
- `perseus-warp` -- an integration that makes it easy to run Perseus on the [Warp](https://github.com/seanmonstar/warp) framework
- `perseus-cli` -- the command-line interface used to run Perseus apps conveniently
- `perseus-engine` -- an internal crate created by the CLI responsible for building an app
- `perseus-engine-server` -- an internal crate created by the CLI responsible for serving an app and performing runtime logic
Expand Down
2 changes: 1 addition & 1 deletion docs/next/en-US/strategies/request-state.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Note that, just like _build state_, this strategy generates stringified properti
<details>
<summary>How do you get the user's request information?</summary>

[Actix Web](https://actix.rs) (and any other framework worth its salt) automatically passes this information to handlers like Perseus. The slightly difficult thing is then converting this from Actix's custom format to Perseus' (which is just an alias for the [`http`](https://docs.rs/http) module's). This is done in the [`perseus-actix-web`](https://docs.rs/perseus-actix-web) crate.
The web frameworks Perseus supports automatically pass this information to handlers like Perseus. The slightly difficult thing is then converting this from their custom format to Perseus' (which is just an alias for the [`http`](https://docs.rs/http) module's). This is done in the appropriate integration crate.

</details>

Expand Down
2 changes: 1 addition & 1 deletion docs/next/en-US/what-is-perseus.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ To our knowledge, the only other framework in the world right now that supports

## How fast is it?

[Benchmarks show](https://rawgit.com/krausest/js-framework-benchmark/master/webdriver-ts-results/table.html) that [Sycamore](https://sycamore-rs.netlify.app) is slightly faster than [Svelte](https://svelte.dev) in places, one of the fastest JS frameworks ever. Perseus uses it and [Actix Web](https://actix.rs), one of the fastest web servers in the world. Essentially, Perseus is built on the fastest tech and is itself made to be fast.
[Benchmarks show](https://rawgit.com/krausest/js-framework-benchmark/master/webdriver-ts-results/table.html) that [Sycamore](https://sycamore-rs.netlify.app) is slightly faster than [Svelte](https://svelte.dev) in places, one of the fastest JS frameworks ever. Perseus uses it and [Actix Web](https://actix.rs) or [Warp](https://github.com/seanmonstar/warp) (either is supported), some of the fastest web servers in the world. Essentially, Perseus is built on the fastest tech and is itself made to be fast.

The speed of web frameworks is often measured by [Lighthouse](https://developers.google.com/web/tools/lighthouse) scores, which are scores out of 100 (higher is better) that measure a whole host of things, like *total blocking time*, *first contentful paint*, and *time to interactive*. These are then aggregated into a final score and grouped into three brackets: 0-49 (slow), 50-89 (medium), and 90-100 (fast). This website, which is built with Perseus, using [static exporting](:exporting) and [size optimizations](:deploying/size), consistently scores a 100 on desktop and above 90 for mobile. You can see this for yourself [here](https://developers.google.com/speed/pagespeed/insights/?url=https%3A%2F%2Farctic-hen7.github.io%2Fperseus%2Fen-US%2F&tab=desktop) on Google's PageSpeed Insights tool.

Expand Down
2 changes: 1 addition & 1 deletion examples/basic/.perseus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[package]
name = "perseus-engine"
version = "0.3.0-beta.17"
version = "0.3.0-beta.18"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/.perseus/builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[package]
name = "perseus-engine-builder"
version = "0.3.0-beta.17"
version = "0.3.0-beta.18"
edition = "2018"
default-run = "perseus-builder"

Expand Down
18 changes: 15 additions & 3 deletions examples/basic/.perseus/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,26 @@

[package]
name = "perseus-engine-server"
version = "0.3.0-beta.17"
version = "0.3.0-beta.18"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
perseus = { path = "../../../../packages/perseus", features = [ "server-side" ] }
perseus-actix-web = { path = "../../../../packages/perseus-actix-web" }
perseus-actix-web = { path = "../../../../packages/perseus-actix-web", optional = true }
perseus-warp = { path = "../../../../packages/perseus-warp", optional = true }
perseus-engine = { path = "../" }
actix-web = "3.3"
actix-web = { version = "3.3", optional = true }
futures = "0.3"
warp = { version = "0.3", git = "https://github.com/arctic-hen7/warp", branch = "master", optional = true }
# TODO Choose features here
tokio = { version = "1", optional = true, features = [ "macros", "rt-multi-thread" ] } # We don't need this for Actix Web

# This binary can use any of the server integrations
# Note: because of the way the CLI works, each feature must be an integration
[features]
integration-actix-web = [ "perseus-actix-web", "actix-web" ]
integration-warp = [ "perseus-warp", "warp", "tokio" ]

default = [ "integration-warp" ]
Loading