@lwrjs/router 0.10.0-alpha.12 → 0.10.0-alpha.13

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 (124) hide show
  1. package/build/bundle/prod/lwr/navigation/es/modules/lwr/contextProvider/contextProvider.d.ts +14 -0
  2. package/build/bundle/prod/lwr/navigation/es/modules/lwr/contextUtils/contextInfo.d.ts +60 -0
  3. package/build/bundle/prod/lwr/navigation/es/modules/lwr/contextUtils/contextUtils.d.ts +24 -0
  4. package/build/bundle/prod/lwr/navigation/es/modules/lwr/contextUtils/navigationApiStore.d.ts +45 -0
  5. package/build/bundle/prod/lwr/navigation/es/modules/lwr/currentPageReference/currentPageReference.d.ts +9 -0
  6. package/build/bundle/prod/lwr/navigation/es/modules/lwr/currentView/currentView.d.ts +3 -2
  7. package/build/bundle/prod/lwr/navigation/es/modules/lwr/domRouter/domRouter.d.ts +192 -0
  8. package/build/bundle/prod/lwr/navigation/es/modules/lwr/domRouterUtils/domRouterUtils.d.ts +4 -0
  9. package/build/bundle/prod/lwr/navigation/es/modules/lwr/domRouterUtils/historyUtils.d.ts +21 -0
  10. package/build/bundle/prod/lwr/navigation/es/modules/lwr/domRouterUtils/types.d.ts +16 -0
  11. package/build/bundle/prod/lwr/navigation/es/modules/lwr/domRouterUtils/uriUtils.d.ts +30 -0
  12. package/build/bundle/prod/lwr/navigation/es/modules/lwr/historyRouter/historyRouter.d.ts +48 -0
  13. package/build/bundle/prod/lwr/navigation/es/modules/lwr/navigation/navigation.d.ts +16 -0
  14. package/build/bundle/prod/lwr/navigation/es/modules/lwr/navigation/navigationApi.d.ts +22 -0
  15. package/build/bundle/prod/lwr/navigation/es/modules/lwr/navigation/navigationMixin.d.ts +15 -0
  16. package/build/bundle/prod/lwr/navigation/es/modules/lwr/navigationContext/navigationContext.d.ts +5 -0
  17. package/build/bundle/prod/lwr/navigation/es/modules/lwr/navigationMixinHacks/navigationMixinHacks.d.ts +7 -0
  18. package/build/bundle/prod/lwr/navigation/es/modules/lwr/observable/observable.d.ts +14 -0
  19. package/build/bundle/prod/lwr/navigation/es/modules/lwr/outlet/outlet.d.ts +19 -0
  20. package/build/bundle/prod/lwr/navigation/es/modules/lwr/router/router.d.ts +11 -0
  21. package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerBridge/routerBridge.d.ts +13 -0
  22. package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerContainer/routerContainer.d.ts +51 -0
  23. package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerContainer/utils.d.ts +32 -0
  24. package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerErrors/routerErrors.d.ts +13 -0
  25. package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerUtils/domUtils.d.ts +2 -0
  26. package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerUtils/filterUtils.d.ts +19 -0
  27. package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerUtils/parseUtils.d.ts +42 -0
  28. package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerUtils/pathToRegexp.d.ts +128 -0
  29. package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerUtils/routeDefUtils.d.ts +43 -0
  30. package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerUtils/routeUtils.d.ts +39 -0
  31. package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerUtils/routerUtils.d.ts +22 -0
  32. package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerUtils/typeUtils.d.ts +38 -0
  33. package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerUtils/types.d.ts +133 -0
  34. package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerUtils/uriUtils.d.ts +66 -0
  35. package/build/bundle/prod/lwr/navigation/es/services/index.d.ts +28 -0
  36. package/build/bundle/prod/lwr/navigation/es/services/module-provider/index.d.ts +22 -0
  37. package/build/bundle/prod/lwr/navigation/es/services/module-provider/utils.d.ts +27 -0
  38. package/build/bundle/prod/lwr/navigation/navigation.js +1 -0
  39. package/build/bundle/prod/lwr/router/es/modules/lwr/contextProvider/contextProvider.d.ts +14 -0
  40. package/build/bundle/prod/lwr/router/es/modules/lwr/contextUtils/contextInfo.d.ts +60 -0
  41. package/build/bundle/prod/lwr/router/es/modules/lwr/contextUtils/contextUtils.d.ts +24 -0
  42. package/build/bundle/prod/lwr/router/es/modules/lwr/contextUtils/navigationApiStore.d.ts +45 -0
  43. package/build/bundle/prod/lwr/router/es/modules/lwr/currentPageReference/currentPageReference.d.ts +9 -0
  44. package/build/bundle/prod/lwr/router/es/modules/lwr/currentView/currentView.d.ts +3 -2
  45. package/build/bundle/prod/lwr/router/es/modules/lwr/domRouter/domRouter.d.ts +192 -0
  46. package/build/bundle/prod/lwr/router/es/modules/lwr/domRouterUtils/domRouterUtils.d.ts +4 -0
  47. package/build/bundle/prod/lwr/router/es/modules/lwr/domRouterUtils/historyUtils.d.ts +21 -0
  48. package/build/bundle/prod/lwr/router/es/modules/lwr/domRouterUtils/types.d.ts +16 -0
  49. package/build/bundle/prod/lwr/router/es/modules/lwr/domRouterUtils/uriUtils.d.ts +30 -0
  50. package/build/bundle/prod/lwr/router/es/modules/lwr/historyRouter/historyRouter.d.ts +48 -0
  51. package/build/bundle/prod/lwr/router/es/modules/lwr/navigation/navigation.d.ts +16 -0
  52. package/build/bundle/prod/lwr/router/es/modules/lwr/navigation/navigationApi.d.ts +22 -0
  53. package/build/bundle/prod/lwr/router/es/modules/lwr/navigation/navigationMixin.d.ts +15 -0
  54. package/build/bundle/prod/lwr/router/es/modules/lwr/navigationContext/navigationContext.d.ts +5 -0
  55. package/build/bundle/prod/lwr/router/es/modules/lwr/navigationMixinHacks/navigationMixinHacks.d.ts +7 -0
  56. package/build/bundle/prod/lwr/router/es/modules/lwr/observable/observable.d.ts +14 -0
  57. package/build/bundle/prod/lwr/router/es/modules/lwr/outlet/outlet.d.ts +19 -0
  58. package/build/bundle/prod/lwr/router/es/modules/lwr/router/router.d.ts +11 -0
  59. package/build/bundle/prod/lwr/router/es/modules/lwr/routerBridge/routerBridge.d.ts +13 -0
  60. package/build/bundle/prod/lwr/router/es/modules/lwr/routerContainer/routerContainer.d.ts +51 -0
  61. package/build/bundle/prod/lwr/router/es/modules/lwr/routerContainer/utils.d.ts +32 -0
  62. package/build/bundle/prod/lwr/router/es/modules/lwr/routerErrors/routerErrors.d.ts +13 -0
  63. package/build/bundle/prod/lwr/router/es/modules/lwr/routerUtils/domUtils.d.ts +2 -0
  64. package/build/bundle/prod/lwr/router/es/modules/lwr/routerUtils/filterUtils.d.ts +19 -0
  65. package/build/bundle/prod/lwr/router/es/modules/lwr/routerUtils/parseUtils.d.ts +42 -0
  66. package/build/bundle/prod/lwr/router/es/modules/lwr/routerUtils/pathToRegexp.d.ts +128 -0
  67. package/build/bundle/prod/lwr/router/es/modules/lwr/routerUtils/routeDefUtils.d.ts +43 -0
  68. package/build/bundle/prod/lwr/router/es/modules/lwr/routerUtils/routeUtils.d.ts +39 -0
  69. package/build/bundle/prod/lwr/router/es/modules/lwr/routerUtils/routerUtils.d.ts +22 -0
  70. package/build/bundle/prod/lwr/router/es/modules/lwr/routerUtils/typeUtils.d.ts +38 -0
  71. package/build/bundle/prod/lwr/router/es/modules/lwr/routerUtils/types.d.ts +133 -0
  72. package/build/bundle/prod/lwr/router/es/modules/lwr/routerUtils/uriUtils.d.ts +66 -0
  73. package/build/bundle/prod/lwr/router/es/services/index.d.ts +28 -0
  74. package/build/bundle/prod/lwr/router/es/services/module-provider/index.d.ts +22 -0
  75. package/build/bundle/prod/lwr/router/es/services/module-provider/utils.d.ts +27 -0
  76. package/build/bundle/prod/lwr/router/router.js +1 -0
  77. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/contextProvider/contextProvider.d.ts +14 -0
  78. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/contextUtils/contextInfo.d.ts +60 -0
  79. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/contextUtils/contextUtils.d.ts +24 -0
  80. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/contextUtils/navigationApiStore.d.ts +45 -0
  81. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/currentPageReference/currentPageReference.d.ts +9 -0
  82. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/currentView/currentView.d.ts +3 -2
  83. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/domRouter/domRouter.d.ts +192 -0
  84. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/domRouterUtils/domRouterUtils.d.ts +4 -0
  85. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/domRouterUtils/historyUtils.d.ts +21 -0
  86. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/domRouterUtils/types.d.ts +16 -0
  87. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/domRouterUtils/uriUtils.d.ts +30 -0
  88. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/historyRouter/historyRouter.d.ts +48 -0
  89. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/navigation/navigation.d.ts +16 -0
  90. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/navigation/navigationApi.d.ts +22 -0
  91. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/navigation/navigationMixin.d.ts +15 -0
  92. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/navigationContext/navigationContext.d.ts +5 -0
  93. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/navigationMixinHacks/navigationMixinHacks.d.ts +7 -0
  94. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/observable/observable.d.ts +14 -0
  95. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/outlet/outlet.d.ts +19 -0
  96. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/router/router.d.ts +11 -0
  97. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerBridge/routerBridge.d.ts +13 -0
  98. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerContainer/routerContainer.d.ts +51 -0
  99. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerContainer/utils.d.ts +32 -0
  100. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerErrors/routerErrors.d.ts +13 -0
  101. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerUtils/domUtils.d.ts +2 -0
  102. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerUtils/filterUtils.d.ts +19 -0
  103. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerUtils/parseUtils.d.ts +42 -0
  104. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerUtils/pathToRegexp.d.ts +128 -0
  105. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerUtils/routeDefUtils.d.ts +43 -0
  106. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerUtils/routeUtils.d.ts +39 -0
  107. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerUtils/routerUtils.d.ts +22 -0
  108. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerUtils/typeUtils.d.ts +38 -0
  109. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerUtils/types.d.ts +133 -0
  110. package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerUtils/uriUtils.d.ts +66 -0
  111. package/build/bundle/prod/lwr/routerContainer/es/services/index.d.ts +28 -0
  112. package/build/bundle/prod/lwr/routerContainer/es/services/module-provider/index.d.ts +22 -0
  113. package/build/bundle/prod/lwr/routerContainer/es/services/module-provider/utils.d.ts +27 -0
  114. package/build/bundle/prod/lwr/routerContainer/routerContainer.js +1 -0
  115. package/build/es/modules/lwr/currentPageReference/currentPageReference.d.ts +1 -1
  116. package/build/es/modules/lwr/currentView/currentView.d.ts +2 -2
  117. package/build/es/modules/lwr/domRouter/domRouter.d.ts +2 -2
  118. package/build/es/modules/lwr/domRouterUtils/types.d.ts +1 -1
  119. package/build/es/modules/lwr/navigationContext/navigationContext.d.ts +2 -2
  120. package/build/es/modules/lwr/navigationMixinHacks/navigationMixinHacks.d.ts +2 -2
  121. package/build/es/modules/lwr/routerUtils/filterUtils.d.ts +1 -1
  122. package/build/es/modules/lwr/routerUtils/pathToRegexp.d.ts +5 -5
  123. package/build/es/modules/lwr/routerUtils/types.d.ts +23 -23
  124. package/package.json +7 -7
