Compare commits
9 Commits
Author | SHA1 | Date |
---|---|---|
|
e9ec9adf81 | |
|
b241df0590 | |
|
de97386d27 | |
|
44c14b73cb | |
|
daa3a7e099 | |
|
1d33dd97f7 | |
|
8d870d1546 | |
|
197e0ce212 | |
|
2457fdf000 |
|
@ -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.
|
||||
|
|
|
@ -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).
|
|
@ -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);
|
||||
})()
|
|
@ -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",
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
|
@ -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"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
listen: localhost:4222
|
||||
websocket {
|
||||
# host: "hostname"
|
||||
port: 4222
|
||||
port: 6222
|
||||
no_tls: true
|
||||
}
|
Loading…
Reference in New Issue