@lark-apaas/client-toolkit 1.2.10-alpha.40 → 1.2.10-alpha.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.
@@ -4,7 +4,11 @@ import '../../runtime';
4
4
  interface IBaseAuthProviderProps {
5
5
  enableAuth?: boolean;
6
6
  }
7
+ interface IToasterProps {
8
+ /** 禁用内建 Toaster 组件,默认 false */
9
+ disableToaster?: boolean;
10
+ }
7
11
  declare const AppContainer: React.FC<{
8
12
  children: React.ReactNode;
9
- } & IBaseThemeProviderProps & IBaseAuthProviderProps>;
13
+ } & IBaseThemeProviderProps & IBaseAuthProviderProps & IToasterProps>;
10
14
  export default AppContainer;
@@ -4,10 +4,8 @@ import { ConfigProvider } from "antd";
4
4
  import { MiaodaInspector } from "@lark-apaas/miaoda-inspector";
5
5
  import zh_CN from "antd/locale/zh_CN";
6
6
  import IframeBridge from "./IframeBridge.js";
7
- import { defaultUIConfig } from "../theme/ui-config.js";
8
7
  import { Toaster } from "./sonner.js";
9
8
  import { PageHoc } from "./PageHoc.js";
10
- import { findValueByPixel, generateTailwindRadiusToken, themeColorTokenMap, themeMetaOptions } from "../theme/index.js";
11
9
  import { reportTeaEvent } from "./utils/tea.js";
12
10
  import { useAppInfo } from "../../hooks/index.js";
13
11
  import { TrackKey } from "../../types/tea.js";
@@ -27,20 +25,10 @@ const readCssVarColor = (varName, fallback)=>{
27
25
  return fallback;
28
26
  }
29
27
  };
