Compare commits

...

No commits in common. "e79d224bea94a2b7bb81a12f47a9b6b6969463e4" and "b7cad16044f084c68a1a2c9185bb350ab1fb80e1" have entirely different histories.

54 changed files with 7612 additions and 2719 deletions

1
.envrc
View file

@ -1 +0,0 @@
use flake

5
.gitignore vendored
View file

@ -1,3 +1,2 @@
.direnv
/target
cozo.db
node_modules
dist

1
.tokeignore Normal file
View file

@ -0,0 +1 @@
pnpm-lock.yaml

3
.vscode/extensions.json vendored Normal file
View file

@ -0,0 +1,3 @@
{
"recommendations": ["tauri-apps.tauri-vscode", "rust-lang.rust-analyzer"]
}

2474
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,4 +0,0 @@
workspace.resolver = "2"
workspace.members = [
"crates/*"
]

7
README.md Normal file
View file

@ -0,0 +1,7 @@
# Tauri + Solid + Typescript
This template should help get you started developing with Tauri, Solid and Typescript in Vite.
## Recommended IDE Setup
- [VS Code](https://code.visualstudio.com/) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer)

13
biome.json Normal file
View file

@ -0,0 +1,13 @@
{
"$schema": "https://biomejs.dev/schemas/1.4.1/schema.json",
"organizeImports": {
"enabled": true
},
"formatter": { "indentWidth": 2, "indentStyle": "space" },
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
}
}

View file

@ -1,15 +0,0 @@
[package]
name = "panorama-daemon"
version = "0.1.0"
edition = "2021"
[dependencies]
anyhow = "1.0.82"
axum = "0.7.5"
cozo = "0.7.6"
miette = "5.10"
serde = { version = "1.0.199", features = ["derive"] }
tokio = { version = "1.37.0", features = ["full"] }
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
uuid = { version = "1.8.0", features = ["v7"] }

View file

@ -1,74 +0,0 @@
#[macro_use]
extern crate tracing;
use std::collections::BTreeMap;
use axum::{
extract::State,
http::StatusCode,
routing::{get, post},
Json, Router,
};
use cozo::{DataValue, DbInstance, ScriptMutability};
use miette::{IntoDiagnostic, Result};
use serde::{Deserialize, Serialize};
use tokio::net::TcpListener;
use tracing_subscriber::util::SubscriberInitExt;
use uuid::Uuid;
#[tokio::main]
async fn main() -> Result<()> {
// initialize tracing
tracing_subscriber::fmt().init();
let db = DbInstance::new("sqlite", "cozo.db", "")?;
// Ensure schema
db.run_script_str(
":create node { node_id: String => type: String }",
"",
false,
);
let state = AppState { db };
// build our application with a route
let app = Router::new()
.route("/", get(root))
.route("/node", post(create_node))
.with_state(state);
// run our app with hyper, listening globally on port 3000
let listener = TcpListener::bind("0.0.0.0:3000").await.unwrap();
axum::serve(listener, app).await.into_diagnostic()?;
Ok(())
}
#[derive(Clone)]
struct AppState {
pub db: DbInstance,
}
// basic handler that responds with a static string
async fn root() -> &'static str {
"Hello, World!"
}
async fn create_node(State(state): State<AppState>) -> StatusCode {
let id = Uuid::now_v7();
let result = state.db.run_script(
"?[node_id, type] <- [[$node_id, $type]]
:put node {node_id => type}",
BTreeMap::from([
("node_id".to_string(), DataValue::from(id.to_string())),
("type".to_string(), DataValue::from("node")),
]),
ScriptMutability::Mutable,
);
warn!("RESULT: {:?}", result);
StatusCode::OK
}

View file

