@tanstack/react-router 0.0.1-beta.224 → 0.0.1-beta.226
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/build/cjs/CatchBoundary.js +3 -6
- package/build/cjs/CatchBoundary.js.map +1 -1
- package/build/cjs/Matches.js +8 -15
- package/build/cjs/Matches.js.map +1 -1
- package/build/cjs/RouterProvider.js +6 -11
- package/build/cjs/RouterProvider.js.map +1 -1
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +1 -3
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/build/cjs/awaited.js +0 -2
- package/build/cjs/awaited.js.map +1 -1
- package/build/cjs/defer.js +0 -2
- package/build/cjs/defer.js.map +1 -1
- package/build/cjs/fileRoute.js +0 -2
- package/build/cjs/fileRoute.js.map +1 -1
- package/build/cjs/index.js +3 -16
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/lazyRouteComponent.js +3 -6
- package/build/cjs/lazyRouteComponent.js.map +1 -1
- package/build/cjs/link.js +4 -7
- package/build/cjs/link.js.map +1 -1
- package/build/cjs/path.js +0 -2
- package/build/cjs/path.js.map +1 -1
- package/build/cjs/qss.js +0 -2
- package/build/cjs/qss.js.map +1 -1
- package/build/cjs/redirects.js +0 -2
- package/build/cjs/redirects.js.map +1 -1
- package/build/cjs/route.js +2 -7
- package/build/cjs/route.js.map +1 -1
- package/build/cjs/router.js +13 -15
- package/build/cjs/router.js.map +1 -1
- package/build/cjs/scroll-restoration.js +3 -6
- package/build/cjs/scroll-restoration.js.map +1 -1
- package/build/cjs/searchParams.js +0 -2
- package/build/cjs/searchParams.js.map +1 -1
- package/build/cjs/useBlocker.js +3 -6
- package/build/cjs/useBlocker.js.map +1 -1
- package/build/cjs/useNavigate.js +3 -6
- package/build/cjs/useNavigate.js.map +1 -1
- package/build/cjs/useParams.js +0 -2
- package/build/cjs/useParams.js.map +1 -1
- package/build/cjs/useSearch.js +0 -2
- package/build/cjs/useSearch.js.map +1 -1
- package/build/cjs/utils.js +9 -6
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +18 -5
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +3494 -2700
- package/build/stats-react.json +290 -290
- package/build/types/CatchBoundary.d.ts +2 -2
- package/build/types/Matches.d.ts +3 -3
- package/build/types/RouterProvider.d.ts +2 -7
- package/build/types/awaited.d.ts +1 -0
- package/build/types/fileRoute.d.ts +3 -2
- package/build/types/route.d.ts +1 -1
- package/build/types/router.d.ts +7 -3
- package/build/umd/index.development.js +22 -11
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +2 -2
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/RouterProvider.tsx +6 -8
- package/src/route.ts +37 -37
- package/src/router.ts +20 -13
|
@@ -4,7 +4,7 @@ export declare function CatchBoundary(props: {
|
|
|
4
4
|
children: any;
|
|
5
5
|
errorComponent?: any;
|
|
6
6
|
onCatch: (error: any) => void;
|
|
7
|
-
}): JSX.Element;
|
|
7
|
+
}): React.JSX.Element;
|
|
8
8
|
export declare class CatchBoundaryImpl extends React.Component<{
|
|
9
9
|
resetKey: string;
|
|
10
10
|
children: (props: {
|
|
@@ -30,4 +30,4 @@ export declare class CatchBoundaryImpl extends React.Component<{
|
|
|
30
30
|
}
|
|
31
31
|
export declare function ErrorComponent({ error }: {
|
|
32
32
|
error: any;
|
|
33
|
-
}): JSX.Element;
|
|
33
|
+
}): React.JSX.Element;
|
package/build/types/Matches.d.ts
CHANGED
|
@@ -28,11 +28,11 @@ export interface RouteMatch<TRouteTree extends AnyRoute = AnyRoute, TRouteId ext
|
|
|
28
28
|
cause: 'enter' | 'stay';
|
|
29
29
|
}
|
|
30
30
|
export type AnyRouteMatch = RouteMatch<any>;
|
|
31
|
-
export declare function Matches(): JSX.Element;
|
|
31
|
+
export declare function Matches(): React.JSX.Element;
|
|
32
32
|
export declare function Match({ matches }: {
|
|
33
33
|
matches: RouteMatch[];
|
|
34
|
-
}): JSX.Element;
|
|
35
|
-
export declare function Outlet(): JSX.Element | null;
|
|
34
|
+
}): React.JSX.Element;
|
|
35
|
+
export declare function Outlet(): React.JSX.Element | null;
|
|
36
36
|
export interface MatchRouteOptions {
|
|
37
37
|
pending?: boolean;
|
|
38
38
|
caseSensitive?: boolean;
|
|
@@ -3,7 +3,7 @@ import { LinkInfo, LinkOptions, NavigateOptions, ResolveRelativePath, ToOptions
|
|
|
3
3
|
import { ParsedLocation } from './location';
|
|
4
4
|
import { AnyRoute } from './route';
|
|
5
5
|
import { RouteById, RoutePaths } from './routeInfo';
|
|
6
|
-
import { BuildNextOptions,
|
|
6
|
+
import { BuildNextOptions, RegisteredRouter, Router, RouterOptions, RouterState } from './router';
|
|
7
7
|
import { NoInfer } from './utils';
|
|
8
8
|
import { MatchRouteOptions } from './Matches';
|
|
9
9
|
import { RouteMatch } from './Matches';
|
|
@@ -21,11 +21,6 @@ export interface MatchLocation {
|
|
|
21
21
|
export type BuildLinkFn<TRouteTree extends AnyRoute> = <TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = ''>(dest: LinkOptions<TRouteTree, TFrom, TTo>) => LinkInfo;
|
|
22
22
|
export type NavigateFn<TRouteTree extends AnyRoute> = <TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> = TFrom, TMaskTo extends string = ''>(opts: NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>) => Promise<void>;
|
|
23
23
|
export type MatchRouteFn<TRouteTree extends AnyRoute> = <TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = '', TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>>(location: ToOptions<TRouteTree, TFrom, TTo>, opts?: MatchRouteOptions) => false | RouteById<TRouteTree, TResolved>['types']['allParams'];
|
|
24
|
-
export type LoadFn = (opts?: {
|
|
25
|
-
next?: ParsedLocation;
|
|
26
|
-
throwOnError?: boolean;
|
|
27
|
-
__dehydratedMatches?: DehydratedRouteMatch[];
|
|
28
|
-
}) => Promise<void>;
|
|
29
24
|
export type BuildLocationFn<TRouteTree extends AnyRoute> = (opts: BuildNextOptions) => ParsedLocation;
|
|
30
25
|
export type InjectedHtmlEntry = string | (() => Promise<string> | string);
|
|
31
26
|
export declare const routerContext: React.Context<Router<any, Record<string, any>>>;
|
|
@@ -34,7 +29,7 @@ export declare class SearchParamError extends Error {
|
|
|
34
29
|
export declare class PathParamError extends Error {
|
|
35
30
|
}
|
|
36
31
|
export declare function getInitialRouterState(location: ParsedLocation): RouterState<any>;
|
|
37
|
-
export declare function RouterProvider<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TDehydrated extends Record<string, any> = Record<string, any>>({ router, ...rest }: RouterProps<TRouteTree, TDehydrated>): JSX.Element;
|
|
32
|
+
export declare function RouterProvider<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TDehydrated extends Record<string, any> = Record<string, any>>({ router, ...rest }: RouterProps<TRouteTree, TDehydrated>): React.JSX.Element;
|
|
38
33
|
export declare function getRouteMatch<TRouteTree extends AnyRoute>(state: RouterState<TRouteTree>, id: string): undefined | RouteMatch<TRouteTree>;
|
|
39
34
|
export declare function useRouterState<TSelected = RouterState<RegisteredRouter['routeTree']>>(opts?: {
|
|
40
35
|
select: (state: RouterState<RegisteredRouter['routeTree']>) => TSelected;
|
package/build/types/awaited.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ParsePathParams } from './link';
|
|
2
|
+
import { AnyRoute, ResolveFullPath, ResolveFullSearchSchema, MergeFromFromParent, RouteContext, AnyContext, RouteOptions, UpdatableRouteOptions, Route, AnyPathParams, RootRouteId, TrimPathLeft, RouteConstraints } from './route';
|
|
2
3
|
import { Assign, Expand, IsAny } from './utils';
|
|
3
4
|
export interface FileRoutesByPath {
|
|
4
5
|
}
|
|
@@ -12,7 +13,7 @@ export type FileRoutePath<TParentRoute extends AnyRoute, TFilePath extends strin
|
|
|
12
13
|
export declare class FileRoute<TFilePath extends keyof FileRoutesByPath, TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'], TId extends RouteConstraints['TId'] = TFilePath, TPath extends RouteConstraints['TPath'] = FileRoutePath<TParentRoute, TFilePath>, TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, RemoveUnderScores<TPath>>> {
|
|
13
14
|
path: TFilePath;
|
|
14
15
|
constructor(path: TFilePath);
|
|
15
|
-
createRoute: <TSearchSchema extends import("./route").AnySearchSchema = {}, TFullSearchSchema extends import("./route").AnySearchSchema =
|
|
16
|
+
createRoute: <TSearchSchema extends import("./route").AnySearchSchema = {}, TFullSearchSchema extends import("./route").AnySearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends Record<string, any> = ParsePathParams<TPath> extends never ? AnyPathParams : Record<ParsePathParams<TPath>, string>, TAllParams extends Record<string, any> = MergeFromFromParent<TParentRoute["types"]["allParams"], TParams>, TRouteContext extends RouteContext = RouteContext, TContext extends Expand<Assign<IsAny<TParentRoute["types"]["allContext"], {}>, TRouteContext>> = Expand<Assign<IsAny<TParentRoute["types"]["allContext"], {}>, TRouteContext>>, TRouterContext extends AnyContext = AnyContext, TLoaderData extends unknown = unknown, TChildren extends unknown = unknown, TRouteTree extends AnyRoute = AnyRoute>(options?: (Omit<RouteOptions<TParentRoute, string, string, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TRouteContext, TContext, TLoaderData>, "path" | "id" | "getParentRoute"> & {
|
|
16
17
|
meta?: import("./route").RouteMeta | undefined;
|
|
17
18
|
} & {
|
|
18
19
|
caseSensitive?: boolean | undefined;
|
package/build/types/route.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export type MetaOptions = keyof PickRequired<RouteMeta> extends never ? {
|
|
|
29
29
|
} : {
|
|
30
30
|
meta: RouteMeta;
|
|
31
31
|
};
|
|
32
|
-
export type RouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TSearchSchema extends Record<string, any> = {}, TFullSearchSchema extends Record<string, any> = TSearchSchema, TParams extends AnyPathParams = AnyPathParams, TAllParams extends AnyPathParams = TParams, TRouteContext extends RouteContext = RouteContext, TAllContext extends Record<string, any> = AnyContext, TLoaderData extends any = unknown> = BaseRouteOptions<TParentRoute, TCustomId, TPath, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TRouteContext, TAllContext, TLoaderData> & NoInfer<
|
|
32
|
+
export type RouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TSearchSchema extends Record<string, any> = {}, TFullSearchSchema extends Record<string, any> = TSearchSchema, TParams extends AnyPathParams = AnyPathParams, TAllParams extends AnyPathParams = TParams, TRouteContext extends RouteContext = RouteContext, TAllContext extends Record<string, any> = AnyContext, TLoaderData extends any = unknown> = BaseRouteOptions<TParentRoute, TCustomId, TPath, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TRouteContext, TAllContext, TLoaderData> & UpdatableRouteOptions<NoInfer<TFullSearchSchema>, NoInfer<TAllParams>, NoInfer<TAllContext>, NoInfer<TLoaderData>>;
|
|
33
33
|
export type ParamsFallback<TPath extends string, TParams> = unknown extends TParams ? Record<ParsePathParams<TPath>, string> : TParams;
|
|
34
34
|
export type BaseRouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TSearchSchema extends Record<string, any> = {}, TFullSearchSchema extends Record<string, any> = TSearchSchema, TParams extends AnyPathParams = {}, TAllParams = ParamsFallback<TPath, TParams>, TRouteContext extends RouteContext = RouteContext, TAllContext extends Record<string, any> = AnyContext, TLoaderData extends any = unknown> = RoutePathOptions<TCustomId, TPath> & {
|
|
35
35
|
getParentRoute: () => TParentRoute;
|
package/build/types/router.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { AnyRouteMatch, RouteMatch } from './Matches';
|
|
|
9
9
|
import { ParsedLocation } from './location';
|
|
10
10
|
import { LocationState } from './location';
|
|
11
11
|
import { SearchSerializer, SearchParser } from './searchParams';
|
|
12
|
-
import { BuildLinkFn, BuildLocationFn, CommitLocationOptions, InjectedHtmlEntry,
|
|
12
|
+
import { BuildLinkFn, BuildLocationFn, CommitLocationOptions, InjectedHtmlEntry, MatchRouteFn, NavigateFn } from './RouterProvider';
|
|
13
13
|
declare global {
|
|
14
14
|
interface Window {
|
|
15
15
|
__TSR_DEHYDRATED__?: HydrationCtx;
|
|
@@ -152,12 +152,16 @@ export declare class Router<TRouteTree extends AnyRoute = AnyRoute, TDehydrated
|
|
|
152
152
|
commitLocation: ({ startTransition, ...next }: ParsedLocation & CommitLocationOptions) => Promise<void>;
|
|
153
153
|
buildAndCommitLocation: ({ replace, resetScroll, startTransition, ...rest }?: BuildNextOptions & CommitLocationOptions) => Promise<void>;
|
|
154
154
|
navigate: NavigateFn<TRouteTree>;
|
|
155
|
-
loadMatches: ({ checkLatest, matches, preload, }: {
|
|
155
|
+
loadMatches: ({ checkLatest, matches, preload, invalidate, }: {
|
|
156
156
|
checkLatest: () => Promise<void> | undefined;
|
|
157
157
|
matches: AnyRouteMatch[];
|
|
158
158
|
preload?: boolean | undefined;
|
|
159
|
+
invalidate?: boolean | undefined;
|
|
159
160
|
}) => Promise<RouteMatch[]>;
|
|
160
|
-
|
|
161
|
+
invalidate: () => Promise<void>;
|
|
162
|
+
load: (opts?: {
|
|
163
|
+
invalidate?: boolean;
|
|
164
|
+
}) => Promise<void>;
|
|
161
165
|
preloadRoute: (navigateOpts?: BuildNextOptions) => Promise<readonly [RouteMatch<AnyRoute, any>, RouteMatch<AnyRoute, any>[]]>;
|
|
162
166
|
buildLink: BuildLinkFn<TRouteTree>;
|
|
163
167
|
matchRoute: MatchRouteFn<TRouteTree>;
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactRouter = {}, global.React));
|
|
15
15
|
})(this, (function (exports, React) { 'use strict';
|
|
16
16
|
|
|
17
|
-
function
|
|
18
|
-
if (e && e.__esModule) return e;
|
|
17
|
+
function _interopNamespaceDefault(e) {
|
|
19
18
|
var n = Object.create(null);
|
|
20
19
|
if (e) {
|
|
21
20
|
Object.keys(e).forEach(function (k) {
|
|
@@ -28,11 +27,11 @@
|
|
|
28
27
|
}
|
|
29
28
|
});
|
|
30
29
|
}
|
|
31
|
-
n
|
|
30
|
+
n.default = e;
|
|
32
31
|
return Object.freeze(n);
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
var React__namespace = /*#__PURE__*/
|
|
34
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
36
35
|
|
|
37
36
|
/**
|
|
38
37
|
* @tanstack/history/src/index.ts
|
|
@@ -170,6 +169,7 @@
|
|
|
170
169
|
* @returns A history instance
|
|
171
170
|
*/
|
|
172
171
|
function createBrowserHistory(opts) {
|
|
172
|
+
console.log('hello');
|
|
173
173
|
const getHref = opts?.getHref ?? (() => `${window.location.pathname}${window.location.search}${window.location.hash}`);
|
|
174
174
|
const createHref = opts?.createHref ?? (path => path);
|
|
175
175
|
let currentLocation = parseLocation(getHref(), window.history.state);
|
|
@@ -446,6 +446,7 @@
|
|
|
446
446
|
// : never
|
|
447
447
|
// }
|
|
448
448
|
// >
|
|
449
|
+
|
|
449
450
|
// // Sample types to merge
|
|
450
451
|
// type TypeA = {
|
|
451
452
|
// shared: string
|
|
@@ -456,6 +457,7 @@
|
|
|
456
457
|
// }
|
|
457
458
|
// array: string[]
|
|
458
459
|
// }
|
|
460
|
+
|
|
459
461
|
// type TypeB = {
|
|
460
462
|
// shared: number
|
|
461
463
|
// onlyInB: number
|
|
@@ -465,6 +467,7 @@
|
|
|
465
467
|
// }
|
|
466
468
|
// array: number[]
|
|
467
469
|
// }
|
|
470
|
+
|
|
468
471
|
// type TypeC = {
|
|
469
472
|
// shared: boolean
|
|
470
473
|
// onlyInC: boolean
|
|
@@ -474,9 +477,12 @@
|
|
|
474
477
|
// }
|
|
475
478
|
// array: boolean[]
|
|
476
479
|
// }
|
|
480
|
+
|
|
477
481
|
// type Test = Expand<Assign<TypeA, TypeB>>
|
|
482
|
+
|
|
478
483
|
// // Using DeepMerge to merge TypeA and TypeB
|
|
479
484
|
// type MergedType = Expand<AssignAll<[TypeA, TypeB, TypeC]>>
|
|
485
|
+
|
|
480
486
|
//
|
|
481
487
|
|
|
482
488
|
const isServer = typeof document === 'undefined';
|
|
@@ -832,6 +838,7 @@
|
|
|
832
838
|
this.options = options || {};
|
|
833
839
|
this.isRoot = !options?.getParentRoute;
|
|
834
840
|
Route.__onInit(this);
|
|
841
|
+
this.$$typeof = Symbol.for('react.memo');
|
|
835
842
|
}
|
|
836
843
|
init = opts => {
|
|
837
844
|
this.originalIndex = opts.originalIndex;
|
|
@@ -1130,6 +1137,7 @@
|
|
|
1130
1137
|
// ) => () => void
|
|
1131
1138
|
// hydrateData: <T>(key: any) => T | undefined
|
|
1132
1139
|
// }
|
|
1140
|
+
|
|
1133
1141
|
const routerContext = /*#__PURE__*/React__namespace.createContext(null);
|
|
1134
1142
|
if (typeof document !== 'undefined') {
|
|
1135
1143
|
window.__TSR_ROUTER_CONTEXT__ = routerContext;
|
|
@@ -1198,7 +1206,7 @@
|
|
|
1198
1206
|
return () => {
|
|
1199
1207
|
unsub();
|
|
1200
1208
|
};
|
|
1201
|
-
}, [history]);
|
|
1209
|
+
}, [router.history]);
|
|
1202
1210
|
React__namespace.useLayoutEffect(() => {
|
|
1203
1211
|
if (!isTransitioning && state.resolvedLocation !== state.location) {
|
|
1204
1212
|
router.emit({
|
|
@@ -2075,7 +2083,8 @@
|
|
|
2075
2083
|
loadMatches = async ({
|
|
2076
2084
|
checkLatest,
|
|
2077
2085
|
matches,
|
|
2078
|
-
preload
|
|
2086
|
+
preload,
|
|
2087
|
+
invalidate
|
|
2079
2088
|
}) => {
|
|
2080
2089
|
let latestPromise;
|
|
2081
2090
|
let firstBadMatchIndex;
|
|
@@ -2191,7 +2200,7 @@
|
|
|
2191
2200
|
// Default to reloading the route all the time
|
|
2192
2201
|
let shouldReload = true;
|
|
2193
2202
|
let shouldReloadDeps = typeof route.options.shouldReload === 'function' ? route.options.shouldReload?.(loaderContext) : !!(route.options.shouldReload ?? true);
|
|
2194
|
-
if (match.cause === 'enter') {
|
|
2203
|
+
if (match.cause === 'enter' || invalidate) {
|
|
2195
2204
|
match.shouldReloadDeps = shouldReloadDeps;
|
|
2196
2205
|
} else if (match.cause === 'stay') {
|
|
2197
2206
|
if (typeof shouldReloadDeps === 'object') {
|
|
@@ -2274,7 +2283,10 @@
|
|
|
2274
2283
|
await Promise.all(matchPromises);
|
|
2275
2284
|
return matches;
|
|
2276
2285
|
};
|
|
2277
|
-
|
|
2286
|
+
invalidate = () => this.load({
|
|
2287
|
+
invalidate: true
|
|
2288
|
+
});
|
|
2289
|
+
load = async opts => {
|
|
2278
2290
|
const promise = new Promise(async (resolve, reject) => {
|
|
2279
2291
|
const next = this.latestLocation;
|
|
2280
2292
|
const prevLocation = this.state.resolvedLocation;
|
|
@@ -2309,7 +2321,8 @@
|
|
|
2309
2321
|
// Load the matches
|
|
2310
2322
|
await this.loadMatches({
|
|
2311
2323
|
matches,
|
|
2312
|
-
checkLatest: () => this.checkLatest(promise)
|
|
2324
|
+
checkLatest: () => this.checkLatest(promise),
|
|
2325
|
+
invalidate: opts?.invalidate
|
|
2313
2326
|
});
|
|
2314
2327
|
} catch (err) {
|
|
2315
2328
|
// swallow this error, since we'll display the
|
|
@@ -2887,7 +2900,5 @@
|
|
|
2887
2900
|
exports.useStableCallback = useStableCallback;
|
|
2888
2901
|
exports.warning = warning;
|
|
2889
2902
|
|
|
2890
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2891
|
-
|
|
2892
2903
|
}));
|
|
2893
2904
|
//# sourceMappingURL=index.development.js.map
|