@rsc-kit/core 0.30.26 → 0.30.28
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/action.d.ts +11 -0
- package/dist/action.js +20 -1
- package/dist/action.js.map +1 -1
- package/dist/edgeShells.d.ts +52 -0
- package/dist/edgeShells.js +98 -0
- package/dist/edgeShells.js.map +1 -0
- package/dist/headers.d.ts +17 -4
- package/dist/headers.js +17 -4
- package/dist/headers.js.map +1 -1
- package/dist/host.js +147 -84
- package/dist/host.js.map +1 -1
- package/dist/vite.js +32 -4
- package/dist/vite.js.map +1 -1
- package/package.json +1 -1
package/dist/vite.js
CHANGED
|
@@ -23,6 +23,7 @@ import rsc, { getPluginApi } from "@vitejs/plugin-rsc";
|
|
|
23
23
|
import { loadEnv, parseAst } from "vite";
|
|
24
24
|
import { stampDisplayNames } from "./stableNames.js";
|
|
25
25
|
import { REPORT_FILE, buildReport } from "./buildReport.js";
|
|
26
|
+
import { edgeShells, pprMarker } from "./edgeShells.js";
|
|
26
27
|
import { MANIFEST_PATH, manifestWarning, webManifest } from "./webManifest.js";
|
|
27
28
|
import { ASSET_BASE, allAppAssets, assetFile, appAssets, headTags, shareImageUrls, typeOf, } from "./appAssets.js";
|
|
28
29
|
import { reactCacheImports } from "./reactCache.js";
|
|
@@ -1764,6 +1765,7 @@ async function prerenderAfterBundles(bundle, staticDir, assetsDir, knownActions
|
|
|
1764
1765
|
const collected = [];
|
|
1765
1766
|
let refusal = null;
|
|
1766
1767
|
let results;
|
|
1768
|
+
const build = await engine.buildId?.();
|
|
1767
1769
|
try {
|
|
1768
1770
|
results = await prerender({
|
|
1769
1771
|
engine,
|
|
@@ -1774,7 +1776,7 @@ async function prerenderAfterBundles(bundle, staticDir, assetsDir, knownActions
|
|
|
1774
1776
|
// them, and replayed against a different bundle React finds the
|
|
1775
1777
|
// wrong name in every slot. Unstamped - which is what every build
|
|
1776
1778
|
// before this one wrote - the host cannot tell and resumes anyway.
|
|
1777
|
-
version:
|
|
1779
|
+
version: build,
|
|
1778
1780
|
serviceWorker: offline,
|
|
1779
1781
|
stylesheet: inlineStylesheets === false
|
|
1780
1782
|
? undefined
|
|
@@ -1972,6 +1974,8 @@ ${legend(counted)}
|
|
|
1972
1974
|
.filter((r) => existsSync(join(staticDir, pathKeyOf(r.url) + ".html")))
|
|
1973
1975
|
.map((r) => r.url),
|
|
1974
1976
|
results,
|
|
1977
|
+
shells: edgeShells(results, manifest.routes),
|
|
1978
|
+
build,
|
|
1975
1979
|
};
|
|
1976
1980
|
}
|
|
1977
1981
|
/**
|
|
@@ -3276,7 +3280,7 @@ import { prerenderedBeside } from ${JSON.stringify(join(packageDir, "files"))}
|
|
|
3276
3280
|
import { observeServed } from ${JSON.stringify(join(packageDir, "served"))}
|
|
3277
3281
|
import { renderToReadableStream, decodeReply, decodeAction, decodeFormState, loadServerAction } from '@vitejs/plugin-rsc/rsc'
|
|
3278
3282
|
import { isQuery, queryCacheControl, isQueryValidationError, queryRefusal } from ${JSON.stringify(join(packageDir, "query"))}
|
|
3279
|
-
import { isActionValidationError, isActionRefusal, isClientBuilt } from ${JSON.stringify(join(packageDir, "action"))}
|
|
3283
|
+
import { isActionValidationError, isActionRefusal, isClientBuilt, turnedAwayStatus } from ${JSON.stringify(join(packageDir, "action"))}
|
|
3280
3284
|
import { forgetCached } from ${JSON.stringify(join(packageDir, "cache"))}
|
|
3281
3285
|
import { noteFallback as noteCaughtRead } from ${JSON.stringify(join(packageDir, "request"))}
|
|
3282
3286
|
import { isOutdatedOptimizedDep, outdatedDepResponse } from ${JSON.stringify(join(packageDir, "devReload"))}
|
|
@@ -5281,7 +5285,8 @@ export async function handleAction(
|
|
|
5281
5285
|
// abort(429, ...), Rsc::refuse) it throws a refusal whose message was written
|
|
5282
5286
|
// for the person asking. Its message is the result's serverError, which is
|
|
5283
5287
|
// where a form's formError reads. Its data is not sent: there is no
|
|
5284
|
-
// .refusal(schema) on a plain function to check it against.
|
|
5288
|
+
// .refusal(schema) on a plain function to check it against. Turned away -
|
|
5289
|
+
// 401, 403, 404 - is answered the same way.
|
|
5285
5290
|
let result: unknown
|
|
5286
5291
|
|
|
5287
5292
|
try {
|
|
@@ -5301,6 +5306,12 @@ export async function handleAction(
|
|
|
5301
5306
|
// Marked for the same reason: a stub awaited directly rejects with the
|
|
5302
5307
|
// fields, so a caller does not take a refusal of its input for its result.
|
|
5303
5308
|
result = { validationErrors: error.errors, __rscRefused: 422 }
|
|
5309
|
+
} else if (turnedAwayStatus(error) !== null) {
|
|
5310
|
+
// Not signed in, not allowed, or no such record - Refuse(404), abort(403),
|
|
5311
|
+
// a notFound() of the action's own. Each message was written for the
|
|
5312
|
+
// person, and an action has no not-found page to show instead. Rethrown,
|
|
5313
|
+
// it was a 500 and "Something went wrong." on every action it reached.
|
|
5314
|
+
result = { serverError: (error as Error).message, __rscRefused: turnedAwayStatus(error) }
|
|
5304
5315
|
} else {
|
|
5305
5316
|
throw error
|
|
5306
5317
|
}
|
|
@@ -8066,7 +8077,7 @@ export function rscKit(options = {}) {
|
|
|
8066
8077
|
const staticDir = clientOut
|
|
8067
8078
|
? join(dirname(clientOut), "server", NITRO_STATIC_DIR)
|
|
8068
8079
|
: join(outDir, NITRO_STATIC_DIR);
|
|
8069
|
-
const { frozen, results } = await prerenderAfterBundles(bundle, staticDir, clientOut ?? publicAssetsDir, builder ? knownActionsOf(builder.config, projectRoot) : []);
|
|
8080
|
+
const { frozen, results, shells, build } = await prerenderAfterBundles(bundle, staticDir, clientOut ?? publicAssetsDir, builder ? knownActionsOf(builder.config, projectRoot) : []);
|
|
8070
8081
|
// The same pages once more, as a module. A Worker has no filesystem, and
|
|
8071
8082
|
// until this existed every Cloudflare deploy rendered its "static" pages
|
|
8072
8083
|
// live, silently - the reader found no directory and fell through. The
|
|
@@ -8102,6 +8113,9 @@ export function rscKit(options = {}) {
|
|
|
8102
8113
|
// after the prerender, and an export taken any earlier left them out.
|
|
8103
8114
|
if (output === "export")
|
|
8104
8115
|
await exportAfterPrerender(results, staticDir, clientOut ?? publicAssetsDir);
|
|
8116
|
+
if (shells.left.length) {
|
|
8117
|
+
log(`ppr: not listed for an edge in ppr.json, so served by the origin: ${shells.left.join("; ")}`);
|
|
8118
|
+
}
|
|
8105
8119
|
// What this build produced, where a deploy can read it without parsing
|
|
8106
8120
|
// vite.config.ts - which can turn export on through RSC_OUTPUT, or
|
|
8107
8121
|
// compute it - or knowing where rsc-kit keeps things inside .output.
|
|
@@ -8115,6 +8129,20 @@ export function rscKit(options = {}) {
|
|
|
8115
8129
|
...compileStep(projectRoot),
|
|
8116
8130
|
...(buildCommands().length ? { commands: buildCommands().map((c) => c.name) } : {}),
|
|
8117
8131
|
}, null, 2) + "\n");
|
|
8132
|
+
// The PPR contract's marker: the pages an edge may answer from a
|
|
8133
|
+
// cached shell, and the build both endpoints will say they belong to.
|
|
8134
|
+
// Written by every server build, with an empty list when there is no
|
|
8135
|
+
// PPR page, so a platform can tell "none" from "an rsc-kit too old to
|
|
8136
|
+
// say". Not by an export, which has no origin to resume against.
|
|
8137
|
+
const marker = join(dirname(clientOut), "ppr.json");
|
|
8138
|
+
if (output !== "export" && build) {
|
|
8139
|
+
writeFileSync(marker, JSON.stringify(pprMarker(build, shells.shells), null, 2) + "\n");
|
|
8140
|
+
}
|
|
8141
|
+
else {
|
|
8142
|
+
// One left by an earlier server build would promise an origin that
|
|
8143
|
+
// is not there.
|
|
8144
|
+
rmSync(marker, { force: true });
|
|
8145
|
+
}
|
|
8118
8146
|
}
|
|
8119
8147
|
},
|
|
8120
8148
|
configResolved(config) {
|