@lark-apaas/client-toolkit 1.2.9-beta.23 → 1.2.9-beta.25
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 +3 -24
- package/lib/components/theme/index.d.ts +0 -1
- package/lib/components/theme/index.js +0 -1
- package/lib/components/theme/util.d.ts +0 -2
- package/lib/components/theme/util.js +0 -108
- package/lib/runtime/index.d.ts +1 -0
- package/lib/runtime/index.js +1 -0
- package/lib/runtime/react-devtools-hook.d.ts +19 -0
- package/lib/runtime/react-devtools-hook.js +20 -0
- package/package.json +2 -2
- package/lib/components/theme/ui-config.d.ts +0 -1
- package/lib/components/theme/ui-config.js +0 -2
|
@@ -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";
|
|
@@ -28,19 +26,8 @@ const readCssVarColor = (varName, fallback)=>{
|
|
|
28
26
|
};
|
|
29
27
|
const appFlags = process.env.APP_FLAGS || {};
|
|
30
28
|
const App = (props)=>{
|
|
31
|
-
const {
|
|
29
|
+
const { enableAuth, disableToaster = false } = props;
|
|
32
30
|
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
31
|
useEffect(()=>{
|
|
45
32
|
if (isMiaodaPreview) fetch(`${location.origin}/ai/api/feida_preview/csrf`).then(()=>{
|
|
46
33
|
setTimeout(()=>{
|
|
@@ -65,14 +52,7 @@ const App = (props)=>{
|
|
|
65
52
|
},
|
|
66
53
|
children: [
|
|
67
54
|
!disableToaster && true !== appFlags.customToaster && /*#__PURE__*/ jsx(Toaster, {}),
|
|
68
|
-
'production' !== process.env.NODE_ENV && /*#__PURE__*/ jsx(MiaodaInspector, {
|
|
69
|
-
theme: {
|
|
70
|
-
themeMetaOptions: themeMetaOptions,
|
|
71
|
-
themeColorTokenMap: themeColorTokenMap,
|
|
72
|
-
themeToken
|
|
73
|
-
},
|
|
74
|
-
cwd: process.env.CWD || ''
|
|
75
|
-
}),
|
|
55
|
+
'production' !== process.env.NODE_ENV && /*#__PURE__*/ jsx(MiaodaInspector, {}),
|
|
76
56
|
'production' !== process.env.NODE_ENV && /*#__PURE__*/ jsx(IframeBridge, {}),
|
|
77
57
|
/*#__PURE__*/ jsx(PageHoc, {
|
|
78
58
|
children: props.children
|
|
@@ -81,7 +61,7 @@ const App = (props)=>{
|
|
|
81
61
|
});
|
|
82
62
|
};
|
|
83
63
|
const AppContainer_AppContainer = (props)=>{
|
|
84
|
-
const { children
|
|
64
|
+
const { children } = props;
|
|
85
65
|
const [cssColors, setCssColors] = useState(()=>({
|
|
86
66
|
background: readCssVarColor('--background'),
|
|
87
67
|
destructive: readCssVarColor('--destructive'),
|
|
@@ -209,7 +189,6 @@ const AppContainer_AppContainer = (props)=>{
|
|
|
209
189
|
}
|
|
210
190
|
},
|
|
211
191
|
children: /*#__PURE__*/ jsx(App, {
|
|
212
|
-
themeMeta: props.themeMeta,
|
|
213
192
|
enableAuth: props.enableAuth,
|
|
214
193
|
disableToaster: props.disableToaster,
|
|
215
194
|
children: children
|
|
@@ -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 };
|
package/lib/runtime/index.d.ts
CHANGED
package/lib/runtime/index.js
CHANGED
|
@@ -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.9-beta.
|
|
3
|
+
"version": "1.2.9-beta.25",
|
|
4
4
|
"types": "./lib/index.d.ts",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"@data-loom/js": "0.4.8",
|
|
97
97
|
"@lark-apaas/auth-sdk": "^0.1.0",
|
|
98
98
|
"@lark-apaas/client-capability": "^0.1.4",
|
|
99
|
-
"@lark-apaas/miaoda-inspector": "
|
|
99
|
+
"@lark-apaas/miaoda-inspector": "1.0.13-beta.9",
|
|
100
100
|
"@lark-apaas/observable-web": "^1.0.1",
|
|
101
101
|
"@radix-ui/react-avatar": "^1.1.10",
|
|
102
102
|
"@radix-ui/react-popover": "^1.1.15",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { defaultUIConfig, type UIComponentConfig, } from '@lark-apaas/miaoda-inspector';
|