raname sdk to ng-sdk-js

Niko 11 months ago
parent 3479428c70
commit 287d12a589
  1. 2
      Cargo.lock
  2. 2
      Cargo.toml
  3. 2
      README.md
  4. 8
      ng-app-js/app-web/test.js
  5. 5
      ng-app/README.md
  6. 2
      ng-app/package.json
  7. 2
      ng-app/src/App.svelte
  8. 2
      ng-app/src/lib/Greet.svelte
  9. 2
      ng-sdk-js/Cargo.toml
  10. 0
      ng-sdk-js/LICENSE-APACHE2
  11. 0
      ng-sdk-js/LICENSE-MIT
  12. 42
      ng-sdk-js/README.md
  13. 0
      ng-sdk-js/app-node/.gitignore
  14. 3
      ng-sdk-js/app-node/index.js
  15. 0
      ng-sdk-js/app-node/package-lock.json
  16. 2
      ng-sdk-js/app-node/package.json
  17. 2
      ng-sdk-js/app-node/test.js
  18. 0
      ng-sdk-js/app-react/.babelrc
  19. 0
      ng-sdk-js/app-react/.gitignore
  20. 0
      ng-sdk-js/app-react/README.md
  21. 0
      ng-sdk-js/app-react/package-lock.json
  22. 2
      ng-sdk-js/app-react/package.json
  23. 0
      ng-sdk-js/app-react/public/index.html
  24. 2
      ng-sdk-js/app-react/src/index.jsx
  25. 2
      ng-sdk-js/app-react/src/test.js
  26. 0
      ng-sdk-js/app-react/webpack.config.js
  27. 0
      ng-sdk-js/app-web/.gitignore
  28. 0
      ng-sdk-js/app-web/LICENSE-APACHE
  29. 0
      ng-sdk-js/app-web/LICENSE-MIT
  30. 0
      ng-sdk-js/app-web/README.md
  31. 0
      ng-sdk-js/app-web/bootstrap.js
  32. 0
      ng-sdk-js/app-web/index.html
  33. 2
      ng-sdk-js/app-web/index.js
  34. 0
      ng-sdk-js/app-web/package-lock.json
  35. 2
      ng-sdk-js/app-web/package.json
  36. 8
      ng-sdk-js/app-web/test.js
  37. 0
      ng-sdk-js/app-web/webpack.config.js
  38. 8
      ng-sdk-js/index.html
  39. 0
      ng-sdk-js/js/browser.js
  40. 0
      ng-sdk-js/js/node.js
  41. 2
      ng-sdk-js/prepare-node.js
  42. 0
      ng-sdk-js/src/lib.rs
  43. 13
      package.json
  44. 4
      pnpm-lock.yaml
  45. 3
      pnpm-workspace.yaml

2
Cargo.lock generated

