@decentnetwork/beagle 0.1.109 → 0.1.111
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/dist/desktop/app.js +87 -9
- package/package.json +2 -2
package/dist/desktop/app.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
window.__DK_UI_VERSION="0.1.
|
|
1
|
+
window.__DK_UI_VERSION="0.1.111";
|
|
2
2
|
"use strict";
|
|
3
3
|
(() => {
|
|
4
4
|
// packages/beagle-ui/dist/beagle-ui.js
|
|
@@ -869,6 +869,12 @@ window.__DK_UI_VERSION="0.1.109";
|
|
|
869
869
|
kind: "node",
|
|
870
870
|
role: "server"
|
|
871
871
|
},
|
|
872
|
+
{
|
|
873
|
+
userid: "5SxEBHAx49Hknq1VzrA1HDtZHjW31vetX3iMEi4P6pK3",
|
|
874
|
+
name: "gfax118",
|
|
875
|
+
kind: "node",
|
|
876
|
+
role: "server"
|
|
877
|
+
},
|
|
872
878
|
{
|
|
873
879
|
userid: "72a4A7awtn6BqZnBt3eNhZH9MdYXRkM6Ht5HG2sqoiKR",
|
|
874
880
|
name: "nv4090-wsl",
|
|
@@ -1152,6 +1158,7 @@ ${cmds}
|
|
|
1152
1158
|
|
|
1153
1159
|
${tail}`;
|
|
1154
1160
|
}
|
|
1161
|
+
var SKIP_NAMES_MAX = 10;
|
|
1155
1162
|
var seq = 0;
|
|
1156
1163
|
var asMsg = (from, text, extra) => Object.assign({
|
|
1157
1164
|
id: `as-${Date.now()}-${seq++}`,
|
|
@@ -1213,22 +1220,29 @@ ${tail}`;
|
|
|
1213
1220
|
ver: r.beagleVer || ""
|
|
1214
1221
|
};
|
|
1215
1222
|
};
|
|
1223
|
+
const skipLine = (skipped) => {
|
|
1224
|
+
if (!skipped.length)
|
|
1225
|
+
return "";
|
|
1226
|
+
const shown = skipped.slice(0, SKIP_NAMES_MAX).map(nameOf);
|
|
1227
|
+
const more = skipped.length - shown.length;
|
|
1228
|
+
const names = shown.join(", ") + (more > 0 ? lang === "zh" ? ` \u7B49 ${more} \u4F4D` : `, and ${more} more` : "");
|
|
1229
|
+
return lang === "zh" ? `
|
|
1230
|
+
|
|
1231
|
+
*\u8DF3\u8FC7\u4E86 ${skipped.length} \u4F4D\u6700\u8FD1 ${RECENT_DAYS} \u5929\u5185\u6DFB\u52A0\u7684\u597D\u53CB\uFF1A${names}\u3002*` : `
|
|
1232
|
+
|
|
1233
|
+
*Skipped ${skipped.length} added in the last ${RECENT_DAYS} days: ${names}.*`;
|
|
1234
|
+
};
|
|
1216
1235
|
const listReply = (rows, skipped, data, title) => {
|
|
1217
1236
|
if (!rows.length) {
|
|
1218
1237
|
return `${title}
|
|
1219
1238
|
|
|
1220
|
-
${lang === "zh" ? "\u6CA1\u6709\u7B26\u5408\u7684\u597D\u53CB\u3002" : "No friends match."}
|
|
1239
|
+
${lang === "zh" ? "\u6CA1\u6709\u7B26\u5408\u7684\u597D\u53CB\u3002" : "No friends match."}${skipLine(skipped)}
|
|
1221
1240
|
|
|
1222
1241
|
${sinceLine(data.historySince, lang)}`;
|
|
1223
1242
|
}
|
|
1224
|
-
const skip = skipped.length ? lang === "zh" ? `
|
|
1225
|
-
|
|
1226
|
-
*\u8DF3\u8FC7\u4E86 ${skipped.length} \u4F4D\u6700\u8FD1 ${RECENT_DAYS} \u5929\u5185\u6DFB\u52A0\u7684\u597D\u53CB\u3002*` : `
|
|
1227
|
-
|
|
1228
|
-
*${skipped.length} friend${skipped.length > 1 ? "s" : ""} added in the last ${RECENT_DAYS} days ${skipped.length > 1 ? "were" : "was"} skipped.*` : "";
|
|
1229
1243
|
return `${title}
|
|
1230
1244
|
|
|
1231
|
-
${friendTable(rows, data.now, lang)}${
|
|
1245
|
+
${friendTable(rows, data.now, lang)}${skipLine(skipped)}
|
|
1232
1246
|
|
|
1233
1247
|
${sinceLine(data.historySince, lang)}`;
|
|
1234
1248
|
};
|
|
@@ -1377,6 +1391,8 @@ ${cands.map((c) => `- ${nameOf(c)}`).join("\n")}`;
|
|
|
1377
1391
|
}, [append, lang, onReloadFriends]);
|
|
1378
1392
|
return { thread, handle, removeFriends };
|
|
1379
1393
|
}
|
|
1394
|
+
var DK_CMD_HIST_KEY = "beagle.assistant.history";
|
|
1395
|
+
var DK_CMD_HIST_MAX = 50;
|
|
1380
1396
|
function RequestsBlock({ T, requests, onAct }) {
|
|
1381
1397
|
const [acted, setActed] = React.useState({});
|
|
1382
1398
|
const [failed, setFailed] = React.useState({});
|
|
@@ -2778,6 +2794,59 @@ ${cands.map((c) => `- ${nameOf(c)}`).join("\n")}`;
|
|
|
2778
2794
|
setSelMode(false);
|
|
2779
2795
|
};
|
|
2780
2796
|
const [draft, setDraft] = React.useState("");
|
|
2797
|
+
const [hist, setHist] = React.useState([]);
|
|
2798
|
+
const histIdx = React.useRef(null);
|
|
2799
|
+
const histStash = React.useRef("");
|
|
2800
|
+
React.useEffect(() => {
|
|
2801
|
+
histIdx.current = null;
|
|
2802
|
+
histStash.current = "";
|
|
2803
|
+
if (!peer.app) {
|
|
2804
|
+
setHist([]);
|
|
2805
|
+
return;
|
|
2806
|
+
}
|
|
2807
|
+
try {
|
|
2808
|
+
setHist(JSON.parse(localStorage.getItem(DK_CMD_HIST_KEY) || "[]"));
|
|
2809
|
+
} catch (e) {
|
|
2810
|
+
setHist([]);
|
|
2811
|
+
}
|
|
2812
|
+
}, [peer.id, peer.app]);
|
|
2813
|
+
const rememberCommand = (text) => {
|
|
2814
|
+
setHist((h) => {
|
|
2815
|
+
const next = (h[h.length - 1] === text ? h : h.concat(text)).slice(-DK_CMD_HIST_MAX);
|
|
2816
|
+
if (peer.app) {
|
|
2817
|
+
try {
|
|
2818
|
+
localStorage.setItem(DK_CMD_HIST_KEY, JSON.stringify(next));
|
|
2819
|
+
} catch (e) {
|
|
2820
|
+
}
|
|
2821
|
+
}
|
|
2822
|
+
return next;
|
|
2823
|
+
});
|
|
2824
|
+
histIdx.current = null;
|
|
2825
|
+
histStash.current = "";
|
|
2826
|
+
};
|
|
2827
|
+
const walkHistory = (dir) => {
|
|
2828
|
+
if (!hist.length)
|
|
2829
|
+
return false;
|
|
2830
|
+
let i = histIdx.current;
|
|
2831
|
+
if (i === null) {
|
|
2832
|
+
if (dir > 0)
|
|
2833
|
+
return false;
|
|
2834
|
+
histStash.current = draft;
|
|
2835
|
+
i = hist.length - 1;
|
|
2836
|
+
} else {
|
|
2837
|
+
i += dir;
|
|
2838
|
+
if (i >= hist.length) {
|
|
2839
|
+
histIdx.current = null;
|
|
2840
|
+
setDraft(histStash.current);
|
|
2841
|
+
return true;
|
|
2842
|
+
}
|
|
2843
|
+
if (i < 0)
|
|
2844
|
+
i = 0;
|
|
2845
|
+
}
|
|
2846
|
+
histIdx.current = i;
|
|
2847
|
+
setDraft(hist[i]);
|
|
2848
|
+
return true;
|
|
2849
|
+
};
|
|
2781
2850
|
const [dragOver, setDragOver] = React.useState(false);
|
|
2782
2851
|
const [sending, setSending] = React.useState(null);
|
|
2783
2852
|
const [theater, setTheater] = React.useState(null);
|
|
@@ -2800,6 +2869,7 @@ ${cands.map((c) => `- ${nameOf(c)}`).join("\n")}`;
|
|
|
2800
2869
|
const sendDraft = () => {
|
|
2801
2870
|
if (draft.trim()) {
|
|
2802
2871
|
followScrollRef.current = true;
|
|
2872
|
+
rememberCommand(draft.trim());
|
|
2803
2873
|
onSend(draft);
|
|
2804
2874
|
setDraft("");
|
|
2805
2875
|
requestAnimationFrame(scrollToBottom);
|
|
@@ -2985,11 +3055,19 @@ ${peer.address}`
|
|
|
2985
3055
|
"input",
|
|
2986
3056
|
{
|
|
2987
3057
|
value: draft,
|
|
2988
|
-
onChange: (e) =>
|
|
3058
|
+
onChange: (e) => {
|
|
3059
|
+
histIdx.current = null;
|
|
3060
|
+
setDraft(e.target.value);
|
|
3061
|
+
},
|
|
2989
3062
|
onKeyDown: (e) => {
|
|
2990
3063
|
if (e.key === "Enter" && !e.shiftKey) {
|
|
2991
3064
|
e.preventDefault();
|
|
2992
3065
|
sendDraft();
|
|
3066
|
+
return;
|
|
3067
|
+
}
|
|
3068
|
+
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
3069
|
+
if (walkHistory(e.key === "ArrowUp" ? -1 : 1))
|
|
3070
|
+
e.preventDefault();
|
|
2993
3071
|
}
|
|
2994
3072
|
},
|
|
2995
3073
|
placeholder: phone ? `${T.message}\u2026` : `${T.message} ${peer.alias || shortKey(peer.userId, 6, 4)}\u2026`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decentnetwork/beagle",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.111",
|
|
4
4
|
"description": "Beagle — P2P chat, file transfer and calls for regular users, on the Decent Network. No admin privilege required.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"yargs": "^17.7.2"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@decentnetwork/beagle-ui": "^0.2.
|
|
38
|
+
"@decentnetwork/beagle-ui": "^0.2.25",
|
|
39
39
|
"@types/js-yaml": "^4.0.9",
|
|
40
40
|
"@types/node": "^20.11.0",
|
|
41
41
|
"@types/yargs": "^17.0.32",
|