Skip to content

Commit 715c881

Browse files
committed
Merge branch 'main' into basepath-redirect
2 parents 57eaeb0 + c906682 commit 715c881

142 files changed

Lines changed: 1704 additions & 176 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
dist
3+
port*.txt
4+
test-results
5+
playwright-report
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Escaped Special Strings E2E Test</title>
7+
</head>
8+
<body>
9+
<div id="app"></div>
10+
<script type="module" src="/src/main.tsx"></script>
11+
</body>
12+
</html>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "tanstack-router-e2e-react-escaped-special-strings",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"dev": "vite --port 3000",
7+
"dev:e2e": "vite",
8+
"build": "vite build && tsc --noEmit",
9+
"preview": "vite preview",
10+
"start": "vite",
11+
"test:e2e": "pnpm run test:e2e:default",
12+
"test:e2e:default": "rm -rf port*.txt; playwright test --project=chromium"
13+
},
14+
"dependencies": {
15+
"@tanstack/react-router": "workspace:^",
16+
"@tanstack/router-plugin": "workspace:^",
17+
"react": "^19.0.0",
18+
"react-dom": "^19.0.0"
19+
},
20+
"devDependencies": {
21+
"@playwright/test": "^1.50.1",
22+
"@tanstack/router-e2e-utils": "workspace:^",
23+
"@types/react": "^19.0.8",
24+
"@types/react-dom": "^19.0.3",
25+
"@vitejs/plugin-react": "^4.3.4",
26+
"vite": "^7.1.7"
27+
}
28+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { defineConfig, devices } from '@playwright/test'
2+
import {
3+
getDummyServerPort,
4+
getTestServerPort,
5+
} from '@tanstack/router-e2e-utils'
6+
import packageJson from './package.json' with { type: 'json' }
7+
8+
const PORT = await getTestServerPort(packageJson.name)
9+
const EXTERNAL_PORT = await getDummyServerPort(packageJson.name)
10+
const baseURL = `http://localhost:${PORT}`
11+
const command = `pnpm build && pnpm preview --port ${PORT}`
12+
13+
console.info('Running with mode: ', process.env.MODE || 'default')
14+
15+
/**
16+
* See https://playwright.dev/docs/test-configuration.
17+
*/
18+
export default defineConfig({
19+
testDir: './tests',
20+
workers: 1,
21+
22+
reporter: [['line']],
23+
24+
globalSetup: './tests/setup/global.setup.ts',
25+
globalTeardown: './tests/setup/global.teardown.ts',
26+
27+
use: {
28+
/* Base URL to use in actions like `await page.goto('/')`. */
29+
baseURL,
30+
},
31+
32+
webServer: {
33+
command,
34+
url: baseURL,
35+
reuseExistingServer: !process.env.CI,
36+
stdout: 'pipe',
37+
env: {
38+
MODE: process.env.MODE || '',
39+
VITE_MODE: process.env.MODE || '',
40+
VITE_NODE_ENV: 'test',
41+
VITE_EXTERNAL_PORT: String(EXTERNAL_PORT),
42+
VITE_SERVER_PORT: String(PORT),
43+
PORT: String(PORT),
44+
},
45+
},
46+
47+
projects: [
48+
{
49+
name: 'chromium',
50+
use: { ...devices['Desktop Chrome'] },
51+
},
52+
],
53+
})
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from 'react'
2+
import ReactDOM from 'react-dom/client'
3+
import { RouterProvider, createRouter } from '@tanstack/react-router'
4+
import { routeTree } from './routeTree.gen'
5+
6+
// Set up a Router instance
7+
const router = createRouter({
8+
routeTree,
9+
defaultPreload: 'intent',
10+
})
11+
12+
// Register things for typesafety
13+
declare module '@tanstack/react-router' {
14+
interface Register {
15+
router: typeof router
16+
}
17+
}
18+
19+
const rootElement = document.getElementById('app')!
20+
21+
if (!rootElement.innerHTML) {
22+
const root = ReactDOM.createRoot(rootElement)
23+
root.render(<RouterProvider router={router} />)
24+
}
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
/* eslint-disable */
2+
3+
// @ts-nocheck
4+
5+
// noinspection JSUnusedGlobalSymbols
6+
7+
// This file was automatically generated by TanStack Router.
8+
// You should NOT make any changes in this file as it will be overwritten.
9+
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
10+
11+
import { Route as rootRouteImport } from './routes/__root'
12+
import { Route as IndexRouteImport } from './routes/[index]'
13+
import { Route as RouteRouteImport } from './routes/[route]'
14+
import { Route as LazyRouteImport } from './routes/[lazy]'
15+
import { Route as BlogRouteImport } from './routes/blog[_]'
16+
import { Route as LayoutRouteImport } from './routes/[_]layout'
17+
18+
const IndexRoute = IndexRouteImport.update({
19+
id: '/index',
20+
path: '/index',
21+
getParentRoute: () => rootRouteImport,
22+
} as any)
23+
const RouteRoute = RouteRouteImport.update({
24+
id: '/route',
25+
path: '/route',
26+
getParentRoute: () => rootRouteImport,
27+
} as any)
28+
const LazyRoute = LazyRouteImport.update({
29+
id: '/lazy',
30+
path: '/lazy',
31+
getParentRoute: () => rootRouteImport,
32+
} as any)
33+
const BlogRoute = BlogRouteImport.update({
34+
id: '/blog_',
35+
path: '/blog_',
36+
getParentRoute: () => rootRouteImport,
37+
} as any)
38+
const LayoutRoute = LayoutRouteImport.update({
39+
id: '/_layout',
40+
path: '/_layout',
41+
getParentRoute: () => rootRouteImport,
42+
} as any)
43+
44+
export interface FileRoutesByFullPath {
45+
'/_layout': typeof LayoutRoute
46+
'/blog_': typeof BlogRoute
47+
'/index': typeof IndexRoute
48+
'/lazy': typeof LazyRoute
49+
'/route': typeof RouteRoute
50+
}
51+
export interface FileRoutesByTo {
52+
'/_layout': typeof LayoutRoute
53+
'/blog_': typeof BlogRoute
54+
'/index': typeof IndexRoute
55+
'/lazy': typeof LazyRoute
56+
'/route': typeof RouteRoute
57+
}
58+
export interface FileRoutesById {
59+
__root__: typeof rootRouteImport
60+
'/_layout': typeof LayoutRoute
61+
'/blog_': typeof BlogRoute
62+
'/index': typeof IndexRoute
63+
'/lazy': typeof LazyRoute
64+
'/route': typeof RouteRoute
65+
}
66+
export interface FileRouteTypes {
67+
fileRoutesByFullPath: FileRoutesByFullPath
68+
fullPaths: '/_layout' | '/blog_' | '/index' | '/lazy' | '/route'
69+
fileRoutesByTo: FileRoutesByTo
70+
to: '/_layout' | '/blog_' | '/index' | '/lazy' | '/route'
71+
id: '__root__' | '/_layout' | '/blog_' | '/index' | '/lazy' | '/route'
72+
fileRoutesById: FileRoutesById
73+
}
74+
export interface RootRouteChildren {
75+
LayoutRoute: typeof LayoutRoute
76+
BlogRoute: typeof BlogRoute
77+
IndexRoute: typeof IndexRoute
78+
LazyRoute: typeof LazyRoute
79+
RouteRoute: typeof RouteRoute
80+
}
81+
82+
declare module '@tanstack/react-router' {
83+
interface FileRoutesByPath {
84+
'/index': {
85+
id: '/index'
86+
path: '/index'
87+
fullPath: '/index'
88+
preLoaderRoute: typeof IndexRouteImport
89+
parentRoute: typeof rootRouteImport
90+
}
91+
'/route': {
92+
id: '/route'
93+
path: '/route'
94+
fullPath: '/route'
95+
preLoaderRoute: typeof RouteRouteImport
96+
parentRoute: typeof rootRouteImport
97+
}
98+
'/lazy': {
99+
id: '/lazy'
100+
path: '/lazy'
101+
fullPath: '/lazy'
102+
preLoaderRoute: typeof LazyRouteImport
103+
parentRoute: typeof rootRouteImport
104+
}
105+
'/blog_': {
106+
id: '/blog_'
107+
path: '/blog_'
108+
fullPath: '/blog_'
109+
preLoaderRoute: typeof BlogRouteImport
110+
parentRoute: typeof rootRouteImport
111+
}
112+
'/_layout': {
113+
id: '/_layout'
114+
path: '/_layout'
115+
fullPath: '/_layout'
116+
preLoaderRoute: typeof LayoutRouteImport
117+
parentRoute: typeof rootRouteImport
118+
}
119+
}
120+
}
121+
122+
const rootRouteChildren: RootRouteChildren = {
123+
LayoutRoute: LayoutRoute,
124+
BlogRoute: BlogRoute,
125+
IndexRoute: IndexRoute,
126+
LazyRoute: LazyRoute,
127+
RouteRoute: RouteRoute,
128+
}
129+
export const routeTree = rootRouteImport
130+
._addFileChildren(rootRouteChildren)
131+
._addFileTypes<FileRouteTypes>()
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { createFileRoute } from '@tanstack/react-router'
2+
3+
// This file uses [_]layout escaping to create a literal /_layout path
4+
// instead of being treated as a pathless layout route
5+
export const Route = createFileRoute('/_layout')({
6+
component: EscapedUnderscoreLayoutComponent,
7+
})
8+
9+
function EscapedUnderscoreLayoutComponent() {
10+
return (
11+
<div>
12+
<h2 data-testid="page-title">Escaped Underscore Layout Page</h2>
13+
<p data-testid="page-path">/_layout</p>
14+
<p data-testid="page-description">
15+
This route was created using [_]layout.tsx to escape the leading
16+
underscore. It renders at the literal path /_layout instead of being a
17+
pathless layout.
18+
</p>
19+
</div>
20+
)
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { createFileRoute } from '@tanstack/react-router'
2+
3+
// This file uses [index] escaping to create a literal /index route
4+
// instead of being treated as an index route for the parent
5+
export const Route = createFileRoute('/index')({
6+
component: EscapedIndexComponent,
7+
})
8+
9+
function EscapedIndexComponent() {
10+
return (
11+
<div>
12+
<h2 data-testid="page-title">Escaped Index Page</h2>
13+
<p data-testid="page-path">/index</p>
14+
<p data-testid="page-description">
15+
This route was created using [index].tsx to escape the special "index"
16+
token. It renders at the literal path /index instead of being the index
17+
route.
18+
</p>
19+
</div>
20+
)
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { createFileRoute } from '@tanstack/react-router'
2+
3+
// This file uses [lazy] escaping to create a literal /lazy path
4+
// instead of being treated as a lazy-loaded route
5+
export const Route = createFileRoute('/lazy')({
6+
component: EscapedLazyComponent,
7+
})
8+
9+
function EscapedLazyComponent() {
10+
return (
11+
<div>
12+
<h2 data-testid="page-title">Escaped Lazy Page</h2>
13+
<p data-testid="page-path">/lazy</p>
14+
<p data-testid="page-description">
15+
This route was created using [lazy].tsx to escape the special "lazy"
16+
token. It renders at the literal path /lazy instead of being a
17+
lazy-loaded route.
18+
</p>
19+
</div>
20+
)
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { createFileRoute } from '@tanstack/react-router'
2+
3+
// This file uses [route] escaping to create a literal /route path
4+
// instead of being treated as a layout configuration file
5+
export const Route = createFileRoute('/route')({
6+
component: EscapedRouteComponent,
7+
})
8+
9+
function EscapedRouteComponent() {
10+
return (
11+
<div>
12+
<h2 data-testid="page-title">Escaped Route Page</h2>
13+
<p data-testid="page-path">/route</p>
14+
<p data-testid="page-description">
15+
This route was created using [route].tsx to escape the special "route"
16+
token. It renders at the literal path /route instead of being a layout
17+
configuration.
18+
</p>
19+
</div>
20+
)
21+
}

0 commit comments

Comments
 (0)