Skip to content

Commit 116a1e8

Browse files
committed
Address comments
1 parent ac7f4b3 commit 116a1e8

4 files changed

Lines changed: 145 additions & 390 deletions

File tree

demo/web/README.md

Lines changed: 0 additions & 87 deletions
This file was deleted.

demo/web/javascript/README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,15 @@ SDK from a plain URL).
2929
const ros = await connect('ws://localhost:9000/capability');
3030
3131
const reply = await ros.call('/add_two_ints', { a: '2n', b: '40n' });
32-
console.log(reply.sum); // '42n'
32+
console.log(reply.sum); // '42n'
3333
3434
await ros.subscribe('/web_demo_tick', (msg) => render(msg.data));
3535
await ros.publish('/web_demo_chatter', { data: 'hi' });
3636
</script>
3737
```
3838

39-
That's the whole client. The page also has a **transport toggle**
40-
(WebSocket vs. HTTP) so you can flip the SDK between the two without
41-
restarting.
39+
The page also has a **transport toggle** (WebSocket vs. HTTP) so you
40+
can flip the SDK between the two without restarting.
4241

4342
## Same capability, no SDK
4443

@@ -67,10 +66,10 @@ The browser code is unchanged; only the URL it points to changes.
6766

6867
## Putting the SDK in your own project
6968

70-
| Approach | When | How |
71-
|---|---|---|
72-
| Plain `<script type="module">` | static page, hackathon | host `web/index.js` somewhere, `import { connect } from '/path/to/it'` |
73-
| ESM via npm | Vite, Next.js, esbuild, webpack | `npm i rclnodejs`, then `import { connect } from 'rclnodejs/web'` |
74-
| ESM CDN | quick prototypes, codepens | `import { connect } from 'https://esm.sh/rclnodejs/web'` |
69+
| Approach | When | How |
70+
| ------------------------------- | ------------------------------- | ------------------------------------------------------------------ |
71+
| Plain `<script type="module">` | static page, hackathon | host `web/index.js` somewhere, `import { connect } from '/path/to/it'` |
72+
| ESM via npm | Vite, Next.js, esbuild, webpack | `npm i rclnodejs`, then `import { connect } from 'rclnodejs/web'` |
73+
| ESM CDN | quick prototypes, codepens | `import { connect } from 'https://esm.sh/rclnodejs/web'` |
7574

7675
For a typed version, see the [TypeScript demo](../typescript/).

demo/web/typescript/README.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@ const reply = await ros.call<'example_interfaces/srv/AddTwoInts'>(
1313

1414
## Run it (two shells)
1515

16-
**Setup once:**
17-
1816
```bash
1917
cd demo/web/typescript
2018
npm install
2119
```
2220

23-
**Shell 1 — runtime (with backing ROS 2 nodes):**
21+
**Shell 1 — runtime:**
2422

2523
```bash
2624
source /opt/ros/<distro>/setup.bash
@@ -39,34 +37,33 @@ npm run dev
3937
# ➜ Local: http://localhost:5173/
4038
```
4139

42-
Edits to `src/main.ts` hot-reload; edits to `server.ts` need a
43-
restart of shell 1.
40+
Edits to `src/main.ts` hot-reload; edits to `server.ts` need a restart
41+
of shell 1.
4442

4543
## Without the bundled `server.ts`
4644

4745
Real projects use the `rclnodejs-web` CLI against an existing ROS 2
48-
graph instead of running `server.ts`:
46+
graph:
4947

5048
```bash
5149
npx rclnodejs-web ../javascript/web.json
52-
# (then `ros2 run demo_nodes_cpp add_two_ints_server` etc.
53-
# to back the panels)
50+
# (then `ros2 run demo_nodes_cpp add_two_ints_server` etc. to back the panels)
5451
```
5552

5653
`src/main.ts` doesn't change between the two setups.
5754

5855
## Other npm scripts
5956

60-
| Command | What it does |
61-
|---|---|
62-
| `npm run typecheck` | `tsc --noEmit` — silent on success |
63-
| `npm run build` | static bundle in `dist/` (~6 kB JS, ~1.5 kB CSS gzipped) |
64-
| `npm run preview` | serve the built `dist/` |
57+
| Command | What it does |
58+
| ------------------- | ---------------------------------------------------- |
59+
| `npm run typecheck` | `tsc --noEmit` — silent on success |
60+
| `npm run build` | static bundle in `dist/` (~6 kB JS, ~1.5 kB CSS gz) |
61+
| `npm run preview` | serve the built `dist/` |
6562

6663
## Deploying for real
6764

6865
Browser bundle (`dist/`) and runtime are independent — they only
6966
share a WebSocket URL. Static-host the bundle anywhere; run
7067
`rclnodejs-web` wherever ROS 2 lives. For production: terminate
7168
`wss://` at a TLS proxy, gate the upgrade with your existing auth,
72-
and keep `web.json` narrow.
69+
keep `web.json` narrow.

0 commit comments

Comments
 (0)