@bacnh85/pi-sub 0.1.1 → 0.1.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.
- package/README.md +1 -1
- package/index.ts +7 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ The footer status includes:
|
|
|
37
37
|
Example subscription line:
|
|
38
38
|
|
|
39
39
|
```text
|
|
40
|
-
Sub Plus user@example.com 5H 85
|
|
40
|
+
Sub · Plus · user@example.com · 5H 85% (18:12) · W 80% (08:00 on 2 Jul) · gpt-5-codex
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
When the current model provider is not supported, `pi-sub` clears its subscription line and does not refresh subscription data.
|
package/index.ts
CHANGED
|
@@ -146,7 +146,9 @@ function formatReset(timestampSeconds: number | undefined): string | undefined {
|
|
|
146
146
|
const now = new Date();
|
|
147
147
|
const time = date.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit", hour12: false });
|
|
148
148
|
if (date.toDateString() === now.toDateString()) return time;
|
|
149
|
-
|
|
149
|
+
const day = date.toLocaleDateString(undefined, { day: "numeric" });
|
|
150
|
+
const month = date.toLocaleDateString(undefined, { month: "short" });
|
|
151
|
+
return `${time} on ${day} ${month}`;
|
|
150
152
|
}
|
|
151
153
|
|
|
152
154
|
function usageWindowFromApi(window: UsageApiWindow | undefined): UsageWindow | undefined {
|
|
@@ -260,19 +262,15 @@ function supportedAdapter(model: ModelLike): SubscriptionProviderAdapter | undef
|
|
|
260
262
|
return adapters.find((adapter) => adapter.isModelSupported(model));
|
|
261
263
|
}
|
|
262
264
|
|
|
263
|
-
function formatWindow(window: UsageWindow | undefined,
|
|
265
|
+
function formatWindow(window: UsageWindow | undefined, _compact = true): string {
|
|
264
266
|
if (!window) return "?";
|
|
265
|
-
if (window.percent !== undefined && window.resetLabel) return
|
|
267
|
+
if (window.percent !== undefined && window.resetLabel) return `${window.percent}% (${window.resetLabel})`;
|
|
266
268
|
if (window.label) return window.label;
|
|
267
269
|
if (window.percent !== undefined) return `${window.percent}%`;
|
|
268
270
|
if (window.used !== undefined && window.limit !== undefined) return `${window.used}/${window.limit}`;
|
|
269
271
|
return "?";
|
|
270
272
|
}
|
|
271
273
|
|
|
272
|
-
function compactResetLabel(label: string): string {
|
|
273
|
-
return label.replace(/^0?(\d+:\d+) on (\d+ \w+)$/i, "$2 $1");
|
|
274
|
-
}
|
|
275
|
-
|
|
276
274
|
function maxPercent(account: SubscriptionAccountSnapshot | undefined): number {
|
|
277
275
|
return Math.max(account?.fiveHour?.percent ?? 0, account?.weekly?.percent ?? 0);
|
|
278
276
|
}
|
|
@@ -299,8 +297,8 @@ function renderSubscriptionLine(ctx: ExtensionContext, state: State): void {
|
|
|
299
297
|
pieces.push(account?.accountLabel ?? "unknown account");
|
|
300
298
|
pieces.push(`5H ${formatWindow(account?.fiveHour)}`);
|
|
301
299
|
pieces.push(`W ${formatWindow(account?.weekly)}`);
|
|
302
|
-
pieces.push(
|
|
303
|
-
line = pieces.join(" ");
|
|
300
|
+
pieces.push(modelId);
|
|
301
|
+
line = pieces.join(" · ");
|
|
304
302
|
color = maxPercent(account) >= 90 ? "error" : maxPercent(account) >= 80 ? "warning" : "dim";
|
|
305
303
|
}
|
|
306
304
|
ctx.ui.setWidget(STATUS_KEY, [theme.fg(color, line)], { placement: "belowEditor" });
|