-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Swtich from dilation webservice to web assembly
* Initialized wasm submodule * Add npm scripts and webpack config to compile wasm and include to assets * Update express to fix mime type issue with wasm * Update react to fix async act (see facebook/react#14853) * Changed error message component props for less tight coupling
- Loading branch information
Showing
21 changed files
with
1,085 additions
and
289 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
dist/ | ||
wasm/ |
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 |
---|---|---|
|
@@ -21,7 +21,7 @@ jobs: | |
run: | | ||
npm ci | ||
npm run build | ||
npm run build-server | ||
npm run build:server | ||
npm test | ||
env: | ||
CI: true |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
coverage/ | ||
dist/ | ||
main.wasm |
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,3 @@ | ||
[submodule "n-dilation-webassembly"] | ||
path = n-dilation-webassembly | ||
url = git@github.com:acra5y/n-dilation-webassembly.git |
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,31 @@ | ||
import { useEffect } from "react"; | ||
|
||
import { useWindowContext } from "./WindowContext"; | ||
|
||
const WasmLoader = () => { | ||
const window = useWindowContext(); | ||
|
||
useEffect(() => { | ||
if (!window.Go) { | ||
const script = document.createElement("script"); | ||
script.onload = async function() { | ||
const go = new window.Go(); | ||
const webAssembly = await window.WebAssembly.instantiateStreaming( | ||
window.fetch("/public/wasm/main.wasm"), | ||
go.importObject | ||
); | ||
go.run(webAssembly.instance); // populates window.UnitaryNDilation | ||
}; | ||
script.src = "/public/wasm/wasm_exec.js"; | ||
script.type = "text/javascript"; | ||
|
||
document.head.appendChild(script); | ||
} | ||
}, []); | ||
|
||
return null; | ||
}; | ||
|
||
WasmLoader.displayName = "WasmLoader"; | ||
|
||
export default WasmLoader; |
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
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
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
Oops, something went wrong.