From 0d86c9172068fb1d5b75c8c364eac8a0589f57bc Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Tue, 12 Oct 2021 14:13:54 +1100 Subject: [PATCH 1/4] Add Pure JS example --- examples/examples.md | 1 + examples/unpkg-js-store/README.md | 11 ++++ examples/unpkg-js-store/index.html | 84 ++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 examples/unpkg-js-store/README.md create mode 100644 examples/unpkg-js-store/index.html diff --git a/examples/examples.md b/examples/examples.md index bb7a4f8b49..e1dac59613 100644 --- a/examples/examples.md +++ b/examples/examples.md @@ -6,3 +6,4 @@ Here is the list of the code examples and the features they demonstrate: - [Ethereum Private Message Web App](eth-pm): Private Messaging, React/TypeScript, Light Push, Signature with Web3, Asymmetric Encryption. - [Minimal ReactJS Chat App](min-react-js-chat): Group chat, React/JavaScript, Relay, Protobuf using `protons`. - [Minimal ReactJS Waku Store App](store-reactjs-chat): Waku Store, React/JavaScript, Protobuf using `protons`. +- [Pure Javascript Using Minified Library](unpkg-js-store): Stop retrieving results from Waku Store on condition, Use minified bundle from Unpkg.com, JavaScript. diff --git a/examples/unpkg-js-store/README.md b/examples/unpkg-js-store/README.md new file mode 100644 index 0000000000..827660a7c3 --- /dev/null +++ b/examples/unpkg-js-store/README.md @@ -0,0 +1,11 @@ +# Pure Javascript Using Minified Library + +**Demonstrates**: + +- Waku Store: Using a condition to stop retrieving results from Waku Store. +- Pure Javascript/HTML. +- Use minified bundle of js from unpkg (todo), no import, no package manager. + +This example uses Waku Store to retrieve the latest ping relay message (used for keep alive purposes) and displays its timestamp. + +To test the example, simply download the `index.html` file from this folder and open it in a browser. diff --git a/examples/unpkg-js-store/index.html b/examples/unpkg-js-store/index.html new file mode 100644 index 0000000000..cddaa07b03 --- /dev/null +++ b/examples/unpkg-js-store/index.html @@ -0,0 +1,84 @@ + + + + + + + JS-Waku unpkg example + + + + +

Timestamp of latest relay ping

+
+ + + + + + From 9a8ecd8611ecf0803863e07df76f9d843f2fb84e Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Tue, 12 Oct 2021 16:29:52 +1100 Subject: [PATCH 2/4] Update README to include unpkg example --- README.md | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 70506864b8..00c42e9fa8 100644 --- a/README.md +++ b/README.md @@ -32,11 +32,42 @@ Install `js-waku` package: npm install js-waku ``` +### Import js-waku + +To use js-waku in your application, you can: + +use `import`: + +```js +import { Waku } from 'js-waku'; + +const waku = await Waku.create(); +``` + +use `require`: + +```js +const jsWaku = require('js-waku'); + +jsWaku.Waku.create().then(waku => { + // ... +}); +``` + +Or directly import it in a ` + +``` + ### Start a waku node ```ts -import { Waku } from 'js-waku'; - const waku = await Waku.create({ bootstrap: true }); ``` From cb0b93d3f1b6c02a117a355fd01c0d0e6a93f764 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Tue, 12 Oct 2021 16:32:04 +1100 Subject: [PATCH 3/4] Remove todo --- examples/unpkg-js-store/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/unpkg-js-store/README.md b/examples/unpkg-js-store/README.md index 827660a7c3..73e1525375 100644 --- a/examples/unpkg-js-store/README.md +++ b/examples/unpkg-js-store/README.md @@ -4,7 +4,7 @@ - Waku Store: Using a condition to stop retrieving results from Waku Store. - Pure Javascript/HTML. -- Use minified bundle of js from unpkg (todo), no import, no package manager. +- Use minified bundle of js from unpkg.com, no import, no package manager. This example uses Waku Store to retrieve the latest ping relay message (used for keep alive purposes) and displays its timestamp. From 137c1dfcc01d8c7336598ff641e026c12898b6b2 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Wed, 13 Oct 2021 08:09:55 +1100 Subject: [PATCH 4/4] Add jswaku --- .cspell.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.cspell.json b/.cspell.json index 82d6d34fc7..0018ca4d89 100644 --- a/.cspell.json +++ b/.cspell.json @@ -40,6 +40,7 @@ "ipfs", "iwant", "jdev", + "jswaku", "keccak", "lastpub", "libauth",