@tramvai/module-router 1.82.3 → 1.84.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.browser.js +22 -12
- package/lib/modules/hooks/spa/runCommands.d.ts +5 -1
- package/package.json +15 -15
package/lib/index.browser.js
CHANGED
|
@@ -509,22 +509,20 @@ const providers = [
|
|
|
509
509
|
provide({
|
|
510
510
|
provide: commandLineListTokens.clear,
|
|
511
511
|
multi: true,
|
|
512
|
-
useFactory: (
|
|
512
|
+
useFactory: ({ store, router, renderMode }) => {
|
|
513
513
|
return async function csrFirstNavigation() {
|
|
514
|
-
const currentRoute =
|
|
514
|
+
const currentRoute = store.getState(RouterStore).currentRoute;
|
|
515
515
|
// in client-side rendering mode, if current route inconsistent with current location,
|
|
516
516
|
// run navigation to current location.
|
|
517
|
-
if (
|
|
517
|
+
if (renderMode === 'client' &&
|
|
518
518
|
(!currentRoute || (currentRoute && currentRoute.actualPath !== window.location.pathname))) {
|
|
519
|
-
return
|
|
519
|
+
return router.navigate(window.location.href);
|
|
520
520
|
}
|
|
521
521
|
};
|
|
522
522
|
},
|
|
523
523
|
deps: {
|
|
524
524
|
store: STORE_TOKEN,
|
|
525
525
|
router: ROUTER_TOKEN,
|
|
526
|
-
actionRegistry: ACTION_REGISTRY_TOKEN,
|
|
527
|
-
actionPageRunner: ACTION_PAGE_RUNNER_TOKEN,
|
|
528
526
|
renderMode: TRAMVAI_RENDER_MODE,
|
|
529
527
|
},
|
|
530
528
|
}),
|
|
@@ -563,17 +561,31 @@ const NoSpaRouterModule = /* @__PURE__ */ Module({
|
|
|
563
561
|
_a$1.forRoot = generateForRoot(_a$1),
|
|
564
562
|
_a$1));
|
|
565
563
|
|
|
566
|
-
const
|
|
564
|
+
const runCommandsSpa = ({ commandLineRunner, di, }) => {
|
|
567
565
|
return async () => {
|
|
568
566
|
await commandLineRunner.run('client', 'spa', [], di);
|
|
569
567
|
};
|
|
570
568
|
};
|
|
569
|
+
const runCommandsAfterSpa = ({ commandLineRunner, di, }) => {
|
|
570
|
+
return async () => {
|
|
571
|
+
await commandLineRunner.run('client', 'afterSpa', [], di);
|
|
572
|
+
};
|
|
573
|
+
};
|
|
571
574
|
|
|
572
575
|
const spaHooks = [
|
|
573
576
|
{
|
|
574
577
|
provide: beforeNavigateHooksToken,
|
|
575
578
|
multi: true,
|
|
576
|
-
useFactory:
|
|
579
|
+
useFactory: runCommandsSpa,
|
|
580
|
+
deps: {
|
|
581
|
+
di: DI_TOKEN,
|
|
582
|
+
commandLineRunner: COMMAND_LINE_RUNNER_TOKEN,
|
|
583
|
+
},
|
|
584
|
+
},
|
|
585
|
+
{
|
|
586
|
+
provide: afterNavigateHooksToken,
|
|
587
|
+
multi: true,
|
|
588
|
+
useFactory: runCommandsAfterSpa,
|
|
577
589
|
deps: {
|
|
578
590
|
di: DI_TOKEN,
|
|
579
591
|
commandLineRunner: COMMAND_LINE_RUNNER_TOKEN,
|
|
@@ -600,13 +612,11 @@ const spaHooks = [
|
|
|
600
612
|
},
|
|
601
613
|
},
|
|
602
614
|
{
|
|
603
|
-
provide: commandLineListTokens.
|
|
615
|
+
provide: commandLineListTokens.afterSpaTransition,
|
|
604
616
|
multi: true,
|
|
605
617
|
useFactory: ({ spaMode, ...deps }) => {
|
|
606
618
|
if (spaMode === 'after') {
|
|
607
|
-
return
|
|
608
|
-
deps.router.registerHook('afterNavigate', runActionsFactory(deps));
|
|
609
|
-
};
|
|
619
|
+
return runActionsFactory(deps);
|
|
610
620
|
}
|
|
611
621
|
return noop;
|
|
612
622
|
},
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { DI_TOKEN, COMMAND_LINE_RUNNER_TOKEN } from '@tramvai/core';
|
|
2
2
|
import type { NavigationHook } from '@tinkoff/router';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const runCommandsSpa: ({ commandLineRunner, di, }: {
|
|
4
|
+
di: typeof DI_TOKEN;
|
|
5
|
+
commandLineRunner: typeof COMMAND_LINE_RUNNER_TOKEN;
|
|
6
|
+
}) => NavigationHook;
|
|
7
|
+
export declare const runCommandsAfterSpa: ({ commandLineRunner, di, }: {
|
|
4
8
|
di: typeof DI_TOKEN;
|
|
5
9
|
commandLineRunner: typeof COMMAND_LINE_RUNNER_TOKEN;
|
|
6
10
|
}) => NavigationHook;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-router",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.84.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"browser": {
|
|
@@ -25,23 +25,23 @@
|
|
|
25
25
|
"@tinkoff/errors": "0.2.20",
|
|
26
26
|
"@tinkoff/router": "0.1.71",
|
|
27
27
|
"@tinkoff/url": "0.7.37",
|
|
28
|
-
"@tramvai/tokens-child-app": "1.
|
|
29
|
-
"@tramvai/tokens-render": "1.
|
|
30
|
-
"@tramvai/tokens-router": "1.
|
|
31
|
-
"@tramvai/tokens-server": "1.
|
|
32
|
-
"@tramvai/experiments": "1.
|
|
28
|
+
"@tramvai/tokens-child-app": "1.84.0",
|
|
29
|
+
"@tramvai/tokens-render": "1.84.0",
|
|
30
|
+
"@tramvai/tokens-router": "1.84.0",
|
|
31
|
+
"@tramvai/tokens-server": "1.84.0",
|
|
32
|
+
"@tramvai/experiments": "1.84.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@tinkoff/utils": "^2.1.2",
|
|
36
|
-
"@tramvai/cli": "1.
|
|
37
|
-
"@tramvai/core": "1.
|
|
38
|
-
"@tramvai/module-log": "1.
|
|
39
|
-
"@tramvai/module-server": "1.
|
|
40
|
-
"@tramvai/papi": "1.
|
|
41
|
-
"@tramvai/state": "1.
|
|
42
|
-
"@tramvai/test-helpers": "1.
|
|
43
|
-
"@tramvai/test-mocks": "1.
|
|
44
|
-
"@tramvai/tokens-common": "1.
|
|
36
|
+
"@tramvai/cli": "1.84.0",
|
|
37
|
+
"@tramvai/core": "1.84.0",
|
|
38
|
+
"@tramvai/module-log": "1.84.0",
|
|
39
|
+
"@tramvai/module-server": "1.84.0",
|
|
40
|
+
"@tramvai/papi": "1.84.0",
|
|
41
|
+
"@tramvai/state": "1.84.0",
|
|
42
|
+
"@tramvai/test-helpers": "1.84.0",
|
|
43
|
+
"@tramvai/test-mocks": "1.84.0",
|
|
44
|
+
"@tramvai/tokens-common": "1.84.0",
|
|
45
45
|
"@tinkoff/dippy": "0.7.39",
|
|
46
46
|
"react": "*",
|
|
47
47
|
"tslib": "^2.0.3"
|