@lark-apaas/client-toolkit 1.1.20-alpha.tea.1 → 1.1.20-antd-test.0

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.
@@ -0,0 +1,4 @@
1
+ import { Table } from 'antd';
2
+ import type { TableProps } from 'antd';
3
+ export { Table };
4
+ export type { TableProps };
@@ -0,0 +1,2 @@
1
+ import { Table } from "antd";
2
+ export { Table };
@@ -1,5 +1,6 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { useEffect } from "react";
2
+ import { useEffect, useState } from "react";
3
+ import { ConfigProvider } from "antd";
3
4
  import { MiaodaInspector } from "@lark-apaas/miaoda-inspector";
4
5
  import IframeBridge from "./IframeBridge.js";
5
6
  import { defaultUIConfig } from "../theme/ui-config.js";
@@ -9,14 +10,20 @@ import { findValueByPixel, generateTailwindRadiusToken, themeColorTokenMap, them
9
10
  import { registerDayjsPlugins } from "./dayjsPlugins.js";
10
11
  import "../../index.css";
11
12
  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";
15
14
  import safety from "./safety.js";
16
- import { getAppId } from "../../utils/getAppId.js";
17
15
  registerDayjsPlugins();
18
16
  initAxiosConfig();
19
17
  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
+ };
20
27
  const App = (props)=>{
21
28
  const { themeMeta = {} } = props;
22
29
  useAppInfo();
@@ -39,16 +46,6 @@ const App = (props)=>{
39
46
  }, 300);
40
47
  });
41
48
  }, []);
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
- }, []);
52
49
  return /*#__PURE__*/ jsxs(Fragment, {
53
50
  children: [
54
51
  /*#__PURE__*/ jsx(Toaster, {}),
@@ -67,17 +64,139 @@ const App = (props)=>{
67
64
  ]
68
65
  });
69
66
  };
