wasm progress
This commit is contained in:
parent
81d28b6740
commit
1646db88d1
10 changed files with 620 additions and 377 deletions
862
Cargo.lock
generated
862
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -1,3 +0,0 @@
|
||||||
fn main() {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,5 +1,4 @@
|
||||||
// The entry file of your WebAssembly module.
|
export function install(): i32 {
|
||||||
|
console.log("Hellosu!");
|
||||||
export function add(a: i32, b: i32): i32 {
|
return 0;
|
||||||
return a + b;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"extends": "../../../node_modules/.pnpm/assemblyscript@0.27.27/node_modules/assemblyscript/std/assembly.json",
|
"extends": "assemblyscript/std/assembly.json",
|
||||||
"include": [
|
"include": [
|
||||||
"./**/*.ts"
|
"./**/*.ts"
|
||||||
]
|
]
|
||||||
|
|
54
apps/journal/package-lock.json
generated
Normal file
54
apps/journal/package-lock.json
generated
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
{
|
||||||
|
"name": "journal",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "journal",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"license": "ISC",
|
||||||
|
"devDependencies": {
|
||||||
|
"assemblyscript": "^0.27.27"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/assemblyscript": {
|
||||||
|
"version": "0.27.27",
|
||||||
|
"resolved": "https://registry.npmjs.org/assemblyscript/-/assemblyscript-0.27.27.tgz",
|
||||||
|
"integrity": "sha512-z4ijXsjjk3uespEeCWpO1K2GQySc6bn+LL5dL0tsC2VXNYKFnKDmAh3wefcKazxXHFVhYlxqNfyv96ajaQyINQ==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"binaryen": "116.0.0-nightly.20240114",
|
||||||
|
"long": "^5.2.1"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"asc": "bin/asc.js",
|
||||||
|
"asinit": "bin/asinit.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16",
|
||||||
|
"npm": ">=7"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/assemblyscript"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/binaryen": {
|
||||||
|
"version": "116.0.0-nightly.20240114",
|
||||||
|
"resolved": "https://registry.npmjs.org/binaryen/-/binaryen-116.0.0-nightly.20240114.tgz",
|
||||||
|
"integrity": "sha512-0GZrojJnuhoe+hiwji7QFaL3tBlJoA+KFUN7ouYSDGZLSo9CKM8swQX8n/UcbR0d1VuZKU+nhogNzv423JEu5A==",
|
||||||
|
"dev": true,
|
||||||
|
"bin": {
|
||||||
|
"wasm-opt": "bin/wasm-opt",
|
||||||
|
"wasm2js": "bin/wasm2js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/long": {
|
||||||
|
"version": "5.2.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/long/-/long-5.2.3.tgz",
|
||||||
|
"integrity": "sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,13 +13,24 @@ itertools = "0.13.0"
|
||||||
serde = { version = "1.0.203", features = ["derive"] }
|
serde = { version = "1.0.203", features = ["derive"] }
|
||||||
serde_json = "1.0.117"
|
serde_json = "1.0.117"
|
||||||
serde_yaml = "0.9.34"
|
serde_yaml = "0.9.34"
|
||||||
sqlx = { version = "0.7.4", features = ["runtime-tokio", "tls-rustls", "macros", "sqlite", "uuid", "chrono", "regexp"] }
|
sqlx = { version = "0.7.4", features = [
|
||||||
|
"runtime-tokio",
|
||||||
|
"tls-rustls",
|
||||||
|
"macros",
|
||||||
|
"sqlite",
|
||||||
|
"uuid",
|
||||||
|
"chrono",
|
||||||
|
"regexp",
|
||||||
|
] }
|
||||||
sugars = "3.0.1"
|
sugars = "3.0.1"
|
||||||
tantivy = { version = "0.22.0", features = ["zstd"] }
|
tantivy = { version = "0.22.0", features = ["zstd"] }
|
||||||
tokio = { version = "1.38.0", features = ["full"] }
|
tokio = { version = "1.38.0", features = ["full"] }
|
||||||
uuid = { version = "1.8.0", features = ["v7"] }
|
uuid = { version = "1.8.0", features = ["v7"] }
|
||||||
walkdir = "2.5.0"
|
walkdir = "2.5.0"
|
||||||
wasmtime = { version = "22.0.0", default-features = false, features = ["runtime"] }
|
wasmtime = { version = "22.0.0", default-features = false, features = [
|
||||||
|
"runtime",
|
||||||
|
"cranelift",
|
||||||
|
] }
|
||||||
|
|
||||||
[dependencies.async-imap]
|
[dependencies.async-imap]
|
||||||
version = "0.9.7"
|
version = "0.9.7"
|
||||||
|
|
|
@ -8,7 +8,7 @@ use std::{
|
||||||
|
|
||||||
use anyhow::{Context as _, Result};
|
use anyhow::{Context as _, Result};
|
||||||
use serde_yaml::Value;
|
use serde_yaml::Value;
|
||||||
use wasmtime::Module;
|
use wasmtime::{Config, Engine, Linker, Module, Store};
|
||||||
|
|
||||||
use crate::AppState;
|
use crate::AppState;
|
||||||
|
|
||||||
|
@ -42,9 +42,16 @@ impl AppState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let all_app_data = HashMap::new();
|
let mut all_app_data = HashMap::new();
|
||||||
for path in found {
|
for path in found {
|
||||||
let app_data = self.install_app_from_path(path).await;
|
let app_data = self.install_app_from_path(&path).await?;
|
||||||
|
println!("App data: {:?}", app_data);
|
||||||
|
all_app_data.insert(
|
||||||
|
path.display().to_string(),
|
||||||
|
AppData {
|
||||||
|
name: "hello".to_string(),
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(all_app_data)
|
Ok(all_app_data)
|
||||||
|
@ -57,7 +64,7 @@ pub struct AppManifest {
|
||||||
version: Option<String>,
|
version: Option<String>,
|
||||||
panorama_version: Option<String>,
|
panorama_version: Option<String>,
|
||||||
description: Option<String>,
|
description: Option<String>,
|
||||||
installer_path: Option<String>,
|
installer_path: PathBuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -73,23 +80,32 @@ impl AppState {
|
||||||
let file = File::open(manifest_path)?;
|
let file = File::open(manifest_path)?;
|
||||||
serde_yaml::from_reader(file)?
|
serde_yaml::from_reader(file)?
|
||||||
};
|
};
|
||||||
println!("manifest: {:?}", manifest);
|
println!("Manifest: {:?}", manifest);
|
||||||
|
|
||||||
let register_path = app_path.join("register.rn");
|
let installer_path = app_path.join(manifest.installer_path);
|
||||||
|
|
||||||
let register_script = {
|
let installer_program = {
|
||||||
let mut file = File::open(register_path)?;
|
let mut file = File::open(&installer_path).with_context(|| {
|
||||||
let mut string = String::new();
|
format!(
|
||||||
file.read_to_string(&mut string)?;
|
"Could not open installer from path: {}",
|
||||||
string
|
installer_path.display()
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
let mut buf = Vec::new();
|
||||||
|
file.read_to_end(&mut buf)?;
|
||||||
|
buf
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
println!("Installer program: {} bytes", installer_program.len());
|
||||||
use wasmtime::{Config, Engine};
|
|
||||||
|
|
||||||
let config = Config::new();
|
let config = Config::new();
|
||||||
let engine = Engine::new(&config)?;
|
let engine = Engine::new(&config)?;
|
||||||
}
|
let module = Module::new(&engine, &installer_program)?;
|
||||||
|
let linker = Linker::new(&engine);
|
||||||
|
let mut store: Store<u32> = Store::new(&engine, 4);
|
||||||
|
let instance = linker.instantiate(&mut store, &module)?;
|
||||||
|
let hello = instance.get_typed_func::<(), i32>(&mut store, "install")?;
|
||||||
|
hello.call(&mut store, ())?;
|
||||||
|
|
||||||
// let mut sources = Sources::new();
|
// let mut sources = Sources::new();
|
||||||
// sources
|
// sources
|
||||||
|
|
|
@ -79,7 +79,7 @@ pub async fn test_install_apps() -> Result<()> {
|
||||||
|
|
||||||
state.install_apps_from_search_paths().await?;
|
state.install_apps_from_search_paths().await?;
|
||||||
|
|
||||||
panic!();
|
todo!();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,10 +33,6 @@ features = ["axum_extras", "time", "uuid", "chrono", "yaml"]
|
||||||
git = "https://github.com/juhaku/utoipa"
|
git = "https://github.com/juhaku/utoipa"
|
||||||
features = ["axum"]
|
features = ["axum"]
|
||||||
|
|
||||||
[dependencies.utoipa-swagger-ui]
|
|
||||||
git = "https://github.com/juhaku/utoipa"
|
|
||||||
features = ["axum"]
|
|
||||||
|
|
||||||
[dependencies.async-imap]
|
[dependencies.async-imap]
|
||||||
version = "0.9.7"
|
version = "0.9.7"
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
Loading…
Reference in a new issue