@lark-apaas/miaoda-core 0.1.0-alpha.2 → 0.1.0-alpha.21

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.
Files changed (70) hide show
  1. package/lib/apis/dataloom.d.ts +1 -1
  2. package/lib/apis/dataloom.js +2 -2
  3. package/lib/apis/hooks/useAppInfo.d.ts +1 -0
  4. package/lib/apis/hooks/useAppInfo.js +1 -0
  5. package/lib/components/AppContainer/IframeBridge.d.ts +1 -0
  6. package/lib/components/AppContainer/IframeBridge.js +31 -18
  7. package/lib/components/AppContainer/LogInterceptor.d.ts +1 -0
  8. package/lib/components/AppContainer/LogInterceptor.js +44 -0
  9. package/lib/components/AppContainer/PageHoc.js +28 -8
  10. package/lib/components/AppContainer/childApi.d.ts +5 -0
  11. package/lib/components/AppContainer/childApi.js +20 -0
  12. package/lib/components/AppContainer/index.js +1 -1
  13. package/lib/components/ErrorRender/index.js +5 -5
  14. package/lib/components/NotFoundRender/index.js +3 -3
  15. package/lib/components/SidebarNav/DrawerNav.d.ts +1 -1
  16. package/lib/components/SidebarNav/DropdownNav.d.ts +1 -1
  17. package/lib/components/SidebarNav/Sidebar.d.ts +1 -1
  18. package/lib/components/TopNav/BottomNav.d.ts +1 -1
  19. package/lib/components/TopNav/TitleBar.js +6 -3
  20. package/lib/components/TopNav/TopNav.d.ts +1 -1
  21. package/lib/components/TopNav/TopNav.js +2 -2
  22. package/lib/components/User/UserDisplay.d.ts +1 -1
  23. package/lib/components/User/UserSelect.js +2 -1
  24. package/lib/components/User/UserWithAvatar.d.ts +1 -1
  25. package/lib/components/common/LogoInfo.js +2 -2
  26. package/lib/components/common/UserAvatarLayout.d.ts +1 -1
  27. package/lib/components/theme/ThemeProvider.d.ts +2 -2
  28. package/lib/components/theme/ThemeProvider.js +3 -3
  29. package/lib/components/theme/constants.d.ts +1 -1
  30. package/lib/components/theme/constants.js +2 -1
  31. package/lib/components/theme/ui-config.d.ts +1 -49
  32. package/lib/components/theme/ui-config.js +1 -757
  33. package/lib/components/theme/util.d.ts +3 -3
  34. package/lib/components/theme/util.js +2 -2
  35. package/lib/hooks/index.d.ts +1 -1
  36. package/lib/hooks/index.js +1 -1
  37. package/lib/hooks/{useCurrentAppInfo.d.ts → useAppInfo.d.ts} +1 -1
  38. package/lib/hooks/{useCurrentAppInfo.js → useAppInfo.js} +6 -5
  39. package/lib/hooks/useCurrentUserProfile.js +34 -2
  40. package/lib/hooks/useLogout.js +14 -0
  41. package/lib/index.css +1 -0
  42. package/lib/inspector.dev.css +10 -0
  43. package/lib/integrations/dataloom.d.ts +2 -1
  44. package/lib/integrations/dataloom.js +22 -8
  45. package/lib/integrations/generateImage.js +17 -2
  46. package/lib/integrations/generateTextStream.d.ts +0 -5
  47. package/lib/integrations/generateTextStream.js +24 -9
  48. package/lib/integrations/getAppInfo.d.ts +1 -1
  49. package/lib/integrations/getAppInfo.js +12 -2
  50. package/lib/tailwind-theme.css +1 -101
  51. package/lib/theme-layer.css +3 -0
  52. package/lib/types/common.d.ts +0 -7
  53. package/lib/types/iframe-events.d.ts +45 -0
  54. package/lib/types/iframe-events.js +0 -0
  55. package/lib/types/index.d.ts +3 -0
  56. package/lib/utils/getAppId.d.ts +1 -6
  57. package/lib/utils/getAppId.js +4 -2
  58. package/lib/utils/getCsrfToken.d.ts +5 -0
  59. package/lib/utils/getCsrfToken.js +10 -0
  60. package/lib/utils/getInitialInfo.d.ts +20 -0
  61. package/lib/utils/getInitialInfo.js +32 -0
  62. package/lib/utils/getParentOrigin.js +2 -2
  63. package/lib/utils/getUserProfile.js +7 -1
  64. package/lib/utils/postMessage.d.ts +8 -0
  65. package/lib/utils/postMessage.js +11 -0
  66. package/lib/utils/utils.d.ts +8 -0
  67. package/lib/utils/utils.js +8 -1
  68. package/package.json +9 -7
  69. package/lib/apis/hooks/useCurrentAppInfo.d.ts +0 -1
  70. package/lib/apis/hooks/useCurrentAppInfo.js +0 -1
