@replit/river 0.23.18 → 0.24.1

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.
Files changed (84) hide show
  1. package/README.md +17 -16
  2. package/dist/chunk-227EQHH5.js +653 -0
  3. package/dist/chunk-227EQHH5.js.map +1 -0
  4. package/dist/chunk-6YFPHVNO.js +277 -0
  5. package/dist/chunk-6YFPHVNO.js.map +1 -0
  6. package/dist/{chunk-7MJYOL32.js → chunk-BGJDNLTJ.js} +15 -23
  7. package/dist/chunk-BGJDNLTJ.js.map +1 -0
  8. package/dist/chunk-HXOQQXL4.js +382 -0
  9. package/dist/chunk-HXOQQXL4.js.map +1 -0
  10. package/dist/{chunk-R2HAS3GM.js → chunk-IYYQ7BII.js} +55 -41
  11. package/dist/chunk-IYYQ7BII.js.map +1 -0
  12. package/dist/{chunk-AVL32IMG.js → chunk-L664A3WA.js} +20 -16
  13. package/dist/chunk-L664A3WA.js.map +1 -0
  14. package/dist/{chunk-EV5HW4IC.js → chunk-M7E6LQO2.js} +66 -53
  15. package/dist/chunk-M7E6LQO2.js.map +1 -0
  16. package/dist/{chunk-6LCL2ZZF.js → chunk-TAH2GVTJ.js} +1 -1
  17. package/dist/chunk-TAH2GVTJ.js.map +1 -0
  18. package/dist/chunk-XOFF3UPL.js +399 -0
  19. package/dist/chunk-XOFF3UPL.js.map +1 -0
  20. package/dist/{client-5776a6bb.d.ts → client-2ba72e89.d.ts} +12 -15
  21. package/dist/connection-55cba970.d.ts +11 -0
  22. package/dist/{connection-bd35d442.d.ts → connection-c6db05d9.d.ts} +1 -5
  23. package/dist/{handshake-a947c234.d.ts → handshake-0b88e8fc.d.ts} +150 -184
  24. package/dist/logging/index.cjs.map +1 -1
  25. package/dist/logging/index.d.cts +1 -1
  26. package/dist/logging/index.d.ts +1 -1
  27. package/dist/logging/index.js +1 -1
  28. package/dist/{index-ea74cdbb.d.ts → message-e6c560fd.d.ts} +2 -2
  29. package/dist/router/index.cjs +105 -63
  30. package/dist/router/index.cjs.map +1 -1
  31. package/dist/router/index.d.cts +11 -10
  32. package/dist/router/index.d.ts +11 -10
  33. package/dist/router/index.js +2 -2
  34. package/dist/server-732e7014.d.ts +42 -0
  35. package/dist/{services-38b3f758.d.ts → services-adfd0bc3.d.ts} +3 -3
  36. package/dist/transport/impls/uds/client.cjs +1246 -1230
  37. package/dist/transport/impls/uds/client.cjs.map +1 -1
  38. package/dist/transport/impls/uds/client.d.cts +4 -4
  39. package/dist/transport/impls/uds/client.d.ts +4 -4
  40. package/dist/transport/impls/uds/client.js +7 -13
  41. package/dist/transport/impls/uds/client.js.map +1 -1
  42. package/dist/transport/impls/uds/server.cjs +1298 -1151
  43. package/dist/transport/impls/uds/server.cjs.map +1 -1
  44. package/dist/transport/impls/uds/server.d.cts +4 -4
  45. package/dist/transport/impls/uds/server.d.ts +4 -4
  46. package/dist/transport/impls/uds/server.js +6 -6
  47. package/dist/transport/impls/ws/client.cjs +976 -965
  48. package/dist/transport/impls/ws/client.cjs.map +1 -1
  49. package/dist/transport/impls/ws/client.d.cts +4 -4
  50. package/dist/transport/impls/ws/client.d.ts +4 -4
  51. package/dist/transport/impls/ws/client.js +6 -7
  52. package/dist/transport/impls/ws/client.js.map +1 -1
  53. package/dist/transport/impls/ws/server.cjs +1182 -1047
  54. package/dist/transport/impls/ws/server.cjs.map +1 -1
  55. package/dist/transport/impls/ws/server.d.cts +4 -4
  56. package/dist/transport/impls/ws/server.d.ts +4 -4
  57. package/dist/transport/impls/ws/server.js +6 -6
  58. package/dist/transport/index.cjs +1433 -1360
  59. package/dist/transport/index.cjs.map +1 -1
  60. package/dist/transport/index.d.cts +5 -5
  61. package/dist/transport/index.d.ts +5 -5
  62. package/dist/transport/index.js +9 -9
  63. package/dist/util/testHelpers.cjs +744 -310
  64. package/dist/util/testHelpers.cjs.map +1 -1
  65. package/dist/util/testHelpers.d.cts +9 -6
  66. package/dist/util/testHelpers.d.ts +9 -6
  67. package/dist/util/testHelpers.js +34 -10
  68. package/dist/util/testHelpers.js.map +1 -1
  69. package/package.json +1 -1
  70. package/dist/chunk-6LCL2ZZF.js.map +0 -1
  71. package/dist/chunk-7MJYOL32.js.map +0 -1
  72. package/dist/chunk-AVL32IMG.js.map +0 -1
  73. package/dist/chunk-DPKOJQWF.js +0 -476
  74. package/dist/chunk-DPKOJQWF.js.map +0 -1
  75. package/dist/chunk-EV5HW4IC.js.map +0 -1
  76. package/dist/chunk-J6N6H2WU.js +0 -476
  77. package/dist/chunk-J6N6H2WU.js.map +0 -1
  78. package/dist/chunk-MW5JXLHY.js +0 -348
  79. package/dist/chunk-MW5JXLHY.js.map +0 -1
  80. package/dist/chunk-R2HAS3GM.js.map +0 -1
  81. package/dist/chunk-RJOWZIWB.js +0 -335
  82. package/dist/chunk-RJOWZIWB.js.map +0 -1
  83. package/dist/connection-df85db7e.d.ts +0 -17
  84. package/dist/server-53cd5b7e.d.ts +0 -24
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # River
2
2
 
