@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.
Files changed (91) hide show
  1. package/esm/common/index.d.ts +2 -0
  2. package/esm/common/index.js +2 -0
  3. package/esm/common/relay-account-client.d.ts +4 -0
  4. package/esm/common/relay-account-client.js +13 -3
  5. package/esm/common/relay-account.d.ts +17 -2
  6. package/esm/common/relay-account.js +15 -6
  7. package/esm/common/relay-accounts.d.ts +2 -0
  8. package/esm/common/relay-accounts.js +16 -2
  9. package/esm/common/relay-group-invites.d.ts +6 -2
  10. package/esm/common/relay-group-invites.js +6 -5
  11. package/esm/common/relay-hub-charter.d.ts +78 -0
  12. package/esm/common/relay-hub-charter.js +152 -0
  13. package/esm/common/relay-hub-epochs.d.ts +43 -0
  14. package/esm/common/relay-hub-epochs.js +92 -0
  15. package/esm/common/relay-hub-util.d.ts +39 -7
  16. package/esm/common/relay-hub-util.js +46 -15
  17. package/esm/common/relay-hub.d.ts +13 -0
  18. package/esm/common/relay-hub.js +81 -18
  19. package/esm/common/relay-hubs-admins.d.ts +27 -0
  20. package/esm/common/relay-hubs-admins.js +91 -0
  21. package/esm/common/relay-hubs-connection.d.ts +19 -63
  22. package/esm/common/relay-hubs-connection.js +100 -87
  23. package/esm/common/relay-hubs-identity.d.ts +7 -1
  24. package/esm/common/relay-hubs-identity.js +28 -1
  25. package/esm/common/relay-hubs-live.d.ts +58 -0
  26. package/esm/common/relay-hubs-live.js +27 -0
  27. package/esm/common/relay-hubs-protocol.d.ts +10 -0
  28. package/esm/common/relay-hubs-util.d.ts +9 -0
  29. package/esm/common/relay-hubs-util.js +23 -1
  30. package/esm/common/relay-hubs.d.ts +15 -15
  31. package/esm/common/relay-hubs.js +76 -57
  32. package/esm/common/relay-protocol.d.ts +14 -3
  33. package/esm/common/relay-protocol.js +1 -1
  34. package/esm/common/relay-room-app.d.ts +106 -0
  35. package/esm/common/relay-room-app.js +171 -0
  36. package/esm/common/relay-room-chat.d.ts +6 -1
  37. package/esm/common/relay-room-chat.js +1 -0
  38. package/esm/guest/guest-i18n.d.ts +3 -0
  39. package/esm/guest/guest-i18n.js +12 -0
  40. package/esm/guest/guest-style.d.ts +1 -1
  41. package/esm/guest/guest-style.js +11 -0
  42. package/esm/guest/guest.js +76 -6
  43. package/esm/node/relay-server-accounts.d.ts +1 -1
  44. package/esm/node/relay-server-accounts.js +1 -1
  45. package/lib/common/index.d.ts +2 -0
  46. package/lib/common/index.js +2 -0
  47. package/lib/common/relay-account-client.d.ts +4 -0
  48. package/lib/common/relay-account-client.js +13 -3
  49. package/lib/common/relay-account.d.ts +17 -2
  50. package/lib/common/relay-account.js +15 -6
  51. package/lib/common/relay-accounts.d.ts +2 -0
  52. package/lib/common/relay-accounts.js +16 -2
  53. package/lib/common/relay-group-invites.d.ts +6 -2
  54. package/lib/common/relay-group-invites.js +6 -5
  55. package/lib/common/relay-hub-charter.d.ts +79 -0
  56. package/lib/common/relay-hub-charter.js +155 -0
  57. package/lib/common/relay-hub-epochs.d.ts +44 -0
  58. package/lib/common/relay-hub-epochs.js +95 -0
  59. package/lib/common/relay-hub-util.d.ts +39 -7
  60. package/lib/common/relay-hub-util.js +46 -15
  61. package/lib/common/relay-hub.d.ts +13 -0
  62. package/lib/common/relay-hub.js +81 -18
  63. package/lib/common/relay-hubs-admins.d.ts +28 -0
  64. package/lib/common/relay-hubs-admins.js +95 -0
  65. package/lib/common/relay-hubs-connection.d.ts +19 -63
  66. package/lib/common/relay-hubs-connection.js +106 -94
  67. package/lib/common/relay-hubs-identity.d.ts +7 -1
  68. package/lib/common/relay-hubs-identity.js +28 -1
  69. package/lib/common/relay-hubs-live.d.ts +59 -0
  70. package/lib/common/relay-hubs-live.js +31 -0
  71. package/lib/common/relay-hubs-protocol.d.ts +10 -0
  72. package/lib/common/relay-hubs-util.d.ts +9 -0
  73. package/lib/common/relay-hubs-util.js +23 -1
  74. package/lib/common/relay-hubs.d.ts +15 -15
  75. package/lib/common/relay-hubs.js +82 -63
  76. package/lib/common/relay-protocol.d.ts +14 -3
  77. package/lib/common/relay-protocol.js +1 -1
  78. package/lib/common/relay-room-app.d.ts +107 -0
  79. package/lib/common/relay-room-app.js +176 -0
  80. package/lib/common/relay-room-chat.d.ts +6 -1
  81. package/lib/common/relay-room-chat.js +1 -0
  82. package/lib/guest/guest-i18n.d.ts +3 -0
  83. package/lib/guest/guest-i18n.js +12 -0
  84. package/lib/guest/guest-style.d.ts +1 -1
  85. package/lib/guest/guest-style.js +11 -0
  86. package/lib/guest/guest.js +76 -6
  87. package/lib/node/relay-server-accounts.d.ts +1 -1
  88. package/lib/node/relay-server-accounts.js +1 -1
  89. package/package.json +3 -3
  90. package/viewer/join.html +17 -6
  91. package/viewer/room.html +26 -15
