ccstatusline 2.2.6 → 2.2.7
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/dist/ccstatusline.js +39 -5
- package/package.json +1 -1
package/dist/ccstatusline.js
CHANGED
|
@@ -56174,7 +56174,7 @@ function getTerminalWidth() {
|
|
|
56174
56174
|
function canDetectTerminalWidth() {
|
|
56175
56175
|
return probeTerminalWidth() !== null;
|
|
56176
56176
|
}
|
|
56177
|
-
var __dirname = "/Users/sirmalloc/Projects/Personal/ccstatusline/src/utils", PACKAGE_VERSION = "2.2.
|
|
56177
|
+
var __dirname = "/Users/sirmalloc/Projects/Personal/ccstatusline/src/utils", PACKAGE_VERSION = "2.2.7";
|
|
56178
56178
|
var init_terminal = () => {};
|
|
56179
56179
|
|
|
56180
56180
|
// src/utils/renderer.ts
|
|
@@ -70568,6 +70568,10 @@ var CoercedNumberSchema = exports_external.preprocess((value) => {
|
|
|
70568
70568
|
const parsed = Number(trimmed);
|
|
70569
70569
|
return Number.isFinite(parsed) ? parsed : value;
|
|
70570
70570
|
}, exports_external.number());
|
|
70571
|
+
var RateLimitPeriodSchema = exports_external.object({
|
|
70572
|
+
used_percentage: CoercedNumberSchema.nullable().optional(),
|
|
70573
|
+
resets_at: CoercedNumberSchema.nullable().optional()
|
|
70574
|
+
});
|
|
70571
70575
|
var StatusJSONSchema = exports_external.looseObject({
|
|
70572
70576
|
hook_event_name: exports_external.string().optional(),
|
|
70573
70577
|
session_id: exports_external.string().optional(),
|
|
@@ -70609,7 +70613,11 @@ var StatusJSONSchema = exports_external.looseObject({
|
|
|
70609
70613
|
used_percentage: CoercedNumberSchema.nullable().optional(),
|
|
70610
70614
|
remaining_percentage: CoercedNumberSchema.nullable().optional()
|
|
70611
70615
|
}).nullable().optional(),
|
|
70612
|
-
vim: exports_external.object({ mode: exports_external.string().optional() }).nullable().optional()
|
|
70616
|
+
vim: exports_external.object({ mode: exports_external.string().optional() }).nullable().optional(),
|
|
70617
|
+
rate_limits: exports_external.object({
|
|
70618
|
+
five_hour: RateLimitPeriodSchema.optional(),
|
|
70619
|
+
seven_day: RateLimitPeriodSchema.optional()
|
|
70620
|
+
}).nullable().optional()
|
|
70613
70621
|
});
|
|
70614
70622
|
|
|
70615
70623
|
// src/ccstatusline.ts
|
|
@@ -70677,11 +70685,37 @@ var USAGE_WIDGET_TYPES = new Set([
|
|
|
70677
70685
|
function hasUsageDependentWidgets(lines) {
|
|
70678
70686
|
return lines.some((line) => line.some((item) => USAGE_WIDGET_TYPES.has(item.type)));
|
|
70679
70687
|
}
|
|
70680
|
-
|
|
70688
|
+
function epochSecondsToIsoString(epochSeconds) {
|
|
70689
|
+
if (epochSeconds === null || epochSeconds === undefined || !Number.isFinite(epochSeconds)) {
|
|
70690
|
+
return;
|
|
70691
|
+
}
|
|
70692
|
+
return new Date(epochSeconds * 1000).toISOString();
|
|
70693
|
+
}
|
|
70694
|
+
function extractUsageDataFromRateLimits(rateLimits) {
|
|
70695
|
+
if (!rateLimits) {
|
|
70696
|
+
return null;
|
|
70697
|
+
}
|
|
70698
|
+
const sessionUsage = rateLimits.five_hour?.used_percentage ?? undefined;
|
|
70699
|
+
const sessionResetAt = epochSecondsToIsoString(rateLimits.five_hour?.resets_at);
|
|
70700
|
+
const weeklyUsage = rateLimits.seven_day?.used_percentage ?? undefined;
|
|
70701
|
+
const weeklyResetAt = epochSecondsToIsoString(rateLimits.seven_day?.resets_at);
|
|
70702
|
+
if (sessionUsage === undefined && weeklyUsage === undefined) {
|
|
70703
|
+
return null;
|
|
70704
|
+
}
|
|
70705
|
+
return { sessionUsage, sessionResetAt, weeklyUsage, weeklyResetAt };
|
|
70706
|
+
}
|
|
70707
|
+
function hasCompleteRateLimitsUsageData(usageData) {
|
|
70708
|
+
return usageData?.sessionUsage !== undefined && usageData.sessionResetAt !== undefined && usageData.weeklyUsage !== undefined && usageData.weeklyResetAt !== undefined;
|
|
70709
|
+
}
|
|
70710
|
+
async function prefetchUsageDataIfNeeded(lines, data) {
|
|
70681
70711
|
if (!hasUsageDependentWidgets(lines)) {
|
|
70682
70712
|
return null;
|
|
70683
70713
|
}
|
|
70684
|
-
|
|
70714
|
+
const rateLimitsData = extractUsageDataFromRateLimits(data?.rate_limits);
|
|
70715
|
+
if (hasCompleteRateLimitsUsageData(rateLimitsData)) {
|
|
70716
|
+
return rateLimitsData;
|
|
70717
|
+
}
|
|
70718
|
+
return fetchUsageData();
|
|
70685
70719
|
}
|
|
70686
70720
|
|
|
70687
70721
|
// src/ccstatusline.ts
|
|
@@ -70744,7 +70778,7 @@ async function renderMultipleLines(data) {
|
|
|
70744
70778
|
if (hasSessionClock && !hasSessionDurationInStatusJson(data) && data.transcript_path) {
|
|
70745
70779
|
sessionDuration = await getSessionDuration(data.transcript_path);
|
|
70746
70780
|
}
|
|
70747
|
-
const usageData = await prefetchUsageDataIfNeeded(lines);
|
|
70781
|
+
const usageData = await prefetchUsageDataIfNeeded(lines, data);
|
|
70748
70782
|
let speedMetrics = null;
|
|
70749
70783
|
let windowedSpeedMetrics = null;
|
|
70750
70784
|
if (hasSpeedItems && data.transcript_path) {
|