@tramvai/module-router 2.22.0 → 2.24.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/lib/index.es.js +23 -26
- package/lib/index.js +23 -26
- package/lib/modules/tokens/server/bundleInfo.d.ts +1 -6
- package/lib/modules/tokens.d.ts +2 -1
- package/package.json +16 -16
package/lib/index.es.js
CHANGED
|
@@ -549,25 +549,29 @@ const routerOptions = ({ requestManager, responseManager, }) => {
|
|
|
549
549
|
const deduplicateArray = (list) => {
|
|
550
550
|
return Array.from(new Set(list));
|
|
551
551
|
};
|
|
552
|
-
const
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
552
|
+
const bundleInfoPapi = createPapiMethod({
|
|
553
|
+
method: 'get',
|
|
554
|
+
path: '/bundleInfo',
|
|
555
|
+
async handler() {
|
|
556
|
+
var _a;
|
|
557
|
+
const { getAdditionalRoutes, routes, routeTransform } = this.deps;
|
|
558
|
+
const loadAdditional = getAdditionalRoutes !== null && getAdditionalRoutes !== void 0 ? getAdditionalRoutes : (() => []);
|
|
559
|
+
return deduplicateArray(flatten(routes || [])
|
|
560
|
+
.concat((_a = (await loadAdditional())) !== null && _a !== void 0 ? _a : [])
|
|
561
|
+
.map(routeTransform)
|
|
562
|
+
.map(prop('path'))
|
|
563
|
+
.filter((path) => !isWildcard(path) && !isHistoryFallback(path))
|
|
564
|
+
.sort());
|
|
565
|
+
},
|
|
566
|
+
deps: {
|
|
567
|
+
routes: {
|
|
568
|
+
token: ROUTES_TOKEN,
|
|
569
|
+
optional: true,
|
|
568
570
|
},
|
|
569
|
-
|
|
570
|
-
}
|
|
571
|
+
routeTransform: routeTransformToken,
|
|
572
|
+
getAdditionalRoutes: { token: routerBundleInfoAdditionalToken, optional: true },
|
|
573
|
+
},
|
|
574
|
+
});
|
|
571
575
|
|
|
572
576
|
const serverTokens = [
|
|
573
577
|
{
|
|
@@ -581,14 +585,7 @@ const serverTokens = [
|
|
|
581
585
|
{
|
|
582
586
|
provide: SERVER_MODULE_PAPI_PUBLIC_ROUTE,
|
|
583
587
|
multi: true,
|
|
584
|
-
|
|
585
|
-
deps: {
|
|
586
|
-
routes: {
|
|
587
|
-
token: ROUTES_TOKEN,
|
|
588
|
-
optional: true,
|
|
589
|
-
},
|
|
590
|
-
routeTransform: routeTransformToken,
|
|
591
|
-
},
|
|
588
|
+
useValue: bundleInfoPapi,
|
|
592
589
|
},
|
|
593
590
|
];
|
|
594
591
|
|
package/lib/index.js
CHANGED
|
@@ -560,25 +560,29 @@ const routerOptions = ({ requestManager, responseManager, }) => {
|
|
|
560
560
|
const deduplicateArray = (list) => {
|
|
561
561
|
return Array.from(new Set(list));
|
|
562
562
|
};
|
|
563
|
-
const
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
563
|
+
const bundleInfoPapi = papi.createPapiMethod({
|
|
564
|
+
method: 'get',
|
|
565
|
+
path: '/bundleInfo',
|
|
566
|
+
async handler() {
|
|
567
|
+
var _a;
|
|
568
|
+
const { getAdditionalRoutes, routes, routeTransform } = this.deps;
|
|
569
|
+
const loadAdditional = getAdditionalRoutes !== null && getAdditionalRoutes !== void 0 ? getAdditionalRoutes : (() => []);
|
|
570
|
+
return deduplicateArray(flatten__default["default"](routes || [])
|
|
571
|
+
.concat((_a = (await loadAdditional())) !== null && _a !== void 0 ? _a : [])
|
|
572
|
+
.map(routeTransform)
|
|
573
|
+
.map(prop__default["default"]('path'))
|
|
574
|
+
.filter((path) => !router.isWildcard(path) && !router.isHistoryFallback(path))
|
|
575
|
+
.sort());
|
|
576
|
+
},
|
|
577
|
+
deps: {
|
|
578
|
+
routes: {
|
|
579
|
+
token: tokensRouter.ROUTES_TOKEN,
|
|
580
|
+
optional: true,
|
|
579
581
|
},
|
|
580
|
-
|
|
581
|
-
}
|
|
582
|
+
routeTransform: routeTransformToken,
|
|
583
|
+
getAdditionalRoutes: { token: routerBundleInfoAdditionalToken, optional: true },
|
|
584
|
+
},
|
|
585
|
+
});
|
|
582
586
|
|
|
583
587
|
const serverTokens = [
|
|
584
588
|
{
|
|
@@ -592,14 +596,7 @@ const serverTokens = [
|
|
|
592
596
|
{
|
|
593
597
|
provide: tokensServer.SERVER_MODULE_PAPI_PUBLIC_ROUTE,
|
|
594
598
|
multi: true,
|
|
595
|
-
|
|
596
|
-
deps: {
|
|
597
|
-
routes: {
|
|
598
|
-
token: tokensRouter.ROUTES_TOKEN,
|
|
599
|
-
optional: true,
|
|
600
|
-
},
|
|
601
|
-
routeTransform: routeTransformToken,
|
|
602
|
-
},
|
|
599
|
+
useValue: bundleInfoPapi,
|
|
603
600
|
},
|
|
604
601
|
];
|
|
605
602
|
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { routeTransformToken } from '../../tokens';
|
|
3
|
-
export declare const bundleInfo: ({ routes, routeTransform, }: {
|
|
4
|
-
routes?: Array<typeof ROUTES_TOKEN>;
|
|
5
|
-
routeTransform: typeof routeTransformToken;
|
|
6
|
-
}) => import("@tramvai/papi").Papi<any, any>;
|
|
1
|
+
export declare const bundleInfoPapi: import("@tramvai/papi").Papi<any, any>;
|
package/lib/modules/tokens.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { NavigationHook, AbstractRouter, NavigationSyncHook, Route } from '@tinkoff/router';
|
|
2
|
+
import type { RouteTransform } from '@tramvai/tokens-router';
|
|
2
3
|
export declare const routerClassToken: import("@tinkoff/dippy").BaseTokenInterface<AbstractRouter>;
|
|
3
4
|
export declare const additionalRouterParameters: import("@tinkoff/dippy").BaseTokenInterface<Record<string, any>>;
|
|
4
5
|
export declare const onChangeHooksToken: import("@tinkoff/dippy").MultiTokenInterface<NavigationSyncHook>;
|
|
@@ -7,5 +8,5 @@ export declare const beforeNavigateHooksToken: import("@tinkoff/dippy").MultiTok
|
|
|
7
8
|
export declare const afterNavigateHooksToken: import("@tinkoff/dippy").MultiTokenInterface<NavigationHook>;
|
|
8
9
|
export declare const beforeUpdateCurrentHooksToken: import("@tinkoff/dippy").MultiTokenInterface<NavigationHook>;
|
|
9
10
|
export declare const afterUpdateCurrentHooksToken: import("@tinkoff/dippy").MultiTokenInterface<NavigationHook>;
|
|
10
|
-
export declare const routeTransformToken: import("@tinkoff/dippy").BaseTokenInterface<
|
|
11
|
+
export declare const routeTransformToken: import("@tinkoff/dippy").BaseTokenInterface<RouteTransform>;
|
|
11
12
|
export declare const routerBundleInfoAdditionalToken: import("@tinkoff/dippy").BaseTokenInterface<() => Promise<Route[]>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-router",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.24.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"browser": {
|
|
@@ -24,26 +24,26 @@
|
|
|
24
24
|
"build-for-publish": "true"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@tinkoff/errors": "0.3.
|
|
27
|
+
"@tinkoff/errors": "0.3.3",
|
|
28
28
|
"@tinkoff/router": "0.2.2",
|
|
29
29
|
"@tinkoff/url": "0.8.2",
|
|
30
|
-
"@tramvai/tokens-child-app": "2.
|
|
31
|
-
"@tramvai/tokens-render": "2.
|
|
32
|
-
"@tramvai/tokens-router": "2.
|
|
33
|
-
"@tramvai/tokens-server": "2.
|
|
34
|
-
"@tramvai/experiments": "2.
|
|
30
|
+
"@tramvai/tokens-child-app": "2.24.0",
|
|
31
|
+
"@tramvai/tokens-render": "2.24.0",
|
|
32
|
+
"@tramvai/tokens-router": "2.24.0",
|
|
33
|
+
"@tramvai/tokens-server": "2.24.0",
|
|
34
|
+
"@tramvai/experiments": "2.24.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@tinkoff/utils": "^2.1.2",
|
|
38
|
-
"@tramvai/cli": "2.
|
|
39
|
-
"@tramvai/core": "2.
|
|
40
|
-
"@tramvai/module-log": "2.
|
|
41
|
-
"@tramvai/module-server": "2.
|
|
42
|
-
"@tramvai/papi": "2.
|
|
43
|
-
"@tramvai/state": "2.
|
|
44
|
-
"@tramvai/test-helpers": "2.
|
|
45
|
-
"@tramvai/test-mocks": "2.
|
|
46
|
-
"@tramvai/tokens-common": "2.
|
|
38
|
+
"@tramvai/cli": "2.24.0",
|
|
39
|
+
"@tramvai/core": "2.24.0",
|
|
40
|
+
"@tramvai/module-log": "2.24.0",
|
|
41
|
+
"@tramvai/module-server": "2.24.0",
|
|
42
|
+
"@tramvai/papi": "2.24.0",
|
|
43
|
+
"@tramvai/state": "2.24.0",
|
|
44
|
+
"@tramvai/test-helpers": "2.24.0",
|
|
45
|
+
"@tramvai/test-mocks": "2.24.0",
|
|
46
|
+
"@tramvai/tokens-common": "2.24.0",
|
|
47
47
|
"@tinkoff/dippy": "0.8.2",
|
|
48
48
|
"react": "*",
|
|
49
49
|
"tslib": "^2.0.3"
|