naaah
This commit is contained in:
parent
6eb9f61e19
commit
ba62eb6a07
10 changed files with 0 additions and 12345 deletions
|
@ -1,51 +0,0 @@
|
||||||
# You must change these to your own details.
|
|
||||||
[package]
|
|
||||||
name = "web-optimle"
|
|
||||||
description = "My super awesome Rust, WebAssembly, and Webpack project!"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["You <you@example.com>"]
|
|
||||||
categories = ["wasm"]
|
|
||||||
readme = "README.md"
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
crate-type = ["cdylib"]
|
|
||||||
|
|
||||||
[profile.release]
|
|
||||||
# This makes the compiled code faster and smaller, but it makes compiling slower,
|
|
||||||
# so it's only enabled in release mode.
|
|
||||||
lto = true
|
|
||||||
|
|
||||||
[features]
|
|
||||||
# If you uncomment this line, it will enable `wee_alloc`:
|
|
||||||
default = ["wee_alloc"]
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
# The `wasm-bindgen` crate provides the bare minimum functionality needed
|
|
||||||
# to interact with JavaScript.
|
|
||||||
wasm-bindgen = "0.2.45"
|
|
||||||
|
|
||||||
# `wee_alloc` is a tiny allocator for wasm that is only ~1K in code size
|
|
||||||
# compared to the default allocator's ~10K. However, it is slower than the default
|
|
||||||
# allocator, so it's not enabled by default.
|
|
||||||
wee_alloc = { version = "0.4.2", optional = true }
|
|
||||||
|
|
||||||
# The `web-sys` crate allows you to interact with the various browser APIs,
|
|
||||||
# like the DOM.
|
|
||||||
[dependencies.web-sys]
|
|
||||||
version = "0.3.22"
|
|
||||||
features = ["console"]
|
|
||||||
|
|
||||||
# The `console_error_panic_hook` crate provides better debugging of panics by
|
|
||||||
# logging them with `console.error`. This is great for development, but requires
|
|
||||||
# all the `std::fmt` and `std::panicking` infrastructure, so it's only enabled
|
|
||||||
# in debug mode.
|
|
||||||
[target."cfg(debug_assertions)".dependencies]
|
|
||||||
console_error_panic_hook = "0.1.5"
|
|
||||||
|
|
||||||
# These crates are used for running unit tests.
|
|
||||||
[dev-dependencies]
|
|
||||||
wasm-bindgen-test = "0.2.45"
|
|
||||||
futures = "0.1.27"
|
|
||||||
js-sys = "0.3.22"
|
|
||||||
wasm-bindgen-futures = "0.3.22"
|
|
|
@ -1,48 +0,0 @@
|
||||||
## How to install
|
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install
|
|
||||||
```
|
|
||||||
|
|
||||||
## How to run in debug mode
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# Builds the project and opens it in a new browser tab. Auto-reloads when the project changes.
|
|
||||||
npm start
|
|
||||||
```
|
|
||||||
|
|
||||||
## How to build in release mode
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# Builds the project and places it into the `dist` folder.
|
|
||||||
npm run build
|
|
||||||
```
|
|
||||||
|
|
||||||
## How to run unit tests
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# Runs tests in Firefox
|
|
||||||
npm test -- --firefox
|
|
||||||
|
|
||||||
# Runs tests in Chrome
|
|
||||||
npm test -- --chrome
|
|
||||||
|
|
||||||
# Runs tests in Safari
|
|
||||||
npm test -- --safari
|
|
||||||
```
|
|
||||||
|
|
||||||
## What does each file do?
|
|
||||||
|
|
||||||
* `Cargo.toml` contains the standard Rust metadata. You put your Rust dependencies in here. You must change this file with your details (name, description, version, authors, categories)
|
|
||||||
|
|
||||||
* `package.json` contains the standard npm metadata. You put your JavaScript dependencies in here. You must change this file with your details (author, name, version)
|
|
||||||
|
|
||||||
* `webpack.config.js` contains the Webpack configuration. You shouldn't need to change this, unless you have very special needs.
|
|
||||||
|
|
||||||
* The `js` folder contains your JavaScript code (`index.js` is used to hook everything into Webpack, you don't need to change it).
|
|
||||||
|
|
||||||
* The `src` folder contains your Rust code.
|
|
||||||
|
|
||||||
* The `static` folder contains any files that you want copied as-is into the final build. It contains an `index.html` file which loads the `index.js` file.
|
|
||||||
|
|
||||||
* The `tests` folder contains your Rust unit tests.
|
|
|
@ -1 +0,0 @@
|
||||||
import("../pkg/index.js").catch(console.error);
|
|
12090
web-optimle/package-lock.json
generated
12090
web-optimle/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -1,25 +0,0 @@
|
||||||
{
|
|
||||||
"author": "ashastral <git@ashastral.com>",
|
|
||||||
"name": "optimle-web",
|
|
||||||
"version": "0.1.0",
|
|
||||||
"scripts": {
|
|
||||||
"build": "rimraf dist pkg && webpack",
|
|
||||||
"start": "rimraf dist pkg && webpack-dev-server --open -d",
|
|
||||||
"test": "cargo test && wasm-pack test --headless"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"preact": "^10.6.6"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@tsconfig/recommended": "^1.0.1",
|
|
||||||
"@types/eslint": "^8.4.1",
|
|
||||||
"@wasm-tool/wasm-pack-plugin": "^1.6.0",
|
|
||||||
"copy-webpack-plugin": "^10.2.4",
|
|
||||||
"ts-loader": "^9.2.6",
|
|
||||||
"typescript": "^4.5.5",
|
|
||||||
"webpack": "^5.69.1",
|
|
||||||
"webpack-cli": "^3.3.3",
|
|
||||||
"webpack-dev-server": "^3.7.1",
|
|
||||||
"rimraf": "^3.0.0"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
use wasm_bindgen::prelude::*;
|
|
||||||
use web_sys::console;
|
|
||||||
|
|
||||||
|
|
||||||
// When the `wee_alloc` feature is enabled, this uses `wee_alloc` as the global
|
|
||||||
// allocator.
|
|
||||||
//
|
|
||||||
// If you don't want to use `wee_alloc`, you can safely delete this.
|
|
||||||
#[cfg(feature = "wee_alloc")]
|
|
||||||
#[global_allocator]
|
|
||||||
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
|
|
||||||
|
|
||||||
|
|
||||||
// This is like the `main` function, except for JavaScript.
|
|
||||||
#[wasm_bindgen(start)]
|
|
||||||
pub fn main_js() -> Result<(), JsValue> {
|
|
||||||
// This provides better error messages in debug mode.
|
|
||||||
// It's disabled in release mode so it doesn't bloat up the file size.
|
|
||||||
#[cfg(debug_assertions)]
|
|
||||||
console_error_panic_hook::set_once();
|
|
||||||
|
|
||||||
|
|
||||||
// Your code goes here!
|
|
||||||
console::log_1(&JsValue::from_str("Hello world!"));
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>My Rust + Webpack project!</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<script src="index.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,35 +0,0 @@
|
||||||
use wasm_bindgen_test::{wasm_bindgen_test_configure, wasm_bindgen_test};
|
|
||||||
use futures::prelude::*;
|
|
||||||
use wasm_bindgen::JsValue;
|
|
||||||
use wasm_bindgen_futures::JsFuture;
|
|
||||||
|
|
||||||
wasm_bindgen_test_configure!(run_in_browser);
|
|
||||||
|
|
||||||
|
|
||||||
// This runs a unit test in native Rust, so it can only use Rust APIs.
|
|
||||||
#[test]
|
|
||||||
fn rust_test() {
|
|
||||||
assert_eq!(1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// This runs a unit test in the browser, so it can use browser APIs.
|
|
||||||
#[wasm_bindgen_test]
|
|
||||||
fn web_test() {
|
|
||||||
assert_eq!(1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// This runs a unit test in the browser, and in addition it supports asynchronous Future APIs.
|
|
||||||
#[wasm_bindgen_test(async)]
|
|
||||||
fn async_test() -> impl Future<Item = (), Error = JsValue> {
|
|
||||||
// Creates a JavaScript Promise which will asynchronously resolve with the value 42.
|
|
||||||
let promise = js_sys::Promise::resolve(&JsValue::from(42));
|
|
||||||
|
|
||||||
// Converts that Promise into a Future.
|
|
||||||
// The unit test will wait for the Future to resolve.
|
|
||||||
JsFuture::from(promise)
|
|
||||||
.map(|x| {
|
|
||||||
assert_eq!(x, 42);
|
|
||||||
})
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
{
|
|
||||||
"extends": "@tsconfig/recommended/tsconfig.json",
|
|
||||||
"compilerOptions": {
|
|
||||||
"sourceMap": true,
|
|
||||||
"jsx": "react",
|
|
||||||
"jsxFactory": "h",
|
|
||||||
"jsxFragmentFactory": "Fragment"
|
|
||||||
},
|
|
||||||
"include": [
|
|
||||||
"src/*.ts",
|
|
||||||
"src/*.tsx"
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
const path = require("path");
|
|
||||||
const CopyPlugin = require("copy-webpack-plugin");
|
|
||||||
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
|
|
||||||
|
|
||||||
const dist = path.resolve(__dirname, "dist");
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
mode: "production",
|
|
||||||
devtool: 'source-map',
|
|
||||||
entry: {
|
|
||||||
index: "./js/index.ts"
|
|
||||||
},
|
|
||||||
output: {
|
|
||||||
path: dist,
|
|
||||||
filename: "[name].js"
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
extensions: ['', '.js', '.ts', '.tsx'],
|
|
||||||
},
|
|
||||||
devServer: {
|
|
||||||
contentBase: dist,
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.tsx?$/,
|
|
||||||
exclude: /node_modules/,
|
|
||||||
use: 'ts-loader',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.css$/,
|
|
||||||
use: ['style-loader', 'css-loader'],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
new CopyPlugin([
|
|
||||||
path.resolve(__dirname, "static")
|
|
||||||
]),
|
|
||||||
|
|
||||||
new WasmPackPlugin({
|
|
||||||
crateDirectory: __dirname,
|
|
||||||
}),
|
|
||||||
]
|
|
||||||
};
|
|
Loading…
Reference in a new issue