@lark-apaas/client-toolkit 0.1.0-alpha.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/LICENSE +13 -0
- package/README.md +8 -0
- package/lib/apis/components/AppContainer.d.ts +1 -0
- package/lib/apis/components/AppContainer.js +2 -0
- package/lib/apis/components/ErrorRender.d.ts +1 -0
- package/lib/apis/components/ErrorRender.js +2 -0
- package/lib/apis/components/NotFoundRender.d.ts +1 -0
- package/lib/apis/components/NotFoundRender.js +2 -0
- package/lib/apis/components/SidebarNav.d.ts +1 -0
- package/lib/apis/components/SidebarNav.js +2 -0
- package/lib/apis/components/User.d.ts +1 -0
- package/lib/apis/components/User.js +1 -0
- package/lib/apis/components/Welcome.d.ts +1 -0
- package/lib/apis/components/Welcome.js +2 -0
- package/lib/apis/constants/img-resources/avatar.d.ts +11 -0
- package/lib/apis/constants/img-resources/avatar.js +12 -0
- package/lib/apis/constants/img-resources/banner.d.ts +24 -0
- package/lib/apis/constants/img-resources/banner.js +25 -0
- package/lib/apis/constants/img-resources/cover.d.ts +36 -0
- package/lib/apis/constants/img-resources/cover.js +37 -0
- package/lib/apis/dataloom.d.ts +1 -0
- package/lib/apis/dataloom.js +2 -0
- package/lib/apis/hooks/useAppInfo.d.ts +1 -0
- package/lib/apis/hooks/useAppInfo.js +1 -0
- package/lib/apis/hooks/useCurrentUserProfile.d.ts +1 -0
- package/lib/apis/hooks/useCurrentUserProfile.js +1 -0
- package/lib/apis/logger.d.ts +1 -0
- package/lib/apis/logger.js +1 -0
- package/lib/apis/tools/generateImage.d.ts +1 -0
- package/lib/apis/tools/generateImage.js +1 -0
- package/lib/apis/tools/generateTextStream.d.ts +1 -0
- package/lib/apis/tools/generateTextStream.js +1 -0
- package/lib/apis/tools/getAppInfo.d.ts +1 -0
- package/lib/apis/tools/getAppInfo.js +1 -0
- package/lib/apis/tools/getCurrentUserProfile.d.ts +1 -0
- package/lib/apis/tools/getCurrentUserProfile.js +1 -0
- package/lib/apis/tools/storage.d.ts +1 -0
- package/lib/apis/tools/storage.js +4 -0
- package/lib/apis/udt-types.d.ts +16 -0
- package/lib/apis/udt-types.js +0 -0
- package/lib/apis/utils/registerChinaMap.d.ts +1 -0
- package/lib/apis/utils/registerChinaMap.js +103319 -0
- package/lib/components/AppContainer/IframeBridge.d.ts +4 -0
- package/lib/components/AppContainer/IframeBridge.js +92 -0
- package/lib/components/AppContainer/LogInterceptor.d.ts +1 -0
- package/lib/components/AppContainer/LogInterceptor.js +44 -0
- package/lib/components/AppContainer/PageHoc.d.ts +4 -0
- package/lib/components/AppContainer/PageHoc.js +30 -0
- package/lib/components/AppContainer/dayjsPlugins.d.ts +1 -0
- package/lib/components/AppContainer/dayjsPlugins.js +69 -0
- package/lib/components/AppContainer/index.d.ts +7 -0
- package/lib/components/AppContainer/index.js +65 -0
- package/lib/components/AppContainer/sonner.css +101 -0
- package/lib/components/AppContainer/sonner.d.ts +8 -0
- package/lib/components/AppContainer/sonner.js +26 -0
- package/lib/components/AppContainer/utils/childApi.d.ts +5 -0
- package/lib/components/AppContainer/utils/childApi.js +20 -0
- package/lib/components/AppContainer/utils/listenHot.d.ts +1 -0
- package/lib/components/AppContainer/utils/listenHot.js +43 -0
- package/lib/components/ErrorRender/index.d.ts +5 -0
- package/lib/components/ErrorRender/index.js +79 -0
- package/lib/components/NotFoundRender/index.d.ts +3 -0
- package/lib/components/NotFoundRender/index.js +59 -0
- package/lib/components/SidebarNav/DrawerNav.d.ts +3 -0
- package/lib/components/SidebarNav/DrawerNav.js +64 -0
- package/lib/components/SidebarNav/DropdownNav.d.ts +3 -0
- package/lib/components/SidebarNav/DropdownNav.js +40 -0
- package/lib/components/SidebarNav/Sidebar.d.ts +3 -0
- package/lib/components/SidebarNav/Sidebar.js +33 -0
- package/lib/components/SidebarNav/index.d.ts +5 -0
- package/lib/components/SidebarNav/index.js +61 -0
- package/lib/components/User/UserDisplay.d.ts +9 -0
- package/lib/components/User/UserDisplay.js +39 -0
- package/lib/components/User/UserProfile/UserProfile.css +34 -0
- package/lib/components/User/UserProfile/UserProfile.d.ts +6 -0
- package/lib/components/User/UserProfile/UserProfile.js +41 -0
- package/lib/components/User/UserProfile/UserProfileContainer.d.ts +4 -0
- package/lib/components/User/UserProfile/UserProfileContainer.js +8 -0
- package/lib/components/User/UserProfile/UserProfileSkeleton.d.ts +3 -0
- package/lib/components/User/UserProfile/UserProfileSkeleton.js +36 -0
- package/lib/components/User/UserProfile/UserProfileUI.d.ts +8 -0
- package/lib/components/User/UserProfile/UserProfileUI.js +113 -0
- package/lib/components/User/UserProfile/index.d.ts +1 -0
- package/lib/components/User/UserProfile/index.js +2 -0
- package/lib/components/User/UserProfile/type.d.ts +8 -0
- package/lib/components/User/UserProfile/type.js +0 -0
- package/lib/components/User/UserProfile/utils.d.ts +5 -0
- package/lib/components/User/UserProfile/utils.js +26 -0
- package/lib/components/User/UserSelect.css +11 -0
- package/lib/components/User/UserSelect.d.ts +11 -0
- package/lib/components/User/UserSelect.js +172 -0
- package/lib/components/User/UserWithAvatar.d.ts +3 -0
- package/lib/components/User/UserWithAvatar.js +41 -0
- package/lib/components/User/index.d.ts +7 -0
- package/lib/components/User/index.js +5 -0
- package/lib/components/User/type.d.ts +13 -0
- package/lib/components/User/type.js +0 -0
- package/lib/components/Welcome/index.d.ts +3 -0
- package/lib/components/Welcome/index.js +17 -0
- package/lib/components/common/LogoInfo.d.ts +5 -0
- package/lib/components/common/LogoInfo.js +30 -0
- package/lib/components/common/NavItem.d.ts +20 -0
- package/lib/components/common/NavItem.js +112 -0
- package/lib/components/common/NavMenu.d.ts +9 -0
- package/lib/components/common/NavMenu.js +50 -0
- package/lib/components/common/UserAvatarLayout.d.ts +4 -0
- package/lib/components/common/UserAvatarLayout.js +41 -0
- package/lib/components/common/UserAvatarMenu.d.ts +4 -0
- package/lib/components/common/UserAvatarMenu.js +58 -0
- package/lib/components/common/index.d.ts +9 -0
- package/lib/components/common/index.js +10 -0
- package/lib/components/index.d.ts +8 -0
- package/lib/components/index.js +6 -0
- package/lib/components/theme/ThemeProvider.d.ts +20 -0
- package/lib/components/theme/ThemeProvider.js +75 -0
- package/lib/components/theme/constants.d.ts +48 -0
- package/lib/components/theme/constants.js +557 -0
- package/lib/components/theme/index.d.ts +4 -0
- package/lib/components/theme/index.js +5 -0
- package/lib/components/theme/miaoDarkTheme.d.ts +2 -0
- package/lib/components/theme/miaoDarkTheme.js +310 -0
- package/lib/components/theme/miaoLightTheme.d.ts +2 -0
- package/lib/components/theme/miaoLightTheme.js +296 -0
- package/lib/components/theme/ui-config.d.ts +1 -0
- package/lib/components/theme/ui-config.js +2 -0
- package/lib/components/theme/util.d.ts +20 -0
- package/lib/components/theme/util.js +188 -0
- package/lib/font-family.css +40 -0
- package/lib/hooks/index.d.ts +5 -0
- package/lib/hooks/index.js +5 -0
- package/lib/hooks/useAppInfo.d.ts +6 -0
- package/lib/hooks/useAppInfo.js +21 -0
- package/lib/hooks/useCurrentUserProfile.d.ts +12 -0
- package/lib/hooks/useCurrentUserProfile.js +58 -0
- package/lib/hooks/useIsMobile.d.ts +1 -0
- package/lib/hooks/useIsMobile.js +20 -0
- package/lib/hooks/useLogout.d.ts +4 -0
- package/lib/hooks/useLogout.js +37 -0
- package/lib/hooks/useTheme.d.ts +4 -0
- package/lib/hooks/useTheme.js +8 -0
- package/lib/hooks/useUpdatingRef.d.ts +1 -0
- package/lib/hooks/useUpdatingRef.js +7 -0
- package/lib/index.css +5 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +5 -0
- package/lib/inspector.dev.css +10 -0
- package/lib/integrations/dataloom.d.ts +2 -0
- package/lib/integrations/dataloom.js +32 -0
- package/lib/integrations/generateImage.d.ts +1 -0
- package/lib/integrations/generateImage.js +47 -0
- package/lib/integrations/generateTextStream.d.ts +21 -0
- package/lib/integrations/generateTextStream.js +98 -0
- package/lib/integrations/getAppInfo.d.ts +2 -0
- package/lib/integrations/getAppInfo.js +14 -0
- package/lib/integrations/getCurrentUserProfile.d.ts +6 -0
- package/lib/integrations/getCurrentUserProfile.js +5 -0
- package/lib/logger/index.d.ts +6 -0
- package/lib/logger/index.js +54 -0
- package/lib/override.css +29 -0
- package/lib/tailwind-theme.css +335 -0
- package/lib/theme-layer.css +3 -0
- package/lib/types/common.d.ts +4 -0
- package/lib/types/common.js +0 -0
- package/lib/types/iframe-events.d.ts +50 -0
- package/lib/types/iframe-events.js +0 -0
- package/lib/types/index.d.ts +43 -0
- package/lib/types/index.js +0 -0
- package/lib/utils/copyToClipboard.d.ts +6 -0
- package/lib/utils/copyToClipboard.js +32 -0
- package/lib/utils/getAppId.d.ts +6 -0
- package/lib/utils/getAppId.js +11 -0
- package/lib/utils/getCsrfToken.d.ts +5 -0
- package/lib/utils/getCsrfToken.js +10 -0
- package/lib/utils/getEnvPath.d.ts +4 -0
- package/lib/utils/getEnvPath.js +4 -0
- package/lib/utils/getInitialInfo.d.ts +20 -0
- package/lib/utils/getInitialInfo.js +32 -0
- package/lib/utils/getParentOrigin.d.ts +5 -0
- package/lib/utils/getParentOrigin.js +7 -0
- package/lib/utils/getUserProfile.d.ts +47 -0
- package/lib/utils/getUserProfile.js +39 -0
- package/lib/utils/postMessage.d.ts +8 -0
- package/lib/utils/postMessage.js +11 -0
- package/lib/utils/url.d.ts +8 -0
- package/lib/utils/url.js +22 -0
- package/lib/utils/utils.d.ts +20 -0
- package/lib/utils/utils.js +22 -0
- package/package.json +135 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
3
|
+
import { useLocation, useNavigate } from "react-router-dom";
|
|
4
|
+
import { connectToParent } from "penpal";
|
|
5
|
+
import { useUpdatingRef } from "../../hooks/useUpdatingRef.js";
|
|
6
|
+
import { postMessage } from "../../utils/postMessage.js";
|
|
7
|
+
import { getPreviewParentOrigin } from "../../utils/getParentOrigin.js";
|
|
8
|
+
import { childApi } from "./utils/childApi.js";
|
|
9
|
+
import "./utils/listenHot.js";
|
|
10
|
+
import "./LogInterceptor.js";
|
|
11
|
+
var IframeBridge_RouteMessageType = /*#__PURE__*/ function(RouteMessageType) {
|
|
12
|
+
RouteMessageType["RouteChange"] = "RouteChange";
|
|
13
|
+
RouteMessageType["RouteBack"] = "RouteBack";
|
|
14
|
+
RouteMessageType["RouteForward"] = "RouteForward";
|
|
15
|
+
return RouteMessageType;
|
|
16
|
+
}(IframeBridge_RouteMessageType || {});
|
|
17
|
+
function isRouteMessageType(type) {
|
|
18
|
+
return Object.values(IframeBridge_RouteMessageType).includes(type);
|
|
19
|
+
}
|
|
20
|
+
async function connectParent() {
|
|
21
|
+
postMessage({
|
|
22
|
+
type: 'PreviewReady',
|
|
23
|
+
data: {}
|
|
24
|
+
});
|
|
25
|
+
const connection = connectToParent({
|
|
26
|
+
parentOrigin: getPreviewParentOrigin(),
|
|
27
|
+
methods: {
|
|
28
|
+
...childApi
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
await connection.promise;
|
|
32
|
+
}
|
|
33
|
+
'production' !== process.env.NODE_ENV && connectParent();
|
|
34
|
+
function IframeBridge() {
|
|
35
|
+
const location = useLocation();
|
|
36
|
+
const navigate = useNavigate();
|
|
37
|
+
const navigateRef = useUpdatingRef(navigate);
|
|
38
|
+
const isActive = useRef(false);
|
|
39
|
+
const historyBack = useCallback(()=>{
|
|
40
|
+
navigateRef.current(-1);
|
|
41
|
+
isActive.current = true;
|
|
42
|
+
}, [
|
|
43
|
+
navigateRef
|
|
44
|
+
]);
|
|
45
|
+
const historyForward = useCallback(()=>{
|
|
46
|
+
navigateRef.current(1);
|
|
47
|
+
isActive.current = true;
|
|
48
|
+
}, [
|
|
49
|
+
navigateRef
|
|
50
|
+
]);
|
|
51
|
+
const operatorMessage = useMemo(()=>({
|
|
52
|
+
["RouteBack"]: historyBack,
|
|
53
|
+
["RouteForward"]: historyForward,
|
|
54
|
+
["RouteChange"]: navigateRef.current
|
|
55
|
+
}), [
|
|
56
|
+
historyBack,
|
|
57
|
+
historyForward,
|
|
58
|
+
navigateRef
|
|
59
|
+
]);
|
|
60
|
+
useEffect(()=>{
|
|
61
|
+
if (isActive.current) {
|
|
62
|
+
isActive.current = false;
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
postMessage({
|
|
66
|
+
type: 'ChildLocationChange',
|
|
67
|
+
data: location
|
|
68
|
+
});
|
|
69
|
+
}, [
|
|
70
|
+
location
|
|
71
|
+
]);
|
|
72
|
+
const handleMessage = useCallback((event)=>{
|
|
73
|
+
const { data } = event;
|
|
74
|
+
if (isRouteMessageType(data?.type)) operatorMessage[data?.type](data?.data);
|
|
75
|
+
}, [
|
|
76
|
+
operatorMessage
|
|
77
|
+
]);
|
|
78
|
+
useEffect(()=>{
|
|
79
|
+
window.addEventListener('message', handleMessage);
|
|
80
|
+
return ()=>{
|
|
81
|
+
window.removeEventListener('message', handleMessage);
|
|
82
|
+
};
|
|
83
|
+
}, [
|
|
84
|
+
handleMessage
|
|
85
|
+
]);
|
|
86
|
+
return /*#__PURE__*/ jsx("div", {
|
|
87
|
+
style: {
|
|
88
|
+
display: 'none'
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
export { IframeBridge as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { postMessage } from "../../utils/postMessage.js";
|
|
2
|
+
const PROXY_CONSOLE_METHOD = [
|
|
3
|
+
'log',
|
|
4
|
+
'info',
|
|
5
|
+
'warn',
|
|
6
|
+
'error'
|
|
7
|
+
];
|
|
8
|
+
const LOG_FILTER_PREFIX = [
|
|
9
|
+
'[Dataloom]',
|
|
10
|
+
'[MiaoDa]'
|
|
11
|
+
];
|
|
12
|
+
const initHandleError = ()=>{
|
|
13
|
+
window.onerror = (message, source, lineno, colno, error)=>{
|
|
14
|
+
const errorList = [];
|
|
15
|
+
if (error) errorList.push(error);
|
|
16
|
+
else {
|
|
17
|
+
if ('string' == typeof message && [
|
|
18
|
+
'Script error.'
|
|
19
|
+
].includes(message)) return;
|
|
20
|
+
if (message) errorList.push(message);
|
|
21
|
+
else if (source) errorList.push(source);
|
|
22
|
+
}
|
|
23
|
+
console.error('[MiaoDa]', ...errorList);
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
const initLogInterceptor = ()=>{
|
|
27
|
+
PROXY_CONSOLE_METHOD.forEach((method)=>{
|
|
28
|
+
const originalMethod = window.console[method];
|
|
29
|
+
window.console[method] = (...args)=>{
|
|
30
|
+
originalMethod(...args);
|
|
31
|
+
const log = args[0];
|
|
32
|
+
if ('string' == typeof log && LOG_FILTER_PREFIX.some((prefix)=>log.startsWith(prefix))) postMessage({
|
|
33
|
+
type: 'Console',
|
|
34
|
+
method,
|
|
35
|
+
data: args
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
function init() {
|
|
41
|
+
initHandleError();
|
|
42
|
+
initLogInterceptor();
|
|
43
|
+
}
|
|
44
|
+
'production' !== process.env.NODE_ENV && init();
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import { snapdom } from "@zumer/snapdom";
|
|
4
|
+
import { postMessage } from "../../utils/postMessage.js";
|
|
5
|
+
function PageHoc(props) {
|
|
6
|
+
const { children } = props;
|
|
7
|
+
useEffect(()=>{
|
|
8
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
9
|
+
const timer = setTimeout(()=>{
|
|
10
|
+
snapdom(document.body, {
|
|
11
|
+
format: 'png',
|
|
12
|
+
width: document.body.scrollWidth,
|
|
13
|
+
height: document.body.scrollHeight,
|
|
14
|
+
backgroundColor: '#ffffff'
|
|
15
|
+
}).then(async (res)=>{
|
|
16
|
+
const imgEle = await res.toPng();
|
|
17
|
+
postMessage({
|
|
18
|
+
type: 'PageScreenshot',
|
|
19
|
+
data: imgEle.src
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}, 1000);
|
|
23
|
+
return ()=>clearTimeout(timer);
|
|
24
|
+
}
|
|
25
|
+
}, []);
|
|
26
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
27
|
+
children: children
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export { PageHoc };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function registerDayjsPlugins(): void;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import advancedFormat from "dayjs/plugin/advancedFormat";
|
|
3
|
+
import arraySupport from "dayjs/plugin/arraySupport";
|
|
4
|
+
import calendar from "dayjs/plugin/calendar";
|
|
5
|
+
import customParseFormat from "dayjs/plugin/customParseFormat";
|
|
6
|
+
import dayOfYear from "dayjs/plugin/dayOfYear";
|
|
7
|
+
import duration from "dayjs/plugin/duration";
|
|
8
|
+
import isBetween from "dayjs/plugin/isBetween";
|
|
9
|
+
import isLeapYear from "dayjs/plugin/isLeapYear";
|
|
10
|
+
import isMoment from "dayjs/plugin/isMoment";
|
|
11
|
+
import isSameOrAfter from "dayjs/plugin/isSameOrAfter";
|
|
12
|
+
import isSameOrBefore from "dayjs/plugin/isSameOrBefore";
|
|
13
|
+
import isToday from "dayjs/plugin/isToday";
|
|
14
|
+
import isTomorrow from "dayjs/plugin/isTomorrow";
|
|
15
|
+
import isYesterday from "dayjs/plugin/isYesterday";
|
|
16
|
+
import isoWeek from "dayjs/plugin/isoWeek";
|
|
17
|
+
import isoWeeksInYear from "dayjs/plugin/isoWeeksInYear";
|
|
18
|
+
import localeData from "dayjs/plugin/localeData";
|
|
19
|
+
import localizedFormat from "dayjs/plugin/localizedFormat";
|
|
20
|
+
import minMax from "dayjs/plugin/minMax";
|
|
21
|
+
import negativeYear from "dayjs/plugin/negativeYear";
|
|
22
|
+
import objectSupport from "dayjs/plugin/objectSupport";
|
|
23
|
+
import pluralGetSet from "dayjs/plugin/pluralGetSet";
|
|
24
|
+
import preParsePostFormat from "dayjs/plugin/preParsePostFormat";
|
|
25
|
+
import quarterOfYear from "dayjs/plugin/quarterOfYear";
|
|
26
|
+
import relativeTime from "dayjs/plugin/relativeTime";
|
|
27
|
+
import toArray from "dayjs/plugin/toArray";
|
|
28
|
+
import toObject from "dayjs/plugin/toObject";
|
|
29
|
+
import updateLocale from "dayjs/plugin/updateLocale";
|
|
30
|
+
import weekOfYear from "dayjs/plugin/weekOfYear";
|
|
31
|
+
import weekYear from "dayjs/plugin/weekYear";
|
|
32
|
+
import weekday from "dayjs/plugin/weekday";
|
|
33
|
+
let isRegistered = false;
|
|
34
|
+
function registerDayjsPlugins() {
|
|
35
|
+
if (isRegistered) return;
|
|
36
|
+
isRegistered = true;
|
|
37
|
+
dayjs.extend(advancedFormat);
|
|
38
|
+
dayjs.extend(arraySupport);
|
|
39
|
+
dayjs.extend(calendar);
|
|
40
|
+
dayjs.extend(customParseFormat);
|
|
41
|
+
dayjs.extend(dayOfYear);
|
|
42
|
+
dayjs.extend(duration);
|
|
43
|
+
dayjs.extend(isBetween);
|
|
44
|
+
dayjs.extend(isLeapYear);
|
|
45
|
+
dayjs.extend(isMoment);
|
|
46
|
+
dayjs.extend(isSameOrAfter);
|
|
47
|
+
dayjs.extend(isSameOrBefore);
|
|
48
|
+
dayjs.extend(isToday);
|
|
49
|
+
dayjs.extend(isTomorrow);
|
|
50
|
+
dayjs.extend(isYesterday);
|
|
51
|
+
dayjs.extend(isoWeek);
|
|
52
|
+
dayjs.extend(isoWeeksInYear);
|
|
53
|
+
dayjs.extend(localeData);
|
|
54
|
+
dayjs.extend(localizedFormat);
|
|
55
|
+
dayjs.extend(minMax);
|
|
56
|
+
dayjs.extend(negativeYear);
|
|
57
|
+
dayjs.extend(objectSupport);
|
|
58
|
+
dayjs.extend(pluralGetSet);
|
|
59
|
+
dayjs.extend(preParsePostFormat);
|
|
60
|
+
dayjs.extend(quarterOfYear);
|
|
61
|
+
dayjs.extend(relativeTime);
|
|
62
|
+
dayjs.extend(toArray);
|
|
63
|
+
dayjs.extend(toObject);
|
|
64
|
+
dayjs.extend(updateLocale);
|
|
65
|
+
dayjs.extend(weekOfYear);
|
|
66
|
+
dayjs.extend(weekYear);
|
|
67
|
+
dayjs.extend(weekday);
|
|
68
|
+
}
|
|
69
|
+
export { registerDayjsPlugins };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import { StyleProvider } from "@ant-design/cssinjs";
|
|
4
|
+
import { MiaodaInspector } from "@lark-apaas/miaoda-inspector";
|
|
5
|
+
import IframeBridge from "./IframeBridge.js";
|
|
6
|
+
import { defaultUIConfig } from "../theme/ui-config.js";
|
|
7
|
+
import { Toaster } from "./sonner.js";
|
|
8
|
+
import { PageHoc } from "./PageHoc.js";
|
|
9
|
+
import { ThemeProvider, findValueByPixel, generateTailwindRadiusToken, themeColorTokenMap, themeMetaOptions } from "../theme/index.js";
|
|
10
|
+
import { registerDayjsPlugins } from "./dayjsPlugins.js";
|
|
11
|
+
import "../../index.css";
|
|
12
|
+
registerDayjsPlugins();
|
|
13
|
+
const isMiaodaPreview = window.IS_MIAODA_PREVIEW;
|
|
14
|
+
const App = (props)=>{
|
|
15
|
+
const { themeMeta = {} } = props;
|
|
16
|
+
const { rem } = findValueByPixel(themeMetaOptions.themeRadius, themeMeta.borderRadius) || {
|
|
17
|
+
rem: '0.625'
|
|
18
|
+
};
|
|
19
|
+
const radiusToken = generateTailwindRadiusToken(Number(rem));
|
|
20
|
+
const themeToken = {
|
|
21
|
+
...defaultUIConfig,
|
|
22
|
+
common: {
|
|
23
|
+
...defaultUIConfig.common,
|
|
24
|
+
borderRadius: radiusToken
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
useEffect(()=>{
|
|
28
|
+
if (isMiaodaPreview) fetch(`${location.origin}/ai/api/feida_preview/csrf`).then(()=>{
|
|
29
|
+
setTimeout(()=>{
|
|
30
|
+
const match = document.cookie.match(/lgw_csrf_token=([^;]+)/);
|
|
31
|
+
if (match) window.lgw_csrf_token = match[1];
|
|
32
|
+
}, 300);
|
|
33
|
+
});
|
|
34
|
+
}, []);
|
|
35
|
+
return /*#__PURE__*/ jsxs(StyleProvider, {
|
|
36
|
+
layer: true,
|
|
37
|
+
children: [
|
|
38
|
+
/*#__PURE__*/ jsx(Toaster, {}),
|
|
39
|
+
'production' !== process.env.NODE_ENV && /*#__PURE__*/ jsx(MiaodaInspector, {
|
|
40
|
+
theme: {
|
|
41
|
+
themeMetaOptions: themeMetaOptions,
|
|
42
|
+
themeColorTokenMap: themeColorTokenMap,
|
|
43
|
+
themeToken
|
|
44
|
+
},
|
|
45
|
+
cwd: process.env.CWD || ''
|
|
46
|
+
}),
|
|
47
|
+
'production' !== process.env.NODE_ENV && /*#__PURE__*/ jsx(IframeBridge, {}),
|
|
48
|
+
/*#__PURE__*/ jsx(PageHoc, {
|
|
49
|
+
children: props.children
|
|
50
|
+
})
|
|
51
|
+
]
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
const AppContainer = (props)=>{
|
|
55
|
+
const { children, ...rest } = props;
|
|
56
|
+
return /*#__PURE__*/ jsx(ThemeProvider, {
|
|
57
|
+
...rest,
|
|
58
|
+
children: /*#__PURE__*/ jsx(App, {
|
|
59
|
+
themeMeta: props.themeMeta,
|
|
60
|
+
children: children
|
|
61
|
+
})
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
const components_AppContainer = AppContainer;
|
|
65
|
+
export { components_AppContainer as default };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--ud-normal-bg: #fff;
|
|
3
|
+
--ud-normal-border: #dee0e3;
|
|
4
|
+
--ud-normal-text: #1f2329;
|
|
5
|
+
--ud-success-bg: #e4fae1;
|
|
6
|
+
--ud-success-border: #32a645;
|
|
7
|
+
--ud-success-text: #1f2329;
|
|
8
|
+
--ud-info-bg: #f0f4ff;
|
|
9
|
+
--ud-info-border: #1456f0;
|
|
10
|
+
--ud-info-text: #1f2329;
|
|
11
|
+
--ud-warning-bg: #fff3e5;
|
|
12
|
+
--ud-warning-border: #ed6d0c;
|
|
13
|
+
--ud-warning-text: #1f2329;
|
|
14
|
+
--ud-error-bg: #fef0f0;
|
|
15
|
+
--ud-error-border: #f54a45;
|
|
16
|
+
--ud-error-text: #1f2329;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
[data-sonner-toast][data-styled="true"] [data-button] {
|
|
20
|
+
background: var(--ud-info-border);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
[data-sonner-toaster][data-sonner-theme="dark"] [data-sonner-toast] [data-close-button] {
|
|
24
|
+
background: var(--ud-normal-bg);
|
|
25
|
+
border-color: var(--ud-normal-border);
|
|
26
|
+
color: var(--ud-normal-text);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
[data-sonner-toaster][data-sonner-theme="dark"] [data-sonner-toast] [data-close-button]:hover {
|
|
30
|
+
background: var(--ud-normal-bg-hover);
|
|
31
|
+
border-color: var(--ud-normal-border-hover);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
[data-rich-colors="true"][data-sonner-toast][data-type="success"] {
|
|
35
|
+
background: var(--ud-success-bg);
|
|
36
|
+
border-color: var(--ud-success-border);
|
|
37
|
+
color: var(--ud-success-text);
|
|
38
|
+
|
|
39
|
+
& [data-icon] {
|
|
40
|
+
color: var(--ud-success-border);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
[data-rich-colors="true"][data-sonner-toast][data-type="success"] [data-close-button] {
|
|
45
|
+
background: var(--ud-success-bg);
|
|
46
|
+
border-color: var(--ud-success-border);
|
|
47
|
+
color: var(--ud-success-text);
|
|
48
|
+
|
|
49
|
+
& [data-icon] {
|
|
50
|
+
color: var(--ud-success-border);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
[data-rich-colors="true"][data-sonner-toast][data-type="info"] {
|
|
55
|
+
background: var(--ud-info-bg);
|
|
56
|
+
border-color: var(--ud-info-border);
|
|
57
|
+
color: var(--ud-info-text);
|
|
58
|
+
|
|
59
|
+
& [data-icon] {
|
|
60
|
+
color: var(--ud-info-border);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
[data-rich-colors="true"][data-sonner-toast][data-type="info"] [data-close-button] {
|
|
65
|
+
background: var(--ud-info-bg);
|
|
66
|
+
border-color: var(--ud-info-border);
|
|
67
|
+
color: var(--ud-info-text);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
[data-rich-colors="true"][data-sonner-toast][data-type="warning"] {
|
|
71
|
+
background: var(--ud-warning-bg);
|
|
72
|
+
border-color: var(--ud-warning-border);
|
|
73
|
+
color: var(--ud-warning-text);
|
|
74
|
+
|
|
75
|
+
& [data-icon] {
|
|
76
|
+
color: var(--ud-warning-border);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
[data-rich-colors="true"][data-sonner-toast][data-type="warning"] [data-close-button] {
|
|
81
|
+
background: var(--ud-warning-bg);
|
|
82
|
+
border-color: var(--ud-warning-border);
|
|
83
|
+
color: var(--ud-warning-text);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
[data-rich-colors="true"][data-sonner-toast][data-type="error"] {
|
|
87
|
+
background: var(--ud-error-bg);
|
|
88
|
+
border-color: var(--ud-error-border);
|
|
89
|
+
color: var(--ud-error-text);
|
|
90
|
+
|
|
91
|
+
& [data-icon] {
|
|
92
|
+
color: var(--ud-error-border);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
[data-rich-colors="true"][data-sonner-toast][data-type="error"] [data-close-button] {
|
|
97
|
+
background: var(--ud-error-bg);
|
|
98
|
+
border-color: var(--ud-error-border);
|
|
99
|
+
color: var(--ud-error-text);
|
|
100
|
+
}
|
|
101
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { Toaster, toast } from "sonner";
|
|
4
|
+
import "./sonner.css";
|
|
5
|
+
import { useTheme } from "../../hooks/index.js";
|
|
6
|
+
const sonner_Toaster = ({ ...props })=>{
|
|
7
|
+
const { theme } = useTheme();
|
|
8
|
+
return /*#__PURE__*/ jsx(Toaster, {
|
|
9
|
+
theme: theme,
|
|
10
|
+
className: "toaster group",
|
|
11
|
+
style: {
|
|
12
|
+
top: 70
|
|
13
|
+
},
|
|
14
|
+
position: "top-center",
|
|
15
|
+
richColors: true,
|
|
16
|
+
toastOptions: {
|
|
17
|
+
classNames: {
|
|
18
|
+
description: 'group-[.toast]:text-muted-foreground',
|
|
19
|
+
actionButton: 'group-[.toast]:bg-primary group-[.toast]:text-primary-foreground',
|
|
20
|
+
cancelButton: 'group-[.toast]:bg-muted group-[.toast]:text-muted-foreground'
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
...props
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
export { sonner_Toaster as Toaster, toast };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { normalizeBasePath } from "../../../utils/utils.js";
|
|
2
|
+
async function getRoutes() {
|
|
3
|
+
let routes = [
|
|
4
|
+
{
|
|
5
|
+
path: '/'
|
|
6
|
+
}
|
|
7
|
+
];
|
|
8
|
+
try {
|
|
9
|
+
const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
|
|
10
|
+
const res = await fetch(`${basePath}/routes.json`);
|
|
11
|
+
routes = await res.json();
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.warn('get routes.json error', error);
|
|
14
|
+
}
|
|
15
|
+
return routes;
|
|
16
|
+
}
|
|
17
|
+
const childApi = {
|
|
18
|
+
getRoutes
|
|
19
|
+
};
|
|
20
|
+
export { childApi };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function connectDevServer(): WebSocket;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import sockjs_client from "sockjs-client";
|
|
2
|
+
import { postMessage } from "../../../utils/postMessage.js";
|
|
3
|
+
import { getWsPath } from "../../../utils/utils.js";
|
|
4
|
+
let hotInited = false;
|
|
5
|
+
function handleDevServerMessage(msg) {
|
|
6
|
+
if ('hash' === msg.type) {
|
|
7
|
+
if (!hotInited) {
|
|
8
|
+
hotInited = true;
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
postMessage({
|
|
12
|
+
type: 'HmrMessage',
|
|
13
|
+
msg: {
|
|
14
|
+
type: 'hot'
|
|
15
|
+
},
|
|
16
|
+
data: null
|
|
17
|
+
});
|
|
18
|
+
} else if ('errors' === msg.type) postMessage({
|
|
19
|
+
type: 'HmrMessage',
|
|
20
|
+
msg: {
|
|
21
|
+
type: 'errors',
|
|
22
|
+
data: JSON.stringify(msg.data)
|
|
23
|
+
},
|
|
24
|
+
data: null
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function connectDevServer() {
|
|
28
|
+
const sockUrl = getWsPath();
|
|
29
|
+
const sock = new sockjs_client(sockUrl);
|
|
30
|
+
sock.onopen = ()=>console.log("✅ connect DevServer SockJS");
|
|
31
|
+
sock.onmessage = (event)=>{
|
|
32
|
+
try {
|
|
33
|
+
const msg = JSON.parse(event.data);
|
|
34
|
+
console.log("hmr 消息:", msg);
|
|
35
|
+
handleDevServerMessage(msg);
|
|
36
|
+
} catch (err) {
|
|
37
|
+
console.error("解析 hmr 消息失败:", event.data);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return sock;
|
|
41
|
+
}
|
|
42
|
+
'production' !== process.env.NODE_ENV && connectDevServer();
|
|
43
|
+
export { connectDevServer };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect } from "react";
|
|
3
|
+
import { useLocation } from "react-router-dom";
|
|
4
|
+
import { Button } from "antd";
|
|
5
|
+
import { postMessage } from "../../utils/postMessage.js";
|
|
6
|
+
import { copyToClipboard } from "../../utils/copyToClipboard.js";
|
|
7
|
+
const RenderError = (props)=>{
|
|
8
|
+
const { error } = props;
|
|
9
|
+
const location = useLocation();
|
|
10
|
+
const onClickCopy = useCallback(()=>{
|
|
11
|
+
const { message, stack } = error ?? {};
|
|
12
|
+
let result = error;
|
|
13
|
+
if (message && stack) {
|
|
14
|
+
const wrapIndex = stack.indexOf('\n');
|
|
15
|
+
const extraMsg = -1 !== wrapIndex ? stack.slice(0, wrapIndex) : stack;
|
|
16
|
+
result = `${message}
|
|
17
|
+
${extraMsg}`;
|
|
18
|
+
}
|
|
19
|
+
copyToClipboard(result);
|
|
20
|
+
}, [
|
|
21
|
+
error
|
|
22
|
+
]);
|
|
23
|
+
const onClickRepair = useCallback(()=>{
|
|
24
|
+
postMessage({
|
|
25
|
+
type: 'RenderErrorRepair',
|
|
26
|
+
data: props.error
|
|
27
|
+
});
|
|
28
|
+
}, [
|
|
29
|
+
props
|
|
30
|
+
]);
|
|
31
|
+
useEffect(()=>{
|
|
32
|
+
if (props.error) postMessage({
|
|
33
|
+
type: 'RenderError',
|
|
34
|
+
data: props.error,
|
|
35
|
+
location: location
|
|
36
|
+
});
|
|
37
|
+
}, [
|
|
38
|
+
props.error,
|
|
39
|
+
location
|
|
40
|
+
]);
|
|
41
|
+
return /*#__PURE__*/ jsx("div", {
|
|
42
|
+
className: "min-h-screen flex items-center justify-center bg-gray-100",
|
|
43
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
44
|
+
className: "flex flex-col justify-center items-center text-center",
|
|
45
|
+
children: [
|
|
46
|
+
/*#__PURE__*/ jsx("img", {
|
|
47
|
+
src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/ylcylz_fsph_ryhs/ljhwZthlaukjlkulzlp/feisuda/template/render_error.svg",
|
|
48
|
+
alt: "render error",
|
|
49
|
+
className: "mb-4 w-[120px]"
|
|
50
|
+
}),
|
|
51
|
+
/*#__PURE__*/ jsx("p", {
|
|
52
|
+
className: "text-l/[22px] text-[#1F2329] font-medium mb-2",
|
|
53
|
+
children: "哎呀,写错代码了"
|
|
54
|
+
}),
|
|
55
|
+
/*#__PURE__*/ jsx("p", {
|
|
56
|
+
className: "text-sm/[22px] text-[#646A73] font-normal mb-2",
|
|
57
|
+
children: "可复制错误信息,或告诉妙搭进行修复"
|
|
58
|
+
}),
|
|
59
|
+
/*#__PURE__*/ jsxs("div", {
|
|
60
|
+
className: "flex space-x-4",
|
|
61
|
+
children: [
|
|
62
|
+
/*#__PURE__*/ jsx(Button, {
|
|
63
|
+
className: "bg-white text-gray-600 font-[400] border rounded-[6px] shadow-xs hover:bg-gray-100 active:bg-gray-200 focus:outline-hidden h-[32px] border-[#D0D3D6]",
|
|
64
|
+
onClick: onClickCopy,
|
|
65
|
+
children: "复制错误信息"
|
|
66
|
+
}),
|
|
67
|
+
/*#__PURE__*/ jsx(Button, {
|
|
68
|
+
className: "h-[32px] text-sm font-medium text-white bg-blue-600 border border-transparent rounded-[6px] shadow-xs hover:bg-blue-600 active:bg-blue-700 focus:outline-hidden ",
|
|
69
|
+
onClick: onClickRepair,
|
|
70
|
+
children: "告诉妙搭修复"
|
|
71
|
+
})
|
|
72
|
+
]
|
|
73
|
+
})
|
|
74
|
+
]
|
|
75
|
+
})
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
const ErrorRender = RenderError;
|
|
79
|
+
export { ErrorRender as default };
|