@@ -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,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. */
@@ -41,6 +41,7 @@ export var RelayRoomChatUtil;
41
41
  ? { agent: { id: agent.id.slice(0, 64), name: agent.name.slice(0, 64) } }
42
42
  : {}),
43
43
  ...(to.length ? { to } : {}),
44
+ ...(line.person === true && to.length && line.double !== true && !line.agent ? { person: true } : {}),
44
45
  ...(typeof line.re === 'string' ? { re: line.re } : {}),
45
46
  ...(line.task === true && to.length ? { task: true } : {}),
46
47
  };
@@ -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);
@@ -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. */
@@ -15,7 +15,7 @@ export class RelayServerAccounts {
15
15
  var _a;
16
16
  const books = new RelayAccountBooks(account => data ? new FileRelayStorage(join(data, 'accounts', RelayBytes.toBase64(new TextEncoder().encode(account)))) : new MemoryHubStorage());
17
17
  const providers = (_a = options.providers) !== null && _a !== void 0 ? _a : (options.authenticate ? [] : [new RelayGitHubAccounts()]);
18
- this.accounts = new RelayAccounts({ book: account => books.book(account), providers, authenticate: options.authenticate });
18
+ this.accounts = new RelayAccounts({ book: account => books.book(account), providers, authenticate: options.authenticate, issue: options.issue });
19
19
  }
20
20
  /** Answers a request of RELAY_ACCOUNT_PATH; never throws, an unhandled rejection would end the relay. */
