@lark-apaas/miaoda-core 0.1.0-alpha.13 → 0.1.0-alpha.15
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/apis/dataloom.d.ts +1 -1
- package/lib/apis/dataloom.js +2 -2
- package/lib/apis/hooks/useAppInfo.d.ts +1 -0
- package/lib/apis/hooks/useAppInfo.js +1 -0
- package/lib/apis/utils/registerChinaMap.js +34 -34
- package/lib/components/AppContainer/IframeBridge.js +62 -96
- package/lib/components/AppContainer/PageHoc.js +1 -1
- package/lib/components/AppContainer/childApi.d.ts +5 -0
- package/lib/components/AppContainer/childApi.js +20 -0
- package/lib/components/AppContainer/index.js +1 -1
- package/lib/components/ErrorRender/index.js +4 -4
- package/lib/components/NotFoundRender/index.js +3 -3
- package/lib/components/TopNav/BottomNav.js +1 -1
- package/lib/components/TopNav/TitleBar.js +9 -6
- package/lib/components/TopNav/TopNav.js +3 -3
- package/lib/components/User/UserDisplay.d.ts +1 -1
- package/lib/components/User/UserProfile/UserProfileUI.js +4 -4
- package/lib/components/User/UserProfile/utils.js +1 -1
- package/lib/components/User/UserSelect.js +3 -2
- package/lib/components/User/UserWithAvatar.js +1 -1
- package/lib/components/Welcome/index.js +3 -3
- package/lib/components/common/LogoInfo.js +3 -3
- package/lib/components/common/NavItem.js +1 -1
- package/lib/components/common/UserAvatarMenu.js +1 -1
- package/lib/components/theme/ThemeProvider.d.ts +2 -2
- package/lib/components/theme/ThemeProvider.js +3 -3
- package/lib/components/theme/constants.d.ts +1 -1
- package/lib/components/theme/constants.js +5 -4
- package/lib/components/theme/ui-config.d.ts +1 -49
- package/lib/components/theme/ui-config.js +1 -757
- package/lib/components/theme/util.d.ts +3 -3
- package/lib/components/theme/util.js +4 -4
- package/lib/hooks/index.d.ts +1 -1
- package/lib/hooks/index.js +1 -1
- package/lib/hooks/{useCurrentAppInfo.d.ts → useAppInfo.d.ts} +1 -1
- package/lib/hooks/{useCurrentAppInfo.js → useAppInfo.js} +6 -5
- package/lib/hooks/useCurrentUserProfile.js +34 -2
- package/lib/hooks/useLogout.js +16 -2
- package/lib/hooks/useTheme.js +1 -1
- package/lib/index.css +1 -0
- package/lib/inspector.dev.css +10 -0
- package/lib/integrations/dataloom.d.ts +2 -1
- package/lib/integrations/dataloom.js +22 -8
- package/lib/integrations/generateImage.js +15 -0
- package/lib/integrations/generateTextStream.d.ts +0 -5
- package/lib/integrations/generateTextStream.js +28 -13
- package/lib/integrations/getAppInfo.d.ts +1 -1
- package/lib/integrations/getAppInfo.js +12 -2
- package/lib/tailwind-theme.css +1 -101
- package/lib/theme-layer.css +3 -0
- package/lib/types/common.d.ts +0 -7
- package/lib/types/iframe-events.d.ts +9 -1
- package/lib/types/index.d.ts +2 -0
- package/lib/utils/copyToClipboard.js +2 -2
- package/lib/utils/getAppId.d.ts +1 -6
- package/lib/utils/getAppId.js +4 -2
- package/lib/utils/getCsrfToken.d.ts +5 -0
- package/lib/utils/getCsrfToken.js +10 -0
- package/lib/utils/getInitialInfo.d.ts +20 -0
- package/lib/utils/getInitialInfo.js +32 -0
- package/lib/utils/getParentOrigin.js +2 -2
- package/lib/utils/getUserProfile.js +7 -1
- package/lib/utils/utils.d.ts +2 -0
- package/lib/utils/utils.js +4 -1
- package/package.json +22 -20
- package/lib/apis/hooks/useCurrentAppInfo.d.ts +0 -1
- package/lib/apis/hooks/useCurrentAppInfo.js +0 -1
|
@@ -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 };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function getPreviewParentOrigin() {
|
|
2
2
|
const { origin } = window.location;
|
|
3
|
-
if (origin.includes('feishuapp.
|
|
4
|
-
if (origin.includes('
|
|
3
|
+
if (origin.includes('miaoda.feishuapp.net')) return 'https://miaoda.feishu.cn';
|
|
4
|
+
if (origin.includes('miaoda-pre.feishuapp.net')) return 'https://miaoda.feishu-pre.cn';
|
|
5
5
|
return 'https://miaoda.feishu-boe.cn';
|
|
6
6
|
}
|
|
7
7
|
export { getPreviewParentOrigin };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { getAppId } from "./getAppId.js";
|
|
2
|
+
import { getCsrfToken } from "./getCsrfToken.js";
|
|
2
3
|
import { getEnvPath } from "./getEnvPath.js";
|
|
4
|
+
import { isSanboxMode } from "./utils.js";
|
|
3
5
|
async function getUserProfile(request, headers = {}) {
|
|
4
6
|
const appId = getAppId(window.location.pathname);
|
|
5
7
|
if (!appId) return {
|
|
@@ -19,7 +21,11 @@ async function getUserProfile(request, headers = {}) {
|
|
|
19
21
|
...window.CSRF_HEADERS || {}
|
|
20
22
|
};
|
|
21
23
|
const envPath = getEnvPath();
|
|
22
|
-
|
|
24
|
+
let endpoint;
|
|
25
|
+
if (isSanboxMode()) {
|
|
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`;
|
|
23
29
|
const response = await fetch(`${window.location.origin}${endpoint}`, {
|
|
24
30
|
method: 'POST',
|
|
25
31
|
headers: mergedHeaders,
|
package/lib/utils/utils.d.ts
CHANGED
package/lib/utils/utils.js
CHANGED
|
@@ -10,4 +10,7 @@ function normalizeBasePath(basePath) {
|
|
|
10
10
|
if (!basePath || '/' === basePath) return '';
|
|
11
11
|
return basePath.replace(/\/+$/, '');
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
function isSanboxMode() {
|
|
14
|
+
return window._IS_Spark_RUNTIME || window.isSanboxMode;
|
|
15
|
+
}
|
|
16
|
+
export { clsxWithTw, isPreview, isSanboxMode, normalizeBasePath };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/miaoda-core",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.15",
|
|
4
4
|
"types": "./lib/index.d.ts",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -57,20 +57,36 @@
|
|
|
57
57
|
"types": "./lib/apis/utils/*.d.ts"
|
|
58
58
|
}
|
|
59
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
|
+
},
|
|
60
75
|
"dependencies": {
|
|
61
76
|
"@ant-design/colors": "^7.2.1",
|
|
62
77
|
"@ant-design/cssinjs": "^1.24.0",
|
|
63
|
-
"@data-loom/js": "0.
|
|
78
|
+
"@data-loom/js": "0.3.1",
|
|
79
|
+
"@lark-apaas/miaoda-inspector": "workspace:*",
|
|
64
80
|
"clsx": "~2.0.1",
|
|
65
81
|
"dayjs": "^1.11.13",
|
|
66
82
|
"echarts": "^6.0.0",
|
|
67
83
|
"html2canvas-pro": "^1.5.11",
|
|
68
84
|
"lodash": "^4.17.21",
|
|
85
|
+
"penpal": "^6.2.2",
|
|
69
86
|
"sonner": "~2.0.0",
|
|
70
87
|
"tailwind-merge": "~2.0.0",
|
|
71
88
|
"tailwind-variants": "0.3.1",
|
|
72
|
-
"tailwindcss-animate": "^1.0.7"
|
|
73
|
-
"@lark-apaas/miaoda-inspector": "0.1.0-alpha.5"
|
|
89
|
+
"tailwindcss-animate": "^1.0.7"
|
|
74
90
|
},
|
|
75
91
|
"devDependencies": {
|
|
76
92
|
"@biomejs/biome": "2.0.6",
|
|
@@ -91,7 +107,6 @@
|
|
|
91
107
|
"@types/node": "^22.10.2",
|
|
92
108
|
"@types/react": "^18.3.23",
|
|
93
109
|
"@types/react-dom": "^18.3.7",
|
|
94
|
-
"typescript-eslint": "^8.41.0",
|
|
95
110
|
"antd": "^5.26.6",
|
|
96
111
|
"eslint": "^8.57.0",
|
|
97
112
|
"jsdom": "^26.1.0",
|
|
@@ -105,6 +120,7 @@
|
|
|
105
120
|
"tailwindcss": "^4.1.13",
|
|
106
121
|
"tsc-watch": "^7.1.1",
|
|
107
122
|
"typescript": "^5.9.2",
|
|
123
|
+
"typescript-eslint": "^8.41.0",
|
|
108
124
|
"vitest": "^3.2.4"
|
|
109
125
|
},
|
|
110
126
|
"peerDependencies": {
|
|
@@ -112,19 +128,5 @@
|
|
|
112
128
|
"react": ">=16.14.0",
|
|
113
129
|
"react-dom": ">=16.14.0",
|
|
114
130
|
"react-router-dom": ">=6.26.2"
|
|
115
|
-
},
|
|
116
|
-
"scripts": {
|
|
117
|
-
"tsc": "tsc --declaration",
|
|
118
|
-
"build": "rslib build",
|
|
119
|
-
"build:storybook": "storybook build",
|
|
120
|
-
"bump": "changeset version",
|
|
121
|
-
"change": "changeset",
|
|
122
|
-
"check": "biome check --write",
|
|
123
|
-
"dev": "rslib build --watch",
|
|
124
|
-
"format": "biome format --write",
|
|
125
|
-
"storybook": "storybook dev",
|
|
126
|
-
"test": "echo 0",
|
|
127
|
-
"lint": "eslint src --ext .js,.jsx,.ts,.tsx",
|
|
128
|
-
"lint:fix": "eslint src --ext .js,.jsx,.ts,.tsx --fix"
|
|
129
131
|
}
|
|
130
|
-
}
|
|
132
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../../hooks/useCurrentAppInfo';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../../hooks/useCurrentAppInfo.js";
|