@lark-apaas/client-toolkit 1.2.76 → 1.2.77-alpha.20261101065543

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.
@@ -1,4 +1,5 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { getWatermarkVariant } from "./watermark-variant.js";
2
3
  import { useEffect, useRef, useState } from "react";
3
4
  import { Content, Portal, Root, Trigger } from "@radix-ui/react-popover";
4
5
  import { DOUBAO_BRAND_TEXT_SRC, DOUBAO_LOGO_SRC, MIAODA_LOGO_SRC } from "./doubao-watermark-asset.js";
@@ -6,8 +7,7 @@ import { getAppId } from "../../utils/getAppId.js";
6
7
  import { getEnv } from "../../utils/getParentOrigin.js";
7
8
  import { getInitialInfo } from "../../utils/getInitialInfo.js";
8
9
  import { useIsMobile } from "../../hooks/index.js";
9
- const DOUBAO_SOURCE = '5';
10
- const VARIANT = String(process.env.MIAODA_APP_SOURCE) === DOUBAO_SOURCE ? 'doubao' : 'miaoda';
10
+ const VARIANT = getWatermarkVariant(process.env.MIAODA_APP_SOURCE, process.env.MIAODA_APP_CREATED_VIA);
11
11
  const VARIANT_CONFIG = {
12
12
  doubao: {
13
13
  brandText: '豆包工作 AI 生成',
@@ -0,0 +1,63 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { getWatermarkVariant } from "../watermark-variant.js";
3
+ describe('getWatermarkVariant', ()=>{
4
+ it.each([
5
+ [
6
+ '5',
7
+ void 0,
8
+ 'doubao'
9
+ ],
10
+ [
11
+ '5',
12
+ 'miaoda',
13
+ 'doubao'
14
+ ],
15
+ [
16
+ '6',
17
+ 'doubao',
18
+ 'doubao'
19
+ ],
20
+ [
21
+ '6',
22
+ 'doubao_moa',
23
+ 'doubao'
24
+ ],
25
+ [
26
+ '6',
27
+ 'doubao_workmate',
28
+ 'doubao'
29
+ ],
30
+ [
31
+ '6',
32
+ ' DOUBAO_MOA ',
33
+ 'doubao'
34
+ ],
35
+ [
36
+ '6',
37
+ 'doubaox',
38
+ 'miaoda'
39
+ ],
40
+ [
41
+ '6',
42
+ 'miaoda',
43
+ 'miaoda'
44
+ ],
45
+ [
46
+ '6',
47
+ '',
48
+ 'miaoda'
49
+ ],
50
+ [
51
+ '6',
52
+ void 0,
53
+ 'miaoda'
54
+ ],
55
+ [
56
+ void 0,
57
+ void 0,
58
+ 'miaoda'
59
+ ]
60
+ ])('source=%s, createdVia=%s => %s', (source, createdVia, expected)=>{
61
+ expect(getWatermarkVariant(source, createdVia)).toBe(expected);
62
+ });
63
+ });
@@ -0,0 +1,2 @@
1
+ /** 保留既有 Source 判断,CreatedVia 补充豆包创建来源。 */
2
+ export declare function getWatermarkVariant(source: string | undefined, createdVia: string | undefined): 'doubao' | 'miaoda';
@@ -0,0 +1,5 @@
1
+ function getWatermarkVariant(source, createdVia) {
2
+ const origin = (createdVia ?? '').trim().toLowerCase();
3
+ return '5' === source || 'doubao' === origin || origin.startsWith('doubao_') ? 'doubao' : 'miaoda';
4
+ }
5
+ export { getWatermarkVariant };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/client-toolkit",
3
- "version": "1.2.76",
3
+ "version": "1.2.77-alpha.20261101065543",
4
4
  "types": "./lib/index.d.ts",
5
5
  "main": "./lib/index.js",
6
6
  "files": [