diff --git a/README.md b/README.md index ea672f1..9523e9b 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ [![project chat](https://img.shields.io/badge/zulip-join_chat-brightgreen.svg)](https://forum.nextgraph.org) ![Crates.io Version](https://img.shields.io/crates/v/nextgraph) ![docs.rs](https://img.shields.io/docsrs/nextgraph) +![NPM Version](https://img.shields.io/npm/v/ng-sdk-node) Rust implementation of NextGraph @@ -71,7 +72,7 @@ The crates are organized as follow : - [ngcli](ngcli/README.md) : CLI tool to manipulate the local documents and repos and administrate the server - [ngd](ngd/README.md) : binary executable of the daemon (that can run a broker, verifier and/or Rust services) - [ng-app](ng-app/README.md) : all the native apps, based on Tauri, and the official web app. -- [ng-sdk-js](ng-sdk-js/README.md) : contains the JS SDK, with example for: web app, react app, or node service. +- [ng-sdk-js](ng-sdk-js/DEV.md) : contains the JS SDK, with example for: web app, react app, or node service. - ng-repo : Repositories common library - ng-net : Network common library - ng-verifier : Verifier library, that exposes the document API to the app diff --git a/nextgraph/README.md b/nextgraph/README.md index 70089e4..af39f5f 100644 --- a/nextgraph/README.md +++ b/nextgraph/README.md @@ -7,10 +7,12 @@ ![MSRV][rustc-image] [![Apache 2.0 Licensed][license-image]][license-link] [![MIT Licensed][license-image2]][license-link2] +[![project chat](https://img.shields.io/badge/zulip-join_chat-brightgreen.svg)](https://forum.nextgraph.org) ![Crates.io Version](https://img.shields.io/crates/v/nextgraph) ![docs.rs](https://img.shields.io/docsrs/nextgraph) +![NPM Version](https://img.shields.io/npm/v/ng-sdk-node) -Rust client library of NextGraph framework +Rust client library for NextGraph framework This library is in active development at [https://git.nextgraph.org/NextGraph/nextgraph-rs](https://git.nextgraph.org/NextGraph/nextgraph-rs), a Gitea instance. For bug reports, issues, merge requests, and in order to join the dev team, please visit the link above and create an account (you can do so with a github account). The [github repo](https://github.com/nextgraph-org/nextgraph-rs) is just a read-only mirror that does not accept issues. diff --git a/nextgraph/src/lib.rs b/nextgraph/src/lib.rs index 1a900c5..f03accb 100644 --- a/nextgraph/src/lib.rs +++ b/nextgraph/src/lib.rs @@ -21,7 +21,9 @@ //! //! In addition, the API for creating and managing your wallet is provided here. //! -//! The same API is also made available in Javascript for the browser (and is used by our webapp), nodejs, in the CLI, and for all the Tauri-based Apps. +//! The Rust API is used internally in the CLI, and for all the Tauri-based Apps. +//! +//! The same API is also made available in Javascript for the browser (and is used by our webapp) and for nodejs. See the npm package [ng-sdk-js](https://www.npmjs.com/package/ng-sdk-js) or [ng-sdk-node](https://www.npmjs.com/package/ng-sdk-node) //! //! The library requires `async-std` minimal version 1.12.0 //! diff --git a/ng-sdk-js/DEV.md b/ng-sdk-js/DEV.md new file mode 100644 index 0000000..0fa2f9b --- /dev/null +++ b/ng-sdk-js/DEV.md @@ -0,0 +1,132 @@ +# ng-sdk-js + +JS/WASM crate containing the SDK of NextGraph + +## NextGraph + +> NextGraph brings about the convergence of 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 (a platform) and software developers (a framework), 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) + +## JS/WASM module + +This crate is composed of + +- the npm package `ng-sdk-js` which is the SDK +- an example of web app using the ESmodule and webpack as bundler `app-web` +- an example of React web app `app-react` +- an example of node-js app `app-node` +- `index.html` an example of vanilla JS usage of the SDK + +## 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 ng-sdk-js +``` + +## For contributors + +We recommend contributors to use the production build, as the creation and opening of wallets is very slow in the dev build. +Only use the dev build when debugging the sdk. see the next chapter for the production build. +Please note that the dev and prod builds share the same output folder, they thus override each other. +When building the app, be sure to have the production build of the SDK in the output folder. + +``` +wasm-pack build --dev --target bundler + +wasm-pack build --dev -t nodejs -d pkg-node +node prepare-node.js +``` + +For testing in vanilla JS + +``` +wasm-pack build --dev --target web -d web +python3 -m http.server +// open http://localhost:8000 + +``` + +Or automated testing with headless chrome: + +``` +wasm-pack test --chrome --headless +``` + +## Production build + +``` +wasm-pack build --target bundler +tar --exclude .DS_Store -zcvf pkg.tar.gz pkg +wasm-pack build -t nodejs -d pkg-node +wasm-pack build --target web -d web +node prepare-node.js +cd pkg +npm publish --access=public +cd ../pkg-node +npm publish --access=public +``` + +### Example Plain JS web app + +``` +cd ../app-web +// for local development +npm install --no-save ../pkg +// or, for install from npm registry: npm install +npm start +``` + +Open this URL in browser : [http://localhost:8080](http://localhost:8080) + +### Example React web app + +``` +cd ../app-react +// for local development +npm install --no-save ../pkg +// or, for install from npm registry: npm install +npm run dev +``` + +This URL will open automatically in browser : [http://localhost:8080](http://localhost:8080) + +### Example NodeJS app + +``` +cd ../app-node +// for local development +npm install --no-save ../pkg-node +// or, for install from npm registry: npm install +npm run start +``` + +### Contributions license + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in the work by you shall be dual licensed as below, without any +additional terms or conditions.s + +## 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-sdk-js/README.md b/ng-sdk-js/README.md index 3ada538..6cf3dec 100644 --- a/ng-sdk-js/README.md +++ b/ng-sdk-js/README.md @@ -1,6 +1,10 @@ # ng-sdk-js -JS/WASM package containing the SDK of NextGraph +[![Apache 2.0 Licensed][license-image]][license-link] +[![MIT Licensed][license-image2]][license-link2] +[![project chat](https://img.shields.io/badge/zulip-join_chat-brightgreen.svg)](https://forum.nextgraph.org) + +JavaScript/WASM package containing the SDK of NextGraph ## NextGraph @@ -10,16 +14,6 @@ JS/WASM package containing the SDK of NextGraph > > More info here [https://nextgraph.org](https://nextgraph.org) -## JS/WASM module - -This crate is composed of - -- the npm package `ng-sdk-js` which is the SDK -- an example of web app using the ESmodule and webpack as bundler `app-web` -- an example of React web app `app-react` -- an example of node-js app `app-node` -- `index.html` an example of vanilla JS usage of the SDK - ## Support Documentation can be found here [https://docs.nextgraph.org](https://docs.nextgraph.org) @@ -34,88 +28,7 @@ Read our [getting started guide](https://docs.nextgraph.org/en/getting-started/) npm i ng-sdk-js ``` -## For contributors - -We recommend contributors to use the production build, as the creation and opening of wallets is very slow in the dev build. -Only use the dev build when debugging the sdk. see the next chapter for the production build. -Please note that the dev and prod builds share the same output folder, they thus override each other. -When building the app, be sure to have the production build of the SDK in the output folder. - -``` -wasm-pack build --dev --target bundler - -wasm-pack build --dev -t nodejs -d pkg-node -node prepare-node.js -``` - -For testing in vanilla JS - -``` -wasm-pack build --dev --target web -d web -python3 -m http.server -// open http://localhost:8000 - -``` - -Or automated testing with headless chrome: - -``` -wasm-pack test --chrome --headless -``` - -## Production build - -``` -wasm-pack build --target bundler -tar --exclude .DS_Store -zcvf pkg.tar.gz pkg -wasm-pack build -t nodejs -d pkg-node -wasm-pack build --target web -d web -node prepare-node.js -cd pkg -npm publish --access=public -cd ../pkg-node -npm publish --access=public -``` - -### Example Plain JS web app - -``` -cd ../app-web -// for local development -npm install --no-save ../pkg -// or, for install from npm registry: npm install -npm start -``` - -Open this URL in browser : [http://localhost:8080](http://localhost:8080) - -### Example React web app - -``` -cd ../app-react -// for local development -npm install --no-save ../pkg -// or, for install from npm registry: npm install -npm run dev -``` - -This URL will open automatically in browser : [http://localhost:8080](http://localhost:8080) - -### Example NodeJS app - -``` -cd ../app-node -// for local development -npm install --no-save ../pkg-node -// or, for install from npm registry: npm install -npm run start -``` - -### Contributions license - -Unless you explicitly state otherwise, any contribution intentionally submitted -for inclusion in the work by you shall be dual licensed as below, without any -additional terms or conditions.s +## How to use it ## License @@ -130,3 +43,8 @@ Licensed under either of --- 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. + +[license-image]: https://img.shields.io/badge/license-Apache2.0-blue.svg +[license-link]: https://git.nextgraph.org/NextGraph/nextgraph-rs/raw/branch/master/LICENSE-APACHE2 +[license-image2]: https://img.shields.io/badge/license-MIT-blue.svg +[license-link2]: https://git.nextgraph.org/NextGraph/nextgraph-rs/src/branch/master/LICENSE-MIT diff --git a/ng-sdk-js/prepare-node.js b/ng-sdk-js/prepare-node.js index 51bb701..0d1fede 100644 --- a/ng-sdk-js/prepare-node.js +++ b/ng-sdk-js/prepare-node.js @@ -1,9 +1,21 @@ const fs = require('fs'); const PATH = './pkg-node/package.json'; +const PATH_README = './pkg-node/README.md'; const pkg_json = fs.readFileSync(PATH); let pkg = JSON.parse(pkg_json) pkg.name = "ng-sdk-node"; -pkg.description = "nodejs app sdk of NextGraph"; -fs.writeFileSync(PATH, JSON.stringify(pkg, null, 2), 'utf8'); \ No newline at end of file +pkg.description = "nodejs SDK of NextGraph"; +fs.writeFileSync(PATH, JSON.stringify(pkg, null, 2), 'utf8'); + +fs.readFile(PATH_README, 'utf8', function (err,data) { + if (err) { + return console.log(err); + } + var result = data.replace(/ng-sdk-js/g, 'ng-sdk-node'); + + fs.writeFile(PATH_README, result, 'utf8', function (err) { + if (err) return console.log(err); + }); + }); \ No newline at end of file