@dsh-tom/dsh-css 0.2.0 → 0.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/README.md +2 -2
- package/dist/client.js +90 -53
- package/package.json +1 -1
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.
|
|
25
|
+
D:\product\dsh-css\dsh-tom-dsh-css-0.2.1.tgz
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
安装并启用,然后完全退出并重新打开 dsh。
|
|
@@ -32,7 +32,7 @@ D:\product\dsh-css\dsh-tom-dsh-css-0.2.0.tgz
|
|
|
32
32
|
包发布到 npmjs 后,先卸载已安装的旧版,再打开 **插件 → 添加插件 → 安装第三方插件**,输入:
|
|
33
33
|
|
|
34
34
|
```text
|
|
35
|
-
@dsh-tom/dsh-css@0.2.
|
|
35
|
+
@dsh-tom/dsh-css@0.2.1
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
选择 **安装源 → npm 官方源**,安装并启用,然后完全退出并重新打开 dsh。
|
package/dist/client.js
CHANGED
|
@@ -29,7 +29,7 @@ __export(client_exports, {
|
|
|
29
29
|
inject: () => inject2
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(client_exports);
|
|
32
|
-
var
|
|
32
|
+
var import_react6 = require("react");
|
|
33
33
|
|
|
34
34
|
// theme.css
|
|
35
35
|
var theme_default = `/* \u6DF1\u8272\u6A21\u5F0F\u914D\u8272\uFF0C\u4FDD\u7559\u5185\u7F6E\u6587\u5B57\u3001\u8FB9\u6846\u548C\u8BED\u6CD5\u9AD8\u4EAE\u989C\u8272\u3002 */
|
|
@@ -1014,8 +1014,44 @@ function registerProjects(ctx) {
|
|
|
1014
1014
|
}, ProjectsNav));
|
|
1015
1015
|
}
|
|
1016
1016
|
|
|
1017
|
+
// src/cache-hit.js
|
|
1018
|
+
var import_react2 = require("react");
|
|
1019
|
+
function replacePercent(value, percent) {
|
|
1020
|
+
if (typeof value === "string") return value.replace(/\d+(?:\.\d+)?%/g, `${percent}%`);
|
|
1021
|
+
if (Array.isArray(value)) return import_react2.Children.map(value, (child) => replacePercent(child, percent));
|
|
1022
|
+
if (!(0, import_react2.isValidElement)(value)) return value;
|
|
1023
|
+
const props = {};
|
|
1024
|
+
for (const key of ["label", "ariaLabel", "children"]) {
|
|
1025
|
+
if (key in value.props) props[key] = replacePercent(value.props[key], percent);
|
|
1026
|
+
}
|
|
1027
|
+
return (0, import_react2.cloneElement)(value, props);
|
|
1028
|
+
}
|
|
1029
|
+
function registerCacheHitPrecision(ctx) {
|
|
1030
|
+
const slot = "conversation.composer.dock";
|
|
1031
|
+
ctx.slots.inject(slot, () => {
|
|
1032
|
+
const original = ctx.slots.entries(slot).find((entry) => entry.options.id === "usage");
|
|
1033
|
+
if (!original) return;
|
|
1034
|
+
const renderUsage = original.component.type;
|
|
1035
|
+
function UsagePill(props) {
|
|
1036
|
+
const element = renderUsage(props);
|
|
1037
|
+
const usage = props.useProjection("tokenUsage");
|
|
1038
|
+
if (!usage) return element;
|
|
1039
|
+
const input2 = usage.uncachedInputTokens + usage.cacheReadTokens + usage.cacheWriteTokens;
|
|
1040
|
+
if (input2 === 0) return element;
|
|
1041
|
+
return replacePercent(element, (usage.cacheReadTokens / input2 * 100).toFixed(2));
|
|
1042
|
+
}
|
|
1043
|
+
return ctx.slots.register({
|
|
1044
|
+
...original.options,
|
|
1045
|
+
name: slot,
|
|
1046
|
+
priority: (original.options.priority ?? 0) - 1,
|
|
1047
|
+
locale: original.locale,
|
|
1048
|
+
inject: original.inject
|
|
1049
|
+
}, UsagePill);
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1017
1053
|
// src/cost/client.js
|
|
1018
|
-
var
|
|
1054
|
+
var import_react5 = require("react");
|
|
1019
1055
|
|
|
1020
1056
|
// src/cost/pricing.js
|
|
1021
1057
|
var PROJECTION_KEY = "dshTomCost";
|
|
@@ -1053,7 +1089,7 @@ function formatMoney(units) {
|
|
|
1053
1089
|
}
|
|
1054
1090
|
|
|
1055
1091
|
// src/cost/panel.js
|
|
1056
|
-
var
|
|
1092
|
+
var import_react3 = require("react");
|
|
1057
1093
|
var import_react_dom = require("react-dom");
|
|
1058
1094
|
|
|
1059
1095
|
// src/cost/panel-styles.js
|
|
@@ -1129,8 +1165,8 @@ function costRows(totals, daily, day = beijingDay()) {
|
|
|
1129
1165
|
];
|
|
1130
1166
|
}
|
|
1131
1167
|
function useBeijingDay() {
|
|
1132
|
-
const [day, setDay] = (0,
|
|
1133
|
-
(0,
|
|
1168
|
+
const [day, setDay] = (0, import_react3.useState)(beijingDay);
|
|
1169
|
+
(0, import_react3.useEffect)(() => {
|
|
1134
1170
|
let timer;
|
|
1135
1171
|
const refresh = () => {
|
|
1136
1172
|
const current = beijingDay();
|
|
@@ -1144,7 +1180,7 @@ function useBeijingDay() {
|
|
|
1144
1180
|
return day;
|
|
1145
1181
|
}
|
|
1146
1182
|
function CostIcon() {
|
|
1147
|
-
return (0,
|
|
1183
|
+
return (0, import_react3.createElement)(
|
|
1148
1184
|
"svg",
|
|
1149
1185
|
{
|
|
1150
1186
|
viewBox: "0 0 24 24",
|
|
@@ -1157,18 +1193,18 @@ function CostIcon() {
|
|
|
1157
1193
|
strokeLinejoin: "round",
|
|
1158
1194
|
"aria-hidden": true
|
|
1159
1195
|
},
|
|
1160
|
-
(0,
|
|
1161
|
-
(0,
|
|
1196
|
+
(0, import_react3.createElement)("circle", { cx: 12, cy: 12, r: 9 }),
|
|
1197
|
+
(0, import_react3.createElement)("path", { d: "m8.5 7.5 3.5 4 3.5-4M8.5 12h7M8.5 15h7M12 11.5V18" })
|
|
1162
1198
|
);
|
|
1163
1199
|
}
|
|
1164
1200
|
function CostPanel({ totals, daily, balance }) {
|
|
1165
1201
|
const day = useBeijingDay();
|
|
1166
1202
|
const rows = costRows(totals, daily, day);
|
|
1167
|
-
const [open2, setOpen] = (0,
|
|
1168
|
-
const anchor2 = (0,
|
|
1169
|
-
const panel = (0,
|
|
1170
|
-
const dialogId = (0,
|
|
1171
|
-
(0,
|
|
1203
|
+
const [open2, setOpen] = (0, import_react3.useState)(false);
|
|
1204
|
+
const anchor2 = (0, import_react3.useRef)(null);
|
|
1205
|
+
const panel = (0, import_react3.useRef)(null);
|
|
1206
|
+
const dialogId = (0, import_react3.useId)();
|
|
1207
|
+
(0, import_react3.useLayoutEffect)(() => {
|
|
1172
1208
|
if (!open2) return;
|
|
1173
1209
|
const element = panel.current;
|
|
1174
1210
|
const document2 = element.ownerDocument;
|
|
@@ -1207,11 +1243,11 @@ function CostPanel({ totals, daily, balance }) {
|
|
|
1207
1243
|
document2.removeEventListener("keydown", dismissEscape);
|
|
1208
1244
|
};
|
|
1209
1245
|
}, [open2]);
|
|
1210
|
-
return (0,
|
|
1246
|
+
return (0, import_react3.createElement)(
|
|
1211
1247
|
"span",
|
|
1212
1248
|
{ className: "dsh-tom-cost-anchor", "data-composer-stat": "cost" },
|
|
1213
|
-
(0,
|
|
1214
|
-
(0,
|
|
1249
|
+
(0, import_react3.createElement)("style", { "data-dsh-tom-cost-styles": "" }, panelStyles),
|
|
1250
|
+
(0, import_react3.createElement)("button", {
|
|
1215
1251
|
ref: anchor2,
|
|
1216
1252
|
type: "button",
|
|
1217
1253
|
className: "dsh-tom-cost-pill",
|
|
@@ -1221,8 +1257,8 @@ function CostPanel({ totals, daily, balance }) {
|
|
|
1221
1257
|
"aria-controls": open2 ? dialogId : void 0,
|
|
1222
1258
|
"aria-label": `\u4F1A\u8BDD\u7D2F\u8BA1\u8D39\u7528 ${rows[1][1]}`,
|
|
1223
1259
|
onClick: () => setOpen(!open2)
|
|
1224
|
-
}, (0,
|
|
1225
|
-
open2 && (0, import_react_dom.createPortal)((0,
|
|
1260
|
+
}, (0, import_react3.createElement)(CostIcon), (0, import_react3.createElement)("span", { className: "dsh-tom-cost-label" }, rows[1][1])),
|
|
1261
|
+
open2 && (0, import_react_dom.createPortal)((0, import_react3.createElement)(
|
|
1226
1262
|
"div",
|
|
1227
1263
|
{
|
|
1228
1264
|
ref: panel,
|
|
@@ -1232,11 +1268,11 @@ function CostPanel({ totals, daily, balance }) {
|
|
|
1232
1268
|
className: "dsh-tom-cost-panel",
|
|
1233
1269
|
style: { visibility: "hidden", left: 0, top: 0 }
|
|
1234
1270
|
},
|
|
1235
|
-
(0,
|
|
1236
|
-
(0,
|
|
1237
|
-
(0,
|
|
1238
|
-
(0,
|
|
1239
|
-
(0,
|
|
1271
|
+
(0, import_react3.createElement)("div", { className: "dsh-tom-cost-title" }, (0, import_react3.createElement)(CostIcon), "\u8D39\u7528\u660E\u7EC6"),
|
|
1272
|
+
(0, import_react3.createElement)("div", { className: "dsh-tom-cost-rule", "aria-hidden": true }),
|
|
1273
|
+
(0, import_react3.createElement)("dl", { className: "dsh-tom-cost-details" }, rows.flatMap(([label, value]) => [
|
|
1274
|
+
(0, import_react3.createElement)("dt", { key: label }, label),
|
|
1275
|
+
(0, import_react3.createElement)("dd", { key: `${label}-value` }, value)
|
|
1240
1276
|
]))
|
|
1241
1277
|
), anchor2.current.ownerDocument.body)
|
|
1242
1278
|
);
|
|
@@ -21183,7 +21219,7 @@ function createBalanceStore(readBalance) {
|
|
|
21183
21219
|
}
|
|
21184
21220
|
|
|
21185
21221
|
// src/cost/settings.js
|
|
21186
|
-
var
|
|
21222
|
+
var import_react4 = require("react");
|
|
21187
21223
|
|
|
21188
21224
|
// src/cost/settings-styles.js
|
|
21189
21225
|
var settingsStyles = `
|
|
@@ -21239,62 +21275,62 @@ function usageSummary(row) {
|
|
|
21239
21275
|
function CostSettings({ useCostReport }) {
|
|
21240
21276
|
const report = useCostReport((value2) => value2);
|
|
21241
21277
|
const day = useBeijingDay();
|
|
21242
|
-
const [hideZero, setHideZero] = (0,
|
|
21278
|
+
const [hideZero, setHideZero] = (0, import_react4.useState)(true);
|
|
21243
21279
|
const value = report.status === "ready" && report.value.day === day ? report.value : void 0;
|
|
21244
21280
|
const status = report.status === "error" ? "\u8BFB\u53D6\u5931\u8D25" : "\u52A0\u8F7D\u4E2D\u2026";
|
|
21245
21281
|
const rows = value ? visibleHistory(value.history, hideZero) : [];
|
|
21246
21282
|
const summaries = [["today", "\u4ECA\u65E5\u8D39\u7528"], ["week", "\u672C\u5468\u8D39\u7528"], ["month", "\u672C\u6708\u8D39\u7528"]];
|
|
21247
|
-
return (0,
|
|
21283
|
+
return (0, import_react4.createElement)(
|
|
21248
21284
|
"section",
|
|
21249
21285
|
{ className: "dsh-tom-cost-settings", "aria-label": "\u8D39\u7528" },
|
|
21250
|
-
(0,
|
|
21251
|
-
(0,
|
|
21286
|
+
(0, import_react4.createElement)("style", null, settingsStyles),
|
|
21287
|
+
(0, import_react4.createElement)("div", { className: "dsh-tom-cost-cards" }, summaries.map(([key, label]) => {
|
|
21252
21288
|
const row = value?.[key];
|
|
21253
|
-
return (0,
|
|
21289
|
+
return (0, import_react4.createElement)(
|
|
21254
21290
|
"div",
|
|
21255
21291
|
{ key, className: "dsh-tom-cost-card" },
|
|
21256
|
-
(0,
|
|
21257
|
-
(0,
|
|
21258
|
-
(0,
|
|
21292
|
+
(0, import_react4.createElement)("div", { className: "dsh-tom-cost-card-label" }, label),
|
|
21293
|
+
(0, import_react4.createElement)("div", { className: "dsh-tom-cost-amount" }, row ? costValue(row.totals, row.failedSessions) : status),
|
|
21294
|
+
(0, import_react4.createElement)("div", { className: "dsh-tom-cost-usage" }, usageSummary(row))
|
|
21259
21295
|
);
|
|
21260
21296
|
})),
|
|
21261
|
-
(0,
|
|
21297
|
+
(0, import_react4.createElement)(
|
|
21262
21298
|
"div",
|
|
21263
21299
|
{ className: "dsh-tom-cost-history-heading" },
|
|
21264
|
-
(0,
|
|
21265
|
-
(0,
|
|
21300
|
+
(0, import_react4.createElement)("h3", null, "\u5386\u53F2\u8BB0\u5F55", (0, import_react4.createElement)("span", null, "\u6700\u8FD1 30 \u5929")),
|
|
21301
|
+
(0, import_react4.createElement)(
|
|
21266
21302
|
"label",
|
|
21267
21303
|
{ className: "dsh-tom-cost-filter" },
|
|
21268
|
-
(0,
|
|
21304
|
+
(0, import_react4.createElement)("input", { type: "checkbox", checked: hideZero, onChange: (event) => setHideZero(event.target.checked) }),
|
|
21269
21305
|
"\u8FC7\u6EE4\u96F6\u8D39\u7528\u65E5\u671F"
|
|
21270
21306
|
)
|
|
21271
21307
|
),
|
|
21272
|
-
(0,
|
|
21308
|
+
(0, import_react4.createElement)(
|
|
21273
21309
|
"div",
|
|
21274
21310
|
{ className: "dsh-tom-cost-table-wrap", tabIndex: 0, role: "region", "aria-label": "\u6BCF\u65E5\u8D39\u7528\u5386\u53F2\u8BB0\u5F55" },
|
|
21275
|
-
(0,
|
|
21311
|
+
(0, import_react4.createElement)(
|
|
21276
21312
|
"table",
|
|
21277
21313
|
{ className: "dsh-tom-cost-table" },
|
|
21278
|
-
(0,
|
|
21279
|
-
(0,
|
|
21314
|
+
(0, import_react4.createElement)("thead", null, (0, import_react4.createElement)("tr", null, ["\u65E5\u671F", "\u8C03\u7528", "\u8F93\u5165 tok", "\u7F13\u5B58 tok", "\u8F93\u51FA tok", "\u8D39\u7528"].map((label) => (0, import_react4.createElement)("th", { key: label, scope: "col" }, label)))),
|
|
21315
|
+
(0, import_react4.createElement)("tbody", null, value && rows.length ? rows.map((row) => {
|
|
21280
21316
|
const totals = row.totals;
|
|
21281
21317
|
const unavailable = row.failedSessions > 0 && calls(totals) === 0;
|
|
21282
|
-
return (0,
|
|
21318
|
+
return (0, import_react4.createElement)(
|
|
21283
21319
|
"tr",
|
|
21284
21320
|
{ key: row.day },
|
|
21285
|
-
(0,
|
|
21286
|
-
(0,
|
|
21287
|
-
...["inputTokens", "cacheTokens", "outputTokens"].map((key) => (0,
|
|
21321
|
+
(0, import_react4.createElement)("td", null, row.day),
|
|
21322
|
+
(0, import_react4.createElement)("td", null, unavailable ? "\u2014" : calls(totals).toLocaleString("zh-CN")),
|
|
21323
|
+
...["inputTokens", "cacheTokens", "outputTokens"].map((key) => (0, import_react4.createElement)("td", {
|
|
21288
21324
|
key,
|
|
21289
21325
|
title: unavailable ? void 0 : totals[key].toLocaleString("zh-CN")
|
|
21290
21326
|
}, unavailable ? "\u2014" : formatTokens(totals[key]))),
|
|
21291
|
-
(0,
|
|
21327
|
+
(0, import_react4.createElement)("td", null, costValue(totals, row.failedSessions))
|
|
21292
21328
|
);
|
|
21293
|
-
}) : (0,
|
|
21329
|
+
}) : (0, import_react4.createElement)("tr", null, (0, import_react4.createElement)("td", { colSpan: 6, className: "dsh-tom-cost-empty", role: "status" }, value ? "\u6700\u8FD1 30 \u5929\u6682\u65E0\u975E\u96F6\u8D39\u7528\u8BB0\u5F55" : status)))
|
|
21294
21330
|
)
|
|
21295
21331
|
),
|
|
21296
|
-
(0,
|
|
21297
|
-
value && value.history.some(incomplete) && (0,
|
|
21332
|
+
(0, import_react4.createElement)("p", { className: "dsh-tom-cost-note" }, "\u5317\u4EAC\u65F6\u95F4 \xB7 \u672C\u5468\u4ECE\u5468\u4E00\u5F00\u59CB \xB7 \u8D39\u7528\u6309\u672C\u673A\u4F1A\u8BDD\u8BB0\u5F55\u4F30\u7B97"),
|
|
21333
|
+
value && value.history.some(incomplete) && (0, import_react4.createElement)(
|
|
21298
21334
|
"p",
|
|
21299
21335
|
{ className: "dsh-tom-cost-note", role: "status" },
|
|
21300
21336
|
"\u90E8\u5206\u8BB0\u5F55\u65E0\u6CD5\u8BFB\u53D6\u6216\u8BA1\u4EF7\uFF0C\u76F8\u5173\u91D1\u989D\u53EF\u80FD\u4E0D\u5B8C\u6574\u3002"
|
|
@@ -21308,7 +21344,7 @@ function CostMount({ useProjection, useDailyCost, useAccountBalance, sessionId }
|
|
|
21308
21344
|
const totals = useProjection(PROJECTION_KEY);
|
|
21309
21345
|
const daily = useDailyCost((value) => value);
|
|
21310
21346
|
const balance = useAccountBalance((value) => value);
|
|
21311
|
-
return (0,
|
|
21347
|
+
return (0, import_react5.createElement)(CostPanel, { key: sessionId, totals, daily, balance });
|
|
21312
21348
|
}
|
|
21313
21349
|
async function apply(ctx) {
|
|
21314
21350
|
await ctx.remote.$mount(dailyRemote);
|
|
@@ -21344,10 +21380,10 @@ function ProjectHover({ sessionId, useWorkspaces, useSessions }) {
|
|
|
21344
21380
|
const cwd = useSessions((state) => state.byId[sessionId]?.cwd);
|
|
21345
21381
|
const path = workspace?.path || cwd;
|
|
21346
21382
|
const name = workspace?.title || path?.split(/[\\/]/).filter(Boolean).at(-1) || path || "\u672A\u5F52\u5C5E\u9879\u76EE";
|
|
21347
|
-
return (0,
|
|
21383
|
+
return (0, import_react6.createElement)(
|
|
21348
21384
|
"div",
|
|
21349
21385
|
{ className: "dsh-css-project", title: path },
|
|
21350
|
-
(0,
|
|
21386
|
+
(0, import_react6.createElement)("svg", {
|
|
21351
21387
|
width: 14,
|
|
21352
21388
|
height: 14,
|
|
21353
21389
|
viewBox: "0 0 24 24",
|
|
@@ -21356,8 +21392,8 @@ function ProjectHover({ sessionId, useWorkspaces, useSessions }) {
|
|
|
21356
21392
|
strokeWidth: 1.7,
|
|
21357
21393
|
strokeLinejoin: "round",
|
|
21358
21394
|
"aria-hidden": true
|
|
21359
|
-
}, (0,
|
|
21360
|
-
(0,
|
|
21395
|
+
}, (0, import_react6.createElement)("path", { d: "M3 7V5a2 2 0 0 1 2-2h5l2 3h7a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Zm0 2h18" })),
|
|
21396
|
+
(0, import_react6.createElement)("span", null, name)
|
|
21361
21397
|
);
|
|
21362
21398
|
}
|
|
21363
21399
|
function applySidebarWidth(layout) {
|
|
@@ -21409,6 +21445,7 @@ async function apply2(ctx) {
|
|
|
21409
21445
|
return () => style.remove();
|
|
21410
21446
|
});
|
|
21411
21447
|
ctx.effect(() => applySidebarWidth(ctx.layout));
|
|
21448
|
+
registerCacheHitPrecision(ctx);
|
|
21412
21449
|
registerProjects(ctx);
|
|
21413
21450
|
ctx.slots.inject("sidebar.session.row.hover", () => ctx.slots.register({
|
|
21414
21451
|
name: "sidebar.session.row.hover",
|