diff --git a/examples/batch-pipelining/server-node.mjs b/examples/batch-pipelining/server-node.mjs index 10ab4e6..1e9857e 100644 --- a/examples/batch-pipelining/server-node.mjs +++ b/examples/batch-pipelining/server-node.mjs @@ -23,7 +23,7 @@ const PROFILES = new Map([ ]); const NOTIFICATIONS = new Map([ - ['u_1', ['Welcome to jsrpc!', 'You have 2 new followers']], + ['u_1', ['Welcome to Cap\'n Web!', 'You have 2 new followers']], ['u_2', ['New feature: pipelining!', 'Security tips for your account']], ]); diff --git a/examples/worker-react/README.md b/examples/worker-react/README.md index 2e47f90..3a6c41d 100644 --- a/examples/worker-react/README.md +++ b/examples/worker-react/README.md @@ -1,6 +1,6 @@ Cloudflare Workers + React Example -This example shows a Cloudflare Worker exposing a JSRPC API and a React app calling it from the browser. It demonstrates batching + promise pipelining vs sequential requests, with timing and request counts. +This example shows a Cloudflare Worker exposing a Cap'n Web API and a React app calling it from the browser. It demonstrates batching + promise pipelining vs sequential requests, with timing and request counts. Prerequisites @@ -21,7 +21,7 @@ Run locally 1) Build the library at repo root (the example uses the local dist build): npm run build -2) Install and build the React app (Vite aliases `@cloudflare/jsrpc` to the local `dist`): +2) Install and build the React app (Vite aliases `capnweb` to the local `dist`): cd examples/worker-react/web npm install npm run build @@ -40,8 +40,4 @@ Tuning delays - `DELAY_PROFILE_MS` (default 120) - `DELAY_NOTIFS_MS` (default 120) - `SIMULATED_RTT_MS` per direction (default 120) - - `SIMULATED_RTT_JITTER_MS` per direction (default 40) - -Notes - -- The frontend imports `@cloudflare/jsrpc`. If trying this example before publish, you can `npm link` the built package into the `web` app or adjust imports to point at a local path. + - `SIMULATED_RTT_JITTER_MS` per direction (default 40) \ No newline at end of file diff --git a/examples/worker-react/src/worker.ts b/examples/worker-react/src/worker.ts index afee9ff..7e89ab1 100644 --- a/examples/worker-react/src/worker.ts +++ b/examples/worker-react/src/worker.ts @@ -1,5 +1,4 @@ -// Use local build output so this example runs without publishing to npm. -import { newWorkersRpcResponse, RpcTarget } from '../../../dist/index.js'; +import { newWorkersRpcResponse, RpcTarget } from 'capnweb'; type Env = { DELAY_AUTH_MS?: string; @@ -23,11 +22,11 @@ const PROFILES = new Map([ ]); const NOTIFICATIONS = new Map([ - ['u_1', ['Welcome to jsrpc!', 'You have 2 new followers']], + ['u_1', ['Welcome to Cap\'n Web!', 'You have 2 new followers']], ['u_2', ['New feature: pipelining!', 'Security tips for your account']], ]); -class Api extends RpcTarget { +export class Api extends RpcTarget { constructor(private env: Env) { super(); } async authenticate(sessionToken: string) { diff --git a/examples/worker-react/web/index.html b/examples/worker-react/web/index.html index 9212994..040235e 100644 --- a/examples/worker-react/web/index.html +++ b/examples/worker-react/web/index.html @@ -3,7 +3,7 @@ - JSRPC Workers + React Example + Cap'n Web Cloudflare Workers + React Example
diff --git a/examples/worker-react/web/package-lock.json b/examples/worker-react/web/package-lock.json index 4d8f12b..7c2d29e 100644 --- a/examples/worker-react/web/package-lock.json +++ b/examples/worker-react/web/package-lock.json @@ -1,11 +1,11 @@ { - "name": "jsrpc-react-web", + "name": "capnweb-react-web", "version": "0.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "jsrpc-react-web", + "name": "capnweb-react-web", "version": "0.0.0", "dependencies": { "react": "^18.3.1", diff --git a/examples/worker-react/web/package.json b/examples/worker-react/web/package.json index b092340..84918f2 100644 --- a/examples/worker-react/web/package.json +++ b/examples/worker-react/web/package.json @@ -1,5 +1,5 @@ { - "name": "jsrpc-react-web", + "name": "capnweb-react-web", "private": true, "version": "0.0.0", "type": "module", diff --git a/examples/worker-react/web/src/main/App.tsx b/examples/worker-react/web/src/main/App.tsx index 079d218..34287b8 100644 --- a/examples/worker-react/web/src/main/App.tsx +++ b/examples/worker-react/web/src/main/App.tsx @@ -1,5 +1,5 @@ import { useMemo, useState } from 'react' -import { newHttpBatchRpcSession } from '@cloudflare/jsrpc' +import { newHttpBatchRpcSession } from 'capnweb' import type { Api } from '../../../src/worker' type Result = { @@ -127,7 +127,7 @@ export function App() { return (
-

JSRPC: Workers + React

+

Cap'n Web: Cloudflare Workers + React

Network RTT is simulated on the server (configurable via SIMULATED_RTT_MS/SIMULATED_RTT_JITTER_MS in wrangler.toml).

This demo calls the Worker API in two ways: