@celljs/ta-relay 4.11.0 → 4.13.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 (86) hide show
  1. package/README.en.md +26 -1
  2. package/README.md +26 -1
  3. package/esm/common/index.d.ts +5 -0
  4. package/esm/common/index.js +5 -0
  5. package/esm/common/relay-faces.d.ts +32 -0
  6. package/esm/common/relay-faces.js +208 -0
  7. package/esm/common/relay-friends.d.ts +154 -0
  8. package/esm/common/relay-friends.js +482 -0
  9. package/esm/common/relay-hub-util.d.ts +9 -0
  10. package/esm/common/relay-hub-util.js +19 -2
  11. package/esm/common/relay-hubs-connection.d.ts +110 -0
  12. package/esm/common/relay-hubs-connection.js +508 -0
  13. package/esm/common/relay-hubs-protocol.d.ts +174 -0
  14. package/esm/common/relay-hubs-protocol.js +2 -0
  15. package/esm/common/relay-hubs.d.ts +68 -216
  16. package/esm/common/relay-hubs.js +303 -507
  17. package/esm/common/relay-identity.d.ts +2 -0
  18. package/esm/common/relay-info.d.ts +44 -0
  19. package/esm/common/relay-info.js +94 -0
  20. package/esm/common/relay-protocol.d.ts +7 -3
  21. package/esm/common/relay-protocol.js +7 -3
  22. package/esm/common/relay-room-chat.d.ts +36 -2
  23. package/esm/common/relay-room-chat.js +32 -7
  24. package/esm/common/relay-spot.d.ts +122 -0
  25. package/esm/common/relay-spot.js +179 -0
  26. package/esm/guest/guest-i18n.d.ts +5 -0
  27. package/esm/guest/guest-i18n.js +10 -0
  28. package/esm/guest/guest-style.d.ts +1 -1
  29. package/esm/guest/guest-style.js +11 -4
  30. package/esm/guest/guest.js +39 -18
  31. package/esm/node/index.d.ts +2 -0
  32. package/esm/node/index.js +2 -0
  33. package/esm/node/relay-file-storage.d.ts +32 -0
  34. package/esm/node/relay-file-storage.js +101 -0
  35. package/esm/node/relay-host.d.ts +63 -28
  36. package/esm/node/relay-host.js +145 -52
  37. package/esm/node/relay-hub-files.d.ts +1 -1
  38. package/esm/node/relay-server.d.ts +37 -3
  39. package/esm/node/relay-server.js +193 -37
  40. package/esm/node/relay-store.d.ts +34 -6
  41. package/esm/node/relay-store.js +54 -22
  42. package/esm/node/relays-file.d.ts +139 -0
  43. package/esm/node/relays-file.js +373 -0
  44. package/lib/common/index.d.ts +5 -0
  45. package/lib/common/index.js +5 -0
  46. package/lib/common/relay-faces.d.ts +33 -0
  47. package/lib/common/relay-faces.js +211 -0
  48. package/lib/common/relay-friends.d.ts +155 -0
  49. package/lib/common/relay-friends.js +486 -0
  50. package/lib/common/relay-hub-util.d.ts +9 -0
  51. package/lib/common/relay-hub-util.js +19 -2
  52. package/lib/common/relay-hubs-connection.d.ts +111 -0
  53. package/lib/common/relay-hubs-connection.js +513 -0
  54. package/lib/common/relay-hubs-protocol.d.ts +175 -0
  55. package/lib/common/relay-hubs-protocol.js +3 -0
  56. package/lib/common/relay-hubs.d.ts +68 -216
  57. package/lib/common/relay-hubs.js +311 -515
  58. package/lib/common/relay-identity.d.ts +2 -0
  59. package/lib/common/relay-info.d.ts +45 -0
  60. package/lib/common/relay-info.js +97 -0
  61. package/lib/common/relay-protocol.d.ts +7 -3
  62. package/lib/common/relay-protocol.js +8 -4
  63. package/lib/common/relay-room-chat.d.ts +36 -2
  64. package/lib/common/relay-room-chat.js +32 -7
  65. package/lib/common/relay-spot.d.ts +123 -0
  66. package/lib/common/relay-spot.js +183 -0
  67. package/lib/guest/guest-i18n.d.ts +5 -0
  68. package/lib/guest/guest-i18n.js +10 -0
  69. package/lib/guest/guest-style.d.ts +1 -1
  70. package/lib/guest/guest-style.js +11 -4
  71. package/lib/guest/guest.js +39 -18
  72. package/lib/node/index.d.ts +2 -0
  73. package/lib/node/index.js +2 -0
  74. package/lib/node/relay-file-storage.d.ts +33 -0
  75. package/lib/node/relay-file-storage.js +105 -0
  76. package/lib/node/relay-host.d.ts +63 -28
  77. package/lib/node/relay-host.js +146 -53
  78. package/lib/node/relay-hub-files.d.ts +1 -1
  79. package/lib/node/relay-server.d.ts +37 -3
  80. package/lib/node/relay-server.js +193 -37
  81. package/lib/node/relay-store.d.ts +34 -6
  82. package/lib/node/relay-store.js +54 -22
  83. package/lib/node/relays-file.d.ts +140 -0
  84. package/lib/node/relays-file.js +378 -0
  85. package/package.json +2 -2
  86. package/viewer/room.html +21 -14
