@lark-apaas/client-toolkit 1.2.61-alpha.4 → 1.2.61-alpha.5

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 (31) hide show
  1. package/lib/apis/components/UniversalLink.d.ts +3 -0
  2. package/lib/apis/components/UniversalLink.js +42 -3
  3. package/lib/components/AppContainer/Watermark.d.ts +60 -0
  4. package/lib/components/AppContainer/Watermark.js +364 -0
  5. package/lib/components/AppContainer/__test__/Watermark.test.js +121 -0
  6. package/lib/components/AppContainer/__test__/safety-error-boundary.test.d.ts +1 -0
  7. package/lib/components/AppContainer/__test__/safety-error-boundary.test.js +53 -0
  8. package/lib/components/AppContainer/doubao-watermark-asset.d.ts +2 -0
  9. package/lib/components/AppContainer/doubao-watermark-asset.js +4 -0
  10. package/lib/components/AppContainer/index.js +9 -4
  11. package/lib/components/AppContainer/safety-error-boundary.d.ts +23 -0
  12. package/lib/components/AppContainer/safety-error-boundary.js +29 -0
  13. package/lib/components/AppContainer/safety.js +50 -0
  14. package/lib/hooks/useCurrentUserProfile.js +1 -1
  15. package/lib/index.d.ts +40 -0
  16. package/lib/index.js +32 -2
  17. package/lib/integrations/__test__/dataloom.test.d.ts +1 -0
  18. package/lib/integrations/__test__/dataloom.test.js +83 -0
  19. package/lib/integrations/dataloom.d.ts +1 -1
  20. package/lib/integrations/dataloom.js +5 -11
  21. package/lib/integrations/services/types.d.ts +43 -0
  22. package/lib/locales/messages.js +4 -0
  23. package/lib/runtime/index.js +0 -2
  24. package/lib/types/iframe-events.d.ts +12 -1
  25. package/lib/utils/postMessage.d.ts +1 -0
  26. package/lib/utils/postMessage.js +1 -1
  27. package/package.json +5 -4
  28. package/lib/runtime/preview-run.d.ts +0 -29
  29. package/lib/runtime/preview-run.js +0 -76
  30. package/lib/runtime/preview-run.spec.js +0 -94
  31. /package/lib/{runtime/preview-run.spec.d.ts → components/AppContainer/__test__/Watermark.test.d.ts} +0 -0
@@ -0,0 +1,4 @@
1
+ const CDN = 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miaoda-ui';
2
+ const DOUBAO_LOGO_SRC = `${CDN}/setting_voice.svg`;
3
+ const DOUBAO_PILL_MOBILE_PNG = `${CDN}/Frame%202147223991%20(3).png`;
4
+ export { DOUBAO_LOGO_SRC, DOUBAO_PILL_MOBILE_PNG };
@@ -7,9 +7,11 @@ import IframeBridge from "./IframeBridge.js";
7
7
  import { Toaster } from "./sonner.js";
8
8
  import { PageHoc } from "./PageHoc.js";
9
9
  import { reportTeaEvent } from "./utils/tea.js";
10
+ import { SafetyErrorBoundary } from "./safety-error-boundary.js";
10
11
  import { useAppInfo } from "../../hooks/index.js";
11
12
  import { TrackKey } from "../../types/tea.js";
12
13
  import { slardar } from "@lark-apaas/internal-slardar";
14
+ import Watermark, { isDoubaoSource } from "./Watermark.js";
13
15
  import { getAppId } from "../../utils/getAppId.js";
14
16
  import { isNewPathEnabled } from "../../utils/apiPath.js";
15
17
  import QueryProvider from "../QueryProvider/index.js";
@@ -75,7 +77,8 @@ const App = (props)=>{
75
77
  },
76
78
  categories: {
77
79
  appId: appId ?? 'unknown',
78
- mode: isMiaodaPreview ? 'preview' : 'runtime'
80
+ mode: isMiaodaPreview ? 'preview' : 'runtime',
81
+ appType: String(process.env.MIAODA_APP_TYPE ?? 'unknown')
79
82
  }
80
83
  });
81
84
  }
@@ -196,9 +199,11 @@ const AppContainer_AppContainer = (props)=>{
196
199
  };
