@tanstack/virtual-file-routes 1.140.0 → 1.145.4

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/cjs/api.cjs CHANGED
@@ -44,11 +44,18 @@ function route(path, fileOrChildren, children) {
44
44
  children: fileOrChildren
45
45
  };
46
46
  }
47
- function physical(pathPrefix, directory) {
47
+ function physical(pathPrefixOrDirectory, directory) {
48
+ if (directory === void 0) {
49
+ return {
50
+ type: "physical",
51
+ directory: pathPrefixOrDirectory,
52
+ pathPrefix: ""
53
+ };
54
+ }
48
55
  return {
49
56
  type: "physical",
50
57
  directory,
51
- pathPrefix
58
+ pathPrefix: pathPrefixOrDirectory
52
59
  };
53
60
  }
54
61
  exports.index = index;
@@ -1 +1 @@
1
- {"version":3,"file":"api.cjs","sources":["../../src/api.ts"],"sourcesContent":["import type {\n IndexRoute,\n LayoutRoute,\n PhysicalSubtree,\n Route,\n VirtualRootRoute,\n VirtualRouteNode,\n} from './types'\n\nexport function rootRoute(\n file: string,\n children?: Array<VirtualRouteNode>,\n): VirtualRootRoute {\n return {\n type: 'root',\n file,\n children,\n }\n}\n\nexport function index(file: string): IndexRoute {\n return {\n type: 'index',\n file,\n }\n}\n\nexport function layout(\n file: string,\n children: Array<VirtualRouteNode>,\n): LayoutRoute\nexport function layout(\n id: string,\n file: string,\n children: Array<VirtualRouteNode>,\n): LayoutRoute\n\nexport function layout(\n idOrFile: string,\n fileOrChildren: string | Array<VirtualRouteNode>,\n children?: Array<VirtualRouteNode>,\n): LayoutRoute {\n if (Array.isArray(fileOrChildren)) {\n return {\n type: 'layout',\n file: idOrFile,\n children: fileOrChildren,\n }\n } else {\n return {\n type: 'layout',\n id: idOrFile,\n file: fileOrChildren,\n children,\n }\n }\n}\n\nexport function route(path: string, children: Array<VirtualRouteNode>): Route\nexport function route(path: string, file: string): Route\nexport function route(\n path: string,\n file: string,\n children: Array<VirtualRouteNode>,\n): Route\nexport function route(\n path: string,\n fileOrChildren: string | Array<VirtualRouteNode>,\n children?: Array<VirtualRouteNode>,\n): Route {\n if (typeof fileOrChildren === 'string') {\n return {\n type: 'route',\n file: fileOrChildren,\n path,\n children,\n }\n }\n return {\n type: 'route',\n path,\n children: fileOrChildren,\n }\n}\n\nexport function physical(\n pathPrefix: string,\n directory: string,\n): PhysicalSubtree {\n return {\n type: 'physical',\n directory,\n pathPrefix,\n }\n}\n"],"names":[],"mappings":";;AASO,SAAS,UACd,MACA,UACkB;AAClB,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EAAA;AAEJ;AAEO,SAAS,MAAM,MAA0B;AAC9C,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,EAAA;AAEJ;AAYO,SAAS,OACd,UACA,gBACA,UACa;AACb,MAAI,MAAM,QAAQ,cAAc,GAAG;AACjC,WAAO;AAAA,MACL,MAAM;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IAAA;AAAA,EAEd,OAAO;AACL,WAAO;AAAA,MACL,MAAM;AAAA,MACN,IAAI;AAAA,MACJ,MAAM;AAAA,MACN;AAAA,IAAA;AAAA,EAEJ;AACF;AASO,SAAS,MACd,MACA,gBACA,UACO;AACP,MAAI,OAAO,mBAAmB,UAAU;AACtC,WAAO;AAAA,MACL,MAAM;AAAA,MACN,MAAM;AAAA,MACN;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AACA,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA,UAAU;AAAA,EAAA;AAEd;AAEO,SAAS,SACd,YACA,WACiB;AACjB,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EAAA;AAEJ;;;;;;"}
1
+ {"version":3,"file":"api.cjs","sources":["../../src/api.ts"],"sourcesContent":["import type {\n IndexRoute,\n LayoutRoute,\n PhysicalSubtree,\n Route,\n VirtualRootRoute,\n VirtualRouteNode,\n} from './types'\n\nexport function rootRoute(\n file: string,\n children?: Array<VirtualRouteNode>,\n): VirtualRootRoute {\n return {\n type: 'root',\n file,\n children,\n }\n}\n\nexport function index(file: string): IndexRoute {\n return {\n type: 'index',\n file,\n }\n}\n\nexport function layout(\n file: string,\n children: Array<VirtualRouteNode>,\n): LayoutRoute\nexport function layout(\n id: string,\n file: string,\n children: Array<VirtualRouteNode>,\n): LayoutRoute\n\nexport function layout(\n idOrFile: string,\n fileOrChildren: string | Array<VirtualRouteNode>,\n children?: Array<VirtualRouteNode>,\n): LayoutRoute {\n if (Array.isArray(fileOrChildren)) {\n return {\n type: 'layout',\n file: idOrFile,\n children: fileOrChildren,\n }\n } else {\n return {\n type: 'layout',\n id: idOrFile,\n file: fileOrChildren,\n children,\n }\n }\n}\n\nexport function route(path: string, children: Array<VirtualRouteNode>): Route\nexport function route(path: string, file: string): Route\nexport function route(\n path: string,\n file: string,\n children: Array<VirtualRouteNode>,\n): Route\nexport function route(\n path: string,\n fileOrChildren: string | Array<VirtualRouteNode>,\n children?: Array<VirtualRouteNode>,\n): Route {\n if (typeof fileOrChildren === 'string') {\n return {\n type: 'route',\n file: fileOrChildren,\n path,\n children,\n }\n }\n return {\n type: 'route',\n path,\n children: fileOrChildren,\n }\n}\n\n/**\n * Mount a physical directory of route files at a given path prefix.\n *\n * @param pathPrefix - The path prefix to mount the directory at. Use empty string '' to merge routes at the current level.\n * @param directory - The directory containing the route files, relative to the routes directory.\n */\nexport function physical(pathPrefix: string, directory: string): PhysicalSubtree\n/**\n * Mount a physical directory of route files at the current level (empty path prefix).\n * This is equivalent to `physical('', directory)`.\n *\n * @param directory - The directory containing the route files, relative to the routes directory.\n */\nexport function physical(directory: string): PhysicalSubtree\nexport function physical(\n pathPrefixOrDirectory: string,\n directory?: string,\n): PhysicalSubtree {\n if (directory === undefined) {\n // Single argument: directory only, use empty path prefix\n return {\n type: 'physical',\n directory: pathPrefixOrDirectory,\n pathPrefix: '',\n }\n }\n // Two arguments: pathPrefix and directory\n return {\n type: 'physical',\n directory,\n pathPrefix: pathPrefixOrDirectory,\n }\n}\n"],"names":[],"mappings":";;AASO,SAAS,UACd,MACA,UACkB;AAClB,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EAAA;AAEJ;AAEO,SAAS,MAAM,MAA0B;AAC9C,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,EAAA;AAEJ;AAYO,SAAS,OACd,UACA,gBACA,UACa;AACb,MAAI,MAAM,QAAQ,cAAc,GAAG;AACjC,WAAO;AAAA,MACL,MAAM;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IAAA;AAAA,EAEd,OAAO;AACL,WAAO;AAAA,MACL,MAAM;AAAA,MACN,IAAI;AAAA,MACJ,MAAM;AAAA,MACN;AAAA,IAAA;AAAA,EAEJ;AACF;AASO,SAAS,MACd,MACA,gBACA,UACO;AACP,MAAI,OAAO,mBAAmB,UAAU;AACtC,WAAO;AAAA,MACL,MAAM;AAAA,MACN,MAAM;AAAA,MACN;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AACA,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA,UAAU;AAAA,EAAA;AAEd;AAgBO,SAAS,SACd,uBACA,WACiB;AACjB,MAAI,cAAc,QAAW;AAE3B,WAAO;AAAA,MACL,MAAM;AAAA,MACN,WAAW;AAAA,MACX,YAAY;AAAA,IAAA;AAAA,EAEhB;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA,YAAY;AAAA,EAAA;AAEhB;;;;;;"}
@@ -6,4 +6,17 @@ export declare function layout(id: string, file: string, children: Array<Virtual
6
6
  export declare function route(path: string, children: Array<VirtualRouteNode>): Route;
7
7
  export declare function route(path: string, file: string): Route;
8
8
  export declare function route(path: string, file: string, children: Array<VirtualRouteNode>): Route;
9
+ /**
10
+ * Mount a physical directory of route files at a given path prefix.
11
+ *
12
+ * @param pathPrefix - The path prefix to mount the directory at. Use empty string '' to merge routes at the current level.
13
+ * @param directory - The directory containing the route files, relative to the routes directory.
14
+ */
9
15
  export declare function physical(pathPrefix: string, directory: string): PhysicalSubtree;
16
+ /**
17
+ * Mount a physical directory of route files at the current level (empty path prefix).
18
+ * This is equivalent to `physical('', directory)`.
19
+ *
20
+ * @param directory - The directory containing the route files, relative to the routes directory.
21
+ */
22
+ export declare function physical(directory: string): PhysicalSubtree;
package/dist/esm/api.d.ts CHANGED
@@ -6,4 +6,17 @@ export declare function layout(id: string, file: string, children: Array<Virtual
6
6
  export declare function route(path: string, children: Array<VirtualRouteNode>): Route;
7
7
  export declare function route(path: string, file: string): Route;
8
8
  export declare function route(path: string, file: string, children: Array<VirtualRouteNode>): Route;
9
+ /**
10
+ * Mount a physical directory of route files at a given path prefix.
11
+ *
12
+ * @param pathPrefix - The path prefix to mount the directory at. Use empty string '' to merge routes at the current level.
13
+ * @param directory - The directory containing the route files, relative to the routes directory.
14
+ */
9
15
  export declare function physical(pathPrefix: string, directory: string): PhysicalSubtree;
16
+ /**
17
+ * Mount a physical directory of route files at the current level (empty path prefix).
18
+ * This is equivalent to `physical('', directory)`.
19
+ *
20
+ * @param directory - The directory containing the route files, relative to the routes directory.
21
+ */
22
+ export declare function physical(directory: string): PhysicalSubtree;
package/dist/esm/api.js CHANGED
@@ -42,11 +42,18 @@ function route(path, fileOrChildren, children) {
42
42
  children: fileOrChildren
43
43
  };
44
44
  }
45
- function physical(pathPrefix, directory) {
45
+ function physical(pathPrefixOrDirectory, directory) {
46
+ if (directory === void 0) {
47
+ return {
48
+ type: "physical",
49
+ directory: pathPrefixOrDirectory,
50
+ pathPrefix: ""
51
+ };
52
+ }
46
53
  return {
47
54
  type: "physical",
48
55
  directory,
49
- pathPrefix
56
+ pathPrefix: pathPrefixOrDirectory
50
57
  };
51
58
  }
52
59
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sources":["../../src/api.ts"],"sourcesContent":["import type {\n IndexRoute,\n LayoutRoute,\n PhysicalSubtree,\n Route,\n VirtualRootRoute,\n VirtualRouteNode,\n} from './types'\n\nexport function rootRoute(\n file: string,\n children?: Array<VirtualRouteNode>,\n): VirtualRootRoute {\n return {\n type: 'root',\n file,\n children,\n }\n}\n\nexport function index(file: string): IndexRoute {\n return {\n type: 'index',\n file,\n }\n}\n\nexport function layout(\n file: string,\n children: Array<VirtualRouteNode>,\n): LayoutRoute\nexport function layout(\n id: string,\n file: string,\n children: Array<VirtualRouteNode>,\n): LayoutRoute\n\nexport function layout(\n idOrFile: string,\n fileOrChildren: string | Array<VirtualRouteNode>,\n children?: Array<VirtualRouteNode>,\n): LayoutRoute {\n if (Array.isArray(fileOrChildren)) {\n return {\n type: 'layout',\n file: idOrFile,\n children: fileOrChildren,\n }\n } else {\n return {\n type: 'layout',\n id: idOrFile,\n file: fileOrChildren,\n children,\n }\n }\n}\n\nexport function route(path: string, children: Array<VirtualRouteNode>): Route\nexport function route(path: string, file: string): Route\nexport function route(\n path: string,\n file: string,\n children: Array<VirtualRouteNode>,\n): Route\nexport function route(\n path: string,\n fileOrChildren: string | Array<VirtualRouteNode>,\n children?: Array<VirtualRouteNode>,\n): Route {\n if (typeof fileOrChildren === 'string') {\n return {\n type: 'route',\n file: fileOrChildren,\n path,\n children,\n }\n }\n return {\n type: 'route',\n path,\n children: fileOrChildren,\n }\n}\n\nexport function physical(\n pathPrefix: string,\n directory: string,\n): PhysicalSubtree {\n return {\n type: 'physical',\n directory,\n pathPrefix,\n }\n}\n"],"names":[],"mappings":"AASO,SAAS,UACd,MACA,UACkB;AAClB,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EAAA;AAEJ;AAEO,SAAS,MAAM,MAA0B;AAC9C,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,EAAA;AAEJ;AAYO,SAAS,OACd,UACA,gBACA,UACa;AACb,MAAI,MAAM,QAAQ,cAAc,GAAG;AACjC,WAAO;AAAA,MACL,MAAM;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IAAA;AAAA,EAEd,OAAO;AACL,WAAO;AAAA,MACL,MAAM;AAAA,MACN,IAAI;AAAA,MACJ,MAAM;AAAA,MACN;AAAA,IAAA;AAAA,EAEJ;AACF;AASO,SAAS,MACd,MACA,gBACA,UACO;AACP,MAAI,OAAO,mBAAmB,UAAU;AACtC,WAAO;AAAA,MACL,MAAM;AAAA,MACN,MAAM;AAAA,MACN;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AACA,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA,UAAU;AAAA,EAAA;AAEd;AAEO,SAAS,SACd,YACA,WACiB;AACjB,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"api.js","sources":["../../src/api.ts"],"sourcesContent":["import type {\n IndexRoute,\n LayoutRoute,\n PhysicalSubtree,\n Route,\n VirtualRootRoute,\n VirtualRouteNode,\n} from './types'\n\nexport function rootRoute(\n file: string,\n children?: Array<VirtualRouteNode>,\n): VirtualRootRoute {\n return {\n type: 'root',\n file,\n children,\n }\n}\n\nexport function index(file: string): IndexRoute {\n return {\n type: 'index',\n file,\n }\n}\n\nexport function layout(\n file: string,\n children: Array<VirtualRouteNode>,\n): LayoutRoute\nexport function layout(\n id: string,\n file: string,\n children: Array<VirtualRouteNode>,\n): LayoutRoute\n\nexport function layout(\n idOrFile: string,\n fileOrChildren: string | Array<VirtualRouteNode>,\n children?: Array<VirtualRouteNode>,\n): LayoutRoute {\n if (Array.isArray(fileOrChildren)) {\n return {\n type: 'layout',\n file: idOrFile,\n children: fileOrChildren,\n }\n } else {\n return {\n type: 'layout',\n id: idOrFile,\n file: fileOrChildren,\n children,\n }\n }\n}\n\nexport function route(path: string, children: Array<VirtualRouteNode>): Route\nexport function route(path: string, file: string): Route\nexport function route(\n path: string,\n file: string,\n children: Array<VirtualRouteNode>,\n): Route\nexport function route(\n path: string,\n fileOrChildren: string | Array<VirtualRouteNode>,\n children?: Array<VirtualRouteNode>,\n): Route {\n if (typeof fileOrChildren === 'string') {\n return {\n type: 'route',\n file: fileOrChildren,\n path,\n children,\n }\n }\n return {\n type: 'route',\n path,\n children: fileOrChildren,\n }\n}\n\n/**\n * Mount a physical directory of route files at a given path prefix.\n *\n * @param pathPrefix - The path prefix to mount the directory at. Use empty string '' to merge routes at the current level.\n * @param directory - The directory containing the route files, relative to the routes directory.\n */\nexport function physical(pathPrefix: string, directory: string): PhysicalSubtree\n/**\n * Mount a physical directory of route files at the current level (empty path prefix).\n * This is equivalent to `physical('', directory)`.\n *\n * @param directory - The directory containing the route files, relative to the routes directory.\n */\nexport function physical(directory: string): PhysicalSubtree\nexport function physical(\n pathPrefixOrDirectory: string,\n directory?: string,\n): PhysicalSubtree {\n if (directory === undefined) {\n // Single argument: directory only, use empty path prefix\n return {\n type: 'physical',\n directory: pathPrefixOrDirectory,\n pathPrefix: '',\n }\n }\n // Two arguments: pathPrefix and directory\n return {\n type: 'physical',\n directory,\n pathPrefix: pathPrefixOrDirectory,\n }\n}\n"],"names":[],"mappings":"AASO,SAAS,UACd,MACA,UACkB;AAClB,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EAAA;AAEJ;AAEO,SAAS,MAAM,MAA0B;AAC9C,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,EAAA;AAEJ;AAYO,SAAS,OACd,UACA,gBACA,UACa;AACb,MAAI,MAAM,QAAQ,cAAc,GAAG;AACjC,WAAO;AAAA,MACL,MAAM;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IAAA;AAAA,EAEd,OAAO;AACL,WAAO;AAAA,MACL,MAAM;AAAA,MACN,IAAI;AAAA,MACJ,MAAM;AAAA,MACN;AAAA,IAAA;AAAA,EAEJ;AACF;AASO,SAAS,MACd,MACA,gBACA,UACO;AACP,MAAI,OAAO,mBAAmB,UAAU;AACtC,WAAO;AAAA,MACL,MAAM;AAAA,MACN,MAAM;AAAA,MACN;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AACA,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA,UAAU;AAAA,EAAA;AAEd;AAgBO,SAAS,SACd,uBACA,WACiB;AACjB,MAAI,cAAc,QAAW;AAE3B,WAAO;AAAA,MACL,MAAM;AAAA,MACN,WAAW;AAAA,MACX,YAAY;AAAA,IAAA;AAAA,EAEhB;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA,YAAY;AAAA,EAAA;AAEhB;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/virtual-file-routes",
3
- "version": "1.140.0",
3
+ "version": "1.145.4",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
package/src/api.ts CHANGED
@@ -83,13 +83,36 @@ export function route(
83
83
  }
84
84
  }
85
85
 
86
+ /**
87
+ * Mount a physical directory of route files at a given path prefix.
88
+ *
89
+ * @param pathPrefix - The path prefix to mount the directory at. Use empty string '' to merge routes at the current level.
90
+ * @param directory - The directory containing the route files, relative to the routes directory.
91
+ */
92
+ export function physical(pathPrefix: string, directory: string): PhysicalSubtree
93
+ /**
94
+ * Mount a physical directory of route files at the current level (empty path prefix).
95
+ * This is equivalent to `physical('', directory)`.
96
+ *
97
+ * @param directory - The directory containing the route files, relative to the routes directory.
98
+ */
99
+ export function physical(directory: string): PhysicalSubtree
86
100
  export function physical(
87
- pathPrefix: string,
88
- directory: string,
101
+ pathPrefixOrDirectory: string,
102
+ directory?: string,
89
103
  ): PhysicalSubtree {
104
+ if (directory === undefined) {
105
+ // Single argument: directory only, use empty path prefix
106
+ return {
107
+ type: 'physical',
108
+ directory: pathPrefixOrDirectory,
109
+ pathPrefix: '',
110
+ }
111
+ }
112
+ // Two arguments: pathPrefix and directory
90
113
  return {
91
114
  type: 'physical',
92
115
  directory,
93
- pathPrefix,
116
+ pathPrefix: pathPrefixOrDirectory,
94
117
  }
95
118
  }