@celljs/ta-bots 4.16.0 → 4.18.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/README.en.md +2 -1
- package/README.md +2 -1
- package/extension/index.mjs +521 -28
- package/host/index.mjs +1130 -147
- package/package.json +3 -3
- package/web/index.js +19 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-bots",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.18.0",
|
|
4
4
|
"description": "A pi package for Ta: bots of WeChat (ClawBot) and WeCom connected to the double, an agent or a conversation, messages and files both ways",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@celljs/ta-protocol": "4.
|
|
31
|
-
"@celljs/ta-web": "4.
|
|
30
|
+
"@celljs/ta-protocol": "4.18.0",
|
|
31
|
+
"@celljs/ta-web": "4.18.0",
|
|
32
32
|
"@types/react": "^19.3.0"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
package/web/index.js
CHANGED
|
@@ -500,6 +500,15 @@ class BotsClient {
|
|
|
500
500
|
}
|
|
501
501
|
}
|
|
502
502
|
}
|
|
503
|
+
function chatIcons(client) {
|
|
504
|
+
return {
|
|
505
|
+
icon: (chat) => {
|
|
506
|
+
const bot = chat.sessionFile ? client.state.bots.find((candidate) => candidate.target?.kind === "session" && candidate.target.sessionFile === chat.sessionFile) : undefined;
|
|
507
|
+
return bot ? { icon: icon(KIND_ICON[bot.kind]), tint: bot.kind } : undefined;
|
|
508
|
+
},
|
|
509
|
+
subscribe: (listener) => client.subscribe(listener)
|
|
510
|
+
};
|
|
511
|
+
}
|
|
503
512
|
function useBots(client) {
|
|
504
513
|
return React.useSyncExternalStore((listener) => client.subscribe(listener), () => client.state);
|
|
505
514
|
}
|
|
@@ -634,6 +643,7 @@ function QrPanel({
|
|
|
634
643
|
onError
|
|
635
644
|
}) {
|
|
636
645
|
const Check = icon("Check");
|
|
646
|
+
const Loading = pi.ui.Loading ?? pi.ui.Skeleton;
|
|
637
647
|
const status = login?.status;
|
|
638
648
|
const handheld = pi.ui.useDevice().handheld;
|
|
639
649
|
const qrBox = React.useRef(null);
|
|
@@ -681,9 +691,10 @@ function QrPanel({
|
|
|
681
691
|
className: "tbo-qr-done"
|
|
682
692
|
}, /* @__PURE__ */ React.createElement(Check, {
|
|
683
693
|
size: 40
|
|
684
|
-
})) : /* @__PURE__ */ React.createElement(
|
|
685
|
-
|
|
686
|
-
|
|
694
|
+
})) : !error && /* @__PURE__ */ React.createElement(Loading, {
|
|
695
|
+
compact: true,
|
|
696
|
+
label: t("loading")
|
|
697
|
+
}), status === "expired" && /* @__PURE__ */ React.createElement("button", {
|
|
687
698
|
type: "button",
|
|
688
699
|
className: "tbo-qr-again",
|
|
689
700
|
onClick: onAgain
|
|
@@ -1191,12 +1202,11 @@ function BotRow({ bot, client, dialogs }) {
|
|
|
1191
1202
|
}), mark("remove"))));
|
|
1192
1203
|
}
|
|
1193
1204
|
function BotsPage({ client, dialogs }) {
|
|
1205
|
+
const Loading = pi.ui.Loading ?? pi.ui.Skeleton;
|
|
1194
1206
|
const { bots, loaded } = useBots(client);
|
|
1195
1207
|
return /* @__PURE__ */ React.createElement("div", {
|
|
1196
1208
|
className: "tbo-page"
|
|
1197
|
-
}, !loaded ? /* @__PURE__ */ React.createElement(pi.ui.
|
|
1198
|
-
rows: 3
|
|
1199
|
-
}) : bots.length === 0 ? /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
1209
|
+
}, !loaded ? /* @__PURE__ */ React.createElement(Loading, null) : bots.length === 0 ? /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
1200
1210
|
title: t("emptyTitle"),
|
|
1201
1211
|
hint: t("emptyHint"),
|
|
1202
1212
|
picture: /* @__PURE__ */ React.createElement(BotsPicture, null)
|
|
@@ -1364,7 +1374,6 @@ var STYLE = `
|
|
|
1364
1374
|
.tbo-qr { position: relative; display: flex; align-items: center; justify-content: center; width: 220px; height: 220px; border-radius: 14px; background: var(--ta-raised); }
|
|
1365
1375
|
.tbo-qr .ta-qr { transition: opacity 200ms, filter 200ms; }
|
|
1366
1376
|
.tbo-qr-dim .ta-qr { opacity: .25; filter: blur(2px); }
|
|
1367
|
-
.tbo-qr-wait { color: var(--ta-muted); font-size: calc(13px * var(--ta-font-scale)); }
|
|
1368
1377
|
.tbo-qr-done { display: inline-flex; align-items: center; justify-content: center; width: 72px; height: 72px; border-radius: 50%; background: var(--ta-green); color: #fff; animation: tbo-pop 320ms var(--ta-ease) both; }
|
|
1369
1378
|
@keyframes tbo-pop { from { opacity: 0; transform: scale(.7); } }
|
|
1370
1379
|
.tbo-qr-again { position: absolute; inset: auto auto 50% 50%; transform: translate(-50%, 50%); height: 32px; padding: 0 14px; border: 0; border-radius: 16px; background: var(--ta-brand); color: var(--ta-brand-text); font: inherit; font-size: calc(13px * var(--ta-font-scale)); cursor: pointer; }
|
|
@@ -1399,7 +1408,7 @@ var STYLE = `
|
|
|
1399
1408
|
.tbo-danger:hover { color: var(--ta-red); }
|
|
1400
1409
|
|
|
1401
1410
|
/* The page of the bots. */
|
|
1402
|
-
.tbo-page { box-sizing: border-box; display: flex; flex-direction: column; width: 100%; max-width:
|
|
1411
|
+
.tbo-page { box-sizing: border-box; display: flex; flex-direction: column; width: 100%; max-width: var(--ta-page-wide); min-height: 100%; margin: 0 auto; padding: 20px 24px 48px; }
|
|
1403
1412
|
.tbo-page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; font-size: calc(13px * var(--ta-font-scale)); }
|
|
1404
1413
|
.tbo-connect-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
|
|
1405
1414
|
.tbo-list { display: flex; flex-direction: column; gap: 8px; }
|
|
@@ -1451,6 +1460,7 @@ function activate(pi2) {
|
|
|
1451
1460
|
const dialogs = new DialogState;
|
|
1452
1461
|
client.start();
|
|
1453
1462
|
pi2.registerComposerAddon(composerAddon(client, dialogs));
|
|
1463
|
+
pi2.registerChatIcon?.(chatIcons(client));
|
|
1454
1464
|
pi2.registerMessageRenderer(INBOUND_TYPE, InboundMessage);
|
|
1455
1465
|
pi2.registerMessageRenderer(SENT_TYPE, SentMessageView);
|
|
1456
1466
|
BotToolLine.register(pi2, () => t("toolSendFile"));
|
|
@@ -1462,7 +1472,7 @@ function activate(pi2) {
|
|
|
1462
1472
|
dialogs
|
|
1463
1473
|
}),
|
|
1464
1474
|
order: 75,
|
|
1465
|
-
|
|
1475
|
+
group: "work"
|
|
1466
1476
|
});
|
|
1467
1477
|
return () => {
|
|
1468
1478
|
client.dispose();
|