feat: some shit
This commit is contained in:
commit
27b6514167
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
node_modules/
|
||||||
|
|
||||||
|
|
||||||
|
# Added by cargo
|
||||||
|
|
||||||
|
/target
|
5306
Cargo.lock
generated
Normal file
5306
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
12
Cargo.toml
Normal file
12
Cargo.toml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[workspace]
|
||||||
|
resolver = "2"
|
||||||
|
members = [
|
||||||
|
"packages/runtime_executor_rust",
|
||||||
|
"nodes/add",
|
||||||
|
"nodes/subtract",
|
||||||
|
"frontend/src-tauri",
|
||||||
|
"packages/node_registry_rust", "nodes/multiply",
|
||||||
|
]
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
lto = true
|
15
backend/.editorconfig
Normal file
15
backend/.editorconfig
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
charset = utf-8
|
||||||
|
|
||||||
|
[*.js]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[{package.json,*.yml,*.cjson}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
3
backend/.eslintignore
Normal file
3
backend/.eslintignore
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
dist
|
||||||
|
.output
|
||||||
|
node-modules
|
5
backend/.eslintrc
Normal file
5
backend/.eslintrc
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"extends": [
|
||||||
|
"@nuxtjs/eslint-config-typescript"
|
||||||
|
]
|
||||||
|
}
|
7
backend/.gitignore
vendored
Normal file
7
backend/.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
node_modules
|
||||||
|
*.log*
|
||||||
|
.nitro
|
||||||
|
.cache
|
||||||
|
.output
|
||||||
|
.env
|
||||||
|
dist
|
2
backend/.npmrc
Normal file
2
backend/.npmrc
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
shamefully-hoist=true
|
||||||
|
strict-peer-dependencies=false
|
42
backend/README.md
Normal file
42
backend/README.md
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
# Nitro Minimal Starter
|
||||||
|
|
||||||
|
Look at the [Nitro documentation](https://nitro.unjs.io/) to learn more.
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
Make sure to install the dependencies:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# npm
|
||||||
|
npm install
|
||||||
|
|
||||||
|
# yarn
|
||||||
|
yarn install
|
||||||
|
|
||||||
|
# pnpm
|
||||||
|
pnpm install
|
||||||
|
```
|
||||||
|
|
||||||
|
## Development Server
|
||||||
|
|
||||||
|
Start the development server on <http://localhost:3000>
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
## Production
|
||||||
|
|
||||||
|
Build the application for production:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
Locally preview production build:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run preview
|
||||||
|
```
|
||||||
|
|
||||||
|
Check out the [deployment documentation](https://nitro.unjs.io/deploy) for more information.
|
2
backend/nitro.config.ts
Normal file
2
backend/nitro.config.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
//https://nitro.unjs.io/config
|
||||||
|
export default defineNitroConfig({});
|
12
backend/package.json
Normal file
12
backend/package.json
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"prepare": "nitropack prepare",
|
||||||
|
"dev": "nitropack dev",
|
||||||
|
"build": "nitropack build",
|
||||||
|
"preview": "node .output/server/index.mjs"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"nitropack": "latest"
|
||||||
|
}
|
||||||
|
}
|
3
backend/routes/index.ts
Normal file
3
backend/routes/index.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export default eventHandler(() => {
|
||||||
|
return { nitro: 'Is Awesome!' }
|
||||||
|
})
|
3
backend/tsconfig.json
Normal file
3
backend/tsconfig.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"extends": "./.nitro/types/tsconfig.json"
|
||||||
|
}
|
1
frontend
Submodule
1
frontend
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 533bfb56272a1e734053a16ac2610b4c1e89bc16
|
10
nodes/add/.vscode/settings.json
vendored
Normal file
10
nodes/add/.vscode/settings.json
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"rust-analyzer.check.overrideCommand": [
|
||||||
|
"cargo",
|
||||||
|
"component",
|
||||||
|
"check",
|
||||||
|
"--workspace",
|
||||||
|
"--all-targets",
|
||||||
|
"--message-format=json"
|
||||||
|
],
|
||||||
|
}
|
17
nodes/add/Cargo.toml
Normal file
17
nodes/add/Cargo.toml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
[package]
|
||||||
|
name = "add"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
wit-bindgen = { version = "0.19.2", default-features = false, features = [
|
||||||
|
"realloc",
|
||||||
|
] }
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
|
[package.metadata.component]
|
||||||
|
package = "component:add"
|
||||||
|
|
||||||
|
[package.metadata.component.dependencies]
|
95
nodes/add/src/bindings.rs
Normal file
95
nodes/add/src/bindings.rs
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
// Generated by `wit-bindgen` 0.18.0. DO NOT EDIT!
|
||||||
|
const _: () = {
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[export_name = "execute"]
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
unsafe extern "C" fn __export_execute(arg0: i32,arg1: i32,) -> i32 {
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use wit_bindgen::rt::{alloc, vec::Vec, string::String};
|
||||||
|
|
||||||
|
// Before executing any other code, use this function to run all static
|
||||||
|
// constructors, if they have not yet been run. This is a hack required
|
||||||
|
// to work around wasi-libc ctors calling import functions to initialize
|
||||||
|
// the environment.
|
||||||
|
//
|
||||||
|
// This functionality will be removed once rust 1.69.0 is stable, at which
|
||||||
|
// point wasi-libc will no longer have this behavior.
|
||||||
|
//
|
||||||
|
// See
|
||||||
|
// https://github.com/bytecodealliance/preview2-prototyping/issues/99
|
||||||
|
// for more details.
|
||||||
|
#[cfg(target_arch="wasm32")]
|
||||||
|
wit_bindgen::rt::run_ctors_once();
|
||||||
|
|
||||||
|
let result0 = <_GuestImpl as Guest>::execute(arg0, arg1);
|
||||||
|
wit_bindgen::rt::as_i32(result0)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const _: () = {
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[export_name = "get-definition"]
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
unsafe extern "C" fn __export_get_definition() -> i32 {
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use wit_bindgen::rt::{alloc, vec::Vec, string::String};
|
||||||
|
|
||||||
|
// Before executing any other code, use this function to run all static
|
||||||
|
// constructors, if they have not yet been run. This is a hack required
|
||||||
|
// to work around wasi-libc ctors calling import functions to initialize
|
||||||
|
// the environment.
|
||||||
|
//
|
||||||
|
// This functionality will be removed once rust 1.69.0 is stable, at which
|
||||||
|
// point wasi-libc will no longer have this behavior.
|
||||||
|
//
|
||||||
|
// See
|
||||||
|
// https://github.com/bytecodealliance/preview2-prototyping/issues/99
|
||||||
|
// for more details.
|
||||||
|
#[cfg(target_arch="wasm32")]
|
||||||
|
wit_bindgen::rt::run_ctors_once();
|
||||||
|
|
||||||
|
let result0 = <_GuestImpl as Guest>::get_definition();
|
||||||
|
let ptr1 = _RET_AREA.0.as_mut_ptr() as i32;
|
||||||
|
let vec2 = (result0.into_bytes()).into_boxed_slice();
|
||||||
|
let ptr2 = vec2.as_ptr() as i32;
|
||||||
|
let len2 = vec2.len() as i32;
|
||||||
|
::core::mem::forget(vec2);
|
||||||
|
*((ptr1 + 4) as *mut i32) = len2;
|
||||||
|
*((ptr1 + 0) as *mut i32) = ptr2;
|
||||||
|
ptr1
|
||||||
|
}
|
||||||
|
|
||||||
|
const _: () = {
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[export_name = "cabi_post_get-definition"]
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
unsafe extern "C" fn __post_return_get_definition(arg0: i32,) {
|
||||||
|
let l0 = *((arg0 + 0) as *const i32);
|
||||||
|
let l1 = *((arg0 + 4) as *const i32);
|
||||||
|
wit_bindgen::rt::dealloc(l0, (l1) as usize, 1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
use super::Component as _GuestImpl;
|
||||||
|
pub trait Guest {
|
||||||
|
fn execute(left: i32,right: i32,) -> i32;
|
||||||
|
fn get_definition() -> wit_bindgen::rt::string::String;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use wit_bindgen::rt::{alloc, vec::Vec, string::String};
|
||||||
|
|
||||||
|
#[repr(align(4))]
|
||||||
|
struct _RetArea([u8; 8]);
|
||||||
|
static mut _RET_AREA: _RetArea = _RetArea([0; 8]);
|
||||||
|
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
#[link_section = "component-type:example"]
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 210] = [0, 97, 115, 109, 13, 0, 1, 0, 0, 25, 22, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 101, 110, 99, 111, 100, 105, 110, 103, 4, 0, 7, 86, 1, 65, 2, 1, 65, 4, 1, 64, 2, 4, 108, 101, 102, 116, 122, 5, 114, 105, 103, 104, 116, 122, 0, 122, 4, 0, 7, 101, 120, 101, 99, 117, 116, 101, 1, 0, 1, 64, 0, 0, 115, 4, 0, 14, 103, 101, 116, 45, 100, 101, 102, 105, 110, 105, 116, 105, 111, 110, 1, 1, 4, 1, 21, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 97, 100, 100, 47, 101, 120, 97, 109, 112, 108, 101, 4, 0, 11, 13, 1, 0, 7, 101, 120, 97, 109, 112, 108, 101, 3, 0, 0, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 50, 49, 46, 48, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 56, 46, 48];
|
||||||
|
|
||||||
|
#[inline(never)]
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
pub fn __link_section() {}
|
16
nodes/add/src/lib.rs
Normal file
16
nodes/add/src/lib.rs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
mod bindings;
|
||||||
|
|
||||||
|
use bindings::Guest;
|
||||||
|
|
||||||
|
struct Component;
|
||||||
|
|
||||||
|
impl Guest for Component {
|
||||||
|
/// Say hello!
|
||||||
|
fn execute(left: i32, right: i32) -> i32 {
|
||||||
|
left + right
|
||||||
|
}
|
||||||
|
fn get_definition() -> String {
|
||||||
|
let definition = include_str!("./node.json");
|
||||||
|
definition.to_string()
|
||||||
|
}
|
||||||
|
}
|
17
nodes/add/src/node.json
Normal file
17
nodes/add/src/node.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"inputs": {
|
||||||
|
"left": {
|
||||||
|
"type": "integer",
|
||||||
|
"default": 50,
|
||||||
|
"min": 0,
|
||||||
|
"max": 255
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "integer",
|
||||||
|
"default": 50,
|
||||||
|
"min": 0,
|
||||||
|
"max": 255
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": ["integer"]
|
||||||
|
}
|
7
nodes/add/wit/world.wit
Normal file
7
nodes/add/wit/world.wit
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package component:add;
|
||||||
|
|
||||||
|
/// An example world for the component to target.
|
||||||
|
world example {
|
||||||
|
export execute: func(left: s32, right: s32) -> s32;
|
||||||
|
export get-definition: func() -> string;
|
||||||
|
}
|
11
nodes/multiply/Cargo.toml
Normal file
11
nodes/multiply/Cargo.toml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[package]
|
||||||
|
name = "multiply"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
wasm-bindgen = "0.2.91"
|
||||||
|
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
crate-type = ["cdylib"]
|
10
nodes/multiply/src/lib.rs
Normal file
10
nodes/multiply/src/lib.rs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn execute(a: u32, b: u32) -> u32 {
|
||||||
|
a + b
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn get_definition() -> String {
|
||||||
|
let bytes = include_str!("./node.json");
|
||||||
|
bytes.to_string()
|
||||||
|
}
|
17
nodes/multiply/src/node.json
Normal file
17
nodes/multiply/src/node.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"inputs": {
|
||||||
|
"left": {
|
||||||
|
"type": "integer",
|
||||||
|
"default": 50,
|
||||||
|
"min": 0,
|
||||||
|
"max": 255
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "integer",
|
||||||
|
"default": 50,
|
||||||
|
"min": 0,
|
||||||
|
"max": 255
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": ["integer"]
|
||||||
|
}
|
10
nodes/subtract/.vscode/settings.json
vendored
Normal file
10
nodes/subtract/.vscode/settings.json
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"rust-analyzer.check.overrideCommand": [
|
||||||
|
"cargo",
|
||||||
|
"component",
|
||||||
|
"check",
|
||||||
|
"--workspace",
|
||||||
|
"--all-targets",
|
||||||
|
"--message-format=json"
|
||||||
|
],
|
||||||
|
}
|
17
nodes/subtract/Cargo.toml
Normal file
17
nodes/subtract/Cargo.toml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
[package]
|
||||||
|
name = "subtract"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
wit-bindgen = { version = "0.19.2", default-features = false, features = [
|
||||||
|
"realloc",
|
||||||
|
] }
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
|
[package.metadata.component]
|
||||||
|
package = "component:subtract"
|
||||||
|
|
||||||
|
[package.metadata.component.dependencies]
|
95
nodes/subtract/src/bindings.rs
Normal file
95
nodes/subtract/src/bindings.rs
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
// Generated by `wit-bindgen` 0.18.0. DO NOT EDIT!
|
||||||
|
const _: () = {
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[export_name = "execute"]
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
unsafe extern "C" fn __export_execute(arg0: i32,arg1: i32,) -> i32 {
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use wit_bindgen::rt::{alloc, vec::Vec, string::String};
|
||||||
|
|
||||||
|
// Before executing any other code, use this function to run all static
|
||||||
|
// constructors, if they have not yet been run. This is a hack required
|
||||||
|
// to work around wasi-libc ctors calling import functions to initialize
|
||||||
|
// the environment.
|
||||||
|
//
|
||||||
|
// This functionality will be removed once rust 1.69.0 is stable, at which
|
||||||
|
// point wasi-libc will no longer have this behavior.
|
||||||
|
//
|
||||||
|
// See
|
||||||
|
// https://github.com/bytecodealliance/preview2-prototyping/issues/99
|
||||||
|
// for more details.
|
||||||
|
#[cfg(target_arch="wasm32")]
|
||||||
|
wit_bindgen::rt::run_ctors_once();
|
||||||
|
|
||||||
|
let result0 = <_GuestImpl as Guest>::execute(arg0, arg1);
|
||||||
|
wit_bindgen::rt::as_i32(result0)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const _: () = {
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[export_name = "get-definition"]
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
unsafe extern "C" fn __export_get_definition() -> i32 {
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use wit_bindgen::rt::{alloc, vec::Vec, string::String};
|
||||||
|
|
||||||
|
// Before executing any other code, use this function to run all static
|
||||||
|
// constructors, if they have not yet been run. This is a hack required
|
||||||
|
// to work around wasi-libc ctors calling import functions to initialize
|
||||||
|
// the environment.
|
||||||
|
//
|
||||||
|
// This functionality will be removed once rust 1.69.0 is stable, at which
|
||||||
|
// point wasi-libc will no longer have this behavior.
|
||||||
|
//
|
||||||
|
// See
|
||||||
|
// https://github.com/bytecodealliance/preview2-prototyping/issues/99
|
||||||
|
// for more details.
|
||||||
|
#[cfg(target_arch="wasm32")]
|
||||||
|
wit_bindgen::rt::run_ctors_once();
|
||||||
|
|
||||||
|
let result0 = <_GuestImpl as Guest>::get_definition();
|
||||||
|
let ptr1 = _RET_AREA.0.as_mut_ptr() as i32;
|
||||||
|
let vec2 = (result0.into_bytes()).into_boxed_slice();
|
||||||
|
let ptr2 = vec2.as_ptr() as i32;
|
||||||
|
let len2 = vec2.len() as i32;
|
||||||
|
::core::mem::forget(vec2);
|
||||||
|
*((ptr1 + 4) as *mut i32) = len2;
|
||||||
|
*((ptr1 + 0) as *mut i32) = ptr2;
|
||||||
|
ptr1
|
||||||
|
}
|
||||||
|
|
||||||
|
const _: () = {
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[export_name = "cabi_post_get-definition"]
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
unsafe extern "C" fn __post_return_get_definition(arg0: i32,) {
|
||||||
|
let l0 = *((arg0 + 0) as *const i32);
|
||||||
|
let l1 = *((arg0 + 4) as *const i32);
|
||||||
|
wit_bindgen::rt::dealloc(l0, (l1) as usize, 1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
use super::Component as _GuestImpl;
|
||||||
|
pub trait Guest {
|
||||||
|
fn execute(left: i32,right: i32,) -> i32;
|
||||||
|
fn get_definition() -> wit_bindgen::rt::string::String;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use wit_bindgen::rt::{alloc, vec::Vec, string::String};
|
||||||
|
|
||||||
|
#[repr(align(4))]
|
||||||
|
struct _RetArea([u8; 8]);
|
||||||
|
static mut _RET_AREA: _RetArea = _RetArea([0; 8]);
|
||||||
|
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
#[link_section = "component-type:example"]
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 215] = [0, 97, 115, 109, 13, 0, 1, 0, 0, 25, 22, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 101, 110, 99, 111, 100, 105, 110, 103, 4, 0, 7, 91, 1, 65, 2, 1, 65, 4, 1, 64, 2, 4, 108, 101, 102, 116, 122, 5, 114, 105, 103, 104, 116, 122, 0, 122, 4, 0, 7, 101, 120, 101, 99, 117, 116, 101, 1, 0, 1, 64, 0, 0, 115, 4, 0, 14, 103, 101, 116, 45, 100, 101, 102, 105, 110, 105, 116, 105, 111, 110, 1, 1, 4, 1, 26, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 115, 117, 98, 116, 114, 97, 99, 116, 47, 101, 120, 97, 109, 112, 108, 101, 4, 0, 11, 13, 1, 0, 7, 101, 120, 97, 109, 112, 108, 101, 3, 0, 0, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 50, 49, 46, 48, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 56, 46, 48];
|
||||||
|
|
||||||
|
#[inline(never)]
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
pub fn __link_section() {}
|
16
nodes/subtract/src/lib.rs
Normal file
16
nodes/subtract/src/lib.rs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
mod bindings;
|
||||||
|
|
||||||
|
use bindings::Guest;
|
||||||
|
|
||||||
|
struct Component;
|
||||||
|
|
||||||
|
impl Guest for Component {
|
||||||
|
/// Say hello!
|
||||||
|
fn execute(left: i32, right: i32) -> i32 {
|
||||||
|
left - right
|
||||||
|
}
|
||||||
|
fn get_definition() -> String {
|
||||||
|
let definition = include_str!("./node.json");
|
||||||
|
definition.to_string()
|
||||||
|
}
|
||||||
|
}
|
17
nodes/subtract/src/node.json
Normal file
17
nodes/subtract/src/node.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"inputs": {
|
||||||
|
"left": {
|
||||||
|
"type": "integer",
|
||||||
|
"default": 50,
|
||||||
|
"min": 0,
|
||||||
|
"max": 255
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "integer",
|
||||||
|
"default": 50,
|
||||||
|
"min": 0,
|
||||||
|
"max": 255
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": ["integer"]
|
||||||
|
}
|
7
nodes/subtract/wit/world.wit
Normal file
7
nodes/subtract/wit/world.wit
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package component:subtract;
|
||||||
|
|
||||||
|
/// An example world for the component to target.
|
||||||
|
world example {
|
||||||
|
export execute: func(left: s32, right: s32) -> s32;
|
||||||
|
export get-definition: func() -> string;
|
||||||
|
}
|
8
packages/node_registry_rust/Cargo.toml
Normal file
8
packages/node_registry_rust/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[package]
|
||||||
|
name = "node_registry_rust"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
3
packages/node_registry_rust/src/lib.rs
Normal file
3
packages/node_registry_rust/src/lib.rs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
pub fn add(left: usize, right: usize) -> usize {
|
||||||
|
left + right
|
||||||
|
}
|
9
packages/runtime_exec/Cargo.toml
Normal file
9
packages/runtime_exec/Cargo.toml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[package]
|
||||||
|
name = "runtime_executor_rust"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
wasmtime = "18.0.1"
|
63
packages/runtime_exec/src/lib.rs
Normal file
63
packages/runtime_exec/src/lib.rs
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
use std::env;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
use wasmtime::*;
|
||||||
|
|
||||||
|
fn get_current_working_dir() -> std::io::Result<PathBuf> {
|
||||||
|
env::current_dir()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn run_nodes() -> Result<i32, String> {
|
||||||
|
// An engine stores and configures global compilation settings like
|
||||||
|
// optimization level, enabled wasm features, etc.
|
||||||
|
let engine = Engine::default();
|
||||||
|
|
||||||
|
let pwd = get_current_working_dir().expect("Cant get wkring dir");
|
||||||
|
println!(
|
||||||
|
"{}",
|
||||||
|
pwd.into_os_string().into_string().expect("cant unwrap")
|
||||||
|
);
|
||||||
|
|
||||||
|
// We start off by creating a `Module` which represents a compiled form
|
||||||
|
// of our input wasm module. In this case it'll be JIT-compiled after
|
||||||
|
// we parse the text format.
|
||||||
|
let module =
|
||||||
|
Module::from_file(&engine, "src/hello.wat").expect("Could not instatiate hello.wat");
|
||||||
|
|
||||||
|
// A `Store` is what will own instances, functions, globals, etc. All wasm
|
||||||
|
// items are stored within a `Store`, and it's what we'll always be using to
|
||||||
|
// interact with the wasm world. Custom data can be stored in stores but for
|
||||||
|
// now we just use `()`.
|
||||||
|
let mut store = Store::new(&engine, ());
|
||||||
|
|
||||||
|
// With a compiled `Module` we can then instantiate it, creating
|
||||||
|
// an `Instance` which we can actually poke at functions on.
|
||||||
|
let instance = Instance::new(&mut store, &module, &[]).expect("Could not instatiate module");
|
||||||
|
|
||||||
|
// The `Instance` gives us access to various exported functions and items,
|
||||||
|
// which we access here to pull out our `answer` exported function and
|
||||||
|
// run it.
|
||||||
|
let answer = instance
|
||||||
|
.get_func(&mut store, "answer")
|
||||||
|
.expect("`answer` was not an exported function");
|
||||||
|
|
||||||
|
// There's a few ways we can call the `answer` `Func` value. The easiest
|
||||||
|
// is to statically assert its signature with `typed` (in this case
|
||||||
|
// asserting it takes no arguments and returns one i32) and then call it.
|
||||||
|
let answer = answer
|
||||||
|
.typed::<(), i32>(&store)
|
||||||
|
.expect("Can't access answer function");
|
||||||
|
|
||||||
|
// And finally we can call our function! Note that the error propagation
|
||||||
|
// with `?` is done to handle the case where the wasm function traps.
|
||||||
|
let result = answer
|
||||||
|
.call(&mut store, ())
|
||||||
|
.expect("Could not call function");
|
||||||
|
println!("Answer: {:?}", result);
|
||||||
|
|
||||||
|
Ok(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
println!("Duude");
|
||||||
|
}
|
7
packages/runtime_executor_rust/Cargo.toml
Normal file
7
packages/runtime_executor_rust/Cargo.toml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
[package]
|
||||||
|
name = "runtime_executor_rust"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
wasmtime = "18.0.1"
|
37
packages/runtime_executor_rust/src/main.rs
Normal file
37
packages/runtime_executor_rust/src/main.rs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
use wasmtime::{Config, Engine, component::Component, component::Instance};
|
||||||
|
|
||||||
|
use std::env;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
fn get_current_working_dir() -> std::io::Result<PathBuf> {
|
||||||
|
env::current_dir()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn run_nodes() -> Result<i32, String> {
|
||||||
|
|
||||||
|
let mut config = Config::new();
|
||||||
|
config.wasm_multi_memory(true);
|
||||||
|
config.wasm_component_model(true);
|
||||||
|
|
||||||
|
// An engine stores and configures global compilation settings like
|
||||||
|
// optimization level, enabled wasm features, etc.
|
||||||
|
let engine = Engine::new(&config).expect("Could not create engine");
|
||||||
|
|
||||||
|
|
||||||
|
let component = Component::from_file(&engine, "../../target/wasm32-unknown-unknown/release/add.wasm").expect("Could not load add.wasm");
|
||||||
|
|
||||||
|
let resources = component.resources_required()
|
||||||
|
.expect("this component does not import any core modules or instances");
|
||||||
|
|
||||||
|
println!("{}", resources.num_memories);
|
||||||
|
|
||||||
|
let instance = Instance::new(&engine, component);
|
||||||
|
|
||||||
|
|
||||||
|
Ok(12)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let _ = run_nodes();
|
||||||
|
}
|
3
packages/types/index.ts
Normal file
3
packages/types/index.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
interface Node {
|
||||||
|
|
||||||
|
}
|
12
packages/types/package.json
Normal file
12
packages/types/package.json
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"name": "types",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC"
|
||||||
|
}
|
3574
pnpm-lock.yaml
Normal file
3574
pnpm-lock.yaml
Normal file
File diff suppressed because it is too large
Load Diff
4
pnpm-workspace.yaml
Normal file
4
pnpm-workspace.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
packages:
|
||||||
|
- backend
|
||||||
|
- frontend
|
||||||
|
- packages/*
|
Loading…
Reference in New Issue
Block a user