Compare commits

...

9 Commits
v1.0.6 ... main

Author SHA1 Message Date
Connor Smith e9ec9adf81 docs: add note about experimental status
Signed-off-by: Connor Smith <connor.smith.256@gmail.com>
2023-10-31 12:19:40 -06:00
Brooks Townsend b241df0590
Merge pull request #26 from wasmCloud/ks2211/updates
Update examples
2022-12-19 16:29:15 -05:00
Kaushik Shanadi de97386d27 update examples
Signed-off-by: Brooks Townsend <brooks@cosmonic.com>
2022-12-19 08:54:52 -05:00
Kaushik Shanadi 44c14b73cb
Merge pull request #20 from wasmCloud/snyk-upgrade-f7bfd93940c4d6a9de6e53510b435dd2
[Snyk] Upgrade axios from 0.21.3 to 0.24.0
2022-01-03 13:39:25 -05:00
Kaushik Shanadi daa3a7e099
Merge pull request #21 from wasmCloud/snyk-upgrade-5a5a87f3ce0884c20cb36e0039f28d09
[Snyk] Upgrade @msgpack/msgpack from 2.7.0 to 2.7.1
2022-01-03 13:39:10 -05:00
snyk-bot 1d33dd97f7
fix: upgrade @msgpack/msgpack from 2.7.0 to 2.7.1
Snyk has created this PR to upgrade @msgpack/msgpack from 2.7.0 to 2.7.1.

See this package in npm:
https://www.npmjs.com/package/@msgpack/msgpack

See this project in Snyk:
https://app.snyk.io/org/wasmcloud-automation/project/7349e195-0622-4c5b-add5-7f34587e7853?utm_source=github&utm_medium=referral&page=upgrade-pr
2021-12-15 20:16:10 +00:00
snyk-bot 8d870d1546
fix: upgrade axios from 0.21.3 to 0.24.0
Snyk has created this PR to upgrade axios from 0.21.3 to 0.24.0.

See this package in npm:
https://www.npmjs.com/package/axios

See this project in Snyk:
https://app.snyk.io/org/wasmcloud-automation/project/7349e195-0622-4c5b-add5-7f34587e7853?utm_source=github&utm_medium=referral&page=upgrade-pr
2021-12-15 20:16:04 +00:00
Kaushik Shanadi 197e0ce212
Merge pull request #18 from wasmCloud/snyk-fix-702adb67744f2233deb4be91f95e8cc6
[Snyk] Security upgrade axios from 0.21.1 to 0.21.3
2021-12-14 20:15:45 -05:00
snyk-bot 2457fdf000
fix: package.json & package-lock.json to reduce vulnerabilities
The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JS-AXIOS-1579269
2021-12-15 01:09:49 +00:00
7 changed files with 41 additions and 54 deletions

View File