@ -1,110 +0,0 @@
{
"nodes": {
"fenix": {
"inputs": {
"nixpkgs": "nixpkgs",
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1714458308,
"narHash": "sha256-lATkVPW7KN1sACwH1DxVZxU1veZEZHC89toMBvOzCSs=",
"owner": "nix-community",
"repo": "fenix",
"rev": "d83eb9a5c92abf60a5cac9af4ddf40f8298ef75a",
"type": "github"
},
"original": {
"id": "fenix",
"type": "indirect"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"id": "flake-utils",
"type": "indirect"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1714253743,
"narHash": "sha256-mdTQw2XlariysyScCv2tTE45QSU9v/ezLcHJ22f0Nxc=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "58a1abdbae3217ca6b702f03d3b35125d88a2994",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1663551060,
"narHash": "sha256-e2SR4cVx9p7aW/XnVsGsWZBplApA9ZJUjc0fejJhnYo=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "8a5b9ee7b7a2b38267c9481f5c629c015108ab0d",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"fenix": "fenix",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_2"
}
},
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1714378571,
"narHash": "sha256-8jmZrjmOaIp3/u8yNc7CQv+HVK7HlHVde4r2YnbgeEo=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "1e61ed723f8dbc31ce20661cb2db7e6bf9d95d37",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View file

@ -1,38 +0,0 @@
{
outputs = { self, nixpkgs, flake-utils, fenix }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ fenix.overlay ];
};
toolchain = pkgs.fenix.complete;
flakePkgs = rec { };
in rec {
devShell = pkgs.mkShell {
packages = with pkgs;
with pkgs.llvmPackages_12; [
cargo-edit
cargo-watch
clangUseLLVM
mdbook
(toolchain.withComponents [
"cargo"
"clippy"
"rustc"
"rust-src"
"rustfmt"
"rust-analyzer"
])
];
inputsFrom = with flakePkgs; [ ];
CARGO_UNSTABLE_SPARSE_REGISTRY = "true";
};
packages = flake-utils.lib.flattenTree flakePkgs;
defaultPackage = packages.e0;
});
}

17
index.html Normal file
View file

@ -0,0 +1,17 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<link rel="icon" type="image/svg+xml" href="/src/assets/logo.svg" />
<title>Tauri + Solid + Typescript App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script src="/src/index.tsx" type="module"></script>
</body>
</html>

27
package.json Normal file
View file

@ -0,0 +1,27 @@
{
"name": "panorama",
"version": "0.0.0",
"description": "",
"type": "module",
"scripts": {
"start": "vite",
"dev": "vite",
"build": "vite build",
"serve": "vite preview",
"tauri": "tauri"
},
"license": "MIT",
"dependencies": {
"@tauri-apps/api": "^2.0.0-alpha.11",
"@tauri-apps/plugin-shell": "^2.0.0-alpha.3",
"solid-js": "^1.7.8"
},
"devDependencies": {
"@tauri-apps/cli": "^2.0.0-alpha.17",
"internal-ip": "^7.0.0",
"sass": "^1.70.0",
"typescript": "^5.0.2",
"vite": "^4.4.4",
"vite-plugin-solid": "^2.7.0"
}
}

1361
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load diff

6
public/tauri.svg Normal file
View file

@ -0,0 +1,6 @@
<svg width="206" height="231" viewBox="0 0 206 231" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M143.143 84C143.143 96.1503 133.293 106 121.143 106C108.992 106 99.1426 96.1503 99.1426 84C99.1426 71.8497 108.992 62 121.143 62C133.293 62 143.143 71.8497 143.143 84Z" fill="#FFC131"/>
<ellipse cx="84.1426" cy="147" rx="22" ry="22" transform="rotate(180 84.1426 147)" fill="#24C8DB"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M166.738 154.548C157.86 160.286 148.023 164.269 137.757 166.341C139.858 160.282 141 153.774 141 147C141 144.543 140.85 142.121 140.558 139.743C144.975 138.204 149.215 136.139 153.183 133.575C162.73 127.404 170.292 118.608 174.961 108.244C179.63 97.8797 181.207 86.3876 179.502 75.1487C177.798 63.9098 172.884 53.4021 165.352 44.8883C157.82 36.3744 147.99 30.2165 137.042 27.1546C126.095 24.0926 114.496 24.2568 103.64 27.6274C92.7839 30.998 83.1319 37.4317 75.8437 46.1553C74.9102 47.2727 74.0206 48.4216 73.176 49.5993C61.9292 50.8488 51.0363 54.0318 40.9629 58.9556C44.2417 48.4586 49.5653 38.6591 56.679 30.1442C67.0505 17.7298 80.7861 8.57426 96.2354 3.77762C111.685 -1.01901 128.19 -1.25267 143.769 3.10474C159.348 7.46215 173.337 16.2252 184.056 28.3411C194.775 40.457 201.767 55.4101 204.193 71.404C206.619 87.3978 204.374 103.752 197.73 118.501C191.086 133.25 180.324 145.767 166.738 154.548ZM41.9631 74.275L62.5557 76.8042C63.0459 72.813 63.9401 68.9018 65.2138 65.1274C57.0465 67.0016 49.2088 70.087 41.9631 74.275Z" fill="#FFC131"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M38.4045 76.4519C47.3493 70.6709 57.2677 66.6712 67.6171 64.6132C65.2774 70.9669 64 77.8343 64 85.0001C64 87.1434 64.1143 89.26 64.3371 91.3442C60.0093 92.8732 55.8533 94.9092 51.9599 97.4256C42.4128 103.596 34.8505 112.392 30.1816 122.756C25.5126 133.12 23.9357 144.612 25.6403 155.851C27.3449 167.09 32.2584 177.598 39.7906 186.112C47.3227 194.626 57.153 200.784 68.1003 203.846C79.0476 206.907 90.6462 206.743 101.502 203.373C112.359 200.002 122.011 193.568 129.299 184.845C130.237 183.722 131.131 182.567 131.979 181.383C143.235 180.114 154.132 176.91 164.205 171.962C160.929 182.49 155.596 192.319 148.464 200.856C138.092 213.27 124.357 222.426 108.907 227.222C93.458 232.019 76.9524 232.253 61.3736 227.895C45.7948 223.538 31.8055 214.775 21.0867 202.659C10.3679 190.543 3.37557 175.59 0.949823 159.596C-1.47592 143.602 0.768139 127.248 7.41237 112.499C14.0566 97.7497 24.8183 85.2327 38.4045 76.4519ZM163.062 156.711L163.062 156.711C162.954 156.773 162.846 156.835 162.738 156.897C162.846 156.835 162.954 156.773 163.062 156.711Z" fill="#24C8DB"/>
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

