@lark-apaas/miaoda-coding-sdk 0.0.14 → 0.0.15-alpha.20260920104806

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.
@@ -965,7 +965,7 @@ var MiaodaRuntime = (() => {
965
965
  }
966
966
  __name(getAppId, "getAppId");
967
967
  function getCsrfToken() {
968
- var _a2;
968
+ var _a;
969
969
  const cookieName = "suda-csrf-token";
970
970
  const cookies = document.cookie.split("; ");
971
971
  for (const cookie of cookies) {
@@ -974,7 +974,7 @@ var MiaodaRuntime = (() => {
974
974
  return decodeURIComponent(value);
975
975
  }
976
976
  }
977
- return (_a2 = window.csrfToken) != null ? _a2 : null;
977
+ return (_a = window.csrfToken) != null ? _a : null;
978
978
  }
979
979
  __name(getCsrfToken, "getCsrfToken");
980
980
  function isNewPathEnabled() {
@@ -994,10 +994,6 @@ var MiaodaRuntime = (() => {
994
994
  }
995
995
  }
996
996
  __name(getEnv, "getEnv");
997
- function isOnlineEnv() {
998
- return window.appEnv != null ? window.appEnv === "runtime" : false;
999
- }
1000
- __name(isOnlineEnv, "isOnlineEnv");
1001
997
  function isMobile() {
1002
998
  const ua = navigator.userAgent;
1003
999
  const isPhone = /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i.test(ua);
@@ -1005,28 +1001,8 @@ var MiaodaRuntime = (() => {
1005
1001
  return isPhone || isIpad;
1006
1002
  }
1007
1003
  __name(isMobile, "isMobile");
1008
- async function fetchShowBadge() {
1009
- var _a2, _b, _c;
1010
- try {
1011
- const appId = getAppId();
1012
- if (!appId) return true;
1013
- const url = isNewPathEnabled() ? `/app/${appId}/__runtime__/api/v1/studio/get_published` : `/spark/b/${appId}/get_published`;
1014
- const response = await fetch(url, {
1015
- headers: {
1016
- "X-Suda-Csrf-Token": (_a2 = getCsrfToken()) != null ? _a2 : ""
1017
- }
1018
- });
1019
- const res = await response.json();
1020
- if (res.code === 0 || res.status_code === "0") {
1021
- return ((_c = (_b = res.data) == null ? void 0 : _b.app_info) == null ? void 0 : _c.show_badge) !== false;
1022
- }
1023
- } catch {
1024
- }
1025
- return true;
1026
- }
1027
- __name(fetchShowBadge, "fetchShowBadge");
1028
1004
  async function getLarkUserInfo() {
1029
- var _a2;
1005
+ var _a;
1030
1006
  const appId = getAppId();
1031
1007
  if (!appId) {
1032
1008
  return {
@@ -1038,7 +1014,7 @@ var MiaodaRuntime = (() => {
1038
1014
  const url = isNewPathEnabled() ? `/app/${appId}/__runtime__/api/v1/studio/lark/user_info` : `/spark/b/${appId}/lark/user_info`;
1039
1015
  const response = await fetch(url, {
1040
1016
  headers: {
1041
- "X-Suda-Csrf-Token": (_a2 = getCsrfToken()) != null ? _a2 : ""
1017
+ "X-Suda-Csrf-Token": (_a = getCsrfToken()) != null ? _a : ""
1042
1018
  }
1043
1019
  });
1044
1020
  return await response.json();
@@ -1059,12 +1035,12 @@ var MiaodaRuntime = (() => {
1059
1035
  __name(encryptTea, "encryptTea");
1060
1036
  var teaInstance = false;
1061
1037
  async function createTracker() {
1062
- var _a2, _b, _c, _d;
1038
+ var _a, _b, _c, _d;
1063
1039
  const { data } = await getLarkUserInfo();
1064
1040
  const { tenantID, userID } = data || {};
1065
1041
  const userIDEncrypt = userID && userID !== "0" ? encryptTea(userID) : void 0;
1066
1042
  const tenantIDEncrypt = tenantID && tenantID !== "0" ? encryptTea(tenantID) : void 0;
1067
- (_a2 = window.collectEvent) == null ? void 0 : _a2.call(window, "init", {
1043
+ (_a = window.collectEvent) == null ? void 0 : _a.call(window, "init", {
1068
1044
  app_id: 788827,
1069
1045
  channel: "cn",
1070
1046
  disable_auto_pv: false,
@@ -1088,386 +1064,124 @@ var MiaodaRuntime = (() => {
1088
1064
  }
1089
1065
  __name(createTracker, "createTracker");
1090
1066
  async function reportTeaEvent({ trackKey, trackParams = {} }) {
1091
- var _a2;
1067
+ var _a;
1092
1068
  try {
1093
1069
  if (!teaInstance) {
1094
1070
  teaInstance = true;
1095
1071
  await createTracker();
1096
1072
  }
1097
- (_a2 = window.collectEvent) == null ? void 0 : _a2.call(window, trackKey, trackParams);
1073
+ (_a = window.collectEvent) == null ? void 0 : _a.call(window, trackKey, trackParams);
1098
1074
  } catch (err) {
1099
1075
  console.error(err);
1100
1076
  }
1101
1077
  }
1102
1078
  __name(reportTeaEvent, "reportTeaEvent");
1103
- function reportPageView() {
1104
- return reportTeaEvent({
1105
- trackKey: TrackKey.VIEW,
1106
- trackParams: {
1107
- artifact_uid: getAppId(),
1108
- agent_id: "agent_miaoda",
1109
- url: window.location.href
1110
- }
1111
- });
1112
- }
1113
- __name(reportPageView, "reportPageView");
1114
1079
 
1115
- // ../observable-web-lite/dist/index.mjs
1116
- function generateUUID() {
1117
- if (typeof crypto !== "undefined" && crypto.getRandomValues) {
1118
- const bytes = new Uint8Array(8);
1119
- crypto.getRandomValues(bytes);
1120
- return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
1121
- }
1122
- let result = "";
1123
- for (let i = 0; i < 16; i++) {
1124
- result += Math.floor(Math.random() * 16).toString(16);
1125
- }
1126
- return result;
1127
- }
1128
- __name(generateUUID, "generateUUID");
1129
- var STORAGE_KEY = "x_sdk_device_id";
1130
- function getDeviceId() {
1131
- try {
1132
- let id = localStorage.getItem(STORAGE_KEY);
1133
- if (!id) {
1134
- id = generateUUID();
1135
- localStorage.setItem(STORAGE_KEY, id);
1080
+ // src/runtime/feishu-feed-jsbridge.ts
1081
+ function markMiaodaFeedMessagesRead({ messageIds, token, docType = 113 }) {
1082
+ var _a, _b;
1083
+ if (messageIds.length === 0 || !token) return false;
1084
+ const payload = {
1085
+ apiName: "markMiaodaFeedMessagesRead",
1086
+ data: {
1087
+ __v2__: true,
1088
+ messageIds: messageIds.map(String),
1089
+ token,
1090
+ docType
1136
1091
  }
1137
- return id;
1138
- } catch {
1139
- return generateUUID();
1140
- }
1141
- }
1142
- __name(getDeviceId, "getDeviceId");
1143
- function getDeviceType() {
1144
- const ua = typeof navigator !== "undefined" ? navigator.userAgent : "";
1145
- if (!ua) return "desktop";
1146
- if (/Android/i.test(ua) && /Mobile/i.test(ua) || /iPhone|iPod/i.test(ua) || /BlackBerry|IEMobile|Opera Mini/i.test(ua)) {
1147
- return "mobile";
1092
+ };
1093
+ const w = window;
1094
+ const iosBridge = (_b = (_a = w.webkit) == null ? void 0 : _a.messageHandlers) == null ? void 0 : _b.invokeNative;
1095
+ if (iosBridge == null ? void 0 : iosBridge.postMessage) {
1096
+ iosBridge.postMessage(payload);
1097
+ return true;
1148
1098
  }
1149
- return "desktop";
1150
- }
1151
- __name(getDeviceType, "getDeviceType");
1152
- var PV_ID_PARAM = "pageSessionID";
1153
- function getPvId() {
1154
- try {
1155
- return new URLSearchParams(window.location.search).get(PV_ID_PARAM) || "";
1156
- } catch {
1157
- return "";
1099
+ const androidBridge = w.Lark_Bridge;
1100
+ if (androidBridge == null ? void 0 : androidBridge.invokeNative) {
1101
+ androidBridge.invokeNative(JSON.stringify(payload));
1102
+ return true;
1158
1103
  }
1104
+ return false;
1159
1105
  }
1160
- __name(getPvId, "getPvId");
1161
- function getDefaultAttributes(overrides = {}) {
1162
- const pvId = overrides.pvId || getPvId();
1163
- return {
1164
- app_id: window.appId || "",
1165
- tenant_id: window.tenantId || "",
1166
- user_id: window.userId || "",
1167
- did: getDeviceId(),
1168
- module: "app_web",
1169
- app_env: "runtime",
1170
- source_type: "user",
1171
- device_type: getDeviceType(),
1172
- release_commit_id: window.__RELEASE_COMMIT_ID__ || "",
1173
- // 只在真有值时落 key,不给空串占位(理由见 getPvId)
1174
- ...pvId ? { pv_id: pvId } : {}
1175
- };
1176
- }
1177
- __name(getDefaultAttributes, "getDefaultAttributes");
1178
- function toNanoString(ms) {
1179
- const msInt = Math.round(ms);
1180
- if (!Number.isFinite(msInt)) {
1181
- throw new RangeError(`toNanoString: \u975E\u6CD5\u65F6\u95F4\u6233 ${ms}`);
1182
- }
1183
- if (typeof BigInt !== "function") {
1184
- return msInt === 0 ? "0" : `${msInt}000000`;
1106
+ __name(markMiaodaFeedMessagesRead, "markMiaodaFeedMessagesRead");
1107
+
1108
+ // src/runtime/mark-feed-read.ts
1109
+ var DOC_TYPE = 113;
1110
+ var API_PATH_PREFIX = "/app/";
1111
+ var API_PATH_SUFFIX = "/__runtime__/api/v1/devops/read_lark_messages";
1112
+ function extractMessageIds(payload) {
1113
+ if (!payload || typeof payload !== "object") return [];
1114
+ const { data } = payload;
1115
+ if (Array.isArray(data)) return data.map(String);
1116
+ if (data && Array.isArray(data.message_ids)) {
1117
+ return data.message_ids.map(String);
1185
1118
  }
1186
- return String(BigInt(msInt) * BigInt(1e6));
1119
+ return [];
1187
1120
  }
1188
- __name(toNanoString, "toNanoString");
1189
- var SDK_VERSION = "1.0.2";
1190
- function buildPayload(dataPoints, overrides) {
1191
- const defaultAttrs = getDefaultAttributes(overrides);
1192
- const nowNs = toNanoString(Date.now());
1193
- return {
1194
- metricsData: {
1195
- resource: {
1196
- attributes: {
1197
- sdk_version: SDK_VERSION,
1198
- sdk_lang: "javascript",
1199
- sdk_type: "client-frontend"
1200
- }
1201
- },
1202
- metrics: [
1203
- {
1204
- name: "apaas_internal_metrics_pv_uv",
1205
- description: "Count of page views",
1206
- unit: "",
1207
- scopeName: "apaas_internal_metrics_pv_uv",
1208
- sum: {
1209
- aggregationTemporality: 1,
1210
- // DELTA
1211
- isMonotonic: true,
1212
- dataPoints: dataPoints.map((dp) => ({
1213
- attributes: {
1214
- ...defaultAttrs,
1215
- url: dp.url,
1216
- path: dp.path,
1217
- referrer: dp.referrer
1218
- },
1219
- startTimeUnixNano: toNanoString(dp.timestampMs),
1220
- timeUnixNano: nowNs,
1221
- asDouble: 1
1222
- }))
1223
- }
1224
- }
1225
- ]
1121
+ __name(extractMessageIds, "extractMessageIds");
1122
+ var markedOnce = false;
1123
+ async function fetchFeedMessageIds(appId) {
1124
+ var _a;
1125
+ const response = await fetch(`${API_PATH_PREFIX}${appId}${API_PATH_SUFFIX}`, {
1126
+ method: "POST",
1127
+ credentials: "same-origin",
1128
+ headers: {
1129
+ "Content-Type": "application/json",
1130
+ "X-Suda-Csrf-Token": (_a = getCsrfToken()) != null ? _a : ""
1226
1131
  }
1227
- };
1132
+ });
1133
+ if (!response.ok) return [];
1134
+ const json = await response.json();
1135
+ return extractMessageIds(json);
1228
1136
  }
1229
- __name(buildPayload, "buildPayload");
1230
- function sendPvData(collectorUrl, dataPoints, headers = {}, overrides) {
1231
- if (dataPoints.length === 0) return;
1232
- let body;
1233
- try {
1234
- body = JSON.stringify(buildPayload(dataPoints, overrides));
1235
- } catch {
1236
- return;
1237
- }
1137
+ __name(fetchFeedMessageIds, "fetchFeedMessageIds");
1138
+ async function markFeedReadOnce() {
1139
+ if (markedOnce) return;
1140
+ markedOnce = true;
1141
+ const appId = getAppId();
1142
+ if (!appId) return;
1238
1143
  try {
1239
- fetch(collectorUrl, {
1240
- method: "POST",
1241
- headers: {
1242
- "Content-Type": "application/json",
1243
- "X-Suda-Csrf-Token": window.csrfToken || "",
1244
- ...headers
1245
- },
1246
- body,
1247
- keepalive: true
1248
- }).catch(() => {
1144
+ const ids = await fetchFeedMessageIds(appId);
1145
+ if (!ids.length) return;
1146
+ markMiaodaFeedMessagesRead({
1147
+ messageIds: ids,
1148
+ token: appId,
1149
+ docType: DOC_TYPE
1249
1150
  });
1250
1151
  } catch {
1251
1152
  }
1252
1153
  }
1253
- __name(sendPvData, "sendPvData");
1254
- var PV_STARTED_FLAG = "__APAAS_PV_TRACKER_STARTED__";
1255
- function claimPvReporting() {
1256
- try {
1257
- const flags = window;
1258
- if (flags[PV_STARTED_FLAG]) return false;
1259
- flags[PV_STARTED_FLAG] = true;
1260
- return true;
1261
- } catch {
1262
- return true;
1263
- }
1264
- }
1265
- __name(claimPvReporting, "claimPvReporting");
1266
- function releasePvReporting() {
1267
- try {
1268
- window[PV_STARTED_FLAG] = false;
1269
- } catch {
1270
- }
1271
- }
1272
- __name(releasePvReporting, "releasePvReporting");
1273
- var _a;
1274
- var PvTracker = (_a = class {
1275
- constructor() {
1276
- this.started = false;
1277
- this.disposers = [];
1278
- this.holdsPvReporting = false;
1279
- this.buffer = [];
1280
- }
1281
- static get instance() {
1282
- if (!this._instance) {
1283
- this._instance = new _a();
1284
- }
1285
- return this._instance;
1286
- }
1287
- start(config) {
1288
- var _a2;
1289
- if (this.started) return;
1290
- if (!claimPvReporting()) return;
1291
- this.holdsPvReporting = true;
1292
- this.config = config;
1293
- this.started = true;
1294
- try {
1295
- this.listenRouteChanges();
1296
- this.registerLifecycleListeners();
1297
- const interval = (_a2 = config.flushIntervalMs) != null ? _a2 : 1e4;
1298
- this.flushTimer = setInterval(() => this.flush(), interval);
1299
- } catch (err) {
1300
- this.started = false;
1301
- if (this.flushTimer) {
1302
- clearInterval(this.flushTimer);
1303
- this.flushTimer = void 0;
1304
- }
1305
- this.holdsPvReporting = false;
1306
- releasePvReporting();
1307
- throw err;
1308
- }
1309
- }
1310
- shutdown() {
1311
- this.flush();
1312
- if (this.flushTimer) {
1313
- clearInterval(this.flushTimer);
1314
- this.flushTimer = void 0;
1315
- }
1316
- if (this.firstFlushTimer) {
1317
- clearTimeout(this.firstFlushTimer);
1318
- this.firstFlushTimer = void 0;
1319
- }
1320
- this.started = false;
1321
- for (const dispose of this.disposers.splice(0)) {
1322
- try {
1323
- dispose();
1324
- } catch {
1325
- }
1326
- }
1327
- if (this.holdsPvReporting) {
1328
- this.holdsPvReporting = false;
1329
- releasePvReporting();
1330
- }
1331
- }
1332
- /**
1333
- * PV 去重键:`origin + pathname + search`,**刻意不含 hash**。用 `location.href` 会让锚点跳转
1334
- * 和 hash 切换多计 PV(SPA 里 `pushState(null,'','#tab2')` 很常见),与"hash 变化不算 PV"的
1335
- * 口径矛盾。`search` **要算进去**:`?id=1` → `?id=2` 是不同内容,算新 PV。
1336
- */
1337
- pageKey() {
1338
- const { origin, pathname, search } = window.location;
1339
- return `${origin}${pathname}${search}`;
1340
- }
1341
- /**
1342
- * 安排首屏补发。**从首条 PV 真正入队时起算,不是从 `start()` 起算。**
1343
- *
1344
- * 曾经写在 `start()` 里,结果是:创意模式页面加载慢,PV 要等 `load` 才记录,而补发定时器
1345
- * 早在 start+1s 就烧掉了(那时 buffer 还空,flush 空跑),PV 只能等下一个 10s tick——线上
1346
- * 实测首次上报落在 **20.6s**。从入队时起算才对得上"首屏尽快发一次"的本意。
1347
- */
1348
- scheduleFirstFlush() {
1349
- var _a2;
1350
- const delay = (_a2 = this.config) == null ? void 0 : _a2.firstFlushDelayMs;
1351
- if (delay == null || this.firstFlushTimer) return;
1352
- this.firstFlushTimer = setTimeout(() => this.flush(), delay);
1353
- }
1354
- recordPv() {
1355
- const key = this.pageKey();
1356
- if (this.lastKey === key) return;
1357
- this.lastKey = key;
1358
- this.buffer.push({
1359
- // 上报完整 href(含 hash):去重不看 hash,但排障时想知道停在哪个片段
1360
- url: window.location.href,
1361
- path: window.location.pathname,
1362
- referrer: document.referrer,
1363
- timestampMs: Date.now()
1364
- });
1365
- this.scheduleFirstFlush();
1366
- }
1367
- flush() {
1368
- if (!this.config || this.buffer.length === 0) return;
1369
- const batch = this.buffer.splice(0);
1370
- sendPvData(this.config.collectorUrl, batch, this.config.headers, {
1371
- pvId: this.config.pvId
1372
- });
1373
- }
1374
- listenRouteChanges() {
1375
- this.recordPv();
1376
- const onPopState = /* @__PURE__ */ __name(() => this.recordPv(), "onPopState");
1377
- window.addEventListener("popstate", onPopState);
1378
- this.disposers.push(
1379
- () => window.removeEventListener("popstate", onPopState)
1380
- );
1381
- this.patchHistory("pushState");
1382
- this.patchHistory("replaceState");
1383
- }
1384
- patchHistory(method) {
1385
- const original = history[method];
1386
- const recordPv = /* @__PURE__ */ __name(() => this.recordPv(), "recordPv");
1387
- history[method] = function(...args) {
1388
- const result = original.apply(this, args);
1389
- recordPv();
1390
- return result;
1391
- };
1392
- this.disposers.push(() => {
1393
- history[method] = original;
1394
- });
1395
- }
1396
- registerLifecycleListeners() {
1397
- const onVisibilityChange = /* @__PURE__ */ __name(() => {
1398
- if (document.visibilityState === "hidden") this.flush();
1399
- }, "onVisibilityChange");
1400
- document.addEventListener("visibilitychange", onVisibilityChange);
1401
- this.disposers.push(
1402
- () => document.removeEventListener("visibilitychange", onVisibilityChange)
1403
- );
1404
- const onPageHide = /* @__PURE__ */ __name(() => this.flush(), "onPageHide");
1405
- window.addEventListener("pagehide", onPageHide);
1406
- this.disposers.push(
1407
- () => window.removeEventListener("pagehide", onPageHide)
1408
- );
1409
- }
1410
- }, __name(_a, "_PvTracker"), _a);
1411
- var pvTracker = PvTracker.instance;
1412
-
1413
- // src/runtime/pv.ts
1414
- function initPvTracking() {
1415
- var _a2;
1416
- const appId = (_a2 = getAppId()) != null ? _a2 : "";
1417
- const collectorUrl = isNewPathEnabled() ? `/app/${appId}/__runtime__/api/v1/observability/metrics/collect` : `/spark/app/${appId}/runtime/api/v1/observability/metrics/collect`;
1418
- pvTracker.start({
1419
- collectorUrl
1420
- });
1421
- }
1422
- __name(initPvTracking, "initPvTracking");
1154
+ __name(markFeedReadOnce, "markFeedReadOnce");
1423
1155
 
1424
1156
  // src/runtime/watermark.ts
1425
- var CDN = "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp";
1426
- var DOUBAO_LOGO_SRC = `${CDN}/miaoda-ui/doubao.svg`;
1427
- var MIAODA_LOGO_SRC = `${CDN}/logo/miaodalogo.svg`;
1157
+ var CDN = "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miaoda-ui";
1158
+ var DOUBAO_AVATAR_SRC = `${CDN}/setting_voice.svg`;
1159
+ var DOUBAO_PILL_MOBILE_PNG = `${CDN}/Frame%202147223991%20(3).png`;
1428
1160
  var CLOSE_ICON_SVG = '<svg viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8.08312 8.08298C8.2384 7.92769 8.23953 7.67705 8.08424 7.52176L5.3625 4.80002L8.08422 2.07829C8.23951 1.92301 8.23839 1.67236 8.0831 1.51708C7.92781 1.36179 7.67717 1.36066 7.52188 1.51595C7.36659 1.67124 4.80016 4.23767 4.80016 4.23767L2.07841 1.51593C1.92313 1.36064 1.67248 1.36177 1.5172 1.51705C1.36191 1.67234 1.36078 1.92298 1.51607 2.07827L4.23782 4.80002L1.51605 7.52178C1.36076 7.67707 1.36189 7.92771 1.51718 8.083C1.67246 8.23829 1.92311 8.23941 2.07839 8.08412L4.80016 5.36236L7.5219 8.0841C7.67719 8.23939 7.92783 8.23826 8.08312 8.08298Z" fill="currentColor"/></svg>';
1429
1161
  var FEEDBACK_ICON_SVG = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12.6667 2H3.33333V14H6.66667V15.3334H3.33333C2.59695 15.3334 2 14.7364 2 14V2C2 1.26364 2.59695 0.666687 3.33333 0.666687H12.6667C13.403 0.666687 14 1.26364 14 2V7.33335H12.6667V2Z" fill="currentColor"/><path d="M5.33333 4.66669C4.96514 4.66669 4.66667 4.96516 4.66667 5.33335C4.66667 5.70154 4.96514 6 5.33333 6H10.6667C11.0349 6 11.3333 5.70154 11.3333 5.33335C11.3333 4.96516 11.0349 4.66669 10.6667 4.66669H5.33333Z" fill="currentColor"/><path d="M4.66667 8.33335C4.66667 7.96516 4.96514 7.66669 5.33333 7.66669H8C8.36819 7.66669 8.66667 7.96516 8.66667 8.33335C8.66667 8.70154 8.36819 9 8 9H5.33333C4.96514 9 4.66667 8.70154 4.66667 8.33335Z" fill="currentColor"/><path d="M13.5523 8.70017C13.9428 8.30964 14.576 8.30964 14.9665 8.70017C15.357 9.09069 15.357 9.72386 14.9665 10.1144L14.2594 10.8215L12.8452 9.40728L13.5523 8.70017Z" fill="currentColor"/><path d="M12.1381 10.1144L13.5523 11.5286L10.2309 14.85C10.0916 14.9892 9.91229 15.0815 9.71798 15.1138L8.45737 15.3234C8.42136 15.3294 8.38467 15.3177 8.35885 15.2918C8.33271 15.2657 8.32099 15.2284 8.32749 15.192L8.55128 13.9374C8.58465 13.7502 8.6746 13.5779 8.80901 13.4435L12.1381 10.1144Z" fill="currentColor"/></svg>';
1430
- var DOWNLOAD_ICON_SVG = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M11.9922 1.99221C12.5445 1.98895 12.9958 2.43407 12.999 2.98634L13.0762 16.1943L14.6387 14.6328L17.8926 11.3789C18.2831 10.9884 18.9171 10.9885 19.3076 11.3789C19.6977 11.7695 19.6979 12.4026 19.3076 12.793L16.0527 16.0479L12.7979 19.3018C12.7111 19.3884 12.6098 19.4566 12.5 19.5059H20.375C20.9271 19.5059 21.3748 19.9538 21.375 20.5059C21.375 21.0581 20.9273 21.5059 20.375 21.5059H3.625C3.07272 21.5059 2.625 21.0581 2.625 20.5059C2.62523 19.9538 3.07286 19.5059 3.625 19.5059H11.6816C11.572 19.4566 11.4704 19.3884 11.3838 19.3018L4.87402 12.793C4.48372 12.4026 4.4839 11.7694 4.87402 11.3789C5.26452 10.9884 5.89756 10.9885 6.28809 11.3789L11.0762 16.166L10.999 2.99806C10.9958 2.44603 11.4402 1.99582 11.9922 1.99221Z" fill="currentColor"/></svg>';
1431
- var EFFICIENCY_ICON_SVG = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M2.0754 7.57153C2.23188 9.44922 3.49231 11.053 5.27982 11.6488C5.31351 11.6601 5.33994 11.6865 5.35117 11.7202L5.72076 12.8289C5.88752 13.3292 6.3557 13.6667 6.88304 13.6667H9.11696C9.6443 13.6667 10.1125 13.3292 10.2792 12.8289L10.6488 11.7202C10.6601 11.6865 10.6865 11.6601 10.7202 11.6488C12.5077 11.053 13.7681 9.44922 13.9246 7.57153L14 6.66667C14 3.35296 11.3137 0.666668 8 0.666668C4.68629 0.666668 2 3.35296 2 6.66667L2.0754 7.57153ZM9.38392 11.2985L9.03899 12.3333H6.96101L6.61608 11.2985C6.47214 10.8667 6.13328 10.5279 5.70146 10.3839C4.41995 9.95675 3.51631 8.80696 3.40413 7.4608L3.33362 6.61462C3.36152 4.06127 5.44004 2 8 2C10.56 2 12.6385 4.06127 12.6664 6.61462L12.5959 7.4608C12.4837 8.80696 11.5801 9.95675 10.2985 10.3839C9.86672 10.5279 9.52786 10.8667 9.38392 11.2985Z" fill="currentColor"/><path d="M6.66667 14.3333C6.29848 14.3333 6 14.6318 6 15C6 15.3682 6.29848 15.6667 6.66667 15.6667H9.33333C9.70152 15.6667 10 15.3682 10 15C10 14.6318 9.70152 14.3333 9.33333 14.3333H6.66667Z" fill="currentColor"/><path d="M8.00864 4.13208L5.44578 6.94049C5.20258 7.18228 5.37835 7.56531 5.74361 7.58951L7.2181 7.6872L7.21814 9.60852C7.21814 9.96788 7.72139 10.1366 7.99168 9.86792C8.26197 9.59921 10.5545 7.05951 10.5545 7.05951C10.7977 6.81772 10.622 6.43469 10.2567 6.41049L8.78222 6.3128L8.78219 4.39148C8.78218 4.03212 8.27893 3.86336 8.00864 4.13208Z" fill="currentColor"/></svg>';
1432
1162
  var REPORT_ENABLED = true;
1163
+ var BRAND_TEXT = "\u8C46\u5305 AI \u751F\u6210";
1164
+ var POWERED_BY_TEXT = "\u7531\u98DE\u4E66\u5999\u642D\u63D0\u4F9B\u652F\u6301";
1433
1165
  var PILL_SHADOW = "0px 8px 32px rgba(0,0,0,0.08), 0px 4px 16px rgba(0,0,0,0.04), 0px 2px 4px rgba(0,0,0,0.02)";
1434
1166
  var CARD_SHADOW = "0px 4px 16px rgba(0,0,0,0.03), 0px 4px 10px rgba(0,0,0,0.03), 0px 2px 4px rgba(0,0,0,0.02)";
1435
1167
  var FONT_FAMILY = "'PingFang SC', -apple-system, BlinkMacSystemFont, sans-serif";
1436
- var VARIANT_CONFIG = {
1437
- doubao: {
1438
- brandText: "\u8C46\u5305\u5DE5\u4F5C\u751F\u6210",
1439
- logoSrc: DOUBAO_LOGO_SRC,
1440
- downloadUrl: "https://ugapk.com/FCtLH"
1441
- },
1442
- miaoda: {
1443
- brandText: "\u5999\u642D\u751F\u6210",
1444
- logoSrc: MIAODA_LOGO_SRC,
1445
- landingUrl: "https://miaoda.feishu.cn/landing"
1446
- }
1447
- };
1448
1168
  var REPORT_DOMAIN = {
1449
1169
  BOE: "tns.feishu-boe.cn",
1450
1170
  PRE: "tns.feishu-pre.cn",
1451
1171
  ONLINE: "tns.feishu.cn"
1452
1172
  };
1453
- function openReport() {
1454
- var _a2;
1173
+ function openDoubaoReport() {
1174
+ var _a;
1455
1175
  const params = JSON.stringify({
1456
1176
  scene: "miaoda_app_report",
1457
- entity_id: (_a2 = getAppId()) != null ? _a2 : "",
1177
+ entity_id: (_a = getAppId()) != null ? _a : "",
1458
1178
  entity_type: "miaoda_app",
1459
1179
  extra: ""
1460
1180
  });
1461
1181
  const url = `https://${REPORT_DOMAIN[getEnv()]}/cust/lark_report/?type=common&params=${encodeURIComponent(params)}&lang=zh-CN`;
1462
1182
  window.open(url, "_blank", "noopener,noreferrer");
1463
1183
  }
1464
- __name(openReport, "openReport");
1465
- var ICON_SVG_MAP = {
1466
- feedback: FEEDBACK_ICON_SVG,
1467
- close: CLOSE_ICON_SVG,
1468
- download: DOWNLOAD_ICON_SVG,
1469
- efficiency: EFFICIENCY_ICON_SVG
1470
- };
1184
+ __name(openDoubaoReport, "openDoubaoReport");
1471
1185
  function makeCloseIcon(size) {
1472
1186
  const span = document.createElement("span");
1473
1187
  Object.assign(span.style, {
@@ -1486,24 +1200,9 @@ var MiaodaRuntime = (() => {
1486
1200
  return span;
1487
1201
  }
1488
1202
  __name(makeCloseIcon, "makeCloseIcon");
1489
- function makeIcon(type, size = 16) {
1490
- if (type === "close") return makeCloseIcon(size);
1491
- const span = document.createElement("span");
1492
- Object.assign(span.style, {
1493
- display: "inline-flex",
1494
- width: `${size}px`,
1495
- height: `${size}px`,
1496
- flexShrink: "0"
1497
- });
1498
- span.innerHTML = ICON_SVG_MAP[type];
1499
- const svg = span.firstElementChild;
1500
- if (svg) svg.style.display = "block";
1501
- return span;
1502
- }
1503
- __name(makeIcon, "makeIcon");
1504
- function makeLogo(src, size) {
1203
+ function makeAvatar(size) {
1505
1204
  const img = document.createElement("img");
1506
- img.src = src;
1205
+ img.src = DOUBAO_AVATAR_SRC;
1507
1206
  img.width = size;
1508
1207
  img.height = size;
1509
1208
  img.alt = "";
@@ -1518,26 +1217,25 @@ var MiaodaRuntime = (() => {
1518
1217
  });
1519
1218
  return img;
1520
1219
  }
1521
- __name(makeLogo, "makeLogo");
1522
- function buildPill(variant, platform, onClose) {
1523
- const isDesktop = platform === "desktop";
1524
- const config = VARIANT_CONFIG[variant];
1220
+ __name(makeAvatar, "makeAvatar");
1221
+ function buildPill(variant, onClose) {
1222
+ const isDesktop = variant === "desktop";
1525
1223
  const pill = document.createElement("div");
1526
1224
  Object.assign(pill.style, {
1527
1225
  boxSizing: "border-box",
1528
1226
  display: "inline-flex",
1529
1227
  alignItems: "center",
1530
- gap: "4px",
1531
- padding: isDesktop ? "6px 12px 6px 8px" : "5px 12px 5px 8px",
1228
+ gap: isDesktop ? "4px" : "6px",
1229
+ padding: isDesktop ? "6px 12px 6px 8px" : "4px 12px 4px 8px",
1532
1230
  background: "#363636",
1533
1231
  border: "0.5px solid rgba(255,255,255,0.1)",
1534
1232
  borderRadius: "100px",
1535
1233
  boxShadow: PILL_SHADOW,
1536
1234
  cursor: "pointer"
1537
1235
  });
1538
- const logo = makeLogo(config.logoSrc, 16);
1236
+ const avatar = makeAvatar(isDesktop ? 16 : 18);
1539
1237
  const text = document.createElement("span");
1540
- text.textContent = config.brandText;
1238
+ text.textContent = BRAND_TEXT;
1541
1239
  Object.assign(text.style, {
1542
1240
  fontFamily: FONT_FAMILY,
1543
1241
  fontSize: isDesktop ? "12px" : "14px",
@@ -1545,12 +1243,12 @@ var MiaodaRuntime = (() => {
1545
1243
  color: "rgba(255,255,255,0.85)",
1546
1244
  whiteSpace: "nowrap"
1547
1245
  });
1548
- pill.append(logo, text);
1246
+ pill.append(avatar, text);
1549
1247
  if (isDesktop && onClose) {
1550
1248
  const close = document.createElement("span");
1551
1249
  close.setAttribute("role", "button");
1552
1250
  close.setAttribute("aria-label", "\u5173\u95ED");
1553
- close.setAttribute("data-watermark-close", "");
1251
+ close.setAttribute("data-doubao-close", "");
1554
1252
  Object.assign(close.style, {
1555
1253
  display: "none",
1556
1254
  alignItems: "center",
@@ -1577,7 +1275,6 @@ var MiaodaRuntime = (() => {
1577
1275
  display: "flex",
1578
1276
  alignItems: "center",
1579
1277
  gap: "8px",
1580
- minHeight: "38px",
1581
1278
  padding: "4px 10px",
1582
1279
  borderRadius: "6px",
1583
1280
  cursor: "pointer",
@@ -1591,7 +1288,11 @@ var MiaodaRuntime = (() => {
1591
1288
  flexShrink: "0",
1592
1289
  color: "#000000"
1593
1290
  });
1594
- icon.appendChild(makeIcon(opts.icon));
1291
+ if (opts.icon === "feedback") {
1292
+ icon.innerHTML = FEEDBACK_ICON_SVG;
1293
+ } else {
1294
+ icon.appendChild(makeCloseIcon(16));
1295
+ }
1595
1296
  const label = document.createElement("span");
1596
1297
  label.textContent = opts.label;
1597
1298
  Object.assign(label.style, {
@@ -1612,18 +1313,7 @@ var MiaodaRuntime = (() => {
1612
1313
  return row;
1613
1314
  }
1614
1315
  __name(buildMenuRow, "buildMenuRow");
1615
- function buildDivider() {
1616
- const div = document.createElement("div");
1617
- Object.assign(div.style, {
1618
- height: "1px",
1619
- background: "rgba(0,0,0,0.08)",
1620
- margin: "0 10px"
1621
- });
1622
- return div;
1623
- }
1624
- __name(buildDivider, "buildDivider");
1625
1316
  function buildMenuCard(opts) {
1626
- var _a2;
1627
1317
  const card = document.createElement("div");
1628
1318
  Object.assign(card.style, {
1629
1319
  boxSizing: "border-box",
@@ -1637,104 +1327,61 @@ var MiaodaRuntime = (() => {
1637
1327
  overflow: "hidden",
1638
1328
  outline: "none"
1639
1329
  });
1640
- if (opts.items.length) {
1641
- const section = document.createElement("div");
1642
- Object.assign(section.style, {
1643
- boxSizing: "border-box",
1644
- padding: "4px",
1645
- display: "flex",
1646
- flexDirection: "column",
1647
- gap: `${(_a2 = opts.itemGap) != null ? _a2 : 0}px`
1648
- });
1649
- opts.items.forEach((r) => section.appendChild(r));
1650
- card.appendChild(section);
1651
- }
1652
- if (opts.extraItems && opts.extraItems.length) {
1653
- card.appendChild(buildDivider());
1654
- const section = document.createElement("div");
1655
- Object.assign(section.style, {
1330
+ if (opts.rows.length) {
1331
+ const items = document.createElement("div");
1332
+ Object.assign(items.style, {
1656
1333
  boxSizing: "border-box",
1657
1334
  padding: "4px"
1658
1335
  });
1659
- opts.extraItems.forEach((r) => section.appendChild(r));
1660
- card.appendChild(section);
1336
+ opts.rows.forEach((r) => items.appendChild(r));
1337
+ card.appendChild(items);
1661
1338
  }
1339
+ const footer = document.createElement("div");
1340
+ footer.textContent = POWERED_BY_TEXT;
1341
+ Object.assign(footer.style, {
1342
+ boxSizing: "border-box",
1343
+ background: "#f9f9f9",
1344
+ padding: "8px 14px",
1345
+ fontFamily: FONT_FAMILY,
1346
+ fontSize: `${opts.footerFontSize}px`,
1347
+ lineHeight: `${opts.footerFontSize + 8}px`,
1348
+ color: "rgba(0,0,0,0.35)",
1349
+ whiteSpace: "nowrap"
1350
+ });
1351
+ card.appendChild(footer);
1662
1352
  return card;
1663
1353
  }
1664
1354
  __name(buildMenuCard, "buildMenuCard");
1665
- function createWatermarkRoot(variant, mobile = false) {
1666
- const host = document.createElement("div");
1667
- host.setAttribute("data-custom-element", `${variant}-watermark${mobile ? "-mobile" : ""}`);
1668
- const shadow = host.attachShadow({
1669
- mode: "open"
1670
- });
1671
- const style = document.createElement("style");
1672
- style.textContent = `
1673
- :host {
1674
- all: initial !important;
1675
- display: block !important;
1676
- position: fixed !important;
1677
- right: 12px !important;
1678
- bottom: 12px !important;
1679
- z-index: 9999 !important;
1680
- direction: ltr !important;
1681
- unicode-bidi: isolate !important;
1682
- }
1683
- :host::before, :host::after { content: none !important; }
1684
- .watermark-root {
1685
- all: initial;
1686
- direction: ltr;
1687
- unicode-bidi: isolate;
1688
- font-family: ${FONT_FAMILY};
1689
- display: flex;
1690
- flex-direction: column;
1691
- align-items: flex-end;
1692
- gap: 8px;
1693
- }
1694
- `;
1355
+ function buildDesktopWatermark() {
1695
1356
  const container = document.createElement("div");
1696
- container.className = "watermark-root";
1697
- shadow.append(style, container);
1698
- return {
1699
- host,
1700
- container
1701
- };
1702
- }
1703
- __name(createWatermarkRoot, "createWatermarkRoot");
1704
- function buildDesktopWatermark(variant) {
1705
- const { host, container } = createWatermarkRoot(variant);
1706
- const items = [];
1707
- if (variant === "doubao") {
1708
- items.push(buildMenuRow({
1709
- icon: "download",
1710
- label: "\u4E0B\u8F7D\u8C46\u5305\u5DE5\u4F5C",
1711
- fontSize: 14,
1712
- onClick: /* @__PURE__ */ __name(() => window.open(VARIANT_CONFIG.doubao.downloadUrl, "_blank", "noopener,noreferrer"), "onClick")
1713
- }));
1714
- } else {
1715
- items.push(buildMenuRow({
1716
- icon: "efficiency",
1717
- label: "\u4E86\u89E3\u5999\u642D",
1718
- fontSize: 14,
1719
- onClick: /* @__PURE__ */ __name(() => window.open(VARIANT_CONFIG.miaoda.landingUrl, "_blank", "noopener,noreferrer"), "onClick")
1720
- }));
1721
- }
1357
+ container.setAttribute("data-custom-element", "doubao-watermark");
1358
+ Object.assign(container.style, {
1359
+ position: "fixed",
1360
+ right: "12px",
1361
+ bottom: "12px",
1362
+ zIndex: "9999",
1363
+ display: "flex",
1364
+ flexDirection: "column",
1365
+ alignItems: "flex-end",
1366
+ gap: "8px"
1367
+ });
1368
+ const rows = [];
1722
1369
  if (REPORT_ENABLED) {
1723
- items.push(buildMenuRow({
1370
+ rows.push(buildMenuRow({
1724
1371
  icon: "feedback",
1725
1372
  label: "\u6295\u8BC9\u4E0E\u4E3E\u62A5",
1726
1373
  fontSize: 14,
1727
- onClick: openReport
1374
+ onClick: openDoubaoReport
1728
1375
  }));
1729
1376
  }
1730
1377
  const menu = buildMenuCard({
1731
- items,
1732
- minWidth: 160,
1733
- itemGap: 8
1378
+ rows,
1379
+ footerFontSize: 12,
1380
+ minWidth: 144
1734
1381
  });
1735
1382
  menu.style.display = "none";
1736
- const pill = buildPill(variant, "desktop", () => host.remove());
1737
- const close = pill.querySelector("[data-watermark-close]");
1383
+ const pill = buildPill("desktop", () => container.remove());
1384
+ const close = pill.querySelector("[data-doubao-close]");
1738
1385
  container.append(menu, pill);
1739
1386
  let timer = null;
1740
1387
  container.addEventListener("mouseenter", () => {
@@ -1748,91 +1395,101 @@ var MiaodaRuntime = (() => {
1748
1395
  if (close) close.style.display = "none";
1749
1396
  }, 100);
1750
1397
  });
1751
- return host;
1398
+ return container;
1752
1399
  }
1753
1400
  __name(buildDesktopWatermark, "buildDesktopWatermark");
1754
- function buildMobileWatermark(variant) {
1755
- const { host, container: wrapper } = createWatermarkRoot(variant, true);
1756
- wrapper.style.cursor = "pointer";
1757
- const items = [];
1758
- if (variant === "miaoda") {
1759
- items.push(buildMenuRow({
1760
- icon: "efficiency",
1761
- label: "\u4E86\u89E3\u5999\u642D",
1762
- fontSize: 16,
1763
- onClick: /* @__PURE__ */ __name(() => window.open(VARIANT_CONFIG.miaoda.landingUrl, "_blank", "noopener,noreferrer"), "onClick")
1764
- }));
1765
- }
1401
+ function buildMobileWatermark() {
1402
+ const wrapper = document.createElement("div");
1403
+ wrapper.setAttribute("data-custom-element", "doubao-watermark-mobile");
1404
+ Object.assign(wrapper.style, {
1405
+ position: "fixed",
1406
+ right: "12px",
1407
+ bottom: "12px",
1408
+ width: "122px",
1409
+ height: "30px",
1410
+ zIndex: "9999",
1411
+ cursor: "pointer"
1412
+ });
1413
+ const pill = document.createElement("img");
1414
+ pill.src = DOUBAO_PILL_MOBILE_PNG;
1415
+ pill.width = 166;
1416
+ pill.height = 94;
1417
+ pill.alt = "\u8C46\u5305 AI \u751F\u6210";
1418
+ Object.assign(pill.style, {
1419
+ position: "absolute",
1420
+ right: "-12px",
1421
+ bottom: "-40px",
1422
+ width: "166px",
1423
+ height: "94px",
1424
+ maxWidth: "none",
1425
+ maxHeight: "none",
1426
+ display: "block",
1427
+ pointerEvents: "none"
1428
+ });
1429
+ wrapper.appendChild(pill);
1430
+ const rows = [];
1766
1431
  if (REPORT_ENABLED) {
1767
- items.push(buildMenuRow({
1432
+ rows.push(buildMenuRow({
1768
1433
  icon: "feedback",
1769
1434
  label: "\u6295\u8BC9\u4E0E\u4E3E\u62A5",
1770
1435
  fontSize: 16,
1771
- onClick: openReport
1436
+ onClick: openDoubaoReport
1772
1437
  }));
1773
1438
  }
1774
- const extraItems = [
1775
- buildMenuRow({
1776
- icon: "close",
1777
- label: "\u4E0D\u518D\u5C55\u793A",
1778
- fontSize: 16,
1779
- onClick: /* @__PURE__ */ __name((e) => {
1780
- e.stopPropagation();
1781
- document.removeEventListener("click", onOutsideClick);
1782
- host.remove();
1783
- }, "onClick")
1784
- })
1785
- ];
1439
+ rows.push(buildMenuRow({
1440
+ icon: "close",
1441
+ label: "\u4E0D\u518D\u5C55\u793A",
1442
+ fontSize: 16,
1443
+ onClick: /* @__PURE__ */ __name((e) => {
1444
+ e.stopPropagation();
1445
+ wrapper.remove();
1446
+ }, "onClick")
1447
+ }));
1786
1448
  const menu = buildMenuCard({
1787
- items,
1788
- extraItems,
1449
+ rows,
1450
+ footerFontSize: 14,
1789
1451
  minWidth: 160
1790
1452
  });
1791
- menu.style.display = "none";
1792
- const pill = buildPill(variant, "mobile");
1793
- wrapper.append(menu, pill);
1453
+ Object.assign(menu.style, {
1454
+ position: "absolute",
1455
+ right: "0",
1456
+ bottom: "38px",
1457
+ display: "none"
1458
+ });
1459
+ wrapper.appendChild(menu);
1794
1460
  wrapper.addEventListener("click", (e) => {
1795
1461
  e.stopPropagation();
1796
1462
  menu.style.display = menu.style.display === "none" ? "flex" : "none";
1797
1463
  });
1798
- const onOutsideClick = /* @__PURE__ */ __name(() => {
1464
+ document.addEventListener("click", () => {
1799
1465
  menu.style.display = "none";
1800
- }, "onOutsideClick");
1801
- document.addEventListener("click", onOutsideClick);
1802
- return host;
1466
+ });
1467
+ return wrapper;
1803
1468
  }
1804
1469
  __name(buildMobileWatermark, "buildMobileWatermark");
1805
1470
  var mounted = false;
1806
- var pending = false;
1807
- async function mountWatermark(variant) {
1808
- if (mounted || pending || typeof document === "undefined") return;
1471
+ function mountDoubaoWatermark() {
1472
+ if (mounted || typeof document === "undefined") return;
1809
1473
  if (document.readyState === "loading") {
1810
- document.addEventListener("DOMContentLoaded", () => mountWatermark(variant), {
1474
+ document.addEventListener("DOMContentLoaded", mountDoubaoWatermark, {
1811
1475
  once: true
1812
1476
  });
1813
1477
  return;
1814
1478
  }
1815
- pending = true;
1816
- const shouldShow = await fetchShowBadge();
1817
1479
  mounted = true;
1818
- pending = false;
1819
- if (!shouldShow) return;
1820
- const el = isMobile() ? buildMobileWatermark(variant) : buildDesktopWatermark(variant);
1480
+ const el = isMobile() ? buildMobileWatermark() : buildDesktopWatermark();
1821
1481
  document.body.appendChild(el);
1822
1482
  }
1823
- __name(mountWatermark, "mountWatermark");
1824
- function mountDoubaoWatermark() {
1825
- return mountWatermark("doubao");
1826
- }
1827
1483
  __name(mountDoubaoWatermark, "mountDoubaoWatermark");
1828
1484
 
1829
1485
  // src/doubao-runtime.ts
1830
- var version = "0.0.14";
1486
+ var version = "0.0.15-alpha.20260920104806";
1831
1487
  var name = "@lark-apaas/miaoda-coding-sdk";
1832
- if (isOnlineEnv()) {
1488
+ if (false) {
1833
1489
  reportPageView();
1834
1490
  initPvTracking();
1835
1491
  }
1836
1492
  mountDoubaoWatermark();
1493
+ void markFeedReadOnce();
1837
1494
  return __toCommonJS(doubao_runtime_exports);
1838
1495
  })();