@lark-apaas/client-toolkit 1.2.65 → 1.2.66-alpha.20260824233146
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/components/AppContainer/Watermark.js +19 -3
- package/lib/components/AppContainer/__test__/Watermark.test.js +2 -2
- package/lib/components/AppContainer/doubao-watermark-asset.d.ts +2 -1
- package/lib/components/AppContainer/doubao-watermark-asset.js +3 -2
- package/lib/components/AppContainer/index.js +1 -2
- package/lib/logger/selected-logs.js +5 -2
- package/package.json +1 -1
- package/lib/components/AppContainer/__test__/standalone.test.d.ts +0 -1
- package/lib/components/AppContainer/__test__/standalone.test.js +0 -36
- package/lib/components/AppContainer/standalone.d.ts +0 -17
- package/lib/components/AppContainer/standalone.js +0 -8
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useRef, useState } from "react";
|
|
3
3
|
import { Content, Portal, Root, Trigger } from "@radix-ui/react-popover";
|
|
4
|
-
import { DOUBAO_LOGO_SRC } from "./doubao-watermark-asset.js";
|
|
4
|
+
import { DOUBAO_LOGO_SRC, DOUBAO_PILL_MOBILE_PNG } from "./doubao-watermark-asset.js";
|
|
5
5
|
import { getAppId } from "../../utils/getAppId.js";
|
|
6
6
|
import { getEnv } from "../../utils/getParentOrigin.js";
|
|
7
7
|
import { useIsMobile } from "../../hooks/index.js";
|
|
@@ -265,11 +265,27 @@ const MobileWatermark = ({ onDontShow })=>{
|
|
|
265
265
|
position: 'fixed',
|
|
266
266
|
right: 12,
|
|
267
267
|
bottom: 12,
|
|
268
|
+
width: 122,
|
|
269
|
+
height: 30,
|
|
268
270
|
zIndex: 9999,
|
|
269
271
|
cursor: 'pointer'
|
|
270
272
|
},
|
|
271
|
-
children: /*#__PURE__*/ jsx(
|
|
272
|
-
|
|
273
|
+
children: /*#__PURE__*/ jsx("img", {
|
|
274
|
+
src: DOUBAO_PILL_MOBILE_PNG,
|
|
275
|
+
width: 166,
|
|
276
|
+
height: 94,
|
|
277
|
+
alt: "豆包 AI 生成",
|
|
278
|
+
style: {
|
|
279
|
+
position: 'absolute',
|
|
280
|
+
right: -12,
|
|
281
|
+
bottom: -40,
|
|
282
|
+
width: 166,
|
|
283
|
+
height: 94,
|
|
284
|
+
maxWidth: 'none',
|
|
285
|
+
maxHeight: 'none',
|
|
286
|
+
display: 'block',
|
|
287
|
+
pointerEvents: 'none'
|
|
288
|
+
}
|
|
273
289
|
})
|
|
274
290
|
})
|
|
275
291
|
}),
|
|
@@ -2,7 +2,7 @@ import { afterEach, describe, expect, it, vi } from "vitest";
|
|
|
2
2
|
import react from "react";
|
|
3
3
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
4
4
|
import Watermark, { Avatar, CloseIcon, FeedbackIcon, MenuCard, Pill, openDoubaoReport } from "../Watermark.js";
|
|
5
|
-
import { DOUBAO_LOGO_SRC } from "../doubao-watermark-asset.js";
|
|
5
|
+
import { DOUBAO_LOGO_SRC, DOUBAO_PILL_MOBILE_PNG } from "../doubao-watermark-asset.js";
|
|
6
6
|
const html = ()=>renderToStaticMarkup(/*#__PURE__*/ react.createElement(Watermark));
|
|
7
7
|
const setViewportWidth = (w)=>Object.defineProperty(window, 'innerWidth', {
|
|
8
8
|
value: w,
|
|
@@ -31,7 +31,7 @@ describe('Watermark(豆包来源水印)', ()=>{
|
|
|
31
31
|
setViewportWidth(375);
|
|
32
32
|
const out = html();
|
|
33
33
|
expect(out).toContain('data-custom-element="doubao-watermark-mobile"');
|
|
34
|
-
expect(out).toContain(
|
|
34
|
+
expect(out).toContain(DOUBAO_PILL_MOBILE_PNG);
|
|
35
35
|
expect(out).toContain('豆包 AI 生成');
|
|
36
36
|
expect(out).not.toContain('aria-label="关闭"');
|
|
37
37
|
});
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export declare const DOUBAO_LOGO_SRC = "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miaoda-ui/
|
|
1
|
+
export declare const DOUBAO_LOGO_SRC = "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miaoda-ui/setting_voice.svg";
|
|
2
|
+
export declare const DOUBAO_PILL_MOBILE_PNG = "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miaoda-ui/Frame%202147223991%20(3).png";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
const CDN = 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miaoda-ui';
|
|
2
|
-
const DOUBAO_LOGO_SRC = `${CDN}/
|
|
3
|
-
|
|
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 };
|
|
@@ -12,7 +12,6 @@ import { useAppInfo } from "../../hooks/index.js";
|
|
|
12
12
|
import { TrackKey } from "../../types/tea.js";
|
|
13
13
|
import { slardar } from "@lark-apaas/internal-slardar";
|
|
14
14
|
import Watermark, { isDoubaoSource } from "./Watermark.js";
|
|
15
|
-
import { isStandaloneBuild } from "./standalone.js";
|
|
16
15
|
import { getAppId } from "../../utils/getAppId.js";
|
|
17
16
|
import { isNewPathEnabled } from "../../utils/apiPath.js";
|
|
18
17
|
import QueryProvider from "../QueryProvider/index.js";
|
|
@@ -201,7 +200,7 @@ const AppContainer_AppContainer = (props)=>{
|
|
|
201
200
|
};
|
|
202
201
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
203
202
|
children: [
|
|
204
|
-
|
|
203
|
+
/*#__PURE__*/ jsx(SafetyErrorBoundary, {
|
|
205
204
|
children: isDoubaoSource() ? /*#__PURE__*/ jsx(Watermark, {}) : /*#__PURE__*/ jsx(Suspense, {
|
|
206
205
|
fallback: null,
|
|
207
206
|
children: /*#__PURE__*/ jsx(Safety, {})
|
|
@@ -24,6 +24,9 @@ const mapStacktrace = (stacktrace)=>stacktrace.map((frame)=>({
|
|
|
24
24
|
lineNumber: frame.lineNumber || 0,
|
|
25
25
|
columnNumber: frame.columnNumber || 0
|
|
26
26
|
}));
|
|
27
|
+
const getStackTraceOptions = ()=>'development' === process.env.NODE_ENV && 'vite' === process.env.BUILD_TOOL ? {
|
|
28
|
+
offline: true
|
|
29
|
+
} : void 0;
|
|
27
30
|
async function sendSelectedLog(logWithoutID) {
|
|
28
31
|
try {
|
|
29
32
|
const log = {
|
|
@@ -38,7 +41,7 @@ async function sendSelectedLog(logWithoutID) {
|
|
|
38
41
|
stack: error.stack
|
|
39
42
|
};
|
|
40
43
|
if (!log.meta.stacktrace) try {
|
|
41
|
-
const stacktrace = await stacktrace_js.fromError(error);
|
|
44
|
+
const stacktrace = await stacktrace_js.fromError(error, getStackTraceOptions());
|
|
42
45
|
log.meta.stacktrace = mapStacktrace(stacktrace);
|
|
43
46
|
} catch (e) {
|
|
44
47
|
if (window.parent !== window) try {
|
|
@@ -119,7 +122,7 @@ async function sendSelectedLog(logWithoutID) {
|
|
|
119
122
|
} catch (e) {}
|
|
120
123
|
}
|
|
121
124
|
async function getStacktrace() {
|
|
122
|
-
const stacktrace = await stacktrace_js.get();
|
|
125
|
+
const stacktrace = await stacktrace_js.get(getStackTraceOptions());
|
|
123
126
|
const frames = mapStacktrace(stacktrace);
|
|
124
127
|
return frames;
|
|
125
128
|
}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
describe('isStandaloneBuild', ()=>{
|
|
3
|
-
afterEach(()=>{
|
|
4
|
-
delete process.env.MIAODA_BUILD_TARGET;
|
|
5
|
-
vi.resetModules();
|
|
6
|
-
});
|
|
7
|
-
async function load() {
|
|
8
|
-
vi.resetModules();
|
|
9
|
-
return (await import("../standalone.js")).isStandaloneBuild;
|
|
10
|
-
}
|
|
11
|
-
it('MIAODA_BUILD_TARGET=standalone → true', async ()=>{
|
|
12
|
-
process.env.MIAODA_BUILD_TARGET = 'standalone';
|
|
13
|
-
expect((await load())()).toBe(true);
|
|
14
|
-
});
|
|
15
|
-
it('未设置 → false(平台正常构建,徽标照常显示)', async ()=>{
|
|
16
|
-
expect((await load())()).toBe(false);
|
|
17
|
-
});
|
|
18
|
-
it('其它取值 → false(--mode 将来扩展新形态时不误判为 standalone)', async ()=>{
|
|
19
|
-
process.env.MIAODA_BUILD_TARGET = 'something-else';
|
|
20
|
-
expect((await load())()).toBe(false);
|
|
21
|
-
});
|
|
22
|
-
it('精确匹配,不做前缀/包含判断', async ()=>{
|
|
23
|
-
process.env.MIAODA_BUILD_TARGET = 'standalone-v2';
|
|
24
|
-
expect((await load())()).toBe(false);
|
|
25
|
-
});
|
|
26
|
-
it('没有 process 全局时返回 false 而不是抛错', async ()=>{
|
|
27
|
-
const isStandaloneBuild = await load();
|
|
28
|
-
const original = globalThis.process;
|
|
29
|
-
delete globalThis.process;
|
|
30
|
-
try {
|
|
31
|
-
expect(isStandaloneBuild()).toBe(false);
|
|
32
|
-
} finally{
|
|
33
|
-
globalThis.process = original;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 是否为 standalone 导出构建(`miaoda app pack --mode standalone`)。
|
|
3
|
-
*
|
|
4
|
-
* standalone 产物脱离妙搭平台、以 `file://` 离线打开,平台徽标(Safety「由妙搭搭建」/
|
|
5
|
-
* 豆包水印)在这里既无意义也无从校验 —— 它们的显隐判据全是 **fail-open** 的:
|
|
6
|
-
* `showBadge` 拿不到平台数据就默认 true、接口失败也 catch 成 true,于是离线产物里
|
|
7
|
-
* 徽标必然出现,还附带两个必然失败的 `tenant_info` / `get_published` 请求。
|
|
8
|
-
* 所以 gate 在挂载处,让整棵子树不渲染,连 effect 里的请求一起省掉。
|
|
9
|
-
*
|
|
10
|
-
* `MIAODA_BUILD_TARGET` 由构建 preset 在 standalone 模式下 define 注入。
|
|
11
|
-
*
|
|
12
|
-
* **必须 try/catch**:客户端 bundle 里没有 `process` 全局,所有 `process.env.X` 全靠
|
|
13
|
-
* 构建期 define 做字符串替换。若应用升级了本 SDK 却仍用**旧版 preset**(不认识这个 key),
|
|
14
|
-
* 该表达式不会被替换,运行时直接 `ReferenceError: process is not defined` 把整个应用打挂。
|
|
15
|
-
* 与同目录 `Watermark.tsx` 的 `isDoubaoSource()` 同一防御口径。
|
|
16
|
-
*/
|
|
17
|
-
export declare const isStandaloneBuild: () => boolean;
|