Skip to content

Commit

Permalink
Do not init twice!
Browse files Browse the repository at this point in the history
  • Loading branch information
lynnagara committed Apr 16, 2019
1 parent 3a92a5d commit 99bd28b
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
build-gh-pages:
wasm-pack build --target web
rm -rf docs
mkdir docs
cp static/index.html docs
Expand All @@ -7,4 +8,5 @@ build-gh-pages:
cp pkg/d0_bg.wasm docs/pkg

build-static:
wasm-pack build --target web
cp -r pkg static/pkg
2 changes: 1 addition & 1 deletion pkg/d0.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ function init(module_or_path, maybe_memory) {
return result.then(({instance, module}) => {
wasm = instance.exports;
init.__wbindgen_wasm_module = module;
wasm.__wbindgen_start();

return wasm;
});
}
Expand Down
1 change: 0 additions & 1 deletion pkg/d0_bg.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ export const memory: WebAssembly.Memory;
export function init_app(): void;
export function __wbindgen_malloc(a: number): number;
export function __wbindgen_realloc(a: number, b: number, c: number): number;
export function __wbindgen_start(): void;
export const __wbg_function_table: WebAssembly.Table;
Binary file modified pkg/d0_bg.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mod toolbar;

static TOOLBAR_WIDTH: u32 = 50;

#[wasm_bindgen(start)]
#[wasm_bindgen]
pub fn init_app() -> Result<(), JsValue> {
let window = window().expect("Could not find `window`");
let document = window.document().expect("Could not find `document`");
Expand Down
3 changes: 1 addition & 2 deletions static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
</head>
<body>
<script type="module">
import { init_app, default as init } from './pkg/d0.js';
import { default as init } from './pkg/d0.js';
async function run() {
await init('./pkg/d0_bg.wasm');
init_app()
}
run();
</script>
Expand Down

0 comments on commit 99bd28b

Please sign in to comment.