@lwrjs/router 0.10.0-alpha.1 → 0.10.0-alpha.10

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.
Files changed (97) hide show
  1. package/build/bundle/prod/lwr/navigation/es/modules/lwr/currentView/currentView.d.ts +28 -0
  2. package/build/bundle/prod/lwr/navigation/navigation.js +1 -1
  3. package/build/bundle/prod/lwr/router/es/modules/lwr/currentView/currentView.d.ts +28 -0
  4. package/build/bundle/prod/lwr/router/router.js +1 -1
  5. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/currentView/currentView.d.ts +28 -0
  6. package/build/bundle/prod/lwr/routerContainer/routerContainer.js +1 -1
  7. package/build/cjs/modules/lwr/outlet/outlet.cjs +4 -1
  8. package/build/es/modules/lwr/contextProvider/contextProvider.js +30 -0
  9. package/build/es/modules/lwr/contextUtils/contextInfo.js +93 -0
  10. package/build/es/modules/lwr/contextUtils/contextUtils.js +77 -0
  11. package/build/es/modules/lwr/contextUtils/navigationApiStore.js +46 -0
  12. package/build/{modules → es/modules}/lwr/currentPageReference/currentPageReference.d.ts +1 -1
  13. package/build/es/modules/lwr/currentPageReference/currentPageReference.js +14 -0
  14. package/build/{modules → es/modules}/lwr/currentView/currentView.d.ts +2 -2
  15. package/build/es/modules/lwr/currentView/currentView.js +62 -0
  16. package/build/{modules → es/modules}/lwr/domRouter/domRouter.d.ts +2 -2
  17. package/build/es/modules/lwr/domRouter/domRouter.js +441 -0
  18. package/build/es/modules/lwr/domRouterUtils/domRouterUtils.js +3 -0
  19. package/build/es/modules/lwr/domRouterUtils/historyUtils.js +30 -0
  20. package/build/{modules → es/modules}/lwr/domRouterUtils/types.d.ts +1 -1
  21. package/build/es/modules/lwr/domRouterUtils/types.js +2 -0
  22. package/build/es/modules/lwr/domRouterUtils/uriUtils.js +69 -0
  23. package/build/es/modules/lwr/historyRouter/historyRouter.js +88 -0
  24. package/build/es/modules/lwr/navigation/navigation.js +20 -0
  25. package/build/es/modules/lwr/navigation/navigationApi.js +27 -0
  26. package/build/es/modules/lwr/navigation/navigationMixin.js +76 -0
  27. package/build/{modules → es/modules}/lwr/navigationContext/navigationContext.d.ts +2 -2
  28. package/build/es/modules/lwr/navigationContext/navigationContext.js +10 -0
  29. package/build/es/modules/lwr/navigationMixinHacks/navigationMixinHacks.d.ts +7 -0
  30. package/build/es/modules/lwr/navigationMixinHacks/navigationMixinHacks.js +5 -0
  31. package/build/es/modules/lwr/observable/observable.js +71 -0
  32. package/build/{modules → es/modules}/lwr/outlet/outlet.d.ts +1 -0
  33. package/build/es/modules/lwr/outlet/outlet.js +69 -0
  34. package/build/es/modules/lwr/router/router.js +201 -0
  35. package/build/es/modules/lwr/routerBridge/routerBridge.js +85 -0
  36. package/build/es/modules/lwr/routerContainer/routerContainer.js +116 -0
  37. package/build/es/modules/lwr/routerContainer/utils.js +83 -0
  38. package/build/es/modules/lwr/routerErrors/routerErrors.js +154 -0
  39. package/build/es/modules/lwr/routerUtils/domUtils.js +3 -0
  40. package/build/{modules → es/modules}/lwr/routerUtils/filterUtils.d.ts +1 -1
  41. package/build/es/modules/lwr/routerUtils/filterUtils.js +74 -0
  42. package/build/es/modules/lwr/routerUtils/parseUtils.js +182 -0
  43. package/build/{modules → es/modules}/lwr/routerUtils/pathToRegexp.d.ts +5 -5
  44. package/build/es/modules/lwr/routerUtils/pathToRegexp.js +415 -0
  45. package/build/es/modules/lwr/routerUtils/routeDefUtils.js +204 -0
  46. package/build/es/modules/lwr/routerUtils/routeUtils.js +239 -0
  47. package/build/es/modules/lwr/routerUtils/routerUtils.js +19 -0
  48. package/build/es/modules/lwr/routerUtils/typeUtils.js +112 -0
  49. package/build/{modules → es/modules}/lwr/routerUtils/types.d.ts +23 -23
  50. package/build/es/modules/lwr/routerUtils/types.js +2 -0
  51. package/build/es/modules/lwr/routerUtils/uriUtils.js +134 -0
  52. package/build/modules/lwr/contextUtils/contextUtils.js +5 -0
  53. package/build/modules/lwr/contextUtils/navigationApiStore.js +7 -0
  54. package/build/modules/lwr/domRouter/domRouter.js +6 -0
  55. package/build/modules/lwr/domRouterUtils/historyUtils.js +0 -1
  56. package/build/modules/lwr/outlet/outlet.css +1 -1
  57. package/build/modules/lwr/outlet/outlet.html +2 -2
  58. package/build/modules/lwr/outlet/outlet.js +3 -4
  59. package/build/modules/lwr/router/router.js +3 -0
  60. package/build/modules/lwr/routerContainer/utils.js +1 -3
  61. package/build/modules/lwr/routerUtils/pathToRegexp.js +17 -0
  62. package/build/modules/lwr/routerUtils/typeUtils.js +0 -1
  63. package/package.json +17 -9
  64. package/pageObjects/outlet.cjs +21 -4
  65. package/pageObjects/outlet.d.ts +10 -2
  66. package/pageObjects/outlet.js +22 -5
  67. package/build/modules/lwr/navigationMixinHacks/navigationMixinHacks.d.ts +0 -7
  68. /package/build/{modules → es/modules}/lwr/contextProvider/contextProvider.d.ts +0 -0
  69. /package/build/{modules → es/modules}/lwr/contextUtils/contextInfo.d.ts +0 -0
  70. /package/build/{modules → es/modules}/lwr/contextUtils/contextUtils.d.ts +0 -0
  71. /package/build/{modules → es/modules}/lwr/contextUtils/navigationApiStore.d.ts +0 -0
  72. /package/build/{modules → es/modules}/lwr/domRouterUtils/domRouterUtils.d.ts +0 -0
  73. /package/build/{modules → es/modules}/lwr/domRouterUtils/historyUtils.d.ts +0 -0
  74. /package/build/{modules → es/modules}/lwr/domRouterUtils/uriUtils.d.ts +0 -0
  75. /package/build/{modules → es/modules}/lwr/historyRouter/historyRouter.d.ts +0 -0
  76. /package/build/{modules → es/modules}/lwr/navigation/navigation.d.ts +0 -0
  77. /package/build/{modules → es/modules}/lwr/navigation/navigationApi.d.ts +0 -0
  78. /package/build/{modules → es/modules}/lwr/navigation/navigationMixin.d.ts +0 -0
  79. /package/build/{modules → es/modules}/lwr/observable/observable.d.ts +0 -0
  80. /package/build/{modules → es/modules}/lwr/router/router.d.ts +0 -0
  81. /package/build/{modules → es/modules}/lwr/routerBridge/routerBridge.d.ts +0 -0
  82. /package/build/{modules → es/modules}/lwr/routerContainer/routerContainer.d.ts +0 -0
  83. /package/build/{modules → es/modules}/lwr/routerContainer/utils.d.ts +0 -0
  84. /package/build/{modules → es/modules}/lwr/routerErrors/routerErrors.d.ts +0 -0
  85. /package/build/{modules → es/modules}/lwr/routerUtils/domUtils.d.ts +0 -0
  86. /package/build/{modules → es/modules}/lwr/routerUtils/parseUtils.d.ts +0 -0
  87. /package/build/{modules → es/modules}/lwr/routerUtils/routeDefUtils.d.ts +0 -0
  88. /package/build/{modules → es/modules}/lwr/routerUtils/routeUtils.d.ts +0 -0
  89. /package/build/{modules → es/modules}/lwr/routerUtils/routerUtils.d.ts +0 -0
  90. /package/build/{modules → es/modules}/lwr/routerUtils/typeUtils.d.ts +0 -0
  91. /package/build/{modules → es/modules}/lwr/routerUtils/uriUtils.d.ts +0 -0
  92. /package/build/{services → es/services}/index.d.ts +0 -0
  93. /package/build/{services → es/services}/index.js +0 -0
  94. /package/build/{services → es/services}/module-provider/index.d.ts +0 -0
  95. /package/build/{services → es/services}/module-provider/index.js +0 -0
  96. /package/build/{services → es/services}/module-provider/utils.d.ts +0 -0
  97. /package/build/{services → es/services}/module-provider/utils.js +0 -0
