@giladbarnea/pi-simple-team 2.0.17 → 2.0.18
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/package.json +1 -1
- package/render.ts +8 -6
- package/teamlog.ts +11 -0
package/package.json
CHANGED
package/render.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { padVisible, stableRenderWidth, visibleLength } from "./render-support/a
|
|
|
4
4
|
import { glyphs } from "./render-support/glyphs.ts";
|
|
5
5
|
import { stackPrefix, toolLabel, treeConnector, treeStem } from "./render-support/theme.ts";
|
|
6
6
|
import { commandExit, plural, renderPendingCall, textContent } from "./render-support/text.ts";
|
|
7
|
-
import { futureTime, monthDay, relativeTime, timeOfDay, type TeamLogEntry } from "./teamlog.ts";
|
|
7
|
+
import { futureTime, logRowTime, monthDay, relativeTime, timeOfDay, type TeamLogEntry } from "./teamlog.ts";
|
|
8
8
|
import { actorHueToken, DIM_SGR_CLOSE, DIM_SGR_OPEN, FactTable, inlineFact, statusWordToken, type FactRow, type TeammateView } from "./teammate-facts.ts";
|
|
9
9
|
|
|
10
10
|
export { actorHueToken, statusWordToken, type TeammateView };
|
|
@@ -604,8 +604,8 @@ function renderLogDetail(theme: ThemeLike, detail: LogDetail, roster: string[]):
|
|
|
604
604
|
|
|
605
605
|
const LOG_ROW_INDENT = " ";
|
|
606
606
|
|
|
607
|
-
function logChrome(theme: ThemeLike, sequence: number, seqWidth: number,
|
|
608
|
-
return theme.fg("borderMuted", `${LOG_ROW_INDENT}${padVisible(`#${sequence}`, seqWidth)} ${
|
|
607
|
+
function logChrome(theme: ThemeLike, sequence: number, seqWidth: number, time: string, timeWidth: number): string {
|
|
608
|
+
return theme.fg("borderMuted", `${LOG_ROW_INDENT}${padVisible(`#${sequence}`, seqWidth)} ${padVisible(time, timeWidth)}`);
|
|
609
609
|
}
|
|
610
610
|
|
|
611
611
|
function sameLocalDay(a: number, b: number): boolean {
|
|
@@ -617,17 +617,19 @@ function dayDividerLine(theme: ThemeLike, epochMilliseconds: number): string {
|
|
|
617
617
|
return `${LOG_ROW_INDENT}${theme.fg("borderMuted", `${rule.repeat(2)} ${monthDay(epochMilliseconds)} ${rule.repeat(30)}`)}`;
|
|
618
618
|
}
|
|
619
619
|
|
|
620
|
-
/** Log rows
|
|
620
|
+
/** Log rows show short relative time under an hour and absolute HH:MM:SS after; day dividers carry the date whenever a row is not from "today". */
|
|
621
621
|
function actionRows(theme: ThemeLike, actions: LogAction[], roster: string[], nowMilliseconds: number): string[] {
|
|
622
622
|
const g = glyphs();
|
|
623
623
|
const seqWidth = Math.max(...actions.map((action) => `#${action.sequence}`.length));
|
|
624
|
+
const times = actions.map((action) => logRowTime(action.epochMilliseconds, nowMilliseconds));
|
|
625
|
+
const timeWidth = Math.max(...times.map((time) => time.length));
|
|
624
626
|
const whoWidth = Math.max(...actions.map((action) => action.who.length));
|
|
625
627
|
const actionWidth = Math.max(...actions.map((action) => action.action.length));
|
|
626
628
|
const iconWidth = Math.max(...actions.map((action) => visibleLength(logIconGlyph(action.icon))));
|
|
627
629
|
const rows: string[] = [];
|
|
628
630
|
let previousWho: string | undefined;
|
|
629
631
|
let previousEpoch = nowMilliseconds;
|
|
630
|
-
for (const action of actions) {
|
|
632
|
+
for (const [index, action] of actions.entries()) {
|
|
631
633
|
if (!sameLocalDay(action.epochMilliseconds, previousEpoch)) {
|
|
632
634
|
rows.push(dayDividerLine(theme, action.epochMilliseconds));
|
|
633
635
|
previousWho = undefined;
|
|
@@ -643,7 +645,7 @@ function actionRows(theme: ThemeLike, actions: LogAction[], roster: string[], no
|
|
|
643
645
|
.filter((detail) => detail.style !== "text" || detail.text.length > 0)
|
|
644
646
|
.map((detail) => renderLogDetail(theme, detail, roster))
|
|
645
647
|
.join(dot);
|
|
646
|
-
rows.push(`${logChrome(theme, action.sequence, seqWidth,
|
|
648
|
+
rows.push(`${logChrome(theme, action.sequence, seqWidth, times[index]!, timeWidth)} ${whoStyled} ${icon} ${actionName}${detailText ? `${dot}${detailText}` : ""}`);
|
|
647
649
|
}
|
|
648
650
|
return rows;
|
|
649
651
|
}
|
package/teamlog.ts
CHANGED
|
@@ -106,6 +106,17 @@ export function relativeTime(epochMilliseconds: number, nowMilliseconds: number)
|
|
|
106
106
|
return `${formatElapsed(elapsed)} ago`;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
/**
|
|
110
|
+
* Log row time: short elapsed time under an hour, absolute time of day from then on.
|
|
111
|
+
* logRowTime(now - 44 * 60_000, now) === "44m"; logRowTime(now - 20_000, now) === "now"; logRowTime(now - 3_600_000, now) === timeOfDay(now - 3_600_000)
|
|
112
|
+
*/
|
|
113
|
+
export function logRowTime(epochMilliseconds: number, nowMilliseconds: number): string {
|
|
114
|
+
const elapsed = Math.max(0, nowMilliseconds - epochMilliseconds);
|
|
115
|
+
if (elapsed >= HOUR_MILLISECONDS) return timeOfDay(epochMilliseconds);
|
|
116
|
+
if (elapsed < MINUTE_MILLISECONDS) return "now";
|
|
117
|
+
return formatElapsed(elapsed);
|
|
118
|
+
}
|
|
119
|
+
|
|
109
120
|
/**
|
|
110
121
|
* futureTime(now + 20 * 86_400_000, now) === "in 2w"
|
|
111
122
|
*/
|