-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
70db885
commit 7afc92e
Showing
9 changed files
with
497 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ examples/*/dist | |
examples/*/Cargo.lock | ||
crates/*/Cargo.lock | ||
.DS_Store | ||
.idea |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[package] | ||
name = "kobold_router" | ||
version = "0.1.0" | ||
authors = ["Bailey Townsend"] | ||
edition = "2021" | ||
license = "MPL-2.0" | ||
readme = "../../README.md" | ||
keywords = ["web", "wasm", "router", "kobold"] | ||
categories = ["wasm", "web-programming"] | ||
description = "A router for web applications written with Kobold" | ||
repository = "https://github.com/maciejhirsz/kobold" | ||
documentation = "https://docs.rs/kobold" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
kobold = { path = "../kobold" } | ||
matchit = "0.8.0" | ||
serde = { version = "1.0.197", features = ["derive"] } | ||
serde-wasm-bindgen = "0.4" | ||
wasm-bindgen = "0.2.84" | ||
|
||
[dependencies.web-sys] | ||
version = "0.3" | ||
features = ["Window", "Location", "History"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export function changeRouteView(view) { | ||
const routerView = document.getElementById("routerView"); | ||
routerView.innerHTML = ""; | ||
routerView.appendChild(view); | ||
} | ||
|
||
export function setupPushStateEvent() { | ||
let _wr = function (type) { | ||
let orig = history[type]; | ||
return function () { | ||
let rv = orig.apply(this, arguments); | ||
let e = new Event(type); | ||
e.arguments = arguments; | ||
window.dispatchEvent(e); | ||
return rv; | ||
}; | ||
}; | ||
history.pushState = _wr('pushState'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use wasm_bindgen::prelude::*; | ||
|
||
#[wasm_bindgen(module = "/js/util.js")] | ||
extern "C" { | ||
#[wasm_bindgen(js_name = "changeRouteView")] | ||
pub(crate) fn change_route_view(view: &JsValue); | ||
|
||
#[wasm_bindgen(js_name = "setupPushStateEvent")] | ||
pub(crate) fn setup_push_state_event(); | ||
} |
Oops, something went wrong.