197
200
  return /*#__PURE__*/ jsxs(Fragment, {
198
201
  children: [
199
- /*#__PURE__*/ jsx(Suspense, {
200
- fallback: null,
201
- children: /*#__PURE__*/ jsx(Safety, {})
202
+ /*#__PURE__*/ jsx(SafetyErrorBoundary, {
203
+ children: isDoubaoSource() ? /*#__PURE__*/ jsx(Watermark, {}) : /*#__PURE__*/ jsx(Suspense, {
204
+ fallback: null,
205
+ children: /*#__PURE__*/ jsx(Safety, {})
206
+ })
202
207
  }),
203
208
  /*#__PURE__*/ jsx(QueryProvider, {
204
209
  children: /*#__PURE__*/ jsx(ConfigProvider, {
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ interface Props {
3
+ children: React.ReactNode;
4
+ }
5
+ interface State {
6
+ hasError: boolean;
7
+ }
8
+ /**
9
+ * SafetyErrorBoundary - 包裹 Safety 徽章的 lazy import 失败兜底
10
+ *
11
+ * Why: AppContainer 内 `<Suspense fallback={null}><Safety /></Suspense>` 中 Safety 是 React.lazy
12
+ * 拆出的非核心徽章 chunk。chunk 加载失败(CDN 缓存窗 / 部署漂移 / dev preview hash 漂移 / 网络抖动)
13
+ * 时 rejected Promise 越过 Suspense 上抛,会冒到 React root 让整应用 unmount = 白屏。
14
+ *
15
+ * ErrorBoundary 把失败局限在徽章自身:徽章不显示,应用继续跑。同时上报 slardar 便于事后归因。
16
+ */
17
+ export declare class SafetyErrorBoundary extends React.Component<Props, State> {
18
+ state: State;
19
+ static getDerivedStateFromError(): State;
20
+ componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
21
+ render(): React.ReactNode;
22
+ }
23
+ export {};
@@ -0,0 +1,29 @@
1
+ import react from "react";
2
+ import { slardar } from "@lark-apaas/internal-slardar";
3
+ class SafetyErrorBoundary extends react.Component {
4
+ state = {
5
+ hasError: false
6
+ };
7
+ static getDerivedStateFromError() {
8
+ return {
9
+ hasError: true
10
+ };
11
+ }
12
+ componentDidCatch(error, errorInfo) {
13
+ try {
14
+ slardar.sendLog({
15
+ content: `safety_chunk_load_error: ${error.message}`,
16
+ level: 'error',
17
+ extra: {
18
+ stack: error.stack ?? '',
19
+ componentStack: errorInfo.componentStack ?? ''
20
+ }
21
+ });
22
+ } catch {}
23
+ }
24
+ render() {
25
+ if (this.state.hasError) return null;
26
+ return this.props.children;
27
+ }
28
+ }
29
+ export { SafetyErrorBoundary };
@@ -2,12 +2,32 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useRef, useState } from "react";
3
3
  import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover.js";
4
4
  import { getAppId } from "../../utils/getAppId.js";
5
+ import { getEnv } from "../../utils/getParentOrigin.js";
5
6
  import { getCsrfToken } from "../../utils/getCsrfToken.js";
6
7
  import { isNewPathEnabled } from "../../utils/apiPath.js";
7
8
  import { useIsMobile } from "../../hooks/index.js";
8
9
  import { X } from "lucide-react";
9
10
  import { Sheet, SheetContent, SheetTrigger } from "../ui/drawer.js";
10
11
  import { t } from "../../locales/index.js";
12
+ const ICON_FEEDBACK_URL = 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miaoda-ui/icon_feedback_outlined.png';
13
+ const REPORT_DOMAIN = {
14
+ BOE: 'tns.feishu-boe.cn',
15
+ PRE: 'tns.feishu-pre.cn',
16
+ ONLINE: 'tns.feishu.cn'
17
+ };
18
+ const openReport = ()=>{
19
+ const appId = getAppId();
20
+ if (!appId) return;
21
+ const params = JSON.stringify({
22
+ scene: 'miaoda_app_report',
23
+ entity_id: appId,
24
+ entity_type: 'miaoda_app',
25
+ extra: ''
26
+ });
27
+ const domain = REPORT_DOMAIN[getEnv()] ?? REPORT_DOMAIN.ONLINE;
28
+ const url = `https://${domain}/cust/lark_report/?type=common&params=${encodeURIComponent(params)}&lang=zh-CN`;
29
+ window.open(url, '_blank', 'noopener,noreferrer');
30
+ };
11
31
  const Component = ()=>{
12
32
  const HasClosedKey = `miaoda-creatByMiaoda-has-closed-${getAppId()}`;
13
33
  const [visible, setVisible] = useState(!window.localStorage?.getItem(HasClosedKey));
@@ -129,6 +149,21 @@ const Component = ()=>{
129
149
  children: t('safety.ai.disclaimer')
130
150
  })
131
151
  ]
152
+ }),
153
+ /*#__PURE__*/ jsxs("div", {
154
+ className: "self-stretch shrink-0 flex items-center gap-x-[6px] cursor-pointer",
155
+ "data-custom-element": "safety-report",
156
+ onClick: openReport,
157
+ children: [
158
+ /*#__PURE__*/ jsx("img", {
159
+ src: ICON_FEEDBACK_URL,
160
+ className: "shrink-0 w-[14px] h-[14px]"
161
+ }),
162
+ /*#__PURE__*/ jsx("p", {
163
+ className: "shrink-0 m-0! text-[#646A73] text-sm underline underline-offset-2",
164
+ children: t('safety.report')
165
+ })
166
+ ]
132
167
  })
133
168
  ]
134
169
  }),
@@ -248,6 +283,21 @@ const Component = ()=>{
248
283
  children: t('safety.ai.disclaimer')
249
284
  })
250
285
  ]