3
- ⚠️ Not production ready, while Replit is using parts of river in production, we are still going through rapid breaking changes. First production ready version will be 1.x.x ⚠️
3
+ ⚠️ Not production ready, while Replit is using parts of River in production, we are still going through rapid breaking changes. First production ready version will be `1.x.x` ⚠️
4
4
 
5
5
  River allows multiple clients to connect to and make remote procedure calls to a remote server as if they were local procedures.
6
6
 
@@ -157,15 +157,6 @@ if (result.ok) {
157
157
  }
158
158
  ```
159
159
 
160
- You can then access the `ParsedMetadata` in your procedure handlers:
161
-
162
- ```ts
163
- async handler(ctx, ...args) {
164
- // this contains the parsed metadata
165
- console.log(ctx.metadata)
166
- }
167
- ```
168
-
169
160
  ### Logging
170
161
 
171
162
  To add logging, you can bind a logging function to a transport.
@@ -192,12 +183,12 @@ River defines two types of reconnects:
192
183
  1. **Transparent reconnects:** These occur when the connection is temporarily lost and reestablished without losing any messages. From the application's perspective, this process is seamless and does not disrupt ongoing operations.
193
184
  2. **Hard reconnect:** This occurs when all server state is lost, requiring the client to reinitialize anything stateful (e.g. subscriptions).
194
185
 
195
- You can listen for transparent reconnects via the `connectionStatus` events, but realistically, no applications should need to listen for this unless it is for debugging purposes. Hard reconnects are signaled via `sessionStatus` events.
186
+ Hard reconnects are signaled via `sessionStatus` events.
196
187
 
197
188
  If your application is stateful on either the server or the client, the service consumer _should_ wrap all the client-side setup with `transport.addEventListener('sessionStatus', (evt) => ...)` to do appropriate setup and teardown.
198
189
 
199
190
  ```ts
200
- transport.addEventListener('connectionStatus', (evt) => {
191
+ transport.addEventListener('sessionStatus', (evt) => {
201
192
  if (evt.status === 'connect') {
202
193
  // do something
203
194
  } else if (evt.status === 'disconnect') {
@@ -205,11 +196,12 @@ transport.addEventListener('connectionStatus', (evt) => {
205
196
  }
206
197
  });
207
198
 
208
- transport.addEventListener('sessionStatus', (evt) => {
209
- if (evt.status === 'connect') {
199
+ // or, listen for specific session states
200
+ transport.addEventListener('sessionTransition', (evt) => {
201
+ if (evt.state === SessionState.Connected) {
202
+ // switch on various transition states
203
+ } else if (evt.state === SessionState.NoConnection) {
210
204
  // do something
211
- } else if (evt.status === 'disconnect') {
212
- // do something else
213
205
  }
214
206
  });
215
207
  ```
@@ -253,6 +245,15 @@ createServer(new MockServerTransport('SERVER'), services, {
253
245
  });
254
246
  ```
255
247
 
248
+ You can then access the `ParsedMetadata` in your procedure handlers:
249
+
250
+ ```ts
251
+ async handler(ctx, ...args) {
252
+ // this contains the parsed metadata
253
+ console.log(ctx.metadata)
254
+ }
255
+ ```
256
+
256
257
  ### Further examples
257
258
 
258
259
  We've also provided an end-to-end testing environment using `Next.js`, and a simple backend connected with the WebSocket transport that you can [play with on Replit](https://replit.com/@jzhao-replit/riverbed).