@react-router/dev 0.0.0-experimental-208f173a8 → 0.0.0-experimental-8e9d8ef63

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-208f173a8
3
+ * @react-router/dev v0.0.0-experimental-8e9d8ef63
4
4
  *
5
5
  * Copyright (c) Remix Software Inc.
6
6
  *
@@ -676,12 +676,55 @@ var init_paths = __esm({
676
676
  }
677
677
  });
678
678
 
679
+ // typegen/params.ts
680
+ function parse2(fullpath2) {
681
+ const result = {};
682
+ let segments = fullpath2.split("/");
683
+ segments.forEach((segment) => {
684
+ const match = segment.match(/^:([\w-]+)(\?)?/);
685
+ if (!match) return;
686
+ const param = match[1];
687
+ const isRequired = match[2] === void 0;
688
+ result[param] ||= isRequired;
689
+ return;
690
+ });
691
+ const hasSplat = segments.at(-1) === "*";
692
+ if (hasSplat) result["*"] = true;
693
+ return result;
694
+ }
695
+ var init_params = __esm({
696
+ "typegen/params.ts"() {
697
+ "use strict";
698
+ }
699
+ });
700
+
701
+ // typegen/route.ts
702
+ function lineage(routes2, route) {
703
+ const result = [];
704
+ while (route) {
705
+ result.push(route);
706
+ if (!route.parentId) break;
707
+ route = routes2[route.parentId];
708
+ }
709
+ result.reverse();
710
+ return result;
711
+ }
712
+ function fullpath(lineage2) {
713
+ if (lineage2.length === 1 && lineage2[0].id === "root") return "/";
714
+ return "/" + lineage2.map((route) => route.path?.replace(/^\//, "")?.replace(/\/$/, "")).filter((path9) => path9 !== void 0 && path9 !== "").join("/");
715
+ }
716
+ var init_route = __esm({
717
+ "typegen/route.ts"() {
718
+ "use strict";
719
+ }
720
+ });
721
+
679
722
  // typegen/generate.ts
680
723
  function generate2(ctx, route) {
681
- const lineage = getRouteLineage(ctx.config.routes, route);
682
- const urlpath = lineage.map((route2) => route2.path).join("/");
724
+ const lineage2 = lineage(ctx.config.routes, route);
725
+ const fullpath2 = fullpath(lineage2);
683
726
  const typesPath = getTypesPath(ctx, route);
684
- const parents = lineage.slice(0, -1);
727
+ const parents = lineage2.slice(0, -1);
685
728
  const parentTypeImports = parents.map((parent, i) => {
686
729
  const rel = Path3.relative(
687
730
  Path3.dirname(typesPath),
@@ -708,7 +751,7 @@ function generate2(ctx, route) {
708
751
  file: "${route.file}"
709
752
  path: "${route.path}"
710
753
  params: {${formatParamProperties(
711
- urlpath
754
+ fullpath2
712
755
  )}} & { [key: string]: string | undefined }
713
756
  module: Module
714
757
  loaderData: T.CreateLoaderData<Module>
@@ -737,46 +780,13 @@ function generate2(ctx, route) {
737
780
  }
738
781
  `;
739
782
  }
740
- function getRouteLineage(routes2, route) {
741
- const result = [];
742
- while (route) {
743
- result.push(route);
744
- if (!route.parentId) break;
745
- route = routes2[route.parentId];
746
- }
747
- result.reverse();
748
- return result;
749
- }
750
- function formatParamProperties(urlpath) {
751
- const params = parseParams(urlpath);
752
- const properties = Object.entries(params).map(([name, values]) => {
753
- if (values.length === 1) {
754
- const isOptional = values[0];
755
- return isOptional ? `"${name}"?: string` : `"${name}": string`;
756
- }
757
- const items = values.map(
758
- (isOptional) => isOptional ? "string | undefined" : "string"
759
- );
760
- return `"${name}": [${items.join(", ")}]`;
761
- });
783
+ function formatParamProperties(fullpath2) {
784
+ const params = parse2(fullpath2);
785
+ const properties = Object.entries(params).map(
786
+ ([name, isRequired]) => isRequired ? `"${name}": string` : `"${name}"?: string`
787
+ );
762
788
  return properties.join("; ");
763
789
  }
764
- function parseParams(urlpath) {
765
- const result = {};
766
- let segments = urlpath.split("/");
767
- segments.forEach((segment) => {
768
- const match = segment.match(/^:([\w-]+)(\?)?/);
769
- if (!match) return;
770
- const param = match[1];
771
- const isOptional = match[2] !== void 0;
772
- result[param] ??= [];
773
- result[param].push(isOptional);
774
- return;
775
- });
776
- const hasSplat = segments.at(-1) === "*";
777
- if (hasSplat) result["*"] = [false];
778
- return result;
779
- }
780
790
  var import_dedent, Path3, Pathe2, noExtension;
781
791
  var init_generate = __esm({
782
792
  "typegen/generate.ts"() {
@@ -785,6 +795,8 @@ var init_generate = __esm({
785
795
  Path3 = __toESM(require("pathe"));
786
796
  Pathe2 = __toESM(require("pathe/utils"));
787
797
  init_paths();
798
+ init_params();
799
+ init_route();
788
800
  noExtension = (path9) => Path3.join(Path3.dirname(path9), Pathe2.filename(path9));
789
801
  }
790
802
  });
@@ -861,11 +873,11 @@ function register(ctx) {
861
873
  t2.tsTypeLiteral(
862
874
  Object.values(ctx.config.routes).map((route) => {
863
875
  if (route.id !== "root" && !route.path) return void 0;
864
- const lineage = getRouteLineage2(ctx.config.routes, route);
865
- const fullpath = route.id === "root" ? "/" : lineage.map((route2) => route2.path).filter((path9) => path9 !== void 0).join("/");
866
- const params = parseParams2(fullpath);
876
+ const lineage2 = lineage(ctx.config.routes, route);
877
+ const fullpath2 = fullpath(lineage2);
878
+ const params = parse2(fullpath2);
867
879
  return t2.tsPropertySignature(
868
- t2.stringLiteral(fullpath),
880
+ t2.stringLiteral(fullpath2),
869
881
  t2.tsTypeAnnotation(
870
882
  t2.tsTypeLiteral(
871
883
  Object.entries(params).map(([param, isRequired]) => {
@@ -884,31 +896,6 @@ function register(ctx) {
884
896
  );
885
897
  return [register2, generate(typeParams).code].join("\n\n");
886
898
  }
887
- function parseParams2(fullpath) {
888
- const result = {};
889
- let segments = fullpath.split("/");
890
- segments.forEach((segment) => {
891
- const match = segment.match(/^:([\w-]+)(\?)?/);
892
- if (!match) return;
893
- const param = match[1];
894
- const isRequired = match[2] === void 0;
895
- result[param] ||= isRequired;
896
- return;
897
- });
898
- const hasSplat = segments.at(-1) === "*";
899
- if (hasSplat) result["*"] = true;
900
- return result;
901
- }
902
- function getRouteLineage2(routes2, route) {
903
- const result = [];
904
- while (route) {
905
- result.push(route);
906
- if (!route.parentId) break;
907
- route = routes2[route.parentId];
908
- }
909
- result.reverse();
910
- return result;
911
- }
912
899
  var import_node_fs3, import_dedent2, Path4, import_picocolors3;
913
900
  var init_typegen = __esm({
914
901
  "typegen/index.ts"() {
@@ -921,6 +908,8 @@ var init_typegen = __esm({
921
908
  init_babel();
922
909
  init_generate();
923
910
  init_paths();
911
+ init_params();
912
+ init_route();
924
913
  }
925
914
  });
926
915
 
package/dist/config.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-208f173a8
2
+ * @react-router/dev v0.0.0-experimental-8e9d8ef63
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/dist/routes.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-208f173a8
2
+ * @react-router/dev v0.0.0-experimental-8e9d8ef63
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-208f173a8
2
+ * @react-router/dev v0.0.0-experimental-8e9d8ef63
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/dist/vite.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-208f173a8
2
+ * @react-router/dev v0.0.0-experimental-8e9d8ef63
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -667,12 +667,45 @@ function getTypesPath(ctx, route) {
667
667
  );
668
668
  }
669
669
 
670
+ // typegen/params.ts
671
+ function parse2(fullpath2) {
672
+ const result = {};
673
+ let segments = fullpath2.split("/");
674
+ segments.forEach((segment) => {
675
+ const match = segment.match(/^:([\w-]+)(\?)?/);
676
+ if (!match) return;
677
+ const param = match[1];
678
+ const isRequired = match[2] === void 0;
679
+ result[param] ||= isRequired;
680
+ return;
681
+ });
682
+ const hasSplat = segments.at(-1) === "*";
683
+ if (hasSplat) result["*"] = true;
684
+ return result;
685
+ }
686
+
687
+ // typegen/route.ts
688
+ function lineage(routes, route) {
689
+ const result = [];
690
+ while (route) {
691
+ result.push(route);
692
+ if (!route.parentId) break;
693
+ route = routes[route.parentId];
694
+ }
695
+ result.reverse();
696
+ return result;
697
+ }
698
+ function fullpath(lineage2) {
699
+ if (lineage2.length === 1 && lineage2[0].id === "root") return "/";
700
+ return "/" + lineage2.map((route) => route.path?.replace(/^\//, "")?.replace(/\/$/, "")).filter((path7) => path7 !== void 0 && path7 !== "").join("/");
701
+ }
702
+
670
703
  // typegen/generate.ts
671
704
  function generate2(ctx, route) {
672
- const lineage = getRouteLineage(ctx.config.routes, route);
673
- const urlpath = lineage.map((route2) => route2.path).join("/");
705
+ const lineage2 = lineage(ctx.config.routes, route);
706
+ const fullpath2 = fullpath(lineage2);
674
707
  const typesPath = getTypesPath(ctx, route);
675
- const parents = lineage.slice(0, -1);
708
+ const parents = lineage2.slice(0, -1);
676
709
  const parentTypeImports = parents.map((parent, i) => {
677
710
  const rel = Path3.relative(
678
711
  Path3.dirname(typesPath),
@@ -699,7 +732,7 @@ function generate2(ctx, route) {
699
732
  file: "${route.file}"
700
733
  path: "${route.path}"
701
734
  params: {${formatParamProperties(
702
- urlpath
735
+ fullpath2
703
736
  )}} & { [key: string]: string | undefined }
704
737
  module: Module
705
738
  loaderData: T.CreateLoaderData<Module>
@@ -729,46 +762,13 @@ function generate2(ctx, route) {
729
762
  `;
730
763
  }
731
764
  var noExtension = (path7) => Path3.join(Path3.dirname(path7), Pathe2.filename(path7));
732
- function getRouteLineage(routes, route) {
733
- const result = [];
734
- while (route) {
735
- result.push(route);
736
- if (!route.parentId) break;
737
- route = routes[route.parentId];
738
- }
739
- result.reverse();
740
- return result;
741
- }
742
- function formatParamProperties(urlpath) {
743
- const params = parseParams(urlpath);
744
- const properties = Object.entries(params).map(([name, values]) => {
745
- if (values.length === 1) {
746
- const isOptional = values[0];
747
- return isOptional ? `"${name}"?: string` : `"${name}": string`;
748
- }
749
- const items = values.map(
750
- (isOptional) => isOptional ? "string | undefined" : "string"
751
- );
752
- return `"${name}": [${items.join(", ")}]`;
753
- });
765
+ function formatParamProperties(fullpath2) {
766
+ const params = parse2(fullpath2);
767
+ const properties = Object.entries(params).map(
768
+ ([name, isRequired]) => isRequired ? `"${name}": string` : `"${name}"?: string`
769
+ );
754
770
  return properties.join("; ");
755
771
  }
756
- function parseParams(urlpath) {
757
- const result = {};
758
- let segments = urlpath.split("/");
759
- segments.forEach((segment) => {
760
- const match = segment.match(/^:([\w-]+)(\?)?/);
761
- if (!match) return;
762
- const param = match[1];
763
- const isOptional = match[2] !== void 0;
764
- result[param] ??= [];
765
- result[param].push(isOptional);
766
- return;
767
- });
768
- const hasSplat = segments.at(-1) === "*";
769
- if (hasSplat) result["*"] = [false];
770
- return result;
771
- }
772
772
 
773
773
  // typegen/index.ts
774
774
  async function watch(rootDirectory, { logger } = {}) {
@@ -838,11 +838,11 @@ function register(ctx) {
838
838
  t2.tsTypeLiteral(
839
839
  Object.values(ctx.config.routes).map((route) => {
840
840
  if (route.id !== "root" && !route.path) return void 0;
841
- const lineage = getRouteLineage2(ctx.config.routes, route);
842
- const fullpath = route.id === "root" ? "/" : lineage.map((route2) => route2.path).filter((path7) => path7 !== void 0).join("/");
843
- const params = parseParams2(fullpath);
841
+ const lineage2 = lineage(ctx.config.routes, route);
842
+ const fullpath2 = fullpath(lineage2);
843
+ const params = parse2(fullpath2);
844
844
  return t2.tsPropertySignature(
845
- t2.stringLiteral(fullpath),
845
+ t2.stringLiteral(fullpath2),
846
846
  t2.tsTypeAnnotation(
847
847
  t2.tsTypeLiteral(
848
848
  Object.entries(params).map(([param, isRequired]) => {
@@ -861,31 +861,6 @@ function register(ctx) {
861
861
  );
862
862
  return [register2, generate(typeParams).code].join("\n\n");
863
863
  }
864
- function parseParams2(fullpath) {
865
- const result = {};
866
- let segments = fullpath.split("/");
867
- segments.forEach((segment) => {
868
- const match = segment.match(/^:([\w-]+)(\?)?/);
869
- if (!match) return;
870
- const param = match[1];
871
- const isRequired = match[2] === void 0;
872
- result[param] ||= isRequired;
873
- return;
874
- });
875
- const hasSplat = segments.at(-1) === "*";
876
- if (hasSplat) result["*"] = true;
877
- return result;
878
- }
879
- function getRouteLineage2(routes, route) {
880
- const result = [];
881
- while (route) {
882
- result.push(route);
883
- if (!route.parentId) break;
884
- route = routes[route.parentId];
885
- }
886
- result.reverse();
887
- return result;
888
- }
889
864
 
890
865
  // vite/node-adapter.ts
891
866
  var import_node_events = require("events");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-router/dev",
3
- "version": "0.0.0-experimental-208f173a8",
3
+ "version": "0.0.0-experimental-8e9d8ef63",
4
4
  "description": "Dev tools and CLI for React Router",
5
5
  "homepage": "https://reactrouter.com",
6
6
  "bugs": {
@@ -88,7 +88,7 @@
88
88
  "set-cookie-parser": "^2.6.0",
89
89
  "valibot": "^0.41.0",
90
90
  "vite-node": "3.0.0-beta.2",
91
- "@react-router/node": "0.0.0-experimental-208f173a8"
91
+ "@react-router/node": "0.0.0-experimental-8e9d8ef63"
92
92
  },
93
93
  "devDependencies": {
94
94
  "@types/babel__core": "^7.20.5",
@@ -117,15 +117,15 @@
117
117
  "vite": "^6.0.0",
118
118
  "wireit": "0.14.9",
119
119
  "wrangler": "^3.28.2",
120
- "react-router": "^0.0.0-experimental-208f173a8",
121
- "@react-router/serve": "0.0.0-experimental-208f173a8"
120
+ "react-router": "^0.0.0-experimental-8e9d8ef63",
121
+ "@react-router/serve": "0.0.0-experimental-8e9d8ef63"
122
122
  },
123
123
  "peerDependencies": {
124
124
  "typescript": "^5.1.0",
125
125
  "vite": "^5.1.0 || ^6.0.0",
126
126
  "wrangler": "^3.28.2",
127
- "@react-router/serve": "^0.0.0-experimental-208f173a8",
128
- "react-router": "^0.0.0-experimental-208f173a8"
127
+ "@react-router/serve": "^0.0.0-experimental-8e9d8ef63",
128
+ "react-router": "^0.0.0-experimental-8e9d8ef63"
129
129
  },
130
130
  "peerDependenciesMeta": {
131
131
  "@react-router/serve": {