@lark-apaas/client-toolkit 1.2.60 → 1.2.61-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.
- package/lib/apis/components/UniversalLink.d.ts +0 -3
- package/lib/apis/components/UniversalLink.js +3 -42
- package/lib/components/AppContainer/index.js +4 -9
- package/lib/components/AppContainer/safety.js +0 -50
- package/lib/hooks/useCurrentUserProfile.js +1 -1
- package/lib/index.d.ts +0 -40
- package/lib/index.js +2 -32
- package/lib/integrations/dataloom.d.ts +1 -1
- package/lib/integrations/dataloom.js +11 -5
- package/lib/integrations/services/types.d.ts +0 -43
- package/lib/locales/messages.js +0 -4
- package/lib/runtime/index.js +2 -0
- package/lib/runtime/preview-run.d.ts +29 -0
- package/lib/runtime/preview-run.js +76 -0
- package/lib/runtime/preview-run.spec.js +94 -0
- package/lib/types/iframe-events.d.ts +1 -12
- package/lib/utils/postMessage.d.ts +0 -1
- package/lib/utils/postMessage.js +1 -1
- package/package.json +3 -4
- package/lib/components/AppContainer/Watermark.d.ts +0 -60
- package/lib/components/AppContainer/Watermark.js +0 -364
- package/lib/components/AppContainer/__test__/Watermark.test.js +0 -121
- package/lib/components/AppContainer/__test__/safety-error-boundary.test.d.ts +0 -1
- package/lib/components/AppContainer/__test__/safety-error-boundary.test.js +0 -53
- package/lib/components/AppContainer/doubao-watermark-asset.d.ts +0 -2
- package/lib/components/AppContainer/doubao-watermark-asset.js +0 -4
- package/lib/components/AppContainer/safety-error-boundary.d.ts +0 -23
- package/lib/components/AppContainer/safety-error-boundary.js +0 -29
- package/lib/integrations/__test__/dataloom.test.d.ts +0 -1
- package/lib/integrations/__test__/dataloom.test.js +0 -83
- /package/lib/{components/AppContainer/__test__/Watermark.test.d.ts → runtime/preview-run.spec.d.ts} +0 -0
|
@@ -1,23 +0,0 @@
|
|
|
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 {};
|
|
@@ -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
|
-
});
|
/package/lib/{components/AppContainer/__test__/Watermark.test.d.ts → runtime/preview-run.spec.d.ts}
RENAMED
|
File without changes
|