@brozarti/spincome 0.1.4 → 0.1.5
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/animate.js +5 -5
- package/dist/display.js +3 -2
- package/package.json +1 -1
- package/src/animate.ts +5 -5
- package/src/display.ts +3 -2
package/dist/animate.js
CHANGED
|
@@ -14,7 +14,7 @@ const SPINNER = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇",
|
|
|
14
14
|
const COIN = ["◐", "◓", "◑", "◒"];
|
|
15
15
|
const LOGO = `${BOLD}${GREEN}$${R}${BOLD} spincome${R}`;
|
|
16
16
|
async function animateWhileLoading(work) {
|
|
17
|
-
process.
|
|
17
|
+
process.stderr.write(HIDE_CURSOR);
|
|
18
18
|
let frame = 0;
|
|
19
19
|
let dots = 0;
|
|
20
20
|
let done = false;
|
|
@@ -26,7 +26,7 @@ async function animateWhileLoading(work) {
|
|
|
26
26
|
const coin = GREEN + COIN[frame % COIN.length] + R;
|
|
27
27
|
dots = (dots + 1) % 4;
|
|
28
28
|
const dotStr = DIM + ".".repeat(dots).padEnd(3) + R;
|
|
29
|
-
process.
|
|
29
|
+
process.stderr.write(CLEAR_LINE +
|
|
30
30
|
` ${spinner} ${LOGO} ${coin} ${DIM}earning${R}${dotStr}`);
|
|
31
31
|
frame++;
|
|
32
32
|
}, 80);
|
|
@@ -36,9 +36,9 @@ async function animateWhileLoading(work) {
|
|
|
36
36
|
finally {
|
|
37
37
|
done = true;
|
|
38
38
|
clearInterval(tick);
|
|
39
|
-
process.
|
|
40
|
-
process.
|
|
41
|
-
process.
|
|
39
|
+
process.stderr.write(CLEAR_LINE);
|
|
40
|
+
process.stderr.write(UP_ONE + CLEAR_LINE);
|
|
41
|
+
process.stderr.write(SHOW_CURSOR);
|
|
42
42
|
}
|
|
43
43
|
return result;
|
|
44
44
|
}
|
package/dist/display.js
CHANGED
|
@@ -22,8 +22,9 @@ function ruler() {
|
|
|
22
22
|
return `${DIM}${"─".repeat(W)}${R}`;
|
|
23
23
|
}
|
|
24
24
|
function renderAd(ad, earnedCents, sessionCents, context) {
|
|
25
|
-
|
|
26
|
-
const
|
|
25
|
+
// earnedCents and sessionCents are stored in milli-cents (1 unit = $0.00001)
|
|
26
|
+
const earnedDollars = (earnedCents / 100000).toFixed(4);
|
|
27
|
+
const sessionDollars = (sessionCents / 100000).toFixed(4);
|
|
27
28
|
const contextTag = context?.fileExt
|
|
28
29
|
? ` · ${context.fileExt.toUpperCase()} dev`
|
|
29
30
|
: context?.toolName
|
package/package.json
CHANGED
package/src/animate.ts
CHANGED
|
@@ -15,7 +15,7 @@ const COIN = ["◐","◓","◑","◒"];
|
|
|
15
15
|
const LOGO = `${BOLD}${GREEN}$${R}${BOLD} spincome${R}`;
|
|
16
16
|
|
|
17
17
|
export async function animateWhileLoading<T>(work: Promise<T>): Promise<T> {
|
|
18
|
-
process.
|
|
18
|
+
process.stderr.write(HIDE_CURSOR);
|
|
19
19
|
|
|
20
20
|
let frame = 0;
|
|
21
21
|
let dots = 0;
|
|
@@ -28,7 +28,7 @@ export async function animateWhileLoading<T>(work: Promise<T>): Promise<T> {
|
|
|
28
28
|
const coin = GREEN + COIN[frame % COIN.length] + R;
|
|
29
29
|
dots = (dots + 1) % 4;
|
|
30
30
|
const dotStr = DIM + ".".repeat(dots).padEnd(3) + R;
|
|
31
|
-
process.
|
|
31
|
+
process.stderr.write(
|
|
32
32
|
CLEAR_LINE +
|
|
33
33
|
` ${spinner} ${LOGO} ${coin} ${DIM}earning${R}${dotStr}`
|
|
34
34
|
);
|
|
@@ -40,9 +40,9 @@ export async function animateWhileLoading<T>(work: Promise<T>): Promise<T> {
|
|
|
40
40
|
} finally {
|
|
41
41
|
done = true;
|
|
42
42
|
clearInterval(tick);
|
|
43
|
-
process.
|
|
44
|
-
process.
|
|
45
|
-
process.
|
|
43
|
+
process.stderr.write(CLEAR_LINE);
|
|
44
|
+
process.stderr.write(UP_ONE + CLEAR_LINE);
|
|
45
|
+
process.stderr.write(SHOW_CURSOR);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
return result!;
|
package/src/display.ts
CHANGED
|
@@ -26,8 +26,9 @@ function ruler(): string {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export function renderAd(ad: Ad, earnedCents: number, sessionCents: number, context?: { toolName?: string; fileExt?: string }): string {
|
|
29
|
-
|
|
30
|
-
const
|
|
29
|
+
// earnedCents and sessionCents are stored in milli-cents (1 unit = $0.00001)
|
|
30
|
+
const earnedDollars = (earnedCents / 100000).toFixed(4);
|
|
31
|
+
const sessionDollars = (sessionCents / 100000).toFixed(4);
|
|
31
32
|
|
|
32
33
|
const contextTag = context?.fileExt
|
|
33
34
|
? ` · ${context.fileExt.toUpperCase()} dev`
|