@rxdi/router 0.7.190 → 0.7.191-nightly.0
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/dist/decorators.js +1 -2
- package/dist/helpers.js +3 -3
- package/dist/index.js +7 -3
- package/dist/injection.tokens.d.ts +4 -4
- package/dist/injection.tokens.js +2 -2
- package/dist/not-found.component.js +2 -2
- package/dist/router.component.js +2 -2
- package/dist/slot/index.js +5 -1
- package/dist/slot/slot.js +2 -2
- package/dist/vaadin/vaadin-router.d.ts +108 -8
- package/package.json +3 -3
package/dist/decorators.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RouteParams =
|
|
3
|
+
exports.RouteParams = RouteParams;
|
|
4
4
|
/**
|
|
5
5
|
* Define getter to `this.location.params` from component `this` and assign params to decorated property
|
|
6
6
|
*
|
|
@@ -36,4 +36,3 @@ function RouteParams() {
|
|
|
36
36
|
});
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
exports.RouteParams = RouteParams;
|
package/dist/helpers.js
CHANGED
|
@@ -9,7 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.ChildRoutesObservable = void 0;
|
|
13
|
+
exports.loadRoutes = loadRoutes;
|
|
14
|
+
exports.getQueryParams = getQueryParams;
|
|
13
15
|
const rxjs_1 = require("rxjs");
|
|
14
16
|
const injection_tokens_1 = require("./injection.tokens");
|
|
15
17
|
const core_1 = require("@rxdi/core");
|
|
@@ -106,7 +108,6 @@ function loadRoutes(routes) {
|
|
|
106
108
|
exports.ChildRoutesObservable.next(null);
|
|
107
109
|
return r;
|
|
108
110
|
}
|
|
109
|
-
exports.loadRoutes = loadRoutes;
|
|
110
111
|
function getQueryParams(params) {
|
|
111
112
|
const uriParams = new URLSearchParams(location.search);
|
|
112
113
|
return params.reduce((prev, curr) => {
|
|
@@ -114,4 +115,3 @@ function getQueryParams(params) {
|
|
|
114
115
|
return prev;
|
|
115
116
|
}, {});
|
|
116
117
|
}
|
|
117
|
-
exports.getQueryParams = getQueryParams;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -44,10 +48,10 @@ let RouterModule = RouterModule_1 = class RouterModule {
|
|
|
44
48
|
return RouterModule_1;
|
|
45
49
|
}
|
|
46
50
|
};
|
|
47
|
-
RouterModule =
|
|
51
|
+
exports.RouterModule = RouterModule;
|
|
52
|
+
exports.RouterModule = RouterModule = RouterModule_1 = __decorate([
|
|
48
53
|
(0, core_1.Module)()
|
|
49
54
|
], RouterModule);
|
|
50
|
-
exports.RouterModule = RouterModule;
|
|
51
55
|
__exportStar(require("./injection.tokens"), exports);
|
|
52
56
|
__exportStar(require("./outlet"), exports);
|
|
53
57
|
__exportStar(require("./decorators"), exports);
|
|
@@ -3,8 +3,8 @@ import { Outlet } from './outlet';
|
|
|
3
3
|
export interface NavigationTrigger {
|
|
4
4
|
}
|
|
5
5
|
export declare function Router(): (target: Object, propertyKey: string) => void;
|
|
6
|
-
export
|
|
7
|
-
export
|
|
6
|
+
export type LazyChildren = (context?: CanActivateContext, commands?: CanActivateCommands) => Promise<any>;
|
|
7
|
+
export type Router = Outlet;
|
|
8
8
|
export interface Route<C = any> {
|
|
9
9
|
path: string;
|
|
10
10
|
component?: C | Function | string;
|
|
@@ -59,8 +59,8 @@ export interface RouterOptions {
|
|
|
59
59
|
log?: boolean;
|
|
60
60
|
freeze?: boolean;
|
|
61
61
|
}
|
|
62
|
-
export
|
|
63
|
-
export
|
|
62
|
+
export type Routes = Route<any>[];
|
|
63
|
+
export type RouterRoutlet = Outlet;
|
|
64
64
|
export interface OnBeforeEnter {
|
|
65
65
|
onBeforeEnter(): Promise<any> | void;
|
|
66
66
|
}
|
package/dist/injection.tokens.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RouterOptions = exports.Routes = exports.RouterRoutlet =
|
|
3
|
+
exports.RouterOptions = exports.Routes = exports.RouterRoutlet = void 0;
|
|
4
|
+
exports.Router = Router;
|
|
4
5
|
const core_1 = require("@rxdi/core");
|
|
5
6
|
function Router() {
|
|
6
7
|
return (target, propertyKey) => {
|
|
@@ -9,7 +10,6 @@ function Router() {
|
|
|
9
10
|
});
|
|
10
11
|
};
|
|
11
12
|
}
|
|
12
|
-
exports.Router = Router;
|
|
13
13
|
exports.RouterRoutlet = 'router-outlet';
|
|
14
14
|
exports.Routes = 'router-routes';
|
|
15
15
|
exports.RouterOptions = 'router-options';
|
|
@@ -10,7 +10,8 @@ exports.NotFoundPathConfig = exports.NotFoundComponent = void 0;
|
|
|
10
10
|
const lit_html_1 = require("@rxdi/lit-html");
|
|
11
11
|
let NotFoundComponent = class NotFoundComponent extends lit_html_1.LitElement {
|
|
12
12
|
};
|
|
13
|
-
NotFoundComponent =
|
|
13
|
+
exports.NotFoundComponent = NotFoundComponent;
|
|
14
|
+
exports.NotFoundComponent = NotFoundComponent = __decorate([
|
|
14
15
|
(0, lit_html_1.Component)({
|
|
15
16
|
selector: 'not-found-component-rxdi',
|
|
16
17
|
template: () => (0, lit_html_1.html) `
|
|
@@ -19,7 +20,6 @@ NotFoundComponent = __decorate([
|
|
|
19
20
|
`,
|
|
20
21
|
})
|
|
21
22
|
], NotFoundComponent);
|
|
22
|
-
exports.NotFoundComponent = NotFoundComponent;
|
|
23
23
|
exports.NotFoundPathConfig = {
|
|
24
24
|
path: '(.*)',
|
|
25
25
|
component: 'not-found-component-rxdi',
|
package/dist/router.component.js
CHANGED
|
@@ -29,6 +29,7 @@ let RouterComponent = class RouterComponent extends lit_html_1.LitElement {
|
|
|
29
29
|
this.dispatchEvent(new CustomEvent('onRouterLoaded', { detail: router }));
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
|
+
exports.RouterComponent = RouterComponent;
|
|
32
33
|
__decorate([
|
|
33
34
|
(0, lit_html_1.property)(),
|
|
34
35
|
__metadata("design:type", String)
|
|
@@ -37,7 +38,7 @@ __decorate([
|
|
|
37
38
|
(0, lit_html_1.property)({ type: Array }),
|
|
38
39
|
__metadata("design:type", Array)
|
|
39
40
|
], RouterComponent.prototype, "routes", void 0);
|
|
40
|
-
RouterComponent = __decorate([
|
|
41
|
+
exports.RouterComponent = RouterComponent = __decorate([
|
|
41
42
|
(0, lit_html_1.Component)({
|
|
42
43
|
selector: "router-outlet",
|
|
43
44
|
template() {
|
|
@@ -49,4 +50,3 @@ RouterComponent = __decorate([
|
|
|
49
50
|
},
|
|
50
51
|
})
|
|
51
52
|
], RouterComponent);
|
|
52
|
-
exports.RouterComponent = RouterComponent;
|
package/dist/slot/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/slot/slot.js
CHANGED
|
@@ -25,6 +25,7 @@ let RouterSlots = class RouterSlots extends lit_html_1.LitElement {
|
|
|
25
25
|
this.routerSlot.add(this.slots);
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
+
exports.RouterSlots = RouterSlots;
|
|
28
29
|
__decorate([
|
|
29
30
|
(0, lit_html_1.property)({ type: Array }),
|
|
30
31
|
__metadata("design:type", Array)
|
|
@@ -33,7 +34,7 @@ __decorate([
|
|
|
33
34
|
(0, lit_html_1.query)('router-slot'),
|
|
34
35
|
__metadata("design:type", router_slot_1.RouterSlot)
|
|
35
36
|
], RouterSlots.prototype, "routerSlot", void 0);
|
|
36
|
-
RouterSlots = __decorate([
|
|
37
|
+
exports.RouterSlots = RouterSlots = __decorate([
|
|
37
38
|
(0, lit_html_1.Component)({
|
|
38
39
|
selector: 'router-slots',
|
|
39
40
|
template() {
|
|
@@ -41,4 +42,3 @@ RouterSlots = __decorate([
|
|
|
41
42
|
},
|
|
42
43
|
})
|
|
43
44
|
], RouterSlots);
|
|
44
|
-
exports.RouterSlots = RouterSlots;
|
|
@@ -36,14 +36,14 @@ export class Resolver {
|
|
|
36
36
|
*
|
|
37
37
|
* @return {!Array<!Router.Route>}
|
|
38
38
|
*/
|
|
39
|
-
getRoutes(): Array<
|
|
39
|
+
getRoutes(): Array<Router.Route>;
|
|
40
40
|
/**
|
|
41
41
|
* Sets the routing config (replacing the existing one).
|
|
42
42
|
*
|
|
43
43
|
* @param {!Array<!Router.Route>|!Router.Route} routes a single route or an array of those
|
|
44
44
|
* (the array is shallow copied)
|
|
45
45
|
*/
|
|
46
|
-
setRoutes(routes: Array<
|
|
46
|
+
setRoutes(routes: Array<Router.Route> | Router.Route): void;
|
|
47
47
|
/**
|
|
48
48
|
* Appends one or several routes to the routing config and returns the
|
|
49
49
|
* effective routing config after the operation.
|
|
@@ -53,7 +53,7 @@ export class Resolver {
|
|
|
53
53
|
* @return {!Array<!Router.Route>}
|
|
54
54
|
* @protected
|
|
55
55
|
*/
|
|
56
|
-
protected addRoutes(routes: Array<
|
|
56
|
+
protected addRoutes(routes: Array<Router.Route> | Router.Route): Array<Router.Route>;
|
|
57
57
|
/**
|
|
58
58
|
* Removes all existing routes from the routing config.
|
|
59
59
|
*/
|
|
@@ -160,7 +160,18 @@ export class Router extends Resolver {
|
|
|
160
160
|
* @param {?Node=} outlet
|
|
161
161
|
* @param {?RouterOptions=} options
|
|
162
162
|
*/
|
|
163
|
-
constructor(outlet?: (Node | null) | undefined, options?:
|
|
163
|
+
constructor(outlet?: (Node | null) | undefined, options?: (RouterOptions | null) | undefined);
|
|
164
|
+
resolveRoute: (context: any) => Promise<any>;
|
|
165
|
+
/**
|
|
166
|
+
* The base URL for all routes in the router instance. By default,
|
|
167
|
+
* if the base element exists in the `<head>`, vaadin-router
|
|
168
|
+
* takes the `<base href>` attribute value, resolves against current `document.URL`
|
|
169
|
+
* and gets the `pathname` from the result.
|
|
170
|
+
*
|
|
171
|
+
* @public
|
|
172
|
+
* @type {string}
|
|
173
|
+
*/
|
|
174
|
+
public baseUrl: string;
|
|
164
175
|
/**
|
|
165
176
|
* A promise that is settled after the current render cycle completes. If
|
|
166
177
|
* there is no render cycle in progress the promise is immediately settled
|
|
@@ -169,7 +180,7 @@ export class Router extends Resolver {
|
|
|
169
180
|
* @public
|
|
170
181
|
* @type {!Promise<!RouterLocation>}
|
|
171
182
|
*/
|
|
172
|
-
public ready: Promise<
|
|
183
|
+
public ready: Promise<RouterLocation>;
|
|
173
184
|
/**
|
|
174
185
|
* Contains read-only information about the current router location:
|
|
175
186
|
* pathname, active routes, parameters. See the
|
|
@@ -179,7 +190,7 @@ export class Router extends Resolver {
|
|
|
179
190
|
* @public
|
|
180
191
|
* @type {!RouterLocation}
|
|
181
192
|
*/
|
|
182
|
-
public location:
|
|
193
|
+
public location: RouterLocation;
|
|
183
194
|
__lastStartedRenderId: number;
|
|
184
195
|
__navigationEventHandler: any;
|
|
185
196
|
__createdByRouter: WeakMap<object, any>;
|
|
@@ -203,6 +214,95 @@ export class Router extends Resolver {
|
|
|
203
214
|
* @return {?Node} the current router outlet (or `undefined`)
|
|
204
215
|
*/
|
|
205
216
|
getOutlet(): Node | null;
|
|
217
|
+
/**
|
|
218
|
+
* Sets the routing config (replacing the existing one) and triggers a
|
|
219
|
+
* navigation event so that the router outlet is refreshed according to the
|
|
220
|
+
* current `window.location` and the new routing config.
|
|
221
|
+
*
|
|
222
|
+
* Each route object may have the following properties, listed here in the processing order:
|
|
223
|
+
* * `path` – the route path (relative to the parent route if any) in the
|
|
224
|
+
* [express.js syntax](https://expressjs.com/en/guide/routing.html#route-paths").
|
|
225
|
+
*
|
|
226
|
+
* * `children` – an array of nested routes or a function that provides this
|
|
227
|
+
* array at the render time. The function can be synchronous or asynchronous:
|
|
228
|
+
* in the latter case the render is delayed until the returned promise is
|
|
229
|
+
* resolved. The `children` function is executed every time when this route is
|
|
230
|
+
* being rendered. This allows for dynamic route structures (e.g. backend-defined),
|
|
231
|
+
* but it might have a performance impact as well. In order to avoid calling
|
|
232
|
+
* the function on subsequent renders, you can override the `children` property
|
|
233
|
+
* of the route object and save the calculated array there
|
|
234
|
+
* (via `context.route.children = [ route1, route2, ...];`).
|
|
235
|
+
* Parent routes are fully resolved before resolving the children. Children
|
|
236
|
+
* 'path' values are relative to the parent ones.
|
|
237
|
+
*
|
|
238
|
+
* * `action` – the action that is executed before the route is resolved.
|
|
239
|
+
* The value for this property should be a function, accepting `context`
|
|
240
|
+
* and `commands` parameters described below. If present, this function is
|
|
241
|
+
* always invoked first, disregarding of the other properties' presence.
|
|
242
|
+
* The action can return a result directly or within a `Promise`, which
|
|
243
|
+
* resolves to the result. If the action result is an `HTMLElement` instance,
|
|
244
|
+
* a `commands.component(name)` result, a `commands.redirect(path)` result,
|
|
245
|
+
* or a `context.next()` result, the current route resolution is finished,
|
|
246
|
+
* and other route config properties are ignored.
|
|
247
|
+
* See also **Route Actions** section in [Live Examples](#/classes/Router/demos/demo/index.html).
|
|
248
|
+
*
|
|
249
|
+
* * `redirect` – other route's path to redirect to. Passes all route parameters to the redirect target.
|
|
250
|
+
* The target route should also be defined.
|
|
251
|
+
* See also **Redirects** section in [Live Examples](#/classes/Router/demos/demo/index.html).
|
|
252
|
+
*
|
|
253
|
+
* * `bundle` – string containing the path to `.js` or `.mjs` bundle to load before resolving the route,
|
|
254
|
+
* or the object with "module" and "nomodule" keys referring to different bundles.
|
|
255
|
+
* Each bundle is only loaded once. If "module" and "nomodule" are set, only one bundle is loaded,
|
|
256
|
+
* depending on whether the browser supports ES modules or not.
|
|
257
|
+
* The property is ignored when either an `action` returns the result or `redirect` property is present.
|
|
258
|
+
* Any error, e.g. 404 while loading bundle will cause route resolution to throw.
|
|
259
|
+
* See also **Code Splitting** section in [Live Examples](#/classes/Router/demos/demo/index.html).
|
|
260
|
+
*
|
|
261
|
+
* * `component` – the tag name of the Web Component to resolve the route to.
|
|
262
|
+
* The property is ignored when either an `action` returns the result or `redirect` property is present.
|
|
263
|
+
* If route contains the `component` property (or an action that return a component)
|
|
264
|
+
* and its child route also contains the `component` property, child route's component
|
|
265
|
+
* will be rendered as a light dom child of a parent component.
|
|
266
|
+
*
|
|
267
|
+
* * `name` – the string name of the route to use in the
|
|
268
|
+
* [`router.urlForName(name, params)`](#/classes/Router#method-urlForName)
|
|
269
|
+
* navigation helper method.
|
|
270
|
+
*
|
|
271
|
+
* For any route function (`action`, `children`) defined, the corresponding `route` object is available inside the callback
|
|
272
|
+
* through the `this` reference. If you need to access it, make sure you define the callback as a non-arrow function
|
|
273
|
+
* because arrow functions do not have their own `this` reference.
|
|
274
|
+
*
|
|
275
|
+
* `context` object that is passed to `action` function holds the following properties:
|
|
276
|
+
* * `context.pathname` – string with the pathname being resolved
|
|
277
|
+
*
|
|
278
|
+
* * `context.search` – search query string
|
|
279
|
+
*
|
|
280
|
+
* * `context.hash` – hash string
|
|
281
|
+
*
|
|
282
|
+
* * `context.params` – object with route parameters
|
|
283
|
+
*
|
|
284
|
+
* * `context.route` – object that holds the route that is currently being rendered.
|
|
285
|
+
*
|
|
286
|
+
* * `context.next()` – function for asynchronously getting the next route
|
|
287
|
+
* contents from the resolution chain (if any)
|
|
288
|
+
*
|
|
289
|
+
* `commands` object that is passed to `action` function has
|
|
290
|
+
* the following methods:
|
|
291
|
+
*
|
|
292
|
+
* * `commands.redirect(path)` – function that creates a redirect data
|
|
293
|
+
* for the path specified.
|
|
294
|
+
*
|
|
295
|
+
* * `commands.component(component)` – function that creates a new HTMLElement
|
|
296
|
+
* with current context. Note: the component created by this function is reused if visiting the same path twice in row.
|
|
297
|
+
*
|
|
298
|
+
*
|
|
299
|
+
* @param {!Array<!Route>|!Route} routes a single route or an array of those
|
|
300
|
+
* @param {?boolean} skipRender configure the router but skip rendering the
|
|
301
|
+
* route corresponding to the current `window.location` values
|
|
302
|
+
*
|
|
303
|
+
* @return {!Promise<!Node>}
|
|
304
|
+
*/
|
|
305
|
+
setRoutes(routes: Array<Route> | Route, skipRender?: boolean | null): Promise<Node>;
|
|
206
306
|
__previousContext: any;
|
|
207
307
|
__urlForName: (routeName: any, params: any) => any;
|
|
208
308
|
/**
|
|
@@ -287,7 +387,7 @@ export class Router extends Resolver {
|
|
|
287
387
|
*
|
|
288
388
|
* @return {string}
|
|
289
389
|
*/
|
|
290
|
-
urlForName(name: string, params?:
|
|
390
|
+
urlForName(name: string, params?: Params | undefined): string;
|
|
291
391
|
/**
|
|
292
392
|
* Generates a URL for the given route path, optionally performing
|
|
293
393
|
* substitution of parameters.
|
|
@@ -299,5 +399,5 @@ export class Router extends Resolver {
|
|
|
299
399
|
*
|
|
300
400
|
* @return {string}
|
|
301
401
|
*/
|
|
302
|
-
urlForPath(path: string, params?:
|
|
402
|
+
urlForPath(path: string, params?: Params | undefined): string;
|
|
303
403
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rxdi/router",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.191-nightly.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"author": "Kristiyan Tachev",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"router-slot": "^1.5.4"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@rxdi/core": "^0.7.
|
|
19
|
-
"@rxdi/lit-html": "^0.7.
|
|
18
|
+
"@rxdi/core": "^0.7.190",
|
|
19
|
+
"@rxdi/lit-html": "^0.7.190"
|
|
20
20
|
},
|
|
21
21
|
"types": "./dist/index.d.ts",
|
|
22
22
|
"module": "./dist/index.js",
|