@ -2487,7 +2487,7 @@ dependencies = [
]
[[package]]
name = "ng-app-js-sdk"
name = "ng-sdk-js"
version = "0.1.0"
dependencies = [
"async-std",

@ -9,7 +9,7 @@ members = [
"ngcli",
"ngd",
"ngone",
"ng-app-js",
"ng-sdk-js",
"ng-app/src-tauri",
"ng-wallet"
]

@ -55,7 +55,7 @@ The crates are organized as follow :
- ngcli : CLI tool to manipulate the repos
- ngd : binary executable of the daemon (that can run a broker, verifier and/or Rust services)
- ngone : server for nextgraph.one (boostrap into the right app)
- ng-app-js : contains the JS SDK, the web app, react app, and some node services
- ng-sdk-js : contains the JS SDK, with example apps: web app, react app, or node service.
- ng-app : all the native apps, based on Tauri, and the web app.
- ng-wallet : keeps the secret keys of all identities of the user in a safe wallet

@ -1,8 +0,0 @@
import * as ng from "ng-app-js-sdk";
function test() {
ng.test()
}
export default test;

@ -30,10 +30,11 @@ pnpm webdev
```
pnpm webbuild
// then the application is available in dist-web folder
// can be served with cd dist-web ; python3 -m http.server
// can be served with:
cd dist-web ; python3 -m http.server
```
in order a build a self-contained html file, useful for offline use, do:
in order to build a self-contained html file, useful for offline use, do:
```
pnpm filebuild

@ -19,7 +19,7 @@
"classnames": "^2.3.2",
"flowbite": "^1.6.5",
"flowbite-svelte": "^0.37.1",
"ng-app-js-sdk": "workspace:^0.1.0",
"ng-sdk-js": "workspace:^0.1.0",
"svelte-spa-router": "^3.3.0",
"vite-plugin-top-level-await": "^1.3.1"
},

@ -10,7 +10,7 @@
-->
<script lang="ts">
import * as ng2 from "../../ng-app-js/pkg/ng_app_js_sdk";
import * as ng2 from "ng-sdk-js";
import Router from "svelte-spa-router";
import Home from "./routes/Home.svelte";

@ -15,7 +15,7 @@
let ng;
if (import.meta.env.NG_APP_WEB) {
import("../../../ng-app-js/pkg/ng_app_js_sdk").then((ng2) => {
import("ng-sdk-js").then((ng2) => {
ng = {
greet: async function (n) {
ng2.test();

@ -1,5 +1,5 @@
[package]
name = "ng-app-js-sdk"
name = "ng-sdk-js"
version = "0.1.0"
edition = "2021"
license = "MIT/Apache-2.0"

@ -1,24 +1,24 @@
# ng-app-js
# ng-sdk-js
JS/WASM module of NextGraph (SDK and apps)
JS/WASM crate containing the SDK 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)
## JS/WASM module
This module is part of the SDK of NextGraph.
This crate is composed of
It is composed of
- the npm package `ng-app-js` which is the SDK
- the plain JS web app `app-web`
- the React web app `app-react`
- the node-js app `app-node`
- the npm package `ng-app-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
@ -31,7 +31,7 @@ And our community forum where you can ask questions is here [https://forum.nextg
Read our [getting started guide](https://docs.nextgraph.org/en/getting-started/).
```
npm i ng-app-js-sdk
npm i ng-sdk-js
```
## For contributors
@ -39,25 +39,28 @@ npm i ng-app-js-sdk
```
wasm-pack build --target bundler
cd pkg
// if you have access to npm registry and want to publish the package
// if you have access to npm registry and want to publish the package
// npm publish --access=public
cd ..
wasm-pack build -t nodejs -d pkg-node
node prepare-node.js
cd pkg-node
// if you have access to npm registry and want to publish the package
// if you have access to npm registry and want to publish the package
// npm publish --access=public
```
For testing in vanilla JS
For testing in vanilla JS
```
wasm-pack build --target web -d web
python3 -m http.server
// open http://localhost:8000
```
```
Or automated testing with headless chrome:
```
wasm-pack test --chrome --headless
```
@ -67,7 +70,7 @@ wasm-pack test --chrome --headless
```
cd ../app-web
// for local development
npm install --no-save ../pkg
npm install --no-save ../pkg
// or, for install from npm registry: npm install
npm start
```
@ -84,7 +87,7 @@ npm install --no-save ../pkg
npm run dev
```
Open this URL in browser : [http://localhost:8080](http://localhost:8080)
This URL will open automatically in browser : [http://localhost:8080](http://localhost:8080)
### NodeJS app
@ -105,9 +108,10 @@ 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.
- 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`

@ -7,7 +7,8 @@
// notice may not be copied, modified, or distributed except
// according to those terms.
const WebSocket = require("ws");
const ng = require("ng-app-node-sdk");
// shim to insert WebSocket in global
const ng = require("ng-sdk-node");
global.WebSocket = WebSocket;
const test = require("./test")

@ -13,7 +13,7 @@
"author": "Niko PLP <niko@nextgraph.org>",
"license": "(MIT OR Apache-2.0)",
"dependencies": {
"ng-app-node-sdk": "^0.1.0",
"ng-sdk-node": "^0.1.0",
"ws": "^8.13.0"
}
}

@ -1,4 +1,4 @@
const ng = require("ng-app-node-sdk");
const ng = require("ng-sdk-node");
module.exports.random = function () {
console.log("FROM TEST");

@ -16,7 +16,7 @@
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"ng-app-js-sdk": "^0.1.0"
"ng-sdk-js": "^0.1.0"
},
"devDependencies": {
"@babel/preset-env": "^7.20.2",

@ -12,7 +12,7 @@ import ReactDOM from "react-dom";
import { createRoot } from 'react-dom/client';
import Test from "./test";
const ng_sdk = import("ng-app-js-sdk");
const ng_sdk = import("ng-sdk-js");
ng_sdk.then((ng) => {
const App = () => {

@ -5,7 +5,7 @@ function Test() {
useEffect(() => {
;(async () => {
try {
const ng = await import('ng-app-js-sdk');
const ng = await import('ng-sdk-js');
ng.test();
} catch (e) {
console.error(e)

@ -7,7 +7,7 @@
// notice may not be copied, modified, or distributed except
// according to those terms.
import * as ng from "ng-app-js-sdk";
import * as ng from "ng-sdk-js";
import test from './test';
ng.test();

@ -24,7 +24,7 @@
},
"homepage": "https://docs.nextgraph.org",
"dependencies": {
"ng-app-js-sdk": "^0.1.0"
"ng-sdk-js": "^0.1.0"
},
"devDependencies": {
"webpack": "^4.29.3",

@ -0,0 +1,8 @@
import * as ng from "ng-sdk-js";
function test() {
ng.test()
}
export default test;

@ -18,7 +18,7 @@
<body>
<p>run <code>python3 -m http.server</code> to use it</p>
<script type="module">
import init, { start, test } from "./web/ng_app_js_sdk.js";
import init, { start, test } from "./web/ng_sdk_js.js";
init().then(() => {
//greet("WebAssembly");
test();
@ -27,9 +27,9 @@
});
// DON'T DO THE FOLLOW:
// it will instantiate twice the SDK, which is not what we want
init().then(() => {
test();
});
// init().then(() => {
// test();
// });
</script>
</body>
</html>

@ -4,6 +4,6 @@ const PATH = './pkg-node/package.json';
const pkg_json = fs.readFileSync(PATH);
let pkg = JSON.parse(pkg_json)
pkg.name = "ng-app-node-sdk";
pkg.name = "ng-sdk-node";
pkg.description = "nodejs app sdk of NextGraph";
fs.writeFileSync(PATH, JSON.stringify(pkg, null, 2), 'utf8');

@ -0,0 +1,13 @@
{
"name": "nextgraph-rs",
"private": true,
"version": "0.1.0",
"pnpm": {
"peerDependencyRules": {
"ignoreMissing": [
"rollup"
]
}
}
}

@ -16,7 +16,7 @@ importers:
flowbite: ^1.6.5
flowbite-svelte: ^0.37.1
internal-ip: ^7.0.0
ng-app-js-sdk: workspace:^0.1.0
ng-sdk-js: workspace:^0.1.0
postcss: ^8.4.23
postcss-load-config: ^4.0.1
svelte: ^3.54.0
@ -37,7 +37,7 @@ importers:
classnames: 2.3.2
flowbite: 1.6.5
flowbite-svelte: 0.37.3_svelte@3.59.1
ng-app-js-sdk: link:../ng-app-js/pkg
ng-sdk-js: link:../ng-sdk-js/pkg
svelte-spa-router: 3.3.0
vite-plugin-top-level-await: 1.3.1_vite@4.3.9
devDependencies:

@ -1,2 +1,3 @@
packages:
- ng-app-js/pkg
- ng-sdk-js/pkg
- ng-app
Loading…
Cancel
Save