Skip to content

Commit

Permalink
fix: spa compatible dev server + Text(En/De)coder
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinKavik authored and David-OConnor committed Apr 22, 2019
1 parent 6a8281b commit 5b49844
Show file tree
Hide file tree
Showing 14 changed files with 161 additions and 115 deletions.
3 changes: 0 additions & 3 deletions .gitignore
@@ -1,7 +1,6 @@

# --- Files ---
**/*.ts
**/*.js
**.wasm
**/*.rs.bk
**/*.log
Expand All @@ -14,5 +13,3 @@
# --- IDE metadata ---
**/.idea
**/.vscode


10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 13 additions & 12 deletions Makefile.toml
@@ -1,6 +1,7 @@
[env]
# all workspace members can use this Makefile
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = "true"
PORT = "8000"

# ---- BUILD & CREATE WASMS ----
[tasks.build]
Expand Down Expand Up @@ -30,39 +31,39 @@ dependencies = ["build", "build_examples", "create_wasms"]

[tasks.e_counter]
extend = "serve"
args = ["./examples/counter"]
args = ["./examples/counter", "--port", "${PORT}"]

# need special start?
[tasks.e_server_integration]
extend = "serve"
args = ["./examples/server_integration"]
args = ["./examples/server_integration", "--port", "${PORT}"]

[tasks.e_server_interaction]
extend = "serve"
args = ["./examples/server_interaction"]
args = ["./examples/server_interaction", "--port", "${PORT}"]

[tasks.e_todomvc]
extend = "serve"
args = ["./examples/todomvc"]
args = ["./examples/todomvc", "--port", "${PORT}"]

# need special start?
[tasks.e_websocket]
extend = "serve"
args = ["./examples/websocket"]
args = ["./examples/websocket", "--port", "${PORT}"]

[tasks.e_window_events]
extend = "serve"
args = ["./examples/window_events"]
args = ["./examples/window_events", "--port", "${PORT}"]

# ---- PRIVATE TASKS - run only inside another task ----
# private atribute is ignored (bug?)

[tasks.serve]
description = "Start server for given example"
install_crate = { crate_name = "https", binary = "http", test_arg = "--help" }
install_crate = { crate_name = "microserver", binary = "microserver", test_arg = "-h" }
workspace = false
command = "http"
args = ["./examples/[change_in_child_task]"]

# ---- PRIVATE TASKS - run only inside another task ----
# private atribute is ignored (bug?)
command = "microserver"
args = ["./examples/[change_in_child_task]", "--port", "${PORT}"]

[tasks.build_example]
description = "Build example"
Expand Down
46 changes: 25 additions & 21 deletions examples/counter/index.html
@@ -1,36 +1,40 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>

<meta name="description" content="">
<meta name="description" content="" />

<link rel="icon" type="image/png" href="/public/favicon.png">
<link rel="icon" type="image/png" href="/public/favicon.png" />

<!--<link rel="stylesheet" type="text/css" href="/style.css">-->

<title>Counter example</title>

</head>
<body>
<section id="app"></section>
<!-- Because of Edge, see https://github.com/samthor/fast-text-encoding -->
<script type="text/javascript" src="/public/text-polyfill.min.js"></script>
</head>
<body>
<section id="app"></section>

<script src='/pkg/package.js'></script>
<script src="/pkg/package.js"></script>

<script>
// the `wasm_bindgen` global is set to the exports of the Rust module
const { render } = wasm_bindgen;
// we'll defer our execution until the wasm is ready to go
function run() {
<script>
// the `wasm_bindgen` global is set to the exports of the Rust module
const { render } = wasm_bindgen;
// we'll defer our execution until the wasm is ready to go
function run() {
render();
}
// here we tell bindgen the path to the wasm file so it can run
// initialization and return to us a promise when it's done
wasm_bindgen('/pkg/package_bg.wasm')
}
// here we tell bindgen the path to the wasm file so it can run
// initialization and return to us a promise when it's done
wasm_bindgen("/pkg/package_bg.wasm")
.then(run)
.catch(console.error);
</script>

</body>
</script>
</body>
</html>
5 changes: 5 additions & 0 deletions examples/counter/public/text-polyfill.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 25 additions & 21 deletions examples/server_interaction/index.html
@@ -1,36 +1,40 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>

<meta name="description" content="">
<meta name="description" content="" />

<link rel="icon" type="image/png" href="/public/favicon.png">
<link rel="icon" type="image/png" href="/public/favicon.png" />

