@microsoft/fast-router 1.0.0-alpha.2 → 1.0.0-alpha.20

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.
@@ -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 { HTMLDirective } from '@microsoft/fast-element';
8
- import { ViewBehaviorTargets } from '@microsoft/fast-element';
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
  /* Excluded from this release type: childRouteParameter */
@@ -38,13 +38,6 @@ export declare type ContributorOptions = {
38
38
  parameters?: boolean;
39
39
  };
40
40
 
41
- /**
42
- * @beta
43
- */
44
- export declare type ConverterObject = {
45
- convert: RouteParameterConverter;
46
- };
47
-
48
41
  /**
49
42
  * @beta
50
43
  */
@@ -199,7 +192,7 @@ export declare class FASTElementLayout implements Layout {
199
192
  private readonly template;
200
193
  private runBeforeCommit;
201
194
  private styles;
202
- constructor(template?: ViewTemplate | null, styles?: ComposableStyles | ComposableStyles[] | null, runBeforeCommit?: boolean);
195
+ constructor(template?: ViewTemplate | null, styles?: ComposableStyles | ComposableStyles[] | undefined, runBeforeCommit?: boolean);
203
196
  beforeCommit(routerElement: HTMLElement): Promise<void>;
204
197
  afterCommit(routerElement: HTMLElement): Promise<void>;
205
198
  private apply;
@@ -319,7 +312,7 @@ export declare interface NavigationCommand {
319
312
  * @beta
320
313
  */
321
314
  export declare interface NavigationCommitPhase<TSettings = any> extends Omit<NavigationPhase<TSettings>, "cancel" | "canceled" | "onCancel"> {
322
- setTitle(title: string): any;
315
+ setTitle(title: string): void;
323
316
  }
324
317
 
325
318
  /**
@@ -339,22 +332,21 @@ export declare type NavigationContributor<TSettings = any> = Partial<Record<Excl
339
332
  */
340
333
  export declare function navigationContributor(options?: ContributorOptions): NavigationContributorDirective;
341
334
 
342
- declare class NavigationContributorBehavior implements Behavior {
343
- private contributor;
344
- private options;
335
+ declare class NavigationContributorBehavior implements ViewBehavior {
336
+ private directive;
345
337
  private router;
346
- constructor(contributor: HTMLElement & NavigationContributor, options: Required<ContributorOptions>);
347
- bind(source: unknown, context: RouterExecutionContext): void;
338
+ private contributor;
339
+ constructor(directive: NavigationContributorDirective);
340
+ bind(controller: ViewController): void;
348
341
  unbind(source: unknown): void;
349
342
  }
350
343
 
351
- declare class NavigationContributorDirective implements HTMLDirective {
352
- private options;
353
- id: string;
354
- nodeId: string;
344
+ declare class NavigationContributorDirective implements ViewBehaviorFactory {
345
+ readonly options: Required<ContributorOptions>;
346
+ targetNodeId: string;
355
347
  constructor(options: Required<ContributorOptions>);
356
348
  createHTML(add: AddViewBehaviorFactory): string;
357
- createBehavior(targets: ViewBehaviorTargets): NavigationContributorBehavior;
349
+ createBehavior(): NavigationContributorBehavior;
358
350
  }
359
351
 
360
352
  /**
@@ -446,7 +438,7 @@ export declare interface NavigationQueue {
446
438
  /**
447
439
  * @beta
448
440
  */
449
- export declare type ParameterConverter = RouteParameterConverter | ConverterObject | Constructable<ConverterObject>;
441
+ export declare type ParameterConverter = RouteParameterConverter | RouteParameterConverterObject | Constructable<RouteParameterConverterObject>;
450
442
 
451
443
  /**
452
444
  * @beta
@@ -472,7 +464,7 @@ export declare const QueryString: Readonly<{
472
464
  * @param traditional - Boolean Use the old URI template standard (RFC6570)
473
465
  * @returns The generated query string, excluding leading '?'.
474
466
  */
475
- build(params: Object, traditional?: boolean): string;
467
+ build(params: Record<string, string>, traditional?: boolean): string;
476
468
  /**
477
469
  * Separate the query string from the path and returns the two parts.
478
470
  * @param path - The path to separate.
@@ -649,7 +641,24 @@ export declare type RouteMatch<TSettings = any> = {
649
641
  /**
650
642
  * @beta
651
643
  */
652
- export declare type RouteParameterConverter = (value: string | undefined) => any | Promise<any>;
644
+ export declare type RouteParameterConverter = (name: string, value: string | undefined, context: RouteParameterConverterContext) => any | Promise<any>;
645
+
646
+ /**
647
+ * @beta
648
+ */
649
+ export declare interface RouteParameterConverterContext<TSettings = any> {
650
+ readonly endpoint: Endpoint<TSettings>;
651
+ readonly params: Readonly<Record<string, string | undefined>>;
652
+ readonly typedParams: Record<string, any>;
653
+ readonly queryParams: Record<string, string>;
654
+ }
655
+
656
+ /**
657
+ * @beta
658
+ */
659
+ export declare type RouteParameterConverterObject = {
660
+ convert: RouteParameterConverter;
661
+ };
653
662
 
654
663
  /**
655
664
  * @beta
@@ -738,31 +747,25 @@ export declare interface RouteRecognizer<TSettings> {
738
747
  export declare interface RouterElement extends HTMLElement {
739
748
  readonly [routerProperty]: Router;
740
749
  config: RouterConfiguration | null;
741
- connectedCallback(): any;
742
- disconnectedCallback(): any;
750
+ connectedCallback(): void;
751
+ disconnectedCallback(): void;
743
752
  }
744
753
 
745
754
  /**
746
755
  * @beta
747
756
  */
748
757
  export declare type RouterExecutionContext = ExecutionContext & {
749
- router: Router;
758
+ router?: Router;
750
759
  };
751
760
 
752
- /**
753
- * @beta
754
- */
755
- export declare const RouterExecutionContext: Readonly<{
756
- create(router: Router): any;
757
- }>;
758
-
759
761
  declare const routerProperty = "$router";
760
762
 
761
763
  /**
762
764
  * @beta
763
765
  */
764
766
  export declare interface RouteView {
765
- bind(allTypedParams: Readonly<Record<string, any>>, context: RouterExecutionContext): void;
767
+ context: RouterExecutionContext;
768
+ bind(allTypedParams: Readonly<Record<string, any>>): void;
766
769
  appendTo(host: HTMLElement): void;
767
770
  dispose(): void;
768
771
  }
@@ -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 { HTMLDirective } from '@microsoft/fast-element';
8
- import { ViewBehaviorTargets } from '@microsoft/fast-element';
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[] | null, runBeforeCommit?: boolean);
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): any;
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 Behavior {
346
- private contributor;
347
- private options;
338
+ declare class NavigationContributorBehavior implements ViewBehavior {
339
+ private directive;
348
340
  private router;
349
- constructor(contributor: HTMLElement & NavigationContributor, options: Required<ContributorOptions>);
350
- bind(source: unknown, context: RouterExecutionContext): void;
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 HTMLDirective {
355
- private options;
356
- id: string;
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(targets: ViewBehaviorTargets): NavigationContributorBehavior;
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 | ConverterObject | Constructable<ConverterObject>;
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: Object, traditional?: boolean): string;
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(): any;
745
- disconnectedCallback(): any;
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: 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
- bind(allTypedParams: Readonly<Record<string, any>>, context: RouterExecutionContext): void;
770
+ context: RouterExecutionContext;
771
+ bind(allTypedParams: Readonly<Record<string, any>>): void;
769
772
  appendTo(host: HTMLElement): void;
770
773
  dispose(): void;
771
774
  }
@@ -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 { HTMLDirective } from '@microsoft/fast-element';
14
- import { ViewBehaviorTargets } from '@microsoft/fast-element';
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[] | null, runBeforeCommit?: boolean);
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): any;
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 | ConverterObject | Constructable<ConverterObject>;
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: Object, traditional?: boolean): string;
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(): any;
590
+ connectedCallback(): void;
579
591
  // (undocumented)
580
- disconnectedCallback(): any;
592
+ disconnectedCallback(): void;
581
593
  }
582
594
 
583
595
  // @beta (undocumented)
584
596
  export type RouterExecutionContext = ExecutionContext & {
585
- router: 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>>, context: RouterExecutionContext): void;
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.2",
5
+ "version": "1.0.0-alpha.20",
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": "^5.0.0",
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": "^5.0.4",
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.2"
83
+ "@microsoft/fast-element": "^2.0.0-beta.20"
84
84
  }
85
85
  }