@ -1,3 +1,6 @@
> [!IMPORTANT]
> This host is **experimental** and does not implement all features or security settings. As a result, this host should not be used in production. For deploying wasmCloud to production, use the [primary host runtime](https://github.com/wasmCloud/wasmCloud/tree/main/crates/host).
# wasmCloud Host in JavaScript/Browser
This is the JavaScript implementation of the wasmCloud host for the browser (NodeJS support in progress). The library runs a host inside a web browser/application that connects to a remote lattice via NATS and can run wasmCloud actors in the browser. The host will automatically listen for actor start/stop from NATS and will initialize the actor using `wapcJS`. Any invocations will be handled by the browser actor and returned to the requesting host via NATS. Users can pass callbacks to handle invocation and event data.

View File

@ -6,6 +6,8 @@ This directory contains examples of using the `wasmcloud-js` library with sample
* NATS with WebSockets enabled
* There is sample infra via docker in the `test/infra` directory of this repo, `cd test/infra && docker-compose up`
* wasmCloud lattice (OTP Version)
* (OPTIONAL) Docker Registry with CORS configured
@ -17,17 +19,32 @@ This directory contains examples of using the `wasmcloud-js` library with sample
## Build
```sh
$ npm install # this will run and build the rust deps
$ npm install webpack esbuild copy-webpack-plugin fs
$ #### if you want to use esbuild, follow these next 2 steps ####
$ node esbuild.js # this produces the esbuild version
$ mv out-esbuild.js out.js # rename the esbuild version
$ #### if you want to use webpack, follow the steps below ####
$ npx webpack --config=example-webpack.config.js # this produces the webpack output
$ mv out-webpack.js out.js #rename the webpack version to out.js
```
## Usage
1. Build the code
1. Build the code with esbuild or webpack
2. Start a web server inside this directory (e.g `python3 -m http.server`)
2. Rename the output file to `out.js`
3. Start a web server inside this directory (e.g `python3 -m http.server` or `npx serve`)
3. Navigate to a browser `localhost:<PORT>`
4. Open the developer console to view the host output
4. Open the developer console to view the host output
5. In the dev tools run `host` and you will get the full host object and methods
6. Start an actor with `host.launchActor('registry:5000/image', (data) => console.log(data))`. Echo actor is recommended (the 2nd parameter here is an invocation callback to handle the data from an invocation)
7. Link the actor with a provider running in Wasmcloud (eg `httpserver`)
8. Run a `curl localhost:port/echo` to see the response in the console (based off the invocation callback).

View File

@ -6,6 +6,7 @@ import { startHost } from '../../dist/src'
(async () => {
console.log('USING A JS BUNDLER')
const host = await startHost('default', false, ['ws://localhost:4222'])
const host = await startHost('default', false, ['ws://localhost:6222'])
window.host = host;
console.log(host);
})()

57
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@wasmcloud/wasmcloud-js",
"version": "1.0.5",
"version": "1.0.6",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -1235,9 +1235,9 @@
"dev": true
},
"@msgpack/msgpack": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/@msgpack/msgpack/-/msgpack-2.7.0.tgz",
"integrity": "sha512-mlRYq9FSsOd4m+3wZWatemn3hGFZPWNJ4JQOdrir4rrMK2PyIk26idKBoUWrqF3HJJHl+5GpRU+M0wEruJwecg=="
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/@msgpack/msgpack/-/msgpack-2.7.1.tgz",
"integrity": "sha512-ApwiSL2c9ObewdOE/sqt788P1C5lomBOHyO8nUBCr4ofErBCnYQ003NtJ8lS9OQZc11ximkbmgAZJjB8y6cCdA=="
},
"@nodelib/fs.scandir": {
"version": "2.1.5",
@ -1781,11 +1781,11 @@
"dev": true
},
"axios": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz",
"integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==",
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz",
"integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==",
"requires": {
"follow-redirects": "^1.10.0"
"follow-redirects": "^1.14.4"
}
},
"babel-loader": {
@ -2147,41 +2147,6 @@
}
}
},
"copy-webpack-plugin": {
"version": "9.0.1",
"resolved": "https://registry.npmjs.org/copy-webpack-plugin/-/copy-webpack-plugin-9.0.1.tgz",
"integrity": "sha512-14gHKKdYIxF84jCEgPgYXCPpldbwpxxLbCmA7LReY7gvbaT555DgeBWBgBZM116tv/fO6RRJrsivBqRyRlukhw==",
"dev": true,
"requires": {
"fast-glob": "^3.2.5",
"glob-parent": "^6.0.0",
"globby": "^11.0.3",
"normalize-path": "^3.0.0",
"p-limit": "^3.1.0",
"schema-utils": "^3.0.0",
"serialize-javascript": "^6.0.0"
},
"dependencies": {
"glob-parent": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.1.tgz",
"integrity": "sha512-kEVjS71mQazDBHKcsq4E9u/vUzaLcw1A8EtUeydawvIWQCJM0qQ08G1H7/XTjFUulla6XQiDOG6MXSaG0HDKog==",
"dev": true,
"requires": {
"is-glob": "^4.0.1"
}
},
"p-limit": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",
"integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==",
"dev": true,
"requires": {
"yocto-queue": "^0.1.0"
}
}
}
},
"core-js-compat": {
"version": "3.16.4",
"resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.16.4.tgz",
@ -2754,9 +2719,9 @@
"dev": true
},
"follow-redirects": {
"version": "1.14.2",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.2.tgz",
"integrity": "sha512-yLR6WaE2lbF0x4K2qE2p9PEXKLDjUjnR/xmjS3wHAYxtlsI9MLLBJUZirAHKzUZDGLxje7w/cXR49WOUo4rbsA=="
"version": "1.14.6",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.6.tgz",
"integrity": "sha512-fhUl5EwSJbbl8AR+uYL2KQDxLkdSjZGR36xy46AO7cOMTrCMON6Sa28FmAnC2tRTDbd/Uuzz3aJBv7EBN7JH8A=="
},
"fs.realpath": {
"version": "1.0.0",

View File

@ -73,9 +73,9 @@
"webpack-cli": "^4.8.0"
},
"dependencies": {
"@msgpack/msgpack": "^2.7.0",
"@msgpack/msgpack": "^2.7.1",
"@wapc/host": "0.0.2",
"axios": "^0.21.1",
"axios": "^0.24.0",
"nats.ws": "^1.2.0"
}
}

View File

@ -3,13 +3,14 @@ services:
registry:
image: registry:2
ports:
- "5000:5000"
- "5001:5001"
volumes:
- ./docker-registry.yml:/etc/docker/registry/config.yml
nats:
image: nats:latest
ports:
- "4222:4222"
- "6222:6222"
volumes:
- ./nats.conf:/etc/nats.conf
command: "-c=/etc/nats.conf -js"

View File

@ -1,6 +1,6 @@
listen: localhost:4222
websocket {
# host: "hostname"
port: 4222
port: 6222
no_tls: true
}