1
public/vite.svg Normal file
View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -1 +1,2 @@
tab_spaces = 2
max_width = 80

4
src-tauri/.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
# Generated by Cargo
# will have compiled files and executables
/target/

5869
src-tauri/Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

33
src-tauri/Cargo.toml Normal file
View file

@ -0,0 +1,33 @@
[package]
name = "panorama"
version = "0.0.0"
description = "A Tauri App"
authors = ["you"]
license = ""
repository = ""
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "panorama_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
tauri-build = { version = "2.0.0-alpha", features = [] }
[dependencies]
tauri = { version = "2.0.0-alpha", features = [] }
tauri-plugin-window = "2.0.0-alpha"
tauri-plugin-shell = "2.0.0-alpha"
serde_json = "1.0"
cozo = { version = "0.7.5", features = ["storage-rocksdb"] }
dirs = "5.0.1"
eyre = "0.6.12"
miette = { version = "5.10.0", features = ["backtrace", "fancy", "is-terminal", "serde"] }
autosurgeon = "0.8.3"
[features]
# this feature is used for production builds or when `devPath` points to the filesystem
# DO NOT REMOVE!!
custom-protocol = ["tauri/custom-protocol"]

3
src-tauri/build.rs Normal file
View file

@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}

BIN
src-tauri/icons/128x128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

BIN
src-tauri/icons/32x32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 974 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 903 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
src-tauri/icons/icon.icns Normal file

Binary file not shown.

BIN
src-tauri/icons/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

BIN
src-tauri/icons/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

28
src-tauri/src/lib.rs Normal file
View file

@ -0,0 +1,28 @@
mod schema;
use cozo::{DbInstance, ScriptMutability};
use schema::ensure_schema;
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
fn greet(name: &str) -> String {
format!("Hello, {}! You've been greeted from Rust!", name)
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
let dir = dirs::data_dir().unwrap().join("panorama");
let db_path = dir.join("cozo-db");
let db = DbInstance::new("rocksdb", db_path, Default::default()).unwrap();
if let Err(err) = ensure_schema(&db) {
println!("WTF? {:?}", err);
}
tauri::Builder::default()
.plugin(tauri_plugin_window::init())
.plugin(tauri_plugin_shell::init())
.invoke_handler(tauri::generate_handler![greet])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

6
src-tauri/src/main.rs Normal file
View file

@ -0,0 +1,6 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
fn main() {
panorama_lib::run()
}

35
src-tauri/src/schema.rs Normal file
View file

@ -0,0 +1,35 @@
use std::collections::BTreeMap;
use cozo::{DataValue, DbInstance, ScriptMutability};
use miette::Result;
pub fn ensure_schema(db: &DbInstance) -> Result<()> {
let existing_relations = db.run_script(
"::relations",
Default::default(),
ScriptMutability::Immutable,
)?;
println!("Result: {:?}", existing_relations);
db.run_script(
"%ignore_error {:create node {id: String, content: String}}",
Default::default(),
ScriptMutability::Mutable,
)?;
let mut create_rule_params = BTreeMap::new();
create_rule_params
.insert(format!("input_data"), DataValue::from(format!("root")));
db.run_script(
"
%if { len[count(x)] := *node[x, y]; ?[x] := len[z], x = z == 0 }
{ ?[node, content] := $input_data; :put node {id, content} }
%end
",
create_rule_params,
ScriptMutability::Mutable,
)?;
Ok(())
}

43
src-tauri/tauri.conf.json Normal file
View file

@ -0,0 +1,43 @@
{
"build": {
"beforeDevCommand": "pnpm dev",
"beforeBuildCommand": "pnpm build",
"devPath": "http://localhost:1420",
"distDir": "../dist"
},
"package": {
"productName": "panorama",
"version": "0.0.0"
},
"tauri": {
"bundle": {
"active": true,
"targets": "all",
"identifier": "com.tauri.dev",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
]
},
"security": {
"csp": null
},
"windows": [
{
"fullscreen": false,
"resizable": true,
"title": "panorama",
"width": 800,
"height": 600
}
]
},
"plugins": {
"shell": {
"open": true
}
}
}

