@lark-apaas/client-toolkit 1.1.21-alpha.auth.dev.0 → 1.1.21-alpha.auth.dev.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.
Files changed (42) hide show
  1. package/README.md +68 -0
  2. package/lib/antd-table.d.ts +4 -0
  3. package/lib/antd-table.js +2 -0
  4. package/lib/apis/utils/getAxiosForBackend.d.ts +1 -0
  5. package/lib/apis/utils/getAxiosForBackend.js +1 -0
  6. package/lib/auth.d.ts +1 -0
  7. package/lib/auth.js +2 -0
  8. package/lib/components/AppContainer/index.js +179 -8
  9. package/lib/components/AppContainer/safety.js +16 -16
  10. package/lib/components/AppContainer/utils/getLarkUser.d.ts +1 -0
  11. package/lib/components/AppContainer/utils/getLarkUser.js +17 -0
  12. package/lib/components/AppContainer/utils/tea.d.ts +8 -0
  13. package/lib/components/AppContainer/utils/tea.js +51 -0
  14. package/lib/components/ErrorRender/index.js +17 -10
  15. package/lib/components/User/UserDisplay.d.ts +3 -2
  16. package/lib/components/User/UserDisplay.js +24 -23
  17. package/lib/components/User/index.d.ts +1 -1
  18. package/lib/components/ui/badge.d.ts +1 -1
  19. package/lib/components/ui/button.d.ts +1 -1
  20. package/lib/hooks/useCurrentUserProfile.js +4 -4
  21. package/lib/logger/selected-logs.js +11 -3
  22. package/lib/server-log/index.d.ts +9 -0
  23. package/lib/server-log/index.js +2 -0
  24. package/lib/server-log/poller.d.ts +87 -0
  25. package/lib/server-log/poller.js +135 -0
  26. package/lib/server-log/types.d.ts +166 -0
  27. package/lib/server-log/types.js +0 -0
  28. package/lib/types/index.d.ts +1 -0
  29. package/lib/types/tea.d.ts +7 -0
  30. package/lib/types/tea.js +5 -0
  31. package/lib/utils/axiosConfig.js +118 -48
  32. package/lib/utils/deviceType.d.ts +3 -0
  33. package/lib/utils/deviceType.js +13 -0
  34. package/lib/utils/getAxiosForBackend.d.ts +11 -0
  35. package/lib/utils/getAxiosForBackend.js +21 -0
  36. package/lib/utils/getParentOrigin.d.ts +2 -1
  37. package/lib/utils/getParentOrigin.js +8 -1
  38. package/lib/utils/requestManager.d.ts +2 -0
  39. package/lib/utils/requestManager.js +26 -0
  40. package/lib/utils/userProfileCache.d.ts +12 -0
  41. package/lib/utils/userProfileCache.js +26 -0
  42. package/package.json +20 -5
@@ -1,10 +1,11 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useMemo, useState } from "react";
3
- import { getDataloom } from "../../integrations/dataloom.js";
3
+ import { getCachedUserProfiles, setCachedUserProfiles } from "../../utils/userProfileCache.js";
4
4
  import { clsxWithTw } from "../../utils/utils.js";
5
5
  import { UserProfile } from "./UserProfile/index.js";
6
6
  import { UserWithAvatar } from "./UserWithAvatar.js";
7
7
  import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover.js";
