raname sdk to ng-sdk-js

pull/19/head
Niko 2 years ago
parent 8b9e68a62d
commit 9bdb27d36a
  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. 28
      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]] [[package]]
name = "ng-app-js-sdk" name = "ng-sdk-js"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"async-std", "async-std",

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

@ -55,7 +55,7 @@ The crates are organized as follow :
- ngcli : CLI tool to manipulate the repos - ngcli : CLI tool to manipulate the repos
- ngd : binary executable of the daemon (that can run a broker, verifier and/or Rust services) - 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) - 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-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 - 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 pnpm webbuild
// then the application is available in dist-web folder // 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 pnpm filebuild

@ -19,7 +19,7 @@
"classnames": "^2.3.2", "classnames": "^2.3.2",
"flowbite": "^1.6.5", "flowbite": "^1.6.5",
"flowbite-svelte": "^0.37.1", "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", "svelte-spa-router": "^3.3.0",
"vite-plugin-top-level-await": "^1.3.1" "vite-plugin-top-level-await": "^1.3.1"
}, },

@ -10,7 +10,7 @@
--> -->
<script lang="ts"> <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 Router from "svelte-spa-router";
import Home from "./routes/Home.svelte"; import Home from "./routes/Home.svelte";

@ -15,7 +15,7 @@
let ng; let ng;
if (import.meta.env.NG_APP_WEB) { 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 = { ng = {
greet: async function (n) { greet: async function (n) {
ng2.test(); ng2.test();

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

@ -1,6 +1,6 @@
# ng-app-js # ng-sdk-js
JS/WASM module of NextGraph (SDK and apps) JS/WASM crate containing the SDK of NextGraph
## NextGraph ## NextGraph
@ -12,13 +12,13 @@ JS/WASM module of NextGraph (SDK and apps)
## JS/WASM module ## 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 npm package `ng-app-js` which is the SDK
- the plain JS web app `app-web` - an example of web app using the ESmodule and webpack as bundler `app-web`
- the React web app `app-react` - an example of React web app `app-react`
- the node-js app `app-node` - an example of node-js app `app-node`
- `index.html` an example of vanilla JS usage of the SDK
## Support ## 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/). 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 ## For contributors
@ -51,13 +51,16 @@ cd pkg-node
``` ```
For testing in vanilla JS For testing in vanilla JS
``` ```
wasm-pack build --target web -d web wasm-pack build --target web -d web
python3 -m http.server python3 -m http.server
// open http://localhost:8000 // open http://localhost:8000
``` ```
Or automated testing with headless chrome: Or automated testing with headless chrome:
``` ```
wasm-pack test --chrome --headless wasm-pack test --chrome --headless
``` ```
@ -84,7 +87,7 @@ npm install --no-save ../pkg
npm run dev 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 ### NodeJS app
@ -105,9 +108,10 @@ additional terms or conditions.s
## License ## License
Licensed under either of 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) - Apache License, Version 2.0 ([LICENSE-APACHE2](LICENSE-APACHE2) or http://www.apache.org/licenses/LICENSE-2.0)
at your option. - MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.
`SPDX-License-Identifier: Apache-2.0 OR MIT` `SPDX-License-Identifier: Apache-2.0 OR MIT`

@ -7,7 +7,8 @@
// notice may not be copied, modified, or distributed except // notice may not be copied, modified, or distributed except
// according to those terms. // according to those terms.
const WebSocket = require("ws"); 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; global.WebSocket = WebSocket;
const test = require("./test") const test = require("./test")

@ -13,7 +13,7 @@
"author": "Niko PLP <niko@nextgraph.org>", "author": "Niko PLP <niko@nextgraph.org>",
"license": "(MIT OR Apache-2.0)", "license": "(MIT OR Apache-2.0)",
"dependencies": { "dependencies": {
"ng-app-node-sdk": "^0.1.0", "ng-sdk-node": "^0.1.0",
"ws": "^8.13.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 () { module.exports.random = function () {
console.log("FROM TEST"); console.log("FROM TEST");

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

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

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

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

@ -24,7 +24,7 @@
}, },
"homepage": "https://docs.nextgraph.org", "homepage": "https://docs.nextgraph.org",
"dependencies": { "dependencies": {
"ng-app-js-sdk": "^0.1.0" "ng-sdk-js": "^0.1.0"
}, },
"devDependencies": { "devDependencies": {
"webpack": "^4.29.3", "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> <body>
<p>run <code>python3 -m http.server</code> to use it</p> <p>run <code>python3 -m http.server</code> to use it</p>
<script type="module"> <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(() => { init().then(() => {
//greet("WebAssembly"); //greet("WebAssembly");
test(); test();
@ -27,9 +27,9 @@
}); });
// DON'T DO THE FOLLOW: // DON'T DO THE FOLLOW:
// it will instantiate twice the SDK, which is not what we want // it will instantiate twice the SDK, which is not what we want
init().then(() => { // init().then(() => {
test(); // test();
}); // });
</script> </script>
</body> </body>
</html> </html>

@ -4,6 +4,6 @@ const PATH = './pkg-node/package.json';
const pkg_json = fs.readFileSync(PATH); const pkg_json = fs.readFileSync(PATH);
let pkg = JSON.parse(pkg_json) let pkg = JSON.parse(pkg_json)
pkg.name = "ng-app-node-sdk"; pkg.name = "ng-sdk-node";
pkg.description = "nodejs app sdk of NextGraph"; pkg.description = "nodejs app sdk of NextGraph";
fs.writeFileSync(PATH, JSON.stringify(pkg, null, 2), 'utf8'); 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: ^1.6.5
flowbite-svelte: ^0.37.1 flowbite-svelte: ^0.37.1
internal-ip: ^7.0.0 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: ^8.4.23
postcss-load-config: ^4.0.1 postcss-load-config: ^4.0.1
svelte: ^3.54.0 svelte: ^3.54.0
@ -37,7 +37,7 @@ importers:
classnames: 2.3.2 classnames: 2.3.2
flowbite: 1.6.5 flowbite: 1.6.5
flowbite-svelte: 0.37.3_svelte@3.59.1 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 svelte-spa-router: 3.3.0
vite-plugin-top-level-await: 1.3.1_vite@4.3.9 vite-plugin-top-level-await: 1.3.1_vite@4.3.9
devDependencies: devDependencies:

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