koishi-plugin-ciyi 1.1.2 → 1.2.2

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.
@@ -0,0 +1,7 @@
1
+ import type CanvasService from "@koishijs/canvas";
2
+ import { BoardOptions, IntroOptions, RankOptions, StartOptions, WinOptions } from "./view";
3
+ export declare function renderBoardCard(service: CanvasService, opts: BoardOptions): Promise<Buffer>;
4
+ export declare function renderIntroCard(service: CanvasService, opts: IntroOptions): Promise<Buffer>;
5
+ export declare function renderStartCard(service: CanvasService, opts: StartOptions): Promise<Buffer>;
6
+ export declare function renderWinCard(service: CanvasService, opts: WinOptions): Promise<Buffer>;
7
+ export declare function renderRankCard(service: CanvasService, opts: RankOptions): Promise<Buffer>;
package/lib/view.d.ts CHANGED
@@ -13,54 +13,37 @@ export interface Tier {
13
13
  }
14
14
  export declare const TIERS: Tier[];
15
15
  export declare function tierOf(rank: number): Tier;
16
- /**
17
- * 排名 → 亲近度百分比。
18
- *
19
- * 榜单是幂律分布的:#1 与 #50 的差别,远大于 #20000 与 #30000 的差别。
20
- * 所以取对数刻度,否则前一千名会全部挤在进度条最左端的一根头发丝里。
21
- */
16
+ /** 排名 → 亲近度百分比(对数刻度,适配幂律分布的榜单)。 */
22
17
  export declare function nearness(rank: number, total: number): number;
23
- export declare function esc(s: any): string;
24
18
  export interface BoardRow {
25
19
  history: History;
26
- /** 本次刚提交的那一条,单独点亮 */
27
20
  fresh?: boolean;
28
- /** 这一行之前被截断了多少条 */
29
21
  gapBefore?: number;
30
22
  }
31
23
  export interface BoardOptions {
32
24
  rows: BoardRow[];
33
- /** 榜单总词数,用于换算亲近度 */
34
25
  total: number;
35
- /** 本局累计猜了多少词(不受截断影响) */
36
26
  attempts: number;
37
27
  tip: string;
38
28
  }
39
- export declare function boardCard(opts: BoardOptions): string;
40
29
  export interface StartOptions {
41
30
  total: number;
42
31
  words: number;
43
- /** 题库里还剩多少道没出过 */
44
32
  left: number;
45
33
  }
46
- export declare function startCard(opts: StartOptions): string;
47
34
  export interface IntroOptions {
48
35
  total: number;
49
36
  words: number;
50
37
  middleware: boolean;
51
38
  }
52
- export declare function introCard(opts: IntroOptions): string;
53
39
  export interface WinOptions {
54
40
  answer: string;
55
41
  attempts: number;
56
- /** 猜中之前最接近的一次排名;首猜即中时为空 */
57
42
  closest: number | null;
58
- /** 榜单上紧挨着答案的几个词,封题后一并奉上 */
59
43
  neighbors: string[];
60
44
  username: string;
61
45
  score: number;
62
46
  }
63
- export declare function winCard(opts: WinOptions): string;
64
47
  export interface RankEntry {
65
48
  username: string;
66
49
  score: number;
@@ -69,7 +52,5 @@ export interface RankEntry {
69
52
  export interface RankOptions {
70
53
  entries: RankEntry[];
71
54
  hidden: number;
72
- /** 上榜总人数 */
73
55
  players: number;
74
56
  }
75
- export declare function rankCard(opts: RankOptions): string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-ciyi",
3
3
  "description": "Koishi 的词意(猜词游戏)插件。根据词语的含义相似程度,猜测正确的词语。",
4
- "version": "1.1.2",
4
+ "version": "1.2.2",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
@@ -15,7 +15,7 @@
15
15
  "database"
16
16
  ],
17
17
  "optional": [
18
- "puppeteer"
18
+ "canvas"
19
19
  ]
20
20
  }
21
21
  },
@@ -40,6 +40,9 @@
40
40
  "词影",
41
41
  "词意"
42
42
  ],
43
+ "dependencies": {
44
+ "@koishijs/canvas": "^0.2.0"
45
+ },
43
46
  "peerDependencies": {
44
47
  "koishi": "^4.18.9",
45
48
  "koishi-plugin-puppeteer": "^3.9.0"
@@ -48,8 +51,5 @@
48
51
  "koishi-plugin-puppeteer": {
49
52
  "optional": true
50
53
  }
51
- },
52
- "devDependencies": {
53
- "koishi-plugin-puppeteer": "^3.9.0"
54
54
  }
55
55
  }
package/readme.md CHANGED
@@ -23,22 +23,27 @@ Koishi 的词意(猜词游戏)插件。根据词语的含义相似程度,
23
23
 
24
24
  ## 图片
25
25
 
26
- 安装 `puppeteer` 服务后,玩法、开局、猜测板、揭晓与排行榜都会渲染成「墨与纸」
27
- 风格的卡片:宣纸底、古籍双线框、朱砂印,每个字住在自己的田字格里,隐去的字
28
- 只留空格与虚线中缝。猜测按名次由近及远排列,配六档亲疏色阶 ——
29
- 咫尺 / 毗邻 / 相近 / 沾边 / 疏远 / 天涯。
26
+ 启用 Koishi Canvas 服务后渲染「墨与纸」风格卡片:宣纸底、古籍双线框、
27
+ 朱砂印,每个字住在自己的田字格里,隐去的字只留空格与虚线中缝。猜测按名次由近及远
28
+ 排列,配六档亲疏色阶 —— 咫尺 / 毗邻 / 相近 / 沾边 / 疏远 / 天涯。
30
29
 
31
- 未安装、渲染失败或在配置里关掉「渲染图片」时,自动回退为排版等价的文本,
30
+ 插件复用 Koishi 的通用 `canvas` 服务。`koishi-plugin-puppeteer` 已经自带服务实现,原本启用了
31
+ Puppeteer 的用户无需再安装 `@napi-rs/canvas` 或其他大型原生依赖。
32
+
33
+ 没有 Canvas 服务、渲染失败或在配置里关掉「渲染图片」时,自动回退为排版等价的文本,
32
34
  玩法不受影响。
33
35
 
36
+ 如果需要图片但尚未启用服务,可安装并启用 `koishi-plugin-puppeteer`;它是可选依赖,不会随
37
+ 词意插件强制下载。只使用文本玩法时无需安装任何绘图后端。
38
+
34
39
  ## 致谢
35
40
 
36
- * [Koishi](https://koishi.chat/)
37
- * [词影](https://cy.surprising.studio/)
41
+ - [Koishi](https://koishi.chat/)
42
+ - [词影](https://cy.surprising.studio/)
38
43
 
39
44
  ## QQ 群
40
45
 
41
- * 956758505
46
+ - 956758505
42
47
 
43
48
  <br>
44
49