@rsc-kit/mcp 0.28.0 → 0.29.0
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/dist/index.js +31 -0
- package/dist/index.js.map +1 -1
- package/dist/recipes.js +63 -7
- package/dist/recipes.js.map +1 -1
- package/guides/deployment.md +2 -2
- package/guides/go.md +36 -5
- package/guides/index.json +5 -0
- package/guides/laravel.md +1 -1
- package/guides/live-data.md +885 -0
- package/guides/mcp.md +38 -0
- package/guides/sections.md +4 -607
- package/guides/testing.md +24 -0
- package/guides/where-it-runs.md +8 -0
- package/guides/your-own-backend.md +36 -10
- package/package.json +2 -1
package/guides/deployment.md
CHANGED
|
@@ -162,7 +162,7 @@ stacks on top of it.
|
|
|
162
162
|
|
|
163
163
|
## Streams and idle timeouts
|
|
164
164
|
|
|
165
|
-
An `events()` route and the [`refreshOn`](/guides/
|
|
165
|
+
An `events()` route and the [`refreshOn`](/guides/live-data)
|
|
166
166
|
stream hold a connection open and are quiet most of the time. Anything in
|
|
167
167
|
front that closes a quiet connection - the server's idle timeout, a proxy's
|
|
168
168
|
read timeout - would cut them, so each sends a keepalive line every **eight
|
|
@@ -189,7 +189,7 @@ one as another, so one leaking does not hand out the rest.
|
|
|
189
189
|
| Variable | What it protects | Who needs it | Read by |
|
|
190
190
|
| --- | --- | --- | --- |
|
|
191
191
|
| `RSC_HOST_CALL_SECRET` | calls between the renderer and a Go or Laravel backend | an app with a backend - required | the renderer **and** the backend |
|
|
192
|
-
| `RSC_SIGNING_SECRET` | the names a page hands a tab for [`refreshOn`](/guides/
|
|
192
|
+
| `RSC_SIGNING_SECRET` | the names a page hands a tab for [`refreshOn`](/guides/live-data) | an app that uses `refreshOn` - required in production | the renderer |
|
|
193
193
|
| `RSC_ACTION_ENCRYPTION_KEY` | values a server action sends through the browser, [across a deploy](#server-actions-across-a-deploy) | optional | the renderer, from the build |
|
|
194
194
|
|
|
195
195
|
`bun create rsc-kit` and `rsc-kit init` generate the first two into `.env` for
|
package/guides/go.md
CHANGED
|
@@ -272,21 +272,52 @@ reg.Changed(ctx, "team:"+teamID+":repos")
|
|
|
272
272
|
Every open tab showing the section refreshes it, the moment the webhook
|
|
273
273
|
lands, with nothing polling. The registry answers `__rsc.changed` by holding
|
|
274
274
|
the renderer's ask until a version moves - woken at once by a `Changed` in
|
|
275
|
-
this process, checking the store every `rsckit.
|
|
275
|
+
this process, checking the store every `rsckit.ChangedPoll` (1s) for one made
|
|
276
276
|
by another instance.
|
|
277
277
|
|
|
278
|
-
Versions live in a `
|
|
278
|
+
Versions live in a `VersionStore`. The default is in memory, which is one
|
|
279
279
|
instance; with more than one, a webhook lands on whichever instance the
|
|
280
280
|
balancer picked, so give them all the same store:
|
|
281
281
|
|
|
282
282
|
```go
|
|
283
|
-
// CREATE TABLE
|
|
284
|
-
reg.
|
|
283
|
+
// CREATE TABLE rsc_versions (name TEXT PRIMARY KEY, version BIGINT NOT NULL)
|
|
284
|
+
reg.Versions(&rsckit.SQLVersions{DB: db, Placeholder: rsckit.Dollar}) // Postgres; nil Placeholder is "?"
|
|
285
285
|
```
|
|
286
286
|
|
|
287
|
+
To hear another instance's change at once instead of within the second - and
|
|
288
|
+
stop reading the store while nothing changes - set `Notify` so each bump
|
|
289
|
+
sends a `pg_notify`, and run a listener with `WakeOn`. The adapter depends on
|
|
290
|
+
no driver, so the listener is yours; with pgx:
|
|
291
|
+
|
|
292
|
+
```go
|
|
293
|
+
reg.Versions(&rsckit.SQLVersions{DB: db, Placeholder: rsckit.Dollar, Notify: "rsc_versions"})
|
|
294
|
+
|
|
295
|
+
reg.WakeOn(ctx, func(ctx context.Context, connected, wake func()) error {
|
|
296
|
+
conn, err := pool.Acquire(ctx)
|
|
297
|
+
if err != nil {
|
|
298
|
+
return err
|
|
299
|
+
}
|
|
300
|
+
defer conn.Release()
|
|
301
|
+
if _, err := conn.Exec(ctx, "LISTEN rsc_versions"); err != nil {
|
|
302
|
+
return err
|
|
303
|
+
}
|
|
304
|
+
connected()
|
|
305
|
+
for {
|
|
306
|
+
if _, err := conn.Conn().WaitForNotification(ctx); err != nil {
|
|
307
|
+
return err
|
|
308
|
+
}
|
|
309
|
+
wake()
|
|
310
|
+
}
|
|
311
|
+
})
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
A listener that drops runs again with backoff, and the poll covers the gap.
|
|
315
|
+
Through PgBouncer in transaction mode, connect the listener straight to
|
|
316
|
+
Postgres. One instance needs none of this.
|
|
317
|
+
|
|
287
318
|
Anything with a `Bump` and a `Versions` fits. Set `RSC_SIGNING_SECRET` for the renderer, the same on every instance:
|
|
288
319
|
it signs the names a page hands the tab, and is not the host-call secret.
|
|
289
|
-
Generating and rotating both: [Secrets](/hosts/deployment#secrets). [Sections](/guides/
|
|
320
|
+
Generating and rotating both: [Secrets](/hosts/deployment#secrets). [Sections](/guides/live-data)
|
|
290
321
|
has the whole picture.
|
|
291
322
|
|
|
292
323
|
## Production
|
package/guides/index.json
CHANGED
|
@@ -124,6 +124,11 @@
|
|
|
124
124
|
"title": "Laravel",
|
|
125
125
|
"description": "React Server Components in front, a Laravel application behind them."
|
|
126
126
|
},
|
|
127
|
+
{
|
|
128
|
+
"slug": "live-data",
|
|
129
|
+
"title": "Live data",
|
|
130
|
+
"description": "Keep what a page shows current as the data changes - refreshOn, events, polling."
|
|
131
|
+
},
|
|
127
132
|
{
|
|
128
133
|
"slug": "mcp",
|
|
129
134
|
"title": "Working with an AI agent",
|
package/guides/laravel.md
CHANGED
|
@@ -368,7 +368,7 @@ that talks to its database.
|
|
|
368
368
|
**Keeping versions in a table** (`RSC_VERSIONS=database`) is for when you
|
|
369
369
|
want them in the database rather than the cache: pruned on a schedule with
|
|
370
370
|
`rsc:prune-versions`, or written by something outside Laravel - a Go service,
|
|
371
|
-
a worker in another language - through the [shared table](/guides/
|
|
371
|
+
a worker in another language - through the [shared table](/guides/live-data#the-table).
|
|
372
372
|
Laravel still answers the renderer from it; nothing else changes.
|
|
373
373
|
|
|
374
374
|
```sh
|