@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
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,19 +1,19 @@
|
|
|
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
7
|
router: Router;
|
|
8
8
|
};
|
|
9
9
|
/**
|
|
10
|
-
* @
|
|
10
|
+
* @beta
|
|
11
11
|
*/
|
|
12
12
|
export declare const RouterExecutionContext: Readonly<{
|
|
13
13
|
create(router: Router): any;
|
|
14
14
|
}>;
|
|
15
15
|
/**
|
|
16
|
-
* @
|
|
16
|
+
* @beta
|
|
17
17
|
*/
|
|
18
18
|
export interface RouteView {
|
|
19
19
|
bind(allTypedParams: Readonly<Record<string, any>>, context: RouterExecutionContext): void;
|
|
@@ -21,7 +21,7 @@ export interface RouteView {
|
|
|
21
21
|
dispose(): void;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* @
|
|
24
|
+
* @beta
|
|
25
25
|
*/
|
|
26
26
|
export interface Transition {
|
|
27
27
|
begin(host: HTMLElement, prev: RouteView | null, next: RouteView): Promise<void>;
|
|
@@ -29,20 +29,20 @@ export interface Transition {
|
|
|
29
29
|
commit(host: HTMLElement, prev: RouteView | null, next: RouteView): Promise<void>;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
|
-
* @
|
|
32
|
+
* @beta
|
|
33
33
|
*/
|
|
34
34
|
export declare const Transition: Readonly<{
|
|
35
35
|
default: Readonly<Transition>;
|
|
36
36
|
}>;
|
|
37
37
|
/**
|
|
38
|
-
* @
|
|
38
|
+
* @beta
|
|
39
39
|
*/
|
|
40
40
|
export interface Layout {
|
|
41
41
|
beforeCommit(routerElement: HTMLElement): Promise<void>;
|
|
42
42
|
afterCommit(routerElement: HTMLElement): Promise<void>;
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
|
-
* @
|
|
45
|
+
* @beta
|
|
46
46
|
*/
|
|
47
47
|
export declare class FASTElementLayout implements Layout {
|
|
48
48
|
private readonly template;
|
|
@@ -54,7 +54,7 @@ export declare class FASTElementLayout implements Layout {
|
|
|
54
54
|
private apply;
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
|
-
* @
|
|
57
|
+
* @beta
|
|
58
58
|
*/
|
|
59
59
|
export declare const Layout: Readonly<{
|
|
60
60
|
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,18 +10,18 @@ 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(targets) {
|
|
21
|
+
return new NavigationContributorBehavior(targets[this.nodeId], this.options);
|
|
23
22
|
}
|
|
24
23
|
}
|
|
24
|
+
HTMLDirective.define(NavigationContributorDirective);
|
|
25
25
|
class NavigationContributorBehavior {
|
|
26
26
|
constructor(contributor, options) {
|
|
27
27
|
this.contributor = contributor;
|
|
@@ -48,7 +48,7 @@ class NavigationContributorBehavior {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
|
-
* @
|
|
51
|
+
* @beta
|
|
52
52
|
*/
|
|
53
53
|
export function navigationContributor(options) {
|
|
54
54
|
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
package/dist/esm/query-string.js
CHANGED
package/dist/esm/recognizer.js
CHANGED
|
@@ -2,7 +2,7 @@ import { __awaiter } from "tslib";
|
|
|
2
2
|
import { QueryString } from "./query-string.js";
|
|
3
3
|
const defaultParameterConverter = (value) => value;
|
|
4
4
|
/**
|
|
5
|
-
* @
|
|
5
|
+
* @beta
|
|
6
6
|
*/
|
|
7
7
|
export class ConfigurableRoute {
|
|
8
8
|
constructor(path, name, caseSensitive) {
|
|
@@ -12,7 +12,7 @@ export class ConfigurableRoute {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* @
|
|
15
|
+
* @beta
|
|
16
16
|
*/
|
|
17
17
|
export class Endpoint {
|
|
18
18
|
constructor(route, paramNames, paramTypes, settings) {
|
|
@@ -26,7 +26,7 @@ export class Endpoint {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
* @
|
|
29
|
+
* @beta
|
|
30
30
|
*/
|
|
31
31
|
export class RecognizedRoute {
|
|
32
32
|
constructor(endpoint, params, typedParams, queryParams) {
|
|
@@ -279,7 +279,7 @@ class RecognizeResult {
|
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
281
|
/**
|
|
282
|
-
* @
|
|
282
|
+
* @beta
|
|
283
283
|
*/
|
|
284
284
|
export class DefaultRouteRecognizer {
|
|
285
285
|
constructor() {
|
|
@@ -458,19 +458,19 @@ class State {
|
|
|
458
458
|
this.nextStates = null;
|
|
459
459
|
this.endpoint = null;
|
|
460
460
|
switch (segment === null || segment === void 0 ? void 0 : segment.kind) {
|
|
461
|
-
case 2 /* dynamic */:
|
|
461
|
+
case 2 /* SegmentKind.dynamic */:
|
|
462
462
|
this.length = prevState.length + 1;
|
|
463
463
|
this.isSeparator = false;
|
|
464
464
|
this.isDynamic = true;
|
|
465
465
|
this.isOptional = segment.optional;
|
|
466
466
|
break;
|
|
467
|
-
case 1 /* star */:
|
|
467
|
+
case 1 /* SegmentKind.star */:
|
|
468
468
|
this.length = prevState.length + 1;
|
|
469
469
|
this.isSeparator = false;
|
|
470
470
|
this.isDynamic = true;
|
|
471
471
|
this.isOptional = false;
|
|
472
472
|
break;
|
|
473
|
-
case 3 /* static */:
|
|
473
|
+
case 3 /* SegmentKind.static */:
|
|
474
474
|
this.length = prevState.length + 1;
|
|
475
475
|
this.isSeparator = false;
|
|
476
476
|
this.isDynamic = false;
|
|
@@ -517,11 +517,11 @@ class State {
|
|
|
517
517
|
isMatch(ch) {
|
|
518
518
|
const segment = this.segment;
|
|
519
519
|
switch (segment === null || segment === void 0 ? void 0 : segment.kind) {
|
|
520
|
-
case 2 /* dynamic */:
|
|
520
|
+
case 2 /* SegmentKind.dynamic */:
|
|
521
521
|
return !this.value.includes(ch);
|
|
522
|
-
case 1 /* star */:
|
|
522
|
+
case 1 /* SegmentKind.star */:
|
|
523
523
|
return true;
|
|
524
|
-
case 3 /* static */:
|
|
524
|
+
case 3 /* SegmentKind.static */:
|
|
525
525
|
case undefined:
|
|
526
526
|
// segment separators (slashes) are non-segments. We could say return ch === '/' as well, technically.
|
|
527
527
|
return this.value.includes(ch);
|
|
@@ -537,7 +537,7 @@ class StaticSegment {
|
|
|
537
537
|
this.caseSensitive = caseSensitive;
|
|
538
538
|
}
|
|
539
539
|
get kind() {
|
|
540
|
-
return 3 /* static */;
|
|
540
|
+
return 3 /* SegmentKind.static */;
|
|
541
541
|
}
|
|
542
542
|
appendTo(state) {
|
|
543
543
|
const { value, value: { length }, } = this;
|
|
@@ -560,7 +560,7 @@ class StaticSegment {
|
|
|
560
560
|
return this.value;
|
|
561
561
|
}
|
|
562
562
|
equals(b) {
|
|
563
|
-
return (b.kind === 3 /* static */ &&
|
|
563
|
+
return (b.kind === 3 /* SegmentKind.static */ &&
|
|
564
564
|
b.caseSensitive === this.caseSensitive &&
|
|
565
565
|
b.value === this.value);
|
|
566
566
|
}
|
|
@@ -571,7 +571,7 @@ class DynamicSegment {
|
|
|
571
571
|
this.optional = optional;
|
|
572
572
|
}
|
|
573
573
|
get kind() {
|
|
574
|
-
return 2 /* dynamic */;
|
|
574
|
+
return 2 /* SegmentKind.dynamic */;
|
|
575
575
|
}
|
|
576
576
|
appendTo(state) {
|
|
577
577
|
state = state.append(/* segment */ this, /* value */ "/");
|
|
@@ -582,7 +582,7 @@ class DynamicSegment {
|
|
|
582
582
|
return params[this.name];
|
|
583
583
|
}
|
|
584
584
|
equals(b) {
|
|
585
|
-
return (b.kind === 2 /* dynamic */ &&
|
|
585
|
+
return (b.kind === 2 /* SegmentKind.dynamic */ &&
|
|
586
586
|
b.optional === this.optional &&
|
|
587
587
|
b.name === this.name);
|
|
588
588
|
}
|
|
@@ -592,7 +592,7 @@ class StarSegment {
|
|
|
592
592
|
this.name = name;
|
|
593
593
|
}
|
|
594
594
|
get kind() {
|
|
595
|
-
return 1 /* star */;
|
|
595
|
+
return 1 /* SegmentKind.star */;
|
|
596
596
|
}
|
|
597
597
|
appendTo(state) {
|
|
598
598
|
state = state.append(/* segment */ this, /* value */ "");
|
|
@@ -603,6 +603,6 @@ class StarSegment {
|
|
|
603
603
|
return params[this.name];
|
|
604
604
|
}
|
|
605
605
|
equals(b) {
|
|
606
|
-
return b.kind === 1 /* star */ && b.name === this.name;
|
|
606
|
+
return b.kind === 1 /* SegmentKind.star */ && b.name === this.name;
|
|
607
607
|
}
|
|
608
608
|
}
|
package/dist/esm/router.js
CHANGED
|
@@ -1,25 +1,10 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
import { FASTElement } from "@microsoft/fast-element";
|
|
3
|
+
import { composedParent } from "@microsoft/fast-element/utilities";
|
|
3
4
|
import { NavigationMessage } from "./navigation.js";
|
|
4
5
|
import { childRouteParameter } from "./routes.js";
|
|
5
6
|
import { RouterExecutionContext } from "./view.js";
|
|
6
7
|
const routerProperty = "$router";
|
|
7
|
-
// TODO: remove this from here and from fast-foundation
|
|
8
|
-
// TODO: move this to fast-element so router and foundation can both use it
|
|
9
|
-
function composedParent(element) {
|
|
10
|
-
const parentNode = element.parentElement;
|
|
11
|
-
if (parentNode) {
|
|
12
|
-
return parentNode;
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
const rootNode = element.getRootNode();
|
|
16
|
-
if (rootNode.host instanceof HTMLElement) {
|
|
17
|
-
// this is shadow-root
|
|
18
|
-
return rootNode.host;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
8
|
function findParentRouterForElement(element) {
|
|
24
9
|
let parent = element;
|
|
25
10
|
while ((parent = composedParent(parent))) {
|
|
@@ -30,7 +15,7 @@ function findParentRouterForElement(element) {
|
|
|
30
15
|
return null;
|
|
31
16
|
}
|
|
32
17
|
/**
|
|
33
|
-
* @
|
|
18
|
+
* @beta
|
|
34
19
|
*/
|
|
35
20
|
export const Router = Object.freeze({
|
|
36
21
|
getOrCreateFor(element) {
|
|
@@ -85,13 +70,13 @@ export const Router = Object.freeze({
|
|
|
85
70
|
},
|
|
86
71
|
});
|
|
87
72
|
/**
|
|
88
|
-
* @
|
|
73
|
+
* @beta
|
|
89
74
|
*/
|
|
90
75
|
export function isFASTElementHost(host) {
|
|
91
76
|
return host instanceof FASTElement;
|
|
92
77
|
}
|
|
93
78
|
/**
|
|
94
|
-
* @
|
|
79
|
+
* @beta
|
|
95
80
|
*/
|
|
96
81
|
export class DefaultRouter {
|
|
97
82
|
constructor(host) {
|
package/dist/esm/routes.js
CHANGED
package/dist/esm/titles.js
CHANGED
package/dist/esm/view.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import {
|
|
2
|
+
import { ElementStyles, ExecutionContext, html, } from "@microsoft/fast-element";
|
|
3
3
|
import { isFASTElementHost } from "./router.js";
|
|
4
4
|
/**
|
|
5
|
-
* @
|
|
5
|
+
* @beta
|
|
6
6
|
*/
|
|
7
7
|
export const RouterExecutionContext = Object.freeze({
|
|
8
8
|
create(router) {
|
|
9
|
-
return Object.create(
|
|
9
|
+
return Object.create(ExecutionContext.default, {
|
|
10
10
|
router: {
|
|
11
11
|
value: router,
|
|
12
12
|
},
|
|
@@ -14,7 +14,7 @@ export const RouterExecutionContext = Object.freeze({
|
|
|
14
14
|
},
|
|
15
15
|
});
|
|
16
16
|
/**
|
|
17
|
-
* @
|
|
17
|
+
* @beta
|
|
18
18
|
*/
|
|
19
19
|
export const Transition = Object.freeze({
|
|
20
20
|
default: Object.freeze({
|
|
@@ -30,7 +30,7 @@ export const Transition = Object.freeze({
|
|
|
30
30
|
}),
|
|
31
31
|
});
|
|
32
32
|
/**
|
|
33
|
-
* @
|
|
33
|
+
* @beta
|
|
34
34
|
*/
|
|
35
35
|
export class FASTElementLayout {
|
|
36
36
|
constructor(template = null, styles = null, runBeforeCommit = true) {
|
|
@@ -40,10 +40,10 @@ export class FASTElementLayout {
|
|
|
40
40
|
styles === void 0 || styles === null
|
|
41
41
|
? null
|
|
42
42
|
: Array.isArray(styles)
|
|
43
|
-
? ElementStyles
|
|
43
|
+
? new ElementStyles(styles)
|
|
44
44
|
: styles instanceof ElementStyles
|
|
45
45
|
? styles
|
|
46
|
-
: ElementStyles
|
|
46
|
+
: new ElementStyles([styles]);
|
|
47
47
|
}
|
|
48
48
|
beforeCommit(routerElement) {
|
|
49
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -71,7 +71,7 @@ export class FASTElementLayout {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
|
-
* @
|
|
74
|
+
* @beta
|
|
75
75
|
*/
|
|
76
76
|
export const Layout = Object.freeze({
|
|
77
77
|
default: new FASTElementLayout(html `
|