@celljs/ta-relay 4.21.0 → 4.23.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 +3 -0
- package/esm/common/index.js +3 -0
- package/esm/common/relay-blobs.d.ts +36 -2
- package/esm/common/relay-blobs.js +33 -5
- package/esm/common/relay-chat-store.d.ts +59 -0
- package/esm/common/relay-chat-store.js +40 -0
- package/esm/common/relay-hub-charter.d.ts +7 -1
- package/esm/common/relay-hub-charter.js +6 -0
- package/esm/common/relay-hub-log.d.ts +65 -0
- package/esm/common/relay-hub-log.js +147 -0
- package/esm/common/relay-hub.d.ts +3 -0
- package/esm/common/relay-hub.js +18 -0
- package/esm/common/relay-hubs-admins.d.ts +1 -0
- package/esm/common/relay-hubs-admins.js +10 -6
- package/esm/common/relay-hubs-chats.d.ts +66 -0
- package/esm/common/relay-hubs-chats.js +342 -0
- package/esm/common/relay-hubs-connection.d.ts +3 -1
- package/esm/common/relay-hubs-connection.js +7 -0
- package/esm/common/relay-hubs-protocol.d.ts +14 -0
- package/esm/common/relay-hubs.d.ts +5 -2
- package/esm/common/relay-hubs.js +31 -13
- package/esm/common/relay-info.d.ts +23 -1
- package/esm/common/relay-info.js +25 -2
- package/esm/common/relay-protocol.d.ts +60 -1
- package/esm/common/relay-protocol.js +15 -0
- package/esm/common/relay-room-app.d.ts +106 -0
- package/esm/common/relay-room-app.js +171 -0
- package/esm/common/relay-room-chat.d.ts +126 -4
- package/esm/common/relay-room-chat.js +230 -6
- package/esm/guest/guest-i18n.d.ts +5 -0
- package/esm/guest/guest-i18n.js +20 -0
- package/esm/guest/guest-style.d.ts +1 -1
- package/esm/guest/guest-style.js +11 -0
- package/esm/guest/guest.js +84 -11
- package/esm/node/index.d.ts +1 -0
- package/esm/node/index.js +1 -0
- package/esm/node/relay-chat-files.d.ts +46 -0
- package/esm/node/relay-chat-files.js +199 -0
- package/esm/node/relay-hub-files.d.ts +11 -1
- package/esm/node/relay-hub-files.js +8 -1
- package/esm/node/relay-server.d.ts +7 -1
- package/esm/node/relay-server.js +23 -13
- package/lib/common/index.d.ts +3 -0
- package/lib/common/index.js +3 -0
- package/lib/common/relay-blobs.d.ts +36 -2
- package/lib/common/relay-blobs.js +34 -6
- package/lib/common/relay-chat-store.d.ts +60 -0
- package/lib/common/relay-chat-store.js +44 -0
- package/lib/common/relay-hub-charter.d.ts +7 -1
- package/lib/common/relay-hub-charter.js +7 -1
- package/lib/common/relay-hub-log.d.ts +66 -0
- package/lib/common/relay-hub-log.js +151 -0
- package/lib/common/relay-hub.d.ts +3 -0
- package/lib/common/relay-hub.js +18 -0
- package/lib/common/relay-hubs-admins.d.ts +1 -0
- package/lib/common/relay-hubs-admins.js +9 -5
- package/lib/common/relay-hubs-chats.d.ts +67 -0
- package/lib/common/relay-hubs-chats.js +346 -0
- package/lib/common/relay-hubs-connection.d.ts +3 -1
- package/lib/common/relay-hubs-connection.js +7 -0
- package/lib/common/relay-hubs-protocol.d.ts +14 -0
- package/lib/common/relay-hubs.d.ts +5 -2
- package/lib/common/relay-hubs.js +30 -12
- package/lib/common/relay-info.d.ts +23 -1
- package/lib/common/relay-info.js +26 -3
- package/lib/common/relay-protocol.d.ts +60 -1
- package/lib/common/relay-protocol.js +16 -1
- package/lib/common/relay-room-app.d.ts +107 -0
- package/lib/common/relay-room-app.js +176 -0
- package/lib/common/relay-room-chat.d.ts +126 -4
- package/lib/common/relay-room-chat.js +231 -7
- package/lib/guest/guest-i18n.d.ts +5 -0
- package/lib/guest/guest-i18n.js +20 -0
- package/lib/guest/guest-style.d.ts +1 -1
- package/lib/guest/guest-style.js +11 -0
- package/lib/guest/guest.js +83 -10
- package/lib/node/index.d.ts +1 -0
- package/lib/node/index.js +1 -0
- package/lib/node/relay-chat-files.d.ts +47 -0
- package/lib/node/relay-chat-files.js +203 -0
- package/lib/node/relay-hub-files.d.ts +11 -1
- package/lib/node/relay-hub-files.js +8 -1
- package/lib/node/relay-server.d.ts +7 -1
- package/lib/node/relay-server.js +21 -11
- package/package.json +3 -3
- package/viewer/join.html +17 -6
- package/viewer/page.html +10 -10
- package/viewer/room.html +26 -15
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type RelayChatState, type RelayChatStore } from './relay-chat-store';
|
|
2
|
+
import { RelayHubsAdmins } from './relay-hubs-admins';
|
|
3
|
+
import { type Live } from './relay-hubs-live';
|
|
4
|
+
import { type RelayHubEvent, type RelayHubFailure, type RelayHubLogItem } from './relay-protocol';
|
|
5
|
+
import { type RelayChatLine, type RelayChatLineExtra } from './relay-room-chat';
|
|
6
|
+
/** The log of a room as this Ta follows it while it runs. */
|
|
7
|
+
declare class LiveChat {
|
|
8
|
+
state?: RelayChatState;
|
|
9
|
+
loading?: Promise<RelayChatState>;
|
|
10
|
+
/** A page of the log asked for, not come yet. */
|
|
11
|
+
syncing: boolean;
|
|
12
|
+
sending: boolean;
|
|
13
|
+
acked: number;
|
|
14
|
+
ackTimer?: ReturnType<typeof setTimeout>;
|
|
15
|
+
lastAt: number;
|
|
16
|
+
readonly ids: Set<string>;
|
|
17
|
+
/** What changes the state, one after another. */
|
|
18
|
+
protected chain: Promise<unknown>;
|
|
19
|
+
run<T>(work: () => Promise<T>): Promise<T>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The part of {@link RelayHubs} that keeps what is said in the rooms (docs/design/ta-chat-history.md 4–6): the log of
|
|
23
|
+
* each room read from the relay after the last number taken, kept on this computer (RelayChatStore); lines said go
|
|
24
|
+
* into an outbox first and to the relay once it is reached, the same line again being the same message there, so
|
|
25
|
+
* nothing is lost nor said twice; a number missed is read again; the relay is told how far this Ta has it.
|
|
26
|
+
*/
|
|
27
|
+
export declare abstract class RelayHubsChats extends RelayHubsAdmins {
|
|
28
|
+
protected readonly chats: RelayChatStore;
|
|
29
|
+
protected readonly following: Map<string, LiveChat>;
|
|
30
|
+
/** The latest lines of a room kept here, before the line `before` when given; those not sent yet last. */
|
|
31
|
+
readChat(roomId: string, options?: {
|
|
32
|
+
before?: string;
|
|
33
|
+
limit?: number;
|
|
34
|
+
}): Promise<{
|
|
35
|
+
lines: RelayChatLine[];
|
|
36
|
+
more: boolean;
|
|
37
|
+
}>;
|
|
38
|
+
/** Says it as this Ta in a room: kept at once, sent once the relay is reached. The line, `pending` till then. */
|
|
39
|
+
say(roomId: string, text: string, extra?: RelayChatLineExtra): Promise<RelayChatLine | undefined>;
|
|
40
|
+
/** What the hub of a room says of its log; `synced` once connected, to read what came while away. */
|
|
41
|
+
protected heardLog(live: Live, event: RelayHubEvent): Promise<void>;
|
|
42
|
+
/** The room was left: what was said there goes from this computer. */
|
|
43
|
+
protected forgetChat(roomId: string): Promise<void>;
|
|
44
|
+
protected chatOf(live: Live): Promise<LiveChat>;
|
|
45
|
+
/**
|
|
46
|
+
* The first time the log of a room is read here: what was said in its state before the log (`chat:` keys), from
|
|
47
|
+
* when this Ta joined, is kept as the start of it (docs/design/ta-chat-history.md 11).
|
|
48
|
+
*/
|
|
49
|
+
protected migrate(live: Live, chat: LiveChat): Promise<void>;
|
|
50
|
+
/** Lines of the log come, in order: each opened against the key its member signs with, kept, told. */
|
|
51
|
+
protected took(live: Live, chat: LiveChat, items: readonly RelayHubLogItem[]): Promise<void>;
|
|
52
|
+
/** Sends the lines waiting, one after another, while the room is reached. */
|
|
53
|
+
protected flush(live: Live, chat: LiveChat): Promise<void>;
|
|
54
|
+
protected post(live: Live, line: RelayChatLine): Promise<{
|
|
55
|
+
ok: boolean;
|
|
56
|
+
v: number;
|
|
57
|
+
error?: RelayHubFailure;
|
|
58
|
+
}>;
|
|
59
|
+
/** The relay took a line of this Ta as number `seq`: kept when it is the next, else read with what came between. Whether to go on. */
|
|
60
|
+
protected posted(live: Live, chat: LiveChat, line: RelayChatLine, seq: number): Promise<boolean>;
|
|
61
|
+
protected refused(live: Live, chat: LiveChat, line: RelayChatLine): Promise<void>;
|
|
62
|
+
protected sync(live: Live, chat: LiveChat): void;
|
|
63
|
+
protected ack(live: Live, chat: LiveChat): void;
|
|
64
|
+
protected remember(chat: LiveChat, id: string): void;
|
|
65
|
+
}
|
|
66
|
+
export {};
|
|
67
|
+
//# sourceMappingURL=relay-hubs-chats.d.ts.map
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RelayHubsChats = void 0;
|
|
4
|
+
const relay_chat_store_1 = require("./relay-chat-store");
|
|
5
|
+
const relay_hub_util_1 = require("./relay-hub-util");
|
|
6
|
+
const relay_hubs_admins_1 = require("./relay-hubs-admins");
|
|
7
|
+
const relay_hubs_live_1 = require("./relay-hubs-live");
|
|
8
|
+
const relay_protocol_1 = require("./relay-protocol");
|
|
9
|
+
const relay_room_chat_1 = require("./relay-room-chat");
|
|
10
|
+
/** Ids of lines taken kept to know one again: the relay could serve an old one anew. */
|
|
11
|
+
const IDS_KEPT = 2000;
|
|
12
|
+
/** How soon after the last line taken the relay is told how far this Ta has the log. */
|
|
13
|
+
const ACK_MS = 2000;
|
|
14
|
+
/** The log of a room as this Ta follows it while it runs. */
|
|
15
|
+
class LiveChat {
|
|
16
|
+
constructor() {
|
|
17
|
+
/** A page of the log asked for, not come yet. */
|
|
18
|
+
this.syncing = false;
|
|
19
|
+
this.sending = false;
|
|
20
|
+
this.acked = 0;
|
|
21
|
+
this.lastAt = 0;
|
|
22
|
+
this.ids = new Set();
|
|
23
|
+
/** What changes the state, one after another. */
|
|
24
|
+
this.chain = Promise.resolve();
|
|
25
|
+
}
|
|
26
|
+
run(work) {
|
|
27
|
+
const done = this.chain.then(work);
|
|
28
|
+
this.chain = done.catch(() => undefined);
|
|
29
|
+
return done;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The part of {@link RelayHubs} that keeps what is said in the rooms (docs/design/ta-chat-history.md 4–6): the log of
|
|
34
|
+
* each room read from the relay after the last number taken, kept on this computer (RelayChatStore); lines said go
|
|
35
|
+
* into an outbox first and to the relay once it is reached, the same line again being the same message there, so
|
|
36
|
+
* nothing is lost nor said twice; a number missed is read again; the relay is told how far this Ta has it.
|
|
37
|
+
*/
|
|
38
|
+
class RelayHubsChats extends relay_hubs_admins_1.RelayHubsAdmins {
|
|
39
|
+
constructor() {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
var _c, _d;
|
|
42
|
+
super(...arguments);
|
|
43
|
+
this.chats = (_d = (_c = this.options.chats) !== null && _c !== void 0 ? _c : (_b = (_a = this.options.store).chats) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _d !== void 0 ? _d : new relay_chat_store_1.RelayChatMemory();
|
|
44
|
+
this.following = new Map();
|
|
45
|
+
}
|
|
46
|
+
/** The latest lines of a room kept here, before the line `before` when given; those not sent yet last. */
|
|
47
|
+
async readChat(roomId, options = {}) {
|
|
48
|
+
var _a;
|
|
49
|
+
var _b;
|
|
50
|
+
const live = this.live.get(roomId);
|
|
51
|
+
if (!live) {
|
|
52
|
+
throw new Error('No such room.');
|
|
53
|
+
}
|
|
54
|
+
const limit = Math.min(Math.max(Math.round(Number(options.limit) || 100), 1), 1000);
|
|
55
|
+
const before = typeof options.before === 'string' ? options.before : undefined;
|
|
56
|
+
const chat = await this.chatOf(live);
|
|
57
|
+
const read = await this.chats.read(roomId, { limit, ...(before ? { before } : {}) });
|
|
58
|
+
return before ? read : { lines: [...read.lines, ...((_b = (_a = chat.state) === null || _a === void 0 ? void 0 : _a.outbox) !== null && _b !== void 0 ? _b : [])], more: read.more };
|
|
59
|
+
}
|
|
60
|
+
/** Says it as this Ta in a room: kept at once, sent once the relay is reached. The line, `pending` till then. */
|
|
61
|
+
async say(roomId, text, extra = {}) {
|
|
62
|
+
var _a, _b, _c, _d;
|
|
63
|
+
var _e;
|
|
64
|
+
const live = this.member(roomId);
|
|
65
|
+
const said = String(text !== null && text !== void 0 ? text : '')
|
|
66
|
+
.trim()
|
|
67
|
+
.slice(0, relay_room_chat_1.RELAY_CHAT_TEXT_MAX);
|
|
68
|
+
const added = relay_room_chat_1.RelayRoomChatUtil.extra(extra);
|
|
69
|
+
if (!said && !((_a = added.images) === null || _a === void 0 ? void 0 : _a.length) && !((_b = added.files) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
const chat = await this.chatOf(live);
|
|
73
|
+
const identity = await this.identityOf(live);
|
|
74
|
+
const name = (_e = (_d = (_c = live.roster) === null || _c === void 0 ? void 0 : _c.members.find(member => member.member === live.record.member)) === null || _d === void 0 ? void 0 : _d.name) !== null && _e !== void 0 ? _e : identity.name;
|
|
75
|
+
const line = await chat.run(async () => {
|
|
76
|
+
const state = chat.state;
|
|
77
|
+
const at = Math.max(Date.now(), chat.lastAt + 1);
|
|
78
|
+
chat.lastAt = at;
|
|
79
|
+
const made = {
|
|
80
|
+
id: relay_room_chat_1.RelayRoomChatUtil.id(),
|
|
81
|
+
from: live.record.member,
|
|
82
|
+
name,
|
|
83
|
+
text: said,
|
|
84
|
+
at,
|
|
85
|
+
...added,
|
|
86
|
+
pending: true,
|
|
87
|
+
};
|
|
88
|
+
state.outbox.push(made);
|
|
89
|
+
await this.chats.setState(roomId, state);
|
|
90
|
+
return made;
|
|
91
|
+
});
|
|
92
|
+
this.emit({ type: 'chat', room: roomId, line });
|
|
93
|
+
void this.flush(live, chat);
|
|
94
|
+
return line;
|
|
95
|
+
}
|
|
96
|
+
/** What the hub of a room says of its log; `synced` once connected, to read what came while away. */
|
|
97
|
+
async heardLog(live, event) {
|
|
98
|
+
var _a;
|
|
99
|
+
var _b;
|
|
100
|
+
if (live.record.status !== 'member' || !live.keys) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const chat = await this.chatOf(live);
|
|
104
|
+
switch (event.t) {
|
|
105
|
+
case 'synced':
|
|
106
|
+
chat.syncing = false;
|
|
107
|
+
await chat.run(() => this.migrate(live, chat));
|
|
108
|
+
this.sync(live, chat);
|
|
109
|
+
return;
|
|
110
|
+
case 'log':
|
|
111
|
+
chat.syncing = false;
|
|
112
|
+
await chat.run(() => this.took(live, chat, event.items));
|
|
113
|
+
if (event.more) {
|
|
114
|
+
this.sync(live, chat);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
this.ack(live, chat);
|
|
118
|
+
void this.flush(live, chat);
|
|
119
|
+
}
|
|
120
|
+
return;
|
|
121
|
+
case 'post': {
|
|
122
|
+
const seq = (_b = (_a = chat.state) === null || _a === void 0 ? void 0 : _a.seq) !== null && _b !== void 0 ? _b : 0;
|
|
123
|
+
if (event.item.s === seq + 1) {
|
|
124
|
+
await chat.run(() => this.took(live, chat, [event.item]));
|
|
125
|
+
clearTimeout(chat.ackTimer);
|
|
126
|
+
chat.ackTimer = setTimeout(() => this.ack(live, chat), ACK_MS);
|
|
127
|
+
}
|
|
128
|
+
else if (event.item.s > seq) {
|
|
129
|
+
// One missed between: read from where this Ta is.
|
|
130
|
+
this.sync(live, chat);
|
|
131
|
+
}
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/** The room was left: what was said there goes from this computer. */
|
|
137
|
+
async forgetChat(roomId) {
|
|
138
|
+
const chat = this.following.get(roomId);
|
|
139
|
+
clearTimeout(chat === null || chat === void 0 ? void 0 : chat.ackTimer);
|
|
140
|
+
this.following.delete(roomId);
|
|
141
|
+
await this.chats.forget(roomId).catch(() => undefined);
|
|
142
|
+
}
|
|
143
|
+
chatOf(live) {
|
|
144
|
+
var _a;
|
|
145
|
+
let chat = this.following.get(live.record.id);
|
|
146
|
+
if (!chat) {
|
|
147
|
+
chat = new LiveChat();
|
|
148
|
+
this.following.set(live.record.id, chat);
|
|
149
|
+
}
|
|
150
|
+
const found = chat;
|
|
151
|
+
(_a = found.loading) !== null && _a !== void 0 ? _a : (found.loading = (async () => {
|
|
152
|
+
var _a;
|
|
153
|
+
const state = (_a = (await this.chats.state(live.record.id))) !== null && _a !== void 0 ? _a : { seq: 0, outbox: [] };
|
|
154
|
+
const latest = await this.chats.read(live.record.id, { limit: IDS_KEPT });
|
|
155
|
+
for (const line of latest.lines) {
|
|
156
|
+
found.ids.add(line.id);
|
|
157
|
+
}
|
|
158
|
+
found.lastAt = Math.max(0, ...latest.lines.map(line => line.at), ...state.outbox.map(line => line.at));
|
|
159
|
+
found.acked = state.seq;
|
|
160
|
+
found.state = state;
|
|
161
|
+
return state;
|
|
162
|
+
})());
|
|
163
|
+
return found.loading.then(() => found);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* The first time the log of a room is read here: what was said in its state before the log (`chat:` keys), from
|
|
167
|
+
* when this Ta joined, is kept as the start of it (docs/design/ta-chat-history.md 11).
|
|
168
|
+
*/
|
|
169
|
+
async migrate(live, chat) {
|
|
170
|
+
var _a, _b;
|
|
171
|
+
const state = chat.state;
|
|
172
|
+
if (state.migrated) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const since = live.record.own ? 0 : ((_a = live.record.joinedAt) !== null && _a !== void 0 ? _a : 0);
|
|
176
|
+
const lines = [];
|
|
177
|
+
for (const [key, value] of live.state) {
|
|
178
|
+
const part = relay_room_chat_1.RelayRoomChatUtil.parse(key);
|
|
179
|
+
if (part && key.startsWith(relay_room_chat_1.RELAY_CHAT_KEY) && value.value !== null) {
|
|
180
|
+
lines.push(...((_b = relay_room_chat_1.RelayRoomChatUtil.lines(part.member, value.value, value.by)) !== null && _b !== void 0 ? _b : []));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const kept = lines.filter(line => line.at >= since && !chat.ids.has(line.id)).sort((a, b) => a.at - b.at || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
184
|
+
if (kept.length) {
|
|
185
|
+
await this.chats.append(live.record.id, kept);
|
|
186
|
+
for (const line of kept) {
|
|
187
|
+
chat.ids.add(line.id);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
state.migrated = true;
|
|
191
|
+
await this.chats.setState(live.record.id, state);
|
|
192
|
+
}
|
|
193
|
+
/** Lines of the log come, in order: each opened against the key its member signs with, kept, told. */
|
|
194
|
+
async took(live, chat, items) {
|
|
195
|
+
var _a, _b;
|
|
196
|
+
var _c;
|
|
197
|
+
const state = chat.state;
|
|
198
|
+
const keys = live.keys;
|
|
199
|
+
if (!keys) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const signs = { ...state.signs };
|
|
203
|
+
for (const member of (_c = (_a = live.roster) === null || _a === void 0 ? void 0 : _a.members) !== null && _c !== void 0 ? _c : []) {
|
|
204
|
+
signs[member.member] = member.sign;
|
|
205
|
+
}
|
|
206
|
+
state.signs = signs;
|
|
207
|
+
const taken = [];
|
|
208
|
+
for (const item of items) {
|
|
209
|
+
if (!(item.s > state.seq)) {
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
state.seq = item.s;
|
|
213
|
+
const signed = await relay_hub_util_1.RelayHubUtil.openIn(keys, item.d, member => signs[member]);
|
|
214
|
+
const line = signed && signed.m === item.m ? relay_room_chat_1.RelayRoomChatUtil.signed(item.m, (_b = signed.b) === null || _b === void 0 ? void 0 : _b.chat, item.s) : undefined;
|
|
215
|
+
if (!line || chat.ids.has(line.id)) {
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
this.remember(chat, line.id);
|
|
219
|
+
state.outbox = state.outbox.filter(waiting => waiting.id !== line.id);
|
|
220
|
+
taken.push(line);
|
|
221
|
+
}
|
|
222
|
+
if (taken.length) {
|
|
223
|
+
await this.chats.append(live.record.id, taken);
|
|
224
|
+
}
|
|
225
|
+
await this.chats.setState(live.record.id, state);
|
|
226
|
+
for (const line of taken) {
|
|
227
|
+
this.emit({ type: 'chat', room: live.record.id, line });
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/** Sends the lines waiting, one after another, while the room is reached. */
|
|
231
|
+
async flush(live, chat) {
|
|
232
|
+
var _a, _b;
|
|
233
|
+
if (chat.sending || chat.syncing || !(((_a = live.socket) === null || _a === void 0 ? void 0 : _a.readyState) === relay_hubs_live_1.OPEN && live.synced)) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
chat.sending = true;
|
|
237
|
+
try {
|
|
238
|
+
for (;;) {
|
|
239
|
+
const line = (_b = chat.state) === null || _b === void 0 ? void 0 : _b.outbox.find(waiting => waiting.pending);
|
|
240
|
+
if (!line) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
const result = await this.post(live, line);
|
|
244
|
+
if (result.error === 'large' || result.error === 'invalid') {
|
|
245
|
+
await chat.run(() => this.refused(live, chat, line));
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
if (!result.ok || !(await chat.run(() => this.posted(live, chat, line, result.v)))) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
finally {
|
|
254
|
+
chat.sending = false;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
async post(live, line) {
|
|
258
|
+
const identity = await this.identityOf(live);
|
|
259
|
+
const [stored] = relay_room_chat_1.RelayRoomChatUtil.stored([line]);
|
|
260
|
+
const d = await relay_hub_util_1.RelayHubUtil.sealIn(live.keys, identity, live.record.member, { chat: stored });
|
|
261
|
+
const id = this.nextId++;
|
|
262
|
+
return new Promise(resolve => {
|
|
263
|
+
const timer = setTimeout(() => {
|
|
264
|
+
live.done.delete(id);
|
|
265
|
+
resolve({ ok: false, v: 0 });
|
|
266
|
+
}, relay_hubs_live_1.READY_MS);
|
|
267
|
+
live.done.set(id, answer => {
|
|
268
|
+
clearTimeout(timer);
|
|
269
|
+
resolve(answer);
|
|
270
|
+
});
|
|
271
|
+
try {
|
|
272
|
+
this.request(live, { t: 'post', id, mid: line.id, d });
|
|
273
|
+
}
|
|
274
|
+
catch (_a) {
|
|
275
|
+
clearTimeout(timer);
|
|
276
|
+
live.done.delete(id);
|
|
277
|
+
resolve({ ok: false, v: 0 });
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
/** The relay took a line of this Ta as number `seq`: kept when it is the next, else read with what came between. Whether to go on. */
|
|
282
|
+
async posted(live, chat, line, seq) {
|
|
283
|
+
var _a;
|
|
284
|
+
const state = chat.state;
|
|
285
|
+
if (seq <= state.seq || !((_a = chat.state) === null || _a === void 0 ? void 0 : _a.outbox.some(waiting => waiting.id === line.id))) {
|
|
286
|
+
state.outbox = state.outbox.filter(waiting => waiting.id !== line.id);
|
|
287
|
+
await this.chats.setState(live.record.id, state);
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
if (seq !== state.seq + 1) {
|
|
291
|
+
this.sync(live, chat);
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
const { pending: _pending, ...sent } = line;
|
|
295
|
+
const taken = { ...sent, seq };
|
|
296
|
+
state.seq = seq;
|
|
297
|
+
state.outbox = state.outbox.filter(waiting => waiting.id !== line.id);
|
|
298
|
+
this.remember(chat, line.id);
|
|
299
|
+
await this.chats.append(live.record.id, [taken]);
|
|
300
|
+
await this.chats.setState(live.record.id, state);
|
|
301
|
+
this.emit({ type: 'chat', room: live.record.id, line: taken });
|
|
302
|
+
clearTimeout(chat.ackTimer);
|
|
303
|
+
chat.ackTimer = setTimeout(() => this.ack(live, chat), ACK_MS);
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
async refused(live, chat, line) {
|
|
307
|
+
const state = chat.state;
|
|
308
|
+
const { pending: _pending, ...rest } = line;
|
|
309
|
+
const failed = { ...rest, failed: true };
|
|
310
|
+
state.outbox = state.outbox.map(waiting => (waiting.id === line.id ? failed : waiting));
|
|
311
|
+
await this.chats.setState(live.record.id, state);
|
|
312
|
+
this.emit({ type: 'chat', room: live.record.id, line: failed });
|
|
313
|
+
}
|
|
314
|
+
sync(live, chat) {
|
|
315
|
+
var _a, _b;
|
|
316
|
+
var _c;
|
|
317
|
+
if (chat.syncing || ((_a = live.socket) === null || _a === void 0 ? void 0 : _a.readyState) !== relay_hubs_live_1.OPEN) {
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
chat.syncing = true;
|
|
321
|
+
try {
|
|
322
|
+
this.request(live, { t: 'sync', after: (_c = (_b = chat.state) === null || _b === void 0 ? void 0 : _b.seq) !== null && _c !== void 0 ? _c : 0, limit: relay_protocol_1.RELAY_HUB_SYNC_PAGE });
|
|
323
|
+
}
|
|
324
|
+
catch (_d) {
|
|
325
|
+
chat.syncing = false;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
ack(live, chat) {
|
|
329
|
+
var _a, _b;
|
|
330
|
+
var _c;
|
|
331
|
+
clearTimeout(chat.ackTimer);
|
|
332
|
+
const seq = (_c = (_a = chat.state) === null || _a === void 0 ? void 0 : _a.seq) !== null && _c !== void 0 ? _c : 0;
|
|
333
|
+
if (seq > chat.acked && ((_b = live.socket) === null || _b === void 0 ? void 0 : _b.readyState) === relay_hubs_live_1.OPEN) {
|
|
334
|
+
chat.acked = seq;
|
|
335
|
+
this.request(live, { t: 'ack', seq });
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
remember(chat, id) {
|
|
339
|
+
chat.ids.add(id);
|
|
340
|
+
if (chat.ids.size > IDS_KEPT) {
|
|
341
|
+
chat.ids.delete(chat.ids.values().next().value);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
exports.RelayHubsChats = RelayHubsChats;
|
|
346
|
+
//# sourceMappingURL=relay-hubs-chats.js.map
|
|
@@ -3,7 +3,7 @@ import { type RelayHubAskBody, type RelayHubMember } from './relay-hub-util';
|
|
|
3
3
|
import { type Live, type MessageBody } from './relay-hubs-live';
|
|
4
4
|
import type { RelayHubsOptions, RelayRoomEvent, RelayRoomRecord, RelayRoomRequest, RelayRoomStatus } from './relay-hubs-protocol';
|
|
5
5
|
import { type RelayIdentity, type RelayPublicIdentity } from './relay-identity';
|
|
6
|
-
import { type RelayHubEntry, type RelayHubFailure, type RelayHubRequest, type RelayHubRoster } from './relay-protocol';
|
|
6
|
+
import { type RelayHubEntry, type RelayHubEvent, type RelayHubFailure, type RelayHubRequest, type RelayHubRoster } from './relay-protocol';
|
|
7
7
|
/**
|
|
8
8
|
* The half of {@link RelayHubs} that keeps a connection to the hub of each room and reads what comes over it:
|
|
9
9
|
* connecting again, the welcome, the roster, the state and the messages, each opened and checked against the
|
|
@@ -62,6 +62,8 @@ export declare abstract class RelayHubsConnection {
|
|
|
62
62
|
protected signOf(live: Live): (member: string) => string | undefined;
|
|
63
63
|
protected readEntry(live: Live, entry: RelayHubEntry, tell: boolean): Promise<void>;
|
|
64
64
|
protected readMessage(live: Live, from: string, sealed: string): Promise<void>;
|
|
65
|
+
/** What the hub says of the log of the room, and `synced` (RelayHubsChats). */
|
|
66
|
+
protected heardLog(_live: Live, _event: RelayHubEvent): Promise<void>;
|
|
65
67
|
/** A member set a key naming another: the owner clears it (RelayHubs). */
|
|
66
68
|
protected foreignSet(_live: Live, _key: string): void;
|
|
67
69
|
/** Ids of those the user chose as friends. */
|
|
@@ -269,6 +269,11 @@ class RelayHubsConnection {
|
|
|
269
269
|
resolve();
|
|
270
270
|
}
|
|
271
271
|
this.emit({ type: 'rooms' });
|
|
272
|
+
await this.heardLog(live, event);
|
|
273
|
+
return;
|
|
274
|
+
case 'log':
|
|
275
|
+
case 'post':
|
|
276
|
+
await this.heardLog(live, event);
|
|
272
277
|
return;
|
|
273
278
|
case 'state':
|
|
274
279
|
await this.readEntry(live, event.entry, true);
|
|
@@ -524,6 +529,8 @@ class RelayHubsConnection {
|
|
|
524
529
|
}
|
|
525
530
|
this.emit({ type: 'message', room: live.record.id, from, name: (_b = sender === null || sender === void 0 ? void 0 : sender.name) !== null && _b !== void 0 ? _b : '', data: signed.b.d });
|
|
526
531
|
}
|
|
532
|
+
/** What the hub says of the log of the room, and `synced` (RelayHubsChats). */
|
|
533
|
+
async heardLog(_live, _event) { }
|
|
527
534
|
/** A member set a key naming another: the owner clears it (RelayHubs). */
|
|
528
535
|
foreignSet(_live, _key) { }
|
|
529
536
|
/** Ids of those the user chose as friends. */
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { RelayChatStore } from './relay-chat-store';
|
|
1
2
|
import type { RelayIdentity, RelayPublicIdentity } from './relay-identity';
|
|
3
|
+
import type { RelayChatLine } from './relay-room-chat';
|
|
2
4
|
/** `member` in the room; `waiting` for the owner to answer; `refused` by the owner; `gone`: closed, removed, or the invitation no longer works. */
|
|
3
5
|
export type RelayRoomStatus = 'member' | 'waiting' | 'refused' | 'gone';
|
|
4
6
|
/** A room this Ta is in or asked to join, in `rooms.json` of the agent directory (docs/design/ta-link.md 3.5). */
|
|
@@ -89,6 +91,8 @@ export interface RelayRoomInfo {
|
|
|
89
91
|
capacity?: number;
|
|
90
92
|
/** The rules its owner set, for all (RelayHubRules); none when it set none. */
|
|
91
93
|
rules?: Record<string, boolean>;
|
|
94
|
+
/** Messages from before they joined a newcomer reads, as its owner set; none: none. */
|
|
95
|
+
history?: number;
|
|
92
96
|
ownerName: string;
|
|
93
97
|
status: RelayRoomStatus;
|
|
94
98
|
reason?: RelayRoomRecord['reason'];
|
|
@@ -165,6 +169,12 @@ export type RelayRoomEvent = {
|
|
|
165
169
|
from: string;
|
|
166
170
|
name: string;
|
|
167
171
|
data: unknown;
|
|
172
|
+
}
|
|
173
|
+
/** A line of the chat of a room: said here (`pending`), sent, refused (`failed`), or taken from another member. */
|
|
174
|
+
| {
|
|
175
|
+
type: 'chat';
|
|
176
|
+
room: string;
|
|
177
|
+
line: RelayChatLine;
|
|
168
178
|
} | {
|
|
169
179
|
type: 'state';
|
|
170
180
|
room: string;
|
|
@@ -175,6 +185,8 @@ export type RelayRoomEvent = {
|
|
|
175
185
|
};
|
|
176
186
|
/** Where a {@link RelayHubs} keeps what it knows: files of the agent directory for Ta, the storage of a browser for a guest. */
|
|
177
187
|
export interface RelayHubsStore {
|
|
188
|
+
/** Where what is said in the rooms is kept, when not in memory (RelayHubsOptions.chats says otherwise). */
|
|
189
|
+
chats?(): RelayChatStore | undefined;
|
|
178
190
|
read<T>(name: RelayHubsStoreName): T | undefined;
|
|
179
191
|
/** Holds keys: kept where the user alone reads it. */
|
|
180
192
|
write(name: RelayHubsStoreName, value: unknown): void;
|
|
@@ -192,6 +204,8 @@ export interface RelayHubsOptions {
|
|
|
192
204
|
guest?: boolean;
|
|
193
205
|
/** The relay new rooms are made on; `use` the feature a room is for (relays.json), `rooms` when none is said. */
|
|
194
206
|
relay(use?: string): string;
|
|
207
|
+
/** Where what is said in the rooms is kept (docs/design/ta-chat-history.md 8); in memory without. */
|
|
208
|
+
chats?: RelayChatStore;
|
|
195
209
|
/** First wait before connecting again; it doubles up to 30 seconds. */
|
|
196
210
|
reconnectDelayMs?: number;
|
|
197
211
|
pingMs?: number;
|
|
@@ -2,7 +2,7 @@ import { RelayFriendSends, type RelayFriendShare } from './relay-friend-sends';
|
|
|
2
2
|
import { RelayFriends } from './relay-friends';
|
|
3
3
|
import { type RelayGroupInvite, RelayGroupInvites } from './relay-group-invites';
|
|
4
4
|
import { type RelayHubAskBody } from './relay-hub-util';
|
|
5
|
-
import {
|
|
5
|
+
import { RelayHubsChats } from './relay-hubs-chats';
|
|
6
6
|
import { Live } from './relay-hubs-live';
|
|
7
7
|
import type { RelayFriend, RelayFriendInfo, RelayFriendRequest, RelayRoomEvent, RelayRoomInfo, RelayRoomRecord, RelayRoomRequest, RelayRoomValue } from './relay-hubs-protocol';
|
|
8
8
|
import { type RelayPublicIdentity } from './relay-identity';
|
|
@@ -12,7 +12,7 @@ import { type RelayPublicIdentity } from './relay-identity';
|
|
|
12
12
|
* the others; every message signed by its member and sealed with the key of the room. The friends are a room of
|
|
13
13
|
* their own (RelayFriends).
|
|
14
14
|
*/
|
|
15
|
-
export declare class RelayHubs extends
|
|
15
|
+
export declare class RelayHubs extends RelayHubsChats {
|
|
16
16
|
protected readonly book: RelayFriends;
|
|
17
17
|
protected readonly groups: RelayGroupInvites;
|
|
18
18
|
protected readonly sends: RelayFriendSends;
|
|
@@ -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;
|
package/lib/common/relay-hubs.js
CHANGED
|
@@ -6,7 +6,7 @@ const relay_friends_1 = require("./relay-friends");
|
|
|
6
6
|
const relay_group_invites_1 = require("./relay-group-invites");
|
|
7
7
|
const relay_hub_charter_1 = require("./relay-hub-charter");
|
|
8
8
|
const relay_hub_util_1 = require("./relay-hub-util");
|
|
9
|
-
const
|
|
9
|
+
const relay_hubs_chats_1 = require("./relay-hubs-chats");
|
|
10
10
|
const relay_hubs_live_1 = require("./relay-hubs-live");
|
|
11
11
|
const relay_identity_1 = require("./relay-identity");
|
|
12
12
|
const relay_protocol_1 = require("./relay-protocol");
|
|
@@ -17,7 +17,7 @@ const DAY_MS = 24 * 60 * 60 * 1000;
|
|
|
17
17
|
* the others; every message signed by its member and sealed with the key of the room. The friends are a room of
|
|
18
18
|
* their own (RelayFriends).
|
|
19
19
|
*/
|
|
20
|
-
class RelayHubs extends
|
|
20
|
+
class RelayHubs extends relay_hubs_chats_1.RelayHubsChats {
|
|
21
21
|
constructor() {
|
|
22
22
|
super(...arguments);
|
|
23
23
|
this.book = new relay_friends_1.RelayFriends({
|
|
@@ -65,6 +65,7 @@ class RelayHubs extends relay_hubs_admins_1.RelayHubsAdmins {
|
|
|
65
65
|
getState: (room, prefix) => this.getState(room, prefix),
|
|
66
66
|
setState: (room, key, value) => this.setState(room, key, value),
|
|
67
67
|
}, this.options.store);
|
|
68
|
+
this.guestsIn = new Map();
|
|
68
69
|
}
|
|
69
70
|
/** Connects to the rooms of rooms.json, and keeps connected. */
|
|
70
71
|
start() {
|
|
@@ -232,8 +233,8 @@ class RelayHubs extends relay_hubs_admins_1.RelayHubsAdmins {
|
|
|
232
233
|
}
|
|
233
234
|
/** The user's answer to one asking to join: admitted, it gets the key of the room and is in the roster. */
|
|
234
235
|
async answer(roomId, askId, accept) {
|
|
235
|
-
var _a, _b;
|
|
236
|
-
var
|
|
236
|
+
var _a, _b, _c;
|
|
237
|
+
var _d, _e;
|
|
237
238
|
const live = this.managed(roomId);
|
|
238
239
|
const asked = live.asks.get(askId);
|
|
239
240
|
if (!asked) {
|
|
@@ -254,7 +255,7 @@ class RelayHubs extends relay_hubs_admins_1.RelayHubsAdmins {
|
|
|
254
255
|
...(live.record.unlisted ? { unlisted: true } : {}),
|
|
255
256
|
};
|
|
256
257
|
const ask = asked.body;
|
|
257
|
-
if (((
|
|
258
|
+
if (((_d = (_a = live.roster) === null || _a === void 0 ? void 0 : _a.members.length) !== null && _d !== void 0 ? _d : 0) >= this.capacityOf(live)) {
|
|
258
259
|
throw new Error('The room is full.');
|
|
259
260
|
}
|
|
260
261
|
const head = live.record.owner;
|
|
@@ -264,7 +265,7 @@ class RelayHubs extends relay_hubs_admins_1.RelayHubsAdmins {
|
|
|
264
265
|
const answer = await relay_hub_util_1.RelayHubUtil.sealAnswer(identity, live.record.id, ask, body, asked.invite, proof);
|
|
265
266
|
const member = { ...relay_identity_1.RelayIdentityUtil.publicOf(ask), member: ask.member, ...(ask.guest ? { guest: true } : {}), at: Date.now() };
|
|
266
267
|
const roster = await this.nextRoster(live, members => [...members.filter(other => other.member !== ask.member), member]);
|
|
267
|
-
this.request(live, { t: 'admit', ask: askId, answer, roster });
|
|
268
|
+
this.request(live, { t: 'admit', ask: askId, answer, roster, history: (_e = (_c = live.charter) === null || _c === void 0 ? void 0 : _c.history) !== null && _e !== void 0 ? _e : 0 });
|
|
268
269
|
}
|
|
269
270
|
live.asks.delete(askId);
|
|
270
271
|
this.emit({ type: 'rooms' });
|
|
@@ -301,6 +302,7 @@ class RelayHubs extends relay_hubs_admins_1.RelayHubsAdmins {
|
|
|
301
302
|
this.disconnect(live);
|
|
302
303
|
this.live.delete(roomId);
|
|
303
304
|
this.save();
|
|
305
|
+
await this.forgetChat(roomId);
|
|
304
306
|
this.emit({ type: 'rooms' });
|
|
305
307
|
}
|
|
306
308
|
/** To every other member, or to one (`to`, its member id). */
|
|
@@ -446,7 +448,7 @@ class RelayHubs extends relay_hubs_admins_1.RelayHubsAdmins {
|
|
|
446
448
|
return this.book.ids();
|
|
447
449
|
}
|
|
448
450
|
heardAsk(live, ask) {
|
|
449
|
-
var _a;
|
|
451
|
+
var _a, _b;
|
|
450
452
|
if (this.isFriends(live)) {
|
|
451
453
|
this.book.asked(ask);
|
|
452
454
|
}
|
|
@@ -454,10 +456,25 @@ class RelayHubs extends relay_hubs_admins_1.RelayHubsAdmins {
|
|
|
454
456
|
// A friend the user invited: in at once, as the user chose it; asked as any other should that fail.
|
|
455
457
|
void this.answer(live.record.id, ask.member, true).then(() => this.groups.admitted(live.record, ask.id), () => super.heardAsk(live, ask));
|
|
456
458
|
}
|
|
459
|
+
else if (ask.guest && ((_b = live.charter) === null || _b === void 0 ? void 0 : _b.rules[relay_hub_charter_1.RELAY_GUESTS_RULE]) && this.manages(live) && this.guestsLetIn(live.record.id)) {
|
|
460
|
+
// The owner lets those of a browser in without asking (they only chat), so many an hour; asked past it, or should that fail.
|
|
461
|
+
void this.answer(live.record.id, ask.member, true).catch(() => super.heardAsk(live, ask));
|
|
462
|
+
}
|
|
457
463
|
else {
|
|
458
464
|
super.heardAsk(live, ask);
|
|
459
465
|
}
|
|
460
466
|
}
|
|
467
|
+
/** One more guest let in without asking fits in the hour of a room (RELAY_GUESTS_PER_HOUR): counted. */
|
|
468
|
+
guestsLetIn(room) {
|
|
469
|
+
var _a;
|
|
470
|
+
const now = Date.now();
|
|
471
|
+
const times = ((_a = this.guestsIn.get(room)) !== null && _a !== void 0 ? _a : []).filter(at => now - at < 60 * 60 * 1000);
|
|
472
|
+
if (times.length >= relay_hub_charter_1.RELAY_GUESTS_PER_HOUR) {
|
|
473
|
+
return false;
|
|
474
|
+
}
|
|
475
|
+
this.guestsIn.set(room, [...times, now]);
|
|
476
|
+
return true;
|
|
477
|
+
}
|
|
461
478
|
foreignSet(live, key) {
|
|
462
479
|
// Not awaited: the owner clears what one set under another's name, as soon as it is in the room.
|
|
463
480
|
void this.setState(live.record.id, key, null).catch(() => undefined);
|
|
@@ -485,10 +502,10 @@ class RelayHubs extends relay_hubs_admins_1.RelayHubsAdmins {
|
|
|
485
502
|
}
|
|
486
503
|
}
|
|
487
504
|
info(live) {
|
|
488
|
-
var _a, _b;
|
|
489
|
-
var
|
|
505
|
+
var _a, _b, _c;
|
|
506
|
+
var _d, _e;
|
|
490
507
|
const { record } = live;
|
|
491
|
-
const members = ((
|
|
508
|
+
const members = ((_d = (_a = live.roster) === null || _a === void 0 ? void 0 : _a.members) !== null && _d !== void 0 ? _d : []).map(member => { var _a; return ({
|
|
492
509
|
member: member.member,
|
|
493
510
|
id: member.id,
|
|
494
511
|
name: member.name,
|
|
@@ -508,12 +525,13 @@ class RelayHubs extends relay_hubs_admins_1.RelayHubsAdmins {
|
|
|
508
525
|
relay: record.relay,
|
|
509
526
|
owner: record.own,
|
|
510
527
|
...(!record.own && this.isAdmin(live, record.member) ? { admin: true } : {}),
|
|
511
|
-
...(record.own ? { capacity: (
|
|
528
|
+
...(record.own ? { capacity: (_e = record.capacity) !== null && _e !== void 0 ? _e : relay_protocol_1.RELAY_ROOM_MAX_MEMBERS } : {}),
|
|
512
529
|
...(live.charter && Object.keys(live.charter.rules).length ? { rules: { ...live.charter.rules } } : {}),
|
|
530
|
+
...(((_b = live.charter) === null || _b === void 0 ? void 0 : _b.history) ? { history: live.charter.history } : {}),
|
|
513
531
|
ownerName: record.owner.name,
|
|
514
532
|
status: record.status,
|
|
515
533
|
...(record.reason ? { reason: record.reason } : {}),
|
|
516
|
-
connected: ((
|
|
534
|
+
connected: ((_c = live.socket) === null || _c === void 0 ? void 0 : _c.readyState) === relay_hubs_live_1.OPEN && (live.synced || record.status === 'waiting'),
|
|
517
535
|
members,
|
|
518
536
|
createdAt: record.createdAt,
|
|
519
537
|
...(record.joinedAt ? { joinedAt: record.joinedAt } : {}),
|