refactoring for wasm
This commit is contained in:
parent
a59a320c85
commit
edcb715de8
29 changed files with 18126 additions and 320 deletions
|
@ -3,7 +3,5 @@
|
||||||
"singleQuote": false,
|
"singleQuote": false,
|
||||||
"trailingComma": "all",
|
"trailingComma": "all",
|
||||||
"tabWidth": 2,
|
"tabWidth": 2,
|
||||||
"printWidth": 80,
|
"printWidth": 80
|
||||||
"plugins": ["prettier-plugin-svelte"],
|
|
||||||
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
|
|
||||||
}
|
}
|
||||||
|
|
184
Cargo.lock
generated
184
Cargo.lock
generated
|
@ -120,12 +120,12 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anstyle-wincon"
|
name = "anstyle-wincon"
|
||||||
version = "3.0.1"
|
version = "3.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628"
|
checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstyle",
|
"anstyle",
|
||||||
"windows-sys 0.48.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -169,20 +169,6 @@ dependencies = [
|
||||||
"syn 2.0.43",
|
"syn 2.0.43",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "async-tungstenite"
|
|
||||||
version = "0.19.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8e6acf7e4a267eecbb127ed696bb2d50572c22ba7f586a646321e1798d8336a1"
|
|
||||||
dependencies = [
|
|
||||||
"futures-io",
|
|
||||||
"futures-util",
|
|
||||||
"log",
|
|
||||||
"pin-project-lite",
|
|
||||||
"tokio",
|
|
||||||
"tungstenite",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "asynchronous-codec"
|
name = "asynchronous-codec"
|
||||||
version = "0.6.2"
|
version = "0.6.2"
|
||||||
|
@ -233,44 +219,12 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "axum"
|
name = "axum"
|
||||||
version = "0.6.20"
|
version = "0.7.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf"
|
checksum = "d09dbe0e490df5da9d69b36dca48a76635288a82f92eca90024883a56202026d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"axum-core 0.3.4",
|
"axum-core",
|
||||||
"bitflags 1.3.2",
|
|
||||||
"bytes",
|
|
||||||
"futures-util",
|
|
||||||
"http 0.2.11",
|
|
||||||
"http-body 0.4.6",
|
|
||||||
"hyper 0.14.28",
|
|
||||||
"itoa",
|
|
||||||
"matchit",
|
|
||||||
"memchr",
|
|
||||||
"mime",
|
|
||||||
"percent-encoding",
|
|
||||||
"pin-project-lite",
|
|
||||||
"rustversion",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"serde_path_to_error",
|
|
||||||
"serde_urlencoded",
|
|
||||||
"sync_wrapper",
|
|
||||||
"tokio",
|
|
||||||
"tower",
|
|
||||||
"tower-layer",
|
|
||||||
"tower-service",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "axum"
|
|
||||||
version = "0.7.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "202651474fe73c62d9e0a56c6133f7a0ff1dc1c8cf7a5b03381af2a26553ac9d"
|
|
||||||
dependencies = [
|
|
||||||
"async-trait",
|
|
||||||
"axum-core 0.4.1",
|
|
||||||
"bytes",
|
"bytes",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"http 1.0.0",
|
"http 1.0.0",
|
||||||
|
@ -294,30 +248,14 @@ dependencies = [
|
||||||
"tower",
|
"tower",
|
||||||
"tower-layer",
|
"tower-layer",
|
||||||
"tower-service",
|
"tower-service",
|
||||||
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "axum-core"
|
name = "axum-core"
|
||||||
version = "0.3.4"
|
version = "0.4.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c"
|
checksum = "e87c8503f93e6d144ee5690907ba22db7ba79ab001a932ab99034f0fe836b3df"
|
||||||
dependencies = [
|
|
||||||
"async-trait",
|
|
||||||
"bytes",
|
|
||||||
"futures-util",
|
|
||||||
"http 0.2.11",
|
|
||||||
"http-body 0.4.6",
|
|
||||||
"mime",
|
|
||||||
"rustversion",
|
|
||||||
"tower-layer",
|
|
||||||
"tower-service",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "axum-core"
|
|
||||||
version = "0.4.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "77cb22c689c44d4c07b0ab44ebc25d69d8ae601a2f28fb8d672d344178fa17aa"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
@ -331,6 +269,7 @@ dependencies = [
|
||||||
"sync_wrapper",
|
"sync_wrapper",
|
||||||
"tower-layer",
|
"tower-layer",
|
||||||
"tower-service",
|
"tower-service",
|
||||||
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -338,20 +277,13 @@ name = "backend"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"axum 0.7.2",
|
"axum",
|
||||||
"chrono",
|
"clap 4.4.12",
|
||||||
"clap 4.4.11",
|
"common",
|
||||||
"colourado",
|
|
||||||
"names",
|
|
||||||
"petgraph 0.6.4",
|
|
||||||
"prisma-client-rust",
|
"prisma-client-rust",
|
||||||
"rand 0.8.5",
|
|
||||||
"rand_chacha 0.3.1",
|
|
||||||
"rspc",
|
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"tokio",
|
"tokio",
|
||||||
"triangle",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -397,12 +329,6 @@ version = "0.13.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
|
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "base64"
|
|
||||||
version = "0.20.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0ea22880d78093b0cbe17c89f64a7d457941e65759157ec6cb31a31d652b05e5"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "base64"
|
name = "base64"
|
||||||
version = "0.21.5"
|
version = "0.21.5"
|
||||||
|
@ -688,9 +614,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "4.4.11"
|
version = "4.4.12"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2"
|
checksum = "dcfab8ba68f3668e89f6ff60f5b205cea56aa7b769451a59f34b8682f51c056d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap_builder",
|
"clap_builder",
|
||||||
"clap_derive 4.4.7",
|
"clap_derive 4.4.7",
|
||||||
|
@ -698,9 +624,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_builder"
|
name = "clap_builder"
|
||||||
version = "4.4.11"
|
version = "4.4.12"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb"
|
checksum = "fb7fb5e4e979aec3be7791562fcba452f94ad85e954da024396433e0e25a79e9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstream",
|
"anstream",
|
||||||
"anstyle",
|
"anstyle",
|
||||||
|
@ -804,6 +730,24 @@ dependencies = [
|
||||||
"unreachable",
|
"unreachable",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "common"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"chrono",
|
||||||
|
"colourado",
|
||||||
|
"getrandom 0.2.11",
|
||||||
|
"names",
|
||||||
|
"petgraph 0.6.4",
|
||||||
|
"prisma-client-rust",
|
||||||
|
"rand 0.8.5",
|
||||||
|
"rand_chacha 0.3.1",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"triangle",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "connection-string"
|
name = "connection-string"
|
||||||
version = "0.1.14"
|
version = "0.1.14"
|
||||||
|
@ -841,17 +785,6 @@ dependencies = [
|
||||||
"unicode-segmentation",
|
"unicode-segmentation",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cookie"
|
|
||||||
version = "0.16.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e859cd57d0710d9e06c381b550c06e76992472a8c6d527aecd2fc673dcc231fb"
|
|
||||||
dependencies = [
|
|
||||||
"percent-encoding",
|
|
||||||
"time",
|
|
||||||
"version_check",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "core-foundation"
|
name = "core-foundation"
|
||||||
version = "0.9.4"
|
version = "0.9.4"
|
||||||
|
@ -1662,8 +1595,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f"
|
checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
|
"js-sys",
|
||||||
"libc",
|
"libc",
|
||||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||||
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1892,25 +1827,6 @@ version = "1.0.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
|
checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "httpz"
|
|
||||||
version = "0.0.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6769d2cb10425c442c41a787d1a3719744770a188cfa7885cd4d8126fa13f37a"
|
|
||||||
dependencies = [
|
|
||||||
"async-tungstenite",
|
|
||||||
"axum 0.6.20",
|
|
||||||
"base64 0.20.0",
|
|
||||||
"cookie",
|
|
||||||
"form_urlencoded",
|
|
||||||
"futures",
|
|
||||||
"http 0.2.11",
|
|
||||||
"hyper 0.14.28",
|
|
||||||
"sha1",
|
|
||||||
"thiserror",
|
|
||||||
"tokio",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hyper"
|
name = "hyper"
|
||||||
version = "0.14.28"
|
version = "0.14.28"
|
||||||
|
@ -4154,7 +4070,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c68477fb8c11280503aeab140c41b7a0eed57156a73185062ffb4782c18a918f"
|
checksum = "c68477fb8c11280503aeab140c41b7a0eed57156a73185062ffb4782c18a918f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"httpz",
|
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"specta",
|
"specta",
|
||||||
|
@ -5398,25 +5313,6 @@ version = "0.2.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
|
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tungstenite"
|
|
||||||
version = "0.18.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "30ee6ab729cd4cf0fd55218530c4522ed30b7b6081752839b68fcec8d0960788"
|
|
||||||
dependencies = [
|
|
||||||
"base64 0.13.1",
|
|
||||||
"byteorder",
|
|
||||||
"bytes",
|
|
||||||
"http 0.2.11",
|
|
||||||
"httparse",
|
|
||||||
"log",
|
|
||||||
"rand 0.8.5",
|
|
||||||
"sha1",
|
|
||||||
"thiserror",
|
|
||||||
"url",
|
|
||||||
"utf-8",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "twox-hash"
|
name = "twox-hash"
|
||||||
version = "1.6.3"
|
version = "1.6.3"
|
||||||
|
@ -5541,12 +5437,6 @@ dependencies = [
|
||||||
"user-facing-error-macros",
|
"user-facing-error-macros",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "utf-8"
|
|
||||||
version = "0.7.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "utf8parse"
|
name = "utf8parse"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
workspace.members = ["backend", "prisma-cli", "triangle", "triangle-sys"]
|
workspace.members = ["backend", "common", "prisma-cli", "triangle", "triangle-sys"]
|
||||||
workspace.resolver = "2"
|
workspace.resolver = "2"
|
||||||
workspace.default-members = ["backend"]
|
workspace.default-members = ["backend"]
|
||||||
|
|
|
@ -4,21 +4,14 @@ version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
triangle = { path = "../triangle" }
|
common = { path = "../common", features = ["worldgen"] }
|
||||||
|
|
||||||
anyhow = "1.0.76"
|
anyhow = "1.0.76"
|
||||||
axum = { version = "0.7.2", features = ["http2"] }
|
axum = { version = "0.7.2", features = ["http2"] }
|
||||||
chrono = "0.4.31"
|
|
||||||
clap = { version = "4.4.11", features = ["derive"] }
|
clap = { version = "4.4.11", features = ["derive"] }
|
||||||
serde = { version = "1.0.193", features = ["derive"] }
|
serde = { version = "1.0.193", features = ["derive"] }
|
||||||
tokio = { version = "1.35.1", features = ["full"] }
|
|
||||||
serde_json = "1.0.108"
|
serde_json = "1.0.108"
|
||||||
petgraph = "0.6.4"
|
tokio = { version = "1.35.1", features = ["full"] }
|
||||||
names = "0.14.0"
|
|
||||||
rand = "0.8.5"
|
|
||||||
rspc = { version = "0.1.3", features = ["axum"] }
|
|
||||||
rand_chacha = "0.3.1"
|
|
||||||
colourado = "0.2.0"
|
|
||||||
|
|
||||||
[dependencies.prisma-client-rust]
|
[dependencies.prisma-client-rust]
|
||||||
git = "https://github.com/Brendonovich/prisma-client-rust"
|
git = "https://github.com/Brendonovich/prisma-client-rust"
|
||||||
|
|
|
@ -1,23 +1,18 @@
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
|
|
||||||
mod generate;
|
|
||||||
#[allow(unused_imports, dead_code, clippy::all)]
|
|
||||||
pub mod prisma;
|
|
||||||
mod routes;
|
mod routes;
|
||||||
pub mod state;
|
|
||||||
mod utils;
|
pub use common::prisma;
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use axum::{routing::get, Router};
|
use axum::{routing::get, Router};
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
use prisma::PrismaClient;
|
use common::{generate::generate_initial_game_state, prisma::PrismaClient};
|
||||||
|
|
||||||
use routes::{empire_list, universe_list, universe_map};
|
use crate::routes::{empire_list, universe_list, universe_map};
|
||||||
|
|
||||||
use crate::generate::generate_initial_game_state;
|
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
|
@ -33,7 +28,7 @@ enum Command {
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct AppState {
|
struct AppState {
|
||||||
prisma: Arc<PrismaClient>,
|
pub prisma: Arc<PrismaClient>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
|
|
@ -5,11 +5,9 @@ use axum::{
|
||||||
use prisma_client_rust::Direction;
|
use prisma_client_rust::Direction;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
use crate::{
|
use common::prisma::{empire, planet, star_system, star_system_edges};
|
||||||
prisma::{empire, planet, star_system, star_system_edges},
|
|
||||||
state::UniverseId,
|
use crate::AppState;
|
||||||
AppState,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub async fn universe_list(state: State<AppState>) -> Json<Value> {
|
pub async fn universe_list(state: State<AppState>) -> Json<Value> {
|
||||||
let universes = state
|
let universes = state
|
||||||
|
@ -51,7 +49,7 @@ pub async fn universe_map(
|
||||||
.star_system()
|
.star_system()
|
||||||
.find_many(vec![star_system::universe_id::equals(universe_id)])
|
.find_many(vec![star_system::universe_id::equals(universe_id)])
|
||||||
.order_by(star_system::index::order(Direction::Asc))
|
.order_by(star_system::index::order(Direction::Asc))
|
||||||
.select(star_system::select!({ index coord_x coord_y owned_by_empire_id }))
|
.select(star_system::select!({ index coord_x coord_y owned_by_empire_id planets }))
|
||||||
.exec()
|
.exec()
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
34
common/Cargo.toml
Normal file
34
common/Cargo.toml
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[package]
|
||||||
|
name = "common"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = []
|
||||||
|
worldgen = ["db", "dep:triangle"]
|
||||||
|
db = ["dep:prisma-client-rust"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
triangle = { path = "../triangle", optional = true }
|
||||||
|
|
||||||
|
anyhow = "1.0.76"
|
||||||
|
chrono = "0.4.31"
|
||||||
|
colourado = "0.2.0"
|
||||||
|
names = "0.14.0"
|
||||||
|
petgraph = "0.6.4"
|
||||||
|
rand = "0.8.5"
|
||||||
|
rand_chacha = "0.3.1"
|
||||||
|
# rspc = { version = "0.1.3", features = ["axum"] }
|
||||||
|
serde = { version = "1.0.193", features = ["derive"] }
|
||||||
|
serde_json = "1.0.108"
|
||||||
|
# tokio = { version = "1.35.1", features = ["full"] }
|
||||||
|
getrandom = { version = "0.2.11", features = ["js"] }
|
||||||
|
|
||||||
|
[dependencies.prisma-client-rust]
|
||||||
|
git = "https://github.com/Brendonovich/prisma-client-rust"
|
||||||
|
tag = "0.6.10"
|
||||||
|
features = ["rspc"]
|
||||||
|
optional = true
|
|
@ -31,7 +31,7 @@ pub fn generate_map() -> Result<Map> {
|
||||||
TrianglulateOpts::builder()
|
TrianglulateOpts::builder()
|
||||||
.point_list(point_list)
|
.point_list(point_list)
|
||||||
.voronoi(true)
|
.voronoi(true)
|
||||||
.maximum_triangle_area(6_000.0)
|
.maximum_triangle_area(7_500.0)
|
||||||
.build()?,
|
.build()?,
|
||||||
)?
|
)?
|
||||||
};
|
};
|
|
@ -11,7 +11,7 @@ use rand::{seq::SliceRandom, thread_rng, RngCore, SeedableRng};
|
||||||
use rand_chacha::ChaCha12Rng;
|
use rand_chacha::ChaCha12Rng;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
prisma::{planet, star_system, universe, PrismaClient},
|
prisma::PrismaClient,
|
||||||
state::{
|
state::{
|
||||||
EmpireCoreState, EmpireId, GameCoreState, PlanetCoreState, PlanetId,
|
EmpireCoreState, EmpireId, GameCoreState, PlanetCoreState, PlanetId,
|
||||||
StarSystemId, UniverseId,
|
StarSystemId, UniverseId,
|
11
common/src/lib.rs
Normal file
11
common/src/lib.rs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#[macro_use]
|
||||||
|
extern crate serde_json;
|
||||||
|
|
||||||
|
#[cfg(feature = "worldgen")]
|
||||||
|
pub mod generate;
|
||||||
|
|
||||||
|
#[allow(unused_imports, dead_code, clippy::all)]
|
||||||
|
#[cfg(feature = "db")]
|
||||||
|
pub mod prisma;
|
||||||
|
pub mod state;
|
||||||
|
pub mod utils;
|
17776
common/src/prisma.rs
Normal file
17776
common/src/prisma.rs
Normal file
File diff suppressed because one or more lines are too long
|
@ -4,9 +4,11 @@ use anyhow::Result;
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use petgraph::graphmap::UnGraphMap;
|
use petgraph::graphmap::UnGraphMap;
|
||||||
|
|
||||||
use crate::{
|
use crate::utils::format_color;
|
||||||
prisma::{empire, planet, star_system, star_system_edges, PrismaClient},
|
|
||||||
utils::format_color,
|
#[cfg(feature = "db")]
|
||||||
|
use crate::prisma::{
|
||||||
|
empire, planet, star_system, star_system_edges, PrismaClient,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{EmpireCoreState, EmpireId, StarSystemCoreState, StarSystemId};
|
use super::{EmpireCoreState, EmpireId, StarSystemCoreState, StarSystemId};
|
||||||
|
@ -29,6 +31,7 @@ pub struct GameDerivedState<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GameCoreState {
|
impl GameCoreState {
|
||||||
|
#[cfg(feature = "db")]
|
||||||
pub async fn save_to_database(&self, client: &PrismaClient) -> Result<()> {
|
pub async fn save_to_database(&self, client: &PrismaClient) -> Result<()> {
|
||||||
// Save star systems to database
|
// Save star systems to database
|
||||||
let mut owned_systems = HashMap::new();
|
let mut owned_systems = HashMap::new();
|
|
@ -2,17 +2,17 @@ module.exports = {
|
||||||
root: true,
|
root: true,
|
||||||
env: { browser: true, es2020: true },
|
env: { browser: true, es2020: true },
|
||||||
extends: [
|
extends: [
|
||||||
'eslint:recommended',
|
"eslint:recommended",
|
||||||
'plugin:@typescript-eslint/recommended',
|
"plugin:@typescript-eslint/recommended",
|
||||||
'plugin:react-hooks/recommended',
|
"plugin:react-hooks/recommended",
|
||||||
],
|
],
|
||||||
ignorePatterns: ['dist', '.eslintrc.cjs'],
|
ignorePatterns: ["dist", ".eslintrc.cjs"],
|
||||||
parser: '@typescript-eslint/parser',
|
parser: "@typescript-eslint/parser",
|
||||||
plugins: ['react-refresh'],
|
plugins: ["react-refresh"],
|
||||||
rules: {
|
rules: {
|
||||||
'react-refresh/only-export-components': [
|
"react-refresh/only-export-components": [
|
||||||
'warn',
|
"warn",
|
||||||
{ allowConstantExport: true },
|
{ allowConstantExport: true },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
"leva": "^0.9.35",
|
"leva": "^0.9.35",
|
||||||
"normalize.css": "^8.0.1",
|
"normalize.css": "^8.0.1",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
|
"react-beautiful-dnd": "^13.1.1",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-draggable": "^4.4.6",
|
"react-draggable": "^4.4.6",
|
||||||
"react-query": "^3.39.3",
|
"react-query": "^3.39.3",
|
||||||
|
@ -35,6 +36,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/react": "^18.2.43",
|
"@types/react": "^18.2.43",
|
||||||
|
"@types/react-beautiful-dnd": "^13.1.8",
|
||||||
"@types/react-dom": "^18.2.17",
|
"@types/react-dom": "^18.2.17",
|
||||||
"@typescript-eslint/eslint-plugin": "^6.14.0",
|
"@typescript-eslint/eslint-plugin": "^6.14.0",
|
||||||
"@typescript-eslint/parser": "^6.14.0",
|
"@typescript-eslint/parser": "^6.14.0",
|
||||||
|
@ -44,6 +46,8 @@
|
||||||
"eslint-plugin-react-refresh": "^0.4.5",
|
"eslint-plugin-react-refresh": "^0.4.5",
|
||||||
"sass": "^1.69.6",
|
"sass": "^1.69.6",
|
||||||
"typescript": "^5.2.2",
|
"typescript": "^5.2.2",
|
||||||
"vite": "^5.0.8"
|
"vite": "^5.0.8",
|
||||||
|
"vite-plugin-top-level-await": "^1.4.1",
|
||||||
|
"vite-plugin-wasm": "^3.3.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,9 @@ dependencies:
|
||||||
react:
|
react:
|
||||||
specifier: ^18.2.0
|
specifier: ^18.2.0
|
||||||
version: 18.2.0
|
version: 18.2.0
|
||||||
|
react-beautiful-dnd:
|
||||||
|
specifier: ^13.1.1
|
||||||
|
version: 13.1.1(react-dom@18.2.0)(react@18.2.0)
|
||||||
react-dom:
|
react-dom:
|
||||||
specifier: ^18.2.0
|
specifier: ^18.2.0
|
||||||
version: 18.2.0(react@18.2.0)
|
version: 18.2.0(react@18.2.0)
|
||||||
|
@ -67,6 +70,9 @@ devDependencies:
|
||||||
'@types/react':
|
'@types/react':
|
||||||
specifier: ^18.2.43
|
specifier: ^18.2.43
|
||||||
version: 18.2.46
|
version: 18.2.46
|
||||||
|
'@types/react-beautiful-dnd':
|
||||||
|
specifier: ^13.1.8
|
||||||
|
version: 13.1.8
|
||||||
'@types/react-dom':
|
'@types/react-dom':
|
||||||
specifier: ^18.2.17
|
specifier: ^18.2.17
|
||||||
version: 18.2.18
|
version: 18.2.18
|
||||||
|
@ -97,6 +103,12 @@ devDependencies:
|
||||||
vite:
|
vite:
|
||||||
specifier: ^5.0.8
|
specifier: ^5.0.8
|
||||||
version: 5.0.10(sass@1.69.6)
|
version: 5.0.10(sass@1.69.6)
|
||||||
|
vite-plugin-top-level-await:
|
||||||
|
specifier: ^1.4.1
|
||||||
|
version: 1.4.1(vite@5.0.10)
|
||||||
|
vite-plugin-wasm:
|
||||||
|
specifier: ^3.3.0
|
||||||
|
version: 3.3.0(vite@5.0.10)
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
|
||||||
|
@ -1047,6 +1059,16 @@ packages:
|
||||||
engines: {node: '>=14.0.0'}
|
engines: {node: '>=14.0.0'}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/@rollup/plugin-virtual@3.0.2:
|
||||||
|
resolution: {integrity: sha512-10monEYsBp3scM4/ND4LNH5Rxvh3e/cVeL3jWTgZ2SrQ+BmUoQcopVQvnaMcOnykb1VkxUFuDAN+0FnpTFRy2A==}
|
||||||
|
engines: {node: '>=14.0.0'}
|
||||||
|
peerDependencies:
|
||||||
|
rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0
|
||||||
|
peerDependenciesMeta:
|
||||||
|
rollup:
|
||||||
|
optional: true
|
||||||
|
dev: true
|
||||||
|
|
||||||
/@rollup/rollup-android-arm-eabi@4.9.1:
|
/@rollup/rollup-android-arm-eabi@4.9.1:
|
||||||
resolution: {integrity: sha512-6vMdBZqtq1dVQ4CWdhFwhKZL6E4L1dV6jUjuBvsavvNJSppzi6dLBbuV+3+IyUREaj9ZFvQefnQm28v4OCXlig==}
|
resolution: {integrity: sha512-6vMdBZqtq1dVQ4CWdhFwhKZL6E4L1dV6jUjuBvsavvNJSppzi6dLBbuV+3+IyUREaj9ZFvQefnQm28v4OCXlig==}
|
||||||
cpu: [arm]
|
cpu: [arm]
|
||||||
|
@ -1286,6 +1308,13 @@ packages:
|
||||||
resolution: {integrity: sha512-4MMUjMQb4yA5fJ4osXx+QxGHt0/ZSy4spT6jL1HM7Tn8OJEC35siqdnpOo+HxPhYjqEFumKfGVF9hJfdyKBIBA==}
|
resolution: {integrity: sha512-4MMUjMQb4yA5fJ4osXx+QxGHt0/ZSy4spT6jL1HM7Tn8OJEC35siqdnpOo+HxPhYjqEFumKfGVF9hJfdyKBIBA==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/@types/hoist-non-react-statics@3.3.5:
|
||||||
|
resolution: {integrity: sha512-SbcrWzkKBw2cdwRTwQAswfpB9g9LJWfjtUeW/jvNwbhC8cpmmNYVePa+ncbUe0rGTQ7G3Ff6mYUN2VMfLVr+Sg==}
|
||||||
|
dependencies:
|
||||||
|
'@types/react': 18.2.46
|
||||||
|
hoist-non-react-statics: 3.3.2
|
||||||
|
dev: false
|
||||||
|
|
||||||
/@types/json-schema@7.0.15:
|
/@types/json-schema@7.0.15:
|
||||||
resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==}
|
resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==}
|
||||||
dev: true
|
dev: true
|
||||||
|
@ -1297,6 +1326,12 @@ packages:
|
||||||
/@types/prop-types@15.7.11:
|
/@types/prop-types@15.7.11:
|
||||||
resolution: {integrity: sha512-ga8y9v9uyeiLdpKddhxYQkxNDrfvuPrlFb0N1qnZZByvcElJaXthF1UhvCh9TLWJBEHeNtdnbysW7Y6Uq8CVng==}
|
resolution: {integrity: sha512-ga8y9v9uyeiLdpKddhxYQkxNDrfvuPrlFb0N1qnZZByvcElJaXthF1UhvCh9TLWJBEHeNtdnbysW7Y6Uq8CVng==}
|
||||||
|
|
||||||
|
/@types/react-beautiful-dnd@13.1.8:
|
||||||
|
resolution: {integrity: sha512-E3TyFsro9pQuK4r8S/OL6G99eq7p8v29sX0PM7oT8Z+PJfZvSQTx4zTQbUJ+QZXioAF0e7TGBEcA1XhYhCweyQ==}
|
||||||
|
dependencies:
|
||||||
|
'@types/react': 18.2.46
|
||||||
|
dev: true
|
||||||
|
|
||||||
/@types/react-dom@18.2.18:
|
/@types/react-dom@18.2.18:
|
||||||
resolution: {integrity: sha512-TJxDm6OfAX2KJWJdMEVTwWke5Sc/E/RlnPGvGfS0W7+6ocy2xhDVQVh/KvC2Uf7kACs+gDytdusDSdWfWkaNzw==}
|
resolution: {integrity: sha512-TJxDm6OfAX2KJWJdMEVTwWke5Sc/E/RlnPGvGfS0W7+6ocy2xhDVQVh/KvC2Uf7kACs+gDytdusDSdWfWkaNzw==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -1314,6 +1349,15 @@ packages:
|
||||||
'@types/react': 18.2.46
|
'@types/react': 18.2.46
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/@types/react-redux@7.1.33:
|
||||||
|
resolution: {integrity: sha512-NF8m5AjWCkert+fosDsN3hAlHzpjSiXlVy9EgQEmLoBhaNXbmyeGs/aj5dQzKuF+/q+S7JQagorGDW8pJ28Hmg==}
|
||||||
|
dependencies:
|
||||||
|
'@types/hoist-non-react-statics': 3.3.5
|
||||||
|
'@types/react': 18.2.46
|
||||||
|
hoist-non-react-statics: 3.3.2
|
||||||
|
redux: 4.2.1
|
||||||
|
dev: false
|
||||||
|
|
||||||
/@types/react@18.2.46:
|
/@types/react@18.2.46:
|
||||||
resolution: {integrity: sha512-nNCvVBcZlvX4NU1nRRNV/mFl1nNRuTuslAJglQsq+8ldXe5Xv0Wd2f7WTE3jOxhLH2BFfiZGC6GCp+kHQbgG+w==}
|
resolution: {integrity: sha512-nNCvVBcZlvX4NU1nRRNV/mFl1nNRuTuslAJglQsq+8ldXe5Xv0Wd2f7WTE3jOxhLH2BFfiZGC6GCp+kHQbgG+w==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -1752,6 +1796,12 @@ packages:
|
||||||
shebang-command: 2.0.0
|
shebang-command: 2.0.0
|
||||||
which: 2.0.2
|
which: 2.0.2
|
||||||
|
|
||||||
|
/css-box-model@1.2.1:
|
||||||
|
resolution: {integrity: sha512-a7Vr4Q/kd/aw96bnJG332W9V9LkJO69JRcaCYDUqjp6/z0w6VcZjgAcTbgFxEPfBgdnAwlh3iwu+hLopa+flJw==}
|
||||||
|
dependencies:
|
||||||
|
tiny-invariant: 1.3.1
|
||||||
|
dev: false
|
||||||
|
|
||||||
/csstype@3.1.3:
|
/csstype@3.1.3:
|
||||||
resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==}
|
resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==}
|
||||||
|
|
||||||
|
@ -2142,6 +2192,12 @@ packages:
|
||||||
tslib: 2.6.2
|
tslib: 2.6.2
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/hoist-non-react-statics@3.3.2:
|
||||||
|
resolution: {integrity: sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==}
|
||||||
|
dependencies:
|
||||||
|
react-is: 16.13.1
|
||||||
|
dev: false
|
||||||
|
|
||||||
/ieee754@1.2.1:
|
/ieee754@1.2.1:
|
||||||
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
|
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
|
||||||
dev: false
|
dev: false
|
||||||
|
@ -2381,6 +2437,10 @@ packages:
|
||||||
remove-accents: 0.4.2
|
remove-accents: 0.4.2
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/memoize-one@5.2.1:
|
||||||
|
resolution: {integrity: sha512-zYiwtZUcYyXKo/np96AGZAckk+FWWsUdJ3cHGGmld7+AhvcWmQyGCYUh1hc4Q/pkOhb65dQR/pqCyK0cOaHz4Q==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/merge-value@1.0.0:
|
/merge-value@1.0.0:
|
||||||
resolution: {integrity: sha512-fJMmvat4NeKz63Uv9iHWcPDjCWcCkoiRoajRTEO8hlhUC6rwaHg0QCF9hBOTjZmm4JuglPckPSTtcuJL5kp0TQ==}
|
resolution: {integrity: sha512-fJMmvat4NeKz63Uv9iHWcPDjCWcCkoiRoajRTEO8hlhUC6rwaHg0QCF9hBOTjZmm4JuglPckPSTtcuJL5kp0TQ==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
|
@ -2625,6 +2685,29 @@ packages:
|
||||||
resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==}
|
resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/raf-schd@4.0.3:
|
||||||
|
resolution: {integrity: sha512-tQkJl2GRWh83ui2DiPTJz9wEiMN20syf+5oKfB03yYP7ioZcJwsIK8FjrtLwH1m7C7e+Tt2yYBlrOpdT+dyeIQ==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/react-beautiful-dnd@13.1.1(react-dom@18.2.0)(react@18.2.0):
|
||||||
|
resolution: {integrity: sha512-0Lvs4tq2VcrEjEgDXHjT98r+63drkKEgqyxdA7qD3mvKwga6a5SscbdLPO2IExotU1jW8L0Ksdl0Cj2AF67nPQ==}
|
||||||
|
peerDependencies:
|
||||||
|
react: ^16.8.5 || ^17.0.0 || ^18.0.0
|
||||||
|
react-dom: ^16.8.5 || ^17.0.0 || ^18.0.0
|
||||||
|
dependencies:
|
||||||
|
'@babel/runtime': 7.23.7
|
||||||
|
css-box-model: 1.2.1
|
||||||
|
memoize-one: 5.2.1
|
||||||
|
raf-schd: 4.0.3
|
||||||
|
react: 18.2.0
|
||||||
|
react-dom: 18.2.0(react@18.2.0)
|
||||||
|
react-redux: 7.2.9(react-dom@18.2.0)(react@18.2.0)
|
||||||
|
redux: 4.2.1
|
||||||
|
use-memo-one: 1.1.3(react@18.2.0)
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- react-native
|
||||||
|
dev: false
|
||||||
|
|
||||||
/react-colorful@5.6.1(react-dom@18.2.0)(react@18.2.0):
|
/react-colorful@5.6.1(react-dom@18.2.0)(react@18.2.0):
|
||||||
resolution: {integrity: sha512-1exovf0uGTGyq5mXQT0zgQ80uvj2PCwvF8zY1RN9/vbJVSjSo3fsB/4L3ObbF7u70NduSiK4xu4Y6q1MHoUGEw==}
|
resolution: {integrity: sha512-1exovf0uGTGyq5mXQT0zgQ80uvj2PCwvF8zY1RN9/vbJVSjSo3fsB/4L3ObbF7u70NduSiK4xu4Y6q1MHoUGEw==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
|
@ -2696,6 +2779,10 @@ packages:
|
||||||
resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==}
|
resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/react-is@17.0.2:
|
||||||
|
resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/react-merge-refs@1.1.0:
|
/react-merge-refs@1.1.0:
|
||||||
resolution: {integrity: sha512-alTKsjEL0dKH/ru1Iyn7vliS2QRcBp9zZPGoWxUOvRGWPUYgjo+V01is7p04It6KhgrzhJGnIj9GgX8W4bZoCQ==}
|
resolution: {integrity: sha512-alTKsjEL0dKH/ru1Iyn7vliS2QRcBp9zZPGoWxUOvRGWPUYgjo+V01is7p04It6KhgrzhJGnIj9GgX8W4bZoCQ==}
|
||||||
dev: false
|
dev: false
|
||||||
|
@ -2744,6 +2831,28 @@ packages:
|
||||||
scheduler: 0.21.0
|
scheduler: 0.21.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/react-redux@7.2.9(react-dom@18.2.0)(react@18.2.0):
|
||||||
|
resolution: {integrity: sha512-Gx4L3uM182jEEayZfRbI/G11ZpYdNAnBs70lFVMNdHJI76XYtR+7m0MN+eAs7UHBPhWXcnFPaS+9owSCJQHNpQ==}
|
||||||
|
peerDependencies:
|
||||||
|
react: ^16.8.3 || ^17 || ^18
|
||||||
|
react-dom: '*'
|
||||||
|
react-native: '*'
|
||||||
|
peerDependenciesMeta:
|
||||||
|
react-dom:
|
||||||
|
optional: true
|
||||||
|
react-native:
|
||||||
|
optional: true
|
||||||
|
dependencies:
|
||||||
|
'@babel/runtime': 7.23.7
|
||||||
|
'@types/react-redux': 7.1.33
|
||||||
|
hoist-non-react-statics: 3.3.2
|
||||||
|
loose-envify: 1.4.0
|
||||||
|
prop-types: 15.8.1
|
||||||
|
react: 18.2.0
|
||||||
|
react-dom: 18.2.0(react@18.2.0)
|
||||||
|
react-is: 17.0.2
|
||||||
|
dev: false
|
||||||
|
|
||||||
/react-redux@9.0.4(@types/react@18.2.46)(react@18.2.0)(redux@5.0.1):
|
/react-redux@9.0.4(@types/react@18.2.46)(react@18.2.0)(redux@5.0.1):
|
||||||
resolution: {integrity: sha512-9J1xh8sWO0vYq2sCxK2My/QO7MzUMRi3rpiILP/+tDr8krBHixC6JMM17fMK88+Oh3e4Ae6/sHIhNBgkUivwFA==}
|
resolution: {integrity: sha512-9J1xh8sWO0vYq2sCxK2My/QO7MzUMRi3rpiILP/+tDr8krBHixC6JMM17fMK88+Oh3e4Ae6/sHIhNBgkUivwFA==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
|
@ -2836,6 +2945,12 @@ packages:
|
||||||
redux: 5.0.1
|
redux: 5.0.1
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/redux@4.2.1:
|
||||||
|
resolution: {integrity: sha512-LAUYz4lc+Do8/g7aeRa8JkyDErK6ekstQaqWQrNRW//MY1TvCEpMtpTWvlQ+FPbWCx+Xixu/6SHt5N0HR+SB4w==}
|
||||||
|
dependencies:
|
||||||
|
'@babel/runtime': 7.23.7
|
||||||
|
dev: false
|
||||||
|
|
||||||
/redux@5.0.1:
|
/redux@5.0.1:
|
||||||
resolution: {integrity: sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==}
|
resolution: {integrity: sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==}
|
||||||
dev: false
|
dev: false
|
||||||
|
@ -3051,6 +3166,10 @@ packages:
|
||||||
resolution: {integrity: sha512-DLU8lc0zNIPkM7rH5/e1Ks1Z8tWCGRq6g8mPowdDJpw1CFBJMU7UoJjC6PefXW7z//SSl0b2+GCw14LB+uDhng==}
|
resolution: {integrity: sha512-DLU8lc0zNIPkM7rH5/e1Ks1Z8tWCGRq6g8mPowdDJpw1CFBJMU7UoJjC6PefXW7z//SSl0b2+GCw14LB+uDhng==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/tiny-invariant@1.3.1:
|
||||||
|
resolution: {integrity: sha512-AD5ih2NlSssTCwsMznbvwMZpJ1cbhkGd2uueNxzv2jDlEeZdU04JQfRnggJQ8DrcVBGjAsCKwFBbDlVNtEMlzw==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/to-regex-range@5.0.1:
|
/to-regex-range@5.0.1:
|
||||||
resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
|
resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
|
||||||
engines: {node: '>=8.0'}
|
engines: {node: '>=8.0'}
|
||||||
|
@ -3138,6 +3257,14 @@ packages:
|
||||||
punycode: 2.3.1
|
punycode: 2.3.1
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/use-memo-one@1.1.3(react@18.2.0):
|
||||||
|
resolution: {integrity: sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ==}
|
||||||
|
peerDependencies:
|
||||||
|
react: ^16.8.0 || ^17.0.0 || ^18.0.0
|
||||||
|
dependencies:
|
||||||
|
react: 18.2.0
|
||||||
|
dev: false
|
||||||
|
|
||||||
/use-sync-external-store@1.2.0(react@18.2.0):
|
/use-sync-external-store@1.2.0(react@18.2.0):
|
||||||
resolution: {integrity: sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==}
|
resolution: {integrity: sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
|
@ -3154,12 +3281,33 @@ packages:
|
||||||
/uuid@9.0.1:
|
/uuid@9.0.1:
|
||||||
resolution: {integrity: sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==}
|
resolution: {integrity: sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
dev: false
|
|
||||||
|
|
||||||
/v8n@1.5.1:
|
/v8n@1.5.1:
|
||||||
resolution: {integrity: sha512-LdabyT4OffkyXFCe9UT+uMkxNBs5rcTVuZClvxQr08D5TUgo1OFKkoT65qYRCsiKBl/usHjpXvP4hHMzzDRj3A==}
|
resolution: {integrity: sha512-LdabyT4OffkyXFCe9UT+uMkxNBs5rcTVuZClvxQr08D5TUgo1OFKkoT65qYRCsiKBl/usHjpXvP4hHMzzDRj3A==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/vite-plugin-top-level-await@1.4.1(vite@5.0.10):
|
||||||
|
resolution: {integrity: sha512-hogbZ6yT7+AqBaV6lK9JRNvJDn4/IJvHLu6ET06arNfo0t2IsyCaon7el9Xa8OumH+ESuq//SDf8xscZFE0rWw==}
|
||||||
|
peerDependencies:
|
||||||
|
vite: '>=2.8'
|
||||||
|
dependencies:
|
||||||
|
'@rollup/plugin-virtual': 3.0.2
|
||||||
|
'@swc/core': 1.3.101
|
||||||
|
uuid: 9.0.1
|
||||||
|
vite: 5.0.10(sass@1.69.6)
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- '@swc/helpers'
|
||||||
|
- rollup
|
||||||
|
dev: true
|
||||||
|
|
||||||
|
/vite-plugin-wasm@3.3.0(vite@5.0.10):
|
||||||
|
resolution: {integrity: sha512-tVhz6w+W9MVsOCHzxo6SSMSswCeIw4HTrXEi6qL3IRzATl83jl09JVO1djBqPSwfjgnpVHNLYcaMbaDX5WB/pg==}
|
||||||
|
peerDependencies:
|
||||||
|
vite: ^2 || ^3 || ^4 || ^5
|
||||||
|
dependencies:
|
||||||
|
vite: 5.0.10(sass@1.69.6)
|
||||||
|
dev: true
|
||||||
|
|
||||||
/vite@5.0.10(sass@1.69.6):
|
/vite@5.0.10(sass@1.69.6):
|
||||||
resolution: {integrity: sha512-2P8J7WWgmc355HUMlFrwofacvr98DAjoE52BfdbwQtyLH06XKwaL/FMnmKM2crF0iX4MpmMKoDlNCB1ok7zHCw==}
|
resolution: {integrity: sha512-2P8J7WWgmc355HUMlFrwofacvr98DAjoE52BfdbwQtyLH06XKwaL/FMnmKM2crF0iX4MpmMKoDlNCB1ok7zHCw==}
|
||||||
engines: {node: ^18.0.0 || >=20.0.0}
|
engines: {node: ^18.0.0 || >=20.0.0}
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
html,body,#root {
|
html,
|
||||||
width: 100%;
|
body,
|
||||||
height: 100%;
|
#root {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#root {
|
#root {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
#root > main {
|
#root > main {
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
flex-shrink: 1;
|
flex-shrink: 1;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
}
|
}
|
|
@ -6,9 +6,9 @@ import { useParams } from "react-router-dom";
|
||||||
import { MapControls, Text } from "@react-three/drei";
|
import { MapControls, Text } from "@react-three/drei";
|
||||||
import { ColorRepresentation, DoubleSide, TextureLoader } from "three";
|
import { ColorRepresentation, DoubleSide, TextureLoader } from "three";
|
||||||
import { Bloom, EffectComposer } from "@react-three/postprocessing";
|
import { Bloom, EffectComposer } from "@react-three/postprocessing";
|
||||||
import Windows from "./Windows";
|
|
||||||
import { useAppDispatch } from "../store";
|
import { useAppDispatch } from "../store";
|
||||||
import { addWindow } from "../store/someShit";
|
import { addWindow } from "../store/someShit";
|
||||||
|
import { DragDropContext } from "react-beautiful-dnd";
|
||||||
|
|
||||||
export default function MapView({}) {
|
export default function MapView({}) {
|
||||||
const { universeId } = useParams();
|
const { universeId } = useParams();
|
||||||
|
@ -35,46 +35,60 @@ export default function MapView({}) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className={styles.main}>
|
<main className={styles.main}>
|
||||||
<Canvas camera={{ position: [0, 20, 0] }}>
|
<DragDropContext
|
||||||
<ambientLight />
|
onDragEnd={(event) => {
|
||||||
<MapControls makeDefault />
|
console.log("evt", event);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Canvas camera={{ position: [0, 20, 0] }}>
|
||||||
|
<ambientLight />
|
||||||
|
<MapControls makeDefault />
|
||||||
|
|
||||||
<EffectComposer>
|
<EffectComposer>
|
||||||
<Bloom />
|
<Bloom />
|
||||||
</EffectComposer>
|
</EffectComposer>
|
||||||
|
|
||||||
<mesh>
|
<mesh>
|
||||||
<sphereGeometry args={[100.0, 32, 32]} />
|
<sphereGeometry args={[100.0, 32, 32]} />
|
||||||
<meshStandardMaterial map={outerSpace} side={DoubleSide} />
|
<meshStandardMaterial map={outerSpace} side={DoubleSide} />
|
||||||
</mesh>
|
</mesh>
|
||||||
|
|
||||||
{mapData.points.map((point) => {
|
{mapData.points.map((point) => {
|
||||||
return (
|
return (
|
||||||
<StarSystem key={point.index} system={point} empires={empireMap} />
|
<StarSystem
|
||||||
);
|
key={point.index}
|
||||||
})}
|
system={point}
|
||||||
|
empires={empireMap}
|
||||||
|
mapData={mapData}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
|
||||||
{mapData.edges.map((edge) => {
|
{mapData.edges.map((edge) => {
|
||||||
return (
|
return (
|
||||||
<Hyperlane
|
<Hyperlane
|
||||||
key={`${edge.fromSystemId}:${edge.toSystemId}`}
|
key={`${edge.fromSystemId}:${edge.toSystemId}`}
|
||||||
edge={edge}
|
edge={edge}
|
||||||
points={mapData.points}
|
points={mapData.points}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</Canvas>
|
</Canvas>
|
||||||
|
</DragDropContext>
|
||||||
<Windows />
|
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function StarSystem({ system, position, empires, ...props }: MeshProps) {
|
function StarSystem({
|
||||||
|
system,
|
||||||
|
position,
|
||||||
|
empires,
|
||||||
|
mapData,
|
||||||
|
...props
|
||||||
|
}: MeshProps) {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const meshRef = useRef();
|
|
||||||
const [hovered, setHover] = useState(false);
|
const [hovered, setHover] = useState(false);
|
||||||
const [active, setActive] = useState(false);
|
const active = false;
|
||||||
|
|
||||||
const x = system.coordX / 80;
|
const x = system.coordX / 80;
|
||||||
const y = system.coordY / 80;
|
const y = system.coordY / 80;
|
||||||
|
@ -88,18 +102,7 @@ function StarSystem({ system, position, empires, ...props }: MeshProps) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<mesh
|
<mesh {...props} position={[x, 0, y]} scale={active ? 1.5 : 1}>
|
||||||
{...props}
|
|
||||||
position={[x, 0, y]}
|
|
||||||
ref={meshRef}
|
|
||||||
scale={active ? 1.5 : 1}
|
|
||||||
onClick={(_event) => {
|
|
||||||
setActive(!active);
|
|
||||||
dispatch(addWindow(["planet", { type: "planet" }]));
|
|
||||||
}}
|
|
||||||
onPointerOver={(_event) => setHover(true)}
|
|
||||||
onPointerOut={(_event) => setHover(false)}
|
|
||||||
>
|
|
||||||
<sphereGeometry args={[0.05]} />
|
<sphereGeometry args={[0.05]} />
|
||||||
<meshStandardMaterial
|
<meshStandardMaterial
|
||||||
color={hovered ? "white" : color}
|
color={hovered ? "white" : color}
|
||||||
|
@ -108,13 +111,33 @@ function StarSystem({ system, position, empires, ...props }: MeshProps) {
|
||||||
/>
|
/>
|
||||||
</mesh>
|
</mesh>
|
||||||
|
|
||||||
|
<mesh
|
||||||
|
{...props}
|
||||||
|
position={[x, 0, y]}
|
||||||
|
onClick={(event) => {
|
||||||
|
dispatch(addWindow(["planet", { type: "planet" }]));
|
||||||
|
event.stopPropagation();
|
||||||
|
}}
|
||||||
|
onPointerOver={(event) => {
|
||||||
|
setHover(true);
|
||||||
|
event.stopPropagation();
|
||||||
|
}}
|
||||||
|
onPointerOut={(event) => {
|
||||||
|
setHover(false);
|
||||||
|
event.stopPropagation();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<sphereGeometry args={[0.2]} />
|
||||||
|
<meshStandardMaterial transparent opacity={0} />
|
||||||
|
</mesh>
|
||||||
|
|
||||||
{owner && (
|
{owner && (
|
||||||
<Text
|
<Text
|
||||||
color="white"
|
color="white"
|
||||||
fontSize={0.48}
|
fontSize={0.48}
|
||||||
anchorX="center"
|
anchorX="center"
|
||||||
anchorY="middle"
|
anchorY="middle"
|
||||||
position={[x, 0.2, y]}
|
position={[x, 0.6, y]}
|
||||||
>
|
>
|
||||||
{owner.name}
|
{owner.name}
|
||||||
<meshStandardMaterial color={"pink"} />
|
<meshStandardMaterial color={"pink"} />
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
.draggableHeader {
|
|
||||||
cursor: move;
|
|
||||||
}
|
|
|
@ -1,68 +0,0 @@
|
||||||
import { createPlugin, Components } from "leva/plugin";
|
|
||||||
import { useControls } from "leva";
|
|
||||||
import { useAppDispatch, useAppSelector } from "../store";
|
|
||||||
import styles from "./Windows.module.scss";
|
|
||||||
import classNames from "classnames";
|
|
||||||
import Draggable from "react-draggable";
|
|
||||||
import { closeWindow } from "../store/someShit";
|
|
||||||
import { Tab, Tabs, TabsExpander } from "@blueprintjs/core";
|
|
||||||
|
|
||||||
const { Row, Label } = Components;
|
|
||||||
|
|
||||||
export default function Windows() {
|
|
||||||
const windowsRaw = useAppSelector((state) => state.someShit.windows);
|
|
||||||
const windows = Object.fromEntries(
|
|
||||||
Object.entries(windowsRaw).map(([name, windowDef]) => {
|
|
||||||
return [name, windowDef];
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
return Object.entries(windows).map(([name, windowDef]) => {
|
|
||||||
return <Window key={name} name={name}></Window>;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function Window({ name }) {
|
|
||||||
const dispatch = useAppDispatch();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Draggable handle={`.${styles.draggableHeader}`}>
|
|
||||||
<div
|
|
||||||
className="bp5-dialog"
|
|
||||||
style={{ position: "absolute", bottom: "0", left: "0" }}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
className={classNames("bp5-dialog-header", styles.draggableHeader)}
|
|
||||||
>
|
|
||||||
<span className="bp5-icon-large bp5-icon-globe" />
|
|
||||||
<h5 className="bp5-heading">Planet</h5>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
aria-label="Close"
|
|
||||||
className="bp5-dialog-close-button bp5-button bp5-minimal bp5-icon-cross"
|
|
||||||
onClick={() => dispatch(closeWindow(name))}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="bp5-dialog-body">
|
|
||||||
<Tabs vertical id="ouaic">
|
|
||||||
<input className="bp5-input" type="text" placeholder="Search..." />
|
|
||||||
<Tab title="Summary" panel={<>Helloge</>} />
|
|
||||||
<Tab title="Jobs" panel={<>Helloge</>} />
|
|
||||||
<Tab title="Armies" panel={<>Helloge</>} />
|
|
||||||
<TabsExpander />
|
|
||||||
</Tabs>
|
|
||||||
</div>
|
|
||||||
{/* <div className="bp5-dialog-footer">
|
|
||||||
<div className="bp5-dialog-footer-actions">
|
|
||||||
<button type="button" className="bp5-button">
|
|
||||||
Secondary button
|
|
||||||
</button>
|
|
||||||
<button type="submit" className="bp5-button bp5-intent-primary">
|
|
||||||
Primary button
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div> */}
|
|
||||||
</div>
|
|
||||||
</Draggable>
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -1,9 +1,11 @@
|
||||||
import { defineConfig } from "vite";
|
import { defineConfig } from "vite";
|
||||||
import react from "@vitejs/plugin-react-swc";
|
import reactPlugin from "@vitejs/plugin-react-swc";
|
||||||
|
import wasmPlugin from "vite-plugin-wasm";
|
||||||
|
import topLevelAwait from "vite-plugin-top-level-await";
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
plugins: [reactPlugin(), wasmPlugin(), topLevelAwait()],
|
||||||
server: {
|
server: {
|
||||||
proxy: {
|
proxy: {
|
||||||
"/api": {
|
"/api": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
generator client {
|
generator client {
|
||||||
provider = "cargo prisma"
|
provider = "cargo prisma"
|
||||||
output = "../backend/src/prisma.rs"
|
output = "../common/src/prisma.rs"
|
||||||
}
|
}
|
||||||
|
|
||||||
datasource db {
|
datasource db {
|
||||||
|
|
Loading…
Reference in a new issue