@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
|
@@ -4,13 +4,26 @@ export interface RelayRoomChatValue {
|
|
|
4
4
|
version: number;
|
|
5
5
|
by: string;
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* What a chat reads and sets: RelayHubs, or TaRoomServer of Ta. With `readChat` and `say`, what is said is the log of
|
|
9
|
+
* the room, kept on this computer (docs/design/ta-chat-history.md); without them (a Ta service of before), the state.
|
|
10
|
+
*/
|
|
8
11
|
export interface RelayRoomChatRooms {
|
|
9
12
|
getState(room: string, prefix?: string): Promise<Record<string, RelayRoomChatValue>>;
|
|
10
13
|
setState(room: string, key: string, value: unknown, version?: number): Promise<{
|
|
11
14
|
ok: boolean;
|
|
12
15
|
version: number;
|
|
13
16
|
}>;
|
|
17
|
+
/** The latest lines kept, before the line `before` (its id) when given, the earliest first: `more` when there are older. */
|
|
18
|
+
readChat?(room: string, options?: {
|
|
19
|
+
before?: string;
|
|
20
|
+
limit?: number;
|
|
21
|
+
}): Promise<{
|
|
22
|
+
lines: RelayChatLine[];
|
|
23
|
+
more: boolean;
|
|
24
|
+
}>;
|
|
25
|
+
/** Says it as this Ta: the line, `pending` till the relay has it. */
|
|
26
|
+
say?(room: string, text: string, extra?: RelayChatLineExtra): Promise<RelayChatLine | undefined>;
|
|
14
27
|
}
|
|
15
28
|
/** One thing said in a room. */
|
|
16
29
|
export interface RelayChatLine {
|
|
@@ -48,16 +61,85 @@ export interface RelayChatLine {
|
|
|
48
61
|
* its own, says how it goes under `tasks:<member>` of the state, and answers with `re` when it ends.
|
|
49
62
|
*/
|
|
50
63
|
task?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Pictures sent with it (docs/design/ta-composer.md 3): what they are, not their bytes, which stay on the computers of
|
|
66
|
+
* the members (the sender's, and each one's that fetched them) and go from one to another through the room, sealed.
|
|
67
|
+
*/
|
|
68
|
+
images?: RelayChatImage[];
|
|
69
|
+
/**
|
|
70
|
+
* Files, a voice message or a video sent with it (docs/design/ta-chat-history.md 7): what they are, not their
|
|
71
|
+
* bytes, which go from member to member through the room and are never kept on the relay.
|
|
72
|
+
*/
|
|
73
|
+
files?: RelayChatFile[];
|
|
74
|
+
/** Its number in the log of the room; none for a line of before the log, or one not sent yet. */
|
|
75
|
+
seq?: number;
|
|
76
|
+
/** Said here, not yet taken by the relay: it goes once it can. */
|
|
77
|
+
pending?: true;
|
|
78
|
+
/** Said here, refused by the relay (too large): it never went. */
|
|
79
|
+
failed?: true;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* A picture of a line (RelayChatLine.images): its id among the pictures of the sender, its type, size and the SHA-256 of
|
|
83
|
+
* its bytes, which whoever fetches it checks; a blurred thumbnail of a few hundred bytes to show until it comes.
|
|
84
|
+
*/
|
|
85
|
+
export interface RelayChatImage {
|
|
86
|
+
id: string;
|
|
87
|
+
type: string;
|
|
88
|
+
w: number;
|
|
89
|
+
h: number;
|
|
90
|
+
bytes: number;
|
|
91
|
+
sha: string;
|
|
92
|
+
thumb?: string;
|
|
93
|
+
/**
|
|
94
|
+
* A copy on the relay of the room while it lasts (docs/design/ta-chat-history.md 7), for whoever comes when no
|
|
95
|
+
* member who has it is online: its id there, what reads it and what opens it (AES-256-GCM), till when.
|
|
96
|
+
*/
|
|
97
|
+
blob?: RelayChatBlob;
|
|
98
|
+
}
|
|
99
|
+
/** A sealed copy of a picture on the relay (RelayChatImage.blob): the relay reads neither it nor what opens it. */
|
|
100
|
+
export interface RelayChatBlob {
|
|
101
|
+
id: string;
|
|
102
|
+
/** base64url, 32 bytes: the token that reads it (the relay keeps its SHA-256). */
|
|
103
|
+
read: string;
|
|
104
|
+
/** base64url, 32 bytes: the key it is sealed with. */
|
|
105
|
+
key: string;
|
|
106
|
+
until: number;
|
|
107
|
+
}
|
|
108
|
+
/** What a file of a line is: any file, a voice message (`ms` long), a video (`ms` long, `w` × `h`, a blurred frame). */
|
|
109
|
+
export type RelayChatFileKind = 'file' | 'voice' | 'video';
|
|
110
|
+
/**
|
|
111
|
+
* A file of a line (RelayChatLine.files): its id among the files of the sender, its name, type, size and the SHA-256
|
|
112
|
+
* of its bytes, which whoever fetches it checks.
|
|
113
|
+
*/
|
|
114
|
+
export interface RelayChatFile {
|
|
115
|
+
id: string;
|
|
116
|
+
kind: RelayChatFileKind;
|
|
117
|
+
name: string;
|
|
118
|
+
type: string;
|
|
119
|
+
bytes: number;
|
|
120
|
+
sha: string;
|
|
121
|
+
ms?: number;
|
|
122
|
+
w?: number;
|
|
123
|
+
h?: number;
|
|
124
|
+
thumb?: string;
|
|
51
125
|
}
|
|
126
|
+
/** The bytes of a file of each kind at most: what passes between members in a minute or two. */
|
|
127
|
+
export declare const RELAY_CHAT_FILE_BYTES: Record<RelayChatFileKind, number>;
|
|
128
|
+
/** How long a voice message and a video are at most. */
|
|
129
|
+
export declare const RELAY_CHAT_VOICE_MS = 60000;
|
|
130
|
+
export declare const RELAY_CHAT_VIDEO_MS: number;
|
|
131
|
+
/** The files of a line at most. */
|
|
132
|
+
export declare const RELAY_CHAT_FILES = 9;
|
|
52
133
|
/** An agent of a member's Ta, in a room (RelayChatLine.agent). */
|
|
53
134
|
export interface RelayChatAgent {
|
|
54
135
|
id: string;
|
|
55
136
|
name: string;
|
|
56
137
|
}
|
|
57
138
|
/** What a line adds to its text: who said it and to whom (RelayRoomChat.say). */
|
|
58
|
-
export type RelayChatLineExtra = Pick<RelayChatLine, 'double' | 'agent' | 'to' | 'person' | 're' | 'task'>;
|
|
59
|
-
/** What is kept of a line: `from` is the key's. */
|
|
60
|
-
type
|
|
139
|
+
export type RelayChatLineExtra = Pick<RelayChatLine, 'double' | 'agent' | 'to' | 'person' | 're' | 'task' | 'images' | 'files'>;
|
|
140
|
+
/** What is kept of a line, and what a member signs of it in the log: `from` is the key's, or the signer's. */
|
|
141
|
+
export type RelayChatStored = Omit<RelayChatLine, 'from' | 'seq' | 'pending' | 'failed'>;
|
|
142
|
+
type StoredLine = RelayChatStored;
|
|
61
143
|
/** The keys of what is said, `chat:<member>:<n>`: each member writes only its own, so none can write as another. */
|
|
62
144
|
export declare const RELAY_CHAT_KEY = "chat:";
|
|
63
145
|
/** The bytes of JSON of one part at most, well under what the relay takes of a value once sealed. */
|
|
@@ -65,6 +147,14 @@ export declare const RELAY_CHAT_PART_BYTES: number;
|
|
|
65
147
|
/** The parts of each member kept: the oldest is cleared as a new one starts. */
|
|
66
148
|
export declare const RELAY_CHAT_PARTS = 6;
|
|
67
149
|
export declare const RELAY_CHAT_TEXT_MAX = 2000;
|
|
150
|
+
/** The pictures of a line at most, as WeChat sends nine at once. */
|
|
151
|
+
export declare const RELAY_CHAT_IMAGES = 9;
|
|
152
|
+
/** The bytes of a picture at most. */
|
|
153
|
+
export declare const RELAY_CHAT_IMAGE_BYTES: number;
|
|
154
|
+
/** The characters of the data URL of a thumbnail at most. */
|
|
155
|
+
export declare const RELAY_CHAT_THUMB_CHARS = 900;
|
|
156
|
+
/** Lines a chat holds at once: the latest; older ones are read as the page asks (RelayRoomChat.older). */
|
|
157
|
+
export declare const RELAY_CHAT_WINDOW = 500;
|
|
68
158
|
export declare namespace RelayRoomChatUtil {
|
|
69
159
|
function key(member: string, part: number): string;
|
|
70
160
|
function parse(key: string): {
|
|
@@ -75,8 +165,16 @@ export declare namespace RelayRoomChatUtil {
|
|
|
75
165
|
function lines(member: string, value: unknown, by: string): RelayChatLine[] | undefined;
|
|
76
166
|
/** What a stored line adds, as far as it is well formed. */
|
|
77
167
|
function extra(line: Record<string, unknown>): RelayChatLineExtra;
|
|
168
|
+
/** The files of a stored line, as far as each is well formed. */
|
|
169
|
+
function files(value: unknown): Pick<RelayChatLine, 'files'>;
|
|
170
|
+
/** What a line says in a word where only text shows (the list of chats, a notice, a page of guests). */
|
|
171
|
+
function preview(line: Pick<RelayChatLine, 'text' | 'images' | 'files'>, picture: string, words?: Record<RelayChatFileKind, string>): string;
|
|
78
172
|
function stored(lines: RelayChatLine[]): StoredLine[];
|
|
173
|
+
/** A line of the log, as its member signed it: well formed, or none. */
|
|
174
|
+
function signed(member: string, value: unknown, seq?: number): RelayChatLine | undefined;
|
|
79
175
|
function bytes(lines: StoredLine[]): number;
|
|
176
|
+
/** An error of a call a Ta service of before does not know (JSON-RPC's method not found, or its words). */
|
|
177
|
+
function unknownMethod(error: unknown): boolean;
|
|
80
178
|
function id(): string;
|
|
81
179
|
}
|
|
82
180
|
interface Part {
|
|
@@ -96,11 +194,34 @@ export declare class RelayRoomChat {
|
|
|
96
194
|
protected readonly parts: Map<string, Part>;
|
|
97
195
|
protected readonly listeners: Set<() => void>;
|
|
98
196
|
protected all: readonly RelayChatLine[];
|
|
197
|
+
/** Older lines are kept than those read (the log, RelayRoomChatRooms.readChat). */
|
|
198
|
+
protected olderKept: boolean;
|
|
199
|
+
/**
|
|
200
|
+
* What is said is the log (RelayRoomChatRooms.readChat): until a Ta service of before, whose proxy names every
|
|
201
|
+
* method all the same, fails it; then the state, as before.
|
|
202
|
+
*/
|
|
203
|
+
protected log: boolean;
|
|
99
204
|
constructor(rooms: RelayRoomChatRooms, room: string);
|
|
100
205
|
/** All that is said, the earliest first. */
|
|
101
206
|
get lines(): readonly RelayChatLine[];
|
|
102
207
|
subscribe(listener: () => void): () => void;
|
|
208
|
+
/** Whether there are older lines than those read: `older` reads them. */
|
|
209
|
+
get more(): boolean;
|
|
103
210
|
load(): Promise<void>;
|
|
211
|
+
/** Lines before those read, a page of them: how many came. */
|
|
212
|
+
older(limit?: number): Promise<number>;
|
|
213
|
+
/**
|
|
214
|
+
* What happened in the room, as its event tells: a line of the log (`chat`), or a key of the state set (`state`,
|
|
215
|
+
* the chat of a Ta service of before). Whether it was of the chat.
|
|
216
|
+
*/
|
|
217
|
+
hear(event: {
|
|
218
|
+
type: string;
|
|
219
|
+
room?: string;
|
|
220
|
+
key?: string;
|
|
221
|
+
line?: RelayChatLine;
|
|
222
|
+
} & Partial<RelayRoomChatValue>): boolean;
|
|
223
|
+
/** A line said or taken: one of the same id is replaced (sent, refused), a new one comes last. */
|
|
224
|
+
heardLine(line: RelayChatLine): void;
|
|
104
225
|
/** A key of the room set, as its event tells: whether it was of the chat. */
|
|
105
226
|
heard(key: string, value: RelayRoomChatValue): boolean;
|
|
106
227
|
/**
|
|
@@ -115,5 +236,6 @@ export declare class RelayRoomChat {
|
|
|
115
236
|
protected latest(member: string): Part | undefined;
|
|
116
237
|
protected put(key: string, value: RelayRoomChatValue): void;
|
|
117
238
|
protected changed(): void;
|
|
239
|
+
protected tell(): void;
|
|
118
240
|
}
|
|
119
241
|
export {};
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/** The bytes of a file of each kind at most: what passes between members in a minute or two. */
|
|
2
|
+
export const RELAY_CHAT_FILE_BYTES = { file: 50 * 1024 * 1024, video: 30 * 1024 * 1024, voice: 2 * 1024 * 1024 };
|
|
3
|
+
/** How long a voice message and a video are at most. */
|
|
4
|
+
export const RELAY_CHAT_VOICE_MS = 60000;
|
|
5
|
+
export const RELAY_CHAT_VIDEO_MS = 3 * 60000;
|
|
6
|
+
/** The files of a line at most. */
|
|
7
|
+
export const RELAY_CHAT_FILES = 9;
|
|
1
8
|
/** The keys of what is said, `chat:<member>:<n>`: each member writes only its own, so none can write as another. */
|
|
2
9
|
export const RELAY_CHAT_KEY = 'chat:';
|
|
3
10
|
/** The bytes of JSON of one part at most, well under what the relay takes of a value once sealed. */
|
|
@@ -5,6 +12,15 @@ export const RELAY_CHAT_PART_BYTES = 8 * 1024;
|
|
|
5
12
|
/** The parts of each member kept: the oldest is cleared as a new one starts. */
|
|
6
13
|
export const RELAY_CHAT_PARTS = 6;
|
|
7
14
|
export const RELAY_CHAT_TEXT_MAX = 2000;
|
|
15
|
+
/** The pictures of a line at most, as WeChat sends nine at once. */
|
|
16
|
+
export const RELAY_CHAT_IMAGES = 9;
|
|
17
|
+
/** The bytes of a picture at most. */
|
|
18
|
+
export const RELAY_CHAT_IMAGE_BYTES = 2 * 1024 * 1024;
|
|
19
|
+
/** The characters of the data URL of a thumbnail at most. */
|
|
20
|
+
export const RELAY_CHAT_THUMB_CHARS = 900;
|
|
21
|
+
const IMAGE_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'];
|
|
22
|
+
/** Lines a chat holds at once: the latest; older ones are read as the page asks (RelayRoomChat.older). */
|
|
23
|
+
export const RELAY_CHAT_WINDOW = 500;
|
|
8
24
|
const TRIES = 6;
|
|
9
25
|
export var RelayRoomChatUtil;
|
|
10
26
|
(function (RelayRoomChatUtil) {
|
|
@@ -44,17 +60,141 @@ export var RelayRoomChatUtil;
|
|
|
44
60
|
...(line.person === true && to.length && line.double !== true && !line.agent ? { person: true } : {}),
|
|
45
61
|
...(typeof line.re === 'string' ? { re: line.re } : {}),
|
|
46
62
|
...(line.task === true && to.length ? { task: true } : {}),
|
|
63
|
+
...images(line.images),
|
|
64
|
+
...files(line.files),
|
|
47
65
|
};
|
|
48
66
|
}
|
|
49
67
|
RelayRoomChatUtil.extra = extra;
|
|
68
|
+
/** The files of a stored line, as far as each is well formed. */
|
|
69
|
+
function files(value) {
|
|
70
|
+
if (!Array.isArray(value)) {
|
|
71
|
+
return {};
|
|
72
|
+
}
|
|
73
|
+
const files = [];
|
|
74
|
+
for (const file of value.slice(0, RELAY_CHAT_FILES)) {
|
|
75
|
+
const kind = file === null || file === void 0 ? void 0 : file.kind;
|
|
76
|
+
if (!file ||
|
|
77
|
+
(kind !== 'file' && kind !== 'voice' && kind !== 'video') ||
|
|
78
|
+
typeof file.id !== 'string' ||
|
|
79
|
+
!/^[a-f0-9]{24}$/.test(file.id) ||
|
|
80
|
+
typeof file.sha !== 'string' ||
|
|
81
|
+
!/^[0-9a-f]{64}$/.test(file.sha) ||
|
|
82
|
+
!Number.isInteger(file.bytes) ||
|
|
83
|
+
file.bytes <= 0 ||
|
|
84
|
+
file.bytes > RELAY_CHAT_FILE_BYTES[kind]) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
const name = [...(typeof file.name === 'string' ? file.name : '')]
|
|
88
|
+
.filter(char => char.charCodeAt(0) >= 32 && char !== '/' && char !== '\\')
|
|
89
|
+
.join('')
|
|
90
|
+
.slice(0, 120) || kind;
|
|
91
|
+
const type = typeof file.type === 'string' && /^[\w.+-]+\/[\w.+-]+$/.test(file.type) ? file.type.slice(0, 100) : 'application/octet-stream';
|
|
92
|
+
const most = kind === 'voice' ? RELAY_CHAT_VOICE_MS : RELAY_CHAT_VIDEO_MS;
|
|
93
|
+
const ms = kind !== 'file' && Number.isFinite(file.ms) ? Math.min(Math.max(Math.round(file.ms), 0), most) : undefined;
|
|
94
|
+
const size = kind === 'video' && Number.isInteger(file.w) && Number.isInteger(file.h) && file.w > 0 && file.h > 0;
|
|
95
|
+
const thumb = kind === 'video' &&
|
|
96
|
+
typeof file.thumb === 'string' &&
|
|
97
|
+
file.thumb.length <= RELAY_CHAT_THUMB_CHARS &&
|
|
98
|
+
/^data:image\/(jpeg|png|webp);base64,/.test(file.thumb)
|
|
99
|
+
? file.thumb
|
|
100
|
+
: undefined;
|
|
101
|
+
files.push({
|
|
102
|
+
id: file.id,
|
|
103
|
+
kind,
|
|
104
|
+
name,
|
|
105
|
+
type,
|
|
106
|
+
bytes: file.bytes,
|
|
107
|
+
sha: file.sha,
|
|
108
|
+
...(ms !== undefined ? { ms } : {}),
|
|
109
|
+
...(size ? { w: file.w, h: file.h } : {}),
|
|
110
|
+
...(thumb ? { thumb } : {}),
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return files.length ? { files } : {};
|
|
114
|
+
}
|
|
115
|
+
RelayRoomChatUtil.files = files;
|
|
116
|
+
/** The pictures of a stored line, as far as each is well formed. */
|
|
117
|
+
function images(value) {
|
|
118
|
+
if (!Array.isArray(value)) {
|
|
119
|
+
return {};
|
|
120
|
+
}
|
|
121
|
+
const images = [];
|
|
122
|
+
for (const image of value.slice(0, RELAY_CHAT_IMAGES)) {
|
|
123
|
+
if (image &&
|
|
124
|
+
typeof image.id === 'string' &&
|
|
125
|
+
/^[A-Za-z0-9-]{8,64}$/.test(image.id) &&
|
|
126
|
+
typeof image.type === 'string' &&
|
|
127
|
+
IMAGE_TYPES.includes(image.type) &&
|
|
128
|
+
typeof image.sha === 'string' &&
|
|
129
|
+
/^[0-9a-f]{64}$/.test(image.sha) &&
|
|
130
|
+
Number.isInteger(image.w) &&
|
|
131
|
+
Number.isInteger(image.h) &&
|
|
132
|
+
Number.isInteger(image.bytes) &&
|
|
133
|
+
image.w > 0 &&
|
|
134
|
+
image.h > 0 &&
|
|
135
|
+
image.bytes > 0 &&
|
|
136
|
+
image.bytes <= RELAY_CHAT_IMAGE_BYTES) {
|
|
137
|
+
const thumb = typeof image.thumb === 'string' && image.thumb.length <= RELAY_CHAT_THUMB_CHARS && /^data:image\/(jpeg|png|webp);base64,/.test(image.thumb)
|
|
138
|
+
? image.thumb
|
|
139
|
+
: undefined;
|
|
140
|
+
const blob = image.blob;
|
|
141
|
+
const ok = !!blob &&
|
|
142
|
+
typeof blob.id === 'string' &&
|
|
143
|
+
/^[A-Za-z0-9_-]{16,64}$/.test(blob.id) &&
|
|
144
|
+
typeof blob.read === 'string' &&
|
|
145
|
+
/^[A-Za-z0-9_-]{43}$/.test(blob.read) &&
|
|
146
|
+
typeof blob.key === 'string' &&
|
|
147
|
+
/^[A-Za-z0-9_-]{43}$/.test(blob.key) &&
|
|
148
|
+
Number.isFinite(blob.until);
|
|
149
|
+
images.push({
|
|
150
|
+
id: image.id,
|
|
151
|
+
type: image.type,
|
|
152
|
+
w: image.w,
|
|
153
|
+
h: image.h,
|
|
154
|
+
bytes: image.bytes,
|
|
155
|
+
sha: image.sha,
|
|
156
|
+
...(thumb ? { thumb } : {}),
|
|
157
|
+
...(ok && blob ? { blob: { id: blob.id, read: blob.read, key: blob.key, until: blob.until } } : {}),
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return images.length ? { images } : {};
|
|
162
|
+
}
|
|
163
|
+
/** What a line says in a word where only text shows (the list of chats, a notice, a page of guests). */
|
|
164
|
+
function preview(line, picture, words = { file: '[file]', voice: '[voice]', video: '[video]' }) {
|
|
165
|
+
var _a;
|
|
166
|
+
var _b;
|
|
167
|
+
const pictures = ((_a = line.images) === null || _a === void 0 ? void 0 : _a.length) ? (line.images.length > 1 ? `${picture}×${line.images.length}` : picture) : '';
|
|
168
|
+
const files = ((_b = line.files) !== null && _b !== void 0 ? _b : []).map(file => (file.kind === 'file' ? `${words.file} ${file.name}` : words[file.kind]));
|
|
169
|
+
return [pictures, ...files, line.text].filter(Boolean).join(' ');
|
|
170
|
+
}
|
|
171
|
+
RelayRoomChatUtil.preview = preview;
|
|
50
172
|
function stored(lines) {
|
|
51
|
-
return lines.map(({ from: _from, ...line }) => line);
|
|
173
|
+
return lines.map(({ from: _from, seq: _seq, pending: _pending, failed: _failed, ...line }) => line);
|
|
52
174
|
}
|
|
53
175
|
RelayRoomChatUtil.stored = stored;
|
|
176
|
+
/** A line of the log, as its member signed it: well formed, or none. */
|
|
177
|
+
function signed(member, value, seq) {
|
|
178
|
+
const line = value;
|
|
179
|
+
if (!line || typeof line.id !== 'string' || typeof line.text !== 'string' || typeof line.at !== 'number') {
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
182
|
+
const name = typeof line.name === 'string' ? line.name.slice(0, 64) : '';
|
|
183
|
+
const text = line.text.slice(0, RELAY_CHAT_TEXT_MAX);
|
|
184
|
+
return { id: line.id.slice(0, 40), from: member, name, text, at: line.at, ...extra(line), ...(seq ? { seq } : {}) };
|
|
185
|
+
}
|
|
186
|
+
RelayRoomChatUtil.signed = signed;
|
|
54
187
|
function bytes(lines) {
|
|
55
188
|
return new TextEncoder().encode(JSON.stringify(lines)).length;
|
|
56
189
|
}
|
|
57
190
|
RelayRoomChatUtil.bytes = bytes;
|
|
191
|
+
/** An error of a call a Ta service of before does not know (JSON-RPC's method not found, or its words). */
|
|
192
|
+
function unknownMethod(error) {
|
|
193
|
+
var _a;
|
|
194
|
+
const found = error;
|
|
195
|
+
return (found === null || found === void 0 ? void 0 : found.code) === -32601 || /method not found|not a function|unknown method|no such method/i.test(String((_a = found === null || found === void 0 ? void 0 : found.message) !== null && _a !== void 0 ? _a : error));
|
|
196
|
+
}
|
|
197
|
+
RelayRoomChatUtil.unknownMethod = unknownMethod;
|
|
58
198
|
function id() {
|
|
59
199
|
return `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
|
|
60
200
|
}
|
|
@@ -72,6 +212,9 @@ export class RelayRoomChat {
|
|
|
72
212
|
this.parts = new Map();
|
|
73
213
|
this.listeners = new Set();
|
|
74
214
|
this.all = [];
|
|
215
|
+
/** Older lines are kept than those read (the log, RelayRoomChatRooms.readChat). */
|
|
216
|
+
this.olderKept = false;
|
|
217
|
+
this.log = typeof rooms.readChat === 'function' && typeof rooms.say === 'function';
|
|
75
218
|
}
|
|
76
219
|
/** All that is said, the earliest first. */
|
|
77
220
|
get lines() {
|
|
@@ -81,7 +224,26 @@ export class RelayRoomChat {
|
|
|
81
224
|
this.listeners.add(listener);
|
|
82
225
|
return () => this.listeners.delete(listener);
|
|
83
226
|
}
|
|
227
|
+
/** Whether there are older lines than those read: `older` reads them. */
|
|
228
|
+
get more() {
|
|
229
|
+
return this.olderKept;
|
|
230
|
+
}
|
|
84
231
|
async load() {
|
|
232
|
+
if (this.log && this.rooms.readChat) {
|
|
233
|
+
const read = await this.rooms.readChat(this.room, { limit: RELAY_CHAT_WINDOW }).catch((error) => {
|
|
234
|
+
if (!RelayRoomChatUtil.unknownMethod(error)) {
|
|
235
|
+
throw error;
|
|
236
|
+
}
|
|
237
|
+
this.log = false;
|
|
238
|
+
return undefined;
|
|
239
|
+
});
|
|
240
|
+
if (read) {
|
|
241
|
+
this.olderKept = read.more;
|
|
242
|
+
this.all = Array.isArray(read.lines) ? read.lines : [];
|
|
243
|
+
this.tell();
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
85
247
|
const state = await this.rooms.getState(this.room, RELAY_CHAT_KEY);
|
|
86
248
|
this.parts.clear();
|
|
87
249
|
for (const [key, value] of Object.entries(state)) {
|
|
@@ -89,8 +251,60 @@ export class RelayRoomChat {
|
|
|
89
251
|
}
|
|
90
252
|
this.changed();
|
|
91
253
|
}
|
|
254
|
+
/** Lines before those read, a page of them: how many came. */
|
|
255
|
+
async older(limit = 100) {
|
|
256
|
+
const first = this.all[0];
|
|
257
|
+
if (!this.log || !this.rooms.readChat || !first || !this.olderKept) {
|
|
258
|
+
return 0;
|
|
259
|
+
}
|
|
260
|
+
const read = await this.rooms.readChat(this.room, { before: first.id, limit });
|
|
261
|
+
const known = new Set(this.all.map(line => line.id));
|
|
262
|
+
const lines = read.lines.filter(line => !known.has(line.id));
|
|
263
|
+
this.olderKept = read.more;
|
|
264
|
+
this.all = [...lines, ...this.all];
|
|
265
|
+
this.tell();
|
|
266
|
+
return lines.length;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* What happened in the room, as its event tells: a line of the log (`chat`), or a key of the state set (`state`,
|
|
270
|
+
* the chat of a Ta service of before). Whether it was of the chat.
|
|
271
|
+
*/
|
|
272
|
+
hear(event) {
|
|
273
|
+
if (event.room !== undefined && event.room !== this.room) {
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
if (event.type === 'chat' && event.line) {
|
|
277
|
+
this.heardLine(event.line);
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
return event.type === 'state' && typeof event.key === 'string' && this.heard(event.key, event);
|
|
281
|
+
}
|
|
282
|
+
/** A line said or taken: one of the same id is replaced (sent, refused), a new one comes last. */
|
|
283
|
+
heardLine(line) {
|
|
284
|
+
const index = this.all.findIndex(each => each.id === line.id);
|
|
285
|
+
if (index >= 0) {
|
|
286
|
+
const next = [...this.all];
|
|
287
|
+
next[index] = line;
|
|
288
|
+
this.all = next;
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
const next = [...this.all, line];
|
|
292
|
+
// A line taken while one of this Ta waits goes before it: the pending come last.
|
|
293
|
+
const pending = next.findIndex(each => each.pending);
|
|
294
|
+
if (pending >= 0 && !line.pending) {
|
|
295
|
+
next.splice(next.length - 1, 1);
|
|
296
|
+
next.splice(pending, 0, line);
|
|
297
|
+
}
|
|
298
|
+
this.all = next.length > RELAY_CHAT_WINDOW * 2 ? next.slice(-RELAY_CHAT_WINDOW) : next;
|
|
299
|
+
this.olderKept || (this.olderKept = next.length > this.all.length);
|
|
300
|
+
}
|
|
301
|
+
this.tell();
|
|
302
|
+
}
|
|
92
303
|
/** A key of the room set, as its event tells: whether it was of the chat. */
|
|
93
304
|
heard(key, value) {
|
|
305
|
+
if (this.log) {
|
|
306
|
+
return !!RelayRoomChatUtil.parse(key);
|
|
307
|
+
}
|
|
94
308
|
if (!RelayRoomChatUtil.parse(key)) {
|
|
95
309
|
return false;
|
|
96
310
|
}
|
|
@@ -107,17 +321,24 @@ export class RelayRoomChat {
|
|
|
107
321
|
* again on what another client of the same Ta wrote first. The line said, or undefined when there was nothing to say.
|
|
108
322
|
*/
|
|
109
323
|
async say(text, self, extra = {}) {
|
|
110
|
-
var _a;
|
|
111
|
-
var
|
|
324
|
+
var _a, _b, _c;
|
|
325
|
+
var _d, _e;
|
|
112
326
|
const said = text.trim().slice(0, RELAY_CHAT_TEXT_MAX);
|
|
113
|
-
if (!said) {
|
|
327
|
+
if (!said && !((_a = extra.images) === null || _a === void 0 ? void 0 : _a.length) && !((_b = extra.files) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
114
328
|
return undefined;
|
|
115
329
|
}
|
|
330
|
+
if (this.log && this.rooms.say) {
|
|
331
|
+
const line = await this.rooms.say(this.room, said, RelayRoomChatUtil.extra(extra));
|
|
332
|
+
if (line) {
|
|
333
|
+
this.heardLine(line);
|
|
334
|
+
}
|
|
335
|
+
return line;
|
|
336
|
+
}
|
|
116
337
|
for (let tries = 0; tries < TRIES; tries++) {
|
|
117
338
|
const latest = this.latest(self.member);
|
|
118
339
|
// After what it said last, even within the same millisecond: the lines of a member keep their order.
|
|
119
340
|
const last = latest === null || latest === void 0 ? void 0 : latest.lines[latest.lines.length - 1];
|
|
120
|
-
const at = Math.max(Date.now(), ((
|
|
341
|
+
const at = Math.max(Date.now(), ((_d = last === null || last === void 0 ? void 0 : last.at) !== null && _d !== void 0 ? _d : 0) + 1);
|
|
121
342
|
const line = {
|
|
122
343
|
id: RelayRoomChatUtil.id(),
|
|
123
344
|
from: self.member,
|
|
@@ -131,7 +352,7 @@ export class RelayRoomChat {
|
|
|
131
352
|
const lines = fits && latest ? [...latest.lines, line] : [line];
|
|
132
353
|
const key = RelayRoomChatUtil.key(self.member, part);
|
|
133
354
|
const value = RelayRoomChatUtil.stored(lines);
|
|
134
|
-
const result = await this.rooms.setState(this.room, key, value, (
|
|
355
|
+
const result = await this.rooms.setState(this.room, key, value, (_e = (_c = this.parts.get(key)) === null || _c === void 0 ? void 0 : _c.version) !== null && _e !== void 0 ? _e : 0);
|
|
135
356
|
if (result.ok) {
|
|
136
357
|
this.put(key, { value, version: result.version, by: self.member });
|
|
137
358
|
this.changed();
|
|
@@ -170,6 +391,9 @@ export class RelayRoomChat {
|
|
|
170
391
|
}
|
|
171
392
|
changed() {
|
|
172
393
|
this.all = [...this.parts.values()].flatMap(part => part.lines).sort((a, b) => a.at - b.at || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
394
|
+
this.tell();
|
|
395
|
+
}
|
|
396
|
+
tell() {
|
|
173
397
|
for (const listener of this.listeners) {
|
|
174
398
|
listener();
|
|
175
399
|
}
|
|
@@ -10,6 +10,8 @@ declare const zh: {
|
|
|
10
10
|
namePlaceholder: string;
|
|
11
11
|
join: string;
|
|
12
12
|
joining: string;
|
|
13
|
+
picture: string;
|
|
14
|
+
file: string;
|
|
13
15
|
keep: string;
|
|
14
16
|
haveTa: string;
|
|
15
17
|
waiting: string;
|
|
@@ -36,6 +38,9 @@ declare const zh: {
|
|
|
36
38
|
rename: string;
|
|
37
39
|
leave: string;
|
|
38
40
|
leaveAsk: string;
|
|
41
|
+
boardOpen: string;
|
|
42
|
+
boardDone: string;
|
|
43
|
+
boardFrom: string;
|
|
39
44
|
game: string;
|
|
40
45
|
empty: string;
|
|
41
46
|
placeholder: string;
|
package/esm/guest/guest-i18n.js
CHANGED
|
@@ -10,6 +10,8 @@ const zh = {
|
|
|
10
10
|
namePlaceholder: '大家看到的名字',
|
|
11
11
|
join: '申请加入',
|
|
12
12
|
joining: '正在申请…',
|
|
13
|
+
picture: '[图片,在 Ta 里看]',
|
|
14
|
+
file: '[文件、语音或视频,在 Ta 里看]',
|
|
13
15
|
keep: '你的名字和一把只属于这个浏览器的钥匙保存在本机;清除浏览器数据后要重新申请。',
|
|
14
16
|
haveTa: '装了 Ta?在 Ta 应用里扫码或粘贴这个链接,还能一起玩小镇等游戏。',
|
|
15
17
|
waiting: '已向{by}申请',
|
|
@@ -36,6 +38,9 @@ const zh = {
|
|
|
36
38
|
rename: '修改我的名字',
|
|
37
39
|
leave: '退出群聊',
|
|
38
40
|
leaveAsk: '退出「{title}」?退出后要有新的邀请才能再进来。',
|
|
41
|
+
boardOpen: '{n} 个处理中',
|
|
42
|
+
boardDone: '{n} 个已完成',
|
|
43
|
+
boardFrom: '来自 {names}',
|
|
39
44
|
game: '这个群里有 Ta 的游戏,装了 Ta 才能一起玩;在这里可以聊天。',
|
|
40
45
|
empty: '还没有人说话。只有群里的人能看到,中继保存的是密文。',
|
|
41
46
|
placeholder: '发消息',
|
|
@@ -55,6 +60,8 @@ const zhTw = {
|
|
|
55
60
|
namePlaceholder: '大家看到的名字',
|
|
56
61
|
join: '申請加入',
|
|
57
62
|
joining: '正在申請…',
|
|
63
|
+
picture: '[圖片,在 Ta 裡看]',
|
|
64
|
+
file: '[檔案、語音或影片,在 Ta 裡看]',
|
|
58
65
|
keep: '你的名字和一把只屬於這個瀏覽器的鑰匙儲存在本機;清除瀏覽器資料後要重新申請。',
|
|
59
66
|
haveTa: '裝了 Ta?在 Ta 應用裡掃碼或貼上這個連結,還能一起玩小鎮等遊戲。',
|
|
60
67
|
waiting: '已向{by}申請',
|
|
@@ -81,6 +88,9 @@ const zhTw = {
|
|
|
81
88
|
rename: '修改我的名字',
|
|
82
89
|
leave: '退出群聊',
|
|
83
90
|
leaveAsk: '退出「{title}」?退出後要有新的邀請才能再進來。',
|
|
91
|
+
boardOpen: '{n} 個處理中',
|
|
92
|
+
boardDone: '{n} 個已完成',
|
|
93
|
+
boardFrom: '來自 {names}',
|
|
84
94
|
game: '這個群裡有 Ta 的遊戲,裝了 Ta 才能一起玩;在這裡可以聊天。',
|
|
85
95
|
empty: '還沒有人說話。只有群裡的人能看到,中繼儲存的是密文。',
|
|
86
96
|
placeholder: '發訊息',
|
|
@@ -100,6 +110,8 @@ const en = {
|
|
|
100
110
|
namePlaceholder: 'What everyone sees',
|
|
101
111
|
join: 'Ask to join',
|
|
102
112
|
joining: 'Asking…',
|
|
113
|
+
picture: '[Picture: see it in Ta]',
|
|
114
|
+
file: '[File, voice or video: see it in Ta]',
|
|
103
115
|
keep: 'Your name and a key of this browser alone are kept on this device; clear its data and you ask again.',
|
|
104
116
|
haveTa: 'Have Ta? Scan this link in the Ta app or paste it there, to play the Town and other games together too.',
|
|
105
117
|
waiting: 'Asked {by}',
|
|
@@ -126,6 +138,9 @@ const en = {
|
|
|
126
138
|
rename: 'Change my name',
|
|
127
139
|
leave: 'Leave the group chat',
|
|
128
140
|
leaveAsk: 'Leave “{title}”? You come back only by a new invitation.',
|
|
141
|
+
boardOpen: '{n} in progress',
|
|
142
|
+
boardDone: '{n} done',
|
|
143
|
+
boardFrom: 'From {names}',
|
|
129
144
|
game: 'This group chat plays a game of Ta, which takes Ta to play; here you chat.',
|
|
130
145
|
empty: 'Nothing said yet. Only those in the group chat read it: the relay keeps it sealed.',
|
|
131
146
|
placeholder: 'Message',
|
|
@@ -145,6 +160,8 @@ const ja = {
|
|
|
145
160
|
namePlaceholder: 'みんなに見える名前',
|
|
146
161
|
join: '参加をリクエスト',
|
|
147
162
|
joining: 'リクエスト中…',
|
|
163
|
+
picture: '[画像:Ta で表示]',
|
|
164
|
+
file: '[ファイル・ボイス・動画:Ta で表示]',
|
|
148
165
|
keep: 'あなたの名前とこのブラウザ専用のキーはこのデバイスに保存されます。ブラウザデータをクリアすると再度リクエストが必要です。',
|
|
149
166
|
haveTa: 'Ta をインストール済みですか?Ta アプリでこのリンクをスキャンするかペーストして、タウンなどのゲームも一緒にプレイできます。',
|
|
150
167
|
waiting: '{by}さんにリクエスト済み',
|
|
@@ -171,6 +188,9 @@ const ja = {
|
|
|
171
188
|
rename: '名前を変更',
|
|
172
189
|
leave: 'グループチャットを退出',
|
|
173
190
|
leaveAsk: '「{title}」を退出しますか?退出後は新しい招待でのみ戻ることができます。',
|
|
191
|
+
boardOpen: '対応中 {n} 件',
|
|
192
|
+
boardDone: '完了 {n} 件',
|
|
193
|
+
boardFrom: '{names} から',
|
|
174
194
|
game: 'このグループチャットには Ta のゲームがあり、プレイするには Ta が必要です。ここでチャットできます。',
|
|
175
195
|
empty: 'まだ誰も話していません。グループ内の人だけが見ることができ、リレーは暗号化されて保存されます。',
|
|
176
196
|
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";
|
package/esm/guest/guest-style.js
CHANGED
|
@@ -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}
|