@lark-apaas/client-toolkit 1.2.10-alpha.8 → 1.2.10
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/utils/childApi.js +1 -0
- package/lib/components/ErrorRender/index.js +5 -11
- package/lib/components/User/UserSelect.js +1 -13
- package/lib/logger/intercept-global-error.js +16 -14
- package/lib/logger/log-types.d.ts +4 -4
- package/lib/logger/log-types.js +1 -1
- package/lib/theme-layer.css +2 -1
- package/lib/utils/hmr-api.d.ts +39 -0
- package/lib/utils/hmr-api.js +36 -0
- package/lib/utils/module-hot.d.ts +9 -5
- package/lib/utils/module-hot.js +9 -10
- package/lib/utils/requestManager.js +1 -3
- package/package.json +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
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 {
|
|
4
|
+
import { getHmrApi } from "../../utils/hmr-api.js";
|
|
5
5
|
import { submitPostMessage } from "../../utils/postMessage.js";
|
|
6
6
|
const RenderError = (props)=>{
|
|
7
7
|
const { error, resetErrorBoundary } = props;
|
|
@@ -27,16 +27,10 @@ const RenderError = (props)=>{
|
|
|
27
27
|
]);
|
|
28
28
|
useEffect(()=>{
|
|
29
29
|
if (!resetErrorBoundary) return;
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
});
|
|
35
|
-
hot.addStatusHandler(handler);
|
|
36
|
-
return ()=>{
|
|
37
|
-
hot.removeStatusHandler(handler);
|
|
38
|
-
};
|
|
39
|
-
}
|
|
30
|
+
const hmr = getHmrApi();
|
|
31
|
+
if (hmr) return hmr.onSuccess(()=>{
|
|
32
|
+
resetErrorBoundary();
|
|
33
|
+
});
|
|
40
34
|
}, [
|
|
41
35
|
resetErrorBoundary
|
|
42
36
|
]);
|
|
@@ -67,20 +67,8 @@ const UserSelect = ({ mode = 'single', defaultValue, value, onChange, placeholde
|
|
|
67
67
|
if (!normalizedIds.length) return void setUiValue(void 0);
|
|
68
68
|
const fetchProfiles = async ()=>{
|
|
69
69
|
try {
|
|
70
|
-
const ids = normalizedIds.map((id)=>Number(id)).filter((id)=>Number.isFinite(id));
|
|
71
|
-
if (!ids.length) {
|
|
72
|
-
const profiles = normalizedIds.map((id)=>inputProfilesMap.get(id) ?? {
|
|
73
|
-
user_id: id,
|
|
74
|
-
name: '',
|
|
75
|
-
avatar: '',
|
|
76
|
-
email: '',
|
|
77
|
-
status: 1
|
|
78
|
-
});
|
|
79
|
-
setUiValue('single' === mode ? profiles[0] : profiles);
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
70
|
const dataloom = await getDataloom();
|
|
83
|
-
const response = await dataloom.service.user.getByIds(
|
|
71
|
+
const response = await dataloom.service.user.getByIds(normalizedIds);
|
|
84
72
|
const fetchedList = Array.isArray(response?.data) ? response?.data : Array.isArray(response?.data?.user_list) ? response?.data?.user_list : [];
|
|
85
73
|
const fetchedMap = new Map();
|
|
86
74
|
fetchedList.forEach((profile)=>{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getHmrApi } from "../utils/hmr-api.js";
|
|
2
2
|
import { submitPostMessage, submitSlardarEvent } from "../utils/postMessage.js";
|
|
3
3
|
import { levelSchema } from "./log-types.js";
|
|
4
4
|
import { logger } from "./logger.js";
|
|
@@ -63,26 +63,28 @@ function processDevServerLog(log) {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
function listenModuleHmr() {
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
const hmr = getHmrApi();
|
|
67
|
+
if (hmr) {
|
|
68
|
+
hmr.onSuccess(()=>{
|
|
69
|
+
submitPostMessage({
|
|
70
|
+
type: 'DevServerMessage',
|
|
71
|
+
data: {
|
|
72
|
+
type: 'devServer-status',
|
|
73
|
+
status: 'hmr-apply-success'
|
|
74
|
+
}
|
|
75
|
+
});
|
|
74
76
|
});
|
|
75
|
-
|
|
76
|
-
console.warn('hmr apply failed',
|
|
77
|
+
hmr.onError((error)=>{
|
|
78
|
+
console.warn('hmr apply failed', error);
|
|
77
79
|
submitSlardarEvent({
|
|
78
80
|
name: 'sandbox-devServer',
|
|
79
81
|
categories: {
|
|
80
82
|
type: 'hmr-apply-failed',
|
|
81
|
-
|
|
83
|
+
error: String(error)
|
|
82
84
|
}
|
|
83
85
|
});
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
86
88
|
}
|
|
87
89
|
function interceptErrors() {
|
|
88
90
|
window.addEventListener('error', (event)=>{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
2
|
export declare const networkRequestLogSchema: z.ZodObject<{
|
|
3
3
|
method: z.ZodString;
|
|
4
|
-
status: z.
|
|
4
|
+
status: z.ZodNumber;
|
|
5
5
|
statusText: z.ZodString;
|
|
6
6
|
path: z.ZodString;
|
|
7
7
|
requestData: z.ZodOptional<z.ZodUnknown>;
|
|
@@ -27,11 +27,11 @@ export declare const logStackFrameSchema: z.ZodObject<{
|
|
|
27
27
|
columnNumber: z.ZodNumber;
|
|
28
28
|
}, z.core.$strip>;
|
|
29
29
|
export declare const levelSchema: z.ZodEnum<{
|
|
30
|
+
error: "error";
|
|
30
31
|
success: "success";
|
|
31
32
|
debug: "debug";
|
|
32
33
|
info: "info";
|
|
33
34
|
warn: "warn";
|
|
34
|
-
error: "error";
|
|
35
35
|
}>;
|
|
36
36
|
export declare const logMeta: z.ZodObject<{
|
|
37
37
|
stacktrace: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -52,11 +52,11 @@ export declare const logMeta: z.ZodObject<{
|
|
|
52
52
|
export declare const selectedLogSchema: z.ZodObject<{
|
|
53
53
|
type: z.ZodLiteral<"typedLogV2">;
|
|
54
54
|
level: z.ZodEnum<{
|
|
55
|
+
error: "error";
|
|
55
56
|
success: "success";
|
|
56
57
|
debug: "debug";
|
|
57
58
|
info: "info";
|
|
58
59
|
warn: "warn";
|
|
59
|
-
error: "error";
|
|
60
60
|
}>;
|
|
61
61
|
id: z.ZodString;
|
|
62
62
|
args: z.ZodArray<z.ZodUnknown>;
|
|
@@ -80,11 +80,11 @@ export declare const selectedLogSchema: z.ZodObject<{
|
|
|
80
80
|
export type LogLevel = z.infer<typeof levelSchema>;
|
|
81
81
|
export declare const logWithMetaSchema: z.ZodObject<{
|
|
82
82
|
level: z.ZodEnum<{
|
|
83
|
+
error: "error";
|
|
83
84
|
success: "success";
|
|
84
85
|
debug: "debug";
|
|
85
86
|
info: "info";
|
|
86
87
|
warn: "warn";
|
|
87
|
-
error: "error";
|
|
88
88
|
}>;
|
|
89
89
|
args: z.ZodArray<z.ZodUnknown>;
|
|
90
90
|
meta: z.ZodOptional<z.ZodObject<{
|
package/lib/logger/log-types.js
CHANGED
package/lib/theme-layer.css
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 统一 HMR API
|
|
3
|
+
*
|
|
4
|
+
* 提供统一的 HMR 成功/失败回调接口,屏蔽 Webpack 和 Vite 的差异。
|
|
5
|
+
*
|
|
6
|
+
* - Webpack/Rspack: 通过 import.meta.webpackHot 或 module.hot
|
|
7
|
+
* - Vite: 通过 error-overlay 注入的 window.__VITE_HMR__
|
|
8
|
+
*
|
|
9
|
+
* @see docs/RFC_HMR_API.md
|
|
10
|
+
*/
|
|
11
|
+
export interface HmrApi {
|
|
12
|
+
/**
|
|
13
|
+
* 注册 HMR 成功回调
|
|
14
|
+
* @param callback 成功回调函数
|
|
15
|
+
* @returns cleanup 函数,用于取消注册
|
|
16
|
+
*/
|
|
17
|
+
onSuccess(callback: () => void): () => void;
|
|
18
|
+
/**
|
|
19
|
+
* 注册 HMR 失败回调
|
|
20
|
+
* @param callback 失败回调函数,参数为错误信息
|
|
21
|
+
* @returns cleanup 函数,用于取消注册
|
|
22
|
+
*/
|
|
23
|
+
onError(callback: (error: unknown) => void): () => void;
|
|
24
|
+
}
|
|
25
|
+
declare global {
|
|
26
|
+
interface Window {
|
|
27
|
+
__VITE_HMR__?: HmrApi;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 获取 HMR API 实例
|
|
32
|
+
*
|
|
33
|
+
* 自动检测当前构建工具(Webpack/Vite)并返回对应实现:
|
|
34
|
+
* - Webpack/Rspack: 使用内置适配器
|
|
35
|
+
* - Vite: 使用 error-overlay 注入的 window.__VITE_HMR__
|
|
36
|
+
*
|
|
37
|
+
* @returns HmrApi 实例,如果不在开发环境或不支持 HMR 则返回 null
|
|
38
|
+
*/
|
|
39
|
+
export declare function getHmrApi(): HmrApi | null;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
function createWebpackHmrApi(hot) {
|
|
2
|
+
return {
|
|
3
|
+
onSuccess (callback) {
|
|
4
|
+
let lastStatus = null;
|
|
5
|
+
const handler = (status)=>{
|
|
6
|
+
if ('idle' === status && 'apply' === lastStatus) try {
|
|
7
|
+
callback();
|
|
8
|
+
} catch (e) {
|
|
9
|
+
console.error('[HMR] Success callback error:', e);
|
|
10
|
+
}
|
|
11
|
+
lastStatus = status;
|
|
12
|
+
};
|
|
13
|
+
hot.addStatusHandler(handler);
|
|
14
|
+
return ()=>hot.removeStatusHandler(handler);
|
|
15
|
+
},
|
|
16
|
+
onError (callback) {
|
|
17
|
+
const handler = (status)=>{
|
|
18
|
+
if ('fail' === status || 'abort' === status) try {
|
|
19
|
+
callback(new Error(`HMR ${status}`));
|
|
20
|
+
} catch (e) {
|
|
21
|
+
console.error('[HMR] Error callback error:', e);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
hot.addStatusHandler(handler);
|
|
25
|
+
return ()=>hot.removeStatusHandler(handler);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function getHmrApi() {
|
|
30
|
+
if ('production' === process.env.NODE_ENV) return null;
|
|
31
|
+
if (import.meta.webpackHot) return createWebpackHmrApi(import.meta.webpackHot);
|
|
32
|
+
'undefined' != typeof module && module.hot;
|
|
33
|
+
if (window.__VITE_HMR__) return window.__VITE_HMR__;
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
export { getHmrApi };
|
|
@@ -10,16 +10,20 @@
|
|
|
10
10
|
* - abort: An update was aborted, but the system is still in its previous state
|
|
11
11
|
* - fail: An update has thrown an exception and the system's state has been compromised
|
|
12
12
|
*/
|
|
13
|
-
type ModuleHotType = 'idle' | 'check' | 'prepare' | 'ready' | 'dispose' | 'apply' | 'abort' | 'fail';
|
|
14
|
-
interface ModuleHotInstance {
|
|
13
|
+
export type ModuleHotType = 'idle' | 'check' | 'prepare' | 'ready' | 'dispose' | 'apply' | 'abort' | 'fail';
|
|
14
|
+
export interface ModuleHotInstance {
|
|
15
15
|
addStatusHandler: (handler: (status: ModuleHotType) => void) => void;
|
|
16
16
|
removeStatusHandler: (handler: (status: ModuleHotType) => void) => void;
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* 获取 Webpack HMR 实例
|
|
20
|
+
* 仅支持 Webpack/Rspack 的 HMR API
|
|
21
|
+
*/
|
|
18
22
|
export declare function getModuleHot(): ModuleHotInstance | null;
|
|
19
23
|
/**
|
|
20
24
|
* 创建模块热更成功处理函数
|
|
21
|
-
*
|
|
22
|
-
*
|
|
25
|
+
* 监听模块热更状态,检测 apply -> idle 转换表示热更成功
|
|
26
|
+
*
|
|
27
|
+
* @param callback 热更回调函数,参数为是否成功和当前状态
|
|
23
28
|
*/
|
|
24
29
|
export declare function createApplyHandle(callback: (success: boolean, status: ModuleHotType) => void): (status: ModuleHotType) => void;
|
|
25
|
-
export {};
|
package/lib/utils/module-hot.js
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
function getModuleHot() {
|
|
2
2
|
if ('production' === process.env.NODE_ENV) return null;
|
|
3
|
-
|
|
3
|
+
if (import.meta.webpackHot) return import.meta.webpackHot;
|
|
4
|
+
'undefined' != typeof module && module.hot;
|
|
5
|
+
return null;
|
|
4
6
|
}
|
|
5
7
|
function createApplyHandle(callback) {
|
|
6
|
-
let
|
|
8
|
+
let lastStatus = null;
|
|
7
9
|
return (status)=>{
|
|
8
10
|
if ('fail' === status || 'abort' === status) {
|
|
9
|
-
|
|
11
|
+
lastStatus = status;
|
|
10
12
|
return callback(false, status);
|
|
11
13
|
}
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
callback(true, status);
|
|
16
|
-
}
|
|
17
|
-
return;
|
|
14
|
+
if ('idle' === status && 'apply' === lastStatus) {
|
|
15
|
+
lastStatus = status;
|
|
16
|
+
return callback(true, status);
|
|
18
17
|
}
|
|
19
|
-
|
|
18
|
+
lastStatus = status;
|
|
20
19
|
};
|
|
21
20
|
}
|
|
22
21
|
export { createApplyHandle, getModuleHot };
|
|
@@ -4,9 +4,7 @@ async function fetchUserProfilesByIds(ids) {
|
|
|
4
4
|
try {
|
|
5
5
|
const dataloom = await getDataloom();
|
|
6
6
|
if (!dataloom) throw new Error('Dataloom client is unavailable');
|
|
7
|
-
const
|
|
8
|
-
if (0 === numericIds.length) return [];
|
|
9
|
-
const response = await dataloom.service.user.getByIds(numericIds);
|
|
7
|
+
const response = await dataloom.service.user.getByIds(ids);
|
|
10
8
|
return Array.isArray(response?.data) ? response.data : response?.data?.user_list || [];
|
|
11
9
|
} catch (error) {
|
|
12
10
|
console.error(`Failed to fetch profiles for user IDs ${ids.join(', ')}:`, error);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/client-toolkit",
|
|
3
|
-
"version": "1.2.10
|
|
3
|
+
"version": "1.2.10",
|
|
4
4
|
"types": "./lib/index.d.ts",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -93,10 +93,10 @@
|
|
|
93
93
|
"dependencies": {
|
|
94
94
|
"@ant-design/colors": "^7.2.1",
|
|
95
95
|
"@ant-design/cssinjs": "^1.24.0",
|
|
96
|
-
"@data-loom/js": "0.4.4
|
|
96
|
+
"@data-loom/js": "0.4.4",
|
|
97
97
|
"@lark-apaas/auth-sdk": "^0.1.0",
|
|
98
98
|
"@lark-apaas/client-capability": "^0.1.3",
|
|
99
|
-
"@lark-apaas/miaoda-inspector": "^1.0.
|
|
99
|
+
"@lark-apaas/miaoda-inspector": "^1.0.14",
|
|
100
100
|
"@lark-apaas/observable-web": "^1.0.1",
|
|
101
101
|
"@radix-ui/react-avatar": "^1.1.10",
|
|
102
102
|
"@radix-ui/react-popover": "^1.1.15",
|