@benjavicente/angular-router-experimental 1.142.11
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/README.md +15 -0
- package/dist/fesm2022/tanstack-angular-router-experimental-experimental.mjs +920 -0
- package/dist/fesm2022/tanstack-angular-router-experimental.mjs +4131 -0
- package/dist/types/tanstack-angular-router-experimental-experimental.d.ts +110 -0
- package/dist/types/tanstack-angular-router-experimental.d.ts +733 -0
- package/experimental/injectRouteErrorHandler.ts +51 -0
- package/experimental/public_api.ts +8 -0
- package/package.json +98 -0
- package/src/DefaultNotFound.ts +9 -0
- package/src/Link.ts +352 -0
- package/src/Match.ts +338 -0
- package/src/Matches.ts +37 -0
- package/src/RouterProvider.ts +162 -0
- package/src/document/build-match-managed-document.ts +308 -0
- package/src/document/document-dehydration.ts +27 -0
- package/src/document/document-equality.ts +29 -0
- package/src/document/document-router-token.ts +6 -0
- package/src/document/index.ts +33 -0
- package/src/document/install-unified-document-sync.ts +108 -0
- package/src/document/managed-document-types.ts +36 -0
- package/src/document/managed-dom.ts +307 -0
- package/src/document/provide-tanstack-body-managed-tags.ts +78 -0
- package/src/document/provide-tanstack-document-title.ts +59 -0
- package/src/document/provide-tanstack-document.ts +62 -0
- package/src/document/provide-tanstack-head-managed-tags.ts +63 -0
- package/src/fileRoute.ts +232 -0
- package/src/index.ts +173 -0
- package/src/injectBlocker.ts +196 -0
- package/src/injectCanGoBack.ts +11 -0
- package/src/injectErrorState.ts +21 -0
- package/src/injectIntersectionObserver.ts +28 -0
- package/src/injectLoaderData.ts +49 -0
- package/src/injectLoaderDeps.ts +45 -0
- package/src/injectLocation.ts +38 -0
- package/src/injectMatch.ts +122 -0
- package/src/injectMatchRoute.ts +58 -0
- package/src/injectMatches.ts +79 -0
- package/src/injectNavigate.ts +24 -0
- package/src/injectParams.ts +71 -0
- package/src/injectRouteContext.ts +31 -0
- package/src/injectRouter.ts +17 -0
- package/src/injectRouterState.ts +53 -0
- package/src/injectSearch.ts +71 -0
- package/src/injectStore.ts +87 -0
- package/src/matchInjectorToken.ts +23 -0
- package/src/renderer/injectIsCatchingError.ts +40 -0
- package/src/renderer/injectRender.ts +69 -0
- package/src/route.ts +641 -0
- package/src/router.ts +141 -0
- package/src/routerInjectionToken.ts +24 -0
- package/src/routerStores.ts +107 -0
- package/src/ssr-scroll-restoration.ts +48 -0
- package/src/transitioner.ts +255 -0
package/src/route.ts
ADDED
|
@@ -0,0 +1,641 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BaseRootRoute,
|
|
3
|
+
BaseRoute,
|
|
4
|
+
BaseRouteApi,
|
|
5
|
+
notFound,
|
|
6
|
+
} from '@benjavicente/router-core'
|
|
7
|
+
import { injectLoaderData } from './injectLoaderData'
|
|
8
|
+
import { injectLoaderDeps } from './injectLoaderDeps'
|
|
9
|
+
import { injectMatch } from './injectMatch'
|
|
10
|
+
import { injectNavigate } from './injectNavigate'
|
|
11
|
+
import { injectParams } from './injectParams'
|
|
12
|
+
import { injectRouteContext } from './injectRouteContext'
|
|
13
|
+
import { injectRouter } from './injectRouter'
|
|
14
|
+
import { injectSearch } from './injectSearch'
|
|
15
|
+
import type { InjectParamsRoute } from './injectParams'
|
|
16
|
+
import type { InjectRouteContextRoute } from './injectRouteContext'
|
|
17
|
+
import type { InjectMatchRoute } from './injectMatch'
|
|
18
|
+
import type { InjectLoaderDepsRoute } from './injectLoaderDeps'
|
|
19
|
+
import type { InjectLoaderDataRoute } from './injectLoaderData'
|
|
20
|
+
import type * as Angular from '@angular/core'
|
|
21
|
+
import type {
|
|
22
|
+
AnyContext,
|
|
23
|
+
AnyRoute,
|
|
24
|
+
AnyRouter,
|
|
25
|
+
ConstrainLiteral,
|
|
26
|
+
NotFoundError,
|
|
27
|
+
Register,
|
|
28
|
+
RegisteredRouter,
|
|
29
|
+
ResolveFullPath,
|
|
30
|
+
ResolveId,
|
|
31
|
+
ResolveParams,
|
|
32
|
+
RootRoute as RootRouteCore,
|
|
33
|
+
RootRouteId,
|
|
34
|
+
RootRouteOptions,
|
|
35
|
+
RouteConstraints,
|
|
36
|
+
Route as RouteCore,
|
|
37
|
+
RouteIds,
|
|
38
|
+
RouteMask,
|
|
39
|
+
RouteOptions,
|
|
40
|
+
RouteTypesById,
|
|
41
|
+
RouterCore,
|
|
42
|
+
ToMaskOptions,
|
|
43
|
+
UseNavigateResult,
|
|
44
|
+
} from '@benjavicente/router-core'
|
|
45
|
+
import type { InjectSearchRoute } from './injectSearch'
|
|
46
|
+
|
|
47
|
+
declare module '@benjavicente/router-core' {
|
|
48
|
+
export interface UpdatableRouteOptionsExtensions {
|
|
49
|
+
component?: RouteComponent
|
|
50
|
+
errorComponent?: false | null | undefined | ErrorRouteComponent
|
|
51
|
+
notFoundComponent?: NotFoundRouteComponent
|
|
52
|
+
pendingComponent?: RouteComponent
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface RootRouteOptionsExtensions {
|
|
56
|
+
shellComponent?: Angular.Type<{
|
|
57
|
+
children: any
|
|
58
|
+
}>
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface RouteExtensions<
|
|
62
|
+
in out TId extends string,
|
|
63
|
+
in out TFullPath extends string,
|
|
64
|
+
> {
|
|
65
|
+
injectMatch: InjectMatchRoute<TId>
|
|
66
|
+
injectRouteContext: InjectRouteContextRoute<TId>
|
|
67
|
+
injectSearch: InjectSearchRoute<TId>
|
|
68
|
+
injectParams: InjectParamsRoute<TId>
|
|
69
|
+
injectLoaderDeps: InjectLoaderDepsRoute<TId>
|
|
70
|
+
injectLoaderData: InjectLoaderDataRoute<TId>
|
|
71
|
+
injectNavigate: () => UseNavigateResult<TFullPath>
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function getRouteApi<
|
|
76
|
+
const TId,
|
|
77
|
+
TRouter extends AnyRouter = RegisteredRouter,
|
|
78
|
+
>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>) {
|
|
79
|
+
return new RouteApi<TId, TRouter>({ id })
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export class RouteApi<
|
|
83
|
+
TId,
|
|
84
|
+
TRouter extends AnyRouter = RegisteredRouter,
|
|
85
|
+
> extends BaseRouteApi<TId, TRouter> {
|
|
86
|
+
/**
|
|
87
|
+
* @deprecated Use the `getRouteApi` function instead.
|
|
88
|
+
*/
|
|
89
|
+
constructor({ id }: { id: TId }) {
|
|
90
|
+
super({ id })
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
injectMatch: InjectMatchRoute<TId> = (opts) => {
|
|
94
|
+
return injectMatch({
|
|
95
|
+
select: opts?.select,
|
|
96
|
+
from: this.id,
|
|
97
|
+
} as any) as any
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
injectRouteContext: InjectRouteContextRoute<TId> = (opts) => {
|
|
101
|
+
return injectRouteContext({ ...(opts as any), from: this.id as any }) as any
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
injectSearch: InjectSearchRoute<TId> = (opts) => {
|
|
105
|
+
return injectSearch({
|
|
106
|
+
select: opts?.select,
|
|
107
|
+
from: this.id,
|
|
108
|
+
} as any) as any
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
injectParams: InjectParamsRoute<TId> = (opts) => {
|
|
112
|
+
return injectParams({
|
|
113
|
+
select: opts?.select,
|
|
114
|
+
from: this.id,
|
|
115
|
+
} as any) as any
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
injectLoaderDeps: InjectLoaderDepsRoute<TId> = (opts) => {
|
|
119
|
+
return injectLoaderDeps({ ...opts, from: this.id, strict: false } as any)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
injectLoaderData: InjectLoaderDataRoute<TId> = (opts) => {
|
|
123
|
+
return injectLoaderData({ ...opts, from: this.id, strict: false } as any)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
injectNavigate = (): UseNavigateResult<
|
|
127
|
+
RouteTypesById<TRouter, TId>['fullPath']
|
|
128
|
+
> => {
|
|
129
|
+
const router = injectRouter()
|
|
130
|
+
return injectNavigate({
|
|
131
|
+
from: router.routesById[this.id as string].fullPath,
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
notFound = (opts?: NotFoundError) => {
|
|
136
|
+
return notFound({ routeId: this.id as string, ...opts })
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export class Route<
|
|
141
|
+
in out TRegister = unknown,
|
|
142
|
+
in out TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,
|
|
143
|
+
in out TPath extends RouteConstraints['TPath'] = '/',
|
|
144
|
+
in out TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<
|
|
145
|
+
TParentRoute,
|
|
146
|
+
TPath
|
|
147
|
+
>,
|
|
148
|
+
in out TCustomId extends RouteConstraints['TCustomId'] = string,
|
|
149
|
+
in out TId extends RouteConstraints['TId'] = ResolveId<
|
|
150
|
+
TParentRoute,
|
|
151
|
+
TCustomId,
|
|
152
|
+
TPath
|
|
153
|
+
>,
|
|
154
|
+
in out TSearchValidator = undefined,
|
|
155
|
+
in out TParams = ResolveParams<TPath>,
|
|
156
|
+
in out TRouterContext = AnyContext,
|
|
157
|
+
in out TRouteContextFn = AnyContext,
|
|
158
|
+
in out TBeforeLoadFn = AnyContext,
|
|
159
|
+
in out TLoaderDeps extends Record<string, any> = {},
|
|
160
|
+
in out TLoaderFn = undefined,
|
|
161
|
+
in out TChildren = unknown,
|
|
162
|
+
in out TFileRouteTypes = unknown,
|
|
163
|
+
in out TSSR = unknown,
|
|
164
|
+
in out TMiddlewares = unknown,
|
|
165
|
+
in out THandlers = undefined,
|
|
166
|
+
>
|
|
167
|
+
extends BaseRoute<
|
|
168
|
+
TRegister,
|
|
169
|
+
TParentRoute,
|
|
170
|
+
TPath,
|
|
171
|
+
TFullPath,
|
|
172
|
+
TCustomId,
|
|
173
|
+
TId,
|
|
174
|
+
TSearchValidator,
|
|
175
|
+
TParams,
|
|
176
|
+
TRouterContext,
|
|
177
|
+
TRouteContextFn,
|
|
178
|
+
TBeforeLoadFn,
|
|
179
|
+
TLoaderDeps,
|
|
180
|
+
TLoaderFn,
|
|
181
|
+
TChildren,
|
|
182
|
+
TFileRouteTypes,
|
|
183
|
+
TSSR,
|
|
184
|
+
TMiddlewares,
|
|
185
|
+
THandlers
|
|
186
|
+
>
|
|
187
|
+
implements
|
|
188
|
+
RouteCore<
|
|
189
|
+
TRegister,
|
|
190
|
+
TParentRoute,
|
|
191
|
+
TPath,
|
|
192
|
+
TFullPath,
|
|
193
|
+
TCustomId,
|
|
194
|
+
TId,
|
|
195
|
+
TSearchValidator,
|
|
196
|
+
TParams,
|
|
197
|
+
TRouterContext,
|
|
198
|
+
TRouteContextFn,
|
|
199
|
+
TBeforeLoadFn,
|
|
200
|
+
TLoaderDeps,
|
|
201
|
+
TLoaderFn,
|
|
202
|
+
TChildren,
|
|
203
|
+
TFileRouteTypes,
|
|
204
|
+
TSSR,
|
|
205
|
+
TMiddlewares,
|
|
206
|
+
THandlers
|
|
207
|
+
>
|
|
208
|
+
{
|
|
209
|
+
/**
|
|
210
|
+
* @deprecated Use the `createRoute` function instead.
|
|
211
|
+
*/
|
|
212
|
+
constructor(
|
|
213
|
+
options?: RouteOptions<
|
|
214
|
+
TRegister,
|
|
215
|
+
TParentRoute,
|
|
216
|
+
TId,
|
|
217
|
+
TCustomId,
|
|
218
|
+
TFullPath,
|
|
219
|
+
TPath,
|
|
220
|
+
TSearchValidator,
|
|
221
|
+
TParams,
|
|
222
|
+
TLoaderDeps,
|
|
223
|
+
TLoaderFn,
|
|
224
|
+
TRouterContext,
|
|
225
|
+
TRouteContextFn,
|
|
226
|
+
TBeforeLoadFn,
|
|
227
|
+
TSSR,
|
|
228
|
+
TMiddlewares,
|
|
229
|
+
THandlers
|
|
230
|
+
>,
|
|
231
|
+
) {
|
|
232
|
+
super(options)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
injectMatch: InjectMatchRoute<TId> = (opts?: any) => {
|
|
236
|
+
return injectMatch({
|
|
237
|
+
select: opts?.select,
|
|
238
|
+
from: this.id,
|
|
239
|
+
} as any) as any
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
injectRouteContext: InjectRouteContextRoute<TId> = (opts?: any) => {
|
|
243
|
+
return injectMatch({
|
|
244
|
+
...opts,
|
|
245
|
+
from: this.id,
|
|
246
|
+
select: (d) => (opts?.select ? opts.select(d.context) : d.context),
|
|
247
|
+
}) as any
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
injectSearch: InjectSearchRoute<TId> = (opts) => {
|
|
251
|
+
return injectSearch({
|
|
252
|
+
select: opts?.select,
|
|
253
|
+
from: this.id,
|
|
254
|
+
} as any) as any
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
injectParams: InjectParamsRoute<TId> = (opts) => {
|
|
258
|
+
return injectParams({
|
|
259
|
+
select: opts?.select,
|
|
260
|
+
from: this.id,
|
|
261
|
+
} as any) as any
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
injectLoaderDeps: InjectLoaderDepsRoute<TId> = (opts) => {
|
|
265
|
+
return injectLoaderDeps({ ...opts, from: this.id } as any)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
injectLoaderData: InjectLoaderDataRoute<TId> = (opts) => {
|
|
269
|
+
return injectLoaderData({ ...opts, from: this.id } as any)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
injectNavigate = (): UseNavigateResult<TFullPath> => {
|
|
273
|
+
return injectNavigate({ from: this.fullPath })
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export function createRoute<
|
|
278
|
+
TRegister = unknown,
|
|
279
|
+
TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,
|
|
280
|
+
TPath extends RouteConstraints['TPath'] = '/',
|
|
281
|
+
TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<
|
|
282
|
+
TParentRoute,
|
|
283
|
+
TPath
|
|
284
|
+
>,
|
|
285
|
+
TCustomId extends RouteConstraints['TCustomId'] = string,
|
|
286
|
+
TId extends RouteConstraints['TId'] = ResolveId<
|
|
287
|
+
TParentRoute,
|
|
288
|
+
TCustomId,
|
|
289
|
+
TPath
|
|
290
|
+
>,
|
|
291
|
+
TSearchValidator = undefined,
|
|
292
|
+
TParams = ResolveParams<TPath>,
|
|
293
|
+
TRouteContextFn = AnyContext,
|
|
294
|
+
TBeforeLoadFn = AnyContext,
|
|
295
|
+
TLoaderDeps extends Record<string, any> = {},
|
|
296
|
+
TLoaderFn = undefined,
|
|
297
|
+
TChildren = unknown,
|
|
298
|
+
TSSR = unknown,
|
|
299
|
+
THandlers = undefined,
|
|
300
|
+
>(
|
|
301
|
+
options: RouteOptions<
|
|
302
|
+
TRegister,
|
|
303
|
+
TParentRoute,
|
|
304
|
+
TId,
|
|
305
|
+
TCustomId,
|
|
306
|
+
TFullPath,
|
|
307
|
+
TPath,
|
|
308
|
+
TSearchValidator,
|
|
309
|
+
TParams,
|
|
310
|
+
TLoaderDeps,
|
|
311
|
+
TLoaderFn,
|
|
312
|
+
AnyContext,
|
|
313
|
+
TRouteContextFn,
|
|
314
|
+
TBeforeLoadFn,
|
|
315
|
+
TSSR,
|
|
316
|
+
THandlers
|
|
317
|
+
>,
|
|
318
|
+
): Route<
|
|
319
|
+
TRegister,
|
|
320
|
+
TParentRoute,
|
|
321
|
+
TPath,
|
|
322
|
+
TFullPath,
|
|
323
|
+
TCustomId,
|
|
324
|
+
TId,
|
|
325
|
+
TSearchValidator,
|
|
326
|
+
TParams,
|
|
327
|
+
AnyContext,
|
|
328
|
+
TRouteContextFn,
|
|
329
|
+
TBeforeLoadFn,
|
|
330
|
+
TLoaderDeps,
|
|
331
|
+
TLoaderFn,
|
|
332
|
+
TChildren,
|
|
333
|
+
unknown,
|
|
334
|
+
TSSR,
|
|
335
|
+
THandlers
|
|
336
|
+
> {
|
|
337
|
+
return new Route<
|
|
338
|
+
TRegister,
|
|
339
|
+
TParentRoute,
|
|
340
|
+
TPath,
|
|
341
|
+
TFullPath,
|
|
342
|
+
TCustomId,
|
|
343
|
+
TId,
|
|
344
|
+
TSearchValidator,
|
|
345
|
+
TParams,
|
|
346
|
+
AnyContext,
|
|
347
|
+
TRouteContextFn,
|
|
348
|
+
TBeforeLoadFn,
|
|
349
|
+
TLoaderDeps,
|
|
350
|
+
TLoaderFn,
|
|
351
|
+
TChildren,
|
|
352
|
+
unknown,
|
|
353
|
+
TSSR,
|
|
354
|
+
THandlers
|
|
355
|
+
>(options)
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
export type AnyRootRoute = RootRoute<
|
|
359
|
+
any,
|
|
360
|
+
any,
|
|
361
|
+
any,
|
|
362
|
+
any,
|
|
363
|
+
any,
|
|
364
|
+
any,
|
|
365
|
+
any,
|
|
366
|
+
any,
|
|
367
|
+
any,
|
|
368
|
+
any
|
|
369
|
+
>
|
|
370
|
+
|
|
371
|
+
export function createRootRouteWithContext<TRouterContext extends {}>() {
|
|
372
|
+
return <
|
|
373
|
+
TRegister = Register,
|
|
374
|
+
TRouteContextFn = AnyContext,
|
|
375
|
+
TBeforeLoadFn = AnyContext,
|
|
376
|
+
TSearchValidator = undefined,
|
|
377
|
+
TLoaderDeps extends Record<string, any> = {},
|
|
378
|
+
TLoaderFn = undefined,
|
|
379
|
+
TSSR = unknown,
|
|
380
|
+
THandlers = undefined,
|
|
381
|
+
>(
|
|
382
|
+
options?: RootRouteOptions<
|
|
383
|
+
TRegister,
|
|
384
|
+
TSearchValidator,
|
|
385
|
+
TRouterContext,
|
|
386
|
+
TRouteContextFn,
|
|
387
|
+
TBeforeLoadFn,
|
|
388
|
+
TLoaderDeps,
|
|
389
|
+
TLoaderFn,
|
|
390
|
+
TSSR,
|
|
391
|
+
THandlers
|
|
392
|
+
>,
|
|
393
|
+
) => {
|
|
394
|
+
return createRootRoute<
|
|
395
|
+
TRegister,
|
|
396
|
+
TSearchValidator,
|
|
397
|
+
TRouterContext,
|
|
398
|
+
TRouteContextFn,
|
|
399
|
+
TBeforeLoadFn,
|
|
400
|
+
TLoaderDeps,
|
|
401
|
+
TLoaderFn,
|
|
402
|
+
TSSR,
|
|
403
|
+
THandlers
|
|
404
|
+
>(options as any)
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export class RootRoute<
|
|
409
|
+
in out TRegister = Register,
|
|
410
|
+
in out TSearchValidator = undefined,
|
|
411
|
+
in out TRouterContext = {},
|
|
412
|
+
in out TRouteContextFn = AnyContext,
|
|
413
|
+
in out TBeforeLoadFn = AnyContext,
|
|
414
|
+
in out TLoaderDeps extends Record<string, any> = {},
|
|
415
|
+
in out TLoaderFn = undefined,
|
|
416
|
+
in out TChildren = unknown,
|
|
417
|
+
in out TFileRouteTypes = unknown,
|
|
418
|
+
in out TSSR = unknown,
|
|
419
|
+
in out THandlers = undefined,
|
|
420
|
+
>
|
|
421
|
+
extends BaseRootRoute<
|
|
422
|
+
TRegister,
|
|
423
|
+
TSearchValidator,
|
|
424
|
+
TRouterContext,
|
|
425
|
+
TRouteContextFn,
|
|
426
|
+
TBeforeLoadFn,
|
|
427
|
+
TLoaderDeps,
|
|
428
|
+
TLoaderFn,
|
|
429
|
+
TChildren,
|
|
430
|
+
TFileRouteTypes,
|
|
431
|
+
TSSR,
|
|
432
|
+
THandlers
|
|
433
|
+
>
|
|
434
|
+
implements
|
|
435
|
+
RootRouteCore<
|
|
436
|
+
TRegister,
|
|
437
|
+
TSearchValidator,
|
|
438
|
+
TRouterContext,
|
|
439
|
+
TRouteContextFn,
|
|
440
|
+
TBeforeLoadFn,
|
|
441
|
+
TLoaderDeps,
|
|
442
|
+
TLoaderFn,
|
|
443
|
+
TChildren,
|
|
444
|
+
TFileRouteTypes,
|
|
445
|
+
TSSR,
|
|
446
|
+
THandlers
|
|
447
|
+
>
|
|
448
|
+
{
|
|
449
|
+
/**
|
|
450
|
+
* @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
|
|
451
|
+
*/
|
|
452
|
+
constructor(
|
|
453
|
+
options?: RootRouteOptions<
|
|
454
|
+
TRegister,
|
|
455
|
+
TSearchValidator,
|
|
456
|
+
TRouterContext,
|
|
457
|
+
TRouteContextFn,
|
|
458
|
+
TBeforeLoadFn,
|
|
459
|
+
TLoaderDeps,
|
|
460
|
+
TLoaderFn,
|
|
461
|
+
TSSR,
|
|
462
|
+
THandlers
|
|
463
|
+
>,
|
|
464
|
+
) {
|
|
465
|
+
super(options)
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
injectMatch: InjectMatchRoute<RootRouteId> = (opts?: any) => {
|
|
469
|
+
return injectMatch({
|
|
470
|
+
select: opts?.select,
|
|
471
|
+
from: this.id,
|
|
472
|
+
} as any) as any
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
injectRouteContext: InjectRouteContextRoute<RootRouteId> = (opts) => {
|
|
476
|
+
return injectMatch({
|
|
477
|
+
...opts,
|
|
478
|
+
from: this.id,
|
|
479
|
+
select: (d) => (opts?.select ? opts.select(d.context) : d.context),
|
|
480
|
+
}) as any
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
injectSearch: InjectSearchRoute<RootRouteId> = (opts) => {
|
|
484
|
+
return injectSearch({
|
|
485
|
+
select: opts?.select,
|
|
486
|
+
from: this.id,
|
|
487
|
+
} as any) as any
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
injectParams: InjectParamsRoute<RootRouteId> = (opts) => {
|
|
491
|
+
return injectParams({
|
|
492
|
+
select: opts?.select,
|
|
493
|
+
from: this.id,
|
|
494
|
+
} as any) as any
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
injectLoaderDeps: InjectLoaderDepsRoute<RootRouteId> = (opts) => {
|
|
498
|
+
return injectLoaderDeps({ ...opts, from: this.id } as any)
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
injectLoaderData: InjectLoaderDataRoute<RootRouteId> = (opts) => {
|
|
502
|
+
return injectLoaderData({ ...opts, from: this.id } as any)
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
injectNavigate = (): UseNavigateResult<'/'> => {
|
|
506
|
+
return injectNavigate({ from: this.fullPath })
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
export function createRouteMask<
|
|
511
|
+
TRouteTree extends AnyRoute,
|
|
512
|
+
TFrom extends string,
|
|
513
|
+
TTo extends string,
|
|
514
|
+
>(
|
|
515
|
+
opts: {
|
|
516
|
+
routeTree: TRouteTree
|
|
517
|
+
} & ToMaskOptions<RouterCore<TRouteTree, 'never', false>, TFrom, TTo>,
|
|
518
|
+
): RouteMask<TRouteTree> {
|
|
519
|
+
return opts as any
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// Use a function becasue class definitions are not hoisted
|
|
523
|
+
|
|
524
|
+
export type RouteComponent<TComponent = unknown> =
|
|
525
|
+
() => Angular.Type<TComponent>
|
|
526
|
+
export type ErrorRouteComponent = () => Angular.Type<unknown>
|
|
527
|
+
export type NotFoundRouteComponent = () => Angular.Type<unknown>
|
|
528
|
+
|
|
529
|
+
export class NotFoundRoute<
|
|
530
|
+
TRegister,
|
|
531
|
+
TParentRoute extends AnyRootRoute,
|
|
532
|
+
TRouterContext = AnyContext,
|
|
533
|
+
TRouteContextFn = AnyContext,
|
|
534
|
+
TBeforeLoadFn = AnyContext,
|
|
535
|
+
TSearchValidator = undefined,
|
|
536
|
+
TLoaderDeps extends Record<string, any> = {},
|
|
537
|
+
TLoaderFn = undefined,
|
|
538
|
+
TChildren = unknown,
|
|
539
|
+
TSSR = unknown,
|
|
540
|
+
THandlers = undefined,
|
|
541
|
+
> extends Route<
|
|
542
|
+
TRegister,
|
|
543
|
+
TParentRoute,
|
|
544
|
+
'/404',
|
|
545
|
+
'/404',
|
|
546
|
+
'404',
|
|
547
|
+
'404',
|
|
548
|
+
TSearchValidator,
|
|
549
|
+
{},
|
|
550
|
+
TRouterContext,
|
|
551
|
+
TRouteContextFn,
|
|
552
|
+
TBeforeLoadFn,
|
|
553
|
+
TLoaderDeps,
|
|
554
|
+
TLoaderFn,
|
|
555
|
+
TChildren,
|
|
556
|
+
TSSR,
|
|
557
|
+
THandlers
|
|
558
|
+
> {
|
|
559
|
+
constructor(
|
|
560
|
+
options: Omit<
|
|
561
|
+
RouteOptions<
|
|
562
|
+
TRegister,
|
|
563
|
+
TParentRoute,
|
|
564
|
+
string,
|
|
565
|
+
string,
|
|
566
|
+
string,
|
|
567
|
+
string,
|
|
568
|
+
TSearchValidator,
|
|
569
|
+
{},
|
|
570
|
+
TLoaderDeps,
|
|
571
|
+
TLoaderFn,
|
|
572
|
+
TRouterContext,
|
|
573
|
+
TRouteContextFn,
|
|
574
|
+
TBeforeLoadFn,
|
|
575
|
+
TSSR,
|
|
576
|
+
THandlers
|
|
577
|
+
>,
|
|
578
|
+
| 'caseSensitive'
|
|
579
|
+
| 'parseParams'
|
|
580
|
+
| 'stringifyParams'
|
|
581
|
+
| 'path'
|
|
582
|
+
| 'id'
|
|
583
|
+
| 'params'
|
|
584
|
+
>,
|
|
585
|
+
) {
|
|
586
|
+
super({
|
|
587
|
+
...(options as any),
|
|
588
|
+
id: '404',
|
|
589
|
+
})
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
export function createRootRoute<
|
|
594
|
+
TRegister = Register,
|
|
595
|
+
TSearchValidator = undefined,
|
|
596
|
+
TRouterContext = {},
|
|
597
|
+
TRouteContextFn = AnyContext,
|
|
598
|
+
TBeforeLoadFn = AnyContext,
|
|
599
|
+
TLoaderDeps extends Record<string, any> = {},
|
|
600
|
+
TLoaderFn = undefined,
|
|
601
|
+
TSSR = unknown,
|
|
602
|
+
THandlers = undefined,
|
|
603
|
+
>(
|
|
604
|
+
options?: RootRouteOptions<
|
|
605
|
+
TRegister,
|
|
606
|
+
TSearchValidator,
|
|
607
|
+
TRouterContext,
|
|
608
|
+
TRouteContextFn,
|
|
609
|
+
TBeforeLoadFn,
|
|
610
|
+
TLoaderDeps,
|
|
611
|
+
TLoaderFn,
|
|
612
|
+
TSSR,
|
|
613
|
+
THandlers
|
|
614
|
+
>,
|
|
615
|
+
): RootRoute<
|
|
616
|
+
TRegister,
|
|
617
|
+
TSearchValidator,
|
|
618
|
+
TRouterContext,
|
|
619
|
+
TRouteContextFn,
|
|
620
|
+
TBeforeLoadFn,
|
|
621
|
+
TLoaderDeps,
|
|
622
|
+
TLoaderFn,
|
|
623
|
+
unknown,
|
|
624
|
+
unknown,
|
|
625
|
+
TSSR,
|
|
626
|
+
THandlers
|
|
627
|
+
> {
|
|
628
|
+
return new RootRoute<
|
|
629
|
+
TRegister,
|
|
630
|
+
TSearchValidator,
|
|
631
|
+
TRouterContext,
|
|
632
|
+
TRouteContextFn,
|
|
633
|
+
TBeforeLoadFn,
|
|
634
|
+
TLoaderDeps,
|
|
635
|
+
TLoaderFn,
|
|
636
|
+
unknown,
|
|
637
|
+
unknown,
|
|
638
|
+
TSSR,
|
|
639
|
+
THandlers
|
|
640
|
+
>(options)
|
|
641
|
+
}
|