@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.
Files changed (192) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +8 -0
  3. package/lib/apis/components/AppContainer.d.ts +1 -0
  4. package/lib/apis/components/AppContainer.js +2 -0
  5. package/lib/apis/components/ErrorRender.d.ts +1 -0
  6. package/lib/apis/components/ErrorRender.js +2 -0
  7. package/lib/apis/components/NotFoundRender.d.ts +1 -0
  8. package/lib/apis/components/NotFoundRender.js +2 -0
  9. package/lib/apis/components/SidebarNav.d.ts +1 -0
  10. package/lib/apis/components/SidebarNav.js +2 -0
  11. package/lib/apis/components/User.d.ts +1 -0
  12. package/lib/apis/components/User.js +1 -0
  13. package/lib/apis/components/Welcome.d.ts +1 -0
  14. package/lib/apis/components/Welcome.js +2 -0
  15. package/lib/apis/constants/img-resources/avatar.d.ts +11 -0
  16. package/lib/apis/constants/img-resources/avatar.js +12 -0
  17. package/lib/apis/constants/img-resources/banner.d.ts +24 -0
  18. package/lib/apis/constants/img-resources/banner.js +25 -0
  19. package/lib/apis/constants/img-resources/cover.d.ts +36 -0
  20. package/lib/apis/constants/img-resources/cover.js +37 -0
  21. package/lib/apis/dataloom.d.ts +1 -0
  22. package/lib/apis/dataloom.js +2 -0
  23. package/lib/apis/hooks/useAppInfo.d.ts +1 -0
  24. package/lib/apis/hooks/useAppInfo.js +1 -0
  25. package/lib/apis/hooks/useCurrentUserProfile.d.ts +1 -0
  26. package/lib/apis/hooks/useCurrentUserProfile.js +1 -0
  27. package/lib/apis/logger.d.ts +1 -0
  28. package/lib/apis/logger.js +1 -0
  29. package/lib/apis/tools/generateImage.d.ts +1 -0
  30. package/lib/apis/tools/generateImage.js +1 -0
  31. package/lib/apis/tools/generateTextStream.d.ts +1 -0
  32. package/lib/apis/tools/generateTextStream.js +1 -0
  33. package/lib/apis/tools/getAppInfo.d.ts +1 -0
  34. package/lib/apis/tools/getAppInfo.js +1 -0
  35. package/lib/apis/tools/getCurrentUserProfile.d.ts +1 -0
  36. package/lib/apis/tools/getCurrentUserProfile.js +1 -0
  37. package/lib/apis/tools/storage.d.ts +1 -0
  38. package/lib/apis/tools/storage.js +4 -0
  39. package/lib/apis/udt-types.d.ts +16 -0
  40. package/lib/apis/udt-types.js +0 -0
  41. package/lib/apis/utils/registerChinaMap.d.ts +1 -0
  42. package/lib/apis/utils/registerChinaMap.js +103319 -0
  43. package/lib/components/AppContainer/IframeBridge.d.ts +4 -0
  44. package/lib/components/AppContainer/IframeBridge.js +92 -0
  45. package/lib/components/AppContainer/LogInterceptor.d.ts +1 -0
  46. package/lib/components/AppContainer/LogInterceptor.js +44 -0
  47. package/lib/components/AppContainer/PageHoc.d.ts +4 -0
  48. package/lib/components/AppContainer/PageHoc.js +40 -0
  49. package/lib/components/AppContainer/api-proxy/core.d.ts +188 -0
  50. package/lib/components/AppContainer/api-proxy/core.js +290 -0
  51. package/lib/components/AppContainer/dayjsPlugins.d.ts +1 -0
  52. package/lib/components/AppContainer/dayjsPlugins.js +69 -0
  53. package/lib/components/AppContainer/index.d.ts +7 -0
  54. package/lib/components/AppContainer/index.js +65 -0
  55. package/lib/components/AppContainer/sonner.css +101 -0
  56. package/lib/components/AppContainer/sonner.d.ts +8 -0
  57. package/lib/components/AppContainer/sonner.js +26 -0
  58. package/lib/components/AppContainer/utils/api-panel.d.ts +11 -0
  59. package/lib/components/AppContainer/utils/api-panel.js +21 -0
  60. package/lib/components/AppContainer/utils/childApi.d.ts +5 -0
  61. package/lib/components/AppContainer/utils/childApi.js +26 -0
  62. package/lib/components/AppContainer/utils/listenHot.d.ts +1 -0
  63. package/lib/components/AppContainer/utils/listenHot.js +43 -0
  64. package/lib/components/ErrorRender/index.d.ts +5 -0
  65. package/lib/components/ErrorRender/index.js +79 -0
  66. package/lib/components/NotFoundRender/index.d.ts +3 -0
  67. package/lib/components/NotFoundRender/index.js +59 -0
  68. package/lib/components/SidebarNav/DrawerNav.d.ts +3 -0
  69. package/lib/components/SidebarNav/DrawerNav.js +64 -0
  70. package/lib/components/SidebarNav/DropdownNav.d.ts +3 -0
  71. package/lib/components/SidebarNav/DropdownNav.js +40 -0
  72. package/lib/components/SidebarNav/Sidebar.d.ts +3 -0
  73. package/lib/components/SidebarNav/Sidebar.js +33 -0
  74. package/lib/components/SidebarNav/index.d.ts +5 -0
  75. package/lib/components/SidebarNav/index.js +61 -0
  76. package/lib/components/User/UserDisplay.d.ts +9 -0
  77. package/lib/components/User/UserDisplay.js +39 -0
  78. package/lib/components/User/UserProfile/UserProfile.css +34 -0
  79. package/lib/components/User/UserProfile/UserProfile.d.ts +6 -0
  80. package/lib/components/User/UserProfile/UserProfile.js +41 -0
  81. package/lib/components/User/UserProfile/UserProfileContainer.d.ts +4 -0
  82. package/lib/components/User/UserProfile/UserProfileContainer.js +8 -0
  83. package/lib/components/User/UserProfile/UserProfileSkeleton.d.ts +3 -0
  84. package/lib/components/User/UserProfile/UserProfileSkeleton.js +36 -0
  85. package/lib/components/User/UserProfile/UserProfileUI.d.ts +8 -0
  86. package/lib/components/User/UserProfile/UserProfileUI.js +113 -0
  87. package/lib/components/User/UserProfile/index.d.ts +1 -0
  88. package/lib/components/User/UserProfile/index.js +2 -0
  89. package/lib/components/User/UserProfile/type.d.ts +8 -0
  90. package/lib/components/User/UserProfile/type.js +0 -0
  91. package/lib/components/User/UserProfile/utils.d.ts +5 -0
  92. package/lib/components/User/UserProfile/utils.js +26 -0
  93. package/lib/components/User/UserSelect.css +11 -0
  94. package/lib/components/User/UserSelect.d.ts +11 -0
  95. package/lib/components/User/UserSelect.js +172 -0
  96. package/lib/components/User/UserWithAvatar.d.ts +3 -0
  97. package/lib/components/User/UserWithAvatar.js +41 -0
  98. package/lib/components/User/index.d.ts +7 -0
  99. package/lib/components/User/index.js +5 -0
  100. package/lib/components/User/type.d.ts +13 -0
  101. package/lib/components/User/type.js +0 -0
  102. package/lib/components/Welcome/index.d.ts +3 -0
  103. package/lib/components/Welcome/index.js +17 -0
  104. package/lib/components/common/LogoInfo.d.ts +5 -0
  105. package/lib/components/common/LogoInfo.js +30 -0
  106. package/lib/components/common/NavItem.d.ts +20 -0
  107. package/lib/components/common/NavItem.js +112 -0
  108. package/lib/components/common/NavMenu.d.ts +9 -0
  109. package/lib/components/common/NavMenu.js +50 -0
  110. package/lib/components/common/UserAvatarLayout.d.ts +4 -0
  111. package/lib/components/common/UserAvatarLayout.js +41 -0
  112. package/lib/components/common/UserAvatarMenu.d.ts +4 -0
  113. package/lib/components/common/UserAvatarMenu.js +58 -0
  114. package/lib/components/common/index.d.ts +9 -0
  115. package/lib/components/common/index.js +10 -0
  116. package/lib/components/index.d.ts +8 -0
  117. package/lib/components/index.js +6 -0
  118. package/lib/components/theme/ThemeProvider.d.ts +20 -0
  119. package/lib/components/theme/ThemeProvider.js +75 -0
  120. package/lib/components/theme/constants.d.ts +48 -0
  121. package/lib/components/theme/constants.js +557 -0
  122. package/lib/components/theme/index.d.ts +4 -0
  123. package/lib/components/theme/index.js +5 -0
  124. package/lib/components/theme/miaoDarkTheme.d.ts +2 -0
  125. package/lib/components/theme/miaoDarkTheme.js +310 -0
  126. package/lib/components/theme/miaoLightTheme.d.ts +2 -0
  127. package/lib/components/theme/miaoLightTheme.js +296 -0
  128. package/lib/components/theme/ui-config.d.ts +1 -0
  129. package/lib/components/theme/ui-config.js +2 -0
  130. package/lib/components/theme/util.d.ts +20 -0
  131. package/lib/components/theme/util.js +188 -0
  132. package/lib/font-family.css +40 -0
  133. package/lib/hooks/index.d.ts +5 -0
  134. package/lib/hooks/index.js +5 -0
  135. package/lib/hooks/useAppInfo.d.ts +6 -0
  136. package/lib/hooks/useAppInfo.js +21 -0
  137. package/lib/hooks/useCurrentUserProfile.d.ts +12 -0
  138. package/lib/hooks/useCurrentUserProfile.js +58 -0
  139. package/lib/hooks/useIsMobile.d.ts +1 -0
  140. package/lib/hooks/useIsMobile.js +20 -0
  141. package/lib/hooks/useLogout.d.ts +4 -0
  142. package/lib/hooks/useLogout.js +37 -0
  143. package/lib/hooks/useTheme.d.ts +4 -0
  144. package/lib/hooks/useTheme.js +8 -0
  145. package/lib/hooks/useUpdatingRef.d.ts +1 -0
  146. package/lib/hooks/useUpdatingRef.js +7 -0
  147. package/lib/index.css +5 -0
  148. package/lib/index.d.ts +4 -0
  149. package/lib/index.js +5 -0
  150. package/lib/inspector.dev.css +10 -0
  151. package/lib/integrations/dataloom.d.ts +2 -0
  152. package/lib/integrations/dataloom.js +32 -0
  153. package/lib/integrations/generateImage.d.ts +1 -0
  154. package/lib/integrations/generateImage.js +47 -0
  155. package/lib/integrations/generateTextStream.d.ts +21 -0
  156. package/lib/integrations/generateTextStream.js +98 -0
  157. package/lib/integrations/getAppInfo.d.ts +2 -0
  158. package/lib/integrations/getAppInfo.js +14 -0
  159. package/lib/integrations/getCurrentUserProfile.d.ts +6 -0
  160. package/lib/integrations/getCurrentUserProfile.js +5 -0
  161. package/lib/logger/index.d.ts +6 -0
  162. package/lib/logger/index.js +54 -0
  163. package/lib/override.css +29 -0
  164. package/lib/tailwind-theme.css +335 -0
  165. package/lib/theme-layer.css +3 -0
  166. package/lib/types/common.d.ts +4 -0
  167. package/lib/types/common.js +0 -0
  168. package/lib/types/iframe-events.d.ts +55 -0
  169. package/lib/types/iframe-events.js +0 -0
  170. package/lib/types/index.d.ts +43 -0
  171. package/lib/types/index.js +0 -0
  172. package/lib/utils/copyToClipboard.d.ts +6 -0
  173. package/lib/utils/copyToClipboard.js +32 -0
  174. package/lib/utils/getAppId.d.ts +6 -0
  175. package/lib/utils/getAppId.js +11 -0
  176. package/lib/utils/getCsrfToken.d.ts +5 -0
  177. package/lib/utils/getCsrfToken.js +10 -0
  178. package/lib/utils/getEnvPath.d.ts +4 -0
  179. package/lib/utils/getEnvPath.js +4 -0
  180. package/lib/utils/getInitialInfo.d.ts +20 -0
  181. package/lib/utils/getInitialInfo.js +32 -0
  182. package/lib/utils/getParentOrigin.d.ts +5 -0
  183. package/lib/utils/getParentOrigin.js +7 -0
  184. package/lib/utils/getUserProfile.d.ts +47 -0
  185. package/lib/utils/getUserProfile.js +39 -0
  186. package/lib/utils/postMessage.d.ts +8 -0
  187. package/lib/utils/postMessage.js +11 -0
  188. package/lib/utils/url.d.ts +8 -0
  189. package/lib/utils/url.js +22 -0
  190. package/lib/utils/utils.d.ts +20 -0
  191. package/lib/utils/utils.js +22 -0
  192. package/package.json +134 -0
