@celljs/ta-relay 4.21.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.
@@ -24,6 +24,7 @@ export * from './relay-info.js';
24
24
  export * from './relay-pairing.js';
25
25
  export * from './relay-protocol.js';
26
26
  export * from './relay-room.js';
27
+ export * from './relay-room-app.js';
27
28
  export * from './relay-room-chat.js';
28
29
  export * from './relay-share.js';
29
30
  export * from './relay-socket.js';
@@ -24,6 +24,7 @@ export * from './relay-info.js';
24
24
  export * from './relay-pairing.js';
25
25
  export * from './relay-protocol.js';
26
26
  export * from './relay-room.js';
27
+ export * from './relay-room-app.js';
27
28
  export * from './relay-room-chat.js';
28
29
  export * from './relay-share.js';
29
30
  export * from './relay-socket.js';
@@ -7,9 +7,13 @@ export interface RelayHubAdmin {
7
7
  }
8
8
  /**
9
9
  * The rules of a room, its owner's for all (docs/design/ta-link.md 8): `approve`, friends invited ask as anyone else;
10
- * the others are the packages' that read them (ta-rooms: `agents`, `doubles`, `tasks`), each false to forbid.
10
+ * `guests` (RELAY_GUESTS_RULE), those asking from a browser come in without asking; the others are the packages' that
11
+ * read them (ta-rooms: `agents`, `doubles`, `tasks`), each false to forbid.
11
12
  */
12
13
  export type RelayHubRules = Record<string, boolean>;
14
+ /** The rule that lets those asking from a browser in without asking (they only chat), as many an hour at most. */
15
+ export declare const RELAY_GUESTS_RULE = "guests";
16
+ export declare const RELAY_GUESTS_PER_HOUR = 30;
13
17
  /** What the owner of a room signs for all: who its admins are, its rules, how many it lets in. `v` grows with each change. */
14
18
  export interface RelayHubCharterBody {
15
19
  room: string;
@@ -1,5 +1,8 @@
1
1
  import { RelayHubUtil } from './relay-hub-util.js';
2
2
  import { RelayIdentityUtil, RelayKeys } from './relay-identity.js';
3
+ /** The rule that lets those asking from a browser in without asking (they only chat), as many an hour at most. */
4
+ export const RELAY_GUESTS_RULE = 'guests';
5
+ export const RELAY_GUESTS_PER_HOUR = 30;
3
6
  /** Admins of a room at most. */
4
7
  export const RELAY_HUB_MAX_ADMINS = 8;
5
8
  const MAX_RULES = 16;
@@ -110,6 +110,9 @@ export declare class RelayHubs extends RelayHubsAdmins {
110
110
  answerFriendShare(id: string, keep: boolean): void;
111
111
  protected friendIds(): Set<string>;
112
112
  protected heardAsk(live: Live, ask: RelayHubAskBody): void;
113
+ protected readonly guestsIn: Map<string, number[]>;
114
+ /** One more guest let in without asking fits in the hour of a room (RELAY_GUESTS_PER_HOUR): counted. */
115
+ protected guestsLetIn(room: string): boolean;
113
116
  protected foreignSet(live: Live, key: string): void;
114
117
  protected heardMembers(members: RelayPublicIdentity[]): void;
115
118
  protected offered(live: Live, from: RelayPublicIdentity, link: string): void;
@@ -1,7 +1,7 @@
1
1
  import { RelayFriendSends } from './relay-friend-sends.js';
2
2
  import { RELAY_FRIENDS_KIND, RelayFriends, RelayFriendsUtil } from './relay-friends.js';
3
3
  import { RelayGroupInvites } from './relay-group-invites.js';
4
- import { RelayHubCharterUtil } from './relay-hub-charter.js';
4
+ import { RELAY_GUESTS_PER_HOUR, RELAY_GUESTS_RULE, RelayHubCharterUtil } from './relay-hub-charter.js';
5
5
  import { RelayHubUtil } from './relay-hub-util.js';
6
6
  import { RelayHubsAdmins } from './relay-hubs-admins.js';
7
7
  import { Live, OPEN, READY_MS } from './relay-hubs-live.js';
@@ -62,6 +62,7 @@ export class RelayHubs extends RelayHubsAdmins {
62
62
  getState: (room, prefix) => this.getState(room, prefix),
63
63
  setState: (room, key, value) => this.setState(room, key, value),
64
64
  }, this.options.store);
65
+ this.guestsIn = new Map();
65
66
  }
