@lark-apaas/client-toolkit 1.2.9 → 1.2.34
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/antd-table.d.ts +2 -2
- package/lib/apis/aily-chat.d.ts +2 -0
- package/lib/apis/aily-chat.js +2 -0
- package/lib/apis/hooks/useScrollReveal.d.ts +1 -0
- package/lib/apis/hooks/useScrollReveal.js +1 -0
- package/lib/apis/udt-types.d.ts +4 -0
- package/lib/apis/utils/resolveAppUrl.d.ts +1 -0
- package/lib/apis/utils/resolveAppUrl.js +2 -0
- package/lib/apis/utils/scopedStorage.d.ts +1 -0
- package/lib/apis/utils/scopedStorage.js +2 -0
- package/lib/auth.d.ts +2 -1
- package/lib/auth.js +2 -2
- package/lib/components/AppContainer/api-proxy/core.js +2 -1
- package/lib/components/AppContainer/index.d.ts +5 -1
- package/lib/components/AppContainer/index.js +41 -34
- package/lib/components/AppContainer/safety.js +27 -8
- package/lib/components/AppContainer/utils/childApi.js +1 -0
- package/lib/components/AppContainer/utils/getLarkUser.js +4 -2
- package/lib/components/AppContainer/utils/observable.js +7 -1
- package/lib/components/AppContainer/utils/tea.js +1 -1
- package/lib/components/ErrorRender/index.js +5 -11
- package/lib/components/User/UserSelect.js +1 -13
- package/lib/components/theme/index.d.ts +0 -1
- package/lib/components/theme/index.js +0 -1
- package/lib/components/theme/util.d.ts +0 -2
- package/lib/components/theme/util.js +0 -108
- package/lib/components/ui/badge.d.ts +1 -1
- package/lib/components/ui/button.d.ts +2 -2
- package/lib/components/ui/button.js +1 -1
- package/lib/components/ui/confirm.d.ts +28 -0
- package/lib/components/ui/confirm.js +83 -0
- package/lib/components/ui/toast.d.ts +2 -0
- package/lib/components/ui/toast.js +53 -0
- package/lib/hooks/index.d.ts +1 -0
- package/lib/hooks/index.js +1 -0
- package/lib/hooks/useCurrentUserProfile.d.ts +18 -3
- package/lib/hooks/useCurrentUserProfile.js +38 -29
- package/lib/hooks/useLogout.js +2 -17
- package/lib/hooks/useScrollReveal.d.ts +61 -0
- package/lib/hooks/useScrollReveal.js +37 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +14 -2
- package/lib/integrations/dataloom.d.ts +3 -1
- package/lib/integrations/dataloom.js +18 -10
- package/lib/integrations/getCurrentUserProfile.d.ts +7 -1
- package/lib/integrations/services/ChatService.d.ts +12 -0
- package/lib/integrations/services/ChatService.js +67 -0
- package/lib/integrations/services/DepartmentService.js +3 -2
- package/lib/integrations/services/UserProfileService.js +3 -2
- package/lib/integrations/services/UserService.d.ts +3 -1
- package/lib/integrations/services/UserService.js +23 -3
- package/lib/integrations/services/index.d.ts +1 -0
- package/lib/integrations/services/index.js +1 -0
- package/lib/integrations/services/types.d.ts +45 -0
- package/lib/logger/intercept-global-error.js +34 -25
- package/lib/logger/log-types.d.ts +4 -4
- package/lib/logger/log-types.js +1 -1
- package/lib/runtime/index.d.ts +1 -0
- package/lib/runtime/index.js +1 -0
- package/lib/runtime/react-devtools-hook.d.ts +19 -0
- package/lib/runtime/react-devtools-hook.js +20 -0
- package/lib/theme-layer.css +2 -1
- package/lib/utils/apiPath.d.ts +5 -0
- package/lib/utils/apiPath.js +5 -0
- package/lib/utils/axiosConfig.js +163 -9
- package/lib/utils/getAppId.d.ts +2 -4
- package/lib/utils/getAppId.js +2 -9
- package/lib/utils/getInitialInfo.d.ts +4 -3
- package/lib/utils/getInitialInfo.js +17 -8
- package/lib/utils/getUserProfile.js +4 -12
- package/lib/utils/hmr-api.d.ts +45 -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/postMessage.d.ts +0 -1
- package/lib/utils/postMessage.js +19 -6
- package/lib/utils/requestManager.js +1 -3
- package/lib/utils/resolveAppUrl.d.ts +27 -0
- package/lib/utils/resolveAppUrl.js +19 -0
- package/lib/utils/safeStringify.js +5 -0
- package/lib/utils/safeStringify.spec.d.ts +1 -0
- package/lib/utils/safeStringify.spec.js +125 -0
- package/lib/utils/scopedStorage.d.ts +5 -0
- package/lib/utils/scopedStorage.js +46 -0
- package/package.json +13 -6
- package/lib/apis/tools/generateImage.d.ts +0 -1
- package/lib/apis/tools/generateImage.js +0 -1
- package/lib/apis/tools/generateTextStream.d.ts +0 -1
- package/lib/apis/tools/generateTextStream.js +0 -1
- package/lib/components/theme/ui-config.d.ts +0 -1
- package/lib/components/theme/ui-config.js +0 -2
- package/lib/integrations/generateImage.d.ts +0 -1
- package/lib/integrations/generateImage.js +0 -47
- package/lib/integrations/generateTextStream.d.ts +0 -21
- package/lib/integrations/generateTextStream.js +0 -98
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
interface GenerateTextOptions {
|
|
2
|
-
text: string;
|
|
3
|
-
thinking_type?: 'enabled' | 'disabled';
|
|
4
|
-
headers?: Record<string, string>;
|
|
5
|
-
}
|
|
6
|
-
interface GenerateTextResult {
|
|
7
|
-
content: string;
|
|
8
|
-
reasoning_content: string;
|
|
9
|
-
success: boolean;
|
|
10
|
-
error?: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* 文生文 - 流式版本
|
|
14
|
-
* 支持实时接收生成内容的回调
|
|
15
|
-
*/
|
|
16
|
-
export declare function generateTextStream(options: GenerateTextOptions, onChunk?: (chunk: {
|
|
17
|
-
content: string;
|
|
18
|
-
reasoning_content: string;
|
|
19
|
-
finished: boolean;
|
|
20
|
-
}) => void): Promise<GenerateTextResult>;
|
|
21
|
-
export {};
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { getAppId } from "../utils/getAppId.js";
|
|
2
|
-
import { getCsrfToken } from "../utils/getCsrfToken.js";
|
|
3
|
-
import { getEnvPath } from "../utils/getEnvPath.js";
|
|
4
|
-
import { isSparkRuntime } from "../utils/utils.js";
|
|
5
|
-
async function generateTextStream(options, onChunk) {
|
|
6
|
-
const { text, thinking_type = 'disabled', headers = {} } = options;
|
|
7
|
-
const appId = getAppId(window.location.pathname);
|
|
8
|
-
if (!appId) return {
|
|
9
|
-
content: '',
|
|
10
|
-
reasoning_content: '',
|
|
11
|
-
success: false,
|
|
12
|
-
error: 'appId is required'
|
|
13
|
-
};
|
|
14
|
-
try {
|
|
15
|
-
const mergedHeaders = {
|
|
16
|
-
'Content-Type': 'application/json',
|
|
17
|
-
...headers,
|
|
18
|
-
'X-Kunlun-Token': window.token,
|
|
19
|
-
'x-miaoda-token': window.MIAODA_BUILTIN_TTT,
|
|
20
|
-
'x-lgw-csrf-token': window.lgw_csrf_token,
|
|
21
|
-
...window.CSRF_HEADERS || {}
|
|
22
|
-
};
|
|
23
|
-
let response;
|
|
24
|
-
if (isSparkRuntime()) {
|
|
25
|
-
mergedHeaders['X-Suda-Csrf-Token'] = getCsrfToken();
|
|
26
|
-
response = await fetch(`${window.location.origin}/spark/b/${appId}/text/generate`, {
|
|
27
|
-
method: 'POST',
|
|
28
|
-
headers: mergedHeaders,
|
|
29
|
-
credentials: 'include',
|
|
30
|
-
body: JSON.stringify({
|
|
31
|
-
text,
|
|
32
|
-
thinking_type
|
|
33
|
-
})
|
|
34
|
-
});
|
|
35
|
-
} else response = await fetch(`${window.location.origin}/ai/api/${getEnvPath()}/v1/apps/${appId}/text/generate`, {
|
|
36
|
-
method: 'POST',
|
|
37
|
-
headers: mergedHeaders,
|
|
38
|
-
credentials: 'include',
|
|
39
|
-
body: JSON.stringify({
|
|
40
|
-
text,
|
|
41
|
-
thinking_type
|
|
42
|
-
})
|
|
43
|
-
});
|
|
44
|
-
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
|
|
45
|
-
const reader = response.body?.getReader();
|
|
46
|
-
if (!reader) throw new Error('无法获取响应流');
|
|
47
|
-
let fullContent = '';
|
|
48
|
-
let fullReasoningContent = '';
|
|
49
|
-
const decoder = new TextDecoder();
|
|
50
|
-
while(true){
|
|
51
|
-
const { done, value } = await reader.read();
|
|
52
|
-
if (done) break;
|
|
53
|
-
const chunk = decoder.decode(value, {
|
|
54
|
-
stream: true
|
|
55
|
-
});
|
|
56
|
-
const lines = chunk.split('\n').filter((line)=>line.trim());
|
|
57
|
-
for (const line of lines)if (line.startsWith('data: ')) {
|
|
58
|
-
const jsonStr = line.slice(6);
|
|
59
|
-
try {
|
|
60
|
-
const data = JSON.parse(jsonStr);
|
|
61
|
-
if (0 !== data.code) return {
|
|
62
|
-
content: '',
|
|
63
|
-
reasoning_content: '',
|
|
64
|
-
success: false,
|
|
65
|
-
error: data.msg || '生成失败'
|
|
66
|
-
};
|
|
67
|
-
if (data.data.content) fullContent += data.data.content;
|
|
68
|
-
if (data.data.reasoning_content) fullReasoningContent += data.data.reasoning_content;
|
|
69
|
-
if (onChunk) onChunk({
|
|
70
|
-
content: data.data.content || '',
|
|
71
|
-
reasoning_content: data.data.reasoning_content || '',
|
|
72
|
-
finished: data.finished
|
|
73
|
-
});
|
|
74
|
-
if (data.finished) return {
|
|
75
|
-
content: fullContent,
|
|
76
|
-
reasoning_content: fullReasoningContent,
|
|
77
|
-
success: true
|
|
78
|
-
};
|
|
79
|
-
} catch (parseError) {
|
|
80
|
-
console.error(`解析JSON失败: ${jsonStr}`);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
content: fullContent,
|
|
86
|
-
reasoning_content: fullReasoningContent,
|
|
87
|
-
success: true
|
|
88
|
-
};
|
|
89
|
-
} catch (error) {
|
|
90
|
-
return {
|
|
91
|
-
content: '',
|
|
92
|
-
reasoning_content: '',
|
|
93
|
-
success: false,
|
|
94
|
-
error: error instanceof Error ? error.message : '未知错误'
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
export { generateTextStream };
|