dsh-usage-badge 0.1.0 → 0.1.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/lib/official-pricing.js +16 -4
- package/package.json +2 -2
package/lib/official-pricing.js
CHANGED
|
@@ -91,16 +91,28 @@ function parseAmount(text) {
|
|
|
91
91
|
function toLocalRanges(ranges, sourceOffsetMinutes, localOffsetMinutes) {
|
|
92
92
|
const delta = localOffsetMinutes - sourceOffsetMinutes
|
|
93
93
|
const round = (value) => Math.round(value * 100) / 100
|
|
94
|
+
const wrap = (minutes) => ((minutes % 1440) + 1440) % 1440
|
|
94
95
|
const out = []
|
|
95
96
|
for (const [start, end] of ranges) {
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
let startMinutes = start * 60 + delta
|
|
98
|
+
let endMinutes = end * 60 + delta
|
|
99
|
+
|
|
100
|
+
// A window pushed entirely out of the day wraps as a whole. Only a window that
|
|
101
|
+
// straddles midnight splits in two — splitting an out-of-range one instead
|
|
102
|
+
// produced nonsense ranges (01:00–04:00 UTC in a UTC-5 host came out as
|
|
103
|
+
// [0,23], i.e. almost the entire day at peak rates).
|
|
104
|
+
if (endMinutes <= 0) {
|
|
105
|
+
startMinutes += 1440
|
|
106
|
+
endMinutes += 1440
|
|
107
|
+
} else if (startMinutes >= 1440) {
|
|
108
|
+
startMinutes -= 1440
|
|
109
|
+
endMinutes -= 1440
|
|
110
|
+
}
|
|
111
|
+
|
|
98
112
|
if (startMinutes >= 0 && endMinutes <= 1440) {
|
|
99
113
|
out.push([round(startMinutes / 60), round(endMinutes / 60)])
|
|
100
114
|
continue
|
|
101
115
|
}
|
|
102
|
-
// The shifted window crosses midnight, so it becomes two ranges.
|
|
103
|
-
const wrap = (minutes) => ((minutes % 1440) + 1440) % 1440
|
|
104
116
|
out.push([round(wrap(startMinutes) / 60), 24])
|
|
105
117
|
out.push([0, round(wrap(endMinutes) / 60)])
|
|
106
118
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-usage-badge",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "DeepSeek Harness 的用量徽标插件:侧边栏底部一行显示当天的 token 总量与估算费用,点开可看 24 小时 / 近 7 日 / 近 30 日 / 近 12 个月用量,按 provider 筛选,并按 DeepSeek 官方定价与中国法定节假日计价。A usage badge plugin for DeepSeek Harness: today's tokens and estimated spend in the sidebar, with 24h / 7d / 30d / 12-month charts, official DeepSeek pricing and Chinese public holidays.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"docs"
|
|
40
40
|
],
|
|
41
41
|
"scripts": {
|
|
42
|
-
"test": "node test/
|
|
42
|
+
"test": "node test/all.mjs",
|
|
43
43
|
"test:smoke": "node test/smoke.mjs",
|
|
44
44
|
"prepublishOnly": "npm test"
|
|
45
45
|
},
|