@lark-apaas/client-toolkit 1.1.8 → 1.1.9-alpha.log.1
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/AppContainer/IframeBridge.d.ts +0 -1
- package/lib/components/AppContainer/IframeBridge.js +0 -1
- package/lib/components/AppContainer/index.js +4 -7
- package/lib/components/AppContainer/sonner.js +1 -6
- package/lib/components/ErrorRender/index.js +15 -67
- package/lib/components/NotFoundRender/index.js +18 -40
- package/lib/components/theme/index.d.ts +1 -2
- package/lib/components/theme/index.js +1 -3
- package/lib/components/theme/util.d.ts +6 -5
- package/lib/components/theme/util.js +1 -81
- package/lib/hooks/index.d.ts +0 -1
- package/lib/hooks/index.js +0 -1
- package/lib/logger/intercept-global-error.d.ts +1 -1
- package/lib/logger/intercept-global-error.js +27 -2
- package/lib/logger/log-types.d.ts +10 -4
- package/lib/logger/log-types.js +12 -12
- package/lib/logger/logger.js +7 -2
- package/lib/logger/selected-logs.js +12 -5
- package/lib/utils/axiosConfig.js +12 -12
- package/package.json +1 -5
- package/lib/apis/hooks/useTheme.d.ts +0 -1
- package/lib/apis/hooks/useTheme.js +0 -1
- package/lib/components/AppContainer/LogInterceptor.d.ts +0 -1
- package/lib/components/AppContainer/LogInterceptor.js +0 -66
- package/lib/components/theme/ThemeProvider.d.ts +0 -20
- package/lib/components/theme/ThemeProvider.js +0 -75
- package/lib/components/theme/miaoDarkTheme.d.ts +0 -2
- package/lib/components/theme/miaoDarkTheme.js +0 -310
- package/lib/components/theme/miaoLightTheme.d.ts +0 -2
- package/lib/components/theme/miaoLightTheme.js +0 -296
- package/lib/hooks/useTheme.d.ts +0 -4
- package/lib/hooks/useTheme.js +0 -8
|
@@ -7,7 +7,6 @@ import { postMessage } from "../../utils/postMessage.js";
|
|
|
7
7
|
import { getPreviewParentOrigin } from "../../utils/getParentOrigin.js";
|
|
8
8
|
import { childApi } from "./utils/childApi.js";
|
|
9
9
|
import "./utils/listenHot.js";
|
|
10
|
-
import "./LogInterceptor.js";
|
|
11
10
|
var IframeBridge_RouteMessageType = /*#__PURE__*/ function(RouteMessageType) {
|
|
12
11
|
RouteMessageType["RouteChange"] = "RouteChange";
|
|
13
12
|
RouteMessageType["RouteBack"] = "RouteBack";
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect } from "react";
|
|
3
|
-
import { StyleProvider } from "@ant-design/cssinjs";
|
|
4
3
|
import { MiaodaInspector } from "@lark-apaas/miaoda-inspector";
|
|
5
4
|
import IframeBridge from "./IframeBridge.js";
|
|
6
5
|
import { defaultUIConfig } from "../theme/ui-config.js";
|
|
7
6
|
import { Toaster } from "./sonner.js";
|
|
8
7
|
import { PageHoc } from "./PageHoc.js";
|
|
9
|
-
import {
|
|
8
|
+
import { findValueByPixel, generateTailwindRadiusToken, themeColorTokenMap, themeMetaOptions } from "../theme/index.js";
|
|
10
9
|
import { registerDayjsPlugins } from "./dayjsPlugins.js";
|
|
11
10
|
import "../../index.css";
|
|
12
11
|
import { initAxiosConfig } from "../../utils/axiosConfig.js";
|
|
@@ -37,8 +36,7 @@ const App = (props)=>{
|
|
|
37
36
|
}, 300);
|
|
38
37
|
});
|
|
39
38
|
}, []);
|
|
40
|
-
return /*#__PURE__*/ jsxs(
|
|
41
|
-
layer: true,
|
|
39
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
42
40
|
children: [
|
|
43
41
|
/*#__PURE__*/ jsx(Toaster, {}),
|
|
44
42
|
'production' !== process.env.NODE_ENV && /*#__PURE__*/ jsx(MiaodaInspector, {
|
|
@@ -58,8 +56,7 @@ const App = (props)=>{
|
|
|
58
56
|
};
|
|
59
57
|
const AppContainer = (props)=>{
|
|
60
58
|
const { children, ...rest } = props;
|
|
61
|
-
return /*#__PURE__*/ jsxs(
|
|
62
|
-
...rest,
|
|
59
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
63
60
|
children: [
|
|
64
61
|
/*#__PURE__*/ jsx(safety, {}),
|
|
65
62
|
/*#__PURE__*/ jsx(App, {
|
|
@@ -2,11 +2,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import "react";
|
|
3
3
|
import { Toaster, toast } from "sonner";
|
|
4
4
|
import "./sonner.css";
|
|
5
|
-
|
|
6
|
-
const sonner_Toaster = ({ ...props })=>{
|
|
7
|
-
const { theme } = useTheme();
|
|
8
|
-
return /*#__PURE__*/ jsx(Toaster, {
|
|
9
|
-
theme: theme,
|
|
5
|
+
const sonner_Toaster = ({ ...props })=>/*#__PURE__*/ jsx(Toaster, {
|
|
10
6
|
className: "toaster group",
|
|
11
7
|
style: {
|
|
12
8
|
top: 70
|
|
@@ -22,5 +18,4 @@ const sonner_Toaster = ({ ...props })=>{
|
|
|
22
18
|
},
|
|
23
19
|
...props
|
|
24
20
|
});
|
|
25
|
-
};
|
|
26
21
|
export { sonner_Toaster as Toaster, toast };
|
|
@@ -1,48 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Button } from "../ui/button.js";
|
|
5
|
-
import { postMessage } from "../../utils/postMessage.js";
|
|
6
|
-
import { copyToClipboard } from "../../utils/copyToClipboard.js";
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import { logger } from "../../logger/index.js";
|
|
7
4
|
const RenderError = (props)=>{
|
|
8
5
|
const { error } = props;
|
|
9
|
-
const location = useLocation();
|
|
10
|
-
const onClickCopy = useCallback(()=>{
|
|
11
|
-
const { message, stack } = error ?? {};
|
|
12
|
-
let result = '';
|
|
13
|
-
if (message && stack) {
|
|
14
|
-
const wrapIndex = stack.indexOf('\n');
|
|
15
|
-
const extraMsg = -1 !== wrapIndex ? stack.slice(0, wrapIndex) : stack;
|
|
16
|
-
result = `${message}
|
|
17
|
-
${extraMsg}`;
|
|
18
|
-
}
|
|
19
|
-
if (!result) try {
|
|
20
|
-
result = JSON.stringify(error);
|
|
21
|
-
} catch (e) {
|
|
22
|
-
console.error('复制到剪切板失败:', error);
|
|
23
|
-
result = 'unknown error';
|
|
24
|
-
}
|
|
25
|
-
copyToClipboard(result);
|
|
26
|
-
}, [
|
|
27
|
-
error
|
|
28
|
-
]);
|
|
29
|
-
const onClickRepair = useCallback(()=>{
|
|
30
|
-
postMessage({
|
|
31
|
-
type: 'RenderErrorRepair',
|
|
32
|
-
data: props.error
|
|
33
|
-
});
|
|
34
|
-
}, [
|
|
35
|
-
props
|
|
36
|
-
]);
|
|
37
6
|
useEffect(()=>{
|
|
38
|
-
if (props.error)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
7
|
+
if (props.error) logger.log({
|
|
8
|
+
level: 'error',
|
|
9
|
+
args: [
|
|
10
|
+
'Render Error',
|
|
11
|
+
error
|
|
12
|
+
],
|
|
13
|
+
meta: {}
|
|
42
14
|
});
|
|
43
15
|
}, [
|
|
44
|
-
props.error
|
|
45
|
-
location
|
|
16
|
+
props.error
|
|
46
17
|
]);
|
|
47
18
|
return /*#__PURE__*/ jsx("div", {
|
|
48
19
|
className: "min-h-screen flex items-center justify-center bg-gray-100",
|
|
@@ -52,35 +23,12 @@ const RenderError = (props)=>{
|
|
|
52
23
|
/*#__PURE__*/ jsx("img", {
|
|
53
24
|
src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/ylcylz_fsph_ryhs/ljhwZthlaukjlkulzlp/feisuda/template/render_error.svg",
|
|
54
25
|
alt: "render error",
|
|
55
|
-
className: "mb-
|
|
26
|
+
className: "mb-3 w-[200px]"
|
|
56
27
|
}),
|
|
57
28
|
/*#__PURE__*/ jsx("p", {
|
|
58
|
-
className: "text-l/[22px] text-[#1F2329] font-medium
|
|
59
|
-
children:
|
|
60
|
-
})
|
|
61
|
-
'production' !== process.env.NODE_ENV ? /*#__PURE__*/ jsxs(Fragment, {
|
|
62
|
-
children: [
|
|
63
|
-
/*#__PURE__*/ jsx("p", {
|
|
64
|
-
className: "text-sm/[22px] text-[#646A73] font-normal mb-2",
|
|
65
|
-
children: "可复制错误信息,或告诉妙搭进行修复"
|
|
66
|
-
}),
|
|
67
|
-
/*#__PURE__*/ jsxs("div", {
|
|
68
|
-
className: "flex space-x-4",
|
|
69
|
-
children: [
|
|
70
|
-
/*#__PURE__*/ jsx(Button, {
|
|
71
|
-
className: "bg-white cursor-pointer text-gray-600 font-[400] border rounded-[6px] shadow-xs hover:bg-gray-100 active:bg-gray-200 focus:outline-hidden h-[32px] border-[#D0D3D6]",
|
|
72
|
-
onClick: onClickCopy,
|
|
73
|
-
children: "复制错误信息"
|
|
74
|
-
}),
|
|
75
|
-
/*#__PURE__*/ jsx(Button, {
|
|
76
|
-
className: "cursor-pointer h-[32px] text-sm font-medium text-white bg-blue-600 border border-transparent rounded-[6px] shadow-xs hover:bg-blue-600 active:bg-blue-700 focus:outline-hidden ",
|
|
77
|
-
onClick: onClickRepair,
|
|
78
|
-
children: "告诉妙搭修复"
|
|
79
|
-
})
|
|
80
|
-
]
|
|
81
|
-
})
|
|
82
|
-
]
|
|
83
|
-
}) : null
|
|
29
|
+
className: "text-l/[22px] text-[14px] text-[#1F2329] font-medium",
|
|
30
|
+
children: "哎呀,出错了"
|
|
31
|
+
})
|
|
84
32
|
]
|
|
85
33
|
})
|
|
86
34
|
});
|
|
@@ -1,57 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useLocation
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useLocation } from "react-router-dom";
|
|
3
3
|
import { useEffect } from "react";
|
|
4
|
-
import { postMessage } from "../../utils/postMessage.js";
|
|
5
|
-
import { useUpdatingRef } from "../../hooks/useUpdatingRef.js";
|
|
6
4
|
import { logger } from "../../logger/index.js";
|
|
7
5
|
const NotFound = ()=>{
|
|
8
6
|
const location = useLocation();
|
|
9
|
-
const navigate = useNavigate();
|
|
10
|
-
const navigateRef = useUpdatingRef(navigate);
|
|
11
7
|
useEffect(()=>{
|
|
12
|
-
logger.
|
|
8
|
+
logger.log({
|
|
9
|
+
level: 'error',
|
|
10
|
+
args: [
|
|
11
|
+
`页面 ${location.pathname} 不存在`
|
|
12
|
+
],
|
|
13
|
+
meta: {
|
|
14
|
+
repairMessage: `页面 ${location.pathname} 不存在,帮我创建`,
|
|
15
|
+
noStacktrace: true
|
|
16
|
+
}
|
|
17
|
+
});
|
|
13
18
|
}, [
|
|
14
19
|
location.pathname
|
|
15
20
|
]);
|
|
16
|
-
const onClick = ()=>{
|
|
17
|
-
if ('production' !== process.env.NODE_ENV) postMessage({
|
|
18
|
-
type: 'CreatePage',
|
|
19
|
-
data: location.pathname
|
|
20
|
-
});
|
|
21
|
-
else navigateRef.current('/');
|
|
22
|
-
};
|
|
23
21
|
return /*#__PURE__*/ jsxs("div", {
|
|
24
|
-
className: "min-h-screen flex flex-col items-center justify-center bg-white",
|
|
22
|
+
className: "min-h-screen flex flex-col items-center justify-center bg-white gap-3",
|
|
25
23
|
children: [
|
|
26
24
|
/*#__PURE__*/ jsx("img", {
|
|
27
|
-
src: '
|
|
28
|
-
alt: "
|
|
29
|
-
className: "
|
|
25
|
+
src: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ylcylz_fsph_ryhs/ljhwZthlaukjlkulzlp/feisuda/template/illustration_empty_neutral_unfinished.svg',
|
|
26
|
+
alt: "Not Found",
|
|
27
|
+
className: "w-[120px]"
|
|
30
28
|
}),
|
|
31
29
|
/*#__PURE__*/ jsx("p", {
|
|
32
30
|
className: "text-l/[22px] text-[14px] text-[#1F2329] font-medium",
|
|
33
|
-
children:
|
|
34
|
-
})
|
|
35
|
-
'production' !== process.env.NODE_ENV ? /*#__PURE__*/ jsxs(Fragment, {
|
|
36
|
-
children: [
|
|
37
|
-
/*#__PURE__*/ jsx("p", {
|
|
38
|
-
className: "text-sm/[22px] text-[14px] text-[#646A73] font-normal mt-1",
|
|
39
|
-
children: "戳下方按钮,我可以根据上下文帮你生成一个"
|
|
40
|
-
}),
|
|
41
|
-
/*#__PURE__*/ jsxs("button", {
|
|
42
|
-
className: "h-[32px] text-sm font-medium text-white bg-blue-600 border border-transparent rounded-md shadow-xs hover:bg-blue-600 active:bg-blue-700 focus:outline-hidden focus:ring-2 focus:ring-blue-500 px-3 flex flex-row items-center mt-3",
|
|
43
|
-
onClick: onClick,
|
|
44
|
-
children: [
|
|
45
|
-
/*#__PURE__*/ jsx("img", {
|
|
46
|
-
src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/ylcylz_fsph_ryhs/ljhwZthlaukjlkulzlp/feisuda/template/icon_chat-ai_outlined.svg",
|
|
47
|
-
alt: "Icon",
|
|
48
|
-
className: "w-[14px] h-[14px] mr-1"
|
|
49
|
-
}),
|
|
50
|
-
"告诉妙搭生成一个"
|
|
51
|
-
]
|
|
52
|
-
})
|
|
53
|
-
]
|
|
54
|
-
}) : null
|
|
31
|
+
children: "哎呀,页面不存在"
|
|
32
|
+
})
|
|
55
33
|
]
|
|
56
34
|
});
|
|
57
35
|
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { UIComponentConfig } from
|
|
3
|
-
export
|
|
1
|
+
import { ITheme } from "../../types";
|
|
2
|
+
import { UIComponentConfig } from "./ui-config";
|
|
3
|
+
export interface IBaseThemeProviderProps {
|
|
4
|
+
defaultTheme?: ITheme;
|
|
5
|
+
themeMeta?: Partial<IThemeTokenMeta>;
|
|
6
|
+
}
|
|
4
7
|
export interface IThemeTokenMeta {
|
|
5
8
|
/**
|
|
6
9
|
* 品牌色
|
|
@@ -16,5 +19,3 @@ export interface IThemeTokenMeta {
|
|
|
16
19
|
spacing: number;
|
|
17
20
|
}
|
|
18
21
|
export declare const generateTailwindRadiusToken: (radiusRemValue: number) => UIComponentConfig;
|
|
19
|
-
export declare function generateLightTheme(override?: Partial<IThemeTokenMeta>): ThemeConfig;
|
|
20
|
-
export declare function generateDarkTheme(override?: Partial<IThemeTokenMeta>): ThemeConfig;
|
|
@@ -1,59 +1,3 @@
|
|
|
1
|
-
import { generate } from "@ant-design/colors";
|
|
2
|
-
import { defaultDarkTheme } from "./miaoDarkTheme.js";
|
|
3
|
-
import { defaultLightTheme } from "./miaoLightTheme.js";
|
|
4
|
-
const generateColorPalettes = (baseColor, mode)=>{
|
|
5
|
-
const colors = generate(baseColor, {
|
|
6
|
-
theme: mode
|
|
7
|
-
});
|
|
8
|
-
return {
|
|
9
|
-
1: colors[0],
|
|
10
|
-
2: colors[1],
|
|
11
|
-
3: colors[2],
|
|
12
|
-
4: colors[3],
|
|
13
|
-
5: colors[6],
|
|
14
|
-
6: colors[5],
|
|
15
|
-
7: colors[4],
|
|
16
|
-
8: colors[6],
|
|
17
|
-
9: colors[5],
|
|
18
|
-
10: colors[4]
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
function generateColorPrimaryToken(colorPrimary, mode = 'light') {
|
|
22
|
-
const primaryColors = generateColorPalettes(colorPrimary, 'dark' === mode ? 'dark' : 'default');
|
|
23
|
-
return {
|
|
24
|
-
colorPrimaryBg: primaryColors[1],
|
|
25
|
-
colorPrimaryBgHover: primaryColors[2],
|
|
26
|
-
colorPrimaryBorder: primaryColors[3],
|
|
27
|
-
colorPrimaryBorderHover: primaryColors[4],
|
|
28
|
-
colorPrimaryHover: primaryColors[5],
|
|
29
|
-
colorPrimary: primaryColors[6],
|
|
30
|
-
colorPrimaryActive: primaryColors[7],
|
|
31
|
-
colorPrimaryTextHover: primaryColors[8],
|
|
32
|
-
colorPrimaryText: primaryColors[9],
|
|
33
|
-
colorPrimaryTextActive: primaryColors[10]
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
const generateBorderRadiusTokenSyncTailwind = (radiusBase)=>({
|
|
37
|
-
borderRadius: radiusBase,
|
|
38
|
-
borderRadiusXS: radiusBase - 4,
|
|
39
|
-
borderRadiusSM: radiusBase - 2,
|
|
40
|
-
borderRadiusLG: radiusBase + 2,
|
|
41
|
-
borderRadiusOuter: radiusBase + 4
|
|
42
|
-
});
|
|
43
|
-
const generateSpacingToken = (token)=>{
|
|
44
|
-
const { sizeUnit, sizeStep } = token;
|
|
45
|
-
return {
|
|
46
|
-
sizeXXL: sizeUnit * (sizeStep + 8),
|
|
47
|
-
sizeXL: sizeUnit * (sizeStep + 4),
|
|
48
|
-
sizeLG: sizeUnit * (sizeStep + 2),
|
|
49
|
-
sizeMD: sizeUnit * (sizeStep + 1),
|
|
50
|
-
sizeMS: sizeUnit * sizeStep,
|
|
51
|
-
size: sizeUnit * sizeStep,
|
|
52
|
-
sizeSM: sizeUnit * (sizeStep - 1),
|
|
53
|
-
sizeXS: sizeUnit * (sizeStep - 2),
|
|
54
|
-
sizeXXS: sizeUnit * (sizeStep - 3)
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
1
|
const generateTailwindRadiusToken = (radiusRemValue)=>{
|
|
58
2
|
try {
|
|
59
3
|
const rootFontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
@@ -161,28 +105,4 @@ const generateTailwindRadiusToken = (radiusRemValue)=>{
|
|
|
161
105
|
};
|
|
162
106
|
}
|
|
163
107
|
};
|
|
164
|
-
|
|
165
|
-
const darkColorPrimary = '#336df4';
|
|
166
|
-
function generateLightTheme(override) {
|
|
167
|
-
return {
|
|
168
|
-
...defaultLightTheme,
|
|
169
|
-
token: {
|
|
170
|
-
...defaultLightTheme.token,
|
|
171
|
-
...generateColorPrimaryToken(override?.colorPrimary || lightColorPrimary, 'light'),
|
|
172
|
-
...generateBorderRadiusTokenSyncTailwind(override?.borderRadius),
|
|
173
|
-
...generateSpacingToken(override)
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
function generateDarkTheme(override) {
|
|
178
|
-
return {
|
|
179
|
-
...defaultDarkTheme,
|
|
180
|
-
token: {
|
|
181
|
-
...defaultDarkTheme.token,
|
|
182
|
-
...generateColorPrimaryToken(override?.colorPrimary || darkColorPrimary, 'dark'),
|
|
183
|
-
...generateBorderRadiusTokenSyncTailwind(override?.borderRadius),
|
|
184
|
-
...generateSpacingToken(override)
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
export { generateDarkTheme, generateLightTheme, generateTailwindRadiusToken };
|
|
108
|
+
export { generateTailwindRadiusToken };
|
package/lib/hooks/index.d.ts
CHANGED
package/lib/hooks/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function interceptErrors(): void;
|
|
@@ -1,10 +1,35 @@
|
|
|
1
|
+
import { levelSchema } from "./log-types.js";
|
|
1
2
|
import { logger } from "./logger.js";
|
|
2
|
-
function
|
|
3
|
+
function interceptErrors() {
|
|
3
4
|
window.addEventListener('error', (event)=>{
|
|
4
5
|
logger.error(event.error);
|
|
5
6
|
});
|
|
6
7
|
window.addEventListener('unhandledrejection', (event)=>{
|
|
7
8
|
logger.error(event.reason);
|
|
8
9
|
});
|
|
10
|
+
const PROXY_CONSOLE_METHOD = [
|
|
11
|
+
'log',
|
|
12
|
+
'info',
|
|
13
|
+
'warn',
|
|
14
|
+
'error'
|
|
15
|
+
];
|
|
16
|
+
PROXY_CONSOLE_METHOD.forEach((method)=>{
|
|
17
|
+
const originalMethod = window.console[method];
|
|
18
|
+
window.console[method] = (...args)=>{
|
|
19
|
+
originalMethod(...args);
|
|
20
|
+
const log = args[0];
|
|
21
|
+
if ('string' == typeof log && log.startsWith('[Dataloom]') && levelSchema.safeParse(method).success) {
|
|
22
|
+
logger.log({
|
|
23
|
+
level: method,
|
|
24
|
+
args
|
|
25
|
+
});
|
|
26
|
+
postMessage({
|
|
27
|
+
type: 'Console',
|
|
28
|
+
method,
|
|
29
|
+
data: args
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
});
|
|
9
34
|
}
|
|
10
|
-
export {
|
|
35
|
+
export { interceptErrors };
|
|
@@ -42,8 +42,10 @@ export declare const logMeta: z.ZodObject<{
|
|
|
42
42
|
}, z.core.$strip>>>;
|
|
43
43
|
logTraceID: z.ZodOptional<z.ZodString>;
|
|
44
44
|
skipFrame: z.ZodOptional<z.ZodNumber>;
|
|
45
|
+
noStacktrace: z.ZodOptional<z.ZodBoolean>;
|
|
46
|
+
repairMessage: z.ZodOptional<z.ZodString>;
|
|
45
47
|
}, z.core.$strip>;
|
|
46
|
-
export declare const selectedLogSchema: z.
|
|
48
|
+
export declare const selectedLogSchema: z.ZodObject<{
|
|
47
49
|
type: z.ZodLiteral<"typedLogV2">;
|
|
48
50
|
level: z.ZodEnum<{
|
|
49
51
|
success: "success";
|
|
@@ -63,8 +65,10 @@ export declare const selectedLogSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
63
65
|
}, z.core.$strip>>>;
|
|
64
66
|
logTraceID: z.ZodOptional<z.ZodString>;
|
|
65
67
|
skipFrame: z.ZodOptional<z.ZodNumber>;
|
|
68
|
+
noStacktrace: z.ZodOptional<z.ZodBoolean>;
|
|
69
|
+
repairMessage: z.ZodOptional<z.ZodString>;
|
|
66
70
|
}, z.core.$strip>;
|
|
67
|
-
}, z.core.$strip
|
|
71
|
+
}, z.core.$strip>;
|
|
68
72
|
export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'success';
|
|
69
73
|
export declare const logWithMetaSchema: z.ZodObject<{
|
|
70
74
|
level: z.ZodEnum<{
|
|
@@ -75,7 +79,7 @@ export declare const logWithMetaSchema: z.ZodObject<{
|
|
|
75
79
|
debug: "debug";
|
|
76
80
|
}>;
|
|
77
81
|
args: z.ZodArray<z.ZodUnknown>;
|
|
78
|
-
meta: z.ZodObject<{
|
|
82
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
79
83
|
stacktrace: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
80
84
|
functionName: z.ZodString;
|
|
81
85
|
fileName: z.ZodString;
|
|
@@ -84,7 +88,9 @@ export declare const logWithMetaSchema: z.ZodObject<{
|
|
|
84
88
|
}, z.core.$strip>>>;
|
|
85
89
|
logTraceID: z.ZodOptional<z.ZodString>;
|
|
86
90
|
skipFrame: z.ZodOptional<z.ZodNumber>;
|
|
87
|
-
|
|
91
|
+
noStacktrace: z.ZodOptional<z.ZodBoolean>;
|
|
92
|
+
repairMessage: z.ZodOptional<z.ZodString>;
|
|
93
|
+
}, z.core.$strip>>;
|
|
88
94
|
}, z.core.$strip>;
|
|
89
95
|
export type LogStackFrame = z.infer<typeof logStackFrameSchema>;
|
|
90
96
|
export type LogWithMeta = z.infer<typeof logWithMetaSchema>;
|
package/lib/logger/log-types.js
CHANGED
|
@@ -36,20 +36,20 @@ const levelSchema = zod["enum"]([
|
|
|
36
36
|
const logMeta = zod.object({
|
|
37
37
|
stacktrace: zod.optional(zod.array(logStackFrameSchema)),
|
|
38
38
|
logTraceID: zod.optional(zod.string()),
|
|
39
|
-
skipFrame: zod.optional(zod.number())
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
id: zod.string(),
|
|
46
|
-
args: zod.array(zod.unknown()),
|
|
47
|
-
meta: logMeta
|
|
48
|
-
})
|
|
49
|
-
]);
|
|
50
|
-
const logWithMetaSchema = zod.object({
|
|
39
|
+
skipFrame: zod.optional(zod.number()),
|
|
40
|
+
noStacktrace: zod.optional(zod.boolean()),
|
|
41
|
+
repairMessage: zod.optional(zod.string())
|
|
42
|
+
});
|
|
43
|
+
const selectedLogSchema = zod.object({
|
|
44
|
+
type: zod.literal('typedLogV2'),
|
|
51
45
|
level: levelSchema,
|
|
46
|
+
id: zod.string(),
|
|
52
47
|
args: zod.array(zod.unknown()),
|
|
53
48
|
meta: logMeta
|
|
54
49
|
});
|
|
50
|
+
const logWithMetaSchema = zod.object({
|
|
51
|
+
level: levelSchema,
|
|
52
|
+
args: zod.array(zod.unknown()),
|
|
53
|
+
meta: zod.optional(logMeta)
|
|
54
|
+
});
|
|
55
55
|
export { genericErrorSchema, levelSchema, logMeta, logStackFrameSchema, logWithMetaSchema, networkRequestLogSchema, noCategoryLogSchema, routerErrorSchema, selectedLogSchema };
|
package/lib/logger/logger.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { interceptors } from "./selected-logs.js";
|
|
2
|
-
import {
|
|
2
|
+
import { interceptErrors } from "./intercept-global-error.js";
|
|
3
3
|
const LOG_LEVELS = [
|
|
4
4
|
'debug',
|
|
5
5
|
'info',
|
|
@@ -59,6 +59,11 @@ let logger = {
|
|
|
59
59
|
if (shouldLog(level)) console.log(...getFormattedPrefix(level), ...args);
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
+
window.__RUNTIME_LOGGER__ = {
|
|
63
|
+
get () {
|
|
64
|
+
return logger;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
62
67
|
for (const interceptor of interceptors)logger = interceptor(logger);
|
|
63
|
-
|
|
68
|
+
'production' !== process.env.NODE_ENV && interceptErrors();
|
|
64
69
|
export { logger };
|
|
@@ -2,6 +2,7 @@ import { SourceMapConsumer as external_source_map_SourceMapConsumer } from "sour
|
|
|
2
2
|
import "../utils/utils.js";
|
|
3
3
|
import { mappingText } from "./source-map-mappings-wasm.js";
|
|
4
4
|
import stacktrace_js from "stacktrace-js";
|
|
5
|
+
import { batchLogInfo, initBatchLogger } from "./batch-logger.js";
|
|
5
6
|
function hexToBuffer(hexString) {
|
|
6
7
|
const hex = hexString.replace(/\s/g, '').toUpperCase();
|
|
7
8
|
if (!/^[0-9A-F]+$/.test(hex)) throw new Error('Invalid hex string');
|
|
@@ -36,20 +37,25 @@ async function sendSelectedLog(logWithoutID) {
|
|
|
36
37
|
message: error.message,
|
|
37
38
|
stack: error.stack
|
|
38
39
|
};
|
|
39
|
-
if (!log.meta.stacktrace) {
|
|
40
|
+
if (!log.meta.stacktrace) try {
|
|
40
41
|
const stacktrace = await stacktrace_js.fromError(error);
|
|
41
42
|
log.meta.stacktrace = mapStacktrace(stacktrace);
|
|
42
|
-
}
|
|
43
|
+
} catch (e) {}
|
|
43
44
|
newParts.push(newError.message, newError);
|
|
44
45
|
} else newParts.push(log.args[i]);
|
|
45
|
-
if (!log.meta.stacktrace) {
|
|
46
|
-
|
|
46
|
+
if (!log.meta.stacktrace) try {
|
|
47
|
+
let frames = await getStacktrace();
|
|
48
|
+
const firstFrameIndex = frames.findIndex((frame)=>!frame.fileName.includes('node_modules/@lark-apaas/client-toolkit/lib/logger'));
|
|
49
|
+
frames = -1 === firstFrameIndex ? [] : frames.slice(firstFrameIndex);
|
|
47
50
|
log.meta.stacktrace = frames;
|
|
48
|
-
}
|
|
51
|
+
} catch (e) {}
|
|
49
52
|
if (void 0 === log.meta.skipFrame) log.meta.skipFrame = 2;
|
|
50
53
|
const logJSON = JSON.stringify(log);
|
|
51
54
|
console.log(JSON.parse(logJSON));
|
|
52
55
|
console.log(logJSON);
|
|
56
|
+
try {
|
|
57
|
+
batchLogInfo('info', logJSON);
|
|
58
|
+
} catch (e) {}
|
|
53
59
|
if (window.parent !== window) try {
|
|
54
60
|
window.parent.postMessage({
|
|
55
61
|
type: 'SELECTED_LOG',
|
|
@@ -152,6 +158,7 @@ const typedLogInterceptor = (logger)=>({
|
|
|
152
158
|
});
|
|
153
159
|
}
|
|
154
160
|
});
|
|
161
|
+
'production' !== process.env.NODE_ENV && initBatchLogger(console);
|
|
155
162
|
const interceptors = 'production' !== process.env.NODE_ENV ? [
|
|
156
163
|
typedLogInterceptor
|
|
157
164
|
] : [];
|
package/lib/utils/axiosConfig.js
CHANGED
|
@@ -3,27 +3,27 @@ import { logger } from "../apis/logger.js";
|
|
|
3
3
|
import { getStacktrace } from "../logger/selected-logs.js";
|
|
4
4
|
async function logResponse(ok, response) {
|
|
5
5
|
const okToTextMap = {
|
|
6
|
-
success: '
|
|
7
|
-
error: '
|
|
6
|
+
success: '请求成功:',
|
|
7
|
+
error: '请求失败:'
|
|
8
8
|
};
|
|
9
|
+
const realOK = 'success' === ok && response.status >= 200 && response.status < 300;
|
|
9
10
|
const parts = [
|
|
10
|
-
okToTextMap[
|
|
11
|
-
(response.config.url || '').split('?')[0],
|
|
11
|
+
okToTextMap[realOK ? 'success' : 'error'],
|
|
12
|
+
(response.config.url || '').split('?')[0].replace(/^\/spark\/p\/app_\w+/, ''),
|
|
12
13
|
' - ',
|
|
13
14
|
Date.now() - response.config._startTime,
|
|
14
15
|
'ms'
|
|
15
16
|
];
|
|
16
17
|
const logTraceID = response.headers['x-log-trace-id'];
|
|
17
18
|
const args = [
|
|
18
|
-
'请求参数:',
|
|
19
|
-
response.config.data,
|
|
20
|
-
'返回数据:',
|
|
21
|
-
response.data,
|
|
22
|
-
'请求摘要:',
|
|
23
19
|
{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
'请求参数:': response.config.data,
|
|
21
|
+
'返回数据:': response.data,
|
|
22
|
+
'请求摘要:': {
|
|
23
|
+
TraceID: logTraceID,
|
|
24
|
+
状态: `${response.statusText}[状态码${response.status}]`,
|
|
25
|
+
时间: `${new Date().toLocaleString()}`
|
|
26
|
+
}
|
|
27
27
|
}
|
|
28
28
|
];
|
|
29
29
|
const requestUUID = response.config._requestUUID;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/client-toolkit",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9-alpha.log.1",
|
|
4
4
|
"types": "./lib/index.d.ts",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -73,8 +73,6 @@
|
|
|
73
73
|
"prepublishOnly": "npm run build && node scripts/replace-workspace-alias.js"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"@ant-design/colors": "^7.2.1",
|
|
77
|
-
"@ant-design/cssinjs": "^1.24.0",
|
|
78
76
|
"@data-loom/js": "0.3.4",
|
|
79
77
|
"@lark-apaas/miaoda-inspector": "^1.0.2",
|
|
80
78
|
"@radix-ui/react-avatar": "^1.1.10",
|
|
@@ -120,7 +118,6 @@
|
|
|
120
118
|
"@types/react": "^18.3.23",
|
|
121
119
|
"@types/react-dom": "^18.3.7",
|
|
122
120
|
"@types/sockjs-client": "^1",
|
|
123
|
-
"antd": "^5.26.6",
|
|
124
121
|
"eslint": "^8.57.0",
|
|
125
122
|
"jsdom": "^26.1.0",
|
|
126
123
|
"lucide-react": "npm:@lark-apaas/lucide-react@1.0.2",
|
|
@@ -137,7 +134,6 @@
|
|
|
137
134
|
"vitest": "^3.2.4"
|
|
138
135
|
},
|
|
139
136
|
"peerDependencies": {
|
|
140
|
-
"antd": ">=5.26.6",
|
|
141
137
|
"react": ">=16.14.0",
|
|
142
138
|
"react-dom": ">=16.14.0",
|
|
143
139
|
"react-router-dom": ">=6.26.2"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../../hooks/useTheme';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../../hooks/useTheme.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|