@microsoft/fast-router 0.4.5 → 1.0.0-alpha.10
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 +224 -11
- package/CHANGELOG.md +88 -5
- 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 +23 -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/{tsdoc-metadata.json → dts/tsdoc-metadata.json} +1 -1
- package/dist/dts/view.d.ts +11 -16
- package/dist/esm/commands.js +10 -8
- package/dist/esm/configuration.js +1 -1
- package/dist/esm/contributors.js +25 -21
- 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 +6 -21
- package/dist/esm/routes.js +1 -1
- package/dist/esm/titles.js +1 -1
- package/dist/esm/view.js +9 -27
- package/dist/fast-router.api.json +9674 -2
- package/dist/fast-router.d.ts +105 -93
- package/dist/fast-router.untrimmed.d.ts +819 -0
- package/docs/api-report.md +95 -94
- package/karma.conf.cjs +6 -17
- package/package.json +12 -16
- package/dist/dts/index-rollup.d.ts +0 -2
- package/dist/esm/index-rollup.js +0 -2
- package/dist/fast-router.js +0 -6793
- package/dist/fast-router.min.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
2
|
+
* @beta
|
|
3
3
|
*/
|
|
4
4
|
export declare const QueryString: Readonly<{
|
|
5
5
|
readonly current: string;
|
|
@@ -10,7 +10,7 @@ export declare const QueryString: Readonly<{
|
|
|
10
10
|
* @param traditional - Boolean Use the old URI template standard (RFC6570)
|
|
11
11
|
* @returns The generated query string, excluding leading '?'.
|
|
12
12
|
*/
|
|
13
|
-
build(params: Object, traditional?: boolean
|
|
13
|
+
build(params: Object, traditional?: boolean): string;
|
|
14
14
|
/**
|
|
15
15
|
* Separate the query string from the path and returns the two parts.
|
|
16
16
|
* @param path - The path to separate.
|
package/dist/dts/recognizer.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Route } from "./navigation.js";
|
|
2
2
|
/**
|
|
3
|
-
* @
|
|
3
|
+
* @beta
|
|
4
4
|
*/
|
|
5
5
|
export declare type RouteParameterConverter = (value: string | undefined) => any | Promise<any>;
|
|
6
6
|
/**
|
|
7
|
-
* @
|
|
7
|
+
* @beta
|
|
8
8
|
*/
|
|
9
9
|
export declare class ConfigurableRoute implements Route {
|
|
10
10
|
readonly path: string;
|
|
@@ -13,7 +13,7 @@ export declare class ConfigurableRoute implements Route {
|
|
|
13
13
|
constructor(path: string, name: string, caseSensitive: boolean);
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* @
|
|
16
|
+
* @beta
|
|
17
17
|
*/
|
|
18
18
|
export declare class Endpoint<TSettings = any> {
|
|
19
19
|
readonly route: ConfigurableRoute;
|
|
@@ -24,7 +24,7 @@ export declare class Endpoint<TSettings = any> {
|
|
|
24
24
|
get path(): string;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
* @
|
|
27
|
+
* @beta
|
|
28
28
|
*/
|
|
29
29
|
export declare class RecognizedRoute<TSettings = any> {
|
|
30
30
|
readonly endpoint: Endpoint<TSettings>;
|
|
@@ -37,7 +37,7 @@ export declare class RecognizedRoute<TSettings = any> {
|
|
|
37
37
|
get settings(): TSettings | null;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
* @
|
|
40
|
+
* @beta
|
|
41
41
|
*/
|
|
42
42
|
export interface RouteRecognizer<TSettings> {
|
|
43
43
|
add(routeOrRoutes: Route | readonly Route[], settings?: TSettings): void;
|
|
@@ -46,7 +46,7 @@ export interface RouteRecognizer<TSettings> {
|
|
|
46
46
|
generateFromPath(path: string, params: object): string | null;
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
|
-
* @
|
|
49
|
+
* @beta
|
|
50
50
|
*/
|
|
51
51
|
export declare class DefaultRouteRecognizer<TSettings> implements RouteRecognizer<TSettings> {
|
|
52
52
|
private names;
|
package/dist/dts/router.d.ts
CHANGED
|
@@ -4,14 +4,14 @@ import { RouterConfiguration } from "./configuration.js";
|
|
|
4
4
|
import { NavigationContributor } from "./contributors.js";
|
|
5
5
|
import { RecognizedRoute } from "./recognizer.js";
|
|
6
6
|
/**
|
|
7
|
-
* @
|
|
7
|
+
* @beta
|
|
8
8
|
*/
|
|
9
9
|
export interface RenderOperation {
|
|
10
10
|
commit(): Promise<void>;
|
|
11
11
|
rollback(): Promise<void>;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
* @
|
|
14
|
+
* @beta
|
|
15
15
|
*/
|
|
16
16
|
export interface Router<TSettings = any> {
|
|
17
17
|
readonly level: number;
|
|
@@ -27,7 +27,7 @@ export interface Router<TSettings = any> {
|
|
|
27
27
|
}
|
|
28
28
|
declare const routerProperty = "$router";
|
|
29
29
|
/**
|
|
30
|
-
* @
|
|
30
|
+
* @beta
|
|
31
31
|
*/
|
|
32
32
|
export interface RouterElement extends HTMLElement {
|
|
33
33
|
readonly [routerProperty]: Router;
|
|
@@ -36,7 +36,7 @@ export interface RouterElement extends HTMLElement {
|
|
|
36
36
|
disconnectedCallback(): any;
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
* @
|
|
39
|
+
* @beta
|
|
40
40
|
*/
|
|
41
41
|
export declare const Router: Readonly<{
|
|
42
42
|
getOrCreateFor(element: HTMLElement): Router<any> | DefaultRouter;
|
|
@@ -47,11 +47,11 @@ export declare const Router: Readonly<{
|
|
|
47
47
|
}>(BaseType: TBase): new () => InstanceType<TBase> & RouterElement;
|
|
48
48
|
}>;
|
|
49
49
|
/**
|
|
50
|
-
* @
|
|
50
|
+
* @beta
|
|
51
51
|
*/
|
|
52
52
|
export declare function isFASTElementHost(host: HTMLElement): host is HTMLElement & FASTElement;
|
|
53
53
|
/**
|
|
54
|
-
* @
|
|
54
|
+
* @beta
|
|
55
55
|
*/
|
|
56
56
|
export declare class DefaultRouter implements Router {
|
|
57
57
|
readonly host: HTMLElement;
|
package/dist/dts/routes.d.ts
CHANGED
|
@@ -9,131 +9,131 @@ import { Route } from "./navigation.js";
|
|
|
9
9
|
*/
|
|
10
10
|
export declare const childRouteParameter = "fast-child-route";
|
|
11
11
|
/**
|
|
12
|
-
* @
|
|
12
|
+
* @beta
|
|
13
13
|
*/
|
|
14
14
|
export declare type SupportsSettings<TSettings = any> = {
|
|
15
15
|
settings?: TSettings;
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
|
-
* @
|
|
18
|
+
* @beta
|
|
19
19
|
*/
|
|
20
20
|
export declare type PathedRouteDefinition<TSettings = any> = SupportsSettings<TSettings> & Route;
|
|
21
21
|
/**
|
|
22
|
-
* @
|
|
22
|
+
* @beta
|
|
23
23
|
*/
|
|
24
24
|
export declare type IgnorableRouteDefinition<TSettings = any> = PathedRouteDefinition<TSettings>;
|
|
25
25
|
/**
|
|
26
|
-
* @
|
|
26
|
+
* @beta
|
|
27
27
|
*/
|
|
28
28
|
export declare type LayoutAndTransitionRouteDefinition = {
|
|
29
29
|
layout?: Layout | ViewTemplate;
|
|
30
30
|
transition?: Transition;
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
33
|
-
* @
|
|
33
|
+
* @beta
|
|
34
34
|
*/
|
|
35
35
|
export declare type RedirectRouteDefinition<TSettings = any> = PathedRouteDefinition<TSettings> & {
|
|
36
36
|
redirect: string;
|
|
37
37
|
};
|
|
38
38
|
/**
|
|
39
|
-
* @
|
|
39
|
+
* @beta
|
|
40
40
|
*/
|
|
41
41
|
export declare type HasTitle = {
|
|
42
42
|
title?: string;
|
|
43
43
|
};
|
|
44
44
|
/**
|
|
45
|
-
* @
|
|
45
|
+
* @beta
|
|
46
46
|
*/
|
|
47
47
|
export declare type NavigableRouteDefinition<TSettings = any> = PathedRouteDefinition<TSettings> & LayoutAndTransitionRouteDefinition & HasTitle & {
|
|
48
48
|
childRouters?: boolean;
|
|
49
49
|
};
|
|
50
50
|
/**
|
|
51
|
-
* @
|
|
51
|
+
* @beta
|
|
52
52
|
*/
|
|
53
53
|
export declare type FASTElementConstructor = new () => FASTElement;
|
|
54
54
|
/**
|
|
55
|
-
* @
|
|
55
|
+
* @beta
|
|
56
56
|
*/
|
|
57
57
|
export declare type HasElement = {
|
|
58
58
|
element: string | FASTElementConstructor | HTMLElement | (() => Promise<string | FASTElementConstructor | HTMLElement>);
|
|
59
59
|
};
|
|
60
60
|
/**
|
|
61
|
-
* @
|
|
61
|
+
* @beta
|
|
62
62
|
*/
|
|
63
63
|
export declare type ElementFallbackRouteDefinition<TSettings = any> = LayoutAndTransitionRouteDefinition & HasElement & SupportsSettings<TSettings> & HasTitle;
|
|
64
64
|
/**
|
|
65
|
-
* @
|
|
65
|
+
* @beta
|
|
66
66
|
*/
|
|
67
67
|
export declare type ElementRouteDefinition<TSettings = any> = NavigableRouteDefinition<TSettings> & HasElement;
|
|
68
68
|
/**
|
|
69
|
-
* @
|
|
69
|
+
* @beta
|
|
70
70
|
*/
|
|
71
71
|
export declare type HasTemplate = {
|
|
72
72
|
template: ViewTemplate | (() => Promise<ViewTemplate>);
|
|
73
73
|
};
|
|
74
74
|
/**
|
|
75
|
-
* @
|
|
75
|
+
* @beta
|
|
76
76
|
*/
|
|
77
77
|
export declare type TemplateFallbackRouteDefinition<TSettings = any> = LayoutAndTransitionRouteDefinition & HasTemplate & SupportsSettings<TSettings> & HasTitle;
|
|
78
78
|
/**
|
|
79
|
-
* @
|
|
79
|
+
* @beta
|
|
80
80
|
*/
|
|
81
81
|
export declare type TemplateRouteDefinition<TSettings = any> = NavigableRouteDefinition<TSettings> & HasTemplate;
|
|
82
82
|
/**
|
|
83
|
-
* @
|
|
83
|
+
* @beta
|
|
84
84
|
*/
|
|
85
85
|
export declare type HasCommand = {
|
|
86
86
|
command: NavigationCommand;
|
|
87
87
|
};
|
|
88
88
|
/**
|
|
89
|
-
* @
|
|
89
|
+
* @beta
|
|
90
90
|
*/
|
|
91
91
|
export declare type CommandRouteDefinition<TSettings = any> = PathedRouteDefinition<TSettings> & HasCommand & HasTitle;
|
|
92
92
|
/**
|
|
93
|
-
* @
|
|
93
|
+
* @beta
|
|
94
94
|
*/
|
|
95
95
|
export declare type CommandFallbackRouteDefinition<TSettings = any> = HasCommand & SupportsSettings<TSettings> & HasTitle;
|
|
96
96
|
/**
|
|
97
|
-
* @
|
|
97
|
+
* @beta
|
|
98
98
|
*/
|
|
99
99
|
export declare type FallbackRouteDefinition<TSettings = any> = ElementFallbackRouteDefinition<TSettings> | TemplateFallbackRouteDefinition<TSettings> | Pick<RedirectRouteDefinition<TSettings>, "redirect"> | CommandFallbackRouteDefinition<TSettings>;
|
|
100
100
|
/**
|
|
101
|
-
* @
|
|
101
|
+
* @beta
|
|
102
102
|
*/
|
|
103
103
|
export declare type DefinitionCallback = () => Promise<FallbackRouteDefinition> | FallbackRouteDefinition;
|
|
104
104
|
/**
|
|
105
|
-
* @
|
|
105
|
+
* @beta
|
|
106
106
|
*/
|
|
107
107
|
export declare type RenderableRouteDefinition<TSettings = any> = ElementRouteDefinition<TSettings> | TemplateRouteDefinition<TSettings>;
|
|
108
108
|
/**
|
|
109
|
-
* @
|
|
109
|
+
* @beta
|
|
110
110
|
*/
|
|
111
111
|
export declare type MappableRouteDefinition<TSettings = any> = RenderableRouteDefinition<TSettings> | RedirectRouteDefinition<TSettings> | CommandRouteDefinition<TSettings> | ParentRouteDefinition<TSettings>;
|
|
112
112
|
/**
|
|
113
|
-
* @
|
|
113
|
+
* @beta
|
|
114
114
|
*/
|
|
115
115
|
export declare type ParentRouteDefinition<TSettings = any> = PathedRouteDefinition<TSettings> & LayoutAndTransitionRouteDefinition & {
|
|
116
116
|
children: MappableRouteDefinition<TSettings>[];
|
|
117
117
|
};
|
|
118
118
|
/**
|
|
119
|
-
* @
|
|
119
|
+
* @beta
|
|
120
120
|
*/
|
|
121
121
|
export declare type RouteMatch<TSettings = any> = {
|
|
122
122
|
route: RecognizedRoute<TSettings>;
|
|
123
123
|
command: NavigationCommand;
|
|
124
124
|
};
|
|
125
125
|
/**
|
|
126
|
-
* @
|
|
126
|
+
* @beta
|
|
127
127
|
*/
|
|
128
128
|
export declare type ConverterObject = {
|
|
129
129
|
convert: RouteParameterConverter;
|
|
130
130
|
};
|
|
131
131
|
/**
|
|
132
|
-
* @
|
|
132
|
+
* @beta
|
|
133
133
|
*/
|
|
134
134
|
export declare type ParameterConverter = RouteParameterConverter | ConverterObject | Constructable<ConverterObject>;
|
|
135
135
|
/**
|
|
136
|
-
* @
|
|
136
|
+
* @beta
|
|
137
137
|
*/
|
|
138
138
|
export declare class RouteCollection<TSettings = any> {
|
|
139
139
|
private owner;
|
package/dist/dts/titles.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
2
|
+
* @beta
|
|
3
3
|
*/
|
|
4
4
|
export interface TitleBuilder {
|
|
5
5
|
joinTitles(parentTitle: string, childTitle: string): string;
|
|
6
6
|
buildTitle(rootTitle: string, routeTitles: string[][]): string;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
* @
|
|
9
|
+
* @beta
|
|
10
10
|
*/
|
|
11
11
|
export declare class DefaultTitleBuilder implements TitleBuilder {
|
|
12
12
|
private segmentSeparator;
|
package/dist/dts/view.d.ts
CHANGED
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import { ComposableStyles, ExecutionContext, ViewTemplate } from "@microsoft/fast-element";
|
|
2
2
|
import { Router } from "./router.js";
|
|
3
3
|
/**
|
|
4
|
-
* @
|
|
4
|
+
* @beta
|
|
5
5
|
*/
|
|
6
6
|
export declare type RouterExecutionContext = ExecutionContext & {
|
|
7
|
-
router
|
|
7
|
+
router?: Router;
|
|
8
8
|
};
|
|
9
9
|
/**
|
|
10
|
-
* @
|
|
11
|
-
*/
|
|
12
|
-
export declare const RouterExecutionContext: Readonly<{
|
|
13
|
-
create(router: Router): any;
|
|
14
|
-
}>;
|
|
15
|
-
/**
|
|
16
|
-
* @alpha
|
|
10
|
+
* @beta
|
|
17
11
|
*/
|
|
18
12
|
export interface RouteView {
|
|
19
|
-
|
|
13
|
+
context: RouterExecutionContext;
|
|
14
|
+
bind(allTypedParams: Readonly<Record<string, any>>): void;
|
|
20
15
|
appendTo(host: HTMLElement): void;
|
|
21
16
|
dispose(): void;
|
|
22
17
|
}
|
|
23
18
|
/**
|
|
24
|
-
* @
|
|
19
|
+
* @beta
|
|
25
20
|
*/
|
|
26
21
|
export interface Transition {
|
|
27
22
|
begin(host: HTMLElement, prev: RouteView | null, next: RouteView): Promise<void>;
|
|
@@ -29,32 +24,32 @@ export interface Transition {
|
|
|
29
24
|
commit(host: HTMLElement, prev: RouteView | null, next: RouteView): Promise<void>;
|
|
30
25
|
}
|
|
31
26
|
/**
|
|
32
|
-
* @
|
|
27
|
+
* @beta
|
|
33
28
|
*/
|
|
34
29
|
export declare const Transition: Readonly<{
|
|
35
30
|
default: Readonly<Transition>;
|
|
36
31
|
}>;
|
|
37
32
|
/**
|
|
38
|
-
* @
|
|
33
|
+
* @beta
|
|
39
34
|
*/
|
|
40
35
|
export interface Layout {
|
|
41
36
|
beforeCommit(routerElement: HTMLElement): Promise<void>;
|
|
42
37
|
afterCommit(routerElement: HTMLElement): Promise<void>;
|
|
43
38
|
}
|
|
44
39
|
/**
|
|
45
|
-
* @
|
|
40
|
+
* @beta
|
|
46
41
|
*/
|
|
47
42
|
export declare class FASTElementLayout implements Layout {
|
|
48
43
|
private readonly template;
|
|
49
44
|
private runBeforeCommit;
|
|
50
45
|
private styles;
|
|
51
|
-
constructor(template?: ViewTemplate | null, styles?: ComposableStyles | ComposableStyles[] |
|
|
46
|
+
constructor(template?: ViewTemplate | null, styles?: ComposableStyles | ComposableStyles[] | undefined, runBeforeCommit?: boolean);
|
|
52
47
|
beforeCommit(routerElement: HTMLElement): Promise<void>;
|
|
53
48
|
afterCommit(routerElement: HTMLElement): Promise<void>;
|
|
54
49
|
private apply;
|
|
55
50
|
}
|
|
56
51
|
/**
|
|
57
|
-
* @
|
|
52
|
+
* @beta
|
|
58
53
|
*/
|
|
59
54
|
export declare const Layout: Readonly<{
|
|
60
55
|
default: Readonly<Layout>;
|
package/dist/esm/commands.js
CHANGED
|
@@ -4,7 +4,7 @@ import { FASTElementLayout } from "./view.js";
|
|
|
4
4
|
import { Route } from "./navigation.js";
|
|
5
5
|
import { navigationContributor } from "./contributors.js";
|
|
6
6
|
/**
|
|
7
|
-
* @
|
|
7
|
+
* @beta
|
|
8
8
|
*/
|
|
9
9
|
export class Ignore {
|
|
10
10
|
createContributor() {
|
|
@@ -20,7 +20,7 @@ export class Ignore {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
* @
|
|
23
|
+
* @beta
|
|
24
24
|
*/
|
|
25
25
|
export class Redirect {
|
|
26
26
|
constructor(redirect) {
|
|
@@ -51,9 +51,11 @@ function factoryFromElementName(name) {
|
|
|
51
51
|
function factoryFromElementInstance(element) {
|
|
52
52
|
const fragment = document.createDocumentFragment();
|
|
53
53
|
fragment.appendChild(element);
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
]
|
|
54
|
+
const factory = navigationContributor();
|
|
55
|
+
factory.nodeId = "h";
|
|
56
|
+
const view = new HTMLView(fragment, [factory], {
|
|
57
|
+
[factory.nodeId]: element,
|
|
58
|
+
});
|
|
57
59
|
return {
|
|
58
60
|
create() {
|
|
59
61
|
return view;
|
|
@@ -86,7 +88,7 @@ class RenderContributor {
|
|
|
86
88
|
}
|
|
87
89
|
}
|
|
88
90
|
/**
|
|
89
|
-
* @
|
|
91
|
+
* @beta
|
|
90
92
|
*/
|
|
91
93
|
export class Render {
|
|
92
94
|
constructor(owner, createView) {
|
|
@@ -134,7 +136,7 @@ export class Render {
|
|
|
134
136
|
else if (typeof element === "function") {
|
|
135
137
|
// Do not cache it becase the function could return
|
|
136
138
|
// a different value each time.
|
|
137
|
-
let def = FASTElementDefinition.
|
|
139
|
+
let def = FASTElementDefinition.getByType(element);
|
|
138
140
|
if (def) {
|
|
139
141
|
factory = factoryFromElementName(def.name);
|
|
140
142
|
}
|
|
@@ -147,7 +149,7 @@ export class Render {
|
|
|
147
149
|
factory = factoryFromElementInstance(element);
|
|
148
150
|
}
|
|
149
151
|
else {
|
|
150
|
-
def = FASTElementDefinition.
|
|
152
|
+
def = FASTElementDefinition.getByType(element);
|
|
151
153
|
if (def) {
|
|
152
154
|
factory = factoryFromElementName(def.name);
|
|
153
155
|
}
|
|
@@ -9,7 +9,7 @@ import { DefaultRoutingEventSink } from "./events.js";
|
|
|
9
9
|
import { isNavigationPhaseContributor } from "./contributors.js";
|
|
10
10
|
import { DefaultRouteRecognizer } from "./recognizer.js";
|
|
11
11
|
/**
|
|
12
|
-
* @
|
|
12
|
+
* @beta
|
|
13
13
|
*/
|
|
14
14
|
export class RouterConfiguration {
|
|
15
15
|
constructor() {
|
package/dist/esm/contributors.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HTMLDirective, Markup, } from "@microsoft/fast-element";
|
|
2
2
|
import { Router } from "./router.js";
|
|
3
3
|
/**
|
|
4
|
-
* @
|
|
4
|
+
* @beta
|
|
5
5
|
*/
|
|
6
6
|
export function isNavigationPhaseContributor(object, phase) {
|
|
7
7
|
return phase in object;
|
|
@@ -10,45 +10,49 @@ const defaultOptions = {
|
|
|
10
10
|
lifecycle: true,
|
|
11
11
|
parameters: true,
|
|
12
12
|
};
|
|
13
|
-
class NavigationContributorDirective
|
|
13
|
+
class NavigationContributorDirective {
|
|
14
14
|
constructor(options) {
|
|
15
|
-
super();
|
|
16
15
|
this.options = options;
|
|
17
16
|
}
|
|
18
|
-
|
|
19
|
-
return
|
|
17
|
+
createHTML(add) {
|
|
18
|
+
return Markup.attribute(add(this));
|
|
20
19
|
}
|
|
21
|
-
createBehavior(
|
|
22
|
-
return new NavigationContributorBehavior(
|
|
20
|
+
createBehavior() {
|
|
21
|
+
return new NavigationContributorBehavior(this);
|
|
23
22
|
}
|
|
24
23
|
}
|
|
24
|
+
HTMLDirective.define(NavigationContributorDirective);
|
|
25
25
|
class NavigationContributorBehavior {
|
|
26
|
-
constructor(
|
|
27
|
-
this.
|
|
28
|
-
this.options = options;
|
|
26
|
+
constructor(directive) {
|
|
27
|
+
this.directive = directive;
|
|
29
28
|
this.router = null;
|
|
30
29
|
}
|
|
31
|
-
bind(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
bind(controller) {
|
|
31
|
+
var _a;
|
|
32
|
+
const context = controller.context;
|
|
33
|
+
const options = this.directive.options;
|
|
34
|
+
this.contributor = controller.targets[this.directive.nodeId];
|
|
35
|
+
if (options.lifecycle) {
|
|
36
|
+
this.router = (_a = context.router) !== null && _a !== void 0 ? _a : Router.find(this.contributor);
|
|
37
|
+
if (this.router) {
|
|
38
|
+
this.router.addContributor(this.contributor);
|
|
39
|
+
controller.onUnbind(this);
|
|
40
|
+
}
|
|
35
41
|
}
|
|
36
|
-
if (
|
|
42
|
+
if (options.parameters) {
|
|
37
43
|
const contributor = this.contributor;
|
|
38
|
-
const routeParams = source;
|
|
44
|
+
const routeParams = controller.source;
|
|
39
45
|
for (const key in routeParams) {
|
|
40
46
|
contributor[key] = routeParams[key];
|
|
41
47
|
}
|
|
42
48
|
}
|
|
43
49
|
}
|
|
44
50
|
unbind(source) {
|
|
45
|
-
|
|
46
|
-
this.router.removeContributor(this.contributor);
|
|
47
|
-
}
|
|
51
|
+
this.router.removeContributor(this.contributor);
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
54
|
/**
|
|
51
|
-
* @
|
|
55
|
+
* @beta
|
|
52
56
|
*/
|
|
53
57
|
export function navigationContributor(options) {
|
|
54
58
|
return new NavigationContributorDirective(Object.assign({}, defaultOptions, options));
|
package/dist/esm/events.js
CHANGED
package/dist/esm/fast-router.js
CHANGED
package/dist/esm/links.js
CHANGED
package/dist/esm/navigation.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
import { Router } from "./router.js";
|
|
3
3
|
/**
|
|
4
|
-
* @
|
|
4
|
+
* @beta
|
|
5
5
|
*/
|
|
6
6
|
export class NavigationMessage {
|
|
7
7
|
constructor(path) {
|
|
@@ -10,7 +10,7 @@ export class NavigationMessage {
|
|
|
10
10
|
}
|
|
11
11
|
const handlers = new Set();
|
|
12
12
|
/**
|
|
13
|
-
* @
|
|
13
|
+
* @beta
|
|
14
14
|
*/
|
|
15
15
|
export const NavigationHandler = Object.freeze({
|
|
16
16
|
register(handler) {
|
|
@@ -25,7 +25,7 @@ export const NavigationHandler = Object.freeze({
|
|
|
25
25
|
// See http://www.ietf.org/rfc/rfc2396.txt section 3.1 for valid scheme format
|
|
26
26
|
const absoluteUrl = /^([a-z][a-z0-9+\-.]*:)?\/\//i;
|
|
27
27
|
/**
|
|
28
|
-
* @
|
|
28
|
+
* @beta
|
|
29
29
|
*/
|
|
30
30
|
export const Route = Object.freeze({
|
|
31
31
|
path: Object.freeze({
|
|
@@ -113,7 +113,7 @@ export const Route = Object.freeze({
|
|
|
113
113
|
}),
|
|
114
114
|
});
|
|
115
115
|
/**
|
|
116
|
-
* @
|
|
116
|
+
* @beta
|
|
117
117
|
*/
|
|
118
118
|
export class DefaultNavigationQueue {
|
|
119
119
|
constructor() {
|
package/dist/esm/process.js
CHANGED