@rsc-kit/mcp 0.42.1 → 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
CHANGED
|
@@ -1794,7 +1794,12 @@ Full guide: read_guide({ slug: 'response-headers' }).`,
|
|
|
1794
1794
|
body: `\`\`\`ts title="vite.config.ts"
|
|
1795
1795
|
rscKit({ contentSecurityPolicy: {} }) // strict default
|
|
1796
1796
|
rscKit({
|
|
1797
|
-
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
|
|
1798
1803
|
directives: { 'default-src': ["'self'"], 'img-src': ["'self'", 'data:'], 'frame-ancestors': ["'none'"] },
|
|
1799
1804
|
reportOnly: false, // true: Content-Security-Policy-Report-Only
|
|
1800
1805
|
},
|
|
@@ -1802,9 +1807,16 @@ rscKit({
|
|
|
1802
1807
|
\`\`\`
|
|
1803
1808
|
|
|
1804
1809
|
{} is: default-src 'self'; base-uri 'self'; object-src 'none'; style-src-attr
|
|
1805
|
-
'unsafe-inline'.
|
|
1806
|
-
|
|
1807
|
-
|
|
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:
|
|
1808
1820
|
|
|
1809
1821
|
- stored at build, or kept by revalidate: the hash of each inline script and
|
|
1810
1822
|
style; no nonce, so caches still share it
|
|
@@ -1889,7 +1901,25 @@ without a restart). rsc-host.json is rewritten every dev start and build, so it
|
|
|
1889
1901
|
is gitignored (init and create-rsc-kit add it); a CI typecheck before the build writes it first
|
|
1890
1902
|
(php artisan rsc:host-manifest). Committed rsc-host.json/types anyway? CI:
|
|
1891
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.
|
|
1892
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").
|
|
1893
1923
|
Go TYPED functions - prefer these: reg.Handle("Orders.recent", func(ctx context.Context, limit int) ([]Order, error) {...})
|
|
1894
1924
|
and reg.HandleAction(jsName, name, fn). Any positional params (structs, slices,
|
|
1895
1925
|
maps...), a trailing pointer is optional, variadic takes the rest. Their types
|