@shuvi/platform-shared 1.0.47 → 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/shared/applicationTypes.d.ts +1 -0
- package/esm/shared/loader/loader.js +2 -2
- package/esm/shared/loader/types.d.ts +3 -1
- package/esm/shared/response.d.ts +2 -2
- package/esm/shared/response.js +1 -1
- package/esm/shuvi-app/application.js +5 -1
- package/lib/shared/applicationTypes.d.ts +1 -0
- package/lib/shared/loader/loader.js +2 -2
- package/lib/shared/loader/types.d.ts +3 -1
- package/lib/shared/response.d.ts +2 -2
- package/lib/shared/response.js +1 -1
- package/package.json +8 -8
|
@@ -67,9 +67,9 @@ function redirectHelper(to, status = 302) {
|
|
|
67
67
|
}
|
|
68
68
|
throw createRedirect(to, status);
|
|
69
69
|
}
|
|
70
|
-
function errorHelper(msg, statusCode = 500) {
|
|
70
|
+
function errorHelper(msg, statusCode = 500, { fatal = false } = {}) {
|
|
71
71
|
invariant(statusCode >= 400 && statusCode < 600, 'status code should be 4xx and 5xx');
|
|
72
|
-
throw response(
|
|
72
|
+
throw response({ error: true, fatal: fatal }, { status: statusCode, statusText: msg });
|
|
73
73
|
}
|
|
74
74
|
export function createLoaderContext({ pathname, query, params, req, getAppContext }) {
|
|
75
75
|
return Object.assign({ pathname,
|
|
@@ -13,7 +13,9 @@ export declare type RedirectFunction = (to: string, status?: number) => any;
|
|
|
13
13
|
export interface ErrorFunction {
|
|
14
14
|
(): any;
|
|
15
15
|
(msg: string): any;
|
|
16
|
-
(msg: string, statusCode?: number
|
|
16
|
+
(msg: string, statusCode?: number, options?: {
|
|
17
|
+
fatal?: boolean;
|
|
18
|
+
}): any;
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
19
21
|
* route component getInitialProps params `context`
|
package/esm/shared/response.d.ts
CHANGED
|
@@ -33,9 +33,9 @@ declare class Headers {
|
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
export declare type ResponseType = 'text' | 'json' | 'redirect' | '
|
|
36
|
+
export declare type ResponseType = 'text' | 'json' | 'redirect' | 'raw';
|
|
37
37
|
export interface Response {
|
|
38
|
-
readonly data:
|
|
38
|
+
readonly data: any;
|
|
39
39
|
readonly status: number;
|
|
40
40
|
readonly statusText: string;
|
|
41
41
|
readonly headers: Headers;
|
package/esm/shared/response.js
CHANGED
|
@@ -108,7 +108,7 @@ export const isJson = createTypeCreator('json');
|
|
|
108
108
|
export const isText = createTypeCreator('text');
|
|
109
109
|
export const isRedirect = createTypeCreator('redirect');
|
|
110
110
|
export function response(data, options) {
|
|
111
|
-
return new ResponseImpl(data, '
|
|
111
|
+
return new ResponseImpl(data, 'raw', options);
|
|
112
112
|
}
|
|
113
113
|
export function json(data) {
|
|
114
114
|
return new ResponseImpl(data, 'json');
|
|
@@ -34,7 +34,11 @@ function getPlugins(runtime, pluginRecords) {
|
|
|
34
34
|
pluginConstructor[method] = runtime[method];
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
plugins.push([
|
|
37
|
+
plugins.push([
|
|
38
|
+
createRuntimePlugin(pluginConstructor, {
|
|
39
|
+
name: 'shuvi-user-app'
|
|
40
|
+
})
|
|
41
|
+
]);
|
|
38
42
|
return plugins;
|
|
39
43
|
}
|
|
40
44
|
export default function application(options) {
|
|
@@ -74,9 +74,9 @@ function redirectHelper(to, status = 302) {
|
|
|
74
74
|
}
|
|
75
75
|
throw (0, response_1.redirect)(to, status);
|
|
76
76
|
}
|
|
77
|
-
function errorHelper(msg, statusCode = 500) {
|
|
77
|
+
function errorHelper(msg, statusCode = 500, { fatal = false } = {}) {
|
|
78
78
|
(0, invariant_1.default)(statusCode >= 400 && statusCode < 600, 'status code should be 4xx and 5xx');
|
|
79
|
-
throw (0, response_1.response)(
|
|
79
|
+
throw (0, response_1.response)({ error: true, fatal: fatal }, { status: statusCode, statusText: msg });
|
|
80
80
|
}
|
|
81
81
|
function createLoaderContext({ pathname, query, params, req, getAppContext }) {
|
|
82
82
|
return Object.assign({ pathname,
|
|
@@ -13,7 +13,9 @@ export declare type RedirectFunction = (to: string, status?: number) => any;
|
|
|
13
13
|
export interface ErrorFunction {
|
|
14
14
|
(): any;
|
|
15
15
|
(msg: string): any;
|
|
16
|
-
(msg: string, statusCode?: number
|
|
16
|
+
(msg: string, statusCode?: number, options?: {
|
|
17
|
+
fatal?: boolean;
|
|
18
|
+
}): any;
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
19
21
|
* route component getInitialProps params `context`
|
package/lib/shared/response.d.ts
CHANGED
|
@@ -33,9 +33,9 @@ declare class Headers {
|
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
export declare type ResponseType = 'text' | 'json' | 'redirect' | '
|
|
36
|
+
export declare type ResponseType = 'text' | 'json' | 'redirect' | 'raw';
|
|
37
37
|
export interface Response {
|
|
38
|
-
readonly data:
|
|
38
|
+
readonly data: any;
|
|
39
39
|
readonly status: number;
|
|
40
40
|
readonly statusText: string;
|
|
41
41
|
readonly headers: Headers;
|
package/lib/shared/response.js
CHANGED
|
@@ -112,7 +112,7 @@ exports.isJson = createTypeCreator('json');
|
|
|
112
112
|
exports.isText = createTypeCreator('text');
|
|
113
113
|
exports.isRedirect = createTypeCreator('redirect');
|
|
114
114
|
function response(data, options) {
|
|
115
|
-
return new ResponseImpl(data, '
|
|
115
|
+
return new ResponseImpl(data, 'raw', options);
|
|
116
116
|
}
|
|
117
117
|
exports.response = response;
|
|
118
118
|
function json(data) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shuvi/platform-shared",
|
|
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",
|
|
@@ -83,16 +83,16 @@
|
|
|
83
83
|
"node": ">= 16.0.0"
|
|
84
84
|
},
|
|
85
85
|
"dependencies": {
|
|
86
|
-
"@shuvi/hook": "1.0.
|
|
86
|
+
"@shuvi/hook": "1.0.49",
|
|
87
87
|
"doura": "0.0.13",
|
|
88
|
-
"@shuvi/router": "1.0.
|
|
89
|
-
"@shuvi/runtime": "1.0.
|
|
90
|
-
"@shuvi/shared": "1.0.
|
|
91
|
-
"@shuvi/toolpack": "1.0.
|
|
92
|
-
"@shuvi/utils": "1.0.
|
|
88
|
+
"@shuvi/router": "1.0.49",
|
|
89
|
+
"@shuvi/runtime": "1.0.49",
|
|
90
|
+
"@shuvi/shared": "1.0.49",
|
|
91
|
+
"@shuvi/toolpack": "1.0.49",
|
|
92
|
+
"@shuvi/utils": "1.0.49"
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
|
-
"@shuvi/service": "1.0.
|
|
95
|
+
"@shuvi/service": "1.0.49"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
98
|
"@shuvi/service": "workspace:*",
|