@react-router/dev 0.0.0-experimental-aecfb0db1 → 0.0.0-experimental-5bbc45fb6

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/cli/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * @react-router/dev v0.0.0-experimental-aecfb0db1
3
+ * @react-router/dev v0.0.0-experimental-5bbc45fb6
4
4
  *
5
5
  * Copyright (c) Remix Software Inc.
6
6
  *
@@ -357,7 +357,7 @@ async function resolveConfig({
357
357
  );
358
358
  let {
359
359
  appDirectory: userAppDirectory,
360
- basename: basename2,
360
+ basename: basename3,
361
361
  buildDirectory: userBuildDirectory,
362
362
  buildEnd,
363
363
  prerender,
@@ -472,7 +472,7 @@ async function resolveConfig({
472
472
  };
473
473
  let reactRouterConfig = deepFreeze({
474
474
  appDirectory,
475
- basename: basename2,
475
+ basename: basename3,
476
476
  buildDirectory,
477
477
  buildEnd,
478
478
  future,
@@ -535,11 +535,11 @@ async function createConfigLoader({
535
535
  fsWatcher = import_chokidar.default.watch([root, appDirectory], {
536
536
  ignoreInitial: true,
537
537
  ignored: (path8) => {
538
- let dirname6 = import_pathe3.default.dirname(path8);
539
- return !dirname6.startsWith(appDirectory) && // Ensure we're only watching files outside of the app directory
538
+ let dirname5 = import_pathe3.default.dirname(path8);
539
+ return !dirname5.startsWith(appDirectory) && // Ensure we're only watching files outside of the app directory
540
540
  // that are at the root level, not nested in subdirectories
541
541
  path8 !== root && // Watch the root directory itself
542
- dirname6 !== root;
542
+ dirname5 !== root;
543
543
  }
544
544
  });
545
545
  fsWatcher.on("all", async (...args) => {
@@ -634,15 +634,15 @@ function omitRoutes(config) {
634
634
  routes: {}
635
635
  };
636
636
  }
637
- function isEntryFile(entryBasename, filename3) {
638
- return entryExts.some((ext) => filename3 === `${entryBasename}${ext}`);
637
+ function isEntryFile(entryBasename, filename2) {
638
+ return entryExts.some((ext) => filename2 === `${entryBasename}${ext}`);
639
639
  }
640
- function findEntry(dir, basename2, options) {
640
+ function findEntry(dir, basename3, options) {
641
641
  let currentDir = import_pathe3.default.resolve(dir);
642
642
  let { root } = import_pathe3.default.parse(currentDir);
643
643
  while (true) {
644
644
  for (let ext of options?.extensions ?? entryExts) {
645
- let file = import_pathe3.default.resolve(currentDir, basename2 + ext);
645
+ let file = import_pathe3.default.resolve(currentDir, basename3 + ext);
646
646
  if (import_node_fs.default.existsSync(file)) {
647
647
  return options?.absolute ?? false ? file : import_pathe3.default.relative(dir, file);
648
648
  }
@@ -780,6 +780,31 @@ var init_profiler = __esm({
780
780
  }
781
781
  });
782
782
 
783
+ // typegen/context.ts
784
+ async function createContext2({
785
+ rootDirectory,
786
+ watch: watch2,
787
+ mode
788
+ }) {
789
+ const configLoader = await createConfigLoader({ rootDirectory, mode, watch: watch2 });
790
+ const configResult = await configLoader.getConfig();
791
+ if (!configResult.ok) {
792
+ throw new Error(configResult.error);
793
+ }
794
+ const config = configResult.value;
795
+ return {
796
+ configLoader,
797
+ rootDirectory,
798
+ config
799
+ };
800
+ }
801
+ var init_context = __esm({
802
+ "typegen/context.ts"() {
803
+ "use strict";
804
+ init_config();
805
+ }
806
+ });
807
+
783
808
  // vite/babel.ts
784
809
  var babel_exports = {};
785
810
  __export(babel_exports, {
@@ -799,27 +824,6 @@ var init_babel = __esm({
799
824
  }
800
825
  });
801
826
 
802
- // typegen/paths.ts
803
- function getTypesDir(ctx) {
804
- return Path3.join(ctx.rootDirectory, ".react-router/types");
805
- }
806
- function getTypesPath(ctx, route) {
807
- return Path3.join(
808
- getTypesDir(ctx),
809
- Path3.relative(ctx.rootDirectory, ctx.config.appDirectory),
810
- Path3.dirname(route.file),
811
- "+types/" + Pathe.filename(route.file) + ".ts"
812
- );
813
- }
814
- var Path3, Pathe;
815
- var init_paths = __esm({
816
- "typegen/paths.ts"() {
817
- "use strict";
818
- Path3 = __toESM(require("pathe"));
819
- Pathe = __toESM(require("pathe/utils"));
820
- }
821
- });
822
-
823
827
  // typegen/params.ts
824
828
  function parse2(fullpath2) {
825
829
  const result = {};
@@ -864,108 +868,335 @@ var init_route = __esm({
864
868
  });
865
869
 
866
870
  // typegen/generate.ts
867
- function generate2(ctx, route) {
868
- const lineage2 = lineage(ctx.config.routes, route);
869
- const fullpath2 = fullpath(lineage2);
870
- const typesPath = getTypesPath(ctx, route);
871
- const parents = lineage2.slice(0, -1);
872
- const parentTypeImports = parents.map((parent, i) => {
873
- const rel = Path4.relative(
874
- Path4.dirname(typesPath),
875
- getTypesPath(ctx, parent)
876
- );
877
- const indent = i === 0 ? "" : " ".repeat(2);
878
- let source = noExtension(rel);
879
- if (!source.startsWith("../")) source = "./" + source;
880
- return `${indent}import type { Info as Parent${i} } from "${source}.js"`;
881
- }).join("\n");
882
- return import_dedent.default`
883
- // React Router generated types for route:
884
- // ${route.file}
885
-
886
- import type * as T from "react-router/route-module"
887
-
888
- ${parentTypeImports}
889
-
890
- type Module = typeof import("../${Pathe2.filename(route.file)}.js")
891
-
892
- export type Info = {
893
- parents: [${parents.map((_, i) => `Parent${i}`).join(", ")}],
894
- id: "${route.id}"
895
- file: "${route.file}"
896
- path: "${route.path}"
897
- params: {${formatParamProperties(
898
- fullpath2
899
- )}} & { [key: string]: string | undefined }
900
- module: Module
901
- loaderData: T.CreateLoaderData<Module>
902
- actionData: T.CreateActionData<Module>
871
+ function typesDirectory(ctx) {
872
+ return Path3.join(ctx.rootDirectory, ".react-router/types");
873
+ }
874
+ function generateFuture(ctx) {
875
+ const filename2 = Path3.join(typesDirectory(ctx), "+future.ts");
876
+ const content = import_dedent.default`
877
+ // Generated by React Router
878
+
879
+ import "react-router";
880
+
881
+ declare module "react-router" {
882
+ interface Future {
883
+ unstable_middleware: ${ctx.config.future.unstable_middleware}
884
+ }
885
+ }
886
+ `;
887
+ return { filename: filename2, content };
888
+ }
889
+ function generateServerBuild(ctx) {
890
+ const filename2 = Path3.join(typesDirectory(ctx), "+server-build.d.ts");
891
+ const content = import_dedent.default`
892
+ // Generated by React Router
893
+
894
+ declare module "virtual:react-router/server-build" {
895
+ import { ServerBuild } from "react-router";
896
+ export const assets: ServerBuild["assets"];
897
+ export const assetsBuildDirectory: ServerBuild["assetsBuildDirectory"];
898
+ export const basename: ServerBuild["basename"];
899
+ export const entry: ServerBuild["entry"];
900
+ export const future: ServerBuild["future"];
901
+ export const isSpaMode: ServerBuild["isSpaMode"];
902
+ export const prerender: ServerBuild["prerender"];
903
+ export const publicPath: ServerBuild["publicPath"];
904
+ export const routeDiscovery: ServerBuild["routeDiscovery"];
905
+ export const routes: ServerBuild["routes"];
906
+ export const ssr: ServerBuild["ssr"];
907
+ export const unstable_getCriticalCss: ServerBuild["unstable_getCriticalCss"];
903
908
  }
909
+ `;
910
+ return { filename: filename2, content };
911
+ }
912
+ function generatePages(ctx) {
913
+ const filename2 = Path3.join(typesDirectory(ctx), "+pages.ts");
914
+ const fullpaths = /* @__PURE__ */ new Set();
915
+ Object.values(ctx.config.routes).forEach((route) => {
916
+ if (route.id !== "root" && !route.path) return;
917
+ const lineage2 = lineage(ctx.config.routes, route);
918
+ const fullpath2 = fullpath(lineage2);
919
+ fullpaths.add(fullpath2);
920
+ });
921
+ const pagesType = t2.tsTypeAliasDeclaration(
922
+ t2.identifier("Pages"),
923
+ null,
924
+ t2.tsTypeLiteral(
925
+ Array.from(fullpaths).map((fullpath2) => {
926
+ return t2.tsPropertySignature(
927
+ t2.stringLiteral(fullpath2),
928
+ t2.tsTypeAnnotation(
929
+ t2.tsTypeLiteral([
930
+ t2.tsPropertySignature(
931
+ t2.identifier("params"),
932
+ t2.tsTypeAnnotation(paramsType(fullpath2))
933
+ )
934
+ ])
935
+ )
936
+ );
937
+ })
938
+ )
939
+ );
940
+ const content = import_dedent.default`
941
+ // Generated by React Router
904
942
 
905
- export namespace Route {
906
- export type LinkDescriptors = T.LinkDescriptors
907
- export type LinksFunction = () => LinkDescriptors
943
+ import "react-router"
908
944
 
909
- export type MetaArgs = T.CreateMetaArgs<Info>
910
- export type MetaDescriptors = T.MetaDescriptors
911
- export type MetaFunction = (args: MetaArgs) => MetaDescriptors
945
+ declare module "react-router" {
946
+ interface Register {
947
+ pages: Pages
948
+ }
949
+ }
950
+ ` + "\n\n" + generate(pagesType).code;
951
+ return { filename: filename2, content };
952
+ }
953
+ function generateRoutes(ctx) {
954
+ const filename2 = Path3.join(typesDirectory(ctx), "+routes-pre.ts");
955
+ const routesType = t2.tsTypeAliasDeclaration(
956
+ t2.identifier("routesPre"),
957
+ null,
958
+ t2.tsTypeLiteral(
959
+ Object.values(ctx.config.routes).map((route) => {
960
+ return t2.tsPropertySignature(
961
+ t2.stringLiteral(route.id),
962
+ t2.tsTypeAnnotation(
963
+ t2.tsTypeLiteral([
964
+ t2.tsPropertySignature(
965
+ t2.identifier("parentId"),
966
+ t2.tsTypeAnnotation(
967
+ route.parentId ? t2.tsLiteralType(t2.stringLiteral(route.parentId)) : t2.tsUndefinedKeyword()
968
+ )
969
+ ),
970
+ t2.tsPropertySignature(
971
+ t2.identifier("path"),
972
+ t2.tsTypeAnnotation(
973
+ route.path ? t2.tsLiteralType(t2.stringLiteral(route.path)) : t2.tsUndefinedKeyword()
974
+ )
975
+ ),
976
+ t2.tsPropertySignature(
977
+ t2.identifier("params"),
978
+ t2.tsTypeAnnotation(paramsType(route.path ?? ""))
979
+ ),
980
+ t2.tsPropertySignature(
981
+ t2.identifier("index"),
982
+ t2.tsTypeAnnotation(
983
+ t2.tsLiteralType(t2.booleanLiteral(route.index ?? false))
984
+ )
985
+ ),
986
+ t2.tsPropertySignature(
987
+ t2.identifier("file"),
988
+ t2.tsTypeAnnotation(t2.tsLiteralType(t2.stringLiteral(route.file)))
989
+ )
990
+ ])
991
+ )
992
+ );
993
+ })
994
+ )
995
+ );
996
+ const content = import_dedent.default`
997
+ // Generated by React Router
912
998
 
913
- export type HeadersArgs = T.HeadersArgs
914
- export type HeadersFunction = (args: HeadersArgs) => Headers | HeadersInit
999
+ import "react-router"
915
1000
 
916
- export type unstable_MiddlewareFunction = T.CreateServerMiddlewareFunction<Info>
917
- export type unstable_ClientMiddlewareFunction = T.CreateClientMiddlewareFunction<Info>
918
- export type LoaderArgs = T.CreateServerLoaderArgs<Info>
919
- export type ClientLoaderArgs = T.CreateClientLoaderArgs<Info>
920
- export type ActionArgs = T.CreateServerActionArgs<Info>
921
- export type ClientActionArgs = T.CreateClientActionArgs<Info>
1001
+ declare module "react-router" {
1002
+ interface Register {
1003
+ routesPre: routesPre
1004
+ }
1005
+ }
1006
+ ` + "\n\n" + generate(routesType).code;
1007
+ return { filename: filename2, content };
1008
+ }
1009
+ function generateRouteModuleAnnotations(ctx) {
1010
+ return Object.values(ctx.config.routes).map((route) => {
1011
+ const filename2 = getRouteModuleAnnotationsFilepath(ctx, route);
1012
+ const parents = getParents(ctx, route);
1013
+ const content = import_dedent.default`
1014
+ // Generated by React Router
922
1015
 
923
- export type HydrateFallbackProps = T.CreateHydrateFallbackProps<Info>
924
- export type ComponentProps = T.CreateComponentProps<Info>
925
- export type ErrorBoundaryProps = T.CreateErrorBoundaryProps<Info>
926
- }
927
- `;
1016
+ import type {
1017
+ Params,
1018
+ RouteModuleAnnotations,
1019
+ CreateLoaderData,
1020
+ CreateActionData,
1021
+ } from "react-router/internal";
1022
+
1023
+ ${parents.map((parent) => parent.import).join("\n" + " ".repeat(3))}
1024
+ type Parents = [${parents.map((parent) => parent.name).join(", ")}]
1025
+
1026
+ type Id = "${route.id}"
1027
+ type Module = typeof import("../${Pathe.filename(route.file)}.js")
1028
+
1029
+ export type unstable_Props = {
1030
+ params: Params[Id]
1031
+ loaderData: CreateLoaderData<Module>
1032
+ actionData: CreateActionData<Module>
1033
+ }
1034
+
1035
+ type Annotations = RouteModuleAnnotations<unstable_Props & {
1036
+ parents: Parents,
1037
+ module: Module,
1038
+ }>;
1039
+
1040
+ export namespace Route {
1041
+ // links
1042
+ export type LinkDescriptors = Annotations["LinkDescriptors"];
1043
+ export type LinksFunction = Annotations["LinksFunction"];
1044
+
1045
+ // meta
1046
+ export type MetaArgs = Annotations["MetaArgs"];
1047
+ export type MetaDescriptors = Annotations["MetaDescriptors"];
1048
+ export type MetaFunction = Annotations["MetaFunction"];
1049
+
1050
+ // headers
1051
+ export type HeadersArgs = Annotations["HeadersArgs"];
1052
+ export type HeadersFunction = Annotations["HeadersFunction"];
1053
+
1054
+ // unstable_middleware
1055
+ export type unstable_MiddlewareFunction = Annotations["unstable_MiddlewareFunction"];
1056
+
1057
+ // unstable_clientMiddleware
1058
+ export type unstable_ClientMiddlewareFunction = Annotations["unstable_ClientMiddlewareFunction"];
1059
+
1060
+ // loader
1061
+ export type LoaderArgs = Annotations["LoaderArgs"];
1062
+
1063
+ // clientLoader
1064
+ export type ClientLoaderArgs = Annotations["ClientLoaderArgs"];
1065
+
1066
+ // action
1067
+ export type ActionArgs = Annotations["ActionArgs"];
1068
+
1069
+ // clientAction
1070
+ export type ClientActionArgs = Annotations["ClientActionArgs"];
1071
+
1072
+ // HydrateFallback
1073
+ export type HydrateFallbackProps = Annotations["HydrateFallbackProps"];
1074
+
1075
+ // Component
1076
+ export type ComponentProps = Annotations["ComponentProps"];
1077
+
1078
+ // ErrorBoundary
1079
+ export type ErrorBoundaryProps = Annotations["ErrorBoundaryProps"];
1080
+ }
1081
+ `;
1082
+ return { filename: filename2, content };
1083
+ });
1084
+ }
1085
+ function getRouteModuleAnnotationsFilepath(ctx, route) {
1086
+ return Path3.join(
1087
+ typesDirectory(ctx),
1088
+ Path3.relative(ctx.rootDirectory, ctx.config.appDirectory),
1089
+ Path3.dirname(route.file),
1090
+ "+types/" + Pathe.filename(route.file) + ".ts"
1091
+ );
928
1092
  }
929
- function formatParamProperties(fullpath2) {
930
- const params = parse2(fullpath2);
931
- const properties = Object.entries(params).map(
932
- ([name, isRequired]) => isRequired ? `"${name}": string` : `"${name}"?: string`
1093
+ function getParents(ctx, route) {
1094
+ const typesPath = getRouteModuleAnnotationsFilepath(ctx, route);
1095
+ const lineage2 = lineage(ctx.config.routes, route);
1096
+ const parents = lineage2.slice(0, -1);
1097
+ return parents.map((parent, i) => {
1098
+ const rel = Path3.relative(
1099
+ Path3.dirname(typesPath),
1100
+ getRouteModuleAnnotationsFilepath(ctx, parent)
1101
+ );
1102
+ let source = noExtension(rel);
1103
+ if (!source.startsWith("../")) source = "./" + source;
1104
+ const name = `Parent${i}`;
1105
+ return {
1106
+ name,
1107
+ import: `import type { unstable_Props as ${name} } from "${source}.js"`
1108
+ };
1109
+ });
1110
+ }
1111
+ function noExtension(path8) {
1112
+ return Path3.join(Path3.dirname(path8), Pathe.filename(path8));
1113
+ }
1114
+ function paramsType(path8) {
1115
+ const params = parse2(path8);
1116
+ return t2.tsTypeLiteral(
1117
+ Object.entries(params).map(([param, isRequired]) => {
1118
+ const property = t2.tsPropertySignature(
1119
+ t2.stringLiteral(param),
1120
+ t2.tsTypeAnnotation(t2.tsStringKeyword())
1121
+ );
1122
+ property.optional = !isRequired;
1123
+ return property;
1124
+ })
933
1125
  );
934
- return properties.join("; ");
935
1126
  }
936
- var import_dedent, Path4, Pathe2, noExtension;
1127
+ var import_dedent, Path3, Pathe, t2;
937
1128
  var init_generate = __esm({
938
1129
  "typegen/generate.ts"() {
939
1130
  "use strict";
940
1131
  import_dedent = __toESM(require("dedent"));
941
- Path4 = __toESM(require("pathe"));
942
- Pathe2 = __toESM(require("pathe/utils"));
943
- init_paths();
1132
+ Path3 = __toESM(require("pathe"));
1133
+ Pathe = __toESM(require("pathe/utils"));
1134
+ init_babel();
944
1135
  init_params();
945
1136
  init_route();
946
- noExtension = (path8) => Path4.join(Path4.dirname(path8), Pathe2.filename(path8));
1137
+ ({ t: t2 } = babel_exports);
947
1138
  }
948
1139
  });
949
1140
 
950
1141
  // typegen/index.ts
1142
+ async function clearRouteModuleAnnotations(ctx) {
1143
+ await import_promises.default.rm(
1144
+ Path4.join(typesDirectory(ctx), Path4.basename(ctx.config.appDirectory)),
1145
+ { recursive: true, force: true }
1146
+ );
1147
+ }
1148
+ async function write(...files) {
1149
+ return Promise.all(
1150
+ files.map(async ({ filename: filename2, content }) => {
1151
+ await import_promises.default.mkdir(Path4.dirname(filename2), { recursive: true });
1152
+ await import_promises.default.writeFile(filename2, content);
1153
+ })
1154
+ );
1155
+ }
951
1156
  async function run(rootDirectory, { mode }) {
952
1157
  const ctx = await createContext2({ rootDirectory, mode, watch: false });
953
- await writeAll(ctx);
1158
+ await clearRouteModuleAnnotations(ctx);
1159
+ await write(
1160
+ generateFuture(ctx),
1161
+ generatePages(ctx),
1162
+ generateRoutes(ctx),
1163
+ generateServerBuild(ctx),
1164
+ ...generateRouteModuleAnnotations(ctx)
1165
+ );
954
1166
  }
955
1167
  async function watch(rootDirectory, { mode, logger }) {
956
1168
  const ctx = await createContext2({ rootDirectory, mode, watch: true });
957
- await writeAll(ctx);
958
- logger?.info(import_picocolors3.default.green("generated types"), { timestamp: true, clear: true });
1169
+ await clearRouteModuleAnnotations(ctx);
1170
+ await write(
1171
+ generateFuture(ctx),
1172
+ generatePages(ctx),
1173
+ generateRoutes(ctx),
1174
+ generateServerBuild(ctx),
1175
+ ...generateRouteModuleAnnotations(ctx)
1176
+ );
1177
+ logger?.info((0, import_picocolors3.green)("generated types"), { timestamp: true, clear: true });
959
1178
  ctx.configLoader.onChange(
960
1179
  async ({ result, configChanged, routeConfigChanged }) => {
961
1180
  if (!result.ok) {
962
- logger?.error(import_picocolors3.default.red(result.error), { timestamp: true, clear: true });
1181
+ logger?.error((0, import_picocolors3.red)(result.error), { timestamp: true, clear: true });
963
1182
  return;
964
1183
  }
965
1184
  ctx.config = result.value;
966
- if (configChanged || routeConfigChanged) {
967
- await writeAll(ctx);
968
- logger?.info(import_picocolors3.default.green("regenerated types"), {
1185
+ if (configChanged) {
1186
+ await write(generateFuture(ctx));
1187
+ logger?.info((0, import_picocolors3.green)("regenerated types"), {
1188
+ timestamp: true,
1189
+ clear: true
1190
+ });
1191
+ }
1192
+ if (routeConfigChanged) {
1193
+ await clearRouteModuleAnnotations(ctx);
1194
+ await write(
1195
+ generatePages(ctx),
1196
+ generateRoutes(ctx),
1197
+ ...generateRouteModuleAnnotations(ctx)
1198
+ );
1199
+ logger?.info((0, import_picocolors3.green)("regenerated types"), {
969
1200
  timestamp: true,
970
1201
  clear: true
971
1202
  });
@@ -976,116 +1207,15 @@ async function watch(rootDirectory, { mode, logger }) {
976
1207
  close: async () => await ctx.configLoader.close()
977
1208
  };
978
1209
  }
979
- async function createContext2({
980
- rootDirectory,
981
- watch: watch2,
982
- mode
983
- }) {
984
- const configLoader = await createConfigLoader({ rootDirectory, mode, watch: watch2 });
985
- const configResult = await configLoader.getConfig();
986
- if (!configResult.ok) {
987
- throw new Error(configResult.error);
988
- }
989
- const config = configResult.value;
990
- return {
991
- configLoader,
992
- rootDirectory,
993
- config
994
- };
995
- }
996
- async function writeAll(ctx) {
997
- const typegenDir = getTypesDir(ctx);
998
- import_node_fs3.default.rmSync(typegenDir, { recursive: true, force: true });
999
- Object.values(ctx.config.routes).forEach((route) => {
1000
- const typesPath = getTypesPath(ctx, route);
1001
- const content = generate2(ctx, route);
1002
- import_node_fs3.default.mkdirSync(Path5.dirname(typesPath), { recursive: true });
1003
- import_node_fs3.default.writeFileSync(typesPath, content);
1004
- });
1005
- const registerPath = Path5.join(typegenDir, "+register.ts");
1006
- import_node_fs3.default.writeFileSync(registerPath, register(ctx));
1007
- const virtualPath = Path5.join(typegenDir, "+virtual.d.ts");
1008
- import_node_fs3.default.writeFileSync(virtualPath, virtual);
1009
- }
1010
- function register(ctx) {
1011
- const register2 = import_dedent2.default`
1012
- import "react-router";
1013
-
1014
- declare module "react-router" {
1015
- interface Register {
1016
- params: Params;
1017
- }
1018
-
1019
- interface Future {
1020
- unstable_middleware: ${ctx.config.future.unstable_middleware}
1021
- }
1022
- }
1023
- `;
1024
- const { t: t2 } = babel_exports;
1025
- const fullpaths = /* @__PURE__ */ new Set();
1026
- Object.values(ctx.config.routes).forEach((route) => {
1027
- if (route.id !== "root" && !route.path) return;
1028
- const lineage2 = lineage(ctx.config.routes, route);
1029
- const fullpath2 = fullpath(lineage2);
1030
- fullpaths.add(fullpath2);
1031
- });
1032
- const typeParams = t2.tsTypeAliasDeclaration(
1033
- t2.identifier("Params"),
1034
- null,
1035
- t2.tsTypeLiteral(
1036
- Array.from(fullpaths).map((fullpath2) => {
1037
- const params = parse2(fullpath2);
1038
- return t2.tsPropertySignature(
1039
- t2.stringLiteral(fullpath2),
1040
- t2.tsTypeAnnotation(
1041
- t2.tsTypeLiteral(
1042
- Object.entries(params).map(([param, isRequired]) => {
1043
- const property = t2.tsPropertySignature(
1044
- t2.stringLiteral(param),
1045
- t2.tsTypeAnnotation(t2.tsStringKeyword())
1046
- );
1047
- property.optional = !isRequired;
1048
- return property;
1049
- })
1050
- )
1051
- )
1052
- );
1053
- })
1054
- )
1055
- );
1056
- return [register2, generate(typeParams).code].join("\n\n");
1057
- }
1058
- var import_node_fs3, import_dedent2, Path5, import_picocolors3, virtual;
1210
+ var import_promises, Path4, import_picocolors3;
1059
1211
  var init_typegen = __esm({
1060
1212
  "typegen/index.ts"() {
1061
1213
  "use strict";
1062
- import_node_fs3 = __toESM(require("fs"));
1063
- import_dedent2 = __toESM(require("dedent"));
1064
- Path5 = __toESM(require("pathe"));
1065
- import_picocolors3 = __toESM(require("picocolors"));
1066
- init_config();
1067
- init_babel();
1214
+ import_promises = __toESM(require("fs/promises"));
1215
+ Path4 = __toESM(require("pathe"));
1216
+ import_picocolors3 = require("picocolors");
1217
+ init_context();
1068
1218
  init_generate();
1069
- init_paths();
1070
- init_params();
1071
- init_route();
1072
- virtual = import_dedent2.default`
1073
- declare module "virtual:react-router/server-build" {
1074
- import { ServerBuild } from "react-router";
1075
- export const assets: ServerBuild["assets"];
1076
- export const assetsBuildDirectory: ServerBuild["assetsBuildDirectory"];
1077
- export const basename: ServerBuild["basename"];
1078
- export const entry: ServerBuild["entry"];
1079
- export const future: ServerBuild["future"];
1080
- export const isSpaMode: ServerBuild["isSpaMode"];
1081
- export const prerender: ServerBuild["prerender"];
1082
- export const publicPath: ServerBuild["publicPath"];
1083
- export const routeDiscovery: ServerBuild["routeDiscovery"];
1084
- export const routes: ServerBuild["routes"];
1085
- export const ssr: ServerBuild["ssr"];
1086
- export const unstable_getCriticalCss: ServerBuild["unstable_getCriticalCss"];
1087
- }
1088
- `;
1089
1219
  }
1090
1220
  });
1091
1221
 
@@ -1214,11 +1344,11 @@ var init_route_chunks = __esm({
1214
1344
  });
1215
1345
 
1216
1346
  // vite/with-props.ts
1217
- var import_dedent3, vmod;
1347
+ var import_dedent2, vmod;
1218
1348
  var init_with_props = __esm({
1219
1349
  "vite/with-props.ts"() {
1220
1350
  "use strict";
1221
- import_dedent3 = __toESM(require("dedent"));
1351
+ import_dedent2 = __toESM(require("dedent"));
1222
1352
  init_babel();
1223
1353
  init_virtual_module();
1224
1354
  vmod = create("with-props");
@@ -1366,7 +1496,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
1366
1496
  copyPublicDir: false,
1367
1497
  // Assets in the public directory are only used by the client
1368
1498
  rollupOptions: {
1369
- input: (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? viteUserConfig.environments?.ssr?.build?.rollupOptions?.input : viteUserConfig.build?.rollupOptions?.input) ?? virtual2.serverBuild.id,
1499
+ input: (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? viteUserConfig.environments?.ssr?.build?.rollupOptions?.input : viteUserConfig.build?.rollupOptions?.input) ?? virtual.serverBuild.id,
1370
1500
  output: {
1371
1501
  entryFileNames: serverBuildFile,
1372
1502
  format: serverModuleFormat
@@ -1457,7 +1587,7 @@ function resolveEnvironmentsOptions(environmentResolvers, resolverOptions) {
1457
1587
  function isNonNullable(x) {
1458
1588
  return x != null;
1459
1589
  }
1460
- var import_node_crypto, fs4, path6, url, fse, babel2, import_react_router2, import_es_module_lexer, import_pick3, import_jsesc, import_picocolors4, import_kebabCase, CLIENT_NON_COMPONENT_EXPORTS, CLIENT_ROUTE_EXPORTS, BUILD_CLIENT_ROUTE_QUERY_STRING, SSR_BUNDLE_PREFIX, virtualHmrRuntime, virtualInjectHmrRuntime, virtual2, getServerBuildDirectory, getClientBuildDirectory, defaultEntriesDir, defaultEntries, REACT_REFRESH_HEADER;
1590
+ var import_node_crypto, fs4, path6, url, fse, babel2, import_react_router2, import_es_module_lexer, import_pick3, import_jsesc, import_picocolors4, import_kebabCase, CLIENT_NON_COMPONENT_EXPORTS, CLIENT_ROUTE_EXPORTS, BUILD_CLIENT_ROUTE_QUERY_STRING, SSR_BUNDLE_PREFIX, virtualHmrRuntime, virtualInjectHmrRuntime, virtual, getServerBuildDirectory, getClientBuildDirectory, defaultEntriesDir, defaultEntries, REACT_REFRESH_HEADER;
1461
1591
  var init_plugin = __esm({
1462
1592
  "vite/plugin.ts"() {
1463
1593
  "use strict";
@@ -1507,7 +1637,7 @@ var init_plugin = __esm({
1507
1637
  SSR_BUNDLE_PREFIX = "ssrBundle_";
1508
1638
  virtualHmrRuntime = create("hmr-runtime");
1509
1639
  virtualInjectHmrRuntime = create("inject-hmr-runtime");
1510
- virtual2 = {
1640
+ virtual = {
1511
1641
  serverBuild: create("server-build"),
1512
1642
  serverManifest: create("server-manifest"),
1513
1643
  browserManifest: create("browser-manifest")
@@ -1524,7 +1654,7 @@ var init_plugin = __esm({
1524
1654
  "config",
1525
1655
  "defaults"
1526
1656
  );
1527
- defaultEntries = fse.readdirSync(defaultEntriesDir).map((filename3) => path6.join(defaultEntriesDir, filename3));
1657
+ defaultEntries = fse.readdirSync(defaultEntriesDir).map((filename2) => path6.join(defaultEntriesDir, filename2));
1528
1658
  invariant(defaultEntries.length > 0, "No default entries found");
1529
1659
  REACT_REFRESH_HEADER = `
1530
1660
  import RefreshRuntime from "${virtualHmrRuntime.id}";
@@ -2009,8 +2139,8 @@ async function checkForEntry(rootDirectory, appDirectory, entries2) {
2009
2139
  let entryPath = path7.resolve(appDirectory, entry);
2010
2140
  let exists = await import_fs_extra.default.pathExists(entryPath);
2011
2141
  if (exists) {
2012
- let relative8 = path7.relative(rootDirectory, entryPath);
2013
- console.error(import_picocolors7.default.red(`Entry file ${relative8} already exists.`));
2142
+ let relative7 = path7.relative(rootDirectory, entryPath);
2143
+ console.error(import_picocolors7.default.red(`Entry file ${relative7} already exists.`));
2014
2144
  return process.exit(1);
2015
2145
  }
2016
2146
  }