6
src/App.module.scss Normal file
View file

@ -0,0 +1,6 @@
.container {
display: flex;
flex-direction: column;
align-items: stretch;
}

21
src/App.tsx Normal file
View file

@ -0,0 +1,21 @@
import NodeContainer from "./components/NodeContainer";
import Sidebar from "./components/Sidebar";
import styles from "./App.module.scss";
import { createSignal } from "solid-js";
function App() {
const [getFocusedNodeId, setFocusedNodeId] = createSignal<string | null>(
null,
);
const focusedNodeId = getFocusedNodeId();
return (
<div class={styles.container}>
<Sidebar />
{focusedNodeId !== null && <NodeContainer id={focusedNodeId} />}
</div>
);
}
export default App;

View file

@ -0,0 +1,7 @@
export interface NodeContainerProps {
id: string;
}
export default function NodeContainer({ id }: NodeContainerProps) {
return <>{id}</>;
}

View file

@ -0,0 +1,8 @@
.sidebar {
background-color: skyblue;
display: flex;
flex-direction: column;
flex-grow: 1;
width: 18rem;
}

View file

@ -0,0 +1,13 @@
import styles from "./Sidebar.module.scss";
export default function Sidebar() {
return (
<div class={styles.sidebar}>
<h1>Panorama</h1>
<h3>Bookmarked Nodes</h3>
<h3>Settings</h3>
</div>
);
}

1
src/declaration.d.ts vendored Normal file
View file

@ -0,0 +1 @@
declare module "*.scss";

7
src/index.tsx Normal file
View file

@ -0,0 +1,7 @@
/* @refresh reload */
import { render } from "solid-js/web";
import "./styles.scss";
import App from "./App";
render(() => <App />, document.getElementById("root") as HTMLElement);

23
src/styles.scss Normal file
View file

@ -0,0 +1,23 @@
html,
body,
#root {
margin: 0;
padding: 0;
display: flex;
width: 100%;
height: 100%;
overflow: hidden;
font-family: Arial, Helvetica, sans-serif;
}
h1,
h2,
h3,
h4,
h5,
h6 {
margin: 0;
}

26
tsconfig.json Normal file
View file

@ -0,0 +1,26 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",
"jsxImportSource": "solid-js",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}

10
tsconfig.node.json Normal file
View file

@ -0,0 +1,10 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}

1
vite-env.d.ts vendored Normal file
View file

@ -0,0 +1 @@
/// <reference types="vite/client" />

29
vite.config.ts Normal file
View file

@ -0,0 +1,29 @@
import { defineConfig } from "vite";
import solid from "vite-plugin-solid";
import { internalIpV4 } from "internal-ip";
// @ts-expect-error process is a nodejs global
const mobile = !!/android|ios/.exec(process.env.TAURI_ENV_PLATFORM);
// https://vitejs.dev/config/
export default defineConfig(async () => ({
plugins: [solid()],
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//
// 1. prevent vite from obscuring rust errors
clearScreen: false,
// 2. tauri expects a fixed port, fail if that port is not available
server: {
port: 1420,
strictPort: true,
host: mobile ? "0.0.0.0" : false,
hmr: mobile
? {
protocol: "ws",
host: await internalIpV4(),
port: 1421,
}
: undefined,
},
}));