@tanstack/virtual-file-routes 1.161.5 → 1.161.6
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 +45 -51
- package/dist/cjs/api.cjs.map +1 -1
- package/dist/cjs/defineConfig.cjs +5 -4
- package/dist/cjs/defineConfig.cjs.map +1 -1
- package/dist/cjs/index.cjs +8 -10
- package/dist/esm/api.js +46 -56
- package/dist/esm/api.js.map +1 -1
- package/dist/esm/defineConfig.js +6 -5
- package/dist/esm/defineConfig.js.map +1 -1
- package/dist/esm/index.js +1 -9
- package/package.json +1 -1
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/esm/index.js.map +0 -1
package/dist/cjs/api.cjs
CHANGED
|
@@ -1,66 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
1
|
+
//#region src/api.ts
|
|
3
2
|
function rootRoute(file, children) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
return {
|
|
4
|
+
type: "root",
|
|
5
|
+
file,
|
|
6
|
+
children
|
|
7
|
+
};
|
|
9
8
|
}
|
|
10
9
|
function index(file) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
return {
|
|
11
|
+
type: "index",
|
|
12
|
+
file
|
|
13
|
+
};
|
|
15
14
|
}
|
|
16
15
|
function layout(idOrFile, fileOrChildren, children) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
children
|
|
29
|
-
};
|
|
30
|
-
}
|
|
16
|
+
if (Array.isArray(fileOrChildren)) return {
|
|
17
|
+
type: "layout",
|
|
18
|
+
file: idOrFile,
|
|
19
|
+
children: fileOrChildren
|
|
20
|
+
};
|
|
21
|
+
else return {
|
|
22
|
+
type: "layout",
|
|
23
|
+
id: idOrFile,
|
|
24
|
+
file: fileOrChildren,
|
|
25
|
+
children
|
|
26
|
+
};
|
|
31
27
|
}
|
|
32
28
|
function route(path, fileOrChildren, children) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
children: fileOrChildren
|
|
45
|
-
};
|
|
29
|
+
if (typeof fileOrChildren === "string") return {
|
|
30
|
+
type: "route",
|
|
31
|
+
file: fileOrChildren,
|
|
32
|
+
path,
|
|
33
|
+
children
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
type: "route",
|
|
37
|
+
path,
|
|
38
|
+
children: fileOrChildren
|
|
39
|
+
};
|
|
46
40
|
}
|
|
47
41
|
function physical(pathPrefixOrDirectory, directory) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
pathPrefix: pathPrefixOrDirectory
|
|
59
|
-
};
|
|
42
|
+
if (directory === void 0) return {
|
|
43
|
+
type: "physical",
|
|
44
|
+
directory: pathPrefixOrDirectory,
|
|
45
|
+
pathPrefix: ""
|
|
46
|
+
};
|
|
47
|
+
return {
|
|
48
|
+
type: "physical",
|
|
49
|
+
directory,
|
|
50
|
+
pathPrefix: pathPrefixOrDirectory
|
|
51
|
+
};
|
|
60
52
|
}
|
|
53
|
+
//#endregion
|
|
61
54
|
exports.index = index;
|
|
62
55
|
exports.layout = layout;
|
|
63
56
|
exports.physical = physical;
|
|
64
57
|
exports.rootRoute = rootRoute;
|
|
65
58
|
exports.route = route;
|
|
66
|
-
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=api.cjs.map
|
package/dist/cjs/api.cjs.map
CHANGED
|
@@ -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\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"],"
|
|
1
|
+
{"version":3,"file":"api.cjs","names":[],"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"],"mappings":";AASA,SAAgB,UACd,MACA,UACkB;AAClB,QAAO;EACL,MAAM;EACN;EACA;EACD;;AAGH,SAAgB,MAAM,MAA0B;AAC9C,QAAO;EACL,MAAM;EACN;EACD;;AAaH,SAAgB,OACd,UACA,gBACA,UACa;AACb,KAAI,MAAM,QAAQ,eAAe,CAC/B,QAAO;EACL,MAAM;EACN,MAAM;EACN,UAAU;EACX;KAED,QAAO;EACL,MAAM;EACN,IAAI;EACJ,MAAM;EACN;EACD;;AAWL,SAAgB,MACd,MACA,gBACA,UACO;AACP,KAAI,OAAO,mBAAmB,SAC5B,QAAO;EACL,MAAM;EACN,MAAM;EACN;EACA;EACD;AAEH,QAAO;EACL,MAAM;EACN;EACA,UAAU;EACX;;AAiBH,SAAgB,SACd,uBACA,WACiB;AACjB,KAAI,cAAc,KAAA,EAEhB,QAAO;EACL,MAAM;EACN,WAAW;EACX,YAAY;EACb;AAGH,QAAO;EACL,MAAM;EACN;EACA,YAAY;EACb"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
1
|
+
//#region src/defineConfig.ts
|
|
3
2
|
function defineVirtualSubtreeConfig(config) {
|
|
4
|
-
|
|
3
|
+
return config;
|
|
5
4
|
}
|
|
5
|
+
//#endregion
|
|
6
6
|
exports.defineVirtualSubtreeConfig = defineVirtualSubtreeConfig;
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=defineConfig.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineConfig.cjs","sources":["../../src/defineConfig.ts"],"sourcesContent":["import type { VirtualRouteNode } from './types'\n\n// this is adapted from vite/src/node/config.ts\n\nexport type ConfigFnObject<TConfig> = () => TConfig\nexport type ConfigFnPromise<TConfig> = () => Promise<TConfig>\nexport type ConfigFn<TConfig> = () => TConfig | Promise<TConfig>\n\nexport type ConfigExport<TConfig> =\n | TConfig\n | Promise<TConfig>\n | ConfigFnObject<TConfig>\n | ConfigFnPromise<TConfig>\n | ConfigFn<TConfig>\n\nexport type VirtualRouteSubtreeConfig = Array<VirtualRouteNode>\n\n/**\n * Type helper to make it easier to use __virtual.ts\n * accepts a direct {@link VirtualRouteSubtreeConfig} object, or a function that returns it.\n */\nexport function defineVirtualSubtreeConfig(\n config: VirtualRouteSubtreeConfig,\n): VirtualRouteSubtreeConfig\nexport function defineVirtualSubtreeConfig(\n config: Promise<VirtualRouteSubtreeConfig>,\n): Promise<VirtualRouteSubtreeConfig>\nexport function defineVirtualSubtreeConfig(\n config: ConfigFnObject<VirtualRouteSubtreeConfig>,\n): ConfigFnObject<VirtualRouteSubtreeConfig>\nexport function defineVirtualSubtreeConfig(\n config: ConfigExport<VirtualRouteSubtreeConfig>,\n): ConfigExport<VirtualRouteSubtreeConfig>\nexport function defineVirtualSubtreeConfig(\n config: ConfigExport<VirtualRouteSubtreeConfig>,\n): ConfigExport<VirtualRouteSubtreeConfig> {\n return config\n}\n"],"
|
|
1
|
+
{"version":3,"file":"defineConfig.cjs","names":[],"sources":["../../src/defineConfig.ts"],"sourcesContent":["import type { VirtualRouteNode } from './types'\n\n// this is adapted from vite/src/node/config.ts\n\nexport type ConfigFnObject<TConfig> = () => TConfig\nexport type ConfigFnPromise<TConfig> = () => Promise<TConfig>\nexport type ConfigFn<TConfig> = () => TConfig | Promise<TConfig>\n\nexport type ConfigExport<TConfig> =\n | TConfig\n | Promise<TConfig>\n | ConfigFnObject<TConfig>\n | ConfigFnPromise<TConfig>\n | ConfigFn<TConfig>\n\nexport type VirtualRouteSubtreeConfig = Array<VirtualRouteNode>\n\n/**\n * Type helper to make it easier to use __virtual.ts\n * accepts a direct {@link VirtualRouteSubtreeConfig} object, or a function that returns it.\n */\nexport function defineVirtualSubtreeConfig(\n config: VirtualRouteSubtreeConfig,\n): VirtualRouteSubtreeConfig\nexport function defineVirtualSubtreeConfig(\n config: Promise<VirtualRouteSubtreeConfig>,\n): Promise<VirtualRouteSubtreeConfig>\nexport function defineVirtualSubtreeConfig(\n config: ConfigFnObject<VirtualRouteSubtreeConfig>,\n): ConfigFnObject<VirtualRouteSubtreeConfig>\nexport function defineVirtualSubtreeConfig(\n config: ConfigExport<VirtualRouteSubtreeConfig>,\n): ConfigExport<VirtualRouteSubtreeConfig>\nexport function defineVirtualSubtreeConfig(\n config: ConfigExport<VirtualRouteSubtreeConfig>,\n): ConfigExport<VirtualRouteSubtreeConfig> {\n return config\n}\n"],"mappings":";AAiCA,SAAgB,2BACd,QACyC;AACzC,QAAO"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
10
|
-
exports.
|
|
11
|
-
//# sourceMappingURL=index.cjs.map
|
|
2
|
+
const require_api = require("./api.cjs");
|
|
3
|
+
const require_defineConfig = require("./defineConfig.cjs");
|
|
4
|
+
exports.defineVirtualSubtreeConfig = require_defineConfig.defineVirtualSubtreeConfig;
|
|
5
|
+
exports.index = require_api.index;
|
|
6
|
+
exports.layout = require_api.layout;
|
|
7
|
+
exports.physical = require_api.physical;
|
|
8
|
+
exports.rootRoute = require_api.rootRoute;
|
|
9
|
+
exports.route = require_api.route;
|
package/dist/esm/api.js
CHANGED
|
@@ -1,66 +1,56 @@
|
|
|
1
|
+
//#region src/api.ts
|
|
1
2
|
function rootRoute(file, children) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
return {
|
|
4
|
+
type: "root",
|
|
5
|
+
file,
|
|
6
|
+
children
|
|
7
|
+
};
|
|
7
8
|
}
|
|
8
9
|
function index(file) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
return {
|
|
11
|
+
type: "index",
|
|
12
|
+
file
|
|
13
|
+
};
|
|
13
14
|
}
|
|
14
15
|
function layout(idOrFile, fileOrChildren, children) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
children
|
|
27
|
-
};
|
|
28
|
-
}
|
|
16
|
+
if (Array.isArray(fileOrChildren)) return {
|
|
17
|
+
type: "layout",
|
|
18
|
+
file: idOrFile,
|
|
19
|
+
children: fileOrChildren
|
|
20
|
+
};
|
|
21
|
+
else return {
|
|
22
|
+
type: "layout",
|
|
23
|
+
id: idOrFile,
|
|
24
|
+
file: fileOrChildren,
|
|
25
|
+
children
|
|
26
|
+
};
|
|
29
27
|
}
|
|
30
28
|
function route(path, fileOrChildren, children) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
children: fileOrChildren
|
|
43
|
-
};
|
|
29
|
+
if (typeof fileOrChildren === "string") return {
|
|
30
|
+
type: "route",
|
|
31
|
+
file: fileOrChildren,
|
|
32
|
+
path,
|
|
33
|
+
children
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
type: "route",
|
|
37
|
+
path,
|
|
38
|
+
children: fileOrChildren
|
|
39
|
+
};
|
|
44
40
|
}
|
|
45
41
|
function physical(pathPrefixOrDirectory, directory) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
pathPrefix: pathPrefixOrDirectory
|
|
57
|
-
};
|
|
42
|
+
if (directory === void 0) return {
|
|
43
|
+
type: "physical",
|
|
44
|
+
directory: pathPrefixOrDirectory,
|
|
45
|
+
pathPrefix: ""
|
|
46
|
+
};
|
|
47
|
+
return {
|
|
48
|
+
type: "physical",
|
|
49
|
+
directory,
|
|
50
|
+
pathPrefix: pathPrefixOrDirectory
|
|
51
|
+
};
|
|
58
52
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
rootRoute,
|
|
64
|
-
route
|
|
65
|
-
};
|
|
66
|
-
//# sourceMappingURL=api.js.map
|
|
53
|
+
//#endregion
|
|
54
|
+
export { index, layout, physical, rootRoute, route };
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=api.js.map
|
package/dist/esm/api.js.map
CHANGED
|
@@ -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\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"],"
|
|
1
|
+
{"version":3,"file":"api.js","names":[],"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"],"mappings":";AASA,SAAgB,UACd,MACA,UACkB;AAClB,QAAO;EACL,MAAM;EACN;EACA;EACD;;AAGH,SAAgB,MAAM,MAA0B;AAC9C,QAAO;EACL,MAAM;EACN;EACD;;AAaH,SAAgB,OACd,UACA,gBACA,UACa;AACb,KAAI,MAAM,QAAQ,eAAe,CAC/B,QAAO;EACL,MAAM;EACN,MAAM;EACN,UAAU;EACX;KAED,QAAO;EACL,MAAM;EACN,IAAI;EACJ,MAAM;EACN;EACD;;AAWL,SAAgB,MACd,MACA,gBACA,UACO;AACP,KAAI,OAAO,mBAAmB,SAC5B,QAAO;EACL,MAAM;EACN,MAAM;EACN;EACA;EACD;AAEH,QAAO;EACL,MAAM;EACN;EACA,UAAU;EACX;;AAiBH,SAAgB,SACd,uBACA,WACiB;AACjB,KAAI,cAAc,KAAA,EAEhB,QAAO;EACL,MAAM;EACN,WAAW;EACX,YAAY;EACb;AAGH,QAAO;EACL,MAAM;EACN;EACA,YAAY;EACb"}
|
package/dist/esm/defineConfig.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
//#region src/defineConfig.ts
|
|
1
2
|
function defineVirtualSubtreeConfig(config) {
|
|
2
|
-
|
|
3
|
+
return config;
|
|
3
4
|
}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
//# sourceMappingURL=defineConfig.js.map
|
|
5
|
+
//#endregion
|
|
6
|
+
export { defineVirtualSubtreeConfig };
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=defineConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineConfig.js","sources":["../../src/defineConfig.ts"],"sourcesContent":["import type { VirtualRouteNode } from './types'\n\n// this is adapted from vite/src/node/config.ts\n\nexport type ConfigFnObject<TConfig> = () => TConfig\nexport type ConfigFnPromise<TConfig> = () => Promise<TConfig>\nexport type ConfigFn<TConfig> = () => TConfig | Promise<TConfig>\n\nexport type ConfigExport<TConfig> =\n | TConfig\n | Promise<TConfig>\n | ConfigFnObject<TConfig>\n | ConfigFnPromise<TConfig>\n | ConfigFn<TConfig>\n\nexport type VirtualRouteSubtreeConfig = Array<VirtualRouteNode>\n\n/**\n * Type helper to make it easier to use __virtual.ts\n * accepts a direct {@link VirtualRouteSubtreeConfig} object, or a function that returns it.\n */\nexport function defineVirtualSubtreeConfig(\n config: VirtualRouteSubtreeConfig,\n): VirtualRouteSubtreeConfig\nexport function defineVirtualSubtreeConfig(\n config: Promise<VirtualRouteSubtreeConfig>,\n): Promise<VirtualRouteSubtreeConfig>\nexport function defineVirtualSubtreeConfig(\n config: ConfigFnObject<VirtualRouteSubtreeConfig>,\n): ConfigFnObject<VirtualRouteSubtreeConfig>\nexport function defineVirtualSubtreeConfig(\n config: ConfigExport<VirtualRouteSubtreeConfig>,\n): ConfigExport<VirtualRouteSubtreeConfig>\nexport function defineVirtualSubtreeConfig(\n config: ConfigExport<VirtualRouteSubtreeConfig>,\n): ConfigExport<VirtualRouteSubtreeConfig> {\n return config\n}\n"],"
|
|
1
|
+
{"version":3,"file":"defineConfig.js","names":[],"sources":["../../src/defineConfig.ts"],"sourcesContent":["import type { VirtualRouteNode } from './types'\n\n// this is adapted from vite/src/node/config.ts\n\nexport type ConfigFnObject<TConfig> = () => TConfig\nexport type ConfigFnPromise<TConfig> = () => Promise<TConfig>\nexport type ConfigFn<TConfig> = () => TConfig | Promise<TConfig>\n\nexport type ConfigExport<TConfig> =\n | TConfig\n | Promise<TConfig>\n | ConfigFnObject<TConfig>\n | ConfigFnPromise<TConfig>\n | ConfigFn<TConfig>\n\nexport type VirtualRouteSubtreeConfig = Array<VirtualRouteNode>\n\n/**\n * Type helper to make it easier to use __virtual.ts\n * accepts a direct {@link VirtualRouteSubtreeConfig} object, or a function that returns it.\n */\nexport function defineVirtualSubtreeConfig(\n config: VirtualRouteSubtreeConfig,\n): VirtualRouteSubtreeConfig\nexport function defineVirtualSubtreeConfig(\n config: Promise<VirtualRouteSubtreeConfig>,\n): Promise<VirtualRouteSubtreeConfig>\nexport function defineVirtualSubtreeConfig(\n config: ConfigFnObject<VirtualRouteSubtreeConfig>,\n): ConfigFnObject<VirtualRouteSubtreeConfig>\nexport function defineVirtualSubtreeConfig(\n config: ConfigExport<VirtualRouteSubtreeConfig>,\n): ConfigExport<VirtualRouteSubtreeConfig>\nexport function defineVirtualSubtreeConfig(\n config: ConfigExport<VirtualRouteSubtreeConfig>,\n): ConfigExport<VirtualRouteSubtreeConfig> {\n return config\n}\n"],"mappings":";AAiCA,SAAgB,2BACd,QACyC;AACzC,QAAO"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
1
|
import { index, layout, physical, rootRoute, route } from "./api.js";
|
|
2
2
|
import { defineVirtualSubtreeConfig } from "./defineConfig.js";
|
|
3
|
-
export {
|
|
4
|
-
defineVirtualSubtreeConfig,
|
|
5
|
-
index,
|
|
6
|
-
layout,
|
|
7
|
-
physical,
|
|
8
|
-
rootRoute,
|
|
9
|
-
route
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=index.js.map
|
|
3
|
+
export { defineVirtualSubtreeConfig, index, layout, physical, rootRoute, route };
|
package/package.json
CHANGED
package/dist/cjs/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|