update
This commit is contained in:
parent
3a2eda20cb
commit
bfca0dfbd7
8 changed files with 262 additions and 26 deletions
201
Cargo.lock
generated
201
Cargo.lock
generated
|
@ -806,6 +806,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 = "colorchoice"
|
||||
version = "1.0.1"
|
||||
|
@ -944,6 +954,12 @@ dependencies = [
|
|||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "critical-section"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216"
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-channel"
|
||||
version = "0.5.13"
|
||||
|
@ -2843,6 +2859,45 @@ version = "0.3.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2195bf6aa996a481483b29d62a7663eed3fe39600c460e323f8ff41e90bdd89b"
|
||||
|
||||
[[package]]
|
||||
name = "musli"
|
||||
version = "0.0.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c21124dd24833900879114414b877f2136f4b7b7a3b49756ecc5c36eca332bb"
|
||||
dependencies = [
|
||||
"musli-macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "musli-common"
|
||||
version = "0.0.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "178446623aa62978aa0f894b2081bc11ea77c2119ccfe35be428ab9ddb495dfc"
|
||||
dependencies = [
|
||||
"musli",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "musli-macros"
|
||||
version = "0.0.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f1ab0e4ac2721bc4fa3528a6a2640c1c30c36c820f8c85159252fbf6c2fac24"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.66",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "musli-storage"
|
||||
version = "0.0.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b2fc1f80b166f611c462e1344220e9b3a9ad37c885e43039d5d2e6887445937c"
|
||||
dependencies = [
|
||||
"musli",
|
||||
"musli-common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ndk"
|
||||
version = "0.7.0"
|
||||
|
@ -2916,6 +2971,30 @@ dependencies = [
|
|||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23"
|
||||
dependencies = [
|
||||
"num-bigint",
|
||||
"num-complex",
|
||||
"num-integer",
|
||||
"num-iter",
|
||||
"num-rational",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-bigint"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7"
|
||||
dependencies = [
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-bigint-dig"
|
||||
version = "0.8.4"
|
||||
|
@ -2933,6 +3012,15 @@ dependencies = [
|
|||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-complex"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-conv"
|
||||
version = "0.1.0"
|
||||
|
@ -2959,6 +3047,17 @@ dependencies = [
|
|||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-rational"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"
|
||||
dependencies = [
|
||||
"num-bigint",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
|
@ -3162,6 +3261,10 @@ name = "once_cell"
|
|||
version = "1.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
|
||||
dependencies = [
|
||||
"critical-section",
|
||||
"portable-atomic",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "oneshot"
|
||||
|
@ -3284,6 +3387,7 @@ dependencies = [
|
|||
"futures",
|
||||
"itertools 0.13.0",
|
||||
"miette",
|
||||
"rune",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sqlx",
|
||||
|
@ -3628,6 +3732,12 @@ dependencies = [
|
|||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "portable-atomic"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0"
|
||||
|
||||
[[package]]
|
||||
name = "powerfmt"
|
||||
version = "0.2.0"
|
||||
|
@ -4019,6 +4129,78 @@ dependencies = [
|
|||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rune"
|
||||
version = "0.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37f1ad3981e4bf4d336b913b33cab141192f7ce196b6faf3f489ce454e94c55f"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"codespan-reporting",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"itoa 1.0.11",
|
||||
"musli",
|
||||
"musli-storage",
|
||||
"num",
|
||||
"once_cell",
|
||||
"pin-project",
|
||||
"rune-alloc",
|
||||
"rune-core",
|
||||
"rune-macros",
|
||||
"ryu",
|
||||
"serde",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rune-alloc"
|
||||
version = "0.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd786d0d250e5768210ab54b57841e5fc48e2c96a2b7e43104dabe47348ee221"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"pin-project",
|
||||
"rune-alloc-macros",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rune-alloc-macros"
|
||||
version = "0.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb6a9c787416444401172f875c1361c9b78d21fecf10206e9a996693ee2d1023"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.66",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rune-core"
|
||||
version = "0.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22249f328286279daf0f991dd04c09c30c8b7fda12fbb20391e3c041ba2dad22"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"musli",
|
||||
"rune-alloc",
|
||||
"serde",
|
||||
"twox-hash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rune-macros"
|
||||
version = "0.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32d7decd5a5f44e2e351f03f4d7dc6beab0c656baefd70528bfc375c1ab49b8d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rune-core",
|
||||
"syn 2.0.66",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-embed"
|
||||
version = "8.4.0"
|
||||
|
@ -5557,6 +5739,15 @@ dependencies = [
|
|||
"utf-8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "terminal_size"
|
||||
version = "0.1.17"
|
||||
|
@ -5917,6 +6108,16 @@ version = "0.2.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
|
||||
|
||||
[[package]]
|
||||
name = "twox-hash"
|
||||
version = "1.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.17.0"
|
||||
|
|
4
apps/journal/manifest.yml
Normal file
4
apps/journal/manifest.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
name: journal
|
||||
version: 0.1.0
|
||||
panorama_version: 0.1.0
|
||||
description: Note taking app
|
3
apps/journal/register.rn
Normal file
3
apps/journal/register.rn
Normal file
|
@ -0,0 +1,3 @@
|
|||
pub fn main() {
|
||||
let y = 1 + 2;
|
||||
}
|
|
@ -10,6 +10,7 @@ chrono = { version = "0.4.38", features = ["serde"] }
|
|||
futures = "0.3.30"
|
||||
itertools = "0.13.0"
|
||||
miette = { version = "5.5.0", features = ["fancy", "backtrace"] }
|
||||
rune = "0.13.2"
|
||||
serde = { version = "1.0.203", features = ["derive"] }
|
||||
serde_json = "1.0.117"
|
||||
sqlx = { version = "0.7.4", features = ["runtime-tokio", "tls-rustls", "macros", "sqlite", "uuid", "chrono", "regexp"] }
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
fn main() {
|
||||
println!("cargo:rerun-if-changed=../../apps");
|
||||
println!("cargo:rerun-if-changed=migrations");
|
||||
}
|
||||
|
|
|
@ -1,9 +1,16 @@
|
|||
use std::{
|
||||
fs,
|
||||
fs::{self, File},
|
||||
io::Read,
|
||||
path::{Path, PathBuf},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use miette::{IntoDiagnostic, Result};
|
||||
use rune::{
|
||||
prepare,
|
||||
termcolor::{ColorChoice, StandardStream},
|
||||
Context, Diagnostics, Hash, Module, Source, Sources, Vm,
|
||||
};
|
||||
|
||||
use crate::AppState;
|
||||
|
||||
|
@ -29,7 +36,7 @@ impl AppState {
|
|||
}
|
||||
|
||||
for path in found {
|
||||
self.install_app_from_path(path).await?;
|
||||
self.install_app_from_path(path).await;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -38,8 +45,48 @@ impl AppState {
|
|||
async fn install_app_from_path(&self, path: impl AsRef<Path>) -> Result<()> {
|
||||
let app_path = path.as_ref();
|
||||
let manifest_path = app_path.join("manifest.yml");
|
||||
let register_path = app_path.join("register.rn");
|
||||
|
||||
// Install tables
|
||||
let register_script = {
|
||||
let mut file = File::open(register_path).into_diagnostic()?;
|
||||
let mut string = String::new();
|
||||
file.read_to_string(&mut string).into_diagnostic()?;
|
||||
string
|
||||
};
|
||||
|
||||
let mut sources = Sources::new();
|
||||
sources
|
||||
.insert(Source::new("register.rn", register_script).into_diagnostic()?)
|
||||
.into_diagnostic()?;
|
||||
|
||||
let mut diagnostics = Diagnostics::new();
|
||||
let register_script_unit = prepare(&mut sources)
|
||||
.with_diagnostics(&mut diagnostics)
|
||||
.build();
|
||||
if !diagnostics.is_empty() {
|
||||
let mut writer = StandardStream::stderr(ColorChoice::Always);
|
||||
diagnostics.emit(&mut writer, &sources).into_diagnostic()?;
|
||||
}
|
||||
let register_script_unit =
|
||||
Arc::new(register_script_unit.into_diagnostic()?);
|
||||
|
||||
let module = Module::new();
|
||||
// let mut ctx = Context::new();
|
||||
let mut ctx = Context::with_default_modules().into_diagnostic()?;
|
||||
ctx.install(module).into_diagnostic()?;
|
||||
|
||||
let rt_ctx = ctx.runtime().into_diagnostic()?;
|
||||
let ctx_arc = Arc::new(rt_ctx);
|
||||
let mut vm = Vm::new(ctx_arc, register_script_unit);
|
||||
|
||||
let main = Hash::type_hash(["main"]);
|
||||
let result = vm
|
||||
.execute(main, ())
|
||||
.into_diagnostic()?
|
||||
.complete()
|
||||
.into_result()
|
||||
.into_diagnostic()?;
|
||||
println!("Executed. {result:?}");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -42,29 +42,6 @@ impl AppState {
|
|||
)
|
||||
.await?;
|
||||
|
||||
// self.db.run_script(
|
||||
// "
|
||||
// {
|
||||
// ?[id, type] <- [[$node_id, 'panorama/journal/page']]
|
||||
// :put node { id, type }
|
||||
// }
|
||||
// {
|
||||
// ?[node_id, title, content] <- [[$node_id, $title, '']]
|
||||
// :put journal { node_id => title, content }
|
||||
// }
|
||||
// {
|
||||
// ?[day, node_id] <- [[$day, $node_id]]
|
||||
// :put journal_day { day => node_id }
|
||||
// }
|
||||
// ",
|
||||
// btmap! {
|
||||
// "node_id".to_owned() => node_id.clone().into(),
|
||||
// "day".to_owned() => today.clone().into(),
|
||||
// "title".to_owned() => today.clone().into(),
|
||||
// },
|
||||
// ScriptMutability::Mutable,
|
||||
// )?;
|
||||
|
||||
return Ok(node_info.node_id);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@ pub async fn run() -> Result<()> {
|
|||
|
||||
let state = AppState::new(&panorama_dir).await?;
|
||||
|
||||
state.install_apps_from_search_paths().await?;
|
||||
|
||||
let cors_layer = CorsLayer::new()
|
||||
.allow_methods([Method::GET, Method::POST, Method::PUT])
|
||||
.allow_headers(cors::Any)
|
||||
|
|
Loading…
Reference in a new issue