@lark-apaas/miaoda-core 0.0.1-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 +40 -0
- package/lib/components/AppContainer/api-proxy/core.d.ts +188 -0
- package/lib/components/AppContainer/api-proxy/core.js +290 -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/api-panel.d.ts +11 -0
- package/lib/components/AppContainer/utils/api-panel.js +21 -0
- package/lib/components/AppContainer/utils/childApi.d.ts +5 -0
- package/lib/components/AppContainer/utils/childApi.js +26 -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 +55 -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 +134 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
async function copyToClipboard(text) {
|
2
|
+
try {
|
3
|
+
if (navigator.clipboard && window.isSecureContext) {
|
4
|
+
await navigator.clipboard.writeText(text);
|
5
|
+
return true;
|
6
|
+
}
|
7
|
+
return fallbackCopyToClipboard(text);
|
8
|
+
} catch (error) {
|
9
|
+
console.error('复制到剪切板失败:', error);
|
10
|
+
return false;
|
11
|
+
}
|
12
|
+
}
|
13
|
+
function fallbackCopyToClipboard(text) {
|
14
|
+
try {
|
15
|
+
const textArea = document.createElement('textarea');
|
16
|
+
textArea.value = text;
|
17
|
+
textArea.style.position = 'fixed';
|
18
|
+
textArea.style.left = '-999999px';
|
19
|
+
textArea.style.top = '-999999px';
|
20
|
+
textArea.setAttribute('readonly', '');
|
21
|
+
document.body.appendChild(textArea);
|
22
|
+
textArea.focus();
|
23
|
+
textArea.select();
|
24
|
+
const successful = document.execCommand('copy');
|
25
|
+
document.body.removeChild(textArea);
|
26
|
+
return successful;
|
27
|
+
} catch (error) {
|
28
|
+
console.error('降级复制方案失败:', error);
|
29
|
+
return false;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
export { copyToClipboard };
|
@@ -0,0 +1,11 @@
|
|
1
|
+
function getAppId(path) {
|
2
|
+
if (window.MIAODA_APP_ID) return window.MIAODA_APP_ID;
|
3
|
+
let prefix;
|
4
|
+
prefix = path.includes('/ai/feida/runtime/') ? '/ai/feida/runtime/' : path.includes('/spark/r/') ? '/spark/r/' : '/ai/miaoda/';
|
5
|
+
if (!path.startsWith(prefix)) return null;
|
6
|
+
const remainder = path.substring(prefix.length);
|
7
|
+
const nextSlashIndex = remainder.indexOf('/');
|
8
|
+
if (-1 === nextSlashIndex) return remainder;
|
9
|
+
return remainder.substring(0, nextSlashIndex);
|
10
|
+
}
|
11
|
+
export { getAppId };
|
@@ -0,0 +1,10 @@
|
|
1
|
+
function getCsrfToken() {
|
2
|
+
const cookieName = 'suda-csrf-token';
|
3
|
+
const cookies = document.cookie.split('; ');
|
4
|
+
for (const cookie of cookies){
|
5
|
+
const [name, value] = cookie.split('=');
|
6
|
+
if (name === cookieName) return decodeURIComponent(value);
|
7
|
+
}
|
8
|
+
return window.csrfToken ?? null;
|
9
|
+
}
|
10
|
+
export { getCsrfToken };
|
@@ -0,0 +1,20 @@
|
|
1
|
+
interface AppRuntimeExtra {
|
2
|
+
token?: string;
|
3
|
+
url?: string;
|
4
|
+
bucket?: BucketConfig;
|
5
|
+
}
|
6
|
+
interface AppRuntimePublished {
|
7
|
+
app_name?: string;
|
8
|
+
css_urls?: string[];
|
9
|
+
js_urls?: string[];
|
10
|
+
app_avatar?: string;
|
11
|
+
}
|
12
|
+
interface BucketConfig {
|
13
|
+
default_bucket_id?: string;
|
14
|
+
}
|
15
|
+
/** 获取应用初始化信息(仅全栈沙箱模式下使用) */
|
16
|
+
export declare function getInitialInfo(): Promise<{
|
17
|
+
app_info?: AppRuntimePublished;
|
18
|
+
app_runtime_extra?: AppRuntimeExtra;
|
19
|
+
}>;
|
20
|
+
export {};
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { getAppId } from "./getAppId.js";
|
2
|
+
import { getCsrfToken } from "./getCsrfToken.js";
|
3
|
+
async function getAppPublished() {
|
4
|
+
try {
|
5
|
+
const headers = {
|
6
|
+
'Content-Type': 'application/json',
|
7
|
+
'X-Kunlun-Token': window.token,
|
8
|
+
'x-miaoda-token': window.MIAODA_BUILTIN_TTT,
|
9
|
+
'X-Suda-Csrf-Token': getCsrfToken()
|
10
|
+
};
|
11
|
+
const appId = getAppId(window.location.pathname) || window.appId;
|
12
|
+
const url = `${window.location.origin}/spark/b/${appId}/get_published`;
|
13
|
+
const response = await fetch(url, {
|
14
|
+
method: 'GET',
|
15
|
+
headers,
|
16
|
+
credentials: 'include'
|
17
|
+
});
|
18
|
+
const res = await response.json();
|
19
|
+
if (0 === res.code) return res.data;
|
20
|
+
console.error('Error fetching published app info:', res);
|
21
|
+
} catch (error) {
|
22
|
+
console.error('Error fetching published app info:', error);
|
23
|
+
}
|
24
|
+
}
|
25
|
+
let initialInfo;
|
26
|
+
async function getInitialInfo() {
|
27
|
+
if (initialInfo) return initialInfo;
|
28
|
+
initialInfo = await getAppPublished();
|
29
|
+
if (initialInfo) window._bucket_id = initialInfo.app_runtime_extra?.bucket?.default_bucket_id;
|
30
|
+
return initialInfo;
|
31
|
+
}
|
32
|
+
export { getInitialInfo };
|
@@ -0,0 +1,7 @@
|
|
1
|
+
function getPreviewParentOrigin() {
|
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';
|
5
|
+
return 'https://miaoda.feishu-boe.cn';
|
6
|
+
}
|
7
|
+
export { getPreviewParentOrigin };
|
@@ -0,0 +1,47 @@
|
|
1
|
+
export interface GetUserProfileRequest {
|
2
|
+
userID?: string;
|
3
|
+
}
|
4
|
+
interface I18nText {
|
5
|
+
text: string;
|
6
|
+
language_code: number;
|
7
|
+
}
|
8
|
+
export interface UserProfile {
|
9
|
+
userID?: string;
|
10
|
+
email?: string;
|
11
|
+
name?: I18nText[];
|
12
|
+
avatar?: string;
|
13
|
+
departmentName?: I18nText[];
|
14
|
+
/**
|
15
|
+
* 1 正常
|
16
|
+
* 2 已暂停
|
17
|
+
*/
|
18
|
+
status?: 1 | 2;
|
19
|
+
feishuOpenID?: string;
|
20
|
+
userType?: string;
|
21
|
+
}
|
22
|
+
export interface GetUserProfileResponse {
|
23
|
+
userProfile?: UserProfile;
|
24
|
+
code?: number;
|
25
|
+
msg?: string;
|
26
|
+
}
|
27
|
+
/**
|
28
|
+
* @internal
|
29
|
+
* 获取用户资料
|
30
|
+
*
|
31
|
+
* 使用示例:
|
32
|
+
* ```typescript
|
33
|
+
* const response = await getUserProfile({
|
34
|
+
* userID: 12345,
|
35
|
+
* });
|
36
|
+
*
|
37
|
+
* if (response.userProfile) {
|
38
|
+
* console.log('User name:', response.userProfile.name);
|
39
|
+
* }
|
40
|
+
* ```
|
41
|
+
*
|
42
|
+
* @param request - 用户资料请求参数
|
43
|
+
* @param headers - 额外的请求头
|
44
|
+
* @returns 用户资料响应
|
45
|
+
*/
|
46
|
+
export declare function getUserProfile(request: GetUserProfileRequest, headers?: Record<string, string>): Promise<any>;
|
47
|
+
export {};
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { getAppId } from "./getAppId.js";
|
2
|
+
import { getCsrfToken } from "./getCsrfToken.js";
|
3
|
+
import { getEnvPath } from "./getEnvPath.js";
|
4
|
+
import { isSparkRuntime } from "./utils.js";
|
5
|
+
async function getUserProfile(request, headers = {}) {
|
6
|
+
const appId = getAppId(window.location.pathname);
|
7
|
+
if (!appId) return {
|
8
|
+
code: 1,
|
9
|
+
msg: 'appId is required',
|
10
|
+
userProfile: {}
|
11
|
+
};
|
12
|
+
const defaultHeaders = {
|
13
|
+
'Content-Type': 'application/json'
|
14
|
+
};
|
15
|
+
const mergedHeaders = {
|
16
|
+
...defaultHeaders,
|
17
|
+
...headers,
|
18
|
+
'X-Kunlun-Token': window.token,
|
19
|
+
'x-miaoda-token': window.MIAODA_BUILTIN_TTT,
|
20
|
+
'x-lgw-csrf-token': window.lgw_csrf_token,
|
21
|
+
...window.CSRF_HEADERS || {}
|
22
|
+
};
|
23
|
+
const envPath = getEnvPath();
|
24
|
+
let endpoint;
|
25
|
+
if (isSparkRuntime()) {
|
26
|
+
endpoint = `/spark/b/${appId}/user/profile`;
|
27
|
+
mergedHeaders['X-Suda-Csrf-Token'] = getCsrfToken();
|
28
|
+
} else endpoint = `/ai/api/${envPath}/v1/apps/${appId}/user/profile`;
|
29
|
+
const response = await fetch(`${window.location.origin}${endpoint}`, {
|
30
|
+
method: 'POST',
|
31
|
+
headers: mergedHeaders,
|
32
|
+
credentials: 'include',
|
33
|
+
body: JSON.stringify({
|
34
|
+
userID: request.userID
|
35
|
+
})
|
36
|
+
});
|
37
|
+
return await response.json();
|
38
|
+
}
|
39
|
+
export { getUserProfile };
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import type { IncomingMessage, OutgoingMessage } from '../types/iframe-events';
|
2
|
+
export declare function postMessage<T extends OutgoingMessage>(message: T, targetOrigin?: string): void;
|
3
|
+
export declare function isOutgoingMessage<T extends OutgoingMessage['type']>(msg: OutgoingMessage, type: T): msg is Extract<OutgoingMessage, {
|
4
|
+
type: T;
|
5
|
+
}>;
|
6
|
+
export declare function isIncomingMessage<T extends IncomingMessage['type']>(msg: IncomingMessage, type: T): msg is Extract<IncomingMessage, {
|
7
|
+
type: T;
|
8
|
+
}>;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { getPreviewParentOrigin } from "./getParentOrigin.js";
|
2
|
+
function postMessage(message, targetOrigin) {
|
3
|
+
window.parent.postMessage(message, targetOrigin ?? getPreviewParentOrigin());
|
4
|
+
}
|
5
|
+
function isOutgoingMessage(msg, type) {
|
6
|
+
return msg.type === type;
|
7
|
+
}
|
8
|
+
function isIncomingMessage(msg, type) {
|
9
|
+
return msg.type === type;
|
10
|
+
}
|
11
|
+
export { isIncomingMessage, isOutgoingMessage, postMessage };
|
package/lib/utils/url.js
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
import { logger } from "../logger/index.js";
|
2
|
+
function splitWorkspaceUrl(fullUrl) {
|
3
|
+
try {
|
4
|
+
const url = new URL(fullUrl);
|
5
|
+
const pathParts = url.pathname.split('/');
|
6
|
+
const workspacesIndex = pathParts.findIndex((part)=>'workspaces' === part);
|
7
|
+
if (-1 === workspacesIndex) throw new Error('Invalid workspace URL format');
|
8
|
+
const basePathParts = pathParts.slice(0, workspacesIndex);
|
9
|
+
const workspace = pathParts[workspacesIndex + 1];
|
10
|
+
return {
|
11
|
+
baseUrl: `${url.origin}${basePathParts.join('/')}`,
|
12
|
+
workspace
|
13
|
+
};
|
14
|
+
} catch (error) {
|
15
|
+
logger.error('Error splitting workspace URL:', error);
|
16
|
+
}
|
17
|
+
return {
|
18
|
+
baseUrl: fullUrl,
|
19
|
+
workspace: 'workspace'
|
20
|
+
};
|
21
|
+
}
|
22
|
+
export { splitWorkspaceUrl };
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { type ClassValue } from 'clsx';
|
2
|
+
/**
|
3
|
+
* @internal
|
4
|
+
* 处理 className 与 tailwind-merge
|
5
|
+
*/
|
6
|
+
export declare function clsxWithTw(...inputs: ClassValue[]): string;
|
7
|
+
/**
|
8
|
+
* @internal
|
9
|
+
* 当前是否是预览态
|
10
|
+
*/
|
11
|
+
export declare function isPreview(): boolean;
|
12
|
+
/**
|
13
|
+
* @internal
|
14
|
+
* 标准化基础路径,确保路径格式一致
|
15
|
+
* 移除末尾的斜杠,确保路径不以斜杠结尾
|
16
|
+
*/
|
17
|
+
export declare function normalizeBasePath(basePath?: string): string;
|
18
|
+
export declare function getWsPath(): string;
|
19
|
+
/** 判断是否是沙箱模式 */
|
20
|
+
export declare function isSparkRuntime(): boolean;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { clsx } from "clsx";
|
2
|
+
import { twMerge } from "tailwind-merge";
|
3
|
+
function clsxWithTw(...inputs) {
|
4
|
+
return twMerge(clsx(inputs));
|
5
|
+
}
|
6
|
+
function isPreview() {
|
7
|
+
return window.IS_MIAODA_PREVIEW;
|
8
|
+
}
|
9
|
+
function normalizeBasePath(basePath) {
|
10
|
+
if (!basePath || '/' === basePath) return '';
|
11
|
+
return basePath.replace(/\/+$/, '');
|
12
|
+
}
|
13
|
+
function getWsPath() {
|
14
|
+
const rawBasePath = process.env.CLIENT_BASE_PATH || '/';
|
15
|
+
const normalizedBasePath = rawBasePath.startsWith('/') ? rawBasePath : `/${rawBasePath}`;
|
16
|
+
const basePathWithoutTrailingSlash = normalizedBasePath.endsWith('/') ? normalizedBasePath.slice(0, -1) : normalizedBasePath;
|
17
|
+
return `${basePathWithoutTrailingSlash}/ws`;
|
18
|
+
}
|
19
|
+
function isSparkRuntime() {
|
20
|
+
return window._IS_Spark_RUNTIME ?? 'fullstack' === process.env.runtimeMode;
|
21
|
+
}
|
22
|
+
export { clsxWithTw, getWsPath, isPreview, isSparkRuntime, normalizeBasePath };
|
package/package.json
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
{
|
2
|
+
"name": "@lark-apaas/miaoda-core",
|
3
|
+
"version": "0.0.1-alpha.1",
|
4
|
+
"types": "./lib/index.d.ts",
|
5
|
+
"main": "./lib/index.js",
|
6
|
+
"files": [
|
7
|
+
"lib"
|
8
|
+
],
|
9
|
+
"publishConfig": {
|
10
|
+
"access": "public"
|
11
|
+
},
|
12
|
+
"exports": {
|
13
|
+
".": {
|
14
|
+
"import": "./lib/index.js",
|
15
|
+
"require": "./lib/index.js",
|
16
|
+
"types": "./lib/index.d.ts"
|
17
|
+
},
|
18
|
+
"./lib/index.css": "./lib/index.css",
|
19
|
+
"./dataloom": {
|
20
|
+
"import": "./lib/apis/dataloom.js",
|
21
|
+
"require": "./lib/apis/dataloom.js",
|
22
|
+
"types": "./lib/apis/dataloom.d.ts"
|
23
|
+
},
|
24
|
+
"./logger": {
|
25
|
+
"import": "./lib/apis/logger.js",
|
26
|
+
"require": "./lib/apis/logger.js",
|
27
|
+
"types": "./lib/apis/logger.d.ts"
|
28
|
+
},
|
29
|
+
"./udt-types": {
|
30
|
+
"import": "./lib/apis/udt-types.js",
|
31
|
+
"require": "./lib/apis/udt-types.js",
|
32
|
+
"types": "./lib/apis/udt-types.d.ts"
|
33
|
+
},
|
34
|
+
"./components/*": {
|
35
|
+
"import": "./lib/apis/components/*.js",
|
36
|
+
"require": "./lib/apis/components/*.js",
|
37
|
+
"types": "./lib/apis/components/*.d.ts"
|
38
|
+
},
|
39
|
+
"./constants/*": {
|
40
|
+
"import": "./lib/apis/constants/**/*.js",
|
41
|
+
"require": "./lib/apis/constants/**/*.js",
|
42
|
+
"types": "./lib/apis/constants/**/*.d.ts"
|
43
|
+
},
|
44
|
+
"./hooks/*": {
|
45
|
+
"import": "./lib/apis/hooks/*.js",
|
46
|
+
"require": "./lib/apis/hooks/*.js",
|
47
|
+
"types": "./lib/apis/hooks/*.d.ts"
|
48
|
+
},
|
49
|
+
"./tools/*": {
|
50
|
+
"import": "./lib/apis/tools/*.js",
|
51
|
+
"require": "./lib/apis/tools/*.js",
|
52
|
+
"types": "./lib/apis/tools/*.d.ts"
|
53
|
+
},
|
54
|
+
"./utils/*": {
|
55
|
+
"import": "./lib/apis/utils/*.js",
|
56
|
+
"require": "./lib/apis/utils/*.js",
|
57
|
+
"types": "./lib/apis/utils/*.d.ts"
|
58
|
+
}
|
59
|
+
},
|
60
|
+
"scripts": {
|
61
|
+
"tsc": "tsc --declaration",
|
62
|
+
"build": "rslib build",
|
63
|
+
"build:storybook": "storybook build",
|
64
|
+
"bump": "changeset version",
|
65
|
+
"change": "changeset",
|
66
|
+
"check": "biome check --write",
|
67
|
+
"dev": "rslib build --watch",
|
68
|
+
"format": "biome format --write",
|
69
|
+
"storybook": "storybook dev",
|
70
|
+
"test": "echo 0",
|
71
|
+
"lint": "eslint src --ext .js,.jsx,.ts,.tsx",
|
72
|
+
"lint:fix": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
|
73
|
+
"prepublishOnly": "npm run build && node scripts/replace-workspace-alias.js"
|
74
|
+
},
|
75
|
+
"dependencies": {
|
76
|
+
"@ant-design/colors": "^7.2.1",
|
77
|
+
"@ant-design/cssinjs": "^1.24.0",
|
78
|
+
"@data-loom/js": "0.3.1",
|
79
|
+
"@lark-apaas/miaoda-inspector": "0.1.0-alpha.8",
|
80
|
+
"clsx": "~2.0.1",
|
81
|
+
"dayjs": "^1.11.13",
|
82
|
+
"echarts": "^6.0.0",
|
83
|
+
"html2canvas-pro": "^1.5.11",
|
84
|
+
"lodash": "^4.17.21",
|
85
|
+
"penpal": "^6.2.2",
|
86
|
+
"sockjs-client": "^1.6.1",
|
87
|
+
"sonner": "~2.0.0",
|
88
|
+
"tailwind-merge": "~2.0.0",
|
89
|
+
"tailwind-variants": "0.3.1",
|
90
|
+
"tailwindcss-animate": "^1.0.7"
|
91
|
+
},
|
92
|
+
"devDependencies": {
|
93
|
+
"@biomejs/biome": "2.0.6",
|
94
|
+
"@changesets/cli": "^2.29.5",
|
95
|
+
"@rsbuild/core": "~1.4.13",
|
96
|
+
"@rsbuild/plugin-react": "^1.3.4",
|
97
|
+
"@rslib/core": "^0.15.0",
|
98
|
+
"@storybook/addon-essentials": "^8.6.14",
|
99
|
+
"@storybook/addon-interactions": "^8.6.14",
|
100
|
+
"@storybook/addon-links": "^8.6.14",
|
101
|
+
"@storybook/addon-onboarding": "^8.6.14",
|
102
|
+
"@storybook/blocks": "^8.6.14",
|
103
|
+
"@storybook/react": "^8.6.14",
|
104
|
+
"@storybook/test": "^8.6.14",
|
105
|
+
"@testing-library/jest-dom": "^6.6.4",
|
106
|
+
"@testing-library/react": "^16.3.0",
|
107
|
+
"@types/lodash": "^4.17.20",
|
108
|
+
"@types/node": "^22.10.2",
|
109
|
+
"@types/react": "^18.3.23",
|
110
|
+
"@types/react-dom": "^18.3.7",
|
111
|
+
"@types/sockjs-client": "^1",
|
112
|
+
"antd": "^5.26.6",
|
113
|
+
"eslint": "^8.57.0",
|
114
|
+
"jsdom": "^26.1.0",
|
115
|
+
"lucide-react": "npm:@lark-apaas/lucide-react@0.1.0-alpha.5",
|
116
|
+
"react": "^18.3.1",
|
117
|
+
"react-dom": "^18.3.1",
|
118
|
+
"react-router-dom": "^6.26.2",
|
119
|
+
"storybook": "^8.6.14",
|
120
|
+
"storybook-addon-rslib": "^1.0.2",
|
121
|
+
"storybook-react-rsbuild": "^1.0.2",
|
122
|
+
"tailwindcss": "^4.1.13",
|
123
|
+
"tsc-watch": "^7.1.1",
|
124
|
+
"typescript": "^5.9.2",
|
125
|
+
"typescript-eslint": "^8.41.0",
|
126
|
+
"vitest": "^3.2.4"
|
127
|
+
},
|
128
|
+
"peerDependencies": {
|
129
|
+
"antd": ">=5.26.6",
|
130
|
+
"react": ">=16.14.0",
|
131
|
+
"react-dom": ">=16.14.0",
|
132
|
+
"react-router-dom": ">=6.26.2"
|
133
|
+
}
|
134
|
+
}
|