<!--<link rel="stylesheet" type="text/css" href="/style.css">-->

<title>Server interaction</title>

</head>
<body>
<section id="main"></section>
<!-- Because of Edge, see https://github.com/samthor/fast-text-encoding -->
<script type="text/javascript" src="/public/text-polyfill.min.js"></script>
</head>
<body>
<section id="main"></section>

<script src='/pkg/package.js'></script>
<script src="/pkg/package.js"></script>

<script>
// the `wasm_bindgen` global is set to the exports of the Rust module
const { render } = wasm_bindgen;
// we'll defer our execution until the wasm is ready to go
function run() {
<script>
// the `wasm_bindgen` global is set to the exports of the Rust module
const { render } = wasm_bindgen;
// we'll defer our execution until the wasm is ready to go
function run() {
render();
}
// here we tell bindgen the path to the wasm file so it can run
// initialization and return to us a promise when it's done
wasm_bindgen('/pkg/package_bg.wasm')
}
// here we tell bindgen the path to the wasm file so it can run
// initialization and return to us a promise when it's done
wasm_bindgen("/pkg/package_bg.wasm")
.then(run)
.catch(console.error);
</script>

</body>
</script>
</body>
</html>
5 changes: 5 additions & 0 deletions examples/server_interaction/public/text-polyfill.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 27 additions & 24 deletions examples/todomvc/index.html
@@ -1,35 +1,38 @@
<!DOCTYPE html>
<html lang="en" data-framework="rust">
<head>
<meta charset="utf-8">
<head>
<meta charset="utf-8" />
<title>Seed • TodoMVC</title>
<link rel="stylesheet" href="/index.css">
<link rel="stylesheet" href="/public/index.css" />

</head>
<body>
<section id="app" class="todoapp"></section>
<!-- Because of Edge, see https://github.com/samthor/fast-text-encoding -->
<script type="text/javascript" src="/public/text-polyfill.min.js"></script>
</head>
<body>
<section id="app" class="todoapp"></section>

<footer class="info">
<p>Double-click to edit a todo</p>
<p>Created by <a href="http://github.com/David-OConnor/">David O'Connor</a></p>
<p>Part of <a href="http://todomvc.com">TodoMVC</a></p>
</footer>
<footer class="info">
<p>Double-click to edit a todo</p>
<p>
Created by <a href="http://github.com/David-OConnor/">David O'Connor</a>
</p>
<p>Part of <a href="http://todomvc.com">TodoMVC</a></p>
</footer>

<script src='/pkg/package.js'></script>
<script src="/pkg/package.js"></script>

<script>
// the `wasm_bindgen` global is set to the exports of the Rust module
const { render } = wasm_bindgen;
// we'll defer our execution until the wasm is ready to go
function run() {
<script>
// the `wasm_bindgen` global is set to the exports of the Rust module
const { render } = wasm_bindgen;
// we'll defer our execution until the wasm is ready to go
function run() {
render();
}
// here we tell bindgen the path to the wasm file so it can run
// initialization and return to us a promise when it's done
wasm_bindgen('/pkg/package_bg.wasm')
}
// here we tell bindgen the path to the wasm file so it can run
// initialization and return to us a promise when it's done
wasm_bindgen("/pkg/package_bg.wasm")
.then(run)
.catch(console.error);
</script>

</body>
</script>
</body>
</html>
File renamed without changes.
5 changes: 5 additions & 0 deletions examples/todomvc/public/text-polyfill.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 16 additions & 8 deletions examples/websocket/index.html
@@ -1,19 +1,27 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<title>seed websocket example</title>

<!-- Because of Edge, see https://github.com/samthor/fast-text-encoding -->
<script type="text/javascript" src="/public/text-polyfill.min.js"></script>
</head>
<body>
<section id="app"></section>
<script src='/pkg/websocket.js'></script>
<script src="/pkg/websocket.js"></script>
<script>
const { start } = wasm_bindgen;
function run() { start(); }
wasm_bindgen('/pkg/websocket_bg.wasm')
.then(run)
.catch(console.error);
const { start } = wasm_bindgen;
function run() {
start();
}
wasm_bindgen("/pkg/websocket_bg.wasm")
.then(run)
.catch(console.error);
</script>
</body>
</html>
5 changes: 5 additions & 0 deletions examples/websocket/public/text-polyfill.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5b49844

Please sign in to comment.