@rsc-kit/mcp 0.31.3 → 0.33.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/recipes.js +42 -4
- package/dist/recipes.js.map +1 -1
- package/guides/content-security-policy.md +48 -1
- package/guides/domains.md +9 -0
- package/guides/go.md +3 -1
- package/guides/installation.md +9 -0
- package/guides/laravel.md +26 -0
- package/guides/metadata.md +6 -0
- package/guides/routing.md +6 -0
- package/guides/seo-files.md +6 -0
- package/guides/your-own-backend.md +9 -0
- package/package.json +2 -2
|
@@ -77,7 +77,8 @@ The engine allows the inline code it writes. Inline code you write:
|
|
|
77
77
|
is hashed with everything else, and runs.
|
|
78
78
|
- **One inside a Suspense hole, or on a page rendered per request**, is
|
|
79
79
|
refused: React gives a nonce to the scripts it writes, not to the elements
|
|
80
|
-
you render
|
|
80
|
+
you render — unless you give it one, with
|
|
81
|
+
[`useNonce()`](#a-library-that-asks-for-a-nonce).
|
|
81
82
|
- **One brought by a navigation** is refused on every page: the browser
|
|
82
83
|
inserts it into a document whose policy was decided before it existed.
|
|
83
84
|
|
|
@@ -86,6 +87,52 @@ So write CSS in a stylesheet and code in a module, which `'self'` allows.
|
|
|
86
87
|
origin in `script-src`. If your app writes `<style>` tags, put
|
|
87
88
|
`'unsafe-inline'` in `style-src` and the engine will leave it alone.
|
|
88
89
|
|
|
90
|
+
### A library that asks for a nonce
|
|
91
|
+
|
|
92
|
+
Some libraries write inline code of their own and take a `nonce` for it:
|
|
93
|
+
next-themes' script that sets the theme before the page paints, and the
|
|
94
|
+
`<style>` its `disableTransitionOnChange` inserts on every theme change; an
|
|
95
|
+
analytics snippet; a CSS-in-JS runtime. `useNonce()` is the nonce to give
|
|
96
|
+
them:
|
|
97
|
+
|
|
98
|
+
```tsx title="app/Theme.tsx"
|
|
99
|
+
'use client';
|
|
100
|
+
|
|
101
|
+
import { ThemeProvider } from 'next-themes';
|
|
102
|
+
import { useNonce } from '@rsc-kit/core/useNonce';
|
|
103
|
+
import type { ReactNode } from 'react';
|
|
104
|
+
|
|
105
|
+
export function Theme({ children }: { children: ReactNode }) {
|
|
106
|
+
const nonce = useNonce();
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<ThemeProvider attribute="class" defaultTheme="system" enableSystem disableTransitionOnChange nonce={nonce}>
|
|
110
|
+
{children}
|
|
111
|
+
</ThemeProvider>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Render `<Theme>` from the root layout in place of the `ThemeProvider`. It is
|
|
117
|
+
a client hook because the nonce that counts is the document's: a navigation's
|
|
118
|
+
payload is rendered with a nonce of its own, which the page on screen has
|
|
119
|
+
never heard of, so a nonce read on the server and passed down as a prop would
|
|
120
|
+
be the wrong one after the first navigation. On the server it is the nonce
|
|
121
|
+
the response is written with; in the browser it is read back from the
|
|
122
|
+
document.
|
|
123
|
+
|
|
124
|
+
It is `undefined` on a page allowed by hash — a stored page, a shell's own
|
|
125
|
+
HTML, one a cache keeps — and that is fine for what is in the HTML: the
|
|
126
|
+
library's inline script is hashed with the rest of the page and runs without
|
|
127
|
+
one. What a library inserts after hydration on such a page has nothing to run
|
|
128
|
+
by unless the page has holes, whose nonce it then uses. On a stored page with
|
|
129
|
+
none, put `'unsafe-inline'` in `style-src` if the library inserts styles, or
|
|
130
|
+
leave the option off — next-themes works without `disableTransitionOnChange`.
|
|
131
|
+
|
|
132
|
+
The engine's own components use it too: `PageTransition`'s style is inserted
|
|
133
|
+
by React in the browser when it was not in the HTML, as in `vite dev`, and
|
|
134
|
+
carries the nonce.
|
|
135
|
+
|
|
89
136
|
`style-src-attr 'unsafe-inline'` is in the default because React's
|
|
90
137
|
`style={{ ... }}` is a style attribute, which no hash or nonce can allow. An
|
|
91
138
|
attribute cannot run code. Leave it out and every `style` prop is refused.
|
package/guides/domains.md
CHANGED
|
@@ -46,6 +46,15 @@ it is in Next. An app with a `metadataBase` and no tenant tree routes every
|
|
|
46
46
|
host by path, and a proxy that forwards to the app by an internal name is not
|
|
47
47
|
read as a tenant called `internal`.
|
|
48
48
|
|
|
49
|
+
A subdomain of the site with no directory of its name falls back the same
|
|
50
|
+
way: with no `app/merchant/`, `merchant.example.com/` serves the home page.
|
|
51
|
+
That keeps a preview deployment under the production domain working. The dev
|
|
52
|
+
server says so once per host, naming the directory to add:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
[rsc-kit] merchant.example.test has no app/merchant/ - served by path, as the site's own. Add app/merchant/ to route the subdomain there.
|
|
56
|
+
```
|
|
57
|
+
|
|
49
58
|
The visitor's url is untouched: `acme.example.com/settings` stays in the
|
|
50
59
|
address bar, and a link to `/billing` on that page goes to
|
|
51
60
|
`acme.example.com/billing`. Only the match changed.
|
package/guides/go.md
CHANGED
|
@@ -216,7 +216,9 @@ Caused in the backend by Backend panic(runtime.boundsError): …
|
|
|
216
216
|
at backend/main.go:64 main.main.func3
|
|
217
217
|
```
|
|
218
218
|
|
|
219
|
-
|
|
219
|
+
A server action that fails this way opens Vite's error overlay on the page in
|
|
220
|
+
development, with the same type and frames; frames from the module cache are
|
|
221
|
+
counted rather than listed. Never in production: a trace names your files.
|
|
220
222
|
|
|
221
223
|
### Refusing
|
|
222
224
|
|
package/guides/installation.md
CHANGED
|
@@ -51,6 +51,15 @@ adds Tailwind, and when `components.json` is already there it asks only
|
|
|
51
51
|
whether to set the flag. Running `shadcn init` yourself
|
|
52
52
|
leaves it `false`; set it to `true` by hand.
|
|
53
53
|
|
|
54
|
+
shadcn writes its theme, the colours and the dark variant, to the stylesheet
|
|
55
|
+
`components.json` names, and `shadcn add` keeps writing there. That file must
|
|
56
|
+
be one the app loads: the root layout's `styles.css`, or a file it imports. In
|
|
57
|
+
a Laravel app, `init` makes `styles.css` import `resources/css/app.css` when
|
|
58
|
+
that file already imports Tailwind, so the theme there, and the one shadcn's
|
|
59
|
+
own `init` writes there, reaches the pages. A `components.json` that names a
|
|
60
|
+
file the app never loads is reported; Blade's `@vite` loaded it before, and
|
|
61
|
+
nothing does now.
|
|
62
|
+
|
|
54
63
|
Use `--yes`, not `-y`, with `bun create`: Bun reads `-y` as its own flag and
|
|
55
64
|
refuses it. `bunx create-rsc-kit my-app -y` accepts either.
|
|
56
65
|
|
package/guides/laravel.md
CHANGED
|
@@ -41,6 +41,20 @@ php artisan rsc:install
|
|
|
41
41
|
JavaScript half. Nothing you already have is overwritten: where a file exists,
|
|
42
42
|
the exact edit is printed for you to make instead.
|
|
43
43
|
|
|
44
|
+
In a terminal, `init` asks the questions that are the app's to answer:
|
|
45
|
+
|
|
46
|
+
- the React Compiler;
|
|
47
|
+
- Tailwind CSS, unless it is already there;
|
|
48
|
+
- shadcn/ui, when Tailwind is there;
|
|
49
|
+
- oxlint, unless oxlint or ESLint already is.
|
|
50
|
+
|
|
51
|
+
It asks nothing about validation or typed environment variables, because
|
|
52
|
+
Laravel already does both: a FormRequest validates, and `.env` holds the
|
|
53
|
+
settings. `composer require` can't ask anything itself, since Composer never
|
|
54
|
+
runs a package's own scripts, so `rsc:install` is where the questions are
|
|
55
|
+
asked. Run without a terminal, as in CI, it takes the defaults and adds no
|
|
56
|
+
linter.
|
|
57
|
+
|
|
44
58
|
What lands:
|
|
45
59
|
|
|
46
60
|
| | |
|
|
@@ -115,6 +129,12 @@ Part of starting Vite rather than a step to remember: a stale manifest names a
|
|
|
115
129
|
method that has since been renamed, and nothing fails until the browser calls
|
|
116
130
|
it.
|
|
117
131
|
|
|
132
|
+
It is rewritten every time, so it is not committed: `init`, and
|
|
133
|
+
`create-rsc-kit` for an app with a backend, add `rsc-host.json` to
|
|
134
|
+
`.gitignore` beside the generated stubs. A CI step that
|
|
135
|
+
type-checks before building runs `php artisan rsc:host-manifest` first, or
|
|
136
|
+
`rpc()` has no names to check against.
|
|
137
|
+
|
|
118
138
|
If you had customised `dev` or `build` yourself, `init` leaves them alone and
|
|
119
139
|
puts the renderer's at `rsc:dev` and `rsc:build`, and says so.
|
|
120
140
|
|
|
@@ -288,6 +308,12 @@ class, message and trace, and the renderer shows them under its own stack as
|
|
|
288
308
|
the error's cause - so a failed `rpc()` in development points at the line of
|
|
289
309
|
PHP that threw.
|
|
290
310
|
|
|
311
|
+
A server action that fails the same way opens Vite's error overlay on the page,
|
|
312
|
+
in development only. It leads with the exception's class and message, then names the
|
|
313
|
+
first frame in your own code, such as `app/Rsc/Actions/Notification.php:20`.
|
|
314
|
+
Laravel's own frames are counted rather than listed. In production the page
|
|
315
|
+
gets a bare 500 and the trace stays in Laravel's log.
|
|
316
|
+
|
|
291
317
|
## Server actions
|
|
292
318
|
|
|
293
319
|
A class under `app/Rsc/Actions/` is a server action. `rsc:host-manifest`
|
package/guides/metadata.md
CHANGED
|
@@ -371,6 +371,12 @@ with something you put in `public/` yourself. The favicon is the exception —
|
|
|
371
371
|
it is served at `/favicon.ico`, because browsers ask for that url whatever the
|
|
372
372
|
markup says.
|
|
373
373
|
|
|
374
|
+
A `public/favicon.ico` is answered at that url before the request reaches the
|
|
375
|
+
app, so it hides yours. Laravel's skeleton ships an empty one, which Herd
|
|
376
|
+
answers with a 404 — the console says the favicon is not found on an app that
|
|
377
|
+
has one. Dev start and the build warn when `public/` holds a file at a url the
|
|
378
|
+
app serves, and name both; delete the one in `public/`.
|
|
379
|
+
|
|
374
380
|
:::note[Set `metadataBase`]
|
|
375
381
|
The image is emitted as `/_app/opengraph-image.png`, which a scraper will not
|
|
376
382
|
fetch. With `metadataBase` on the root layout it goes out absolute — see [the
|
package/guides/routing.md
CHANGED
|
@@ -68,6 +68,12 @@ visitor. `searchParams` works the same way.
|
|
|
68
68
|
Parenthesised directories like `(marketing)` group files without adding a URL
|
|
69
69
|
segment. `app/(marketing)/pricing/page.tsx` serves `GET /pricing`.
|
|
70
70
|
|
|
71
|
+
Since a group adds nothing to the URL, two groups can put a page at the same
|
|
72
|
+
URL: `app/(home)/page.tsx` and `app/(preview)/(home)/page.tsx` are both `/`.
|
|
73
|
+
That stops the dev server and the build with an error naming both files, so
|
|
74
|
+
one of them can't silently go unreachable. Give one a directory that is part
|
|
75
|
+
of the URL, like `app/(preview)/home/page.tsx`.
|
|
76
|
+
|
|
71
77
|
## Fetching data
|
|
72
78
|
|
|
73
79
|
A server component runs on the server, so it reads its data the way any
|
package/guides/seo-files.md
CHANGED
|
@@ -131,6 +131,12 @@ A hand-written file beside the root layout is served at the root as it is:
|
|
|
131
131
|
copies them beside the client output. A file and a function for the same url
|
|
132
132
|
is a build error naming both.
|
|
133
133
|
|
|
134
|
+
A file of the same name in `public/` wins over both: whatever serves
|
|
135
|
+
`public/` — Herd, nginx in front of Laravel, the server's static handler —
|
|
136
|
+
answers before the app is reached. Laravel's skeleton ships a
|
|
137
|
+
`public/robots.txt`, so a `robots.ts` beside the root layout is never seen
|
|
138
|
+
until it is deleted. Dev start and the build warn, naming both files.
|
|
139
|
+
|
|
134
140
|
## Coming from Next
|
|
135
141
|
|
|
136
142
|
`app/robots.ts` and `app/sitemap.ts` carry across unchanged. `app/llms.txt`
|
|
@@ -166,6 +166,11 @@ development - Laravel's `app.debug`, Go's `CallbackHandler.Debug` - never in
|
|
|
166
166
|
production, where it would name your files to whoever caused the error, and
|
|
167
167
|
never with a refusal, which is an answer and not a bug.
|
|
168
168
|
|
|
169
|
+
In development, a server action that fails this way opens Vite's error overlay
|
|
170
|
+
in the browser: the `type` and `message` as its heading, the first frame not under
|
|
171
|
+
`vendor/`, `node_modules/` or `pkg/mod/` as its file, and the rest beneath. A
|
|
172
|
+
frame is easiest to read as `path:line` followed by what was running there.
|
|
173
|
+
|
|
169
174
|
## Batches
|
|
170
175
|
|
|
171
176
|
Calls issued in the same tick of a render — sibling components each awaiting
|
|
@@ -510,6 +515,10 @@ It checks the whole contract on this page:
|
|
|
510
515
|
- **purges** - a change posted to `RSC_PURGE_URL` as its tag, as JSON,
|
|
511
516
|
only once the version has moved. Without `--purge-port` these fail: every
|
|
512
517
|
adapter purges.
|
|
518
|
+
- **debug** - with `--debug`, for an adapter started with its debug on, a
|
|
519
|
+
failure carrying `debug` with a type, a message and at least one frame.
|
|
520
|
+
Without the flag it is not checked: a backend sends a trace only in
|
|
521
|
+
development.
|
|
513
522
|
|
|
514
523
|
It exits non-zero on any failure, so it can gate your CI. The Go adapter's
|
|
515
524
|
`cmd/conformance` and Laravel's `tests/Conformance` are working fixtures to
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsc-kit/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"description": "An MCP server over what an rsc-kit build decided: the routes, why each one is static or not, and what it costs the browser.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
37
|
-
"create-rsc-kit": "^0.
|
|
37
|
+
"create-rsc-kit": "^0.33.0",
|
|
38
38
|
"zod": "^3.25"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|