@rsc-kit/core 0.39.0 → 0.41.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/vite.js CHANGED
@@ -304,6 +304,12 @@ let hostFunctions = null;
304
304
  /** The backend's typed signatures, by function name, and the named types they refer to. */
305
305
  let hostTypes = {};
306
306
  let hostDefs = {};
307
+ /**
308
+ * The functions the backend can check without running: given `validate`, it
309
+ * runs the guards and the validation and stops there. Only these are ever
310
+ * sent a check - a backend that has never heard of one would run the call.
311
+ */
312
+ let hostValidates = [];
307
313
  /**
308
314
  * The manifest commands run in this process, by project and command.
309
315
  *
@@ -382,8 +388,58 @@ function envRouteConfig() {
382
388
  }
383
389
  /** The file a backend writes its action names into. */
384
390
  const HOST_FILE = "rsc-host.json";
385
- /** The "use server" module of the backend's action stubs, written beside the app. */
386
- const HOST_ACTIONS_MODULE = "server-actions.generated.ts";
391
+ /**
392
+ * The folder of "use server" modules of the backend's action stubs, in the
393
+ * source directory: one module per class, `server-actions/billing/invoices.ts`
394
+ * for `Billing/Invoices`. The build's own - it writes every file in it and
395
+ * removes the ones a backend no longer has.
396
+ */
397
+ const HOST_ACTIONS_DIR = "server-actions";
398
+ /** What every module the build writes there starts with - and what it removes by. */
399
+ const HOST_ACTIONS_HEADER = "// @generated — do not edit. Written by the RSC build from the host action map.";
400
+ const HOST_MODULE_PATH = /^[a-z0-9]+(?:-[a-z0-9]+)*(?:\/[a-z0-9]+(?:-[a-z0-9]+)*)*$/;
401
+ const JS_IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
402
+ // Fine as a property - orders.delete - and not as a function's name, so
403
+ // these are declared under another and exported under their own.
404
+ const JS_RESERVED = new Set(("break case catch class const continue debugger default delete do else enum export extends false finally for " +
405
+ "function if import in instanceof new null return super switch this throw true try typeof var void while with " +
406
+ "yield let static implements interface package private protected public await arguments eval").split(" "));
407
+ /**
408
+ * The action map, checked: a module path of lowercase words, and exports that
409
+ * are identifiers or `default`. The flat `{ jsName: target }` of before is
410
+ * named as such - read as modules it would write nothing and say nothing.
411
+ */
412
+ function checkHostActions(actions, from) {
413
+ const isMap = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
414
+ if (!isMap(actions))
415
+ throw new Error(`[rsc-kit] ${from}: "actions" must be an object of { module: { export: "Function.name" } }.`);
416
+ for (const [module, exports] of Object.entries(actions)) {
417
+ if (typeof exports === "string") {
418
+ throw new Error(`[rsc-kit] ${from} lists actions the old way ({ "${module}": "${exports}" }). Actions are one module per class now - ` +
419
+ `{ "orders": { "create": "Orders.create" } } - so update the backend's adapter and run its manifest command.`);
420
+ }
421
+ if (!HOST_MODULE_PATH.test(module)) {
422
+ throw new Error(`[rsc-kit] ${from}: "${module}" is not a module path - lowercase words joined by dashes, folders by slashes.`);
423
+ }
424
+ if (!isMap(exports))
425
+ throw new Error(`[rsc-kit] ${from}: actions["${module}"] must be an object of { export: "Function.name" }.`);
426
+ for (const [name, target] of Object.entries(exports)) {
427
+ if (!JS_IDENTIFIER.test(name))
428
+ throw new Error(`[rsc-kit] ${from}: "${name}" in "${module}" is not a name JavaScript can export.`);
429
+ if (typeof target !== "string")
430
+ throw new Error(`[rsc-kit] ${from}: actions["${module}"]["${name}"] must be a function name.`);
431
+ }
432
+ }
433
+ return actions;
434
+ }
435
+ /** The `.ts` files under a folder, at any depth. */
436
+ function tsFilesUnder(dir) {
437
+ if (!existsSync(dir))
438
+ return [];
439
+ return readdirSync(dir, { recursive: true, encoding: "utf-8" })
440
+ .filter((f) => f.endsWith(".ts"))
441
+ .map((f) => join(dir, f));
442
+ }
387
443
  function fileHostManifest(root) {
388
444
  const path = join(root, HOST_FILE);
389
445
  if (!existsSync(path)) {
@@ -391,7 +447,7 @@ function fileHostManifest(root) {
391
447
  throw new Error("[rsc-kit] rsc-host-actions.json is the old manifest. The backend now writes " +
392
448
  HOST_FILE + " - { actions, functions } - so update the adapter and run its manifest command.");
393
449
  }
394
- return { actions: {}, functions: null, types: {}, defs: {} };
450
+ return { actions: {}, functions: null, types: {}, defs: {}, validates: [] };
395
451
  }
396
452
  let parsed;
397
453
  try {
@@ -402,21 +458,23 @@ function fileHostManifest(root) {
402
458
  }
403
459
  // An empty list is an empty map: PHP's json_encode writes an empty array
404
460
  // as [] whatever it was declared as.
405
- const actions = Array.isArray(parsed?.actions) && parsed.actions.length === 0 ? {} : parsed?.actions ?? {};
406
- if (typeof actions !== "object" || actions === null || Array.isArray(actions)) {
407
- throw new Error(`[rsc-kit] ${HOST_FILE}: "actions" must be an object of { jsName: "Function.name" }.`);
408
- }
461
+ const actions = checkHostActions(Array.isArray(parsed?.actions) && parsed.actions.length === 0 ? {} : parsed?.actions ?? {}, HOST_FILE);
409
462
  const functions = parsed?.functions;
410
463
  if (functions !== undefined && (!Array.isArray(functions) || functions.some((n) => typeof n !== "string"))) {
411
464
  throw new Error(`[rsc-kit] ${HOST_FILE}: "functions" must be an array of names.`);
412
465
  }
413
466
  const isMap = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
467
+ const validates = parsed?.validates;
468
+ if (validates !== undefined && (!Array.isArray(validates) || validates.some((n) => typeof n !== "string"))) {
469
+ throw new Error(`[rsc-kit] ${HOST_FILE}: "validates" must be an array of function names.`);
470
+ }
414
471
  return {
415
472
  types: isMap(parsed?.types) ? parsed.types : {},
416
473
  defs: isMap(parsed?.defs) ? parsed.defs : {},
417
- actions: actions,
474
+ actions,
418
475
  // The reserved guard call is the engine's to make, not the app's.
419
476
  functions: functions ? functions.filter((n) => !n.startsWith("__rsc.")).sort() : null,
477
+ validates: validates ?? [],
420
478
  };
421
479
  }
422
480
  /**
@@ -759,7 +817,7 @@ function resolvePaths(options) {
759
817
  screenshots: foundAssets.screenshots.map((shot) => shot.href),
760
818
  };
761
819
  }
762
- loadHostManifest(options);
820
+ loadHostManifest(options, true);
763
821
  }
764
822
  /**
765
823
  * rsc-host.json as this process last read it, null when there was none. The
@@ -777,13 +835,26 @@ function hostFileOnDisk() {
777
835
  return null;
778
836
  }
779
837
  }
780
- function loadHostManifest(options) {
838
+ function loadHostManifest(options, before = false) {
781
839
  hostFileText = hostFileOnDisk();
782
- const manifest = fileHostManifest(projectRoot);
783
- hostActions = options.hostActions ?? manifest.actions;
840
+ let manifest;
841
+ try {
842
+ manifest = fileHostManifest(projectRoot);
843
+ }
844
+ catch (error) {
845
+ // Read as the plugin is made, before the backend's command has run: a
846
+ // file it is about to write over - the old shape, from before an
847
+ // upgrade - is not yet the backend's answer. The command's is, and is
848
+ // checked when it lands.
849
+ if (!before || !options.hostManifest)
850
+ throw error;
851
+ manifest = { actions: {}, functions: null, types: {}, defs: {}, validates: [] };
852
+ }
853
+ hostActions = options.hostActions ? checkHostActions(options.hostActions, "rscKit({ hostActions })") : manifest.actions;
784
854
  hostFunctions = manifest.functions;
785
855
  hostTypes = manifest.types;
786
856
  hostDefs = manifest.defs;
857
+ hostValidates = manifest.validates;
787
858
  }
788
859
  /** Run the backend's manifest command, once per process; see the option. */
789
860
  function runHostManifest(options, isBuild, again = false) {
@@ -1170,15 +1241,45 @@ function writeHostBindings(manifest) {
1170
1241
  // which typechecks a server and fails a prerender script.
1171
1242
  writeGenerated(join(typesDir, "rsc-engine.d.ts"), ENGINE_TYPES);
1172
1243
  warnIfTypesUnreachable();
1173
- const target = join(sourceDir, HOST_ACTIONS_MODULE);
1174
- // A host with no functions of its own leaves no file behind: kept, its
1175
- // stubs would go on naming targets the host has stopped answering for.
1176
- if (Object.keys(hostActions).length === 0) {
1177
- if (existsSync(target))
1178
- rmSync(target);
1179
- return;
1244
+ writeHostActions();
1245
+ }
1246
+ /**
1247
+ * One "use server" module per backend class, under server-actions/. A module
1248
+ * the backend no longer has is removed - kept, its stubs would go on naming
1249
+ * targets the host has stopped answering for - and so is the single module
1250
+ * the build wrote before. Only files the build wrote: anything else in the
1251
+ * folder is the app's, and is left alone or, in the way, named.
1252
+ */
1253
+ function writeHostActions() {
1254
+ const dir = join(sourceDir, HOST_ACTIONS_DIR);
1255
+ const wanted = new Map(Object.keys(hostActions).map((module) => [join(dir, module + ".ts"), module]));
1256
+ const ours = (file) => readFileSync(file, "utf-8").slice(0, 200).includes("@generated");
1257
+ const flat = join(sourceDir, "server-actions.generated.ts");
1258
+ if (existsSync(flat) && ours(flat))
1259
+ rmSync(flat);
1260
+ for (const file of tsFilesUnder(dir)) {
1261
+ if (wanted.has(file) || !ours(file))
1262
+ continue;
1263
+ rmSync(file);
1264
+ }
1265
+ for (const [file, module] of wanted) {
1266
+ if (existsSync(file) && !ours(file)) {
1267
+ throw new Error(`[rsc-kit] ${relative(projectRoot, file)} is the app's, and the backend's ${module} actions are written there. ` +
1268
+ `${HOST_ACTIONS_DIR}/ is the build's: move the file out of it.`);
1269
+ }
1270
+ mkdirSync(dirname(file), { recursive: true });
1271
+ writeGenerated(file, renderHostActions(module));
1272
+ }
1273
+ // Folders a removed module leaves empty, deepest first.
1274
+ if (existsSync(dir)) {
1275
+ const folders = readdirSync(dir, { recursive: true, encoding: "utf-8" })
1276
+ .map((f) => join(dir, f))
1277
+ .filter((f) => statSync(f).isDirectory())
1278
+ .sort((a, b) => b.length - a.length);
1279
+ for (const folder of [...folders, dir])
1280
+ if (readdirSync(folder).length === 0)
1281
+ rmSync(folder, { recursive: true });
1180
1282
  }
1181
- writeGenerated(target, renderHostActions());
1182
1283
  }
1183
1284
  /**
1184
1285
  * The generated engine bundle, as the type its callers expect.
@@ -2214,7 +2315,7 @@ async function prerenderAfterBundles(bundle, staticDir, assetsDir, knownActions
2214
2315
  // on who calls it runs there - Laravel's guards, Go's middleware - where
2215
2316
  // this build cannot see it. Counted, they made every backend action look
2216
2317
  // unguarded: "11 actions run no middleware" for an API that checks them all.
2217
- const bare = audited.filter((a) => !a.client && basename(a.file) !== HOST_ACTIONS_MODULE);
2318
+ const bare = audited.filter((a) => !a.client && !/(^|[\\/])server-actions[\\/]/.test(a.file));
2218
2319
  if (bare.length > 0) {
2219
2320
  const byFile = new Map();
2220
2321
  for (const a of bare)
@@ -2755,19 +2856,34 @@ const FORM_ARGS = `function formArgs(args: unknown[], schemas: (Record<string, a
2755
2856
  return [...args.slice(0, at), out]
2756
2857
  }
2757
2858
  `;
2758
- /** The "use server" module exposing each host function as a plain async call. */
2759
- function renderHostActions() {
2760
- const lines = [
2761
- '"use server";',
2762
- "// @generated — do not edit. Written by the RSC build from the host action map.",
2763
- "",
2764
- ];
2859
+ /**
2860
+ * One class's "use server" module: each host function a plain async call. An
2861
+ * __invoke is the default export, and a method JavaScript reserves the name
2862
+ * of - delete, new - is declared under another and exported under its own.
2863
+ */
2864
+ function renderHostActions(module) {
2865
+ const lines = [HOST_ACTIONS_HEADER, '"use server";', ""];
2866
+ const exportsOf = hostActions[module] ?? {};
2867
+ const taken = new Set(Object.keys(exportsOf));
2868
+ const renamed = [];
2765
2869
  // Type-only, so the module stays what "use server" allows: functions.
2766
2870
  lines.push('import type { Redirected } from "@rsc-kit/core/errors";');
2767
2871
  lines.push('import type { FormFields } from "@rsc-kit/core/form";', "");
2768
2872
  lines.push(FORM_ARGS);
2769
- for (const [name, target] of Object.entries(hostActions)) {
2873
+ for (const [exported, target] of Object.entries(exportsOf)) {
2770
2874
  const sig = hostTypes[target];
2875
+ // The default's own name is the module's - send-invite, sendInvite - so a
2876
+ // stack trace says which action it was.
2877
+ const own = exported === "default" ? module.split("/").pop().replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase()) : exported;
2878
+ const plain = exported !== "default" && !JS_RESERVED.has(exported);
2879
+ let name = own;
2880
+ if (!plain) {
2881
+ while (JS_RESERVED.has(name) || taken.has(name))
2882
+ name = "_" + name;
2883
+ taken.add(name);
2884
+ renamed.push(name + " as " + exported);
2885
+ }
2886
+ const declare = plain ? "export async function " : "async function ";
2771
2887
  // Typed where the backend described it: its own parameters, or the form
2772
2888
  // that posts to it, and what it returns. Untyped otherwise, as before.
2773
2889
  if (sig) {
@@ -2776,16 +2892,16 @@ function renderHostActions() {
2776
2892
  // with where the visitor is going. A type that said T let callers read
2777
2893
  // it as data.
2778
2894
  const result = "Promise<" + (sig.result ? tsOf(sig.result) : "void") + " | Redirected>";
2779
- lines.push("export async function " + name + "(" + tsParams(sig) + "): " + result + ";");
2895
+ lines.push(declare + name + "(" + tsParams(sig) + "): " + result + ";");
2780
2896
  // The form overload is last, which is the one `stub.bind(null, team)`
2781
2897
  // reads: bound, it is `(form: FormFields<…>) => …`, so a form's action
2782
2898
  // keeps the struct's field names. Leading parameters are the ones the
2783
2899
  // form does not fill; any after the struct are left to the backend.
2784
2900
  const at = formParam(sig);
2785
2901
  const leading = at > 0 ? sig.params.slice(0, at).map((p, i) => "arg" + (i + 1) + ": " + tsOf(p)) : [];
2786
- lines.push("export async function " + name + "(" + [...leading, "form: " + formType(sig)].join(", ") + "): " + result + ";");
2902
+ lines.push(declare + name + "(" + [...leading, "form: " + formType(sig)].join(", ") + "): " + result + ";");
2787
2903
  }
2788
- lines.push("export async function " + name + "(...args: unknown[]) {");
2904
+ lines.push(declare + name + "(...args: unknown[]) {");
2789
2905
  lines.push(" return await (globalThis as any)." +
2790
2906
  hostGlobal +
2791
2907
  "(" +
@@ -2796,6 +2912,8 @@ function renderHostActions() {
2796
2912
  lines.push("}");
2797
2913
  lines.push("");
2798
2914
  }
2915
+ if (renamed.length > 0)
2916
+ lines.push("export { " + renamed.join(", ") + " };", "");
2799
2917
  return lines.join("\n");
2800
2918
  }
2801
2919
  /** Ambient declaration for the host global, written beside the app's source. */
@@ -3785,11 +3903,11 @@ import { SlotBoundary } from ${JSON.stringify(join(packageDir, "js/SlotBoundary"
3785
3903
  import { RouteErrorBoundary } from ${JSON.stringify(join(packageDir, "js/RouteErrorBoundary"))}
3786
3904
  import __rsc_assets from 'virtual:vite-rsc/assets-manifest'
3787
3905
  ${
3788
- // The backend's actions, so defineBlueprint({ actions: { create: contactSend } }) can tell
3906
+ // The backend's actions, so defineBlueprint({ actions: { create: contact.send } }) can tell
3789
3907
  // which backend function a stub calls: the stub is the key, by identity.
3790
- Object.keys(hostActions).length > 0
3791
- ? `import * as __rsc_host_actions from ${JSON.stringify(join(sourceDir, HOST_ACTIONS_MODULE))}\n`
3792
- : ""}import { isSharedSection, sectionComponent } from ${JSON.stringify(join(packageDir, "js/section"))}
3908
+ Object.keys(hostActions)
3909
+ .map((module, i) => `import * as __rsc_host_actions_${i} from ${JSON.stringify(join(sourceDir, HOST_ACTIONS_DIR, module + ".ts"))}\n`)
3910
+ .join("")}import { isSharedSection, sectionComponent } from ${JSON.stringify(join(packageDir, "js/section"))}
3793
3911
  import { shareRender } from ${JSON.stringify(join(packageDir, "sharedRenders"))}
3794
3912
  import { PathnameProvider } from ${JSON.stringify(join(packageDir, "js/PathnameProvider"))}
3795
3913
  import { DefaultRouteError } from ${JSON.stringify(join(packageDir, "js/DefaultRouteError"))}
@@ -3811,6 +3929,7 @@ import { observeServed } from ${JSON.stringify(join(packageDir, "served"))}
3811
3929
  import { renderToReadableStream, decodeReply, decodeAction, decodeFormState, loadServerAction } from '@vitejs/plugin-rsc/rsc'
3812
3930
  import { isQuery, queryCacheControl, isQueryValidationError, queryRefusal } from ${JSON.stringify(join(packageDir, "query"))}
3813
3931
  import { isActionValidationError, isActionRefusal, isClientBuilt, turnedAwayStatus } from ${JSON.stringify(join(packageDir, "action"))}
3932
+ import { checkOf, checkOnly } from ${JSON.stringify(join(packageDir, "precognition"))}
3814
3933
  import { forgetCached } from ${JSON.stringify(join(packageDir, "cache"))}
3815
3934
  import { noteFallback as noteCaughtRead } from ${JSON.stringify(join(packageDir, "request"))}
3816
3935
  import { isOutdatedOptimizedDep, outdatedDepResponse } from ${JSON.stringify(join(packageDir, "devReload"))}
@@ -4193,9 +4312,15 @@ const HOST_GLOBAL = ${JSON.stringify(hostGlobal)}
4193
4312
  // which time this entry has run.
4194
4313
  ;(globalThis as Record<symbol, unknown>)[Symbol.for('rsc-kit.host-forms')] = {
4195
4314
  actions: new Map<unknown, string>(${Object.keys(hostActions).length > 0
4196
- ? `Object.entries(${JSON.stringify(hostActions)}).map(([name, target]) => [(__rsc_host_actions as Record<string, unknown>)[name], target])`
4315
+ ? "[" +
4316
+ Object.entries(hostActions)
4317
+ .flatMap(([, exports], i) => Object.entries(exports).map(([name, target]) => `[__rsc_host_actions_${i}[${JSON.stringify(name)}], ${JSON.stringify(target)}]`))
4318
+ .join(", ") +
4319
+ "]"
4197
4320
  : ""}),
4198
4321
  inputs: ${JSON.stringify(formInputs(hostTypes, hostDefs))},
4322
+ // Which of them the backend can check without running - see checkOnly().
4323
+ validates: new Set<string>(${JSON.stringify(hostValidates)}),
4199
4324
  }
4200
4325
 
4201
4326
  /**
@@ -5855,6 +5980,20 @@ export async function handleAction(
5855
5980
  const args = (await decodeReply(decodable)) as unknown[]
5856
5981
  const action = await loadServerAction(actionId)
5857
5982
 
5983
+ // A check, not a submit: <Form> asking whether the fields it names would
5984
+ // pass, before anyone presses the button. The action's guards and validation run; its body never does,
5985
+ // and nothing is revalidated, because nothing was written.
5986
+ //
5987
+ // The mark rides in the form's own data rather than a header beside it, so
5988
+ // nothing can deliver the call without it. A header set for the next call
5989
+ // is missed by a call React sends a tick later, and a check that arrived
5990
+ // unmarked would be a submit.
5991
+ const checking = checkOf(args)
5992
+
5993
+ if (checking) {
5994
+ return { stream: renderToReadableStream({ __rscChecked: await checkOnly(action, args, checking) }, { onError: flightOnError }) }
5995
+ }
5996
+
5858
5997
  // A query reached the ACTION endpoint, which means it was called directly
5859
5998
  // rather than through fetchQuery — so it went out as a POST and none of the
5860
5999
  // reasons it was marked a read apply to it. It still works, which is the
@@ -7783,16 +7922,16 @@ export const SERVER_ONLY = {
7783
7922
  "js/section": "section",
7784
7923
  "js/refreshOn": "section",
7785
7924
  host: "host",
7786
- hostCalls: "host-calls",
7925
+ hostCalls: "adapter/host-calls",
7787
7926
  commands: "commands",
7788
7927
  prerender: "prerender",
7789
7928
  export: "export",
7790
7929
  files: "files",
7791
- "build-rsc-vite": "build",
7792
- runtime: "runtime",
7930
+ "build-rsc-vite": "internal/build",
7931
+ runtime: "internal/runtime",
7793
7932
  embed: "embed",
7794
- typegen: "typegen",
7795
- conformance: "conformance",
7933
+ typegen: "internal/typegen",
7934
+ conformance: "adapter/conformance",
7796
7935
  testing: "testing",
7797
7936
  vite: "vite",
7798
7937
  };
@@ -8026,6 +8165,26 @@ export const SHUTDOWN_PLUGIN = `export default function rscKitShutdown() {
8026
8165
  process.once('SIGINT', stop)
8027
8166
  }
8028
8167
  `;
8168
+ /**
8169
+ * The Nitro rsc-kit is built against, and the oldest it runs on. Nitro 3
8170
+ * numbers its prereleases by date (3.0.YYMMDD-tag), and a semver peer range
8171
+ * cannot hold that: `>=3.0.261103-rc` refuses every later rc as a mismatch.
8172
+ */
8173
+ export const NITRO_VERSION = "3.0.261103-rc";
8174
+ /** What to say when an app's Nitro is older than NITRO_VERSION, or null. */
8175
+ export function nitroVersionProblem(version) {
8176
+ const day = (v) => /^3\.0\.(\d{6})(?:-|$)/.exec(v)?.[1];
8177
+ const found = version && day(version);
8178
+ // Plain 3.0.0 is not newer: it is an older release that npm sorts below the
8179
+ // dated ones, builds without complaint and answers 404 to every route (see
8180
+ // "Why nitro is pinned"). Only a 3.1 or a 4 would be past the dated ones.
8181
+ const later = /^(\d+)\.(\d+)\./.exec(version ?? "");
8182
+ const past = later !== null && (Number(later[1]) > 3 || (Number(later[1]) === 3 && Number(later[2]) >= 1));
8183
+ if (!version || past || (found && Number(found) >= Number(day(NITRO_VERSION))))
8184
+ return null;
8185
+ return (`[rsc-kit] nitro ${version} is older than ${NITRO_VERSION}, the version rsc-kit builds with. ` +
8186
+ `Set "nitro": "${NITRO_VERSION}" in package.json and install again.`);
8187
+ }
8029
8188
  /**
8030
8189
  * One dev-server restart at a time, and none lost.
8031
8190
  *
@@ -8198,10 +8357,14 @@ export function rscKit(options = {}) {
8198
8357
  ? { version: PACKAGE_VERSION, output: "export", dir: relative(projectRoot, exportPath) }
8199
8358
  : { version: PACKAGE_VERSION, output: "server", ...compileStep(projectRoot) };
8200
8359
  },
8360
+ /** Where the app's source is: forms/ and server-actions/ are under it. */
8361
+ sourceDir() {
8362
+ return sourceDir;
8363
+ },
8201
8364
  generatedFiles() {
8202
8365
  return [
8203
8366
  join(projectRoot, HOST_FILE),
8204
- join(sourceDir, HOST_ACTIONS_MODULE),
8367
+ ...tsFilesUnder(join(sourceDir, HOST_ACTIONS_DIR)),
8205
8368
  // The type declarations only: the folder also holds the build's
8206
8369
  // own output - the route table, its report, the server entries -
8207
8370
  // which nobody commits and --check has no business comparing.
@@ -8220,6 +8383,9 @@ export function rscKit(options = {}) {
8220
8383
  nitro: {
8221
8384
  name: "rsc-kit",
8222
8385
  setup(nitro) {
8386
+ const outdated = nitroVersionProblem(nitro.meta?.version);
8387
+ if (outdated)
8388
+ throw new Error(outdated);
8223
8389
  if (nitro.options.dev)
8224
8390
  return;
8225
8391
  nitroPreset = nitro.options.preset ?? null;
@@ -8235,8 +8401,9 @@ export function rscKit(options = {}) {
8235
8401
  // entry of the server bundle, it is written beside the server's
8236
8402
  // `_ssr/rsc.mjs` and shares its chunks - without importing the entry
8237
8403
  // that imports instrumentation.ts.
8238
- nitro.hooks.hook("rollup:before", (_nitro, config) => {
8239
- if (!buildCommands().some((command) => !command.instrumented))
8404
+ nitro.hooks.hook("build:config", (_nitro, built) => {
8405
+ const config = built.rollup ?? built.rolldown;
8406
+ if (!config || !buildCommands().some((command) => !command.instrumented))
8240
8407
  return;
8241
8408
  const file = join(nitro.options.buildDir, "vite", "services", "rsc", BARE_COMMANDS_ENVIRONMENT + ".js");
8242
8409
  const input = config.input;