@tanstack/router-core 0.0.1-beta.15 → 0.0.1-beta.150
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/LICENSE +21 -0
- package/build/cjs/fileRoute.js +29 -0
- package/build/cjs/fileRoute.js.map +1 -0
- package/build/cjs/history.js +226 -0
- package/build/cjs/history.js.map +1 -0
- package/build/cjs/index.js +78 -0
- package/build/cjs/{packages/router-core/src/index.js.map → index.js.map} +1 -1
- package/build/cjs/{packages/router-core/src/path.js → path.js} +45 -56
- package/build/cjs/path.js.map +1 -0
- package/build/cjs/{packages/router-core/src/qss.js → qss.js} +10 -16
- package/build/cjs/qss.js.map +1 -0
- package/build/cjs/route.js +103 -0
- package/build/cjs/route.js.map +1 -0
- package/build/cjs/router.js +1113 -0
- package/build/cjs/router.js.map +1 -0
- package/build/cjs/{packages/router-core/src/searchParams.js → searchParams.js} +11 -13
- package/build/cjs/searchParams.js.map +1 -0
- package/build/cjs/{packages/router-core/src/utils.js → utils.js} +54 -64
- package/build/cjs/utils.js.map +1 -0
- package/build/esm/index.js +1417 -2105
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +59 -49
- package/build/stats-react.json +203 -234
- package/build/types/index.d.ts +604 -426
- package/build/umd/index.development.js +1640 -2224
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +13 -2
- package/build/umd/index.production.js.map +1 -1
- package/package.json +11 -7
- package/src/fileRoute.ts +122 -0
- package/src/history.ts +292 -0
- package/src/index.ts +3 -10
- package/src/link.ts +118 -113
- package/src/path.ts +37 -17
- package/src/qss.ts +1 -2
- package/src/route.ts +891 -218
- package/src/routeInfo.ts +121 -204
- package/src/router.ts +1494 -1017
- package/src/searchParams.ts +1 -1
- package/src/utils.ts +80 -49
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -33
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
- package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js +0 -33
- package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js.map +0 -1
- package/build/cjs/node_modules/history/index.js +0 -815
- package/build/cjs/node_modules/history/index.js.map +0 -1
- package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js +0 -30
- package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js.map +0 -1
- package/build/cjs/packages/router-core/src/index.js +0 -58
- package/build/cjs/packages/router-core/src/path.js.map +0 -1
- package/build/cjs/packages/router-core/src/qss.js.map +0 -1
- package/build/cjs/packages/router-core/src/route.js +0 -147
- package/build/cjs/packages/router-core/src/route.js.map +0 -1
- package/build/cjs/packages/router-core/src/routeConfig.js +0 -69
- package/build/cjs/packages/router-core/src/routeConfig.js.map +0 -1
- package/build/cjs/packages/router-core/src/routeMatch.js +0 -231
- package/build/cjs/packages/router-core/src/routeMatch.js.map +0 -1
- package/build/cjs/packages/router-core/src/router.js +0 -833
- package/build/cjs/packages/router-core/src/router.js.map +0 -1
- package/build/cjs/packages/router-core/src/searchParams.js.map +0 -1
- package/build/cjs/packages/router-core/src/utils.js.map +0 -1
- package/src/frameworks.ts +0 -11
- package/src/routeConfig.ts +0 -514
- package/src/routeMatch.ts +0 -319
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/router-core",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "0.0.1-beta.
|
|
4
|
+
"version": "0.0.1-beta.150",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "tanstack/router",
|
|
7
7
|
"homepage": "https://tanstack.com/router",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"url": "https://github.com/sponsors/tannerlinsley"
|
|
24
24
|
},
|
|
25
25
|
"module": "build/esm/index.js",
|
|
26
|
-
"main": "build/cjs/
|
|
26
|
+
"main": "build/cjs/index.js",
|
|
27
27
|
"browser": "build/umd/index.production.js",
|
|
28
28
|
"types": "build/types/index.d.ts",
|
|
29
29
|
"engines": {
|
|
@@ -40,10 +40,14 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@babel/runtime": "^7.16.7",
|
|
43
|
-
"
|
|
44
|
-
"tiny-
|
|
43
|
+
"tiny-invariant": "^1.3.1",
|
|
44
|
+
"tiny-warning": "^1.0.3",
|
|
45
|
+
"@gisatcz/cross-package-react-context": "^0.2.0",
|
|
46
|
+
"@tanstack/react-store": "0.0.1-beta.150"
|
|
45
47
|
},
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "rollup --config rollup.config.js",
|
|
50
|
+
"test": "vitest",
|
|
51
|
+
"test:dev": "vitest --watch"
|
|
48
52
|
}
|
|
49
|
-
}
|
|
53
|
+
}
|
package/src/fileRoute.ts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { Last, ParsePathParams, Split } from './link'
|
|
2
|
+
import {
|
|
3
|
+
AnyRoute,
|
|
4
|
+
ResolveFullPath,
|
|
5
|
+
ResolveId,
|
|
6
|
+
AnySearchSchema,
|
|
7
|
+
ResolveFullSearchSchema,
|
|
8
|
+
MergeParamsFromParent,
|
|
9
|
+
RouteContext,
|
|
10
|
+
AnyContext,
|
|
11
|
+
RouteOptions,
|
|
12
|
+
InferFullSearchSchema,
|
|
13
|
+
UpdatableRouteOptions,
|
|
14
|
+
Route,
|
|
15
|
+
} from './route'
|
|
16
|
+
import { DefaultRoutesInfo } from './routeInfo'
|
|
17
|
+
|
|
18
|
+
export interface FileRoutesByPath {
|
|
19
|
+
// '/': {
|
|
20
|
+
// parentRoute: typeof rootRoute
|
|
21
|
+
// }
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type Test = Last<Split<'/test/:id'>>
|
|
25
|
+
|
|
26
|
+
export class FileRoute<
|
|
27
|
+
TFilePath extends keyof FileRoutesByPath,
|
|
28
|
+
TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],
|
|
29
|
+
TPath extends string = Last<Split<TFilePath>>,
|
|
30
|
+
TCustomId extends string = TPath extends `_${infer T}` ? T : string,
|
|
31
|
+
> {
|
|
32
|
+
constructor(public path: TFilePath) {}
|
|
33
|
+
|
|
34
|
+
createRoute = <
|
|
35
|
+
TFullPath extends ResolveFullPath<TParentRoute, TPath> = ResolveFullPath<
|
|
36
|
+
TParentRoute,
|
|
37
|
+
TPath
|
|
38
|
+
>,
|
|
39
|
+
TId extends ResolveId<TParentRoute, TCustomId, TPath> = ResolveId<
|
|
40
|
+
TParentRoute,
|
|
41
|
+
TCustomId,
|
|
42
|
+
TPath
|
|
43
|
+
>,
|
|
44
|
+
TLoader = unknown,
|
|
45
|
+
TSearchSchema extends AnySearchSchema = {},
|
|
46
|
+
TFullSearchSchema extends AnySearchSchema = ResolveFullSearchSchema<
|
|
47
|
+
TParentRoute,
|
|
48
|
+
TSearchSchema
|
|
49
|
+
>,
|
|
50
|
+
TParams extends Record<ParsePathParams<TPath>, any> = Record<
|
|
51
|
+
ParsePathParams<TPath>,
|
|
52
|
+
string
|
|
53
|
+
>,
|
|
54
|
+
TAllParams extends MergeParamsFromParent<
|
|
55
|
+
TParentRoute['__types']['allParams'],
|
|
56
|
+
TParams
|
|
57
|
+
> = MergeParamsFromParent<TParentRoute['__types']['allParams'], TParams>,
|
|
58
|
+
TParentContext extends TParentRoute['__types']['routeContext'] = TParentRoute['__types']['routeContext'],
|
|
59
|
+
TAllParentContext extends TParentRoute['__types']['context'] = TParentRoute['__types']['context'],
|
|
60
|
+
TRouteContext extends RouteContext = RouteContext,
|
|
61
|
+
TContext extends MergeParamsFromParent<
|
|
62
|
+
TParentRoute['__types']['context'],
|
|
63
|
+
TRouteContext
|
|
64
|
+
> = MergeParamsFromParent<
|
|
65
|
+
TParentRoute['__types']['context'],
|
|
66
|
+
TRouteContext
|
|
67
|
+
>,
|
|
68
|
+
TRouterContext extends AnyContext = AnyContext,
|
|
69
|
+
TChildren extends unknown = unknown,
|
|
70
|
+
TRoutesInfo extends DefaultRoutesInfo = DefaultRoutesInfo,
|
|
71
|
+
>(
|
|
72
|
+
options: Omit<
|
|
73
|
+
RouteOptions<
|
|
74
|
+
TParentRoute,
|
|
75
|
+
TCustomId,
|
|
76
|
+
TPath,
|
|
77
|
+
TLoader,
|
|
78
|
+
InferFullSearchSchema<TParentRoute>,
|
|
79
|
+
TSearchSchema,
|
|
80
|
+
TFullSearchSchema,
|
|
81
|
+
TParentRoute['__types']['allParams'],
|
|
82
|
+
TParams,
|
|
83
|
+
TAllParams,
|
|
84
|
+
TParentContext,
|
|
85
|
+
TAllParentContext,
|
|
86
|
+
TRouteContext,
|
|
87
|
+
TContext
|
|
88
|
+
>,
|
|
89
|
+
'getParentRoute' | 'path' | 'id'
|
|
90
|
+
> &
|
|
91
|
+
UpdatableRouteOptions<
|
|
92
|
+
TLoader,
|
|
93
|
+
TSearchSchema,
|
|
94
|
+
TFullSearchSchema,
|
|
95
|
+
TAllParams,
|
|
96
|
+
TRouteContext,
|
|
97
|
+
TContext
|
|
98
|
+
>,
|
|
99
|
+
): Route<
|
|
100
|
+
TParentRoute,
|
|
101
|
+
TPath,
|
|
102
|
+
TFullPath,
|
|
103
|
+
TCustomId,
|
|
104
|
+
TId,
|
|
105
|
+
TLoader,
|
|
106
|
+
TSearchSchema,
|
|
107
|
+
TFullSearchSchema,
|
|
108
|
+
TParams,
|
|
109
|
+
TAllParams,
|
|
110
|
+
TParentContext,
|
|
111
|
+
TAllParentContext,
|
|
112
|
+
TRouteContext,
|
|
113
|
+
TContext,
|
|
114
|
+
TRouterContext,
|
|
115
|
+
TChildren,
|
|
116
|
+
TRoutesInfo
|
|
117
|
+
> => {
|
|
118
|
+
const route = new Route(options as any)
|
|
119
|
+
;(route as any).isRoot = false
|
|
120
|
+
return route as any
|
|
121
|
+
}
|
|
122
|
+
}
|
package/src/history.ts
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
// While the public API was clearly inspired by the "history" npm package,
|
|
2
|
+
// This implementation attempts to be more lightweight by
|
|
3
|
+
// making assumptions about the way TanStack Router works
|
|
4
|
+
|
|
5
|
+
export interface RouterHistory {
|
|
6
|
+
location: RouterLocation
|
|
7
|
+
listen: (cb: () => void) => () => void
|
|
8
|
+
push: (path: string, state?: any) => void
|
|
9
|
+
replace: (path: string, state?: any) => void
|
|
10
|
+
go: (index: number) => void
|
|
11
|
+
back: () => void
|
|
12
|
+
forward: () => void
|
|
13
|
+
createHref: (href: string) => string
|
|
14
|
+
block: (blockerFn: BlockerFn) => () => void
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ParsedPath {
|
|
18
|
+
href: string
|
|
19
|
+
pathname: string
|
|
20
|
+
search: string
|
|
21
|
+
hash: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface RouterLocation extends ParsedPath {
|
|
25
|
+
state: any
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
type BlockerFn = (retry: () => void, cancel: () => void) => void
|
|
29
|
+
|
|
30
|
+
const pushStateEvent = 'pushstate'
|
|
31
|
+
const popStateEvent = 'popstate'
|
|
32
|
+
const beforeUnloadEvent = 'beforeunload'
|
|
33
|
+
|
|
34
|
+
const beforeUnloadListener = (event: Event) => {
|
|
35
|
+
event.preventDefault()
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
return (event.returnValue = '')
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const stopBlocking = () => {
|
|
41
|
+
removeEventListener(beforeUnloadEvent, beforeUnloadListener, {
|
|
42
|
+
capture: true,
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function createHistory(opts: {
|
|
47
|
+
getLocation: () => RouterLocation
|
|
48
|
+
listener: false | ((onUpdate: () => void) => () => void)
|
|
49
|
+
pushState: (path: string, state: any) => void
|
|
50
|
+
replaceState: (path: string, state: any) => void
|
|
51
|
+
go: (n: number) => void
|
|
52
|
+
back: () => void
|
|
53
|
+
forward: () => void
|
|
54
|
+
createHref: (path: string) => string
|
|
55
|
+
}): RouterHistory {
|
|
56
|
+
let location = opts.getLocation()
|
|
57
|
+
let unsub = () => {}
|
|
58
|
+
let listeners = new Set<() => void>()
|
|
59
|
+
let blockers: BlockerFn[] = []
|
|
60
|
+
let queue: (() => void)[] = []
|
|
61
|
+
|
|
62
|
+
const tryFlush = () => {
|
|
63
|
+
if (blockers.length) {
|
|
64
|
+
blockers[0]?.(tryFlush, () => {
|
|
65
|
+
blockers = []
|
|
66
|
+
stopBlocking()
|
|
67
|
+
})
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
while (queue.length) {
|
|
72
|
+
queue.shift()?.()
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (!opts.listener) {
|
|
76
|
+
onUpdate()
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const queueTask = (task: () => void) => {
|
|
81
|
+
queue.push(task)
|
|
82
|
+
tryFlush()
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const onUpdate = () => {
|
|
86
|
+
location = opts.getLocation()
|
|
87
|
+
listeners.forEach((listener) => listener())
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
get location() {
|
|
92
|
+
return location
|
|
93
|
+
},
|
|
94
|
+
listen: (cb: () => void) => {
|
|
95
|
+
if (listeners.size === 0) {
|
|
96
|
+
unsub =
|
|
97
|
+
typeof opts.listener === 'function'
|
|
98
|
+
? opts.listener(onUpdate)
|
|
99
|
+
: () => {}
|
|
100
|
+
}
|
|
101
|
+
listeners.add(cb)
|
|
102
|
+
|
|
103
|
+
return () => {
|
|
104
|
+
listeners.delete(cb)
|
|
105
|
+
if (listeners.size === 0) {
|
|
106
|
+
unsub()
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
push: (path: string, state: any) => {
|
|
111
|
+
queueTask(() => {
|
|
112
|
+
opts.pushState(path, state)
|
|
113
|
+
})
|
|
114
|
+
},
|
|
115
|
+
replace: (path: string, state: any) => {
|
|
116
|
+
queueTask(() => {
|
|
117
|
+
opts.replaceState(path, state)
|
|
118
|
+
})
|
|
119
|
+
},
|
|
120
|
+
go: (index) => {
|
|
121
|
+
queueTask(() => {
|
|
122
|
+
opts.go(index)
|
|
123
|
+
})
|
|
124
|
+
},
|
|
125
|
+
back: () => {
|
|
126
|
+
queueTask(() => {
|
|
127
|
+
opts.back()
|
|
128
|
+
})
|
|
129
|
+
},
|
|
130
|
+
forward: () => {
|
|
131
|
+
queueTask(() => {
|
|
132
|
+
opts.forward()
|
|
133
|
+
})
|
|
134
|
+
},
|
|
135
|
+
createHref: (str) => opts.createHref(str),
|
|
136
|
+
block: (cb) => {
|
|
137
|
+
blockers.push(cb)
|
|
138
|
+
|
|
139
|
+
if (blockers.length === 1) {
|
|
140
|
+
addEventListener(beforeUnloadEvent, beforeUnloadListener, {
|
|
141
|
+
capture: true,
|
|
142
|
+
})
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return () => {
|
|
146
|
+
blockers = blockers.filter((b) => b !== cb)
|
|
147
|
+
|
|
148
|
+
if (!blockers.length) {
|
|
149
|
+
stopBlocking()
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function createBrowserHistory(opts?: {
|
|
157
|
+
getHref?: () => string
|
|
158
|
+
createHref?: (path: string) => string
|
|
159
|
+
}): RouterHistory {
|
|
160
|
+
const getHref =
|
|
161
|
+
opts?.getHref ??
|
|
162
|
+
(() =>
|
|
163
|
+
`${window.location.pathname}${window.location.search}${window.location.hash}`)
|
|
164
|
+
const createHref = opts?.createHref ?? ((path) => path)
|
|
165
|
+
const getLocation = () => parseLocation(getHref(), history.state)
|
|
166
|
+
|
|
167
|
+
return createHistory({
|
|
168
|
+
getLocation,
|
|
169
|
+
listener: (onUpdate) => {
|
|
170
|
+
window.addEventListener(pushStateEvent, onUpdate)
|
|
171
|
+
window.addEventListener(popStateEvent, onUpdate)
|
|
172
|
+
|
|
173
|
+
var pushState = window.history.pushState
|
|
174
|
+
window.history.pushState = function () {
|
|
175
|
+
let res = pushState.apply(history, arguments as any)
|
|
176
|
+
onUpdate()
|
|
177
|
+
return res
|
|
178
|
+
}
|
|
179
|
+
var replaceState = window.history.replaceState
|
|
180
|
+
window.history.replaceState = function () {
|
|
181
|
+
let res = replaceState.apply(history, arguments as any)
|
|
182
|
+
onUpdate()
|
|
183
|
+
return res
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return () => {
|
|
187
|
+
window.history.pushState = pushState
|
|
188
|
+
window.history.replaceState = replaceState
|
|
189
|
+
window.removeEventListener(pushStateEvent, onUpdate)
|
|
190
|
+
window.removeEventListener(popStateEvent, onUpdate)
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
pushState: (path, state) => {
|
|
194
|
+
window.history.pushState(
|
|
195
|
+
{ ...state, key: createRandomKey() },
|
|
196
|
+
'',
|
|
197
|
+
createHref(path),
|
|
198
|
+
)
|
|
199
|
+
},
|
|
200
|
+
replaceState: (path, state) => {
|
|
201
|
+
window.history.replaceState(
|
|
202
|
+
{ ...state, key: createRandomKey() },
|
|
203
|
+
'',
|
|
204
|
+
createHref(path),
|
|
205
|
+
)
|
|
206
|
+
},
|
|
207
|
+
back: () => window.history.back(),
|
|
208
|
+
forward: () => window.history.forward(),
|
|
209
|
+
go: (n) => window.history.go(n),
|
|
210
|
+
createHref: (path) => createHref(path),
|
|
211
|
+
})
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export function createHashHistory(): RouterHistory {
|
|
215
|
+
return createBrowserHistory({
|
|
216
|
+
getHref: () => window.location.hash.substring(1),
|
|
217
|
+
createHref: (path) => `#${path}`,
|
|
218
|
+
})
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export function createMemoryHistory(
|
|
222
|
+
opts: {
|
|
223
|
+
initialEntries: string[]
|
|
224
|
+
initialIndex?: number
|
|
225
|
+
} = {
|
|
226
|
+
initialEntries: ['/'],
|
|
227
|
+
},
|
|
228
|
+
): RouterHistory {
|
|
229
|
+
const entries = opts.initialEntries
|
|
230
|
+
let index = opts.initialIndex ?? entries.length - 1
|
|
231
|
+
let currentState = {}
|
|
232
|
+
|
|
233
|
+
const getLocation = () => parseLocation(entries[index]!, currentState)
|
|
234
|
+
|
|
235
|
+
return createHistory({
|
|
236
|
+
getLocation,
|
|
237
|
+
listener: false,
|
|
238
|
+
pushState: (path, state) => {
|
|
239
|
+
currentState = {
|
|
240
|
+
...state,
|
|
241
|
+
key: createRandomKey(),
|
|
242
|
+
}
|
|
243
|
+
entries.push(path)
|
|
244
|
+
index++
|
|
245
|
+
},
|
|
246
|
+
replaceState: (path, state) => {
|
|
247
|
+
currentState = {
|
|
248
|
+
...state,
|
|
249
|
+
key: createRandomKey(),
|
|
250
|
+
}
|
|
251
|
+
entries[index] = path
|
|
252
|
+
},
|
|
253
|
+
back: () => {
|
|
254
|
+
index--
|
|
255
|
+
},
|
|
256
|
+
forward: () => {
|
|
257
|
+
index = Math.min(index + 1, entries.length - 1)
|
|
258
|
+
},
|
|
259
|
+
go: (n) => window.history.go(n),
|
|
260
|
+
createHref: (path) => path,
|
|
261
|
+
})
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function parseLocation(href: string, state: any): RouterLocation {
|
|
265
|
+
let hashIndex = href.indexOf('#')
|
|
266
|
+
let searchIndex = href.indexOf('?')
|
|
267
|
+
|
|
268
|
+
return {
|
|
269
|
+
href,
|
|
270
|
+
pathname: href.substring(
|
|
271
|
+
0,
|
|
272
|
+
hashIndex > 0
|
|
273
|
+
? searchIndex > 0
|
|
274
|
+
? Math.min(hashIndex, searchIndex)
|
|
275
|
+
: hashIndex
|
|
276
|
+
: searchIndex > 0
|
|
277
|
+
? searchIndex
|
|
278
|
+
: href.length,
|
|
279
|
+
),
|
|
280
|
+
hash: hashIndex > -1 ? href.substring(hashIndex) : '',
|
|
281
|
+
search:
|
|
282
|
+
searchIndex > -1
|
|
283
|
+
? href.slice(searchIndex, hashIndex === -1 ? undefined : hashIndex)
|
|
284
|
+
: '',
|
|
285
|
+
state,
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// Thanks co-pilot!
|
|
290
|
+
function createRandomKey() {
|
|
291
|
+
return (Math.random() + 1).toString(36).substring(7)
|
|
292
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
export {
|
|
2
|
-
createHashHistory,
|
|
3
|
-
createBrowserHistory,
|
|
4
|
-
createMemoryHistory,
|
|
5
|
-
} from 'history'
|
|
6
|
-
|
|
7
1
|
export { default as invariant } from 'tiny-invariant'
|
|
8
|
-
|
|
9
|
-
export * from './
|
|
2
|
+
export { default as warning } from 'tiny-warning'
|
|
3
|
+
export * from './history'
|
|
10
4
|
export * from './link'
|
|
11
5
|
export * from './path'
|
|
12
6
|
export * from './qss'
|
|
13
7
|
export * from './route'
|
|
14
|
-
export * from './
|
|
8
|
+
export * from './fileRoute'
|
|
15
9
|
export * from './routeInfo'
|
|
16
|
-
export * from './routeMatch'
|
|
17
10
|
export * from './router'
|
|
18
11
|
export * from './searchParams'
|
|
19
12
|
export * from './utils'
|