70
- const AppContainer = (props)=>{
67
+ const AppContainer_AppContainer = (props)=>{
71
68
  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
+ }));
82
+ useEffect(()=>{
83
+ if ('production' === process.env.NODE_ENV) return ()=>{};
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) {
96
+ let retryCount = 0;
97
+ const maxRetries = 10;
98
+ const retryDelay = 400;
99
+ const updateColors = ()=>{
100
+ const newColors = {
101
+ background: readCssVarColor('--background'),
102
+ destructive: readCssVarColor('--destructive'),
103
+ primary: readCssVarColor('--primary'),
104
+ foreground: readCssVarColor('--foreground'),
105
+ warning: readCssVarColor('--warning'),
106
+ success: readCssVarColor('--success'),
107
+ muted: readCssVarColor('--muted'),
108
+ mutedForeground: readCssVarColor('--muted-foreground'),
109
+ border: readCssVarColor('--border'),
110
+ popover: readCssVarColor('--popover'),
111
+ accent: readCssVarColor('--accent')
112
+ };
113
+ setCssColors((currentColors)=>{
114
+ if (JSON.stringify(currentColors) !== JSON.stringify(newColors)) {
115
+ retryCount = 0;
116
+ return newColors;
117
+ }
118
+ if (retryCount < maxRetries) {
119
+ retryCount++;
120
+ setTimeout(updateColors, retryDelay);
121
+ }
122
+ return currentColors;
123
+ });
124
+ };
125
+ setTimeout(updateColors, 100);
126
+ }
127
+ }
128
+ });
129
+ observer.observe(document.head, {
130
+ childList: true,
131
+ subtree: true,
132
+ attributes: true,
133
+ attributeFilter: [
134
+ 'href'
135
+ ]
136
+ });
137
+ return ()=>{
138
+ observer.disconnect();
139
+ };
140
+ }, []);
141
+ const antdThemeToken = {
142
+ colorBgBase: cssColors.background,
143
+ colorError: cssColors.destructive,
144
+ colorInfo: cssColors.primary,
145
+ colorLink: cssColors.primary,
146
+ colorPrimary: cssColors.primary,
147
+ colorSuccess: cssColors.primary,
148
+ colorTextBase: cssColors.foreground,
149
+ colorWarning: cssColors.destructive
150
+ };
151
+ const antdTableToken = {
152
+ bodySortBg: cssColors.muted,
153
+ borderColor: cssColors.border,
154
+ expandIconBg: cssColors.background,
155
+ filterDropdownBg: cssColors.popover,
156
+ filterDropdownMenuBg: cssColors.popover,
157
+ fixedHeaderSortActiveBg: cssColors.muted,
158
+ footerBg: cssColors.muted,
159
+ footerColor: cssColors.mutedForeground,
160
+ headerBg: cssColors.muted,
161
+ headerColor: cssColors.mutedForeground,
162
+ headerFilterHoverBg: cssColors.muted,
163
+ headerSortActiveBg: cssColors.muted,
164
+ headerSortHoverBg: cssColors.muted,
165
+ headerSplitColor: cssColors.border,
166
+ rowExpandedBg: cssColors.background,
167
+ rowHoverBg: cssColors.muted,
168
+ rowSelectedBg: cssColors.accent,
169
+ rowSelectedHoverBg: cssColors.accent,
170
+ stickyScrollBarBg: cssColors.muted
171
+ };
172
+ const antdPaginationToken = {
173
+ itemActiveBg: cssColors.background,
174
+ itemActiveBgDisabled: cssColors.muted,
175
+ itemActiveColor: cssColors.primary,
176
+ itemActiveColorDisabled: cssColors.muted,
177
+ itemActiveColorHover: cssColors.muted,
178
+ itemBg: cssColors.background,
179
+ itemInputBg: cssColors.background,
180
+ itemLinkBg: cssColors.background
181
+ };
72
182
  return /*#__PURE__*/ jsxs(Fragment, {
73
183
  children: [
74
184
  /*#__PURE__*/ jsx(safety, {}),
75
- /*#__PURE__*/ jsx(App, {
76
- themeMeta: props.themeMeta,
77
- children: children
185
+ /*#__PURE__*/ jsx(ConfigProvider, {
186
+ theme: {
187
+ token: antdThemeToken,
188
+ components: {
189
+ Table: antdTableToken,
190
+ Pagination: antdPaginationToken
191
+ }
192
+ },
193
+ children: /*#__PURE__*/ jsx(App, {
194
+ themeMeta: props.themeMeta,
195
+ children: children
196
+ })
78
197
  })
79
198
  ]
80
199
  });
81
200
  };
82
- const components_AppContainer = AppContainer;
83
- export { components_AppContainer as default };
201
+ const AppContainer = AppContainer_AppContainer;
202
+ export { AppContainer as default };
@@ -152,7 +152,7 @@ const Component = ()=>{
152
152
  /*#__PURE__*/ jsx(PopoverTrigger, {
153
153
  asChild: true,
154
154
  children: /*#__PURE__*/ jsxs("div", {
155
- className: "fixed right-3 bottom-3 inline-flex items-center gap-x-1 border-solid border-[#ffffff1a] border px-2.5 py-1.5 bg-[#1f2329e5] backdrop-blur-[5px] shadow-[0px_6px_12px_0px_#41444a0a,0px_8px_24px_8px_#41444a0a] rounded-md text-[#ebebeb)] font-['PingFang_SC'] text-xs leading-[20px] tracking-[0px] z-[10000000] cursor-pointer",
155
+ className: "fixed right-3 bottom-3 inline-flex items-center gap-x-1 border-solid border-[#ffffff1a] border px-2.5 py-1.5 bg-[#1f2329e5] backdrop-blur-[5px] shadow-[0px_6px_12px_0px_#41444a0a,0px_8px_24px_8px_#41444a0a] rounded-[6px] text-[#ebebeb)] font-['PingFang_SC'] text-xs leading-[20px] tracking-[0px] z-[10000000] cursor-pointer",
156
156
  onMouseEnter: ()=>{
157
157
  clearTimeout(timeoutRef.current);
158
158
  setOpen(true);
@@ -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-xl!",
176
+ className: "overflow-hidden p-0 m-0 border-0 rounded-[12px]!",
177
177
  style: {
178
178
  boxShadow: '0 6px 12px 0 #41444a0a, 0 8px 24px 0 #41444a0a'
179
179
  },
@@ -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> & {
@@ -10,6 +10,5 @@ declare global {
10
10
  _IS_Spark_RUNTIME?: boolean;
11
11
  _bucket_id?: string;
12
12
  csrfToken?: string;
13
- collectEvent?: (...args: any[]) => void;
14
13
  }
15
14
  }
@@ -1,4 +1,3 @@
1
- export declare function getEnv(): 'BOE' | 'PRE' | 'ONLINE';
2
1
  /**
3
2
  * @internal
4
3
  * 获取预览环境父级域名
@@ -1,13 +1,7 @@
1
- function getEnv() {
2
- const { origin } = window.location;
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
1
  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';
2
+ const { origin } = window.location;
3
+ if (origin.includes('feishuapp.cn') || origin.includes('miaoda.feishuapp.net')) return 'https://miaoda.feishu.cn';
4
+ if (origin.includes('fsapp.kundou.cn') || origin.includes('miaoda-pre.feishuapp.net')) return 'https://miaoda.feishu-pre.cn';
11
5
  return 'https://miaoda.feishu-boe.cn';
12
6
  }
13
- export { getEnv, getPreviewParentOrigin };
7
+ export { getPreviewParentOrigin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/client-toolkit",
3
- "version": "1.1.20-alpha.tea.1",
3
+ "version": "1.1.20-antd-test.0",
4
4
  "types": "./lib/index.d.ts",
5
5
  "main": "./lib/index.js",
6
6
  "files": [
@@ -15,6 +15,11 @@
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
+ },
18
23
  "./lib/index.css": "./lib/index.css",
19
24
  "./dataloom": {
20
25
  "import": "./lib/apis/dataloom.js",
@@ -83,10 +88,8 @@
83
88
  "@radix-ui/react-tooltip": "^1.2.8",
84
89
  "@zumer/snapdom": "^1.9.14",
85
90
  "axios": "^1.12.2",
86
- "blueimp-md5": "2.10.0",
87
91
  "class-variance-authority": "^0.7.1",
88
92
  "clsx": "~2.0.1",
89
- "crypto-js": "3.1.9-1",
90
93
  "dayjs": "^1.11.13",
91
94
  "echarts": "^6.0.0",
92
95
  "lodash": "^4.17.21",
@@ -1 +0,0 @@
1
- export declare function getLarkUserInfo(): Promise<any>;
@@ -1,17 +0,0 @@
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 };
@@ -1,8 +0,0 @@
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>;
@@ -1,51 +0,0 @@
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 +0,0 @@
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
- }
package/lib/types/tea.js DELETED
@@ -1,5 +0,0 @@
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 };
@@ -1,3 +0,0 @@
1
- export declare const isIpad: () => boolean;
2
- export declare const isMobile: () => boolean;
3
- export declare const isIOS: () => boolean;
@@ -1,13 +0,0 @@
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 };