@microsoft/fast-router 1.0.0-alpha.27 → 1.0.0-alpha.29

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,62 @@
1
1
  {
2
2
  "name": "@microsoft/fast-router",
3
3
  "entries": [
4
+ {
5
+ "date": "Wed, 11 Dec 2024 19:52:58 GMT",
6
+ "version": "1.0.0-alpha.29",
7
+ "tag": "@microsoft/fast-router_v1.0.0-alpha.29",
8
+ "comments": {
9
+ "prerelease": [
10
+ {
11
+ "author": "7559015+janechu@users.noreply.github.com",
12
+ "package": "@microsoft/fast-router",
13
+ "commit": "1238af4df3abec01799cb05c5657f8d245cf3f25",
14
+ "comment": "Change the router to use peerDependency for fast-element"
15
+ },
16
+ {
17
+ "author": "beachball",
18
+ "package": "@microsoft/fast-router",
19
+ "comment": "Bump @microsoft/fast-element to v2.0.1",
20
+ "commit": "not available"
21
+ }
22
+ ]
23
+ }
24
+ },
25
+ {
26
+ "date": "Mon, 19 Aug 2024 22:04:19 GMT",
27
+ "version": "1.0.0-alpha.28",
28
+ "tag": "@microsoft/fast-router_v1.0.0-alpha.28",
29
+ "comments": {
30
+ "none": [
31
+ {
32
+ "author": "13071055+chrisdholt@users.noreply.github.com",
33
+ "package": "@microsoft/fast-router",
34
+ "commit": "630a5e25a953201afa016e54aa77cf68d9d7663a",
35
+ "comment": "update beachball and move disallowedChangeTypes to package.json"
36
+ },
37
+ {
38
+ "author": "7559015+janechu@users.noreply.github.com",
39
+ "package": "@microsoft/fast-router",
40
+ "commit": "78910b1158a6a24b717b3d94616fa93ab6786ab4",
41
+ "comment": "Remove yarn and lerna in favor of npm"
42
+ }
43
+ ],
44
+ "prerelease": [
45
+ {
46
+ "author": "7559015+janechu@users.noreply.github.com",
47
+ "package": "@microsoft/fast-router",
48
+ "commit": "035aefc8a25f4f75f3eb2e8cfb4dd0c60e0d2f67",
49
+ "comment": "Fix CodeQL issues"
50
+ },
51
+ {
52
+ "author": "beachball",
53
+ "package": "@microsoft/fast-router",
54
+ "comment": "Bump @microsoft/fast-element to v2.0.0",
55
+ "commit": "not available"
56
+ }
57
+ ]
58
+ }
59
+ },
4
60
  {
5
61
  "date": "Thu, 20 Jun 2024 17:00:56 GMT",
6
62
  "version": "1.0.0-alpha.27",
package/CHANGELOG.md CHANGED
@@ -1,9 +1,27 @@
1
1
  # Change Log - @microsoft/fast-router
2
2
 
3
- This log was last generated on Thu, 20 Jun 2024 17:00:56 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 11 Dec 2024 19:52:58 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 1.0.0-alpha.29
8
+
9
+ Wed, 11 Dec 2024 19:52:58 GMT
10
+
11
+ ### Changes
12
+
13
+ - Change the router to use peerDependency for fast-element (7559015+janechu@users.noreply.github.com)
14
+ - Bump @microsoft/fast-element to v2.0.1
15
+
16
+ ## 1.0.0-alpha.28
17
+
18
+ Mon, 19 Aug 2024 22:04:19 GMT
19
+
20
+ ### Changes
21
+
22
+ - Fix CodeQL issues (7559015+janechu@users.noreply.github.com)
23
+ - Bump @microsoft/fast-element to v2.0.0
24
+
7
25
  ## 1.0.0-alpha.27
8
26
 
9
27
  Thu, 20 Jun 2024 17:00:56 GMT
package/README.md CHANGED
@@ -6,16 +6,12 @@ The `@microsoft/fast-router` package contains a history-based navigation and rou
6
6
 
7
7
  ### From NPM
8
8
 
9
- To install the `fast-router` library, use either `npm` or `yarn` as follows:
9
+ To install the `fast-router` library using `npm`:
10
10
 
11
11
  ```shell
12
12
  npm install --save @microsoft/fast-router
13
13
  ```
14
14
 
15
- ```shell
16
- yarn add @microsoft/fast-router
17
- ```
18
-
19
15
  Within your JavaScript or TypeScript code, you can then import library APIs like this:
20
16
 
21
17
  ```ts
@@ -3,7 +3,7 @@ import { NavigationCommitPhaseHook, NavigationPhaseHook, NavigationPhaseName } f
3
3
  /**
4
4
  * @beta
5
5
  */
6
- export type NavigationContributor<TSettings = any> = Partial<Record<Exclude<NavigationPhaseName, "commit">, NavigationPhaseHook<TSettings>>> & {
6
+ export declare type NavigationContributor<TSettings = any> = Partial<Record<Exclude<NavigationPhaseName, "commit">, NavigationPhaseHook<TSettings>>> & {
7
7
  commit?: NavigationCommitPhaseHook<TSettings>;
8
8
  };
9
9
  /**
@@ -13,7 +13,7 @@ export declare function isNavigationPhaseContributor<T extends NavigationPhaseNa
13
13
  /**
14
14
  * @beta
15
15
  */
16
- export type ContributorOptions = {
16
+ export declare type ContributorOptions = {
17
17
  lifecycle?: boolean;
18
18
  parameters?: boolean;
19
19
  };
@@ -3,19 +3,19 @@ import { Router } from "./router.js";
3
3
  /**
4
4
  * @beta
5
5
  */
6
- export type NavigationPhaseName = "navigate" | "leave" | "construct" | "enter" | "commit";
6
+ export declare type NavigationPhaseName = "navigate" | "leave" | "construct" | "enter" | "commit";
7
7
  /**
8
8
  * @beta
9
9
  */
10
- export type NavigationPhaseHook<TSettings = any> = (phase: NavigationPhase<TSettings>) => Promise<any> | any;
10
+ export declare type NavigationPhaseHook<TSettings = any> = (phase: NavigationPhase<TSettings>) => Promise<any> | any;
11
11
  /**
12
12
  * @beta
13
13
  */
14
- export type NavigationCommitPhaseHook<TSettings = any> = (phase: NavigationCommitPhase<TSettings>) => Promise<any> | any;
14
+ export declare type NavigationCommitPhaseHook<TSettings = any> = (phase: NavigationCommitPhase<TSettings>) => Promise<any> | any;
15
15
  /**
16
16
  * @beta
17
17
  */
18
- export type NavigationPhaseFollowupAction = () => Promise<any> | any;
18
+ export declare type NavigationPhaseFollowupAction = () => Promise<any> | any;
19
19
  /**
20
20
  * @beta
21
21
  */
@@ -11,7 +11,7 @@ export interface RouteParameterConverterContext<TSettings = any> {
11
11
  /**
12
12
  * @beta
13
13
  */
14
- export type RouteParameterConverter = (name: string, value: string | undefined, context: RouteParameterConverterContext) => any | Promise<any>;
14
+ export declare type RouteParameterConverter = (name: string, value: string | undefined, context: RouteParameterConverterContext) => any | Promise<any>;
15
15
  /**
16
16
  * @beta
17
17
  */
@@ -11,127 +11,127 @@ export declare const childRouteParameter = "fast-child-route";
11
11
  /**
12
12
  * @beta
13
13
  */
14
- export type SupportsSettings<TSettings = any> = {
14
+ export declare type SupportsSettings<TSettings = any> = {
15
15
  settings?: TSettings;
16
16
  };
17
17
  /**
18
18
  * @beta
19
19
  */
20
- export type PathedRouteDefinition<TSettings = any> = SupportsSettings<TSettings> & Route;
20
+ export declare type PathedRouteDefinition<TSettings = any> = SupportsSettings<TSettings> & Route;
21
21
  /**
22
22
  * @beta
23
23
  */
24
- export type IgnorableRouteDefinition<TSettings = any> = PathedRouteDefinition<TSettings>;
24
+ export declare type IgnorableRouteDefinition<TSettings = any> = PathedRouteDefinition<TSettings>;
25
25
  /**
26
26
  * @beta
27
27
  */
28
- export type LayoutAndTransitionRouteDefinition = {
28
+ export declare type LayoutAndTransitionRouteDefinition = {
29
29
  layout?: Layout | ViewTemplate;
30
30
  transition?: Transition;
31
31
  };
32
32
  /**
33
33
  * @beta
34
34
  */
35
- export type RedirectRouteDefinition<TSettings = any> = PathedRouteDefinition<TSettings> & {
35
+ export declare type RedirectRouteDefinition<TSettings = any> = PathedRouteDefinition<TSettings> & {
36
36
  redirect: string;
37
37
  };
38
38
  /**
39
39
  * @beta
40
40
  */
41
- export type HasTitle = {
41
+ export declare type HasTitle = {
42
42
  title?: string;
43
43
  };
44
44
  /**
45
45
  * @beta
46
46
  */
47
- export type NavigableRouteDefinition<TSettings = any> = PathedRouteDefinition<TSettings> & LayoutAndTransitionRouteDefinition & HasTitle & {
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
- export type FASTElementConstructor = new () => FASTElement;
53
+ export declare type FASTElementConstructor = new () => FASTElement;
54
54
  /**
55
55
  * @beta
56
56
  */
57
- export type HasElement = {
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
- export type ElementFallbackRouteDefinition<TSettings = any> = LayoutAndTransitionRouteDefinition & HasElement & SupportsSettings<TSettings> & HasTitle;
63
+ export declare type ElementFallbackRouteDefinition<TSettings = any> = LayoutAndTransitionRouteDefinition & HasElement & SupportsSettings<TSettings> & HasTitle;
64
64
  /**
65
65
  * @beta
66
66
  */
67
- export type ElementRouteDefinition<TSettings = any> = NavigableRouteDefinition<TSettings> & HasElement;
67
+ export declare type ElementRouteDefinition<TSettings = any> = NavigableRouteDefinition<TSettings> & HasElement;
68
68
  /**
69
69
  * @beta
70
70
  */
71
- export type HasTemplate = {
71
+ export declare type HasTemplate = {
72
72
  template: ViewTemplate | (() => Promise<ViewTemplate>);
73
73
  };
74
74
  /**
75
75
  * @beta
76
76
  */
77
- export type TemplateFallbackRouteDefinition<TSettings = any> = LayoutAndTransitionRouteDefinition & HasTemplate & SupportsSettings<TSettings> & HasTitle;
77
+ export declare type TemplateFallbackRouteDefinition<TSettings = any> = LayoutAndTransitionRouteDefinition & HasTemplate & SupportsSettings<TSettings> & HasTitle;
78
78
  /**
79
79
  * @beta
80
80
  */
81
- export type TemplateRouteDefinition<TSettings = any> = NavigableRouteDefinition<TSettings> & HasTemplate;
81
+ export declare type TemplateRouteDefinition<TSettings = any> = NavigableRouteDefinition<TSettings> & HasTemplate;
82
82
  /**
83
83
  * @beta
84
84
  */
85
- export type HasCommand = {
85
+ export declare type HasCommand = {
86
86
  command: NavigationCommand;
87
87
  };
88
88
  /**
89
89
  * @beta
90
90
  */
91
- export type CommandRouteDefinition<TSettings = any> = PathedRouteDefinition<TSettings> & HasCommand & HasTitle;
91
+ export declare type CommandRouteDefinition<TSettings = any> = PathedRouteDefinition<TSettings> & HasCommand & HasTitle;
92
92
  /**
93
93
  * @beta
94
94
  */
95
- export type CommandFallbackRouteDefinition<TSettings = any> = HasCommand & SupportsSettings<TSettings> & HasTitle;
95
+ export declare type CommandFallbackRouteDefinition<TSettings = any> = HasCommand & SupportsSettings<TSettings> & HasTitle;
96
96
  /**
97
97
  * @beta
98
98
  */
99
- export type FallbackRouteDefinition<TSettings = any> = ElementFallbackRouteDefinition<TSettings> | TemplateFallbackRouteDefinition<TSettings> | Pick<RedirectRouteDefinition<TSettings>, "redirect"> | CommandFallbackRouteDefinition<TSettings>;
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
- export type DefinitionCallback = () => Promise<FallbackRouteDefinition> | FallbackRouteDefinition;
103
+ export declare type DefinitionCallback = () => Promise<FallbackRouteDefinition> | FallbackRouteDefinition;
104
104
  /**
105
105
  * @beta
106
106
  */
107
- export type RenderableRouteDefinition<TSettings = any> = ElementRouteDefinition<TSettings> | TemplateRouteDefinition<TSettings>;
107
+ export declare type RenderableRouteDefinition<TSettings = any> = ElementRouteDefinition<TSettings> | TemplateRouteDefinition<TSettings>;
108
108
  /**
109
109
  * @beta
110
110
  */
111
- export type MappableRouteDefinition<TSettings = any> = RenderableRouteDefinition<TSettings> | RedirectRouteDefinition<TSettings> | CommandRouteDefinition<TSettings> | ParentRouteDefinition<TSettings>;
111
+ export declare type MappableRouteDefinition<TSettings = any> = RenderableRouteDefinition<TSettings> | RedirectRouteDefinition<TSettings> | CommandRouteDefinition<TSettings> | ParentRouteDefinition<TSettings>;
112
112
  /**
113
113
  * @beta
114
114
  */
115
- export type ParentRouteDefinition<TSettings = any> = PathedRouteDefinition<TSettings> & LayoutAndTransitionRouteDefinition & {
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
- export type RouteMatch<TSettings = any> = {
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
- export type RouteParameterConverterObject = {
128
+ export declare type RouteParameterConverterObject = {
129
129
  convert: RouteParameterConverter;
130
130
  };
131
131
  /**
132
132
  * @beta
133
133
  */
134
- export type ParameterConverter = RouteParameterConverter | RouteParameterConverterObject | Constructable<RouteParameterConverterObject>;
134
+ export declare type ParameterConverter = RouteParameterConverter | RouteParameterConverterObject | Constructable<RouteParameterConverterObject>;
135
135
  /**
136
136
  * @beta
137
137
  */
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.24.2"
8
+ "packageVersion": "7.47.0"
9
9
  }
10
10
  ]
11
11
  }
@@ -3,7 +3,7 @@ import { Router } from "./router.js";
3
3
  /**
4
4
  * @beta
5
5
  */
6
- export type RouterExecutionContext = ExecutionContext & {
6
+ export declare type RouterExecutionContext = ExecutionContext & {
7
7
  router?: Router;
8
8
  };
9
9
  /**
@@ -1,12 +1,6 @@
1
1
  import { __awaiter } from "tslib";
2
2
  import { isNavigationPhaseContributor } from "./contributors.js";
3
3
  class NavigationPhaseImpl {
4
- get route() {
5
- return this.routes[this.routes.length - 1];
6
- }
7
- get router() {
8
- return this.routers[this.routers.length - 1];
9
- }
10
4
  constructor(name, route, router, commitActions, cancelActions) {
11
5
  this.name = name;
12
6
  this.commitActions = commitActions;
@@ -18,6 +12,12 @@ class NavigationPhaseImpl {
18
12
  this.routes.push(route);
19
13
  this.routers.push(router);
20
14
  }
15
+ get route() {
16
+ return this.routes[this.routes.length - 1];
17
+ }
18
+ get router() {
19
+ return this.routers[this.routers.length - 1];
20
+ }
21
21
  cancel(callback) {
22
22
  this.canceled = true;
23
23
  if (callback) {
@@ -1,5 +1,5 @@
1
1
  const encode = encodeURIComponent;
2
- const encodeKey = (key) => encode(key).replace("%24", "$");
2
+ const encodeKey = (key) => encode(key).replace(/%24/g, "$");
3
3
  function buildParam(key, value, traditional) {
4
4
  let result = [];
5
5
  if (value === null || value === undefined) {
@@ -51,14 +51,15 @@ function parseComplexParam(queryParams, keys, value) {
51
51
  if (j < keysLastIndex) {
52
52
  // The value has to be an array or a false value
53
53
  // It can happen that the value is no array if the key was repeated with traditional style like `list=1&list[]=2`
54
- const prevValue = !currentParams[key] || typeof currentParams[key] === "object"
55
- ? currentParams[key]
56
- : [currentParams[key]];
57
- currentParams = currentParams[key] =
58
- prevValue || (isNaN(keys[j + 1]) ? {} : []);
54
+ const prevValue = !currentParams.get(key) || typeof currentParams.get(key) === "object"
55
+ ? currentParams.get(key)
56
+ : [currentParams.get(key)];
57
+ currentParams.set(key, prevValue || (isNaN(keys[j + 1]) ? {} : []));
58
+ currentParams = currentParams.get(key);
59
59
  }
60
60
  else {
61
- currentParams = currentParams[key] = value;
61
+ currentParams.set(key, value);
62
+ currentParams = currentParams.get(key);
62
63
  }
63
64
  }
64
65
  }
@@ -249,13 +249,13 @@ function compareChains(a, b) {
249
249
  return a.compareTo(b);
250
250
  }
251
251
  class RecognizeResult {
252
- get isEmpty() {
253
- return this.candidates.length === 0;
254
- }
255
252
  constructor(rootState) {
256
253
  this.candidates = [];
257
254
  this.candidates = [new Candidate([""], [rootState], [], this)];
258
255
  }
256
+ get isEmpty() {
257
+ return this.candidates.length === 0;
258
+ }
259
259
  getSolution() {
260
260
  const candidates = this.candidates.filter(hasEndpoint);
261
261
  if (candidates.length === 0) {
@@ -539,13 +539,13 @@ function isNotEmpty(segment) {
539
539
  return segment.length > 0;
540
540
  }
541
541
  class StaticSegment {
542
- get kind() {
543
- return 3 /* SegmentKind.static */;
544
- }
545
542
  constructor(value, caseSensitive) {
546
543
  this.value = value;
547
544
  this.caseSensitive = caseSensitive;
548
545
  }
546
+ get kind() {
547
+ return 3 /* SegmentKind.static */;
548
+ }
549
549
  appendTo(state) {
550
550
  const { value, value: { length }, } = this;
551
551
  if (this.caseSensitive) {
@@ -573,13 +573,13 @@ class StaticSegment {
573
573
  }
574
574
  }
575
575
  class DynamicSegment {
576
- get kind() {
577
- return 2 /* SegmentKind.dynamic */;
578
- }
579
576
  constructor(name, optional) {
580
577
  this.name = name;
581
578
  this.optional = optional;
582
579
  }
580
+ get kind() {
581
+ return 2 /* SegmentKind.dynamic */;
582
+ }
583
583
  appendTo(state) {
584
584
  state = state.append(/* segment */ this, /* value */ "/");
585
585
  return state;
@@ -595,12 +595,12 @@ class DynamicSegment {
595
595
  }
596
596
  }
597
597
  class StarSegment {
598
- get kind() {
599
- return 1 /* SegmentKind.star */;
600
- }
601
598
  constructor(name) {
602
599
  this.name = name;
603
600
  }
601
+ get kind() {
602
+ return 1 /* SegmentKind.star */;
603
+ }
604
604
  appendTo(state) {
605
605
  state = state.append(/* segment */ this, /* value */ "");
606
606
  return state;