@tramvai/module-router 1.48.3 → 1.49.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/README.md +24 -14
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# @tramvai/module-router
|
|
2
2
|
|
|
3
|
-
Module for routing in the application.
|
|
4
|
-
Exports two sub-modules: with client SPA transitions, and no-SPA.
|
|
3
|
+
Module for routing in the application. Exports two sub-modules: with client SPA transitions, and no-SPA.
|
|
5
4
|
|
|
6
5
|
## Installation
|
|
7
6
|
|
|
@@ -28,21 +27,28 @@ createApp({
|
|
|
28
27
|
|
|
29
28
|
The module is based on the library [@tinkoff/router](references/libs/router.md)
|
|
30
29
|
|
|
30
|
+
### Default Settings
|
|
31
|
+
|
|
32
|
+
Next [settings](references/libs/router.md#constructor-options) are used
|
|
33
|
+
|
|
34
|
+
- `trailingSlashes = true`
|
|
35
|
+
- `mergeSlashes = true`
|
|
36
|
+
|
|
31
37
|
### Navigation flow on the server
|
|
32
38
|
|
|
33
|
-

|
|
34
40
|
|
|
35
41
|
### Flow of the first navigation on the client
|
|
36
42
|
|
|
37
|
-

|
|
38
44
|
|
|
39
45
|
### Flow of navigation on the client without SPA transitions
|
|
40
46
|
|
|
41
|
-

|
|
42
48
|
|
|
43
49
|
### Flow of navigation on the client with SPA transitions
|
|
44
50
|
|
|
45
|
-

|
|
46
52
|
|
|
47
53
|
## API
|
|
48
54
|
|
|
@@ -275,8 +281,7 @@ You can work with routing inside React components using hooks and components - `
|
|
|
275
281
|
|
|
276
282
|
### How to set static routes
|
|
277
283
|
|
|
278
|
-
[RouterModule](references/modules/router.md) allows you to add new routes when configuring your application.
|
|
279
|
-
The second way is to pass static routes to DI via the `ROUTES_TOKEN` token.
|
|
284
|
+
[RouterModule](references/modules/router.md) allows you to add new routes when configuring your application. The second way is to pass static routes to DI via the `ROUTES_TOKEN` token.
|
|
280
285
|
|
|
281
286
|
<p>
|
|
282
287
|
<details>
|
|
@@ -289,7 +294,7 @@ The second way is to pass static routes to DI via the `ROUTES_TOKEN` token.
|
|
|
289
294
|
|
|
290
295
|
### How to set Route Guard
|
|
291
296
|
|
|
292
|
-
|
|
297
|
+
`ROUTER_GUARD_TOKEN` is set as an asynchronous function, which allows you to perform various actions and influence the routing behavior.
|
|
293
298
|
|
|
294
299
|
<p>
|
|
295
300
|
<details>
|
|
@@ -300,6 +305,14 @@ The second way is to pass static routes to DI via the `ROUTES_TOKEN` token.
|
|
|
300
305
|
</details>
|
|
301
306
|
</p>
|
|
302
307
|
|
|
308
|
+
### How to add transition hooks
|
|
309
|
+
|
|
310
|
+
[Transition hooks](references/libs/router.md#transition-hooks) allows to subscribe on different steps of the transition
|
|
311
|
+
|
|
312
|
+
1. Get router instance with `ROUTER_TOKEN` token
|
|
313
|
+
2. Use methods `registerHook`, `registerSyncHook` to add new hooks to the router
|
|
314
|
+
3. Registration should happen as soon as possible so appropriate line is `customerStart` as it executes before navigation happens.
|
|
315
|
+
|
|
303
316
|
### How to set the Not found route
|
|
304
317
|
|
|
305
318
|
The Not found route is used if the corresponding route is not found for the url.
|
|
@@ -317,8 +330,7 @@ Such a route is specified in the list of routes with the special `*` character i
|
|
|
317
330
|
|
|
318
331
|
### How to change Not found route response status
|
|
319
332
|
|
|
320
|
-
By default, responses for the Not found route return a status of 200.
|
|
321
|
-
You can change status in custom Route Guard, by using `RESPONSE_MANAGER_TOKEN`.
|
|
333
|
+
By default, responses for the Not found route return a status of 200. You can change status in custom Route Guard, by using `RESPONSE_MANAGER_TOKEN`.
|
|
322
334
|
|
|
323
335
|
<p>
|
|
324
336
|
<details>
|
|
@@ -333,9 +345,7 @@ You can change status in custom Route Guard, by using `RESPONSE_MANAGER_TOKEN`.
|
|
|
333
345
|
|
|
334
346
|
For example, you make a important request in action, and if this request will fail, application need to return 500 or 404 status.
|
|
335
347
|
|
|
336
|
-
Page actions running after router navigation flow, when route is completely resolved.
|
|
337
|
-
You can change status by using `RESPONSE_MANAGER_TOKEN`.
|
|
338
|
-
If you want to prevent page component rendering, you can throw `NotFoundError` from `@tinkoff/errors` library.
|
|
348
|
+
Page actions running after router navigation flow, when route is completely resolved. You can change status by using `RESPONSE_MANAGER_TOKEN`. If you want to prevent page component rendering, you can throw `NotFoundError` from `@tinkoff/errors` library.
|
|
339
349
|
|
|
340
350
|
<p>
|
|
341
351
|
<details>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-router",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.49.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"browser": {
|
|
@@ -25,22 +25,22 @@
|
|
|
25
25
|
"@tinkoff/errors": "0.2.18",
|
|
26
26
|
"@tinkoff/router": "0.1.65",
|
|
27
27
|
"@tinkoff/url": "0.7.37",
|
|
28
|
-
"@tramvai/tokens-render": "1.
|
|
29
|
-
"@tramvai/tokens-router": "1.
|
|
30
|
-
"@tramvai/tokens-server": "1.
|
|
31
|
-
"@tramvai/experiments": "1.
|
|
28
|
+
"@tramvai/tokens-render": "1.49.0",
|
|
29
|
+
"@tramvai/tokens-router": "1.49.0",
|
|
30
|
+
"@tramvai/tokens-server": "1.49.0",
|
|
31
|
+
"@tramvai/experiments": "1.49.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"@tinkoff/utils": "^2.1.2",
|
|
35
|
-
"@tramvai/cli": "1.
|
|
36
|
-
"@tramvai/core": "1.
|
|
37
|
-
"@tramvai/module-log": "1.
|
|
38
|
-
"@tramvai/module-server": "1.
|
|
39
|
-
"@tramvai/papi": "1.
|
|
40
|
-
"@tramvai/state": "1.
|
|
41
|
-
"@tramvai/test-helpers": "1.
|
|
42
|
-
"@tramvai/test-mocks": "1.
|
|
43
|
-
"@tramvai/tokens-common": "1.
|
|
35
|
+
"@tramvai/cli": "1.49.0",
|
|
36
|
+
"@tramvai/core": "1.49.0",
|
|
37
|
+
"@tramvai/module-log": "1.49.0",
|
|
38
|
+
"@tramvai/module-server": "1.49.0",
|
|
39
|
+
"@tramvai/papi": "1.49.0",
|
|
40
|
+
"@tramvai/state": "1.49.0",
|
|
41
|
+
"@tramvai/test-helpers": "1.49.0",
|
|
42
|
+
"@tramvai/test-mocks": "1.49.0",
|
|
43
|
+
"@tramvai/tokens-common": "1.49.0",
|
|
44
44
|
"@tinkoff/dippy": "0.7.36",
|
|
45
45
|
"react": "*",
|
|
46
46
|
"tslib": "^2.0.3"
|