@tramvai/module-router 2.94.27 → 2.95.4
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/components/link.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createToken, provide } from '@tramvai/core';
|
|
2
2
|
import { COMPONENT_REGISTRY_TOKEN, BUNDLE_MANAGER_TOKEN, LOGGER_TOKEN } from '@tramvai/tokens-common';
|
|
3
3
|
import { LINK_PREFETCH_MANAGER_TOKEN, ROUTER_TOKEN, ROUTE_RESOLVE_TOKEN } from '@tramvai/tokens-router';
|
|
4
|
-
import {
|
|
4
|
+
import { parse } from '@tinkoff/url';
|
|
5
5
|
import { resolveLazyComponent } from '@tramvai/react';
|
|
6
|
+
import { scheduling } from '@tramvai/state';
|
|
6
7
|
import { isFileSystemPageComponent } from '@tramvai/experiments';
|
|
7
8
|
import { routeTransformToken } from '../../tokens.browser.js';
|
|
8
9
|
|
|
@@ -16,10 +17,19 @@ const prefetchProviders = [
|
|
|
16
17
|
provide({
|
|
17
18
|
provide: PREFETCHED_LINKS_QUEUE_TOKEN,
|
|
18
19
|
useFactory: () => {
|
|
20
|
+
const schedule = scheduling();
|
|
19
21
|
let queue = Promise.resolve();
|
|
20
22
|
return {
|
|
21
23
|
add(run) {
|
|
22
|
-
queue = queue.then(
|
|
24
|
+
queue = queue.then(() => {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
// break microtask queue
|
|
27
|
+
schedule(() => {
|
|
28
|
+
// eslint-disable-next-line promise/no-nesting
|
|
29
|
+
run().then(resolve).catch(reject);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
});
|
|
23
33
|
return queue;
|
|
24
34
|
},
|
|
25
35
|
};
|
|
@@ -42,15 +52,15 @@ const prefetchProviders = [
|
|
|
42
52
|
// if route not found, try to resolve dynamic route,
|
|
43
53
|
// logic from `ROUTER_TOKEN` provider factory, without `router.addRoute` method call
|
|
44
54
|
if (!route && routeResolve) {
|
|
45
|
-
|
|
46
|
-
// that this route request no need to be cached or have any personalization
|
|
47
|
-
const parsedUrl = addQuery(url, { prefetchRoute: 'true' });
|
|
55
|
+
const parsedUrl = parse(url);
|
|
48
56
|
route = await routeResolve({
|
|
49
57
|
url: parsedUrl,
|
|
50
58
|
type: 'navigate',
|
|
51
59
|
});
|
|
52
60
|
if (route) {
|
|
53
61
|
route = routeTransform(route);
|
|
62
|
+
// warmup route for possible navigation
|
|
63
|
+
router.addRoute(route);
|
|
54
64
|
}
|
|
55
65
|
}
|
|
56
66
|
if (!route) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-router",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.95.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"browser": {
|
|
@@ -28,24 +28,24 @@
|
|
|
28
28
|
"@tinkoff/errors": "0.3.8",
|
|
29
29
|
"@tinkoff/router": "0.2.14",
|
|
30
30
|
"@tinkoff/url": "0.8.6",
|
|
31
|
-
"@tramvai/react": "2.
|
|
32
|
-
"@tramvai/tokens-child-app": "2.
|
|
33
|
-
"@tramvai/tokens-render": "2.
|
|
34
|
-
"@tramvai/tokens-router": "2.
|
|
35
|
-
"@tramvai/tokens-server": "2.
|
|
36
|
-
"@tramvai/experiments": "2.
|
|
31
|
+
"@tramvai/react": "2.95.4",
|
|
32
|
+
"@tramvai/tokens-child-app": "2.95.4",
|
|
33
|
+
"@tramvai/tokens-render": "2.95.4",
|
|
34
|
+
"@tramvai/tokens-router": "2.95.4",
|
|
35
|
+
"@tramvai/tokens-server": "2.95.4",
|
|
36
|
+
"@tramvai/experiments": "2.95.4"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@tinkoff/utils": "^2.1.2",
|
|
40
|
-
"@tramvai/cli": "2.
|
|
41
|
-
"@tramvai/core": "2.
|
|
42
|
-
"@tramvai/module-log": "2.
|
|
43
|
-
"@tramvai/module-server": "2.
|
|
44
|
-
"@tramvai/papi": "2.
|
|
45
|
-
"@tramvai/state": "2.
|
|
46
|
-
"@tramvai/test-helpers": "2.
|
|
47
|
-
"@tramvai/test-mocks": "2.
|
|
48
|
-
"@tramvai/tokens-common": "2.
|
|
40
|
+
"@tramvai/cli": "2.95.4",
|
|
41
|
+
"@tramvai/core": "2.95.4",
|
|
42
|
+
"@tramvai/module-log": "2.95.4",
|
|
43
|
+
"@tramvai/module-server": "2.95.4",
|
|
44
|
+
"@tramvai/papi": "2.95.4",
|
|
45
|
+
"@tramvai/state": "2.95.4",
|
|
46
|
+
"@tramvai/test-helpers": "2.95.4",
|
|
47
|
+
"@tramvai/test-mocks": "2.95.4",
|
|
48
|
+
"@tramvai/tokens-common": "2.95.4",
|
|
49
49
|
"@tinkoff/dippy": "0.8.15",
|
|
50
50
|
"react": "*",
|
|
51
51
|
"tslib": "^2.4.0"
|