@shuvi/error-overlay 1.0.0-rc.9 → 1.0.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/lib/client.js +11 -9
- package/lib/iframe-bundle.js +9 -7
- package/lib/iframeScript.js +6 -4
- package/lib/middleware/helper/getSourceById.d.ts +1 -1
- package/package.json +5 -5
- package/umd/index.js +14 -12
- package/umd/middleware/helper/getSourceById.d.ts +1 -1
- package/umd/middleware/helper/index.d.ts +0 -5
package/lib/client.js
CHANGED
|
@@ -12,7 +12,7 @@ let stackTraceLimit = undefined;
|
|
|
12
12
|
let iframe = null;
|
|
13
13
|
let isLoadingIframe = false;
|
|
14
14
|
let isIframeReady = false;
|
|
15
|
-
let
|
|
15
|
+
let errorTypeList = [];
|
|
16
16
|
let hasBuildError = false;
|
|
17
17
|
let hasRuntimeError = false;
|
|
18
18
|
const iframeStyle = {
|
|
@@ -31,11 +31,11 @@ function onUnhandledError(ev) {
|
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
33
|
hasRuntimeError = true;
|
|
34
|
-
|
|
34
|
+
errorTypeList.push({
|
|
35
35
|
type: constants_1.TYPE_UNHANDLED_ERROR,
|
|
36
36
|
reason: error,
|
|
37
37
|
frames: (0, parseStack_1.parseStack)(error.stack)
|
|
38
|
-
};
|
|
38
|
+
});
|
|
39
39
|
update();
|
|
40
40
|
}
|
|
41
41
|
function onUnhandledRejection(ev) {
|
|
@@ -47,11 +47,11 @@ function onUnhandledRejection(ev) {
|
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
hasRuntimeError = true;
|
|
50
|
-
|
|
50
|
+
errorTypeList.push({
|
|
51
51
|
type: constants_1.TYPE_UNHANDLED_REJECTION,
|
|
52
52
|
reason: reason,
|
|
53
53
|
frames: (0, parseStack_1.parseStack)(reason.stack)
|
|
54
|
-
};
|
|
54
|
+
});
|
|
55
55
|
update();
|
|
56
56
|
}
|
|
57
57
|
function startReportingRuntimeErrors({ onError }) {
|
|
@@ -94,18 +94,18 @@ function stopReportingRuntimeErrors() {
|
|
|
94
94
|
exports.stopReportingRuntimeErrors = stopReportingRuntimeErrors;
|
|
95
95
|
function onBuildOk() {
|
|
96
96
|
hasBuildError = false;
|
|
97
|
-
|
|
97
|
+
errorTypeList.push({ type: constants_1.TYPE_BUILD_OK });
|
|
98
98
|
update();
|
|
99
99
|
}
|
|
100
100
|
exports.onBuildOk = onBuildOk;
|
|
101
101
|
function onBuildError(message) {
|
|
102
102
|
hasBuildError = true;
|
|
103
|
-
|
|
103
|
+
errorTypeList.push({ type: constants_1.TYPE_BUILD_ERROR, message });
|
|
104
104
|
update();
|
|
105
105
|
}
|
|
106
106
|
exports.onBuildError = onBuildError;
|
|
107
107
|
function onRefresh() {
|
|
108
|
-
|
|
108
|
+
errorTypeList.push({ type: constants_1.TYPE_REFRESH });
|
|
109
109
|
}
|
|
110
110
|
exports.onRefresh = onRefresh;
|
|
111
111
|
function applyStyles(element, styles) {
|
|
@@ -154,10 +154,12 @@ function updateIframeContent() {
|
|
|
154
154
|
}
|
|
155
155
|
//@ts-ignore
|
|
156
156
|
const isRendered = iframe.contentWindow.updateContent({
|
|
157
|
-
|
|
157
|
+
errorTypeList,
|
|
158
158
|
hasBuildError,
|
|
159
159
|
hasRuntimeError
|
|
160
160
|
});
|
|
161
|
+
//After the errors have been added to the queue of the error handler, we must clear the errorTypeList
|
|
162
|
+
errorTypeList = [];
|
|
161
163
|
if (!isRendered) {
|
|
162
164
|
window.document.body.removeChild(iframe);
|
|
163
165
|
iframe = null;
|
package/lib/iframe-bundle.js
CHANGED
|
@@ -1671,9 +1671,9 @@ function getErrorSource(error) {
|
|
|
1671
1671
|
|
|
1672
1672
|
// common
|
|
1673
1673
|
const NAME = 'shuvi';
|
|
1674
|
-
const
|
|
1675
|
-
const DEV_HOT_LAUNCH_EDITOR_ENDPOINT = `${
|
|
1676
|
-
const DEV_ORIGINAL_STACK_FRAME_ENDPOINT = `${
|
|
1674
|
+
const DEV_ONLY_URL_PREFIX = `/_${NAME}`;
|
|
1675
|
+
const DEV_HOT_LAUNCH_EDITOR_ENDPOINT = `${DEV_ONLY_URL_PREFIX}/development/open-stack-frame-in-editor`;
|
|
1676
|
+
const DEV_ORIGINAL_STACK_FRAME_ENDPOINT = `${DEV_ONLY_URL_PREFIX}/development/original-stack-frame`;
|
|
1677
1677
|
|
|
1678
1678
|
function getOriginalStackFrames(frames, type, errorMessage) {
|
|
1679
1679
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -2603,16 +2603,18 @@ const ErrorOverlay = function ErrorOverlay() {
|
|
|
2603
2603
|
let iframeRoot = null;
|
|
2604
2604
|
let errorBody = null;
|
|
2605
2605
|
let isFirstRender = true;
|
|
2606
|
-
function render({
|
|
2607
|
-
|
|
2606
|
+
function render({ errorTypeList, hasBuildError, hasRuntimeError }) {
|
|
2607
|
+
errorTypeList.forEach((errorType) => {
|
|
2608
|
+
emit(errorType);
|
|
2609
|
+
});
|
|
2608
2610
|
if (!hasBuildError && !hasRuntimeError) {
|
|
2609
2611
|
return null;
|
|
2610
2612
|
}
|
|
2611
2613
|
return jsxRuntime.exports.jsx(ErrorOverlay, {});
|
|
2612
2614
|
}
|
|
2613
|
-
window.updateContent = function updateContent({
|
|
2615
|
+
window.updateContent = function updateContent({ errorTypeList, hasBuildError, hasRuntimeError }) {
|
|
2614
2616
|
let renderedElement = render({
|
|
2615
|
-
|
|
2617
|
+
errorTypeList,
|
|
2616
2618
|
hasBuildError,
|
|
2617
2619
|
hasRuntimeError
|
|
2618
2620
|
});
|
package/lib/iframeScript.js
CHANGED
|
@@ -40,16 +40,18 @@ const errorTypeHandler = __importStar(require("./view/errorTypeHandler"));
|
|
|
40
40
|
let iframeRoot = null;
|
|
41
41
|
let errorBody = null;
|
|
42
42
|
let isFirstRender = true;
|
|
43
|
-
function render({
|
|
44
|
-
|
|
43
|
+
function render({ errorTypeList, hasBuildError, hasRuntimeError }) {
|
|
44
|
+
errorTypeList.forEach((errorType) => {
|
|
45
|
+
errorTypeHandler.emit(errorType);
|
|
46
|
+
});
|
|
45
47
|
if (!hasBuildError && !hasRuntimeError) {
|
|
46
48
|
return null;
|
|
47
49
|
}
|
|
48
50
|
return (0, jsx_runtime_1.jsx)(ErrorOverlay_1.ErrorOverlay, {});
|
|
49
51
|
}
|
|
50
|
-
window.updateContent = function updateContent({
|
|
52
|
+
window.updateContent = function updateContent({ errorTypeList, hasBuildError, hasRuntimeError }) {
|
|
51
53
|
let renderedElement = render({
|
|
52
|
-
|
|
54
|
+
errorTypeList,
|
|
53
55
|
hasBuildError,
|
|
54
56
|
hasRuntimeError
|
|
55
57
|
});
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shuvi/error-overlay",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"main": "umd/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib",
|
|
7
7
|
"umd"
|
|
8
8
|
],
|
|
9
9
|
"scripts": {
|
|
10
|
-
"dev": "
|
|
11
|
-
"iframe
|
|
10
|
+
"dev": "run-p watch:*",
|
|
11
|
+
"watch:iframe": "cross-env NODE_ENV=development rollup -c rollup.config.iframe.js -w",
|
|
12
12
|
"watch:cjs": "tsc -p tsconfig.build.json -m commonjs --outDir lib -w",
|
|
13
13
|
"watch:umd": "cross-env NODE_ENV=development rollup -c rollup.config.js -w",
|
|
14
14
|
"prebuild": "rimraf lib",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@babel/code-frame": "7.14.5",
|
|
25
|
-
"@shuvi/shared": "1.0.0
|
|
26
|
-
"@shuvi/toolpack": "1.0.0
|
|
25
|
+
"@shuvi/shared": "1.0.0",
|
|
26
|
+
"@shuvi/toolpack": "1.0.0",
|
|
27
27
|
"anser": "1.4.9",
|
|
28
28
|
"data-uri-to-buffer": "3.0.1",
|
|
29
29
|
"html-entities": "2.3.2",
|