@lark-apaas/client-toolkit 1.1.19-antd-test.4 → 1.1.20-alpha.tea.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/index.js +20 -129
- package/lib/components/AppContainer/safety.js +1 -1
- package/lib/components/AppContainer/utils/getLarkUser.d.ts +1 -0
- package/lib/components/AppContainer/utils/getLarkUser.js +17 -0
- package/lib/components/AppContainer/utils/tea.d.ts +8 -0
- package/lib/components/AppContainer/utils/tea.js +51 -0
- package/lib/components/ui/badge.d.ts +1 -1
- package/lib/components/ui/button.d.ts +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/tea.d.ts +7 -0
- package/lib/types/tea.js +5 -0
- package/lib/utils/deviceType.d.ts +3 -0
- package/lib/utils/deviceType.js +13 -0
- package/lib/utils/getParentOrigin.d.ts +1 -0
- package/lib/utils/getParentOrigin.js +10 -4
- package/package.json +3 -6
- package/lib/antd-table.d.ts +0 -4
- package/lib/antd-table.js +0 -2
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect
|
|
3
|
-
import { ConfigProvider } from "antd";
|
|
2
|
+
import { useEffect } from "react";
|
|
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";
|
|
@@ -10,20 +9,14 @@ import { findValueByPixel, generateTailwindRadiusToken, themeColorTokenMap, them
|
|
|
10
9
|
import { registerDayjsPlugins } from "./dayjsPlugins.js";
|
|
11
10
|
import "../../index.css";
|
|
12
11
|
import { initAxiosConfig } from "../../utils/axiosConfig.js";
|
|
12
|
+
import { reportTeaEvent } from "./utils/tea.js";
|
|
13
13
|
import { useAppInfo } from "../../hooks/index.js";
|
|
14
|
+
import { TrackKey } from "../../types/tea.js";
|
|
14
15
|
import safety from "./safety.js";
|
|
16
|
+
import { getAppId } from "../../utils/getAppId.js";
|
|
15
17
|
registerDayjsPlugins();
|
|
16
18
|
initAxiosConfig();
|
|
17
19
|
const isMiaodaPreview = window.IS_MIAODA_PREVIEW;
|
|
18
|
-
const readCssVarColor = (varName, fallback)=>{
|
|
19
|
-
try {
|
|
20
|
-
if ('undefined' == typeof document) return fallback;
|
|
21
|
-
const value = getComputedStyle(document.documentElement).getPropertyValue(varName).trim();
|
|
22
|
-
return value || fallback;
|
|
23
|
-
} catch {
|
|
24
|
-
return fallback;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
20
|
const App = (props)=>{
|
|
28
21
|
const { themeMeta = {} } = props;
|
|
29
22
|
useAppInfo();
|
|
@@ -46,6 +39,16 @@ const App = (props)=>{
|
|
|
46
39
|
}, 300);
|
|
47
40
|
});
|
|
48
41
|
}, []);
|
|
42
|
+
useEffect(()=>{
|
|
43
|
+
if ('production' === process.env.NODE_ENV) reportTeaEvent({
|
|
44
|
+
trackKey: TrackKey.VIEW,
|
|
45
|
+
trackParams: {
|
|
46
|
+
artifact_uid: getAppId(window.location.pathname),
|
|
47
|
+
agent_id: 'agent_miaoda',
|
|
48
|
+
url: window.location.href
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}, []);
|
|
49
52
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
50
53
|
children: [
|
|
51
54
|
/*#__PURE__*/ jsx(Toaster, {}),
|
|
@@ -64,129 +67,17 @@ const App = (props)=>{
|
|
|
64
67
|
]
|
|
65
68
|
});
|
|
66
69
|
};
|
|
67
|
-
const
|
|
70
|
+
const AppContainer = (props)=>{
|
|
68
71
|
const { children, ...rest } = props;
|
|
69
|
-
const [cssColors, setCssColors] = useState(()=>({
|
|
70
|
-
background: readCssVarColor('--background'),
|
|
71
|
-
destructive: readCssVarColor('--destructive'),
|
|
72
|
-
primary: readCssVarColor('--primary'),
|
|
73
|
-
foreground: readCssVarColor('--foreground'),
|
|
74
|
-
warning: readCssVarColor('--warning'),
|
|
75
|
-
success: readCssVarColor('--success'),
|
|
76
|
-
muted: readCssVarColor('--muted'),
|
|
77
|
-
mutedForeground: readCssVarColor('--muted-foreground'),
|
|
78
|
-
border: readCssVarColor('--border'),
|
|
79
|
-
popover: readCssVarColor('--popover'),
|
|
80
|
-
accent: readCssVarColor('--accent'),
|
|
81
|
-
radius: readCssVarColor('--radius')
|
|
82
|
-
}));
|
|
83
|
-
useEffect(()=>{
|
|
84
|
-
const observer = new MutationObserver((mutations)=>{
|
|
85
|
-
for (const mutation of mutations){
|
|
86
|
-
let linkTag = null;
|
|
87
|
-
if ('attributes' === mutation.type) {
|
|
88
|
-
if ('fullstack-nestjs-template:chunk-main' === mutation.target.dataset.webpack) linkTag = mutation.target;
|
|
89
|
-
} else if ('childList' === mutation.type) {
|
|
90
|
-
for (const node of Array.from(mutation.addedNodes))if ('LINK' === node.nodeName && 'fullstack-nestjs-template:chunk-main' === node.dataset.webpack) {
|
|
91
|
-
linkTag = node;
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
if (linkTag) setTimeout(()=>{
|
|
96
|
-
const newColors = {
|
|
97
|
-
background: readCssVarColor('--background'),
|
|
98
|
-
destructive: readCssVarColor('--destructive'),
|
|
99
|
-
primary: readCssVarColor('--primary'),
|
|
100
|
-
foreground: readCssVarColor('--foreground'),
|
|
101
|
-
warning: readCssVarColor('--warning'),
|
|
102
|
-
success: readCssVarColor('--success'),
|
|
103
|
-
muted: readCssVarColor('--muted'),
|
|
104
|
-
mutedForeground: readCssVarColor('--muted-foreground'),
|
|
105
|
-
border: readCssVarColor('--border'),
|
|
106
|
-
popover: readCssVarColor('--popover'),
|
|
107
|
-
accent: readCssVarColor('--accent'),
|
|
108
|
-
radius: readCssVarColor('--radius')
|
|
109
|
-
};
|
|
110
|
-
setCssColors((currentColors)=>{
|
|
111
|
-
if (JSON.stringify(currentColors) !== JSON.stringify(newColors)) return newColors;
|
|
112
|
-
return currentColors;
|
|
113
|
-
});
|
|
114
|
-
}, 100);
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
observer.observe(document.head, {
|
|
118
|
-
childList: true,
|
|
119
|
-
subtree: true,
|
|
120
|
-
attributes: true,
|
|
121
|
-
attributeFilter: [
|
|
122
|
-
'href'
|
|
123
|
-
]
|
|
124
|
-
});
|
|
125
|
-
return ()=>{
|
|
126
|
-
observer.disconnect();
|
|
127
|
-
};
|
|
128
|
-
}, []);
|
|
129
|
-
const antdThemeToken = {
|
|
130
|
-
borderRadius: cssColors.radius,
|
|
131
|
-
colorBgBase: cssColors.background,
|
|
132
|
-
colorError: cssColors.destructive,
|
|
133
|
-
colorInfo: cssColors.primary,
|
|
134
|
-
colorLink: cssColors.primary,
|
|
135
|
-
colorPrimary: cssColors.primary,
|
|
136
|
-
colorSuccess: cssColors.primary,
|
|
137
|
-
colorTextBase: cssColors.foreground,
|
|
138
|
-
colorWarning: cssColors.destructive
|
|
139
|
-
};
|
|
140
|
-
const antdTableToken = {
|
|
141
|
-
bodySortBg: cssColors.muted,
|
|
142
|
-
borderColor: cssColors.border,
|
|
143
|
-
expandIconBg: cssColors.background,
|
|
144
|
-
filterDropdownBg: cssColors.popover,
|
|
145
|
-
filterDropdownMenuBg: cssColors.popover,
|
|
146
|
-
fixedHeaderSortActiveBg: cssColors.muted,
|
|
147
|
-
footerBg: cssColors.muted,
|
|
148
|
-
footerColor: cssColors.mutedForeground,
|
|
149
|
-
headerBg: cssColors.muted,
|
|
150
|
-
headerColor: cssColors.mutedForeground,
|
|
151
|
-
headerFilterHoverBg: cssColors.muted,
|
|
152
|
-
headerSortActiveBg: cssColors.muted,
|
|
153
|
-
headerSortHoverBg: cssColors.muted,
|
|
154
|
-
headerSplitColor: cssColors.border,
|
|
155
|
-
rowExpandedBg: cssColors.background,
|
|
156
|
-
rowHoverBg: cssColors.muted,
|
|
157
|
-
rowSelectedBg: cssColors.accent,
|
|
158
|
-
rowSelectedHoverBg: cssColors.accent,
|
|
159
|
-
stickyScrollBarBg: cssColors.muted,
|
|
160
|
-
headerBorderRadius: 'var(--radius)'
|
|
161
|
-
};
|
|
162
|
-
const antdPaginationToken = {
|
|
163
|
-
itemActiveBg: cssColors.background,
|
|
164
|
-
itemActiveBgDisabled: cssColors.muted,
|
|
165
|
-
itemActiveColor: cssColors.primary,
|
|
166
|
-
itemActiveColorDisabled: cssColors.muted,
|
|
167
|
-
itemActiveColorHover: cssColors.muted,
|
|
168
|
-
itemBg: cssColors.background,
|
|
169
|
-
itemInputBg: cssColors.background,
|
|
170
|
-
itemLinkBg: cssColors.background
|
|
171
|
-
};
|
|
172
72
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
173
73
|
children: [
|
|
174
74
|
/*#__PURE__*/ jsx(safety, {}),
|
|
175
|
-
/*#__PURE__*/ jsx(
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
components: {
|
|
179
|
-
Table: antdTableToken,
|
|
180
|
-
Pagination: antdPaginationToken
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
children: /*#__PURE__*/ jsx(App, {
|
|
184
|
-
themeMeta: props.themeMeta,
|
|
185
|
-
children: children
|
|
186
|
-
})
|
|
75
|
+
/*#__PURE__*/ jsx(App, {
|
|
76
|
+
themeMeta: props.themeMeta,
|
|
77
|
+
children: children
|
|
187
78
|
})
|
|
188
79
|
]
|
|
189
80
|
});
|
|
190
81
|
};
|
|
191
|
-
const
|
|
192
|
-
export {
|
|
82
|
+
const components_AppContainer = AppContainer;
|
|
83
|
+
export { components_AppContainer as default };
|
|
@@ -173,7 +173,7 @@ const Component = ()=>{
|
|
|
173
173
|
})
|
|
174
174
|
}),
|
|
175
175
|
/*#__PURE__*/ jsx(PopoverContent, {
|
|
176
|
-
className: "overflow-hidden p-0 m-0 border-0 rounded-
|
|
176
|
+
className: "overflow-hidden p-0 m-0 border-0 rounded-xl!",
|
|
177
177
|
style: {
|
|
178
178
|
boxShadow: '0 6px 12px 0 #41444a0a, 0 8px 24px 0 #41444a0a'
|
|
179
179
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getLarkUserInfo(): Promise<any>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { getAppId } from "../../../utils/getAppId.js";
|
|
2
|
+
import { getCsrfToken } from "../../../utils/getCsrfToken.js";
|
|
3
|
+
async function getLarkUserInfo() {
|
|
4
|
+
const appId = getAppId(window.location.pathname);
|
|
5
|
+
if (!appId) return {
|
|
6
|
+
code: 1,
|
|
7
|
+
msg: 'appId is required',
|
|
8
|
+
data: {}
|
|
9
|
+
};
|
|
10
|
+
const response = await fetch(`/spark/b/${getAppId(window.location.pathname)}/tenant_info`, {
|
|
11
|
+
headers: {
|
|
12
|
+
'X-Suda-Csrf-Token': getCsrfToken()
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
return await response.json();
|
|
16
|
+
}
|
|
17
|
+
export { getLarkUserInfo };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type TrackParams } from '../../../types/tea';
|
|
2
|
+
export declare const encryptTea: (message: any) => string;
|
|
3
|
+
/**
|
|
4
|
+
* 初始化Tea 客户端
|
|
5
|
+
* @export
|
|
6
|
+
*/
|
|
7
|
+
export declare function createTracker(): Promise<void>;
|
|
8
|
+
export declare const reportTeaEvent: ({ trackKey, trackParams }: TrackParams) => Promise<void>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import blueimp_md5 from "blueimp-md5";
|
|
2
|
+
import sha1 from "crypto-js/sha1";
|
|
3
|
+
import { isMobile } from "../../../utils/deviceType.js";
|
|
4
|
+
import { getEnv } from "../../../utils/getParentOrigin.js";
|
|
5
|
+
import { getLarkUserInfo } from "./getLarkUser.js";
|
|
6
|
+
const saltA = '08a441';
|
|
7
|
+
const saltB = '42b91e';
|
|
8
|
+
const encryptTea = (message)=>{
|
|
9
|
+
const msgString = String(message);
|
|
10
|
+
return sha1(saltA + blueimp_md5(msgString + saltB)).toString();
|
|
11
|
+
};
|
|
12
|
+
let teaInstance = false;
|
|
13
|
+
async function createTracker() {
|
|
14
|
+
const { data } = await getLarkUserInfo();
|
|
15
|
+
const { tenantID, userID } = data || {};
|
|
16
|
+
const userIDEncrypt = userID && '0' !== userID ? encryptTea(userID) : void 0;
|
|
17
|
+
const tenantIDEncrypt = tenantID && '0' !== tenantID ? encryptTea(tenantID) : void 0;
|
|
18
|
+
window.collectEvent('init', {
|
|
19
|
+
app_id: 672575,
|
|
20
|
+
channel: 'cn',
|
|
21
|
+
disable_auto_pv: false,
|
|
22
|
+
enable_ab_test: false,
|
|
23
|
+
enable_debug: false,
|
|
24
|
+
enable_stay_duration: true,
|
|
25
|
+
reportTime: 1000
|
|
26
|
+
});
|
|
27
|
+
window.collectEvent('config', {
|
|
28
|
+
user_unique_id: userIDEncrypt,
|
|
29
|
+
device_type: isMobile() ? 'mobile' : 'pc',
|
|
30
|
+
evtParams: {
|
|
31
|
+
open_from: new URLSearchParams(window.location.search).get('open-from') ?? void 0,
|
|
32
|
+
env: getEnv(),
|
|
33
|
+
user_id: userIDEncrypt,
|
|
34
|
+
tenant_id: tenantIDEncrypt
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
teaInstance = true;
|
|
38
|
+
window.collectEvent('start');
|
|
39
|
+
}
|
|
40
|
+
const reportTeaEvent = async ({ trackKey, trackParams = {} })=>{
|
|
41
|
+
if (!teaInstance) {
|
|
42
|
+
teaInstance = true;
|
|
43
|
+
await createTracker();
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
window.collectEvent(trackKey, trackParams);
|
|
47
|
+
} catch (err) {
|
|
48
|
+
console.error(err);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
export { createTracker, encryptTea, reportTeaEvent };
|
|
@@ -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" | "
|
|
4
|
+
variant?: "default" | "secondary" | "destructive" | "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" | "
|
|
4
|
+
variant?: "default" | "link" | "secondary" | "destructive" | "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> & {
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/tea.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const isIpad = ()=>{
|
|
2
|
+
const _isIpad = /iPad|Tab|Tablet/i.test(navigator.userAgent) && navigator.maxTouchPoints && navigator.maxTouchPoints > 1;
|
|
3
|
+
return Boolean(_isIpad);
|
|
4
|
+
};
|
|
5
|
+
const isMobile = ()=>{
|
|
6
|
+
const isPhone = /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i.test(navigator.userAgent);
|
|
7
|
+
return isPhone || isIpad();
|
|
8
|
+
};
|
|
9
|
+
const isIOS = ()=>{
|
|
10
|
+
if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) return true;
|
|
11
|
+
return false;
|
|
12
|
+
};
|
|
13
|
+
export { isIOS, isIpad, isMobile };
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
function
|
|
1
|
+
function getEnv() {
|
|
2
2
|
const { origin } = window.location;
|
|
3
|
-
if (origin.includes('feishuapp.cn') || origin.includes('miaoda.feishuapp.net')) return '
|
|
4
|
-
if (origin.includes('fsapp.kundou.cn') || origin.includes('miaoda-pre.feishuapp.net')) return '
|
|
3
|
+
if (origin.includes('feishuapp.cn') || origin.includes('miaoda.feishuapp.net')) return 'ONLINE';
|
|
4
|
+
if (origin.includes('fsapp.kundou.cn') || origin.includes('miaoda-pre.feishuapp.net')) return 'PRE';
|
|
5
|
+
return 'BOE';
|
|
6
|
+
}
|
|
7
|
+
function getPreviewParentOrigin() {
|
|
8
|
+
const env = getEnv();
|
|
9
|
+
if ('ONLINE' === env) return 'https://miaoda.feishu.cn';
|
|
10
|
+
if ('PRE' === env) return 'https://miaoda.feishu-pre.cn';
|
|
5
11
|
return 'https://miaoda.feishu-boe.cn';
|
|
6
12
|
}
|
|
7
|
-
export { getPreviewParentOrigin };
|
|
13
|
+
export { getEnv, getPreviewParentOrigin };
|
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.20-alpha.tea.1",
|
|
4
4
|
"types": "./lib/index.d.ts",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -15,11 +15,6 @@
|
|
|
15
15
|
"require": "./lib/index.js",
|
|
16
16
|
"types": "./lib/index.d.ts"
|
|
17
17
|
},
|
|
18
|
-
"./antd-table": {
|
|
19
|
-
"import": "./lib/antd-table.js",
|
|
20
|
-
"require": "./lib/antd-table.js",
|
|
21
|
-
"types": "./lib/antd-table.d.ts"
|
|
22
|
-
},
|
|
23
18
|
"./lib/index.css": "./lib/index.css",
|
|
24
19
|
"./dataloom": {
|
|
25
20
|
"import": "./lib/apis/dataloom.js",
|
|
@@ -88,8 +83,10 @@
|
|
|
88
83
|
"@radix-ui/react-tooltip": "^1.2.8",
|
|
89
84
|
"@zumer/snapdom": "^1.9.14",
|
|
90
85
|
"axios": "^1.12.2",
|
|
86
|
+
"blueimp-md5": "2.10.0",
|
|
91
87
|
"class-variance-authority": "^0.7.1",
|
|
92
88
|
"clsx": "~2.0.1",
|
|
89
|
+
"crypto-js": "3.1.9-1",
|
|
93
90
|
"dayjs": "^1.11.13",
|
|
94
91
|
"echarts": "^6.0.0",
|
|
95
92
|
"lodash": "^4.17.21",
|
package/lib/antd-table.d.ts
DELETED
package/lib/antd-table.js
DELETED