286
+ }),
287
+ /*#__PURE__*/ jsxs("div", {
288
+ className: "self-stretch shrink-0 flex items-center gap-x-[6px] cursor-pointer",
289
+ "data-custom-element": "safety-report",
290
+ onClick: openReport,
291
+ children: [
292
+ /*#__PURE__*/ jsx("img", {
293
+ src: ICON_FEEDBACK_URL,
294
+ className: "shrink-0 w-[12px] h-[12px]"
295
+ }),
296
+ /*#__PURE__*/ jsx("p", {
297
+ className: "shrink-0 m-0! text-[#a6a6a6] underline underline-offset-2",
298
+ children: t('safety.report')
299
+ })
300
+ ]
251
301
  })
252
302
  ]
253
303
  }),
@@ -44,7 +44,7 @@ const useCurrentUserProfile = ()=>{
44
44
  email: info?.email,
45
45
  name: userName,
46
46
  avatar: info?.avatar?.image?.large,
47
- userName: userName,
47
+ userName,
48
48
  userAvatar: info?.avatar?.image?.large
49
49
  };
50
50
  const larkUserId = await fetchLarkUserId();
package/lib/index.d.ts CHANGED
@@ -1,6 +1,46 @@
1
+ import { getAppId } from './utils/getAppId';
2
+ import { logger } from './logger';
1
3
  export declare const capabilityClient: import("@lark-apaas/client-capability").CapabilityClient;
2
4
  export { showConfirm } from './components/ui/confirm';
3
5
  export type { ConfirmOptions } from './components/ui/confirm';
6
+ export { default as AppContainer } from './components/AppContainer';
7
+ export { default as QueryProvider } from './components/QueryProvider';
8
+ export { default as PagePlaceholder } from './components/PagePlaceholder';
9
+ export { default as Welcome } from './components/PagePlaceholder';
10
+ export { default as ErrorRender } from './components/ErrorRender';
11
+ export { ActiveLink } from './apis/components/ActiveLink';
12
+ export { NavLink } from './apis/components/NavLink';
13
+ export { UniversalLink } from './apis/components/UniversalLink';
14
+ export { useAppInfo } from './hooks/useAppInfo';
15
+ export { useCurrentUserProfile } from './hooks/useCurrentUserProfile';
16
+ export { useIsMobile } from './hooks/useIsMobile';
17
+ export { useLogout } from './hooks/useLogout';
18
+ export { clsxWithTw, isPreview, normalizeBasePath, getWsPath } from './utils/utils';
19
+ export { getCsrfToken } from './utils/getCsrfToken';
20
+ export { scopedStorage } from './utils/scopedStorage';
21
+ export { copyToClipboard } from './utils/copyToClipboard';
22
+ export { isIpad, isMobile, isIOS } from './utils/deviceType';
23
+ export { resolveAppUrl } from './utils/resolveAppUrl';
24
+ export { getEnvPath } from './utils/getEnvPath';
25
+ export { safeStringify } from './utils/safeStringify';
26
+ export { getAxiosForBackend, axiosForBackend } from './utils/getAxiosForBackend';
27
+ export { initAxiosConfig } from './utils/axiosConfig';
28
+ export { getAppId };
29
+ export { getAppInfo } from './integrations/getAppInfo';
30
+ export { getCurrentUserProfile } from './integrations/getCurrentUserProfile';
31
+ export { getDataloom } from './integrations/dataloom';
32
+ export { logger };
33
+ export type { LogLevel, LogWithMeta } from './logger/log-types';
34
+ export { trace } from './trace';
35
+ export { initObservable } from './runtime/observable';
36
+ export type { AppInfoPayload } from './types/common';
37
+ export type { IUserProfile, IJson, IFileAttachment } from './apis/udt-types';
38
+ export type { TrackParams } from './types/tea';
39
+ export { TrackKey } from './types/tea';
40
+ export { reportTeaEvent } from './components/AppContainer/utils/tea';
41
+ export * as avatarImages from './apis/constants/img-resources/avatar';
42
+ export * as bannerImages from './apis/constants/img-resources/banner';
43
+ export * as coverImages from './apis/constants/img-resources/cover';
4
44
  declare const _default: {
5
45
  version: string;
6
46
  };
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createClient } from "@lark-apaas/client-capability";
2
- import { normalizeBasePath } from "./utils/utils.js";
2
+ import { clsxWithTw, getWsPath, isPreview, normalizeBasePath } from "./utils/utils.js";
3
3
  import { getAppId } from "./utils/getAppId.js";
