@rsc-kit/core 0.30.0 → 0.30.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.
- package/dist/host.js +28 -0
- package/dist/host.js.map +1 -1
- package/dist/js/Form.d.ts +16 -5
- package/dist/js/Form.js +1 -1
- package/dist/js/Form.js.map +1 -1
- package/dist/testing.d.ts +16 -0
- package/dist/testing.js +30 -1
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/dist/host.js
CHANGED
|
@@ -134,6 +134,21 @@ function redirectResponse(to, isPayloadRequest) {
|
|
|
134
134
|
*/
|
|
135
135
|
const LATE_NOINDEX = '<meta name="robots" content="noindex">' +
|
|
136
136
|
"<script>document.head.appendChild(document.currentScript.previousSibling)</script>";
|
|
137
|
+
/**
|
|
138
|
+
* What a browser fetches as part of a page, by the request's own
|
|
139
|
+
* Sec-Fetch-Dest. A page can never be the answer to one. Not `empty` (a
|
|
140
|
+
* fetch(), which may want a page's HTML), not `document` or a frame, and not
|
|
141
|
+
* a request that does not say: those are answered as they always were.
|
|
142
|
+
*/
|
|
143
|
+
const SUBRESOURCE = new Set([
|
|
144
|
+
"image", "script", "style", "font", "audio", "video", "track", "manifest",
|
|
145
|
+
"object", "embed", "worker", "sharedworker", "serviceworker",
|
|
146
|
+
"audioworklet", "paintworklet", "xslt",
|
|
147
|
+
]);
|
|
148
|
+
function forSubresource(request) {
|
|
149
|
+
const dest = request.headers.get("sec-fetch-dest");
|
|
150
|
+
return dest !== null && SUBRESOURCE.has(dest);
|
|
151
|
+
}
|
|
137
152
|
/**
|
|
138
153
|
* Append the redirect a render asked for after its shell had already gone out.
|
|
139
154
|
*
|
|
@@ -792,6 +807,19 @@ export function createRscHandler(options) {
|
|
|
792
807
|
const formPost = posted;
|
|
793
808
|
if (!formPost && request.method !== "GET" && request.method !== "HEAD")
|
|
794
809
|
return null;
|
|
810
|
+
// An image, a script, a stylesheet - a browser's /favicon.ico - is never
|
|
811
|
+
// answered by a page. A dynamic route claims nearly every path, so a
|
|
812
|
+
// missing asset under /[team] ran the team's middleware, its backend
|
|
813
|
+
// calls and every layout, to stream a not-found page into an <img>.
|
|
814
|
+
// Decided by what the request says it is for, never by the url's
|
|
815
|
+
// extension: a page may live at /docs/v1.2. A route.ts, above, still
|
|
816
|
+
// answers such a request - an image endpoint is a route, not a page.
|
|
817
|
+
if (forSubresource(request) && matchPage(routes, url)) {
|
|
818
|
+
return new Response("Not found", {
|
|
819
|
+
status: 404,
|
|
820
|
+
headers: { "Content-Type": "text/plain; charset=utf-8", "Cache-Control": "no-store" },
|
|
821
|
+
});
|
|
822
|
+
}
|
|
795
823
|
// A client saying which build it runs, and it is not this one: its
|
|
796
824
|
// manifest cannot load what this build's payload names - a client
|
|
797
825
|
// component added since is "client reference not found" and the route's
|