@microsoft/fast-router 1.0.0-alpha.2 → 1.0.0-alpha.21
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/CHANGELOG.json +323 -0
- package/CHANGELOG.md +158 -1
- package/dist/dts/contributors.d.ts +10 -12
- package/dist/dts/phases.d.ts +1 -1
- package/dist/dts/query-string.d.ts +1 -1
- package/dist/dts/recognizer.d.ts +10 -1
- package/dist/dts/router.d.ts +2 -2
- package/dist/dts/routes.d.ts +2 -2
- package/dist/dts/view.d.ts +4 -9
- package/dist/esm/commands.js +5 -4
- package/dist/esm/contributors.js +18 -14
- package/dist/esm/recognizer.js +13 -6
- package/dist/esm/router.js +17 -10
- package/dist/esm/routes.js +8 -8
- package/dist/esm/view.js +6 -24
- package/dist/fast-router.api.json +255 -101
- package/dist/fast-router.d.ts +39 -36
- package/dist/fast-router.untrimmed.d.ts +39 -36
- package/docs/api-report.md +31 -22
- package/package.json +4 -4
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { AddViewBehaviorFactory } from '@microsoft/fast-element';
|
|
2
|
-
import { Behavior } from '@microsoft/fast-element';
|
|
3
2
|
import { ComposableStyles } from '@microsoft/fast-element';
|
|
4
3
|
import { Constructable } from '@microsoft/fast-element';
|
|
5
4
|
import { ExecutionContext } from '@microsoft/fast-element';
|
|
6
5
|
import { FASTElement } from '@microsoft/fast-element';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { ViewBehavior } from '@microsoft/fast-element';
|
|
7
|
+
import { ViewBehaviorFactory } from '@microsoft/fast-element';
|
|
8
|
+
import { ViewController } from '@microsoft/fast-element';
|
|
9
9
|
import { ViewTemplate } from '@microsoft/fast-element';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -41,13 +41,6 @@ export declare type ContributorOptions = {
|
|
|
41
41
|
parameters?: boolean;
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
/**
|
|
45
|
-
* @beta
|
|
46
|
-
*/
|
|
47
|
-
export declare type ConverterObject = {
|
|
48
|
-
convert: RouteParameterConverter;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
44
|
/**
|
|
52
45
|
* @beta
|
|
53
46
|
*/
|
|
@@ -202,7 +195,7 @@ export declare class FASTElementLayout implements Layout {
|
|
|
202
195
|
private readonly template;
|
|
203
196
|
private runBeforeCommit;
|
|
204
197
|
private styles;
|
|
205
|
-
constructor(template?: ViewTemplate | null, styles?: ComposableStyles | ComposableStyles[] |
|
|
198
|
+
constructor(template?: ViewTemplate | null, styles?: ComposableStyles | ComposableStyles[] | undefined, runBeforeCommit?: boolean);
|
|
206
199
|
beforeCommit(routerElement: HTMLElement): Promise<void>;
|
|
207
200
|
afterCommit(routerElement: HTMLElement): Promise<void>;
|
|
208
201
|
private apply;
|
|
@@ -322,7 +315,7 @@ export declare interface NavigationCommand {
|
|
|
322
315
|
* @beta
|
|
323
316
|
*/
|
|
324
317
|
export declare interface NavigationCommitPhase<TSettings = any> extends Omit<NavigationPhase<TSettings>, "cancel" | "canceled" | "onCancel"> {
|
|
325
|
-
setTitle(title: string):
|
|
318
|
+
setTitle(title: string): void;
|
|
326
319
|
}
|
|
327
320
|
|
|
328
321
|
/**
|
|
@@ -342,22 +335,21 @@ export declare type NavigationContributor<TSettings = any> = Partial<Record<Excl
|
|
|
342
335
|
*/
|
|
343
336
|
export declare function navigationContributor(options?: ContributorOptions): NavigationContributorDirective;
|
|
344
337
|
|
|
345
|
-
declare class NavigationContributorBehavior implements
|
|
346
|
-
private
|
|
347
|
-
private options;
|
|
338
|
+
declare class NavigationContributorBehavior implements ViewBehavior {
|
|
339
|
+
private directive;
|
|
348
340
|
private router;
|
|
349
|
-
|
|
350
|
-
|
|
341
|
+
private contributor;
|
|
342
|
+
constructor(directive: NavigationContributorDirective);
|
|
343
|
+
bind(controller: ViewController): void;
|
|
351
344
|
unbind(source: unknown): void;
|
|
352
345
|
}
|
|
353
346
|
|
|
354
|
-
declare class NavigationContributorDirective implements
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
nodeId: string;
|
|
347
|
+
declare class NavigationContributorDirective implements ViewBehaviorFactory {
|
|
348
|
+
readonly options: Required<ContributorOptions>;
|
|
349
|
+
targetNodeId: string;
|
|
358
350
|
constructor(options: Required<ContributorOptions>);
|
|
359
351
|
createHTML(add: AddViewBehaviorFactory): string;
|
|
360
|
-
createBehavior(
|
|
352
|
+
createBehavior(): NavigationContributorBehavior;
|
|
361
353
|
}
|
|
362
354
|
|
|
363
355
|
/**
|
|
@@ -449,7 +441,7 @@ export declare interface NavigationQueue {
|
|
|
449
441
|
/**
|
|
450
442
|
* @beta
|
|
451
443
|
*/
|
|
452
|
-
export declare type ParameterConverter = RouteParameterConverter |
|
|
444
|
+
export declare type ParameterConverter = RouteParameterConverter | RouteParameterConverterObject | Constructable<RouteParameterConverterObject>;
|
|
453
445
|
|
|
454
446
|
/**
|
|
455
447
|
* @beta
|
|
@@ -475,7 +467,7 @@ export declare const QueryString: Readonly<{
|
|
|
475
467
|
* @param traditional - Boolean Use the old URI template standard (RFC6570)
|
|
476
468
|
* @returns The generated query string, excluding leading '?'.
|
|
477
469
|
*/
|
|
478
|
-
build(params:
|
|
470
|
+
build(params: Record<string, string>, traditional?: boolean): string;
|
|
479
471
|
/**
|
|
480
472
|
* Separate the query string from the path and returns the two parts.
|
|
481
473
|
* @param path - The path to separate.
|
|
@@ -652,7 +644,24 @@ export declare type RouteMatch<TSettings = any> = {
|
|
|
652
644
|
/**
|
|
653
645
|
* @beta
|
|
654
646
|
*/
|
|
655
|
-
export declare type RouteParameterConverter = (value: string | undefined) => any | Promise<any>;
|
|
647
|
+
export declare type RouteParameterConverter = (name: string, value: string | undefined, context: RouteParameterConverterContext) => any | Promise<any>;
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* @beta
|
|
651
|
+
*/
|
|
652
|
+
export declare interface RouteParameterConverterContext<TSettings = any> {
|
|
653
|
+
readonly endpoint: Endpoint<TSettings>;
|
|
654
|
+
readonly params: Readonly<Record<string, string | undefined>>;
|
|
655
|
+
readonly typedParams: Record<string, any>;
|
|
656
|
+
readonly queryParams: Record<string, string>;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* @beta
|
|
661
|
+
*/
|
|
662
|
+
export declare type RouteParameterConverterObject = {
|
|
663
|
+
convert: RouteParameterConverter;
|
|
664
|
+
};
|
|
656
665
|
|
|
657
666
|
/**
|
|
658
667
|
* @beta
|
|
@@ -741,31 +750,25 @@ export declare interface RouteRecognizer<TSettings> {
|
|
|
741
750
|
export declare interface RouterElement extends HTMLElement {
|
|
742
751
|
readonly [routerProperty]: Router;
|
|
743
752
|
config: RouterConfiguration | null;
|
|
744
|
-
connectedCallback():
|
|
745
|
-
disconnectedCallback():
|
|
753
|
+
connectedCallback(): void;
|
|
754
|
+
disconnectedCallback(): void;
|
|
746
755
|
}
|
|
747
756
|
|
|
748
757
|
/**
|
|
749
758
|
* @beta
|
|
750
759
|
*/
|
|
751
760
|
export declare type RouterExecutionContext = ExecutionContext & {
|
|
752
|
-
router
|
|
761
|
+
router?: Router;
|
|
753
762
|
};
|
|
754
763
|
|
|
755
|
-
/**
|
|
756
|
-
* @beta
|
|
757
|
-
*/
|
|
758
|
-
export declare const RouterExecutionContext: Readonly<{
|
|
759
|
-
create(router: Router): any;
|
|
760
|
-
}>;
|
|
761
|
-
|
|
762
764
|
declare const routerProperty = "$router";
|
|
763
765
|
|
|
764
766
|
/**
|
|
765
767
|
* @beta
|
|
766
768
|
*/
|
|
767
769
|
export declare interface RouteView {
|
|
768
|
-
|
|
770
|
+
context: RouterExecutionContext;
|
|
771
|
+
bind(allTypedParams: Readonly<Record<string, any>>): void;
|
|
769
772
|
appendTo(host: HTMLElement): void;
|
|
770
773
|
dispose(): void;
|
|
771
774
|
}
|
package/docs/api-report.md
CHANGED
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
```ts
|
|
6
6
|
|
|
7
7
|
import { AddViewBehaviorFactory } from '@microsoft/fast-element';
|
|
8
|
-
import { Behavior } from '@microsoft/fast-element';
|
|
9
8
|
import { ComposableStyles } from '@microsoft/fast-element';
|
|
10
9
|
import { Constructable } from '@microsoft/fast-element';
|
|
11
10
|
import { ExecutionContext } from '@microsoft/fast-element';
|
|
12
11
|
import { FASTElement } from '@microsoft/fast-element';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
12
|
+
import { ViewBehavior } from '@microsoft/fast-element';
|
|
13
|
+
import { ViewBehaviorFactory } from '@microsoft/fast-element';
|
|
14
|
+
import { ViewController } from '@microsoft/fast-element';
|
|
15
15
|
import { ViewTemplate } from '@microsoft/fast-element';
|
|
16
16
|
|
|
17
17
|
// Warning: (ae-internal-missing-underscore) The name "childRouteParameter" should be prefixed with an underscore because the declaration is marked as @internal
|
|
@@ -42,11 +42,6 @@ export type ContributorOptions = {
|
|
|
42
42
|
parameters?: boolean;
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
// @beta (undocumented)
|
|
46
|
-
export type ConverterObject = {
|
|
47
|
-
convert: RouteParameterConverter;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
45
|
// @beta (undocumented)
|
|
51
46
|
export class DefaultLinkHandler implements LinkHandler {
|
|
52
47
|
// (undocumented)
|
|
@@ -152,7 +147,7 @@ export type FASTElementConstructor = new () => FASTElement;
|
|
|
152
147
|
|
|
153
148
|
// @beta (undocumented)
|
|
154
149
|
export class FASTElementLayout implements Layout {
|
|
155
|
-
constructor(template?: ViewTemplate | null, styles?: ComposableStyles | ComposableStyles[] |
|
|
150
|
+
constructor(template?: ViewTemplate | null, styles?: ComposableStyles | ComposableStyles[] | undefined, runBeforeCommit?: boolean);
|
|
156
151
|
// (undocumented)
|
|
157
152
|
afterCommit(routerElement: HTMLElement): Promise<void>;
|
|
158
153
|
// (undocumented)
|
|
@@ -246,7 +241,7 @@ export interface NavigationCommand {
|
|
|
246
241
|
// @beta (undocumented)
|
|
247
242
|
export interface NavigationCommitPhase<TSettings = any> extends Omit<NavigationPhase<TSettings>, "cancel" | "canceled" | "onCancel"> {
|
|
248
243
|
// (undocumented)
|
|
249
|
-
setTitle(title: string):
|
|
244
|
+
setTitle(title: string): void;
|
|
250
245
|
}
|
|
251
246
|
|
|
252
247
|
// @beta (undocumented)
|
|
@@ -327,7 +322,7 @@ export interface NavigationQueue {
|
|
|
327
322
|
}
|
|
328
323
|
|
|
329
324
|
// @beta (undocumented)
|
|
330
|
-
export type ParameterConverter = RouteParameterConverter |
|
|
325
|
+
export type ParameterConverter = RouteParameterConverter | RouteParameterConverterObject | Constructable<RouteParameterConverterObject>;
|
|
331
326
|
|
|
332
327
|
// @beta (undocumented)
|
|
333
328
|
export type ParentRouteDefinition<TSettings = any> = PathedRouteDefinition<TSettings> & LayoutAndTransitionRouteDefinition & {
|
|
@@ -340,7 +335,7 @@ export type PathedRouteDefinition<TSettings = any> = SupportsSettings<TSettings>
|
|
|
340
335
|
// @beta (undocumented)
|
|
341
336
|
export const QueryString: Readonly<{
|
|
342
337
|
readonly current: string;
|
|
343
|
-
build(params:
|
|
338
|
+
build(params: Record<string, string>, traditional?: boolean): string;
|
|
344
339
|
separate(path: string): Readonly<{
|
|
345
340
|
path: string;
|
|
346
341
|
queryString: string;
|
|
@@ -474,7 +469,24 @@ export type RouteMatch<TSettings = any> = {
|
|
|
474
469
|
};
|
|
475
470
|
|
|
476
471
|
// @beta (undocumented)
|
|
477
|
-
export type RouteParameterConverter = (value: string | undefined) => any | Promise<any>;
|
|
472
|
+
export type RouteParameterConverter = (name: string, value: string | undefined, context: RouteParameterConverterContext) => any | Promise<any>;
|
|
473
|
+
|
|
474
|
+
// @beta (undocumented)
|
|
475
|
+
export interface RouteParameterConverterContext<TSettings = any> {
|
|
476
|
+
// (undocumented)
|
|
477
|
+
readonly endpoint: Endpoint<TSettings>;
|
|
478
|
+
// (undocumented)
|
|
479
|
+
readonly params: Readonly<Record<string, string | undefined>>;
|
|
480
|
+
// (undocumented)
|
|
481
|
+
readonly queryParams: Record<string, string>;
|
|
482
|
+
// (undocumented)
|
|
483
|
+
readonly typedParams: Record<string, any>;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// @beta (undocumented)
|
|
487
|
+
export type RouteParameterConverterObject = {
|
|
488
|
+
convert: RouteParameterConverter;
|
|
489
|
+
};
|
|
478
490
|
|
|
479
491
|
// @beta (undocumented)
|
|
480
492
|
export interface Router<TSettings = any> {
|
|
@@ -575,27 +587,24 @@ export interface RouterElement extends HTMLElement {
|
|
|
575
587
|
// (undocumented)
|
|
576
588
|
config: RouterConfiguration | null;
|
|
577
589
|
// (undocumented)
|
|
578
|
-
connectedCallback():
|
|
590
|
+
connectedCallback(): void;
|
|
579
591
|
// (undocumented)
|
|
580
|
-
disconnectedCallback():
|
|
592
|
+
disconnectedCallback(): void;
|
|
581
593
|
}
|
|
582
594
|
|
|
583
595
|
// @beta (undocumented)
|
|
584
596
|
export type RouterExecutionContext = ExecutionContext & {
|
|
585
|
-
router
|
|
597
|
+
router?: Router;
|
|
586
598
|
};
|
|
587
599
|
|
|
588
|
-
// @beta (undocumented)
|
|
589
|
-
export const RouterExecutionContext: Readonly<{
|
|
590
|
-
create(router: Router): any;
|
|
591
|
-
}>;
|
|
592
|
-
|
|
593
600
|
// @beta (undocumented)
|
|
594
601
|
export interface RouteView {
|
|
595
602
|
// (undocumented)
|
|
596
603
|
appendTo(host: HTMLElement): void;
|
|
597
604
|
// (undocumented)
|
|
598
|
-
bind(allTypedParams: Readonly<Record<string, any
|
|
605
|
+
bind(allTypedParams: Readonly<Record<string, any>>): void;
|
|
606
|
+
// (undocumented)
|
|
607
|
+
context: RouterExecutionContext;
|
|
599
608
|
// (undocumented)
|
|
600
609
|
dispose(): void;
|
|
601
610
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@microsoft/fast-router",
|
|
3
3
|
"description": "A web-components-based router.",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "1.0.0-alpha.
|
|
5
|
+
"version": "1.0.0-alpha.21",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Microsoft",
|
|
8
8
|
"url": "https://discord.gg/FcSNfg4"
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@microsoft/api-extractor": "7.24.2",
|
|
50
50
|
"@types/chai": "^4.2.11",
|
|
51
|
-
"@types/karma": "^
|
|
51
|
+
"@types/karma": "^6.3.3",
|
|
52
52
|
"@types/mocha": "^7.0.2",
|
|
53
53
|
"@types/webpack-env": "^1.15.2",
|
|
54
54
|
"chai": "^4.2.0",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"istanbul-instrumenter-loader": "^3.0.1",
|
|
59
59
|
"jsdom": "^16.2.2",
|
|
60
60
|
"jsdom-global": "3.0.2",
|
|
61
|
-
"karma": "^
|
|
61
|
+
"karma": "^6.4.1",
|
|
62
62
|
"karma-chrome-launcher": "^3.1.0",
|
|
63
63
|
"karma-coverage": "^2.0.2",
|
|
64
64
|
"karma-coverage-istanbul-reporter": "^3.0.0",
|
|
@@ -80,6 +80,6 @@
|
|
|
80
80
|
"webpack-cli": "^4.9.2"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@microsoft/fast-element": "^2.0.0-beta.
|
|
83
|
+
"@microsoft/fast-element": "^2.0.0-beta.21"
|
|
84
84
|
}
|
|
85
85
|
}
|