@@ -0,0 +1,211 @@
1
+ "use strict";
2
+ /*
3
+ * The faces of those who are not Ta (agents, the people of rooms), framework-free so that Ta Web (ui.Face, React) and
4
+ * the page of web guests of the relay (src/guest, the DOM) draw the same: a small coloured shape with two eyes, cheeks
5
+ * and a mouth, one of FACE_COUNT, on a 40 × 40 grid. Their styles (`ta-face-eyes` blinks, `ta-face-look` looks
6
+ * about while at work) are those of the page that draws them.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.FaceUtil = exports.FACE_COUNT = void 0;
10
+ /** How many faces there are. */
11
+ exports.FACE_COUNT = 16;
12
+ const BLUE = '#4285F4';
13
+ const RED = '#EA4335';
14
+ const YELLOW = '#FBBC05';
15
+ const GREEN = '#34A853';
16
+ const MINT = '#5CC27F';
17
+ const ORANGE = '#EE7B3B';
18
+ const VIOLET = '#8C5CF0';
19
+ const CREAM = '#F1DFC0';
20
+ const TEAL = '#26B0A9';
21
+ const PINK = '#F27BA6';
22
+ const LILAC = '#B49CF5';
23
+ const SKY = '#45B5E8';
24
+ const INDIGO = '#5C6BC0';
25
+ const MIST = '#DCE3F0';
26
+ const INK = '#202124';
27
+ const WHITE = '#FFFFFF';
28
+ const CHEEK = 'rgba(255, 160, 185, 0.55)';
29
+ /** The edge of a light face. */
30
+ const EDGE = 'rgba(0, 0, 0, 0.14)';
31
+ const CHEEK_DEEP = 'rgba(120, 10, 30, 0.35)';
32
+ const CHEEK_WARM = 'rgba(234, 67, 53, 0.4)';
33
+ /** By face: the order is that of the shapes drawn in {@link shape}. */
34
+ const LOOKS = [
35
+ { color: MINT, eye: '#1D3B27', cheek: CHEEK, eyeY: 21, gap: 8 }, // round
36
+ { color: BLUE, eye: WHITE, cheek: CHEEK, eyeY: 23, gap: 8 }, // cat
37
+ { color: RED, eye: WHITE, cheek: CHEEK_DEEP, eyeY: 22, gap: 8 }, // pentagon
38
+ { color: CREAM, eye: '#4A3420', cheek: 'rgba(240, 120, 120, 0.5)', accent: '#DDBF8E', eyeY: 22, gap: 7.6 }, // bear
39
+ { color: GREEN, eye: WHITE, cheek: CHEEK, eyeY: 19, gap: 7.2 }, // capsule
40
+ { color: INDIGO, eye: WHITE, cheek: CHEEK, eyeY: 20, gap: 7.4 }, // diamond
41
+ { color: YELLOW, eye: INK, cheek: CHEEK_WARM, accent: '#F29900', eyeY: 24, gap: 8.4 }, // bun
42
+ { color: VIOLET, eye: '#22134A', cheek: CHEEK, eyeY: 20, gap: 8 }, // hexagon
43
+ { color: MIST, eye: '#2B3245', cheek: CHEEK, eyeY: 19, gap: 7.6 }, // ghost
44
+ { color: SKY, eye: WHITE, cheek: CHEEK, eyeY: 21, gap: 6.4 }, // star
45
+ { color: ORANGE, eye: '#3D1C08', cheek: CHEEK, accent: GREEN, eyeY: 22, gap: 8.6, brows: true }, // pumpkin
46
+ { color: WHITE, eye: WHITE, cheek: CHEEK, accent: INK, mouth: INK, eyeY: 22, gap: 10 }, // panda
47
+ { color: TEAL, eye: WHITE, cheek: CHEEK, accent: '#1B8A84', eyeY: 22.5, gap: 8.4 }, // screen
48
+ { color: PINK, eye: '#4A1428', cheek: 'rgba(160, 20, 70, 0.3)', eyeY: 24, gap: 7.4 }, // drop
49
+ { color: LILAC, eye: '#2A1A5E', cheek: CHEEK, eyeY: 25, gap: 8 }, // rabbit
50
+ { color: YELLOW, eye: INK, cheek: CHEEK_WARM, eyeY: 25, gap: 7.4 }, // triangle
51
+ ];
52
+ /** The corners of a polygon of `count` sides around (cx, cy), the first straight up; `inner` makes it a star. */
53
+ function corners(count, radius, cx, cy, inner) {
54
+ const points = [];
55
+ const steps = inner ? count * 2 : count;
56
+ for (let index = 0; index < steps; index++) {
57
+ const r = inner && index % 2 === 1 ? inner : radius;
58
+ const angle = -Math.PI / 2 + (index * 2 * Math.PI) / steps;
59
+ points.push(`${(cx + r * Math.cos(angle)).toFixed(2)},${(cy + r * Math.sin(angle)).toFixed(2)}`);
60
+ }
61
+ return points.join(' ');
62
+ }
63
+ const PENTAGON = corners(5, 13.5, 20, 21.5);
64
+ const HEXAGON = corners(6, 14, 20, 20);
65
+ const STAR = corners(5, 15.5, 20, 21.5, 8.6);
66
+ function node(tag, attrs, children) {
67
+ return children ? { tag, attrs, children } : { tag, attrs };
68
+ }
69
+ /** A polygon with round corners: filled and stroked in the same colour. */
70
+ function rounded(points, color, width = 5) {
71
+ return node('polygon', { points, fill: color, stroke: color, 'stroke-width': width, 'stroke-linejoin': 'round' });
72
+ }
73
+ function shape(face, look) {
74
+ const { color, accent = color } = look;
75
+ switch (face) {
76
+ case 1:
77
+ return node('g', {}, [
78
+ rounded('7.5,6.5 17,12 8.5,18', color, 4),
79
+ rounded('32.5,6.5 23,12 31.5,18', color, 4),
80
+ node('ellipse', { cx: 20, cy: 23, rx: 14.5, ry: 12.5, fill: color }),
81
+ ]);
82
+ case 2:
83
+ return rounded(PENTAGON, color);
84
+ case 3:
85
+ return node('g', {}, [
86
+ node('circle', { cx: 9.5, cy: 10.5, r: 5.5, fill: color }),
87
+ node('circle', { cx: 30.5, cy: 10.5, r: 5.5, fill: color }),
88
+ node('circle', { cx: 9.5, cy: 10.5, r: 2.6, fill: accent }),
89
+ node('circle', { cx: 30.5, cy: 10.5, r: 2.6, fill: accent }),
90
+ node('ellipse', { cx: 20, cy: 22.5, rx: 14.5, ry: 13, fill: color }),
91
+ ]);
92
+ case 4:
93
+ return node('rect', { x: 8.5, y: 4, width: 23, height: 32, rx: 11.5, fill: color });
94
+ case 5:
95
+ return rounded('20,5.5 34.5,20 20,34.5 5.5,20', color, 5.5);
96
+ case 6:
97
+ return node('g', {}, [
98
+ node('ellipse', { cx: 20, cy: 11, rx: 3.2, ry: 3.6, fill: accent }),
99
+ node('path', { d: 'M20 12.5c9.2 0 15.5 5.6 15.5 12.4 0 6.4-6.9 10.1-15.5 10.1S4.5 31.3 4.5 24.9C4.5 18.1 10.8 12.5 20 12.5Z', fill: color }),
100
+ ]);
101
+ case 7:
102
+ return rounded(HEXAGON, color);
103
+ case 8:
104
+ return node('path', {
105
+ d: 'M8 19a12 12 0 0 1 24 0v14l-4-3-4 3-4-3-4 3-4-3-4 3Z',
106
+ fill: color,
107
+ stroke: EDGE,
108
+ 'stroke-width': 0.8,
109
+ 'stroke-linejoin': 'round',
110
+ });
111
+ case 9:
112
+ return rounded(STAR, color, 4.5);
113
+ case 10:
114
+ return node('g', {}, [
115
+ node('rect', { x: 18.6, y: 4.5, width: 2.8, height: 7, rx: 1.4, fill: accent }),
116
+ node('ellipse', { cx: 12.5, cy: 23, rx: 8.5, ry: 11, fill: color }),
117
+ node('ellipse', { cx: 27.5, cy: 23, rx: 8.5, ry: 11, fill: color }),
118
+ node('ellipse', { cx: 20, cy: 22.5, rx: 9.5, ry: 12, fill: color }),
119
+ ]);
120
+ case 11:
121
+ return node('g', {}, [
122
+ node('circle', { cx: 9.5, cy: 10, r: 5, fill: accent }),
123
+ node('circle', { cx: 30.5, cy: 10, r: 5, fill: accent }),
124
+ node('ellipse', { cx: 20, cy: 22.5, rx: 14.5, ry: 13, fill: color, stroke: EDGE, 'stroke-width': 0.8 }),
125
+ node('ellipse', { cx: 14.6, cy: 22, rx: 3.6, ry: 4.4, transform: 'rotate(20 14.6 22)', fill: accent }),
126
+ node('ellipse', { cx: 25.4, cy: 22, rx: 3.6, ry: 4.4, transform: 'rotate(-20 25.4 22)', fill: accent }),
127
+ ]);
128
+ case 12:
129
+ return node('g', {}, [
130
+ node('rect', { x: 19.1, y: 6, width: 1.8, height: 7, fill: accent }),
131
+ node('circle', { cx: 20, cy: 5, r: 2.2, fill: accent }),
132
+ node('rect', { x: 5.5, y: 12, width: 29, height: 22.5, rx: 6.5, fill: color }),
133
+ ]);
134
+ case 13:
135
+ return node('path', { d: 'M20 4.5c2 0 13 11.6 13 20.2 0 6.4-5.8 10.8-13 10.8S7 31.1 7 24.7C7 16.1 18 4.5 20 4.5Z', fill: color });
136
+ case 14:
137
+ return node('g', {}, [
138
+ node('ellipse', { cx: 14, cy: 10.5, rx: 3.6, ry: 8, transform: 'rotate(-8 14 10.5)', fill: color }),
139
+ node('ellipse', { cx: 26, cy: 10.5, rx: 3.6, ry: 8, transform: 'rotate(8 26 10.5)', fill: color }),
140
+ node('ellipse', { cx: 20, cy: 25, rx: 14, ry: 11, fill: color }),
141
+ ]);
142
+ case 15:
143
+ return rounded('20,7 35,33 5,33', color, 6);
144
+ default:
145
+ return node('circle', { cx: 20, cy: 21, r: 14.5, fill: color });
146
+ }
147
+ }
148
+ var FaceUtil;
149
+ (function (FaceUtil) {
150
+ /** The face of an id: the same for the same id, on every device. */
151
+ function of(seed) {
152
+ let hash = 0;
153
+ for (const char of seed) {
154
+ hash = (hash * 31 + char.charCodeAt(0)) | 0;
155
+ }
156
+ return Math.abs(hash) % exports.FACE_COUNT;
157
+ }
158
+ FaceUtil.of = of;
159
+ /** The face given, if it is one, else that of `seed`. */
160
+ function pick(face, seed = '') {
161
+ return face !== undefined && face >= 0 && face < exports.FACE_COUNT ? Math.floor(face) : of(seed);
162
+ }
163
+ FaceUtil.pick = pick;
164
+ /** Its colour, for what draws no faces. */
165
+ function color(face) {
166
+ var _a;
167
+ return ((_a = LOOKS[face]) !== null && _a !== void 0 ? _a : LOOKS[0]).color;
168
+ }
169
+ FaceUtil.color = color;
170
+ /** What is in the `<svg viewBox="0 0 40 40">` of a face: its shape, then its cheeks, brows, eyes and mouth. */
171
+ function art(face) {
172
+ var _a, _b;
173
+ const look = (_a = LOOKS[face]) !== null && _a !== void 0 ? _a : LOOKS[0];
174
+ const half = look.gap / 2;
175
+ const eyeW = 4.1;
176
+ const eyeH = 4.9;
177
+ const top = look.eyeY - eyeH / 2;
178
+ const cheekY = look.eyeY + 3.6;
179
+ const cheekX = half + 2.2;
180
+ const mouthY = look.eyeY + 3.4;
181
+ const features = [
182
+ node('g', { fill: look.cheek }, [
183
+ node('ellipse', { cx: 20 - cheekX, cy: cheekY, rx: 2.2, ry: 1.25 }),
184
+ node('ellipse', { cx: 20 + cheekX, cy: cheekY, rx: 2.2, ry: 1.25 }),
185
+ ]),
186
+ ];
187
+ if (look.brows) {
188
+ features.push(node('path', {
189
+ d: `M${20 - half - 3.4} ${top - 2.6}l3.6 1.6M${20 + half + 3.4} ${top - 2.6}l-3.6 1.6`,
190
+ stroke: look.eye,
191
+ 'stroke-width': 1.4,
192
+ 'stroke-linecap': 'round',
193
+ fill: 'none',
194
+ }));
195
+ }
196
+ features.push(node('g', { class: 'ta-face-eyes', fill: look.eye }, [
197
+ node('rect', { x: 20 - half - eyeW / 2, y: top, width: eyeW, height: eyeH, rx: eyeW / 2 }),
198
+ node('rect', { x: 20 + half - eyeW / 2, y: top, width: eyeW, height: eyeH, rx: eyeW / 2 }),
199
+ ]), node('path', {
200
+ d: `M18.1 ${mouthY}q.95 1.25 1.9 0q.95 1.25 1.9 0`,
201
+ fill: 'none',
202
+ stroke: (_b = look.mouth) !== null && _b !== void 0 ? _b : look.eye,
203
+ 'stroke-width': 1.1,
204
+ 'stroke-linecap': 'round',
205
+ 'stroke-linejoin': 'round',
206
+ }));
207
+ return node('g', { class: 'ta-face-body' }, [shape(face, look), node('g', { class: 'ta-face-look' }, features)]);
208
+ }
209
+ FaceUtil.art = art;
210
+ })(FaceUtil || (exports.FaceUtil = FaceUtil = {}));
211
+ //# sourceMappingURL=relay-faces.js.map
@@ -0,0 +1,155 @@
1
+ import type { RelayFriend, RelayFriendInfo, RelayFriendRequest, RelayHubsStore, RelayRoomEvent, RelayRoomInfo, RelayRoomRecord, RelayRoomValue } from './relay-hubs-protocol';
2
+ import { type RelayIdentity, type RelayPublicIdentity } from './relay-identity';
3
+ /** The kind of the room of a Ta's friends (docs/design/ta-link.md 3.1): unlisted, one a Ta, its friends its members. */
4
+ export declare const RELAY_FRIENDS_KIND = "ta-friends";
5
+ /** What the friends of a Ta need of its rooms (RelayHubs). */
6
+ export interface RelayFriendRooms {
7
+ identity(): Promise<RelayIdentity>;
8
+ list(): RelayRoomInfo[];
9
+ /** The identity id of a room's owner, known from the link while waiting. */
10
+ ownerOf(room: string): string | undefined;
11
+ /** The public identity of a member of a room, as its roster has it. */
12
+ memberOf(room: string, member: string): RelayPublicIdentity | undefined;
13
+ /** Those asking to join a room of this Ta, as they ask. */
14
+ asksOf(room: string): (RelayPublicIdentity & {
15
+ member: string;
16
+ at: number;
17
+ guest?: boolean;
18
+ })[];
19
+ create(input: {
20
+ kind: string;
21
+ title: string;
22
+ unlisted: boolean;
23
+ }): Promise<RelayRoomInfo>;
24
+ invite(room: string, options: {
25
+ days?: number;
26
+ renew?: boolean;
27
+ }): Promise<{
28
+ link: string;
29
+ expiresAt: number;
30
+ }>;
31
+ join(link: string): Promise<RelayRoomInfo>;
32
+ answer(room: string, ask: string, accept: boolean): Promise<void>;
33
+ remove(room: string, member: string): Promise<void>;
34
+ leave(room: string): Promise<void>;
35
+ getState(room: string, prefix?: string): Promise<Record<string, RelayRoomValue>>;
36
+ setState(room: string, key: string, value: unknown): Promise<{
37
+ ok: boolean;
38
+ version: number;
39
+ }>;
40
+ /** Asks a member of a shared room to be friends: the link of this Ta's room of friends, to it alone. */
41
+ offer(room: string, member: string, link: string): Promise<void>;
42
+ }
43
+ /** Asked to be friends in a room the two share: the link of the other's room of friends. */
44
+ interface Offer extends RelayPublicIdentity {
45
+ link: string;
46
+ /** The title of the room it was asked in. */
47
+ room: string;
48
+ at: number;
49
+ }
50
+ /** `friends.json`: those the user chose as friends, and who asked the user in a shared room. */
51
+ interface Book {
52
+ v: 2;
53
+ friends: RelayFriend[];
54
+ offers: Offer[];
55
+ }
56
+ /**
57
+ * The friends of a Ta (docs/design/ta-link.md 3.1): one kind of friend, each on the word of both. A Ta has one
58
+ * unlisted room of friends; two are friends when each is a member of the other's. One asks by the link of the other's
59
+ * room (a code, a link sent), or in a room the two share (the other is sent the link of this one's room); the other
60
+ * answers. Then each Ta joins the other's room on its own: the user chose the other (`friends`), and the other wrote
61
+ * the link of its room in this one's (`back:`). Removing a friend ends it on both sides. Other features of Ta keep
62
+ * what they give friends in the room of friends (Moments its posts), and share with friends by their keys.
63
+ */
64
+ export declare class RelayFriends {
65
+ protected readonly rooms: RelayFriendRooms;
66
+ protected readonly store: RelayHubsStore;
67
+ protected readonly emit: (event: RelayRoomEvent) => void;
68
+ protected settle?: ReturnType<typeof setTimeout>;
69
+ protected queue: Promise<unknown>;
70
+ /** Links of `back:` joined while this runs: one that failed is not tried again till it changes. */
71
+ protected readonly tried: Set<string>;
72
+ /** Asks the user was told of while this runs. */
73
+ protected readonly told: Set<string>;
74
+ protected stopped: boolean;
75
+ constructor(rooms: RelayFriendRooms, store: RelayHubsStore, emit: (event: RelayRoomEvent) => void);
76
+ start(): void;
77
+ stop(): void;
78
+ /** The user's room of friends, made the first time. */
79
+ room(): Promise<RelayRoomInfo>;
80
+ /** The link (and code) that asks to be the user's friend. */
81
+ link(renew?: boolean): Promise<{
82
+ link: string;
83
+ expiresAt: number;
84
+ }>;
85
+ /** Asks the one of a link to be friends, on the user's word. */
86
+ add(link: string): Promise<void>;
87
+ /** Asks a member of a room the user is in to be friends: it is told, and answers in its Ta. */
88
+ offer(room: string, member: string): Promise<void>;
89
+ /** A member of a shared room asked the user to be friends: joined back at once if the user asked it, else asked. */
90
+ offered(from: RelayPublicIdentity, link: string, title: string): void;
91
+ /** Those asking the user to be friends: by the link of the user's room, or in a room the two share. */
92
+ requests(): RelayFriendRequest[];
93
+ /** One asking to join the room of friends, heard: told the user, unless the user chose it (let in as it settles). */
94
+ asked(ask: RelayPublicIdentity & {
95
+ member: string;
96
+ at: number;
97
+ guest?: boolean;
98
+ }): void;
99
+ /** The user's answer to one asking to be friends. Only ever on the user's word, never on an agent's. */
100
+ answer(id: string, accept: boolean): Promise<void>;
101
+ /** No longer friends, on both sides: out of the user's room, and the user out of theirs. */
102
+ remove(id: string): Promise<boolean>;
103
+ /** The user's friends, and those being added: whether each is a friend yet, and online. */
104
+ list(): RelayFriendInfo[];
105
+ /** The friends, with their keys: those both chose, and in each other's room (shares to friends use their keys). */
106
+ friends(): (RelayFriend & RelayPublicIdentity)[];
107
+ /** Ids of those the user chose. */
108
+ ids(): Set<string>;
109
+ /** Those of a roster: the names and keys of friends kept up to date. */
110
+ heard(members: RelayPublicIdentity[]): void;
111
+ /** Friends of the user's other computer, with those of this Ta (a move, sync). */
112
+ merge(friends: RelayFriend[]): number;
113
+ /** Those the user chose, for the user's other computers. */
114
+ chosen(): RelayFriend[];
115
+ /** Something changed in the rooms: friends are made both ways, let in and let go of, once it settles. */
116
+ changed(): void;
117
+ /** The user changed the friends: pages read them again, and the rooms follow. */
118
+ protected updated(): void;
119
+ protected reconcile(): Promise<void>;
120
+ /** No longer friends with `id`: out of the user's room, and the user out of theirs (forgotten when gone). */
121
+ protected unfollow(id: string): Promise<void>;
122
+ protected mine(): RelayRoomInfo | undefined;
123
+ protected theirs(rooms: RelayRoomInfo[], id: string): RelayRoomInfo | undefined;
124
+ /** The user chose this one: kept, with its keys when known. */
125
+ protected choose(person: Pick<RelayPublicIdentity, 'id' | 'name'> & Partial<RelayPublicIdentity>): void;
126
+ protected read(): Book;
127
+ protected write(book: Book): void;
128
+ /** One after another: each reads what the one before wrote. */
129
+ protected serial<T>(run: () => Promise<T>): Promise<T>;
130
+ }
131
+ export declare namespace RelayFriendsUtil {
132
+ /** The kind of a room or link of friends, as it is now or was. */
133
+ function isKind(kind: string | undefined): boolean;
134
+ /** The kind a room of friends goes by, whatever it was made as. */
135
+ function kindOf(kind: string): string;
136
+ function isFriend(friend: unknown): friend is RelayFriend;
137
+ /** What is kept of a friend: its identity and when, nothing else a bundle of before held. */
138
+ function clean(friend: RelayFriend): RelayFriend;
139
+ function mergeFriend(local: RelayFriend, other: RelayFriend): RelayFriend;
140
+ function requestOf(offer: Offer): RelayFriendRequest;
141
+ /** `friends.json` as it is now: those of before kept only if they were Moments friends (see migrate). */
142
+ function book(value: unknown): Book;
143
+ /**
144
+ * Friends as they were before (2026-11-16): everyone met in a room was a "Ta friend", and Moments kept friends of
145
+ * its own in rooms of kind `ta-moments`. Now the rooms of Moments are the rooms of friends, and the friends are
146
+ * those whose room the user is in (both chose each other); the others met in rooms are no longer friends. Undefined
147
+ * when there is nothing to do.
148
+ */
149
+ function migrate(records: RelayRoomRecord[], stored: unknown): {
150
+ records: RelayRoomRecord[];
151
+ book: Book;
152
+ } | undefined;
153
+ }
154
+ export {};
155
+ //# sourceMappingURL=relay-friends.d.ts.map