@lark-apaas/client-toolkit 1.2.9-beta.4 → 1.2.9-beta.41

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.
Files changed (94) hide show
  1. package/lib/antd-table.d.ts +2 -2
  2. package/lib/apis/aily-chat.d.ts +2 -0
  3. package/lib/apis/aily-chat.js +2 -0
  4. package/lib/apis/hooks/useScrollReveal.d.ts +1 -0
  5. package/lib/apis/hooks/useScrollReveal.js +1 -0
  6. package/lib/apis/utils/resolveAppUrl.d.ts +1 -0
  7. package/lib/apis/utils/resolveAppUrl.js +2 -0
  8. package/lib/apis/utils/scopedStorage.d.ts +1 -0
  9. package/lib/apis/utils/scopedStorage.js +2 -0
  10. package/lib/auth.d.ts +2 -1
  11. package/lib/auth.js +2 -2
  12. package/lib/components/AppContainer/api-proxy/core.js +2 -1
  13. package/lib/components/AppContainer/index.d.ts +5 -1
  14. package/lib/components/AppContainer/index.js +41 -34
  15. package/lib/components/AppContainer/safety.js +27 -8
  16. package/lib/components/AppContainer/utils/childApi.js +1 -0
  17. package/lib/components/AppContainer/utils/getLarkUser.js +4 -2
  18. package/lib/components/AppContainer/utils/observable.js +7 -1
  19. package/lib/components/AppContainer/utils/tea.js +1 -1
  20. package/lib/components/ErrorRender/index.js +5 -11
  21. package/lib/components/User/UserSelect.js +1 -13
  22. package/lib/components/theme/index.d.ts +0 -1
  23. package/lib/components/theme/index.js +0 -1
  24. package/lib/components/theme/util.d.ts +0 -2
  25. package/lib/components/theme/util.js +0 -108
  26. package/lib/components/ui/badge.d.ts +1 -1
  27. package/lib/components/ui/button.d.ts +2 -2
  28. package/lib/components/ui/button.js +1 -1
  29. package/lib/components/ui/confirm.d.ts +28 -0
  30. package/lib/components/ui/confirm.js +83 -0
  31. package/lib/components/ui/toast.d.ts +2 -0
  32. package/lib/components/ui/toast.js +53 -0
  33. package/lib/hooks/index.d.ts +1 -0
  34. package/lib/hooks/index.js +1 -0
  35. package/lib/hooks/useCurrentUserProfile.d.ts +18 -3
  36. package/lib/hooks/useCurrentUserProfile.js +22 -29
  37. package/lib/hooks/useLogout.js +2 -17
  38. package/lib/hooks/useScrollReveal.d.ts +61 -0
  39. package/lib/hooks/useScrollReveal.js +37 -0
  40. package/lib/index.d.ts +2 -0
  41. package/lib/index.js +14 -2
  42. package/lib/integrations/dataloom.d.ts +3 -1
  43. package/lib/integrations/dataloom.js +18 -10
  44. package/lib/integrations/getCurrentUserProfile.d.ts +7 -1
  45. package/lib/integrations/services/ChatService.d.ts +12 -0
  46. package/lib/integrations/services/ChatService.js +67 -0
  47. package/lib/integrations/services/DepartmentService.js +3 -2
  48. package/lib/integrations/services/UserProfileService.js +3 -2
  49. package/lib/integrations/services/UserService.d.ts +3 -1
  50. package/lib/integrations/services/UserService.js +23 -3
  51. package/lib/integrations/services/index.d.ts +1 -0
  52. package/lib/integrations/services/index.js +1 -0
  53. package/lib/integrations/services/types.d.ts +45 -0
  54. package/lib/logger/intercept-global-error.js +34 -25
  55. package/lib/logger/log-types.d.ts +4 -4
  56. package/lib/logger/log-types.js +1 -1
  57. package/lib/runtime/index.d.ts +1 -0
  58. package/lib/runtime/index.js +1 -0
  59. package/lib/runtime/react-devtools-hook.d.ts +19 -0
  60. package/lib/runtime/react-devtools-hook.js +20 -0
  61. package/lib/theme-layer.css +2 -1
  62. package/lib/utils/apiPath.d.ts +5 -0
  63. package/lib/utils/apiPath.js +5 -0
  64. package/lib/utils/axiosConfig.js +163 -9
  65. package/lib/utils/getAppId.d.ts +2 -4
  66. package/lib/utils/getAppId.js +2 -9
  67. package/lib/utils/getInitialInfo.d.ts +4 -3
  68. package/lib/utils/getInitialInfo.js +17 -8
  69. package/lib/utils/getUserProfile.js +4 -12
  70. package/lib/utils/hmr-api.d.ts +45 -0
  71. package/lib/utils/hmr-api.js +36 -0
  72. package/lib/utils/module-hot.d.ts +9 -5
  73. package/lib/utils/module-hot.js +9 -10
  74. package/lib/utils/postMessage.d.ts +0 -1
  75. package/lib/utils/postMessage.js +19 -6
  76. package/lib/utils/requestManager.js +1 -3
  77. package/lib/utils/resolveAppUrl.d.ts +27 -0
  78. package/lib/utils/resolveAppUrl.js +19 -0
  79. package/lib/utils/safeStringify.js +5 -0
  80. package/lib/utils/safeStringify.spec.d.ts +1 -0
  81. package/lib/utils/safeStringify.spec.js +125 -0
  82. package/lib/utils/scopedStorage.d.ts +5 -0
  83. package/lib/utils/scopedStorage.js +46 -0
  84. package/package.json +13 -6
  85. package/lib/apis/tools/generateImage.d.ts +0 -1
  86. package/lib/apis/tools/generateImage.js +0 -1
  87. package/lib/apis/tools/generateTextStream.d.ts +0 -1
  88. package/lib/apis/tools/generateTextStream.js +0 -1
  89. package/lib/components/theme/ui-config.d.ts +0 -1
  90. package/lib/components/theme/ui-config.js +0 -2
  91. package/lib/integrations/generateImage.d.ts +0 -1
  92. package/lib/integrations/generateImage.js +0 -47
  93. package/lib/integrations/generateTextStream.d.ts +0 -21
  94. package/lib/integrations/generateTextStream.js +0 -98
@@ -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 };