diff --git a/Cargo.lock b/Cargo.lock index 06cc912..d999ee1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -946,6 +946,13 @@ dependencies = [ "tempfile", ] +[[package]] +name = "ng-app-web" +version = "0.1.0" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "ngcli" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index bf7b342..be24c11 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,4 +7,5 @@ members = [ "p2p-stores-lmdb", "ngcli", "ngd", + "ng-app-web", ] \ No newline at end of file diff --git a/flake.nix b/flake.nix index c6bcf53..e55926b 100644 --- a/flake.nix +++ b/flake.nix @@ -30,6 +30,11 @@ myNativeBuildInputs = with pkgs; [ pkgconfig + (rust-bin.stable.latest.default.override { + targets = [ "wasm32-unknown-unknown" ]; + }) + wasm-pack + wasm-bindgen-cli ] ++ lib.optionals stdenv.isLinux (with pkgs; [ @@ -89,6 +94,10 @@ pname = "ngd"; buildAndTestSubdir = "./ngd"; }; + ng-app-web = myBuildRustPackage rec { + pname = "ng-app-web"; + buildAndTestSubdir = "./ng-app-web"; + }; default = ngd; }; diff --git a/ng-app-web/Cargo.toml b/ng-app-web/Cargo.toml new file mode 100644 index 0000000..bb03061 --- /dev/null +++ b/ng-app-web/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "ng-app-web" +version = "0.1.0" +edition = "2021" +license = "MIT/Apache-2.0" +authors = ["Niko PLP "] +description = "Web app client of NextGraph" +repository = "https://git.nextgraph.org/NextGraph/nextgraph-rs" + +[package.metadata.wasm-pack.profile.release] +wasm-opt = false + +[lib] +crate-type = ["cdylib"] + +[dependencies] +wasm-bindgen = "0.2" diff --git a/ng-app-web/LICENSE-APACHE2 b/ng-app-web/LICENSE-APACHE2 new file mode 100644 index 0000000..9ce5b19 --- /dev/null +++ b/ng-app-web/LICENSE-APACHE2 @@ -0,0 +1,16 @@ +Apache 2.0 License + +Copyright (c) 2022-2023 Niko Bonnieure, Par le Peuple, NextGraph.org developers +All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file diff --git a/ng-app-web/LICENSE-MIT b/ng-app-web/LICENSE-MIT new file mode 100644 index 0000000..173b8f6 --- /dev/null +++ b/ng-app-web/LICENSE-MIT @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2022-2023 Niko Bonnieure, Par le Peuple, NextGraph.org developers +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/ng-app-web/README.md b/ng-app-web/README.md new file mode 100644 index 0000000..1b89a71 --- /dev/null +++ b/ng-app-web/README.md @@ -0,0 +1,42 @@ +# ng-app-web + +Web JS/WASM module of NextGraph + +## NextGraph + +> NextGraph brings about the convergence between P2P and Semantic Web technologies, towards a decentralized, secure and privacy-preserving cloud, based on CRDTs. +> +> This open source ecosystem provides solutions for end-users and software developers alike, wishing to use or create **decentralized** apps featuring: **live collaboration** on rich-text documents, peer to peer communication with end-to-end encryption, offline-first, **local-first**, portable and interoperable data, total ownership of data and software, security and privacy. Centered on repositories containing **semantic data** (RDF), **rich text**, and structured data formats like **JSON**, synced between peers belonging to permissioned groups of users, it offers strong eventual consistency, thanks to the use of **CRDTs**. Documents can be linked together, signed, shared securely, queried using the **SPARQL** language and organized into sites and containers. +> +> More info here [https://nextgraph.org](https://nextgraph.org) + +## Web JS/WASM module + +This module is part of the SDK of NextGraph. + +## Support + +Documentation can be found here [https://docs.nextgraph.org](https://docs.nextgraph.org) + +And our community forum where you can ask questions is here [https://forum.nextgraph.org](https://forum.nextgraph.org) + +## For developers + +Read our [getting started guide](https://docs.nextgraph.org/en/getting-started/). + +``` +npm i np-app-web +``` + +## License + +Licensed under either of + * Apache License, Version 2.0 ([LICENSE-APACHE2](LICENSE-APACHE2) or http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) +at your option. + +`SPDX-License-Identifier: Apache-2.0 OR MIT` + +--- + +NextGraph received funding through the [NGI Assure Fund](https://nlnet.nl/project/NextGraph/index.html), a fund established by [NLnet](https://nlnet.nl/) with financial support from the European Commission's [Next Generation Internet](https://ngi.eu/) programme, under the aegis of DG Communications Networks, Content and Technology under grant agreement No 957073. diff --git a/ng-app-web/index.html b/ng-app-web/index.html new file mode 100644 index 0000000..e76a21b --- /dev/null +++ b/ng-app-web/index.html @@ -0,0 +1,15 @@ + + + + + hello-wasm example + + + + + diff --git a/ng-app-web/src/lib.rs b/ng-app-web/src/lib.rs new file mode 100644 index 0000000..1dadb36 --- /dev/null +++ b/ng-app-web/src/lib.rs @@ -0,0 +1,11 @@ +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern { + pub fn alert(s: &str); +} + +#[wasm_bindgen] +pub fn greet(name: &str) { + alert(&format!("Hello, {}!", name)); +}