21
21
  serve(request, response) {
@@ -14,6 +14,7 @@ export * from './relay-friends';
14
14
  export * from './relay-group-invites';
15
15
  export * from './relay-host-calls';
16
16
  export * from './relay-hub';
17
+ export * from './relay-hub-charter';
17
18
  export * from './relay-hub-util';
18
19
  export * from './relay-hubs';
19
20
  export * from './relay-hubs-protocol';
@@ -23,6 +24,7 @@ export * from './relay-info';
23
24
  export * from './relay-pairing';
24
25
  export * from './relay-protocol';
25
26
  export * from './relay-room';
27
+ export * from './relay-room-app';
26
28
  export * from './relay-room-chat';
27
29
  export * from './relay-share';
28
30
  export * from './relay-socket';
@@ -30,6 +30,7 @@ __exportStar(require("./relay-friends"), exports);
30
30
  __exportStar(require("./relay-group-invites"), exports);
31
31
  __exportStar(require("./relay-host-calls"), exports);
32
32
  __exportStar(require("./relay-hub"), exports);
33
+ __exportStar(require("./relay-hub-charter"), exports);
33
34
  __exportStar(require("./relay-hub-util"), exports);
34
35
  __exportStar(require("./relay-hubs"), exports);
35
36
  __exportStar(require("./relay-hubs-protocol"), exports);
@@ -39,6 +40,7 @@ __exportStar(require("./relay-info"), exports);
39
40
  __exportStar(require("./relay-pairing"), exports);
40
41
  __exportStar(require("./relay-protocol"), exports);
41
42
  __exportStar(require("./relay-room"), exports);
43
+ __exportStar(require("./relay-room-app"), exports);
42
44
  __exportStar(require("./relay-room-chat"), exports);
43
45
  __exportStar(require("./relay-share"), exports);
44
46
  __exportStar(require("./relay-socket"), exports);
@@ -133,6 +133,10 @@ export declare class AccountAgent {
133
133
  approve(id: string): Promise<AccountView>;
134
134
  /** Removes a device (one waiting that is not the user's, or one lost): every device drops it. */
135
135
  remove(id: string): Promise<AccountView>;
136
+ /** A token of the account for a device the user brings in by hand (a computer whose code they scanned). */
137
+ invite(): Promise<{
138
+ token: string;
139
+ }>;
136
140
  /** Leaves the account: removed from it, its token dropped. */
137
141
  signOut(): Promise<void>;
138
142
  }
@@ -129,7 +129,7 @@ class AccountAgent {
129
129
  /** A new device of `account`: its own keys, trusting itself alone. */
130
130
  static async create(service, token, account, kind, name) {
131
131
  const self = await relay_identity_1.RelayIdentityUtil.create(name);
132
- return { service: service.replace(/\/+$/, ''), token, account, kind, self, circle: relay_account_1.AccountCircle.alone(self), pairings: {} };
132
+ return { service: service.replace(/\/+$/, ''), token, account, kind, self, circle: relay_account_1.AccountCircle.alone(self, kind), pairings: {} };
133
133
  }
134
134
  get state() {
135
135
  return this.kept;
@@ -213,12 +213,14 @@ class AccountAgent {
213
213
  if (this.hooks.pair && this.hooks.paired) {
214
214
  const paired = new Set(this.hooks.paired());
215
215
  for (const id of paired) {
216
- if (!ids.has(id)) {
216
+ const device = trusted.find(one => one.id === id);
217
+ if (!ids.has(id) || (device && relay_account_1.AccountCircle.cloud(this.kept.circle, device))) {
217
218
  await ((_b = (_a = this.hooks).unpair) === null || _b === void 0 ? void 0 : _b.call(_a, id));
218
219
  }
219
220
  }
220
221
  for (const device of trusted) {
221
- if (!paired.has(device.id)) {
222
+ // A Ta in the cloud gets no way into a computer: devices open it, it does not reach them.
223
+ if (!paired.has(device.id) && !relay_account_1.AccountCircle.cloud(this.kept.circle, device)) {
222
224
  const link = await this.hooks.pair(device);
223
225
  await this.calls.send(await relay_account_1.AccountCircle.seal(this.kept.self, device, 'pairing', { link }));
224
226
  }
@@ -312,6 +314,10 @@ class AccountAgent {
312
314
  /** Lets a waiting device in: signs it, and sends it whom this device trusts. */
313
315
  async approve(id) {
314
316
  return this.guard(async () => {
317
+ if (this.kept.kind === 'cloud') {
318
+ // Not 403: that would sign this device out (guard).
319
+ throw new AccountCallError(409, 'A Ta in the cloud lets no device in.');
320
+ }
315
321
  const roster = await this.calls.roster(this.kept.self.id);
316
322
  const device = roster.devices.find(one => one.id === id);
317
323
  if (!device || !relay_account_1.AccountCircle.waiting(device)) {
@@ -330,6 +336,10 @@ class AccountAgent {
330
336
  return this.sync();
331
337
  });
332
338
  }
339
+ /** A token of the account for a device the user brings in by hand (a computer whose code they scanned). */
340
+ invite() {
341
+ return this.guard(() => this.calls.invite());
342
+ }
333
343
  /** Leaves the account: removed from it, its token dropped. */
334
344
  async signOut() {
335
345
  const { self, account } = this.kept;
@@ -5,7 +5,11 @@ export declare const RELAY_ACCOUNT_PATH = "/v1/account/";
5
5
  export declare const RELAY_ACCOUNT_MAX_DEVICES = 20;
6
6
  /** A device seen within this is online: computers say they are there every minute. */
7
7
  export declare const RELAY_ACCOUNT_ONLINE_MS: number;
8
- export type AccountDeviceKind = 'computer' | 'phone' | 'browser';
8
+ /**
9
+ * `cloud`: a Ta in the cloud, in a sandbox of the gateway (docs/design/ta-me.md 2). The devices of the account open it,
10
+ * but it lets no device in and gets no way into a computer: whoever runs the gateway runs it.
11
+ */
12
+ export type AccountDeviceKind = 'computer' | 'phone' | 'browser' | 'cloud';
9
13
  export interface AccountName {
10
14
  /** `github:<id>`, `iam:<user>`: the provider and who the user is there. */
11
15
  id: string;
@@ -73,6 +77,13 @@ export interface AccountCalls {
73
77
  send(mail: Omit<AccountMail, 'at'>): Promise<void>;
74
78
  mail(to: string): Promise<AccountMail[]>;
75
79
  signOut(): Promise<void>;
80
+ /**
81
+ * A token of the account for another device the user brings in by hand (a computer whose code they scanned): it
82
+ * joins with it and waits to be let in, as any device signing in.
83
+ */
84
+ invite(): Promise<{
85
+ token: string;
86
+ }>;
76
87
  }
77
88
  export type AccountCallName = keyof AccountCalls;
78
89
  export declare const ACCOUNT_CALLS: readonly AccountCallName[];
@@ -96,9 +107,11 @@ export type AccountSignInPoll = {
96
107
  };
97
108
  /** What a device keeps of the devices it trusts (docs/design/ta-account.md 5). */
98
109
  export interface AccountCircleState {
110
+ /** `kind` as it was let in with (signed): a Ta in the cloud lets no one in. None from a device of before. */
99
111
  trusted: Record<string, {
100
112
  sign: string;
101
113
  box: string;
114
+ kind?: AccountDeviceKind;
102
115
  }>;
103
116
  /** Removed once: never trusted again, whatever the service says later. */
104
117
  removed: string[];
@@ -115,7 +128,9 @@ export declare namespace AccountCircle {
115
128
  /** Waiting for a device of the account to let it in. */
116
129
  function waiting(device: AccountDevice): boolean;
117
130
  /** A device trusting itself alone: the first one, or one not let in yet. */
118
- function alone(self: Pick<AccountDevice, 'id' | 'sign' | 'box'>): AccountCircleState;
131
+ function alone(self: Pick<AccountDevice, 'id' | 'sign' | 'box'>, kind?: AccountDeviceKind): AccountCircleState;
132
+ /** A Ta in the cloud, as trusted: its kind as it was let in with, else as the service says. */
133
+ function cloud(state: AccountCircleState, device: Pick<AccountDevice, 'id' | 'kind'>): boolean;
119
134
  /**
120
135
  * Who to trust now: those trusted before and not removed, and those a trusted device let in with a good signature,
121
136
  * until no more. A device the service adds without a signature of one of them is never trusted.