@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/src/searchParams.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { decode, encode } from './qss'
|
|
2
|
-
import { AnySearchSchema } from './
|
|
2
|
+
import { AnySearchSchema } from './route'
|
|
3
3
|
|
|
4
4
|
export const defaultParseSearch = parseSearchWith(JSON.parse)
|
|
5
5
|
export const defaultStringifySearch = stringifySearchWith(JSON.stringify)
|
package/src/utils.ts
CHANGED
|
@@ -7,13 +7,14 @@ export type PickAsRequired<T, K extends keyof T> = Omit<T, K> &
|
|
|
7
7
|
export type PickAsPartial<T, K extends keyof T> = Omit<T, K> &
|
|
8
8
|
Partial<Pick<T, K>>
|
|
9
9
|
export type PickUnsafe<T, K> = K extends keyof T ? Pick<T, K> : never
|
|
10
|
-
export type PickExtra<T, K> =
|
|
10
|
+
export type PickExtra<T, K> = {
|
|
11
11
|
[TKey in keyof K as string extends TKey
|
|
12
12
|
? never
|
|
13
13
|
: TKey extends keyof T
|
|
14
14
|
? never
|
|
15
15
|
: TKey]: K[TKey]
|
|
16
|
-
}
|
|
16
|
+
}
|
|
17
|
+
|
|
17
18
|
export type PickRequired<T> = {
|
|
18
19
|
[K in keyof T as undefined extends T[K] ? never : K]: T[K]
|
|
19
20
|
}
|
|
@@ -24,11 +25,27 @@ export type Expand<T> = T extends object
|
|
|
24
25
|
: never
|
|
25
26
|
: T
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
export type UnionToIntersection<U> = (
|
|
29
|
+
U extends any ? (k: U) => void : never
|
|
30
|
+
) extends (k: infer I) => any
|
|
31
|
+
? I
|
|
32
|
+
: never
|
|
33
|
+
|
|
34
|
+
type Compute<T> = { [K in keyof T]: T[K] } | never
|
|
35
|
+
|
|
36
|
+
type AllKeys<T> = T extends any ? keyof T : never
|
|
37
|
+
|
|
38
|
+
export type MergeUnion<T, Keys extends keyof T = keyof T> = Compute<
|
|
39
|
+
{
|
|
40
|
+
[K in Keys]: T[Keys]
|
|
41
|
+
} & {
|
|
42
|
+
[K in AllKeys<T>]?: T extends any
|
|
43
|
+
? K extends keyof T
|
|
44
|
+
? T[K]
|
|
45
|
+
: never
|
|
46
|
+
: never
|
|
47
|
+
}
|
|
48
|
+
>
|
|
32
49
|
|
|
33
50
|
export type Values<O> = O[ValueKeys<O>]
|
|
34
51
|
export type ValueKeys<O> = Extract<keyof O, PropertyKey>
|
|
@@ -40,9 +57,9 @@ export type DeepAwaited<T> = T extends Promise<infer A>
|
|
|
40
57
|
: T
|
|
41
58
|
|
|
42
59
|
export type PathParamMask<TRoutePath extends string> =
|
|
43
|
-
TRoutePath extends `${infer L}
|
|
60
|
+
TRoutePath extends `${infer L}/$${infer C}/${infer R}`
|
|
44
61
|
? PathParamMask<`${L}/${string}/${R}`>
|
|
45
|
-
: TRoutePath extends `${infer L}
|
|
62
|
+
: TRoutePath extends `${infer L}/$${infer C}`
|
|
46
63
|
? PathParamMask<`${L}/${string}`>
|
|
47
64
|
: TRoutePath
|
|
48
65
|
|
|
@@ -60,42 +77,71 @@ export type PickExclude<T, U> = {
|
|
|
60
77
|
[K in keyof T as T[K] extends U ? never : K]: T[K]
|
|
61
78
|
}
|
|
62
79
|
|
|
80
|
+
export function last<T>(arr: T[]) {
|
|
81
|
+
return arr[arr.length - 1]
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function isFunction(d: any): d is Function {
|
|
85
|
+
return typeof d === 'function'
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function functionalUpdate<TResult>(
|
|
89
|
+
updater: Updater<TResult>,
|
|
90
|
+
previous: TResult,
|
|
91
|
+
) {
|
|
92
|
+
if (isFunction(updater)) {
|
|
93
|
+
return updater(previous as TResult)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return updater
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function pick<T, K extends keyof T>(parent: T, keys: K[]): Pick<T, K> {
|
|
100
|
+
return keys.reduce((obj: any, key: K) => {
|
|
101
|
+
obj[key] = parent[key]
|
|
102
|
+
return obj
|
|
103
|
+
}, {} as any)
|
|
104
|
+
}
|
|
105
|
+
|
|
63
106
|
/**
|
|
64
107
|
* This function returns `a` if `b` is deeply equal.
|
|
65
108
|
* If not, it will replace any deeply equal children of `b` with those of `a`.
|
|
66
|
-
* This can be used for structural sharing between JSON values for example.
|
|
109
|
+
* This can be used for structural sharing between immutable JSON values for example.
|
|
110
|
+
* Do not use this with signals
|
|
67
111
|
*/
|
|
68
|
-
export function replaceEqualDeep(prev: any,
|
|
69
|
-
if (prev ===
|
|
112
|
+
export function replaceEqualDeep<T>(prev: any, _next: T): T {
|
|
113
|
+
if (prev === _next) {
|
|
70
114
|
return prev
|
|
71
115
|
}
|
|
72
116
|
|
|
117
|
+
const next = _next as any
|
|
118
|
+
|
|
73
119
|
const array = Array.isArray(prev) && Array.isArray(next)
|
|
74
120
|
|
|
75
121
|
if (array || (isPlainObject(prev) && isPlainObject(next))) {
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
const
|
|
122
|
+
const prevSize = array ? prev.length : Object.keys(prev).length
|
|
123
|
+
const nextItems = array ? next : Object.keys(next)
|
|
124
|
+
const nextSize = nextItems.length
|
|
79
125
|
const copy: any = array ? [] : {}
|
|
80
126
|
|
|
81
127
|
let equalItems = 0
|
|
82
128
|
|
|
83
|
-
for (let i = 0; i <
|
|
84
|
-
const key = array ? i :
|
|
129
|
+
for (let i = 0; i < nextSize; i++) {
|
|
130
|
+
const key = array ? i : nextItems[i]
|
|
85
131
|
copy[key] = replaceEqualDeep(prev[key], next[key])
|
|
86
132
|
if (copy[key] === prev[key]) {
|
|
87
133
|
equalItems++
|
|
88
134
|
}
|
|
89
135
|
}
|
|
90
136
|
|
|
91
|
-
return
|
|
137
|
+
return prevSize === nextSize && equalItems === prevSize ? prev : copy
|
|
92
138
|
}
|
|
93
139
|
|
|
94
140
|
return next
|
|
95
141
|
}
|
|
96
142
|
|
|
97
143
|
// Copied from: https://github.com/jonschlinkert/is-plain-object
|
|
98
|
-
function isPlainObject(o: any) {
|
|
144
|
+
export function isPlainObject(o: any) {
|
|
99
145
|
if (!hasObjectPrototype(o)) {
|
|
100
146
|
return false
|
|
101
147
|
}
|
|
@@ -125,40 +171,25 @@ function hasObjectPrototype(o: any) {
|
|
|
125
171
|
return Object.prototype.toString.call(o) === '[object Object]'
|
|
126
172
|
}
|
|
127
173
|
|
|
128
|
-
export function
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
export function warning(cond: any, message: string): cond is true {
|
|
133
|
-
if (cond) {
|
|
134
|
-
if (typeof console !== 'undefined') console.warn(message)
|
|
135
|
-
|
|
136
|
-
try {
|
|
137
|
-
throw new Error(message)
|
|
138
|
-
} catch {}
|
|
174
|
+
export function partialDeepEqual(a: any, b: any): boolean {
|
|
175
|
+
if (a === b) {
|
|
176
|
+
return true
|
|
139
177
|
}
|
|
140
178
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
function isFunction(d: any): d is Function {
|
|
145
|
-
return typeof d === 'function'
|
|
146
|
-
}
|
|
179
|
+
if (typeof a !== typeof b) {
|
|
180
|
+
return false
|
|
181
|
+
}
|
|
147
182
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
previous: TResult,
|
|
151
|
-
) {
|
|
152
|
-
if (isFunction(updater)) {
|
|
153
|
-
return updater(previous as TResult)
|
|
183
|
+
if (isPlainObject(a) && isPlainObject(b)) {
|
|
184
|
+
return !Object.keys(b).some((key) => !partialDeepEqual(a[key], b[key]))
|
|
154
185
|
}
|
|
155
186
|
|
|
156
|
-
|
|
157
|
-
|
|
187
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
188
|
+
return (
|
|
189
|
+
a.length === b.length &&
|
|
190
|
+
a.every((item, index) => partialDeepEqual(item, b[index]))
|
|
191
|
+
)
|
|
192
|
+
}
|
|
158
193
|
|
|
159
|
-
|
|
160
|
-
return keys.reduce((obj: any, key: K) => {
|
|
161
|
-
obj[key] = parent[key]
|
|
162
|
-
return obj
|
|
163
|
-
}, {} as any)
|
|
194
|
+
return false
|
|
164
195
|
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* router-core
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
function _extends() {
|
|
16
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
17
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
18
|
-
var source = arguments[i];
|
|
19
|
-
|
|
20
|
-
for (var key in source) {
|
|
21
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
22
|
-
target[key] = source[key];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return target;
|
|
28
|
-
};
|
|
29
|
-
return _extends.apply(this, arguments);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
exports["extends"] = _extends;
|
|
33
|
-
//# sourceMappingURL=_rollupPluginBabelHelpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_rollupPluginBabelHelpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* router-core
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
function _extends() {
|
|
16
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
17
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
18
|
-
var source = arguments[i];
|
|
19
|
-
|
|
20
|
-
for (var key in source) {
|
|
21
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
22
|
-
target[key] = source[key];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return target;
|
|
28
|
-
};
|
|
29
|
-
return _extends.apply(this, arguments);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
exports["default"] = _extends;
|
|
33
|
-
//# sourceMappingURL=extends.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extends.js","sources":["../../../../../../../../../node_modules/@babel/runtime/helpers/esm/extends.js"],"sourcesContent":["export default function _extends() {\n _extends = Object.assign ? Object.assign.bind() : function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n };\n return _extends.apply(this, arguments);\n}"],"names":[],"mappings":";;;;;;;;;;;;;;AAAe,SAAS,QAAQ,GAAG;AACnC,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,UAAU,MAAM,EAAE;AACtE,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC/C,MAAM,IAAI,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAChC;AACA,MAAM,KAAK,IAAI,GAAG,IAAI,MAAM,EAAE;AAC9B,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE;AAC/D,UAAU,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;AACpC,SAAS;AACT,OAAO;AACP,KAAK;AACL;AACA,IAAI,OAAO,MAAM,CAAC;AAClB,GAAG,CAAC;AACJ,EAAE,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AACzC;;;;"}
|