@lark-apaas/client-toolkit 1.1.32-alpha.4 → 1.1.33-alpha.0

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.
@@ -0,0 +1 @@
1
+ export { default as QueryProvider, getDefaultQueryClient } from '../../components/QueryProvider';
@@ -0,0 +1,2 @@
1
+ import QueryProvider, { getDefaultQueryClient } from "../../components/QueryProvider/index.js";
2
+ export { QueryProvider, getDefaultQueryClient };
@@ -16,6 +16,7 @@ import { TrackKey } from "../../types/tea.js";
16
16
  import safety from "./safety.js";
17
17
  import { getAppId } from "../../utils/getAppId.js";
18
18
  import { ServerLogPoller } from "../../server-log/index.js";
19
+ import QueryProvider from "../QueryProvider/index.js";
19
20
  registerDayjsPlugins();
20
21
  initAxiosConfig();
21
22
  const isMiaodaPreview = window.IS_MIAODA_PREVIEW;
@@ -221,17 +222,19 @@ const AppContainer_AppContainer = (props)=>{
221
222
  return /*#__PURE__*/ jsxs(Fragment, {
222
223
  children: [
223
224
  /*#__PURE__*/ jsx(safety, {}),
224
- /*#__PURE__*/ jsx(ConfigProvider, {
225
- theme: {
226
- token: antdThemeToken,
227
- components: {
228
- Table: antdTableToken,
229
- Pagination: antdPaginationToken
230
- }
231
- },
232
- children: /*#__PURE__*/ jsx(App, {
233
- themeMeta: props.themeMeta,
234
- children: children
225
+ /*#__PURE__*/ jsx(QueryProvider, {
226
+ children: /*#__PURE__*/ jsx(ConfigProvider, {
227
+ theme: {
228
+ token: antdThemeToken,
229
+ components: {
230
+ Table: antdTableToken,
231
+ Pagination: antdPaginationToken
232
+ }
233
+ },
234
+ children: /*#__PURE__*/ jsx(App, {
235
+ themeMeta: props.themeMeta,
236
+ children: children
237
+ })
235
238
  })
236
239
  })
237
240
  ]
@@ -28,11 +28,6 @@ async function getSourceMap() {
28
28
  }
29
29
  const childApi = {
30
30
  getRoutes,
31
- updateAppInfo: (appInfo)=>{
32
- dispatchEvent(new CustomEvent('MiaoDaMetaInfoChanged', {
33
- detail: appInfo
34
- }));
35
- },
36
31
  getSourceMap,
37
32
  apiProxy: {
38
33
  api_get: api_get,
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { QueryClient } from '@tanstack/react-query';
3
+ declare const getDefaultQueryClient: () => QueryClient;
4
+ export type QueryProviderProps = {
5
+ children: React.ReactNode;
6
+ client?: QueryClient;
7
+ };
8
+ declare const QueryProvider: React.FC<QueryProviderProps>;
9
+ export default QueryProvider;
10
+ export { getDefaultQueryClient };
@@ -0,0 +1,27 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import "react";
3
+ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
4
+ let defaultQueryClient = null;
5
+ const getDefaultQueryClient = ()=>{
6
+ if (!defaultQueryClient) defaultQueryClient = new QueryClient({
7
+ defaultOptions: {
8
+ queries: {
9
+ retry: 1,
10
+ refetchOnWindowFocus: false
11
+ },
12
+ mutations: {
13
+ retry: 1
14
+ }
15
+ }
16
+ });
17
+ return defaultQueryClient;
18
+ };
19
+ const QueryProvider = ({ children, client })=>{
20
+ const qc = client ?? getDefaultQueryClient();
21
+ return /*#__PURE__*/ jsx(QueryClientProvider, {
22
+ client: qc,
23
+ children: children
24
+ });
25
+ };
26
+ const components_QueryProvider = QueryProvider;
27
+ export { components_QueryProvider as default, getDefaultQueryClient };
@@ -3,5 +3,4 @@ export declare const useAppInfo: () => {
3
3
  appLogo: string;
4
4
  name?: string;
5
5
  avatar?: string;
6
- description?: string;
7
6
  };
@@ -3,12 +3,9 @@ import { getAppInfo } from "../integrations/getAppInfo.js";
3
3
  const useAppInfo = ()=>{
4
4
  const [appInfo, setAppInfo] = useState({});
5
5
  useEffect(()=>{
6
- const updateDomInfo = (info)=>{
7
- if (info.name) {
8
- document.title = info.name;
9
- const meta = document.querySelector("meta[property='og:title']");
10
- if (meta) meta.content = info.name;
11
- }
6
+ const handleMetaInfoChanged = async ()=>{
7
+ const info = await getAppInfo();
8
+ if (info.name) document.title = info.name;
12
9
  if (info.avatar) {
13
10
  let link = document.querySelector("link[rel~='icon']");
14
11
  if (!link) {
@@ -17,30 +14,13 @@ const useAppInfo = ()=>{
17
14
  document.head.appendChild(link);
18
15
  }
19
16
  link.href = info.avatar;
20
- const meta = document.querySelector("meta[property='og:image']");
21
- if (meta) meta.content = info.avatar;
22
- }
23
- if (info.description) {
24
- const meta = document.querySelector("meta[property='og:description']");
25
- if (meta) meta.content = info.description;
26
17
  }
27
- };
28
- const handleMetaInfoChanged = async (info)=>{
29
- if (!info) info = await getAppInfo(true);
30
- updateDomInfo(info);
31
- setAppInfo((prev)=>({
32
- ...prev,
33
- ...info
34
- }));
18
+ setAppInfo(info);
35
19
  };
36
20
  handleMetaInfoChanged();
37
- const onUpdate = (e)=>{
38
- const info = e.detail;
39
- handleMetaInfoChanged(info);
40
- };
41
- window.addEventListener('MiaoDaMetaInfoChanged', onUpdate);
21
+ window.addEventListener('MiaoDaMetaInfoChanged', handleMetaInfoChanged);
42
22
  return ()=>{
43
- window.removeEventListener('MiaoDaMetaInfoChanged', onUpdate);
23
+ window.removeEventListener('MiaoDaMetaInfoChanged', handleMetaInfoChanged);
44
24
  };
45
25
  }, []);
46
26
  return {
@@ -1,2 +1,2 @@
1
1
  import { AppInfoPayload } from '../types/common';
2
- export declare function getAppInfo(refresh?: boolean): Promise<AppInfoPayload>;
2
+ export declare function getAppInfo(): Promise<AppInfoPayload>;
@@ -1,9 +1,9 @@
1
1
  import { getInitialInfo } from "../utils/getInitialInfo.js";
2
2
  import { isSparkRuntime } from "../utils/utils.js";
3
- async function getAppInfo(refresh = false) {
3
+ async function getAppInfo() {
4
4
  let appInfo = 'undefined' != typeof window ? window._appInfo : void 0;
5
- if ((!appInfo || refresh) && isSparkRuntime()) {
6
- const info = (await getInitialInfo(refresh))?.app_info;
5
+ if (!appInfo && isSparkRuntime()) {
6
+ const info = (await getInitialInfo())?.app_info;
7
7
  appInfo = {
8
8
  name: info?.app_name || '',
9
9
  avatar: info?.app_avatar || ''
@@ -1,5 +1,4 @@
1
1
  export interface AppInfoPayload {
2
2
  name: string;
3
3
  avatar: string;
4
- description: string;
5
4
  }
@@ -1,4 +1,3 @@
1
- import { AppInfoPayload } from "./common";
2
1
  export interface IframeMessage<T = unknown> {
3
2
  type: string;
4
3
  data: T;
@@ -56,8 +55,6 @@ export interface ParentApi {
56
55
  export interface ChildApi {
57
56
  getRoutes: () => Promise<any[]>;
58
57
  getSourceMap: () => Promise<string>;
59
- /** 更新应用信息 */
60
- updateAppInfo: (appInfo: AppInfoPayload) => void;
61
58
  apiProxy: {
62
59
  api_get: (url: string, config?: any) => Promise<any>;
63
60
  api_post: (url: string, data?: any, config?: any) => Promise<any>;
@@ -13,7 +13,7 @@ interface BucketConfig {
13
13
  default_bucket_id?: string;
14
14
  }
15
15
  /** 获取应用初始化信息(仅全栈沙箱模式下使用) */
16
- export declare function getInitialInfo(refresh?: boolean): Promise<{
16
+ export declare function getInitialInfo(): Promise<{
17
17
  app_info?: AppRuntimePublished;
18
18
  app_runtime_extra?: AppRuntimeExtra;
19
19
  }>;
@@ -23,8 +23,8 @@ async function getAppPublished() {
23
23
  }
24
24
  }
25
25
  let initialInfo;
26
- async function getInitialInfo(refresh = false) {
27
- if (initialInfo && !refresh) return initialInfo;
26
+ async function getInitialInfo() {
27
+ if (initialInfo) return initialInfo;
28
28
  initialInfo = await getAppPublished();
29
29
  if (initialInfo) window._bucket_id = initialInfo.app_runtime_extra?.bucket?.default_bucket_id;
30
30
  return initialInfo;
@@ -3,4 +3,4 @@ export declare function getEnv(): 'BOE' | 'PRE' | 'ONLINE';
3
3
  * @internal
4
4
  * 获取预览环境父级域名
5
5
  */
6
- export declare function getPreviewParentOrigin(): "https://force.feishu-boe.cn" | "https://miaoda.feishu.cn" | "https://miaoda.feishu-pre.cn" | "https://miaoda.feishu-boe.cn";
6
+ export declare function getPreviewParentOrigin(): "https://force.feishu.cn" | "https://force.feishu-pre.cn" | "https://force.feishu-boe.cn" | "https://miaoda.feishu.cn" | "https://miaoda.feishu-pre.cn" | "https://miaoda.feishu-boe.cn";
@@ -6,6 +6,8 @@ function getEnv() {
6
6
  }
7
7
  function getPreviewParentOrigin() {
8
8
  const { origin } = window.location;
9
+ if (origin.includes('force.feishuapp.net')) return 'https://force.feishu.cn';
10
+ if (origin.includes('force-pre.feishuapp.net')) return 'https://force.feishu-pre.cn';
9
11
  if (origin.includes('force.byted.org')) return 'https://force.feishu-boe.cn';
10
12
  if (origin.includes('feishuapp.cn') || origin.includes('miaoda.feishuapp.net')) return 'https://miaoda.feishu.cn';
11
13
  if (origin.includes('fsapp.kundou.cn') || origin.includes('miaoda-pre.feishuapp.net')) return 'https://miaoda.feishu-pre.cn';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/client-toolkit",
3
- "version": "1.1.32-alpha.4",
3
+ "version": "1.1.33-alpha.0",
4
4
  "types": "./lib/index.d.ts",
5
5
  "main": "./lib/index.js",
6
6
  "files": [
@@ -148,6 +148,7 @@
148
148
  "vitest": "^3.2.4"
149
149
  },
150
150
  "peerDependencies": {
151
+ "@tanstack/react-query": "^5.90.12",
151
152
  "antd": ">=5.26.6",
152
153
  "react": ">=16.14.0",
153
154
  "react-dom": ">=16.14.0",