4
4
  import { isNewPathEnabled } from "./utils/apiPath.js";
5
5
  import { logger } from "./logger/index.js";
@@ -7,6 +7,36 @@ import { showToast } from "./components/ui/toast.js";
7
7
  import { t } from "./locales/index.js";
8
8
  import { version } from "../package.json";
9
9
  import { showConfirm } from "./components/ui/confirm.js";
10
+ import AppContainer from "./components/AppContainer/index.js";
11
+ import QueryProvider from "./components/QueryProvider/index.js";
12
+ import PagePlaceholder from "./components/PagePlaceholder/index.js";
13
+ import ErrorRender from "./components/ErrorRender/index.js";
14
+ import { ActiveLink } from "./apis/components/ActiveLink.js";
15
+ import { NavLink } from "./apis/components/NavLink.js";
16
+ import { UniversalLink } from "./apis/components/UniversalLink.js";
17
+ import { useAppInfo } from "./hooks/useAppInfo.js";
18
+ import { useCurrentUserProfile } from "./hooks/useCurrentUserProfile.js";
19
+ import { useIsMobile } from "./hooks/useIsMobile.js";
20
+ import { useLogout } from "./hooks/useLogout.js";
21
+ import { getCsrfToken } from "./utils/getCsrfToken.js";
22
+ import { scopedStorage } from "./utils/scopedStorage.js";
23
+ import { copyToClipboard } from "./utils/copyToClipboard.js";
24
+ import { isIOS, isIpad, isMobile } from "./utils/deviceType.js";
25
+ import { resolveAppUrl } from "./utils/resolveAppUrl.js";
26
+ import { getEnvPath } from "./utils/getEnvPath.js";
27
+ import { safeStringify } from "./utils/safeStringify.js";
28
+ import { axiosForBackend, getAxiosForBackend } from "./utils/getAxiosForBackend.js";
29
+ import { initAxiosConfig } from "./utils/axiosConfig.js";
30
+ import { getAppInfo } from "./integrations/getAppInfo.js";
31
+ import { getCurrentUserProfile } from "./integrations/getCurrentUserProfile.js";
32
+ import { getDataloom } from "./integrations/dataloom.js";
33
+ import { trace } from "./trace/index.js";
34
+ import { initObservable } from "./runtime/observable.js";
35
+ import { TrackKey } from "./types/tea.js";
36
+ import { reportTeaEvent } from "./components/AppContainer/utils/tea.js";
37
+ import * as __WEBPACK_EXTERNAL_MODULE__apis_constants_img_resources_avatar_js_2c154035__ from "./apis/constants/img-resources/avatar.js";
38
+ import * as __WEBPACK_EXTERNAL_MODULE__apis_constants_img_resources_banner_js_72c990bf__ from "./apis/constants/img-resources/banner.js";
39
+ import * as __WEBPACK_EXTERNAL_MODULE__apis_constants_img_resources_cover_js_90a812c2__ from "./apis/constants/img-resources/cover.js";
10
40
  const _appId = getAppId();
11
41
  const _acquireUploadUrl = isNewPathEnabled() ? `/app/${_appId}/__runtime__/api/v1/studio/plugins/tmp_files/acquire_upload_url` : "/af/api/v1/studio/plugins/tmp_files/acquire_upload_url";
12
42
  const _acquireDownloadUrl = isNewPathEnabled() ? `/app/${_appId}/__runtime__/api/v1/studio/plugins/tmp_files/acquire_download_url` : "/af/api/v1/studio/plugins/tmp_files/acquire_download_url";
