mirror of
https://github.com/speice-io/isomorphic-rust
synced 2024-11-23 00:18:21 -05:00
Attempt adding binaryen - doesn't actually run though
This commit is contained in:
parent
e7edfc1e8c
commit
d6c662ac80
42
binaryen/.compilerc
Normal file
42
binaryen/.compilerc
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"development": {
|
||||||
|
"application/javascript": {
|
||||||
|
"presets": [
|
||||||
|
[
|
||||||
|
"env",
|
||||||
|
{
|
||||||
|
"targets": {
|
||||||
|
"electron": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"react"
|
||||||
|
],
|
||||||
|
"plugins": [
|
||||||
|
"transform-async-to-generator"
|
||||||
|
],
|
||||||
|
"sourceMaps": "inline"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"production": {
|
||||||
|
"application/javascript": {
|
||||||
|
"presets": [
|
||||||
|
[
|
||||||
|
"env",
|
||||||
|
{
|
||||||
|
"targets": {
|
||||||
|
"electron": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"react"
|
||||||
|
],
|
||||||
|
"plugins": [
|
||||||
|
"transform-async-to-generator"
|
||||||
|
],
|
||||||
|
"sourceMaps": "none"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
9
binaryen/.eslintrc
Normal file
9
binaryen/.eslintrc
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"extends": "eslint-config-airbnb",
|
||||||
|
"rules": {
|
||||||
|
"import/extensions": 0,
|
||||||
|
"import/no-extraneous-dependencies": 0,
|
||||||
|
"import/no-unresolved": [2, { "ignore": ["electron"] }],
|
||||||
|
"linebreak-style": 0
|
||||||
|
}
|
||||||
|
}
|
5
binaryen/.gitignore
vendored
Normal file
5
binaryen/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
node_modules/
|
||||||
|
Cargo.lock
|
||||||
|
target/
|
||||||
|
dist/
|
||||||
|
binaryen/
|
15
binaryen/Cargo.toml
Normal file
15
binaryen/Cargo.toml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
[package]
|
||||||
|
authors = ["Bradlee Speice"]
|
||||||
|
categories = ["wasm"]
|
||||||
|
description = "A no-framework WASM Electron app"
|
||||||
|
license = "Apache-2.0/MIT"
|
||||||
|
name = "stdweb_electron"
|
||||||
|
readme = "./README.md"
|
||||||
|
repository = "https://github.com/rustwasm/rust-webpack-template"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
stdweb = "0.4"
|
27
binaryen/build.sh
Executable file
27
binaryen/build.sh
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
DIR="$(dirname $0)"
|
||||||
|
WASM_DIR="$DIR/target/wasm32-unknown-unknown"
|
||||||
|
WASM_NAME="$(cat "$DIR/Cargo.toml" | grep name | sed 's/name = "//' | sed 's/"//g')"
|
||||||
|
APP_DIR="$DIR/dist/"
|
||||||
|
|
||||||
|
if [ ! -f "$DIR/binaryen/bin/wasm2js" ]; then
|
||||||
|
git clone "https://github.com/WebAssembly/binaryen" "$DIR/binaryen"
|
||||||
|
pushd "$DIR/binaryen"
|
||||||
|
cmake . && make -j8
|
||||||
|
popd
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "$APP_DIR" ]; then
|
||||||
|
mkdir "$APP_DIR"
|
||||||
|
fi
|
||||||
|
cp "$DIR/static/"* "$APP_DIR"
|
||||||
|
|
||||||
|
if [ -z "$(which cargo)" ]; then
|
||||||
|
echo 'Must install `cargo` before proceeding. Please see https://rustup.rs/ for more information.'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cargo +nightly build --target=wasm32-unknown-unknown && \
|
||||||
|
"$DIR/binaryen/bin/wasm2js" --pedantic "$WASM_DIR/debug/stdweb_electron.wasm" -o "$APP_DIR/stdweb_electron.js" && \
|
||||||
|
"$DIR/node_modules/webpack-cli/bin/cli.js" --mode=development "$APP_DIR/stdweb_electron.js" -o "$APP_DIR/bundle.js"
|
66
binaryen/package.json
Normal file
66
binaryen/package.json
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
{
|
||||||
|
"name": "electron_percy_wasm",
|
||||||
|
"productName": "electron_percy_wasm",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "My Electron application description",
|
||||||
|
"main": "dist/index.js",
|
||||||
|
"scripts": {
|
||||||
|
"prestart": "./build.sh",
|
||||||
|
"start": "electron-forge start",
|
||||||
|
"package": "electron-forge package",
|
||||||
|
"make": "electron-forge make",
|
||||||
|
"lint": "eslint src"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "bspeice",
|
||||||
|
"license": "MIT",
|
||||||
|
"config": {
|
||||||
|
"forge": {
|
||||||
|
"make_targets": {
|
||||||
|
"win32": [
|
||||||
|
"squirrel"
|
||||||
|
],
|
||||||
|
"darwin": [
|
||||||
|
"zip"
|
||||||
|
],
|
||||||
|
"linux": [
|
||||||
|
"deb",
|
||||||
|
"rpm"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"electronPackagerConfig": {
|
||||||
|
"packageManager": "yarn"
|
||||||
|
},
|
||||||
|
"electronWinstallerConfig": {
|
||||||
|
"name": "electron_percy_wasm"
|
||||||
|
},
|
||||||
|
"electronInstallerDebian": {},
|
||||||
|
"electronInstallerRedhat": {},
|
||||||
|
"github_repository": {
|
||||||
|
"owner": "",
|
||||||
|
"name": ""
|
||||||
|
},
|
||||||
|
"windowsStoreConfig": {
|
||||||
|
"packageName": "",
|
||||||
|
"name": "electron_percy_wasm"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"electron-compile": "^6.4.3",
|
||||||
|
"webpack": "^4.17.1",
|
||||||
|
"webpack-cli": "^3.1.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"babel-plugin-transform-async-to-generator": "^6.24.1",
|
||||||
|
"babel-preset-env": "^1.7.0",
|
||||||
|
"babel-preset-react": "^6.24.1",
|
||||||
|
"electron-forge": "^5.2.2",
|
||||||
|
"electron-prebuilt-compile": "2.0.7",
|
||||||
|
"eslint": "^3",
|
||||||
|
"eslint-config-airbnb": "^15",
|
||||||
|
"eslint-plugin-import": "^2",
|
||||||
|
"eslint-plugin-jsx-a11y": "^5",
|
||||||
|
"eslint-plugin-react": "^7"
|
||||||
|
}
|
||||||
|
}
|
16
binaryen/src/lib.rs
Normal file
16
binaryen/src/lib.rs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
extern crate stdweb;
|
||||||
|
|
||||||
|
use stdweb::web::document;
|
||||||
|
use stdweb::web::INode;
|
||||||
|
use stdweb::web::IElement;
|
||||||
|
|
||||||
|
pub fn run() {
|
||||||
|
stdweb::initialize();
|
||||||
|
|
||||||
|
let doc = document();
|
||||||
|
let val = doc.create_element("p").unwrap();
|
||||||
|
val.set_attribute("innerHTML", "IT IS ALIVE").unwrap();
|
||||||
|
doc.body().unwrap().append_child(&val);
|
||||||
|
|
||||||
|
stdweb::event_loop();
|
||||||
|
}
|
8
binaryen/static/app_loader.js
Normal file
8
binaryen/static/app_loader.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
const app = import("./stdweb_electron")
|
||||||
|
app.then(module => {
|
||||||
|
console.log("Finished resolving application bundle")
|
||||||
|
module.run()
|
||||||
|
}, (e) => {
|
||||||
|
console.log("Unable to resolve application bundle: ")
|
||||||
|
console.log(e)
|
||||||
|
})
|
11
binaryen/static/index.html
Normal file
11
binaryen/static/index.html
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title></title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<p>Loading...</p>
|
||||||
|
</body>
|
||||||
|
<script src="./bundle.js"/>
|
||||||
|
</html>
|
52
binaryen/static/index.js
Normal file
52
binaryen/static/index.js
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
import { app, BrowserWindow } from 'electron';
|
||||||
|
|
||||||
|
// Keep a global reference of the window object, if you don't, the window will
|
||||||
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
|
let mainWindow;
|
||||||
|
|
||||||
|
const createWindow = () => {
|
||||||
|
// Create the browser window.
|
||||||
|
mainWindow = new BrowserWindow({
|
||||||
|
width: 800,
|
||||||
|
height: 600,
|
||||||
|
});
|
||||||
|
|
||||||
|
// and load the index.html of the app.
|
||||||
|
mainWindow.loadURL(`file://${__dirname}/index.html`);
|
||||||
|
|
||||||
|
// Open the DevTools.
|
||||||
|
mainWindow.webContents.openDevTools();
|
||||||
|
|
||||||
|
// Emitted when the window is closed.
|
||||||
|
mainWindow.on('closed', () => {
|
||||||
|
// Dereference the window object, usually you would store windows
|
||||||
|
// in an array if your app supports multi windows, this is the time
|
||||||
|
// when you should delete the corresponding element.
|
||||||
|
mainWindow = null;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// This method will be called when Electron has finished
|
||||||
|
// initialization and is ready to create browser windows.
|
||||||
|
// Some APIs can only be used after this event occurs.
|
||||||
|
app.on('ready', createWindow);
|
||||||
|
|
||||||
|
// Quit when all windows are closed.
|
||||||
|
app.on('window-all-closed', () => {
|
||||||
|
// On OS X it is common for applications and their menu bar
|
||||||
|
// to stay active until the user quits explicitly with Cmd + Q
|
||||||
|
if (process.platform !== 'darwin') {
|
||||||
|
app.quit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
app.on('activate', () => {
|
||||||
|
// On OS X it's common to re-create a window in the app when the
|
||||||
|
// dock icon is clicked and there are no other windows open.
|
||||||
|
if (mainWindow === null) {
|
||||||
|
createWindow();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// In this file you can include the rest of your app's specific main process
|
||||||
|
// code. You can also put them in separate files and import them here.
|
7736
binaryen/yarn.lock
Normal file
7736
binaryen/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user