fetch some nodes
3943
package-lock.json
generated
Normal file
12
package.json
|
@ -13,15 +13,15 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tauri-apps/api": "^2.0.0-alpha.11",
|
"@tauri-apps/api": "^2.0.0-alpha.11",
|
||||||
"@tauri-apps/plugin-shell": "^2.0.0-alpha.3",
|
"@tauri-apps/plugin-shell": "^2.0.0-beta.0",
|
||||||
"solid-js": "^1.7.8"
|
"solid-js": "^1.8.14"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tauri-apps/cli": "^2.0.0-alpha.17",
|
"@tauri-apps/cli": "^2.0.0-alpha.17",
|
||||||
"internal-ip": "^7.0.0",
|
"internal-ip": "^8.0.0",
|
||||||
"sass": "^1.70.0",
|
"sass": "^1.70.0",
|
||||||
"typescript": "^5.0.2",
|
"typescript": "^5.3.3",
|
||||||
"vite": "^4.4.4",
|
"vite": "^5.0.12",
|
||||||
"vite-plugin-solid": "^2.7.0"
|
"vite-plugin-solid": "^2.9.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
src-tauri/.gitignore
vendored
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Cargo
|
# Generated by Cargo
|
||||||
# will have compiled files and executables
|
# will have compiled files and executables
|
||||||
/target/
|
/target/
|
||||||
|
/gen/schemas
|
||||||
|
|
1550
src-tauri/Cargo.lock
generated
|
@ -1,32 +1,32 @@
|
||||||
[package]
|
[package]
|
||||||
name = "panorama"
|
name = "app"
|
||||||
version = "0.0.0"
|
version = "0.1.0"
|
||||||
description = "A Tauri App"
|
description = "A Tauri App"
|
||||||
authors = ["you"]
|
authors = ["you"]
|
||||||
license = ""
|
license = ""
|
||||||
repository = ""
|
repository = ""
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
rust-version = "1.70"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "panorama_lib"
|
name = "app_lib"
|
||||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
tauri-build = { version = "2.0.0-alpha", features = [] }
|
tauri-build = { version = "2.0.0-beta.1", features = [] }
|
||||||
|
|
||||||
[dependencies]
|
[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"
|
serde_json = "1.0"
|
||||||
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
tauri = { version = "2.0.0-beta.2", features = [] }
|
||||||
cozo = { version = "0.7.5", features = ["storage-rocksdb"] }
|
cozo = { version = "0.7.5", features = ["storage-rocksdb"] }
|
||||||
dirs = "5.0.1"
|
dirs = "5.0.1"
|
||||||
eyre = "0.6.12"
|
eyre = "0.6.12"
|
||||||
miette = { version = "5.10.0", features = ["backtrace", "fancy", "is-terminal", "serde"] }
|
miette = { version = "5.10.0", features = ["backtrace", "fancy", "is-terminal", "serde"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# this feature is used for production builds or when `devPath` points to the filesystem
|
# this feature is used for production builds or when `devUrl` points to the filesystem
|
||||||
# DO NOT REMOVE!!
|
# DO NOT REMOVE!!
|
||||||
custom-protocol = ["tauri/custom-protocol"]
|
custom-protocol = [ "tauri/custom-protocol" ]
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
tauri_build::build()
|
tauri_build::build()
|
||||||
}
|
}
|
||||||
|
|
16
src-tauri/capabilities/default.json
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"$schema": "../gen/schemas/desktop-schema.json",
|
||||||
|
"identifier": "default-plugins",
|
||||||
|
"description": "enables the default permissions",
|
||||||
|
"windows": ["main"],
|
||||||
|
"permissions": [
|
||||||
|
"path:default",
|
||||||
|
"event:default",
|
||||||
|
"window:default",
|
||||||
|
"webview:default",
|
||||||
|
"app:default",
|
||||||
|
"resources:default",
|
||||||
|
"menu:default",
|
||||||
|
"tray:default"
|
||||||
|
]
|
||||||
|
}
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 974 B After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 9 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 903 B After Width: | Height: | Size: 2 KiB |
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 7.4 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 37 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 49 KiB |
|
@ -1,12 +1,12 @@
|
||||||
mod schema;
|
mod schema;
|
||||||
|
|
||||||
use cozo::{DbInstance, ScriptMutability};
|
use cozo::{DbInstance, ScriptMutability};
|
||||||
use schema::ensure_schema;
|
use tauri::State;
|
||||||
|
|
||||||
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
|
use crate::schema::ensure_schema;
|
||||||
#[tauri::command]
|
|
||||||
fn greet(name: &str) -> String {
|
struct AppState {
|
||||||
format!("Hello, {}! You've been greeted from Rust!", name)
|
db: DbInstance,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||||
|
@ -19,10 +19,29 @@ pub fn run() {
|
||||||
println!("WTF? {:?}", err);
|
println!("WTF? {:?}", err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let state = AppState { db };
|
||||||
|
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.plugin(tauri_plugin_window::init())
|
.manage(state)
|
||||||
.plugin(tauri_plugin_shell::init())
|
.invoke_handler(tauri::generate_handler![fetch_nodes])
|
||||||
.invoke_handler(tauri::generate_handler![greet])
|
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
fn fetch_nodes(state: State<AppState>) -> Vec<String> {
|
||||||
|
let result = state
|
||||||
|
.db
|
||||||
|
.run_script(
|
||||||
|
"?[id, content] := *node[id, content]",
|
||||||
|
Default::default(),
|
||||||
|
ScriptMutability::Immutable,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
result
|
||||||
|
.rows
|
||||||
|
.iter()
|
||||||
|
.map(|row| format!("row: {:?}", row[0]))
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
panorama_lib::run()
|
app_lib::run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
use std::collections::BTreeMap;
|
|
||||||
|
|
||||||
use cozo::{DataValue, DbInstance, ScriptMutability};
|
use cozo::{DataValue, DbInstance, ScriptMutability};
|
||||||
use miette::Result;
|
use miette::Result;
|
||||||
|
|
||||||
pub fn ensure_schema(db: &DbInstance) -> Result<()> {
|
pub fn ensure_schema(db: &DbInstance) -> Result<()> {
|
||||||
|
// Get existing list of relations to see what we need to create
|
||||||
let existing_relations = db.run_script(
|
let existing_relations = db.run_script(
|
||||||
"::relations",
|
"::relations",
|
||||||
Default::default(),
|
Default::default(),
|
||||||
|
@ -12,22 +11,22 @@ pub fn ensure_schema(db: &DbInstance) -> Result<()> {
|
||||||
|
|
||||||
println!("Result: {:?}", existing_relations);
|
println!("Result: {:?}", existing_relations);
|
||||||
|
|
||||||
|
// Create the `node` relation
|
||||||
db.run_script(
|
db.run_script(
|
||||||
"%ignore_error {:create node {id: String, content: String}}",
|
"%ignore_error { :create node { id: String, => content: String } }",
|
||||||
Default::default(),
|
Default::default(),
|
||||||
ScriptMutability::Mutable,
|
ScriptMutability::Mutable,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let mut create_rule_params = BTreeMap::new();
|
// Create the root node
|
||||||
create_rule_params
|
|
||||||
.insert(format!("input_data"), DataValue::from(format!("root")));
|
|
||||||
db.run_script(
|
db.run_script(
|
||||||
"
|
"
|
||||||
%if { len[count(x)] := *node[x, y]; ?[x] := len[z], x = z == 0 }
|
{
|
||||||
{ ?[node, content] := $input_data; :put node {id, content} }
|
?[id, content] <- [['root', '']]
|
||||||
%end
|
:put node {id, content}
|
||||||
|
}
|
||||||
",
|
",
|
||||||
create_rule_params,
|
Default::default(),
|
||||||
ScriptMutability::Mutable,
|
ScriptMutability::Mutable,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
|
|
@ -1,43 +1,37 @@
|
||||||
{
|
{
|
||||||
"build": {
|
"$schema": "../node_modules/@tauri-apps/cli/schema.json",
|
||||||
"beforeDevCommand": "pnpm dev",
|
"app": {
|
||||||
"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": {
|
"security": {
|
||||||
"csp": null
|
"csp": null
|
||||||
},
|
},
|
||||||
"windows": [
|
"windows": [
|
||||||
{
|
{
|
||||||
"fullscreen": false,
|
"fullscreen": false,
|
||||||
|
"height": 600,
|
||||||
"resizable": true,
|
"resizable": true,
|
||||||
"title": "panorama",
|
"title": "panorama",
|
||||||
"width": 800,
|
"width": 800
|
||||||
"height": 600
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"plugins": {
|
"build": {
|
||||||
"shell": {
|
"beforeBuildCommand": "npm run build",
|
||||||
"open": true
|
"beforeDevCommand": "npm run dev",
|
||||||
}
|
"devUrl": "http://localhost:1420",
|
||||||
}
|
"frontendDist": "../dist"
|
||||||
|
},
|
||||||
|
"bundle": {
|
||||||
|
"active": true,
|
||||||
|
"icon": [
|
||||||
|
"icons/32x32.png",
|
||||||
|
"icons/128x128.png",
|
||||||
|
"icons/128x128@2x.png",
|
||||||
|
"icons/icon.icns",
|
||||||
|
"icons/icon.ico"
|
||||||
|
],
|
||||||
|
"targets": "all"
|
||||||
|
},
|
||||||
|
"identifier": "com.tauri.dev",
|
||||||
|
"productName": "panorama",
|
||||||
|
"version": "0.1.0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,15 @@
|
||||||
import NodeContainer from "./components/NodeContainer";
|
import NodeContainer from "./components/NodeContainer";
|
||||||
import Sidebar from "./components/Sidebar";
|
import Sidebar from "./components/Sidebar";
|
||||||
import styles from "./App.module.scss";
|
import styles from "./App.module.scss";
|
||||||
|
import { createEffect } from "solid-js";
|
||||||
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
|
createEffect(async () => {
|
||||||
|
const result = await invoke("fetch_nodes");
|
||||||
|
console.log("helloge", result);
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class={styles.container}>
|
<div class={styles.container}>
|
||||||
<Sidebar />
|
<Sidebar />
|
||||||
|
|