koishi-plugin-ciyi 2.2.0 → 2.2.1

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/DESIGN_SYSTEM.md CHANGED
@@ -7,13 +7,13 @@
7
7
  - 视觉、组件、形状、排版与语义颜色以 [Material 3 / Expressive](https://m3.material.io/) 为准。
8
8
  - [Apple HIG](https://developer.apple.com/design/human-interface-guidelines/accessibility) 用于操作反馈、平台惯例、可恢复性与可访问性,不引入 Apple 视觉组件。
9
9
  - [WCAG 2.2 AA](https://www.w3.org/TR/WCAG22/) 用于非文本内容、颜色与对比度、时间限制、输入错误和破坏性操作审查。
10
- - 色彩使用 Google Material Color Utilities 0.4.0 的 HCT 与 Tonal Spot 动态角色,明确使用 2025 色彩规范。历史 `lch` API 名仅用于源码兼容,计算已经统一为 HCT。
10
+ - 色彩使用 Google Material Color Utilities 0.4.0 的 HCT 与 Tonal Spot 动态角色,明确使用 2025 色彩规范。历史 `lch` API 名仅用于源码兼容,计算已经统一为 HCT。彩色角色(primary / secondary / tertiary / error 及其容器)走官方 Tonal Spot;中性面(surface 系列、on-surface 系列、outline 系列)由 HCT 按本设计系统的色调重算——表面留住一点源色味道、文字取深色档,避免成片近白、文字偏浅的发晃感。
11
11
  - `m3.ts` 是角色颜色、字阶、间距、圆角、层级和基础组件的唯一源文件。`material-color*.ts` 是固定版本的官方算法生成物,授权见 `THIRD_PARTY_NOTICES.md`。
12
12
  - 不额外添加静态截图无法表达的动画;基础 CSS 禁用减少动态效果偏好下的动画和过渡。
13
13
 
14
14
  ## 输出、交互与内容
15
15
 
16
- 1. 图片是信息的增强形式。信息卡、榜单、棋盘在图文模式中附带文字;文字模式保留信息,减少对截图的依赖。
16
+ 1. 图文模式只发渲染图,不附文字;完整文字只在用户切到「文字」模式时出现。图片的等价文字随图片标记,切换到文字模式时展开,因此不会在群里重复刷屏。
17
17
  2. `插件主指令.显示 文字` / `插件主指令.显示 图文` 切换个人显示偏好;同一机器人中的这些插件共享选择。设置保存在内存,重启恢复图文。文本回复不能把后续条目无提示地压掉;较长管理列表分页。
18
18
  3. 裸输入必须符合词法、对局状态及参与条件。多个插件匹配时不执行,要求明确完整指令;完整指令继续可用。
19
19
  4. 回复说明当前结果、未完成原因和可执行的下一步,不用管理员日志替代用户可用的反馈。退款、赔付与渲染失败不能伪装成功。
package/lib/index.js CHANGED
@@ -50,9 +50,10 @@ function usePresentation(ctx, command) {
50
50
  });
51
51
  return {
52
52
  textOnly: /* @__PURE__ */ __name((session) => shared.modes.get(userKey(session)) === true, "textOnly"),
53
+ /** 图文模式只给图片;图片缺失或用户选了文字模式时才退回文字。 */
53
54
  present(session, image, text) {
54
55
  if (!image || shared.modes.get(userKey(session))) return text;
55
- return [...import_koishi.h.normalize(image), (0, import_koishi.h)("p", {}, import_koishi.h.normalize(text))];
56
+ return import_koishi.h.normalize(image);
56
57
  }
57
58
  };
58
59
  }
@@ -5103,9 +5104,13 @@ function onColor(background) {
5103
5104
  }
5104
5105
  __name(onColor, "onColor");
5105
5106
  var SPACING = { xs: 4, sm: 8, md: 12, lg: 16, xl: 24, xxl: 32 };
5107
+ var NEUTRAL_CHROMA = 6;
5108
+ var NEUTRAL_VARIANT_CHROMA = 12;
5106
5109
  function scheme(hue, dark = false, options = {}) {
5107
5110
  const source = Hct.from(hue, options.chroma ?? 56, 50);
5108
5111
  const dynamic = new SchemeTonalSpot(source, dark, 0, "2025");
5112
+ const neutral = /* @__PURE__ */ __name((tone) => hexFromArgb(Hct.from(hue, NEUTRAL_CHROMA, tone).toInt()), "neutral");
5113
+ const variant = /* @__PURE__ */ __name((tone) => hexFromArgb(Hct.from(hue, NEUTRAL_VARIANT_CHROMA, tone).toInt()), "variant");
5109
5114
  return {
5110
5115
  primary: hexFromArgb(dynamic.primary),
5111
5116
  onPrimary: hexFromArgb(dynamic.onPrimary),
@@ -5123,23 +5128,23 @@ function scheme(hue, dark = false, options = {}) {
5123
5128
  onError: hexFromArgb(dynamic.onError),
5124
5129
  errorContainer: hexFromArgb(dynamic.errorContainer),
5125
5130
  onErrorContainer: hexFromArgb(dynamic.onErrorContainer),
5126
- background: hexFromArgb(dynamic.background),
5127
- onBackground: hexFromArgb(dynamic.onBackground),
5128
- surface: hexFromArgb(dynamic.surface),
5129
- onSurface: hexFromArgb(dynamic.onSurface),
5130
- surfaceVariant: hexFromArgb(dynamic.surfaceVariant),
5131
- onSurfaceVariant: hexFromArgb(dynamic.onSurfaceVariant),
5132
- surfaceDim: hexFromArgb(dynamic.surfaceDim),
5133
- surfaceBright: hexFromArgb(dynamic.surfaceBright),
5134
- surfaceContainerLowest: hexFromArgb(dynamic.surfaceContainerLowest),
5135
- surfaceContainerLow: hexFromArgb(dynamic.surfaceContainerLow),
5136
- surfaceContainer: hexFromArgb(dynamic.surfaceContainer),
5137
- surfaceContainerHigh: hexFromArgb(dynamic.surfaceContainerHigh),
5138
- surfaceContainerHighest: hexFromArgb(dynamic.surfaceContainerHighest),
5139
- outline: hexFromArgb(dynamic.outline),
5140
- outlineVariant: hexFromArgb(dynamic.outlineVariant),
5141
- inverseSurface: hexFromArgb(dynamic.inverseSurface),
5142
- inverseOnSurface: hexFromArgb(dynamic.inverseOnSurface),
5131
+ background: dark ? neutral(6) : neutral(97),
5132
+ onBackground: dark ? neutral(90) : neutral(10),
5133
+ surface: dark ? neutral(6) : neutral(97),
5134
+ onSurface: dark ? neutral(90) : neutral(10),
5135
+ surfaceVariant: dark ? variant(30) : variant(90),
5136
+ onSurfaceVariant: dark ? variant(80) : variant(30),
5137
+ surfaceDim: dark ? neutral(6) : neutral(88),
5138
+ surfaceBright: dark ? neutral(24) : neutral(98),
5139
+ surfaceContainerLowest: dark ? neutral(4) : neutral(100),
5140
+ surfaceContainerLow: dark ? neutral(10) : neutral(96),
5141
+ surfaceContainer: dark ? neutral(12) : neutral(94),
5142
+ surfaceContainerHigh: dark ? neutral(17) : neutral(92),
5143
+ surfaceContainerHighest: dark ? neutral(22) : neutral(90),
5144
+ outline: dark ? variant(60) : variant(50),
5145
+ outlineVariant: dark ? variant(30) : variant(80),
5146
+ inverseSurface: dark ? neutral(90) : neutral(20),
5147
+ inverseOnSurface: dark ? neutral(20) : neutral(95),
5143
5148
  inversePrimary: hexFromArgb(dynamic.inversePrimary),
5144
5149
  scrim: hexFromArgb(dynamic.scrim),
5145
5150
  shadow: hexFromArgb(dynamic.shadow)
package/lib/ux.d.ts CHANGED
@@ -3,9 +3,10 @@ type Owner = {
3
3
  name: string;
4
4
  matches: (session: Session) => boolean | Promise<boolean>;
5
5
  };
6
- /** Default output is an image plus its usable text equivalent. Preferences affect this user only. */
6
+ /** 图文模式默认只发渲染图;完整文字只在用户切到「文字」模式时出现。偏好只影响本人。 */
7
7
  export declare function usePresentation(ctx: Context, command: string): {
8
8
  textOnly: (session: Session) => boolean;
9
+ /** 图文模式只给图片;图片缺失或用户选了文字模式时才退回文字。 */
9
10
  present(session: Session, image: h.Fragment | null | undefined, text: h.Fragment): h.Fragment;
10
11
  };
11
12
  /** Plugins register their active input grammar; overlapping messages are never executed. */
@@ -14,7 +15,17 @@ export declare function directInputConflict(ctx: Context, session: Session): Pro
14
15
  /** No hidden time limit: users can extend the non-game input step without losing context. */
15
16
  export declare function promptInput(session: Session, instruction: string): Promise<string | undefined>;
16
17
  export declare const IMAGE_FAILURE = "\u56FE\u7247\u6682\u65F6\u65E0\u6CD5\u751F\u6210\uFF0C\u5DF2\u4FDD\u7559\u6587\u5B57\u5185\u5BB9\u3002\u53EF\u4EE5\u7A0D\u540E\u91CD\u8BD5\uFF1B\u82E5\u6301\u7EED\u5931\u8D25\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u3002";
17
- /** Preserve companion text when image messages are switched to text mode. */
18
+ /**
19
+ * 渲染图的等价文字。图文模式随图片一起丢掉、文字模式展开成正文,
20
+ * 因此它永远不会原样发到聊天平台。
21
+ */
22
+ export declare const IMAGE_TEXT_TYPE = "ux-image-text";
23
+ export declare function imageText(text: h.Fragment): h;
24
+ /** 图文模式:保留图片与普通文字,去掉图片的等价文字。 */
25
+ export declare function imagesOnly(content: h.Fragment): h[];
26
+ /** 文字模式:去掉图片,把等价文字展开成普通文本。 */
18
27
  export declare function withoutImages(content: h.Fragment): h[];
28
+ /** 发送前的统一选择:文字模式去掉图片,图文模式去掉等价文字。 */
29
+ export declare function choosePresentation(content: h.Fragment, textOnly: boolean): h[];
19
30
  export declare function isTextOnly(ctx: Context, session: Session): boolean;
20
31
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-ciyi",
3
3
  "description": "Koishi 群聊猜词:每天一个两字词,支持续猜和排行榜。",
4
- "version": "2.2.0",
4
+ "version": "2.2.1",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [