@shuvi/platform-web 1.0.37 → 1.0.38
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/esm/shuvi-app/app/client.js +8 -7
- package/esm/shuvi-app/app/server.js +10 -11
- package/package.json +11 -11
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { getRoutes } from '@shuvi/app/core/platform';
|
|
11
|
-
import { runPreload, runLoaders, getRouteMatchesWithInvalidLoader, isRedirect, isResponse } from '@shuvi/platform-shared/shared';
|
|
11
|
+
import { runPreload, runLoaders, createLoaderContext, getRouteMatchesWithInvalidLoader, isRedirect, isResponse } from '@shuvi/platform-shared/shared';
|
|
12
12
|
import application from '@shuvi/platform-shared/shuvi-app/application';
|
|
13
13
|
import { createRouter, createBrowserHistory, createHashHistory } from '@shuvi/router';
|
|
14
14
|
import { historyMode } from '@shuvi/app/files/routerConfig';
|
|
@@ -63,6 +63,12 @@ export const createApp = ({ routes, appData, appComponent }) => {
|
|
|
63
63
|
const runLoadersTrace = clientRenderTrace.traceChild(SHUVI_CLIENT_RUN_LOADERS.name);
|
|
64
64
|
const pageLoaders = yield app.getLoaders();
|
|
65
65
|
const matches = getRouteMatchesWithInvalidLoader(to, from, pageLoaders);
|
|
66
|
+
const loaderContext = createLoaderContext({
|
|
67
|
+
pathname: to.pathname,
|
|
68
|
+
query: to.query,
|
|
69
|
+
params: to.params,
|
|
70
|
+
getAppContext: () => app.context
|
|
71
|
+
});
|
|
66
72
|
try {
|
|
67
73
|
const loaderDatas = yield new Promise((resolve, reject) => {
|
|
68
74
|
let value;
|
|
@@ -85,12 +91,7 @@ export const createApp = ({ routes, appData, appComponent }) => {
|
|
|
85
91
|
.catch(err => {
|
|
86
92
|
reject(err);
|
|
87
93
|
});
|
|
88
|
-
runLoaders(matches, pageLoaders,
|
|
89
|
-
pathname: to.pathname,
|
|
90
|
-
query: to.query,
|
|
91
|
-
params: to.params,
|
|
92
|
-
getAppContext: () => app.context
|
|
93
|
-
})
|
|
94
|
+
runLoaders(matches, pageLoaders, loaderContext)
|
|
94
95
|
.then(_value => {
|
|
95
96
|
value = _value;
|
|
96
97
|
tryResolve();
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import routes from '@shuvi/app/files/routes';
|
|
11
11
|
import { getRoutes, app as AppComponent } from '@shuvi/app/core/platform';
|
|
12
|
-
import { runLoaders, getRouteMatchesWithInvalidLoader, isResponse, isRedirect } from '@shuvi/platform-shared/shared';
|
|
12
|
+
import { runLoaders, createLoaderContext, getRouteMatchesWithInvalidLoader, isResponse, isRedirect } from '@shuvi/platform-shared/shared';
|
|
13
13
|
import application from '@shuvi/platform-shared/shuvi-app/application';
|
|
14
14
|
import { createRouter, createMemoryHistory, pathToString } from '@shuvi/router';
|
|
15
15
|
import { SERVER_CREATE_APP } from '@shuvi/shared/constants/trace';
|
|
@@ -33,14 +33,15 @@ export const createApp = options => {
|
|
|
33
33
|
const runLoadersTrace = serverCreateAppTrace.traceChild(SHUVI_SERVER_RUN_LOADERS.name, { [SHUVI_SERVER_RUN_LOADERS.attrs.requestId.name]: req._requestId });
|
|
34
34
|
const pageLoaders = yield app.getLoaders();
|
|
35
35
|
const matches = getRouteMatchesWithInvalidLoader(to, from, pageLoaders);
|
|
36
|
+
const loaderContext = createLoaderContext({
|
|
37
|
+
req,
|
|
38
|
+
pathname: to.pathname,
|
|
39
|
+
query: to.query,
|
|
40
|
+
params: to.params,
|
|
41
|
+
getAppContext: () => app.context
|
|
42
|
+
});
|
|
36
43
|
try {
|
|
37
|
-
const loaderResult = yield runLoaders(matches, pageLoaders,
|
|
38
|
-
req,
|
|
39
|
-
pathname: to.pathname,
|
|
40
|
-
query: to.query,
|
|
41
|
-
params: to.params,
|
|
42
|
-
getAppContext: () => app.context
|
|
43
|
-
});
|
|
44
|
+
const loaderResult = yield runLoaders(matches, pageLoaders, loaderContext);
|
|
44
45
|
app.setLoadersData(loaderResult);
|
|
45
46
|
runLoadersTrace.setAttribute(SHUVI_SERVER_RUN_LOADERS.attrs.error.name, false);
|
|
46
47
|
runLoadersTrace.stop();
|
|
@@ -73,9 +74,7 @@ export const createApp = options => {
|
|
|
73
74
|
runLoadersTrace.stop();
|
|
74
75
|
return;
|
|
75
76
|
}
|
|
76
|
-
|
|
77
|
-
logger.error(error.stack);
|
|
78
|
-
}
|
|
77
|
+
logger.error(error.stack);
|
|
79
78
|
app.setError(serializeServerError(error));
|
|
80
79
|
next();
|
|
81
80
|
runLoadersTrace.setAttribute(SHUVI_SERVER_RUN_LOADERS.attrs.errorType.name, 'unexpectedError');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shuvi/platform-web",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.38",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/shuvijs/shuvi.git",
|
|
@@ -72,15 +72,15 @@
|
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"@next/react-refresh-utils": "12.1.6",
|
|
75
|
-
"@shuvi/error-overlay": "1.0.
|
|
76
|
-
"@shuvi/hook": "1.0.
|
|
77
|
-
"@shuvi/platform-shared": "1.0.
|
|
78
|
-
"@shuvi/router": "1.0.
|
|
79
|
-
"@shuvi/router-react": "1.0.
|
|
80
|
-
"@shuvi/runtime": "1.0.
|
|
81
|
-
"@shuvi/shared": "1.0.
|
|
82
|
-
"@shuvi/toolpack": "1.0.
|
|
83
|
-
"@shuvi/utils": "1.0.
|
|
75
|
+
"@shuvi/error-overlay": "1.0.38",
|
|
76
|
+
"@shuvi/hook": "1.0.38",
|
|
77
|
+
"@shuvi/platform-shared": "1.0.38",
|
|
78
|
+
"@shuvi/router": "1.0.38",
|
|
79
|
+
"@shuvi/router-react": "1.0.38",
|
|
80
|
+
"@shuvi/runtime": "1.0.38",
|
|
81
|
+
"@shuvi/shared": "1.0.38",
|
|
82
|
+
"@shuvi/toolpack": "1.0.38",
|
|
83
|
+
"@shuvi/utils": "1.0.38",
|
|
84
84
|
"content-type": "1.0.4",
|
|
85
85
|
"core-js": "3.6.5",
|
|
86
86
|
"doura": "0.0.13",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"whatwg-fetch": "3.0.0"
|
|
99
99
|
},
|
|
100
100
|
"peerDependencies": {
|
|
101
|
-
"@shuvi/service": "1.0.
|
|
101
|
+
"@shuvi/service": "1.0.38"
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
104
104
|
"@shuvi/service": "workspace:*",
|