@dsh-tom/dsh-css 0.2.10 → 0.2.11

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/README.md CHANGED
@@ -22,7 +22,7 @@ npm publish --access public --registry=https://registry.npmjs.org/
22
22
  打开 **插件 → 添加插件 → 安装第三方插件**,在“包名或地址”输入:
23
23
 
24
24
  ```text
25
- D:\product\dsh-css\dsh-tom-dsh-css-0.2.10.tgz
25
+ D:\product\dsh-css\dsh-tom-dsh-css-0.2.11.tgz
26
26
  ```
27
27
 
28
28
  安装并启用,然后完全退出并重新打开 dsh。
@@ -32,7 +32,7 @@ D:\product\dsh-css\dsh-tom-dsh-css-0.2.10.tgz
32
32
  包发布到 npmjs 后,先卸载已安装的旧版,再打开 **插件 → 添加插件 → 安装第三方插件**,输入:
33
33
 
34
34
  ```text
35
- @dsh-tom/dsh-css@0.2.10
35
+ @dsh-tom/dsh-css@0.2.11
36
36
  ```
37
37
 
38
38
  选择 **安装源 → npm 官方源**,安装并启用,然后完全退出并重新打开 dsh。
package/dist/client.js CHANGED
@@ -1083,24 +1083,37 @@ function replacePercent(value, percent) {
1083
1083
  function registerCacheHitPrecision(ctx) {
1084
1084
  const slot = "conversation.composer.dock";
1085
1085
  ctx.slots.inject(slot, () => {
1086
- const original = ctx.slots.entries(slot).find((entry) => entry.options.id === "usage");
1087
- if (!original) return;
1088
- const renderUsage = original.component.type;
1089
- function UsagePill(props) {
1090
- const element = renderUsage(props);
1091
- const usage = props.useProjection("tokenUsage");
1092
- if (!usage) return element;
1093
- const input2 = usage.uncachedInputTokens + usage.cacheReadTokens + usage.cacheWriteTokens;
1094
- if (input2 === 0) return element;
1095
- return replacePercent(element, (usage.cacheReadTokens / input2 * 100).toFixed(2));
1096
- }
1097
- return ctx.slots.register({
1098
- ...original.options,
1099
- name: slot,
1100
- priority: (original.options.priority ?? 0) - 1,
1101
- locale: original.locale,
1102
- inject: original.inject
1103
- }, UsagePill);
1086
+ let original;
1087
+ let dispose;
1088
+ const sync = () => {
1089
+ if (original && ctx.slots.entries(slot).includes(original)) return;
1090
+ dispose?.();
1091
+ dispose = void 0;
1092
+ original = ctx.slots.entries(slot).find((entry) => entry.options.id === "usage");
1093
+ if (!original) return;
1094
+ const renderUsage = original.component.type;
1095
+ function UsagePill(props) {
1096
+ const element = renderUsage(props);
1097
+ const usage = props.useProjection("tokenUsage");
1098
+ if (!usage) return element;
1099
+ const input2 = usage.uncachedInputTokens + usage.cacheReadTokens + usage.cacheWriteTokens;
1100
+ if (input2 === 0) return element;
1101
+ return replacePercent(element, (usage.cacheReadTokens / input2 * 100).toFixed(2));
1102
+ }
1103
+ dispose = ctx.slots.register({
1104
+ ...original.options,
1105
+ name: slot,
1106
+ priority: (original.options.priority ?? 0) - 1,
1107
+ locale: original.locale,
1108
+ inject: original.inject
1109
+ }, UsagePill);
1110
+ };
1111
+ const unsubscribe = ctx.slots.subscribe(slot, sync);
1112
+ sync();
1113
+ return () => {
1114
+ unsubscribe();
1115
+ dispose?.();
1116
+ };
1104
1117
  });
1105
1118
  }
1106
1119
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsh-tom/dsh-css",
3
- "version": "0.2.10",
3
+ "version": "0.2.11",
4
4
  "description": "为 DeepSeek Harness 调整深色界面,增加项目管理、费用统计和任务进展播报。",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",