@emeryld/rrroutes-client 2.6.2 → 2.6.4
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/README.md +10 -6
- package/dist/index.cjs +1262 -1229
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1260 -1227
- package/dist/index.mjs.map +1 -1
- package/dist/sockets/socket.client.context.client.d.ts +5 -0
- package/dist/sockets/socket.client.context.connection.d.ts +18 -0
- package/dist/sockets/socket.client.context.d.ts +4 -71
- package/dist/sockets/socket.client.context.debug.d.ts +50 -0
- package/dist/sockets/socket.client.context.provider.d.ts +26 -0
- package/dist/sockets/socket.client.core.d.ts +116 -0
- package/dist/sockets/socket.client.index.d.ts +1 -116
- package/dist/sockets/socket.client.sys.d.ts +1 -1
- package/dist/sockets/socketedRoute/socket.client.helper.d.ts +2 -70
- package/dist/sockets/socketedRoute/socket.client.helper.debug.d.ts +54 -0
- package/dist/sockets/socketedRoute/socket.client.helper.rooms.d.ts +17 -0
- package/dist/sockets/socketedRoute/socket.client.helper.route.d.ts +31 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -347,8 +347,8 @@ const client = new SocketClient(events, {
|
|
|
347
347
|
debug: { receive: true, emit: true, verbose: true, logger: console.log },
|
|
348
348
|
})
|
|
349
349
|
|
|
350
|
-
client.on('chat:message', (payload,
|
|
351
|
-
console.log('socket message', payload.text, 'latency', ctx
|
|
350
|
+
client.on('chat:message', (payload, meta) => {
|
|
351
|
+
console.log('socket message', payload.text, 'latency', meta?.ctx?.latencyMs)
|
|
352
352
|
})
|
|
353
353
|
|
|
354
354
|
void client.emit('chat:message', {
|
|
@@ -423,7 +423,7 @@ import { useSocketClient } from './socketProvider';
|
|
|
423
423
|
|
|
424
424
|
const listRooms = client.build(registry.byKey['GET /v1/rooms'], { staleTime: 120_000 });
|
|
425
425
|
|
|
426
|
-
const
|
|
426
|
+
const socketedRooms = buildSocketedRoute({
|
|
427
427
|
built: listRooms,
|
|
428
428
|
toRooms: (page) => ({
|
|
429
429
|
rooms: page.items.map((r) => r.id), // derive rooms from data (feeds supported)
|
|
@@ -432,8 +432,10 @@ const useSocketedRooms = buildSocketedRoute({
|
|
|
432
432
|
}),
|
|
433
433
|
useSocketClient,
|
|
434
434
|
applySocket: {
|
|
435
|
-
'chat:message': (prev, payload) => {
|
|
436
|
-
if (!prev) return
|
|
435
|
+
'chat:message': (prev, payload, meta) => {
|
|
436
|
+
if (!prev) return null; // explicit no-op update
|
|
437
|
+
const [args] = meta.args;
|
|
438
|
+
console.debug('socket patch args', args);
|
|
437
439
|
// Example: bump unread count in cache
|
|
438
440
|
const apply = (items: any[]) =>
|
|
439
441
|
items.map((room) =>
|
|
@@ -447,7 +449,7 @@ const useSocketedRooms = buildSocketedRoute({
|
|
|
447
449
|
});
|
|
448
450
|
|
|
449
451
|
function RoomList() {
|
|
450
|
-
const { data, rooms } =
|
|
452
|
+
const { data, rooms } = socketedRooms.useEndpoint();
|
|
451
453
|
return (
|
|
452
454
|
<>
|
|
453
455
|
<p>Subscribed rooms: {rooms.join(', ')}</p>
|
|
@@ -457,6 +459,8 @@ function RoomList() {
|
|
|
457
459
|
}
|
|
458
460
|
```
|
|
459
461
|
|
|
462
|
+
`buildSocketedRoute(...)` returns a built endpoint object with `useEndpoint()` plus the original built helpers. `applySocket` receives `{ envelope?, ctx?, args }` and can return `null` to skip cache updates.
|
|
463
|
+
|
|
460
464
|
---
|
|
461
465
|
|
|
462
466
|
## Edge cases & notes
|