Skip to content

Commit

Permalink
Restructure using a cargo workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
mondeja committed Mar 11, 2024
1 parent dcddac2 commit 048d82b
Show file tree
Hide file tree
Showing 42 changed files with 1,576 additions and 482 deletions.
1,499 changes: 1,332 additions & 167 deletions Cargo.lock

Large diffs are not rendered by default.

41 changes: 10 additions & 31 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,31 +1,10 @@
[package]
name = "leptos_hotkeys"
version = "0.1.6"
edition = "2021"
description = "A library that declaratively pairs keybindings with callbacks for Leptos applications."
license = "MIT"
repository = "http://github.com/friendlymatthew/leptos-hotkeys"
readme = "README.md"
authors = [
"Matthew Kim <[email protected]>",
"Robert Junkins <[email protected]>",
]
keywords = ["leptos", "hotkeys", "wasm"]


[dependencies]
leptos = { version = "0.6.5", features = ["nightly"] }
wasm-bindgen = { version = "0.2.89", optional = true }
log = "0.4.20"
cfg-if = { version = "1.0.0", features = [] }
web-sys = { version = "0.3.66", optional = true }

[lib]
name = "leptos_hotkeys"
path = "src/lib.rs"

[features]
hydrate = ["dep:web-sys", "dep:wasm-bindgen"]
csr = ["dep:web-sys", "dep:wasm-bindgen"]
debug = []
ssr = []
[workspace]
members = ["leptos_hotkeys", "examples/demo", "examples/ssr-demo"]
resolver = "2"

[profile.wasm-release]
inherits = "release"
opt-level = "z"
lto = true
codegen-units = 1
panic = "abort"
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions examples/demo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "demo"
version = "0.1.0"
edition = "2021"

[dependencies]
leptos = { version = "0.6", features = ["csr", "nightly"] }
console_error_panic_hook = "0.1"
console_log = "1"
copy_dir = "0.1"
leptos_meta = "0.6"
leptos_router = { version = "0.6", features = ["csr"] }
log = "0.4"
leptos_theme = "0.1"
leptos_hotkeys = { path = "../../leptos_hotkeys", features = ["csr"] }
5 changes: 5 additions & 0 deletions examples/demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# leptos-hotkeys CSR demo

```sh
trunk serve --open
```

Large diffs are not rendered by default.

Binary file added examples/demo/dist/demo-58c21fa1bd9b4c2f_bg.wasm
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>demo</title>
<script type="module">import init from '/demo-edcae59c146cb5aa.js';init('/demo-edcae59c146cb5aa_bg.wasm');</script>
<script type="module">import init from '/demo-58c21fa1bd9b4c2f.js';init('/demo-58c21fa1bd9b4c2f_bg.wasm');</script>


<link rel="stylesheet" href="/output-ca0a674fcde1a78.css">
Expand Down Expand Up @@ -56,8 +56,8 @@
}
</style>

<link rel="preload" href="/demo-edcae59c146cb5aa_bg.wasm" as="fetch" type="application/wasm" crossorigin="">
<link rel="modulepreload" href="/demo-edcae59c146cb5aa.js"></head>
<link rel="preload" href="/demo-58c21fa1bd9b4c2f_bg.wasm" as="fetch" type="application/wasm" crossorigin="">
<link rel="modulepreload" href="/demo-58c21fa1bd9b4c2f.js"></head>
<body>


Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@

[toolchain]
channel = "nightly"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
33 changes: 5 additions & 28 deletions workspace/ssr-demo/Cargo.toml → examples/ssr-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ leptos_router = { version = "0.6", features = ["nightly"] }
tokio = { version = "1", features = ["rt-multi-thread"], optional = true }
tower = { version = "0.4", optional = true }
tower-http = { version = "0.5", features = ["fs"], optional = true }
wasm-bindgen = "=0.2.89"
wasm-bindgen = "=0.2.92"
thiserror = "1"
tracing = { version = "0.1", optional = true }
http = "1"
leptos_hotkeys = { path = "../..", features = ["hydrate", "debug"] }
leptos_hotkeys = { path = "../../leptos_hotkeys", features = [
"hydrate",
"debug"
] }

