@rsc-kit/mcp 0.42.0 → 0.43.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 +40 -4
- package/dist/recipes.js.map +1 -1
- package/guides/backend-answered-pages.md +81 -0
- package/guides/connection.md +2 -0
- package/guides/content-security-policy.md +41 -9
- package/guides/ppr.md +4 -2
- package/guides/pwa.md +21 -0
- package/guides/static-generation.md +4 -2
- package/package.json +2 -2
package/dist/recipes.js
CHANGED
|
@@ -1305,6 +1305,12 @@ css, fonts, manifest, icons, / and /offline with their boot payloads; images,
|
|
|
1305
1305
|
wasm and the share card are cached on first use. A frozen page never visited
|
|
1306
1306
|
falls back to /offline like any other navigation. Do not add a second service
|
|
1307
1307
|
worker or a precache list; app/sw.js is importScripts'd into this one.
|
|
1308
|
+
MOVING DOMAIN (www -> bare, old -> new): redirect everything on the old
|
|
1309
|
+
origin EXCEPT /sw.js, which the app keeps serving there for a few weeks. A
|
|
1310
|
+
browser never updates a worker whose script redirects, so without the
|
|
1311
|
+
exception a returning visitor's worker serves the old origin's stored pages
|
|
1312
|
+
and the offline page instead of the redirect. From 0.42.1 the worker also
|
|
1313
|
+
leaves on its own when a request fails because its url now redirects.
|
|
1308
1314
|
|
|
1309
1315
|
An action that redirect()s RESOLVES with { redirected: '/where' } on the
|
|
1310
1316
|
client once the navigation starts - it does not throw, so a plain
|
|
@@ -1788,7 +1794,12 @@ Full guide: read_guide({ slug: 'response-headers' }).`,
|
|
|
1788
1794
|
body: `\`\`\`ts title="vite.config.ts"
|
|
1789
1795
|
rscKit({ contentSecurityPolicy: {} }) // strict default
|
|
1790
1796
|
rscKit({
|
|
1791
|
-
contentSecurityPolicy: {
|
|
1797
|
+
contentSecurityPolicy: { // the default, plus Turnstile
|
|
1798
|
+
extend: { 'script-src': 'https://challenges.cloudflare.com', 'frame-src': 'https://challenges.cloudflare.com' },
|
|
1799
|
+
},
|
|
1800
|
+
})
|
|
1801
|
+
rscKit({
|
|
1802
|
+
contentSecurityPolicy: { // the whole policy, replacing the default
|
|
1792
1803
|
directives: { 'default-src': ["'self'"], 'img-src': ["'self'", 'data:'], 'frame-ancestors': ["'none'"] },
|
|
1793
1804
|
reportOnly: false, // true: Content-Security-Policy-Report-Only
|
|
1794
1805
|
},
|
|
@@ -1796,9 +1807,16 @@ rscKit({
|
|
|
1796
1807
|
\`\`\`
|
|
1797
1808
|
|
|
1798
1809
|
{} is: default-src 'self'; base-uri 'self'; object-src 'none'; style-src-attr
|
|
1799
|
-
'unsafe-inline'.
|
|
1800
|
-
|
|
1801
|
-
|
|
1810
|
+
'unsafe-inline'. To allow one more origin use \`extend\`, never a retyped
|
|
1811
|
+
default: it ADDS to the default, and a directive the default does not name
|
|
1812
|
+
starts from its fallback (script-src, frame-src from default-src 'self'), so
|
|
1813
|
+
'self' is kept - do not write it. frame-ancestors and form-action fall back to
|
|
1814
|
+
nothing and are only what you write. A source added to a 'none' directive
|
|
1815
|
+
replaces the 'none'; extend cannot close one ('frame-src': "'none'" fails the
|
|
1816
|
+
build). extend and directives together fail the build. The engine adds a
|
|
1817
|
+
script-src and style-src naming the page's OWN inline code - the boot script,
|
|
1818
|
+
React's streaming scripts - so the policy needs no 'unsafe-inline'. How, by
|
|
1819
|
+
page:
|
|
1802
1820
|
|
|
1803
1821
|
- stored at build, or kept by revalidate: the hash of each inline script and
|
|
1804
1822
|
style; no nonce, so caches still share it
|
|
@@ -1883,7 +1901,25 @@ without a restart). rsc-host.json is rewritten every dev start and build, so it
|
|
|
1883
1901
|
is gitignored (init and create-rsc-kit add it); a CI typecheck before the build writes it first
|
|
1884
1902
|
(php artisan rsc:host-manifest). Committed rsc-host.json/types anyway? CI:
|
|
1885
1903
|
rsc-kit-typegen --check fails when they are stale.
|
|
1904
|
+
An optional "sources" ({ "Orders.recent": { file, line, name } }, file relative to
|
|
1905
|
+
the manifest) makes go-to-definition on the word rpc open the backend's function;
|
|
1906
|
+
the string is not a link. Needs the function in "types". It restarts nothing and is
|
|
1907
|
+
never stale, so do not strip it.
|
|
1886
1908
|
(Go: reg.WriteManifest(path); Laravel: php artisan rsc:host-manifest).
|
|
1909
|
+
|
|
1910
|
+
rpc() at build: with hostManifest, the build ASKS THE BACKEND and stores what is
|
|
1911
|
+
the same for everyone; there is no attribute to add. A function that reads the
|
|
1912
|
+
visitor (session, cookie, header, auth, address) or answers 401/403 is noticed
|
|
1913
|
+
and streams per request, so it needs a <Suspense> above it as before. A stored
|
|
1914
|
+
answer lasts until the next build - no tag, Rsc::changed or cache() refreshes it:
|
|
1915
|
+
await connection() before the call asks per request, export const revalidate = 60
|
|
1916
|
+
keeps it for a time. The build then needs the backend's database; a function that
|
|
1917
|
+
throws fails the build; a function that writes, called from a render, writes at
|
|
1918
|
+
build. Not noticed: raw $_COOKIE, state kept outside the framework (Go: outside
|
|
1919
|
+
ctx) - await connection() there. No database in CI: hostManifest: { calls: false }.
|
|
1920
|
+
Laravel answers by itself. Go: reg.BuildCalls("-calls") and, when that flag is
|
|
1921
|
+
given, reg.ServeCalls(os.Stdin, os.Stdout) before the -manifest branch; a context
|
|
1922
|
+
key that is not the visitor's: rsckit.NotTheVisitor("main.requestIDKey").
|
|
1887
1923
|
Go TYPED functions - prefer these: reg.Handle("Orders.recent", func(ctx context.Context, limit int) ([]Order, error) {...})
|
|
1888
1924
|
and reg.HandleAction(jsName, name, fn). Any positional params (structs, slices,
|
|
1889
1925
|
maps...), a trailing pointer is optional, variadic takes the rest. Their types
|