@celljs/ta-rooms 4.22.0 → 4.24.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/extension/index.mjs +273 -10
- package/host/index.mjs +2871 -1304
- package/package.json +4 -4
- package/web/index.js +1339 -107
package/web/index.js
CHANGED
|
@@ -67,6 +67,8 @@ var RELAY_ROOM_PATH = "/r";
|
|
|
67
67
|
var RELAY_HUB_MAX_VALUE = 96 * 1024;
|
|
68
68
|
var RELAY_HUB_MAX_STATE = 3 * 1024 * 1024;
|
|
69
69
|
var RELAY_PICTURE_MAX_CHARS = 16 * 1024;
|
|
70
|
+
var RELAY_HUB_LOG_CHARS = 4 * 1024 * 1024;
|
|
71
|
+
var RELAY_HUB_HISTORY_MAX = 500;
|
|
70
72
|
|
|
71
73
|
// ../ta-relay/esm/common/relay-identity.js
|
|
72
74
|
var encoder = new TextEncoder;
|
|
@@ -221,12 +223,14 @@ var RelayHubCharterUtil;
|
|
|
221
223
|
return;
|
|
222
224
|
}
|
|
223
225
|
const capacity = Math.round(Number(body.capacity));
|
|
226
|
+
const history = Math.min(Math.round(Number(body.history) || 0), RELAY_HUB_HISTORY_MAX);
|
|
224
227
|
return {
|
|
225
228
|
room,
|
|
226
229
|
v: Number(body.v),
|
|
227
230
|
admins: body.admins.filter((admin) => admin && typeof admin.member === "string" && typeof admin.id === "string").slice(0, RELAY_HUB_MAX_ADMINS).map((admin) => ({ member: admin.member, id: admin.id })),
|
|
228
231
|
rules: rules(body.rules),
|
|
229
|
-
...capacity >= 2 ? { capacity } : {}
|
|
232
|
+
...capacity >= 2 ? { capacity } : {},
|
|
233
|
+
...history > 0 ? { history } : {}
|
|
230
234
|
};
|
|
231
235
|
} catch (_a) {
|
|
232
236
|
return;
|
|
@@ -801,6 +805,8 @@ var TASK_MESSAGE_TYPE = "ta-rooms:task";
|
|
|
801
805
|
var ROOM_CAPABILITIES = ["files", "commands"];
|
|
802
806
|
var DoubleKeys;
|
|
803
807
|
((DoubleKeys) => {
|
|
808
|
+
DoubleKeys.PICTURES = "pictures.came";
|
|
809
|
+
DoubleKeys.FILES = "files.came";
|
|
804
810
|
DoubleKeys.QUIET = "doubles.quiet";
|
|
805
811
|
DoubleKeys.REPLY = "doubles.reply";
|
|
806
812
|
DoubleKeys.DRAFTS = "doubles.drafts";
|
|
@@ -857,10 +863,19 @@ var DirectUtil;
|
|
|
857
863
|
})(DirectUtil ||= {});
|
|
858
864
|
|
|
859
865
|
// ../ta-relay/esm/common/relay-room-chat.js
|
|
866
|
+
var RELAY_CHAT_FILE_BYTES = { file: 50 * 1024 * 1024, video: 30 * 1024 * 1024, voice: 2 * 1024 * 1024 };
|
|
867
|
+
var RELAY_CHAT_VOICE_MS = 60000;
|
|
868
|
+
var RELAY_CHAT_VIDEO_MS = 3 * 60000;
|
|
869
|
+
var RELAY_CHAT_FILES = 9;
|
|
860
870
|
var RELAY_CHAT_KEY = "chat:";
|
|
861
871
|
var RELAY_CHAT_PART_BYTES = 8 * 1024;
|
|
862
872
|
var RELAY_CHAT_PARTS = 6;
|
|
863
873
|
var RELAY_CHAT_TEXT_MAX = 2000;
|
|
874
|
+
var RELAY_CHAT_IMAGES = 9;
|
|
875
|
+
var RELAY_CHAT_IMAGE_BYTES = 2 * 1024 * 1024;
|
|
876
|
+
var RELAY_CHAT_THUMB_CHARS = 900;
|
|
877
|
+
var IMAGE_TYPES = ["image/jpeg", "image/png", "image/gif", "image/webp"];
|
|
878
|
+
var RELAY_CHAT_WINDOW = 500;
|
|
864
879
|
var TRIES = 6;
|
|
865
880
|
var RelayRoomChatUtil;
|
|
866
881
|
(function(RelayRoomChatUtil2) {
|
|
@@ -895,18 +910,99 @@ var RelayRoomChatUtil;
|
|
|
895
910
|
...to.length ? { to } : {},
|
|
896
911
|
...line.person === true && to.length && line.double !== true && !line.agent ? { person: true } : {},
|
|
897
912
|
...typeof line.re === "string" ? { re: line.re } : {},
|
|
898
|
-
...line.task === true && to.length ? { task: true } : {}
|
|
913
|
+
...line.task === true && to.length ? { task: true } : {},
|
|
914
|
+
...images(line.images),
|
|
915
|
+
...files(line.files)
|
|
899
916
|
};
|
|
900
917
|
}
|
|
901
918
|
RelayRoomChatUtil2.extra = extra;
|
|
919
|
+
function files(value) {
|
|
920
|
+
if (!Array.isArray(value)) {
|
|
921
|
+
return {};
|
|
922
|
+
}
|
|
923
|
+
const files2 = [];
|
|
924
|
+
for (const file of value.slice(0, RELAY_CHAT_FILES)) {
|
|
925
|
+
const kind = file === null || file === undefined ? undefined : file.kind;
|
|
926
|
+
if (!file || kind !== "file" && kind !== "voice" && kind !== "video" || typeof file.id !== "string" || !/^[a-f0-9]{24}$/.test(file.id) || typeof file.sha !== "string" || !/^[0-9a-f]{64}$/.test(file.sha) || !Number.isInteger(file.bytes) || file.bytes <= 0 || file.bytes > RELAY_CHAT_FILE_BYTES[kind]) {
|
|
927
|
+
continue;
|
|
928
|
+
}
|
|
929
|
+
const name = [...typeof file.name === "string" ? file.name : ""].filter((char) => char.charCodeAt(0) >= 32 && char !== "/" && char !== "\\").join("").slice(0, 120) || kind;
|
|
930
|
+
const type = typeof file.type === "string" && /^[\w.+-]+\/[\w.+-]+$/.test(file.type) ? file.type.slice(0, 100) : "application/octet-stream";
|
|
931
|
+
const most = kind === "voice" ? RELAY_CHAT_VOICE_MS : RELAY_CHAT_VIDEO_MS;
|
|
932
|
+
const ms = kind !== "file" && Number.isFinite(file.ms) ? Math.min(Math.max(Math.round(file.ms), 0), most) : undefined;
|
|
933
|
+
const size = kind === "video" && Number.isInteger(file.w) && Number.isInteger(file.h) && file.w > 0 && file.h > 0;
|
|
934
|
+
const thumb = kind === "video" && typeof file.thumb === "string" && file.thumb.length <= RELAY_CHAT_THUMB_CHARS && /^data:image\/(jpeg|png|webp);base64,/.test(file.thumb) ? file.thumb : undefined;
|
|
935
|
+
files2.push({
|
|
936
|
+
id: file.id,
|
|
937
|
+
kind,
|
|
938
|
+
name,
|
|
939
|
+
type,
|
|
940
|
+
bytes: file.bytes,
|
|
941
|
+
sha: file.sha,
|
|
942
|
+
...ms !== undefined ? { ms } : {},
|
|
943
|
+
...size ? { w: file.w, h: file.h } : {},
|
|
944
|
+
...thumb ? { thumb } : {}
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
return files2.length ? { files: files2 } : {};
|
|
948
|
+
}
|
|
949
|
+
RelayRoomChatUtil2.files = files;
|
|
950
|
+
function images(value) {
|
|
951
|
+
if (!Array.isArray(value)) {
|
|
952
|
+
return {};
|
|
953
|
+
}
|
|
954
|
+
const images2 = [];
|
|
955
|
+
for (const image of value.slice(0, RELAY_CHAT_IMAGES)) {
|
|
956
|
+
if (image && typeof image.id === "string" && /^[A-Za-z0-9-]{8,64}$/.test(image.id) && typeof image.type === "string" && IMAGE_TYPES.includes(image.type) && typeof image.sha === "string" && /^[0-9a-f]{64}$/.test(image.sha) && Number.isInteger(image.w) && Number.isInteger(image.h) && Number.isInteger(image.bytes) && image.w > 0 && image.h > 0 && image.bytes > 0 && image.bytes <= RELAY_CHAT_IMAGE_BYTES) {
|
|
957
|
+
const thumb = typeof image.thumb === "string" && image.thumb.length <= RELAY_CHAT_THUMB_CHARS && /^data:image\/(jpeg|png|webp);base64,/.test(image.thumb) ? image.thumb : undefined;
|
|
958
|
+
const blob = image.blob;
|
|
959
|
+
const ok = !!blob && typeof blob.id === "string" && /^[A-Za-z0-9_-]{16,64}$/.test(blob.id) && typeof blob.read === "string" && /^[A-Za-z0-9_-]{43}$/.test(blob.read) && typeof blob.key === "string" && /^[A-Za-z0-9_-]{43}$/.test(blob.key) && Number.isFinite(blob.until);
|
|
960
|
+
images2.push({
|
|
961
|
+
id: image.id,
|
|
962
|
+
type: image.type,
|
|
963
|
+
w: image.w,
|
|
964
|
+
h: image.h,
|
|
965
|
+
bytes: image.bytes,
|
|
966
|
+
sha: image.sha,
|
|
967
|
+
...thumb ? { thumb } : {},
|
|
968
|
+
...ok && blob ? { blob: { id: blob.id, read: blob.read, key: blob.key, until: blob.until } } : {}
|
|
969
|
+
});
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
return images2.length ? { images: images2 } : {};
|
|
973
|
+
}
|
|
974
|
+
function preview(line, picture, words = { file: "[file]", voice: "[voice]", video: "[video]" }) {
|
|
975
|
+
var _a;
|
|
976
|
+
var _b;
|
|
977
|
+
const pictures = ((_a = line.images) === null || _a === undefined ? undefined : _a.length) ? line.images.length > 1 ? `${picture}×${line.images.length}` : picture : "";
|
|
978
|
+
const files2 = ((_b = line.files) !== null && _b !== undefined ? _b : []).map((file) => file.kind === "file" ? `${words.file} ${file.name}` : words[file.kind]);
|
|
979
|
+
return [pictures, ...files2, line.text].filter(Boolean).join(" ");
|
|
980
|
+
}
|
|
981
|
+
RelayRoomChatUtil2.preview = preview;
|
|
902
982
|
function stored(lines2) {
|
|
903
|
-
return lines2.map(({ from: _from, ...line }) => line);
|
|
983
|
+
return lines2.map(({ from: _from, seq: _seq, pending: _pending, failed: _failed, ...line }) => line);
|
|
904
984
|
}
|
|
905
985
|
RelayRoomChatUtil2.stored = stored;
|
|
986
|
+
function signed(member, value, seq) {
|
|
987
|
+
const line = value;
|
|
988
|
+
if (!line || typeof line.id !== "string" || typeof line.text !== "string" || typeof line.at !== "number") {
|
|
989
|
+
return;
|
|
990
|
+
}
|
|
991
|
+
const name = typeof line.name === "string" ? line.name.slice(0, 64) : "";
|
|
992
|
+
const text = line.text.slice(0, RELAY_CHAT_TEXT_MAX);
|
|
993
|
+
return { id: line.id.slice(0, 40), from: member, name, text, at: line.at, ...extra(line), ...seq ? { seq } : {} };
|
|
994
|
+
}
|
|
995
|
+
RelayRoomChatUtil2.signed = signed;
|
|
906
996
|
function bytes(lines2) {
|
|
907
997
|
return new TextEncoder().encode(JSON.stringify(lines2)).length;
|
|
908
998
|
}
|
|
909
999
|
RelayRoomChatUtil2.bytes = bytes;
|
|
1000
|
+
function unknownMethod(error) {
|
|
1001
|
+
var _a;
|
|
1002
|
+
const found = error;
|
|
1003
|
+
return (found === null || found === undefined ? undefined : found.code) === -32601 || /method not found|not a function|unknown method|no such method/i.test(String((_a = found === null || found === undefined ? undefined : found.message) !== null && _a !== undefined ? _a : error));
|
|
1004
|
+
}
|
|
1005
|
+
RelayRoomChatUtil2.unknownMethod = unknownMethod;
|
|
910
1006
|
function id() {
|
|
911
1007
|
return `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
|
|
912
1008
|
}
|
|
@@ -920,6 +1016,8 @@ class RelayRoomChat {
|
|
|
920
1016
|
this.parts = new Map;
|
|
921
1017
|
this.listeners = new Set;
|
|
922
1018
|
this.all = [];
|
|
1019
|
+
this.olderKept = false;
|
|
1020
|
+
this.log = typeof rooms.readChat === "function" && typeof rooms.say === "function";
|
|
923
1021
|
}
|
|
924
1022
|
get lines() {
|
|
925
1023
|
return this.all;
|
|
@@ -928,7 +1026,25 @@ class RelayRoomChat {
|
|
|
928
1026
|
this.listeners.add(listener);
|
|
929
1027
|
return () => this.listeners.delete(listener);
|
|
930
1028
|
}
|
|
1029
|
+
get more() {
|
|
1030
|
+
return this.olderKept;
|
|
1031
|
+
}
|
|
931
1032
|
async load() {
|
|
1033
|
+
if (this.log && this.rooms.readChat) {
|
|
1034
|
+
const read = await this.rooms.readChat(this.room, { limit: RELAY_CHAT_WINDOW }).catch((error) => {
|
|
1035
|
+
if (!RelayRoomChatUtil.unknownMethod(error)) {
|
|
1036
|
+
throw error;
|
|
1037
|
+
}
|
|
1038
|
+
this.log = false;
|
|
1039
|
+
return;
|
|
1040
|
+
});
|
|
1041
|
+
if (read) {
|
|
1042
|
+
this.olderKept = read.more;
|
|
1043
|
+
this.all = Array.isArray(read.lines) ? read.lines : [];
|
|
1044
|
+
this.tell();
|
|
1045
|
+
return;
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
932
1048
|
const state = await this.rooms.getState(this.room, RELAY_CHAT_KEY);
|
|
933
1049
|
this.parts.clear();
|
|
934
1050
|
for (const [key, value] of Object.entries(state)) {
|
|
@@ -936,7 +1052,51 @@ class RelayRoomChat {
|
|
|
936
1052
|
}
|
|
937
1053
|
this.changed();
|
|
938
1054
|
}
|
|
1055
|
+
async older(limit = 100) {
|
|
1056
|
+
const first = this.all[0];
|
|
1057
|
+
if (!this.log || !this.rooms.readChat || !first || !this.olderKept) {
|
|
1058
|
+
return 0;
|
|
1059
|
+
}
|
|
1060
|
+
const read = await this.rooms.readChat(this.room, { before: first.id, limit });
|
|
1061
|
+
const known = new Set(this.all.map((line) => line.id));
|
|
1062
|
+
const lines = read.lines.filter((line) => !known.has(line.id));
|
|
1063
|
+
this.olderKept = read.more;
|
|
1064
|
+
this.all = [...lines, ...this.all];
|
|
1065
|
+
this.tell();
|
|
1066
|
+
return lines.length;
|
|
1067
|
+
}
|
|
1068
|
+
hear(event) {
|
|
1069
|
+
if (event.room !== undefined && event.room !== this.room) {
|
|
1070
|
+
return false;
|
|
1071
|
+
}
|
|
1072
|
+
if (event.type === "chat" && event.line) {
|
|
1073
|
+
this.heardLine(event.line);
|
|
1074
|
+
return true;
|
|
1075
|
+
}
|
|
1076
|
+
return event.type === "state" && typeof event.key === "string" && this.heard(event.key, event);
|
|
1077
|
+
}
|
|
1078
|
+
heardLine(line) {
|
|
1079
|
+
const index = this.all.findIndex((each) => each.id === line.id);
|
|
1080
|
+
if (index >= 0) {
|
|
1081
|
+
const next = [...this.all];
|
|
1082
|
+
next[index] = line;
|
|
1083
|
+
this.all = next;
|
|
1084
|
+
} else {
|
|
1085
|
+
const next = [...this.all, line];
|
|
1086
|
+
const pending = next.findIndex((each) => each.pending);
|
|
1087
|
+
if (pending >= 0 && !line.pending) {
|
|
1088
|
+
next.splice(next.length - 1, 1);
|
|
1089
|
+
next.splice(pending, 0, line);
|
|
1090
|
+
}
|
|
1091
|
+
this.all = next.length > RELAY_CHAT_WINDOW * 2 ? next.slice(-RELAY_CHAT_WINDOW) : next;
|
|
1092
|
+
this.olderKept || (this.olderKept = next.length > this.all.length);
|
|
1093
|
+
}
|
|
1094
|
+
this.tell();
|
|
1095
|
+
}
|
|
939
1096
|
heard(key, value) {
|
|
1097
|
+
if (this.log) {
|
|
1098
|
+
return !!RelayRoomChatUtil.parse(key);
|
|
1099
|
+
}
|
|
940
1100
|
if (!RelayRoomChatUtil.parse(key)) {
|
|
941
1101
|
return false;
|
|
942
1102
|
}
|
|
@@ -949,16 +1109,23 @@ class RelayRoomChat {
|
|
|
949
1109
|
return true;
|
|
950
1110
|
}
|
|
951
1111
|
async say(text, self, extra = {}) {
|
|
952
|
-
var _a;
|
|
953
|
-
var
|
|
1112
|
+
var _a, _b, _c;
|
|
1113
|
+
var _d, _e;
|
|
954
1114
|
const said = text.trim().slice(0, RELAY_CHAT_TEXT_MAX);
|
|
955
|
-
if (!said) {
|
|
1115
|
+
if (!said && !((_a = extra.images) === null || _a === undefined ? undefined : _a.length) && !((_b = extra.files) === null || _b === undefined ? undefined : _b.length)) {
|
|
956
1116
|
return;
|
|
957
1117
|
}
|
|
1118
|
+
if (this.log && this.rooms.say) {
|
|
1119
|
+
const line = await this.rooms.say(this.room, said, RelayRoomChatUtil.extra(extra));
|
|
1120
|
+
if (line) {
|
|
1121
|
+
this.heardLine(line);
|
|
1122
|
+
}
|
|
1123
|
+
return line;
|
|
1124
|
+
}
|
|
958
1125
|
for (let tries = 0;tries < TRIES; tries++) {
|
|
959
1126
|
const latest = this.latest(self.member);
|
|
960
1127
|
const last = latest === null || latest === undefined ? undefined : latest.lines[latest.lines.length - 1];
|
|
961
|
-
const at = Math.max(Date.now(), ((
|
|
1128
|
+
const at = Math.max(Date.now(), ((_d = last === null || last === undefined ? undefined : last.at) !== null && _d !== undefined ? _d : 0) + 1);
|
|
962
1129
|
const line = {
|
|
963
1130
|
id: RelayRoomChatUtil.id(),
|
|
964
1131
|
from: self.member,
|
|
@@ -972,7 +1139,7 @@ class RelayRoomChat {
|
|
|
972
1139
|
const lines = fits && latest ? [...latest.lines, line] : [line];
|
|
973
1140
|
const key = RelayRoomChatUtil.key(self.member, part);
|
|
974
1141
|
const value = RelayRoomChatUtil.stored(lines);
|
|
975
|
-
const result = await this.rooms.setState(this.room, key, value, (
|
|
1142
|
+
const result = await this.rooms.setState(this.room, key, value, (_e = (_c = this.parts.get(key)) === null || _c === undefined ? undefined : _c.version) !== null && _e !== undefined ? _e : 0);
|
|
976
1143
|
if (result.ok) {
|
|
977
1144
|
this.put(key, { value, version: result.version, by: self.member });
|
|
978
1145
|
this.changed();
|
|
@@ -1013,6 +1180,9 @@ class RelayRoomChat {
|
|
|
1013
1180
|
}
|
|
1014
1181
|
changed() {
|
|
1015
1182
|
this.all = [...this.parts.values()].flatMap((part) => part.lines).sort((a, b) => a.at - b.at || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
1183
|
+
this.tell();
|
|
1184
|
+
}
|
|
1185
|
+
tell() {
|
|
1016
1186
|
for (const listener of this.listeners) {
|
|
1017
1187
|
listener();
|
|
1018
1188
|
}
|
|
@@ -1140,8 +1310,45 @@ var EN = {
|
|
|
1140
1310
|
openPage: "Open {name}",
|
|
1141
1311
|
apps: "Apps",
|
|
1142
1312
|
pageLine: "A group chat of {name}: play in it together",
|
|
1313
|
+
unsent: "Not sent: too long",
|
|
1143
1314
|
chatEmpty: "Nothing said yet. Only those in the group chat read it: the relay keeps it sealed.",
|
|
1144
1315
|
chatPlaceholder: "Message",
|
|
1316
|
+
storageTitle: "Storage",
|
|
1317
|
+
storageLead: "Chats on this computer",
|
|
1318
|
+
storageHint: "Pictures and files others sent come again from them when you open them. What you sent stays: others get it from you.",
|
|
1319
|
+
storageTotal: "In all",
|
|
1320
|
+
storageParts: "Messages {said} · pictures and files {media}",
|
|
1321
|
+
storageClearMedia: "Clear pictures and files others sent ({size})",
|
|
1322
|
+
storageOlder: "Clear earlier history",
|
|
1323
|
+
storageOlderTitle: "Clear earlier history with {name}",
|
|
1324
|
+
storageOlderHint: "What was said before then goes from this computer only, a month at a time; the others keep theirs.",
|
|
1325
|
+
storageOlderMonths: "Older than {n} month(s)",
|
|
1326
|
+
storageOlderYear: "Older than a year",
|
|
1327
|
+
storageOlderNone: "Nothing",
|
|
1328
|
+
storageClear: "Clear chat history",
|
|
1329
|
+
storageClearTitle: "Clear the chat history with {name}?",
|
|
1330
|
+
storageClearHint: "It goes from this computer only; the others keep theirs, and it does not come back.",
|
|
1331
|
+
storageFreed: "{size} freed",
|
|
1332
|
+
storageNone: "No chats yet",
|
|
1333
|
+
file: "[File]",
|
|
1334
|
+
voice: "[Voice]",
|
|
1335
|
+
video: "[Video]",
|
|
1336
|
+
sendFile: "File",
|
|
1337
|
+
sendVideo: "Video",
|
|
1338
|
+
sendVoice: "Voice",
|
|
1339
|
+
fileTooLarge: "Too large to send: {mb} MB at most",
|
|
1340
|
+
videoTooLong: "A video is 3 minutes at most",
|
|
1341
|
+
fileComing: "Receiving {percent}%",
|
|
1342
|
+
fileWait: "Opens once {name} is online",
|
|
1343
|
+
fileSending: "Sending {name} {percent}%",
|
|
1344
|
+
voiceTitle: "Voice message",
|
|
1345
|
+
voiceLong: "60 seconds at most",
|
|
1346
|
+
voiceCancel: "Cancel",
|
|
1347
|
+
voiceSend: "Send",
|
|
1348
|
+
voiceNoMic: "The microphone cannot be used",
|
|
1349
|
+
picture: "[Picture]",
|
|
1350
|
+
pictureAlt: "A picture from {name}",
|
|
1351
|
+
pictureWait: "Comes once {name} is online",
|
|
1145
1352
|
showOnHome: "Show group chats on the double's home",
|
|
1146
1353
|
showOnHomeHint: "With group chats, the double's home has a Group chats section, beside members and channels.",
|
|
1147
1354
|
friendsDetail: "{n} friends",
|
|
@@ -1290,8 +1497,45 @@ var ZH = {
|
|
|
1290
1497
|
openPage: "打开{name}",
|
|
1291
1498
|
apps: "应用",
|
|
1292
1499
|
pageLine: "{name}的群聊,大家可以一起玩",
|
|
1500
|
+
unsent: "未发出:内容太长",
|
|
1293
1501
|
chatEmpty: "还没有人说话。只有群里的人能看到,中继保存的是密文。",
|
|
1294
1502
|
chatPlaceholder: "发消息",
|
|
1503
|
+
storageTitle: "存储空间",
|
|
1504
|
+
storageLead: "本机的聊天",
|
|
1505
|
+
storageHint: "别人发的图片和文件,清理后再打开会重新从对方那里取;你发的会保留,别人要从你这里取。",
|
|
1506
|
+
storageTotal: "共计",
|
|
1507
|
+
storageParts: "消息 {said} · 图片和文件 {media}",
|
|
1508
|
+
storageClearMedia: "清理别人发的图片和文件({size})",
|
|
1509
|
+
storageOlder: "清理更早的聊天记录",
|
|
1510
|
+
storageOlderTitle: "清理与{name}更早的聊天记录",
|
|
1511
|
+
storageOlderHint: "按月清理,只删本机的,其他人的不受影响,删了不能恢复。",
|
|
1512
|
+
storageOlderMonths: "{n} 个月以前",
|
|
1513
|
+
storageOlderYear: "一年以前",
|
|
1514
|
+
storageOlderNone: "没有",
|
|
1515
|
+
storageClear: "清空聊天记录",
|
|
1516
|
+
storageClearTitle: "清空与{name}的聊天记录?",
|
|
1517
|
+
storageClearHint: "只删本机的,其他人的不受影响,删了不能恢复。",
|
|
1518
|
+
storageFreed: "已释放 {size}",
|
|
1519
|
+
storageNone: "还没有聊天",
|
|
1520
|
+
file: "[文件]",
|
|
1521
|
+
voice: "[语音]",
|
|
1522
|
+
video: "[视频]",
|
|
1523
|
+
sendFile: "文件",
|
|
1524
|
+
sendVideo: "视频",
|
|
1525
|
+
sendVoice: "语音",
|
|
1526
|
+
fileTooLarge: "文件太大,最多 {mb} MB",
|
|
1527
|
+
videoTooLong: "视频最长 3 分钟",
|
|
1528
|
+
fileComing: "正在接收 {percent}%",
|
|
1529
|
+
fileWait: "等{name}上线后可以打开",
|
|
1530
|
+
fileSending: "正在发送 {name} {percent}%",
|
|
1531
|
+
voiceTitle: "语音消息",
|
|
1532
|
+
voiceLong: "最长 60 秒",
|
|
1533
|
+
voiceCancel: "取消",
|
|
1534
|
+
voiceSend: "发送",
|
|
1535
|
+
voiceNoMic: "无法使用麦克风",
|
|
1536
|
+
picture: "[图片]",
|
|
1537
|
+
pictureAlt: "{name}发的图片",
|
|
1538
|
+
pictureWait: "等{name}上线后显示",
|
|
1295
1539
|
showOnHome: "在分身首页显示群聊",
|
|
1296
1540
|
showOnHomeHint: "有群聊时,分身首页多一个“群聊”分类,和成员、频道放在一起。",
|
|
1297
1541
|
friendsDetail: "{n} 位好友",
|
|
@@ -1440,8 +1684,45 @@ var ZH_TW = {
|
|
|
1440
1684
|
openPage: "開啟{name}",
|
|
1441
1685
|
apps: "應用",
|
|
1442
1686
|
pageLine: "{name}的群聊,大家可以一起玩",
|
|
1687
|
+
unsent: "未送出:內容太長",
|
|
1443
1688
|
chatEmpty: "還沒有人說話。只有群裡的人能看到,中繼儲存的是密文。",
|
|
1444
1689
|
chatPlaceholder: "發訊息",
|
|
1690
|
+
storageTitle: "儲存空間",
|
|
1691
|
+
storageLead: "本機的聊天",
|
|
1692
|
+
storageHint: "別人傳的圖片和檔案,清理後再打開會重新從對方那裡取;你傳的會保留,別人要從你這裡取。",
|
|
1693
|
+
storageTotal: "共計",
|
|
1694
|
+
storageParts: "訊息 {said} · 圖片和檔案 {media}",
|
|
1695
|
+
storageClearMedia: "清理別人傳的圖片和檔案({size})",
|
|
1696
|
+
storageOlder: "清理更早的聊天記錄",
|
|
1697
|
+
storageOlderTitle: "清理與{name}更早的聊天記錄",
|
|
1698
|
+
storageOlderHint: "按月清理,只刪本機的,其他人的不受影響,刪了不能恢復。",
|
|
1699
|
+
storageOlderMonths: "{n} 個月以前",
|
|
1700
|
+
storageOlderYear: "一年以前",
|
|
1701
|
+
storageOlderNone: "沒有",
|
|
1702
|
+
storageClear: "清空聊天記錄",
|
|
1703
|
+
storageClearTitle: "清空與{name}的聊天記錄?",
|
|
1704
|
+
storageClearHint: "只刪本機的,其他人的不受影響,刪了不能恢復。",
|
|
1705
|
+
storageFreed: "已釋放 {size}",
|
|
1706
|
+
storageNone: "還沒有聊天",
|
|
1707
|
+
file: "[檔案]",
|
|
1708
|
+
voice: "[語音]",
|
|
1709
|
+
video: "[影片]",
|
|
1710
|
+
sendFile: "檔案",
|
|
1711
|
+
sendVideo: "影片",
|
|
1712
|
+
sendVoice: "語音",
|
|
1713
|
+
fileTooLarge: "檔案太大,最多 {mb} MB",
|
|
1714
|
+
videoTooLong: "影片最長 3 分鐘",
|
|
1715
|
+
fileComing: "正在接收 {percent}%",
|
|
1716
|
+
fileWait: "等{name}上線後可以打開",
|
|
1717
|
+
fileSending: "正在傳送 {name} {percent}%",
|
|
1718
|
+
voiceTitle: "語音訊息",
|
|
1719
|
+
voiceLong: "最長 60 秒",
|
|
1720
|
+
voiceCancel: "取消",
|
|
1721
|
+
voiceSend: "傳送",
|
|
1722
|
+
voiceNoMic: "無法使用麥克風",
|
|
1723
|
+
picture: "[圖片]",
|
|
1724
|
+
pictureAlt: "{name}傳的圖片",
|
|
1725
|
+
pictureWait: "等{name}上線後顯示",
|
|
1445
1726
|
showOnHome: "在分身首頁顯示群聊",
|
|
1446
1727
|
showOnHomeHint: "有群聊時,分身首頁多一個「群聊」分類,和成員、頻道放在一起。",
|
|
1447
1728
|
friendsDetail: "{n} 位好友",
|
|
@@ -1590,8 +1871,45 @@ var JA = {
|
|
|
1590
1871
|
openPage: "{name} を開く",
|
|
1591
1872
|
apps: "アプリ",
|
|
1592
1873
|
pageLine: "{name} のグループチャット:一緒にプレイします",
|
|
1874
|
+
unsent: "送信できませんでした:長すぎます",
|
|
1593
1875
|
chatEmpty: "まだ何も言われていません。グループ内の人だけが見ることができます。リレーは暗号化されて保存します。",
|
|
1594
1876
|
chatPlaceholder: "メッセージ",
|
|
1877
|
+
storageTitle: "ストレージ",
|
|
1878
|
+
storageLead: "このコンピュータのチャット",
|
|
1879
|
+
storageHint: "他の人が送った画像やファイルは、消しても開くとその人から取り直します。自分が送ったものは残ります(他の人があなたから取ります)。",
|
|
1880
|
+
storageTotal: "合計",
|
|
1881
|
+
storageParts: "メッセージ {said} · 画像とファイル {media}",
|
|
1882
|
+
storageClearMedia: "他の人が送った画像とファイルを消す({size})",
|
|
1883
|
+
storageOlder: "以前の履歴を消す",
|
|
1884
|
+
storageOlderTitle: "{name}との以前の履歴を消す",
|
|
1885
|
+
storageOlderHint: "月ごとに、このコンピュータからだけ消えます。他の人の分はそのままで、元に戻せません。",
|
|
1886
|
+
storageOlderMonths: "{n} か月より前",
|
|
1887
|
+
storageOlderYear: "1 年より前",
|
|
1888
|
+
storageOlderNone: "なし",
|
|
1889
|
+
storageClear: "チャット履歴を消す",
|
|
1890
|
+
storageClearTitle: "{name}とのチャット履歴を消しますか?",
|
|
1891
|
+
storageClearHint: "このコンピュータからだけ消えます。他の人の分はそのままで、元に戻せません。",
|
|
1892
|
+
storageFreed: "{size} を空けました",
|
|
1893
|
+
storageNone: "まだチャットはありません",
|
|
1894
|
+
file: "[ファイル]",
|
|
1895
|
+
voice: "[ボイス]",
|
|
1896
|
+
video: "[動画]",
|
|
1897
|
+
sendFile: "ファイル",
|
|
1898
|
+
sendVideo: "動画",
|
|
1899
|
+
sendVoice: "ボイス",
|
|
1900
|
+
fileTooLarge: "大きすぎます(最大 {mb} MB)",
|
|
1901
|
+
videoTooLong: "動画は最長 3 分です",
|
|
1902
|
+
fileComing: "受信中 {percent}%",
|
|
1903
|
+
fileWait: "{name}がオンラインになると開けます",
|
|
1904
|
+
fileSending: "{name} を送信中 {percent}%",
|
|
1905
|
+
voiceTitle: "ボイスメッセージ",
|
|
1906
|
+
voiceLong: "最長 60 秒",
|
|
1907
|
+
voiceCancel: "キャンセル",
|
|
1908
|
+
voiceSend: "送信",
|
|
1909
|
+
voiceNoMic: "マイクを使えません",
|
|
1910
|
+
picture: "[画像]",
|
|
1911
|
+
pictureAlt: "{name}からの画像",
|
|
1912
|
+
pictureWait: "{name}がオンラインになると表示",
|
|
1595
1913
|
showOnHome: "分身のホームにグループチャットを表示",
|
|
1596
1914
|
showOnHomeHint: "グループチャットがあると、分身のホームに「グループチャット」セクションが追加され、メンバーとチャンネルと一緒に表示されます。",
|
|
1597
1915
|
friendsDetail: "友だち {n} 人",
|
|
@@ -1814,10 +2132,10 @@ class RoomBook {
|
|
|
1814
2132
|
this.putAgents(room, { ...known, [key]: { value: agents, by: member, version: known[key]?.version ?? 0 } });
|
|
1815
2133
|
}
|
|
1816
2134
|
heard(event) {
|
|
2135
|
+
this.chats.get("room" in event ? event.room : "")?.hear(event);
|
|
1817
2136
|
if (event.type !== "state") {
|
|
1818
2137
|
return;
|
|
1819
2138
|
}
|
|
1820
|
-
this.chats.get(event.room)?.heard(event.key, event);
|
|
1821
2139
|
const known = this.agentStates.get(event.room);
|
|
1822
2140
|
if (known && event.key.startsWith(ROOM_AGENTS_KEY) && (known[event.key]?.version ?? 0) < event.version) {
|
|
1823
2141
|
this.putAgents(event.room, { ...known, [event.key]: event });
|
|
@@ -2180,7 +2498,9 @@ class DirectBook {
|
|
|
2180
2498
|
};
|
|
2181
2499
|
}
|
|
2182
2500
|
async keep(friend, room) {
|
|
2183
|
-
|
|
2501
|
+
if (!this.loaded) {
|
|
2502
|
+
await this.read();
|
|
2503
|
+
}
|
|
2184
2504
|
if (this.kept[friend] !== room) {
|
|
2185
2505
|
this.put({ ...this.kept, [friend]: room });
|
|
2186
2506
|
await pi.storage.set(DIRECT_KEY, this.kept);
|
|
@@ -2238,38 +2558,47 @@ function openDirect(friend) {
|
|
|
2238
2558
|
return open;
|
|
2239
2559
|
}
|
|
2240
2560
|
var opening = new Map;
|
|
2561
|
+
function known(friend) {
|
|
2562
|
+
const list = book.get().rooms;
|
|
2563
|
+
return list && directs.loaded ? DirectUtil.find(list, directs.get(), friend) : undefined;
|
|
2564
|
+
}
|
|
2241
2565
|
async function openOrMake(friend) {
|
|
2242
2566
|
const server = rooms();
|
|
2243
2567
|
if (!server?.inviteFriends) {
|
|
2244
2568
|
return;
|
|
2245
2569
|
}
|
|
2246
2570
|
try {
|
|
2247
|
-
|
|
2248
|
-
const { rooms: list = [] } = book.get();
|
|
2249
|
-
let room = DirectUtil.find(list, directs.get(), friend.id);
|
|
2250
|
-
const invite = !room ? (await server.listGroupInvites().catch(() => [])).find((each) => each.kind === DIRECT_KIND && each.by.id === friend.id) : undefined;
|
|
2251
|
-
if (invite) {
|
|
2252
|
-
await server.answerGroupInvite(invite.room, true);
|
|
2253
|
-
room = (await server.listRooms()).find((each) => each.id === invite.room && each.status === "member");
|
|
2254
|
-
}
|
|
2571
|
+
let room = known(friend.id);
|
|
2255
2572
|
if (!room) {
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
return;
|
|
2259
|
-
});
|
|
2260
|
-
await server.inviteFriends(room.id, [friend.id]);
|
|
2261
|
-
} else if (room.owner && !DirectUtil.peer(room)) {
|
|
2262
|
-
await server.inviteFriends(room.id, [friend.id]).catch(() => {
|
|
2263
|
-
return;
|
|
2264
|
-
});
|
|
2573
|
+
await book.load();
|
|
2574
|
+
room = DirectUtil.find(book.get().rooms ?? [], directs.get(), friend.id) ?? await joinOrMake(server, friend);
|
|
2265
2575
|
}
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2576
|
+
directs.keep(friend.id, room.id).catch(() => {
|
|
2577
|
+
return;
|
|
2578
|
+
});
|
|
2579
|
+
book.chat(room.id);
|
|
2580
|
+
await openRoom(room.id, true);
|
|
2269
2581
|
} catch (error) {
|
|
2270
2582
|
pi.ui.notify(message(error), "error");
|
|
2271
2583
|
}
|
|
2272
2584
|
}
|
|
2585
|
+
async function joinOrMake(server, friend) {
|
|
2586
|
+
const invite = (await server.listGroupInvites().catch(() => [])).find((each) => each.kind === DIRECT_KIND && each.by.id === friend.id);
|
|
2587
|
+
let room;
|
|
2588
|
+
if (invite) {
|
|
2589
|
+
await server.answerGroupInvite(invite.room, true);
|
|
2590
|
+
room = (await server.listRooms()).find((each) => each.id === invite.room && each.status === "member");
|
|
2591
|
+
}
|
|
2592
|
+
if (!room) {
|
|
2593
|
+
room = await server.createRoom({ kind: DIRECT_KIND, title: friend.name });
|
|
2594
|
+
await server.configureRoom(room.id, { members: 2 }).catch(() => {
|
|
2595
|
+
return;
|
|
2596
|
+
});
|
|
2597
|
+
await server.inviteFriends?.(room.id, [friend.id]);
|
|
2598
|
+
}
|
|
2599
|
+
await book.load();
|
|
2600
|
+
return room;
|
|
2601
|
+
}
|
|
2273
2602
|
var tidied = new Set;
|
|
2274
2603
|
function tidyDirects(list) {
|
|
2275
2604
|
const server = rooms();
|
|
@@ -2927,8 +3256,8 @@ class DoublesStore {
|
|
|
2927
3256
|
});
|
|
2928
3257
|
this.replyValue = replyValue;
|
|
2929
3258
|
next.reply = ReplyPolicyUtil.parse(replyValue, next.quiet);
|
|
2930
|
-
const
|
|
2931
|
-
const fresh = keys.includes(DoubleKeys.ASKS) ? next.asks.filter((ask) => !
|
|
3259
|
+
const known2 = new Set(this.state.asks.map((ask) => ask.id));
|
|
3260
|
+
const fresh = keys.includes(DoubleKeys.ASKS) ? next.asks.filter((ask) => !known2.has(ask.id)) : [];
|
|
2932
3261
|
this.state = next;
|
|
2933
3262
|
for (const listener of this.listeners) {
|
|
2934
3263
|
listener();
|
|
@@ -3024,7 +3353,7 @@ var EN3 = {
|
|
|
3024
3353
|
drafted: "Drafted",
|
|
3025
3354
|
message: "Message",
|
|
3026
3355
|
directEmpty: "Your chat with {name}",
|
|
3027
|
-
directHint: "
|
|
3356
|
+
directHint: "End-to-end encrypted, just the two of you",
|
|
3028
3357
|
directWaiting: "{name} gets it in their Ta",
|
|
3029
3358
|
directDelete: "Delete the chat",
|
|
3030
3359
|
directDeleteTitle: "Delete your chat with {name}?",
|
|
@@ -3062,7 +3391,8 @@ var EN3 = {
|
|
|
3062
3391
|
approveTitle: "{name} hands your double a task",
|
|
3063
3392
|
approveTake: "Take it",
|
|
3064
3393
|
approveDecline: "Not this time",
|
|
3065
|
-
approveWaiting: "Waits for you to take it"
|
|
3394
|
+
approveWaiting: "Waits for you to take it",
|
|
3395
|
+
approveHint: "Taken, it counts as yours: within what you let {name} have, pushing and deploying are not blocked either."
|
|
3066
3396
|
};
|
|
3067
3397
|
var ZH3 = {
|
|
3068
3398
|
replyTitle: "别人与我的分身",
|
|
@@ -3103,7 +3433,7 @@ var ZH3 = {
|
|
|
3103
3433
|
drafted: "已拟稿",
|
|
3104
3434
|
message: "发消息",
|
|
3105
3435
|
directEmpty: "和{name}的聊天",
|
|
3106
|
-
directHint: "
|
|
3436
|
+
directHint: "端到端加密,只有你们两人可见",
|
|
3107
3437
|
directWaiting: "{name}会在自己的 Ta 里收到",
|
|
3108
3438
|
directDelete: "删除聊天",
|
|
3109
3439
|
directDeleteTitle: "删除和{name}的聊天?",
|
|
@@ -3141,7 +3471,8 @@ var ZH3 = {
|
|
|
3141
3471
|
approveTitle: "{name}给你的分身派了任务",
|
|
3142
3472
|
approveTake: "接",
|
|
3143
3473
|
approveDecline: "这次不接",
|
|
3144
|
-
approveWaiting: "等你决定接不接"
|
|
3474
|
+
approveWaiting: "等你决定接不接",
|
|
3475
|
+
approveHint: "接下后按你发起的算:在你给{name}授权的范围内,推送、部署也不再拦。"
|
|
3145
3476
|
};
|
|
3146
3477
|
var ZH_TW3 = {
|
|
3147
3478
|
replyTitle: "別人與我的分身",
|
|
@@ -3182,7 +3513,7 @@ var ZH_TW3 = {
|
|
|
3182
3513
|
drafted: "已擬稿",
|
|
3183
3514
|
message: "傳訊息",
|
|
3184
3515
|
directEmpty: "和{name}的聊天",
|
|
3185
|
-
directHint: "
|
|
3516
|
+
directHint: "端對端加密,只有你們兩人可見",
|
|
3186
3517
|
directWaiting: "{name}會在自己的 Ta 裡收到",
|
|
3187
3518
|
directDelete: "刪除聊天",
|
|
3188
3519
|
directDeleteTitle: "刪除和{name}的聊天?",
|
|
@@ -3220,7 +3551,8 @@ var ZH_TW3 = {
|
|
|
3220
3551
|
approveTitle: "{name}給你的分身派了任務",
|
|
3221
3552
|
approveTake: "接",
|
|
3222
3553
|
approveDecline: "這次不接",
|
|
3223
|
-
approveWaiting: "等你決定接不接"
|
|
3554
|
+
approveWaiting: "等你決定接不接",
|
|
3555
|
+
approveHint: "接下後按你發起的算:在你給{name}授權的範圍內,推送、部署也不再攔。"
|
|
3224
3556
|
};
|
|
3225
3557
|
var JA3 = {
|
|
3226
3558
|
replyTitle: "ほかの人と分身",
|
|
@@ -3261,7 +3593,7 @@ var JA3 = {
|
|
|
3261
3593
|
drafted: "下書き済み",
|
|
3262
3594
|
message: "メッセージ",
|
|
3263
3595
|
directEmpty: "{name} とのチャット",
|
|
3264
|
-
directHint: "
|
|
3596
|
+
directHint: "エンドツーエンド暗号化、ふたりだけに表示",
|
|
3265
3597
|
directWaiting: "{name} の Ta に届きます",
|
|
3266
3598
|
directDelete: "チャットを削除",
|
|
3267
3599
|
directDeleteTitle: "{name} とのチャットを削除しますか?",
|
|
@@ -3299,7 +3631,8 @@ var JA3 = {
|
|
|
3299
3631
|
approveTitle: "{name}があなたの分身にタスクを依頼しました",
|
|
3300
3632
|
approveTake: "受ける",
|
|
3301
3633
|
approveDecline: "今回は受けない",
|
|
3302
|
-
approveWaiting: "受けるかどうか待っています"
|
|
3634
|
+
approveWaiting: "受けるかどうか待っています",
|
|
3635
|
+
approveHint: "受けると、あなたが頼んだものとして扱います。{name}に許可した範囲内では、プッシュやデプロイもブロックしません。"
|
|
3303
3636
|
};
|
|
3304
3637
|
var REPLY_WORDS = { "zh-CN": ZH3, "zh-TW": ZH_TW3, "en-US": EN3, "ja-JP": JA3 };
|
|
3305
3638
|
function rt(key, values = {}) {
|
|
@@ -3509,7 +3842,9 @@ function ApproveDialog({ task, close }) {
|
|
|
3509
3842
|
size: 36
|
|
3510
3843
|
}), /* @__PURE__ */ React.createElement("p", {
|
|
3511
3844
|
className: "trm-lead"
|
|
3512
|
-
}, task.text)), /* @__PURE__ */ React.createElement("
|
|
3845
|
+
}, task.text)), /* @__PURE__ */ React.createElement("p", {
|
|
3846
|
+
className: "trm-note"
|
|
3847
|
+
}, rt("approveHint", { name: task.name })), /* @__PURE__ */ React.createElement("div", {
|
|
3513
3848
|
className: "trm-actions"
|
|
3514
3849
|
}, /* @__PURE__ */ React.createElement("button", {
|
|
3515
3850
|
type: "button",
|
|
@@ -3748,14 +4083,16 @@ async function setReply(change) {
|
|
|
3748
4083
|
pi.ui.notify(message(error), "error");
|
|
3749
4084
|
}
|
|
3750
4085
|
}
|
|
4086
|
+
var SETTING_SELECT = "ta-input ta-select";
|
|
3751
4087
|
function ModeSelect({
|
|
3752
4088
|
value,
|
|
3753
4089
|
onChange,
|
|
3754
4090
|
inherit,
|
|
3755
|
-
label
|
|
4091
|
+
label,
|
|
4092
|
+
className = "trm-field"
|
|
3756
4093
|
}) {
|
|
3757
4094
|
return /* @__PURE__ */ React.createElement("select", {
|
|
3758
|
-
className
|
|
4095
|
+
className,
|
|
3759
4096
|
"aria-label": label,
|
|
3760
4097
|
value: value ?? "",
|
|
3761
4098
|
onChange: (event) => onChange(ReplyPolicyUtil.isMode(event.target.value) ? event.target.value : undefined)
|
|
@@ -3802,6 +4139,7 @@ function ReplyHere({ room }) {
|
|
|
3802
4139
|
function DefaultMode() {
|
|
3803
4140
|
const { reply } = useDoubles();
|
|
3804
4141
|
return /* @__PURE__ */ React.createElement(ModeSelect, {
|
|
4142
|
+
className: SETTING_SELECT,
|
|
3805
4143
|
value: reply.mode,
|
|
3806
4144
|
label: rt("replyDefault"),
|
|
3807
4145
|
onChange: (mode) => mode && void setReply((policy) => ({ ...policy, mode }))
|
|
@@ -3811,7 +4149,7 @@ function AwayMinutes() {
|
|
|
3811
4149
|
const { reply } = useDoubles();
|
|
3812
4150
|
const choices = AWAY_MINUTES.includes(reply.awayMinutes) ? AWAY_MINUTES : [...AWAY_MINUTES, reply.awayMinutes].sort((a, b) => a - b);
|
|
3813
4151
|
return /* @__PURE__ */ React.createElement("select", {
|
|
3814
|
-
className:
|
|
4152
|
+
className: SETTING_SELECT,
|
|
3815
4153
|
"aria-label": rt("replyAway"),
|
|
3816
4154
|
value: reply.awayMinutes,
|
|
3817
4155
|
onChange: (event) => void setReply((policy) => ({ ...policy, awayMinutes: Number(event.target.value) }))
|
|
@@ -3823,6 +4161,7 @@ function AwayMinutes() {
|
|
|
3823
4161
|
function StrangersMode() {
|
|
3824
4162
|
const { reply } = useDoubles();
|
|
3825
4163
|
return /* @__PURE__ */ React.createElement(ModeSelect, {
|
|
4164
|
+
className: SETTING_SELECT,
|
|
3826
4165
|
value: reply.strangers,
|
|
3827
4166
|
label: rt("replyStrangers"),
|
|
3828
4167
|
onChange: (mode) => mode && void setReply((policy) => ({ ...policy, strangers: mode }))
|
|
@@ -3904,9 +4243,10 @@ function OwnList() {
|
|
|
3904
4243
|
})
|
|
3905
4244
|
];
|
|
3906
4245
|
if (!rows.length) {
|
|
3907
|
-
return /* @__PURE__ */ React.createElement(
|
|
3908
|
-
|
|
3909
|
-
|
|
4246
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
4247
|
+
compact: true,
|
|
4248
|
+
title: rt("replyOwnNone")
|
|
4249
|
+
});
|
|
3910
4250
|
}
|
|
3911
4251
|
return /* @__PURE__ */ React.createElement("ul", {
|
|
3912
4252
|
className: "trm-reply-own"
|
|
@@ -3950,7 +4290,7 @@ function Choice({
|
|
|
3950
4290
|
onChange
|
|
3951
4291
|
}) {
|
|
3952
4292
|
return /* @__PURE__ */ React.createElement("select", {
|
|
3953
|
-
className:
|
|
4293
|
+
className: SETTING_SELECT,
|
|
3954
4294
|
"aria-label": label,
|
|
3955
4295
|
value,
|
|
3956
4296
|
onChange: (event) => onChange(event.target.value)
|
|
@@ -4244,6 +4584,623 @@ function AgentRow({ room, agent }) {
|
|
|
4244
4584
|
})));
|
|
4245
4585
|
}
|
|
4246
4586
|
|
|
4587
|
+
// web-src/files-view.tsx
|
|
4588
|
+
var CALL_BYTES = 384 * 1024;
|
|
4589
|
+
var AGAIN_MS = 1500;
|
|
4590
|
+
var KEPT = 6;
|
|
4591
|
+
var THUMB_SIDE = 16;
|
|
4592
|
+
var FilesUtil;
|
|
4593
|
+
((FilesUtil) => {
|
|
4594
|
+
function size(bytes) {
|
|
4595
|
+
return bytes <= 0 ? "0 KB" : bytes < 1024 * 1024 ? `${Math.max(1, Math.round(bytes / 1024))} KB` : `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
4596
|
+
}
|
|
4597
|
+
FilesUtil.size = size;
|
|
4598
|
+
function seconds(ms = 0) {
|
|
4599
|
+
const all = Math.max(1, Math.round(ms / 1000));
|
|
4600
|
+
return all < 60 ? `${all}″` : `${Math.floor(all / 60)}:${String(all % 60).padStart(2, "0")}`;
|
|
4601
|
+
}
|
|
4602
|
+
FilesUtil.seconds = seconds;
|
|
4603
|
+
function base64(bytes) {
|
|
4604
|
+
let binary = "";
|
|
4605
|
+
for (let at = 0;at < bytes.length; at += 32768) {
|
|
4606
|
+
binary += String.fromCharCode(...bytes.subarray(at, at + 32768));
|
|
4607
|
+
}
|
|
4608
|
+
return btoa(binary);
|
|
4609
|
+
}
|
|
4610
|
+
FilesUtil.base64 = base64;
|
|
4611
|
+
})(FilesUtil ||= {});
|
|
4612
|
+
|
|
4613
|
+
class FileStore {
|
|
4614
|
+
urls = new Map;
|
|
4615
|
+
progress = new Map;
|
|
4616
|
+
listeners = new Set;
|
|
4617
|
+
url(room, id) {
|
|
4618
|
+
return this.urls.get(`${room}:${id}`);
|
|
4619
|
+
}
|
|
4620
|
+
coming(room, id) {
|
|
4621
|
+
return this.progress.get(`${room}:${id}`);
|
|
4622
|
+
}
|
|
4623
|
+
subscribe(listener) {
|
|
4624
|
+
this.listeners.add(listener);
|
|
4625
|
+
return () => this.listeners.delete(listener);
|
|
4626
|
+
}
|
|
4627
|
+
async open(room, file) {
|
|
4628
|
+
const key = `${room}:${file.id}`;
|
|
4629
|
+
const known2 = this.urls.get(key);
|
|
4630
|
+
if (known2) {
|
|
4631
|
+
return known2;
|
|
4632
|
+
}
|
|
4633
|
+
const parts = [];
|
|
4634
|
+
for (let offset = 0;offset < file.bytes; ) {
|
|
4635
|
+
const read = await callDoubles({ kind: "fileRead", room, id: file.id, offset });
|
|
4636
|
+
if (read.status !== "here") {
|
|
4637
|
+
this.set(key, read.status === "coming" ? read.got / Math.max(read.bytes, 1) : -1);
|
|
4638
|
+
return;
|
|
4639
|
+
}
|
|
4640
|
+
const bytes = Uint8Array.from(atob(read.data), (char) => char.charCodeAt(0));
|
|
4641
|
+
if (!bytes.length) {
|
|
4642
|
+
return;
|
|
4643
|
+
}
|
|
4644
|
+
parts.push(bytes);
|
|
4645
|
+
offset += bytes.length;
|
|
4646
|
+
if (offset < file.bytes) {
|
|
4647
|
+
this.set(key, offset / file.bytes);
|
|
4648
|
+
}
|
|
4649
|
+
}
|
|
4650
|
+
const url = URL.createObjectURL(new Blob(parts, { type: file.type }));
|
|
4651
|
+
this.urls.set(key, url);
|
|
4652
|
+
this.progress.delete(key);
|
|
4653
|
+
for (const old of this.urls.keys()) {
|
|
4654
|
+
if (this.urls.size <= KEPT) {
|
|
4655
|
+
break;
|
|
4656
|
+
}
|
|
4657
|
+
URL.revokeObjectURL(this.urls.get(old));
|
|
4658
|
+
this.urls.delete(old);
|
|
4659
|
+
}
|
|
4660
|
+
this.tell();
|
|
4661
|
+
return url;
|
|
4662
|
+
}
|
|
4663
|
+
set(key, value) {
|
|
4664
|
+
this.progress.set(key, value);
|
|
4665
|
+
this.tell();
|
|
4666
|
+
}
|
|
4667
|
+
tell() {
|
|
4668
|
+
for (const listener of this.listeners) {
|
|
4669
|
+
listener();
|
|
4670
|
+
}
|
|
4671
|
+
}
|
|
4672
|
+
}
|
|
4673
|
+
var store = new FileStore;
|
|
4674
|
+
function use(file, url) {
|
|
4675
|
+
if (file.kind === "voice") {
|
|
4676
|
+
new Audio(url).play().catch(() => {
|
|
4677
|
+
return;
|
|
4678
|
+
});
|
|
4679
|
+
} else if (file.kind === "video") {
|
|
4680
|
+
show(({ close }) => /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
4681
|
+
title: file.name,
|
|
4682
|
+
onClose: close
|
|
4683
|
+
}, /* @__PURE__ */ React.createElement("video", {
|
|
4684
|
+
className: "trm-video-play",
|
|
4685
|
+
src: url,
|
|
4686
|
+
controls: true,
|
|
4687
|
+
autoPlay: true,
|
|
4688
|
+
playsInline: true
|
|
4689
|
+
})));
|
|
4690
|
+
} else {
|
|
4691
|
+
const link = document.createElement("a");
|
|
4692
|
+
link.href = url;
|
|
4693
|
+
link.download = file.name;
|
|
4694
|
+
link.click();
|
|
4695
|
+
}
|
|
4696
|
+
}
|
|
4697
|
+
function useOpen(room, file) {
|
|
4698
|
+
const read = () => `${store.url(room, file.id) ? "here" : ""}:${store.coming(room, file.id) ?? ""}`;
|
|
4699
|
+
const state = React.useSyncExternalStore((listener) => store.subscribe(listener), read);
|
|
4700
|
+
const [wanted, setWanted] = React.useState(false);
|
|
4701
|
+
const [here, coming] = state.split(":");
|
|
4702
|
+
React.useEffect(() => {
|
|
4703
|
+
if (!wanted) {
|
|
4704
|
+
return;
|
|
4705
|
+
}
|
|
4706
|
+
let opened = false;
|
|
4707
|
+
const again = () => void store.open(room, file).then((url) => {
|
|
4708
|
+
if (url && !opened) {
|
|
4709
|
+
opened = true;
|
|
4710
|
+
setWanted(false);
|
|
4711
|
+
use(file, url);
|
|
4712
|
+
}
|
|
4713
|
+
}, (error) => pi.ui.notify(message(error), "error"));
|
|
4714
|
+
again();
|
|
4715
|
+
const timer = setInterval(again, AGAIN_MS);
|
|
4716
|
+
const came = pi.storage?.onChange((keys) => keys.includes(DoubleKeys.FILES) && again());
|
|
4717
|
+
return () => {
|
|
4718
|
+
clearInterval(timer);
|
|
4719
|
+
came?.();
|
|
4720
|
+
};
|
|
4721
|
+
}, [wanted, room, file]);
|
|
4722
|
+
return {
|
|
4723
|
+
here: !!here,
|
|
4724
|
+
...wanted && coming !== "" ? { coming: Number(coming) } : {},
|
|
4725
|
+
open: () => {
|
|
4726
|
+
const url = store.url(room, file.id);
|
|
4727
|
+
if (url) {
|
|
4728
|
+
use(file, url);
|
|
4729
|
+
} else {
|
|
4730
|
+
setWanted(true);
|
|
4731
|
+
}
|
|
4732
|
+
}
|
|
4733
|
+
};
|
|
4734
|
+
}
|
|
4735
|
+
function FileItem({ room, file, name }) {
|
|
4736
|
+
const { open, coming } = useOpen(room, file);
|
|
4737
|
+
const status = coming === undefined ? FilesUtil.size(file.bytes) : coming < 0 ? t("fileWait", { name }) : t("fileComing", { percent: Math.floor(coming * 100) });
|
|
4738
|
+
if (file.kind === "voice") {
|
|
4739
|
+
const Mic = icon("Mic");
|
|
4740
|
+
const width = 72 + Math.min(1, (file.ms ?? 0) / RELAY_CHAT_VOICE_MS) * 120;
|
|
4741
|
+
return /* @__PURE__ */ React.createElement("button", {
|
|
4742
|
+
type: "button",
|
|
4743
|
+
className: "trm-voice",
|
|
4744
|
+
style: { width },
|
|
4745
|
+
onClick: open,
|
|
4746
|
+
"aria-label": t("voice")
|
|
4747
|
+
}, /* @__PURE__ */ React.createElement(Mic, {
|
|
4748
|
+
size: 15
|
|
4749
|
+
}), /* @__PURE__ */ React.createElement("span", null, coming === undefined ? FilesUtil.seconds(file.ms) : status));
|
|
4750
|
+
}
|
|
4751
|
+
if (file.kind === "video") {
|
|
4752
|
+
const Play = icon("Play");
|
|
4753
|
+
const ratio = file.w && file.h ? file.w / file.h : 16 / 9;
|
|
4754
|
+
return /* @__PURE__ */ React.createElement("button", {
|
|
4755
|
+
type: "button",
|
|
4756
|
+
className: "trm-video",
|
|
4757
|
+
style: { aspectRatio: String(ratio), ...file.thumb ? { backgroundImage: `url(${file.thumb})` } : {} },
|
|
4758
|
+
onClick: open,
|
|
4759
|
+
"aria-label": file.name
|
|
4760
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
4761
|
+
className: "trm-video-mark"
|
|
4762
|
+
}, /* @__PURE__ */ React.createElement(Play, {
|
|
4763
|
+
size: 18
|
|
4764
|
+
})), /* @__PURE__ */ React.createElement("span", {
|
|
4765
|
+
className: "trm-video-time"
|
|
4766
|
+
}, coming === undefined ? FilesUtil.seconds(file.ms) : status));
|
|
4767
|
+
}
|
|
4768
|
+
const File = icon("FileText");
|
|
4769
|
+
return /* @__PURE__ */ React.createElement("button", {
|
|
4770
|
+
type: "button",
|
|
4771
|
+
className: "trm-file",
|
|
4772
|
+
onClick: open
|
|
4773
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
4774
|
+
className: "trm-file-text"
|
|
4775
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
4776
|
+
className: "trm-file-name"
|
|
4777
|
+
}, file.name), /* @__PURE__ */ React.createElement("span", {
|
|
4778
|
+
className: "trm-file-size"
|
|
4779
|
+
}, status)), /* @__PURE__ */ React.createElement(File, {
|
|
4780
|
+
size: 28
|
|
4781
|
+
}));
|
|
4782
|
+
}
|
|
4783
|
+
function LineFiles({ room, line, name }) {
|
|
4784
|
+
if (!line.files?.length) {
|
|
4785
|
+
return null;
|
|
4786
|
+
}
|
|
4787
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
4788
|
+
className: "trm-files"
|
|
4789
|
+
}, line.files.map((file) => /* @__PURE__ */ React.createElement(FileItem, {
|
|
4790
|
+
key: file.id,
|
|
4791
|
+
room,
|
|
4792
|
+
file,
|
|
4793
|
+
name
|
|
4794
|
+
})));
|
|
4795
|
+
}
|
|
4796
|
+
function videoLook(blob) {
|
|
4797
|
+
return new Promise((resolve) => {
|
|
4798
|
+
const url = URL.createObjectURL(blob);
|
|
4799
|
+
const video = document.createElement("video");
|
|
4800
|
+
const done = (look) => {
|
|
4801
|
+
URL.revokeObjectURL(url);
|
|
4802
|
+
resolve(look);
|
|
4803
|
+
};
|
|
4804
|
+
const timer = setTimeout(() => done({}), 8000);
|
|
4805
|
+
video.muted = true;
|
|
4806
|
+
video.playsInline = true;
|
|
4807
|
+
video.preload = "auto";
|
|
4808
|
+
video.onloadeddata = () => {
|
|
4809
|
+
video.currentTime = Math.min(0.1, video.duration || 0);
|
|
4810
|
+
};
|
|
4811
|
+
video.onseeked = () => {
|
|
4812
|
+
clearTimeout(timer);
|
|
4813
|
+
const w = video.videoWidth;
|
|
4814
|
+
const h = video.videoHeight;
|
|
4815
|
+
const ms = Number.isFinite(video.duration) ? Math.round(video.duration * 1000) : undefined;
|
|
4816
|
+
const scale = THUMB_SIDE / Math.max(w, h, 1);
|
|
4817
|
+
const canvas = document.createElement("canvas");
|
|
4818
|
+
canvas.width = Math.max(1, Math.round(w * scale));
|
|
4819
|
+
canvas.height = Math.max(1, Math.round(h * scale));
|
|
4820
|
+
const context = canvas.getContext("2d");
|
|
4821
|
+
context?.drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
4822
|
+
const thumb = context ? [canvas.toDataURL("image/webp", 0.5), canvas.toDataURL("image/jpeg", 0.3), canvas.toDataURL("image/png")].find((each) => each.length <= 900) : undefined;
|
|
4823
|
+
done({ ...w && h ? { w, h } : {}, ...ms ? { ms } : {}, ...thumb && thumb.length <= 900 ? { thumb } : {} });
|
|
4824
|
+
};
|
|
4825
|
+
video.onerror = () => {
|
|
4826
|
+
clearTimeout(timer);
|
|
4827
|
+
done({});
|
|
4828
|
+
};
|
|
4829
|
+
video.src = url;
|
|
4830
|
+
});
|
|
4831
|
+
}
|
|
4832
|
+
|
|
4833
|
+
class Uploads {
|
|
4834
|
+
going = new Map;
|
|
4835
|
+
listeners = new Set;
|
|
4836
|
+
tell() {
|
|
4837
|
+
for (const listener of this.listeners) {
|
|
4838
|
+
listener();
|
|
4839
|
+
}
|
|
4840
|
+
}
|
|
4841
|
+
}
|
|
4842
|
+
var uploads = new Uploads;
|
|
4843
|
+
async function sendFile(room, blob, kind, name, known2 = {}) {
|
|
4844
|
+
const most = RELAY_CHAT_FILE_BYTES[kind];
|
|
4845
|
+
if (blob.size > most) {
|
|
4846
|
+
throw new Error(t("fileTooLarge", { mb: Math.round(most / (1024 * 1024)) }));
|
|
4847
|
+
}
|
|
4848
|
+
const look = kind === "video" ? await videoLook(blob) : {};
|
|
4849
|
+
if (kind === "video" && (look.ms ?? 0) > RELAY_CHAT_VIDEO_MS) {
|
|
4850
|
+
throw new Error(t("videoTooLong"));
|
|
4851
|
+
}
|
|
4852
|
+
const type = blob.type || "application/octet-stream";
|
|
4853
|
+
const upload = await callDoubles({ kind: "fileBegin", room: room.id, fileKind: kind, type, bytes: blob.size });
|
|
4854
|
+
uploads.going.set(upload, { room: room.id, name, done: 0 });
|
|
4855
|
+
uploads.tell();
|
|
4856
|
+
try {
|
|
4857
|
+
for (let offset = 0;offset < blob.size; offset += CALL_BYTES) {
|
|
4858
|
+
const bytes = new Uint8Array(await blob.slice(offset, offset + CALL_BYTES).arrayBuffer());
|
|
4859
|
+
await callDoubles({ kind: "fileAppend", upload, offset, data: FilesUtil.base64(bytes) });
|
|
4860
|
+
uploads.going.set(upload, { room: room.id, name, done: Math.min(1, (offset + bytes.length) / blob.size) });
|
|
4861
|
+
uploads.tell();
|
|
4862
|
+
}
|
|
4863
|
+
return await callDoubles({ kind: "fileFinish", upload, name, ...look, ...known2 });
|
|
4864
|
+
} finally {
|
|
4865
|
+
uploads.going.delete(upload);
|
|
4866
|
+
uploads.tell();
|
|
4867
|
+
}
|
|
4868
|
+
}
|
|
4869
|
+
function FileUploads({ room }) {
|
|
4870
|
+
const read = () => [...uploads.going.values()].filter((each) => each.room === room).map((each) => `${each.name} ${Math.floor(each.done * 100)}`).join(`
|
|
4871
|
+
`);
|
|
4872
|
+
const going = React.useSyncExternalStore((listener) => {
|
|
4873
|
+
uploads.listeners.add(listener);
|
|
4874
|
+
return () => uploads.listeners.delete(listener);
|
|
4875
|
+
}, read);
|
|
4876
|
+
if (!going) {
|
|
4877
|
+
return null;
|
|
4878
|
+
}
|
|
4879
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
4880
|
+
className: "trm-uploads",
|
|
4881
|
+
role: "status"
|
|
4882
|
+
}, going.split(`
|
|
4883
|
+
`).map((each) => {
|
|
4884
|
+
const [name, percent] = each.split("\t");
|
|
4885
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
4886
|
+
key: name,
|
|
4887
|
+
className: "trm-upload"
|
|
4888
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
4889
|
+
className: "ta-spinner"
|
|
4890
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
4891
|
+
className: "trm-ellipsis"
|
|
4892
|
+
}, t("fileSending", { name, percent })));
|
|
4893
|
+
}));
|
|
4894
|
+
}
|
|
4895
|
+
function pickFile(accept) {
|
|
4896
|
+
return new Promise((resolve) => {
|
|
4897
|
+
const input = document.createElement("input");
|
|
4898
|
+
input.type = "file";
|
|
4899
|
+
input.accept = accept;
|
|
4900
|
+
input.onchange = () => resolve(input.files?.[0]);
|
|
4901
|
+
input.oncancel = () => resolve(undefined);
|
|
4902
|
+
input.click();
|
|
4903
|
+
});
|
|
4904
|
+
}
|
|
4905
|
+
function VoiceRecorder({ close, onDone }) {
|
|
4906
|
+
const [elapsed, setElapsed] = React.useState(0);
|
|
4907
|
+
const [error, setError] = React.useState("");
|
|
4908
|
+
const recorder = React.useRef(undefined);
|
|
4909
|
+
const keep = React.useRef(false);
|
|
4910
|
+
React.useEffect(() => {
|
|
4911
|
+
let stream;
|
|
4912
|
+
let timer;
|
|
4913
|
+
const started = Date.now();
|
|
4914
|
+
const chunks = [];
|
|
4915
|
+
navigator.mediaDevices?.getUserMedia({ audio: true }).then((got) => {
|
|
4916
|
+
stream = got;
|
|
4917
|
+
const made = new MediaRecorder(got);
|
|
4918
|
+
recorder.current = made;
|
|
4919
|
+
made.ondataavailable = (event) => event.data.size && chunks.push(event.data);
|
|
4920
|
+
made.onstop = () => {
|
|
4921
|
+
for (const track of got.getTracks()) {
|
|
4922
|
+
track.stop();
|
|
4923
|
+
}
|
|
4924
|
+
if (keep.current && chunks.length) {
|
|
4925
|
+
onDone(new Blob(chunks, { type: made.mimeType || "audio/webm" }), Math.min(Date.now() - started, RELAY_CHAT_VOICE_MS));
|
|
4926
|
+
}
|
|
4927
|
+
};
|
|
4928
|
+
made.start();
|
|
4929
|
+
timer = setInterval(() => {
|
|
4930
|
+
const ms = Date.now() - started;
|
|
4931
|
+
setElapsed(ms);
|
|
4932
|
+
if (ms >= RELAY_CHAT_VOICE_MS) {
|
|
4933
|
+
keep.current = true;
|
|
4934
|
+
made.stop();
|
|
4935
|
+
close();
|
|
4936
|
+
}
|
|
4937
|
+
}, 200);
|
|
4938
|
+
}).catch(() => setError(t("voiceNoMic")));
|
|
4939
|
+
if (!navigator.mediaDevices) {
|
|
4940
|
+
setError(t("voiceNoMic"));
|
|
4941
|
+
}
|
|
4942
|
+
return () => {
|
|
4943
|
+
clearInterval(timer);
|
|
4944
|
+
if (recorder.current?.state === "recording") {
|
|
4945
|
+
recorder.current.stop();
|
|
4946
|
+
}
|
|
4947
|
+
for (const track of stream?.getTracks() ?? []) {
|
|
4948
|
+
track.stop();
|
|
4949
|
+
}
|
|
4950
|
+
};
|
|
4951
|
+
}, []);
|
|
4952
|
+
const stop = (send) => {
|
|
4953
|
+
keep.current = send;
|
|
4954
|
+
if (recorder.current?.state === "recording") {
|
|
4955
|
+
recorder.current.stop();
|
|
4956
|
+
}
|
|
4957
|
+
close();
|
|
4958
|
+
};
|
|
4959
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
4960
|
+
title: t("voiceTitle"),
|
|
4961
|
+
onClose: () => stop(false)
|
|
4962
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
4963
|
+
className: "trm-recorder"
|
|
4964
|
+
}, error ? /* @__PURE__ */ React.createElement("p", {
|
|
4965
|
+
className: "trm-note"
|
|
4966
|
+
}, error) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("span", {
|
|
4967
|
+
className: "trm-recorder-dot"
|
|
4968
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
4969
|
+
className: "trm-recorder-time"
|
|
4970
|
+
}, FilesUtil.seconds(elapsed)), /* @__PURE__ */ React.createElement("span", {
|
|
4971
|
+
className: "trm-note"
|
|
4972
|
+
}, t("voiceLong"))), /* @__PURE__ */ React.createElement("div", {
|
|
4973
|
+
className: "trm-answers"
|
|
4974
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
4975
|
+
type: "button",
|
|
4976
|
+
className: "ta-button",
|
|
4977
|
+
onClick: () => stop(false)
|
|
4978
|
+
}, t("voiceCancel")), !error && /* @__PURE__ */ React.createElement("button", {
|
|
4979
|
+
type: "button",
|
|
4980
|
+
className: "ta-button ta-primary",
|
|
4981
|
+
onClick: () => stop(true)
|
|
4982
|
+
}, t("voiceSend")))));
|
|
4983
|
+
}
|
|
4984
|
+
function fileActions(room, said) {
|
|
4985
|
+
const sendOne = async (blob, kind, name, known2 = {}) => {
|
|
4986
|
+
try {
|
|
4987
|
+
await said([await sendFile(room, blob, kind, name, known2)]);
|
|
4988
|
+
} catch (error) {
|
|
4989
|
+
pi.ui.notify(message(error), "error");
|
|
4990
|
+
}
|
|
4991
|
+
};
|
|
4992
|
+
const pick = (accept, kind) => () => void pickFile(accept).then((file) => file && sendOne(file, kind, file.name));
|
|
4993
|
+
return [
|
|
4994
|
+
{ key: "send-video", label: t("sendVideo"), icon: icon("Film"), run: pick("video/*", "video") },
|
|
4995
|
+
{ key: "send-file", label: t("sendFile"), icon: icon("FileText"), run: pick("*/*", "file") },
|
|
4996
|
+
{
|
|
4997
|
+
key: "send-voice",
|
|
4998
|
+
label: t("sendVoice"),
|
|
4999
|
+
icon: icon("Mic"),
|
|
5000
|
+
run: () => void show(({ close }) => /* @__PURE__ */ React.createElement(VoiceRecorder, {
|
|
5001
|
+
close,
|
|
5002
|
+
onDone: (blob, ms) => void sendOne(blob, "voice", t("voice"), { ms })
|
|
5003
|
+
}))
|
|
5004
|
+
}
|
|
5005
|
+
];
|
|
5006
|
+
}
|
|
5007
|
+
|
|
5008
|
+
// web-src/pictures-view.tsx
|
|
5009
|
+
var PICTURE_LIMITS = { side: 1600, bytes: 1024 * 1024 };
|
|
5010
|
+
var THUMB_SIDE2 = 16;
|
|
5011
|
+
var KEPT2 = 60;
|
|
5012
|
+
var AGAIN_MS2 = 15000;
|
|
5013
|
+
|
|
5014
|
+
class PictureStore {
|
|
5015
|
+
kept = new Map;
|
|
5016
|
+
loading = new Set;
|
|
5017
|
+
wanted = new Map;
|
|
5018
|
+
listeners = new Set;
|
|
5019
|
+
watching;
|
|
5020
|
+
get(room, id) {
|
|
5021
|
+
return this.kept.get(`${room}:${id}`);
|
|
5022
|
+
}
|
|
5023
|
+
subscribe(listener) {
|
|
5024
|
+
this.listeners.add(listener);
|
|
5025
|
+
this.watch();
|
|
5026
|
+
return () => this.listeners.delete(listener);
|
|
5027
|
+
}
|
|
5028
|
+
want(room, id) {
|
|
5029
|
+
const key = `${room}:${id}`;
|
|
5030
|
+
this.wanted.set(key, (this.wanted.get(key) ?? 0) + 1);
|
|
5031
|
+
this.load(room, id);
|
|
5032
|
+
}
|
|
5033
|
+
unwant(room, id) {
|
|
5034
|
+
const key = `${room}:${id}`;
|
|
5035
|
+
const left2 = (this.wanted.get(key) ?? 1) - 1;
|
|
5036
|
+
if (left2 > 0) {
|
|
5037
|
+
this.wanted.set(key, left2);
|
|
5038
|
+
} else {
|
|
5039
|
+
this.wanted.delete(key);
|
|
5040
|
+
}
|
|
5041
|
+
}
|
|
5042
|
+
load(room, id) {
|
|
5043
|
+
const key = `${room}:${id}`;
|
|
5044
|
+
if (this.kept.has(key) || this.loading.has(key)) {
|
|
5045
|
+
return;
|
|
5046
|
+
}
|
|
5047
|
+
this.loading.add(key);
|
|
5048
|
+
callDoubles({ kind: "picture", room, id }).then((data) => {
|
|
5049
|
+
if (typeof data === "string" && data.startsWith("data:image/")) {
|
|
5050
|
+
this.keep(key, data);
|
|
5051
|
+
}
|
|
5052
|
+
}).catch(() => {
|
|
5053
|
+
return;
|
|
5054
|
+
}).finally(() => this.loading.delete(key));
|
|
5055
|
+
}
|
|
5056
|
+
again() {
|
|
5057
|
+
for (const key of this.wanted.keys()) {
|
|
5058
|
+
const at = key.indexOf(":");
|
|
5059
|
+
this.load(key.slice(0, at), key.slice(at + 1));
|
|
5060
|
+
}
|
|
5061
|
+
}
|
|
5062
|
+
keep(key, data) {
|
|
5063
|
+
this.kept.delete(key);
|
|
5064
|
+
this.kept.set(key, data);
|
|
5065
|
+
for (const old of this.kept.keys()) {
|
|
5066
|
+
if (this.kept.size <= KEPT2) {
|
|
5067
|
+
break;
|
|
5068
|
+
}
|
|
5069
|
+
if (!this.wanted.has(old)) {
|
|
5070
|
+
this.kept.delete(old);
|
|
5071
|
+
}
|
|
5072
|
+
}
|
|
5073
|
+
for (const listener of this.listeners) {
|
|
5074
|
+
listener();
|
|
5075
|
+
}
|
|
5076
|
+
}
|
|
5077
|
+
watch() {
|
|
5078
|
+
if (this.watching || !pi.storage) {
|
|
5079
|
+
return;
|
|
5080
|
+
}
|
|
5081
|
+
this.watching = pi.storage.onChange((keys) => keys.includes(DoubleKeys.PICTURES) && this.again());
|
|
5082
|
+
}
|
|
5083
|
+
}
|
|
5084
|
+
var store2 = new PictureStore;
|
|
5085
|
+
function useSources(room, images) {
|
|
5086
|
+
const ids = images.map((image) => image.id).join(",");
|
|
5087
|
+
const read = () => images.map((image) => store2.get(room, image.id) ?? "").join(`
|
|
5088
|
+
`);
|
|
5089
|
+
const joined = React.useSyncExternalStore((listener) => store2.subscribe(listener), read);
|
|
5090
|
+
const sources = joined.split(`
|
|
5091
|
+
`).map((source) => source || undefined);
|
|
5092
|
+
const missing = images.filter((_, at) => !sources[at]).map((image) => image.id).join(",");
|
|
5093
|
+
React.useEffect(() => {
|
|
5094
|
+
if (!missing) {
|
|
5095
|
+
return;
|
|
5096
|
+
}
|
|
5097
|
+
const wanted = missing.split(",");
|
|
5098
|
+
for (const id of wanted) {
|
|
5099
|
+
store2.want(room, id);
|
|
5100
|
+
}
|
|
5101
|
+
const timer = setInterval(() => {
|
|
5102
|
+
for (const id of wanted) {
|
|
5103
|
+
store2.load(room, id);
|
|
5104
|
+
}
|
|
5105
|
+
}, AGAIN_MS2);
|
|
5106
|
+
return () => {
|
|
5107
|
+
clearInterval(timer);
|
|
5108
|
+
for (const id of wanted) {
|
|
5109
|
+
store2.unwant(room, id);
|
|
5110
|
+
}
|
|
5111
|
+
};
|
|
5112
|
+
}, [room, missing]);
|
|
5113
|
+
return ids ? sources : [];
|
|
5114
|
+
}
|
|
5115
|
+
async function thumbOf(image) {
|
|
5116
|
+
const blob = await (await fetch(`data:${image.mimeType};base64,${image.data}`)).blob();
|
|
5117
|
+
const bitmap = await createImageBitmap(blob);
|
|
5118
|
+
try {
|
|
5119
|
+
const scale = THUMB_SIDE2 / Math.max(bitmap.width, bitmap.height);
|
|
5120
|
+
const canvas = document.createElement("canvas");
|
|
5121
|
+
canvas.width = Math.max(1, Math.round(bitmap.width * scale));
|
|
5122
|
+
canvas.height = Math.max(1, Math.round(bitmap.height * scale));
|
|
5123
|
+
const context = canvas.getContext("2d");
|
|
5124
|
+
let thumb;
|
|
5125
|
+
if (context) {
|
|
5126
|
+
context.fillStyle = "#fff";
|
|
5127
|
+
context.fillRect(0, 0, canvas.width, canvas.height);
|
|
5128
|
+
context.drawImage(bitmap, 0, 0, canvas.width, canvas.height);
|
|
5129
|
+
thumb = canvas.toDataURL("image/jpeg", 0.5);
|
|
5130
|
+
}
|
|
5131
|
+
return { thumb: thumb && thumb.length <= 900 ? thumb : undefined, w: image.width ?? bitmap.width, h: image.height ?? bitmap.height };
|
|
5132
|
+
} finally {
|
|
5133
|
+
bitmap.close();
|
|
5134
|
+
}
|
|
5135
|
+
}
|
|
5136
|
+
async function sendPictures(room, images) {
|
|
5137
|
+
return Promise.all(images.map(async (image) => {
|
|
5138
|
+
const [put, look] = await Promise.all([
|
|
5139
|
+
callDoubles({ kind: "putPicture", room: room.id, data: image.data, type: image.mimeType }),
|
|
5140
|
+
thumbOf(image)
|
|
5141
|
+
]);
|
|
5142
|
+
return { ...put, w: look.w, h: look.h, ...look.thumb ? { thumb: look.thumb } : {} };
|
|
5143
|
+
}));
|
|
5144
|
+
}
|
|
5145
|
+
function LinePictures({ room, line, name }) {
|
|
5146
|
+
const images = line.images ?? [];
|
|
5147
|
+
const sources = useSources(room, images);
|
|
5148
|
+
const ChatImages = pi.ui.ChatImages;
|
|
5149
|
+
if (!images.length) {
|
|
5150
|
+
return null;
|
|
5151
|
+
}
|
|
5152
|
+
if (!ChatImages) {
|
|
5153
|
+
return /* @__PURE__ */ React.createElement("span", {
|
|
5154
|
+
className: "trm-quiet"
|
|
5155
|
+
}, t("picture"));
|
|
5156
|
+
}
|
|
5157
|
+
const waiting = sources.some((source) => !source);
|
|
5158
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
5159
|
+
className: "trm-pics",
|
|
5160
|
+
title: waiting ? t("pictureWait", { name }) : undefined
|
|
5161
|
+
}, /* @__PURE__ */ React.createElement(ChatImages, {
|
|
5162
|
+
alt: t("pictureAlt", { name }),
|
|
5163
|
+
images: images.map((image, at) => ({ key: image.id, src: sources[at], thumb: image.thumb, width: image.w, height: image.h }))
|
|
5164
|
+
}));
|
|
5165
|
+
}
|
|
5166
|
+
|
|
5167
|
+
// web-src/room-rules.ts
|
|
5168
|
+
var ROOM_RULES = ["agents", "doubles", "tasks"];
|
|
5169
|
+
var RoomRulesUtil;
|
|
5170
|
+
((RoomRulesUtil) => {
|
|
5171
|
+
function allows(room, rule) {
|
|
5172
|
+
return room?.rules?.[rule] !== false;
|
|
5173
|
+
}
|
|
5174
|
+
RoomRulesUtil.allows = allows;
|
|
5175
|
+
function approves(room) {
|
|
5176
|
+
return room?.rules?.approve === true;
|
|
5177
|
+
}
|
|
5178
|
+
RoomRulesUtil.approves = approves;
|
|
5179
|
+
function refused(rule, language) {
|
|
5180
|
+
return TaLanguageUtil.pick(language, {
|
|
5181
|
+
agents: {
|
|
5182
|
+
"zh-CN": "群主没有允许在这个群里用智能体",
|
|
5183
|
+
"zh-TW": "群主沒有允許在這個群裡用智慧體",
|
|
5184
|
+
"en-US": "the owner allows no agents in this group chat",
|
|
5185
|
+
"ja-JP": "このグループチャットではグループ主がエージェントを許可していません"
|
|
5186
|
+
},
|
|
5187
|
+
doubles: {
|
|
5188
|
+
"zh-CN": "群主没有允许分身在这个群里代答",
|
|
5189
|
+
"zh-TW": "群主沒有允許分身在這個群裡代答",
|
|
5190
|
+
"en-US": "the owner allows no double to answer in this group chat",
|
|
5191
|
+
"ja-JP": "このグループチャットではグループ主が分身の代理応答を許可していません"
|
|
5192
|
+
},
|
|
5193
|
+
tasks: {
|
|
5194
|
+
"zh-CN": "群主没有允许在这个群里给分身派任务",
|
|
5195
|
+
"zh-TW": "群主沒有允許在這個群裡給分身派任務",
|
|
5196
|
+
"en-US": "the owner allows no tasks for doubles in this group chat",
|
|
5197
|
+
"ja-JP": "このグループチャットではグループ主が分身へのタスクを許可していません"
|
|
5198
|
+
}
|
|
5199
|
+
}[rule]);
|
|
5200
|
+
}
|
|
5201
|
+
RoomRulesUtil.refused = refused;
|
|
5202
|
+
})(RoomRulesUtil ||= {});
|
|
5203
|
+
|
|
4247
5204
|
// web-src/tasks-view.tsx
|
|
4248
5205
|
function taskStatusWord(status) {
|
|
4249
5206
|
switch (status) {
|
|
@@ -4586,6 +5543,7 @@ function RoomView({ room, head, onBack }) {
|
|
|
4586
5543
|
const tasks = useTaskStates(room);
|
|
4587
5544
|
const list = React.useRef(null);
|
|
4588
5545
|
const stuck = React.useRef(true);
|
|
5546
|
+
const older = React.useRef(undefined);
|
|
4589
5547
|
const self = room.members.find((member) => member.self);
|
|
4590
5548
|
const personOf = (line) => room.members.find((member) => member.member === line.from)?.name ?? line.name;
|
|
4591
5549
|
const nameOf = (line) => line.agent ? line.agent.name : !line.double ? personOf(line) : line.from === self?.member ? dt("myDouble") : dt("doubleOf", { name: personOf(line) });
|
|
@@ -4616,13 +5574,30 @@ function RoomView({ room, head, onBack }) {
|
|
|
4616
5574
|
book.see(room.id, last.at);
|
|
4617
5575
|
}
|
|
4618
5576
|
}, [lines, room.id]);
|
|
4619
|
-
const
|
|
5577
|
+
const { apps } = useRoomApps(room);
|
|
5578
|
+
const actions = [
|
|
5579
|
+
fileActions(room, async (files) => {
|
|
5580
|
+
if (self && chat) {
|
|
5581
|
+
stuck.current = true;
|
|
5582
|
+
await chat.say("", self, { files });
|
|
5583
|
+
}
|
|
5584
|
+
}),
|
|
5585
|
+
[
|
|
5586
|
+
...RoomRulesUtil.allows(room, "agents") ? [{ key: "invite-agent", label: dt("inviteAgent"), icon: icon("Bot"), run: () => openAgentPicker(room) }] : [],
|
|
5587
|
+
...apps.map((app) => ({ key: `app:${app.id}`, label: app.label, detail: app.status, icon: app.icon, run: () => openApp(room, app) }))
|
|
5588
|
+
]
|
|
5589
|
+
];
|
|
5590
|
+
const say = async (text, images = []) => {
|
|
4620
5591
|
if (!self || !chat) {
|
|
4621
5592
|
throw new Error(t("connecting"));
|
|
4622
5593
|
}
|
|
4623
5594
|
stuck.current = true;
|
|
4624
5595
|
const { to, person } = addressed(text, room, agents);
|
|
4625
|
-
|
|
5596
|
+
const pictures = images.length ? await sendPictures(room, images) : [];
|
|
5597
|
+
await chat.say(text, self, {
|
|
5598
|
+
...to.length ? { to, ...person ? { person: true } : {} } : {},
|
|
5599
|
+
...pictures.length ? { images: pictures } : {}
|
|
5600
|
+
});
|
|
4626
5601
|
};
|
|
4627
5602
|
return /* @__PURE__ */ React.createElement("div", {
|
|
4628
5603
|
className: "trm-room-page"
|
|
@@ -4646,6 +5621,15 @@ function RoomView({ room, head, onBack }) {
|
|
|
4646
5621
|
onScroll: (event) => {
|
|
4647
5622
|
const element = event.currentTarget;
|
|
4648
5623
|
stuck.current = element.scrollHeight - element.scrollTop - element.clientHeight < 48;
|
|
5624
|
+
if (element.scrollTop < 120 && chat?.more && !older.current) {
|
|
5625
|
+
older.current = chat.older().then(() => {
|
|
5626
|
+
return;
|
|
5627
|
+
}, () => {
|
|
5628
|
+
return;
|
|
5629
|
+
}).finally(() => {
|
|
5630
|
+
older.current = undefined;
|
|
5631
|
+
});
|
|
5632
|
+
}
|
|
4649
5633
|
}
|
|
4650
5634
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
4651
5635
|
className: "trm-chat-col"
|
|
@@ -4677,13 +5661,23 @@ function RoomView({ room, head, onBack }) {
|
|
|
4677
5661
|
}, separator && /* @__PURE__ */ React.createElement("div", {
|
|
4678
5662
|
className: "trm-chat-time"
|
|
4679
5663
|
}, time(line.at)), line.from === self?.member && !line.double && !line.agent ? /* @__PURE__ */ React.createElement("div", {
|
|
4680
|
-
className:
|
|
5664
|
+
className: `ta-message ta-user trm-mine${line.pending ? " trm-pending" : ""}`,
|
|
4681
5665
|
title: time(line.at)
|
|
4682
|
-
}, /* @__PURE__ */ React.createElement(
|
|
5666
|
+
}, /* @__PURE__ */ React.createElement(LinePictures, {
|
|
5667
|
+
room: room.id,
|
|
5668
|
+
line,
|
|
5669
|
+
name: nameOf(line)
|
|
5670
|
+
}), /* @__PURE__ */ React.createElement(LineFiles, {
|
|
5671
|
+
room: room.id,
|
|
5672
|
+
line,
|
|
5673
|
+
name: nameOf(line)
|
|
5674
|
+
}), line.text && /* @__PURE__ */ React.createElement("div", {
|
|
4683
5675
|
className: "ta-bubble"
|
|
4684
5676
|
}, /* @__PURE__ */ React.createElement(pi.ui.Markdown, {
|
|
4685
5677
|
text: line.text
|
|
4686
|
-
}))
|
|
5678
|
+
})), line.failed && /* @__PURE__ */ React.createElement("div", {
|
|
5679
|
+
className: "trm-unsent"
|
|
5680
|
+
}, t("unsent"))) : /* @__PURE__ */ React.createElement("div", {
|
|
4687
5681
|
className: `trm-msg${first ? " trm-first" : ""}${line.double ? " trm-double" : ""}${line.agent ? " trm-agent" : ""}`
|
|
4688
5682
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
4689
5683
|
className: "trm-msg-face"
|
|
@@ -4700,7 +5694,15 @@ function RoomView({ room, head, onBack }) {
|
|
|
4700
5694
|
className: `trm-tag ${line.agent ? "trm-tag-agent" : "trm-tag-double"}`
|
|
4701
5695
|
}, tagOf(line)), line.task && /* @__PURE__ */ React.createElement("span", {
|
|
4702
5696
|
className: "trm-tag trm-tag-task"
|
|
4703
|
-
}, dt("taskTag"))), /* @__PURE__ */ React.createElement(
|
|
5697
|
+
}, dt("taskTag"))), /* @__PURE__ */ React.createElement(LinePictures, {
|
|
5698
|
+
room: room.id,
|
|
5699
|
+
line,
|
|
5700
|
+
name: nameOf(line)
|
|
5701
|
+
}), /* @__PURE__ */ React.createElement(LineFiles, {
|
|
5702
|
+
room: room.id,
|
|
5703
|
+
line,
|
|
5704
|
+
name: nameOf(line)
|
|
5705
|
+
}), line.text && /* @__PURE__ */ React.createElement("div", {
|
|
4704
5706
|
className: "trm-msg-bubble",
|
|
4705
5707
|
title: time(line.at)
|
|
4706
5708
|
}, /* @__PURE__ */ React.createElement(pi.ui.Markdown, {
|
|
@@ -4718,10 +5720,14 @@ function RoomView({ room, head, onBack }) {
|
|
|
4718
5720
|
className: "trm-chat-bottom"
|
|
4719
5721
|
}, /* @__PURE__ */ React.createElement(Drafts, {
|
|
4720
5722
|
room
|
|
5723
|
+
}), /* @__PURE__ */ React.createElement(FileUploads, {
|
|
5724
|
+
room: room.id
|
|
4721
5725
|
}), /* @__PURE__ */ React.createElement(pi.ui.Composer, {
|
|
4722
5726
|
placeholder: t("chatPlaceholder"),
|
|
4723
5727
|
draft: room.id,
|
|
4724
5728
|
onSend: say,
|
|
5729
|
+
images: PICTURE_LIMITS,
|
|
5730
|
+
actions,
|
|
4725
5731
|
mentions,
|
|
4726
5732
|
mentionLabel: rt("mentionPerson")
|
|
4727
5733
|
})));
|
|
@@ -4855,13 +5861,16 @@ function PersonDialog({ person, room, close }) {
|
|
|
4855
5861
|
}, /* @__PURE__ */ React.createElement("button", {
|
|
4856
5862
|
type: "button",
|
|
4857
5863
|
className: "ta-button ta-danger",
|
|
4858
|
-
onClick: () => void
|
|
4859
|
-
await rooms()?.removeFriend(friend.id);
|
|
4860
|
-
close();
|
|
4861
|
-
await book.load();
|
|
4862
|
-
})
|
|
5864
|
+
onClick: () => void removeFriend(friend, close)
|
|
4863
5865
|
}, rt("removeFriendLong")))));
|
|
4864
5866
|
}
|
|
5867
|
+
function removeFriend(friend, then) {
|
|
5868
|
+
return confirmThen(t("removeFriendTitle", { name: friend.name }), t("removeFriendHint"), t("removeFriend"), async () => {
|
|
5869
|
+
await rooms()?.removeFriend(friend.id);
|
|
5870
|
+
then?.();
|
|
5871
|
+
await book.load();
|
|
5872
|
+
});
|
|
5873
|
+
}
|
|
4865
5874
|
function openPerson(person, room) {
|
|
4866
5875
|
show(({ close }) => /* @__PURE__ */ React.createElement(PersonDialog, {
|
|
4867
5876
|
person,
|
|
@@ -5054,7 +6063,7 @@ function FriendLinkDialog({ text, close }) {
|
|
|
5054
6063
|
const link = RelayHubUtil.parse(text);
|
|
5055
6064
|
const { identity, friends } = useBook();
|
|
5056
6065
|
const [busy, run] = useRun();
|
|
5057
|
-
const
|
|
6066
|
+
const known2 = friends?.find((friend) => friend.id === link.owner && friend.status === "friend");
|
|
5058
6067
|
const own = identity?.id === link.owner;
|
|
5059
6068
|
const add = () => void run(async () => {
|
|
5060
6069
|
await rooms()?.addFriend(text);
|
|
@@ -5077,13 +6086,13 @@ function FriendLinkDialog({ text, close }) {
|
|
|
5077
6086
|
className: "trm-join-name"
|
|
5078
6087
|
}, link.by || "…"), /* @__PURE__ */ React.createElement("p", {
|
|
5079
6088
|
className: "trm-lead"
|
|
5080
|
-
}, own ? t("addFriendOwn") :
|
|
6089
|
+
}, own ? t("addFriendOwn") : known2 ? t("addFriendKnown", { name: link.by }) : t("addFriendBody", { name: link.by || "…" }))), /* @__PURE__ */ React.createElement("div", {
|
|
5081
6090
|
className: "trm-actions"
|
|
5082
6091
|
}, /* @__PURE__ */ React.createElement("button", {
|
|
5083
6092
|
type: "button",
|
|
5084
6093
|
className: "ta-button",
|
|
5085
6094
|
onClick: close
|
|
5086
|
-
}, t("later")), !own && !
|
|
6095
|
+
}, t("later")), !own && !known2 && /* @__PURE__ */ React.createElement("button", {
|
|
5087
6096
|
type: "button",
|
|
5088
6097
|
className: `ta-button ta-primary${busy ? " ta-busy" : ""}`,
|
|
5089
6098
|
disabled: busy,
|
|
@@ -5377,9 +6386,9 @@ function openJoin(text) {
|
|
|
5377
6386
|
return;
|
|
5378
6387
|
}
|
|
5379
6388
|
const link = RelayHubUtil.parse(text);
|
|
5380
|
-
const
|
|
6389
|
+
const known2 = () => book.get().rooms?.find((room) => room.id === link.room && room.status === "member");
|
|
5381
6390
|
const go = () => {
|
|
5382
|
-
const room =
|
|
6391
|
+
const room = known2();
|
|
5383
6392
|
if (!room) {
|
|
5384
6393
|
show(({ close }) => /* @__PURE__ */ React.createElement(JoinDialog, {
|
|
5385
6394
|
link,
|
|
@@ -5392,7 +6401,7 @@ function openJoin(text) {
|
|
|
5392
6401
|
openRoom(room.id);
|
|
5393
6402
|
}
|
|
5394
6403
|
};
|
|
5395
|
-
if (
|
|
6404
|
+
if (known2()) {
|
|
5396
6405
|
go();
|
|
5397
6406
|
} else {
|
|
5398
6407
|
book.load().then(go, go);
|
|
@@ -5865,43 +6874,6 @@ function openGroupInvite(invite) {
|
|
|
5865
6874
|
}));
|
|
5866
6875
|
}
|
|
5867
6876
|
|
|
5868
|
-
// web-src/room-rules.ts
|
|
5869
|
-
var ROOM_RULES = ["agents", "doubles", "tasks"];
|
|
5870
|
-
var RoomRulesUtil;
|
|
5871
|
-
((RoomRulesUtil) => {
|
|
5872
|
-
function allows(room, rule) {
|
|
5873
|
-
return room?.rules?.[rule] !== false;
|
|
5874
|
-
}
|
|
5875
|
-
RoomRulesUtil.allows = allows;
|
|
5876
|
-
function approves(room) {
|
|
5877
|
-
return room?.rules?.approve === true;
|
|
5878
|
-
}
|
|
5879
|
-
RoomRulesUtil.approves = approves;
|
|
5880
|
-
function refused(rule, language) {
|
|
5881
|
-
return TaLanguageUtil.pick(language, {
|
|
5882
|
-
agents: {
|
|
5883
|
-
"zh-CN": "群主没有允许在这个群里用智能体",
|
|
5884
|
-
"zh-TW": "群主沒有允許在這個群裡用智慧體",
|
|
5885
|
-
"en-US": "the owner allows no agents in this group chat",
|
|
5886
|
-
"ja-JP": "このグループチャットではグループ主がエージェントを許可していません"
|
|
5887
|
-
},
|
|
5888
|
-
doubles: {
|
|
5889
|
-
"zh-CN": "群主没有允许分身在这个群里代答",
|
|
5890
|
-
"zh-TW": "群主沒有允許分身在這個群裡代答",
|
|
5891
|
-
"en-US": "the owner allows no double to answer in this group chat",
|
|
5892
|
-
"ja-JP": "このグループチャットではグループ主が分身の代理応答を許可していません"
|
|
5893
|
-
},
|
|
5894
|
-
tasks: {
|
|
5895
|
-
"zh-CN": "群主没有允许在这个群里给分身派任务",
|
|
5896
|
-
"zh-TW": "群主沒有允許在這個群裡給分身派任務",
|
|
5897
|
-
"en-US": "the owner allows no tasks for doubles in this group chat",
|
|
5898
|
-
"ja-JP": "このグループチャットではグループ主が分身へのタスクを許可していません"
|
|
5899
|
-
}
|
|
5900
|
-
}[rule]);
|
|
5901
|
-
}
|
|
5902
|
-
RoomRulesUtil.refused = refused;
|
|
5903
|
-
})(RoomRulesUtil ||= {});
|
|
5904
|
-
|
|
5905
6877
|
// web-src/rules-i18n.ts
|
|
5906
6878
|
var EN4 = {
|
|
5907
6879
|
rulesManage: "Manage the group chat",
|
|
@@ -5924,6 +6896,9 @@ var EN4 = {
|
|
|
5924
6896
|
joining: "Joining",
|
|
5925
6897
|
capacity: "Members at most",
|
|
5926
6898
|
capacityValue: "Up to {n}",
|
|
6899
|
+
history: "Chat history for new members",
|
|
6900
|
+
historyNone: "None",
|
|
6901
|
+
historyValue: "Last {n} messages",
|
|
5927
6902
|
linkDays: "The link that invites works",
|
|
5928
6903
|
linkDaysValue7: "7 days",
|
|
5929
6904
|
linkDaysValue30: "30 days",
|
|
@@ -5957,6 +6932,9 @@ var ZH4 = {
|
|
|
5957
6932
|
joining: "加入",
|
|
5958
6933
|
capacity: "人数上限",
|
|
5959
6934
|
capacityValue: "最多 {n} 人",
|
|
6935
|
+
history: "新成员可见的聊天记录",
|
|
6936
|
+
historyNone: "不可见",
|
|
6937
|
+
historyValue: "最近 {n} 条",
|
|
5960
6938
|
linkDays: "邀请链接有效期",
|
|
5961
6939
|
linkDaysValue7: "7 天",
|
|
5962
6940
|
linkDaysValue30: "30 天",
|
|
@@ -5990,6 +6968,9 @@ var ZH_TW4 = {
|
|
|
5990
6968
|
joining: "加入",
|
|
5991
6969
|
capacity: "人數上限",
|
|
5992
6970
|
capacityValue: "最多 {n} 人",
|
|
6971
|
+
history: "新成員可見的聊天記錄",
|
|
6972
|
+
historyNone: "不可見",
|
|
6973
|
+
historyValue: "最近 {n} 則",
|
|
5993
6974
|
linkDays: "邀請連結有效期",
|
|
5994
6975
|
linkDaysValue7: "7 天",
|
|
5995
6976
|
linkDaysValue30: "30 天",
|
|
@@ -6023,6 +7004,9 @@ var JA4 = {
|
|
|
6023
7004
|
joining: "参加",
|
|
6024
7005
|
capacity: "人数の上限",
|
|
6025
7006
|
capacityValue: "最大 {n} 人",
|
|
7007
|
+
history: "新しいメンバーが見られる履歴",
|
|
7008
|
+
historyNone: "見られない",
|
|
7009
|
+
historyValue: "直近 {n} 件",
|
|
6026
7010
|
linkDays: "招待リンクの有効期限",
|
|
6027
7011
|
linkDaysValue7: "7 日",
|
|
6028
7012
|
linkDaysValue30: "30 日",
|
|
@@ -6074,6 +7058,7 @@ function GroupRulesRow({ room }) {
|
|
|
6074
7058
|
size: 15
|
|
6075
7059
|
}));
|
|
6076
7060
|
}
|
|
7061
|
+
var HISTORY_CHOICES = [0, 50, 100, 200, 500];
|
|
6077
7062
|
function configure(room, options) {
|
|
6078
7063
|
const call = rooms()?.configureRoom(room.id, options);
|
|
6079
7064
|
return (call ?? Promise.resolve()).catch((error) => {
|
|
@@ -6107,6 +7092,7 @@ function Joining({ room }) {
|
|
|
6107
7092
|
const Check = icon("Check");
|
|
6108
7093
|
const choose = (event, items) => openMenu(event, [items.map((item) => ({ key: item.key, label: item.label, ...item.on ? { icon: Check } : {}, run: item.run }))]);
|
|
6109
7094
|
const capacity = room.capacity ?? MEMBER_CHOICES[0];
|
|
7095
|
+
const history = room.history ?? 0;
|
|
6110
7096
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
6111
7097
|
className: "trm-panel-label"
|
|
6112
7098
|
}, gt("joining")), /* @__PURE__ */ React.createElement(JoinRow, {
|
|
@@ -6129,6 +7115,17 @@ function Joining({ room }) {
|
|
|
6129
7115
|
on: n === days,
|
|
6130
7116
|
run: () => void setLinkDays(room.id, n).then(() => pi.ui.notify(gt("linkDaysHint"))).catch((error) => pi.ui.notify(message(error), "error"))
|
|
6131
7117
|
})))
|
|
7118
|
+
}), /* @__PURE__ */ React.createElement(JoinRow, {
|
|
7119
|
+
label: gt("history"),
|
|
7120
|
+
value: history ? gt("historyValue", { n: history }) : gt("historyNone"),
|
|
7121
|
+
onClick: (event) => choose(event, HISTORY_CHOICES.map((n) => ({
|
|
7122
|
+
key: String(n),
|
|
7123
|
+
label: n ? gt("historyValue", { n }) : gt("historyNone"),
|
|
7124
|
+
on: n === history,
|
|
7125
|
+
run: () => void configure(room, { history: n }).catch(() => {
|
|
7126
|
+
return;
|
|
7127
|
+
})
|
|
7128
|
+
})))
|
|
6132
7129
|
}), menu, /* @__PURE__ */ React.createElement("div", {
|
|
6133
7130
|
className: "trm-panel-sep"
|
|
6134
7131
|
}));
|
|
@@ -6590,11 +7587,12 @@ function roomPreview(room, last) {
|
|
|
6590
7587
|
}
|
|
6591
7588
|
const self = room.members.find((each) => each.self)?.member;
|
|
6592
7589
|
if (direct && !last.agent && !last.double) {
|
|
6593
|
-
return plain(last
|
|
7590
|
+
return plain(RelayRoomChatUtil.preview(last, t("picture"), { file: t("file"), voice: t("voice"), video: t("video") }));
|
|
6594
7591
|
}
|
|
6595
7592
|
const person = room.members.find((each) => each.member === last.from)?.name ?? last.name;
|
|
6596
7593
|
const name = last.agent?.name ?? (!last.double ? person : last.from === self ? dt("myDouble") : dt("doubleOf", { name: person }));
|
|
6597
|
-
|
|
7594
|
+
const said = plain(RelayRoomChatUtil.preview(last, t("picture"), { file: t("file"), voice: t("voice"), video: t("video") }));
|
|
7595
|
+
return last.from === self && !last.agent && !last.double ? said : t("said", { name, text: said });
|
|
6598
7596
|
}
|
|
6599
7597
|
function lastAt(room) {
|
|
6600
7598
|
const lines = room.status === "member" ? book.chat(room.id)?.lines : undefined;
|
|
@@ -7259,9 +8257,15 @@ class RoomsPartners {
|
|
|
7259
8257
|
icon: icon("Contact"),
|
|
7260
8258
|
...friend.status === "adding" ? { status: "waiting", about: t("friendAdding") } : {},
|
|
7261
8259
|
...online ? { online } : {},
|
|
7262
|
-
chat: shared ? { last: t("friendShareRow", { title: shared.title || shared.link }), at: shared.at, unseen: true } : direct ? {
|
|
8260
|
+
chat: shared ? { last: t("friendShareRow", { title: shared.title || shared.link }), at: shared.at, unseen: true } : direct ? {
|
|
8261
|
+
last: roomPreview(direct, said.at(-1)) || undefined,
|
|
8262
|
+
at,
|
|
8263
|
+
unseen: unseen(direct, said, book.get().seen),
|
|
8264
|
+
close: { key: "close", label: rt("directDelete"), danger: true, run: () => void leaveRoom(direct) }
|
|
8265
|
+
} : undefined,
|
|
7263
8266
|
open: () => shared ? openFriendShare(shared) : friend.status === "friend" ? openDirect(friend) : openFriend(friend.id),
|
|
7264
|
-
|
|
8267
|
+
info: () => openPerson({ id: friend.id, name: friend.name }),
|
|
8268
|
+
remove: { key: "remove", label: rt("removeFriendLong"), danger: true, run: () => void removeFriend(friend) }
|
|
7265
8269
|
};
|
|
7266
8270
|
}
|
|
7267
8271
|
groupOf(room) {
|
|
@@ -7275,10 +8279,12 @@ class RoomsPartners {
|
|
|
7275
8279
|
size
|
|
7276
8280
|
})),
|
|
7277
8281
|
icon: icon("Users"),
|
|
8282
|
+
friends: true,
|
|
7278
8283
|
about: t("roomOf", { name: room.ownerName }),
|
|
7279
8284
|
chat: { last: roomPreview(room, said.at(-1)) || undefined, at: lastAt(room), unseen: unseen(room, said, book.get().seen) },
|
|
7280
8285
|
open: () => openRoom(room.id, true),
|
|
7281
|
-
|
|
8286
|
+
info: () => void openRoom(room.id, true).then(() => pi.ui.showView(MEMBERS_VIEW)),
|
|
8287
|
+
remove: { key: "leave", label: room.owner ? t("close") : t("leave"), danger: true, run: () => void leaveRoom(room) }
|
|
7282
8288
|
};
|
|
7283
8289
|
}
|
|
7284
8290
|
asking(request) {
|
|
@@ -7366,6 +8372,202 @@ function RoomFaceOf({ id, size }) {
|
|
|
7366
8372
|
}) : null;
|
|
7367
8373
|
}
|
|
7368
8374
|
|
|
8375
|
+
// web-src/storage-view.tsx
|
|
8376
|
+
var total = (each) => each.said + each.media.mine + each.media.others;
|
|
8377
|
+
var MONTHS = [1, 3, 6, 12];
|
|
8378
|
+
function monthsAgo(months, now = new Date) {
|
|
8379
|
+
return new Date(now.getFullYear(), now.getMonth() - months, 1).getTime();
|
|
8380
|
+
}
|
|
8381
|
+
function ClearOlder({ room, name, close, onDone }) {
|
|
8382
|
+
const [freed, setFreed] = React.useState({});
|
|
8383
|
+
const [busy, setBusy] = React.useState(false);
|
|
8384
|
+
React.useEffect(() => {
|
|
8385
|
+
(async () => {
|
|
8386
|
+
const read = {};
|
|
8387
|
+
for (const months of MONTHS) {
|
|
8388
|
+
read[months] = (await rooms()?.chatUsage?.(monthsAgo(months)).catch(() => {
|
|
8389
|
+
return;
|
|
8390
|
+
}))?.[room.id] ?? 0;
|
|
8391
|
+
}
|
|
8392
|
+
setFreed(read);
|
|
8393
|
+
})();
|
|
8394
|
+
}, [room.id]);
|
|
8395
|
+
const clear = async (months) => {
|
|
8396
|
+
setBusy(true);
|
|
8397
|
+
try {
|
|
8398
|
+
await rooms()?.clearChat(room.id, monthsAgo(months));
|
|
8399
|
+
pi.ui.notify(t("storageFreed", { size: FilesUtil.size(freed[months] ?? 0) }));
|
|
8400
|
+
book.chat(room.id)?.load();
|
|
8401
|
+
onDone();
|
|
8402
|
+
close();
|
|
8403
|
+
} catch (error) {
|
|
8404
|
+
pi.ui.notify(message(error), "error");
|
|
8405
|
+
setBusy(false);
|
|
8406
|
+
}
|
|
8407
|
+
};
|
|
8408
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
8409
|
+
title: t("storageOlderTitle", { name }),
|
|
8410
|
+
onClose: close
|
|
8411
|
+
}, /* @__PURE__ */ React.createElement("p", {
|
|
8412
|
+
className: "trm-note"
|
|
8413
|
+
}, t("storageOlderHint")), /* @__PURE__ */ React.createElement("ul", {
|
|
8414
|
+
className: "trm-panel-members trm-older"
|
|
8415
|
+
}, MONTHS.map((months) => /* @__PURE__ */ React.createElement("li", {
|
|
8416
|
+
key: months
|
|
8417
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
8418
|
+
type: "button",
|
|
8419
|
+
className: `trm-member${busy ? " ta-pending" : ""}`,
|
|
8420
|
+
disabled: busy || freed[months] === 0,
|
|
8421
|
+
onClick: () => void clear(months)
|
|
8422
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
8423
|
+
className: "trm-member-text"
|
|
8424
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
8425
|
+
className: "trm-member-name"
|
|
8426
|
+
}, t(months === 12 ? "storageOlderYear" : "storageOlderMonths", { n: months }))), /* @__PURE__ */ React.createElement("span", {
|
|
8427
|
+
className: "trm-storage-size"
|
|
8428
|
+
}, freed[months] === undefined ? "…" : freed[months] ? FilesUtil.size(freed[months]) : t("storageOlderNone")))))));
|
|
8429
|
+
}
|
|
8430
|
+
function useUsage() {
|
|
8431
|
+
const { rooms: list, friends } = useBook();
|
|
8432
|
+
const [usage, setUsage] = React.useState();
|
|
8433
|
+
const [again, setAgain] = React.useState(0);
|
|
8434
|
+
const chats = (list ?? []).filter((room) => !room.unlisted && room.status === "member");
|
|
8435
|
+
const ids = chats.map((room) => room.id).join(",");
|
|
8436
|
+
React.useEffect(() => {
|
|
8437
|
+
let gone = false;
|
|
8438
|
+
(async () => {
|
|
8439
|
+
const said = await rooms()?.chatUsage?.().catch(() => {
|
|
8440
|
+
return;
|
|
8441
|
+
}) ?? {};
|
|
8442
|
+
const read = [];
|
|
8443
|
+
for (const room of chats) {
|
|
8444
|
+
const media = await callDoubles({ kind: "mediaUsage", room: room.id }).catch(() => {
|
|
8445
|
+
return;
|
|
8446
|
+
}) ?? {
|
|
8447
|
+
mine: 0,
|
|
8448
|
+
others: 0
|
|
8449
|
+
};
|
|
8450
|
+
read.push({ room, said: said[room.id] ?? 0, media });
|
|
8451
|
+
}
|
|
8452
|
+
if (!gone) {
|
|
8453
|
+
setUsage(read.sort((a, b) => total(b) - total(a)));
|
|
8454
|
+
}
|
|
8455
|
+
})();
|
|
8456
|
+
return () => {
|
|
8457
|
+
gone = true;
|
|
8458
|
+
};
|
|
8459
|
+
}, [ids, again, friends?.length]);
|
|
8460
|
+
return { usage, load: () => setAgain((n) => n + 1) };
|
|
8461
|
+
}
|
|
8462
|
+
function nameOf(room) {
|
|
8463
|
+
return DirectUtil.is(room) ? directPeer(room, book.get().friends).name : room.title;
|
|
8464
|
+
}
|
|
8465
|
+
function ChatRow({ each, onChanged }) {
|
|
8466
|
+
const [menu, openMenu] = pi.ui.useContextMenu();
|
|
8467
|
+
const [busy, run] = (pi.ui.useBusy ?? (() => [false, async (action) => action()]))();
|
|
8468
|
+
const Chevron = icon("ChevronRight");
|
|
8469
|
+
const name = nameOf(each.room);
|
|
8470
|
+
const clearMedia = () => void run(async () => {
|
|
8471
|
+
try {
|
|
8472
|
+
const freed = await callDoubles({ kind: "clearMedia", room: each.room.id });
|
|
8473
|
+
pi.ui.notify(t("storageFreed", { size: FilesUtil.size(freed) }));
|
|
8474
|
+
} catch (error) {
|
|
8475
|
+
pi.ui.notify(message(error), "error");
|
|
8476
|
+
}
|
|
8477
|
+
onChanged();
|
|
8478
|
+
});
|
|
8479
|
+
const clearChat = () => void run(async () => {
|
|
8480
|
+
const sure = await pi.ui.confirm(t("storageClearTitle", { name }), t("storageClearHint"), { confirmLabel: t("storageClear"), danger: true });
|
|
8481
|
+
if (!sure) {
|
|
8482
|
+
return;
|
|
8483
|
+
}
|
|
8484
|
+
try {
|
|
8485
|
+
await rooms()?.clearChat(each.room.id);
|
|
8486
|
+
book.chat(each.room.id)?.load();
|
|
8487
|
+
} catch (error) {
|
|
8488
|
+
pi.ui.notify(message(error), "error");
|
|
8489
|
+
}
|
|
8490
|
+
onChanged();
|
|
8491
|
+
});
|
|
8492
|
+
const open = (event) => openMenu(event, [
|
|
8493
|
+
[
|
|
8494
|
+
{
|
|
8495
|
+
key: "media",
|
|
8496
|
+
label: t("storageClearMedia", { size: FilesUtil.size(each.media.others) }),
|
|
8497
|
+
icon: icon("Image"),
|
|
8498
|
+
...each.media.others ? {} : { disabled: true },
|
|
8499
|
+
run: clearMedia
|
|
8500
|
+
},
|
|
8501
|
+
{
|
|
8502
|
+
key: "older",
|
|
8503
|
+
label: t("storageOlder"),
|
|
8504
|
+
icon: icon("Calendar"),
|
|
8505
|
+
...each.said ? {} : { disabled: true },
|
|
8506
|
+
run: () => void show(({ close }) => /* @__PURE__ */ React.createElement(ClearOlder, {
|
|
8507
|
+
room: each.room,
|
|
8508
|
+
name,
|
|
8509
|
+
close,
|
|
8510
|
+
onDone: onChanged
|
|
8511
|
+
}))
|
|
8512
|
+
},
|
|
8513
|
+
{ key: "chat", label: t("storageClear"), icon: icon("Trash2"), danger: true, run: clearChat }
|
|
8514
|
+
]
|
|
8515
|
+
]);
|
|
8516
|
+
return /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("button", {
|
|
8517
|
+
type: "button",
|
|
8518
|
+
className: `trm-member${busy ? " ta-pending" : ""}`,
|
|
8519
|
+
onClick: open
|
|
8520
|
+
}, DirectUtil.is(each.room) ? /* @__PURE__ */ React.createElement(DirectFace, {
|
|
8521
|
+
room: each.room,
|
|
8522
|
+
size: 34
|
|
8523
|
+
}) : /* @__PURE__ */ React.createElement(RoomFace, {
|
|
8524
|
+
room: each.room,
|
|
8525
|
+
size: 34
|
|
8526
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
8527
|
+
className: "trm-member-text"
|
|
8528
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
8529
|
+
className: "trm-member-name trm-ellipsis"
|
|
8530
|
+
}, name), /* @__PURE__ */ React.createElement("span", {
|
|
8531
|
+
className: "trm-note trm-ellipsis"
|
|
8532
|
+
}, t("storageParts", { said: FilesUtil.size(each.said), media: FilesUtil.size(each.media.mine + each.media.others) }))), /* @__PURE__ */ React.createElement("span", {
|
|
8533
|
+
className: "trm-storage-size"
|
|
8534
|
+
}, FilesUtil.size(total(each))), /* @__PURE__ */ React.createElement(Chevron, {
|
|
8535
|
+
size: 15
|
|
8536
|
+
})), menu);
|
|
8537
|
+
}
|
|
8538
|
+
function StorageList() {
|
|
8539
|
+
const { usage, load } = useUsage();
|
|
8540
|
+
if (!usage) {
|
|
8541
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Loading, null);
|
|
8542
|
+
}
|
|
8543
|
+
if (!usage.length) {
|
|
8544
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
8545
|
+
compact: true,
|
|
8546
|
+
title: t("storageNone")
|
|
8547
|
+
});
|
|
8548
|
+
}
|
|
8549
|
+
const all = usage.reduce((sum, each) => sum + total(each), 0);
|
|
8550
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
8551
|
+
className: "trm-storage"
|
|
8552
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
8553
|
+
className: "trm-storage-total"
|
|
8554
|
+
}, /* @__PURE__ */ React.createElement("span", null, t("storageTotal")), /* @__PURE__ */ React.createElement("strong", null, FilesUtil.size(all))), /* @__PURE__ */ React.createElement("ul", {
|
|
8555
|
+
className: "trm-panel-members"
|
|
8556
|
+
}, usage.map((each) => /* @__PURE__ */ React.createElement(ChatRow, {
|
|
8557
|
+
key: each.room.id,
|
|
8558
|
+
each,
|
|
8559
|
+
onChanged: load
|
|
8560
|
+
}))));
|
|
8561
|
+
}
|
|
8562
|
+
function storageSettings() {
|
|
8563
|
+
return {
|
|
8564
|
+
title: () => t("storageTitle"),
|
|
8565
|
+
icon: icon("HardDrive"),
|
|
8566
|
+
group: "general",
|
|
8567
|
+
rows: [{ key: "chat-storage", label: () => t("storageLead"), description: () => t("storageHint"), render: StorageList, stacked: true }]
|
|
8568
|
+
};
|
|
8569
|
+
}
|
|
8570
|
+
|
|
7369
8571
|
// web-src/style.ts
|
|
7370
8572
|
var STYLE = `
|
|
7371
8573
|
.trm-ellipsis { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
@@ -7480,6 +8682,8 @@ var STYLE = `
|
|
|
7480
8682
|
.trm-chat-empty strong { margin-top: 6px; color: var(--ta-text); font-size: calc(16px * var(--ta-font-scale)); }
|
|
7481
8683
|
.trm-chat-hint { margin-top: 4px; font-size: calc(12px * var(--ta-font-scale)); line-height: 1.6; }
|
|
7482
8684
|
.trm-mine { margin: 6px 0 2px; }
|
|
8685
|
+
.trm-pending .ta-bubble { opacity: 0.6; transition: opacity 0.2s; }
|
|
8686
|
+
.trm-unsent { align-self: flex-end; margin-top: 2px; color: var(--ta-muted); font-size: calc(11.5px * var(--ta-font-scale)); }
|
|
7483
8687
|
.trm-msg { display: flex; align-items: flex-start; gap: 10px; }
|
|
7484
8688
|
.trm-msg.trm-first { margin-top: 10px; }
|
|
7485
8689
|
.trm-msg-face { display: flex; justify-content: center; width: 28px; flex: none; }
|
|
@@ -7487,6 +8691,26 @@ var STYLE = `
|
|
|
7487
8691
|
.trm-msg-name { margin: 0 2px 4px; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); line-height: calc(16px * var(--ta-font-scale)); }
|
|
7488
8692
|
.trm-msg-bubble { min-width: 0; max-width: 100%; padding: 9px 14px; border: 1px solid var(--ta-border-muted); border-radius: 5px 16px 16px 16px; background: var(--ta-side); color: var(--ta-body); line-height: 1.6; overflow-wrap: anywhere; }
|
|
7489
8693
|
.trm-msg-bubble pre { max-width: 100%; overflow-x: auto; }
|
|
8694
|
+
/* Pictures of a line (ui.ChatImages), no bubble around them, on the side of who sent them. */
|
|
8695
|
+
.trm-pics { margin: 1px 0 3px; }
|
|
8696
|
+
.trm-mine .trm-pics { align-self: flex-end; }
|
|
8697
|
+
.trm-files { display: flex; flex-direction: column; gap: 6px; margin: 1px 0 3px; max-width: min(78%, 280px); }
|
|
8698
|
+
.trm-mine .trm-files { align-self: flex-end; align-items: flex-end; }
|
|
8699
|
+
.trm-file { display: flex; align-items: center; gap: 12px; width: 240px; max-width: 100%; padding: 10px 12px; border: 1px solid var(--ta-border-muted); border-radius: 12px; background: var(--ta-side); color: var(--ta-secondary); text-align: left; cursor: pointer; }
|
|
8700
|
+
.trm-file-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
|
|
8701
|
+
.trm-file-name { color: var(--ta-body); font-size: calc(14px * var(--ta-font-scale)); line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
|
|
8702
|
+
.trm-file-size { font-size: calc(11.5px * var(--ta-font-scale)); font-variant-numeric: tabular-nums; }
|
|
8703
|
+
.trm-voice { display: inline-flex; align-items: center; gap: 8px; min-width: 72px; max-width: 100%; height: 36px; padding: 0 12px; border: 1px solid var(--ta-border-muted); border-radius: 5px 16px 16px 16px; background: var(--ta-side); color: var(--ta-body); font-size: calc(13px * var(--ta-font-scale)); font-variant-numeric: tabular-nums; cursor: pointer; }
|
|
8704
|
+
.trm-mine .trm-voice { flex-direction: row-reverse; border: 0; border-radius: 16px 16px 5px 16px; background: var(--ta-user); color: var(--ta-text); }
|
|
8705
|
+
.trm-video { position: relative; width: 200px; max-height: 300px; border: 0; border-radius: 10px; background: #222 center / cover no-repeat; overflow: hidden; cursor: pointer; }
|
|
8706
|
+
.trm-video-mark { position: absolute; inset: 0; margin: auto; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: rgba(0, 0, 0, 0.45); color: #fff; }
|
|
8707
|
+
.trm-video-time { position: absolute; right: 8px; bottom: 6px; color: #fff; font-size: calc(11.5px * var(--ta-font-scale)); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); font-variant-numeric: tabular-nums; }
|
|
8708
|
+
.trm-video-play { display: block; width: 100%; max-height: 70vh; border-radius: 8px; background: #000; }
|
|
8709
|
+
.trm-uploads { display: flex; flex-direction: column; gap: 4px; padding: 4px 12px; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
|
|
8710
|
+
.trm-upload { display: flex; align-items: center; gap: 8px; min-width: 0; }
|
|
8711
|
+
.trm-recorder { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 8px 0 4px; }
|
|
8712
|
+
.trm-recorder-dot { width: 12px; height: 12px; border-radius: 50%; background: #e5484d; animation: trm-breathe 1.2s ease-in-out infinite; }
|
|
8713
|
+
.trm-recorder-time { font-size: calc(28px * var(--ta-font-scale)); font-variant-numeric: tabular-nums; color: var(--ta-body); }
|
|
7490
8714
|
.trm-chat-bottom { flex: none; width: 100%; max-width: calc(var(--ta-col) + 48px); margin: 0 auto; padding: 8px 24px calc(16px + env(safe-area-inset-bottom)); box-sizing: border-box; }
|
|
7491
8715
|
/* Above the keyboard the home indicator is not there: no room for it, as under the box of a conversation. */
|
|
7492
8716
|
:root[data-keyboard] .trm-chat-bottom { padding-bottom: 8px; }
|
|
@@ -7500,6 +8724,12 @@ var STYLE = `
|
|
|
7500
8724
|
.trm-panel-title span { color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
|
|
7501
8725
|
.trm-panel-label { padding: 10px 10px 6px; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
|
|
7502
8726
|
.trm-panel-members { margin: 0; padding: 0; list-style: none; }
|
|
8727
|
+
.trm-storage { width: 100%; align-self: stretch; }
|
|
8728
|
+
.trm-storage-total { display: flex; align-items: baseline; justify-content: space-between; padding: 4px 10px 10px; color: var(--ta-secondary); font-size: calc(13px * var(--ta-font-scale)); }
|
|
8729
|
+
.trm-storage-total strong { color: var(--ta-text); font-size: calc(20px * var(--ta-font-scale)); font-weight: 600; font-variant-numeric: tabular-nums; }
|
|
8730
|
+
.trm-older { margin-top: 6px; }
|
|
8731
|
+
.trm-older .trm-member:disabled { opacity: 0.45; cursor: default; }
|
|
8732
|
+
.trm-storage-size { flex: none; color: var(--ta-secondary); font-size: calc(13px * var(--ta-font-scale)); font-variant-numeric: tabular-nums; }
|
|
7503
8733
|
.trm-member { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; box-sizing: border-box; border: 0; border-radius: 12px; background: none; color: var(--ta-text); font: inherit; text-align: left; }
|
|
7504
8734
|
button.trm-member { cursor: pointer; }
|
|
7505
8735
|
.trm-member-plus { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--ta-hover); color: var(--ta-secondary); }
|
|
@@ -7716,6 +8946,7 @@ function activate(pi2) {
|
|
|
7716
8946
|
icon: icon("Users"),
|
|
7717
8947
|
render: MembersView,
|
|
7718
8948
|
location: "panel",
|
|
8949
|
+
navigation: false,
|
|
7719
8950
|
order: 90
|
|
7720
8951
|
});
|
|
7721
8952
|
pi2.registerView(DOUBLES_VIEW.slice(DOUBLES_VIEW.lastIndexOf("/") + 1), {
|
|
@@ -7730,6 +8961,7 @@ function activate(pi2) {
|
|
|
7730
8961
|
}
|
|
7731
8962
|
if (pi2.rooms) {
|
|
7732
8963
|
pi2.registerSettings(replySettings());
|
|
8964
|
+
pi2.registerSettings(storageSettings());
|
|
7733
8965
|
}
|
|
7734
8966
|
const stopDirects = pi2.rooms ? directs.start() : () => {
|
|
7735
8967
|
return;
|