@react-router/dev 0.0.0-experimental-004e483a8 → 0.0.0-experimental-263c97949

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-004e483a8
3
+ * @react-router/dev v0.0.0-experimental-263c97949
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).filter((path9) => path9 !== void 0).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
  });
@@ -860,11 +872,12 @@ function register(ctx) {
860
872
  null,
861
873
  t2.tsTypeLiteral(
862
874
  Object.values(ctx.config.routes).map((route) => {
863
- const lineage = getRouteLineage2(ctx.config.routes, route);
864
- const fullpath = lineage.map((route2) => route2.path).join("/");
865
- const params = parseParams2(fullpath);
875
+ if (route.id !== "root" && !route.path) return void 0;
876
+ const lineage2 = lineage(ctx.config.routes, route);
877
+ const fullpath2 = fullpath(lineage2);
878
+ const params = parse2(fullpath2);
866
879
  return t2.tsPropertySignature(
867
- t2.stringLiteral(fullpath),
880
+ t2.stringLiteral(fullpath2),
868
881
  t2.tsTypeAnnotation(
869
882
  t2.tsTypeLiteral(
870
883
  Object.entries(params).map(([param, isRequired]) => {
@@ -878,36 +891,11 @@ function register(ctx) {
878
891
  )
879
892
  )
880
893
  );
881
- })
894
+ }).filter((x) => x !== void 0)
882
895
  )
883
896
  );
884
897
  return [register2, generate(typeParams).code].join("\n\n");
885
898
  }
886
- function parseParams2(fullpath) {
887
- const result = {};
888
- let segments = fullpath.split("/");
889
- segments.forEach((segment) => {
890
- const match = segment.match(/^:([\w-]+)(\?)?/);
891
- if (!match) return;
892
- const param = match[1];
893
- const isRequired = match[2] === void 0;
894
- result[param] ||= isRequired;
895
- return;
896
- });
897
- const hasSplat = segments.at(-1) === "*";
898
- if (hasSplat) result["*"] = true;
899
- return result;
900
- }
901
- function getRouteLineage2(routes2, route) {
902
- const result = [];
903
- while (route) {
904
- result.push(route);
905
- if (!route.parentId) break;
906
- route = routes2[route.parentId];
907
- }
908
- result.reverse();
909
- return result;
910
- }
911
899
  var import_node_fs3, import_dedent2, Path4, import_picocolors3;
912
900
  var init_typegen = __esm({
913
901
  "typegen/index.ts"() {
@@ -920,6 +908,8 @@ var init_typegen = __esm({
920
908
  init_babel();
921
909
  init_generate();
922
910
  init_paths();
911
+ init_params();
912
+ init_route();
923
913
  }
924
914
  });
925
915
 
package/dist/config.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-004e483a8
2
+ * @react-router/dev v0.0.0-experimental-263c97949
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-004e483a8
2
+ * @react-router/dev v0.0.0-experimental-263c97949
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-004e483a8
2
+ * @react-router/dev v0.0.0-experimental-263c97949
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-004e483a8
2
+ * @react-router/dev v0.0.0-experimental-263c97949
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).filter((path7) => path7 !== void 0).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 } = {}) {
@@ -837,11 +837,12 @@ function register(ctx) {
837
837
  null,
838
838
  t2.tsTypeLiteral(
839
839
  Object.values(ctx.config.routes).map((route) => {
840
- const lineage = getRouteLineage2(ctx.config.routes, route);
841
- const fullpath = lineage.map((route2) => route2.path).join("/");
842
- const params = parseParams2(fullpath);
840
+ if (route.id !== "root" && !route.path) return void 0;
841
+ const lineage2 = lineage(ctx.config.routes, route);
842
+ const fullpath2 = fullpath(lineage2);
843
+ const params = parse2(fullpath2);
843
844
  return t2.tsPropertySignature(
844
- t2.stringLiteral(fullpath),
845
+ t2.stringLiteral(fullpath2),
845
846
  t2.tsTypeAnnotation(
846
847
  t2.tsTypeLiteral(
847
848
  Object.entries(params).map(([param, isRequired]) => {
@@ -855,36 +856,11 @@ function register(ctx) {
855
856
  )
856
857
  )
857
858
  );
858
- })
859
+ }).filter((x) => x !== void 0)
859
860
  )
860
861
  );
861
862
  return [register2, generate(typeParams).code].join("\n\n");
862
863
  }
863
- function parseParams2(fullpath) {
864
- const result = {};
865
- let segments = fullpath.split("/");
866
- segments.forEach((segment) => {
867
- const match = segment.match(/^:([\w-]+)(\?)?/);
868
- if (!match) return;
869
- const param = match[1];
870
- const isRequired = match[2] === void 0;
871
- result[param] ||= isRequired;
872
- return;
873
- });
874
- const hasSplat = segments.at(-1) === "*";
875
- if (hasSplat) result["*"] = true;
876
- return result;
877
- }
878
- function getRouteLineage2(routes, route) {
879
- const result = [];
880
- while (route) {
881
- result.push(route);
882
- if (!route.parentId) break;
883
- route = routes[route.parentId];
884
- }
885
- result.reverse();
886
- return result;
887
- }
888
864
 
889
865
  // vite/node-adapter.ts
890
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-004e483a8",
3
+ "version": "0.0.0-experimental-263c97949",
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-004e483a8"
91
+ "@react-router/node": "0.0.0-experimental-263c97949"
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-004e483a8",
121
- "@react-router/serve": "0.0.0-experimental-004e483a8"
120
+ "@react-router/serve": "0.0.0-experimental-263c97949",
121
+ "react-router": "^0.0.0-experimental-263c97949"
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-004e483a8",
128
- "react-router": "^0.0.0-experimental-004e483a8"
127
+ "react-router": "^0.0.0-experimental-263c97949",
128
+ "@react-router/serve": "^0.0.0-experimental-263c97949"
129
129
  },
130
130
  "peerDependenciesMeta": {
131
131
  "@react-router/serve": {