@@ -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,7 @@
1
+ import React from 'react';
2
+ import { IBaseThemeProviderProps } from '../theme';
3
+ import '../../index.css';
4
+ declare const AppContainer: React.FC<{
5
+ children: React.ReactNode;
6
+ } & IBaseThemeProviderProps>;
7
+ export default AppContainer;
@@ -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,8 @@
1
+ import React from 'react';
2
+ import { toast } from 'sonner';
3
+ import './sonner.css';
4
+ /**
5
+ * 配置全局 Sonner Container 的入口
6
+ */
7
+ declare const Toaster: ({ ...props }: any) => React.JSX.Element;
8
+ export { Toaster, toast };
@@ -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,11 @@
1
+ import apiProxy from '../api-proxy/core';
2
+ /**
3
+ * api panel
4
+ * 获取open-api.json
5
+ */
6
+ declare function getOpenApiJson(): Promise<void>;
7
+ /**
8
+ * 获取日志json
9
+ */
10
+ declare function getLogJson(): Promise<void>;
11
+ export { getOpenApiJson, getLogJson, apiProxy };
@@ -0,0 +1,21 @@
1
+ import { normalizeBasePath } from "../../../utils/utils.js";
2
+ import core from "../api-proxy/core.js";
3
+ async function getOpenApiJson() {
4
+ try {
5
+ const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
6
+ const res = await fetch(`${basePath}/openapi.json`);
7
+ await res.json();
8
+ } catch (error) {
9
+ console.warn('get routes.json error', error);
10
+ }
11
+ }
12
+ async function getLogJson() {
13
+ try {
14
+ const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
15
+ const res = await fetch(`${basePath}/log.json`);
16
+ await res.json();
17
+ } catch (error) {
18
+ console.warn('get log.json error', error);
19
+ }
20
+ }
21
+ export { core as apiProxy, getLogJson, getOpenApiJson };
@@ -0,0 +1,5 @@
1
+ import { ChildApi } from '../../../types/iframe-events';
2
+ /**
3
+ * 子级方法,提供给父级调用
4
+ */
5
+ export declare const childApi: ChildApi;
@@ -0,0 +1,26 @@
1
+ import { normalizeBasePath } from "../../../utils/utils.js";
2
+ import { apiProxy, getLogJson, getOpenApiJson } from "./api-panel.js";
3
+ async function getRoutes() {
4
+ let routes = [
5
+ {
6
+ path: '/'
7
+ }
8
+ ];
9
+ try {
10
+ const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
11
+ const res = await fetch(`${basePath}/routes.json`);
12
+ routes = await res.json();
13
+ } catch (error) {
14
+ console.warn('get routes.json error', error);
15
+ }
16
+ return routes;
17
+ }
18
+ const childApi = {
19
+ getRoutes,
20
+ apiProxy: {
21
+ api: apiProxy,
22
+ getOpenApiJson: getOpenApiJson,
23
+ getLogJson: getLogJson
24
+ }
25
+ };
26
+ 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,5 @@
1
+ import React from 'react';
2
+ declare const RenderError: React.FC<{
3
+ error: Error;
4
+ }>;
5
+ export default RenderError;
@@ -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 };
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const NotFound: () => React.JSX.Element;
3
+ export default NotFound;
@@ -0,0 +1,59 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { useLocation, useNavigate } from "react-router-dom";
3
+ import { useEffect } from "react";
4
+ import { postMessage } from "../../utils/postMessage.js";
5
+ import { useUpdatingRef } from "../../hooks/useUpdatingRef.js";
6
+ import { logger } from "../../logger/index.js";
7
+ const NotFound = ()=>{
8
+ const location = useLocation();
9
+ const navigate = useNavigate();
10
+ const navigateRef = useUpdatingRef(navigate);
11
+ useEffect(()=>{
12
+ logger.error('404 Error: User attempted to access non-existent route:', location.pathname);
13
+ }, [
14
+ location.pathname
15
+ ]);
16
+ const onClick = ()=>{
17
+ if ('production' !== process.env.NODE_ENV) postMessage({
18
+ type: 'CreatePage',
19
+ data: location.pathname
20
+ });
21
+ else navigateRef.current('/');
22
+ };
23
+ return /*#__PURE__*/ jsxs("div", {
24
+ className: "min-h-screen flex flex-col items-center justify-center bg-white",
25
+ children: [
26
+ /*#__PURE__*/ jsx("img", {
27
+ src: 'production' !== process.env.NODE_ENV ? 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ylcylz_fsph_ryhs/ljhwZthlaukjlkulzlp/feisuda/template/illustration_empty_positive_create.svg' : 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ylcylz_fsph_ryhs/ljhwZthlaukjlkulzlp/feisuda/template/illustration_empty_negative_failure-miss.svg',
28
+ alt: "Empty",
29
+ className: "mb-3 w-[120px]"
30
+ }),
31
+ /*#__PURE__*/ jsx("p", {
32
+ className: "text-l/[22px] text-[14px] text-[#1F2329] font-medium",
33
+ children: 'production' !== process.env.NODE_ENV ? '哎呀,这个页面尚未生成' : '404'
34
+ }),
35
+ 'production' !== process.env.NODE_ENV ? /*#__PURE__*/ jsxs(Fragment, {
36
+ children: [
37
+ /*#__PURE__*/ jsx("p", {
38
+ className: "text-sm/[22px] text-[14px] text-[#646A73] font-normal mt-1",
39
+ children: "戳下方按钮,我可以根据上下文帮你生成一个"
40
+ }),
41
+ /*#__PURE__*/ jsxs("button", {
42
+ className: "h-[32px] text-sm font-medium text-white bg-blue-600 border border-transparent rounded-md shadow-xs hover:bg-blue-600 active:bg-blue-700 focus:outline-hidden focus:ring-2 focus:ring-blue-500 px-3 flex flex-row items-center mt-3",
43
+ onClick: onClick,
44
+ children: [
45
+ /*#__PURE__*/ jsx("img", {
46
+ src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/ylcylz_fsph_ryhs/ljhwZthlaukjlkulzlp/feisuda/template/icon_chat-ai_outlined.svg",
47
+ alt: "Icon",
48
+ className: "w-[14px] h-[14px] mr-1"
49
+ }),
50
+ "告诉妙搭生成一个"
51
+ ]
52
+ })
53
+ ]
54
+ }) : null
55
+ ]
56
+ });
57
+ };
58
+ const NotFoundRender = NotFound;
59
+ export { NotFoundRender as default };
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import { BaseNavProps } from '../../types';
3
+ export default function DrawerNav({ navList, className, activeClassName, }: BaseNavProps): React.JSX.Element;
@@ -0,0 +1,64 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { Button, Drawer } from "antd";
4
+ import { Menu } from "lucide-react";
5
+ import { clsxWithTw } from "../../utils/utils.js";
6
+ import { LogoInfo, NavMenu, TopHeaderThemeClass, UserAvatarLayout } from "../common/index.js";
7
+ function DrawerNav({ navList, className, activeClassName }) {
8
+ const [open, setOpen] = useState(false);
9
+ const showDrawer = ()=>{
10
+ setOpen(true);
11
+ };
12
+ const onClose = ()=>{
13
+ setOpen(false);
14
+ };
15
+ return /*#__PURE__*/ jsxs("div", {
16
+ className: clsxWithTw('w-full sticky top-0 z-50 flex flex-row h-14 px-3 items-center', TopHeaderThemeClass, className),
17
+ children: [
18
+ /*#__PURE__*/ jsx(Button, {
19
+ type: "text",
20
+ onClick: showDrawer,
21
+ className: "md:hidden px-0 text-inherit border-0",
22
+ children: /*#__PURE__*/ jsx(Menu, {
23
+ className: "h-6 w-6"
24
+ })
25
+ }),
26
+ /*#__PURE__*/ jsx(LogoInfo, {
27
+ className: "ml-[6px] pl-3"
28
+ }),
29
+ /*#__PURE__*/ jsxs(Drawer, {
30
+ placement: "left",
31
+ rootClassName: "miao-nav",
32
+ closeIcon: null,
33
+ classNames: {
34
+ body: clsxWithTw('w-full h-full flex flex-col p-0', className),
35
+ content: 'w-[320px]'
36
+ },
37
+ onClose: onClose,
38
+ open: open,
39
+ children: [
40
+ /*#__PURE__*/ jsx("div", {
41
+ className: "w-full h-14",
42
+ children: /*#__PURE__*/ jsx(LogoInfo, {
43
+ className: "pl-5 pr-3 h-full flex items-center"
44
+ })
45
+ }),
46
+ /*#__PURE__*/ jsx("div", {
47
+ className: "flex-1 overflow-auto min-h-0",
48
+ children: /*#__PURE__*/ jsx(NavMenu, {
49
+ navList: navList,
50
+ className: clsxWithTw('border-0', className),
51
+ activeClassName: activeClassName,
52
+ mode: "vertical",
53
+ onClick: onClose
54
+ })
55
+ }),
56
+ /*#__PURE__*/ jsx(UserAvatarLayout, {
57
+ className: "mt-2"
58
+ })
59
+ ]
60
+ })
61
+ ]
62
+ });
63
+ }
64
+ export { DrawerNav as default };
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import { BaseNavProps } from '../../types';
3
+ export default function DropdownNav({ navList, className, activeClassName, }: BaseNavProps): React.JSX.Element;
@@ -0,0 +1,40 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { Menu, X } from "lucide-react";
4
+ import { clsxWithTw } from "../../utils/utils.js";
5
+ import { DropdownThemeClass, LogoInfo, NavMenu, TopHeaderThemeClass, UserAvatarMenu } from "../common/index.js";
6
+ function DropdownNav({ navList = [], className, activeClassName }) {
7
+ const [isMenuOpen, setIsMenuOpen] = useState(false);
8
+ const MenuDropdownIcon = isMenuOpen ? X : Menu;
9
+ return /*#__PURE__*/ jsxs("header", {
10
+ className: clsxWithTw('w-full flex sticky top-0 z-50 h-14 px-3 gap-1.5 items-center', TopHeaderThemeClass, isMenuOpen ? 'border-transparent' : '', className),
11
+ children: [
12
+ navList.length > 0 ? /*#__PURE__*/ jsx("div", {
13
+ className: "md:hidden flex mr-3",
14
+ children: /*#__PURE__*/ jsx(MenuDropdownIcon, {
15
+ className: "h-6 w-6 cursor-pointer",
16
+ onClick: ()=>setIsMenuOpen(!isMenuOpen)
17
+ })
18
+ }) : null,
19
+ /*#__PURE__*/ jsx(LogoInfo, {
20
+ className: "flex-1"
21
+ }),
22
+ /*#__PURE__*/ jsx(UserAvatarMenu, {
23
+ className: className
24
+ }),
25
+ isMenuOpen && navList.length > 0 ? /*#__PURE__*/ jsx("div", {
26
+ className: clsxWithTw('overflow-y-auto max-h-[482px] px-2 pb-2 absolute top-14 left-0 right-0 shadow-lg', DropdownThemeClass, className),
27
+ children: /*#__PURE__*/ jsx(NavMenu, {
28
+ navList: navList,
29
+ className: className,
30
+ activeClassName: activeClassName,
31
+ onClick: (_key)=>{
32
+ setIsMenuOpen(false);
33
+ },
34
+ mode: "vertical"
35
+ })
36
+ }) : null
37
+ ]
38
+ });
39
+ }
40
+ export { DropdownNav as default };
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import { NavProps } from '../../types';
3
+ export default function SidebarNav({ activeClassName, className, navList, }: NavProps): React.JSX.Element;