@microsoft/fast-router 0.4.2 → 1.0.0-alpha.1
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/.eslintrc.json +0 -4
- package/CHANGELOG.json +105 -1
- package/CHANGELOG.md +19 -2
- package/README.md +3 -32
- package/dist/dts/commands.d.ts +5 -5
- package/dist/dts/configuration.d.ts +1 -1
- package/dist/dts/contributors.d.ts +24 -6
- package/dist/dts/events.d.ts +2 -2
- package/dist/dts/fast-router.d.ts +1 -1
- package/dist/dts/links.d.ts +2 -2
- package/dist/dts/navigation.d.ts +7 -7
- package/dist/dts/phases.d.ts +6 -6
- package/dist/dts/process.d.ts +2 -2
- package/dist/dts/query-string.d.ts +2 -2
- package/dist/dts/recognizer.d.ts +6 -6
- package/dist/dts/router.d.ts +6 -6
- package/dist/dts/routes.d.ts +26 -26
- package/dist/dts/titles.d.ts +2 -2
- package/dist/dts/view.d.ts +8 -8
- package/dist/esm/commands.js +10 -8
- package/dist/esm/configuration.js +1 -1
- package/dist/esm/contributors.js +9 -9
- package/dist/esm/events.js +1 -1
- package/dist/esm/fast-router.js +1 -1
- package/dist/esm/links.js +1 -1
- package/dist/esm/navigation.js +4 -4
- package/dist/esm/process.js +1 -1
- package/dist/esm/query-string.js +1 -1
- package/dist/esm/recognizer.js +16 -16
- package/dist/esm/router.js +4 -19
- package/dist/esm/routes.js +1 -1
- package/dist/esm/titles.js +1 -1
- package/dist/esm/view.js +8 -8
- package/dist/fast-router.api.json +9699 -2
- package/dist/fast-router.d.ts +101 -83
- package/dist/fast-router.untrimmed.d.ts +825 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/docs/api-report.md +90 -86
- package/karma.conf.cjs +6 -17
- package/package.json +11 -15
- package/dist/dts/index-rollup.d.ts +0 -2
- package/dist/esm/index-rollup.js +0 -2
- package/dist/fast-router.js +0 -6776
- package/dist/fast-router.min.js +0 -1
|
@@ -0,0 +1,825 @@
|
|
|
1
|
+
import { AddViewBehaviorFactory } from '@microsoft/fast-element';
|
|
2
|
+
import { Behavior } from '@microsoft/fast-element';
|
|
3
|
+
import { ComposableStyles } from '@microsoft/fast-element';
|
|
4
|
+
import { Constructable } from '@microsoft/fast-element';
|
|
5
|
+
import { ExecutionContext } from '@microsoft/fast-element';
|
|
6
|
+
import { FASTElement } from '@microsoft/fast-element';
|
|
7
|
+
import { HTMLDirective } from '@microsoft/fast-element';
|
|
8
|
+
import { ViewBehaviorTargets } from '@microsoft/fast-element';
|
|
9
|
+
import { ViewTemplate } from '@microsoft/fast-element';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export declare const childRouteParameter = "fast-child-route";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @beta
|
|
18
|
+
*/
|
|
19
|
+
export declare type CommandFallbackRouteDefinition<TSettings = any> = HasCommand & SupportsSettings<TSettings> & HasTitle;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @beta
|
|
23
|
+
*/
|
|
24
|
+
export declare type CommandRouteDefinition<TSettings = any> = PathedRouteDefinition<TSettings> & HasCommand & HasTitle;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @beta
|
|
28
|
+
*/
|
|
29
|
+
export declare class ConfigurableRoute implements Route {
|
|
30
|
+
readonly path: string;
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly caseSensitive: boolean;
|
|
33
|
+
constructor(path: string, name: string, caseSensitive: boolean);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @beta
|
|
38
|
+
*/
|
|
39
|
+
export declare type ContributorOptions = {
|
|
40
|
+
lifecycle?: boolean;
|
|
41
|
+
parameters?: boolean;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @beta
|
|
46
|
+
*/
|
|
47
|
+
export declare type ConverterObject = {
|
|
48
|
+
convert: RouteParameterConverter;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @beta
|
|
53
|
+
*/
|
|
54
|
+
export declare class DefaultLinkHandler implements LinkHandler {
|
|
55
|
+
private handler;
|
|
56
|
+
connect(): void;
|
|
57
|
+
disconnect(): void;
|
|
58
|
+
private getEventInfo;
|
|
59
|
+
private findClosestAnchor;
|
|
60
|
+
private targetIsThisWindow;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @beta
|
|
65
|
+
*/
|
|
66
|
+
export declare class DefaultNavigationProcess<TSettings> {
|
|
67
|
+
private phases;
|
|
68
|
+
run(router: Router, message: NavigationMessage): Promise<void>;
|
|
69
|
+
commit(phase: NavigationPhaseImpl): void;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @beta
|
|
74
|
+
*/
|
|
75
|
+
export declare class DefaultNavigationQueue implements NavigationQueue, NavigationHandler {
|
|
76
|
+
private queue;
|
|
77
|
+
private promise;
|
|
78
|
+
private resolve;
|
|
79
|
+
connect(): void;
|
|
80
|
+
disconnect(): void;
|
|
81
|
+
receive(): Promise<NavigationMessage>;
|
|
82
|
+
enqueue(msg: NavigationMessage): void;
|
|
83
|
+
private tryDequeue;
|
|
84
|
+
handleEvent(event: PopStateEvent): void;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @beta
|
|
89
|
+
*/
|
|
90
|
+
export declare class DefaultRouter implements Router {
|
|
91
|
+
readonly host: HTMLElement;
|
|
92
|
+
private parentRouter;
|
|
93
|
+
private contributors;
|
|
94
|
+
private navigationQueue;
|
|
95
|
+
private linkHandler;
|
|
96
|
+
private newView;
|
|
97
|
+
private newRoute;
|
|
98
|
+
private childCommandContributor;
|
|
99
|
+
private childRoute;
|
|
100
|
+
private isConnected;
|
|
101
|
+
private routerConfig;
|
|
102
|
+
private view;
|
|
103
|
+
route: RecognizedRoute | null;
|
|
104
|
+
constructor(host: HTMLElement);
|
|
105
|
+
get config(): RouterConfiguration | null;
|
|
106
|
+
set config(value: RouterConfiguration | null);
|
|
107
|
+
get parent(): Router<any> | null;
|
|
108
|
+
get level(): number;
|
|
109
|
+
shouldRender(route: RecognizedRoute): boolean;
|
|
110
|
+
beginRender(route: RecognizedRoute, command: RenderCommand): Promise<{
|
|
111
|
+
commit: any;
|
|
112
|
+
rollback: any;
|
|
113
|
+
}>;
|
|
114
|
+
connect(): void;
|
|
115
|
+
disconnect(): void;
|
|
116
|
+
addContributor(contributor: NavigationContributor): void;
|
|
117
|
+
removeContributor(contributor: NavigationContributor): void;
|
|
118
|
+
private tryConnect;
|
|
119
|
+
private onNavigationMessage;
|
|
120
|
+
private renderOperationCommit;
|
|
121
|
+
private renderOperationRollback;
|
|
122
|
+
private navigate;
|
|
123
|
+
private leave;
|
|
124
|
+
private construct;
|
|
125
|
+
private enter;
|
|
126
|
+
private commit;
|
|
127
|
+
private tunnel;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @beta
|
|
132
|
+
*/
|
|
133
|
+
export declare class DefaultRouteRecognizer<TSettings> implements RouteRecognizer<TSettings> {
|
|
134
|
+
private names;
|
|
135
|
+
private paths;
|
|
136
|
+
private readonly rootState;
|
|
137
|
+
add(routeOrRoutes: Route | readonly Route[], settings?: TSettings): void;
|
|
138
|
+
private $add;
|
|
139
|
+
recognize(path: string, converters?: Readonly<Record<string, RouteParameterConverter>>): Promise<RecognizedRoute<TSettings> | null>;
|
|
140
|
+
/**
|
|
141
|
+
* Generate a path and query string from a route name and params object.
|
|
142
|
+
*
|
|
143
|
+
* @param name - The name of the route to generate from.
|
|
144
|
+
* @param params - The route params to use when populating the pattern.
|
|
145
|
+
* Properties not required by the pattern will be appended to the query string.
|
|
146
|
+
* @returns The generated absolute path and query string.
|
|
147
|
+
*/
|
|
148
|
+
generateFromName(name: string, params: object): string | null;
|
|
149
|
+
/**
|
|
150
|
+
* Generate a path and query string from a route path and params object.
|
|
151
|
+
*
|
|
152
|
+
* @param path - The path of the route to generate from.
|
|
153
|
+
* @param params - The route params to use when populating the pattern.
|
|
154
|
+
* Properties not required by the pattern will be appended to the query string.
|
|
155
|
+
* @returns The generated absolute path and query string.
|
|
156
|
+
*/
|
|
157
|
+
generateFromPath(path: string, params: object): string | null;
|
|
158
|
+
private generate;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @beta
|
|
163
|
+
*/
|
|
164
|
+
export declare type DefinitionCallback = () => Promise<FallbackRouteDefinition> | FallbackRouteDefinition;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* @beta
|
|
168
|
+
*/
|
|
169
|
+
export declare type ElementFallbackRouteDefinition<TSettings = any> = LayoutAndTransitionRouteDefinition & HasElement & SupportsSettings<TSettings> & HasTitle;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* @beta
|
|
173
|
+
*/
|
|
174
|
+
export declare type ElementRouteDefinition<TSettings = any> = NavigableRouteDefinition<TSettings> & HasElement;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* @beta
|
|
178
|
+
*/
|
|
179
|
+
export declare class Endpoint<TSettings = any> {
|
|
180
|
+
readonly route: ConfigurableRoute;
|
|
181
|
+
readonly paramNames: readonly string[];
|
|
182
|
+
readonly paramTypes: readonly string[];
|
|
183
|
+
readonly settings: TSettings | null;
|
|
184
|
+
constructor(route: ConfigurableRoute, paramNames: readonly string[], paramTypes: readonly string[], settings: TSettings | null);
|
|
185
|
+
get path(): string;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* @beta
|
|
190
|
+
*/
|
|
191
|
+
export declare type FallbackRouteDefinition<TSettings = any> = ElementFallbackRouteDefinition<TSettings> | TemplateFallbackRouteDefinition<TSettings> | Pick<RedirectRouteDefinition<TSettings>, "redirect"> | CommandFallbackRouteDefinition<TSettings>;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* @beta
|
|
195
|
+
*/
|
|
196
|
+
export declare type FASTElementConstructor = new () => FASTElement;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* @beta
|
|
200
|
+
*/
|
|
201
|
+
export declare class FASTElementLayout implements Layout {
|
|
202
|
+
private readonly template;
|
|
203
|
+
private runBeforeCommit;
|
|
204
|
+
private styles;
|
|
205
|
+
constructor(template?: ViewTemplate | null, styles?: ComposableStyles | ComposableStyles[] | null, runBeforeCommit?: boolean);
|
|
206
|
+
beforeCommit(routerElement: HTMLElement): Promise<void>;
|
|
207
|
+
afterCommit(routerElement: HTMLElement): Promise<void>;
|
|
208
|
+
private apply;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* @beta
|
|
213
|
+
*/
|
|
214
|
+
export declare class FASTRouter extends FASTRouter_base {
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
declare const FASTRouter_base: new () => FASTElement & RouterElement;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* @beta
|
|
221
|
+
*/
|
|
222
|
+
export declare type HasCommand = {
|
|
223
|
+
command: NavigationCommand;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* @beta
|
|
228
|
+
*/
|
|
229
|
+
export declare type HasElement = {
|
|
230
|
+
element: string | FASTElementConstructor | HTMLElement | (() => Promise<string | FASTElementConstructor | HTMLElement>);
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* @beta
|
|
235
|
+
*/
|
|
236
|
+
export declare type HasTemplate = {
|
|
237
|
+
template: ViewTemplate | (() => Promise<ViewTemplate>);
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* @beta
|
|
242
|
+
*/
|
|
243
|
+
export declare type HasTitle = {
|
|
244
|
+
title?: string;
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* @beta
|
|
249
|
+
*/
|
|
250
|
+
export declare type IgnorableRouteDefinition<TSettings = any> = PathedRouteDefinition<TSettings>;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* @beta
|
|
254
|
+
*/
|
|
255
|
+
export declare class Ignore implements NavigationCommand {
|
|
256
|
+
createContributor(): Promise<{
|
|
257
|
+
navigate(phase: NavigationPhase): Promise<void>;
|
|
258
|
+
}>;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* @beta
|
|
263
|
+
*/
|
|
264
|
+
export declare function isFASTElementHost(host: HTMLElement): host is HTMLElement & FASTElement;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* @beta
|
|
268
|
+
*/
|
|
269
|
+
export declare function isNavigationPhaseContributor<T extends NavigationPhaseName>(object: any, phase: T): object is Record<T, NavigationPhaseHook>;
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* @beta
|
|
273
|
+
*/
|
|
274
|
+
export declare interface Layout {
|
|
275
|
+
beforeCommit(routerElement: HTMLElement): Promise<void>;
|
|
276
|
+
afterCommit(routerElement: HTMLElement): Promise<void>;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* @beta
|
|
281
|
+
*/
|
|
282
|
+
export declare const Layout: Readonly<{
|
|
283
|
+
default: Readonly<Layout>;
|
|
284
|
+
}>;
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* @beta
|
|
288
|
+
*/
|
|
289
|
+
export declare type LayoutAndTransitionRouteDefinition = {
|
|
290
|
+
layout?: Layout | ViewTemplate;
|
|
291
|
+
transition?: Transition;
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* @beta
|
|
296
|
+
*/
|
|
297
|
+
export declare interface LinkHandler {
|
|
298
|
+
connect(): void;
|
|
299
|
+
disconnect(): void;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* @beta
|
|
304
|
+
*/
|
|
305
|
+
export declare type MappableRouteDefinition<TSettings = any> = RenderableRouteDefinition<TSettings> | RedirectRouteDefinition<TSettings> | CommandRouteDefinition<TSettings> | ParentRouteDefinition<TSettings>;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* @beta
|
|
309
|
+
*/
|
|
310
|
+
export declare type NavigableRouteDefinition<TSettings = any> = PathedRouteDefinition<TSettings> & LayoutAndTransitionRouteDefinition & HasTitle & {
|
|
311
|
+
childRouters?: boolean;
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* @beta
|
|
316
|
+
*/
|
|
317
|
+
export declare interface NavigationCommand {
|
|
318
|
+
createContributor(router: Router, route: RecognizedRoute): Promise<NavigationContributor>;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* @beta
|
|
323
|
+
*/
|
|
324
|
+
export declare interface NavigationCommitPhase<TSettings = any> extends Omit<NavigationPhase<TSettings>, "cancel" | "canceled" | "onCancel"> {
|
|
325
|
+
setTitle(title: string): any;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* @beta
|
|
330
|
+
*/
|
|
331
|
+
export declare type NavigationCommitPhaseHook<TSettings = any> = (phase: NavigationCommitPhase<TSettings>) => Promise<any> | any;
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* @beta
|
|
335
|
+
*/
|
|
336
|
+
export declare type NavigationContributor<TSettings = any> = Partial<Record<Exclude<NavigationPhaseName, "commit">, NavigationPhaseHook<TSettings>>> & {
|
|
337
|
+
commit?: NavigationCommitPhaseHook<TSettings>;
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* @beta
|
|
342
|
+
*/
|
|
343
|
+
export declare function navigationContributor(options?: ContributorOptions): NavigationContributorDirective;
|
|
344
|
+
|
|
345
|
+
declare class NavigationContributorBehavior implements Behavior {
|
|
346
|
+
private contributor;
|
|
347
|
+
private options;
|
|
348
|
+
private router;
|
|
349
|
+
constructor(contributor: HTMLElement & NavigationContributor, options: Required<ContributorOptions>);
|
|
350
|
+
bind(source: unknown, context: RouterExecutionContext): void;
|
|
351
|
+
unbind(source: unknown): void;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
declare class NavigationContributorDirective implements HTMLDirective {
|
|
355
|
+
private options;
|
|
356
|
+
id: string;
|
|
357
|
+
nodeId: string;
|
|
358
|
+
constructor(options: Required<ContributorOptions>);
|
|
359
|
+
createHTML(add: AddViewBehaviorFactory): string;
|
|
360
|
+
createBehavior(targets: ViewBehaviorTargets): NavigationContributorBehavior;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* @beta
|
|
365
|
+
*/
|
|
366
|
+
export declare interface NavigationHandler {
|
|
367
|
+
enqueue(msg: NavigationMessage): void;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* @beta
|
|
372
|
+
*/
|
|
373
|
+
export declare const NavigationHandler: Readonly<{
|
|
374
|
+
register(handler: NavigationHandler): void;
|
|
375
|
+
unregister(handler: NavigationHandler): void;
|
|
376
|
+
}>;
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* @beta
|
|
380
|
+
*/
|
|
381
|
+
export declare class NavigationMessage {
|
|
382
|
+
path: string;
|
|
383
|
+
constructor(path: string);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* @beta
|
|
388
|
+
*/
|
|
389
|
+
export declare interface NavigationPhase<TSettings = any> {
|
|
390
|
+
readonly name: NavigationPhaseName;
|
|
391
|
+
readonly route: RecognizedRoute<TSettings>;
|
|
392
|
+
readonly router: Router<TSettings>;
|
|
393
|
+
readonly canceled: boolean;
|
|
394
|
+
cancel(callback?: NavigationPhaseFollowupAction): void;
|
|
395
|
+
onCancel(callback: NavigationPhaseFollowupAction): void;
|
|
396
|
+
onCommit(callback: NavigationPhaseFollowupAction): void;
|
|
397
|
+
evaluateContributor(contributor: any, route?: RecognizedRoute<TSettings>, router?: Router<TSettings>): Promise<void>;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* @beta
|
|
402
|
+
*/
|
|
403
|
+
export declare type NavigationPhaseFollowupAction = () => Promise<any> | any;
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* @beta
|
|
407
|
+
*/
|
|
408
|
+
export declare type NavigationPhaseHook<TSettings = any> = (phase: NavigationPhase<TSettings>) => Promise<any> | any;
|
|
409
|
+
|
|
410
|
+
declare class NavigationPhaseImpl<TSettings = any> implements NavigationCommitPhase<TSettings> {
|
|
411
|
+
readonly name: NavigationPhaseName;
|
|
412
|
+
private readonly commitActions;
|
|
413
|
+
private readonly cancelActions;
|
|
414
|
+
private routes;
|
|
415
|
+
private routers;
|
|
416
|
+
canceled: boolean;
|
|
417
|
+
titles: Array<Array<string>>;
|
|
418
|
+
get route(): RecognizedRoute<TSettings>;
|
|
419
|
+
get router(): Router;
|
|
420
|
+
constructor(name: NavigationPhaseName, route: RecognizedRoute<TSettings>, router: Router<TSettings>, commitActions: NavigationPhaseFollowupAction[], cancelActions: NavigationPhaseFollowupAction[]);
|
|
421
|
+
cancel(callback?: NavigationPhaseFollowupAction): void;
|
|
422
|
+
onCommit(callback: NavigationPhaseFollowupAction): void;
|
|
423
|
+
onCancel(callback: NavigationPhaseFollowupAction): void;
|
|
424
|
+
setTitle(title: string): void;
|
|
425
|
+
evaluateContributor(contributor: any, route?: RecognizedRoute<TSettings>, router?: Router): Promise<void>;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* @beta
|
|
430
|
+
*/
|
|
431
|
+
export declare type NavigationPhaseName = "navigate" | "leave" | "construct" | "enter" | "commit";
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* @beta
|
|
435
|
+
*/
|
|
436
|
+
export declare interface NavigationProcess {
|
|
437
|
+
run(router: Router, message: NavigationMessage): Promise<void>;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* @beta
|
|
442
|
+
*/
|
|
443
|
+
export declare interface NavigationQueue {
|
|
444
|
+
connect(): void;
|
|
445
|
+
disconnect(): void;
|
|
446
|
+
receive(): Promise<NavigationMessage>;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* @beta
|
|
451
|
+
*/
|
|
452
|
+
export declare type ParameterConverter = RouteParameterConverter | ConverterObject | Constructable<ConverterObject>;
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* @beta
|
|
456
|
+
*/
|
|
457
|
+
export declare type ParentRouteDefinition<TSettings = any> = PathedRouteDefinition<TSettings> & LayoutAndTransitionRouteDefinition & {
|
|
458
|
+
children: MappableRouteDefinition<TSettings>[];
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* @beta
|
|
463
|
+
*/
|
|
464
|
+
export declare type PathedRouteDefinition<TSettings = any> = SupportsSettings<TSettings> & Route;
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* @beta
|
|
468
|
+
*/
|
|
469
|
+
export declare const QueryString: Readonly<{
|
|
470
|
+
readonly current: string;
|
|
471
|
+
/**
|
|
472
|
+
* Generate a query string from an object.
|
|
473
|
+
*
|
|
474
|
+
* @param params - Object containing the keys and values to be used.
|
|
475
|
+
* @param traditional - Boolean Use the old URI template standard (RFC6570)
|
|
476
|
+
* @returns The generated query string, excluding leading '?'.
|
|
477
|
+
*/
|
|
478
|
+
build(params: Object, traditional?: boolean): string;
|
|
479
|
+
/**
|
|
480
|
+
* Separate the query string from the path and returns the two parts.
|
|
481
|
+
* @param path - The path to separate.
|
|
482
|
+
*/
|
|
483
|
+
separate(path: string): Readonly<{
|
|
484
|
+
path: string;
|
|
485
|
+
queryString: string;
|
|
486
|
+
}>;
|
|
487
|
+
/**
|
|
488
|
+
* Parse a query string.
|
|
489
|
+
*
|
|
490
|
+
* @param queryString - The query string to parse.
|
|
491
|
+
* @returns Object with keys and values mapped from the query string.
|
|
492
|
+
*/
|
|
493
|
+
parse(queryString: string): Readonly<Record<string, string>>;
|
|
494
|
+
}>;
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* @beta
|
|
498
|
+
*/
|
|
499
|
+
export declare class RecognizedRoute<TSettings = any> {
|
|
500
|
+
readonly endpoint: Endpoint<TSettings>;
|
|
501
|
+
readonly params: Readonly<Record<string, string | undefined>>;
|
|
502
|
+
readonly typedParams: Readonly<Record<string, any>>;
|
|
503
|
+
readonly queryParams: Readonly<Record<string, string>>;
|
|
504
|
+
readonly allParams: Readonly<Record<string, string | undefined>>;
|
|
505
|
+
readonly allTypedParams: Readonly<Record<string, any>>;
|
|
506
|
+
constructor(endpoint: Endpoint<TSettings>, params: Readonly<Record<string, string | undefined>>, typedParams: Readonly<Record<string, any>>, queryParams: Readonly<Record<string, string>>);
|
|
507
|
+
get settings(): TSettings | null;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* @beta
|
|
512
|
+
*/
|
|
513
|
+
export declare class Redirect implements NavigationCommand {
|
|
514
|
+
private redirect;
|
|
515
|
+
constructor(redirect: string);
|
|
516
|
+
createContributor(): Promise<{
|
|
517
|
+
navigate(phase: NavigationPhase): Promise<void>;
|
|
518
|
+
}>;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* @beta
|
|
523
|
+
*/
|
|
524
|
+
export declare type RedirectRouteDefinition<TSettings = any> = PathedRouteDefinition<TSettings> & {
|
|
525
|
+
redirect: string;
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* @beta
|
|
530
|
+
*/
|
|
531
|
+
export declare class Render implements RenderCommand {
|
|
532
|
+
private owner;
|
|
533
|
+
createView: () => Promise<RouteView>;
|
|
534
|
+
private _layout;
|
|
535
|
+
private _transition;
|
|
536
|
+
title: string;
|
|
537
|
+
constructor(owner: RouterConfiguration, createView: () => Promise<RouteView>);
|
|
538
|
+
get transition(): Transition;
|
|
539
|
+
set transition(value: Transition);
|
|
540
|
+
get layout(): Layout;
|
|
541
|
+
set layout(value: Layout);
|
|
542
|
+
createContributor(router: Router, route: RecognizedRoute): Promise<RenderContributor>;
|
|
543
|
+
static fromDefinition(owner: RouterConfiguration, definition: ElementRouteDefinition | TemplateRouteDefinition | ElementFallbackRouteDefinition | TemplateFallbackRouteDefinition): Render;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* @beta
|
|
548
|
+
*/
|
|
549
|
+
export declare type RenderableRouteDefinition<TSettings = any> = ElementRouteDefinition<TSettings> | TemplateRouteDefinition<TSettings>;
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* @beta
|
|
553
|
+
*/
|
|
554
|
+
export declare interface RenderCommand extends NavigationCommand {
|
|
555
|
+
layout: Layout;
|
|
556
|
+
transition: Transition;
|
|
557
|
+
createView(): Promise<RouteView>;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
declare class RenderContributor {
|
|
561
|
+
private router;
|
|
562
|
+
private route;
|
|
563
|
+
private command;
|
|
564
|
+
private operation;
|
|
565
|
+
constructor(router: Router, route: RecognizedRoute, command: Render);
|
|
566
|
+
construct(phase: NavigationPhase): Promise<void>;
|
|
567
|
+
commit(phase: NavigationCommitPhase): Promise<void>;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* @beta
|
|
572
|
+
*/
|
|
573
|
+
export declare interface RenderOperation {
|
|
574
|
+
commit(): Promise<void>;
|
|
575
|
+
rollback(): Promise<void>;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* @beta
|
|
580
|
+
*/
|
|
581
|
+
export declare interface Route {
|
|
582
|
+
readonly path: string;
|
|
583
|
+
readonly name?: string;
|
|
584
|
+
readonly caseSensitive?: boolean;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* @beta
|
|
589
|
+
*/
|
|
590
|
+
export declare const Route: Readonly<{
|
|
591
|
+
path: Readonly<{
|
|
592
|
+
readonly current: string;
|
|
593
|
+
generateRoute(relativeTo: HTMLElement | Router, path: string, params?: Object): Promise<string | null>;
|
|
594
|
+
push(path: string, trigger?: boolean): void;
|
|
595
|
+
replace(path: string, trigger?: boolean): void;
|
|
596
|
+
trigger(path: string): void;
|
|
597
|
+
}>;
|
|
598
|
+
name: Readonly<{
|
|
599
|
+
generateRoute(relativeTo: HTMLElement | Router, name: string, params?: Object): Promise<string | null>;
|
|
600
|
+
push(relativeTo: HTMLElement | Router, name: string, params?: Object, trigger?: boolean): Promise<void>;
|
|
601
|
+
replace(relativeTo: HTMLElement | Router, name: string, params?: Object, trigger?: boolean): Promise<void>;
|
|
602
|
+
trigger(relativeTo: HTMLElement | Router, name: string, params?: Object): Promise<void>;
|
|
603
|
+
}>;
|
|
604
|
+
}>;
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* @beta
|
|
608
|
+
*/
|
|
609
|
+
export declare class RouteCollection<TSettings = any> {
|
|
610
|
+
private owner;
|
|
611
|
+
private _recognizer;
|
|
612
|
+
private pathToCommand;
|
|
613
|
+
private fallbackCommand;
|
|
614
|
+
private fallbackSettings;
|
|
615
|
+
private converters;
|
|
616
|
+
constructor(owner: RouterConfiguration);
|
|
617
|
+
private get recognizer();
|
|
618
|
+
ignore(definitionOrString: IgnorableRouteDefinition<TSettings> | string): void;
|
|
619
|
+
map(...routes: MappableRouteDefinition<TSettings>[]): void;
|
|
620
|
+
fallback(definitionOrCallback: FallbackRouteDefinition<TSettings> | DefinitionCallback): void;
|
|
621
|
+
converter(name: string, converter: ParameterConverter): void;
|
|
622
|
+
recognize(path: string): Promise<RouteMatch<TSettings> | null>;
|
|
623
|
+
/**
|
|
624
|
+
* Generate a path and query string from a route name and params object.
|
|
625
|
+
*
|
|
626
|
+
* @param name - The name of the route to generate from.
|
|
627
|
+
* @param params - The route params to use when populating the pattern.
|
|
628
|
+
* Properties not required by the pattern will be appended to the query string.
|
|
629
|
+
* @returns The generated absolute path and query string.
|
|
630
|
+
*/
|
|
631
|
+
generateFromName(name: string, params: object): string | null;
|
|
632
|
+
/**
|
|
633
|
+
* Generate a path and query string from a route path and params object.
|
|
634
|
+
*
|
|
635
|
+
* @param path - The path of the route to generate from.
|
|
636
|
+
* @param params - The route params to use when populating the pattern.
|
|
637
|
+
* Properties not required by the pattern will be appended to the query string.
|
|
638
|
+
* @returns The generated absolute path and query string.
|
|
639
|
+
*/
|
|
640
|
+
generateFromPath(path: string, params: object): string | null;
|
|
641
|
+
private aggregateConverters;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* @beta
|
|
646
|
+
*/
|
|
647
|
+
export declare type RouteMatch<TSettings = any> = {
|
|
648
|
+
route: RecognizedRoute<TSettings>;
|
|
649
|
+
command: NavigationCommand;
|
|
650
|
+
};
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* @beta
|
|
654
|
+
*/
|
|
655
|
+
export declare type RouteParameterConverter = (value: string | undefined) => any | Promise<any>;
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* @beta
|
|
659
|
+
*/
|
|
660
|
+
export declare interface Router<TSettings = any> {
|
|
661
|
+
readonly level: number;
|
|
662
|
+
readonly parent: Router | null;
|
|
663
|
+
readonly route: RecognizedRoute | null;
|
|
664
|
+
config: RouterConfiguration | null;
|
|
665
|
+
connect(): void;
|
|
666
|
+
disconnect(): void;
|
|
667
|
+
shouldRender(route: RecognizedRoute<TSettings>): boolean;
|
|
668
|
+
beginRender(route: RecognizedRoute<TSettings>, command: RenderCommand): Promise<RenderOperation>;
|
|
669
|
+
addContributor(contributor: NavigationContributor): void;
|
|
670
|
+
removeContributor(contributor: NavigationContributor): void;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* @beta
|
|
675
|
+
*/
|
|
676
|
+
export declare const Router: Readonly<{
|
|
677
|
+
getOrCreateFor(element: HTMLElement): Router<any> | DefaultRouter;
|
|
678
|
+
find(element: HTMLElement): Router | null;
|
|
679
|
+
from<TBase extends {
|
|
680
|
+
new (): HTMLElement;
|
|
681
|
+
prototype: HTMLElement;
|
|
682
|
+
}>(BaseType: TBase): new () => InstanceType<TBase> & RouterElement;
|
|
683
|
+
}>;
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* @beta
|
|
687
|
+
*/
|
|
688
|
+
export declare abstract class RouterConfiguration<TSettings = any> {
|
|
689
|
+
private isConfigured;
|
|
690
|
+
readonly routes: RouteCollection<TSettings>;
|
|
691
|
+
readonly contributors: NavigationContributor<TSettings>[];
|
|
692
|
+
defaultLayout: Layout;
|
|
693
|
+
defaultTransition: Readonly<Transition>;
|
|
694
|
+
title: string;
|
|
695
|
+
parent: RouterConfiguration<TSettings> | null;
|
|
696
|
+
createNavigationQueue(): NavigationQueue;
|
|
697
|
+
createLinkHandler(): LinkHandler;
|
|
698
|
+
createNavigationProcess(): NavigationProcess;
|
|
699
|
+
createEventSink(): RoutingEventSink;
|
|
700
|
+
createTitleBuilder(): TitleBuilder;
|
|
701
|
+
createRouteRecognizer(): RouteRecognizer<TSettings>;
|
|
702
|
+
construct<T>(Type: Constructable<T>): T;
|
|
703
|
+
recognizeRoute(path: string): Promise<RouteMatch<TSettings> | null>;
|
|
704
|
+
/**
|
|
705
|
+
* Generate a path and query string from a route name and params object.
|
|
706
|
+
*
|
|
707
|
+
* @param name - The name of the route to generate from.
|
|
708
|
+
* @param params - The route params to use when populating the pattern.
|
|
709
|
+
* Properties not required by the pattern will be appended to the query string.
|
|
710
|
+
* @returns The generated absolute path and query string.
|
|
711
|
+
*/
|
|
712
|
+
generateRouteFromName(name: string, params: object): Promise<string | null>;
|
|
713
|
+
/**
|
|
714
|
+
* Generate a path and query string from a route path and params object.
|
|
715
|
+
*
|
|
716
|
+
* @param path - The path of the route to generate from.
|
|
717
|
+
* @param params - The route params to use when populating the pattern.
|
|
718
|
+
* Properties not required by the pattern will be appended to the query string.
|
|
719
|
+
* @returns The generated absolute path and query string.
|
|
720
|
+
*/
|
|
721
|
+
generateRouteFromPath(path: string, params: object): Promise<string | null>;
|
|
722
|
+
findContributors<T extends NavigationPhaseName>(phase: T): Record<T, NavigationPhaseHook<TSettings>>[];
|
|
723
|
+
protected abstract configure(): Promise<void> | void;
|
|
724
|
+
protected cached(ElementType: new () => HTMLElement): () => Promise<HTMLElement>;
|
|
725
|
+
private ensureConfigured;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
/**
|
|
729
|
+
* @beta
|
|
730
|
+
*/
|
|
731
|
+
export declare interface RouteRecognizer<TSettings> {
|
|
732
|
+
add(routeOrRoutes: Route | readonly Route[], settings?: TSettings): void;
|
|
733
|
+
recognize(path: string, converters?: Readonly<Record<string, RouteParameterConverter>>): Promise<RecognizedRoute<TSettings> | null>;
|
|
734
|
+
generateFromName(name: string, params: object): string | null;
|
|
735
|
+
generateFromPath(path: string, params: object): string | null;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* @beta
|
|
740
|
+
*/
|
|
741
|
+
export declare interface RouterElement extends HTMLElement {
|
|
742
|
+
readonly [routerProperty]: Router;
|
|
743
|
+
config: RouterConfiguration | null;
|
|
744
|
+
connectedCallback(): any;
|
|
745
|
+
disconnectedCallback(): any;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
/**
|
|
749
|
+
* @beta
|
|
750
|
+
*/
|
|
751
|
+
export declare type RouterExecutionContext = ExecutionContext & {
|
|
752
|
+
router: Router;
|
|
753
|
+
};
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* @beta
|
|
757
|
+
*/
|
|
758
|
+
export declare const RouterExecutionContext: Readonly<{
|
|
759
|
+
create(router: Router): any;
|
|
760
|
+
}>;
|
|
761
|
+
|
|
762
|
+
declare const routerProperty = "$router";
|
|
763
|
+
|
|
764
|
+
/**
|
|
765
|
+
* @beta
|
|
766
|
+
*/
|
|
767
|
+
export declare interface RouteView {
|
|
768
|
+
bind(allTypedParams: Readonly<Record<string, any>>, context: RouterExecutionContext): void;
|
|
769
|
+
appendTo(host: HTMLElement): void;
|
|
770
|
+
dispose(): void;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* @beta
|
|
775
|
+
*/
|
|
776
|
+
declare interface RoutingEventSink {
|
|
777
|
+
onUnhandledNavigationMessage(router: Router, message: NavigationMessage): void;
|
|
778
|
+
onNavigationBegin(router: Router, route: RecognizedRoute, command: NavigationCommand): void;
|
|
779
|
+
onPhaseBegin(phase: NavigationPhase): void;
|
|
780
|
+
onPhaseEnd(phase: NavigationPhase): void;
|
|
781
|
+
onNavigationEnd(router: Router, route: RecognizedRoute, command: NavigationCommand): void;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* @beta
|
|
786
|
+
*/
|
|
787
|
+
export declare type SupportsSettings<TSettings = any> = {
|
|
788
|
+
settings?: TSettings;
|
|
789
|
+
};
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* @beta
|
|
793
|
+
*/
|
|
794
|
+
export declare type TemplateFallbackRouteDefinition<TSettings = any> = LayoutAndTransitionRouteDefinition & HasTemplate & SupportsSettings<TSettings> & HasTitle;
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* @beta
|
|
798
|
+
*/
|
|
799
|
+
export declare type TemplateRouteDefinition<TSettings = any> = NavigableRouteDefinition<TSettings> & HasTemplate;
|
|
800
|
+
|
|
801
|
+
/**
|
|
802
|
+
* @beta
|
|
803
|
+
*/
|
|
804
|
+
declare interface TitleBuilder {
|
|
805
|
+
joinTitles(parentTitle: string, childTitle: string): string;
|
|
806
|
+
buildTitle(rootTitle: string, routeTitles: string[][]): string;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
/**
|
|
810
|
+
* @beta
|
|
811
|
+
*/
|
|
812
|
+
export declare interface Transition {
|
|
813
|
+
begin(host: HTMLElement, prev: RouteView | null, next: RouteView): Promise<void>;
|
|
814
|
+
rollback(host: HTMLElement, prev: RouteView | null, next: RouteView): Promise<void>;
|
|
815
|
+
commit(host: HTMLElement, prev: RouteView | null, next: RouteView): Promise<void>;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* @beta
|
|
820
|
+
*/
|
|
821
|
+
export declare const Transition: Readonly<{
|
|
822
|
+
default: Readonly<Transition>;
|
|
823
|
+
}>;
|
|
824
|
+
|
|
825
|
+
export { }
|