@tanstack/router-generator 1.167.4 → 1.167.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/config.cjs +1 -1
- package/dist/cjs/config.cjs.map +1 -1
- package/dist/cjs/config.d.cts +60 -187
- package/dist/cjs/utils.cjs +22 -3
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/esm/config.d.ts +60 -187
- package/dist/esm/config.js +1 -1
- package/dist/esm/config.js.map +1 -1
- package/dist/esm/utils.js +22 -3
- package/dist/esm/utils.js.map +1 -1
- package/package.json +6 -6
- package/src/config.ts +1 -1
- package/src/utils.ts +48 -5
package/dist/cjs/config.cjs
CHANGED
|
@@ -51,7 +51,7 @@ var configSchema = baseConfigSchema.extend({
|
|
|
51
51
|
disableTypes: zod.z.boolean().optional().default(false),
|
|
52
52
|
addExtensions: zod.z.union([zod.z.boolean(), zod.z.string()]).optional().default(false).transform((v) => typeof v === "string" ? v.startsWith(".") ? v : `.${v}` : v),
|
|
53
53
|
enableRouteTreeFormatting: zod.z.boolean().optional().default(true),
|
|
54
|
-
routeTreeFileFooter: zod.z.union([zod.z.array(zod.z.string()).optional().default([]), zod.z.
|
|
54
|
+
routeTreeFileFooter: zod.z.union([zod.z.array(zod.z.string()).optional().default([]), zod.z.custom((value) => typeof value === "function")]).optional(),
|
|
55
55
|
autoCodeSplitting: zod.z.boolean().optional(),
|
|
56
56
|
customScaffolding: zod.z.object({
|
|
57
57
|
routeTemplate: zod.z.string().optional(),
|
package/dist/cjs/config.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.cjs","names":[],"sources":["../../src/config.ts"],"sourcesContent":["import path from 'node:path'\nimport { existsSync, readFileSync } from 'node:fs'\nimport { z } from 'zod'\nimport { virtualRootRouteSchema } from './filesystem/virtual/config'\nimport type { GeneratorPlugin } from './plugin/types'\n\nconst tokenJsonRegexSchema = z.object({\n regex: z.string(),\n flags: z.string().optional(),\n})\n\nconst tokenMatcherSchema = z.union([\n z.string(),\n z.instanceof(RegExp),\n tokenJsonRegexSchema,\n])\n\nexport type TokenMatcherJson = string | z.infer<typeof tokenJsonRegexSchema>\n\nexport type TokenMatcher = z.infer<typeof tokenMatcherSchema>\n\nexport const baseConfigSchema = z.object({\n target: z.enum(['react', 'solid', 'vue']).optional().default('react'),\n virtualRouteConfig: virtualRootRouteSchema.or(z.string()).optional(),\n routeFilePrefix: z.string().optional(),\n routeFileIgnorePrefix: z.string().optional().default('-'),\n routeFileIgnorePattern: z.string().optional(),\n routesDirectory: z.string().optional().default('./src/routes'),\n quoteStyle: z.enum(['single', 'double']).optional().default('single'),\n semicolons: z.boolean().optional().default(false),\n disableLogging: z.boolean().optional().default(false),\n routeTreeFileHeader: z\n .array(z.string())\n .optional()\n .default([\n '/* eslint-disable */',\n '// @ts-nocheck',\n '// noinspection JSUnusedGlobalSymbols',\n ]),\n indexToken: tokenMatcherSchema.optional().default('index'),\n routeToken: tokenMatcherSchema.optional().default('route'),\n pathParamsAllowedCharacters: z\n .array(z.enum([';', ':', '@', '&', '=', '+', '$', ',']))\n .optional(),\n})\n\nexport type BaseConfig = z.infer<typeof baseConfigSchema>\n\nexport const configSchema = baseConfigSchema.extend({\n generatedRouteTree: z.string().optional().default('./src/routeTree.gen.ts'),\n disableTypes: z.boolean().optional().default(false),\n addExtensions: z\n .union([z.boolean(), z.string()])\n .optional()\n .default(false)\n .transform((v) =>\n typeof v === 'string' ? (v.startsWith('.') ? v : `.${v}`) : v,\n ),\n enableRouteTreeFormatting: z.boolean().optional().default(true),\n routeTreeFileFooter: z\n .union([\n z.array(z.string()).optional().default([]),\n z.function().returns(z.array(z.string())),\n ])\n .optional(),\n autoCodeSplitting: z.boolean().optional(),\n customScaffolding: z\n .object({\n routeTemplate: z.string().optional(),\n lazyRouteTemplate: z.string().optional(),\n })\n .optional(),\n experimental: z\n .object({\n // TODO: This has been made stable and is now \"autoCodeSplitting\". Remove in next major version.\n enableCodeSplitting: z.boolean().optional(),\n })\n .optional(),\n plugins: z.array(z.custom<GeneratorPlugin>()).optional(),\n tmpDir: z.string().optional().default(''),\n importRoutesUsingAbsolutePaths: z.boolean().optional().default(false),\n})\n\nexport type Config = z.infer<typeof configSchema>\n\ntype ResolveParams = {\n configDirectory: string\n}\n\nexport function resolveConfigPath({ configDirectory }: ResolveParams) {\n return path.resolve(configDirectory, 'tsr.config.json')\n}\n\nexport function getConfig(\n inlineConfig: Partial<Config> = {},\n configDirectory?: string,\n): Config {\n if (configDirectory === undefined) {\n configDirectory = process.cwd()\n }\n const configFilePathJson = resolveConfigPath({ configDirectory })\n const exists = existsSync(configFilePathJson)\n\n let config: Config\n\n if (exists) {\n // Parse file config (allows JSON regex-object form)\n const fileConfigRaw = JSON.parse(readFileSync(configFilePathJson, 'utf-8'))\n\n // Merge raw configs (inline overrides file), then parse once to apply defaults\n // This ensures file config values aren't overwritten by inline defaults\n const merged = {\n ...fileConfigRaw,\n ...inlineConfig,\n }\n config = configSchema.parse(merged)\n } else {\n config = configSchema.parse(inlineConfig)\n }\n\n // If typescript is disabled, make sure the generated route tree is a .js file\n if (config.disableTypes) {\n config.generatedRouteTree = config.generatedRouteTree.replace(\n /\\.(ts|tsx)$/,\n '.js',\n )\n }\n\n // if a configDirectory is used, paths should be relative to that directory\n if (configDirectory) {\n // if absolute configDirectory is provided, use it as the root\n if (path.isAbsolute(configDirectory)) {\n config.routesDirectory = path.resolve(\n configDirectory,\n config.routesDirectory,\n )\n config.generatedRouteTree = path.resolve(\n configDirectory,\n config.generatedRouteTree,\n )\n } else {\n config.routesDirectory = path.resolve(\n process.cwd(),\n configDirectory,\n config.routesDirectory,\n )\n config.generatedRouteTree = path.resolve(\n process.cwd(),\n configDirectory,\n config.generatedRouteTree,\n )\n }\n }\n\n const resolveTmpDir = (dir: string | Array<string>) => {\n if (Array.isArray(dir)) {\n dir = path.join(...dir)\n }\n if (!path.isAbsolute(dir)) {\n dir = path.resolve(process.cwd(), dir)\n }\n return dir\n }\n\n if (config.tmpDir) {\n config.tmpDir = resolveTmpDir(config.tmpDir)\n } else if (process.env.TSR_TMP_DIR) {\n config.tmpDir = resolveTmpDir(process.env.TSR_TMP_DIR)\n } else {\n config.tmpDir = resolveTmpDir(['.tanstack', 'tmp'])\n }\n\n validateConfig(config)\n return config\n}\n\nfunction validateConfig(config: Config) {\n if (typeof config.experimental?.enableCodeSplitting !== 'undefined') {\n const message = `\n------\n⚠️ ⚠️ ⚠️\nERROR: The \"experimental.enableCodeSplitting\" flag has been made stable and is now \"autoCodeSplitting\". Please update your configuration file to use \"autoCodeSplitting\" instead of \"experimental.enableCodeSplitting\".\n------\n`\n console.error(message)\n throw new Error(message)\n }\n\n // Check that indexToken and routeToken are not identical\n // Works for strings, RegExp, and JSON regex objects\n if (areTokensEqual(config.indexToken, config.routeToken)) {\n throw new Error(\n `The \"indexToken\" and \"routeToken\" options must be different.`,\n )\n }\n\n if (\n config.routeFileIgnorePrefix &&\n config.routeFileIgnorePrefix.trim() === '_'\n ) {\n throw new Error(\n `The \"routeFileIgnorePrefix\" cannot be an underscore (\"_\"). This is a reserved character used to denote a pathless route. Please use a different prefix.`,\n )\n }\n\n return config\n}\n\n/**\n * Compares two token matchers for equality.\n * Handles strings, RegExp instances, and JSON regex objects.\n */\nfunction areTokensEqual(a: TokenMatcher, b: TokenMatcher): boolean {\n // Both strings\n if (typeof a === 'string' && typeof b === 'string') {\n return a === b\n }\n\n // Both RegExp instances\n if (a instanceof RegExp && b instanceof RegExp) {\n return a.source === b.source && a.flags === b.flags\n }\n\n // Both JSON regex objects\n if (\n typeof a === 'object' &&\n 'regex' in a &&\n typeof b === 'object' &&\n 'regex' in b\n ) {\n return a.regex === b.regex && (a.flags ?? '') === (b.flags ?? '')\n }\n\n // Mixed types - not equal\n return false\n}\n"],"mappings":";;;;;;;AAMA,IAAM,uBAAuB,IAAA,EAAE,OAAO;CACpC,OAAO,IAAA,EAAE,QAAQ;CACjB,OAAO,IAAA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M,IAAI,MAAM,QAAQ;;AAK1B,KAAI,eAAe,OAAO,YAAY,OAAO,WAAW,CACtD,OAAM,IAAI,MACR,+DACD;AAGH,KACE,OAAO,yBACP,OAAO,sBAAsB,MAAM,KAAK,IAExC,OAAM,IAAI,MACR,0JACD;AAGH,QAAO;;;;;;AAOT,SAAS,eAAe,GAAiB,GAA0B;AAEjE,KAAI,OAAO,MAAM,YAAY,OAAO,MAAM,SACxC,QAAO,MAAM;AAIf,KAAI,aAAa,UAAU,aAAa,OACtC,QAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE;AAIhD,KACE,OAAO,MAAM,YACb,WAAW,KACX,OAAO,MAAM,YACb,WAAW,EAEX,QAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,SAAS,EAAE,SAAS;AAIhE,QAAO"}
|
|
1
|
+
{"version":3,"file":"config.cjs","names":[],"sources":["../../src/config.ts"],"sourcesContent":["import path from 'node:path'\nimport { existsSync, readFileSync } from 'node:fs'\nimport { z } from 'zod'\nimport { virtualRootRouteSchema } from './filesystem/virtual/config'\nimport type { GeneratorPlugin } from './plugin/types'\n\nconst tokenJsonRegexSchema = z.object({\n regex: z.string(),\n flags: z.string().optional(),\n})\n\nconst tokenMatcherSchema = z.union([\n z.string(),\n z.instanceof(RegExp),\n tokenJsonRegexSchema,\n])\n\nexport type TokenMatcherJson = string | z.infer<typeof tokenJsonRegexSchema>\n\nexport type TokenMatcher = z.infer<typeof tokenMatcherSchema>\n\nexport const baseConfigSchema = z.object({\n target: z.enum(['react', 'solid', 'vue']).optional().default('react'),\n virtualRouteConfig: virtualRootRouteSchema.or(z.string()).optional(),\n routeFilePrefix: z.string().optional(),\n routeFileIgnorePrefix: z.string().optional().default('-'),\n routeFileIgnorePattern: z.string().optional(),\n routesDirectory: z.string().optional().default('./src/routes'),\n quoteStyle: z.enum(['single', 'double']).optional().default('single'),\n semicolons: z.boolean().optional().default(false),\n disableLogging: z.boolean().optional().default(false),\n routeTreeFileHeader: z\n .array(z.string())\n .optional()\n .default([\n '/* eslint-disable */',\n '// @ts-nocheck',\n '// noinspection JSUnusedGlobalSymbols',\n ]),\n indexToken: tokenMatcherSchema.optional().default('index'),\n routeToken: tokenMatcherSchema.optional().default('route'),\n pathParamsAllowedCharacters: z\n .array(z.enum([';', ':', '@', '&', '=', '+', '$', ',']))\n .optional(),\n})\n\nexport type BaseConfig = z.infer<typeof baseConfigSchema>\n\nexport const configSchema = baseConfigSchema.extend({\n generatedRouteTree: z.string().optional().default('./src/routeTree.gen.ts'),\n disableTypes: z.boolean().optional().default(false),\n addExtensions: z\n .union([z.boolean(), z.string()])\n .optional()\n .default(false)\n .transform((v) =>\n typeof v === 'string' ? (v.startsWith('.') ? v : `.${v}`) : v,\n ),\n enableRouteTreeFormatting: z.boolean().optional().default(true),\n routeTreeFileFooter: z\n .union([\n z.array(z.string()).optional().default([]),\n z.custom<() => Array<string>>((value) => typeof value === 'function'),\n ])\n .optional(),\n autoCodeSplitting: z.boolean().optional(),\n customScaffolding: z\n .object({\n routeTemplate: z.string().optional(),\n lazyRouteTemplate: z.string().optional(),\n })\n .optional(),\n experimental: z\n .object({\n // TODO: This has been made stable and is now \"autoCodeSplitting\". Remove in next major version.\n enableCodeSplitting: z.boolean().optional(),\n })\n .optional(),\n plugins: z.array(z.custom<GeneratorPlugin>()).optional(),\n tmpDir: z.string().optional().default(''),\n importRoutesUsingAbsolutePaths: z.boolean().optional().default(false),\n})\n\nexport type Config = z.infer<typeof configSchema>\n\ntype ResolveParams = {\n configDirectory: string\n}\n\nexport function resolveConfigPath({ configDirectory }: ResolveParams) {\n return path.resolve(configDirectory, 'tsr.config.json')\n}\n\nexport function getConfig(\n inlineConfig: Partial<Config> = {},\n configDirectory?: string,\n): Config {\n if (configDirectory === undefined) {\n configDirectory = process.cwd()\n }\n const configFilePathJson = resolveConfigPath({ configDirectory })\n const exists = existsSync(configFilePathJson)\n\n let config: Config\n\n if (exists) {\n // Parse file config (allows JSON regex-object form)\n const fileConfigRaw = JSON.parse(readFileSync(configFilePathJson, 'utf-8'))\n\n // Merge raw configs (inline overrides file), then parse once to apply defaults\n // This ensures file config values aren't overwritten by inline defaults\n const merged = {\n ...fileConfigRaw,\n ...inlineConfig,\n }\n config = configSchema.parse(merged)\n } else {\n config = configSchema.parse(inlineConfig)\n }\n\n // If typescript is disabled, make sure the generated route tree is a .js file\n if (config.disableTypes) {\n config.generatedRouteTree = config.generatedRouteTree.replace(\n /\\.(ts|tsx)$/,\n '.js',\n )\n }\n\n // if a configDirectory is used, paths should be relative to that directory\n if (configDirectory) {\n // if absolute configDirectory is provided, use it as the root\n if (path.isAbsolute(configDirectory)) {\n config.routesDirectory = path.resolve(\n configDirectory,\n config.routesDirectory,\n )\n config.generatedRouteTree = path.resolve(\n configDirectory,\n config.generatedRouteTree,\n )\n } else {\n config.routesDirectory = path.resolve(\n process.cwd(),\n configDirectory,\n config.routesDirectory,\n )\n config.generatedRouteTree = path.resolve(\n process.cwd(),\n configDirectory,\n config.generatedRouteTree,\n )\n }\n }\n\n const resolveTmpDir = (dir: string | Array<string>) => {\n if (Array.isArray(dir)) {\n dir = path.join(...dir)\n }\n if (!path.isAbsolute(dir)) {\n dir = path.resolve(process.cwd(), dir)\n }\n return dir\n }\n\n if (config.tmpDir) {\n config.tmpDir = resolveTmpDir(config.tmpDir)\n } else if (process.env.TSR_TMP_DIR) {\n config.tmpDir = resolveTmpDir(process.env.TSR_TMP_DIR)\n } else {\n config.tmpDir = resolveTmpDir(['.tanstack', 'tmp'])\n }\n\n validateConfig(config)\n return config\n}\n\nfunction validateConfig(config: Config) {\n if (typeof config.experimental?.enableCodeSplitting !== 'undefined') {\n const message = `\n------\n⚠️ ⚠️ ⚠️\nERROR: The \"experimental.enableCodeSplitting\" flag has been made stable and is now \"autoCodeSplitting\". Please update your configuration file to use \"autoCodeSplitting\" instead of \"experimental.enableCodeSplitting\".\n------\n`\n console.error(message)\n throw new Error(message)\n }\n\n // Check that indexToken and routeToken are not identical\n // Works for strings, RegExp, and JSON regex objects\n if (areTokensEqual(config.indexToken, config.routeToken)) {\n throw new Error(\n `The \"indexToken\" and \"routeToken\" options must be different.`,\n )\n }\n\n if (\n config.routeFileIgnorePrefix &&\n config.routeFileIgnorePrefix.trim() === '_'\n ) {\n throw new Error(\n `The \"routeFileIgnorePrefix\" cannot be an underscore (\"_\"). This is a reserved character used to denote a pathless route. Please use a different prefix.`,\n )\n }\n\n return config\n}\n\n/**\n * Compares two token matchers for equality.\n * Handles strings, RegExp instances, and JSON regex objects.\n */\nfunction areTokensEqual(a: TokenMatcher, b: TokenMatcher): boolean {\n // Both strings\n if (typeof a === 'string' && typeof b === 'string') {\n return a === b\n }\n\n // Both RegExp instances\n if (a instanceof RegExp && b instanceof RegExp) {\n return a.source === b.source && a.flags === b.flags\n }\n\n // Both JSON regex objects\n if (\n typeof a === 'object' &&\n 'regex' in a &&\n typeof b === 'object' &&\n 'regex' in b\n ) {\n return a.regex === b.regex && (a.flags ?? '') === (b.flags ?? '')\n }\n\n // Mixed types - not equal\n return false\n}\n"],"mappings":";;;;;;;AAMA,IAAM,uBAAuB,IAAA,EAAE,OAAO;CACpC,OAAO,IAAA,EAAE,QAAQ;CACjB,OAAO,IAAA,EAAE,QAAQ,CAAC,UAAU;CAC7B,CAAC;AAEF,IAAM,qBAAqB,IAAA,EAAE,MAAM;CACjC,IAAA,EAAE,QAAQ;CACV,IAAA,EAAE,WAAW,OAAO;CACpB;CACD,CAAC;AAMF,IAAa,mBAAmB,IAAA,EAAE,OAAO;CACvC,QAAQ,IAAA,EAAE,KAAK;EAAC;EAAS;EAAS;EAAM,CAAC,CAAC,UAAU,CAAC,QAAQ,QAAQ;CACrE,oBAAoB,eAAA,uBAAuB,GAAG,IAAA,EAAE,QAAQ,CAAC,CAAC,UAAU;CACpE,iBAAiB,IAAA,EAAE,QAAQ,CAAC,UAAU;CACtC,uBAAuB,IAAA,EAAE,QAAQ,CAAC,UAAU,CAAC,QAAQ,IAAI;CACzD,w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"}
|
package/dist/cjs/config.d.cts
CHANGED
|
@@ -3,231 +3,104 @@ import { GeneratorPlugin } from './plugin/types.cjs';
|
|
|
3
3
|
declare const tokenJsonRegexSchema: z.ZodObject<{
|
|
4
4
|
regex: z.ZodString;
|
|
5
5
|
flags: z.ZodOptional<z.ZodString>;
|
|
6
|
-
},
|
|
7
|
-
|
|
8
|
-
flags?: string | undefined;
|
|
9
|
-
}, {
|
|
10
|
-
regex: string;
|
|
11
|
-
flags?: string | undefined;
|
|
12
|
-
}>;
|
|
13
|
-
declare const tokenMatcherSchema: z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>, z.ZodObject<{
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
declare const tokenMatcherSchema: z.ZodUnion<readonly [z.ZodString, z.ZodCustom<RegExp, RegExp>, z.ZodObject<{
|
|
14
8
|
regex: z.ZodString;
|
|
15
9
|
flags: z.ZodOptional<z.ZodString>;
|
|
16
|
-
},
|
|
17
|
-
regex: string;
|
|
18
|
-
flags?: string | undefined;
|
|
19
|
-
}, {
|
|
20
|
-
regex: string;
|
|
21
|
-
flags?: string | undefined;
|
|
22
|
-
}>]>;
|
|
10
|
+
}, z.core.$strip>]>;
|
|
23
11
|
export type TokenMatcherJson = string | z.infer<typeof tokenJsonRegexSchema>;
|
|
24
12
|
export type TokenMatcher = z.infer<typeof tokenMatcherSchema>;
|
|
25
13
|
export declare const baseConfigSchema: z.ZodObject<{
|
|
26
|
-
target: z.ZodDefault<z.ZodOptional<z.ZodEnum<
|
|
27
|
-
|
|
14
|
+
target: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
15
|
+
vue: "vue";
|
|
16
|
+
react: "react";
|
|
17
|
+
solid: "solid";
|
|
18
|
+
}>>>;
|
|
19
|
+
virtualRouteConfig: z.ZodOptional<z.ZodUnion<[z.ZodType<import('@tanstack/virtual-file-routes').VirtualRootRoute, unknown, z.core.$ZodTypeInternals<import('@tanstack/virtual-file-routes').VirtualRootRoute, unknown>>, z.ZodString]>>;
|
|
28
20
|
routeFilePrefix: z.ZodOptional<z.ZodString>;
|
|
29
21
|
routeFileIgnorePrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
30
22
|
routeFileIgnorePattern: z.ZodOptional<z.ZodString>;
|
|
31
23
|
routesDirectory: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
32
|
-
quoteStyle: z.ZodDefault<z.ZodOptional<z.ZodEnum<
|
|
24
|
+
quoteStyle: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
25
|
+
single: "single";
|
|
26
|
+
double: "double";
|
|
27
|
+
}>>>;
|
|
33
28
|
semicolons: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
34
29
|
disableLogging: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
35
|
-
routeTreeFileHeader: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString
|
|
36
|
-
indexToken: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodString, z.
|
|
30
|
+
routeTreeFileHeader: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
31
|
+
indexToken: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<RegExp, RegExp>, z.ZodObject<{
|
|
37
32
|
regex: z.ZodString;
|
|
38
33
|
flags: z.ZodOptional<z.ZodString>;
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
flags?: string | undefined;
|
|
42
|
-
}, {
|
|
43
|
-
regex: string;
|
|
44
|
-
flags?: string | undefined;
|
|
45
|
-
}>]>>>;
|
|
46
|
-
routeToken: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>, z.ZodObject<{
|
|
34
|
+
}, z.core.$strip>]>>>;
|
|
35
|
+
routeToken: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<RegExp, RegExp>, z.ZodObject<{
|
|
47
36
|
regex: z.ZodString;
|
|
48
37
|
flags: z.ZodOptional<z.ZodString>;
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
quoteStyle: "single" | "double";
|
|
62
|
-
semicolons: boolean;
|
|
63
|
-
disableLogging: boolean;
|
|
64
|
-
routeTreeFileHeader: string[];
|
|
65
|
-
indexToken: string | RegExp | {
|
|
66
|
-
regex: string;
|
|
67
|
-
flags?: string | undefined;
|
|
68
|
-
};
|
|
69
|
-
routeToken: string | RegExp | {
|
|
70
|
-
regex: string;
|
|
71
|
-
flags?: string | undefined;
|
|
72
|
-
};
|
|
73
|
-
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
74
|
-
routeFilePrefix?: string | undefined;
|
|
75
|
-
routeFileIgnorePattern?: string | undefined;
|
|
76
|
-
pathParamsAllowedCharacters?: (":" | "$" | ";" | "@" | "&" | "=" | "+" | ",")[] | undefined;
|
|
77
|
-
}, {
|
|
78
|
-
target?: "vue" | "react" | "solid" | undefined;
|
|
79
|
-
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
80
|
-
routeFilePrefix?: string | undefined;
|
|
81
|
-
routeFileIgnorePrefix?: string | undefined;
|
|
82
|
-
routeFileIgnorePattern?: string | undefined;
|
|
83
|
-
routesDirectory?: string | undefined;
|
|
84
|
-
quoteStyle?: "single" | "double" | undefined;
|
|
85
|
-
semicolons?: boolean | undefined;
|
|
86
|
-
disableLogging?: boolean | undefined;
|
|
87
|
-
routeTreeFileHeader?: string[] | undefined;
|
|
88
|
-
indexToken?: string | RegExp | {
|
|
89
|
-
regex: string;
|
|
90
|
-
flags?: string | undefined;
|
|
91
|
-
} | undefined;
|
|
92
|
-
routeToken?: string | RegExp | {
|
|
93
|
-
regex: string;
|
|
94
|
-
flags?: string | undefined;
|
|
95
|
-
} | undefined;
|
|
96
|
-
pathParamsAllowedCharacters?: (":" | "$" | ";" | "@" | "&" | "=" | "+" | ",")[] | undefined;
|
|
97
|
-
}>;
|
|
38
|
+
}, z.core.$strip>]>>>;
|
|
39
|
+
pathParamsAllowedCharacters: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
40
|
+
":": ":";
|
|
41
|
+
$: "$";
|
|
42
|
+
";": ";";
|
|
43
|
+
"@": "@";
|
|
44
|
+
"&": "&";
|
|
45
|
+
"=": "=";
|
|
46
|
+
"+": "+";
|
|
47
|
+
",": ",";
|
|
48
|
+
}>>>;
|
|
49
|
+
}, z.core.$strip>;
|
|
98
50
|
export type BaseConfig = z.infer<typeof baseConfigSchema>;
|
|
99
51
|
export declare const configSchema: z.ZodObject<{
|
|
100
|
-
target: z.ZodDefault<z.ZodOptional<z.ZodEnum<
|
|
101
|
-
|
|
52
|
+
target: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
53
|
+
vue: "vue";
|
|
54
|
+
react: "react";
|
|
55
|
+
solid: "solid";
|
|
56
|
+
}>>>;
|
|
57
|
+
virtualRouteConfig: z.ZodOptional<z.ZodUnion<[z.ZodType<import('@tanstack/virtual-file-routes').VirtualRootRoute, unknown, z.core.$ZodTypeInternals<import('@tanstack/virtual-file-routes').VirtualRootRoute, unknown>>, z.ZodString]>>;
|
|
102
58
|
routeFilePrefix: z.ZodOptional<z.ZodString>;
|
|
103
59
|
routeFileIgnorePrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
104
60
|
routeFileIgnorePattern: z.ZodOptional<z.ZodString>;
|
|
105
61
|
routesDirectory: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
106
|
-
quoteStyle: z.ZodDefault<z.ZodOptional<z.ZodEnum<
|
|
62
|
+
quoteStyle: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
63
|
+
single: "single";
|
|
64
|
+
double: "double";
|
|
65
|
+
}>>>;
|
|
107
66
|
semicolons: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
108
67
|
disableLogging: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
109
|
-
routeTreeFileHeader: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString
|
|
110
|
-
indexToken: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodString, z.
|
|
68
|
+
routeTreeFileHeader: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
69
|
+
indexToken: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<RegExp, RegExp>, z.ZodObject<{
|
|
111
70
|
regex: z.ZodString;
|
|
112
71
|
flags: z.ZodOptional<z.ZodString>;
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
flags?: string | undefined;
|
|
116
|
-
}, {
|
|
117
|
-
regex: string;
|
|
118
|
-
flags?: string | undefined;
|
|
119
|
-
}>]>>>;
|
|
120
|
-
routeToken: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>, z.ZodObject<{
|
|
72
|
+
}, z.core.$strip>]>>>;
|
|
73
|
+
routeToken: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<RegExp, RegExp>, z.ZodObject<{
|
|
121
74
|
regex: z.ZodString;
|
|
122
75
|
flags: z.ZodOptional<z.ZodString>;
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
76
|
+
}, z.core.$strip>]>>>;
|
|
77
|
+
pathParamsAllowedCharacters: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
78
|
+
":": ":";
|
|
79
|
+
$: "$";
|
|
80
|
+
";": ";";
|
|
81
|
+
"@": "@";
|
|
82
|
+
"&": "&";
|
|
83
|
+
"=": "=";
|
|
84
|
+
"+": "+";
|
|
85
|
+
",": ",";
|
|
86
|
+
}>>>;
|
|
132
87
|
generatedRouteTree: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
133
88
|
disableTypes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
134
|
-
addExtensions: z.
|
|
89
|
+
addExtensions: z.ZodPipe<z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>>, z.ZodTransform<string | boolean, string | boolean>>;
|
|
135
90
|
enableRouteTreeFormatting: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
136
|
-
routeTreeFileFooter: z.ZodOptional<z.ZodUnion<[z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString
|
|
91
|
+
routeTreeFileFooter: z.ZodOptional<z.ZodUnion<readonly [z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>, z.ZodCustom<() => Array<string>, () => Array<string>>]>>;
|
|
137
92
|
autoCodeSplitting: z.ZodOptional<z.ZodBoolean>;
|
|
138
93
|
customScaffolding: z.ZodOptional<z.ZodObject<{
|
|
139
94
|
routeTemplate: z.ZodOptional<z.ZodString>;
|
|
140
95
|
lazyRouteTemplate: z.ZodOptional<z.ZodString>;
|
|
141
|
-
},
|
|
142
|
-
routeTemplate?: string | undefined;
|
|
143
|
-
lazyRouteTemplate?: string | undefined;
|
|
144
|
-
}, {
|
|
145
|
-
routeTemplate?: string | undefined;
|
|
146
|
-
lazyRouteTemplate?: string | undefined;
|
|
147
|
-
}>>;
|
|
96
|
+
}, z.core.$strip>>;
|
|
148
97
|
experimental: z.ZodOptional<z.ZodObject<{
|
|
149
98
|
enableCodeSplitting: z.ZodOptional<z.ZodBoolean>;
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
}, {
|
|
153
|
-
enableCodeSplitting?: boolean | undefined;
|
|
154
|
-
}>>;
|
|
155
|
-
plugins: z.ZodOptional<z.ZodArray<z.ZodType<GeneratorPlugin, z.ZodTypeDef, GeneratorPlugin>, "many">>;
|
|
99
|
+
}, z.core.$strip>>;
|
|
100
|
+
plugins: z.ZodOptional<z.ZodArray<z.ZodCustom<GeneratorPlugin, GeneratorPlugin>>>;
|
|
156
101
|
tmpDir: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
157
102
|
importRoutesUsingAbsolutePaths: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
158
|
-
},
|
|
159
|
-
target: "vue" | "react" | "solid";
|
|
160
|
-
routeFileIgnorePrefix: string;
|
|
161
|
-
routesDirectory: string;
|
|
162
|
-
quoteStyle: "single" | "double";
|
|
163
|
-
semicolons: boolean;
|
|
164
|
-
disableLogging: boolean;
|
|
165
|
-
routeTreeFileHeader: string[];
|
|
166
|
-
indexToken: string | RegExp | {
|
|
167
|
-
regex: string;
|
|
168
|
-
flags?: string | undefined;
|
|
169
|
-
};
|
|
170
|
-
routeToken: string | RegExp | {
|
|
171
|
-
regex: string;
|
|
172
|
-
flags?: string | undefined;
|
|
173
|
-
};
|
|
174
|
-
generatedRouteTree: string;
|
|
175
|
-
disableTypes: boolean;
|
|
176
|
-
addExtensions: string | boolean;
|
|
177
|
-
enableRouteTreeFormatting: boolean;
|
|
178
|
-
tmpDir: string;
|
|
179
|
-
importRoutesUsingAbsolutePaths: boolean;
|
|
180
|
-
plugins?: GeneratorPlugin[] | undefined;
|
|
181
|
-
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
182
|
-
routeFilePrefix?: string | undefined;
|
|
183
|
-
routeFileIgnorePattern?: string | undefined;
|
|
184
|
-
pathParamsAllowedCharacters?: (":" | "$" | ";" | "@" | "&" | "=" | "+" | ",")[] | undefined;
|
|
185
|
-
routeTreeFileFooter?: string[] | ((...args: unknown[]) => string[]) | undefined;
|
|
186
|
-
autoCodeSplitting?: boolean | undefined;
|
|
187
|
-
customScaffolding?: {
|
|
188
|
-
routeTemplate?: string | undefined;
|
|
189
|
-
lazyRouteTemplate?: string | undefined;
|
|
190
|
-
} | undefined;
|
|
191
|
-
experimental?: {
|
|
192
|
-
enableCodeSplitting?: boolean | undefined;
|
|
193
|
-
} | undefined;
|
|
194
|
-
}, {
|
|
195
|
-
plugins?: GeneratorPlugin[] | undefined;
|
|
196
|
-
target?: "vue" | "react" | "solid" | undefined;
|
|
197
|
-
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
198
|
-
routeFilePrefix?: string | undefined;
|
|
199
|
-
routeFileIgnorePrefix?: string | undefined;
|
|
200
|
-
routeFileIgnorePattern?: string | undefined;
|
|
201
|
-
routesDirectory?: string | undefined;
|
|
202
|
-
quoteStyle?: "single" | "double" | undefined;
|
|
203
|
-
semicolons?: boolean | undefined;
|
|
204
|
-
disableLogging?: boolean | undefined;
|
|
205
|
-
routeTreeFileHeader?: string[] | undefined;
|
|
206
|
-
indexToken?: string | RegExp | {
|
|
207
|
-
regex: string;
|
|
208
|
-
flags?: string | undefined;
|
|
209
|
-
} | undefined;
|
|
210
|
-
routeToken?: string | RegExp | {
|
|
211
|
-
regex: string;
|
|
212
|
-
flags?: string | undefined;
|
|
213
|
-
} | undefined;
|
|
214
|
-
pathParamsAllowedCharacters?: (":" | "$" | ";" | "@" | "&" | "=" | "+" | ",")[] | undefined;
|
|
215
|
-
generatedRouteTree?: string | undefined;
|
|
216
|
-
disableTypes?: boolean | undefined;
|
|
217
|
-
addExtensions?: string | boolean | undefined;
|
|
218
|
-
enableRouteTreeFormatting?: boolean | undefined;
|
|
219
|
-
routeTreeFileFooter?: string[] | ((...args: unknown[]) => string[]) | undefined;
|
|
220
|
-
autoCodeSplitting?: boolean | undefined;
|
|
221
|
-
customScaffolding?: {
|
|
222
|
-
routeTemplate?: string | undefined;
|
|
223
|
-
lazyRouteTemplate?: string | undefined;
|
|
224
|
-
} | undefined;
|
|
225
|
-
experimental?: {
|
|
226
|
-
enableCodeSplitting?: boolean | undefined;
|
|
227
|
-
} | undefined;
|
|
228
|
-
tmpDir?: string | undefined;
|
|
229
|
-
importRoutesUsingAbsolutePaths?: boolean | undefined;
|
|
230
|
-
}>;
|
|
103
|
+
}, z.core.$strip>;
|
|
231
104
|
export type Config = z.infer<typeof configSchema>;
|
|
232
105
|
type ResolveParams = {
|
|
233
106
|
configDirectory: string;
|
package/dist/cjs/utils.cjs
CHANGED
|
@@ -497,6 +497,24 @@ var inferFullPath = (routeNode) => {
|
|
|
497
497
|
var shouldPreferIndexRoute = (current, existing) => {
|
|
498
498
|
return existing.cleanedPath === "/" && current.cleanedPath !== "/";
|
|
499
499
|
};
|
|
500
|
+
var isIndexRouteNode = (routeNode) => {
|
|
501
|
+
return routeNode.routePath?.endsWith("/") ?? false;
|
|
502
|
+
};
|
|
503
|
+
var isPathlessRouteNode = (routeNode) => {
|
|
504
|
+
return routeNode._fsRouteType === "pathless_layout";
|
|
505
|
+
};
|
|
506
|
+
var shouldReplaceRouteNodeForTo = (current, existing) => {
|
|
507
|
+
const currentIsIndex = isIndexRouteNode(current);
|
|
508
|
+
if (currentIsIndex !== isIndexRouteNode(existing)) return currentIsIndex;
|
|
509
|
+
const currentIsPathless = isPathlessRouteNode(current);
|
|
510
|
+
if (currentIsPathless !== isPathlessRouteNode(existing)) return !currentIsPathless;
|
|
511
|
+
return true;
|
|
512
|
+
};
|
|
513
|
+
var shouldReplaceRouteNodeForFullPath = (current, existing) => {
|
|
514
|
+
const currentIsPathless = isPathlessRouteNode(current);
|
|
515
|
+
if (currentIsPathless !== isPathlessRouteNode(existing)) return !currentIsPathless;
|
|
516
|
+
return true;
|
|
517
|
+
};
|
|
500
518
|
/**
|
|
501
519
|
* Creates a map from fullPath to routeNode
|
|
502
520
|
*/
|
|
@@ -507,6 +525,8 @@ var createRouteNodesByFullPath = (routeNodes) => {
|
|
|
507
525
|
if (fullPath === "/" && map.has("/")) {
|
|
508
526
|
if (shouldPreferIndexRoute(routeNode, map.get("/"))) continue;
|
|
509
527
|
}
|
|
528
|
+
const existing = map.get(fullPath);
|
|
529
|
+
if (existing && !shouldReplaceRouteNodeForFullPath(routeNode, existing)) continue;
|
|
510
530
|
map.set(fullPath, routeNode);
|
|
511
531
|
}
|
|
512
532
|
return map;
|
|
@@ -518,9 +538,8 @@ var createRouteNodesByTo = (routeNodes) => {
|
|
|
518
538
|
const map = /* @__PURE__ */ new Map();
|
|
519
539
|
for (const routeNode of dedupeBranchesAndIndexRoutes(routeNodes)) {
|
|
520
540
|
const to = inferTo(routeNode);
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
}
|
|
541
|
+
const existing = map.get(to);
|
|
542
|
+
if (existing && !shouldReplaceRouteNodeForTo(routeNode, existing)) continue;
|
|
524
543
|
map.set(to, routeNode);
|
|
525
544
|
}
|
|
526
545
|
return map;
|