@celljs/ta-relay 4.20.0 → 4.22.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/esm/common/index.d.ts +2 -0
- package/esm/common/index.js +2 -0
- package/esm/common/relay-account-client.d.ts +4 -0
- package/esm/common/relay-account-client.js +13 -3
- package/esm/common/relay-account.d.ts +17 -2
- package/esm/common/relay-account.js +15 -6
- package/esm/common/relay-accounts.d.ts +2 -0
- package/esm/common/relay-accounts.js +16 -2
- package/esm/common/relay-group-invites.d.ts +6 -2
- package/esm/common/relay-group-invites.js +6 -5
- package/esm/common/relay-hub-charter.d.ts +78 -0
- package/esm/common/relay-hub-charter.js +152 -0
- package/esm/common/relay-hub-epochs.d.ts +43 -0
- package/esm/common/relay-hub-epochs.js +92 -0
- package/esm/common/relay-hub-util.d.ts +39 -7
- package/esm/common/relay-hub-util.js +46 -15
- package/esm/common/relay-hub.d.ts +13 -0
- package/esm/common/relay-hub.js +81 -18
- package/esm/common/relay-hubs-admins.d.ts +27 -0
- package/esm/common/relay-hubs-admins.js +91 -0
- package/esm/common/relay-hubs-connection.d.ts +19 -63
- package/esm/common/relay-hubs-connection.js +100 -87
- package/esm/common/relay-hubs-identity.d.ts +7 -1
- package/esm/common/relay-hubs-identity.js +28 -1
- package/esm/common/relay-hubs-live.d.ts +58 -0
- package/esm/common/relay-hubs-live.js +27 -0
- package/esm/common/relay-hubs-protocol.d.ts +10 -0
- package/esm/common/relay-hubs-util.d.ts +9 -0
- package/esm/common/relay-hubs-util.js +23 -1
- package/esm/common/relay-hubs.d.ts +15 -15
- package/esm/common/relay-hubs.js +76 -57
- package/esm/common/relay-protocol.d.ts +14 -3
- package/esm/common/relay-protocol.js +1 -1
- package/esm/common/relay-room-app.d.ts +106 -0
- package/esm/common/relay-room-app.js +171 -0
- package/esm/common/relay-room-chat.d.ts +6 -1
- package/esm/common/relay-room-chat.js +1 -0
- package/esm/guest/guest-i18n.d.ts +3 -0
- package/esm/guest/guest-i18n.js +12 -0
- package/esm/guest/guest-style.d.ts +1 -1
- package/esm/guest/guest-style.js +11 -0
- package/esm/guest/guest.js +76 -6
- package/esm/node/relay-server-accounts.d.ts +1 -1
- package/esm/node/relay-server-accounts.js +1 -1
- package/lib/common/index.d.ts +2 -0
- package/lib/common/index.js +2 -0
- package/lib/common/relay-account-client.d.ts +4 -0
- package/lib/common/relay-account-client.js +13 -3
- package/lib/common/relay-account.d.ts +17 -2
- package/lib/common/relay-account.js +15 -6
- package/lib/common/relay-accounts.d.ts +2 -0
- package/lib/common/relay-accounts.js +16 -2
- package/lib/common/relay-group-invites.d.ts +6 -2
- package/lib/common/relay-group-invites.js +6 -5
- package/lib/common/relay-hub-charter.d.ts +79 -0
- package/lib/common/relay-hub-charter.js +155 -0
- package/lib/common/relay-hub-epochs.d.ts +44 -0
- package/lib/common/relay-hub-epochs.js +95 -0
- package/lib/common/relay-hub-util.d.ts +39 -7
- package/lib/common/relay-hub-util.js +46 -15
- package/lib/common/relay-hub.d.ts +13 -0
- package/lib/common/relay-hub.js +81 -18
- package/lib/common/relay-hubs-admins.d.ts +28 -0
- package/lib/common/relay-hubs-admins.js +95 -0
- package/lib/common/relay-hubs-connection.d.ts +19 -63
- package/lib/common/relay-hubs-connection.js +106 -94
- package/lib/common/relay-hubs-identity.d.ts +7 -1
- package/lib/common/relay-hubs-identity.js +28 -1
- package/lib/common/relay-hubs-live.d.ts +59 -0
- package/lib/common/relay-hubs-live.js +31 -0
- package/lib/common/relay-hubs-protocol.d.ts +10 -0
- package/lib/common/relay-hubs-util.d.ts +9 -0
- package/lib/common/relay-hubs-util.js +23 -1
- package/lib/common/relay-hubs.d.ts +15 -15
- package/lib/common/relay-hubs.js +82 -63
- package/lib/common/relay-protocol.d.ts +14 -3
- package/lib/common/relay-protocol.js +1 -1
- package/lib/common/relay-room-app.d.ts +107 -0
- package/lib/common/relay-room-app.js +176 -0
- package/lib/common/relay-room-chat.d.ts +6 -1
- package/lib/common/relay-room-chat.js +1 -0
- package/lib/guest/guest-i18n.d.ts +3 -0
- package/lib/guest/guest-i18n.js +12 -0
- package/lib/guest/guest-style.d.ts +1 -1
- package/lib/guest/guest-style.js +11 -0
- package/lib/guest/guest.js +76 -6
- package/lib/node/relay-server-accounts.d.ts +1 -1
- package/lib/node/relay-server-accounts.js +1 -1
- package/package.json +3 -3
- package/viewer/join.html +17 -6
- package/viewer/room.html +26 -15
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RelayBoardUtil = exports.RELAY_BOARD_MAX = exports.RELAY_BOARD_KEY = exports.RoomPacer = exports.RoomAppUtil = exports.ROOM_APP_STALE_MS = exports.ROOM_AGENTS_KEY = void 0;
|
|
4
|
+
exports.roomSpeaker = roomSpeaker;
|
|
5
|
+
/**
|
|
6
|
+
* What every app of a group chat that listens and speaks there needs (docs/design/ta-feedback.md 1): what others said
|
|
7
|
+
* since it last read, paced; who speaks for the user (their double or an agent of theirs in the room); what others wrote
|
|
8
|
+
* kept as theirs when a model reads it; and a board of how things go that every member, and those in a browser, see.
|
|
9
|
+
* Feedback is one such app; a vote, a rota or a help desk would be others.
|
|
10
|
+
*/
|
|
11
|
+
/** Under `agents:<member>` of the state of a room, each member lists the agents of theirs they invited to it. */
|
|
12
|
+
exports.ROOM_AGENTS_KEY = 'agents:';
|
|
13
|
+
/** A line older than this when an app reads it is left: Ta was off for days. */
|
|
14
|
+
exports.ROOM_APP_STALE_MS = 3 * 24 * 60 * 60 * 1000;
|
|
15
|
+
const HOUR_MS = 60 * 60 * 1000;
|
|
16
|
+
var RoomAppUtil;
|
|
17
|
+
(function (RoomAppUtil) {
|
|
18
|
+
/** What others wrote, which a model reads inside tags: no tags of its own. */
|
|
19
|
+
function quote(text) {
|
|
20
|
+
return text.replace(/</g, '<').replace(/>/g, '>');
|
|
21
|
+
}
|
|
22
|
+
RoomAppUtil.quote = quote;
|
|
23
|
+
/**
|
|
24
|
+
* What others said to the room since `since`: not by the user, not too long ago, not to someone in particular (@ a
|
|
25
|
+
* person, a double or an agent: theirs to answer), not said by a double or an agent.
|
|
26
|
+
*/
|
|
27
|
+
function fresh(lines, self, since, now, staleMs = exports.ROOM_APP_STALE_MS) {
|
|
28
|
+
return lines.filter(line => { var _a; return line.from !== self && line.at > since && now - line.at < staleMs && !((_a = line.to) === null || _a === void 0 ? void 0 : _a.length) && !line.double && !line.agent; });
|
|
29
|
+
}
|
|
30
|
+
RoomAppUtil.fresh = fresh;
|
|
31
|
+
/** Whether one more fits in the hour before `now`. */
|
|
32
|
+
function within(times, now, most) {
|
|
33
|
+
return times.filter(at => now - at < HOUR_MS).length < most;
|
|
34
|
+
}
|
|
35
|
+
RoomAppUtil.within = within;
|
|
36
|
+
/** People named with @, each once. */
|
|
37
|
+
function mentions(names) {
|
|
38
|
+
return [...new Set(names)].map(name => `@${name}`).join(' ');
|
|
39
|
+
}
|
|
40
|
+
RoomAppUtil.mentions = mentions;
|
|
41
|
+
})(RoomAppUtil || (exports.RoomAppUtil = RoomAppUtil = {}));
|
|
42
|
+
/**
|
|
43
|
+
* Who speaks for the user in a room: the agent of theirs they chose, while it is in the room (as `agents:<member>` of
|
|
44
|
+
* its state lists it, written by them), else their double, named `doubleName`.
|
|
45
|
+
*/
|
|
46
|
+
async function roomSpeaker(rooms, room, self, agent, doubleName) {
|
|
47
|
+
if (agent) {
|
|
48
|
+
const key = `${exports.ROOM_AGENTS_KEY}${self}`;
|
|
49
|
+
const listed = (await rooms.getState(room, key).catch(() => ({})))[key];
|
|
50
|
+
const found = (listed === null || listed === void 0 ? void 0 : listed.by) === self && Array.isArray(listed.value) ? listed.value.find(each => (each === null || each === void 0 ? void 0 : each.id) === agent) : undefined;
|
|
51
|
+
if (found && typeof found.name === 'string') {
|
|
52
|
+
return { name: found.name, extra: { agent: { id: found.id, name: found.name } } };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return { name: doubleName, extra: { double: true } };
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Paces the work of an app on what is said in rooms: once the room is quiet for `settleMs` (a few lines read as one), one
|
|
59
|
+
* run at a time per room, and no more runs that did something than `hourly` in an hour (past it, again after `laterMs`).
|
|
60
|
+
* `run` says whether it did something (a turn of a model, a line said).
|
|
61
|
+
*/
|
|
62
|
+
class RoomPacer {
|
|
63
|
+
constructor(run, options) {
|
|
64
|
+
this.run = run;
|
|
65
|
+
this.options = options;
|
|
66
|
+
this.timers = new Map();
|
|
67
|
+
this.queues = new Map();
|
|
68
|
+
this.runs = new Map();
|
|
69
|
+
this.disposed = false;
|
|
70
|
+
}
|
|
71
|
+
/** Something was said in a room: it is read once it is quiet (`delay`, settleMs by default). */
|
|
72
|
+
heard(room, delay = this.options.settleMs) {
|
|
73
|
+
var _a, _b;
|
|
74
|
+
if (this.disposed) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
clearTimeout(this.timers.get(room));
|
|
78
|
+
const timer = setTimeout(() => {
|
|
79
|
+
var _a;
|
|
80
|
+
this.timers.delete(room);
|
|
81
|
+
const next = ((_a = this.queues.get(room)) !== null && _a !== void 0 ? _a : Promise.resolve())
|
|
82
|
+
.then(() => this.turn(room))
|
|
83
|
+
.catch(error => this.options.failed(error))
|
|
84
|
+
.finally(() => {
|
|
85
|
+
if (this.queues.get(room) === next) {
|
|
86
|
+
this.queues.delete(room);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
this.queues.set(room, next);
|
|
90
|
+
}, delay);
|
|
91
|
+
(_b = (_a = timer).unref) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
92
|
+
this.timers.set(room, timer);
|
|
93
|
+
}
|
|
94
|
+
/** What runs in a room now, done. */
|
|
95
|
+
idle(room) {
|
|
96
|
+
var _a;
|
|
97
|
+
return (_a = this.queues.get(room)) !== null && _a !== void 0 ? _a : Promise.resolve();
|
|
98
|
+
}
|
|
99
|
+
dispose() {
|
|
100
|
+
this.disposed = true;
|
|
101
|
+
for (const timer of this.timers.values()) {
|
|
102
|
+
clearTimeout(timer);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async turn(room) {
|
|
106
|
+
var _a;
|
|
107
|
+
if (this.disposed) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const now = this.options.now();
|
|
111
|
+
const times = ((_a = this.runs.get(room)) !== null && _a !== void 0 ? _a : []).filter(at => now - at < HOUR_MS);
|
|
112
|
+
if (!RoomAppUtil.within(times, now, this.options.hourly)) {
|
|
113
|
+
this.heard(room, this.options.laterMs);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (await this.run(room)) {
|
|
117
|
+
this.runs.set(room, [...times, now]);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.RoomPacer = RoomPacer;
|
|
122
|
+
/** Under `board:<app>:<member>` of the state of a room, its owner says how the things of an app go, for all in it. */
|
|
123
|
+
exports.RELAY_BOARD_KEY = 'board:';
|
|
124
|
+
/** Items of a board at most, the latest. */
|
|
125
|
+
exports.RELAY_BOARD_MAX = 30;
|
|
126
|
+
const STATES = ['doing', 'waiting', 'done', 'closed'];
|
|
127
|
+
var RelayBoardUtil;
|
|
128
|
+
(function (RelayBoardUtil) {
|
|
129
|
+
function key(app, member) {
|
|
130
|
+
return `${exports.RELAY_BOARD_KEY}${app}:${member}`;
|
|
131
|
+
}
|
|
132
|
+
RelayBoardUtil.key = key;
|
|
133
|
+
/** The board under a key of the state, if the owner of the room wrote it under their own name and it is well formed. */
|
|
134
|
+
function read(key, value, by, owner) {
|
|
135
|
+
if (!owner || by !== owner || !key.startsWith(exports.RELAY_BOARD_KEY) || !key.endsWith(`:${owner}`) || !value || typeof value !== 'object') {
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
const { title, items } = value;
|
|
139
|
+
if (typeof title !== 'string' || !Array.isArray(items)) {
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
title: cut(title, 40),
|
|
144
|
+
items: items
|
|
145
|
+
.filter(item => item &&
|
|
146
|
+
Number.isInteger(item.n) &&
|
|
147
|
+
typeof item.title === 'string' &&
|
|
148
|
+
STATES.includes(item.state) &&
|
|
149
|
+
typeof item.label === 'string' &&
|
|
150
|
+
typeof item.at === 'number')
|
|
151
|
+
.slice(-exports.RELAY_BOARD_MAX)
|
|
152
|
+
.map(item => ({
|
|
153
|
+
n: item.n,
|
|
154
|
+
title: cut(item.title, 80),
|
|
155
|
+
state: item.state,
|
|
156
|
+
label: cut(item.label, 30),
|
|
157
|
+
people: Array.isArray(item.people) ? item.people.filter((name) => typeof name === 'string').slice(0, 5) : [],
|
|
158
|
+
at: item.at,
|
|
159
|
+
})),
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
RelayBoardUtil.read = read;
|
|
163
|
+
/** How many are being done or wait, and how many are done: what a line over the chat says. */
|
|
164
|
+
function counts(board) {
|
|
165
|
+
return {
|
|
166
|
+
open: board.items.filter(item => item.state === 'doing' || item.state === 'waiting').length,
|
|
167
|
+
done: board.items.filter(item => item.state === 'done').length,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
RelayBoardUtil.counts = counts;
|
|
171
|
+
function cut(text, max) {
|
|
172
|
+
const one = text.replace(/\s+/g, ' ').trim();
|
|
173
|
+
return one.length > max ? `${one.slice(0, max - 1)}…` : one;
|
|
174
|
+
}
|
|
175
|
+
})(RelayBoardUtil || (exports.RelayBoardUtil = RelayBoardUtil = {}));
|
|
176
|
+
//# sourceMappingURL=relay-room-app.js.map
|
|
@@ -36,6 +36,11 @@ export interface RelayChatLine {
|
|
|
36
36
|
* by `<member>/<agent id>`, their member's Ta answering.
|
|
37
37
|
*/
|
|
38
38
|
to?: string[];
|
|
39
|
+
/**
|
|
40
|
+
* `to` names the members themselves with @, not their doubles (docs/design/ta-link.md 7): each one's Ta tells them, and
|
|
41
|
+
* answers for them as far as they set it to (their double at once, once they are away, a draft for them to send).
|
|
42
|
+
*/
|
|
43
|
+
person?: boolean;
|
|
39
44
|
/** The id of the line it answers. */
|
|
40
45
|
re?: string;
|
|
41
46
|
/**
|
|
@@ -50,7 +55,7 @@ export interface RelayChatAgent {
|
|
|
50
55
|
name: string;
|
|
51
56
|
}
|
|
52
57
|
/** What a line adds to its text: who said it and to whom (RelayRoomChat.say). */
|
|
53
|
-
export type RelayChatLineExtra = Pick<RelayChatLine, 'double' | 'agent' | 'to' | 're' | 'task'>;
|
|
58
|
+
export type RelayChatLineExtra = Pick<RelayChatLine, 'double' | 'agent' | 'to' | 'person' | 're' | 'task'>;
|
|
54
59
|
/** What is kept of a line: `from` is the key's. */
|
|
55
60
|
type StoredLine = Omit<RelayChatLine, 'from'>;
|
|
56
61
|
/** The keys of what is said, `chat:<member>:<n>`: each member writes only its own, so none can write as another. */
|
|
@@ -44,6 +44,7 @@ var RelayRoomChatUtil;
|
|
|
44
44
|
? { agent: { id: agent.id.slice(0, 64), name: agent.name.slice(0, 64) } }
|
|
45
45
|
: {}),
|
|
46
46
|
...(to.length ? { to } : {}),
|
|
47
|
+
...(line.person === true && to.length && line.double !== true && !line.agent ? { person: true } : {}),
|
|
47
48
|
...(typeof line.re === 'string' ? { re: line.re } : {}),
|
|
48
49
|
...(line.task === true && to.length ? { task: true } : {}),
|
|
49
50
|
};
|
package/lib/guest/guest-i18n.js
CHANGED
|
@@ -39,6 +39,9 @@ const zh = {
|
|
|
39
39
|
rename: '修改我的名字',
|
|
40
40
|
leave: '退出群聊',
|
|
41
41
|
leaveAsk: '退出「{title}」?退出后要有新的邀请才能再进来。',
|
|
42
|
+
boardOpen: '{n} 个处理中',
|
|
43
|
+
boardDone: '{n} 个已完成',
|
|
44
|
+
boardFrom: '来自 {names}',
|
|
42
45
|
game: '这个群里有 Ta 的游戏,装了 Ta 才能一起玩;在这里可以聊天。',
|
|
43
46
|
empty: '还没有人说话。只有群里的人能看到,中继保存的是密文。',
|
|
44
47
|
placeholder: '发消息',
|
|
@@ -84,6 +87,9 @@ const zhTw = {
|
|
|
84
87
|
rename: '修改我的名字',
|
|
85
88
|
leave: '退出群聊',
|
|
86
89
|
leaveAsk: '退出「{title}」?退出後要有新的邀請才能再進來。',
|
|
90
|
+
boardOpen: '{n} 個處理中',
|
|
91
|
+
boardDone: '{n} 個已完成',
|
|
92
|
+
boardFrom: '來自 {names}',
|
|
87
93
|
game: '這個群裡有 Ta 的遊戲,裝了 Ta 才能一起玩;在這裡可以聊天。',
|
|
88
94
|
empty: '還沒有人說話。只有群裡的人能看到,中繼儲存的是密文。',
|
|
89
95
|
placeholder: '發訊息',
|
|
@@ -129,6 +135,9 @@ const en = {
|
|
|
129
135
|
rename: 'Change my name',
|
|
130
136
|
leave: 'Leave the group chat',
|
|
131
137
|
leaveAsk: 'Leave “{title}”? You come back only by a new invitation.',
|
|
138
|
+
boardOpen: '{n} in progress',
|
|
139
|
+
boardDone: '{n} done',
|
|
140
|
+
boardFrom: 'From {names}',
|
|
132
141
|
game: 'This group chat plays a game of Ta, which takes Ta to play; here you chat.',
|
|
133
142
|
empty: 'Nothing said yet. Only those in the group chat read it: the relay keeps it sealed.',
|
|
134
143
|
placeholder: 'Message',
|
|
@@ -174,6 +183,9 @@ const ja = {
|
|
|
174
183
|
rename: '名前を変更',
|
|
175
184
|
leave: 'グループチャットを退出',
|
|
176
185
|
leaveAsk: '「{title}」を退出しますか?退出後は新しい招待でのみ戻ることができます。',
|
|
186
|
+
boardOpen: '対応中 {n} 件',
|
|
187
|
+
boardDone: '完了 {n} 件',
|
|
188
|
+
boardFrom: '{names} から',
|
|
177
189
|
game: 'このグループチャットには Ta のゲームがあり、プレイするには Ta が必要です。ここでチャットできます。',
|
|
178
190
|
empty: 'まだ誰も話していません。グループ内の人だけが見ることができ、リレーは暗号化されて保存されます。',
|
|
179
191
|
placeholder: 'メッセージ',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const GUEST_STYLE = "\n:root{color-scheme:light dark;--bg:#fff;--fg:#1f1f1f;--muted:#737373;--faint:#a3a3a3;--line:#ececec;--soft:#f5f5f5;--bubble:#f2f2f2;--mine:#e7f6ec;--mine-fg:#14532d;--code:#f6f6f6;--accent:#16a34a;--red:#dc2626;--radius:16px}\n@media (prefers-color-scheme:dark){:root{--bg:#191919;--fg:#ececec;--muted:#a3a3a3;--faint:#6b6b6b;--line:#2c2c2c;--soft:#222;--bubble:#262626;--mine:#1f3a2a;--mine-fg:#d1fae5;--code:#232323;--accent:#4ade80;--red:#f87171}}\n*{box-sizing:border-box}\nhtml,body{margin:0;height:100%;background:var(--bg);color:var(--fg);font:15px/1.6 -apple-system,BlinkMacSystemFont,\"Segoe UI\",\"PingFang SC\",\"Hiragino Sans GB\",\"Microsoft YaHei\",sans-serif;-webkit-font-smoothing:antialiased;overscroll-behavior:none}\nbutton{font:inherit;color:inherit;cursor:pointer;-webkit-tap-highlight-color:transparent}\n.app{display:flex;flex-direction:column;height:100dvh;max-width:760px;margin:0 auto}\n.top{flex:none;display:flex;align-items:center;gap:10px;min-height:54px;padding:8px 10px 8px 16px;padding-top:max(8px,env(safe-area-inset-top));border-bottom:1px solid var(--line);background:var(--bg)}\n.open-in-ta{flex:none;display:inline-flex;align-items:center;height:32px;padding:0 14px;border-radius:16px;background:var(--fg);color:var(--bg);font-size:13.5px;font-weight:600;text-decoration:none;white-space:nowrap;-webkit-tap-highlight-color:transparent}\n.open-in-ta:active{opacity:.8}\n.logo{width:26px;height:26px;border-radius:8px;background:var(--fg);color:var(--bg);display:grid;place-items:center;font-weight:700;font-size:13px;flex:none}\n.heading{flex:1;min-width:0;display:flex;flex-direction:column}\n.heading b{font-size:15px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.heading b span{color:var(--muted);font-weight:500;margin-left:4px}\n.heading small{font-size:11.5px;line-height:15px;color:var(--accent)}\n.heading small.quiet{color:var(--muted)}\n.icon{flex:none;width:36px;height:36px;display:grid;place-items:center;border:0;border-radius:10px;background:none;font-size:20px;line-height:1;color:var(--muted)}\n.icon:hover{background:var(--soft);color:var(--fg)}\n.center{flex:1;display:flex;flex-direction:column;justify-content:center;padding:24px 22px calc(32px + env(safe-area-inset-bottom));max-width:440px;width:100%;margin:0 auto;gap:14px}\n.card-face{align-self:center}\n.lead{margin:0;text-align:center;color:var(--muted);font-size:14px}\n.room-name{margin:0;text-align:center;font-size:21px;font-weight:600;line-height:1.35;word-break:break-word}\n.hint{margin:0;text-align:center;color:var(--muted);font-size:13px}\n.small{margin:0;color:var(--faint);font-size:12px;line-height:1.55;text-align:center}\nlabel.field{display:flex;flex-direction:column;gap:6px;font-size:13px;color:var(--muted);margin-top:6px}\ninput.text{font:inherit;font-size:16px;color:var(--fg);background:var(--soft);border:1px solid var(--line);border-radius:12px;padding:11px 13px;outline:none}\ninput.text:focus{border-color:var(--accent)}\n.primary{border:0;border-radius:12px;padding:12px 16px;background:#16a34a;color:#fff;font-weight:600;font-size:15px}\n.primary:disabled{opacity:.55;cursor:default}\n.plain{border:0;background:none;color:var(--muted);font-size:13.5px;padding:8px}\n.plain:hover{color:var(--fg)}\n.danger{color:var(--red)}\n.error{margin:0;text-align:center;color:var(--red);font-size:13px}\n.spin{width:22px;height:22px;border-radius:50%;border:2px solid var(--line);border-top-color:var(--accent);animation:spin .9s linear infinite;align-self:center}\n@keyframes spin{to{transform:rotate(360deg)}}\n.face{flex:none;display:inline-flex;position:relative;user-select:none}\n.face svg{display:block;overflow:visible}\n.ta-face-eyes{transform-box:fill-box;transform-origin:center;animation:blink 5.2s infinite}\n.face[data-face=\"1\"] .ta-face-eyes,.face[data-face=\"5\"] .ta-face-eyes,.face[data-face=\"9\"] .ta-face-eyes,.face[data-face=\"13\"] .ta-face-eyes{animation-delay:-1.7s}\n.face[data-face=\"2\"] .ta-face-eyes,.face[data-face=\"6\"] .ta-face-eyes,.face[data-face=\"10\"] .ta-face-eyes,.face[data-face=\"14\"] .ta-face-eyes{animation-delay:-3.1s}\n.face[data-face=\"3\"] .ta-face-eyes,.face[data-face=\"7\"] .ta-face-eyes,.face[data-face=\"11\"] .ta-face-eyes,.face[data-face=\"15\"] .ta-face-eyes{animation-delay:-4.4s}\n@keyframes blink{0%,94%,100%{transform:scaleY(1)}97%{transform:scaleY(.1)}}\n@media (prefers-reduced-motion:reduce){.face *{animation:none!important}}\n@media (prefers-color-scheme:dark){.face[data-face=\"11\"] .ta-face-body>g>circle{fill:#4a4a52}}\n.face i{position:absolute;right:-1px;bottom:-1px;width:28%;height:28%;min-width:7px;min-height:7px;border-radius:50%;border:2px solid var(--bg);background:var(--faint)}\n.face i.on{background:var(--accent)}\n.banner{flex:none;margin:10px 14px 0;padding:8px 12px;border-radius:12px;background:var(--soft);color:var(--muted);font-size:12.5px;line-height:1.5}\n.list{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:none;padding:10px 14px 12px;display:flex;flex-direction:column;gap:4px}\n.empty{margin:14vh auto 0;max-width:300px;text-align:center;color:var(--muted);font-size:13px}\n.when{align-self:center;margin:14px 0 6px;color:var(--faint);font-size:11.5px;font-variant-numeric:tabular-nums}\n.msg{display:flex;align-items:flex-start;gap:10px}\n.msg.first{margin-top:10px}\n.msg .slot{width:32px;flex:none;display:flex;justify-content:center}\n.msg .col{display:flex;flex-direction:column;align-items:flex-start;min-width:0;max-width:calc(100% - 84px)}\n.msg .who{display:flex;align-items:center;gap:6px;margin:0 2px 4px;color:var(--muted);font-size:12px;line-height:16px}\n.msg.double .bubble{border:1px dashed var(--soft);background:none}\n.bubble{min-width:0;max-width:100%;padding:8px 13px;border-radius:5px var(--radius) var(--radius) var(--radius);background:var(--bubble);word-break:break-word}\n.mine{display:flex;justify-content:flex-end;margin:6px 0 2px}\n.mine .bubble{max-width:78%;border-radius:var(--radius) 5px var(--radius) var(--radius);background:var(--mine);color:var(--mine-fg)}\n.bubble>:first-child{margin-top:0}.bubble>:last-child{margin-bottom:0}\n.bubble p{margin:0 0 .6em}\n.bubble ul,.bubble ol{margin:0 0 .6em;padding-left:1.3em}\n.bubble a{color:inherit;text-decoration:underline;text-underline-offset:2px}\n.bubble code{font:13px ui-monospace,SFMono-Regular,Menlo,monospace;background:var(--code);padding:1px 4px;border-radius:5px}\n.bubble pre{margin:0 0 .6em;padding:8px 10px;background:var(--code);border-radius:10px;overflow-x:auto}\n.bubble pre code{background:none;padding:0}\n.bubble blockquote{margin:0 0 .6em;padding-left:10px;border-left:3px solid var(--line);color:var(--muted)}\n.failed{align-self:flex-end;color:var(--red);font-size:12px;margin:2px 4px 0}\n.box{flex:none;display:flex;align-items:flex-end;gap:8px;padding:8px 12px calc(10px + env(safe-area-inset-bottom));border-top:1px solid var(--line);background:var(--bg)}\n.box textarea{flex:1;min-width:0;resize:none;max-height:160px;font:inherit;font-size:16px;line-height:1.45;color:var(--fg);background:var(--soft);border:1px solid var(--line);border-radius:18px;padding:8px 14px;outline:none}\n.box textarea:focus{border-color:var(--accent)}\n.box .primary{flex:none;border-radius:18px;padding:8px 16px;min-height:40px}\n.foot{flex:none;text-align:center;color:var(--faint);font-size:11px;padding:0 0 6px}\n.sheet{position:fixed;inset:0;z-index:5;display:flex;align-items:flex-end;justify-content:center;background:rgba(0,0,0,.32)}\n.sheet .panel{width:100%;max-width:520px;max-height:80dvh;overflow-y:auto;background:var(--bg);border-radius:18px 18px 0 0;padding:14px 8px calc(14px + env(safe-area-inset-bottom))}\n@media (min-width:700px){.sheet{align-items:center}.sheet .panel{border-radius:18px}}\n.panel h3{margin:4px 14px 8px;font-size:13px;font-weight:500;color:var(--muted)}\n.member{display:flex;align-items:center;gap:10px;padding:8px 12px}\n.member .nm{flex:1;min-width:0;display:flex;align-items:center;gap:6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.tag{flex:none;padding:0 6px;border-radius:6px;background:var(--soft);color:var(--muted);font-size:11px;line-height:18px}\n.member .st{font-size:12px;color:var(--muted)}\n.member .st.on{color:var(--accent)}\n.row{display:block;width:100%;text-align:left;border:0;background:none;padding:12px 14px;border-radius:12px;font-size:14.5px}\n.row:hover{background:var(--soft)}\n.sep{height:1px;margin:6px 12px;background:var(--line)}\n";
|
|
1
|
+
export declare const GUEST_STYLE = "\n:root{color-scheme:light dark;--bg:#fff;--fg:#1f1f1f;--muted:#737373;--faint:#a3a3a3;--line:#ececec;--soft:#f5f5f5;--bubble:#f2f2f2;--mine:#e7f6ec;--mine-fg:#14532d;--code:#f6f6f6;--accent:#16a34a;--red:#dc2626;--radius:16px}\n@media (prefers-color-scheme:dark){:root{--bg:#191919;--fg:#ececec;--muted:#a3a3a3;--faint:#6b6b6b;--line:#2c2c2c;--soft:#222;--bubble:#262626;--mine:#1f3a2a;--mine-fg:#d1fae5;--code:#232323;--accent:#4ade80;--red:#f87171}}\n*{box-sizing:border-box}\nhtml,body{margin:0;height:100%;background:var(--bg);color:var(--fg);font:15px/1.6 -apple-system,BlinkMacSystemFont,\"Segoe UI\",\"PingFang SC\",\"Hiragino Sans GB\",\"Microsoft YaHei\",sans-serif;-webkit-font-smoothing:antialiased;overscroll-behavior:none}\nbutton{font:inherit;color:inherit;cursor:pointer;-webkit-tap-highlight-color:transparent}\n.app{display:flex;flex-direction:column;height:100dvh;max-width:760px;margin:0 auto}\n.top{flex:none;display:flex;align-items:center;gap:10px;min-height:54px;padding:8px 10px 8px 16px;padding-top:max(8px,env(safe-area-inset-top));border-bottom:1px solid var(--line);background:var(--bg)}\n.open-in-ta{flex:none;display:inline-flex;align-items:center;height:32px;padding:0 14px;border-radius:16px;background:var(--fg);color:var(--bg);font-size:13.5px;font-weight:600;text-decoration:none;white-space:nowrap;-webkit-tap-highlight-color:transparent}\n.open-in-ta:active{opacity:.8}\n.logo{width:26px;height:26px;border-radius:8px;background:var(--fg);color:var(--bg);display:grid;place-items:center;font-weight:700;font-size:13px;flex:none}\n.heading{flex:1;min-width:0;display:flex;flex-direction:column}\n.heading b{font-size:15px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.heading b span{color:var(--muted);font-weight:500;margin-left:4px}\n.heading small{font-size:11.5px;line-height:15px;color:var(--accent)}\n.heading small.quiet{color:var(--muted)}\n.icon{flex:none;width:36px;height:36px;display:grid;place-items:center;border:0;border-radius:10px;background:none;font-size:20px;line-height:1;color:var(--muted)}\n.icon:hover{background:var(--soft);color:var(--fg)}\n.center{flex:1;display:flex;flex-direction:column;justify-content:center;padding:24px 22px calc(32px + env(safe-area-inset-bottom));max-width:440px;width:100%;margin:0 auto;gap:14px}\n.card-face{align-self:center}\n.lead{margin:0;text-align:center;color:var(--muted);font-size:14px}\n.room-name{margin:0;text-align:center;font-size:21px;font-weight:600;line-height:1.35;word-break:break-word}\n.hint{margin:0;text-align:center;color:var(--muted);font-size:13px}\n.small{margin:0;color:var(--faint);font-size:12px;line-height:1.55;text-align:center}\nlabel.field{display:flex;flex-direction:column;gap:6px;font-size:13px;color:var(--muted);margin-top:6px}\ninput.text{font:inherit;font-size:16px;color:var(--fg);background:var(--soft);border:1px solid var(--line);border-radius:12px;padding:11px 13px;outline:none}\ninput.text:focus{border-color:var(--accent)}\n.primary{border:0;border-radius:12px;padding:12px 16px;background:#16a34a;color:#fff;font-weight:600;font-size:15px}\n.primary:disabled{opacity:.55;cursor:default}\n.plain{border:0;background:none;color:var(--muted);font-size:13.5px;padding:8px}\n.plain:hover{color:var(--fg)}\n.danger{color:var(--red)}\n.error{margin:0;text-align:center;color:var(--red);font-size:13px}\n.spin{width:22px;height:22px;border-radius:50%;border:2px solid var(--line);border-top-color:var(--accent);animation:spin .9s linear infinite;align-self:center}\n@keyframes spin{to{transform:rotate(360deg)}}\n.face{flex:none;display:inline-flex;position:relative;user-select:none}\n.face svg{display:block;overflow:visible}\n.ta-face-eyes{transform-box:fill-box;transform-origin:center;animation:blink 5.2s infinite}\n.face[data-face=\"1\"] .ta-face-eyes,.face[data-face=\"5\"] .ta-face-eyes,.face[data-face=\"9\"] .ta-face-eyes,.face[data-face=\"13\"] .ta-face-eyes{animation-delay:-1.7s}\n.face[data-face=\"2\"] .ta-face-eyes,.face[data-face=\"6\"] .ta-face-eyes,.face[data-face=\"10\"] .ta-face-eyes,.face[data-face=\"14\"] .ta-face-eyes{animation-delay:-3.1s}\n.face[data-face=\"3\"] .ta-face-eyes,.face[data-face=\"7\"] .ta-face-eyes,.face[data-face=\"11\"] .ta-face-eyes,.face[data-face=\"15\"] .ta-face-eyes{animation-delay:-4.4s}\n@keyframes blink{0%,94%,100%{transform:scaleY(1)}97%{transform:scaleY(.1)}}\n@media (prefers-reduced-motion:reduce){.face *{animation:none!important}}\n@media (prefers-color-scheme:dark){.face[data-face=\"11\"] .ta-face-body>g>circle{fill:#4a4a52}}\n.face i{position:absolute;right:-1px;bottom:-1px;width:28%;height:28%;min-width:7px;min-height:7px;border-radius:50%;border:2px solid var(--bg);background:var(--faint)}\n.face i.on{background:var(--accent)}\n.boards{flex:none;display:flex;gap:6px;overflow-x:auto;margin:10px 14px 0;scrollbar-width:none}\n.boards::-webkit-scrollbar{display:none}\n.board{flex:none;display:flex;align-items:center;gap:6px;border:0;padding:7px 12px;border-radius:12px;background:var(--soft);color:var(--fg);font-size:12.5px;line-height:1.4;white-space:nowrap}\n.board .dot{width:6px;height:6px;border-radius:50%;background:var(--accent)}\n.item{display:flex;flex-direction:column;gap:2px;padding:9px 14px}\n.item .hd{display:flex;align-items:center;gap:8px;font-size:14.5px}\n.item .n{color:var(--muted);font-variant-numeric:tabular-nums}\n.item .tt{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.item .lb{flex:none;font-size:12px;color:var(--muted)}\n.item .lb.doing,.item .lb.waiting{color:var(--accent)}\n.item .by{font-size:12px;color:var(--muted);padding-left:2px}\n.banner{flex:none;margin:10px 14px 0;padding:8px 12px;border-radius:12px;background:var(--soft);color:var(--muted);font-size:12.5px;line-height:1.5}\n.list{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:none;padding:10px 14px 12px;display:flex;flex-direction:column;gap:4px}\n.empty{margin:14vh auto 0;max-width:300px;text-align:center;color:var(--muted);font-size:13px}\n.when{align-self:center;margin:14px 0 6px;color:var(--faint);font-size:11.5px;font-variant-numeric:tabular-nums}\n.msg{display:flex;align-items:flex-start;gap:10px}\n.msg.first{margin-top:10px}\n.msg .slot{width:32px;flex:none;display:flex;justify-content:center}\n.msg .col{display:flex;flex-direction:column;align-items:flex-start;min-width:0;max-width:calc(100% - 84px)}\n.msg .who{display:flex;align-items:center;gap:6px;margin:0 2px 4px;color:var(--muted);font-size:12px;line-height:16px}\n.msg.double .bubble{border:1px dashed var(--soft);background:none}\n.bubble{min-width:0;max-width:100%;padding:8px 13px;border-radius:5px var(--radius) var(--radius) var(--radius);background:var(--bubble);word-break:break-word}\n.mine{display:flex;justify-content:flex-end;margin:6px 0 2px}\n.mine .bubble{max-width:78%;border-radius:var(--radius) 5px var(--radius) var(--radius);background:var(--mine);color:var(--mine-fg)}\n.bubble>:first-child{margin-top:0}.bubble>:last-child{margin-bottom:0}\n.bubble p{margin:0 0 .6em}\n.bubble ul,.bubble ol{margin:0 0 .6em;padding-left:1.3em}\n.bubble a{color:inherit;text-decoration:underline;text-underline-offset:2px}\n.bubble code{font:13px ui-monospace,SFMono-Regular,Menlo,monospace;background:var(--code);padding:1px 4px;border-radius:5px}\n.bubble pre{margin:0 0 .6em;padding:8px 10px;background:var(--code);border-radius:10px;overflow-x:auto}\n.bubble pre code{background:none;padding:0}\n.bubble blockquote{margin:0 0 .6em;padding-left:10px;border-left:3px solid var(--line);color:var(--muted)}\n.failed{align-self:flex-end;color:var(--red);font-size:12px;margin:2px 4px 0}\n.box{flex:none;display:flex;align-items:flex-end;gap:8px;padding:8px 12px calc(10px + env(safe-area-inset-bottom));border-top:1px solid var(--line);background:var(--bg)}\n.box textarea{flex:1;min-width:0;resize:none;max-height:160px;font:inherit;font-size:16px;line-height:1.45;color:var(--fg);background:var(--soft);border:1px solid var(--line);border-radius:18px;padding:8px 14px;outline:none}\n.box textarea:focus{border-color:var(--accent)}\n.box .primary{flex:none;border-radius:18px;padding:8px 16px;min-height:40px}\n.foot{flex:none;text-align:center;color:var(--faint);font-size:11px;padding:0 0 6px}\n.sheet{position:fixed;inset:0;z-index:5;display:flex;align-items:flex-end;justify-content:center;background:rgba(0,0,0,.32)}\n.sheet .panel{width:100%;max-width:520px;max-height:80dvh;overflow-y:auto;background:var(--bg);border-radius:18px 18px 0 0;padding:14px 8px calc(14px + env(safe-area-inset-bottom))}\n@media (min-width:700px){.sheet{align-items:center}.sheet .panel{border-radius:18px}}\n.panel h3{margin:4px 14px 8px;font-size:13px;font-weight:500;color:var(--muted)}\n.member{display:flex;align-items:center;gap:10px;padding:8px 12px}\n.member .nm{flex:1;min-width:0;display:flex;align-items:center;gap:6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.tag{flex:none;padding:0 6px;border-radius:6px;background:var(--soft);color:var(--muted);font-size:11px;line-height:18px}\n.member .st{font-size:12px;color:var(--muted)}\n.member .st.on{color:var(--accent)}\n.row{display:block;width:100%;text-align:left;border:0;background:none;padding:12px 14px;border-radius:12px;font-size:14.5px}\n.row:hover{background:var(--soft)}\n.sep{height:1px;margin:6px 12px;background:var(--line)}\n";
|
|
2
2
|
//# sourceMappingURL=guest-style.d.ts.map
|
package/lib/guest/guest-style.js
CHANGED
|
@@ -47,6 +47,17 @@ input.text:focus{border-color:var(--accent)}
|
|
|
47
47
|
@media (prefers-color-scheme:dark){.face[data-face="11"] .ta-face-body>g>circle{fill:#4a4a52}}
|
|
48
48
|
.face i{position:absolute;right:-1px;bottom:-1px;width:28%;height:28%;min-width:7px;min-height:7px;border-radius:50%;border:2px solid var(--bg);background:var(--faint)}
|
|
49
49
|
.face i.on{background:var(--accent)}
|
|
50
|
+
.boards{flex:none;display:flex;gap:6px;overflow-x:auto;margin:10px 14px 0;scrollbar-width:none}
|
|
51
|
+
.boards::-webkit-scrollbar{display:none}
|
|
52
|
+
.board{flex:none;display:flex;align-items:center;gap:6px;border:0;padding:7px 12px;border-radius:12px;background:var(--soft);color:var(--fg);font-size:12.5px;line-height:1.4;white-space:nowrap}
|
|
53
|
+
.board .dot{width:6px;height:6px;border-radius:50%;background:var(--accent)}
|
|
54
|
+
.item{display:flex;flex-direction:column;gap:2px;padding:9px 14px}
|
|
55
|
+
.item .hd{display:flex;align-items:center;gap:8px;font-size:14.5px}
|
|
56
|
+
.item .n{color:var(--muted);font-variant-numeric:tabular-nums}
|
|
57
|
+
.item .tt{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
58
|
+
.item .lb{flex:none;font-size:12px;color:var(--muted)}
|
|
59
|
+
.item .lb.doing,.item .lb.waiting{color:var(--accent)}
|
|
60
|
+
.item .by{font-size:12px;color:var(--muted);padding-left:2px}
|
|
50
61
|
.banner{flex:none;margin:10px 14px 0;padding:8px 12px;border-radius:12px;background:var(--soft);color:var(--muted);font-size:12.5px;line-height:1.5}
|
|
51
62
|
.list{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:none;padding:10px 14px 12px;display:flex;flex-direction:column;gap:4px}
|
|
52
63
|
.empty{margin:14vh auto 0;max-width:300px;text-align:center;color:var(--muted);font-size:13px}
|
package/lib/guest/guest.js
CHANGED
|
@@ -4,6 +4,7 @@ const relay_faces_1 = require("../common/relay-faces");
|
|
|
4
4
|
const relay_hub_util_1 = require("../common/relay-hub-util");
|
|
5
5
|
const relay_hubs_1 = require("../common/relay-hubs");
|
|
6
6
|
const relay_open_in_ta_1 = require("../common/relay-open-in-ta");
|
|
7
|
+
const relay_room_app_1 = require("../common/relay-room-app");
|
|
7
8
|
const relay_room_chat_1 = require("../common/relay-room-chat");
|
|
8
9
|
const viewer_markdown_1 = require("../viewer/viewer-markdown");
|
|
9
10
|
const guest_i18n_1 = require("./guest-i18n");
|
|
@@ -95,12 +96,17 @@ class GuestPage {
|
|
|
95
96
|
this.screen = '';
|
|
96
97
|
this.stuck = true;
|
|
97
98
|
this.connected = false;
|
|
99
|
+
/** The boards of the apps of the room, by key, as its owner writes them (RelayRoomBoard): what a guest sees of them. */
|
|
100
|
+
this.boards = new Map();
|
|
98
101
|
}
|
|
99
102
|
start() {
|
|
100
103
|
this.hubs.onEvent(event => {
|
|
101
104
|
var _a;
|
|
102
105
|
if (event.type === 'state' && event.room === this.link.room) {
|
|
103
106
|
(_a = this.chat) === null || _a === void 0 ? void 0 : _a.heard(event.key, event);
|
|
107
|
+
if (event.key.startsWith(relay_room_app_1.RELAY_BOARD_KEY)) {
|
|
108
|
+
this.heardBoard(event.key, event.value, event.by);
|
|
109
|
+
}
|
|
104
110
|
}
|
|
105
111
|
else if (event.type === 'rooms') {
|
|
106
112
|
this.update();
|
|
@@ -263,7 +269,17 @@ class GuestPage {
|
|
|
263
269
|
}
|
|
264
270
|
});
|
|
265
271
|
const banner = room.view ? [div('banner', t('game'))] : [];
|
|
266
|
-
this.
|
|
272
|
+
this.boardBar = div('boards');
|
|
273
|
+
this.boardBar.hidden = true;
|
|
274
|
+
this.frame(top, ...banner, this.boardBar, list, div('box', field, send), div('foot', t('secure')));
|
|
275
|
+
void this.hubs
|
|
276
|
+
.getState(room.id, relay_room_app_1.RELAY_BOARD_KEY)
|
|
277
|
+
.then(state => {
|
|
278
|
+
for (const [key, value] of Object.entries(state)) {
|
|
279
|
+
this.heardBoard(key, value.value, value.by);
|
|
280
|
+
}
|
|
281
|
+
})
|
|
282
|
+
.catch(() => undefined);
|
|
267
283
|
this.refresh(room);
|
|
268
284
|
this.draw();
|
|
269
285
|
}
|
|
@@ -281,7 +297,7 @@ class GuestPage {
|
|
|
281
297
|
const sub = el('small', !room.connected ? t('connecting') : online ? t('online', { n: online }) : t('nobody'));
|
|
282
298
|
sub.className = room.connected && online ? '' : 'quiet';
|
|
283
299
|
(_b = this.heading) === null || _b === void 0 ? void 0 : _b.replaceChildren(title, sub);
|
|
284
|
-
if (this.sheet) {
|
|
300
|
+
if (this.sheet && this.sheetOf === 'members') {
|
|
285
301
|
this.members();
|
|
286
302
|
}
|
|
287
303
|
}
|
|
@@ -296,10 +312,8 @@ class GuestPage {
|
|
|
296
312
|
const self = (_a = room.members.find(member => member.self)) === null || _a === void 0 ? void 0 : _a.member;
|
|
297
313
|
const personOf = (line) => { var _a; var _b; return (_b = (_a = room.members.find(member => member.member === line.from)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : line.name; };
|
|
298
314
|
// What a double says (docs/design/ta-link.md 4) is its own: `X's double`, a guest having none; an agent's, its name.
|
|
299
|
-
const nameOf = (line) => (line.agent ? line.agent.name : line.double ? t('doubleOf'
|
|
300
|
-
const tagOf = (line) => [line.agent ? t('agentOf'
|
|
301
|
-
.filter(Boolean)
|
|
302
|
-
.join(' · ');
|
|
315
|
+
const nameOf = (line) => (line.agent ? line.agent.name : line.double ? t('doubleOf', { name: personOf(line) }) : personOf(line));
|
|
316
|
+
const tagOf = (line) => [line.agent ? t('agentOf', { name: personOf(line) }) : line.double ? t('double') : '', line.task ? t('task') : ''].filter(Boolean).join(' · ');
|
|
303
317
|
const speaker = (line) => { var _a; var _b; return `${line.from}:${line.double ? 'd' : ''}:${(_b = (_a = line.agent) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : ''}`; };
|
|
304
318
|
const nodes = [];
|
|
305
319
|
if (!lines.length) {
|
|
@@ -330,6 +344,61 @@ class GuestPage {
|
|
|
330
344
|
list.scrollTop = list.scrollHeight;
|
|
331
345
|
}
|
|
332
346
|
}
|
|
347
|
+
/** A board of an app of the room changed: kept if its owner wrote it, and drawn over the chat. */
|
|
348
|
+
heardBoard(key, value, by) {
|
|
349
|
+
var _a, _b;
|
|
350
|
+
const owner = (_b = (_a = this.room()) === null || _a === void 0 ? void 0 : _a.members.find(member => member.owner)) === null || _b === void 0 ? void 0 : _b.member;
|
|
351
|
+
const board = relay_room_app_1.RelayBoardUtil.read(key, value, by, owner);
|
|
352
|
+
if (board === null || board === void 0 ? void 0 : board.items.length) {
|
|
353
|
+
this.boards.set(key, board);
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
this.boards.delete(key);
|
|
357
|
+
}
|
|
358
|
+
this.drawBoards();
|
|
359
|
+
}
|
|
360
|
+
/** A chip for each board, how many are in progress and done; a tap opens its items. */
|
|
361
|
+
drawBoards() {
|
|
362
|
+
const bar = this.boardBar;
|
|
363
|
+
if (!bar) {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
const chips = [...this.boards].map(([key, board]) => {
|
|
367
|
+
const { open, done } = relay_room_app_1.RelayBoardUtil.counts(board);
|
|
368
|
+
const parts = [open ? t('boardOpen', { n: open }) : '', done ? t('boardDone', { n: done }) : ''].filter(Boolean);
|
|
369
|
+
const chip = button('board', [board.title, ...parts].join(' · '), () => this.showBoard(key));
|
|
370
|
+
if (open) {
|
|
371
|
+
chip.prepend(Object.assign(el('span'), { className: 'dot' }));
|
|
372
|
+
}
|
|
373
|
+
return chip;
|
|
374
|
+
});
|
|
375
|
+
bar.replaceChildren(...chips);
|
|
376
|
+
bar.hidden = !chips.length;
|
|
377
|
+
}
|
|
378
|
+
showBoard(key) {
|
|
379
|
+
var _a;
|
|
380
|
+
const board = this.boards.get(key);
|
|
381
|
+
if (!board) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
const panel = div('panel', el('h3', board.title));
|
|
385
|
+
for (const item of [...board.items].reverse()) {
|
|
386
|
+
const label = Object.assign(el('span', item.label), { className: `lb ${item.state}` });
|
|
387
|
+
const head = div('hd', Object.assign(el('span', `#${item.n}`), { className: 'n' }), Object.assign(el('span', item.title), { className: 'tt' }), label);
|
|
388
|
+
panel.append(div('item', head, ...(item.people.length ? [div('by', t('boardFrom', { names: item.people.join('、') }))] : [])));
|
|
389
|
+
}
|
|
390
|
+
panel.append(div('sep'), button('row', t('close'), () => this.closeSheet()));
|
|
391
|
+
const sheet = div('sheet', panel);
|
|
392
|
+
sheet.addEventListener('click', event => {
|
|
393
|
+
if (event.target === sheet) {
|
|
394
|
+
this.closeSheet();
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
(_a = this.sheet) === null || _a === void 0 ? void 0 : _a.remove();
|
|
398
|
+
document.body.append(sheet);
|
|
399
|
+
this.sheet = sheet;
|
|
400
|
+
this.sheetOf = 'board';
|
|
401
|
+
}
|
|
333
402
|
/** The members, over the chat: who is online, and the user's name and way out. */
|
|
334
403
|
members() {
|
|
335
404
|
var _a;
|
|
@@ -337,6 +406,7 @@ class GuestPage {
|
|
|
337
406
|
if (!room) {
|
|
338
407
|
return;
|
|
339
408
|
}
|
|
409
|
+
this.sheetOf = 'members';
|
|
340
410
|
const panel = div('panel', Object.assign(el('h3', `${t('members')} (${room.members.length})`)));
|
|
341
411
|
for (const member of room.members) {
|
|
342
412
|
const tags = [member.self ? t('you') : '', member.owner ? t('owner') : '', member.guest ? t('guest') : ''].filter(Boolean);
|
|
@@ -7,7 +7,7 @@ import { type RelayAccountProvider, RelayAccounts, type RelayAccountsOptions } f
|
|
|
7
7
|
export declare class RelayServerAccounts {
|
|
8
8
|
protected readonly accounts: RelayAccounts;
|
|
9
9
|
/** `authenticate`: a gateway's, whose sign-in gives the tokens (RelayAccountsOptions.authenticate). */
|
|
10
|
-
constructor(data: string | undefined, options?: Pick<RelayAccountsOptions, 'authenticate'> & {
|
|
10
|
+
constructor(data: string | undefined, options?: Pick<RelayAccountsOptions, 'authenticate' | 'issue'> & {
|
|
11
11
|
providers?: RelayAccountProvider[];
|
|
12
12
|
});
|
|
13
13
|
/** Answers a request of RELAY_ACCOUNT_PATH; never throws, an unhandled rejection would end the relay. */
|
|
@@ -18,7 +18,7 @@ class RelayServerAccounts {
|
|
|
18
18
|
var _a;
|
|
19
19
|
const books = new relay_accounts_1.RelayAccountBooks(account => data ? new relay_file_storage_1.FileRelayStorage((0, node_path_1.join)(data, 'accounts', relay_bytes_1.RelayBytes.toBase64(new TextEncoder().encode(account)))) : new relay_memory_storage_1.MemoryHubStorage());
|
|
20
20
|
const providers = (_a = options.providers) !== null && _a !== void 0 ? _a : (options.authenticate ? [] : [new relay_accounts_1.RelayGitHubAccounts()]);
|
|
21
|
-
this.accounts = new relay_accounts_1.RelayAccounts({ book: account => books.book(account), providers, authenticate: options.authenticate });
|
|
21
|
+
this.accounts = new relay_accounts_1.RelayAccounts({ book: account => books.book(account), providers, authenticate: options.authenticate, issue: options.issue });
|
|
22
22
|
}
|
|
23
23
|
/** Answers a request of RELAY_ACCOUNT_PATH; never throws, an unhandled rejection would end the relay. */
|
|
24
24
|
serve(request, response) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-relay",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.22.0",
|
|
4
4
|
"description": "Ta from anywhere: a relay that only forwards, and end-to-end encryption between a paired device and ta serve",
|
|
5
5
|
"homepage": "https://github.com/cellbang/ta",
|
|
6
6
|
"bugs": {
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@celljs/rpc": "4.
|
|
34
|
-
"@celljs/ta-protocol": "4.
|
|
33
|
+
"@celljs/rpc": "4.22.0",
|
|
34
|
+
"@celljs/ta-protocol": "4.22.0"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|