@microsoft/fast-router 1.0.0-alpha.6 → 1.0.0-alpha.8

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 CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "@microsoft/fast-router",
3
3
  "entries": [
4
+ {
5
+ "date": "Tue, 27 Sep 2022 22:31:52 GMT",
6
+ "tag": "@microsoft/fast-router_v1.0.0-alpha.8",
7
+ "version": "1.0.0-alpha.8",
8
+ "comments": {
9
+ "prerelease": [
10
+ {
11
+ "author": "beachball",
12
+ "package": "@microsoft/fast-router",
13
+ "comment": "Bump @microsoft/fast-element to v2.0.0-beta.8",
14
+ "commit": "8834c6732c727d39f92f72b197388453a9c17f9b"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Fri, 23 Sep 2022 22:53:27 GMT",
21
+ "tag": "@microsoft/fast-router_v1.0.0-alpha.7",
22
+ "version": "1.0.0-alpha.7",
23
+ "comments": {
24
+ "prerelease": [
25
+ {
26
+ "author": "roeisenb@microsoft.com",
27
+ "package": "@microsoft/fast-router",
28
+ "commit": "2edd63a8abe24c68cfc7c76d773c912c6f2d6543",
29
+ "comment": "fix: update router to use the new behavior API"
30
+ },
31
+ {
32
+ "author": "beachball",
33
+ "package": "@microsoft/fast-router",
34
+ "comment": "Bump @microsoft/fast-element to v2.0.0-beta.7",
35
+ "commit": "1646b26450a08a77c8bd6302560fe12cc6989ae1"
36
+ }
37
+ ]
38
+ }
39
+ },
4
40
  {
5
41
  "date": "Thu, 01 Sep 2022 21:53:34 GMT",
6
42
  "tag": "@microsoft/fast-router_v1.0.0-alpha.6",
package/CHANGELOG.md CHANGED
@@ -1,9 +1,26 @@
1
1
  # Change Log - @microsoft/fast-router
2
2
 
3
- This log was last generated on Thu, 01 Sep 2022 21:53:34 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 27 Sep 2022 22:31:52 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 1.0.0-alpha.8
8
+
9
+ Tue, 27 Sep 2022 22:31:52 GMT
10
+
11
+ ### Changes
12
+
13
+ - Bump @microsoft/fast-element to v2.0.0-beta.8
14
+
15
+ ## 1.0.0-alpha.7
16
+
17
+ Fri, 23 Sep 2022 22:53:27 GMT
18
+
19
+ ### Changes
20
+
21
+ - fix: update router to use the new behavior API (roeisenb@microsoft.com)
22
+ - Bump @microsoft/fast-element to v2.0.0-beta.7
23
+
7
24
  ## 1.0.0-alpha.6
8
25
 
9
26
  Thu, 01 Sep 2022 21:53:34 GMT
@@ -1,6 +1,5 @@
1
- import { AddViewBehaviorFactory, Behavior, HTMLDirective, ViewBehaviorTargets } from "@microsoft/fast-element";
1
+ import { AddViewBehaviorFactory, ViewBehavior, ViewBehaviorFactory, ViewController } from "@microsoft/fast-element";
2
2
  import { NavigationCommitPhaseHook, NavigationPhaseHook, NavigationPhaseName } from "./phases.js";
3
- import { RouterExecutionContext } from "./view.js";
4
3
  /**
5
4
  * @beta
6
5
  */
@@ -18,20 +17,20 @@ export declare type ContributorOptions = {
18
17
  lifecycle?: boolean;
19
18
  parameters?: boolean;
20
19
  };
21
- declare class NavigationContributorDirective implements HTMLDirective {
22
- private options;
20
+ declare class NavigationContributorDirective implements ViewBehaviorFactory {
21
+ readonly options: Required<ContributorOptions>;
23
22
  id: string;
24
23
  nodeId: string;
25
24
  constructor(options: Required<ContributorOptions>);
26
25
  createHTML(add: AddViewBehaviorFactory): string;
27
- createBehavior(targets: ViewBehaviorTargets): NavigationContributorBehavior;
26
+ createBehavior(): NavigationContributorBehavior;
28
27
  }
29
- declare class NavigationContributorBehavior implements Behavior {
30
- private contributor;
31
- private options;
28
+ declare class NavigationContributorBehavior implements ViewBehavior {
29
+ private directive;
32
30
  private router;
33
- constructor(contributor: HTMLElement & NavigationContributor, options: Required<ContributorOptions>);
34
- bind(source: unknown, context: RouterExecutionContext): void;
31
+ private contributor;
32
+ constructor(directive: NavigationContributorDirective);
33
+ bind(controller: ViewController): void;
35
34
  unbind(source: unknown): void;
36
35
  }
37
36
  /**
@@ -4,19 +4,14 @@ import { Router } from "./router.js";
4
4
  * @beta
5
5
  */
6
6
  export declare type RouterExecutionContext = ExecutionContext & {
7
- router: Router;
7
+ router?: Router;
8
8
  };
9
- /**
10
- * @beta
11
- */
12
- export declare const RouterExecutionContext: Readonly<{
13
- create(router: Router): any;
14
- }>;
15
9
  /**
16
10
  * @beta
17
11
  */
18
12
  export interface RouteView {
19
- bind(allTypedParams: Readonly<Record<string, any>>, context: RouterExecutionContext): void;
13
+ context: RouterExecutionContext;
14
+ bind(allTypedParams: Readonly<Record<string, any>>): void;
20
15
  appendTo(host: HTMLElement): void;
21
16
  dispose(): void;
22
17
  }
@@ -17,34 +17,38 @@ class NavigationContributorDirective {
17
17
  createHTML(add) {
18
18
  return Markup.attribute(add(this));
19
19
  }
20
- createBehavior(targets) {
21
- return new NavigationContributorBehavior(targets[this.nodeId], this.options);
20
+ createBehavior() {
21
+ return new NavigationContributorBehavior(this);
22
22
  }
23
23
  }
24
24
  HTMLDirective.define(NavigationContributorDirective);
25
25
  class NavigationContributorBehavior {
26
- constructor(contributor, options) {
27
- this.contributor = contributor;
28
- this.options = options;
26
+ constructor(directive) {
27
+ this.directive = directive;
29
28
  this.router = null;
30
29
  }
31
- bind(source, context) {
32
- if (this.options.lifecycle) {
33
- this.router = context.router || Router.find(this.contributor);
34
- this.router.addContributor(this.contributor);
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 (this.options.parameters) {
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
- if (this.router !== null) {
46
- this.router.removeContributor(this.contributor);
47
- }
51
+ this.router.removeContributor(this.contributor);
48
52
  }
49
53
  }
50
54
  /**
@@ -3,7 +3,6 @@ import { FASTElement } from "@microsoft/fast-element";
3
3
  import { composedParent } from "@microsoft/fast-element/utilities";
4
4
  import { NavigationMessage } from "./navigation.js";
5
5
  import { childRouteParameter } from "./routes.js";
6
- import { RouterExecutionContext } from "./view.js";
7
6
  const routerProperty = "$router";
8
7
  function findParentRouterForElement(element) {
9
8
  let parent = element;
@@ -137,7 +136,8 @@ export class DefaultRouter {
137
136
  return __awaiter(this, void 0, void 0, function* () {
138
137
  this.newRoute = route;
139
138
  this.newView = yield command.createView();
140
- this.newView.bind(route.allTypedParams, RouterExecutionContext.create(this));
139
+ this.newView.context.router = this;
140
+ this.newView.bind(route.allTypedParams);
141
141
  this.newView.appendTo(this.host);
142
142
  yield command.transition.begin(this.host, this.view, this.newView);
143
143
  return {
package/dist/esm/view.js CHANGED
@@ -1,18 +1,6 @@
1
1
  import { __awaiter } from "tslib";
2
- import { ElementStyles, ExecutionContext, html, } from "@microsoft/fast-element";
2
+ import { ElementStyles, html, } from "@microsoft/fast-element";
3
3
  import { isFASTElementHost } from "./router.js";
4
- /**
5
- * @beta
6
- */
7
- export const RouterExecutionContext = Object.freeze({
8
- create(router) {
9
- return Object.create(ExecutionContext.default, {
10
- router: {
11
- value: router,
12
- },
13
- });
14
- },
15
- });
16
4
  /**
17
5
  * @beta
18
6
  */
@@ -58,8 +46,8 @@ export class FASTElementLayout {
58
46
  if (routerElement.$fastController.template !== this.template) {
59
47
  routerElement.$fastController.template = this.template;
60
48
  }
61
- if (routerElement.$fastController.styles !== this.styles) {
62
- routerElement.$fastController.styles = this.styles;
49
+ if (routerElement.$fastController.mainStyles !== this.styles) {
50
+ routerElement.$fastController.mainStyles = this.styles;
63
51
  }
64
52
  }
65
53
  }
@@ -9097,11 +9097,11 @@
9097
9097
  {
9098
9098
  "kind": "Reference",
9099
9099
  "text": "ExecutionContext",
9100
- "canonicalReference": "@microsoft/fast-element!ExecutionContext:class"
9100
+ "canonicalReference": "@microsoft/fast-element!ExecutionContext:interface"
9101
9101
  },
9102
9102
  {
9103
9103
  "kind": "Content",
9104
- "text": " & {\n router: "
9104
+ "text": " & {\n router?: "
9105
9105
  },
9106
9106
  {
9107
9107
  "kind": "Reference",
@@ -9124,41 +9124,6 @@
9124
9124
  "endIndex": 5
9125
9125
  }
9126
9126
  },
9127
- {
9128
- "kind": "Variable",
9129
- "canonicalReference": "@microsoft/fast-router!RouterExecutionContext:var",
9130
- "docComment": "/**\n * @beta\n */\n",
9131
- "excerptTokens": [
9132
- {
9133
- "kind": "Content",
9134
- "text": "RouterExecutionContext: "
9135
- },
9136
- {
9137
- "kind": "Reference",
9138
- "text": "Readonly",
9139
- "canonicalReference": "!Readonly:type"
9140
- },
9141
- {
9142
- "kind": "Content",
9143
- "text": "<{\n create(router: "
9144
- },
9145
- {
9146
- "kind": "Reference",
9147
- "text": "Router",
9148
- "canonicalReference": "@microsoft/fast-router!Router:interface"
9149
- },
9150
- {
9151
- "kind": "Content",
9152
- "text": "): any;\n}>"
9153
- }
9154
- ],
9155
- "releaseTag": "Beta",
9156
- "name": "RouterExecutionContext",
9157
- "variableTypeTokenRange": {
9158
- "startIndex": 1,
9159
- "endIndex": 5
9160
- }
9161
- },
9162
9127
  {
9163
9128
  "kind": "Interface",
9164
9129
  "canonicalReference": "@microsoft/fast-router!RouteView:interface",
@@ -9245,15 +9210,6 @@
9245
9210
  "kind": "Content",
9246
9211
  "text": "<string, any>>"
9247
9212
  },
9248
- {
9249
- "kind": "Content",
9250
- "text": ", context: "
9251
- },
9252
- {
9253
- "kind": "Reference",
9254
- "text": "RouterExecutionContext",
9255
- "canonicalReference": "@microsoft/fast-router!RouterExecutionContext:type"
9256
- },
9257
9213
  {
9258
9214
  "kind": "Content",
9259
9215
  "text": "): "
@@ -9269,8 +9225,8 @@
9269
9225
  ],
9270
9226
  "isOptional": false,
9271
9227
  "returnTypeTokenRange": {
9272
- "startIndex": 8,
9273
- "endIndex": 9
9228
+ "startIndex": 6,
9229
+ "endIndex": 7
9274
9230
  },
9275
9231
  "releaseTag": "Beta",
9276
9232
  "overloadIndex": 1,
@@ -9282,17 +9238,36 @@
9282
9238
  "endIndex": 5
9283
9239
  },
9284
9240
  "isOptional": false
9241
+ }
9242
+ ],
9243
+ "name": "bind"
9244
+ },
9245
+ {
9246
+ "kind": "PropertySignature",
9247
+ "canonicalReference": "@microsoft/fast-router!RouteView#context:member",
9248
+ "docComment": "",
9249
+ "excerptTokens": [
9250
+ {
9251
+ "kind": "Content",
9252
+ "text": "context: "
9285
9253
  },
9286
9254
  {
9287
- "parameterName": "context",
9288
- "parameterTypeTokenRange": {
9289
- "startIndex": 6,
9290
- "endIndex": 7
9291
- },
9292
- "isOptional": false
9255
+ "kind": "Reference",
9256
+ "text": "RouterExecutionContext",
9257
+ "canonicalReference": "@microsoft/fast-router!RouterExecutionContext:type"
9258
+ },
9259
+ {
9260
+ "kind": "Content",
9261
+ "text": ";"
9293
9262
  }
9294
9263
  ],
9295
- "name": "bind"
9264
+ "isOptional": false,
9265
+ "releaseTag": "Beta",
9266
+ "name": "context",
9267
+ "propertyTypeTokenRange": {
9268
+ "startIndex": 1,
9269
+ "endIndex": 2
9270
+ }
9296
9271
  },
9297
9272
  {
9298
9273
  "kind": "MethodSignature",
@@ -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 */
@@ -339,22 +339,22 @@ export declare type NavigationContributor<TSettings = any> = Partial<Record<Excl
339
339
  */
340
340
  export declare function navigationContributor(options?: ContributorOptions): NavigationContributorDirective;
341
341
 
342
- declare class NavigationContributorBehavior implements Behavior {
343
- private contributor;
344
- private options;
342
+ declare class NavigationContributorBehavior implements ViewBehavior {
343
+ private directive;
345
344
  private router;
346
- constructor(contributor: HTMLElement & NavigationContributor, options: Required<ContributorOptions>);
347
- bind(source: unknown, context: RouterExecutionContext): void;
345
+ private contributor;
346
+ constructor(directive: NavigationContributorDirective);
347
+ bind(controller: ViewController): void;
348
348
  unbind(source: unknown): void;
349
349
  }
350
350
 
351
- declare class NavigationContributorDirective implements HTMLDirective {
352
- private options;
351
+ declare class NavigationContributorDirective implements ViewBehaviorFactory {
352
+ readonly options: Required<ContributorOptions>;
353
353
  id: string;
354
354
  nodeId: string;
355
355
  constructor(options: Required<ContributorOptions>);
356
356
  createHTML(add: AddViewBehaviorFactory): string;
357
- createBehavior(targets: ViewBehaviorTargets): NavigationContributorBehavior;
357
+ createBehavior(): NavigationContributorBehavior;
358
358
  }
359
359
 
360
360
  /**
@@ -746,23 +746,17 @@ export declare interface RouterElement extends HTMLElement {
746
746
  * @beta
747
747
  */
748
748
  export declare type RouterExecutionContext = ExecutionContext & {
749
- router: Router;
749
+ router?: Router;
750
750
  };
751
751
 
752
- /**
753
- * @beta
754
- */
755
- export declare const RouterExecutionContext: Readonly<{
756
- create(router: Router): any;
757
- }>;
758
-
759
752
  declare const routerProperty = "$router";
760
753
 
761
754
  /**
762
755
  * @beta
763
756
  */
764
757
  export declare interface RouteView {
765
- bind(allTypedParams: Readonly<Record<string, any>>, context: RouterExecutionContext): void;
758
+ context: RouterExecutionContext;
759
+ bind(allTypedParams: Readonly<Record<string, any>>): void;
766
760
  appendTo(host: HTMLElement): void;
767
761
  dispose(): void;
768
762
  }
@@ -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
  /**
@@ -342,22 +342,22 @@ export declare type NavigationContributor<TSettings = any> = Partial<Record<Excl
342
342
  */
343
343
  export declare function navigationContributor(options?: ContributorOptions): NavigationContributorDirective;
344
344
 
345
- declare class NavigationContributorBehavior implements Behavior {
346
- private contributor;
347
- private options;
345
+ declare class NavigationContributorBehavior implements ViewBehavior {
346
+ private directive;
348
347
  private router;
349
- constructor(contributor: HTMLElement & NavigationContributor, options: Required<ContributorOptions>);
350
- bind(source: unknown, context: RouterExecutionContext): void;
348
+ private contributor;
349
+ constructor(directive: NavigationContributorDirective);
350
+ bind(controller: ViewController): void;
351
351
  unbind(source: unknown): void;
352
352
  }
353
353
 
354
- declare class NavigationContributorDirective implements HTMLDirective {
355
- private options;
354
+ declare class NavigationContributorDirective implements ViewBehaviorFactory {
355
+ readonly options: Required<ContributorOptions>;
356
356
  id: string;
357
357
  nodeId: string;
358
358
  constructor(options: Required<ContributorOptions>);
359
359
  createHTML(add: AddViewBehaviorFactory): string;
360
- createBehavior(targets: ViewBehaviorTargets): NavigationContributorBehavior;
360
+ createBehavior(): NavigationContributorBehavior;
361
361
  }
362
362
 
363
363
  /**
@@ -749,23 +749,17 @@ export declare interface RouterElement extends HTMLElement {
749
749
  * @beta
750
750
  */
751
751
  export declare type RouterExecutionContext = ExecutionContext & {
752
- router: Router;
752
+ router?: Router;
753
753
  };
754
754
 
755
- /**
756
- * @beta
757
- */
758
- export declare const RouterExecutionContext: Readonly<{
759
- create(router: Router): any;
760
- }>;
761
-
762
755
  declare const routerProperty = "$router";
763
756
 
764
757
  /**
765
758
  * @beta
766
759
  */
767
760
  export declare interface RouteView {
768
- bind(allTypedParams: Readonly<Record<string, any>>, context: RouterExecutionContext): void;
761
+ context: RouterExecutionContext;
762
+ bind(allTypedParams: Readonly<Record<string, any>>): void;
769
763
  appendTo(host: HTMLElement): void;
770
764
  dispose(): void;
771
765
  }
@@ -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
@@ -582,20 +582,17 @@ export interface RouterElement extends HTMLElement {
582
582
 
583
583
  // @beta (undocumented)
584
584
  export type RouterExecutionContext = ExecutionContext & {
585
- router: Router;
585
+ router?: Router;
586
586
  };
587
587
 
588
- // @beta (undocumented)
589
- export const RouterExecutionContext: Readonly<{
590
- create(router: Router): any;
591
- }>;
592
-
593
588
  // @beta (undocumented)
594
589
  export interface RouteView {
595
590
  // (undocumented)
596
591
  appendTo(host: HTMLElement): void;
597
592
  // (undocumented)
598
- bind(allTypedParams: Readonly<Record<string, any>>, context: RouterExecutionContext): void;
593
+ bind(allTypedParams: Readonly<Record<string, any>>): void;
594
+ // (undocumented)
595
+ context: RouterExecutionContext;
599
596
  // (undocumented)
600
597
  dispose(): void;
601
598
  }
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.6",
5
+ "version": "1.0.0-alpha.8",
6
6
  "author": {
7
7
  "name": "Microsoft",
8
8
  "url": "https://discord.gg/FcSNfg4"
@@ -80,6 +80,6 @@
80
80
  "webpack-cli": "^4.9.2"
81
81
  },
82
82
  "dependencies": {
83
- "@microsoft/fast-element": "^2.0.0-beta.6"
83
+ "@microsoft/fast-element": "^2.0.0-beta.8"
84
84
  }
85
85
  }