@@ -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 { isSparkRuntime } 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
- const endpoint = `/ai/api/${envPath}/v1/apps/${appId}/user/profile`;
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`;
23
29
  const response = await fetch(`${window.location.origin}${endpoint}`, {
24
30
  method: 'POST',
25
31
  headers: mergedHeaders,
@@ -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 };
@@ -9,3 +9,11 @@ export declare function clsxWithTw(...inputs: ClassValue[]): string;
9
9
  * 当前是否是预览态
10
10
  */
11
11
  export declare function isPreview(): boolean;
12
+ /**
13
+ * @internal
14
+ * 标准化基础路径,确保路径格式一致
15
+ * 移除末尾的斜杠,确保路径不以斜杠结尾
16
+ */
17
+ export declare function normalizeBasePath(basePath?: string): string;
18
+ /** 判断是否是沙箱模式 */
19
+ export declare function isSparkRuntime(): boolean;
@@ -6,4 +6,11 @@ function clsxWithTw(...inputs) {
6
6
  function isPreview() {
7
7
  return window.IS_MIAODA_PREVIEW;
8
8
  }
9
- export { clsxWithTw, isPreview };
9
+ function normalizeBasePath(basePath) {
10
+ if (!basePath || '/' === basePath) return '';
11
+ return basePath.replace(/\/+$/, '');
12
+ }
13
+ function isSparkRuntime() {
14
+ return window._IS_Spark_RUNTIME ?? 'true' === process.env.fullstack;
15
+ }
16
+ export { clsxWithTw, isPreview, isSparkRuntime, normalizeBasePath };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/miaoda-core",
3
- "version": "0.1.0-alpha.2",
3
+ "version": "0.1.0-alpha.21",
4
4
  "types": "./lib/index.d.ts",
5
5
  "main": "./lib/index.js",
6
6
  "files": [
@@ -15,6 +15,7 @@
15
15
  "require": "./lib/index.js",
16
16
  "types": "./lib/index.d.ts"
17
17
  },
18
+ "./lib/index.css": "./lib/index.css",
18
19
  "./dataloom": {
19
20
  "import": "./lib/apis/dataloom.js",
20
21
  "require": "./lib/apis/dataloom.js",
@@ -69,18 +70,19 @@
69
70
  "test": "echo 0",
70
71
  "lint": "eslint src --ext .js,.jsx,.ts,.tsx",
71
72
  "lint:fix": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
72
- "prepublishOnly": "npm run build"
73
+ "prepublishOnly": "npm run build && node scripts/replace-workspace-alias.js"
73
74
  },
74
75
  "dependencies": {
75
76
  "@ant-design/colors": "^7.2.1",
76
77
  "@ant-design/cssinjs": "^1.24.0",
77
- "@lark-apaas/miaoda-inspector": "0.1.0-alpha.1",
78
- "@data-loom/js": "0.2.3",
78
+ "@data-loom/js": "0.3.1",
79
+ "@lark-apaas/miaoda-inspector": "0.1.0-alpha.7",
79
80
  "clsx": "~2.0.1",
80
81
  "dayjs": "^1.11.13",
81
82
  "echarts": "^6.0.0",
82
83
  "html2canvas-pro": "^1.5.11",
83
84
  "lodash": "^4.17.21",
85
+ "penpal": "^6.2.2",
84
86
  "sonner": "~2.0.0",
85
87
  "tailwind-merge": "~2.0.0",
86
88
  "tailwind-variants": "0.3.1",
@@ -91,7 +93,7 @@
91
93
  "@changesets/cli": "^2.29.5",
92
94
  "@rsbuild/core": "~1.4.13",
93
95
  "@rsbuild/plugin-react": "^1.3.4",
94
- "@rslib/core": "^0.12.0",
96
+ "@rslib/core": "^0.15.0",
95
97
  "@storybook/addon-essentials": "^8.6.14",
96
98
  "@storybook/addon-interactions": "^8.6.14",
97
99
  "@storybook/addon-links": "^8.6.14",
@@ -108,7 +110,7 @@
108
110
  "antd": "^5.26.6",
109
111
  "eslint": "^8.57.0",
110
112
  "jsdom": "^26.1.0",
111
- "lucide-react": "^0.541.0",
113
+ "lucide-react": "npm:@lark-apaas/lucide-react@0.1.0-alpha.5",
112
114
  "react": "^18.3.1",
113
115
  "react-dom": "^18.3.1",
114
116
  "react-router-dom": "^6.26.2",
@@ -118,11 +120,11 @@
118
120
  "tailwindcss": "^4.1.13",
119
121
  "tsc-watch": "^7.1.1",
120
122
  "typescript": "^5.9.2",
123
+ "typescript-eslint": "^8.41.0",
121
124
  "vitest": "^3.2.4"
122
125
  },
123
126
  "peerDependencies": {
124
127
  "antd": ">=5.26.6",
125
- "lucide-react": "^0.541.0",
126
128
  "react": ">=16.14.0",
127
129
  "react-dom": ">=16.14.0",
128
130
  "react-router-dom": ">=6.26.2"
@@ -1 +0,0 @@
1
- export * from '../../hooks/useCurrentAppInfo';
@@ -1 +0,0 @@
1
- export * from "../../hooks/useCurrentAppInfo.js";