@celljs/ta-relay 4.11.0 → 4.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/common/index.d.ts +2 -0
- package/esm/common/index.js +2 -0
- package/esm/common/relay-faces.d.ts +32 -0
- package/esm/common/relay-faces.js +208 -0
- package/esm/common/relay-hubs-connection.d.ts +98 -0
- package/esm/common/relay-hubs-connection.js +505 -0
- package/esm/common/relay-hubs-protocol.d.ts +130 -0
- package/esm/common/relay-hubs-protocol.js +2 -0
- package/esm/common/relay-hubs.d.ts +4 -214
- package/esm/common/relay-hubs.js +2 -495
- package/esm/common/relay-room-chat.d.ts +31 -2
- package/esm/common/relay-room-chat.js +31 -7
- package/esm/guest/guest-i18n.d.ts +3 -0
- package/esm/guest/guest-i18n.js +6 -0
- package/esm/guest/guest-style.d.ts +1 -1
- package/esm/guest/guest-style.js +11 -4
- package/esm/guest/guest.js +31 -18
- package/esm/node/relay-hub-files.d.ts +1 -1
- package/lib/common/index.d.ts +2 -0
- package/lib/common/index.js +2 -0
- package/lib/common/relay-faces.d.ts +33 -0
- package/lib/common/relay-faces.js +211 -0
- package/lib/common/relay-hubs-connection.d.ts +99 -0
- package/lib/common/relay-hubs-connection.js +510 -0
- package/lib/common/relay-hubs-protocol.d.ts +131 -0
- package/lib/common/relay-hubs-protocol.js +3 -0
- package/lib/common/relay-hubs.d.ts +4 -214
- package/lib/common/relay-hubs.js +9 -502
- package/lib/common/relay-room-chat.d.ts +31 -2
- package/lib/common/relay-room-chat.js +31 -7
- package/lib/guest/guest-i18n.d.ts +3 -0
- package/lib/guest/guest-i18n.js +6 -0
- package/lib/guest/guest-style.d.ts +1 -1
- package/lib/guest/guest-style.js +11 -4
- package/lib/guest/guest.js +31 -18
- package/lib/node/relay-hub-files.d.ts +1 -1
- package/package.json +2 -2
- package/viewer/room.html +21 -14
|
@@ -28,14 +28,28 @@ var RelayRoomChatUtil;
|
|
|
28
28
|
const lines = [];
|
|
29
29
|
for (const line of value) {
|
|
30
30
|
if (line && typeof line.id === 'string' && typeof line.text === 'string' && typeof line.at === 'number') {
|
|
31
|
-
lines.push({ id: line.id, from: member, name: typeof line.name === 'string' ? line.name : '', text: line.text, at: line.at });
|
|
31
|
+
lines.push({ id: line.id, from: member, name: typeof line.name === 'string' ? line.name : '', text: line.text, at: line.at, ...extra(line) });
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
return lines;
|
|
35
35
|
}
|
|
36
36
|
RelayRoomChatUtil.lines = lines;
|
|
37
|
+
/** What a stored line adds, as far as it is well formed. */
|
|
38
|
+
function extra(line) {
|
|
39
|
+
const to = Array.isArray(line.to) ? line.to.filter((each) => typeof each === 'string').slice(0, 16) : [];
|
|
40
|
+
const agent = line.agent;
|
|
41
|
+
return {
|
|
42
|
+
...(line.double === true ? { double: true } : {}),
|
|
43
|
+
...(agent && typeof agent.id === 'string' && agent.id && typeof agent.name === 'string' && line.double !== true
|
|
44
|
+
? { agent: { id: agent.id.slice(0, 64), name: agent.name.slice(0, 64) } }
|
|
45
|
+
: {}),
|
|
46
|
+
...(to.length ? { to } : {}),
|
|
47
|
+
...(typeof line.re === 'string' ? { re: line.re } : {}),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
RelayRoomChatUtil.extra = extra;
|
|
37
51
|
function stored(lines) {
|
|
38
|
-
return lines.map(({
|
|
52
|
+
return lines.map(({ from: _from, ...line }) => line);
|
|
39
53
|
}
|
|
40
54
|
RelayRoomChatUtil.stored = stored;
|
|
41
55
|
function bytes(lines) {
|
|
@@ -89,20 +103,30 @@ class RelayRoomChat {
|
|
|
89
103
|
this.changed();
|
|
90
104
|
return true;
|
|
91
105
|
}
|
|
92
|
-
/**
|
|
93
|
-
|
|
106
|
+
/**
|
|
107
|
+
* Says `text` as `self` (its member id and name), with what `extra` adds (its double says it, to whose doubles); set
|
|
108
|
+
* again on what another client of the same Ta wrote first. The line said, or undefined when there was nothing to say.
|
|
109
|
+
*/
|
|
110
|
+
async say(text, self, extra = {}) {
|
|
94
111
|
var _a;
|
|
95
112
|
var _b, _c;
|
|
96
113
|
const said = text.trim().slice(0, exports.RELAY_CHAT_TEXT_MAX);
|
|
97
114
|
if (!said) {
|
|
98
|
-
return;
|
|
115
|
+
return undefined;
|
|
99
116
|
}
|
|
100
117
|
for (let tries = 0; tries < TRIES; tries++) {
|
|
101
118
|
const latest = this.latest(self.member);
|
|
102
119
|
// After what it said last, even within the same millisecond: the lines of a member keep their order.
|
|
103
120
|
const last = latest === null || latest === void 0 ? void 0 : latest.lines[latest.lines.length - 1];
|
|
104
121
|
const at = Math.max(Date.now(), ((_b = last === null || last === void 0 ? void 0 : last.at) !== null && _b !== void 0 ? _b : 0) + 1);
|
|
105
|
-
const line = {
|
|
122
|
+
const line = {
|
|
123
|
+
id: RelayRoomChatUtil.id(),
|
|
124
|
+
from: self.member,
|
|
125
|
+
name: self.name,
|
|
126
|
+
text: said,
|
|
127
|
+
at,
|
|
128
|
+
...RelayRoomChatUtil.extra(extra),
|
|
129
|
+
};
|
|
106
130
|
const fits = latest && RelayRoomChatUtil.bytes(RelayRoomChatUtil.stored([...latest.lines, line])) <= exports.RELAY_CHAT_PART_BYTES;
|
|
107
131
|
const part = !latest ? 0 : fits ? latest.part : latest.part + 1;
|
|
108
132
|
const lines = fits && latest ? [...latest.lines, line] : [line];
|
|
@@ -115,7 +139,7 @@ class RelayRoomChat {
|
|
|
115
139
|
if (part >= exports.RELAY_CHAT_PARTS) {
|
|
116
140
|
void this.clear(RelayRoomChatUtil.key(self.member, part - exports.RELAY_CHAT_PARTS));
|
|
117
141
|
}
|
|
118
|
-
return;
|
|
142
|
+
return line;
|
|
119
143
|
}
|
|
120
144
|
await this.load();
|
|
121
145
|
}
|
package/lib/guest/guest-i18n.js
CHANGED
|
@@ -29,6 +29,9 @@ const zh = {
|
|
|
29
29
|
owner: '房主',
|
|
30
30
|
you: '我',
|
|
31
31
|
guest: '网页访客',
|
|
32
|
+
doubleOf: '{name}的分身',
|
|
33
|
+
double: '分身',
|
|
34
|
+
agentOf: '{name}的智能体',
|
|
32
35
|
rename: '修改我的名字',
|
|
33
36
|
leave: '退出房间',
|
|
34
37
|
leaveAsk: '退出「{title}」?退出后要有新的邀请才能再进来。',
|
|
@@ -68,6 +71,9 @@ const en = {
|
|
|
68
71
|
owner: 'Owner',
|
|
69
72
|
you: 'You',
|
|
70
73
|
guest: 'Web guest',
|
|
74
|
+
doubleOf: "{name}'s double",
|
|
75
|
+
double: 'Double',
|
|
76
|
+
agentOf: "{name}'s agent",
|
|
71
77
|
rename: 'Change my name',
|
|
72
78
|
leave: 'Leave the room',
|
|
73
79
|
leaveAsk: 'Leave “{title}”? You come back only by a new invitation.',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const GUEST_STYLE = "\n:root{color-scheme:light dark;--bg:#fff;--fg:#1f1f1f;--muted:#737373;--faint:#a3a3a3;--line:#ececec;--soft:#f5f5f5;--bubble:#f2f2f2;--mine:#e7f6ec;--mine-fg:#14532d;--code:#f6f6f6;--accent:#16a34a;--red:#dc2626;--radius:16px}\n@media (prefers-color-scheme:dark){:root{--bg:#191919;--fg:#ececec;--muted:#a3a3a3;--faint:#6b6b6b;--line:#2c2c2c;--soft:#222;--bubble:#262626;--mine:#1f3a2a;--mine-fg:#d1fae5;--code:#232323;--accent:#4ade80;--red:#f87171}}\n*{box-sizing:border-box}\nhtml,body{margin:0;height:100%;background:var(--bg);color:var(--fg);font:15px/1.6 -apple-system,BlinkMacSystemFont,\"Segoe UI\",\"PingFang SC\",\"Hiragino Sans GB\",\"Microsoft YaHei\",sans-serif;-webkit-font-smoothing:antialiased;overscroll-behavior:none}\nbutton{font:inherit;color:inherit;cursor:pointer;-webkit-tap-highlight-color:transparent}\n.app{display:flex;flex-direction:column;height:100dvh;max-width:760px;margin:0 auto}\n.top{flex:none;display:flex;align-items:center;gap:10px;min-height:54px;padding:8px 10px 8px 16px;padding-top:max(8px,env(safe-area-inset-top));border-bottom:1px solid var(--line);background:var(--bg)}\n.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-
|
|
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.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";
|
|
2
2
|
//# sourceMappingURL=guest-style.d.ts.map
|
package/lib/guest/guest-style.js
CHANGED
|
@@ -34,9 +34,15 @@ input.text:focus{border-color:var(--accent)}
|
|
|
34
34
|
.error{margin:0;text-align:center;color:var(--red);font-size:13px}
|
|
35
35
|
.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}
|
|
36
36
|
@keyframes spin{to{transform:rotate(360deg)}}
|
|
37
|
-
.face{flex:none;display:inline-
|
|
38
|
-
.
|
|
39
|
-
|
|
37
|
+
.face{flex:none;display:inline-flex;position:relative;user-select:none}
|
|
38
|
+
.face svg{display:block;overflow:visible}
|
|
39
|
+
.ta-face-eyes{transform-box:fill-box;transform-origin:center;animation:blink 5.2s infinite}
|
|
40
|
+
.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}
|
|
41
|
+
.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}
|
|
42
|
+
.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}
|
|
43
|
+
@keyframes blink{0%,94%,100%{transform:scaleY(1)}97%{transform:scaleY(.1)}}
|
|
44
|
+
@media (prefers-reduced-motion:reduce){.face *{animation:none!important}}
|
|
45
|
+
@media (prefers-color-scheme:dark){.face[data-face="11"] .ta-face-body>g>circle{fill:#4a4a52}}
|
|
40
46
|
.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)}
|
|
41
47
|
.face i.on{background:var(--accent)}
|
|
42
48
|
.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}
|
|
@@ -47,7 +53,8 @@ input.text:focus{border-color:var(--accent)}
|
|
|
47
53
|
.msg.first{margin-top:10px}
|
|
48
54
|
.msg .slot{width:32px;flex:none;display:flex;justify-content:center}
|
|
49
55
|
.msg .col{display:flex;flex-direction:column;align-items:flex-start;min-width:0;max-width:calc(100% - 84px)}
|
|
50
|
-
.msg .who{margin:0 2px 4px;color:var(--muted);font-size:12px;line-height:16px}
|
|
56
|
+
.msg .who{display:flex;align-items:center;gap:6px;margin:0 2px 4px;color:var(--muted);font-size:12px;line-height:16px}
|
|
57
|
+
.msg.double .bubble{border:1px dashed var(--soft);background:none}
|
|
51
58
|
.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}
|
|
52
59
|
.mine{display:flex;justify-content:flex-end;margin:6px 0 2px}
|
|
53
60
|
.mine .bubble{max-width:78%;border-radius:var(--radius) 5px var(--radius) var(--radius);background:var(--mine);color:var(--mine-fg)}
|
package/lib/guest/guest.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const relay_faces_1 = require("../common/relay-faces");
|
|
3
4
|
const relay_hub_util_1 = require("../common/relay-hub-util");
|
|
4
5
|
const relay_hubs_1 = require("../common/relay-hubs");
|
|
5
6
|
const relay_room_chat_1 = require("../common/relay-room-chat");
|
|
@@ -43,19 +44,25 @@ function div(className, ...children) {
|
|
|
43
44
|
node.append(...children);
|
|
44
45
|
return node;
|
|
45
46
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
const SVG = 'http://www.w3.org/2000/svg';
|
|
48
|
+
function svg(node) {
|
|
49
|
+
var _a;
|
|
50
|
+
const element = document.createElementNS(SVG, node.tag);
|
|
51
|
+
for (const [name, value] of Object.entries(node.attrs)) {
|
|
52
|
+
element.setAttribute(name, String(value));
|
|
50
53
|
}
|
|
51
|
-
|
|
54
|
+
element.append(...((_a = node.children) !== null && _a !== void 0 ? _a : []).map(svg));
|
|
55
|
+
return element;
|
|
52
56
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const node = el('span'
|
|
57
|
-
node.className =
|
|
58
|
-
node.
|
|
57
|
+
/** The face of one in the room, as Ta draws it (FaceUtil.art); a dot at its corner when told whether online. */
|
|
58
|
+
function face(id, size, online) {
|
|
59
|
+
const shown = relay_faces_1.FaceUtil.of(id);
|
|
60
|
+
const node = el('span');
|
|
61
|
+
node.className = 'face';
|
|
62
|
+
node.dataset.face = String(shown);
|
|
63
|
+
node.style.cssText = `width:${size}px;height:${size}px`;
|
|
64
|
+
const picture = svg({ tag: 'svg', attrs: { viewBox: '0 0 40 40', width: size, height: size, 'aria-hidden': 'true' }, children: [relay_faces_1.FaceUtil.art(shown)] });
|
|
65
|
+
node.append(picture);
|
|
59
66
|
if (online !== undefined) {
|
|
60
67
|
const dot = el('i');
|
|
61
68
|
dot.className = online ? 'on' : '';
|
|
@@ -180,7 +187,7 @@ class GuestPage {
|
|
|
180
187
|
void submit();
|
|
181
188
|
}
|
|
182
189
|
});
|
|
183
|
-
this.frame(this.top(), div('center', Object.assign(face(this.link.owner,
|
|
190
|
+
this.frame(this.top(), div('center', Object.assign(face(this.link.owner, 64), { className: 'face card-face' }), Object.assign(el('p', t('invited', { by: this.link.by || '…' })), { className: 'lead' }), Object.assign(el('h1', this.link.title || t('title')), { className: 'room-name' }), Object.assign(el('p', t('joinHint')), { className: 'hint' }), label, ...shown, ask, Object.assign(el('p', t('keep')), { className: 'small' }), Object.assign(el('p', t('haveTa')), { className: 'small' })));
|
|
184
191
|
}
|
|
185
192
|
waiting() {
|
|
186
193
|
this.frame(this.top(), div('center', Object.assign(el('div'), { className: 'spin' }), Object.assign(el('h1', t('waiting', { by: this.link.by || '…' })), { className: 'room-name' }), Object.assign(el('p', t('waitingHint')), { className: 'hint' }), button('plain', t('cancel'), () => void this.hubs.leave(this.link.room).then(() => this.update()))));
|
|
@@ -282,28 +289,34 @@ class GuestPage {
|
|
|
282
289
|
}
|
|
283
290
|
const lines = this.chat.lines;
|
|
284
291
|
const self = (_a = room.members.find(member => member.self)) === null || _a === void 0 ? void 0 : _a.member;
|
|
285
|
-
const
|
|
292
|
+
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; };
|
|
293
|
+
// 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.
|
|
294
|
+
const nameOf = (line) => (line.agent ? line.agent.name : line.double ? t('doubleOf').replace('{name}', personOf(line)) : personOf(line));
|
|
295
|
+
const tagOf = (line) => (line.agent ? t('agentOf').replace('{name}', personOf(line)) : line.double ? t('double') : '');
|
|
296
|
+
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 : ''}`; };
|
|
286
297
|
const nodes = [];
|
|
287
298
|
if (!lines.length) {
|
|
288
299
|
nodes.push(div('empty', t('empty')));
|
|
289
300
|
}
|
|
290
301
|
lines.forEach((line, index) => {
|
|
291
302
|
var _a;
|
|
303
|
+
var _b, _c;
|
|
292
304
|
const before = lines[index - 1];
|
|
293
305
|
const separator = !before || line.at - before.at > PAUSE_MS;
|
|
294
|
-
const first = separator || before
|
|
306
|
+
const first = separator || speaker(before) !== speaker(line) || line.at - before.at > RUN_MS;
|
|
295
307
|
if (separator) {
|
|
296
308
|
nodes.push(div('when', guest_i18n_1.GuestI18n.time(line.at)));
|
|
297
309
|
}
|
|
298
310
|
const bubble = div('bubble', viewer_markdown_1.ViewerMarkdown.render(line.text));
|
|
299
311
|
bubble.title = guest_i18n_1.GuestI18n.time(line.at);
|
|
300
|
-
if (line.from === self) {
|
|
312
|
+
if (line.from === self && !line.agent) {
|
|
301
313
|
nodes.push(div('mine', bubble));
|
|
302
314
|
return;
|
|
303
315
|
}
|
|
304
316
|
const other = room.members.find(member => member.member === line.from);
|
|
305
|
-
const
|
|
306
|
-
|
|
317
|
+
const tag = tagOf(line);
|
|
318
|
+
const col = div('col', ...(first ? [div('who', nameOf(line), ...(tag ? [div('tag', tag)] : []))] : []), bubble);
|
|
319
|
+
nodes.push(div(`msg${first ? ' first' : ''}${line.double || line.agent ? ' double' : ''}`, div('slot', ...(first ? [face((_c = (_b = (_a = line.agent) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : other === null || other === void 0 ? void 0 : other.id) !== null && _c !== void 0 ? _c : line.from, 32)] : [])), col));
|
|
307
320
|
});
|
|
308
321
|
list.replaceChildren(...nodes);
|
|
309
322
|
if (this.stuck) {
|
|
@@ -322,7 +335,7 @@ class GuestPage {
|
|
|
322
335
|
const tags = [member.self ? t('you') : '', member.owner ? t('owner') : '', member.guest ? t('guest') : ''].filter(Boolean);
|
|
323
336
|
const name = div('nm', member.name, ...tags.map(tag => Object.assign(el('span', tag), { className: 'tag' })));
|
|
324
337
|
const status = Object.assign(el('span', member.online ? t('onlineNow') : ''), { className: 'st on' });
|
|
325
|
-
panel.append(div('member', face(member.id,
|
|
338
|
+
panel.append(div('member', face(member.id, 34, member.online), name, status));
|
|
326
339
|
}
|
|
327
340
|
panel.append(div('sep'), button('row', t('rename'), () => {
|
|
328
341
|
var _a, _b;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RelayHubsStore, RelayHubsStoreName } from '../common/relay-hubs';
|
|
1
|
+
import type { RelayHubsStore, RelayHubsStoreName } from '../common/relay-hubs-protocol';
|
|
2
2
|
/** What the rooms of a Ta keep, as files of its agent directory readable by the user alone: `identity.json`, `rooms.json`, `friends.json`. */
|
|
3
3
|
export declare class RelayHubFiles implements RelayHubsStore {
|
|
4
4
|
readonly agentDir: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-relay",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.12.0",
|
|
4
4
|
"description": "Ta from anywhere: a relay that only forwards, and end-to-end encryption between a paired device and ta serve",
|
|
5
5
|
"homepage": "https://github.com/cellbang/cell",
|
|
6
6
|
"bugs": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@celljs/rpc": "4.
|
|
33
|
+
"@celljs/rpc": "4.12.0"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|