@lark-apaas/client-toolkit 1.1.19-alpha.error.1 → 1.1.19
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/ErrorRender/index.d.ts +0 -1
- package/lib/components/ErrorRender/index.js +3 -13
- package/lib/logger/intercept-global-error.js +6 -14
- package/lib/types/iframe-events.d.ts +1 -1
- package/package.json +2 -2
- package/lib/utils/module-hot.d.ts +0 -24
- package/lib/utils/module-hot.js +0 -22
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect } from "react";
|
|
3
3
|
import { logger } from "../../logger/index.js";
|
|
4
|
-
import { createApplyHandle, getModuleHot } from "../../utils/module-hot.js";
|
|
5
4
|
const RenderError = (props)=>{
|
|
6
|
-
const { error
|
|
5
|
+
const { error } = props;
|
|
7
6
|
useEffect(()=>{
|
|
8
|
-
if (error) logger.log({
|
|
7
|
+
if (props.error) logger.log({
|
|
9
8
|
level: 'error',
|
|
10
9
|
args: [
|
|
11
10
|
'Render Error',
|
|
@@ -16,16 +15,7 @@ const RenderError = (props)=>{
|
|
|
16
15
|
}
|
|
17
16
|
});
|
|
18
17
|
}, [
|
|
19
|
-
error
|
|
20
|
-
]);
|
|
21
|
-
useEffect(()=>{
|
|
22
|
-
if (!resetErrorBoundary) return;
|
|
23
|
-
const hot = getModuleHot();
|
|
24
|
-
if (hot) hot.addStatusHandler(createApplyHandle((success)=>{
|
|
25
|
-
if (success) resetErrorBoundary();
|
|
26
|
-
}));
|
|
27
|
-
}, [
|
|
28
|
-
resetErrorBoundary
|
|
18
|
+
props.error
|
|
29
19
|
]);
|
|
30
20
|
return /*#__PURE__*/ jsx("div", {
|
|
31
21
|
className: "min-h-screen flex items-center justify-center bg-white",
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createApplyHandle, getModuleHot } from "../utils/module-hot.js";
|
|
2
1
|
import { submitPostMessage, submitSlardarEvent } from "../utils/postMessage.js";
|
|
3
2
|
import { levelSchema } from "./log-types.js";
|
|
4
3
|
import { logger } from "./logger.js";
|
|
@@ -62,17 +61,10 @@ function processDevServerLog(log) {
|
|
|
62
61
|
});
|
|
63
62
|
}
|
|
64
63
|
}
|
|
65
|
-
function
|
|
66
|
-
const hot =
|
|
67
|
-
if (hot) hot.addStatusHandler(
|
|
68
|
-
if (
|
|
69
|
-
type: 'DevServerMessage',
|
|
70
|
-
data: {
|
|
71
|
-
type: 'devServer-status',
|
|
72
|
-
status: 'hmr-apply-success'
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
else {
|
|
64
|
+
function listenHmrApplyFailed() {
|
|
65
|
+
const hot = import.meta.webpackHot || module.hot;
|
|
66
|
+
if (hot) hot.addStatusHandler((status)=>{
|
|
67
|
+
if ('fail' === status || 'abort' === status) {
|
|
76
68
|
console.warn('hmr apply failed', status);
|
|
77
69
|
submitSlardarEvent({
|
|
78
70
|
name: 'sandbox-devServer',
|
|
@@ -82,7 +74,7 @@ function listenModuleHmr() {
|
|
|
82
74
|
}
|
|
83
75
|
});
|
|
84
76
|
}
|
|
85
|
-
})
|
|
77
|
+
});
|
|
86
78
|
}
|
|
87
79
|
function interceptErrors() {
|
|
88
80
|
window.addEventListener('error', (event)=>{
|
|
@@ -91,7 +83,7 @@ function interceptErrors() {
|
|
|
91
83
|
window.addEventListener('unhandledrejection', (event)=>{
|
|
92
84
|
logger.error(event.reason);
|
|
93
85
|
});
|
|
94
|
-
|
|
86
|
+
listenHmrApplyFailed();
|
|
95
87
|
const PROXY_CONSOLE_METHOD = [
|
|
96
88
|
'log',
|
|
97
89
|
'info',
|
|
@@ -41,7 +41,7 @@ export interface HmrMessage extends IframeMessage<Record<string, never>> {
|
|
|
41
41
|
/** devServer相关消息 */
|
|
42
42
|
export interface DevServerMessage extends IframeMessage<{
|
|
43
43
|
type: 'devServer-status';
|
|
44
|
-
status: 'connected' | 'disconnected'
|
|
44
|
+
status: 'connected' | 'disconnected';
|
|
45
45
|
}> {
|
|
46
46
|
type: 'DevServerMessage';
|
|
47
47
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/client-toolkit",
|
|
3
|
-
"version": "1.1.19
|
|
3
|
+
"version": "1.1.19",
|
|
4
4
|
"types": "./lib/index.d.ts",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"@ant-design/colors": "^7.2.1",
|
|
77
77
|
"@ant-design/cssinjs": "^1.24.0",
|
|
78
78
|
"@data-loom/js": "^0.4.0",
|
|
79
|
-
"@lark-apaas/miaoda-inspector": "^1.0.
|
|
79
|
+
"@lark-apaas/miaoda-inspector": "^1.0.4",
|
|
80
80
|
"@radix-ui/react-avatar": "^1.1.10",
|
|
81
81
|
"@radix-ui/react-popover": "^1.1.15",
|
|
82
82
|
"@radix-ui/react-slot": "^1.2.3",
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Module Hot Replacement 状态类型定义
|
|
3
|
-
*
|
|
4
|
-
* - idle: The process is waiting for a call to check
|
|
5
|
-
* - check: The process is checking for updates
|
|
6
|
-
* - prepare: The process is getting ready for the update (e.g. downloading the updated module)
|
|
7
|
-
* - ready: The update is prepared and available
|
|
8
|
-
* - dispose: The process is calling the dispose handlers on the modules that will be replaced
|
|
9
|
-
* - apply: The process is calling the accept handlers and re-executing self-accepted modules
|
|
10
|
-
* - abort: An update was aborted, but the system is still in its previous state
|
|
11
|
-
* - fail: An update has thrown an exception and the system's state has been compromised
|
|
12
|
-
*/
|
|
13
|
-
type ModuleHotType = 'idle' | 'check' | 'prepare' | 'ready' | 'dispose' | 'apply' | 'abort' | 'fail';
|
|
14
|
-
interface ModuleHotInstance {
|
|
15
|
-
addStatusHandler: (handler: (status: ModuleHotType) => void) => void;
|
|
16
|
-
}
|
|
17
|
-
export declare function getModuleHot(): ModuleHotInstance | null;
|
|
18
|
-
/**
|
|
19
|
-
* 创建模块热更成功处理函数
|
|
20
|
-
* 监听模块热更状态,当状态为apply时,调用回调函数并传入true
|
|
21
|
-
* @param callback 热更成功回调函数,参数为是否成功
|
|
22
|
-
*/
|
|
23
|
-
export declare function createApplyHandle(callback: (success: boolean) => void): (status: ModuleHotType) => void;
|
|
24
|
-
export {};
|
package/lib/utils/module-hot.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
function getModuleHot() {
|
|
2
|
-
if ('production' === process.env.NODE_ENV) return null;
|
|
3
|
-
return import.meta.webpackHot || module.hot;
|
|
4
|
-
}
|
|
5
|
-
function createApplyHandle(callback) {
|
|
6
|
-
let hasApply = false;
|
|
7
|
-
return (status)=>{
|
|
8
|
-
if ('fail' === status || 'abort' === status) {
|
|
9
|
-
hasApply = false;
|
|
10
|
-
return callback(false);
|
|
11
|
-
}
|
|
12
|
-
if (hasApply) {
|
|
13
|
-
if ('idle' === status) {
|
|
14
|
-
hasApply = false;
|
|
15
|
-
callback(true);
|
|
16
|
-
}
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
hasApply = 'apply' === status;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export { createApplyHandle, getModuleHot };
|