@@ -1,40 +1,40 @@
1
1
  import type { Key, PathFunction } from './pathToRegexp';
2
2
  import type { ContextId } from 'lwr/navigationContext';
3
3
  import { Unsubscriber } from 'lwr/observable';
4
- export declare type Module = Record<string | symbol | number, unknown>;
5
- export declare type Constructor<T = object> = new (...args: any[]) => T;
4
+ export type Module = Record<string | symbol | number, unknown>;
5
+ export type Constructor<T = object> = new (...args: any[]) => T;
6
6
  export interface Constructable<T = object> {
7
7
  constructor: Constructor<T>;
8
8
  }
9
- export declare type UrlMapper<TAddress> = {
9
+ export type UrlMapper<TAddress> = {
10
10
  generateUrl(address: TAddress): string | null;
11
11
  parseUrl(url: string): TAddress | null;
12
12
  };
13
- export declare type RouteMatcher<TAddress> = {
13
+ export type RouteMatcher<TAddress> = {
14
14
  matchRoute(address: TAddress): RoutingMatch | null;
15
15
  };
16
- export declare type ViewMapper<TAddress> = {
16
+ export type ViewMapper<TAddress> = {
17
17
  navigate(address: TAddress): void;
18
18
  subscribe(callback: RouteCallback, replay?: boolean): Unsubscriber;
19
19
  resolveView(address: TAddress): Promise<RouteDestination>;
20
20
  contextId?: ContextId;
21
21
  };
22
- export declare type Router<TAddress = string> = ViewMapper<TAddress> & UrlMapper<TAddress> & RouteMatcher<TAddress>;
22
+ export type Router<TAddress = string> = ViewMapper<TAddress> & UrlMapper<TAddress> & RouteMatcher<TAddress>;
23
23
  export interface DEPRECATED_getRouteFromUrl {
24
24
  <TAddress>(url: string, defaultImpl: Function): TAddress | null;
25
25
  }
26
26
  export interface DEPRECATED_getUrlFromRoute {
27
27
  <TAddress>(route: TAddress, defaultImpl: Function): string | null;
28
28
  }
29
- export declare type RouterConfig = {
29
+ export type RouterConfig = {
30
30
  basePath?: string;
31
31
  routes?: RouteDefinition[];
32
32
  caseSensitive?: boolean;
33
33
  DEPRECATED_getRouteFromUrl?: DEPRECATED_getRouteFromUrl;
34
34
  DEPRECATED_getUrlFromRoute?: DEPRECATED_getUrlFromRoute;
35
35
  };
36
- export declare type RouterSerializationConfig<TAddress> = Required<Omit<RouterConfig, 'DEPRECATED_getRouteFromUrl' | 'DEPRECATED_getUrlFromRoute'> & UrlMapper<TAddress>>;
37
- export declare type RouteParameterPatterns = {
36
+ export type RouterSerializationConfig<TAddress> = Required<Omit<RouterConfig, 'DEPRECATED_getRouteFromUrl' | 'DEPRECATED_getUrlFromRoute'> & UrlMapper<TAddress>>;
37
+ export type RouteParameterPatterns = {
38
38
  [paramName: string]: string;
39
39
  };
40
40
  export interface RouteDefinition<TMetadata = Record<string, any>> {
@@ -46,21 +46,21 @@ export interface RouteDefinition<TMetadata = Record<string, any>> {
46
46
  handler: () => Promise<RouteHandlerModule>;
47
47
  metadata?: TMetadata;
48
48
  }
49
- export declare type PageBindings = {
49
+ export type PageBindings = {
50
50
  attributeBindings: NullableStringAttributes;
51
51
  stateBindings: NullableStringAttributes;
52
52
  };
53
- declare type CompiledQueryResult = {
53
+ type CompiledQueryResult = {
54
54
  literalValue?: string | null;
55
55
  routeParamName?: string;
56
56
  };
57
- export declare type CompiledQuery = Record<string, CompiledQueryResult>;
58
- declare type MatchedQueryResult = {
57
+ export type CompiledQuery = Record<string, CompiledQueryResult>;
58
+ type MatchedQueryResult = {
59
59
  value: string | null;
60
60
  routeParamName?: string;
61
61
  };
62
- export declare type MatchedQuery = Record<string, MatchedQueryResult>;
63
- export declare type QueryMatcher = (queryObject: QueryObject) => MatchedQuery | null;
62
+ export type MatchedQuery = Record<string, MatchedQueryResult>;
63
+ export type QueryMatcher = (queryObject: QueryObject) => MatchedQuery | null;
64
64
  export interface CompiledRouteDefinition {
65
65
  original: RouteDefinition;
66
66
  regex: RegExp;
@@ -69,11 +69,11 @@ export interface CompiledRouteDefinition {
69
69
  compiledQuery: CompiledQuery;
70
70
  queryMatcher: QueryMatcher;
71
71
  }
72
- export declare type RouteHandlerCallback = (routeDestination: RouteDestination) => void;
73
- export declare type RouteHandlerClass = {
72
+ export type RouteHandlerCallback = (routeDestination: RouteDestination) => void;
73
+ export type RouteHandlerClass = {
74
74
  new (callback: RouteHandlerCallback): RouteHandler;
75
75
  };
76
- export declare type RouteHandlerModule = {
76
+ export type RouteHandlerModule = {
77
77
  default: RouteHandlerClass;
78
78
  };
79
79
  export interface RouteInstance {
@@ -82,12 +82,12 @@ export interface RouteInstance {
82
82
  state: NullableStringAttributes;
83
83
  pageReference: PageReference;
84
84
  }
85
- export declare type RouteDestination = {
85
+ export type RouteDestination = {
86
86
  status?: 200 | 404 | 500;
87
87
  viewset: ViewSet;
88
88
  error?: Error;
89
89
  };
90
- export declare type RoutingMatch = {
90
+ export type RoutingMatch = {
91
91
  pathMatch: string;
92
92
  route: RouteInstance;
93
93
  routeDefinition: RouteDefinition;
@@ -96,7 +96,7 @@ export interface CompiledRoutingMatch {
96
96
  route: RouteInstance;
97
97
  routeDefinition: CompiledRouteDefinition;
98
98
  }
99
- export declare type RoutingResult = RoutingMatch & RouteDestination;
99
+ export type RoutingResult = RoutingMatch & RouteDestination;
100
100
  export interface ViewSet {
101
101
  [viewName: string]: (() => Promise<Module>) | ViewInfo;
102
102
  }
@@ -104,7 +104,7 @@ export interface ViewInfo {
104
104
  module: () => Promise<Module>;
105
105
  specifier: string;
106
106
  }
107
- export declare type RouteCallback = (result: RoutingResult) => void;
107
+ export type RouteCallback = (result: RoutingResult) => void;
108
108
  export interface RouteHandler {
109
109
  dispose(): void;
110
110
  update(routeInfo: RouteInstance): void;
@@ -122,7 +122,7 @@ export interface MessageObject {
122
122
  url?: string;
123
123
  address?: string;
124
124
  }
125
- export declare type QueryObject = NullableStringAttributes;
125
+ export type QueryObject = NullableStringAttributes;
126
126
  export interface StringAttributes {
127
127
  [key: string]: string;
128
128
  }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Copyright (c) 2019, salesforce.com, inc.
3
+ * All rights reserved.
4
+ * SPDX-License-Identifier: MIT
5
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6
+ */
7
+ /**
8
+ * f("one two &") -> "one%20two%20%26"
9
+ *
10
+ * @param str - String to URI encode
11
+ *
12
+ * @returns {string}
13
+ */
14
+ export function encode(str = '') {
15
+ str = str || '';
16
+ return encodeURIComponent(str);
17
+ }
18
+ /**
19
+ * f("one%20two%20%26") -> "one two &"
20
+ *
21
+ * @param str - String to URI decode
22
+ *
23
+ * @returns {string}
24
+ */
25
+ export function decode(str = '') {
26
+ str = str || '';
27
+ return decodeURIComponent(str);
28
+ }
29
+ /**
30
+ * f(url) -> "/some/relative/path"
31
+ * Output will...
32
+ * - always start with '/'
33
+ * - not contain query params or fragment
34
+ * - akin to window.location.pathname
35
+ *
36
+ * @param {string} url - URL string to parse for a path
37
+ *
38
+ * @returns {string}
39
+ */
40
+ export function getPathFromUrl(url) {
41
+ url = url || '/';
42
+ if (url.charAt(0) !== '/') {
43
+ url = '/' + url;
44
+ }
45
+ // can't use url object here to maintain portability
46
+ const fullmatch = url.match(/^[^#?]+/);
47
+ if (fullmatch !== null) {
48
+ const path = fullmatch[0];
49
+ return path === '/' ? '/' : path.replace(/\/$/, '');
50
+ }
51
+ return '/';
52
+ }
53
+ /**
54
+ * f(url) -> { "param1": "one", "param2": "two", param3: "" }
55
+ * Parameters without values get set to an empty string.
56
+ *
57
+ * @param {string} url - URL string to parse for a query object
58
+ *
59
+ * @returns {object}
60
+ */
61
+ export function getQueryFromUrl(url) {
62
+ // Ensure this is a full URL.
63
+ url = url || '';
64
+ // Remove the fragment off the end if present
65
+ const fragmentStart = url.indexOf('#');
66
+ if (fragmentStart >= 0) {
67
+ url = url.substring(0, fragmentStart);
68
+ }
69
+ // can't use url object here to maintain portability
70
+ const queryIdx = url.indexOf('?');
71
+ const queryStr = queryIdx >= 0 ? url.substr(queryIdx + 1) : null;
72
+ const queryParams = {};
73
+ if (queryStr) {
74
+ queryStr.split('&').forEach((pair) => {
75
+ if (pair.indexOf('=') >= 0) {
76
+ const [key, value = ''] = pair.split('=');
77
+ queryParams[decode(key)] = decode(value);
78
+ }
79
+ else {
80
+ // e.g, ?qKey1 => { qKey1: null }
81
+ queryParams[decode(pair)] = null;
82
+ }
83
+ });
84
+ }
85
+ return queryParams;
86
+ }
87
+ /**
88
+ * f({ "param1": "one", "param2": "two", param3: "" }) -> "?param1=one&param2=two&param3"
89
+ * Query parameter values, but not keys, get URI encoded.
90
+ *
91
+ * @param {object} queryObject - Query object to turn into a string
92
+ *
93
+ * @returns {string}
94
+ */
95
+ export function getQueryString(queryObj = {}) {
96
+ const keys = Object.keys(queryObj);
97
+ return keys.length // handle params without values here
98
+ ? `?${keys
99
+ .map((key) => {
100
+ const value = queryObj[key];
101
+ if (value === null) {
102
+ // { qKey: null } => '?qKey
103
+ return key;
104
+ }
105
+ return `${key}=${encode(value)}`;
106
+ })
107
+ .join('&')}`
108
+ : '';
109
+ }
110
+ /**
111
+ * Determines if the given string is a paramter name (":paramName")
112
+ * @param str string to test
113
+ * @returns true if string starts with ":"
114
+ */
115
+ export function isParam(str) {
116
+ return str && str.length > 1 ? str.startsWith(':') : false;
117
+ }
118
+ /**
119
+ * @param routeParamName - routeParamName from CompiledQueryResult
120
+ * @returns the paramName without prefix; or undefined
121
+ */
122
+ export function getParamName(routeParamName) {
123
+ return routeParamName ? (isParam(routeParamName) ? routeParamName.substr(1) : false) : false;
124
+ }
125
+ export function getQueryNames(compiledQuery) {
126
+ return Object.values(compiledQuery).reduce((paramNames, { routeParamName }) => {
127
+ const paramName = getParamName(routeParamName);
128
+ if (paramName) {
129
+ paramNames.push(paramName);
130
+ }
131
+ return paramNames;
132
+ }, []);
133
+ }
134
+ //# sourceMappingURL=uriUtils.js.map
@@ -4,6 +4,11 @@
4
4
  import { ContextInfo } from './contextInfo';
5
5
  export { ContextInfo };
6
6
  export { getNavigationHelm, registerNavigationHelm } from './navigationApiStore';
7
+
8
+ /**
9
+ * Interface for contextual wire adapters to subscribe to context changes
10
+ */
11
+
7
12
  export function generateContextualWireAdapter(contextInstance) {
8
13
  const Adapter = class Adapter {
9
14
  constructor(callback) {
@@ -6,6 +6,13 @@
6
6
  */
7
7
 
8
8
  import { generateMessage, messages } from 'lwr/routerErrors';
9
+
10
+ /**
11
+ * Provides the ability for a given context provider to find its NavigationHelm
12
+ * provider by just an ID. Having access to the NavigationHelm allows the consumer
13
+ * to direct navigation. Generally, the Helm is more powerful than the exposed APIs.
14
+ */
15
+
9
16
  // Keep a cache of context metadata, with their IDs as keys
10
17
  const CACHE = new WeakMap();
11
18
 
@@ -18,6 +18,12 @@ import { CONTEXT_ID_BACKDOOR } from 'lwr/navigationMixinHacks';
18
18
  export const NAV_EVENT = `universalcontainernavigationevent${guid()}`;
19
19
  // Event fired to find nearest parent
20
20
  export const PARENT_EVENT = `universalcontainerparentevent${guid()}`;
21
+
22
+ /*
23
+ * Provides a DomRouter class. Extended by the HistoryRouter and composed by the router-container LWCs.
24
+ * Composed with a Router for underlying routing capabilities.
25
+ */
26
+
21
27
  export class DomRouterImpl {
22
28
  pendingRoute = null;
23
29
  committedRoute = null;
@@ -9,7 +9,6 @@
9
9
  * Manipulates the browser history on the window.
10
10
  * Ths just uses the window.history functionality directly.
11
11
  */
12
-
13
12
  /**
14
13
  * Sets a history state.
15
14
 
@@ -1,3 +1,3 @@
1
- div[role='region'] {
1
+ div[role='region'].outlet {
2
2
  outline: none;
3
3
  }
@@ -1,10 +1,10 @@
1
- <template>
1
+ <template lwc:render-mode="light">
2
2
  <div role="alert">
3
3
  <template if:true={hasError}>
4
4
  <slot name="error"></slot>
5
5
  </template>
6
6
  </div>
7
- <div role="region" tabindex="-1">
7
+ <div class="outlet" role="region" tabindex="-1">
8
8
  <lwr-dynamic lwc:dynamic={viewCtor}></lwr-dynamic>
9
9
  </div>
10
10
  </template>
@@ -1,6 +1,7 @@
1
1
  import { LightningElement, api, wire } from 'lwc';
2
2
  import { CurrentView } from 'lwr/navigation';
3
3
  export default class Outlet extends LightningElement {
4
+ static renderMode = 'light';
4
5
  @api
5
6
  refocusOff = false;
6
7
  @api
@@ -52,10 +53,8 @@ export default class Outlet extends LightningElement {
52
53
  // If the feature is not turned off, put the browser focus onto the dynamic content.
53
54
  // This is done after a route change for accessibility.
54
55
  if (!this.refocusOff) {
55
- // TODO: LightningElement template type 'ShadowRootTheGoodPart' does not contain
56
- // a querySelector function, neccessitating 'any'
57
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
- this.template.querySelector(`div[role='region']`).focus();
56
+ const region = this.querySelector(`div[role='region'].outlet`);
57
+ if (region) region.focus();
59
58
  }
60
59
  }
61
60
  }
@@ -10,6 +10,9 @@ import { generateMessage, messages } from 'lwr/routerErrors';
10
10
  import { createObservable } from 'lwr/observable';
11
11
  class RouterImpl {
12
12
  deprecatedConfig = {};
13
+
14
+ // The in-flight route state to be committed once the view mapping is handled
15
+
13
16
  routeHandlerId = 0;
14
17
 
15
18
  /**
@@ -10,9 +10,7 @@ import { invariant, messages } from 'lwr/routerErrors';
10
10
  import { DomRouterImpl } from 'lwr/domRouter';
11
11
  /*
12
12
  * Provides programmatic routing capabilities.
13
- */
14
-
15
- // The application may create 1 root router at a time.
13
+ */ // The application may create 1 root router at a time.
16
14
  let hasRoot = false;
17
15
  /**
18
16
  * Create a new navigation context, attach to the given node.
@@ -311,6 +311,19 @@ export function tokensToFunction(tokens, options = {}) {
311
311
  export function compile(str, options) {
312
312
  return tokensToFunction(parse(str, options), options);
313
313
  }
314
+
315
+ /**
316
+ * A match result contains data about the path match.
317
+ */
318
+
319
+ /**
320
+ * A match is either `false` (no match) or a match result.
321
+ */
322
+
323
+ /**
324
+ * The match function takes a string and returns whether it matched the path.
325
+ */
326
+
314
327
  /**
315
328
  * Create a path match function from `path-to-regexp` output.
316
329
  */
@@ -350,6 +363,10 @@ export function regexpToFunction(re, keys, options = {}) {
350
363
  * Metadata about a key.
351
364
  */
352
365
 
366
+ /**
367
+ * A token is a string (nothing special) or key metadata (capture group).
368
+ */
369
+
353
370
  /**
354
371
  * Pull out keys from a regexp.
355
372
  */
@@ -8,7 +8,6 @@
8
8
  /*
9
9
  * Utilities for checking type, including route types.
10
10
  */
11
-
12
11
  /**
13
12
  * @param {*} o - Item to check if it's an object
14
13
  * @returns {boolean}
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
- "version": "0.10.0-alpha.1",
8
+ "version": "0.10.0-alpha.10",
9
9
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
10
10
  "repository": {
11
11
  "type": "git",
@@ -16,16 +16,16 @@
16
16
  "url": "https://github.com/salesforce-experience-platform-emu/lwr/issues"
17
17
  },
18
18
  "type": "module",
19
- "types": "build/services/index.d.ts",
19
+ "types": "build/es/services/index.d.ts",
20
20
  "main": "build/cjs/services/index.cjs",
21
- "module": "build/services/index.js",
21
+ "module": "build/es/services/index.js",
22
22
  "exports": {
23
23
  ".": {
24
- "import": "./build/services/index.js",
24
+ "import": "./build/es/services/index.js",
25
25
  "require": "./build/cjs/services/index.cjs"
26
26
  },
27
27
  "./module-provider": {
28
- "import": "./build/services/module-provider/index.js",
28
+ "import": "./build/es/services/module-provider/index.js",
29
29
  "require": "./build/cjs/services/module-provider/index.cjs"
30
30
  },
31
31
  "./pageObjects/*": {
@@ -48,11 +48,16 @@
48
48
  "utam:compile": "utam -c utam.config.cjs -t module"
49
49
  },
50
50
  "dependencies": {
51
- "@lwrjs/client-modules": "0.10.0-alpha.1",
52
- "@lwrjs/diagnostics": "0.10.0-alpha.1",
53
- "@lwrjs/shared-utils": "0.10.0-alpha.1",
51
+ "@lwrjs/client-modules": "0.10.0-alpha.10",
52
+ "@lwrjs/diagnostics": "0.10.0-alpha.10",
53
+ "@lwrjs/shared-utils": "0.10.0-alpha.10",
54
54
  "ajv": "6.12.6"
55
55
  },
56
+ "devDependencies": {
57
+ "@rollup/plugin-typescript": "^11.1.0",
58
+ "rollup": "^2.78.0",
59
+ "utam": "^2.0.0"
60
+ },
56
61
  "lwc": {
57
62
  "modules": [
58
63
  {
@@ -76,5 +81,8 @@
76
81
  "engines": {
77
82
  "node": ">=16.0.0 <20"
78
83
  },
79
- "gitHead": "2683dd5839b4da2ed93d42874cfceb78cbb5bf0d"
84
+ "volta": {
85
+ "extends": "../../../package.json"
86
+ },
87
+ "gitHead": "81dd6125be1023415344b59c4dcd977c8dbaf7f5"
80
88
  }
@@ -1,18 +1,25 @@
1
+
1
2
  'use strict';
2
3
 
3
4
  var core = require('@utam/core');
4
5
 
5
6
  async function _utam_get_content(driver, root) {
6
7
  let _element = root;
7
- const _locator = core.By.css(`lwr-dynamic`);
8
- _element = new core.ShadowRoot(driver, _element);
8
+ const _locator = core.By.css("lwr-dynamic");
9
9
  return _element.findElement(_locator);
10
10
  }
11
11
 
12
+ /**
13
+ * @lwrjs/router Outlet dynamically renders LWC view components.
14
+ * generated from JSON src/modules/lwr/outlet/__utam__/outlet.utam.json
15
+ * @version 0.10
16
+ * @author lwr-js
17
+ */
12
18
  class Outlet extends core.UtamBaseRootPageObject {
13
- constructor(driver, element, locator = core.By.css(`lwr-outlet`)) {
19
+ constructor(driver, element, locator = core.By.css("lwr-outlet")) {
14
20
  super(driver, element, locator);
15
21
  }
22
+
16
23
  async __getRoot() {
17
24
  const driver = this.driver;
18
25
  const root = await this.getRootElement();
@@ -23,10 +30,20 @@ class Outlet extends core.UtamBaseRootPageObject {
23
30
  async getContent(ContainerCtor) {
24
31
  const driver = this.driver;
25
32
  const root = await this.getRootElement();
26
- let element = await _utam_get_content(driver, root, );
33
+ let element = await _utam_get_content(driver, root);
27
34
  element = new ContainerCtor(driver, element);
28
35
  return element;
29
36
  }
37
+
38
+ async waitForOutletContent() {
39
+ await this.waitFor(async () => {
40
+ const _statement0 = await this.__getRoot();
41
+ const _result0 = await _statement0.containsElement(core.By.css("lwr-dynamic"), true);
42
+ return _result0;
43
+ });
44
+ return this;
45
+ }
46
+
30
47
  }
31
48
 
32
49
  module.exports = Outlet;
@@ -1,6 +1,14 @@
1
- import { By as _By, ShadowRoot as _ShadowRoot, UtamBaseRootPageObject as _UtamBaseRootPageObject, UtamBasePageObject as _UtamBasePageObject, Driver as _Driver, Element as _Element, Locator as _Locator, BaseUtamElement as _BaseUtamElement, ContainerCtor as _ContainerCtor } from '@utam/core';
1
+
2
+ import { Driver as _Driver, Element as _Element, Locator as _Locator, ContainerCtor as _ContainerCtor, UtamBasePageObject as _UtamBasePageObject, UtamBaseRootPageObject as _UtamBaseRootPageObject } from '@utam/core';
3
+
4
+ /**
5
+ * @lwrjs/router Outlet dynamically renders LWC view components.
6
+ * generated from JSON src/modules/lwr/outlet/__utam__/outlet.utam.json
7
+ * @version 0.10
8
+ * @author lwr-js
9
+ */
2
10
  export default class Outlet extends _UtamBaseRootPageObject {
3
11
  constructor(driver: _Driver, element?: _Element, locator?: _Locator);
4
-
12
+ waitForOutletContent(): Promise<this>;
5
13
  getContent<T extends _UtamBasePageObject>(ContainerCtor: _ContainerCtor<T>): Promise<T>;
6
14
  }
@@ -1,16 +1,23 @@
1
- import { By as _By, ShadowRoot as _ShadowRoot, UtamBaseRootPageObject as _UtamBaseRootPageObject, createUtamMixinCtor as _createUtamMixinCtor, UtamBasePageObject as _UtamBasePageObject } from '@utam/core';
1
+
2
+ import { By as _By, createUtamMixinCtor as _createUtamMixinCtor, UtamBaseRootPageObject as _UtamBaseRootPageObject } from '@utam/core';
2
3
 
3
4
  async function _utam_get_content(driver, root) {
4
5
  let _element = root;
5
- const _locator = _By.css(`lwr-dynamic`);
6
- _element = new _ShadowRoot(driver, _element);
6
+ const _locator = _By.css("lwr-dynamic");
7
7
  return _element.findElement(_locator);
8
8
  }
9
9
 
10
+ /**
11
+ * @lwrjs/router Outlet dynamically renders LWC view components.
12
+ * generated from JSON src/modules/lwr/outlet/__utam__/outlet.utam.json
13
+ * @version 0.10
14
+ * @author lwr-js
15
+ */
10
16
  export default class Outlet extends _UtamBaseRootPageObject {
11
- constructor(driver, element, locator = _By.css(`lwr-outlet`)) {
17
+ constructor(driver, element, locator = _By.css("lwr-outlet")) {
12
18
  super(driver, element, locator);
13
19
  }
20
+
14
21
  async __getRoot() {
15
22
  const driver = this.driver;
16
23
  const root = await this.getRootElement();
@@ -21,8 +28,18 @@ export default class Outlet extends _UtamBaseRootPageObject {
21
28
  async getContent(ContainerCtor) {
22
29
  const driver = this.driver;
23
30
  const root = await this.getRootElement();
24
- let element = await _utam_get_content(driver, root, );
31
+ let element = await _utam_get_content(driver, root);
25
32
  element = new ContainerCtor(driver, element);
26
33
  return element;
27
34
  }
35
+
36
+ async waitForOutletContent() {
37
+ await this.waitFor(async () => {
38
+ const _statement0 = await this.__getRoot();
39
+ const _result0 = await _statement0.containsElement(_By.css("lwr-dynamic"), true);
40
+ return _result0;
41
+ });
42
+ return this;
43
+ }
44
+
28
45
  }
@@ -1,7 +0,0 @@
1
- export declare const CONTEXT_ID_BACKDOOR: string;
2
- export declare type NavigationContextBackdoorEvent = globalThis.CustomEvent<NavigationContextBackdoorEventPayload>;
3
- import type { ContextId } from 'lwr/navigation';
4
- export declare type NavigationContextBackdoorEventPayload = {
5
- callback: (contextId: ContextId) => void;
6
- };
7
- //# sourceMappingURL=navigationMixinHacks.d.ts.map