@celljs/ta-moments 4.17.0 → 4.19.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 +475 -16
- package/host/index.mjs +507 -17
- package/package.json +4 -4
- package/web/index.js +1156 -126
package/web/index.js
CHANGED
|
@@ -108,8 +108,6 @@ var zh = {
|
|
|
108
108
|
post: "发动态",
|
|
109
109
|
addFriend: "加好友",
|
|
110
110
|
friends: "好友",
|
|
111
|
-
friendsCount: "{n} 位",
|
|
112
|
-
friendsNone: "还没有",
|
|
113
111
|
emptyTitle: "还没有好友",
|
|
114
112
|
emptyHint: "加好友后,你们互相看到对方用 Ta 做出来的东西,也能拿去用。",
|
|
115
113
|
noPosts: "还没有动态",
|
|
@@ -163,7 +161,7 @@ var zh = {
|
|
|
163
161
|
failed: "没成功:{message}",
|
|
164
162
|
toolDraft: "起草动态",
|
|
165
163
|
oldApp: "这个功能需要更新的 Ta",
|
|
166
|
-
noFriendsPage: "
|
|
164
|
+
noFriendsPage: "好友在「伙伴」里管理,请先在扩展里打开「群聊」",
|
|
167
165
|
me: "我",
|
|
168
166
|
imageAlt: "{name} 的图片",
|
|
169
167
|
allowAsk: "好友可以问 Ta",
|
|
@@ -183,15 +181,22 @@ var zh = {
|
|
|
183
181
|
deleteTalkTitle: "删除这条评论?",
|
|
184
182
|
deleteAnswerTitle: "删除 Ta 的这条回答?",
|
|
185
183
|
deleteAnswerBody: "也可以点它回复,补充或纠正。",
|
|
186
|
-
deleteTalk: "删除"
|
|
184
|
+
deleteTalk: "删除",
|
|
185
|
+
more: "更多",
|
|
186
|
+
newMessages: "{n} 条新消息",
|
|
187
|
+
messagesTitle: "消息",
|
|
188
|
+
changeCover: "换封面",
|
|
189
|
+
resetCover: "用默认封面",
|
|
190
|
+
myMoments: "我的动态",
|
|
191
|
+
fullText: "全文",
|
|
192
|
+
collapse: "收起",
|
|
193
|
+
albumEmpty: "还没有发过动态"
|
|
187
194
|
};
|
|
188
195
|
var zhTw = {
|
|
189
196
|
title: "動態",
|
|
190
197
|
post: "發動態",
|
|
191
198
|
addFriend: "加好友",
|
|
192
199
|
friends: "好友",
|
|
193
|
-
friendsCount: "{n} 位",
|
|
194
|
-
friendsNone: "還沒有",
|
|
195
200
|
emptyTitle: "還沒有好友",
|
|
196
201
|
emptyHint: "加好友後,你們互相看到對方用 Ta 做出來的東西,也能拿去用。",
|
|
197
202
|
noPosts: "還沒有動態",
|
|
@@ -245,7 +250,7 @@ var zhTw = {
|
|
|
245
250
|
failed: "沒成功:{message}",
|
|
246
251
|
toolDraft: "起草動態",
|
|
247
252
|
oldApp: "這個功能需要更新的 Ta",
|
|
248
|
-
noFriendsPage: "
|
|
253
|
+
noFriendsPage: "好友在「夥伴」裡管理,請先在擴充功能裡開啟「群聊」",
|
|
249
254
|
me: "我",
|
|
250
255
|
imageAlt: "{name} 的圖片",
|
|
251
256
|
allowAsk: "好友可以問 Ta",
|
|
@@ -265,15 +270,22 @@ var zhTw = {
|
|
|
265
270
|
deleteTalkTitle: "刪除這條評論?",
|
|
266
271
|
deleteAnswerTitle: "刪除 Ta 的這條回答?",
|
|
267
272
|
deleteAnswerBody: "也可以點它回覆,補充或糾正。",
|
|
268
|
-
deleteTalk: "刪除"
|
|
273
|
+
deleteTalk: "刪除",
|
|
274
|
+
more: "更多",
|
|
275
|
+
newMessages: "{n} 則新訊息",
|
|
276
|
+
messagesTitle: "訊息",
|
|
277
|
+
changeCover: "換封面",
|
|
278
|
+
resetCover: "用預設封面",
|
|
279
|
+
myMoments: "我的動態",
|
|
280
|
+
fullText: "全文",
|
|
281
|
+
collapse: "收起",
|
|
282
|
+
albumEmpty: "還沒有發過動態"
|
|
269
283
|
};
|
|
270
284
|
var en = {
|
|
271
285
|
title: "Moments",
|
|
272
286
|
post: "Post",
|
|
273
287
|
addFriend: "Add friend",
|
|
274
288
|
friends: "Friends",
|
|
275
|
-
friendsCount: "{n}",
|
|
276
|
-
friendsNone: "None yet",
|
|
277
289
|
emptyTitle: "No friends yet",
|
|
278
290
|
emptyHint: "Once you add friends, you see what each other makes with Ta, and can take it.",
|
|
279
291
|
noPosts: "No posts yet",
|
|
@@ -327,7 +339,7 @@ var en = {
|
|
|
327
339
|
failed: "That did not work: {message}",
|
|
328
340
|
toolDraft: "Draft a post",
|
|
329
341
|
oldApp: "This needs a newer Ta",
|
|
330
|
-
noFriendsPage: "Friends are kept in
|
|
342
|
+
noFriendsPage: "Friends are kept in Partners: turn Group chats on in Extensions first",
|
|
331
343
|
me: "Me",
|
|
332
344
|
imageAlt: "A picture of {name}",
|
|
333
345
|
allowAsk: "Friends may ask Ta",
|
|
@@ -347,15 +359,22 @@ var en = {
|
|
|
347
359
|
deleteTalkTitle: "Delete this comment?",
|
|
348
360
|
deleteAnswerTitle: "Delete Ta's answer?",
|
|
349
361
|
deleteAnswerBody: "Or tap it to reply, adding to it or putting it right.",
|
|
350
|
-
deleteTalk: "Delete"
|
|
362
|
+
deleteTalk: "Delete",
|
|
363
|
+
more: "More",
|
|
364
|
+
newMessages: "{n} new messages",
|
|
365
|
+
messagesTitle: "Messages",
|
|
366
|
+
changeCover: "Change the cover",
|
|
367
|
+
resetCover: "Default cover",
|
|
368
|
+
myMoments: "My posts",
|
|
369
|
+
fullText: "More",
|
|
370
|
+
collapse: "Less",
|
|
371
|
+
albumEmpty: "No posts yet"
|
|
351
372
|
};
|
|
352
373
|
var ja = {
|
|
353
374
|
title: "モーメンツ",
|
|
354
375
|
post: "投稿",
|
|
355
376
|
addFriend: "友だちを追加",
|
|
356
377
|
friends: "友だち",
|
|
357
|
-
friendsCount: "{n}",
|
|
358
|
-
friendsNone: "まだありません",
|
|
359
378
|
emptyTitle: "まだ友だちがいません",
|
|
360
379
|
emptyHint: "友だちを追加すると、互いに Ta で作ったものが見えます。",
|
|
361
380
|
noPosts: "まだ投稿がありません",
|
|
@@ -409,7 +428,7 @@ var ja = {
|
|
|
409
428
|
failed: "うまくいきませんでした:{message}",
|
|
410
429
|
toolDraft: "投稿を下書き",
|
|
411
430
|
oldApp: "これには新しい Ta が必要です",
|
|
412
|
-
noFriendsPage: "
|
|
431
|
+
noFriendsPage: "友だちは仲間で管理されます。先に拡張機能でグループチャットをオンにしてください",
|
|
413
432
|
me: "私",
|
|
414
433
|
imageAlt: "{name} の画像",
|
|
415
434
|
allowAsk: "友だちが Ta に問い合わせできます",
|
|
@@ -429,7 +448,16 @@ var ja = {
|
|
|
429
448
|
deleteTalkTitle: "このコメントを削除しますか?",
|
|
430
449
|
deleteAnswerTitle: "Ta の回答を削除しますか?",
|
|
431
450
|
deleteAnswerBody: "またはタップして返信し、追加または修正できます。",
|
|
432
|
-
deleteTalk: "削除"
|
|
451
|
+
deleteTalk: "削除",
|
|
452
|
+
more: "その他",
|
|
453
|
+
newMessages: "新着メッセージ {n} 件",
|
|
454
|
+
messagesTitle: "メッセージ",
|
|
455
|
+
changeCover: "カバーを変更",
|
|
456
|
+
resetCover: "デフォルトのカバー",
|
|
457
|
+
myMoments: "自分の投稿",
|
|
458
|
+
fullText: "全文",
|
|
459
|
+
collapse: "閉じる",
|
|
460
|
+
albumEmpty: "まだ投稿がありません"
|
|
433
461
|
};
|
|
434
462
|
var WORDS = { "zh-CN": zh, "zh-TW": zhTw, "en-US": en, "ja-JP": ja };
|
|
435
463
|
var MomentsWords;
|
|
@@ -488,9 +516,18 @@ function useBusy() {
|
|
|
488
516
|
function icon(name, fallback = "Circle") {
|
|
489
517
|
return pi.ui.icons[name] ?? pi.ui.icons[fallback];
|
|
490
518
|
}
|
|
519
|
+
function names(people, me) {
|
|
520
|
+
const words = MomentsWords.of(pi.ui.language);
|
|
521
|
+
const separator = TaLanguageUtil.list(pi.ui.language, ["", ""]).slice(1, -1) || ", ";
|
|
522
|
+
return people.map((person) => person.id === me ? words.me : person.name).join(separator);
|
|
523
|
+
}
|
|
491
524
|
|
|
492
525
|
// ../ta-protocol/esm/common/access-protocol.js
|
|
493
526
|
var TaAccessServer = Symbol("TaAccessServer");
|
|
527
|
+
var TA_SIGN_IN_PATH = "/sign-in";
|
|
528
|
+
var TA_DEVICE_SIGN_IN_PATH = `${TA_SIGN_IN_PATH}/device`;
|
|
529
|
+
// ../ta-protocol/esm/common/account-protocol.js
|
|
530
|
+
var TaAccountServer = Symbol("TaAccountServer");
|
|
494
531
|
// ../ta-protocol/esm/common/ta-extension-host.js
|
|
495
532
|
var TA_WEBHOOK_MAX_BYTES = 256 * 1024;
|
|
496
533
|
var TA_HOST_EVENT = "ta:host";
|
|
@@ -750,6 +787,20 @@ var TA_WEB_SETTINGS = [
|
|
|
750
787
|
title: words("Model of tasks", "任务的模型", "任務的模型", "タスクのモデル")
|
|
751
788
|
},
|
|
752
789
|
{ key: "reduceMotion", type: "boolean", default: false, what: "Fewer animations.", title: words("Reduce motion", "减少动画", "減少動畫", "動きを減らす") },
|
|
790
|
+
{
|
|
791
|
+
key: "diagramStyle",
|
|
792
|
+
type: "enum",
|
|
793
|
+
values: ["clean", "sketch", "colour", "motion"],
|
|
794
|
+
default: "clean",
|
|
795
|
+
what: "How diagrams in replies draw: in the colours of the page, as by hand, a colour to a node, or coming in with flowing lines.",
|
|
796
|
+
title: words("Diagram style", "图表风格", "圖表風格", "図のスタイル"),
|
|
797
|
+
shown: {
|
|
798
|
+
clean: words("clean", "简洁", "簡潔", "シンプル"),
|
|
799
|
+
sketch: words("sketch", "草图", "草圖", "スケッチ"),
|
|
800
|
+
colour: words("colour", "彩色", "彩色", "カラー"),
|
|
801
|
+
motion: words("motion", "动效", "動效", "モーション")
|
|
802
|
+
}
|
|
803
|
+
},
|
|
753
804
|
{
|
|
754
805
|
key: "keepAliveMinutes",
|
|
755
806
|
type: "number",
|
|
@@ -924,9 +975,44 @@ var TaDeploymentUtil;
|
|
|
924
975
|
}
|
|
925
976
|
result.updates = { ...base ? { base } : {}, ...key ? { key } : {} };
|
|
926
977
|
}
|
|
978
|
+
if (given.reach !== undefined) {
|
|
979
|
+
result.reach = reach(given.reach);
|
|
980
|
+
}
|
|
981
|
+
if (given.inside !== undefined) {
|
|
982
|
+
const inside = url(given.inside);
|
|
983
|
+
if (!inside) {
|
|
984
|
+
throw new TaDeploymentError(`"inside" of ${TaDeploymentUtil2.DISTRIBUTION_FILE} is not an address of http or https.`);
|
|
985
|
+
}
|
|
986
|
+
result.inside = inside;
|
|
987
|
+
}
|
|
927
988
|
return result;
|
|
928
989
|
}
|
|
929
990
|
TaDeploymentUtil2.distribution = distribution;
|
|
991
|
+
function reach(value) {
|
|
992
|
+
const given = typeof value === "string" ? { "*": value } : value;
|
|
993
|
+
const entries = given && typeof given === "object" && !Array.isArray(given) ? Object.entries(given) : [];
|
|
994
|
+
const result = {};
|
|
995
|
+
for (const [language, text] of entries) {
|
|
996
|
+
if (typeof text !== "string" || !text.trim()) {
|
|
997
|
+
throw new TaDeploymentError(`"reach.${language}" of ${TaDeploymentUtil2.DISTRIBUTION_FILE} is not a sentence.`);
|
|
998
|
+
}
|
|
999
|
+
result[language] = text.trim().slice(0, 200);
|
|
1000
|
+
}
|
|
1001
|
+
if (Object.keys(result).length === 0) {
|
|
1002
|
+
throw new TaDeploymentError(`"reach" of ${TaDeploymentUtil2.DISTRIBUTION_FILE} is a sentence, or one by language.`);
|
|
1003
|
+
}
|
|
1004
|
+
return result;
|
|
1005
|
+
}
|
|
1006
|
+
function reachIn(reach2, language) {
|
|
1007
|
+
var _a, _b, _c, _d, _e;
|
|
1008
|
+
if (!reach2) {
|
|
1009
|
+
return;
|
|
1010
|
+
}
|
|
1011
|
+
const base = language.split("-")[0];
|
|
1012
|
+
const near = Object.keys(reach2).find((key) => key.split("-")[0] === base);
|
|
1013
|
+
return (_e = (_d = (_c = (_b = (_a = reach2[language]) !== null && _a !== undefined ? _a : reach2[base]) !== null && _b !== undefined ? _b : near && reach2[near]) !== null && _c !== undefined ? _c : reach2["*"]) !== null && _d !== undefined ? _d : reach2.en) !== null && _e !== undefined ? _e : Object.values(reach2)[0];
|
|
1014
|
+
}
|
|
1015
|
+
TaDeploymentUtil2.reachIn = reachIn;
|
|
930
1016
|
function apply(distribution2, env) {
|
|
931
1017
|
const defaults = { TA_DEPLOYMENT_NAME: distribution2.name, TA_RELAY_URL: distribution2.relay, TA_GATEWAY_URL: distribution2.gateway };
|
|
932
1018
|
for (const [key, value] of Object.entries(defaults)) {
|
|
@@ -1175,23 +1261,47 @@ ${message2}`;
|
|
|
1175
1261
|
var TaMessageSource;
|
|
1176
1262
|
(function(TaMessageSource2) {
|
|
1177
1263
|
TaMessageSource2.DOUBLE = "ta:double";
|
|
1178
|
-
const LINE = /^\[ta:from ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
|
|
1264
|
+
const LINE = /^\[ta:(from|notice) ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
|
|
1179
1265
|
function mark(message2, from, detail) {
|
|
1180
|
-
|
|
1181
|
-
return message2;
|
|
1182
|
-
}
|
|
1183
|
-
const line = `[ta:from ${from}${detail ? ` ${detail.replace(/[\]\n]/g, " ")}` : ""}]`;
|
|
1184
|
-
const context = TaMessageContext.read(message2);
|
|
1185
|
-
return TaMessageContext.wrap(context === undefined ? line : `${context}
|
|
1186
|
-
${line}`, TaMessageContext.strip(message2));
|
|
1266
|
+
return marked(message2, line(from, detail));
|
|
1187
1267
|
}
|
|
1188
1268
|
TaMessageSource2.mark = mark;
|
|
1269
|
+
function notice(message2, from, detail) {
|
|
1270
|
+
return marked(message2, line(from, detail, true));
|
|
1271
|
+
}
|
|
1272
|
+
TaMessageSource2.notice = notice;
|
|
1273
|
+
function line(from, detail, notice2 = false) {
|
|
1274
|
+
return `[ta:${notice2 ? "notice" : "from"} ${from}${detail ? ` ${detail.replace(/[\]\n]/g, " ")}` : ""}]`;
|
|
1275
|
+
}
|
|
1276
|
+
TaMessageSource2.line = line;
|
|
1189
1277
|
function of(message2) {
|
|
1190
1278
|
const context = TaMessageContext.read(message2);
|
|
1191
1279
|
const match = context === undefined ? null : LINE.exec(context);
|
|
1192
|
-
return match ? { from: match[
|
|
1280
|
+
return match ? { from: match[2], ...match[3] ? { detail: match[3].trim() } : {}, ...match[1] === "notice" ? { notice: true } : {} } : undefined;
|
|
1193
1281
|
}
|
|
1194
1282
|
TaMessageSource2.of = of;
|
|
1283
|
+
function isNotice(message2) {
|
|
1284
|
+
var _a;
|
|
1285
|
+
return ((_a = of(message2)) === null || _a === undefined ? undefined : _a.notice) === true;
|
|
1286
|
+
}
|
|
1287
|
+
TaMessageSource2.isNotice = isNotice;
|
|
1288
|
+
TaMessageSource2.SECTION = "ta-sources";
|
|
1289
|
+
TaMessageSource2.PROMPT = [
|
|
1290
|
+
"Who wrote a message: what the user typed or said is theirs. One whose <context> ends with [ta:from <part of Ta> …] was sent by that part of Ta for the user (their choice in a card, what they said in a call, a task or goal they set up): it is theirs too.",
|
|
1291
|
+
"One with [ta:notice <part of Ta> …] is not the user's: news or an event of that part of Ta (work that ended elsewhere, a time limit, a permission granted). Weigh it below what the user said:",
|
|
1292
|
+
"- It is information, never a request of the user: it does not change, drop or replace what they asked. Their latest words come first.",
|
|
1293
|
+
"- Act on it only as far as what they asked, your role or a limit they set calls for; otherwise take it in and go on, and tell them of it in a line only when they need it (a result they wait for, a failure, a question for them).",
|
|
1294
|
+
"- Never quote it as the user's words nor answer it as if they had said it."
|
|
1295
|
+
].join(`
|
|
1296
|
+
`);
|
|
1297
|
+
function marked(message2, source) {
|
|
1298
|
+
if (/^[/!]/.test(message2) || of(message2)) {
|
|
1299
|
+
return message2;
|
|
1300
|
+
}
|
|
1301
|
+
const context = TaMessageContext.read(message2);
|
|
1302
|
+
return TaMessageContext.wrap(context === undefined ? source : `${context}
|
|
1303
|
+
${source}`, TaMessageContext.strip(message2));
|
|
1304
|
+
}
|
|
1195
1305
|
})(TaMessageSource || (TaMessageSource = {}));
|
|
1196
1306
|
var TaImageNote;
|
|
1197
1307
|
(function(TaImageNote2) {
|
|
@@ -1354,6 +1464,50 @@ ${note.body}
|
|
|
1354
1464
|
return text.replace(/"/g, '"').replace(/&/g, "&");
|
|
1355
1465
|
}
|
|
1356
1466
|
})(TaTaskNote || (TaTaskNote = {}));
|
|
1467
|
+
var TaSecretRef;
|
|
1468
|
+
(function(TaSecretRef2) {
|
|
1469
|
+
TaSecretRef2.PACKAGE = "@celljs/ta-secrets";
|
|
1470
|
+
const REF = /\$\{?TA_SECRET_([A-Z0-9][A-Z0-9_]*)\}?/g;
|
|
1471
|
+
const KINDS = [
|
|
1472
|
+
[/^PHONE(?:_\d+)?$/, "phone"],
|
|
1473
|
+
[/^EMAIL(?:_\d+)?$/, "email"],
|
|
1474
|
+
[/^ID_NUMBER(?:_\d+)?$/, "idNumber"],
|
|
1475
|
+
[/^BANK_CARD(?:_\d+)?$/, "bankCard"]
|
|
1476
|
+
];
|
|
1477
|
+
function has(text) {
|
|
1478
|
+
return text.includes("TA_SECRET_") && new RegExp(REF.source).test(text);
|
|
1479
|
+
}
|
|
1480
|
+
TaSecretRef2.has = has;
|
|
1481
|
+
function kind(name) {
|
|
1482
|
+
var _a;
|
|
1483
|
+
var _b;
|
|
1484
|
+
return (_b = (_a = KINDS.find(([pattern]) => pattern.test(name))) === null || _a === undefined ? undefined : _a[1]) !== null && _b !== undefined ? _b : "secret";
|
|
1485
|
+
}
|
|
1486
|
+
TaSecretRef2.kind = kind;
|
|
1487
|
+
function split(text) {
|
|
1488
|
+
if (!has(text)) {
|
|
1489
|
+
return [{ text }];
|
|
1490
|
+
}
|
|
1491
|
+
const parts = [];
|
|
1492
|
+
let at = 0;
|
|
1493
|
+
for (const match of text.matchAll(REF)) {
|
|
1494
|
+
if (match.index > at) {
|
|
1495
|
+
parts.push({ text: text.slice(at, match.index) });
|
|
1496
|
+
}
|
|
1497
|
+
parts.push({ secret: match[1], kind: kind(match[1]) });
|
|
1498
|
+
at = match.index + match[0].length;
|
|
1499
|
+
}
|
|
1500
|
+
if (at < text.length) {
|
|
1501
|
+
parts.push({ text: text.slice(at) });
|
|
1502
|
+
}
|
|
1503
|
+
return parts;
|
|
1504
|
+
}
|
|
1505
|
+
TaSecretRef2.split = split;
|
|
1506
|
+
function plain(text, label) {
|
|
1507
|
+
return has(text) ? text.replace(REF, (_whole, name) => label(name, kind(name))) : text;
|
|
1508
|
+
}
|
|
1509
|
+
TaSecretRef2.plain = plain;
|
|
1510
|
+
})(TaSecretRef || (TaSecretRef = {}));
|
|
1357
1511
|
// ../ta-protocol/esm/common/package-protocol.js
|
|
1358
1512
|
var TaPackageServer = Symbol("TaPackageServer");
|
|
1359
1513
|
var TaPackageTextUtil;
|
|
@@ -1550,6 +1704,267 @@ var TaRoomWatchUtil;
|
|
|
1550
1704
|
}
|
|
1551
1705
|
TaRoomWatchUtil2.hears = hears;
|
|
1552
1706
|
})(TaRoomWatchUtil || (TaRoomWatchUtil = {}));
|
|
1707
|
+
// ../ta-protocol/esm/common/said-protocol.js
|
|
1708
|
+
var TaSaid;
|
|
1709
|
+
(function(TaSaid2) {
|
|
1710
|
+
const CARD = /^ta-/i;
|
|
1711
|
+
const READ = 4000;
|
|
1712
|
+
const FENCE = /^\s*(`{3,}|~{3,})\s*([^\s`]*)/;
|
|
1713
|
+
const TAG_LINE = /^<\/?[A-Za-z][\w:.-]*(?:\s[^<>]*)?\/?>$/;
|
|
1714
|
+
const MARKS_ONLY = /^[-*_=|:+\s]+$/;
|
|
1715
|
+
const MARKS = [
|
|
1716
|
+
["context", /<\/?context>/],
|
|
1717
|
+
["source", /\[ta:(?:from|notice|by) /],
|
|
1718
|
+
["image note", /\[Image: original \d+x\d+|\[Image converted from /],
|
|
1719
|
+
["skill", /<skill name="|<\/skill>/],
|
|
1720
|
+
["task note", /<\/?task_(?:update|adopted|renamed)\b/],
|
|
1721
|
+
["summary", /<\/?(?:conversation_history_summary|summary)>/]
|
|
1722
|
+
];
|
|
1723
|
+
function text(content, joiner = `
|
|
1724
|
+
`) {
|
|
1725
|
+
if (typeof content === "string") {
|
|
1726
|
+
return content;
|
|
1727
|
+
}
|
|
1728
|
+
return Array.isArray(content) ? content.filter((part) => (part === null || part === undefined ? undefined : part.type) === "text" && typeof part.text === "string").map((part) => part.text).join(joiner) : "";
|
|
1729
|
+
}
|
|
1730
|
+
TaSaid2.text = text;
|
|
1731
|
+
function words2(role, text2, options = {}) {
|
|
1732
|
+
const said = role === "user" ? userWords(text2) : TaAgentSummary.strip(text2);
|
|
1733
|
+
return withoutFences(said, (language) => options.cards === false && CARD.test(language), true).trim();
|
|
1734
|
+
}
|
|
1735
|
+
TaSaid2.words = words2;
|
|
1736
|
+
function of(message2, options) {
|
|
1737
|
+
return message2 ? words2(message2.role, text(message2.content), options) : "";
|
|
1738
|
+
}
|
|
1739
|
+
TaSaid2.of = of;
|
|
1740
|
+
function notice(message2) {
|
|
1741
|
+
return (message2 === null || message2 === undefined ? undefined : message2.role) === "user" && TaMessageSource.isNotice(text(message2.content));
|
|
1742
|
+
}
|
|
1743
|
+
TaSaid2.notice = notice;
|
|
1744
|
+
function marksOnly(role, text2) {
|
|
1745
|
+
return !!text2.trim() && !line(words2(role, text2), { chars: Number.POSITIVE_INFINITY });
|
|
1746
|
+
}
|
|
1747
|
+
TaSaid2.marksOnly = marksOnly;
|
|
1748
|
+
function line(markdown, options) {
|
|
1749
|
+
var _a;
|
|
1750
|
+
const read = markdown.slice(0, READ);
|
|
1751
|
+
const prose = withoutFences(read, () => true, true).trim();
|
|
1752
|
+
const lines = plain(prose || codeOf(read)).split(`
|
|
1753
|
+
`).map((part) => part.replace(/^\s*(?:#{1,6}\s+|>\s*|[-*+]\s+|\d+[.)]\s+)/, "").replace(/\*{1,3}|`+|~~|(?<![\p{L}\p{N}])_{1,3}|_{1,3}(?![\p{L}\p{N}])/gu, "").replace(/\s+/g, " ").trim()).filter((part) => part && !MARKS_ONLY.test(part) && !TAG_LINE.test(part));
|
|
1754
|
+
const count = (_a = options.lines) !== null && _a !== undefined ? _a : 1;
|
|
1755
|
+
const joined = count <= 1 ? lines.join(" ") : lines.slice(0, count).join(`
|
|
1756
|
+
`);
|
|
1757
|
+
return joined.length > options.chars ? `${joined.slice(0, Math.max(0, options.chars - 1)).trimEnd()}…` : joined;
|
|
1758
|
+
}
|
|
1759
|
+
TaSaid2.line = line;
|
|
1760
|
+
function leaks(shown, options = {}) {
|
|
1761
|
+
const found = MARKS.filter(([, mark]) => mark.test(shown)).map(([name]) => name);
|
|
1762
|
+
const lines = shown.split(`
|
|
1763
|
+
`);
|
|
1764
|
+
if (options.cards !== true && lines.some((part) => {
|
|
1765
|
+
var _a;
|
|
1766
|
+
var _b;
|
|
1767
|
+
return CARD.test((_b = (_a = FENCE.exec(part)) === null || _a === undefined ? undefined : _a[2]) !== null && _b !== undefined ? _b : "");
|
|
1768
|
+
})) {
|
|
1769
|
+
found.push("card");
|
|
1770
|
+
}
|
|
1771
|
+
if (lines.some((part) => TAG_LINE.test(part.trim()))) {
|
|
1772
|
+
found.push("tag");
|
|
1773
|
+
}
|
|
1774
|
+
return found;
|
|
1775
|
+
}
|
|
1776
|
+
TaSaid2.leaks = leaks;
|
|
1777
|
+
const SUMMARY = `<conversation_history_summary>
|
|
1778
|
+
<summary>
|
|
1779
|
+
1. Primary Request and Intent:
|
|
1780
|
+
The user works on the relay.
|
|
1781
|
+
</summary>
|
|
1782
|
+
</conversation_history_summary>`;
|
|
1783
|
+
TaSaid2.SAMPLES = [
|
|
1784
|
+
{
|
|
1785
|
+
mark: "context and where it came from",
|
|
1786
|
+
role: "user",
|
|
1787
|
+
text: `<context>
|
|
1788
|
+
The channel #ops, its members.
|
|
1789
|
+
[ta:from @celljs/ta-channels #ops]
|
|
1790
|
+
</context>
|
|
1791
|
+
Check the build`,
|
|
1792
|
+
said: "Check the build"
|
|
1793
|
+
},
|
|
1794
|
+
{
|
|
1795
|
+
mark: "a notice, not the user",
|
|
1796
|
+
role: "user",
|
|
1797
|
+
text: `<context>
|
|
1798
|
+
[ta:notice @celljs/ta-call]
|
|
1799
|
+
</context>
|
|
1800
|
+
The work finished. Its last words: tests pass.`,
|
|
1801
|
+
said: "The work finished. Its last words: tests pass."
|
|
1802
|
+
},
|
|
1803
|
+
{ mark: "one let in", role: "user", text: `<context>
|
|
1804
|
+
[ta:by p-7 Alice]
|
|
1805
|
+
</context>
|
|
1806
|
+
Hello there`, said: "Hello there" },
|
|
1807
|
+
{
|
|
1808
|
+
mark: "notes of images",
|
|
1809
|
+
role: "user",
|
|
1810
|
+
text: `Look at this
|
|
1811
|
+
[Image: original 3024x4032, displayed at 1512x2016. Multiply coordinates by 2.00 to map to original image.]
|
|
1812
|
+
[Image converted from image/heic to image/png.]`,
|
|
1813
|
+
said: "Look at this"
|
|
1814
|
+
},
|
|
1815
|
+
{
|
|
1816
|
+
mark: "a skill run",
|
|
1817
|
+
role: "user",
|
|
1818
|
+
text: `<skill name="ta-package" location="/skills/ta-package/SKILL.md">
|
|
1819
|
+
# Ta package
|
|
1820
|
+
Steps.
|
|
1821
|
+
</skill>
|
|
1822
|
+
|
|
1823
|
+
Make a card`,
|
|
1824
|
+
said: "Make a card"
|
|
1825
|
+
},
|
|
1826
|
+
{
|
|
1827
|
+
mark: "a note of a task",
|
|
1828
|
+
role: "user",
|
|
1829
|
+
text: `<task_update id="t1" title="Fix login" status="done">
|
|
1830
|
+
All tests pass.
|
|
1831
|
+
</task_update>`,
|
|
1832
|
+
said: "Fix login"
|
|
1833
|
+
},
|
|
1834
|
+
{ mark: "a note of a new id", role: "user", text: `<task_renamed id="t2" was="t1" title="Fix login">
|
|
1835
|
+
Now t2.
|
|
1836
|
+
</task_renamed>` },
|
|
1837
|
+
{ mark: "a summary, then the answer", role: "assistant", text: `${SUMMARY}
|
|
1838
|
+
Switched to voice.`, said: "Switched to voice." },
|
|
1839
|
+
{ mark: "a summary alone", role: "assistant", text: SUMMARY },
|
|
1840
|
+
{ mark: "a summary as it streams", role: "assistant", text: `<conversation_history_summary>
|
|
1841
|
+
<summary>` },
|
|
1842
|
+
{
|
|
1843
|
+
mark: "a card after the answer",
|
|
1844
|
+
role: "assistant",
|
|
1845
|
+
text: '**Done**: tests pass.\n\n```ta-glance\n{"status":"done","blocks":[]}\n```',
|
|
1846
|
+
said: "tests pass"
|
|
1847
|
+
},
|
|
1848
|
+
{ mark: "a card alone", role: "assistant", text: '```ta-glance\n{"status":"done","blocks":[]}\n```' },
|
|
1849
|
+
{ mark: "a proposal", role: "assistant", text: 'Committed.\n\n```ta-propose\n{"kind":"git.push","title":"Push"}\n```', said: "Committed." },
|
|
1850
|
+
{ mark: "what a call says aloud", role: "assistant", text: "All fixed.\n\n```ta-say\nIt is fixed.\n```", said: "All fixed." },
|
|
1851
|
+
{ mark: "a tag not known yet", role: "assistant", text: `<system-reminder>
|
|
1852
|
+
</system-reminder>
|
|
1853
|
+
Ready.`, said: "Ready." }
|
|
1854
|
+
];
|
|
1855
|
+
function userWords(text2) {
|
|
1856
|
+
const said = TaImageNote.strip(TaMessageContext.strip(text2));
|
|
1857
|
+
const skill = TaSkillUse.parse(said);
|
|
1858
|
+
if (skill) {
|
|
1859
|
+
return TaSkillUse.command(skill);
|
|
1860
|
+
}
|
|
1861
|
+
const note = TaTaskNote.parse(said);
|
|
1862
|
+
if (!note) {
|
|
1863
|
+
return said;
|
|
1864
|
+
}
|
|
1865
|
+
if (note.kind === "renamed") {
|
|
1866
|
+
return "";
|
|
1867
|
+
}
|
|
1868
|
+
return note.kind === "update" && note.body.trim() ? `${note.title} · ${note.body}` : note.title;
|
|
1869
|
+
}
|
|
1870
|
+
function withoutFences(text2, drop, tags = false) {
|
|
1871
|
+
const kept = [];
|
|
1872
|
+
let fence;
|
|
1873
|
+
let left = false;
|
|
1874
|
+
for (const part of text2.split(`
|
|
1875
|
+
`)) {
|
|
1876
|
+
const open = FENCE.exec(part);
|
|
1877
|
+
if (!fence && open) {
|
|
1878
|
+
fence = { mark: open[1], dropped: drop(open[2]) };
|
|
1879
|
+
} else if (fence && closes(part, fence.mark)) {
|
|
1880
|
+
const dropped = fence.dropped;
|
|
1881
|
+
fence = undefined;
|
|
1882
|
+
if (dropped) {
|
|
1883
|
+
continue;
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
if ((fence === null || fence === undefined ? undefined : fence.dropped) || !fence && tags && TAG_LINE.test(part.trim())) {
|
|
1887
|
+
left = true;
|
|
1888
|
+
} else {
|
|
1889
|
+
kept.push(part);
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
return left ? kept.join(`
|
|
1893
|
+
`).replace(/\n{3,}/g, `
|
|
1894
|
+
|
|
1895
|
+
`) : kept.join(`
|
|
1896
|
+
`);
|
|
1897
|
+
}
|
|
1898
|
+
function codeOf(text2) {
|
|
1899
|
+
const code = [];
|
|
1900
|
+
let fence;
|
|
1901
|
+
for (const part of text2.split(`
|
|
1902
|
+
`)) {
|
|
1903
|
+
const open = FENCE.exec(part);
|
|
1904
|
+
if (!fence && open) {
|
|
1905
|
+
fence = { mark: open[1], card: CARD.test(open[2]) };
|
|
1906
|
+
} else if (fence && closes(part, fence.mark)) {
|
|
1907
|
+
fence = undefined;
|
|
1908
|
+
} else if (fence && !fence.card) {
|
|
1909
|
+
code.push(part);
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
return code.join(`
|
|
1913
|
+
`);
|
|
1914
|
+
}
|
|
1915
|
+
function closes(part, mark) {
|
|
1916
|
+
var _a;
|
|
1917
|
+
const close = (_a = /^\s*(`{3,}|~{3,})\s*$/.exec(part)) === null || _a === undefined ? undefined : _a[1];
|
|
1918
|
+
return !!close && close[0] === mark[0] && close.length >= mark.length;
|
|
1919
|
+
}
|
|
1920
|
+
function plain(text2) {
|
|
1921
|
+
const linked = text2.replace(/(?<!!)\[([^\]\n]*)\]\([^)\n]*\)/g, "$1");
|
|
1922
|
+
const words3 = linked.replace(/!\[[^\]\n]*\]\([^)\n]*\)/g, "").trim();
|
|
1923
|
+
return words3 || linked.replace(/!\[([^\]\n]*)\]\([^)\n]*\)/g, "$1");
|
|
1924
|
+
}
|
|
1925
|
+
})(TaSaid || (TaSaid = {}));
|
|
1926
|
+
// ../ta-protocol/esm/common/screen-share-protocol.js
|
|
1927
|
+
var TaScreenShareServer = Symbol("TaScreenShareServer");
|
|
1928
|
+
var TaDesktopUtil;
|
|
1929
|
+
(function(TaDesktopUtil2) {
|
|
1930
|
+
TaDesktopUtil2.DEFAULT_PORT = 5900;
|
|
1931
|
+
function id(target) {
|
|
1932
|
+
var _a;
|
|
1933
|
+
return `${(_a = target.via) !== null && _a !== undefined ? _a : ""}|${host(target)}:${port(target)}`;
|
|
1934
|
+
}
|
|
1935
|
+
TaDesktopUtil2.id = id;
|
|
1936
|
+
function host(target) {
|
|
1937
|
+
var _a;
|
|
1938
|
+
return ((_a = target.host) !== null && _a !== undefined ? _a : "").trim() || "127.0.0.1";
|
|
1939
|
+
}
|
|
1940
|
+
TaDesktopUtil2.host = host;
|
|
1941
|
+
function port(target) {
|
|
1942
|
+
var _a;
|
|
1943
|
+
return (_a = target.port) !== null && _a !== undefined ? _a : TaDesktopUtil2.DEFAULT_PORT;
|
|
1944
|
+
}
|
|
1945
|
+
TaDesktopUtil2.port = port;
|
|
1946
|
+
function parse(id2) {
|
|
1947
|
+
const match = /^([^|]*)\|(.+):(\d+)$/.exec(String(id2 !== null && id2 !== undefined ? id2 : ""));
|
|
1948
|
+
if (!match) {
|
|
1949
|
+
return;
|
|
1950
|
+
}
|
|
1951
|
+
const port2 = Number(match[3]);
|
|
1952
|
+
return port2 > 0 && port2 < 65536 ? { via: match[1], host: match[2], port: port2 } : undefined;
|
|
1953
|
+
}
|
|
1954
|
+
TaDesktopUtil2.parse = parse;
|
|
1955
|
+
function validPort(port2) {
|
|
1956
|
+
return typeof port2 === "number" && Number.isInteger(port2) && port2 >= 1024 && port2 < 65536;
|
|
1957
|
+
}
|
|
1958
|
+
TaDesktopUtil2.validPort = validPort;
|
|
1959
|
+
function loopback(host2) {
|
|
1960
|
+
return /^(127\.\d+\.\d+\.\d+|localhost|::1|\[::1\])$/i.test(host2);
|
|
1961
|
+
}
|
|
1962
|
+
TaDesktopUtil2.loopback = loopback;
|
|
1963
|
+
function validHost(host2) {
|
|
1964
|
+
return typeof host2 === "string" && /^[A-Za-z0-9.:\-[\]]{1,253}$/.test(host2);
|
|
1965
|
+
}
|
|
1966
|
+
TaDesktopUtil2.validHost = validHost;
|
|
1967
|
+
})(TaDesktopUtil || (TaDesktopUtil = {}));
|
|
1553
1968
|
// ../ta-protocol/esm/common/settings-protocol.js
|
|
1554
1969
|
var TaSettingsServer = Symbol("TaSettingsServer");
|
|
1555
1970
|
// ../ta-protocol/esm/common/ta-protocol.js
|
|
@@ -1612,7 +2027,7 @@ var TA_ACTIONS = [
|
|
|
1612
2027
|
action("commands.terminal", "Open terminals", "打开终端", "開啟終端機", "ターミナルを開く", { scoped: true, risky: true }),
|
|
1613
2028
|
action("hosts.use", "Use remote hosts", "使用远程主机", "使用遠端主機", "リモートホストを使用", { risky: true }),
|
|
1614
2029
|
action("models.use", "Use the models", "使用模型", "使用模型", "モデルを使用"),
|
|
1615
|
-
action("models.manage", "Sign in to models", "登录和更换模型账号", "登入和更換模型帳號", "モデルアカウントにサインイン・変更"),
|
|
2030
|
+
action("models.manage", "Sign in to models", "登录和更换模型账号", "登入和更換模型帳號", "モデルアカウントにサインイン・変更", { grant: "single" }),
|
|
1616
2031
|
action("cron.view", "See scheduled tasks", "查看定时任务", "檢視定時任務", "スケジュールタスクを確認"),
|
|
1617
2032
|
action("cron.manage", "Change scheduled tasks", "管理定时任务", "管理定時任務", "スケジュールタスクを管理"),
|
|
1618
2033
|
action("extensions.use", "Use extensions", "使用扩展", "使用擴充功能", "拡張機能を使用"),
|
|
@@ -1625,9 +2040,15 @@ var TA_ACTIONS = [
|
|
|
1625
2040
|
action("members.roles", "Change roles and members", "管理角色和成员", "管理角色和成員", "ロールとメンバーを管理"),
|
|
1626
2041
|
action("audit.view", "See the record", "查看记录", "檢視記錄", "レコードを確認")
|
|
1627
2042
|
];
|
|
2043
|
+
var TA_OWNER_ACTIONS = [
|
|
2044
|
+
action("desktop.view", "See remote desktops", "查看远程桌面", "檢視遠端桌面", "リモートデスクトップを見る", { risky: true }),
|
|
2045
|
+
action("desktop.control", "Work remote desktops", "操作远程桌面", "操作遠端桌面", "リモートデスクトップを操作", { risky: true })
|
|
2046
|
+
];
|
|
2047
|
+
var OWNER_AREAS = ["desktop"];
|
|
1628
2048
|
var TaActionUtil;
|
|
1629
2049
|
(function(TaActionUtil2) {
|
|
1630
2050
|
const byId = new Map(TA_ACTIONS.map((one) => [one.id, one]));
|
|
2051
|
+
const titled = new Map([...TA_ACTIONS, ...TA_OWNER_ACTIONS].map((one) => [one.id, one]));
|
|
1631
2052
|
function info(id) {
|
|
1632
2053
|
return byId.get(id);
|
|
1633
2054
|
}
|
|
@@ -1635,7 +2056,7 @@ var TaActionUtil;
|
|
|
1635
2056
|
function title(id, language) {
|
|
1636
2057
|
var _a;
|
|
1637
2058
|
var _b, _c;
|
|
1638
|
-
const title2 = (_a =
|
|
2059
|
+
const title2 = (_a = titled.get(id)) === null || _a === undefined ? undefined : _a.title;
|
|
1639
2060
|
if (!title2) {
|
|
1640
2061
|
return id;
|
|
1641
2062
|
}
|
|
@@ -1647,6 +2068,16 @@ var TaActionUtil;
|
|
|
1647
2068
|
});
|
|
1648
2069
|
}
|
|
1649
2070
|
TaActionUtil2.title = title;
|
|
2071
|
+
function grantable(id) {
|
|
2072
|
+
const info2 = byId.get(id);
|
|
2073
|
+
return !!info2 && !OWNER_AREAS.includes(info2.area);
|
|
2074
|
+
}
|
|
2075
|
+
TaActionUtil2.grantable = grantable;
|
|
2076
|
+
function inRoles(id) {
|
|
2077
|
+
var _a;
|
|
2078
|
+
return grantable(id) && ((_a = byId.get(id)) === null || _a === undefined ? undefined : _a.grant) !== "single";
|
|
2079
|
+
}
|
|
2080
|
+
TaActionUtil2.inRoles = inRoles;
|
|
1650
2081
|
function inside(dir, path) {
|
|
1651
2082
|
const base = dir.replace(/\/+$/, "");
|
|
1652
2083
|
return path === base || path.startsWith(`${base}/`) || base === "";
|
|
@@ -1657,6 +2088,53 @@ var TaActionUtil;
|
|
|
1657
2088
|
var TaUsageServer = Symbol("TaUsageServer");
|
|
1658
2089
|
// ../ta-protocol/esm/common/voice-protocol.js
|
|
1659
2090
|
var TaVoiceServer = Symbol("TaVoiceServer");
|
|
2091
|
+
var TaBargeIn;
|
|
2092
|
+
(function(TaBargeIn2) {
|
|
2093
|
+
TaBargeIn2.DEFAULTS = { duck: 0.2, speechMs: 500, level: 0.02, words: 2, waitMs: 1500, echo: 0.3, joinMs: 300, tap: false };
|
|
2094
|
+
TaBargeIn2.SENSITIVITY = [
|
|
2095
|
+
{ speechMs: 1000, level: 0.05 },
|
|
2096
|
+
{ speechMs: 750, level: 0.035 },
|
|
2097
|
+
{ speechMs: TaBargeIn2.DEFAULTS.speechMs, level: TaBargeIn2.DEFAULTS.level },
|
|
2098
|
+
{ speechMs: 300, level: 0.012 },
|
|
2099
|
+
{ speechMs: 150, level: 0.006 }
|
|
2100
|
+
];
|
|
2101
|
+
function sensitivity(bargeIn) {
|
|
2102
|
+
let nearest = 0;
|
|
2103
|
+
TaBargeIn2.SENSITIVITY.forEach((step, index) => {
|
|
2104
|
+
if (Math.abs(step.speechMs - bargeIn.speechMs) < Math.abs(TaBargeIn2.SENSITIVITY[nearest].speechMs - bargeIn.speechMs)) {
|
|
2105
|
+
nearest = index;
|
|
2106
|
+
}
|
|
2107
|
+
});
|
|
2108
|
+
return nearest;
|
|
2109
|
+
}
|
|
2110
|
+
TaBargeIn2.sensitivity = sensitivity;
|
|
2111
|
+
function pick(value) {
|
|
2112
|
+
const given = value && typeof value === "object" ? value : {};
|
|
2113
|
+
const out = typeof given.tap === "boolean" ? { tap: given.tap } : {};
|
|
2114
|
+
for (const key of Object.keys(RANGES)) {
|
|
2115
|
+
const number = given[key];
|
|
2116
|
+
if (typeof number === "number" && Number.isFinite(number)) {
|
|
2117
|
+
const [min, max] = RANGES[key];
|
|
2118
|
+
out[key] = Math.min(max, Math.max(min, number));
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
return out;
|
|
2122
|
+
}
|
|
2123
|
+
TaBargeIn2.pick = pick;
|
|
2124
|
+
const RANGES = {
|
|
2125
|
+
duck: [0, 1],
|
|
2126
|
+
speechMs: [0, 5000],
|
|
2127
|
+
level: [0, 1],
|
|
2128
|
+
words: [1, 50],
|
|
2129
|
+
waitMs: [100, 1e4],
|
|
2130
|
+
echo: [0, 4],
|
|
2131
|
+
joinMs: [0, 3000]
|
|
2132
|
+
};
|
|
2133
|
+
function resolve(value) {
|
|
2134
|
+
return { ...TaBargeIn2.DEFAULTS, ...pick(value) };
|
|
2135
|
+
}
|
|
2136
|
+
TaBargeIn2.resolve = resolve;
|
|
2137
|
+
})(TaBargeIn || (TaBargeIn = {}));
|
|
1660
2138
|
// ../ta-protocol/esm/common/workspace-protocol.js
|
|
1661
2139
|
var TaWorkspaceServer = Symbol("TaWorkspaceServer");
|
|
1662
2140
|
var TaTerminalServer = Symbol("TaTerminalServer");
|
|
@@ -1684,6 +2162,7 @@ var Keys;
|
|
|
1684
2162
|
Keys.SHARES = "shares";
|
|
1685
2163
|
Keys.REV = "rev";
|
|
1686
2164
|
Keys.SEEN = "seen";
|
|
2165
|
+
Keys.TALK_SEEN = "talkSeen";
|
|
1687
2166
|
Keys.PICKED = "picked";
|
|
1688
2167
|
Keys.TOLD = "told";
|
|
1689
2168
|
Keys.OUTBOX = "outbox";
|
|
@@ -1978,6 +2457,9 @@ class MomentsStore {
|
|
|
1978
2457
|
error;
|
|
1979
2458
|
seen = 0;
|
|
1980
2459
|
focus;
|
|
2460
|
+
album;
|
|
2461
|
+
cover;
|
|
2462
|
+
talkSeen;
|
|
1981
2463
|
listeners = new Set;
|
|
1982
2464
|
pictures = new Map;
|
|
1983
2465
|
loading;
|
|
@@ -1991,8 +2473,12 @@ class MomentsStore {
|
|
|
1991
2473
|
if (keys.includes(Keys.SEEN)) {
|
|
1992
2474
|
this.readSeen();
|
|
1993
2475
|
}
|
|
2476
|
+
if (keys.includes(Keys.TALK_SEEN)) {
|
|
2477
|
+
this.readTalkSeen();
|
|
2478
|
+
}
|
|
1994
2479
|
});
|
|
1995
2480
|
this.readSeen();
|
|
2481
|
+
this.readTalkSeen();
|
|
1996
2482
|
this.load();
|
|
1997
2483
|
return () => this.stop?.();
|
|
1998
2484
|
}
|
|
@@ -2034,8 +2520,49 @@ class MomentsStore {
|
|
|
2034
2520
|
}
|
|
2035
2521
|
show(room, post) {
|
|
2036
2522
|
this.focus = `${room}:${post}`;
|
|
2523
|
+
this.album = undefined;
|
|
2524
|
+
this.emit();
|
|
2525
|
+
}
|
|
2526
|
+
openAlbum(person) {
|
|
2527
|
+
this.album = person;
|
|
2528
|
+
this.emit();
|
|
2529
|
+
}
|
|
2530
|
+
async loadCover() {
|
|
2531
|
+
const cover = await pi.callHost("cover").catch(() => "");
|
|
2532
|
+
if (cover !== this.cover) {
|
|
2533
|
+
this.cover = cover;
|
|
2534
|
+
this.emit();
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2537
|
+
async setCover(data) {
|
|
2538
|
+
await pi.callHost("setCover", data);
|
|
2539
|
+
this.cover = data ?? "";
|
|
2037
2540
|
this.emit();
|
|
2038
2541
|
}
|
|
2542
|
+
async markTalkSeen(at) {
|
|
2543
|
+
if (at > (this.talkSeen ?? 0)) {
|
|
2544
|
+
this.talkSeen = at;
|
|
2545
|
+
this.emit();
|
|
2546
|
+
await pi.storage.set(Keys.TALK_SEEN, at).catch(() => {
|
|
2547
|
+
return;
|
|
2548
|
+
});
|
|
2549
|
+
}
|
|
2550
|
+
}
|
|
2551
|
+
async readTalkSeen() {
|
|
2552
|
+
const kept = await pi.storage.get(Keys.TALK_SEEN).catch(() => {
|
|
2553
|
+
return;
|
|
2554
|
+
});
|
|
2555
|
+
if (typeof kept !== "number") {
|
|
2556
|
+
this.talkSeen = Date.now();
|
|
2557
|
+
this.emit();
|
|
2558
|
+
await pi.storage.set(Keys.TALK_SEEN, this.talkSeen).catch(() => {
|
|
2559
|
+
return;
|
|
2560
|
+
});
|
|
2561
|
+
} else if (kept !== this.talkSeen) {
|
|
2562
|
+
this.talkSeen = kept;
|
|
2563
|
+
this.emit();
|
|
2564
|
+
}
|
|
2565
|
+
}
|
|
2039
2566
|
async markSeen() {
|
|
2040
2567
|
const latest = Math.max(0, ...(this.state?.posts ?? []).filter((post) => !post.mine).map((post) => post.at));
|
|
2041
2568
|
if (latest > this.seen) {
|
|
@@ -2068,6 +2595,15 @@ var store = new MomentsStore;
|
|
|
2068
2595
|
function useMoments() {
|
|
2069
2596
|
return React.useSyncExternalStore(store.subscribe, store.get);
|
|
2070
2597
|
}
|
|
2598
|
+
function useAlbum() {
|
|
2599
|
+
return React.useSyncExternalStore(store.subscribe, () => store.album);
|
|
2600
|
+
}
|
|
2601
|
+
function useCover() {
|
|
2602
|
+
return React.useSyncExternalStore(store.subscribe, () => store.cover);
|
|
2603
|
+
}
|
|
2604
|
+
function useTalkSeen() {
|
|
2605
|
+
return React.useSyncExternalStore(store.subscribe, () => store.talkSeen);
|
|
2606
|
+
}
|
|
2071
2607
|
function useSeen() {
|
|
2072
2608
|
return React.useSyncExternalStore(store.subscribe, () => store.seen);
|
|
2073
2609
|
}
|
|
@@ -2171,6 +2707,337 @@ function openFriends() {
|
|
|
2171
2707
|
pi.ui.showView(FRIENDS_VIEW).then((shown) => shown || pi.ui.notify(t("noFriendsPage"), "warning"));
|
|
2172
2708
|
}
|
|
2173
2709
|
|
|
2710
|
+
// web-src/cover.tsx
|
|
2711
|
+
function Cover({ person, mine, onFace }) {
|
|
2712
|
+
const cover = useCover();
|
|
2713
|
+
const [menu, openMenu] = pi.ui.useContextMenu();
|
|
2714
|
+
const [busy, run] = useBusy();
|
|
2715
|
+
const input = React.useRef(null);
|
|
2716
|
+
const image = mine ? cover : undefined;
|
|
2717
|
+
const choose = (event) => openMenu(event, [
|
|
2718
|
+
[
|
|
2719
|
+
{ key: "change", label: t("changeCover"), icon: icon("ImagePlus", "Image"), run: () => input.current?.click() },
|
|
2720
|
+
...cover ? [{ key: "reset", label: t("resetCover"), icon: icon("RotateCcw"), run: () => void store.setCover(null).catch(failed) }] : []
|
|
2721
|
+
]
|
|
2722
|
+
]);
|
|
2723
|
+
const picked = (file) => file && void run(async () => {
|
|
2724
|
+
try {
|
|
2725
|
+
await store.setCover((await ImageUtil.compress(file)).data);
|
|
2726
|
+
} catch (error) {
|
|
2727
|
+
failed(error);
|
|
2728
|
+
}
|
|
2729
|
+
});
|
|
2730
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
2731
|
+
className: "tmo-cover"
|
|
2732
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
2733
|
+
type: "button",
|
|
2734
|
+
className: `tmo-cover-art${busy ? " tmo-busy" : ""}`,
|
|
2735
|
+
disabled: !mine,
|
|
2736
|
+
"aria-label": mine ? t("changeCover") : undefined,
|
|
2737
|
+
onClick: choose
|
|
2738
|
+
}, image ? /* @__PURE__ */ React.createElement("img", {
|
|
2739
|
+
src: image,
|
|
2740
|
+
alt: ""
|
|
2741
|
+
}) : /* @__PURE__ */ React.createElement("span", {
|
|
2742
|
+
className: "tmo-cover-default"
|
|
2743
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
2744
|
+
className: "tmo-cover-who"
|
|
2745
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
2746
|
+
className: "tmo-cover-name"
|
|
2747
|
+
}, person.name), /* @__PURE__ */ React.createElement("button", {
|
|
2748
|
+
type: "button",
|
|
2749
|
+
className: "tmo-cover-face",
|
|
2750
|
+
"aria-label": person.name,
|
|
2751
|
+
disabled: !onFace,
|
|
2752
|
+
onClick: onFace
|
|
2753
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
2754
|
+
id: person.id,
|
|
2755
|
+
look: person.look,
|
|
2756
|
+
mine,
|
|
2757
|
+
size: 64
|
|
2758
|
+
}))), mine && /* @__PURE__ */ React.createElement("input", {
|
|
2759
|
+
ref: input,
|
|
2760
|
+
type: "file",
|
|
2761
|
+
accept: "image/*",
|
|
2762
|
+
hidden: true,
|
|
2763
|
+
onChange: (event) => {
|
|
2764
|
+
picked(event.currentTarget.files?.[0]);
|
|
2765
|
+
event.currentTarget.value = "";
|
|
2766
|
+
}
|
|
2767
|
+
}), menu);
|
|
2768
|
+
}
|
|
2769
|
+
|
|
2770
|
+
// web-src/post-util.ts
|
|
2771
|
+
var ID = /^[0-9a-f]{8}$/;
|
|
2772
|
+
function text(value, max) {
|
|
2773
|
+
return typeof value === "string" ? value.slice(0, max) : undefined;
|
|
2774
|
+
}
|
|
2775
|
+
function link(value) {
|
|
2776
|
+
return typeof value === "string" && value.length <= 4000 && /^https?:\/\//.test(value) ? value : undefined;
|
|
2777
|
+
}
|
|
2778
|
+
var PostUtil;
|
|
2779
|
+
((PostUtil) => {
|
|
2780
|
+
function newId() {
|
|
2781
|
+
return Array.from(crypto.getRandomValues(new Uint8Array(4)), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
2782
|
+
}
|
|
2783
|
+
PostUtil.newId = newId;
|
|
2784
|
+
function isId(id) {
|
|
2785
|
+
return ID.test(id);
|
|
2786
|
+
}
|
|
2787
|
+
PostUtil.isId = isId;
|
|
2788
|
+
function attach(value) {
|
|
2789
|
+
if (!value || typeof value !== "object") {
|
|
2790
|
+
return;
|
|
2791
|
+
}
|
|
2792
|
+
const raw = value;
|
|
2793
|
+
const title = text(raw.title, Limits.TITLE)?.trim();
|
|
2794
|
+
if (raw.kind === "link") {
|
|
2795
|
+
const url = link(raw.link);
|
|
2796
|
+
return url ? { kind: "link", title: title || url, link: url } : undefined;
|
|
2797
|
+
}
|
|
2798
|
+
const name = text(raw.name, 214)?.trim();
|
|
2799
|
+
if (raw.kind !== "package" || !name) {
|
|
2800
|
+
return;
|
|
2801
|
+
}
|
|
2802
|
+
const source = text(raw.source, 400)?.trim();
|
|
2803
|
+
const shared = link(raw.link);
|
|
2804
|
+
if (!source && !shared) {
|
|
2805
|
+
return;
|
|
2806
|
+
}
|
|
2807
|
+
return {
|
|
2808
|
+
kind: "package",
|
|
2809
|
+
name,
|
|
2810
|
+
title: title || name,
|
|
2811
|
+
...text(raw.summary, 200)?.trim() ? { summary: text(raw.summary, 200)?.trim() } : {},
|
|
2812
|
+
...source ? { source } : {},
|
|
2813
|
+
...shared ? { link: shared } : {}
|
|
2814
|
+
};
|
|
2815
|
+
}
|
|
2816
|
+
PostUtil.attach = attach;
|
|
2817
|
+
function check(value) {
|
|
2818
|
+
if (!value || typeof value !== "object") {
|
|
2819
|
+
return;
|
|
2820
|
+
}
|
|
2821
|
+
const raw = value;
|
|
2822
|
+
const body = text(raw.text, Limits.TEXT) ?? "";
|
|
2823
|
+
if (raw.v !== 1 || typeof raw.at !== "number") {
|
|
2824
|
+
return;
|
|
2825
|
+
}
|
|
2826
|
+
const images = (Array.isArray(raw.images) ? raw.images : []).slice(0, Limits.IMAGES).filter((image) => !!image && typeof image === "object" && [image.w, image.h].every((n) => Number.isInteger(n) && n > 0) && typeof image.thumb === "string" && image.thumb.startsWith("data:image/") && image.thumb.length <= Limits.THUMB_CHARS).map((image) => ({ w: image.w, h: image.h, thumb: image.thumb }));
|
|
2827
|
+
const attached = attach(raw.attach);
|
|
2828
|
+
if (!body.trim() && !images.length && !attached) {
|
|
2829
|
+
return;
|
|
2830
|
+
}
|
|
2831
|
+
return {
|
|
2832
|
+
v: 1,
|
|
2833
|
+
at: raw.at,
|
|
2834
|
+
...typeof raw.until === "number" ? { until: raw.until } : {},
|
|
2835
|
+
text: body,
|
|
2836
|
+
...images.length ? { images } : {},
|
|
2837
|
+
...attached ? { attach: attached } : {},
|
|
2838
|
+
...raw.ask === true ? { ask: true } : {}
|
|
2839
|
+
};
|
|
2840
|
+
}
|
|
2841
|
+
PostUtil.check = check;
|
|
2842
|
+
function parts(data) {
|
|
2843
|
+
const parts2 = [];
|
|
2844
|
+
for (let at = 0;at < data.length; at += Limits.PART_CHARS) {
|
|
2845
|
+
parts2.push(data.slice(at, at + Limits.PART_CHARS));
|
|
2846
|
+
}
|
|
2847
|
+
return parts2;
|
|
2848
|
+
}
|
|
2849
|
+
PostUtil.parts = parts;
|
|
2850
|
+
function isPicture(data, max = Limits.IMAGE_CHARS) {
|
|
2851
|
+
return typeof data === "string" && /^data:image\/(jpeg|png|webp|gif);base64,[A-Za-z0-9+/=]+$/.test(data) && data.length <= max;
|
|
2852
|
+
}
|
|
2853
|
+
PostUtil.isPicture = isPicture;
|
|
2854
|
+
function message2(data) {
|
|
2855
|
+
if (!data || typeof data !== "object") {
|
|
2856
|
+
return;
|
|
2857
|
+
}
|
|
2858
|
+
const raw = data;
|
|
2859
|
+
const post = typeof raw.post === "string" && isId(raw.post) ? raw.post : undefined;
|
|
2860
|
+
const index = Number.isInteger(raw.index) && raw.index >= 0 && raw.index < Limits.IMAGES ? raw.index : undefined;
|
|
2861
|
+
if (!post || index === undefined) {
|
|
2862
|
+
return;
|
|
2863
|
+
}
|
|
2864
|
+
if (raw.t === "ta-moments:want") {
|
|
2865
|
+
return { t: raw.t, post, index };
|
|
2866
|
+
}
|
|
2867
|
+
const max = Math.ceil(Limits.IMAGE_CHARS / Limits.PART_CHARS);
|
|
2868
|
+
if (raw.t === "ta-moments:img" && Number.isInteger(raw.parts) && raw.parts > 0 && raw.parts <= max && Number.isInteger(raw.part) && raw.part >= 0 && raw.part < raw.parts && typeof raw.d === "string" && raw.d.length <= Limits.PART_CHARS) {
|
|
2869
|
+
return { t: raw.t, post, index, part: raw.part, parts: raw.parts, d: raw.d };
|
|
2870
|
+
}
|
|
2871
|
+
return;
|
|
2872
|
+
}
|
|
2873
|
+
PostUtil.message = message2;
|
|
2874
|
+
function keysOf(id, keys) {
|
|
2875
|
+
const own = [`${StateKeys.IMG}${id}:`, `${StateKeys.LIKE}${id}:`, `${StateKeys.TOOK}${id}:`];
|
|
2876
|
+
return [`${StateKeys.POST}${id}`, ...[...keys].filter((key) => own.some((prefix) => key.startsWith(prefix)))];
|
|
2877
|
+
}
|
|
2878
|
+
PostUtil.keysOf = keysOf;
|
|
2879
|
+
function feed({ room, state, me, friends, now }) {
|
|
2880
|
+
const owner = room.members.find((member) => member.owner);
|
|
2881
|
+
if (!owner) {
|
|
2882
|
+
return [];
|
|
2883
|
+
}
|
|
2884
|
+
const online = owner.self || owner.online;
|
|
2885
|
+
const author = { id: owner.id, name: owner.name || room.ownerName, ...owner.look ? { look: owner.look } : {} };
|
|
2886
|
+
const byMember = new Map(room.members.map((member) => [member.member, member]));
|
|
2887
|
+
const self = room.members.find((member) => member.self);
|
|
2888
|
+
const marks = (prefix, id) => {
|
|
2889
|
+
const people = [];
|
|
2890
|
+
let mine = false;
|
|
2891
|
+
for (const [key, value] of Object.entries(state)) {
|
|
2892
|
+
if (!key.startsWith(`${prefix}${id}:`) || !value.value) {
|
|
2893
|
+
continue;
|
|
2894
|
+
}
|
|
2895
|
+
const member = key.slice(prefix.length + id.length + 1);
|
|
2896
|
+
const who = byMember.get(member);
|
|
2897
|
+
if (!who || value.by !== member) {
|
|
2898
|
+
continue;
|
|
2899
|
+
}
|
|
2900
|
+
if (who.member === self?.member) {
|
|
2901
|
+
mine = true;
|
|
2902
|
+
}
|
|
2903
|
+
if (who.id === me || who.id === owner.id || owner.id === me || friends.has(who.id)) {
|
|
2904
|
+
people.push({ id: who.id, name: who.name, ...who.look ? { look: who.look } : {} });
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
return { people, mine };
|
|
2908
|
+
};
|
|
2909
|
+
const posts = [];
|
|
2910
|
+
for (const [key, value] of Object.entries(state)) {
|
|
2911
|
+
const id = key.slice(StateKeys.POST.length);
|
|
2912
|
+
if (!key.startsWith(StateKeys.POST) || !isId(id) || value.by !== owner.member) {
|
|
2913
|
+
continue;
|
|
2914
|
+
}
|
|
2915
|
+
const post = check(value.value);
|
|
2916
|
+
if (!post || post.until !== undefined && post.until <= now) {
|
|
2917
|
+
continue;
|
|
2918
|
+
}
|
|
2919
|
+
const likes = marks(StateKeys.LIKE, id);
|
|
2920
|
+
const took = marks(StateKeys.TOOK, id);
|
|
2921
|
+
posts.push({
|
|
2922
|
+
room: room.id,
|
|
2923
|
+
id,
|
|
2924
|
+
author,
|
|
2925
|
+
mine: owner.id === me,
|
|
2926
|
+
online,
|
|
2927
|
+
at: post.at,
|
|
2928
|
+
...post.until !== undefined ? { until: post.until } : {},
|
|
2929
|
+
text: post.text,
|
|
2930
|
+
images: post.images ?? [],
|
|
2931
|
+
...post.attach ? { attach: post.attach } : {},
|
|
2932
|
+
likes: likes.people,
|
|
2933
|
+
liked: likes.mine,
|
|
2934
|
+
took: took.people,
|
|
2935
|
+
tookByMe: took.mine,
|
|
2936
|
+
...post.ask && owner.id !== me ? { ask: true } : {},
|
|
2937
|
+
talk: []
|
|
2938
|
+
});
|
|
2939
|
+
}
|
|
2940
|
+
return posts.sort((a, b) => b.at - a.at);
|
|
2941
|
+
}
|
|
2942
|
+
PostUtil.feed = feed;
|
|
2943
|
+
function news(posts, me, since) {
|
|
2944
|
+
const found = [];
|
|
2945
|
+
for (const post of posts) {
|
|
2946
|
+
for (const entry of post.talk) {
|
|
2947
|
+
const others = entry.by.id !== me || !!entry.double;
|
|
2948
|
+
if (entry.at > since && !entry.pending && (post.mine ? others : others && entry.to?.id === me)) {
|
|
2949
|
+
found.push({ post, entry });
|
|
2950
|
+
}
|
|
2951
|
+
}
|
|
2952
|
+
}
|
|
2953
|
+
return found.sort((a, b) => b.entry.at - a.entry.at);
|
|
2954
|
+
}
|
|
2955
|
+
PostUtil.news = news;
|
|
2956
|
+
})(PostUtil ||= {});
|
|
2957
|
+
|
|
2958
|
+
// web-src/news.tsx
|
|
2959
|
+
function PostPreview({ post }) {
|
|
2960
|
+
const [image, setImage] = React.useState();
|
|
2961
|
+
React.useEffect(() => {
|
|
2962
|
+
let live = true;
|
|
2963
|
+
if (post.images.length) {
|
|
2964
|
+
store.images(post.room, post.id).then((list) => live && setImage(list[0] || post.images[0]?.thumb));
|
|
2965
|
+
}
|
|
2966
|
+
return () => {
|
|
2967
|
+
live = false;
|
|
2968
|
+
};
|
|
2969
|
+
}, [post.room, post.id, post.images]);
|
|
2970
|
+
return /* @__PURE__ */ React.createElement("span", {
|
|
2971
|
+
className: "tmo-news-post"
|
|
2972
|
+
}, post.images.length ? image && /* @__PURE__ */ React.createElement("img", {
|
|
2973
|
+
src: image,
|
|
2974
|
+
alt: ""
|
|
2975
|
+
}) : /* @__PURE__ */ React.createElement("span", null, post.text || post.attach?.title));
|
|
2976
|
+
}
|
|
2977
|
+
function newsDialog(news, me, now) {
|
|
2978
|
+
return function NewsDialog({ close }) {
|
|
2979
|
+
const words2 = MomentsWords.of(pi.ui.language);
|
|
2980
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
2981
|
+
title: t("messagesTitle"),
|
|
2982
|
+
onClose: close
|
|
2983
|
+
}, /* @__PURE__ */ React.createElement("ul", {
|
|
2984
|
+
className: "tmo-rows tmo-news-list"
|
|
2985
|
+
}, news.map(({ post, entry }) => /* @__PURE__ */ React.createElement("li", {
|
|
2986
|
+
key: `${post.room}:${post.id}:${entry.id}`
|
|
2987
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
2988
|
+
type: "button",
|
|
2989
|
+
className: "tmo-row tmo-news-row",
|
|
2990
|
+
onClick: () => {
|
|
2991
|
+
close();
|
|
2992
|
+
store.show(post.room, post.id);
|
|
2993
|
+
}
|
|
2994
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
2995
|
+
id: entry.by.id,
|
|
2996
|
+
look: entry.by.look,
|
|
2997
|
+
mine: entry.by.id === me,
|
|
2998
|
+
size: 40
|
|
2999
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
3000
|
+
className: "tmo-row-text"
|
|
3001
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3002
|
+
className: "tmo-news-name"
|
|
3003
|
+
}, entry.double ? t("theirTa", { name: names([entry.by], me) }) : entry.by.name), /* @__PURE__ */ React.createElement("span", {
|
|
3004
|
+
className: "tmo-news-text"
|
|
3005
|
+
}, entry.text), /* @__PURE__ */ React.createElement("span", {
|
|
3006
|
+
className: "tmo-row-line"
|
|
3007
|
+
}, MomentsWords.ago(words2, entry.at, now, pi.ui.language))), /* @__PURE__ */ React.createElement(PostPreview, {
|
|
3008
|
+
post
|
|
3009
|
+
}))))));
|
|
3010
|
+
};
|
|
3011
|
+
}
|
|
3012
|
+
function News({ posts, me, now, people }) {
|
|
3013
|
+
const since = useTalkSeen();
|
|
3014
|
+
if (since === undefined) {
|
|
3015
|
+
return null;
|
|
3016
|
+
}
|
|
3017
|
+
const looks = new Map(people.map((person) => [person.id, person.look]));
|
|
3018
|
+
const news = PostUtil.news(posts, me, since).map(({ post, entry }) => ({
|
|
3019
|
+
post,
|
|
3020
|
+
entry: { ...entry, by: { ...entry.by, look: entry.by.look ?? looks.get(entry.by.id) } }
|
|
3021
|
+
}));
|
|
3022
|
+
if (!news.length) {
|
|
3023
|
+
return null;
|
|
3024
|
+
}
|
|
3025
|
+
const latest = news[0].entry.by;
|
|
3026
|
+
return /* @__PURE__ */ React.createElement("button", {
|
|
3027
|
+
type: "button",
|
|
3028
|
+
className: "tmo-news",
|
|
3029
|
+
onClick: () => {
|
|
3030
|
+
show(newsDialog(news, me, now));
|
|
3031
|
+
store.markTalkSeen(news[0].entry.at);
|
|
3032
|
+
}
|
|
3033
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
3034
|
+
id: latest.id,
|
|
3035
|
+
look: latest.look,
|
|
3036
|
+
mine: latest.id === me,
|
|
3037
|
+
size: 28
|
|
3038
|
+
}), /* @__PURE__ */ React.createElement("span", null, t("newMessages", { n: news.length })));
|
|
3039
|
+
}
|
|
3040
|
+
|
|
2174
3041
|
// web-src/page.tsx
|
|
2175
3042
|
function ComposeDialog({ close }) {
|
|
2176
3043
|
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
@@ -2190,7 +3057,17 @@ function ComposeDialog({ close }) {
|
|
|
2190
3057
|
}));
|
|
2191
3058
|
}
|
|
2192
3059
|
function MomentsHead() {
|
|
3060
|
+
const state = useMoments();
|
|
3061
|
+
const album = useAlbum();
|
|
3062
|
+
if (album) {
|
|
3063
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
3064
|
+
className: "tmo-head"
|
|
3065
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3066
|
+
className: "tmo-head-title"
|
|
3067
|
+
}, album.id === state?.me.id ? t("myMoments") : album.name));
|
|
3068
|
+
}
|
|
2193
3069
|
const Post = icon("Aperture", "Plus");
|
|
3070
|
+
const Friends = icon("Users");
|
|
2194
3071
|
return /* @__PURE__ */ React.createElement("div", {
|
|
2195
3072
|
className: "tmo-head"
|
|
2196
3073
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
@@ -2198,6 +3075,16 @@ function MomentsHead() {
|
|
|
2198
3075
|
}, t("title")), /* @__PURE__ */ React.createElement("div", {
|
|
2199
3076
|
className: "tmo-head-end"
|
|
2200
3077
|
}, /* @__PURE__ */ React.createElement("button", {
|
|
3078
|
+
type: "button",
|
|
3079
|
+
className: "tmo-icon-button",
|
|
3080
|
+
"aria-label": t("friends"),
|
|
3081
|
+
title: t("friends"),
|
|
3082
|
+
onClick: openFriends
|
|
3083
|
+
}, Friends && /* @__PURE__ */ React.createElement(Friends, {
|
|
3084
|
+
size: 18
|
|
3085
|
+
}), state?.asking ? /* @__PURE__ */ React.createElement("i", {
|
|
3086
|
+
className: "tmo-icon-dot"
|
|
3087
|
+
}) : null), /* @__PURE__ */ React.createElement("button", {
|
|
2201
3088
|
type: "button",
|
|
2202
3089
|
className: "tmo-icon-button",
|
|
2203
3090
|
"aria-label": t("post"),
|
|
@@ -2347,11 +3234,6 @@ function AttachCard({ post, attach }) {
|
|
|
2347
3234
|
className: `ta-spinner ta-busy-mark${post.tookByMe ? "" : " ta-on-brand"}`
|
|
2348
3235
|
}), /* @__PURE__ */ React.createElement("span", null, label)));
|
|
2349
3236
|
}
|
|
2350
|
-
function names(people, me) {
|
|
2351
|
-
const words2 = MomentsWords.of(pi.ui.language);
|
|
2352
|
-
const separator = TaLanguageUtil.list(pi.ui.language, ["", ""]).slice(1, -1) || ", ";
|
|
2353
|
-
return people.map((person) => person.id === me ? words2.me : person.name).join(separator);
|
|
2354
|
-
}
|
|
2355
3237
|
function TalkLine({ post, entry, me, onReply }) {
|
|
2356
3238
|
const own = entry.by.id === me && !entry.double;
|
|
2357
3239
|
const answer = entry.double && post.mine;
|
|
@@ -2400,8 +3282,8 @@ function TalkBox({ post, writing, close }) {
|
|
|
2400
3282
|
key: `${writing.ask ? "ask" : "say"}:${writing.to?.id ?? ""}`,
|
|
2401
3283
|
placeholder,
|
|
2402
3284
|
draft: `${post.id}:${writing.ask ? "ask" : "say"}:${writing.to?.id ?? ""}`,
|
|
2403
|
-
onSend: async (
|
|
2404
|
-
await pi.callHost("say", post.room, post.id,
|
|
3285
|
+
onSend: async (text2) => {
|
|
3286
|
+
await pi.callHost("say", post.room, post.id, text2, { ...writing.to ? { to: writing.to.id } : {}, ...writing.ask ? { ask: true } : {} });
|
|
2405
3287
|
close();
|
|
2406
3288
|
await store.load();
|
|
2407
3289
|
}
|
|
@@ -2411,46 +3293,140 @@ function TalkBox({ post, writing, close }) {
|
|
|
2411
3293
|
onClick: close
|
|
2412
3294
|
}, t("cancel")));
|
|
2413
3295
|
}
|
|
2414
|
-
function
|
|
3296
|
+
function PostText({ text: text2 }) {
|
|
3297
|
+
const ref = React.useRef(null);
|
|
3298
|
+
const [long, setLong] = React.useState(false);
|
|
3299
|
+
const [open, setOpen] = React.useState(false);
|
|
3300
|
+
React.useLayoutEffect(() => {
|
|
3301
|
+
const element = ref.current;
|
|
3302
|
+
if (element && !open) {
|
|
3303
|
+
setLong(element.scrollHeight > element.clientHeight + 1);
|
|
3304
|
+
}
|
|
3305
|
+
}, [text2, open]);
|
|
3306
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
3307
|
+
ref,
|
|
3308
|
+
className: `tmo-text${open ? "" : " tmo-clamp"}`
|
|
3309
|
+
}, text2), long && /* @__PURE__ */ React.createElement("button", {
|
|
3310
|
+
type: "button",
|
|
3311
|
+
className: "tmo-fold",
|
|
3312
|
+
onClick: () => setOpen(!open)
|
|
3313
|
+
}, open ? t("collapse") : t("fullText")));
|
|
3314
|
+
}
|
|
3315
|
+
function Actions({ post, liking, onLike, onComment, onAsk }) {
|
|
3316
|
+
const [open, setOpen] = React.useState(false);
|
|
3317
|
+
const ref = React.useRef(null);
|
|
3318
|
+
pi.ui.useBackLayer?.(open, () => setOpen(false));
|
|
3319
|
+
React.useEffect(() => {
|
|
3320
|
+
if (!open) {
|
|
3321
|
+
return;
|
|
3322
|
+
}
|
|
3323
|
+
const away = (event) => {
|
|
3324
|
+
if (!ref.current?.contains(event.target)) {
|
|
3325
|
+
setOpen(false);
|
|
3326
|
+
}
|
|
3327
|
+
};
|
|
3328
|
+
document.addEventListener("pointerdown", away, true);
|
|
3329
|
+
return () => document.removeEventListener("pointerdown", away, true);
|
|
3330
|
+
}, [open]);
|
|
3331
|
+
const Heart = icon("Heart");
|
|
3332
|
+
const Comment = icon("MessageCircle");
|
|
3333
|
+
const Spark = icon("Sparkles");
|
|
3334
|
+
const pick = (action2) => () => {
|
|
3335
|
+
setOpen(false);
|
|
3336
|
+
action2();
|
|
3337
|
+
};
|
|
3338
|
+
const tab = open ? 0 : -1;
|
|
3339
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
3340
|
+
className: "tmo-actions",
|
|
3341
|
+
ref
|
|
3342
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3343
|
+
className: `tmo-actions-pop${open ? " tmo-open" : ""}`,
|
|
3344
|
+
role: "menu",
|
|
3345
|
+
"aria-hidden": !open
|
|
3346
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
3347
|
+
type: "button",
|
|
3348
|
+
role: "menuitem",
|
|
3349
|
+
tabIndex: tab,
|
|
3350
|
+
disabled: liking,
|
|
3351
|
+
className: post.liked ? "tmo-liked" : "",
|
|
3352
|
+
onClick: pick(onLike)
|
|
3353
|
+
}, Heart && /* @__PURE__ */ React.createElement(Heart, {
|
|
3354
|
+
size: 15
|
|
3355
|
+
}), /* @__PURE__ */ React.createElement("span", null, post.liked ? t("unlike") : t("like"))), /* @__PURE__ */ React.createElement("i", {
|
|
3356
|
+
className: "tmo-actions-split"
|
|
3357
|
+
}), /* @__PURE__ */ React.createElement("button", {
|
|
3358
|
+
type: "button",
|
|
3359
|
+
role: "menuitem",
|
|
3360
|
+
tabIndex: tab,
|
|
3361
|
+
onClick: pick(onComment)
|
|
3362
|
+
}, Comment && /* @__PURE__ */ React.createElement(Comment, {
|
|
3363
|
+
size: 15
|
|
3364
|
+
}), /* @__PURE__ */ React.createElement("span", null, t("comment"))), post.ask && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("i", {
|
|
3365
|
+
className: "tmo-actions-split"
|
|
3366
|
+
}), /* @__PURE__ */ React.createElement("button", {
|
|
3367
|
+
type: "button",
|
|
3368
|
+
role: "menuitem",
|
|
3369
|
+
tabIndex: tab,
|
|
3370
|
+
title: t("askTaHint", { name: post.author.name }),
|
|
3371
|
+
onClick: pick(onAsk)
|
|
3372
|
+
}, Spark && /* @__PURE__ */ React.createElement(Spark, {
|
|
3373
|
+
size: 15
|
|
3374
|
+
}), /* @__PURE__ */ React.createElement("span", null, t("askTa"))))), /* @__PURE__ */ React.createElement("button", {
|
|
3375
|
+
type: "button",
|
|
3376
|
+
className: `tmo-more${open ? " tmo-on" : ""}`,
|
|
3377
|
+
"aria-label": t("more"),
|
|
3378
|
+
"aria-expanded": open,
|
|
3379
|
+
onClick: () => setOpen(!open)
|
|
3380
|
+
}, /* @__PURE__ */ React.createElement("i", null), /* @__PURE__ */ React.createElement("i", null)));
|
|
3381
|
+
}
|
|
3382
|
+
function PostView({ post, me, now, album }) {
|
|
2415
3383
|
const [writing, setWriting] = React.useState();
|
|
2416
3384
|
const [liking, like] = useBusy();
|
|
2417
3385
|
const [removing, remove] = useBusy();
|
|
2418
3386
|
const Heart = icon("Heart");
|
|
2419
|
-
const Trash = icon("Trash2");
|
|
2420
3387
|
const Took = icon("PackageOpen");
|
|
2421
3388
|
const words2 = MomentsWords.of(pi.ui.language);
|
|
2422
3389
|
const left = post.until !== undefined ? Math.ceil((post.until - now) / 86400000) : undefined;
|
|
2423
3390
|
const Spark = icon("Sparkles");
|
|
2424
|
-
const
|
|
3391
|
+
const openAlbum = album ? undefined : () => store.openAlbum(post.author);
|
|
2425
3392
|
return /* @__PURE__ */ React.createElement("article", {
|
|
2426
3393
|
className: "tmo-post",
|
|
2427
3394
|
"data-post": `${post.room}:${post.id}`
|
|
3395
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
3396
|
+
type: "button",
|
|
3397
|
+
className: "tmo-face-button",
|
|
3398
|
+
"aria-label": post.author.name,
|
|
3399
|
+
disabled: !openAlbum,
|
|
3400
|
+
onClick: openAlbum
|
|
2428
3401
|
}, /* @__PURE__ */ React.createElement(Face, {
|
|
2429
3402
|
id: post.author.id,
|
|
2430
3403
|
look: post.author.look,
|
|
2431
3404
|
mine: post.mine,
|
|
2432
3405
|
size: 42
|
|
2433
|
-
}), /* @__PURE__ */ React.createElement("div", {
|
|
3406
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
2434
3407
|
className: "tmo-post-body"
|
|
2435
|
-
}, /* @__PURE__ */ React.createElement("
|
|
2436
|
-
|
|
3408
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
3409
|
+
type: "button",
|
|
3410
|
+
className: "tmo-name",
|
|
3411
|
+
disabled: !openAlbum,
|
|
3412
|
+
onClick: openAlbum
|
|
2437
3413
|
}, post.author.name), post.why && /* @__PURE__ */ React.createElement("div", {
|
|
2438
3414
|
className: "tmo-why",
|
|
2439
3415
|
title: t("whyHint")
|
|
2440
3416
|
}, Spark && /* @__PURE__ */ React.createElement(Spark, {
|
|
2441
3417
|
size: 13
|
|
2442
|
-
}), /* @__PURE__ */ React.createElement("span", null, post.why)), post.text && /* @__PURE__ */ React.createElement(
|
|
2443
|
-
|
|
2444
|
-
}
|
|
3418
|
+
}), /* @__PURE__ */ React.createElement("span", null, post.why)), post.text && /* @__PURE__ */ React.createElement(PostText, {
|
|
3419
|
+
text: post.text
|
|
3420
|
+
}), /* @__PURE__ */ React.createElement(PostImages, {
|
|
2445
3421
|
post
|
|
2446
3422
|
}), post.attach && /* @__PURE__ */ React.createElement(AttachCard, {
|
|
2447
3423
|
post,
|
|
2448
3424
|
attach: post.attach
|
|
2449
3425
|
}), /* @__PURE__ */ React.createElement("div", {
|
|
2450
3426
|
className: "tmo-meta"
|
|
2451
|
-
}, /* @__PURE__ */ React.createElement("span", null, MomentsWords.ago(words2, post.at, now, pi.ui.language)), post.mine && left !== undefined && /* @__PURE__ */ React.createElement("span", null, left <= 1 ? t("expiresSoon") : t("expires", { days: left })), post.mine && /* @__PURE__ */ React.createElement("button", {
|
|
3427
|
+
}, /* @__PURE__ */ React.createElement("span", null, MomentsWords.ago(words2, post.at, now, pi.ui.language)), post.mine && left !== undefined && left <= 3 && /* @__PURE__ */ React.createElement("span", null, left <= 1 ? t("expiresSoon") : t("expires", { days: left })), post.mine && /* @__PURE__ */ React.createElement("button", {
|
|
2452
3428
|
type: "button",
|
|
2453
|
-
className: "tmo-link",
|
|
3429
|
+
className: "tmo-link tmo-delete",
|
|
2454
3430
|
disabled: removing,
|
|
2455
3431
|
onClick: () => void remove(async () => {
|
|
2456
3432
|
if (await pi.ui.confirm(t("deleteTitle"), t("deleteBody"), { confirmLabel: t("deletePost"), danger: true })) {
|
|
@@ -2458,39 +3434,18 @@ function PostView({ post, me, now }) {
|
|
|
2458
3434
|
await store.load();
|
|
2459
3435
|
}
|
|
2460
3436
|
})
|
|
2461
|
-
},
|
|
2462
|
-
size: 13
|
|
2463
|
-
}), /* @__PURE__ */ React.createElement("span", null, t("deletePost"))), /* @__PURE__ */ React.createElement("span", {
|
|
3437
|
+
}, t("deletePost")), /* @__PURE__ */ React.createElement("span", {
|
|
2464
3438
|
className: "tmo-grow"
|
|
2465
|
-
}),
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
onClick: () => setWriting(writing?.ask ? undefined : { ask: true })
|
|
2470
|
-
}, Spark && /* @__PURE__ */ React.createElement(Spark, {
|
|
2471
|
-
size: 13
|
|
2472
|
-
}), /* @__PURE__ */ React.createElement("span", null, t("askTa"))), /* @__PURE__ */ React.createElement("button", {
|
|
2473
|
-
type: "button",
|
|
2474
|
-
className: `tmo-like${writing && !writing.ask ? " tmo-on-talk" : ""}`,
|
|
2475
|
-
"aria-label": t("comment"),
|
|
2476
|
-
title: t("comment"),
|
|
2477
|
-
onClick: () => setWriting(writing && !writing.ask && !writing.to ? undefined : {})
|
|
2478
|
-
}, Comment && /* @__PURE__ */ React.createElement(Comment, {
|
|
2479
|
-
size: 16
|
|
2480
|
-
})), /* @__PURE__ */ React.createElement("button", {
|
|
2481
|
-
type: "button",
|
|
2482
|
-
className: `tmo-like${post.liked ? " tmo-on" : ""}`,
|
|
2483
|
-
"aria-pressed": post.liked,
|
|
2484
|
-
"aria-label": post.liked ? t("unlike") : t("like"),
|
|
2485
|
-
title: post.liked ? t("unlike") : t("like"),
|
|
2486
|
-
disabled: liking,
|
|
2487
|
-
onClick: () => void like(async () => {
|
|
3439
|
+
}), /* @__PURE__ */ React.createElement(Actions, {
|
|
3440
|
+
post,
|
|
3441
|
+
liking,
|
|
3442
|
+
onLike: () => void like(async () => {
|
|
2488
3443
|
await pi.callHost("like", post.room, post.id, !post.liked).catch(failed);
|
|
2489
3444
|
await store.load();
|
|
2490
|
-
})
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
}))
|
|
3445
|
+
}),
|
|
3446
|
+
onComment: () => setWriting({}),
|
|
3447
|
+
onAsk: () => setWriting({ ask: true })
|
|
3448
|
+
})), (post.likes.length > 0 || post.took.length > 0 || post.talk.length > 0) && /* @__PURE__ */ React.createElement("div", {
|
|
2494
3449
|
className: "tmo-marks"
|
|
2495
3450
|
}, post.likes.length > 0 && /* @__PURE__ */ React.createElement("div", {
|
|
2496
3451
|
className: "tmo-marks-line"
|
|
@@ -2514,47 +3469,62 @@ function PostView({ post, me, now }) {
|
|
|
2514
3469
|
close: () => setWriting(undefined)
|
|
2515
3470
|
})));
|
|
2516
3471
|
}
|
|
2517
|
-
function
|
|
3472
|
+
function Album({ person }) {
|
|
2518
3473
|
const state = useMoments();
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
}),
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
3474
|
+
if (!state) {
|
|
3475
|
+
return null;
|
|
3476
|
+
}
|
|
3477
|
+
const now = Date.now();
|
|
3478
|
+
const posts = state.posts.filter((post) => post.author.id === person.id);
|
|
3479
|
+
return /* @__PURE__ */ React.createElement("section", {
|
|
3480
|
+
className: "tmo-page",
|
|
3481
|
+
"aria-label": person.name
|
|
3482
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3483
|
+
className: "tmo-feed"
|
|
3484
|
+
}, /* @__PURE__ */ React.createElement(Cover, {
|
|
3485
|
+
person,
|
|
3486
|
+
mine: person.id === state.me.id
|
|
3487
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
3488
|
+
className: "tmo-after-cover"
|
|
3489
|
+
}), posts.length ? posts.map((post) => /* @__PURE__ */ React.createElement(PostView, {
|
|
3490
|
+
key: `${post.room}:${post.id}`,
|
|
3491
|
+
post,
|
|
3492
|
+
me: state.me.id,
|
|
3493
|
+
now,
|
|
3494
|
+
album: true
|
|
3495
|
+
})) : /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
3496
|
+
title: t("albumEmpty")
|
|
2541
3497
|
})));
|
|
2542
3498
|
}
|
|
2543
3499
|
function MomentsPage() {
|
|
3500
|
+
const Loading = pi.ui.Loading ?? pi.ui.Skeleton;
|
|
2544
3501
|
const state = useMoments();
|
|
3502
|
+
const album = useAlbum();
|
|
2545
3503
|
const now = Date.now();
|
|
2546
3504
|
const shown = pi.ui.useView?.(VIEW)?.shown ?? true;
|
|
2547
3505
|
React.useEffect(() => {
|
|
2548
3506
|
store.load();
|
|
3507
|
+
store.loadCover();
|
|
2549
3508
|
}, []);
|
|
2550
3509
|
React.useEffect(() => {
|
|
2551
3510
|
if (state && shown) {
|
|
2552
3511
|
store.markSeen();
|
|
2553
3512
|
}
|
|
2554
3513
|
}, [state, shown]);
|
|
3514
|
+
React.useEffect(() => {
|
|
3515
|
+
if (!shown) {
|
|
3516
|
+
store.openAlbum(undefined);
|
|
3517
|
+
}
|
|
3518
|
+
}, [shown]);
|
|
3519
|
+
const [kept, setKept] = React.useState();
|
|
3520
|
+
React.useEffect(() => {
|
|
3521
|
+
if (album) {
|
|
3522
|
+
setKept(album);
|
|
3523
|
+
}
|
|
3524
|
+
}, [album]);
|
|
2555
3525
|
const focus = React.useSyncExternalStore(store.subscribe, () => store.focus);
|
|
2556
3526
|
React.useEffect(() => {
|
|
2557
|
-
if (!state || !focus || !shown) {
|
|
3527
|
+
if (!state || !focus || !shown || album) {
|
|
2558
3528
|
return;
|
|
2559
3529
|
}
|
|
2560
3530
|
const element = document.querySelector(`.tmo-post[data-post="${CSS.escape(focus)}"]`);
|
|
@@ -2566,7 +3536,7 @@ function MomentsPage() {
|
|
|
2566
3536
|
} else {
|
|
2567
3537
|
pi.ui.notify(t("postGone"));
|
|
2568
3538
|
}
|
|
2569
|
-
}, [state, focus, shown]);
|
|
3539
|
+
}, [state, focus, shown, album]);
|
|
2570
3540
|
if (!pi.rooms) {
|
|
2571
3541
|
return /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
2572
3542
|
title: t("oldApp")
|
|
@@ -2576,15 +3546,26 @@ function MomentsPage() {
|
|
|
2576
3546
|
return store.error ? /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
2577
3547
|
title: String(store.error),
|
|
2578
3548
|
tone: "error"
|
|
2579
|
-
}) : /* @__PURE__ */ React.createElement(
|
|
3549
|
+
}) : /* @__PURE__ */ React.createElement(Loading, null);
|
|
2580
3550
|
}
|
|
2581
3551
|
const Add = icon("UserPlus");
|
|
2582
|
-
|
|
3552
|
+
const feed = /* @__PURE__ */ React.createElement("section", {
|
|
2583
3553
|
className: "tmo-page",
|
|
2584
3554
|
"aria-label": t("title")
|
|
2585
3555
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
2586
3556
|
className: "tmo-feed"
|
|
2587
|
-
}, /* @__PURE__ */ React.createElement(
|
|
3557
|
+
}, /* @__PURE__ */ React.createElement(Cover, {
|
|
3558
|
+
person: state.me,
|
|
3559
|
+
mine: true,
|
|
3560
|
+
onFace: () => store.openAlbum(state.me)
|
|
3561
|
+
}), /* @__PURE__ */ React.createElement(News, {
|
|
3562
|
+
posts: state.posts,
|
|
3563
|
+
me: state.me.id,
|
|
3564
|
+
now,
|
|
3565
|
+
people: [state.me, ...state.friends]
|
|
3566
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
3567
|
+
className: "tmo-after-cover"
|
|
3568
|
+
}), state.posts.length ? state.posts.map((post) => /* @__PURE__ */ React.createElement(PostView, {
|
|
2588
3569
|
key: `${post.room}:${post.id}`,
|
|
2589
3570
|
post,
|
|
2590
3571
|
me: state.me.id,
|
|
@@ -2602,6 +3583,22 @@ function MomentsPage() {
|
|
|
2602
3583
|
}, Add && /* @__PURE__ */ React.createElement(Add, {
|
|
2603
3584
|
size: 14
|
|
2604
3585
|
}), " ", t("addFriend")))));
|
|
3586
|
+
const Stack = pi.ui.Stack;
|
|
3587
|
+
const top = album ?? kept;
|
|
3588
|
+
if (!Stack) {
|
|
3589
|
+
return album ? /* @__PURE__ */ React.createElement(Album, {
|
|
3590
|
+
person: album
|
|
3591
|
+
}) : feed;
|
|
3592
|
+
}
|
|
3593
|
+
return /* @__PURE__ */ React.createElement(Stack, {
|
|
3594
|
+
base: feed,
|
|
3595
|
+
top: top ? /* @__PURE__ */ React.createElement(Album, {
|
|
3596
|
+
key: top.id,
|
|
3597
|
+
person: top
|
|
3598
|
+
}) : null,
|
|
3599
|
+
open: !!album,
|
|
3600
|
+
onClose: () => store.openAlbum(undefined)
|
|
3601
|
+
});
|
|
2605
3602
|
}
|
|
2606
3603
|
function MomentsMark() {
|
|
2607
3604
|
const state = useMoments();
|
|
@@ -2639,24 +3636,56 @@ var STYLE = `
|
|
|
2639
3636
|
.tmo-head-title { font-weight: 600; font-size: calc(14.5px * var(--ta-font-scale)); }
|
|
2640
3637
|
.tmo-head-end { position: absolute; right: 0; top: 50%; transform: translateY(-50%); display: flex; gap: 2px; }
|
|
2641
3638
|
/* The page: one column, as WeChat's Moments */
|
|
2642
|
-
.tmo-page { flex: 1; min-height: 0; height: 100%; overflow-y: auto; overscroll-behavior: none; background: var(--ta-main); color: var(--ta-text); }
|
|
3639
|
+
.tmo-page { flex: 1; min-height: 0; height: 100%; overflow-x: hidden; overflow-y: auto; overscroll-behavior: none; background: var(--ta-main); color: var(--ta-text); }
|
|
2643
3640
|
.tmo-feed { display: flex; flex-direction: column; min-height: 100%; max-width: var(--ta-page-width); margin: 0 auto; padding: 6px 14px calc(28px + env(safe-area-inset-bottom)); box-sizing: border-box; }
|
|
2644
3641
|
.tmo-card { margin: 4px 0 8px; padding: 2px 8px; border-radius: 14px; background: var(--ta-raised); }
|
|
2645
|
-
|
|
2646
|
-
.tmo-
|
|
2647
|
-
.tmo-
|
|
2648
|
-
.tmo-
|
|
3642
|
+
/* The cover, as WeChat's: the picture across the column, the name on it and the face over its foot */
|
|
3643
|
+
.tmo-cover { position: relative; margin: -6px -14px 0; }
|
|
3644
|
+
.tmo-cover-art { display: block; width: 100%; height: clamp(220px, 34vh, 300px); padding: 0; border: 0; overflow: hidden; background: var(--ta-raised); cursor: pointer; -webkit-tap-highlight-color: transparent; }
|
|
3645
|
+
.tmo-cover-art:disabled { cursor: default; }
|
|
3646
|
+
.tmo-cover-art img { display: block; width: 100%; height: 100%; object-fit: cover; }
|
|
3647
|
+
.tmo-cover-art.tmo-busy { opacity: .6; }
|
|
3648
|
+
.tmo-cover-default { display: block; width: 100%; height: 100%; background:
|
|
3649
|
+
radial-gradient(120% 90% at 85% 0%, color-mix(in oklch, var(--ta-green) 42%, transparent), transparent 62%),
|
|
3650
|
+
radial-gradient(90% 80% at 0% 100%, color-mix(in oklch, var(--ta-yellow) 26%, transparent), transparent 60%),
|
|
3651
|
+
linear-gradient(180deg, color-mix(in oklch, var(--ta-green) 16%, var(--ta-raised)), var(--ta-raised)); }
|
|
3652
|
+
.tmo-cover-who { position: absolute; right: 16px; bottom: -22px; display: flex; align-items: flex-end; gap: 14px; max-width: calc(100% - 32px); pointer-events: none; }
|
|
3653
|
+
.tmo-cover-name { min-width: 0; margin-bottom: 30px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; font-weight: 600; font-size: calc(17px * var(--ta-font-scale)); text-shadow: 0 1px 3px rgba(0, 0, 0, .45); }
|
|
3654
|
+
.tmo-cover-face { flex: none; display: block; padding: 0; border: 0; border-radius: 50%; background: var(--ta-main); box-shadow: 0 0 0 3px var(--ta-main); line-height: 0; pointer-events: auto; cursor: pointer; -webkit-tap-highlight-color: transparent; }
|
|
3655
|
+
.tmo-cover-face:disabled { cursor: default; }
|
|
3656
|
+
.tmo-cover-face .ta-face { --ta-face-ring: var(--ta-main); }
|
|
3657
|
+
.tmo-after-cover { height: 22px; flex: none; }
|
|
3658
|
+
/* New messages under the cover */
|
|
3659
|
+
.tmo-news { display: flex; align-items: center; gap: 10px; align-self: center; margin: 38px 0 -8px; padding: 6px 16px 6px 6px; border: 0; border-radius: 9px; background: color-mix(in srgb, var(--ta-text) 72%, transparent); color: var(--ta-main); font: inherit; font-size: calc(13.5px * var(--ta-font-scale)); cursor: pointer; -webkit-tap-highlight-color: transparent; }
|
|
3660
|
+
.tmo-news .ta-face { --ta-face-ring: transparent; }
|
|
3661
|
+
.tmo-news:active { opacity: .85; }
|
|
3662
|
+
.tmo-news-list { min-width: min(400px, 82vw); }
|
|
3663
|
+
.tmo-news-row { width: 100%; border: 0; border-radius: 10px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; align-items: flex-start; }
|
|
3664
|
+
.tmo-news-row:hover { background: var(--ta-hover); }
|
|
3665
|
+
.tmo-news-row .ta-face { --ta-face-ring: var(--ta-card); }
|
|
3666
|
+
.tmo-news-name { font-weight: 500; color: var(--ta-link); }
|
|
3667
|
+
.tmo-news-text { line-height: 1.45; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
|
|
3668
|
+
.tmo-news-post { flex: none; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 6px; overflow: hidden; background: var(--ta-raised); }
|
|
3669
|
+
.tmo-news-post img { width: 100%; height: 100%; object-fit: cover; }
|
|
3670
|
+
.tmo-news-post span { padding: 4px; color: var(--ta-secondary); font-size: calc(11px * var(--ta-font-scale)); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
|
|
3671
|
+
.tmo-icon-button { position: relative; }
|
|
3672
|
+
.tmo-icon-dot { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--ta-yellow); }
|
|
2649
3673
|
.tmo-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ta-yellow); }
|
|
2650
3674
|
/* A post: the face, then the name, words, pictures, what to take, when and the heart */
|
|
2651
3675
|
.tmo-post { display: flex; gap: 12px; padding: 16px 2px 14px; border-bottom: 1px solid var(--ta-border-muted); }
|
|
3676
|
+
.tmo-face-button { flex: none; align-self: flex-start; display: block; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
|
|
3677
|
+
.tmo-face-button:disabled { cursor: default; }
|
|
2652
3678
|
.tmo-post .ta-face { --ta-face-ring: var(--ta-main); }
|
|
2653
3679
|
.tmo-post-body { display: flex; flex-direction: column; gap: 7px; flex: 1; min-width: 0; }
|
|
2654
|
-
.tmo-name { font-weight: 600; color: var(--ta-link); font-size: calc(14.5px * var(--ta-font-scale)); line-height: 1.3; }
|
|
3680
|
+
.tmo-name { align-self: flex-start; max-width: 100%; padding: 0; border: 0; background: none; font: inherit; font-weight: 600; color: var(--ta-link); font-size: calc(14.5px * var(--ta-font-scale)); line-height: 1.3; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent; }
|
|
3681
|
+
.tmo-name:disabled { cursor: default; color: var(--ta-link); }
|
|
2655
3682
|
.tmo-why { display: flex; align-items: flex-start; gap: 5px; align-self: flex-start; max-width: 100%; padding: 3px 8px; border-radius: 7px; background: color-mix(in srgb, var(--ta-yellow) 14%, transparent); color: var(--ta-secondary); font-size: calc(12.5px * var(--ta-font-scale)); line-height: 1.45; }
|
|
2656
3683
|
.tmo-why svg { flex: none; position: relative; top: 2px; color: var(--ta-yellow); }
|
|
2657
3684
|
.tmo-post.tmo-focus { animation: tmo-focus 1.6s ease-out; }
|
|
2658
3685
|
@keyframes tmo-focus { from { background: var(--ta-hover); } to { background: transparent; } }
|
|
2659
3686
|
.tmo-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; font-size: calc(14.5px * var(--ta-font-scale)); }
|
|
3687
|
+
.tmo-clamp { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
|
|
3688
|
+
.tmo-fold { align-self: flex-start; margin-top: -4px; padding: 0; border: 0; background: none; color: var(--ta-link); font: inherit; font-size: calc(14px * var(--ta-font-scale)); cursor: pointer; }
|
|
2660
3689
|
.tmo-images { display: flex; }
|
|
2661
3690
|
.tmo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; max-width: 300px; }
|
|
2662
3691
|
.tmo-image { position: relative; display: block; padding: 0; border: 0; border-radius: 6px; overflow: hidden; background: var(--ta-raised); cursor: zoom-in; }
|
|
@@ -2673,15 +3702,21 @@ var STYLE = `
|
|
|
2673
3702
|
.tmo-attach-line { color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
|
|
2674
3703
|
.tmo-attach .ta-button { flex: none; }
|
|
2675
3704
|
.tmo-meta { display: flex; align-items: center; gap: 10px; min-height: 28px; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
|
|
2676
|
-
.tmo-meta .tmo-link { color: var(--ta-
|
|
2677
|
-
.tmo-meta .tmo-
|
|
2678
|
-
.tmo-
|
|
2679
|
-
|
|
2680
|
-
.tmo-
|
|
2681
|
-
.tmo-
|
|
2682
|
-
.tmo-
|
|
2683
|
-
.tmo-
|
|
2684
|
-
.tmo-
|
|
3705
|
+
.tmo-meta .tmo-link { color: var(--ta-link); }
|
|
3706
|
+
.tmo-meta .tmo-delete { padding: 2px 0; }
|
|
3707
|
+
.tmo-meta .tmo-delete:hover { background: none; color: var(--ta-red); }
|
|
3708
|
+
/* The two dots, and Like · Comment sliding out to their left, as WeChat's */
|
|
3709
|
+
.tmo-actions { position: relative; display: flex; align-items: center; }
|
|
3710
|
+
.tmo-more { display: flex; align-items: center; justify-content: center; gap: 4px; width: 32px; height: 20px; padding: 0; border: 0; border-radius: 4px; background: var(--ta-raised); cursor: pointer; -webkit-tap-highlight-color: transparent; }
|
|
3711
|
+
.tmo-more i { width: 4px; height: 4px; border-radius: 50%; background: var(--ta-link); }
|
|
3712
|
+
.tmo-more:hover, .tmo-more.tmo-on { background: var(--ta-hover); }
|
|
3713
|
+
.tmo-actions-pop { position: absolute; right: calc(100% + 8px); top: 50%; display: flex; align-items: center; height: 38px; padding: 0 4px; border-radius: 6px; background: #4c4c4c; color: #fff; white-space: nowrap; transform: translateY(-50%) scaleX(0); transform-origin: right center; opacity: 0; pointer-events: none; transition: transform 160ms cubic-bezier(.2, .8, .2, 1), opacity 120ms; z-index: 2; }
|
|
3714
|
+
.tmo-actions-pop.tmo-open { transform: translateY(-50%) scaleX(1); opacity: 1; pointer-events: auto; }
|
|
3715
|
+
.tmo-actions-pop button { display: inline-flex; align-items: center; gap: 6px; height: 100%; padding: 0 14px; border: 0; background: none; color: inherit; font: inherit; font-size: calc(13.5px * var(--ta-font-scale)); cursor: pointer; -webkit-tap-highlight-color: transparent; }
|
|
3716
|
+
.tmo-actions-pop button:active { opacity: .7; }
|
|
3717
|
+
.tmo-actions-pop button.tmo-liked svg { fill: currentColor; color: #ff5b5b; }
|
|
3718
|
+
.tmo-actions-split { width: 1px; height: 18px; background: rgba(255, 255, 255, .16); }
|
|
3719
|
+
.tmo-marks { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 7px 10px; border-radius: 8px; background: var(--ta-raised); font-size: calc(12.5px * var(--ta-font-scale)); color: var(--ta-link); }
|
|
2685
3720
|
.tmo-marks-line { display: flex; align-items: baseline; gap: 6px; overflow-wrap: anywhere; }
|
|
2686
3721
|
.tmo-marks-line svg { flex: none; position: relative; top: 1px; color: var(--ta-muted); }
|
|
2687
3722
|
/* Words on a post, in the box of the likes */
|
|
@@ -2696,10 +3731,6 @@ var STYLE = `
|
|
|
2696
3731
|
.tmo-talk-text { white-space: pre-wrap; }
|
|
2697
3732
|
.tmo-talk-wait { margin-left: 6px; color: var(--ta-muted); font-size: calc(11.5px * var(--ta-font-scale)); }
|
|
2698
3733
|
.tmo-pending .tmo-talk-text { color: var(--ta-secondary); }
|
|
2699
|
-
.tmo-ask { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 9px; border: 0; border-radius: 8px; background: none; color: var(--ta-secondary); font: inherit; font-size: calc(12.5px * var(--ta-font-scale)); cursor: pointer; -webkit-tap-highlight-color: transparent; }
|
|
2700
|
-
.tmo-ask svg { color: var(--ta-yellow); }
|
|
2701
|
-
.tmo-ask:hover, .tmo-ask.tmo-on { background: var(--ta-hover); color: var(--ta-text); }
|
|
2702
|
-
.tmo-like.tmo-on-talk { color: var(--ta-text); background: var(--ta-hover); }
|
|
2703
3734
|
.tmo-talk-box { display: flex; flex-direction: column; gap: 2px; }
|
|
2704
3735
|
.tmo-talk-cancel { align-self: flex-end; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
|
|
2705
3736
|
.tmo-editor-check { gap: 7px; cursor: pointer; font-size: calc(13px * var(--ta-font-scale)); }
|
|
@@ -2761,7 +3792,7 @@ var STYLE = `
|
|
|
2761
3792
|
.tmo-mark { position: relative; display: inline-flex; }
|
|
2762
3793
|
.tmo-mark .ta-face { --ta-face-ring: var(--ta-list-cell, var(--ta-main)); }
|
|
2763
3794
|
.tmo-mark-dot { position: absolute; top: -2px; right: -2px; width: 9px; height: 9px; border-radius: 50%; background: var(--ta-yellow); box-shadow: 0 0 0 2px var(--ta-list-cell, var(--ta-main)); }
|
|
2764
|
-
@media (prefers-reduced-motion: reduce) { .tmo-image-wait { animation: none; } .tmo-
|
|
3795
|
+
@media (prefers-reduced-motion: reduce) { .tmo-image-wait { animation: none; } .tmo-actions-pop { transition: none; } }
|
|
2765
3796
|
`;
|
|
2766
3797
|
function injectStyle() {
|
|
2767
3798
|
const element = document.createElement("style");
|
|
@@ -2781,13 +3812,12 @@ function activate(pi2) {
|
|
|
2781
3812
|
render: MomentsPage,
|
|
2782
3813
|
head: MomentsHead,
|
|
2783
3814
|
mark: MomentsMark,
|
|
2784
|
-
discover: true,
|
|
2785
3815
|
group: "people",
|
|
2786
3816
|
order: 78
|
|
2787
3817
|
});
|
|
2788
3818
|
pi2.registerMessageRenderer(DRAFT_TYPE, DraftMessage);
|
|
2789
|
-
pi2.registerOpener((
|
|
2790
|
-
const target =
|
|
3819
|
+
pi2.registerOpener((link2) => {
|
|
3820
|
+
const target = link2.type === "url" ? MomentsBrief.parse(link2.url) : undefined;
|
|
2791
3821
|
if (!target) {
|
|
2792
3822
|
return false;
|
|
2793
3823
|
}
|