@@ -27,4 +57,4 @@ const capabilityClient = createClient({
27
57
  const src = {
28
58
  version: version
29
59
  };
30
- export { capabilityClient, src as default, showConfirm };
60
+ export { ActiveLink, AppContainer, ErrorRender, NavLink, PagePlaceholder, QueryProvider, TrackKey, UniversalLink, PagePlaceholder as Welcome, __WEBPACK_EXTERNAL_MODULE__apis_constants_img_resources_avatar_js_2c154035__ as avatarImages, axiosForBackend, __WEBPACK_EXTERNAL_MODULE__apis_constants_img_resources_banner_js_72c990bf__ as bannerImages, capabilityClient, clsxWithTw, copyToClipboard, __WEBPACK_EXTERNAL_MODULE__apis_constants_img_resources_cover_js_90a812c2__ as coverImages, src as default, getAppId, getAppInfo, getAxiosForBackend, getCsrfToken, getCurrentUserProfile, getDataloom, getEnvPath, getWsPath, initAxiosConfig, initObservable, isIOS, isIpad, isMobile, isPreview, logger, normalizeBasePath, reportTeaEvent, resolveAppUrl, safeStringify, scopedStorage, showConfirm, trace, useAppInfo, useCurrentUserProfile, useIsMobile, useLogout };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,83 @@
1
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
2
+ import { getDataloom } from "../dataloom.js";
3
+ const { getInitialInfoMock, getAppPublishedMock, getAppIdMock, createClientMock, authUserMock, authSessionMock } = vi.hoisted(()=>({
4
+ getInitialInfoMock: vi.fn(),
5
+ getAppPublishedMock: vi.fn(),
6
+ getAppIdMock: vi.fn(),
7
+ createClientMock: vi.fn(),
8
+ authUserMock: {},
9
+ authSessionMock: {}
10
+ }));
11
+ vi.mock('../../utils/getInitialInfo', ()=>({
12
+ getInitialInfo: getInitialInfoMock,
13
+ getAppPublished: getAppPublishedMock
14
+ }));
15
+ vi.mock('../../utils/getAppId', ()=>({
16
+ getAppId: getAppIdMock
17
+ }));
18
+ vi.mock('@lark-apaas/dataloom', ()=>({
19
+ createClient: createClientMock
20
+ }));
21
+ vi.mock('@lark-apaas/auth-sdk', ()=>({
22
+ authClient: {
23
+ user: authUserMock,
24
+ session: authSessionMock
25
+ }
26
+ }));
27
+ beforeEach(()=>{
28
+ getInitialInfoMock.mockReset();
29
+ getAppPublishedMock.mockReset();
30
+ getAppIdMock.mockReset();
31
+ createClientMock.mockReset();
32
+ });
33
+ afterEach(()=>{
34
+ vi.restoreAllMocks();
35
+ });
36
+ describe('getDataloom', ()=>{
37
+ it('返回-createClient实例-改用getInitialInfo-新签名不取token/url-appId注入-并发去重-缓存复用', async ()=>{
38
+ getAppIdMock.mockReturnValue('app-1');
39
+ getInitialInfoMock.mockResolvedValue({
40
+ app_runtime_extra: {
41
+ token: 'pat',
42
+ url: 'https://x'
43
+ }
44
+ });
45
+ const client = {
46
+ __id: 'client-1'
47
+ };
48
+ createClientMock.mockReturnValue(client);
49
+ const p1 = getDataloom();
50
+ const p2 = getDataloom();
51
+ expect(p1).toBe(p2);
52
+ const [c1, c2] = await Promise.all([
53
+ p1,
54
+ p2
55
+ ]);
56
+ expect(c1).toBe(client);
57
+ expect(c2).toBe(client);
58
+ expect(getInitialInfoMock).toHaveBeenCalledTimes(1);
59
+ expect(getAppPublishedMock).not.toHaveBeenCalled();
60
+ expect(createClientMock).toHaveBeenCalledTimes(1);
61
+ const args = createClientMock.mock.calls[0];
62
+ expect(args).toHaveLength(1);
63
+ const options = args[0];
64
+ expect(typeof options).toBe('object');
65
+ expect(options).not.toBe('https://x');
66
+ expect(options).not.toBe('pat');
67
+ expect(options.global).toBeDefined();
68
+ expect(options.global).not.toHaveProperty('url');
69
+ expect(options.global).not.toHaveProperty('key');
70
+ expect(options.global?.appId).toBe('app-1');
71
+ expect(options.global?.accountServices).toEqual({
72
+ user: authUserMock,
73
+ session: authSessionMock
74
+ });
75
+ const cached1 = await getDataloom();
76
+ const cached2 = await getDataloom();
77
+ expect(cached1).toBe(client);
78
+ expect(cached2).toBe(client);
79
+ expect(cached1).toBe(cached2);
80
+ expect(getInitialInfoMock).toHaveBeenCalledTimes(1);
81
+ expect(createClientMock).toHaveBeenCalledTimes(1);
82
+ });
83
+ });
@@ -1,4 +1,4 @@
1
- declare const createDataLoomClient: (url?: string, pat?: string) => import("@lark-apaas/dataloom").DataloomClient;
1
+ declare const createDataLoomClient: () => import("@lark-apaas/dataloom").DataloomClient;
2
2
  /** 获取dataloom实例 */
3
3
  export declare function getDataloom(): Promise<ReturnType<typeof createDataLoomClient>>;
4
4
  export {};
@@ -1,14 +1,10 @@
1
- import { splitWorkspaceUrl } from "../utils/url.js";
2
1
  import { createClient } from "@lark-apaas/dataloom";
3
2
  import { authClient } from "@lark-apaas/auth-sdk";
4
3
  import { getAppId } from "../utils/getAppId.js";
5
- import { getAppPublished } from "../utils/getInitialInfo.js";
6
- const createDataLoomClient = (url, pat)=>{
7
- const { baseUrl } = url ? splitWorkspaceUrl(url) : {
8
- baseUrl: ''
9
- };
4
+ import { getInitialInfo } from "../utils/getInitialInfo.js";
5
+ const createDataLoomClient = ()=>{
10
6
  const appId = getAppId();
11
- return createClient(baseUrl, pat, {
7
+ return createClient({
12
8
  global: {
13
9
  enableDataloomLog: 'production' !== process.env.NODE_ENV,
14
10
  requestRateLimit: 'production' !== process.env.NODE_ENV ? 100 : void 0,
@@ -26,10 +22,8 @@ let pendingPromise = null;
26
22
  function getDataloom() {
27
23
  if (dataloom) return Promise.resolve(dataloom);
28
24
  if (pendingPromise) return pendingPromise;
29
- pendingPromise = getAppPublished().then((info)=>{
30
- const DATALOOM_CLIENT_URL = info?.app_runtime_extra?.url;
31
- const DATALOOM_PAT = info?.app_runtime_extra?.token;
32
- dataloom = createDataLoomClient(DATALOOM_CLIENT_URL, DATALOOM_PAT);
25
+ pendingPromise = getInitialInfo().then(()=>{
26
+ dataloom = createDataLoomClient();
33
27
  return dataloom;
34
28
  }).finally(()=>{
35
29
  pendingPromise = null;
@@ -6,6 +6,15 @@ export type I18nText = {
6
6
  export type DepartmentBasic = {
7
7
  departmentID: string;
8
8
  name: I18nText;
9
+ /** 飞书部门 open id(od- 开头),调飞书部门能力时使用 */
10
+ openDepartmentID?: string;
11
+ };
12
+ /** 直属上级 / 虚线上级,仅在 needFullFields 时返回 */
13
+ export type LeaderUser = {
14
+ /** 飞书企业内 user_id */
15
+ employeeID?: string;
16
+ /** 妙搭用户全局唯一 ID */
17
+ miaodaUserID?: string;
9
18
  };
10
19
  export type UserInfo = {
11
20
  userID: string;
@@ -16,11 +25,41 @@ export type UserInfo = {
16
25
  department: DepartmentBasic;
17
26
  email?: string;
18
27
  tenantName?: string;
28
+ /** 妙搭用户全局唯一 ID(来源同 userID,向前兼容别名) */
29
+ miaodaUserID?: string;
30
+ /** 飞书企业内 user_id,仅内部飞书用户;调飞书开放平台能力时使用 */
31
+ employeeID?: string;
32
+ /** 飞书用户全局唯一 ID(来源同 larkUserID 别名) */
33
+ larkID?: string;
34
+ /** 昵称(多语言),仅 needFullFields=true 时返回 */
35
+ nickname?: I18nText;
36
+ /** 手机号,仅 needFullFields=true 时返回 */
37
+ mobile?: string;
38
+ /** 性别,仅 needFullFields=true 时返回 */
39
+ gender?: string;
40
+ /** 国家/地区,仅 needFullFields=true 时返回 */
41
+ country?: string;
42
+ /** 工位,仅 needFullFields=true 时返回 */
43
+ workStation?: string;
44
+ /** 工号,仅 needFullFields=true 时返回 */
45
+ employeeNo?: string;
46
+ /** 城市,仅 needFullFields=true 时返回 */
47
+ city?: string;
48
+ /** 职位(多语言),仅 needFullFields=true 时返回 */
49
+ jobTitle?: I18nText;
50
+ /** 员工类型,仅 needFullFields=true 时返回 */
51
+ employeeType?: string;
52
+ /** 直属上级,仅 needFullFields=true 时返回 */
53
+ leader?: LeaderUser;
54
+ /** 虚线上级,仅 needFullFields=true 时返回 */
55
+ dottedLineLeaders?: LeaderUser[];
19
56
  };
20
57
  export type DepartmentInfo = {
21
58
  departmentID: string;
22
59
  larkDepartmentID: string;
23
60
  name: I18nText;
61
+ /** 飞书部门 open id(od- 开头) */
62
+ openDepartmentID?: string;
24
63
  };
25
64
  export type AccountType = 'apaas' | 'lark';
26
65
  export type SearchAvatar = {
@@ -35,6 +74,8 @@ export type SearchUsersParams = {
35
74
  offset?: number;
36
75
  pageSize?: number;
37
76
  searchExternalContact?: boolean;
77
+ /** 是否返回 full 字段(手机号/职位/上级等),默认 false */
78
+ needFullFields?: boolean;
38
79
  };
39
80
  export type SearchUsersResponse = {
40
81
  data: {
@@ -75,6 +116,8 @@ export type SearchDepartmentsResponse = {
75
116
  export type ChatInfo = {
76
117
  /** 群组 ID */
77
118
  chatID: string;
119
+ /** 飞书群组 open id(oc_ 开头),调飞书群组能力时使用 */
120
+ openChatID?: string;
78
121
  /** 群组名称(国际化文本) */
79
122
  name: I18nText;
80
123
  /** 头像:URL 或 16 进制 RGB 颜色 */
@@ -23,6 +23,10 @@ const messages_messages = {
23
23
  zh: '了解更多',
24
24
  en: 'Learn more'
25
25
  },
26
+ 'safety.report': {
27
+ zh: '投诉与举报',
28
+ en: 'Report'
29
+ },
26
30
  'safety.cover.pc': {
27
31
  zh: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/logo/miaodacover.png',
28
32
  en: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/logo/miaodacover-weben.png'
@@ -5,13 +5,11 @@ import { initAxiosConfig } from "./axios.js";
5
5
  import { initObservable } from "./observable.js";
6
6
  import { initServerLog } from "./server-log.js";
7
7
  import { initIframeBridge } from "./iframe-bridge.js";
8
- import { initPreviewRunReporting } from "./preview-run.js";
9
8
  if (!window.__FULLSTACK_RUNTIME_INITIALIZED__) {
10
9
  window.__FULLSTACK_RUNTIME_INITIALIZED__ = true;
11
10
  registerDayjsPlugins();
12
11
  initAxiosConfig();
13
12
  initObservable();
14
- initPreviewRunReporting();
15
13
  if ('production' !== process.env.NODE_ENV) {
16
14
  initServerLog();
17
15
  initIframeBridge();
@@ -46,7 +46,18 @@ export interface DevServerMessage extends IframeMessage<{
46
46
  }> {
47
47
  type: 'DevServerMessage';
48
48
  }
49
- export type OutgoingMessage = PreviewReadyMessage | HmrMessage | ConsoleMessage | ChildLocationChangeMessage | CreatePageMessage | RenderErrorMessage | RenderErrorRepairMessage | PageScreenshotMessage | DevServerMessage | UpdateRoutesMessage;
49
+ /**
50
+ * 预览态下链接点击通知父页面处理。
51
+ * iframe 内直接跳转可能被浏览器安全策略拦截,
52
+ * 通过 postMessage 让父页面在新标签页或外壳中打开链接。
53
+ */
54
+ export interface OpenIframeLinkMessage extends IframeMessage<{
55
+ href: string;
56
+ external: boolean;
57
+ }> {
58
+ type: 'OpenIframeLink';
59
+ }
60
+ export type OutgoingMessage = PreviewReadyMessage | HmrMessage | ConsoleMessage | ChildLocationChangeMessage | CreatePageMessage | RenderErrorMessage | RenderErrorRepairMessage | PageScreenshotMessage | DevServerMessage | UpdateRoutesMessage | OpenIframeLinkMessage;
50
61
  export interface GetRoutesMessage extends IframeMessage<Record<string, never>> {
51
62
  type: 'GetRoutes';
52
63
  }
@@ -1,4 +1,5 @@
1
1
  import type { IncomingMessage, OutgoingMessage } from '../types/iframe-events';
2
+ export declare function getParentOriginFromParams(): string | undefined;
2
3
  export declare function resolveParentOrigin(): string;
3
4
  export declare function submitPostMessage<T extends OutgoingMessage>(message: T, targetOrigin?: string): void;
4
5
  export declare function isOutgoingMessage<T extends OutgoingMessage['type']>(msg: OutgoingMessage, type: T): msg is Extract<OutgoingMessage, {
@@ -50,4 +50,4 @@ function isOutgoingMessage(msg, type) {
50
50
  function isIncomingMessage(msg, type) {
51
51
  return msg.type === type;
52
52
  }
53
- export { isIncomingMessage, isOutgoingMessage, resolveParentOrigin, submitPostMessage };
53
+ export { getParentOriginFromParams, isIncomingMessage, isOutgoingMessage, resolveParentOrigin, submitPostMessage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/client-toolkit",
3
- "version": "1.2.61-alpha.4",
3
+ "version": "1.2.61-alpha.5",
4
4
  "types": "./lib/index.d.ts",
5
5
  "main": "./lib/index.js",
6
6
  "files": [
@@ -26,6 +26,7 @@
26
26
  "types": "./lib/antd-table.d.ts"
27
27
  },
28
28
  "./lib/index.css": "./lib/index.css",
29
+ "./styles.css": "./lib/index.css",
29
30
  "./dataloom": {
30
31
  "import": "./lib/apis/dataloom.js",
31
32
  "require": "./lib/apis/dataloom.js",
@@ -98,12 +99,12 @@
98
99
  "dependencies": {
99
100
  "@ant-design/colors": "^7.2.1",
100
101
  "@ant-design/cssinjs": "^1.24.0",
101
- "@lark-apaas/aily-web-sdk": "^0.0.11",
102
+ "@lark-apaas/aily-web-sdk": "^0.0.12",
102
103
  "@lark-apaas/auth-sdk": "^0.1.5",
103
104
  "@lark-apaas/client-capability": "^0.1.7",
104
- "@lark-apaas/dataloom": "^0.1.2",
105
+ "@lark-apaas/dataloom": "^0.1.4",
105
106
  "@lark-apaas/internal-slardar": "^0.0.3",
106
- "@lark-apaas/miaoda-inspector": "^1.0.23",
107
+ "@lark-apaas/miaoda-inspector": "1.0.24-alpha.0",
107
108
  "@lark-apaas/observable-web": "^1.0.6",
108
109
  "@radix-ui/react-avatar": "^1.1.10",
109
110
  "@radix-ui/react-popover": "^1.1.15",
@@ -1,29 +0,0 @@
1
- export declare const PREVIEW_RUN_ID_QUERY = "__miaoda_preview_run_id";
2
- export declare const PREVIEW_RENDERED_MESSAGE_TYPE = "MiaodaPreviewRendered";
3
- interface PreviewRenderedMessage {
4
- type: typeof PREVIEW_RENDERED_MESSAGE_TYPE;
5
- data: {
6
- runID: string;
7
- customTtiMs: number;
8
- renderedAtEpochMs: number;
9
- };
10
- }
11
- interface CreatePreviewRenderedMessageOptions {
12
- search: string;
13
- customTtiMs: number;
14
- eventTimeStampMs: number;
15
- performanceTimeOriginMs: number;
16
- renderedAtEpochMs?: number;
17
- }
18
- interface PreviewRunReportingEnvironment {
19
- search: string;
20
- referrer: string;
21
- performanceTimeOriginMs: number;
22
- isEmbedded: boolean;
23
- addEventListener(type: 'builderV3-custom-TTI', handler: (event: Event) => void): void;
24
- removeEventListener(type: 'builderV3-custom-TTI', handler: (event: Event) => void): void;
25
- postMessage(message: PreviewRenderedMessage, targetOrigin: string): void;
26
- }
27
- export declare function createPreviewRenderedMessage(options: CreatePreviewRenderedMessageOptions): PreviewRenderedMessage | undefined;
28
- export declare function initPreviewRunReporting(environment?: PreviewRunReportingEnvironment): () => void;
29
- export {};