[features]
hydrate = [
Expand All @@ -41,74 +44,48 @@ ssr = [
"dep:tracing",
]

# Defines a size-optimized profile for the WASM bundle in release mode
[profile.wasm-release]
inherits = "release"
opt-level = 'z'
lto = true
codegen-units = 1
panic = "abort"

[package.metadata.leptos]
# The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name
output-name = "ssr-demo"

# The site root folder is where cargo-leptos generate all output. WARNING: all content of this folder will be erased on a rebuild. Use it in your server setup.
site-root = "target/site"

# The site-root relative folder where all compiled output (JS, WASM and CSS) is written
# Defaults to pkg
site-pkg-dir = "pkg"

# [Optional] The source CSS file. If it ends with .sass or .scss then it will be compiled by dart-sass into CSS. The CSS is optimized by Lightning CSS before being written to <site-root>/<site-pkg>/app.css
style-file = "style/main.scss"
# Assets source dir. All files found here will be copied and synchronized to site-root.
# The assets-dir cannot have a sub directory with the same name/path as site-pkg-dir.
#
# Optional. Env: LEPTOS_ASSETS_DIR.
assets-dir = "public"

# The IP and port (ex: 127.0.0.1:3000) where the server serves the content. Use it in your server setup.
site-addr = "127.0.0.1:3000"

# The port to use for automatic reload monitoring
reload-port = 3001

# [Optional] Command to use when running end2end tests. It will run in the end2end dir.
# [Windows] for non-WSL use "npx.cmd playwright test"
# This binary name can be checked in Powershell with Get-Command npx
end2end-cmd = "npx playwright test"
end2end-dir = "end2end"

# The browserlist query used for optimizing the CSS.
browserquery = "defaults"

# Set by cargo-leptos watch when building with that tool. Controls whether autoreload JS will be included in the head
watch = false

# The environment Leptos will run in, usually either "DEV" or "PROD"
env = "DEV"

# The features to use when compiling the bin target
#
# Optional. Can be over-ridden with the command line parameter --bin-features
bin-features = ["ssr"]

# If the --no-default-features flag should be used when compiling the bin target
#
# Optional. Defaults to false.
bin-default-features = false

# The features to use when compiling the lib target
#
# Optional. Can be over-ridden with the command line parameter --lib-features
lib-features = ["hydrate"]

# If the --no-default-features flag should be used when compiling the lib target
#
# Optional. Defaults to false.
lib-default-features = false

# The profile to use for the lib target when compiling for release
#
# Optional. Defaults to "release".
Expand Down
6 changes: 6 additions & 0 deletions examples/ssr-demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# leptos-hotkeys SSR demo

```sh
cargo install cargo-leptos
cargo leptos watch
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
30 changes: 30 additions & 0 deletions leptos_hotkeys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[package]
name = "leptos_hotkeys"
version = "0.1.6"
edition = "2021"
description = "A library that declaratively pairs keybindings with callbacks for Leptos applications."
license = "MIT"
repository = "http://github.com/friendlymatthew/leptos-hotkeys"
readme = "README.md"
authors = [
"Matthew Kim <[email protected]>",
"Robert Junkins <[email protected]>",
]
keywords = ["leptos", "hotkeys", "wasm"]

[dependencies]
leptos = { version = "0.6.5", features = ["nightly"] }
wasm-bindgen = { version = "0.2.92", optional = true }
log = "0.4.20"
cfg-if = { version = "1.0.0", features = [] }
web-sys = { version = "0.3.66", optional = true }

[lib]
name = "leptos_hotkeys"
path = "src/lib.rs"

[features]
hydrate = ["dep:web-sys", "dep:wasm-bindgen"]
csr = ["dep:web-sys", "dep:wasm-bindgen"]
debug = []
ssr = []
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@

[toolchain]
channel = "nightly"

17 changes: 0 additions & 17 deletions workspace/demo/Cargo.toml

This file was deleted.

59 changes: 0 additions & 59 deletions workspace/demo/README.md

This file was deleted.

Binary file removed workspace/demo/dist/demo-edcae59c146cb5aa_bg.wasm
Binary file not shown.
3 changes: 0 additions & 3 deletions workspace/ssr-demo/rust-toolchain.toml

This file was deleted.

0 comments on commit 048d82b

Please sign in to comment.