66
67
  /** Connects to the rooms of rooms.json, and keeps connected. */
67
68
  start() {
@@ -443,7 +444,7 @@ export class RelayHubs extends RelayHubsAdmins {
443
444
  return this.book.ids();
444
445
  }
445
446
  heardAsk(live, ask) {
446
- var _a;
447
+ var _a, _b;
447
448
  if (this.isFriends(live)) {
448
449
  this.book.asked(ask);
449
450
  }
@@ -451,10 +452,25 @@ export class RelayHubs extends RelayHubsAdmins {
451
452
  // A friend the user invited: in at once, as the user chose it; asked as any other should that fail.
452
453
  void this.answer(live.record.id, ask.member, true).then(() => this.groups.admitted(live.record, ask.id), () => super.heardAsk(live, ask));
453
454
  }
455
+ else if (ask.guest && ((_b = live.charter) === null || _b === void 0 ? void 0 : _b.rules[RELAY_GUESTS_RULE]) && this.manages(live) && this.guestsLetIn(live.record.id)) {
456
+ // The owner lets those of a browser in without asking (they only chat), so many an hour; asked past it, or should that fail.
457
+ void this.answer(live.record.id, ask.member, true).catch(() => super.heardAsk(live, ask));
458
+ }
454
459
  else {
455
460
  super.heardAsk(live, ask);
456
461
  }
457
462
  }
463
+ /** One more guest let in without asking fits in the hour of a room (RELAY_GUESTS_PER_HOUR): counted. */
464
+ guestsLetIn(room) {
465
+ var _a;
466
+ const now = Date.now();
467
+ const times = ((_a = this.guestsIn.get(room)) !== null && _a !== void 0 ? _a : []).filter(at => now - at < 60 * 60 * 1000);
468
+ if (times.length >= RELAY_GUESTS_PER_HOUR) {
469
+ return false;
470
+ }
471
+ this.guestsIn.set(room, [...times, now]);
472
+ return true;
473
+ }
458
474
  foreignSet(live, key) {
459
475
  // Not awaited: the owner clears what one set under another's name, as soon as it is in the room.
460
476
  void this.setState(live.record.id, key, null).catch(() => undefined);
@@ -0,0 +1,106 @@
1
+ import type { RelayChatLine, RelayChatLineExtra } from './relay-room-chat.js';
2
+ /**
3
+ * What every app of a group chat that listens and speaks there needs (docs/design/ta-feedback.md 1): what others said
4
+ * since it last read, paced; who speaks for the user (their double or an agent of theirs in the room); what others wrote
5
+ * kept as theirs when a model reads it; and a board of how things go that every member, and those in a browser, see.
6
+ * Feedback is one such app; a vote, a rota or a help desk would be others.
7
+ */
8
+ /** Under `agents:<member>` of the state of a room, each member lists the agents of theirs they invited to it. */
9
+ export declare const ROOM_AGENTS_KEY = "agents:";
10
+ /** A line older than this when an app reads it is left: Ta was off for days. */
11
+ export declare const ROOM_APP_STALE_MS: number;
12
+ export declare namespace RoomAppUtil {
13
+ /** What others wrote, which a model reads inside tags: no tags of its own. */
14
+ function quote(text: string): string;
15
+ /**
16
+ * What others said to the room since `since`: not by the user, not too long ago, not to someone in particular (@ a
17
+ * person, a double or an agent: theirs to answer), not said by a double or an agent.
18
+ */
19
+ function fresh(lines: readonly RelayChatLine[], self: string, since: number, now: number, staleMs?: number): RelayChatLine[];
20
+ /** Whether one more fits in the hour before `now`. */
21
+ function within(times: readonly number[], now: number, most: number): boolean;
22
+ /** People named with @, each once. */
23
+ function mentions(names: readonly string[]): string;
24
+ }
25
+ export interface RoomSpeaker {
26
+ name: string;
27
+ /** What the line it says carries (RelayRoomChat.say): the agent, or that it is the double. */
28
+ extra: RelayChatLineExtra;
29
+ }
30
+ /**
31
+ * Who speaks for the user in a room: the agent of theirs they chose, while it is in the room (as `agents:<member>` of
32
+ * its state lists it, written by them), else their double, named `doubleName`.
33
+ */
34
+ export declare function roomSpeaker(rooms: {
35
+ getState(room: string, prefix?: string): Promise<Record<string, {
36
+ value: unknown;
37
+ by: string;
38
+ }>>;
39
+ }, room: string, self: string, agent: string | undefined, doubleName: string): Promise<RoomSpeaker>;
40
+ /**
41
+ * 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
42
+ * run at a time per room, and no more runs that did something than `hourly` in an hour (past it, again after `laterMs`).
43
+ * `run` says whether it did something (a turn of a model, a line said).
44
+ */
45
+ export declare class RoomPacer {
46
+ protected readonly run: (room: string) => Promise<boolean>;
47
+ protected readonly options: {
48
+ settleMs: number;
49
+ hourly: number;
50
+ laterMs: number;
51
+ now(): number;
52
+ failed(error: unknown): void;
53
+ };
54
+ protected readonly timers: Map<string, NodeJS.Timeout>;
55
+ protected readonly queues: Map<string, Promise<void>>;
56
+ protected readonly runs: Map<string, number[]>;
57
+ protected disposed: boolean;
58
+ constructor(run: (room: string) => Promise<boolean>, options: {
59
+ settleMs: number;
60
+ hourly: number;
61
+ laterMs: number;
62
+ now(): number;
63
+ failed(error: unknown): void;
64
+ });
65
+ /** Something was said in a room: it is read once it is quiet (`delay`, settleMs by default). */
66
+ heard(room: string, delay?: number): void;
67
+ /** What runs in a room now, done. */
68
+ idle(room: string): Promise<void>;
69
+ dispose(): void;
70
+ protected turn(room: string): Promise<void>;
71
+ }
72
+ /** Under `board:<app>:<member>` of the state of a room, its owner says how the things of an app go, for all in it. */
73
+ export declare const RELAY_BOARD_KEY = "board:";
74
+ /** Items of a board at most, the latest. */
75
+ export declare const RELAY_BOARD_MAX = 30;
76
+ /**
77
+ * How an item goes, for anyone to draw without knowing the app: being done, waiting (for the owner, or for more from
78
+ * those who said it), done, or closed without it.
79
+ */
80
+ export type RelayBoardState = 'doing' | 'waiting' | 'done' | 'closed';
81
+ export interface RelayBoardItem {
82
+ /** Its number in the room, as people name it (#n). */
83
+ n: number;
84
+ title: string;
85
+ state: RelayBoardState;
86
+ /** How it goes in words of the owner's language: `Being fixed`, `Waiting for the owner`. */
87
+ label: string;
88
+ /** Who it came from, by name. */
89
+ people: string[];
90
+ at: number;
91
+ }
92
+ /** A board of an app in a room: its name (`Feedback`), and its items, the latest last. */
93
+ export interface RelayRoomBoard {
94
+ title: string;
95
+ items: RelayBoardItem[];
96
+ }
97
+ export declare namespace RelayBoardUtil {
98
+ function key(app: string, member: string): string;
99
+ /** 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. */
100
+ function read(key: string, value: unknown, by: string, owner: string | undefined): RelayRoomBoard | undefined;
101
+ /** How many are being done or wait, and how many are done: what a line over the chat says. */
102
+ function counts(board: RelayRoomBoard): {
103
+ open: number;
104
+ done: number;
105
+ };
106
+ }
@@ -0,0 +1,171 @@
1
+ /**
2
+ * What every app of a group chat that listens and speaks there needs (docs/design/ta-feedback.md 1): what others said
3
+ * since it last read, paced; who speaks for the user (their double or an agent of theirs in the room); what others wrote
4
+ * kept as theirs when a model reads it; and a board of how things go that every member, and those in a browser, see.
5
+ * Feedback is one such app; a vote, a rota or a help desk would be others.
6
+ */
7
+ /** Under `agents:<member>` of the state of a room, each member lists the agents of theirs they invited to it. */
8
+ export const ROOM_AGENTS_KEY = 'agents:';
9
+ /** A line older than this when an app reads it is left: Ta was off for days. */
10
+ export const ROOM_APP_STALE_MS = 3 * 24 * 60 * 60 * 1000;
11
+ const HOUR_MS = 60 * 60 * 1000;
12
+ export var RoomAppUtil;
13
+ (function (RoomAppUtil) {
14
+ /** What others wrote, which a model reads inside tags: no tags of its own. */
15
+ function quote(text) {
16
+ return text.replace(/</g, '&lt;').replace(/>/g, '&gt;');
17
+ }
18
+ RoomAppUtil.quote = quote;
19
+ /**
20
+ * What others said to the room since `since`: not by the user, not too long ago, not to someone in particular (@ a
21
+ * person, a double or an agent: theirs to answer), not said by a double or an agent.
22
+ */
23
+ function fresh(lines, self, since, now, staleMs = ROOM_APP_STALE_MS) {
24
+ 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; });
25
+ }
26
+ RoomAppUtil.fresh = fresh;
27
+ /** Whether one more fits in the hour before `now`. */
28
+ function within(times, now, most) {
29
+ return times.filter(at => now - at < HOUR_MS).length < most;
30
+ }
31
+ RoomAppUtil.within = within;
32
+ /** People named with @, each once. */
33
+ function mentions(names) {
34
+ return [...new Set(names)].map(name => `@${name}`).join(' ');
35
+ }
36
+ RoomAppUtil.mentions = mentions;
37
+ })(RoomAppUtil || (RoomAppUtil = {}));
38
+ /**
39
+ * Who speaks for the user in a room: the agent of theirs they chose, while it is in the room (as `agents:<member>` of
40
+ * its state lists it, written by them), else their double, named `doubleName`.
41
+ */
42
+ export async function roomSpeaker(rooms, room, self, agent, doubleName) {
43
+ if (agent) {
44
+ const key = `${ROOM_AGENTS_KEY}${self}`;
45
+ const listed = (await rooms.getState(room, key).catch(() => ({})))[key];
46
+ 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;
47
+ if (found && typeof found.name === 'string') {
48
+ return { name: found.name, extra: { agent: { id: found.id, name: found.name } } };
49
+ }
50
+ }
51
+ return { name: doubleName, extra: { double: true } };
52
+ }
53
+ /**
54
+ * 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
55
+ * run at a time per room, and no more runs that did something than `hourly` in an hour (past it, again after `laterMs`).
56
+ * `run` says whether it did something (a turn of a model, a line said).
57
+ */
58
+ export class RoomPacer {
59
+ constructor(run, options) {
60
+ this.run = run;
61
+ this.options = options;
62
+ this.timers = new Map();
63
+ this.queues = new Map();
64
+ this.runs = new Map();
65
+ this.disposed = false;
66
+ }
67
+ /** Something was said in a room: it is read once it is quiet (`delay`, settleMs by default). */
68
+ heard(room, delay = this.options.settleMs) {
69
+ var _a, _b;
70
+ if (this.disposed) {
71
+ return;
72
+ }
73
+ clearTimeout(this.timers.get(room));
74
+ const timer = setTimeout(() => {
75
+ var _a;
76
+ this.timers.delete(room);
77
+ const next = ((_a = this.queues.get(room)) !== null && _a !== void 0 ? _a : Promise.resolve())
78
+ .then(() => this.turn(room))
79
+ .catch(error => this.options.failed(error))
80
+ .finally(() => {
81
+ if (this.queues.get(room) === next) {
82
+ this.queues.delete(room);
83
+ }
84
+ });
85
+ this.queues.set(room, next);
86
+ }, delay);
87
+ (_b = (_a = timer).unref) === null || _b === void 0 ? void 0 : _b.call(_a);
88
+ this.timers.set(room, timer);
89
+ }
90
+ /** What runs in a room now, done. */
91
+ idle(room) {
92
+ var _a;
93
+ return (_a = this.queues.get(room)) !== null && _a !== void 0 ? _a : Promise.resolve();
94
+ }
95
+ dispose() {
96
+ this.disposed = true;
97
+ for (const timer of this.timers.values()) {
98
+ clearTimeout(timer);
99
+ }
100
+ }
101
+ async turn(room) {
102
+ var _a;
103
+ if (this.disposed) {
104
+ return;
105
+ }
106
+ const now = this.options.now();
107
+ const times = ((_a = this.runs.get(room)) !== null && _a !== void 0 ? _a : []).filter(at => now - at < HOUR_MS);
108
+ if (!RoomAppUtil.within(times, now, this.options.hourly)) {
109
+ this.heard(room, this.options.laterMs);
110
+ return;
111
+ }
112
+ if (await this.run(room)) {
113
+ this.runs.set(room, [...times, now]);
114
+ }
115
+ }
116
+ }
117
+ /** Under `board:<app>:<member>` of the state of a room, its owner says how the things of an app go, for all in it. */
118
+ export const RELAY_BOARD_KEY = 'board:';
119
+ /** Items of a board at most, the latest. */
120
+ export const RELAY_BOARD_MAX = 30;
121
+ const STATES = ['doing', 'waiting', 'done', 'closed'];
122
+ export var RelayBoardUtil;
123
+ (function (RelayBoardUtil) {
124
+ function key(app, member) {
125
+ return `${RELAY_BOARD_KEY}${app}:${member}`;
126
+ }
127
+ RelayBoardUtil.key = key;
128
+ /** 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. */
129
+ function read(key, value, by, owner) {
130
+ if (!owner || by !== owner || !key.startsWith(RELAY_BOARD_KEY) || !key.endsWith(`:${owner}`) || !value || typeof value !== 'object') {
131
+ return undefined;
132
+ }
133
+ const { title, items } = value;
134
+ if (typeof title !== 'string' || !Array.isArray(items)) {
135
+ return undefined;
136
+ }
137
+ return {
138
+ title: cut(title, 40),
139
+ items: items
140
+ .filter(item => item &&
141
+ Number.isInteger(item.n) &&
142
+ typeof item.title === 'string' &&
143
+ STATES.includes(item.state) &&
144
+ typeof item.label === 'string' &&
145
+ typeof item.at === 'number')
146
+ .slice(-RELAY_BOARD_MAX)
147
+ .map(item => ({
148
+ n: item.n,
149
+ title: cut(item.title, 80),
150
+ state: item.state,
151
+ label: cut(item.label, 30),
152
+ people: Array.isArray(item.people) ? item.people.filter((name) => typeof name === 'string').slice(0, 5) : [],
153
+ at: item.at,
154
+ })),
155
+ };
156
+ }
157
+ RelayBoardUtil.read = read;
158
+ /** How many are being done or wait, and how many are done: what a line over the chat says. */
159
+ function counts(board) {
160
+ return {
161
+ open: board.items.filter(item => item.state === 'doing' || item.state === 'waiting').length,
162
+ done: board.items.filter(item => item.state === 'done').length,
163
+ };
164
+ }
165
+ RelayBoardUtil.counts = counts;
166
+ function cut(text, max) {
167
+ const one = text.replace(/\s+/g, ' ').trim();
168
+ return one.length > max ? `${one.slice(0, max - 1)}…` : one;
169
+ }
170
+ })(RelayBoardUtil || (RelayBoardUtil = {}));
171
+ //# sourceMappingURL=relay-room-app.js.map
@@ -36,6 +36,9 @@ declare const zh: {
36
36
  rename: string;
37
37
  leave: string;
38
38
  leaveAsk: string;
39
+ boardOpen: string;
40
+ boardDone: string;
41
+ boardFrom: string;
39
42
  game: string;
40
43
  empty: string;
41
44
  placeholder: string;
@@ -36,6 +36,9 @@ const zh = {
36
36
  rename: '修改我的名字',
37
37
  leave: '退出群聊',
38
38
  leaveAsk: '退出「{title}」?退出后要有新的邀请才能再进来。',
39
+ boardOpen: '{n} 个处理中',
40
+ boardDone: '{n} 个已完成',
41
+ boardFrom: '来自 {names}',
39
42
  game: '这个群里有 Ta 的游戏,装了 Ta 才能一起玩;在这里可以聊天。',
40
43
  empty: '还没有人说话。只有群里的人能看到,中继保存的是密文。',
41
44
  placeholder: '发消息',
@@ -81,6 +84,9 @@ const zhTw = {
81
84
  rename: '修改我的名字',
82
85
  leave: '退出群聊',
83
86
  leaveAsk: '退出「{title}」?退出後要有新的邀請才能再進來。',
87
+ boardOpen: '{n} 個處理中',
88
+ boardDone: '{n} 個已完成',
89
+ boardFrom: '來自 {names}',
84
90
  game: '這個群裡有 Ta 的遊戲,裝了 Ta 才能一起玩;在這裡可以聊天。',
85
91
  empty: '還沒有人說話。只有群裡的人能看到,中繼儲存的是密文。',
86
92
  placeholder: '發訊息',
@@ -126,6 +132,9 @@ const en = {
126
132
  rename: 'Change my name',
127
133
  leave: 'Leave the group chat',
128
134
  leaveAsk: 'Leave “{title}”? You come back only by a new invitation.',
135
+ boardOpen: '{n} in progress',
136
+ boardDone: '{n} done',
137
+ boardFrom: 'From {names}',
129
138
  game: 'This group chat plays a game of Ta, which takes Ta to play; here you chat.',
130
139
  empty: 'Nothing said yet. Only those in the group chat read it: the relay keeps it sealed.',
131
140
  placeholder: 'Message',
@@ -171,6 +180,9 @@ const ja = {
171
180
  rename: '名前を変更',
172
181
  leave: 'グループチャットを退出',
173
182
  leaveAsk: '「{title}」を退出しますか?退出後は新しい招待でのみ戻ることができます。',
183
+ boardOpen: '対応中 {n} 件',
184
+ boardDone: '完了 {n} 件',
185
+ boardFrom: '{names} から',
174
186
  game: 'このグループチャットには Ta のゲームがあり、プレイするには Ta が必要です。ここでチャットできます。',
175
187
  empty: 'まだ誰も話していません。グループ内の人だけが見ることができ、リレーは暗号化されて保存されます。',
176
188
  placeholder: 'メッセージ',
@@ -1 +1 @@
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";
@@ -44,6 +44,17 @@ input.text:focus{border-color:var(--accent)}
44
44
  @media (prefers-color-scheme:dark){.face[data-face="11"] .ta-face-body>g>circle{fill:#4a4a52}}
45
45
  .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)}
46
46
  .face i.on{background:var(--accent)}
47
+ .boards{flex:none;display:flex;gap:6px;overflow-x:auto;margin:10px 14px 0;scrollbar-width:none}
48
+ .boards::-webkit-scrollbar{display:none}
49
+ .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}
50
+ .board .dot{width:6px;height:6px;border-radius:50%;background:var(--accent)}
51
+ .item{display:flex;flex-direction:column;gap:2px;padding:9px 14px}
52
+ .item .hd{display:flex;align-items:center;gap:8px;font-size:14.5px}
53
+ .item .n{color:var(--muted);font-variant-numeric:tabular-nums}
54
+ .item .tt{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
55
+ .item .lb{flex:none;font-size:12px;color:var(--muted)}
56
+ .item .lb.doing,.item .lb.waiting{color:var(--accent)}
57
+ .item .by{font-size:12px;color:var(--muted);padding-left:2px}
47
58
  .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}
48
59
  .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}
49
60
  .empty{margin:14vh auto 0;max-width:300px;text-align:center;color:var(--muted);font-size:13px}
@@ -2,6 +2,7 @@ import { FaceUtil } from '../common/relay-faces.js';
2
2
  import { RelayHubUtil } from '../common/relay-hub-util.js';
3
3
  import { RelayHubs } from '../common/relay-hubs.js';
4
4
  import { RelayOpenInTa } from '../common/relay-open-in-ta.js';
5
+ import { RELAY_BOARD_KEY, RelayBoardUtil } from '../common/relay-room-app.js';
5
6
  import { RelayRoomChat } from '../common/relay-room-chat.js';
6
7
  import { ViewerMarkdown } from '../viewer/viewer-markdown.js';
7
8
  import { GuestI18n } from './guest-i18n.js';
@@ -93,12 +94,17 @@ class GuestPage {
93
94
  this.screen = '';
94
95
  this.stuck = true;
95
96
  this.connected = false;
97
+ /** The boards of the apps of the room, by key, as its owner writes them (RelayRoomBoard): what a guest sees of them. */
98
+ this.boards = new Map();
96
99
  }
97
100
  start() {
98
101
  this.hubs.onEvent(event => {
99
102
  var _a;
100
103
  if (event.type === 'state' && event.room === this.link.room) {
101
104
  (_a = this.chat) === null || _a === void 0 ? void 0 : _a.heard(event.key, event);
105
+ if (event.key.startsWith(RELAY_BOARD_KEY)) {
106
+ this.heardBoard(event.key, event.value, event.by);
107
+ }
102
108
  }
103
109
  else if (event.type === 'rooms') {
104
110
  this.update();
@@ -261,7 +267,17 @@ class GuestPage {
261
267
  }
262
268
  });
263
269
  const banner = room.view ? [div('banner', t('game'))] : [];
264
- this.frame(top, ...banner, list, div('box', field, send), div('foot', t('secure')));
270
+ this.boardBar = div('boards');
271
+ this.boardBar.hidden = true;
272
+ this.frame(top, ...banner, this.boardBar, list, div('box', field, send), div('foot', t('secure')));
273
+ void this.hubs
274
+ .getState(room.id, RELAY_BOARD_KEY)
275
+ .then(state => {
276
+ for (const [key, value] of Object.entries(state)) {
277
+ this.heardBoard(key, value.value, value.by);
278
+ }
279
+ })
280
+ .catch(() => undefined);
265
281
  this.refresh(room);
266
282
  this.draw();
267
283
  }
@@ -279,7 +295,7 @@ class GuestPage {
279
295
  const sub = el('small', !room.connected ? t('connecting') : online ? t('online', { n: online }) : t('nobody'));
280
296
  sub.className = room.connected && online ? '' : 'quiet';
281
297
  (_b = this.heading) === null || _b === void 0 ? void 0 : _b.replaceChildren(title, sub);
282
- if (this.sheet) {
298
+ if (this.sheet && this.sheetOf === 'members') {
283
299
  this.members();
284
300
  }
285
301
  }
@@ -294,10 +310,8 @@ class GuestPage {
294
310
  const self = (_a = room.members.find(member => member.self)) === null || _a === void 0 ? void 0 : _a.member;
295
311
  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; };
296
312
  // 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.
297
- const nameOf = (line) => (line.agent ? line.agent.name : line.double ? t('doubleOf').replace('{name}', personOf(line)) : personOf(line));
298
- const tagOf = (line) => [line.agent ? t('agentOf').replace('{name}', personOf(line)) : line.double ? t('double') : '', line.task ? t('task') : '']
299
- .filter(Boolean)
300
- .join(' · ');
313
+ const nameOf = (line) => (line.agent ? line.agent.name : line.double ? t('doubleOf', { name: personOf(line) }) : personOf(line));
314
+ const tagOf = (line) => [line.agent ? t('agentOf', { name: personOf(line) }) : line.double ? t('double') : '', line.task ? t('task') : ''].filter(Boolean).join(' · ');
301
315
  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 : ''}`; };
302
316
  const nodes = [];
303
317
  if (!lines.length) {
@@ -328,6 +342,61 @@ class GuestPage {
328
342
  list.scrollTop = list.scrollHeight;
329
343
  }
330
344
  }
345
+ /** A board of an app of the room changed: kept if its owner wrote it, and drawn over the chat. */
346
+ heardBoard(key, value, by) {
347
+ var _a, _b;
348
+ 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;
349
+ const board = RelayBoardUtil.read(key, value, by, owner);
350
+ if (board === null || board === void 0 ? void 0 : board.items.length) {
351
+ this.boards.set(key, board);
352
+ }
353
+ else {
354
+ this.boards.delete(key);
355
+ }
356
+ this.drawBoards();
357
+ }
358
+ /** A chip for each board, how many are in progress and done; a tap opens its items. */
359
+ drawBoards() {
360
+ const bar = this.boardBar;
361
+ if (!bar) {
362
+ return;
363
+ }
364
+ const chips = [...this.boards].map(([key, board]) => {
365
+ const { open, done } = RelayBoardUtil.counts(board);
366
+ const parts = [open ? t('boardOpen', { n: open }) : '', done ? t('boardDone', { n: done }) : ''].filter(Boolean);
367
+ const chip = button('board', [board.title, ...parts].join(' · '), () => this.showBoard(key));
368
+ if (open) {
369
+ chip.prepend(Object.assign(el('span'), { className: 'dot' }));
370
+ }
371
+ return chip;
372
+ });
373
+ bar.replaceChildren(...chips);
374
+ bar.hidden = !chips.length;
375
+ }
376
+ showBoard(key) {
377
+ var _a;
378
+ const board = this.boards.get(key);
379
+ if (!board) {
380
+ return;
381
+ }
382
+ const panel = div('panel', el('h3', board.title));
383
+ for (const item of [...board.items].reverse()) {
384
+ const label = Object.assign(el('span', item.label), { className: `lb ${item.state}` });
385
+ const head = div('hd', Object.assign(el('span', `#${item.n}`), { className: 'n' }), Object.assign(el('span', item.title), { className: 'tt' }), label);
386
+ panel.append(div('item', head, ...(item.people.length ? [div('by', t('boardFrom', { names: item.people.join('、') }))] : [])));
387
+ }
388
+ panel.append(div('sep'), button('row', t('close'), () => this.closeSheet()));
389
+ const sheet = div('sheet', panel);
390
+ sheet.addEventListener('click', event => {
391
+ if (event.target === sheet) {
392
+ this.closeSheet();
393
+ }
394
+ });
395
+ (_a = this.sheet) === null || _a === void 0 ? void 0 : _a.remove();
396
+ document.body.append(sheet);
397
+ this.sheet = sheet;
398
+ this.sheetOf = 'board';
399
+ }
331
400
  /** The members, over the chat: who is online, and the user's name and way out. */
332
401
  members() {
333
402
  var _a;
@@ -335,6 +404,7 @@ class GuestPage {
335
404
  if (!room) {
336
405
  return;
337
406
  }
407
+ this.sheetOf = 'members';
338
408
  const panel = div('panel', Object.assign(el('h3', `${t('members')} (${room.members.length})`)));
339
409
  for (const member of room.members) {
340
410
  const tags = [member.self ? t('you') : '', member.owner ? t('owner') : '', member.guest ? t('guest') : ''].filter(Boolean);
@@ -24,6 +24,7 @@ export * from './relay-info';
24
24
  export * from './relay-pairing';
25
25
  export * from './relay-protocol';
26
26
  export * from './relay-room';
27
+ export * from './relay-room-app';
27
28
  export * from './relay-room-chat';
28
29
  export * from './relay-share';
29
30
  export * from './relay-socket';
@@ -40,6 +40,7 @@ __exportStar(require("./relay-info"), exports);
40
40
  __exportStar(require("./relay-pairing"), exports);
41
41
  __exportStar(require("./relay-protocol"), exports);
42
42
  __exportStar(require("./relay-room"), exports);
43
+ __exportStar(require("./relay-room-app"), exports);
43
44
  __exportStar(require("./relay-room-chat"), exports);
44
45
  __exportStar(require("./relay-share"), exports);
45
46
  __exportStar(require("./relay-socket"), exports);