@tanstack/virtual-file-routes 1.54.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.
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ function rootRoute(file, children) {
4
+ return {
5
+ type: "root",
6
+ file,
7
+ children
8
+ };
9
+ }
10
+ function index(file) {
11
+ return {
12
+ type: "index",
13
+ file
14
+ };
15
+ }
16
+ function layout(idOrFile, fileOrChildren, children) {
17
+ if (Array.isArray(fileOrChildren)) {
18
+ return {
19
+ type: "layout",
20
+ file: idOrFile,
21
+ children: fileOrChildren
22
+ };
23
+ } else {
24
+ return {
25
+ type: "layout",
26
+ id: idOrFile,
27
+ file: fileOrChildren,
28
+ children
29
+ };
30
+ }
31
+ }
32
+ function route(path, file, children) {
33
+ return {
34
+ type: "route",
35
+ file,
36
+ path,
37
+ children
38
+ };
39
+ }
40
+ function physical(pathPrefix, directory) {
41
+ return {
42
+ type: "physical",
43
+ directory,
44
+ pathPrefix
45
+ };
46
+ }
47
+ exports.index = index;
48
+ exports.layout = layout;
49
+ exports.physical = physical;
50
+ exports.rootRoute = rootRoute;
51
+ exports.route = route;
52
+ //# sourceMappingURL=api.cjs.map
@@ -0,0 +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(\n path: string,\n file: string,\n children?: Array<VirtualRouteNode>,\n): Route {\n return {\n type: 'route',\n file,\n path,\n children,\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":";;AASgB,SAAA,UACd,MACA,UACkB;AACX,SAAA;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EAAA;AAEJ;AAEO,SAAS,MAAM,MAA0B;AACvC,SAAA;AAAA,IACL,MAAM;AAAA,IACN;AAAA,EAAA;AAEJ;AAYgB,SAAA,OACd,UACA,gBACA,UACa;AACT,MAAA,MAAM,QAAQ,cAAc,GAAG;AAC1B,WAAA;AAAA,MACL,MAAM;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IAAA;AAAA,EACZ,OACK;AACE,WAAA;AAAA,MACL,MAAM;AAAA,MACN,IAAI;AAAA,MACJ,MAAM;AAAA,MACN;AAAA,IAAA;AAAA,EAEJ;AACF;AAEgB,SAAA,MACd,MACA,MACA,UACO;AACA,SAAA;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;AAEgB,SAAA,SACd,YACA,WACiB;AACV,SAAA;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EAAA;AAEJ;;;;;;"}
@@ -0,0 +1,7 @@
1
+ import { IndexRoute, LayoutRoute, PhysicalSubtree, Route, VirtualRootRoute, VirtualRouteNode } from './types.cjs';
2
+ export declare function rootRoute(file: string, children?: Array<VirtualRouteNode>): VirtualRootRoute;
3
+ export declare function index(file: string): IndexRoute;
4
+ export declare function layout(file: string, children: Array<VirtualRouteNode>): LayoutRoute;
5
+ export declare function layout(id: string, file: string, children: Array<VirtualRouteNode>): LayoutRoute;
6
+ export declare function route(path: string, file: string, children?: Array<VirtualRouteNode>): Route;
7
+ export declare function physical(pathPrefix: string, directory: string): PhysicalSubtree;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const api = require("./api.cjs");
4
+ exports.index = api.index;
5
+ exports.layout = api.layout;
6
+ exports.physical = api.physical;
7
+ exports.rootRoute = api.rootRoute;
8
+ exports.route = api.route;
9
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ export { rootRoute, index, route, layout, physical } from './api.cjs';
2
+ export type { LayoutRoute, Route, IndexRoute, PhysicalSubtree, VirtualRootRoute, VirtualRouteNode, } from './types.cjs';
@@ -0,0 +1,27 @@
1
+ export type IndexRoute = {
2
+ type: 'index';
3
+ file: string;
4
+ };
5
+ export type LayoutRoute = {
6
+ type: 'layout';
7
+ id?: string;
8
+ file: string;
9
+ children?: Array<VirtualRouteNode>;
10
+ };
11
+ export type PhysicalSubtree = {
12
+ type: 'physical';
13
+ directory: string;
14
+ pathPrefix: string;
15
+ };
16
+ export type Route = {
17
+ type: 'route';
18
+ file: string;
19
+ path: string;
20
+ children?: Array<VirtualRouteNode>;
21
+ };
22
+ export type VirtualRouteNode = IndexRoute | LayoutRoute | Route | PhysicalSubtree;
23
+ export type VirtualRootRoute = {
24
+ type: 'root';
25
+ file: string;
26
+ children?: Array<VirtualRouteNode>;
27
+ };
@@ -0,0 +1,7 @@
1
+ import { IndexRoute, LayoutRoute, PhysicalSubtree, Route, VirtualRootRoute, VirtualRouteNode } from './types.js';
2
+ export declare function rootRoute(file: string, children?: Array<VirtualRouteNode>): VirtualRootRoute;
3
+ export declare function index(file: string): IndexRoute;
4
+ export declare function layout(file: string, children: Array<VirtualRouteNode>): LayoutRoute;
5
+ export declare function layout(id: string, file: string, children: Array<VirtualRouteNode>): LayoutRoute;
6
+ export declare function route(path: string, file: string, children?: Array<VirtualRouteNode>): Route;
7
+ export declare function physical(pathPrefix: string, directory: string): PhysicalSubtree;
@@ -0,0 +1,52 @@
1
+ function rootRoute(file, children) {
2
+ return {
3
+ type: "root",
4
+ file,
5
+ children
6
+ };
7
+ }
8
+ function index(file) {
9
+ return {
10
+ type: "index",
11
+ file
12
+ };
13
+ }
14
+ function layout(idOrFile, fileOrChildren, children) {
15
+ if (Array.isArray(fileOrChildren)) {
16
+ return {
17
+ type: "layout",
18
+ file: idOrFile,
19
+ children: fileOrChildren
20
+ };
21
+ } else {
22
+ return {
23
+ type: "layout",
24
+ id: idOrFile,
25
+ file: fileOrChildren,
26
+ children
27
+ };
28
+ }
29
+ }
30
+ function route(path, file, children) {
31
+ return {
32
+ type: "route",
33
+ file,
34
+ path,
35
+ children
36
+ };
37
+ }
38
+ function physical(pathPrefix, directory) {
39
+ return {
40
+ type: "physical",
41
+ directory,
42
+ pathPrefix
43
+ };
44
+ }
45
+ export {
46
+ index,
47
+ layout,
48
+ physical,
49
+ rootRoute,
50
+ route
51
+ };
52
+ //# sourceMappingURL=api.js.map
@@ -0,0 +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(\n path: string,\n file: string,\n children?: Array<VirtualRouteNode>,\n): Route {\n return {\n type: 'route',\n file,\n path,\n children,\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":"AASgB,SAAA,UACd,MACA,UACkB;AACX,SAAA;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EAAA;AAEJ;AAEO,SAAS,MAAM,MAA0B;AACvC,SAAA;AAAA,IACL,MAAM;AAAA,IACN;AAAA,EAAA;AAEJ;AAYgB,SAAA,OACd,UACA,gBACA,UACa;AACT,MAAA,MAAM,QAAQ,cAAc,GAAG;AAC1B,WAAA;AAAA,MACL,MAAM;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IAAA;AAAA,EACZ,OACK;AACE,WAAA;AAAA,MACL,MAAM;AAAA,MACN,IAAI;AAAA,MACJ,MAAM;AAAA,MACN;AAAA,IAAA;AAAA,EAEJ;AACF;AAEgB,SAAA,MACd,MACA,MACA,UACO;AACA,SAAA;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;AAEgB,SAAA,SACd,YACA,WACiB;AACV,SAAA;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EAAA;AAEJ;"}
@@ -0,0 +1,2 @@
1
+ export { rootRoute, index, route, layout, physical } from './api.js';
2
+ export type { LayoutRoute, Route, IndexRoute, PhysicalSubtree, VirtualRootRoute, VirtualRouteNode, } from './types.js';
@@ -0,0 +1,9 @@
1
+ import { index, layout, physical, rootRoute, route } from "./api.js";
2
+ export {
3
+ index,
4
+ layout,
5
+ physical,
6
+ rootRoute,
7
+ route
8
+ };
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,27 @@
1
+ export type IndexRoute = {
2
+ type: 'index';
3
+ file: string;
4
+ };
5
+ export type LayoutRoute = {
6
+ type: 'layout';
7
+ id?: string;
8
+ file: string;
9
+ children?: Array<VirtualRouteNode>;
10
+ };
11
+ export type PhysicalSubtree = {
12
+ type: 'physical';
13
+ directory: string;
14
+ pathPrefix: string;
15
+ };
16
+ export type Route = {
17
+ type: 'route';
18
+ file: string;
19
+ path: string;
20
+ children?: Array<VirtualRouteNode>;
21
+ };
22
+ export type VirtualRouteNode = IndexRoute | LayoutRoute | Route | PhysicalSubtree;
23
+ export type VirtualRootRoute = {
24
+ type: 'root';
25
+ file: string;
26
+ children?: Array<VirtualRouteNode>;
27
+ };
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@tanstack/virtual-file-routes",
3
+ "version": "1.54.0",
4
+ "description": "Modern and scalable routing for React applications",
5
+ "author": "Tanner Linsley",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/TanStack/router.git",
10
+ "directory": "packages/virtual-file-routes"
11
+ },
12
+ "homepage": "https://tanstack.com/router",
13
+ "funding": {
14
+ "type": "github",
15
+ "url": "https://github.com/sponsors/tannerlinsley"
16
+ },
17
+ "keywords": [
18
+ "react",
19
+ "location",
20
+ "router",
21
+ "routing",
22
+ "async",
23
+ "async router",
24
+ "typescript"
25
+ ],
26
+ "scripts": {
27
+ "clean": "rimraf ./dist && rimraf ./coverage",
28
+ "test:eslint": "eslint ./src",
29
+ "test:build": "publint --strict && attw --ignore-rules no-resolution --pack .",
30
+ "build": "vite build"
31
+ },
32
+ "type": "module",
33
+ "types": "dist/esm/index.d.ts",
34
+ "main": "dist/cjs/index.cjs",
35
+ "module": "dist/esm/index.js",
36
+ "exports": {
37
+ ".": {
38
+ "import": {
39
+ "types": "./dist/esm/index.d.ts",
40
+ "default": "./dist/esm/index.js"
41
+ },
42
+ "require": {
43
+ "types": "./dist/cjs/index.d.cts",
44
+ "default": "./dist/cjs/index.cjs"
45
+ }
46
+ },
47
+ "./package.json": "./package.json"
48
+ },
49
+ "sideEffects": false,
50
+ "files": [
51
+ "dist",
52
+ "src"
53
+ ],
54
+ "engines": {
55
+ "node": ">=12"
56
+ }
57
+ }
package/src/api.ts ADDED
@@ -0,0 +1,81 @@
1
+ import type {
2
+ IndexRoute,
3
+ LayoutRoute,
4
+ PhysicalSubtree,
5
+ Route,
6
+ VirtualRootRoute,
7
+ VirtualRouteNode,
8
+ } from './types'
9
+
10
+ export function rootRoute(
11
+ file: string,
12
+ children?: Array<VirtualRouteNode>,
13
+ ): VirtualRootRoute {
14
+ return {
15
+ type: 'root',
16
+ file,
17
+ children,
18
+ }
19
+ }
20
+
21
+ export function index(file: string): IndexRoute {
22
+ return {
23
+ type: 'index',
24
+ file,
25
+ }
26
+ }
27
+
28
+ export function layout(
29
+ file: string,
30
+ children: Array<VirtualRouteNode>,
31
+ ): LayoutRoute
32
+ export function layout(
33
+ id: string,
34
+ file: string,
35
+ children: Array<VirtualRouteNode>,
36
+ ): LayoutRoute
37
+
38
+ export function layout(
39
+ idOrFile: string,
40
+ fileOrChildren: string | Array<VirtualRouteNode>,
41
+ children?: Array<VirtualRouteNode>,
42
+ ): LayoutRoute {
43
+ if (Array.isArray(fileOrChildren)) {
44
+ return {
45
+ type: 'layout',
46
+ file: idOrFile,
47
+ children: fileOrChildren,
48
+ }
49
+ } else {
50
+ return {
51
+ type: 'layout',
52
+ id: idOrFile,
53
+ file: fileOrChildren,
54
+ children,
55
+ }
56
+ }
57
+ }
58
+
59
+ export function route(
60
+ path: string,
61
+ file: string,
62
+ children?: Array<VirtualRouteNode>,
63
+ ): Route {
64
+ return {
65
+ type: 'route',
66
+ file,
67
+ path,
68
+ children,
69
+ }
70
+ }
71
+
72
+ export function physical(
73
+ pathPrefix: string,
74
+ directory: string,
75
+ ): PhysicalSubtree {
76
+ return {
77
+ type: 'physical',
78
+ directory,
79
+ pathPrefix,
80
+ }
81
+ }
package/src/index.ts ADDED
@@ -0,0 +1,9 @@
1
+ export { rootRoute, index, route, layout, physical } from './api'
2
+ export type {
3
+ LayoutRoute,
4
+ Route,
5
+ IndexRoute,
6
+ PhysicalSubtree,
7
+ VirtualRootRoute,
8
+ VirtualRouteNode,
9
+ } from './types'
package/src/types.ts ADDED
@@ -0,0 +1,35 @@
1
+ export type IndexRoute = {
2
+ type: 'index'
3
+ file: string
4
+ }
5
+
6
+ export type LayoutRoute = {
7
+ type: 'layout'
8
+ id?: string
9
+ file: string
10
+ children?: Array<VirtualRouteNode>
11
+ }
12
+
13
+ export type PhysicalSubtree = {
14
+ type: 'physical'
15
+ directory: string
16
+ pathPrefix: string
17
+ }
18
+
19
+ export type Route = {
20
+ type: 'route'
21
+ file: string
22
+ path: string
23
+ children?: Array<VirtualRouteNode>
24
+ }
25
+ export type VirtualRouteNode =
26
+ | IndexRoute
27
+ | LayoutRoute
28
+ | Route
29
+ | PhysicalSubtree
30
+
31
+ export type VirtualRootRoute = {
32
+ type: 'root'
33
+ file: string
34
+ children?: Array<VirtualRouteNode>
35
+ }