28
+ const appFlags = process.env.APP_FLAGS || {};
30
29
  const App = (props)=>{
31
- const { themeMeta = {}, enableAuth } = props;
30
+ const { enableAuth, disableToaster = false } = props;
32
31
  useAppInfo();
33
- const { rem } = findValueByPixel(themeMetaOptions.themeRadius, themeMeta.borderRadius) || {
34
- rem: '0.625'
35
- };
36
- const radiusToken = generateTailwindRadiusToken(Number(rem));
37
- const themeToken = {
38
- ...defaultUIConfig,
39
- common: {
40
- ...defaultUIConfig.common,
41
- borderRadius: radiusToken
42
- }
43
- };
44
32
  useEffect(()=>{
45
33
  if (isMiaodaPreview) fetch(`${location.origin}/ai/api/feida_preview/csrf`).then(()=>{
46
34
  setTimeout(()=>{
@@ -69,15 +57,8 @@ const App = (props)=>{
69
57
  }
70
58
  },
71
59
  children: [
72
- /*#__PURE__*/ jsx(Toaster, {}),
73
- 'production' !== process.env.NODE_ENV && /*#__PURE__*/ jsx(MiaodaInspector, {
74
- theme: {
75
- themeMetaOptions: themeMetaOptions,
76
- themeColorTokenMap: themeColorTokenMap,
77
- themeToken
78
- },
79
- cwd: process.env.CWD || ''
80
- }),
60
+ !disableToaster && true !== appFlags.customToaster && /*#__PURE__*/ jsx(Toaster, {}),
61
+ 'production' !== process.env.NODE_ENV && /*#__PURE__*/ jsx(MiaodaInspector, {}),
81
62
  'production' !== process.env.NODE_ENV && /*#__PURE__*/ jsx(IframeBridge, {}),
82
63
  /*#__PURE__*/ jsx(PageHoc, {
83
64
  children: props.children
@@ -86,7 +67,7 @@ const App = (props)=>{
86
67
  });
87
68
  };
88
69
  const AppContainer_AppContainer = (props)=>{
89
- const { children, ...rest } = props;
70
+ const { children } = props;
90
71
  const [cssColors, setCssColors] = useState(()=>({
91
72
  background: readCssVarColor('--background'),
92
73
  destructive: readCssVarColor('--destructive'),
@@ -214,8 +195,8 @@ const AppContainer_AppContainer = (props)=>{
214
195
  }
215
196
  },
216
197
  children: /*#__PURE__*/ jsx(App, {
217
- themeMeta: props.themeMeta,
218
198
  enableAuth: props.enableAuth,
199
+ disableToaster: props.disableToaster,
219
200
  children: children
220
201
  })
221
202
  })
@@ -1,3 +1,2 @@
1
1
  export * from './constants';
2
2
  export * from './util';
3
- export * from './ui-config';
@@ -1,3 +1,2 @@
1
1
  export * from "./constants.js";
2
2
  export * from "./util.js";
3
- export * from "./ui-config.js";
@@ -1,5 +1,4 @@
1
1
  import { ITheme } from "../../types";
2
- import { UIComponentConfig } from "./ui-config";
3
2
  export interface IBaseThemeProviderProps {
4
3
  defaultTheme?: ITheme;
5
4
  themeMeta?: Partial<IThemeTokenMeta>;
@@ -18,4 +17,3 @@ export interface IThemeTokenMeta {
18
17
  */
19
18
  spacing: number;
20
19
  }
21
- export declare const generateTailwindRadiusToken: (radiusRemValue: number) => UIComponentConfig;
@@ -1,108 +0,0 @@
1
- const generateTailwindRadiusToken = (radiusRemValue)=>{
2
- try {
3
- const rootFontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);
4
- const radiusPx = radiusRemValue * rootFontSize;
5
- const tempElement = document.createElement('div');
6
- tempElement.style.position = 'absolute';
7
- tempElement.style.visibility = 'hidden';
8
- document.body.appendChild(tempElement);
9
- tempElement.style.borderRadius = `${radiusPx}px`;
10
- const computed = getComputedStyle(tempElement).borderRadius;
11
- document.body.removeChild(tempElement);
12
- if (computed && 'auto' !== computed && 'initial' !== computed) return {
13
- type: 'select',
14
- options: [
15
- {
16
- value: 'rounded-none',
17
- label: 'none(0px)',
18
- rawValue: '0'
19
- },
20
- {
21
- value: 'rounded-sm',
22
- label: `sm (${Math.max(0, radiusPx - 4)}px)`,
23
- rawValue: `${Math.max(0, radiusPx - 4)}`
24
- },
25
- {
26
- value: 'rounded',
27
- label: 's (4px)',
28
- rawValue: '4'
29
- },
30
- {
31
- value: 'rounded-md',
32
- label: `m (${Math.max(0, radiusPx - 2)}px)`,
33
- rawValue: `${Math.max(0, radiusPx - 2)}`
34
- },
35
- {
36
- value: 'rounded-lg',
37
- label: `l (${radiusPx}px)`,
38
- rawValue: `${radiusPx}`
39
- },
40
- {
41
- value: 'rounded-xl',
42
- label: `xl (${radiusPx + 4}px)`,
43
- rawValue: `${radiusPx + 4}`
44
- },
45
- {
46
- value: 'rounded-2xl',
47
- label: '2xl (16px)',
48
- rawValue: '16'
49
- },
50
- {
51
- value: 'rounded-full',
52
- label: 'Full',
53
- rawValue: '9999'
54
- }
55
- ]
56
- };
57
- throw new Error('Browser calculation validation failed');
58
- } catch (error) {
59
- console.warn('Failed to get computed values from browser, falling back to default calculation:', error);
60
- const radiusPx = 16 * radiusRemValue;
61
- return {
62
- type: 'select',
63
- options: [
64
- {
65
- value: 'rounded-none',
66
- label: 'none(0px)',
67
- rawValue: '0'
68
- },
69
- {
70
- value: 'rounded-sm',
71
- label: `sm (${Math.max(0, radiusPx - 4)}px)`,
72
- rawValue: `${Math.max(0, radiusPx - 4)}`
73
- },
74
- {
75
- value: 'rounded',
76
- label: 's (4px)',
77
- rawValue: '4'
78
- },
79
- {
80
- value: 'rounded-md',
81
- label: `m (${Math.max(0, radiusPx - 2)}px)`,
82
- rawValue: `${Math.max(0, radiusPx - 2)}`
83
- },
84
- {
85
- value: 'rounded-lg',
86
- label: `l (${radiusPx}px)`,
87
- rawValue: `${radiusPx}`
88
- },
89
- {
90
- value: 'rounded-xl',
91
- label: `xl (${radiusPx + 4}px)`,
92
- rawValue: `${radiusPx + 4}`
93
- },
94
- {
95
- value: 'rounded-2xl',
96
- label: '2xl (16px)',
97
- rawValue: '16'
98
- },
99
- {
100
- value: 'rounded-full',
101
- label: 'Full',
102
- rawValue: '9999'
103
- }
104
- ]
105
- };
106
- }
107
- };
108
- export { generateTailwindRadiusToken };
@@ -14,6 +14,7 @@ export type UserInfo = {
14
14
  avatar: string;
15
15
  userType: '_employee' | '_externalUser' | '_anonymousUser';
16
16
  department: DepartmentBasic;
17
+ email?: string;
17
18
  };
18
19
  export type DepartmentInfo = {
19
20
  departmentID: string;
@@ -15,6 +15,7 @@
15
15
  * - 使用 __FULLSTACK_RUNTIME_INITIALIZED__ 标志位防止重复初始化
16
16
  * - 旧版 AppContainer 和新版 runtime 可以共存
17
17
  */
18
+ import './react-devtools-hook';
18
19
  import './styles';
19
20
  declare global {
20
21
  interface Window {
@@ -1,3 +1,4 @@
1
+ import "./react-devtools-hook.js";
1
2
  import "./styles.js";
2
3
  import { registerDayjsPlugins } from "./dayjs.js";
3
4
  import { initAxiosConfig } from "./axios.js";
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Inject minimal __REACT_DEVTOOLS_GLOBAL_HOOK__ before React loads.
3
+ * React checks for this hook during module initialization and registers its
4
+ * renderer via hook.inject(). This gives us access to renderer.overrideProps()
5
+ * for live component prop modification in the inspector.
6
+ *
7
+ * Must execute before React's module-level code runs.
8
+ *
9
+ * When react-refresh-runtime runs first (as an rspack runtime module),
10
+ * it may create __REACT_DEVTOOLS_GLOBAL_HOOK__ with an inject() that
11
+ * doesn't populate the renderers Map. We patch the existing hook to
12
+ * ensure renderers are always tracked.
13
+ */
14
+ export {};
15
+ declare global {
16
+ interface Window {
17
+ __REACT_DEVTOOLS_GLOBAL_HOOK__?: any;
18
+ }
19
+ }
@@ -0,0 +1,20 @@
1
+ if ('undefined' != typeof window && 'production' !== process.env.NODE_ENV) if (window.__REACT_DEVTOOLS_GLOBAL_HOOK__) {
2
+ const hook = window.__REACT_DEVTOOLS_GLOBAL_HOOK__;
3
+ if (!(hook.renderers instanceof Map)) hook.renderers = new Map();
4
+ const originalInject = 'function' == typeof hook.inject ? hook.inject.bind(hook) : null;
5
+ hook.inject = function(renderer) {
6
+ const id = originalInject ? originalInject(renderer) : hook.renderers.size + 1;
7
+ if (null != id && !hook.renderers.has(id)) hook.renderers.set(id, renderer);
8
+ return id;
9
+ };
10
+ } else window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = {
11
+ renderers: new Map(),
12
+ supportsFiber: true,
13
+ inject (renderer) {
14
+ const id = this.renderers.size + 1;
15
+ this.renderers.set(id, renderer);
16
+ return id;
17
+ },
18
+ onCommitFiberRoot () {},
19
+ onCommitFiberUnmount () {}
20
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/client-toolkit",
3
- "version": "1.2.10-alpha.40",
3
+ "version": "1.2.10-alpha.41",
4
4
  "types": "./lib/index.d.ts",
5
5
  "main": "./lib/index.js",
6
6
  "files": [
@@ -94,8 +94,8 @@
94
94
  "@ant-design/colors": "^7.2.1",
95
95
  "@ant-design/cssinjs": "^1.24.0",
96
96
  "@data-loom/js": "0.4.9-alpha.2",
97
- "@lark-apaas/auth-sdk": "0.1.0-alpha.55",
98
- "@lark-apaas/client-capability": "0.1.3-alpha.14",
97
+ "@lark-apaas/auth-sdk": "0.1.0-alpha.56",
98
+ "@lark-apaas/client-capability": "0.1.3-alpha.15",
99
99
  "@lark-apaas/miaoda-inspector": "^1.0.15",
100
100
  "@lark-apaas/observable-web": "^1.0.1",
101
101
  "@radix-ui/react-avatar": "^1.1.10",
@@ -1 +0,0 @@
1
- export { defaultUIConfig, type UIComponentConfig, } from '@lark-apaas/miaoda-inspector';
@@ -1,2 +0,0 @@
1
- import { defaultUIConfig } from "@lark-apaas/miaoda-inspector";
2
- export { defaultUIConfig };