This commit is contained in:
Michael Zhang 2024-02-07 23:09:11 -06:00
parent 6db9469d8e
commit 1b4e74485b
8 changed files with 254 additions and 52 deletions

2
rustfmt.toml Normal file
View file

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

226
src-tauri/Cargo.lock generated
View file

@ -82,9 +82,9 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.75"
version = "1.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca"
[[package]]
name = "approx"
@ -235,7 +235,7 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.39",
"syn 2.0.48",
]
[[package]]
@ -270,7 +270,7 @@ checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.39",
"syn 2.0.48",
]
[[package]]
@ -646,6 +646,16 @@ dependencies = [
"objc",
]
[[package]]
name = "codespan-reporting"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e"
dependencies = [
"termcolor",
"unicode-width",
]
[[package]]
name = "color_quant"
version = "1.1.0"
@ -743,6 +753,7 @@ dependencies = [
"casey",
"chrono",
"chrono-tz",
"cozorocks",
"crossbeam",
"csv",
"document-features",
@ -787,6 +798,21 @@ dependencies = [
"uuid",
]
[[package]]
name = "cozorocks"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c948d757956819219eb6ddab355a2dcc96b1f3896b38d6dbb202f79d2405a8d"
dependencies = [
"cc",
"cxx",
"cxx-build",
"libc",
"lz4-sys",
"miette",
"zstd-sys",
]
[[package]]
name = "cpufeatures"
version = "0.2.11"
@ -906,7 +932,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331"
dependencies = [
"quote",
"syn 2.0.39",
"syn 2.0.48",
]
[[package]]
@ -937,7 +963,51 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37e366bff8cd32dd8754b0991fb66b279dc48f598c3a18914852a6673deef583"
dependencies = [
"quote",
"syn 2.0.39",
"syn 2.0.48",
]
[[package]]
name = "cxx"
version = "1.0.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba1ba0a82363c553ecb7b4cd58ba6e1c017baef8e3cca4e7d66ca17879201144"
dependencies = [
"cc",
"cxxbridge-flags",
"cxxbridge-macro",
"link-cplusplus",
]
[[package]]
name = "cxx-build"
version = "1.0.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac9ec8372f860c6ee7c6463b96a26d08dd590bcbcd9bf2d1894db09ae81410d3"
dependencies = [
"cc",
"codespan-reporting",
"once_cell",
"proc-macro2",
"quote",
"scratch",
"syn 2.0.48",
]
[[package]]
name = "cxxbridge-flags"
version = "1.0.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "409667bbb937bae87f7cfa91ca29e1415bb92d415371e3344b5269c10d90d595"
[[package]]
name = "cxxbridge-macro"
version = "1.0.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fb2a9757fb085d6d97856b28d4f049141ca4a61a64c697f4426433b5f6caa1f"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.48",
]
[[package]]
@ -961,7 +1031,7 @@ dependencies = [
"proc-macro2",
"quote",
"strsim",
"syn 2.0.39",
"syn 2.0.48",
]
[[package]]
@ -972,7 +1042,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5"
dependencies = [
"darling_core",
"quote",
"syn 2.0.39",
"syn 2.0.48",
]
[[package]]
@ -1043,6 +1113,15 @@ dependencies = [
"crypto-common",
]
[[package]]
name = "dirs"
version = "5.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225"
dependencies = [
"dirs-sys",
]
[[package]]
name = "dirs-next"
version = "2.0.0"
@ -1053,6 +1132,18 @@ dependencies = [
"dirs-sys-next",
]
[[package]]
name = "dirs-sys"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c"
dependencies = [
"libc",
"option-ext",
"redox_users",
"windows-sys 0.48.0",
]
[[package]]
name = "dirs-sys-next"
version = "0.1.2"
@ -1152,7 +1243,7 @@ checksum = "f95e2801cd355d4a1a3e3953ce6ee5ae9603a5c833455343a8bfe3f44d418246"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.39",
"syn 2.0.48",
]
[[package]]
@ -1211,6 +1302,16 @@ dependencies = [
"pin-project-lite",
]
[[package]]
name = "eyre"
version = "0.6.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec"
dependencies = [
"indenter",
"once_cell",
]
[[package]]
name = "fast-float"
version = "0.2.0"
@ -1305,7 +1406,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.39",
"syn 2.0.48",
]
[[package]]
@ -1404,7 +1505,7 @@ checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.39",
"syn 2.0.48",
]
[[package]]
@ -1647,7 +1748,7 @@ dependencies = [
"proc-macro-error",
"proc-macro2",
"quote",
"syn 2.0.39",
"syn 2.0.48",
]
[[package]]
@ -1766,7 +1867,7 @@ dependencies = [
"proc-macro-error",
"proc-macro2",
"quote",
"syn 2.0.39",
"syn 2.0.48",
]
[[package]]
@ -1961,6 +2062,12 @@ dependencies = [
"num-traits",
]
[[package]]
name = "indenter"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
[[package]]
name = "indexmap"
version = "1.9.3"
@ -2255,6 +2362,15 @@ dependencies = [
"memchr",
]
[[package]]
name = "link-cplusplus"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d240c6f7e1ba3a28b0249f774e6a9dd0175054b52dfbb61b16eb8505c3785c9"
dependencies = [
"cc",
]
[[package]]
name = "linux-raw-sys"
version = "0.3.8"
@ -2304,6 +2420,16 @@ dependencies = [
"tracing-subscriber",
]
[[package]]
name = "lz4-sys"
version = "1.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57d27b317e207b10f69f5e75494119e391a96f48861ae870d1da6edac98ca900"
dependencies = [
"cc",
"libc",
]
[[package]]
name = "lz4_flex"
version = "0.10.0"
@ -2412,6 +2538,7 @@ dependencies = [
"miette-derive",
"once_cell",
"owo-colors",
"serde",
"supports-color",
"supports-hyperlinks",
"supports-unicode",
@ -2429,7 +2556,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.39",
"syn 2.0.48",
]
[[package]]
@ -2743,6 +2870,12 @@ dependencies = [
"pathdiff",
]
[[package]]
name = "option-ext"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
[[package]]
name = "ordered-float"
version = "3.9.2"
@ -2824,6 +2957,9 @@ name = "panorama"
version = "0.0.0"
dependencies = [
"cozo",
"dirs",
"eyre",
"miette",
"serde_json",
"tauri",
"tauri-build",
@ -2918,7 +3054,7 @@ dependencies = [
"pest_meta",
"proc-macro2",
"quote",
"syn 2.0.39",
"syn 2.0.48",
]
[[package]]
@ -3046,7 +3182,7 @@ dependencies = [
"phf_shared 0.11.2",
"proc-macro2",
"quote",
"syn 2.0.39",
"syn 2.0.48",
]
[[package]]
@ -3241,9 +3377,9 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068"
[[package]]
name = "proc-macro2"
version = "1.0.69"
version = "1.0.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da"
checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae"
dependencies = [
"unicode-ident",
]
@ -3265,9 +3401,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.33"
version = "1.0.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
dependencies = [
"proc-macro2",
]
@ -3651,6 +3787,12 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "scratch"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152"
[[package]]
name = "sct"
version = "0.7.1"
@ -3713,7 +3855,7 @@ checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.39",
"syn 2.0.48",
]
[[package]]
@ -3735,7 +3877,7 @@ checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.39",
"syn 2.0.48",
]
[[package]]
@ -3785,7 +3927,7 @@ dependencies = [
"darling",
"proc-macro2",
"quote",
"syn 2.0.39",
"syn 2.0.48",
]
[[package]]
@ -4118,9 +4260,9 @@ dependencies = [
[[package]]
name = "syn"
version = "2.0.39"
version = "2.0.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a"
checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f"
dependencies = [
"proc-macro2",
"quote",
@ -4505,22 +4647,22 @@ checksum = "8eaa81235c7058867fa8c0e7314f33dcce9c215f535d1913822a2b3f5e289f3c"
[[package]]
name = "thiserror"
version = "1.0.50"
version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2"
checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.50"
version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8"
checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.39",
"syn 2.0.48",
]
[[package]]
@ -4702,7 +4844,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.39",
"syn 2.0.48",
]
[[package]]
@ -4981,7 +5123,7 @@ dependencies = [
"once_cell",
"proc-macro2",
"quote",
"syn 2.0.39",
"syn 2.0.48",
"wasm-bindgen-shared",
]
@ -5015,7 +5157,7 @@ checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.39",
"syn 2.0.48",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@ -5121,7 +5263,7 @@ checksum = "ac1345798ecd8122468840bcdf1b95e5dc6d2206c5e4b0eafa078d061f59c9bc"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.39",
"syn 2.0.48",
]
[[package]]
@ -5216,7 +5358,7 @@ checksum = "fb2b158efec5af20d8846836622f50a87e6556b9153a42772fa047f773c0e555"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.39",
"syn 2.0.48",
]
[[package]]
@ -5227,7 +5369,7 @@ checksum = "0546e63e1ce64c04403d2311fa0e3ab5ae3a367bd524b4a38d8d8d18c70cfa76"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.39",
"syn 2.0.48",
]
[[package]]
@ -5541,7 +5683,17 @@ checksum = "c2f140bda219a26ccc0cdb03dba58af72590c53b22642577d88a927bc5c87d6b"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.39",
"syn 2.0.48",
]
[[package]]
name = "zstd-sys"
version = "2.0.9+zstd.1.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e16efa8a874a0481a574084d34cc26fdb3b99627480f785888deb6386506656"
dependencies = [
"cc",
"pkg-config",
]
[[package]]

View file

@ -21,7 +21,10 @@ 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 = "0.7.5"
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"] }
[features]
# this feature is used for production builds or when `devPath` points to the filesystem

View file

@ -1,4 +1,7 @@
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]
@ -8,12 +11,13 @@ fn greet(name: &str) -> String {
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
let db = DbInstance::new("mem", "", Default::default()).unwrap();
let script = "?[a] := a in [1, 2, 3]";
let result = db
.run_script(script, Default::default(), ScriptMutability::Immutable)
.unwrap();
println!("{:?}", result);
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())

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(())
}

View file

@ -1,6 +1,7 @@
.sidebar {
background-color: #ccffcc;
background-color: skyblue;
display: flex;
flex-direction: column;
flex-grow: 1;
width: 18rem;

View file

@ -4,6 +4,10 @@ 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";