@shuvi/platform-web 1.0.48 → 1.0.49
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 +2 -1
- package/esm/shuvi-app/app/server.js +2 -1
- package/esm/shuvi-app/react/view/ReactView.server.jsx +5 -2
- package/lib/node/features/filesystem-routes/page/routes.js +1 -1
- package/lib/node/features/html-render/lib/getPageMiddleware.js +6 -0
- package/package.json +11 -11
|
@@ -120,7 +120,8 @@ export const createApp = ({ routes, appData, appComponent }) => {
|
|
|
120
120
|
if (isResponse(error) && error.status >= 400 && error.status < 600) {
|
|
121
121
|
// client error has no status code
|
|
122
122
|
app.setError({
|
|
123
|
-
message: error.
|
|
123
|
+
message: error.statusText,
|
|
124
|
+
fatal: error.data.fatal
|
|
124
125
|
});
|
|
125
126
|
next();
|
|
126
127
|
runLoadersTrace.setAttribute(SHUVI_CLIENT_RUN_LOADERS.attrs.errorType.name, 'userError');
|
|
@@ -70,7 +70,8 @@ export const createApp = options => {
|
|
|
70
70
|
if (isResponse(error) && error.status >= 400 && error.status < 600) {
|
|
71
71
|
app.setError({
|
|
72
72
|
code: error.status,
|
|
73
|
-
message: error.
|
|
73
|
+
message: error.statusText,
|
|
74
|
+
fatal: error.data.fatal
|
|
74
75
|
});
|
|
75
76
|
next();
|
|
76
77
|
runLoadersTrace.setAttribute(SHUVI_SERVER_RUN_LOADERS.attrs.errorType.name, 'userError');
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import * as React from 'react';
|
|
11
11
|
import { renderToString } from 'react-dom/server';
|
|
12
|
-
import { redirect } from '@shuvi/platform-shared/shared';
|
|
12
|
+
import { redirect, response } from '@shuvi/platform-shared/shared';
|
|
13
13
|
import { SHUVI_ERROR } from '@shuvi/shared/constants';
|
|
14
14
|
import { SERVER_REQUEST } from '@shuvi/shared/constants/trace';
|
|
15
15
|
import { Router } from '@shuvi/router-react';
|
|
@@ -24,7 +24,7 @@ export class ReactServerView {
|
|
|
24
24
|
constructor() {
|
|
25
25
|
this.renderApp = ({ req, app, manifest }) => __awaiter(this, void 0, void 0, function* () {
|
|
26
26
|
yield Loadable.preloadAll();
|
|
27
|
-
const { router, appComponent: AppComponent, setError: setAppError } = app;
|
|
27
|
+
const { router, appComponent: AppComponent, setError: setAppError, error } = app;
|
|
28
28
|
yield router.ready;
|
|
29
29
|
// todo: move these into renderer
|
|
30
30
|
let { matches, redirected, state, pathname } = router.current;
|
|
@@ -32,6 +32,9 @@ export class ReactServerView {
|
|
|
32
32
|
if (!matches.length) {
|
|
33
33
|
setAppError(SHUVI_ERROR.PAGE_NOT_FOUND);
|
|
34
34
|
}
|
|
35
|
+
if (error && error.fatal) {
|
|
36
|
+
return response('', { status: error.code, statusText: error.message });
|
|
37
|
+
}
|
|
35
38
|
if (redirected) {
|
|
36
39
|
// handel loader redirect
|
|
37
40
|
if (state &&
|
|
@@ -22,7 +22,7 @@ const file_1 = require("@shuvi/utils/file");
|
|
|
22
22
|
const paths_1 = require("../../../paths");
|
|
23
23
|
const EmptyComponnetPath = (0, paths_1.resolvePkgFile)('lib/node/features/filesystem-routes/page/EmptyPageComponent');
|
|
24
24
|
function genRouteId(filepath) {
|
|
25
|
-
return (0, crypto_1.createHash)('
|
|
25
|
+
return (0, crypto_1.createHash)('shake256').update(filepath).digest('hex').substr(0, 4);
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* returns JSON string of INormalizedPageRouteConfig
|
|
@@ -56,6 +56,12 @@ function createPageHandler(serverPluginContext) {
|
|
|
56
56
|
yield sendHtml(textResp.data, { req, res });
|
|
57
57
|
sendHtmlHookTrace.stop();
|
|
58
58
|
}
|
|
59
|
+
else if ((0, shared_1.isResponse)(result)) {
|
|
60
|
+
const rawResp = result;
|
|
61
|
+
res.statusCode = rawResp.status;
|
|
62
|
+
res.statusMessage = rawResp.statusText;
|
|
63
|
+
res.end(rawResp.data);
|
|
64
|
+
}
|
|
59
65
|
else {
|
|
60
66
|
// should never reach here
|
|
61
67
|
throw new Error('Unexpected reponse type from renderToHTML');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shuvi/platform-web",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.49",
|
|
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.49",
|
|
76
|
+
"@shuvi/hook": "1.0.49",
|
|
77
|
+
"@shuvi/platform-shared": "1.0.49",
|
|
78
|
+
"@shuvi/router": "1.0.49",
|
|
79
|
+
"@shuvi/router-react": "1.0.49",
|
|
80
|
+
"@shuvi/runtime": "1.0.49",
|
|
81
|
+
"@shuvi/shared": "1.0.49",
|
|
82
|
+
"@shuvi/toolpack": "1.0.49",
|
|
83
|
+
"@shuvi/utils": "1.0.49",
|
|
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.49"
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
104
104
|
"@shuvi/service": "workspace:*",
|