@@ -0,0 +1,51 @@
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
+ import { LightningElement } from 'lwc';
8
+ import type { RouterApi } from './utils';
9
+ import type { MessageObject } from 'lwr/routerUtils';
10
+ import type { PageReference, Router, RoutingResult } from 'lwr/router';
11
+ import type { RouteChange } from 'lwr/domRouterUtils';
12
+ export default class RouterContainer extends LightningElement {
13
+ static renderMode: string;
14
+ routerApi?: RouterApi;
15
+ router?: Router<PageReference>;
16
+ historyDisabled: boolean;
17
+ currentTitle: string;
18
+ constructor();
19
+ /**
20
+ * Create a router attached to this component.
21
+ */
22
+ connectedCallback(): void;
23
+ /**
24
+ * The preNavigate hook surfaced as a cancelable CustomEvent.
25
+ * @param {RouteChange} - the current and proposed route information
26
+ */
27
+ preNavigate(routeChange: RouteChange): boolean;
28
+ /**
29
+ * The postNavigate hook surfaced as a CustomEvent.
30
+ * @param {RoutingResult} - the resulting navigation information
31
+ */
32
+ postNavigate(routingResult: RoutingResult): void;
33
+ /**
34
+ * The errorNavigate hook surfaced as a CustomEvent.
35
+ * @param {MessageObject} - error, the error encountered while navigating (if applicable)
36
+ */
37
+ errorNavigate(error: MessageObject): boolean;
38
+ /**
39
+ * The preNavigate hook surfaced as a cancelable CustomEvent.
40
+ * @param {object} - address: The address being navigated to
41
+ * @param {boolean} - shouldReplace
42
+ */
43
+ handleNavigation(address: PageReference, replace?: boolean): boolean;
44
+ /**
45
+ * Disconnect the router after DOM removal.
46
+ */
47
+ disconnectedCallback(): void;
48
+ private _createEvent;
49
+ }
50
+ export type { RouteChange } from 'lwr/domRouterUtils';
51
+ //# sourceMappingURL=routerContainer.d.ts.map
@@ -0,0 +1,32 @@
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
+ import type { Filter, MessageObject } from 'lwr/routerUtils';
8
+ import type { PageReference, RouteCallback, Router } from 'lwr/router';
9
+ import type { DomRouterConfig, RouteChange } from 'lwr/domRouterUtils';
10
+ import type { ContextId } from 'lwr/navigationContext';
11
+ export interface RouterApi {
12
+ addPreNavigate: (filter: Filter<RouteChange>) => RouterApi;
13
+ addPostNavigate: (listener: RouteCallback) => RouterApi;
14
+ addErrorNavigate: (listener: Filter<MessageObject>) => RouterApi;
15
+ connect: () => void;
16
+ disconnect: () => void;
17
+ id?: ContextId;
18
+ }
19
+ export interface RouterConfigApi extends DomRouterConfig {
20
+ historyDisabled?: boolean;
21
+ }
22
+ /**
23
+ * Create a new navigation context, attach to the given node.
24
+ * An application can only have ONE root router.
25
+ *
26
+ * @param {HTMLElement} - The DOM node where the navigation context should be established
27
+ * @param {object} config - The router config object, all properties are optional
28
+ *
29
+ * @returns {object} - { addPreNavigate, addPostNavigate, addErrorNavigate, connect, disconnect }
30
+ */
31
+ export declare function createNavigationContext(node: EventTarget, config: RouterConfigApi | undefined, portableRouter: Router<PageReference>): RouterApi;
32
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1,13 @@
1
+ /** @hidden */
2
+ /**
3
+ * Copyright (c) 2019, salesforce.com, inc.
4
+ * All rights reserved.
5
+ * SPDX-License-Identifier: MIT
6
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7
+ */
8
+ import type { MessageObject } from '../routerUtils/types';
9
+ export declare function generateMessage(info: MessageObject, args?: string[]): string;
10
+ export declare function generateMessageObject(info: MessageObject, args?: string[]): MessageObject;
11
+ export declare function invariant(condition: boolean, errorInfo: MessageObject, args?: string[]): void;
12
+ export declare const messages: Record<string, MessageObject>;
13
+ //# sourceMappingURL=routerErrors.d.ts.map
@@ -0,0 +1,2 @@
1
+ export declare const hasDocument: boolean;
2
+ //# sourceMappingURL=domUtils.d.ts.map
@@ -0,0 +1,19 @@
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
+ export declare type Filter<V> = (v: V) => Promise<boolean> | boolean;
8
+ export interface FilterChain<V> {
9
+ add: (f: Filter<V>[] | Filter<V>) => void;
10
+ compile: (arg: V) => Promise<boolean>;
11
+ empty: () => boolean;
12
+ }
13
+ /**
14
+ * Creates a filter chain as an array. Filters can return true, false or a Promise resulting in true or false.
15
+ *
16
+ * @returns {object}
17
+ */
18
+ export declare function createFilterChain<V>(): FilterChain<V>;
19
+ //# sourceMappingURL=filterUtils.d.ts.map
@@ -0,0 +1,42 @@
1
+ import type { CompiledRouteDefinition, RouterSerializationConfig } from 'lwr/routerUtils';
2
+ import type { QueryObject, CompiledQuery, QueryMatcher } from './types';
3
+ /**
4
+ * Parse the route definitions with path-to-regex functionality for paths, and
5
+ * query parameter validation
6
+ *
7
+ * @example
8
+ * {
9
+ * original: the user-defined route definition
10
+ * regex: regular expression based on the route definition path
11
+ * toPath: function which takes an object of parameters and creates a path
12
+ * params: an array of objects with info on each path parameter
13
+ * compiledQuery: an object that represents defined routeDefintion query params
14
+ * queryMatcher: a function that can be used to see if this route defintion
15
+ * mataches against a given input QueryObject
16
+ * }
17
+ */
18
+ export declare function parseRoutes<TAddress>(config: RouterSerializationConfig<TAddress>): CompiledRouteDefinition[];
19
+ /**
20
+ * Converts a QueryObject create from the routeDefintion.uri, and converts it into a
21
+ * CompiledQuery object that represents the defined 1) queryStringKeys, 2) routeParameter name,
22
+ * and 3) and what input is valid for this query. e.g.,
23
+ *
24
+ * Given the following uri: /path?someKey=:qParam, then "someKey" is the queryStringKey, ":qParam"
25
+ * is the route parameter name, and any input would be valid.
26
+ *
27
+ * @param {QueryObject} queryObject - queryObject retrieved from the routeDefinition uri
28
+ * @returns {CompiledQuery} - CompiledQuery
29
+ */
30
+ export declare function compileQueryObject(queryObject: QueryObject): CompiledQuery;
31
+ /**
32
+ * Takes a CompiledQuery a returns a QueryMatcher function that will match a QueryObject
33
+ * against the CompiledQuery and returns either a MatchedQuery, representing all the
34
+ * input values that match the CompiledQuery, or null if any input query parameter
35
+ * doesn't match the CompiledQuery.
36
+ *
37
+ * @param compiledQuery - CompiledQuery object to use to create the matcher
38
+ * @param {boolean} caseSensitive - true if this should case-sensitive match query values
39
+ * @returns {QueryMatcher} - The queryMatcher function
40
+ */
41
+ export declare function getQueryMatcher(compiledQuery: CompiledQuery, caseSensitive?: boolean): QueryMatcher;
42
+ //# sourceMappingURL=parseUtils.d.ts.map
@@ -0,0 +1,128 @@
1
+ export interface ParseOptions {
2
+ /**
3
+ * Set the default delimiter for repeat parameters. (default: `'/'`)
4
+ */
5
+ delimiter?: string;
6
+ /**
7
+ * List of characters to automatically consider prefixes when parsing.
8
+ */
9
+ prefixes?: string;
10
+ }
11
+ /**
12
+ * Parse a string for the raw tokens.
13
+ */
14
+ export declare function parse(str: string, options?: ParseOptions): Token[];
15
+ export interface TokensToFunctionOptions {
16
+ /**
17
+ * When `true` the regexp will be case sensitive. (default: `false`)
18
+ */
19
+ sensitive?: boolean;
20
+ /**
21
+ * Function for encoding input strings for output.
22
+ */
23
+ encode?: (value: string, token: Key) => string;
24
+ /**
25
+ * When `false` the function can produce an invalid (unmatched) path. (default: `true`)
26
+ */
27
+ validate?: boolean;
28
+ }
29
+ export declare type PathFunction<P extends object = object> = (data?: P) => string;
30
+ /**
31
+ * Expose a method for transforming tokens into the path function.
32
+ */
33
+ export declare function tokensToFunction<P extends object = object>(tokens: Token[], options?: TokensToFunctionOptions): PathFunction<P>;
34
+ /**
35
+ * Compile a string to a template function for the path.
36
+ */
37
+ export declare function compile<P extends object = object>(str: string, options?: ParseOptions & TokensToFunctionOptions): PathFunction<P>;
38
+ export interface RegexpToFunctionOptions {
39
+ /**
40
+ * Function for decoding strings for params.
41
+ */
42
+ decode?: (value: string, token: Key) => string;
43
+ }
44
+ /**
45
+ * A match result contains data about the path match.
46
+ */
47
+ export interface MatchResult<P extends object = object> {
48
+ path: string;
49
+ index: number;
50
+ params: P;
51
+ }
52
+ /**
53
+ * A match is either `false` (no match) or a match result.
54
+ */
55
+ export declare type Match<P extends object = object> = false | MatchResult<P>;
56
+ /**
57
+ * The match function takes a string and returns whether it matched the path.
58
+ */
59
+ export declare type MatchFunction<P extends object = object> = (path: string) => Match<P>;
60
+ /**
61
+ * Create a path match function from `path-to-regexp` output.
62
+ */
63
+ export declare function regexpToFunction<P extends object = object>(re: RegExp, keys: Key[], options?: RegexpToFunctionOptions): MatchFunction<P>;
64
+ /**
65
+ * Metadata about a key.
66
+ */
67
+ export interface Key {
68
+ name: string | number;
69
+ prefix: string;
70
+ suffix: string;
71
+ pattern: string;
72
+ modifier: string;
73
+ }
74
+ /**
75
+ * A token is a string (nothing special) or key metadata (capture group).
76
+ */
77
+ export declare type Token = string | Key;
78
+ export interface TokensToRegexpOptions {
79
+ /**
80
+ * When `true` the regexp will be case sensitive. (default: `false`)
81
+ */
82
+ sensitive?: boolean;
83
+ /**
84
+ * When `true` the regexp won't allow an optional trailing delimiter to match. (default: `false`)
85
+ */
86
+ strict?: boolean;
87
+ /**
88
+ * When `true` the regexp will match to the end of the string. (default: `true`)
89
+ */
90
+ end?: boolean;
91
+ /**
92
+ * When `true` the regexp will match from the beginning of the string. (default: `true`)
93
+ */
94
+ start?: boolean;
95
+ /**
96
+ * Sets the final character for non-ending optimistic matches. (default: `/`)
97
+ */
98
+ delimiter?: string;
99
+ /**
100
+ * List of characters that can also be "end" characters.
101
+ */
102
+ endsWith?: string;
103
+ /**
104
+ * Encode path tokens for use in the `RegExp`.
105
+ */
106
+ encode?: (value: string) => string;
107
+ }
108
+ /**
109
+ * Expose a function for taking tokens and returning a RegExp.
110
+ */
111
+ export declare function tokensToRegexp(tokens: Token[], keys?: Key[], options?: TokensToRegexpOptions): RegExp;
112
+ /**
113
+ * Supported `path-to-regexp` input types.
114
+ */
115
+ export declare type Path = string | RegExp | Array<string | RegExp>;
116
+ /**
117
+ * Normalize the given path string, returning a regular expression.
118
+ *
119
+ * An empty array can be passed in for the keys, which will hold the
120
+ * placeholder key descriptions. For example, using `/user/:id`, `keys` will
121
+ * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.
122
+ */
123
+ export declare function pathToRegexp(path: Path, keys?: Key[], options?: TokensToRegexpOptions & ParseOptions): RegExp;
124
+ /**
125
+ * Create path match function from `path-to-regexp` spec.
126
+ */
127
+ export declare function match<P extends object = object>(str: Path, options?: ParseOptions & TokensToRegexpOptions & RegexpToFunctionOptions): MatchFunction<P>;
128
+ //# sourceMappingURL=pathToRegexp.d.ts.map
@@ -0,0 +1,43 @@
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
+ import type { CompiledRouteDefinition, PageReference, StringAttributes, QueryObject, NullableStringAttributes } from './types';
8
+ /**
9
+ * f(route, routes[]) -> RouteDef
10
+ * Match a route's id to a Route Definition id from the given list.
11
+ *
12
+ * @param {object} route - Route to match to a Route Definition
13
+ * @param {array[object]} routeDefs - List of Route Definitions to match to the url
14
+ *
15
+ * @returns {object | null}
16
+ */
17
+ export declare function matchRouteDefinitionByPageReference(pageReference: PageReference, routeDefs: CompiledRouteDefinition[]): CompiledRouteDefinition | null;
18
+ /**
19
+ * Returns an object of paramName->pathValue pairs based on the given path string
20
+ * and the params defined within the routeDef uri
21
+ * @param path
22
+ * @param routeDef
23
+ */
24
+ export declare function getPathParams(path: string, routeDef: CompiledRouteDefinition): StringAttributes | null;
25
+ /**
26
+ * Returns an object of paramName->queryValue pairs based on the given queryObject
27
+ * and bindings defined within the routeDef uri
28
+ * @param queryObj
29
+ * @param routeDef
30
+ */
31
+ export declare function getQueryParams(queryObj: QueryObject, routeDef: CompiledRouteDefinition): NullableStringAttributes | null;
32
+ /**
33
+ * f(path, routeDef) -> { "attr1": "one", "attr2": "two" }
34
+ * Parse a path into an object of attributes based on the Route Definition's parameterized path.
35
+ * URI decode the path parts that are parsed as attributes.
36
+ *
37
+ * @param {string} path - A path (hopefully) matching the Route Definition
38
+ * @param {object} routeDef - Route Definition containing the path to parameterize
39
+ *
40
+ * @returns {object}
41
+ */
42
+ export declare function getPageReferenceFromUriAndRouteDef(uri: string, routeDef: CompiledRouteDefinition): PageReference | null;
43
+ //# sourceMappingURL=routeDefUtils.d.ts.map
@@ -0,0 +1,39 @@
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
+ import type { CompiledRouteDefinition, CompiledRoutingMatch, PageReference } from './types';
8
+ /**
9
+ * f(URL, routes[]?) -> route
10
+ * Match a URL's path to a Route Definition, use these to build a route.
11
+ *
12
+ * @param {string} url - URL string to turn into a route
13
+ * @param {array[object]} routeDefs - List of Route Definitions to match to the url
14
+ * @param {string} basePath - Optional: if provided, remove the base path before conversion.
15
+ *
16
+ * @returns {object}
17
+ */
18
+ export declare function matchRouteByUrl(url: string, routeDefs: CompiledRouteDefinition[], basePath?: string): CompiledRoutingMatch | null;
19
+ /**
20
+ * Serializes the given pageReference into a url based on the first route definition
21
+ * with a binding the pageReference matches against.
22
+ * @param pageReference pageReference to serialize into url
23
+ * @param routeDefs RouteDefs to match pageReference against
24
+ * @param basePath Base path for the url
25
+ * @returns the url or null if no match
26
+ */
27
+ export declare function getUrlFromPageReference(pageReference: PageReference, routeDefs: CompiledRouteDefinition[], basePath?: string): string | null;
28
+ /**
29
+ * Generates a url for the given pageReference using the given routeDef
30
+ * @param pageReference pageReference to serialize
31
+ * @param routeDef routeDef to that defines how serialize the given pageReference
32
+ * @returns url for the given pageReference
33
+ */
34
+ export declare function getUrlFromPageReferenceAndRouteDef(pageReference: PageReference, routeDef: CompiledRouteDefinition, basePath?: string): string;
35
+ /**
36
+ * Obtains the pageReference for the given URL
37
+ */
38
+ export declare function getPageReferenceFromUrl(url: string, routeDefs: CompiledRouteDefinition[], basePath?: string): PageReference | null;
39
+ //# sourceMappingURL=routeUtils.d.ts.map
@@ -0,0 +1,22 @@
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
+ export { createFilterChain } from './filterUtils';
8
+ export { getPageReferenceFromUriAndRouteDef } from './routeDefUtils';
9
+ export { getUrlFromPageReference, getPageReferenceFromUrl, matchRouteByUrl, getUrlFromPageReferenceAndRouteDef, } from './routeUtils';
10
+ export { isObject, freeze, guid, isValidRoute } from './typeUtils';
11
+ export { parseRoutes } from './parseUtils';
12
+ import { pathToRegexp as ptr, compile as ptrCompile } from './pathToRegexp';
13
+ export declare const pathToRegexp: {
14
+ pathToRegexp: typeof ptr;
15
+ compile: typeof ptrCompile;
16
+ };
17
+ export { getPathFromUrl, getQueryFromUrl, getQueryString, encode, decode } from './uriUtils';
18
+ export { hasDocument } from './domUtils';
19
+ export type { Key } from './pathToRegexp';
20
+ export type { Filter, FilterChain } from './filterUtils';
21
+ export type { CompiledRouteDefinition, CompiledRoutingMatch, Constructor, Constructable, MessageObject, Module, PageReference, RouteCallback, RouteDefinition, RouteHandler, RouteHandlerCallback, RouteHandlerClass, RouteHandlerModule, Router, RouterConfig, RouteDestination, RouteInstance, RoutingMatch, RoutingResult, StringAttributes, UrlMapper, ViewSet, ViewInfo, RouterSerializationConfig, } from './types';
22
+ //# sourceMappingURL=routerUtils.d.ts.map
@@ -0,0 +1,38 @@
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
+ * @param {*} o - Item to check if it's an object
9
+ * @returns {boolean}
10
+ */
11
+ export declare function isObject(o: unknown): boolean;
12
+ /**
13
+ * true if input is string
14
+ * @param o
15
+ */
16
+ export declare function isString(o: unknown): boolean;
17
+ /**
18
+ * @param {*} o - Object to freeze N layers deep (e.g. { prop: 'p', o: { one: 1, two: 2 } })
19
+ */
20
+ export declare function freeze(o: object, depthLimit?: number): object;
21
+ /**
22
+ * Return a 4 character identifier.
23
+ */
24
+ export declare function guid(): string;
25
+ /**
26
+ * f(route) -> true/false
27
+ *
28
+ * @param {*} route - Item to check if it's a valid route
29
+ *
30
+ * @returns {boolean}
31
+ */
32
+ export declare function isValidRoute(object: unknown): boolean;
33
+ /**
34
+ * Returns true if the given object is a valid pageReference.
35
+ * @param object
36
+ */
37
+ export declare function isValidPageReference(object: unknown): boolean;
38
+ //# sourceMappingURL=typeUtils.d.ts.map
@@ -0,0 +1,133 @@
1
+ import type { Key, PathFunction } from './pathToRegexp';
2
+ import type { ContextId } from 'lwr/navigationContext';
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;
6
+ export interface Constructable<T = object> {
7
+ constructor: Constructor<T>;
8
+ }
9
+ export declare type UrlMapper<TAddress> = {
10
+ generateUrl(address: TAddress): string | null;
11
+ parseUrl(url: string): TAddress | null;
12
+ };
13
+ export declare type RouteMatcher<TAddress> = {
14
+ matchRoute(address: TAddress): RoutingMatch | null;
15
+ };
16
+ export declare type ViewMapper<TAddress> = {
17
+ navigate(address: TAddress): void;
18
+ subscribe(callback: RouteCallback, replay?: boolean): Unsubscriber;
19
+ resolveView(address: TAddress): Promise<RouteDestination>;
20
+ contextId?: ContextId;
21
+ };
22
+ export declare type Router<TAddress = string> = ViewMapper<TAddress> & UrlMapper<TAddress> & RouteMatcher<TAddress>;
23
+ export interface DEPRECATED_getRouteFromUrl {
24
+ <TAddress>(url: string, defaultImpl: Function): TAddress | null;
25
+ }
26
+ export interface DEPRECATED_getUrlFromRoute {
27
+ <TAddress>(route: TAddress, defaultImpl: Function): string | null;
28
+ }
29
+ export declare type RouterConfig = {
30
+ basePath?: string;
31
+ routes?: RouteDefinition[];
32
+ caseSensitive?: boolean;
33
+ DEPRECATED_getRouteFromUrl?: DEPRECATED_getRouteFromUrl;
34
+ DEPRECATED_getUrlFromRoute?: DEPRECATED_getUrlFromRoute;
35
+ };
36
+ export declare type RouterSerializationConfig<TAddress> = Required<Omit<RouterConfig, 'DEPRECATED_getRouteFromUrl' | 'DEPRECATED_getUrlFromRoute'> & UrlMapper<TAddress>>;
37
+ export declare type RouteParameterPatterns = {
38
+ [paramName: string]: string;
39
+ };
40
+ export interface RouteDefinition<TMetadata = Record<string, any>> {
41
+ id: string;
42
+ uri: string;
43
+ patterns?: RouteParameterPatterns;
44
+ exact?: boolean;
45
+ page: Partial<PageReference>;
46
+ handler: () => Promise<RouteHandlerModule>;
47
+ metadata?: TMetadata;
48
+ }
49
+ export declare type PageBindings = {
50
+ attributeBindings: NullableStringAttributes;
51
+ stateBindings: NullableStringAttributes;
52
+ };
53
+ declare type CompiledQueryResult = {
54
+ literalValue?: string | null;
55
+ routeParamName?: string;
56
+ };
57
+ export declare type CompiledQuery = Record<string, CompiledQueryResult>;
58
+ declare type MatchedQueryResult = {
59
+ value: string | null;
60
+ routeParamName?: string;
61
+ };
62
+ export declare type MatchedQuery = Record<string, MatchedQueryResult>;
63
+ export declare type QueryMatcher = (queryObject: QueryObject) => MatchedQuery | null;
64
+ export interface CompiledRouteDefinition {
65
+ original: RouteDefinition;
66
+ regex: RegExp;
67
+ params: Key[];
68
+ toPath: PathFunction<object>;
69
+ compiledQuery: CompiledQuery;
70
+ queryMatcher: QueryMatcher;
71
+ }
72
+ export declare type RouteHandlerCallback = (routeDestination: RouteDestination) => void;
73
+ export declare type RouteHandlerClass = {
74
+ new (callback: RouteHandlerCallback): RouteHandler;
75
+ };
76
+ export declare type RouteHandlerModule = {
77
+ default: RouteHandlerClass;
78
+ };
79
+ export interface RouteInstance {
80
+ id: string;
81
+ attributes: NullableStringAttributes;
82
+ state: NullableStringAttributes;
83
+ pageReference: PageReference;
84
+ }
85
+ export declare type RouteDestination = {
86
+ status?: 200 | 404 | 500;
87
+ viewset: ViewSet;
88
+ error?: Error;
89
+ };
90
+ export declare type RoutingMatch = {
91
+ pathMatch: string;
92
+ route: RouteInstance;
93
+ routeDefinition: RouteDefinition;
94
+ };
95
+ export interface CompiledRoutingMatch {
96
+ route: RouteInstance;
97
+ routeDefinition: CompiledRouteDefinition;
98
+ }
99
+ export declare type RoutingResult = RoutingMatch & RouteDestination;
100
+ export interface ViewSet {
101
+ [viewName: string]: (() => Promise<Module>) | ViewInfo;
102
+ }
103
+ export interface ViewInfo {
104
+ module: () => Promise<Module>;
105
+ specifier: string;
106
+ }
107
+ export declare type RouteCallback = (result: RoutingResult) => void;
108
+ export interface RouteHandler {
109
+ dispose(): void;
110
+ update(routeInfo: RouteInstance): void;
111
+ }
112
+ export interface PageReference {
113
+ type: string;
114
+ attributes: NullableStringAttributes;
115
+ state: NullableStringAttributes;
116
+ }
117
+ export interface MessageObject {
118
+ code: string | number;
119
+ message: string;
120
+ level: number;
121
+ stack?: string;
122
+ url?: string;
123
+ address?: string;
124
+ }
125
+ export declare type QueryObject = NullableStringAttributes;
126
+ export interface StringAttributes {
127
+ [key: string]: string;
128
+ }
129
+ export interface NullableStringAttributes {
130
+ [key: string]: string | null;
131
+ }
132
+ export {};
133
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,66 @@
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
+ import type { QueryObject, CompiledQuery } from './types';
8
+ /**
9
+ * f("one two &") -> "one%20two%20%26"
10
+ *
11
+ * @param str - String to URI encode
12
+ *
13
+ * @returns {string}
14
+ */
15
+ export declare function encode(str?: string): string;
16
+ /**
17
+ * f("one%20two%20%26") -> "one two &"
18
+ *
19
+ * @param str - String to URI decode
20
+ *
21
+ * @returns {string}
22
+ */
23
+ export declare function decode(str?: string): string;
24
+ /**
25
+ * f(url) -> "/some/relative/path"
26
+ * Output will...
27
+ * - always start with '/'
28
+ * - not contain query params or fragment
29
+ * - akin to window.location.pathname
30
+ *
31
+ * @param {string} url - URL string to parse for a path
32
+ *
33
+ * @returns {string}
34
+ */
35
+ export declare function getPathFromUrl(url: string): string;
36
+ /**
37
+ * f(url) -> { "param1": "one", "param2": "two", param3: "" }
38
+ * Parameters without values get set to an empty string.
39
+ *
40
+ * @param {string} url - URL string to parse for a query object
41
+ *
42
+ * @returns {object}
43
+ */
44
+ export declare function getQueryFromUrl(url: string): QueryObject;
45
+ /**
46
+ * f({ "param1": "one", "param2": "two", param3: "" }) -> "?param1=one&param2=two&param3"
47
+ * Query parameter values, but not keys, get URI encoded.
48
+ *
49
+ * @param {object} queryObject - Query object to turn into a string
50
+ *
51
+ * @returns {string}
52
+ */
53
+ export declare function getQueryString(queryObj?: QueryObject): string;
54
+ /**
55
+ * Determines if the given string is a paramter name (":paramName")
56
+ * @param str string to test
57
+ * @returns true if string starts with ":"
58
+ */
59
+ export declare function isParam(str: string | null | undefined): boolean;
60
+ /**
61
+ * @param routeParamName - routeParamName from CompiledQueryResult
62
+ * @returns the paramName without prefix; or undefined
63
+ */
64
+ export declare function getParamName(routeParamName: string | undefined | null): string | false;
65
+ export declare function getQueryNames(compiledQuery: CompiledQuery): string[];
66
+ //# sourceMappingURL=uriUtils.d.ts.map
@@ -0,0 +1,28 @@
1
+ export declare const DEFAULT_SCHEMA = "pageReference_v1";
2
+ export interface LwrRouterConfig {
3
+ basePath?: string;
4
+ caseSensitive?: boolean;
5
+ routes: LwrConfigRouteDefinition[];
6
+ }
7
+ export interface LwrConfigRouteDefinition {
8
+ id: string;
9
+ uri: string;
10
+ patterns?: Record<string, string>;
11
+ exact?: boolean;
12
+ page: Partial<PageReference>;
13
+ metadata?: Record<string, any>;
14
+ handler?: string;
15
+ component?: string;
16
+ }
17
+ export interface PageReference {
18
+ type: string;
19
+ attributes: Record<string, string | null>;
20
+ state: Record<string, string | null>;
21
+ }
22
+ export declare function deleteRouterConfigJsonCacheEntry(path: string): void;
23
+ /**
24
+ * Given a Routes Config path, return the array of Config Route Definitions
25
+ * @param path - A path to a Route Config files
26
+ */
27
+ export declare function getClientRoutes(path: string): LwrRouterConfig | undefined;
28
+ //# sourceMappingURL=index.d.ts.map