@lark-apaas/client-toolkit 1.2.54-alpha.2 → 1.2.54-alpha.4

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 (34) hide show
  1. package/lib/apis/components/UniversalLink.d.ts +0 -3
  2. package/lib/apis/components/UniversalLink.js +3 -42
  3. package/lib/auth.d.ts +0 -2
  4. package/lib/auth.js +2 -2
  5. package/lib/components/AppContainer/index.js +3 -7
  6. package/lib/components/AppContainer/safety.js +0 -50
  7. package/lib/components/User/UserSelect.js +5 -3
  8. package/lib/hooks/useCurrentUserProfile.d.ts +15 -5
  9. package/lib/hooks/useCurrentUserProfile.js +12 -17
  10. package/lib/hooks/useLogout.js +3 -2
  11. package/lib/index.d.ts +0 -40
  12. package/lib/index.js +2 -32
  13. package/lib/integrations/dataloom.d.ts +1 -1
  14. package/lib/integrations/dataloom.js +12 -11
  15. package/lib/integrations/getCurrentUserProfile.d.ts +4 -3
  16. package/lib/integrations/services/types.d.ts +34 -0
  17. package/lib/locales/messages.js +0 -4
  18. package/lib/types/iframe-events.d.ts +1 -12
  19. package/lib/utils/postMessage.d.ts +0 -1
  20. package/lib/utils/postMessage.js +1 -1
  21. package/lib/utils/requestManager.js +4 -2
  22. package/package.json +4 -5
  23. package/lib/components/AppContainer/Watermark.d.ts +0 -60
  24. package/lib/components/AppContainer/Watermark.js +0 -364
  25. package/lib/components/AppContainer/__test__/Watermark.test.d.ts +0 -1
  26. package/lib/components/AppContainer/__test__/Watermark.test.js +0 -121
  27. package/lib/components/AppContainer/__test__/safety-error-boundary.test.d.ts +0 -1
  28. package/lib/components/AppContainer/__test__/safety-error-boundary.test.js +0 -53
  29. package/lib/components/AppContainer/doubao-watermark-asset.d.ts +0 -2
  30. package/lib/components/AppContainer/doubao-watermark-asset.js +0 -4
  31. package/lib/components/AppContainer/safety-error-boundary.d.ts +0 -23
  32. package/lib/components/AppContainer/safety-error-boundary.js +0 -29
  33. package/lib/integrations/__test__/dataloom.test.d.ts +0 -1
  34. package/lib/integrations/__test__/dataloom.test.js +0 -83
@@ -1,29 +0,0 @@
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 };
@@ -1 +0,0 @@
1
- export {};
@@ -1,83 +0,0 @@
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
- });