@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.
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/contextProvider/contextProvider.d.ts +14 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/contextUtils/contextInfo.d.ts +60 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/contextUtils/contextUtils.d.ts +24 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/contextUtils/navigationApiStore.d.ts +45 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/currentPageReference/currentPageReference.d.ts +9 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/currentView/currentView.d.ts +3 -2
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/domRouter/domRouter.d.ts +192 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/domRouterUtils/domRouterUtils.d.ts +4 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/domRouterUtils/historyUtils.d.ts +21 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/domRouterUtils/types.d.ts +16 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/domRouterUtils/uriUtils.d.ts +30 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/historyRouter/historyRouter.d.ts +48 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/navigation/navigation.d.ts +16 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/navigation/navigationApi.d.ts +22 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/navigation/navigationMixin.d.ts +15 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/navigationContext/navigationContext.d.ts +5 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/navigationMixinHacks/navigationMixinHacks.d.ts +7 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/observable/observable.d.ts +14 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/outlet/outlet.d.ts +19 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/router/router.d.ts +11 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerBridge/routerBridge.d.ts +13 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerContainer/routerContainer.d.ts +51 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerContainer/utils.d.ts +32 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerErrors/routerErrors.d.ts +13 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerUtils/domUtils.d.ts +2 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerUtils/filterUtils.d.ts +19 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerUtils/parseUtils.d.ts +42 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerUtils/pathToRegexp.d.ts +128 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerUtils/routeDefUtils.d.ts +43 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerUtils/routeUtils.d.ts +39 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerUtils/routerUtils.d.ts +22 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerUtils/typeUtils.d.ts +38 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerUtils/types.d.ts +133 -0
- package/build/bundle/prod/lwr/navigation/es/modules/lwr/routerUtils/uriUtils.d.ts +66 -0
- package/build/bundle/prod/lwr/navigation/es/services/index.d.ts +28 -0
- package/build/bundle/prod/lwr/navigation/es/services/module-provider/index.d.ts +22 -0
- package/build/bundle/prod/lwr/navigation/es/services/module-provider/utils.d.ts +27 -0
- package/build/bundle/prod/lwr/navigation/navigation.js +1 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/contextProvider/contextProvider.d.ts +14 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/contextUtils/contextInfo.d.ts +60 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/contextUtils/contextUtils.d.ts +24 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/contextUtils/navigationApiStore.d.ts +45 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/currentPageReference/currentPageReference.d.ts +9 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/currentView/currentView.d.ts +3 -2
- package/build/bundle/prod/lwr/router/es/modules/lwr/domRouter/domRouter.d.ts +192 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/domRouterUtils/domRouterUtils.d.ts +4 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/domRouterUtils/historyUtils.d.ts +21 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/domRouterUtils/types.d.ts +16 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/domRouterUtils/uriUtils.d.ts +30 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/historyRouter/historyRouter.d.ts +48 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/navigation/navigation.d.ts +16 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/navigation/navigationApi.d.ts +22 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/navigation/navigationMixin.d.ts +15 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/navigationContext/navigationContext.d.ts +5 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/navigationMixinHacks/navigationMixinHacks.d.ts +7 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/observable/observable.d.ts +14 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/outlet/outlet.d.ts +19 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/router/router.d.ts +11 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/routerBridge/routerBridge.d.ts +13 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/routerContainer/routerContainer.d.ts +51 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/routerContainer/utils.d.ts +32 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/routerErrors/routerErrors.d.ts +13 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/routerUtils/domUtils.d.ts +2 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/routerUtils/filterUtils.d.ts +19 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/routerUtils/parseUtils.d.ts +42 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/routerUtils/pathToRegexp.d.ts +128 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/routerUtils/routeDefUtils.d.ts +43 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/routerUtils/routeUtils.d.ts +39 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/routerUtils/routerUtils.d.ts +22 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/routerUtils/typeUtils.d.ts +38 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/routerUtils/types.d.ts +133 -0
- package/build/bundle/prod/lwr/router/es/modules/lwr/routerUtils/uriUtils.d.ts +66 -0
- package/build/bundle/prod/lwr/router/es/services/index.d.ts +28 -0
- package/build/bundle/prod/lwr/router/es/services/module-provider/index.d.ts +22 -0
- package/build/bundle/prod/lwr/router/es/services/module-provider/utils.d.ts +27 -0
- package/build/bundle/prod/lwr/router/router.js +1 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/contextProvider/contextProvider.d.ts +14 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/contextUtils/contextInfo.d.ts +60 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/contextUtils/contextUtils.d.ts +24 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/contextUtils/navigationApiStore.d.ts +45 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/currentPageReference/currentPageReference.d.ts +9 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/currentView/currentView.d.ts +3 -2
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/domRouter/domRouter.d.ts +192 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/domRouterUtils/domRouterUtils.d.ts +4 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/domRouterUtils/historyUtils.d.ts +21 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/domRouterUtils/types.d.ts +16 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/domRouterUtils/uriUtils.d.ts +30 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/historyRouter/historyRouter.d.ts +48 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/navigation/navigation.d.ts +16 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/navigation/navigationApi.d.ts +22 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/navigation/navigationMixin.d.ts +15 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/navigationContext/navigationContext.d.ts +5 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/navigationMixinHacks/navigationMixinHacks.d.ts +7 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/observable/observable.d.ts +14 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/outlet/outlet.d.ts +19 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/router/router.d.ts +11 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerBridge/routerBridge.d.ts +13 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerContainer/routerContainer.d.ts +51 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerContainer/utils.d.ts +32 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerErrors/routerErrors.d.ts +13 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerUtils/domUtils.d.ts +2 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerUtils/filterUtils.d.ts +19 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerUtils/parseUtils.d.ts +42 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerUtils/pathToRegexp.d.ts +128 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerUtils/routeDefUtils.d.ts +43 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerUtils/routeUtils.d.ts +39 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerUtils/routerUtils.d.ts +22 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerUtils/typeUtils.d.ts +38 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerUtils/types.d.ts +133 -0
- package/build/bundle/prod/lwr/routerContainer/es/modules/lwr/routerUtils/uriUtils.d.ts +66 -0
- package/build/bundle/prod/lwr/routerContainer/es/services/index.d.ts +28 -0
- package/build/bundle/prod/lwr/routerContainer/es/services/module-provider/index.d.ts +22 -0
- package/build/bundle/prod/lwr/routerContainer/es/services/module-provider/utils.d.ts +27 -0
- package/build/bundle/prod/lwr/routerContainer/routerContainer.js +1 -0
- package/build/es/modules/lwr/currentPageReference/currentPageReference.d.ts +1 -1
- package/build/es/modules/lwr/currentView/currentView.d.ts +2 -2
- package/build/es/modules/lwr/domRouter/domRouter.d.ts +2 -2
- package/build/es/modules/lwr/domRouterUtils/types.d.ts +1 -1
- package/build/es/modules/lwr/navigationContext/navigationContext.d.ts +2 -2
- package/build/es/modules/lwr/navigationMixinHacks/navigationMixinHacks.d.ts +2 -2
- package/build/es/modules/lwr/routerUtils/filterUtils.d.ts +1 -1
- package/build/es/modules/lwr/routerUtils/pathToRegexp.d.ts +5 -5
- package/build/es/modules/lwr/routerUtils/types.d.ts +23 -23
- package/package.json +7 -7
|
@@ -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¶m2=two¶m3"
|
|
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
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AbstractModuleId, ModuleCompiled, ModuleEntry, ModuleProvider, ProviderContext } from '@lwrjs/types';
|
|
2
|
+
interface RouterProviderOptions {
|
|
3
|
+
routesDir?: string;
|
|
4
|
+
}
|
|
5
|
+
export default class RouterModuleProvider implements ModuleProvider {
|
|
6
|
+
name: string;
|
|
7
|
+
version: string;
|
|
8
|
+
routesDir: string;
|
|
9
|
+
appBasePath?: string;
|
|
10
|
+
private routerEmitter;
|
|
11
|
+
private routerWatcher?;
|
|
12
|
+
private watchedFileMap;
|
|
13
|
+
private routerModuleCache;
|
|
14
|
+
constructor({ routesDir }: RouterProviderOptions, context: ProviderContext);
|
|
15
|
+
onRouterModuleChange(configPath: string, deleted?: boolean): Promise<void>;
|
|
16
|
+
private watchConfigs;
|
|
17
|
+
private getRouterConfig;
|
|
18
|
+
getModuleEntry({ specifier }: AbstractModuleId): Promise<ModuleEntry | undefined>;
|
|
19
|
+
getModule(moduleId: AbstractModuleId): Promise<ModuleCompiled | undefined>;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Watcher } from '@lwrjs/types';
|
|
2
|
+
import type { LwrRouterConfig } from '../index.js';
|
|
3
|
+
import type { WatcherFactory } from '@lwrjs/types';
|
|
4
|
+
export declare const SPECIFIER_PREFIX = "@lwrjs/router/";
|
|
5
|
+
/**
|
|
6
|
+
* Parse a specifier into its Router Config ID
|
|
7
|
+
* Return undefined if the specifier is invalid
|
|
8
|
+
* @param specifier - The raw specifier to parse
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseSpecifier(specifier: string): string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Given a Router Config ID and directory, return the file path to the router metadata
|
|
13
|
+
* @param dir - Path to directory containing Router Config files
|
|
14
|
+
* @param specifier - Specifier for the Router Config module
|
|
15
|
+
*/
|
|
16
|
+
export declare function getRouterConfigPath(dir: string, specifier: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Set up a file system watcher; used to spy on Router Config file changes
|
|
19
|
+
* @param onModuleChange - File change callback function
|
|
20
|
+
*/
|
|
21
|
+
export declare function setUpWatcher(factory: WatcherFactory, onModuleChange: (file: string, deleted?: boolean) => void): Watcher;
|
|
22
|
+
/**
|
|
23
|
+
* Generate a module string which fulfills a router request
|
|
24
|
+
* @param routes - The array of route definitions
|
|
25
|
+
*/
|
|
26
|
+
export declare function generateModule(config?: LwrRouterConfig): string;
|
|
27
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1,2 @@
|
|
|
1
1
|
import{parseFragment as e,registerTemplate as t,freezeTemplate as r,createContextProvider as i,registerDecorators as n,registerComponent as o,LightningElement as s}from"lwc";import{ROUTER_VIEW as a,ROUTER_NAV as c,ROUTER_ERROR as d}from"lwr/metrics";import{logOperationEnd as l,logOperationStart as h}from"lwr/profiler";var u=[function(e,t,r){return"span.router-title"+(e?"["+e+"]":"")+" {position: absolute;margin: -1px;border: 0;padding: 0;width: 1px;height: 1px;overflow: hidden;clip: rect(0 0 0 0);text-transform: none;white-space: nowrap;}"}];const p=e`<span class="router-title${0}" aria-live="polite" aria-atomic="true"${2}></span>`,v={key:0},g=[];function f(e,t,r,i){const{s:n,st:o,f:s}=e;return s([n("",v,g,r),o(p(),2)])}var m=t(f);function b(e){if(null==e)throw new TypeError("Provider must be defined.")}f.slots=[""],f.stylesheets=[],f.renderMode="light",u&&f.stylesheets.push.apply(f.stylesheets,u),f.stylesheetToken="lwr-routerContainer_routerContainer",r(f);class E{constructor(e){this.infoMap=new WeakMap,this.defaultValue=e}getInfo(e){let t=this.infoMap.get(e);return void 0===t&&(t={consumers:new Set},this.infoMap.set(e,t)),t}setContext(e,t){b(e);const r=t,i=this.getInfo(e);i.contextValue=t,i.consumers.forEach((e=>e.provide(r))),0===i.consumers.size&&r?.onComplete&&r.onComplete()}getContext(e){b(e);const{contextValue:t}=this.getInfo(e);return void 0!==t?t:this.defaultValue}clearContext(e){b(e),this.infoMap.delete(e)}subscribeContext(e,t){b(e);const{consumers:r,contextValue:i}=this.getInfo(e);r.has(t)||(r.add(t),t.provide(i))}unsubscribeContext(e,t){b(e),this.getInfo(e).consumers.delete(t)}}function I(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function w(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?I(Object(r),!0).forEach((function(t){N(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):I(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function N(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const y="LWR",_=1;function O(e,t){return Array.isArray(t)?e.replace(/\{([0-9]+)\}/g,((e,r)=>t[r])):e}function P(e,t){const r=w(w({},e),{},{message:O(e.message,t)});return e.address&&(r.address=O(e.address,t)),e.stack&&(r.stack=O(e.stack,t)),r}function R(e,t,r){if(!e)throw new Error(function(e,t){return`${e.code}: ${O(e.message,t)}`}(t,r))}const x={INVALID_MIXIN_CMP:{code:`${y}4001`,message:"{0} must be an Element type",level:_},MISSING_CONTEXT:{code:`${y}4002`,message:"Could not find context to perform navigation action.",level:_},INVALID_CONTEXT:{code:`${y}4003`,message:"Cannot register navigation context; it must have this shape: { navigate, generateUrl, subscribe }",level:_},MULTIPLE_ROOTS:{code:`${y}4004`,message:"Router connection failed. There can only be one root router.",level:_},MULTIPLE_CHILDREN:{code:`${y}4005`,message:"Could not add to the navigation hierarchy. There can only be one child per navigation node.",level:_},MISSING_ROUTE:{code:`${y}4006`,message:'A route cannot be created to navigate to URL "{0}"',level:_,address:"{0}"},MISSING_URL:{code:`${y}4007`,message:'A URL cannot be created to navigate to route "{0}"',level:_,address:"{0}"},PRENAV_FAILED:{code:`${y}4008`,message:'A preNavigate hook listener blocked routing to "{0}"',level:2,address:"{0}"},MISSING_ROUTE_TEMPLATE:{code:`${y}4009`,message:'A route definition must contain a "uri" property.',level:_},MISSING_ROUTE_CMP:{code:`${y}4016`,message:"Expected a route view component with a default export.",level:_},MISSING_DATA_CONTEXT:{code:`${y}4018`,message:"Could not find context to retrieve navigation data.",level:_},INVALID_ROUTE_QUERY:{code:`${y}4019`,message:"Invalid query param in route definition.",level:_},MISSING_PAGE_BINDING:{code:`${y}4020`,message:"Route definition must provide page binding",level:_},INVALID_PAGE_BINDING:{code:`${y}4021`,message:"Invalid page binding in route definition",level:_},INVALID_URI_SYNTAX:{code:`${y}4022`,message:"Invalid uri syntax. URI cannot contain *, +, (, ), ",level:_},VIEW_IMPORT_FAILED:{code:`${y}4023`,message:'Error importing view with name "{0}", failure was: {1}',level:_,stack:"{2}"},VIEW_MISSING:{code:`${y}4024`,message:'Expected a view with name "{0}" in the viewset',level:_},VIEW_IMPORT_FAILED_WITH_SPECIFIER:{code:`${y}4025`,message:'Error importing module "{0}" from view with name "{1}", failure was: {2}',level:_,stack:"{3}"},NO_ROUTE_MATCH:{code:`${y}4026`,message:"A routing match cannot be found for: {0}",level:_},INVALID_ROUTE_HANDLER:{code:`${y}4027`,message:'Route definition "{0}" does not have a valid route handler module',level:_},DESTINATION_NOT_FOUND:{code:`${y}4028`,message:"Route handler returned 404: Not Found",level:_},DESTINATION_ERROR:{code:`${y}4029`,message:"Route handler returned error status {0}: {1}",level:_,stack:"{2}"}},C=new WeakMap;function T(e){var t;return(t=class{constructor(e){this._callback=e}connect(){}disconnect(){}update(e,t){t&&this._callback(t)}static setContext(t,r){e.setContext(t,r)}static getContext(t){return e.getContext(t)}static clearContext(t){e.clearContext(t)}static subscribeContext(t,r){e.subscribeContext(t,r)}static unsubscribeContext(t,r){e.unsubscribeContext(t,r)}}).contextSchema={value:"required"},t}const S=T(new E(void 0)),D=T(new E(void 0)),A=new E(void 0),M=class extends(T(A)){async update(e,t){if(t){const r=e&&e.viewName?e.viewName:"default",i=t.viewset[r],n=i,o=n&&n.module||i;let s;if(o)try{const e=await o(),t=e&&e.default;if(!t||void 0===t.constructor)throw new Error("error occurred with view import");this._callback(t)}catch(e){const t=e;s=n.specifier?P(x.VIEW_IMPORT_FAILED_WITH_SPECIFIER,[n.specifier,r,t.message,t.stack||""]):P(x.VIEW_IMPORT_FAILED,[r,t.message,t.stack||""])}else s=P(x.VIEW_MISSING,[r]);t.onComplete&&t.onComplete(s)}}};function $(){const e=[],t=t=>{"function"==typeof t&&e.push(t)};return{add:(e=[])=>{Array.isArray(e)?e.forEach((e=>t(e))):t(e)},compile:t=>0===e.length?Promise.resolve(!0):e.reduce(((e,r)=>e.then((e=>!1===e?Promise.reject():Promise.resolve(r(t))))),Promise.resolve(!0)).then((e=>!1!==e)).catch((e=>{if(e instanceof Error)throw e;return!1})),empty:()=>0===e.length}}function L(e=""){return e=e||"",decodeURIComponent(e)}function U(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}const j="undefined"!=typeof document,k=`universalcontainergetnavigationcontext${U()}`,F=j?i(D):void 0,V=j?i(M):void 0,G=j?i(S):void 0;function W(e,t,r,i){r&&i&&(i.setContext(t,e),r(t,{consumerConnectedCallback:i.subscribeContext.bind(i,t),consumerDisconnectedCallback:i.unsubscribeContext.bind(i,t)}))}function H(){let e,t,r=[];const i=i=>{r.filter((e=>null!==e)).forEach((e=>e.error&&e.error(i))),e=void 0,t=i};return{next:i=>{r.filter((e=>null!==e)).forEach((e=>e.next&&e.next(i))),e=i,t=void 0},error:i,complete:()=>{r.filter((e=>null!==e)).forEach((e=>e.complete&&e.complete())),r=[],e=void 0,t=void 0},subscribe:(n,o=!0)=>{(e=>{r.push(e)})(n),e&&o&&n.next(e),t&&i(t);const s=r.length-1;return{unsubscribe:()=>(e=>{r=[...r.slice(0,e),...r.slice(e+1)]})(s)}}}}function B(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function X(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?B(Object(r),!0).forEach((function(t){q(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):B(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function q(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const z=`universalcontainernavigationevent${U()}`,Y=`universalcontainerparentevent${U()}`;class J{constructor(e,t,r){this.pendingRoute=null,this.committedRoute=null,this.contextId=Object.freeze((()=>{})),this.connected=!1,this.preNavFilters=$(),this.errorNavFilters=$(),this._handleNavigationEvent=e=>{const t=e;if(t.detail&&"object"==typeof t.detail){const{url:e,replace:r,address:i}=t.detail;this.config.handleNavigation(i,r)?this.root&&!e?this.root.processError(P(x.MISSING_URL,[JSON.stringify(i)])):this.parent||this.process(e,r):t.stopPropagation()}},this._handleParentEvent=e=>{e.stopImmediatePropagation();const t=e;t&&t.detail&&"function"==typeof t.detail&&t.detail(this)},this.config={handleNavigation:e.handleNavigation||(()=>!0)},this.target=r||window,this.router=t,this.router.contextId=this.contextId,this.routeObservable=H()}get root(){if(!this.parent)return this;let e=this.parent;for(;e;){if(!e.parent)return e;e=e.parent}throw new Error("No root router could be found")}updateWires(e,t,r){if(r)this.processError(r);else{if(this.committedRoute&&e.route===this.committedRoute.route)return;l({id:a,specifier:this.eventId}),this.pendingRoute=this.pendingRoute||X(X({},e),{},{url:t}),this.committedRoute=X(X({},this.pendingRoute),e),D.setContext(this.target,e.route.pageReference),this.routeObservable.next(X(X({},this.committedRoute),{},{viewset:e.viewset})),l({id:c,specifier:this.eventId}),this.child&&this.child.process(this._stripUrlForChild(this.committedRoute.url))}}connect(){this._sendEvent(Y,(e=>{this.parent=e,e.addChild(this)}));const e={navigate:(e,t)=>this.navigate(e,t),generateUrl:e=>this.generateUrl(e),subscribe:(e,t)=>this.subscribe(e,t)};!function(e,t){const r={id:e,value:t,update:e=>{r.value=e}};C.set(r.id,r)}(this.contextId,e),W(this.contextId,this.target,G,S),W(void 0,this.target,F,D),W(void 0,this.target,V,M),this.router.subscribe((e=>{if(404===e.status)return void this.processError(P(x.DESTINATION_NOT_FOUND));if(e.status&&e.status>=400){const t=e.error||new Error;return void this.processError(P(x.DESTINATION_ERROR,[e.status.toString(),t.message,t.stack||""]))}const t=e.route.pageReference||{},r=this.router.generateUrl(t)||"";if(h({id:a,specifier:this.eventId}),e.viewset){const t={viewset:e.viewset,onComplete:this.updateWires.bind(this,e,r)};M.setContext(this.target,t)}else e.route.pageReference&&this.updateWires(e,r)}),!0),j&&(this.target.addEventListener(z,this._handleNavigationEvent),this.target.addEventListener(Y,this._handleParentEvent),this.target.addEventListener(k,(e=>{const t=e;t.detail.callback&&t.detail.callback(this.contextId)}))),this.connected=!0}disconnect(){this.target.removeEventListener(z,this._handleNavigationEvent),this.target.removeEventListener(Y,this._handleParentEvent),this.parent&&(this.parent.child=void 0),this.parent=void 0,this.child&&(this.child.parent=void 0),this.child=void 0,this.connected=!1}addPreNavigate(e){this.preNavFilters.add(e)}addErrorNavigate(e){this.errorNavFilters.add(e)}async addChild(e){if(await new Promise((t=>{setTimeout((()=>{R(!this.child,x.MULTIPLE_CHILDREN),this.child=e,t()}),0)})),this.child&&this.committedRoute){const e=this._stripUrlForChild(this.committedRoute.url);await this.child.preProcess(e)&&this.child.process(e)}}async process(e,t){this.eventId=(new Date).getTime().toString(),h({id:c,specifier:this.eventId});try{this.parent||await this.preProcess(e)}catch(e){if(e.code)return this.processError(e),!1;throw e}const r=this.router.parseUrl(e);return r&&this.router.navigate(r),!0}preProcess(e){const t=this.router.parseUrl(e),r=t&&this.router.matchRoute(t);if(!r)return Promise.reject(P(x.MISSING_ROUTE,[e]));this.pendingRoute=X({url:e},r);return(this.preNavFilters.empty()?Promise.resolve(!0):this.preNavFilters.compile({current:this.committedRoute||void 0,next:this.pendingRoute})).then((t=>t&&this.child?this.child.preProcess(this._stripUrlForChild(e)):t)).then((t=>t||Promise.reject(P(x.PRENAV_FAILED,[e]))))}processError(e){h({id:d}),this.errorNavFilters.compile(e),this.child&&this.child.processError(e)}navigate(e,t){let r=this.router.generateUrl(e);if(r){r=(this.parent&&this.parent.committedRoute&&this.parent.committedRoute.pathMatch||"").concat(r)}this._sendEvent(z,{url:r,replace:t,address:e})}generateUrl(e){const t=this.router.generateUrl(e);if(!t)return null;return`${this.parent&&this.parent.committedRoute&&this.parent.committedRoute.pathMatch||""}${t}`}subscribe(e,t){return this.routeObservable.subscribe({next:e,error:()=>{},complete:()=>{}},Boolean(t))}_sendEvent(e,t){j&&this.target.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}_stripUrlForChild(e){return this.pendingRoute&&0===e.indexOf(this.pendingRoute.pathMatch)?e.replace(this.pendingRoute.pathMatch,""):e}}function Q(e){const t=function(e=""){if((e=e||"").indexOf("://")<0){const t=window.location.port?`:${window.location.port}`:"",r=`${window.location.protocol}//${window.location.hostname}${t}`,i="/"===e.charAt(0)?"":"/";e=r+i+e}const t={},r=document.createElement("a");r.href=e;const i=r.search.substring(1);return i&&i.split("&").forEach((e=>{const[r,i=""]=e.split("=");t[L(r)]=L(i)})),{href:r.href,origin:`${r.protocol}//${r.hostname}${r.port?`:${r.port}`:""}`,pathname:r.pathname.replace(/(\/)?/,"/"),searchParams:t}}(e),r=t.href.replace(/:\d+/,""),i=t.origin.replace(/:\d+/,"");return r.replace(i,"")}class K extends J{constructor(){super(...arguments),this.historyDisabled=!1}connect(){super.connect(),this.historyDisabled||(j&&window.addEventListener("popstate",this.onpopstate.bind(this)),this.onpopstate())}onpopstate(){!this.parent&&j&&this.catchBrowserUpdate(Q(document.location.href))}disconnect(){super.disconnect(),j&&window.removeEventListener("popstate",this.onpopstate)}async process(e,t,r=!0){const i=await super.process(e);return i&&!this.historyDisabled&&r&&this.connected&&!this.parent&&(t?function(e,t){const r=t||{};window.history.replaceState(r,"",e)}(e):function(e,t){const r=t||{};window.history.pushState(r,"",e)}(e)),i}catchBrowserUpdate(e){this.process(e,!1,!1)}}let Z=!1;class ee extends s{constructor(){super(),this.router=void 0,this.historyDisabled=!1,this.currentTitle=j?document.title:""}connectedCallback(){const e={historyDisabled:this.historyDisabled,handleNavigation:this.handleNavigation.bind(this)};this.router&&(this.routerApi=function(e,t={},r){const i=t.historyDisabled?new J(t,r,e):new K(t,r,e),n={addPreNavigate:e=>(i.addPreNavigate(e),n),addPostNavigate:e=>(i.subscribe(e),n),addErrorNavigate:e=>(i.addErrorNavigate(e),n),connect:()=>{i.connect(),R(!Z||!!i.parent,x.MULTIPLE_ROOTS),Z=Z||!i.parent,n.id=i.contextId},disconnect:()=>{Z=Z&&!!i.parent,i.disconnect()}};return n}(this,e,this.router),this.routerApi.addPreNavigate(this.preNavigate.bind(this)).addPostNavigate(this.postNavigate.bind(this)).addErrorNavigate(this.errorNavigate.bind(this)).connect())}preNavigate(e){const t=this._createEvent("prenavigate",e,!0);return this.dispatchEvent(t),!t.defaultPrevented}postNavigate(e){this.dispatchEvent(this._createEvent("postnavigate",e));const t=e.routeDefinition.metadata&&e.routeDefinition.metadata.title;t&&(this.currentTitle=t,document.title=t);const r=this.querySelector("span.router-title");r&&(r.innerHTML=this.currentTitle)}errorNavigate(e){return this.dispatchEvent(this._createEvent("errornavigate",e)),!0}handleNavigation(e,t){const r=this._createEvent("handlenavigation",{address:e,replace:t},!0);return this.dispatchEvent(r),!r.defaultPrevented}disconnectedCallback(){this.routerApi&&this.routerApi.disconnect()}_createEvent(e,t,r){return new CustomEvent(e,{detail:t,bubbles:!1,composed:!1,cancelable:r})}}ee.renderMode="light",n(ee,{publicProps:{router:{config:0},historyDisabled:{config:0}}});var te=o(ee,{tmpl:m,sel:"lwr-router-container"});export{te as default};
|
|
2
|
+
//# sourceMappingURL=routerContainer.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PageReference } from 'lwr/router';
|
|
2
|
-
type PageReferenceContext = PageReference | undefined;
|
|
2
|
+
declare type PageReferenceContext = PageReference | undefined;
|
|
3
3
|
/**
|
|
4
4
|
* Services @wire(CurrentPageReference) requests.
|
|
5
5
|
* Hooks up to an Observable from the current navigation context.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="lwc" />
|
|
2
2
|
import type { ViewSet } from 'lwr/router';
|
|
3
3
|
import type { Constructable } from 'lwr/routerUtils';
|
|
4
|
-
type ViewContext = {
|
|
4
|
+
declare type ViewContext = {
|
|
5
5
|
viewset: ViewSet;
|
|
6
6
|
onComplete?: Function;
|
|
7
7
|
} | undefined;
|
|
8
|
-
type CurrentViewConfig = {
|
|
8
|
+
declare type CurrentViewConfig = {
|
|
9
9
|
viewName?: string;
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
@@ -14,8 +14,8 @@ export declare const PARENT_EVENT: string;
|
|
|
14
14
|
interface RouterParent {
|
|
15
15
|
addChild(child: DomRouter): Promise<void>;
|
|
16
16
|
}
|
|
17
|
-
export type ParentRouterEvent = CustomEvent<(router: RouterParent) => void>;
|
|
18
|
-
type DomRoutingMatch = RoutingMatch & {
|
|
17
|
+
export declare type ParentRouterEvent = CustomEvent<(router: RouterParent) => void>;
|
|
18
|
+
declare type DomRoutingMatch = RoutingMatch & {
|
|
19
19
|
url: string;
|
|
20
20
|
};
|
|
21
21
|
interface DomRouterNode extends RouterParent {
|
|
@@ -3,7 +3,7 @@ export interface RouteChange {
|
|
|
3
3
|
current?: RoutingMatch;
|
|
4
4
|
next: RoutingMatch;
|
|
5
5
|
}
|
|
6
|
-
export type NavigationHandler = (address: PageReference, replace?: boolean) => boolean;
|
|
6
|
+
export declare type NavigationHandler = (address: PageReference, replace?: boolean) => boolean;
|
|
7
7
|
export interface DomRouterConfig {
|
|
8
8
|
handleNavigation?: NavigationHandler;
|
|
9
9
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type ContextId = () => void;
|
|
2
|
-
type NavigationContextType = ContextId | undefined;
|
|
1
|
+
export declare type ContextId = () => void;
|
|
2
|
+
declare type NavigationContextType = ContextId | undefined;
|
|
3
3
|
export declare const NavigationContext: import("lwr/contextUtils").ContextualWireAdapter<NavigationContextType, unknown, NavigationContextType>;
|
|
4
4
|
export {};
|
|
5
5
|
//# sourceMappingURL=navigationContext.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const CONTEXT_ID_BACKDOOR: string;
|
|
2
|
-
export type NavigationContextBackdoorEvent = globalThis.CustomEvent<NavigationContextBackdoorEventPayload>;
|
|
2
|
+
export declare type NavigationContextBackdoorEvent = globalThis.CustomEvent<NavigationContextBackdoorEventPayload>;
|
|
3
3
|
import type { ContextId } from 'lwr/navigation';
|
|
4
|
-
export type NavigationContextBackdoorEventPayload = {
|
|
4
|
+
export declare type NavigationContextBackdoorEventPayload = {
|
|
5
5
|
callback: (contextId: ContextId) => void;
|
|
6
6
|
};
|
|
7
7
|
//# sourceMappingURL=navigationMixinHacks.d.ts.map
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
export type Filter<V> = (v: V) => Promise<boolean> | boolean;
|
|
7
|
+
export declare type Filter<V> = (v: V) => Promise<boolean> | boolean;
|
|
8
8
|
export interface FilterChain<V> {
|
|
9
9
|
add: (f: Filter<V>[] | Filter<V>) => void;
|
|
10
10
|
compile: (arg: V) => Promise<boolean>;
|
|
@@ -26,7 +26,7 @@ export interface TokensToFunctionOptions {
|
|
|
26
26
|
*/
|
|
27
27
|
validate?: boolean;
|
|
28
28
|
}
|
|
29
|
-
export type PathFunction<P extends object = object> = (data?: P) => string;
|
|
29
|
+
export declare type PathFunction<P extends object = object> = (data?: P) => string;
|
|
30
30
|
/**
|
|
31
31
|
* Expose a method for transforming tokens into the path function.
|
|
32
32
|
*/
|
|
@@ -52,11 +52,11 @@ export interface MatchResult<P extends object = object> {
|
|
|
52
52
|
/**
|
|
53
53
|
* A match is either `false` (no match) or a match result.
|
|
54
54
|
*/
|
|
55
|
-
export type Match<P extends object = object> = false | MatchResult<P>;
|
|
55
|
+
export declare type Match<P extends object = object> = false | MatchResult<P>;
|
|
56
56
|
/**
|
|
57
57
|
* The match function takes a string and returns whether it matched the path.
|
|
58
58
|
*/
|
|
59
|
-
export type MatchFunction<P extends object = object> = (path: string) => Match<P>;
|
|
59
|
+
export declare type MatchFunction<P extends object = object> = (path: string) => Match<P>;
|
|
60
60
|
/**
|
|
61
61
|
* Create a path match function from `path-to-regexp` output.
|
|
62
62
|
*/
|
|
@@ -74,7 +74,7 @@ export interface Key {
|
|
|
74
74
|
/**
|
|
75
75
|
* A token is a string (nothing special) or key metadata (capture group).
|
|
76
76
|
*/
|
|
77
|
-
export type Token = string | Key;
|
|
77
|
+
export declare type Token = string | Key;
|
|
78
78
|
export interface TokensToRegexpOptions {
|
|
79
79
|
/**
|
|
80
80
|
* When `true` the regexp will be case sensitive. (default: `false`)
|
|
@@ -112,7 +112,7 @@ export declare function tokensToRegexp(tokens: Token[], keys?: Key[], options?:
|
|
|
112
112
|
/**
|
|
113
113
|
* Supported `path-to-regexp` input types.
|
|
114
114
|
*/
|
|
115
|
-
export type Path = string | RegExp | Array<string | RegExp>;
|
|
115
|
+
export declare type Path = string | RegExp | Array<string | RegExp>;
|
|
116
116
|
/**
|
|
117
117
|
* Normalize the given path string, returning a regular expression.
|
|
118
118
|
*
|
|
@@ -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 type Module = Record<string | symbol | number, unknown>;
|
|
5
|
-
export type Constructor<T = object> = new (...args: any[]) => T;
|
|
4
|
+
export declare type Module = Record<string | symbol | number, unknown>;
|
|
5
|
+
export declare type Constructor<T = object> = new (...args: any[]) => T;
|
|
6
6
|
export interface Constructable<T = object> {
|
|
7
7
|
constructor: Constructor<T>;
|
|
8
8
|
}
|
|
9
|
-
export type UrlMapper<TAddress> = {
|
|
9
|
+
export declare type UrlMapper<TAddress> = {
|
|
10
10
|
generateUrl(address: TAddress): string | null;
|
|
11
11
|
parseUrl(url: string): TAddress | null;
|
|
12
12
|
};
|
|
13
|
-
export type RouteMatcher<TAddress> = {
|
|
13
|
+
export declare type RouteMatcher<TAddress> = {
|
|
14
14
|
matchRoute(address: TAddress): RoutingMatch | null;
|
|
15
15
|
};
|
|
16
|
-
export type ViewMapper<TAddress> = {
|
|
16
|
+
export declare 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 type Router<TAddress = string> = ViewMapper<TAddress> & UrlMapper<TAddress> & RouteMatcher<TAddress>;
|
|
22
|
+
export declare 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 type RouterConfig = {
|
|
29
|
+
export declare 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 type RouterSerializationConfig<TAddress> = Required<Omit<RouterConfig, 'DEPRECATED_getRouteFromUrl' | 'DEPRECATED_getUrlFromRoute'> & UrlMapper<TAddress>>;
|
|
37
|
-
export type RouteParameterPatterns = {
|
|
36
|
+
export declare type RouterSerializationConfig<TAddress> = Required<Omit<RouterConfig, 'DEPRECATED_getRouteFromUrl' | 'DEPRECATED_getUrlFromRoute'> & UrlMapper<TAddress>>;
|
|
37
|
+
export declare 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 type PageBindings = {
|
|
49
|
+
export declare type PageBindings = {
|
|
50
50
|
attributeBindings: NullableStringAttributes;
|
|
51
51
|
stateBindings: NullableStringAttributes;
|
|
52
52
|
};
|
|
53
|
-
type CompiledQueryResult = {
|
|
53
|
+
declare type CompiledQueryResult = {
|
|
54
54
|
literalValue?: string | null;
|
|
55
55
|
routeParamName?: string;
|
|
56
56
|
};
|
|
57
|
-
export type CompiledQuery = Record<string, CompiledQueryResult>;
|
|
58
|
-
type MatchedQueryResult = {
|
|
57
|
+
export declare type CompiledQuery = Record<string, CompiledQueryResult>;
|
|
58
|
+
declare type MatchedQueryResult = {
|
|
59
59
|
value: string | null;
|
|
60
60
|
routeParamName?: string;
|
|
61
61
|
};
|
|
62
|
-
export type MatchedQuery = Record<string, MatchedQueryResult>;
|
|
63
|
-
export type QueryMatcher = (queryObject: QueryObject) => MatchedQuery | null;
|
|
62
|
+
export declare type MatchedQuery = Record<string, MatchedQueryResult>;
|
|
63
|
+
export declare 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 type RouteHandlerCallback = (routeDestination: RouteDestination) => void;
|
|
73
|
-
export type RouteHandlerClass = {
|
|
72
|
+
export declare type RouteHandlerCallback = (routeDestination: RouteDestination) => void;
|
|
73
|
+
export declare type RouteHandlerClass = {
|
|
74
74
|
new (callback: RouteHandlerCallback): RouteHandler;
|
|
75
75
|
};
|
|
76
|
-
export type RouteHandlerModule = {
|
|
76
|
+
export declare 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 type RouteDestination = {
|
|
85
|
+
export declare type RouteDestination = {
|
|
86
86
|
status?: 200 | 404 | 500;
|
|
87
87
|
viewset: ViewSet;
|
|
88
88
|
error?: Error;
|
|
89
89
|
};
|
|
90
|
-
export type RoutingMatch = {
|
|
90
|
+
export declare 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 type RoutingResult = RoutingMatch & RouteDestination;
|
|
99
|
+
export declare 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 type RouteCallback = (result: RoutingResult) => void;
|
|
107
|
+
export declare 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 type QueryObject = NullableStringAttributes;
|
|
125
|
+
export declare type QueryObject = NullableStringAttributes;
|
|
126
126
|
export interface StringAttributes {
|
|
127
127
|
[key: string]: string;
|
|
128
128
|
}
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
|
-
"version": "0.10.0-alpha.
|
|
8
|
+
"version": "0.10.0-alpha.13",
|
|
9
9
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -45,18 +45,18 @@
|
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "node ../../../bin/pack-lwc --dir src/modules build/modules && yarn utam:compile && yarn build:bundle",
|
|
47
47
|
"build:bundle": "rollup --config scripts/rollup.moduleBundle.config.cjs",
|
|
48
|
-
"utam:compile": "utam -c utam.config.cjs
|
|
48
|
+
"utam:compile": "utam -c utam.config.cjs"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@lwrjs/client-modules": "0.10.0-alpha.
|
|
52
|
-
"@lwrjs/diagnostics": "0.10.0-alpha.
|
|
53
|
-
"@lwrjs/shared-utils": "0.10.0-alpha.
|
|
51
|
+
"@lwrjs/client-modules": "0.10.0-alpha.13",
|
|
52
|
+
"@lwrjs/diagnostics": "0.10.0-alpha.13",
|
|
53
|
+
"@lwrjs/shared-utils": "0.10.0-alpha.13",
|
|
54
54
|
"ajv": "6.12.6"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@rollup/plugin-typescript": "^11.1.0",
|
|
58
58
|
"rollup": "^2.78.0",
|
|
59
|
-
"utam": "^2.0.
|
|
59
|
+
"utam": "^2.0.2"
|
|
60
60
|
},
|
|
61
61
|
"lwc": {
|
|
62
62
|
"modules": [
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"volta": {
|
|
85
85
|
"extends": "../../../package.json"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "f6d142d5a027554cb1685389e0b173734149683d"
|
|
88
88
|
}
|