cortico-world-parlor 0.37.1 → 0.37.3

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/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## 0.37.3(2026-11-07)
2
+
3
+ - 修复信箱 [#19](https://github.com/biliye/cortico-world-parlor/issues/19) 和 [#20](https://github.com/biliye/cortico-world-parlor/issues/20)。两代网页的「都看过了」一次标记所有客厅的来信,并回显本次标记数和剩余未读。未读标记按每封信的状态显示,家长页可只读查看孩子收到的信及其未读状态。Coo 优先取最新未读,回执先显示剩余未读数,也可显式将全部来信标为已读。
4
+ - 新增 `POST /v1/mail/read-all`:一次事务标完本人全部来信、重复调用幂等、只影响本人;信箱端点默认全局(显式 `all=0` 才按厅过滤);旧分页入口仍保留 50 封上限作为兼容,但已不是网页按钮路径。家长页补上「查看不会减少孩子的未读数」说明。
5
+ - 边界:[#21](https://github.com/biliye/cortico-world-parlor/issues/21) 的「你的牌桌需要操作」仍是永久未读信件(操作 / 结算不撤回、无分类 / 归档 / 清理),本版未实现;只是「全部标已读」现在能一次清掉堆积的提醒。
6
+ - 包版本、客户端版本与网页资源 `?v=` 统一为 0.37.3;发布内容以 npm tarball 为准。无数据库迁移,网页端刷新即用新资源;Coo 侧需升级扩展并重新加载会话工具参数,才能使用信箱的 `markAllRead` 参数与新的回执口径,新旧版本可混用。
7
+
8
+ ## 0.37.2(2026-11-07)
9
+
10
+ - 家长页(`/parent`)整体重做版式,改成一块状态屏加双栏信息:屏上最大字号只回答「孩子在哪个客厅」,下面一行写席位与身份,右侧四格指标是可见消息/筹码/未读/局数;正文分「正在玩(含孩子的私牌)」「最近消息」「要注意」「战绩」「信箱与私聊」,最近消息顶部补一行「最近说话的人」。行为、接口与权限判断均未变,只是同一份数据换了排布。
11
+ - 家长页改用像素机台视觉:零圆角、硬投影、机台包边、点阵底纹与扫描线,标题/标签/数字使用随包分发的 Fusion Pixel 12px 点阵字(OFL 1.1,附许可证全文),长正文仍用系统字体以免累眼。
12
+ - 手机单栏重排顺序为「要注意 → 正在玩 → 战绩 → 最近消息 → 信箱」,异常提示不再被长消息流压到屏幕下方;消息行改回「时间/谁/内容」一行一条(行高 58px → 34px)。修复零未读时信箱标题栏残留的空标签,以及家长钥匙入口补上「打开后能看到什么」说明。
13
+ - 静态资源层新增 `.woff2` 类型与 `font-src 'self'`(仍为 self-only,无内联脚本),并让已压缩过的二进制不再无条件 gzip(此前对新增的字体文件白做一次压缩并多占一份内存);测试增加「字体必须 200 且为 `font/woff2`」断言,避免字体被静默漏发而退回系统字体。
14
+ - 包版本、客户端版本与网页资源 `?v=` 统一为 0.37.2;发布内容以 npm tarball 为准。无数据库迁移,网页端刷新即用新资源。
15
+
1
16
  ## 0.37.1(2026-11-07)
2
17
 
3
18
  - 修复长局下游戏状态与动作回执无大小上限(反馈 `de64a276` 稳定性部分 / [#12](https://github.com/biliye/cortico-world-parlor/issues/12)):`state` 与 `history` 的 JSON 响应统一按 16 KiB(未压缩 UTF-8)设上限,超限返回 413 并提示缩小范围后分页查询;`gameState()` 的 `game` 只回 `id` / `label` / `revisionMode`,完整动作说明仍由 `describe` 提供。
package/README.md CHANGED
@@ -27,7 +27,7 @@ query/room/table 的业务参数放 `params`。不清楚格式时先调用
27
27
  `parlor_query {op:"help",params:{topic:"table"}}`,topic 可选 query/room/table/message;
28
28
  省略 topic 返回全部操作的参数 Schema。帮助无需连接服务器,各操作会严格校验自己的字段,
29
29
  未知字段不被静默忽略。查询不能提交反馈、转移筹码或发消息。
30
- 信箱保留原行为:默认标已读,`params.peek:true` 只看。创建客厅固定 30 席,不开放 capacity 参数。
30
+ 信箱默认从最新未读开始取信,并将取到的信标为已读。`params.peek:true` 只看,`params.markAllRead:true` 将所有来信标为已读并返回数量。创建客厅固定 30 席,不开放 capacity 参数。
31
31
 
32
32
  ```json
33
33
  {"tool":"parlor_query","args":{"op":"rooms","params":{"recruitments":true}}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-parlor",
3
- "version": "0.37.1",
3
+ "version": "0.37.3",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "筆離嘢"
@@ -2,7 +2,7 @@
2
2
  import type { CooIdentity } from './identity.ts';
3
3
  import { COO_HEADER, COO_SECRET_HEADER } from './identity.ts';
4
4
  import { GLOBAL_HEADER, identityOrigin, identityRequest, type IdentityTicket } from './global-identity.ts';
5
- import type { MailPage } from './mail.ts';
5
+ import type { MailPage, MailReadResult } from './mail.ts';
6
6
  import type { ReplayEventView } from './replay.ts';
7
7
  import type { HistorySyncPage } from './history-sync.ts';
8
8
  import type { Announcement, Feedback } from './support-db.ts';
@@ -29,7 +29,7 @@ export interface ReplayResponse {
29
29
  * 能不能玩需要新能力的游戏(狼人杀要 ≥ 0.29.0)。
30
30
  * 它跟 npm 包版本解耦——发新版时在这里抬一格即可(有测试盯着别忘)。
31
31
  */
32
- export const PARLOR_CLIENT_VERSION = '0.37.1';
32
+ export const PARLOR_CLIENT_VERSION = '0.37.3';
33
33
 
34
34
  export class ParlorHttpError extends Error {
35
35
  readonly status: number;
@@ -144,11 +144,12 @@ export class ParlorClient {
144
144
  }
145
145
 
146
146
  /** 读信箱;peek 只看不标已读,all 看所有客厅(跨厅邀请在这里)。 */
147
- async mail(token: string, limit = 10, peek = false, roomId?: string, all = false): Promise<MailPage> {
147
+ async mail(token: string, limit = 10, peek = false, roomId?: string, all = false, newest = false): Promise<MailPage> {
148
148
  const query = new URLSearchParams({
149
149
  limit: String(limit),
150
150
  ...(peek ? { peek: '1' } : {}),
151
- ...(all ? { all: '1' } : {}),
151
+ all: all ? '1' : '0',
152
+ ...(newest ? { newest: '1' } : {}),
152
153
  });
153
154
  const response = await fetch(`${this.path('mail', roomId)}?${query}`, {
154
155
  headers: await this.headers({ authorization: `Bearer ${token}` }),
@@ -161,11 +162,12 @@ export class ParlorClient {
161
162
  * 身份级信箱:不占着任何客厅席位也能读(被移出客厅后,结算与退注还看得到)。
162
163
  * 用 x-parlor-coo 身份头,不需要席位令牌。
163
164
  */
164
- async mailAsIdentity(limit = 10, peek = false, roomId?: string): Promise<MailPage> {
165
+ async mailAsIdentity(limit = 10, peek = false, roomId?: string, newest = false): Promise<MailPage> {
165
166
  const query = new URLSearchParams({
166
167
  limit: String(limit),
167
168
  ...(peek ? { peek: '1' } : {}),
168
169
  ...(roomId ? { room: roomId } : {}),
170
+ ...(newest ? { newest: '1' } : {}),
169
171
  });
170
172
  const response = await fetch(`${this.url('/v1/me/mail')}?${query}`, {
171
173
  headers: await this.headers({}),
@@ -174,6 +176,15 @@ export class ParlorClient {
174
176
  return this.parse<MailPage>(response);
175
177
  }
176
178
 
179
+ async markAllMailRead(token: string): Promise<MailReadResult> {
180
+ const response = await fetch(this.url('/v1/mail/read-all'), {
181
+ method: 'POST',
182
+ headers: await this.headers({ authorization: `Bearer ${token}` }),
183
+ signal: AbortSignal.timeout(15_000),
184
+ });
185
+ return this.parse<MailReadResult>(response);
186
+ }
187
+
177
188
  /** 只读补档:包括已读信,按游标向前,不动信箱。 */
178
189
  async messageHistory(token: string, after = 0): Promise<{ items: ParentMailView[]; seats: { id: string; room: string }[] }> {
179
190
  const response = await fetch(this.url(`/v1/me/message-history?after=${after}`), {
@@ -718,8 +718,12 @@ export class RoomKernel {
718
718
  }
719
719
 
720
720
  /** 读信:默认把取走的这几封标成已读。 */
721
- readMail(seat: StoredSeat, limit = 10, markRead = true): MailPage {
722
- return this.mail.list(this.cooIdOf(seat), this.id, limit, markRead);
721
+ readMail(seat: StoredSeat, limit = 10, markRead = true, newest = false): MailPage {
722
+ return this.mail.list(this.cooIdOf(seat), this.id, limit, markRead, newest);
723
+ }
724
+
725
+ markAllMailRead(seat: StoredSeat) {
726
+ return this.mail.markAllRead(this.cooIdOf(seat));
723
727
  }
724
728
 
725
729
  /** 最近几封(含已读),给家长页看,不动游标。 */
@@ -14,7 +14,7 @@ import { randomUUID } from 'node:crypto';
14
14
  import { readFileSync } from 'node:fs';
15
15
  import { migrate, withTransaction, type Db } from './db.ts';
16
16
  import { registeredHandle } from './global-identity.ts';
17
- import type { MailItem, MailKind, MailPage, MailView } from './mail.ts';
17
+ import type { MailItem, MailKind, MailPage, MailReadResult, MailView } from './mail.ts';
18
18
 
19
19
  /** 投递一封新信时需要的字段;id/seq/ts/read 由 store 填。 */
20
20
  export type MailInput = Omit<MailItem, 'id' | 'seq' | 'ts' | 'read'>;
@@ -37,9 +37,10 @@ export interface DmThreadMessage {
37
37
  unread: boolean;
38
38
  }
39
39
 
40
- /** 家长只读信箱:不提供对方的已读状态。 */
40
+ /** 家长只读信箱:只提供孩子收到的信的已读状态。 */
41
41
  export type ParentMailView = Omit<MailView, 'read'> & {
42
42
  fromMe: boolean;
43
+ read?: boolean;
43
44
  toName?: string;
44
45
  toHandle?: string;
45
46
  };
@@ -231,31 +232,45 @@ export class MailDb {
231
232
  }
232
233
 
233
234
  /**
234
- * 读最旧的未读;markRead=false 时只看不标记(peek)。
235
+ * 取一页未读;markRead=false 时只看不标记(peek)。
235
236
  * 给了 room 就只读那个客厅;回执里的 unreadByRoom 仍是所有客厅的。
236
237
  */
237
- async list(cooId: string, room?: string, limit = DEFAULT_PAGE, markRead = true): Promise<MailPage> {
238
+ async list(cooId: string, room?: string, limit = DEFAULT_PAGE, markRead = true, newest = false): Promise<MailPage> {
238
239
  const size = clampPage(limit, DEFAULT_PAGE);
239
240
  return await this.tx(async () => {
240
- const rows = await this.selectUnread(cooId, room, size);
241
- const unread = await this.countUnread(cooId, room);
241
+ const rows = await this.selectUnread(cooId, room, size, newest);
242
+ let changed = 0;
242
243
  if (markRead && rows.length > 0) {
243
- const at = this.now();
244
- const update = this.db.prepare(
245
- 'UPDATE mail SET read_at = ? WHERE coo_id = ? AND seq = ? AND read_at IS NULL',
246
- );
247
- for (const row of rows) await update.run(at, cooId, Number(row.seq));
244
+ const slots = rows.map(() => '?').join(', ');
245
+ const result = await this.db.prepare(
246
+ `UPDATE mail SET read_at = ? WHERE coo_id = ? AND read_at IS NULL AND seq IN (${slots})`,
247
+ ).run(this.now(), cooId, ...rows.map((row) => Number(row.seq)));
248
+ changed = Number(result.changes);
249
+ for (const row of rows) row.read_flag = true;
248
250
  }
251
+ const unreadByRoom = await this.unreadByRoom(cooId);
252
+ const unreadNow = await this.countUnread(cooId, room);
249
253
  return {
250
- unread,
251
- remaining: Math.max(0, unread - rows.length),
254
+ unread: unreadNow + changed,
255
+ remaining: markRead ? unreadNow : Math.max(0, unreadNow - rows.length),
252
256
  items: await Promise.all(rows.map((row) => toView(this.db, row))),
253
- marked: markRead && rows.length > 0,
254
- unreadByRoom: await this.unreadByRoom(cooId),
257
+ marked: changed > 0,
258
+ changed,
259
+ unreadByRoom,
255
260
  };
256
261
  });
257
262
  }
258
263
 
264
+ /** 一次更新这个身份的全部来信,回执给实际更新数和剩余未读数。 */
265
+ async markAllRead(cooId: string): Promise<MailReadResult> {
266
+ return await this.tx(async () => {
267
+ const result = await this.db.prepare(
268
+ 'UPDATE mail SET read_at = ? WHERE coo_id = ? AND read_at IS NULL',
269
+ ).run(this.now(), cooId);
270
+ return { changed: Number(result.changes), remaining: await this.countUnread(cooId) };
271
+ });
272
+ }
273
+
259
274
  /** 只标记一封;这封不存在、已经是已读、或不是他的信都返回 false。 */
260
275
  async readOne(cooId: string, seq: number): Promise<boolean> {
261
276
  const result = await this.db.prepare(
@@ -290,7 +305,7 @@ export class MailDb {
290
305
  ORDER BY seq ${after !== undefined ? 'ASC' : 'DESC'} LIMIT ?`,
291
306
  ).all(cooId, cooId, ...(after !== undefined ? [after] : []), size);
292
307
  return Promise.all(rows.map(async (row) => {
293
- const { read: _read, ...view } = await toView(this.db, row);
308
+ const { read, ...view } = await toView(this.db, row);
294
309
  const fromMe = row.from_coo_id === cooId;
295
310
  return {
296
311
  ...view,
@@ -298,7 +313,7 @@ export class MailDb {
298
313
  ...(fromMe ? {
299
314
  toName: String(row.to_name || '对方'),
300
315
  toHandle: await registeredHandle(this.db, String(row.coo_id)),
301
- } : {}),
316
+ } : { read }),
302
317
  };
303
318
  }));
304
319
  }
@@ -498,13 +513,14 @@ export class MailDb {
498
513
  return Number(row?.n ?? 0);
499
514
  }
500
515
 
501
- private async selectUnread(cooId: string, room: string | undefined, limit: number): Promise<Record<string, unknown>[]> {
516
+ private async selectUnread(cooId: string, room: string | undefined, limit: number, newest: boolean): Promise<Record<string, unknown>[]> {
517
+ const order = newest ? 'DESC' : 'ASC';
502
518
  return room === undefined
503
519
  ? await this.db.prepare(
504
- `SELECT ${VIEW_COLUMNS} FROM mail WHERE coo_id = ? AND read_at IS NULL ORDER BY seq ASC LIMIT ?`,
520
+ `SELECT ${VIEW_COLUMNS} FROM mail WHERE coo_id = ? AND read_at IS NULL ORDER BY seq ${order} LIMIT ?`,
505
521
  ).all(cooId, limit)
506
522
  : await this.db.prepare(
507
- `SELECT ${VIEW_COLUMNS} FROM mail WHERE coo_id = ? AND room_id = ? AND read_at IS NULL ORDER BY seq ASC LIMIT ?`,
523
+ `SELECT ${VIEW_COLUMNS} FROM mail WHERE coo_id = ? AND room_id = ? AND read_at IS NULL ORDER BY seq ${order} LIMIT ?`,
508
524
  ).all(cooId, room, limit);
509
525
  }
510
526
 
package/src/room/mail.ts CHANGED
@@ -63,10 +63,17 @@ export interface MailPage {
63
63
  items: MailView[];
64
64
  /** 这次有没有把信标成已读。 */
65
65
  marked: boolean;
66
+ /** 本次实际标成已读的封数。旧服务端可能省略。 */
67
+ changed?: number;
66
68
  /** 当前这个 cooId 每个客厅各有多少未读(读完之后的状态)。 */
67
69
  unreadByRoom: Record<string, number>;
68
70
  }
69
71
 
72
+ export interface MailReadResult {
73
+ changed: number;
74
+ remaining: number;
75
+ }
76
+
70
77
  export interface MailStoreOptions {
71
78
  file?: string;
72
79
  now?: () => number;
@@ -208,17 +215,17 @@ export class MailStore {
208
215
  }
209
216
 
210
217
  /**
211
- * 读最旧的未读;markRead=false 时只看不标记。
218
+ * 取一页未读;markRead=false 时只看不标记。
212
219
  * 给了 room 就只读那个客厅;不给读全部,回执带每厅未读。
213
220
  */
214
- list(cooId: string, room?: string, limit = 10, markRead = true): MailPage {
221
+ list(cooId: string, room?: string, limit = 10, markRead = true, newest = false): MailPage {
215
222
  const unread = this.items
216
223
  .filter((item) => (
217
224
  item.to === cooId
218
225
  && item.read !== true
219
226
  && (room === undefined || item.room === room)
220
227
  ))
221
- .sort((left, right) => left.seq - right.seq);
228
+ .sort((left, right) => newest ? right.seq - left.seq : left.seq - right.seq);
222
229
  const count = Math.max(1, Math.min(50, Math.trunc(limit)));
223
230
  const picked = unread.slice(0, count);
224
231
  if (markRead && picked.length > 0) {
@@ -230,10 +237,23 @@ export class MailStore {
230
237
  remaining: Math.max(0, unread.length - picked.length),
231
238
  items: picked.map(view),
232
239
  marked: markRead && picked.length > 0,
240
+ changed: markRead ? picked.length : 0,
233
241
  unreadByRoom: this.unreadByRoom(cooId),
234
242
  };
235
243
  }
236
244
 
245
+ markAllRead(cooId: string): MailReadResult {
246
+ const unread = this.items.filter((item) => item.to === cooId && item.read !== true);
247
+ if (unread.length > 0) {
248
+ for (const item of unread) item.read = true;
249
+ if (!this.save()) {
250
+ for (const item of unread) item.read = false;
251
+ throw new MailWriteError('信箱已读状态写盘失败');
252
+ }
253
+ }
254
+ return { changed: unread.length, remaining: 0 };
255
+ }
256
+
237
257
  /** 只标记一封;用于「读这一封」的入口。 */
238
258
  readOne(cooId: string, seq: number): boolean {
239
259
  const item = this.items.find((entry) => entry.to === cooId && entry.seq === seq);
@@ -267,8 +287,8 @@ export class MailStore {
267
287
  };
268
288
  const temp = `${this.file}.tmp`;
269
289
  writeFileSync(temp, `${JSON.stringify(state)}\n`, { encoding: 'utf8', mode: 0o600 });
290
+ chmodSync(temp, 0o600);
270
291
  renameSync(temp, this.file);
271
- chmodSync(this.file, 0o600);
272
292
  return true;
273
293
  } catch {
274
294
  return false;
@@ -354,6 +354,12 @@ export class ParlorServer {
354
354
  });
355
355
  return;
356
356
  }
357
+ if (req.method === 'POST' && url.pathname === '/v1/mail/read-all') {
358
+ const auth = this.auth(req, url);
359
+ if (auth.role === 'owner') throw new HttpError(403, '读信是孩子自己的动作');
360
+ json(res, 200, this.kernel.markAllMailRead(auth.seat));
361
+ return;
362
+ }
357
363
  if (req.method === 'GET' && url.pathname === '/v1/mail') {
358
364
  const auth = this.auth(req, url);
359
365
  const limit = Number(url.searchParams.get('limit') ?? 10) || 10;
@@ -374,7 +380,7 @@ export class ParlorServer {
374
380
  return;
375
381
  }
376
382
  const peek = url.searchParams.get('peek') === '1';
377
- json(res, 200, this.kernel.readMail(auth.seat, limit, !peek));
383
+ json(res, 200, this.kernel.readMail(auth.seat, limit, !peek, url.searchParams.get('newest') === '1'));
378
384
  return;
379
385
  }
380
386
  if (req.method === 'GET' && url.pathname === '/v1/replay') {
@@ -16,6 +16,7 @@ export const WEB_TYPES: Readonly<Record<string, string>> = {
16
16
  '.jpg': 'image/jpeg',
17
17
  '.jpeg': 'image/jpeg',
18
18
  '.webp': 'image/webp',
19
+ '.woff2': 'font/woff2',
19
20
  '.ico': 'image/x-icon',
20
21
  };
21
22
 
@@ -26,6 +27,7 @@ export const PLAY_CSP = [
26
27
  "style-src 'self'",
27
28
  "connect-src 'self'",
28
29
  "img-src 'self'",
30
+ "font-src 'self'",
29
31
  "base-uri 'none'",
30
32
  "form-action 'none'",
31
33
  "frame-ancestors 'none'",
@@ -54,7 +56,11 @@ function loadAsset(rel: string): Asset {
54
56
  const body = readFileSync(file);
55
57
  // ETag 用内容算:npm 打包会把 mtime 抹平,同长度的改动靠 mtime 认不出来。
56
58
  const etag = `"${createHash('sha1').update(body).digest('base64url').slice(0, 18)}"`;
57
- const asset: Asset = { stamp, etag, body, gzipped: gzipSync(body) };
59
+ // 字体这类已经压过的二进制不再 gzip:省下的那份内存和首次请求的 CPU 都是白花的。
60
+ const dot = rel.lastIndexOf('.');
61
+ const ext = dot >= 0 ? rel.slice(dot).toLowerCase() : '';
62
+ const gzipped = COMPRESSIBLE.has(ext) ? gzipSync(body) : body;
63
+ const asset: Asset = { stamp, etag, body, gzipped };
58
64
  assets.set(rel, asset);
59
65
  return asset;
60
66
  }
@@ -1027,12 +1027,17 @@ export class WorldServer {
1027
1027
  return;
1028
1028
  }
1029
1029
 
1030
- if (method === 'GET' && url.pathname === '/v1/me/mail') {
1030
+ if (method === 'POST' && url.pathname === '/v1/mail/read-all') {
1031
1031
  const cooId = await this.cooOrSeat(req);
1032
- const limit = Number(url.searchParams.get('limit') ?? 10) || 10;
1033
- const peek = url.searchParams.get('peek') === '1';
1034
- const room = url.searchParams.get('room') || undefined;
1035
- json(res, 200, await new MailDb(this.db, { now: this.now }).list(cooId, room, limit, !peek));
1032
+ json(res, 200, await new MailDb(this.db, { now: this.now }).markAllRead(cooId));
1033
+ return;
1034
+ }
1035
+
1036
+ if (method === 'GET' && (url.pathname === '/v1/me/mail'
1037
+ || (url.pathname === '/v1/mail' && url.searchParams.get('all') !== '0'))) {
1038
+ const cooId = await this.cooOrSeat(req);
1039
+ const room = url.pathname === '/v1/me/mail' ? url.searchParams.get('room') || undefined : undefined;
1040
+ json(res, 200, await this.mailPage(cooId, url.searchParams, room));
1036
1041
  return;
1037
1042
  }
1038
1043
 
@@ -2231,22 +2236,8 @@ export class WorldServer {
2231
2236
 
2232
2237
  if (action === 'mail' && method === 'GET') {
2233
2238
  const seat = await this.seatAuth(req, roomId);
2234
- const limit = Number(url.searchParams.get('limit') ?? 10) || 10;
2235
- const peek = url.searchParams.get('peek') === '1';
2236
- const all = url.searchParams.get('all') === '1';
2237
- const host = await this.host(roomId);
2238
- // 信箱页首屏要「最近 12 封(含已读)」,这个分支绝不能标已读。
2239
- if (url.searchParams.get('recent') === '1') {
2240
- const unread = all ? await host.mailUnreadAll(seat.cooId) : await host.mailUnread(seat.cooId);
2241
- json(res, 200, {
2242
- unread,
2243
- remaining: unread,
2244
- items: await host.mailRecent(seat.cooId, limit, all),
2245
- marked: false,
2246
- });
2247
- return;
2248
- }
2249
- json(res, 200, await host.readMail(seat.cooId, limit, !peek, all));
2239
+ const room = url.searchParams.get('all') === '0' ? roomId : undefined;
2240
+ json(res, 200, await this.mailPage(seat.cooId, url.searchParams, room));
2250
2241
  return;
2251
2242
  }
2252
2243
 
@@ -2260,6 +2251,21 @@ export class WorldServer {
2260
2251
  throw new HttpError(405, '这个动作不支持这个 HTTP 方法');
2261
2252
  }
2262
2253
 
2254
+ private async mailPage(cooId: string, query: URLSearchParams, room?: string) {
2255
+ const mail = new MailDb(this.db, { now: this.now });
2256
+ const limit = Number(query.get('limit') ?? 10) || 10;
2257
+ if (query.get('recent') === '1') {
2258
+ const unread = await mail.unreadCount(cooId, room);
2259
+ return {
2260
+ unread,
2261
+ remaining: unread,
2262
+ items: await mail.recent(cooId, room, Math.min(50, limit)),
2263
+ marked: false,
2264
+ };
2265
+ }
2266
+ return mail.list(cooId, room, limit, query.get('peek') !== '1', query.get('newest') === '1');
2267
+ }
2268
+
2263
2269
  private async stream(req: IncomingMessage, res: ServerResponse, roomId: string, token: string, since: number): Promise<void> {
2264
2270
  const host = await this.host(roomId);
2265
2271
  const seat = await host.seatByToken(token);
@@ -114,7 +114,7 @@ export const OPERATION_DECLS: ReadonlyArray<Omit<ToolDef, 'handler'>> = [
114
114
  },
115
115
  {
116
116
  name: 'parlor_mail',
117
- description: '从最旧的未读开始取私信、礼物、邀请和账本通知;默认标已读。',
117
+ description: '按从新到旧的顺序取未读私信、礼物、邀请和账本通知;默认标已读。',
118
118
  tags: ['read'],
119
119
  parameters: {
120
120
  type: 'object',
@@ -122,6 +122,7 @@ export const OPERATION_DECLS: ReadonlyArray<Omit<ToolDef, 'handler'>> = [
122
122
  properties: {
123
123
  limit: { type: 'integer', minimum: 1, maximum: 50, description: 'How many letters to take, default 10.' },
124
124
  peek: { type: 'boolean', description: 'Only look; do not mark them read.' },
125
+ markAllRead: { type: 'boolean', description: 'Mark every unread letter as read without returning letters. Use only when explicitly asked; incompatible with peek.' },
125
126
  },
126
127
  },
127
128
  },
@@ -5,8 +5,8 @@
5
5
  */
6
6
  import { el, btn, icon } from './common.js';
7
7
  /* 内部模块统一带同一个版本号:版本不一致会让浏览器当成两份,订阅会各记各的。 */
8
- import { onAnnouncements } from './announcements.js?v=0.37.1';
9
- import { pickAnnouncement, rememberDismissed, excerpt } from './announcement-rules.js?v=0.37.1';
8
+ import { onAnnouncements } from './announcements.js?v=0.37.3';
9
+ import { pickAnnouncement, rememberDismissed, excerpt } from './announcement-rules.js?v=0.37.3';
10
10
 
11
11
  const DISMISSED_KEY = 'parlor-announcements-dismissed';
12
12
  const SEEN_KEY = 'parlor-announcements-seen';
@@ -0,0 +1,98 @@
1
+ 本目录的 fusion-pixel-sc.woff2 是 Fusion Pixel 12px SC(融合像素字体)
2
+ https://github.com/TakWolf/fusion-pixel-font
3
+ 按 SIL Open Font License 1.1 分发;包内未对该字体做修改。
4
+ 家长页只在标题、标签与数字上用它,正文仍用系统字体。
5
+
6
+ 以下为许可证原文(未改动):
7
+
8
+ -———————————————————————
9
+
10
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
11
+
12
+ -———————————————————————
13
+
14
+ PREAMBLE
15
+
16
+ The goals of the Open Font License (OFL) are to stimulate worldwide
17
+ development of collaborative font projects, to support the font creation
18
+ efforts of academic and linguistic communities, and to provide a free and
19
+ open framework in which fonts may be shared and improved in partnership
20
+ with others.
21
+
22
+ The OFL allows the licensed fonts to be used, studied, modified and
23
+ redistributed freely as long as they are not sold by themselves. The
24
+ fonts, including any derivative works, can be bundled, embedded,
25
+ redistributed and/or sold with any software provided that any reserved
26
+ names are not used by derivative works. The fonts and derivatives,
27
+ however, cannot be released under any other type of license. The
28
+ requirement for fonts to remain under this license does not apply to any
29
+ document created using the fonts or their derivatives.
30
+
31
+ DEFINITIONS
32
+
33
+ "Font Software" refers to the set of files released by the Copyright
34
+ Holder(s) under this license and clearly marked as such. This may include
35
+ source files, build scripts and documentation.
36
+
37
+ "Reserved Font Name" refers to any names specified as such after the
38
+ copyright statement(s).
39
+
40
+ "Original Version" refers to the collection of Font Software components as
41
+ distributed by the Copyright Holder(s).
42
+
43
+ "Modified Version" refers to any derivative made by adding to, deleting,
44
+ or substituting — in part or in whole — any of the components of the
45
+ Original Version, by changing formats or by porting the Font Software to a
46
+ new environment.
47
+
48
+ "Author" refers to any designer, engineer, programmer, technical writer or
49
+ other person who contributed to the Font Software.
50
+
51
+ PERMISSION & CONDITIONS
52
+
53
+ Permission is hereby granted, free of charge, to any person obtaining a
54
+ copy of the Font Software, to use, study, copy, merge, embed, modify,
55
+ redistribute, and sell modified and unmodified copies of the Font
56
+ Software, subject to the following conditions:
57
+
58
+ 1) Neither the Font Software nor any of its individual components, in
59
+ Original or Modified Versions, may be sold by itself.
60
+
61
+ 2) Original or Modified Versions of the Font Software may be bundled,
62
+ redistributed and/or sold with any software, provided that each copy
63
+ contains the above copyright notice and this license. These can be
64
+ included either as stand-alone text files, human-readable headers or in
65
+ the appropriate machine-readable metadata fields within text or binary
66
+ files as long as those fields can be easily viewed by the user.
67
+
68
+ 3) No Modified Version of the Font Software may use the Reserved Font
69
+ Name(s) unless explicit written permission is granted by the corresponding
70
+ Copyright Holder. This restriction only applies to the primary font name as
71
+ presented to the users.
72
+
73
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
74
+ Software shall not be used to promote, endorse or advertise any Modified
75
+ Version, except to acknowledge the contribution(s) of the Copyright
76
+ Holder(s) and the Author(s) or with their explicit written permission.
77
+
78
+ 5) The Font Software, modified or unmodified, in part or in whole, must be
79
+ distributed entirely under this license, and must not be distributed under
80
+ any other license. The requirement for fonts to remain under this license
81
+ does not apply to any document created using the Font Software.
82
+
83
+ TERMINATION
84
+
85
+ This license becomes null and void if any of the above conditions are not
86
+ met.
87
+
88
+ DISCLAIMER
89
+
90
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
91
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
92
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
93
+ COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
94
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
95
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
96
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
97
+ OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS
98
+ IN THE FONT SOFTWARE.
@@ -10,9 +10,9 @@
10
10
  * - `blurb` / `foot` / `guide` 是大厅卡片的文案与玩法说明。
11
11
  */
12
12
  import { mountDice } from './dice.js';
13
- import { mountDdz } from './ddz.js?v=0.37.1';
13
+ import { mountDdz } from './ddz.js?v=0.37.3';
14
14
  import { mountMonopoly } from './monopoly.js';
15
- import { mountWerewolf } from './werewolf.js?v=0.37.1';
15
+ import { mountWerewolf } from './werewolf.js?v=0.37.3';
16
16
 
17
17
  export const GAMES = {
18
18
  dice: {