@evjs/create-app 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/templates/api-routes/package.json +1 -1
- package/templates/basic/package.json +1 -1
- package/templates/complex-routing/package.json +1 -1
- package/templates/custom-ws-transport/README.md +3 -3
- package/templates/custom-ws-transport/package.json +1 -1
- package/templates/custom-ws-transport/src/pages/home.tsx +5 -5
- package/templates/mpa/ev.config.ts +2 -6
- package/templates/mpa/package.json +1 -1
- package/templates/plugin-authoring/package.json +1 -1
- package/templates/with-sqlite/package.json +1 -1
- package/templates/with-tailwind/package.json +1 -1
- package/templates/with-trpc/package.json +1 -1
package/package.json
CHANGED
|
@@ -12,14 +12,14 @@ npm run dev
|
|
|
12
12
|
|
|
13
13
|
| File | Purpose |
|
|
14
14
|
|------|---------|
|
|
15
|
-
| `src/main.tsx` | `initTransport` with WebSocket
|
|
15
|
+
| `src/main.tsx` | `initTransport` with WebSocket adapter |
|
|
16
16
|
| `src/routes.tsx` | UI with users CRUD |
|
|
17
17
|
| `src/api/users.server.ts` | Server functions |
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
## What It Demonstrates
|
|
21
21
|
|
|
22
|
-
- Custom `
|
|
23
|
-
- `initTransport({
|
|
22
|
+
- Custom `TransportAdapter` over WebSocket
|
|
23
|
+
- `initTransport({ adapter: { send } })` extension
|
|
24
24
|
- `dispatch()` for protocol-agnostic server-side handling
|
|
25
25
|
- Same server functions work over HTTP and WebSocket
|
|
@@ -3,13 +3,13 @@ import { useEffect, useState } from "react";
|
|
|
3
3
|
import { createUser, getUsers } from "../api/users.server";
|
|
4
4
|
import { rootRoute } from "./__root";
|
|
5
5
|
|
|
6
|
-
// ── WebSocket
|
|
6
|
+
// ── WebSocket Adapter ──
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Custom WebSocket
|
|
9
|
+
* Custom WebSocket adapter that sends RPC calls over a persistent
|
|
10
10
|
* WebSocket connection instead of HTTP POST.
|
|
11
11
|
*/
|
|
12
|
-
function
|
|
12
|
+
function createWebSocketAdapter(url: string) {
|
|
13
13
|
let ws: WebSocket | null = null;
|
|
14
14
|
let requestId = 0;
|
|
15
15
|
const pending = new Map<
|
|
@@ -65,10 +65,10 @@ function createWebSocketTransport(url: string) {
|
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
// Configure the transport to use WebSocket
|
|
68
|
+
// Configure the transport runtime to use WebSocket
|
|
69
69
|
const wsUrl = `ws://${window.location.hostname}:${window.location.port}/ws`;
|
|
70
70
|
initTransport({
|
|
71
|
-
|
|
71
|
+
adapter: createWebSocketAdapter(wsUrl),
|
|
72
72
|
});
|
|
73
73
|
|
|
74
74
|
// ── Users Page ──
|
|
@@ -4,11 +4,7 @@ export default defineConfig({
|
|
|
4
4
|
server: false,
|
|
5
5
|
html: "./index.html",
|
|
6
6
|
pages: {
|
|
7
|
-
home:
|
|
8
|
-
|
|
9
|
-
},
|
|
10
|
-
about: {
|
|
11
|
-
entry: "./src/about/main.tsx",
|
|
12
|
-
},
|
|
7
|
+
home: "./src/home/main.tsx",
|
|
8
|
+
about: "./src/about/main.tsx",
|
|
13
9
|
},
|
|
14
10
|
});
|