8
+ import { fetchWithDeduplication } from "../../utils/requestManager.js";
8
9
  const UserDisplay = ({ users, size, className, style, showLabel = true })=>{
9
10
  const normalizedIds = useMemo(()=>{
10
11
  if (!users) return [];
@@ -12,12 +13,12 @@ const UserDisplay = ({ users, size, className, style, showLabel = true })=>{
12
13
  if (0 === users.length) return [];
13
14
  const first = users[0];
14
15
  const isStringArray = 'string' == typeof first;
15
- return isStringArray ? users.filter(Boolean).map((id)=>String(id)) : users.map((u)=>String(u.user_id)).filter(Boolean);
16
+ return isStringArray ? users.filter(Boolean).map((id)=>String(id)) : users.map((u)=>String(u?.user_id)).filter(Boolean);
16
17
  }
17
18
  return 'string' == typeof users ? [
18
19
  String(users)
19
20
  ] : [
20
- String(users.user_id)
21
+ String(users?.user_id)
21
22
  ].filter(Boolean);
22
23
  }, [
23
24
  users
@@ -71,22 +72,20 @@ const UserDisplay = ({ users, size, className, style, showLabel = true })=>{
71
72
  const fetchProfiles = async ()=>{
72
73
  try {
73
74
  setLoadingProfiles(true);
74
- const dataloom = await getDataloom();
75
- if (!dataloom) throw new Error('dataloom client is unavailable');
76
- const ids = normalizedIds.map((id)=>Number(id)).filter((id)=>Number.isFinite(id));
77
- if (!ids.length) {
78
- setResolvedUsers(normalizedIds.map((id)=>inputProfilesMap.get(id) ?? {
79
- user_id: id,
80
- name: '',
81
- avatar: '',
82
- email: '',
83
- status: 1
84
- }));
85
- setLoadingProfiles(false);
86
- return;
87
- }
88
- const response = await dataloom.service.user.getByIds(ids);
89
- const fetchedList = Array.isArray(response?.data) ? response?.data : Array.isArray(response?.data?.user_list) ? response?.data?.user_list : [];
75
+ const { cachedProfiles, remainingIds } = getCachedUserProfiles(normalizedIds);
76
+ if (cachedProfiles.length > 0) setResolvedUsers((prev)=>{
77
+ const updatedUsers = [
78
+ ...prev
79
+ ];
80
+ cachedProfiles.forEach((cached)=>{
81
+ const index = updatedUsers.findIndex((u)=>u.user_id === cached.user_id);
82
+ if (-1 !== index) updatedUsers[index] = cached;
83
+ });
84
+ return updatedUsers;
85
+ });
86
+ if (0 === remainingIds.length) return void setLoadingProfiles(false);
87
+ const fetchedList = await fetchWithDeduplication(remainingIds);
88
+ if (isCancelled || !fetchedList) return;
90
89
  const fetchedMap = new Map();
91
90
  fetchedList.forEach((profile)=>{
92
91
  const id = String(profile?.user_id ?? '');
@@ -99,13 +98,15 @@ const UserDisplay = ({ users, size, className, style, showLabel = true })=>{
99
98
  status: profile?.status ?? 1
100
99
  });
101
100
  });
101
+ setCachedUserProfiles(fetchedList);
102
102
  const mergedUsers = normalizedIds.map((id)=>{
103
103
  const fetched = fetchedMap.get(id);
104
104
  const given = inputProfilesMap.get(id);
105
- const name = given?.name?.trim() ? given.name : fetched?.name ?? '';
106
- const avatar = given?.avatar || fetched?.avatar || '';
107
- const email = given?.email || fetched?.email || '';
108
- const status = given?.status ?? fetched?.status ?? 1;
105
+ const cached = cachedProfiles.find((p)=>p.user_id === id);
106
+ const name = given?.name?.trim() || fetched?.name || cached?.name || '';
107
+ const avatar = given?.avatar || fetched?.avatar || cached?.avatar || '';
108
+ const email = given?.email || fetched?.email || cached?.email || '';
109
+ const status = given?.status ?? fetched?.status ?? cached?.status ?? 1;
109
110
  return {
110
111
  user_id: id,
111
112
  name,
@@ -1,7 +1,7 @@
1
1
  export { UserSelect } from './UserSelect';
2
2
  export type { UserSelectProps } from './UserSelect';
3
3
  export { UserDisplay } from './UserDisplay';
4
- export type { UserDisplayProps } from './UserDisplay';
4
+ export type { IUserDisplayProps as UserDisplayProps } from './UserDisplay';
5
5
  export { UserWithAvatar } from './UserWithAvatar';
6
6
  export type { UserWithAvatarProps } from './type';
7
7
  export { UserProfile } from './UserProfile';
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { type VariantProps } from "class-variance-authority";
3
3
  declare const badgeVariants: (props?: {
4
- variant?: "default" | "secondary" | "destructive" | "outline";
4
+ variant?: "default" | "destructive" | "secondary" | "outline";
5
5
  } & import("class-variance-authority/dist/types").ClassProp) => string;
6
6
  declare function Badge({ className, variant, asChild, ...props }: React.ComponentProps<"span"> & VariantProps<typeof badgeVariants> & {
7
7
  asChild?: boolean;
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { type VariantProps } from "class-variance-authority";
3
3
  declare const buttonVariants: (props?: {
4
- variant?: "default" | "link" | "secondary" | "destructive" | "outline" | "ghost";
4
+ variant?: "default" | "link" | "destructive" | "secondary" | "outline" | "ghost";
5
5
  size?: "default" | "icon" | "sm" | "lg" | "icon-sm" | "icon-lg";
6
6
  } & import("class-variance-authority/dist/types").ClassProp) => string;
7
7
  declare function Button({ className, variant, size, asChild, ...props }: React.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
@@ -19,9 +19,9 @@ const useCurrentUserProfile = ()=>{
19
19
  (async ()=>{
20
20
  const dataloom = await getDataloom();
21
21
  const result = await dataloom.service.session.getUserInfo();
22
- const userInfo = result?.data?.user_info;
22
+ const userInfo = result?.data?.userInfo;
23
23
  setUserInfo({
24
- user_id: userInfo?.user_id?.toString(),
24
+ user_id: userInfo?.userID?.toString(),
25
25
  email: userInfo?.email,
26
26
  name: userInfo?.name?.[0]?.text,
27
27
  avatar: userInfo?.avatar?.image?.large,
@@ -32,9 +32,9 @@ const useCurrentUserProfile = ()=>{
32
32
  handleMetaInfoChanged = async ()=>{
33
33
  const dataloom = await getDataloom();
34
34
  const result = await dataloom.service.session.getUserInfo();
35
- const userInfo = result?.data?.user_info;
35
+ const userInfo = result?.data?.userInfo;
36
36
  const newUserInfo = {
37
- user_id: userInfo?.user_id?.toString(),
37
+ user_id: userInfo?.userID?.toString(),
38
38
  email: userInfo?.email,
39
39
  name: userInfo?.name?.[0]?.text,
40
40
  avatar: userInfo?.avatar?.image?.large,
@@ -71,18 +71,26 @@ async function sendSelectedLog(logWithoutID) {
71
71
  } catch (postError) {}
72
72
  }
73
73
  if (void 0 === log.meta.skipFrame) log.meta.skipFrame = 2;
74
- const logJSON = JSON.stringify(log);
74
+ const errorReplacer = (key, value)=>{
75
+ if (value instanceof Error) return {
76
+ message: value.message,
77
+ stack: value.stack,
78
+ name: value.name
79
+ };
80
+ return value;
81
+ };
82
+ const logJSON = JSON.stringify(log, errorReplacer);
75
83
  const logForDedup = {
76
84
  ...log
77
85
  };
78
86
  delete logForDedup.id;
79
- const logContentForDedup = JSON.stringify(logForDedup);
87
+ const logContentForDedup = JSON.stringify(logForDedup, errorReplacer);
80
88
  if (lastLogInfo && lastLogInfo.content === logContentForDedup) {
81
89
  lastLogInfo.count++;
82
90
  log.meta.isDuplicate = true;
83
91
  log.meta.duplicateCount = lastLogInfo.count;
84
92
  log.meta.duplicateOfId = lastLogInfo.id;
85
- const updatedLogJSON = JSON.stringify(log);
93
+ const updatedLogJSON = JSON.stringify(log, errorReplacer);
86
94
  try {
87
95
  batchLogInfo('info', updatedLogJSON);
88
96
  } catch (e) {}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Server Log 模块
3
+ *
4
+ * 通过 HTTP 轮询方式获取服务端日志并转发给父窗口
5
+ */
6
+ export { ServerLogPoller } from './poller';
7
+ export type { ServerLogPollerOptions } from './poller';
8
+ export type { ServerLog, ServerLogLevel, ServerLogSource, ServerLogMeta, ServerLogPostMessage, ClientToServerMessage, ServerToClientMessage, } from './types';
9
+ export { ServerLogPoller as default } from './poller';
@@ -0,0 +1,2 @@
1
+ import { ServerLogPoller } from "./poller.js";
2
+ export { ServerLogPoller, ServerLogPoller as default };
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Server Log Poller (HTTP 轮询版本)
3
+ *
4
+ * 职责:
5
+ * 1. 定期轮询后端 HTTP API (/dev/logs/server-logs)
6
+ * 2. 获取新的服务端日志
7
+ * 3. 将接收到的日志通过 postMessage 转发给父窗口 (miaoda)
8
+ * 4. 管理连接状态并通知父窗口
9
+ *
10
+ * 与 ServerLogForwarder 的区别:
11
+ * - 使用 HTTP 轮询代替 WebSocket
12
+ * - 无需 socket.io-client 依赖
13
+ * - 更简单、更稳定、更易调试
14
+ */
15
+ export interface ServerLogPollerOptions {
16
+ /**
17
+ * 后端服务器 URL
18
+ * @example 'http://localhost:3000'
19
+ */
20
+ serverUrl: string;
21
+ /**
22
+ * API 路径
23
+ * @default '/dev/logs/server-logs'
24
+ */
25
+ apiPath?: string;
26
+ /**
27
+ * 轮询间隔(毫秒)
28
+ * @default 2000
29
+ */
30
+ pollInterval?: number;
31
+ /**
32
+ * 每次获取的日志数量
33
+ * @default 100
34
+ */
35
+ limit?: number;
36
+ /**
37
+ * 是否启用调试日志
38
+ * @default false
39
+ */
40
+ debug?: boolean;
41
+ }
42
+ type ConnectionStatus = 'disconnected' | 'connecting' | 'connected' | 'error';
43
+ export declare class ServerLogPoller {
44
+ private intervalId;
45
+ private status;
46
+ private lastTimestamp;
47
+ private options;
48
+ private isPolling;
49
+ constructor(options: ServerLogPollerOptions);
50
+ /**
51
+ * 启动轮询器
52
+ */
53
+ start(): void;
54
+ /**
55
+ * 停止轮询器
56
+ */
57
+ stop(): void;
58
+ /**
59
+ * 获取当前连接状态
60
+ */
61
+ getStatus(): ConnectionStatus;
62
+ /**
63
+ * 执行一次轮询
64
+ */
65
+ private poll;
66
+ /**
67
+ * 转发日志到父窗口
68
+ */
69
+ private forwardLog;
70
+ /**
71
+ * 更新连接状态并通知父窗口
72
+ */
73
+ private updateStatus;
74
+ /**
75
+ * 发送消息到父窗口
76
+ */
77
+ private postToParent;
78
+ /**
79
+ * 调试日志
80
+ */
81
+ private log;
82
+ /**
83
+ * 错误日志
84
+ */
85
+ private error;
86
+ }
87
+ export {};
@@ -0,0 +1,135 @@
1
+ class ServerLogPoller {
2
+ intervalId = null;
3
+ status = 'disconnected';
4
+ lastTimestamp = 0;
5
+ options;
6
+ isPolling = false;
7
+ constructor(options){
8
+ this.options = {
9
+ serverUrl: options.serverUrl,
10
+ apiPath: (process.env.CLIENT_BASE_PATH || '') + (options.apiPath || '/dev/logs/server-logs'),
11
+ pollInterval: options.pollInterval || 2000,
12
+ limit: options.limit || 100,
13
+ debug: options.debug ?? false
14
+ };
15
+ }
16
+ start() {
17
+ if (this.isPolling) return void this.log('Poller already started');
18
+ this.isPolling = true;
19
+ this.updateStatus('connecting');
20
+ this.log('Starting server log poller...', {
21
+ serverUrl: this.options.serverUrl,
22
+ apiPath: this.options.apiPath,
23
+ pollInterval: this.options.pollInterval
24
+ });
25
+ this.poll();
26
+ this.intervalId = window.setInterval(()=>{
27
+ this.poll();
28
+ }, this.options.pollInterval);
29
+ }
30
+ stop() {
31
+ if (!this.isPolling) return void this.log('Poller not running');
32
+ this.log('Stopping server log poller...');
33
+ if (null !== this.intervalId) {
34
+ window.clearInterval(this.intervalId);
35
+ this.intervalId = null;
36
+ }
37
+ this.isPolling = false;
38
+ this.updateStatus('disconnected');
39
+ }
40
+ getStatus() {
41
+ return this.status;
42
+ }
43
+ async poll() {
44
+ try {
45
+ const url = `${this.options.serverUrl}${this.options.apiPath}?limit=${this.options.limit}&sources=server,trace,server-std,client-std`;
46
+ this.log('Polling...', {
47
+ url
48
+ });
49
+ const response = await fetch(url, {
50
+ method: 'GET',
51
+ headers: {
52
+ Accept: 'application/json'
53
+ },
54
+ signal: AbortSignal.timeout(5000)
55
+ });
56
+ if (!response.ok) throw new Error(`HTTP ${response.status}: ${response.statusText}`);
57
+ const data = await response.json();
58
+ this.log('Received logs', {
59
+ count: data.logs.length,
60
+ total: data.total,
61
+ hasMore: data.hasMore
62
+ });
63
+ const newLogs = data.logs.filter((log)=>log.timestamp > this.lastTimestamp);
64
+ if (newLogs.length > 0) {
65
+ this.lastTimestamp = Math.max(...newLogs.map((log)=>log.timestamp));
66
+ newLogs.sort((a, b)=>a.timestamp - b.timestamp);
67
+ this.log(`Forwarding ${newLogs.length} new logs`);
68
+ newLogs.forEach((log)=>{
69
+ this.forwardLog(log);
70
+ });
71
+ }
72
+ if ('connected' !== this.status) {
73
+ this.updateStatus('connected');
74
+ if (0 === this.lastTimestamp && data.logs.length > 0) this.lastTimestamp = Math.max(...data.logs.map((log)=>log.timestamp));
75
+ }
76
+ } catch (error) {
77
+ this.error('Poll failed', error);
78
+ if ('error' !== this.status) {
79
+ this.updateStatus('error');
80
+ this.postToParent({
81
+ type: 'SERVER_LOG_CONNECTION',
82
+ status: 'error',
83
+ error: error instanceof Error ? error.message : String(error)
84
+ });
85
+ }
86
+ }
87
+ }
88
+ forwardLog(log) {
89
+ try {
90
+ this.log('Forwarding log to parent window', {
91
+ type: 'SERVER_LOG',
92
+ logId: log.id,
93
+ level: log.level,
94
+ tags: log.tags
95
+ });
96
+ this.postToParent({
97
+ type: 'SERVER_LOG',
98
+ payload: JSON.stringify(log)
99
+ });
100
+ this.log('Log forwarded successfully');
101
+ } catch (e) {
102
+ this.error('Failed to forward log', e);
103
+ }
104
+ }
105
+ updateStatus(status) {
106
+ const previousStatus = this.status;
107
+ this.status = status;
108
+ if (previousStatus !== status) {
109
+ this.log(`Status changed: ${previousStatus} → ${status}`);
110
+ this.postToParent({
111
+ type: 'SERVER_LOG_CONNECTION',
112
+ status
113
+ });
114
+ }
115
+ }
116
+ postToParent(message) {
117
+ if (window.parent === window) return;
118
+ try {
119
+ window.parent.postMessage(message, '*');
120
+ } catch (e) {
121
+ this.error('postMessage error', e);
122
+ }
123
+ }
124
+ log(message, data) {
125
+ const enableLog = 'true' === localStorage.getItem('debug_server_log_poller');
126
+ if (this.options.debug && enableLog) if (data) console.log(`[ServerLogPoller] ${message}`, data);
127
+ else console.log(`[ServerLogPoller] ${message}`);
128
+ }
129
+ error(message, error) {
130
+ const enableLog = 'true' === localStorage.getItem('debug_server_log_poller');
131
+ if (enableLog) if (error) console.error(`[ServerLogPoller] ${message}`, error);
132
+ else console.error(`[ServerLogPoller] ${message}`);
133
+ }
134
+ }
135
+ export { ServerLogPoller };
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Server Log Stream 类型定义
3
+ *
4
+ * 这些类型与 @lark-apaas/nestjs-logger 保持一致
5
+ * 用于 iframe 端的日志转发功能
6
+ */
7
+ /**
8
+ * 后端日志级别
9
+ * 与 NestJS LogLevel 对齐,但增加了 fatal
10
+ */
11
+ export type ServerLogLevel = 'fatal' | 'error' | 'warn' | 'log' | 'debug' | 'verbose';
12
+ /**
13
+ * 日志来源
14
+ */
15
+ export type ServerLogSource = 'server' | 'trace' | 'server-std' | 'client-std' | 'browser';
16
+ /**
17
+ * 日志元数据
18
+ */
19
+ export interface ServerLogMeta {
20
+ pid?: number;
21
+ hostname?: string;
22
+ service?: string;
23
+ path?: string;
24
+ method?: string;
25
+ statusCode?: number;
26
+ durationMs?: number;
27
+ ip?: string;
28
+ requestBody?: any;
29
+ responseBody?: any;
30
+ [key: string]: unknown;
31
+ }
32
+ /**
33
+ * 后端日志对象
34
+ * 用于实时推送给前端展示
35
+ */
36
+ export interface ServerLog {
37
+ /**
38
+ * 唯一标识符(UUID)
39
+ * 用于前端去重和引用
40
+ */
41
+ id: string;
42
+ /**
43
+ * 日志级别
44
+ */
45
+ level: ServerLogLevel;
46
+ /**
47
+ * 时间戳(毫秒)
48
+ */
49
+ timestamp: number;
50
+ /**
51
+ * 日志消息
52
+ */
53
+ message: string;
54
+ /**
55
+ * 日志上下文(如 Controller 名称、Service 名称)
56
+ */
57
+ context?: string;
58
+ /**
59
+ * 请求追踪 ID
60
+ * 用于关联同一个请求的所有日志
61
+ */
62
+ traceId?: string;
63
+ /**
64
+ * 用户 ID
65
+ */
66
+ userId?: string;
67
+ /**
68
+ * 应用 ID
69
+ */
70
+ appId?: string;
71
+ /**
72
+ * 租户 ID
73
+ */
74
+ tenantId?: string;
75
+ /**
76
+ * 错误堆栈(仅 ERROR/FATAL 级别)
77
+ */
78
+ stack?: string;
79
+ /**
80
+ * 额外的元数据
81
+ */
82
+ meta?: ServerLogMeta;
83
+ /**
84
+ * 自定义标签
85
+ * 如 ['server', 'bootstrap'] 或 ['trace', 'http']
86
+ */
87
+ tags?: string[];
88
+ }
89
+ /**
90
+ * WebSocket 消息类型(客户端 → 服务端)
91
+ */
92
+ export type ClientToServerMessage = {
93
+ type: 'SUBSCRIBE';
94
+ payload: {
95
+ levels?: ServerLogLevel[];
96
+ tags?: string[];
97
+ sources?: ServerLogSource[];
98
+ };
99
+ } | {
100
+ type: 'UNSUBSCRIBE';
101
+ } | {
102
+ type: 'GET_HISTORY';
103
+ payload: {
104
+ limit?: number;
105
+ offset?: number;
106
+ levels?: ServerLogLevel[];
107
+ sources?: ServerLogSource[];
108
+ };
109
+ } | {
110
+ type: 'CLEAR_LOGS';
111
+ };
112
+ /**
113
+ * WebSocket 消息类型(服务端 → 客户端)
114
+ */
115
+ export type ServerToClientMessage = {
116
+ type: 'CONNECTED';
117
+ payload: {
118
+ clientId: string;
119
+ timestamp: number;
120
+ };
121
+ } | {
122
+ type: 'LOG';
123
+ payload: ServerLog;
124
+ } | {
125
+ type: 'LOGS_BATCH';
126
+ payload: ServerLog[];
127
+ } | {
128
+ type: 'HISTORY';
129
+ payload: {
130
+ logs: ServerLog[];
131
+ total: number;
132
+ hasMore: boolean;
133
+ };
134
+ } | {
135
+ type: 'LOGS_CLEARED';
136
+ } | {
137
+ type: 'SUBSCRIBED';
138
+ payload: {
139
+ levels?: ServerLogLevel[];
140
+ tags?: string[];
141
+ sources?: ServerLogSource[];
142
+ };
143
+ } | {
144
+ type: 'UNSUBSCRIBED';
145
+ } | {
146
+ type: 'ERROR';
147
+ payload: {
148
+ message: string;
149
+ code?: string;
150
+ };
151
+ };
152
+ /**
153
+ * PostMessage 类型(iframe → parent)
154
+ *
155
+ * iframe 端通过 postMessage 将接收到的 WebSocket 消息转发给父窗口
156
+ */
157
+ export type ServerLogPostMessage = {
158
+ type: 'SERVER_LOG';
159
+ payload: string;
160
+ } | {
161
+ type: 'SERVER_LOG_CONNECTION';
162
+ status: 'connected' | 'disconnected' | 'error' | 'connecting';
163
+ error?: string;
164
+ } | {
165
+ type: 'SERVER_LOG_CLEARED';
166
+ };
File without changes
@@ -10,5 +10,6 @@ declare global {
10
10
  _IS_Spark_RUNTIME?: boolean;
11
11
  _bucket_id?: string;
12
12
  csrfToken?: string;
13
+ collectEvent?: (...args: any[]) => void;
13
14
  }
14
15
  }
@@ -0,0 +1,7 @@
1
+ export interface TrackParams {
2
+ trackKey: TrackKey;
3
+ trackParams?: Record<string, unknown>;
4
+ }
5
+ export declare enum TrackKey {
6
+ VIEW = "aily_agent_artifact_page_view"
7
+ }
@@ -0,0 +1,5 @@
1
+ var tea_TrackKey = /*#__PURE__*/ function(TrackKey) {
2
+ TrackKey["VIEW"] = "aily_agent_artifact_page_view";
3
+ return TrackKey;
4
+ }({});
5
+ export { tea_TrackKey as TrackKey };