add web-app stub
This commit is contained in:
Generated
+4
@@ -161,9 +161,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"js-sys",
|
||||
"libc",
|
||||
"r-efi",
|
||||
"rand_core",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -472,8 +474,10 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"colored",
|
||||
"derive_more",
|
||||
"getrandom",
|
||||
"indicatif",
|
||||
"rand",
|
||||
"rayon",
|
||||
"tabular",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
@@ -9,6 +9,7 @@ edition = "2021"
|
||||
[lib]
|
||||
name = "wordle_solver"
|
||||
path = "src/lib/lib.rs"
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[[bin]]
|
||||
name = "wordle-solver"
|
||||
@@ -21,7 +22,13 @@ path = "src/app/wordle_simulation.rs"
|
||||
[dependencies]
|
||||
colored = "3.1.1"
|
||||
derive_more = { version = "2.1.1", features = [ "debug", "display" ] }
|
||||
getrandom = { version = "0.4.3", optional = true }
|
||||
indicatif = { version = "0.18.6", features = ["rayon"] }
|
||||
rand = "0.10.2"
|
||||
rayon = "1.12.0"
|
||||
tabular = { version = "0.2.0", features = ["ansi-cell"] }
|
||||
wasm-bindgen = { version = "0.2.127", optional = true }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
wasm-bindgen = ["dep:wasm-bindgen", "getrandom/wasm_js"]
|
||||
|
||||
@@ -65,7 +65,14 @@
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = [rust-toolchain];
|
||||
buildInputs = [
|
||||
rust-toolchain
|
||||
pkgs.typescript-language-server
|
||||
pkgs.vscode-langservers-extracted
|
||||
pkgs.wasm-bindgen-cli
|
||||
pkgs.wasm-pack
|
||||
pkgs.yarn
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
[toolchain]
|
||||
channel = "1.96.0"
|
||||
components = [ "rustfmt", "rustc-dev", "rust-analyzer", "rust-src"]
|
||||
targets = [ "wasm32-unknown-unknown" ] # beside the standard system target
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use std::collections::hash_map;
|
||||
use std::io;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
pub mod game;
|
||||
pub mod pattern;
|
||||
pub mod solver;
|
||||
#[cfg(feature = "wasm-bindgen")]
|
||||
pub mod wasm;
|
||||
pub mod word_list;
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen]
|
||||
extern "C" {
|
||||
fn alert(s: &str);
|
||||
}
|
||||
#[wasm_bindgen]
|
||||
pub fn greet() {
|
||||
alert("Hello, wasm-on-web!");
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
@@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>WASM Demo</title>
|
||||
</head>
|
||||
<body>
|
||||
<button id="my-button">Do greet</button>
|
||||
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "web",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "run-s wasm-pack:release tsc vite:build",
|
||||
"dev": "run-s wasm-pack:dev vite:dev",
|
||||
"tsc": "tsc",
|
||||
"vite:build": "vite build",
|
||||
"vite:dev": "vite -c vite.config.dev.ts",
|
||||
"vite:preview": "vite preview",
|
||||
"wasm-pack:dev": "wasm-pack build --dev --features wasm-bindgen --manifest-path ../Cargo.toml",
|
||||
"wasm-pack:release": "wasm-pack build --features wasm-bindgen --manifest-path ../Cargo.toml"
|
||||
},
|
||||
"devDependencies": {
|
||||
"npm-run-all": "^4.1.5",
|
||||
"typescript": "~6.0.2",
|
||||
"vite": "^8.2.0",
|
||||
"vite-plugin-top-level-await": "^1.6.0",
|
||||
"vite-plugin-wasm": "^3.6.0",
|
||||
"vite-plugin-wasm-pack-watcher": "^1.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"esbuild": "^0.28.2",
|
||||
"rollup": "^4.62.4",
|
||||
"wordle-solver": "link:../pkg"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { greet } from "wordle-solver";
|
||||
|
||||
const button = document.getElementById("my-button")!;
|
||||
|
||||
button.addEventListener("click", () => {
|
||||
greet();
|
||||
});
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2023",
|
||||
"module": "esnext",
|
||||
"lib": ["ES2023", "DOM"],
|
||||
"types": ["vite/client"],
|
||||
"allowArbitraryExtensions": true,
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
|
||||
/* Linting */
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"erasableSyntaxOnly": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { defineConfig } from "vite";
|
||||
import wasm from "vite-plugin-wasm";
|
||||
import wasmPackWatchPlugin from "vite-plugin-wasm-pack-watcher";
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
watch: {
|
||||
include: ["src/**/*.ts", "../src/**/*.rs"],
|
||||
},
|
||||
},
|
||||
plugins: [wasmPackWatchPlugin(), wasm()],
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { defineConfig } from "vite";
|
||||
import wasm from "vite-plugin-wasm";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [wasm()],
|
||||
});
|
||||
+1855
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user