@outfitter/cli 0.3.0 → 0.4.0
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 +23 -4
- package/dist/actions.js +0 -2
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +1 -2
- package/dist/{render → colors}/colors.d.ts +1 -1
- package/dist/{render → colors}/colors.js +2 -6
- package/dist/colors/index.d.ts +1 -1
- package/dist/colors/index.js +3 -4
- package/dist/command.d.ts +1 -1
- package/dist/command.js +1 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -4
- package/dist/input.d.ts +3 -26
- package/dist/input.js +1 -31
- package/dist/output.d.ts +2 -2
- package/dist/output.js +0 -1
- package/dist/pagination.d.ts +1 -1
- package/dist/pagination.js +0 -2
- package/dist/shared/@outfitter/{cli-ttt7r0j7.d.ts → cli-02kyvj7h.d.ts} +2 -13
- package/dist/shared/@outfitter/{cli-e6yv2764.d.ts → cli-f79bwzsp.d.ts} +1 -1
- package/dist/shared/@outfitter/{cli-d9ad0rqj.js → cli-jbj78ac5.js} +1 -6
- package/dist/shared/@outfitter/{cli-5g6rkv3d.js → cli-rk9zagkm.js} +24 -32
- package/dist/shared/@outfitter/{cli-4h4rpdra.js → cli-zahqsaby.js} +32 -10
- package/dist/terminal/detection.js +1 -5
- package/dist/terminal/index.js +1 -6
- package/dist/{shared/@outfitter/cli-4cb5g831.d.ts → text.d.ts} +1 -1
- package/dist/{shared/@outfitter/cli-mwxsh3sr.js → text.js} +15 -14
- package/dist/types.d.ts +2 -2
- package/dist/types.js +0 -2
- package/package.json +35 -213
- package/dist/borders/index.d.ts +0 -3
- package/dist/borders/index.js +0 -13
- package/dist/box/index.d.ts +0 -4
- package/dist/box/index.js +0 -13
- package/dist/demo/index.d.ts +0 -78
- package/dist/demo/index.js +0 -148
- package/dist/demo/registry.d.ts +0 -7
- package/dist/demo/registry.js +0 -28
- package/dist/demo/renderers/borders.d.ts +0 -7
- package/dist/demo/renderers/borders.js +0 -17
- package/dist/demo/renderers/box.d.ts +0 -7
- package/dist/demo/renderers/box.js +0 -18
- package/dist/demo/renderers/colors.d.ts +0 -7
- package/dist/demo/renderers/colors.js +0 -18
- package/dist/demo/renderers/indicators.d.ts +0 -7
- package/dist/demo/renderers/indicators.js +0 -17
- package/dist/demo/renderers/list.d.ts +0 -7
- package/dist/demo/renderers/list.js +0 -19
- package/dist/demo/renderers/markdown.d.ts +0 -7
- package/dist/demo/renderers/markdown.js +0 -18
- package/dist/demo/renderers/progress.d.ts +0 -7
- package/dist/demo/renderers/progress.js +0 -17
- package/dist/demo/renderers/spinner.d.ts +0 -7
- package/dist/demo/renderers/spinner.js +0 -19
- package/dist/demo/renderers/table.d.ts +0 -7
- package/dist/demo/renderers/table.js +0 -19
- package/dist/demo/renderers/text.d.ts +0 -7
- package/dist/demo/renderers/text.js +0 -16
- package/dist/demo/renderers/tree.d.ts +0 -7
- package/dist/demo/renderers/tree.js +0 -18
- package/dist/demo/section.d.ts +0 -5
- package/dist/demo/section.js +0 -23
- package/dist/demo/templates.d.ts +0 -4
- package/dist/demo/templates.js +0 -10
- package/dist/demo/types.d.ts +0 -3
- package/dist/demo/types.js +0 -8
- package/dist/list/index.d.ts +0 -3
- package/dist/list/index.js +0 -9
- package/dist/preset/full.d.ts +0 -14
- package/dist/preset/full.js +0 -41
- package/dist/preset/standard.d.ts +0 -11
- package/dist/preset/standard.js +0 -30
- package/dist/prompt/confirm.d.ts +0 -4
- package/dist/prompt/confirm.js +0 -9
- package/dist/prompt/group.d.ts +0 -4
- package/dist/prompt/group.js +0 -9
- package/dist/prompt/index.d.ts +0 -7
- package/dist/prompt/index.js +0 -32
- package/dist/prompt/select.d.ts +0 -4
- package/dist/prompt/select.js +0 -11
- package/dist/prompt/text.d.ts +0 -4
- package/dist/prompt/text.js +0 -11
- package/dist/prompt/types.d.ts +0 -3
- package/dist/prompt/types.js +0 -8
- package/dist/prompt/validators.d.ts +0 -2
- package/dist/prompt/validators.js +0 -8
- package/dist/render/borders.d.ts +0 -2
- package/dist/render/borders.js +0 -15
- package/dist/render/box.d.ts +0 -3
- package/dist/render/box.js +0 -23
- package/dist/render/date.d.ts +0 -2
- package/dist/render/date.js +0 -12
- package/dist/render/format-relative.d.ts +0 -2
- package/dist/render/format-relative.js +0 -8
- package/dist/render/format.d.ts +0 -2
- package/dist/render/format.js +0 -10
- package/dist/render/heading.d.ts +0 -3
- package/dist/render/heading.js +0 -14
- package/dist/render/index.d.ts +0 -32
- package/dist/render/index.js +0 -235
- package/dist/render/indicators.d.ts +0 -2
- package/dist/render/indicators.js +0 -16
- package/dist/render/json.d.ts +0 -2
- package/dist/render/json.js +0 -10
- package/dist/render/layout.d.ts +0 -5
- package/dist/render/layout.js +0 -25
- package/dist/render/list.d.ts +0 -2
- package/dist/render/list.js +0 -8
- package/dist/render/markdown.d.ts +0 -2
- package/dist/render/markdown.js +0 -10
- package/dist/render/progress.d.ts +0 -2
- package/dist/render/progress.js +0 -8
- package/dist/render/separator.d.ts +0 -3
- package/dist/render/separator.js +0 -14
- package/dist/render/shapes.d.ts +0 -2
- package/dist/render/shapes.js +0 -35
- package/dist/render/spinner.d.ts +0 -2
- package/dist/render/spinner.js +0 -12
- package/dist/render/stack.d.ts +0 -3
- package/dist/render/stack.js +0 -38
- package/dist/render/table.d.ts +0 -3
- package/dist/render/table.js +0 -12
- package/dist/render/text.d.ts +0 -2
- package/dist/render/text.js +0 -27
- package/dist/render/tree.d.ts +0 -2
- package/dist/render/tree.js +0 -10
- package/dist/render/types.d.ts +0 -2
- package/dist/shared/@outfitter/cli-0djg8q91.js +0 -7
- package/dist/shared/@outfitter/cli-0w242qtv.d.ts +0 -48
- package/dist/shared/@outfitter/cli-1g8tt31a.d.ts +0 -119
- package/dist/shared/@outfitter/cli-1kwbnt86.d.ts +0 -45
- package/dist/shared/@outfitter/cli-1sb3xvnw.js +0 -95
- package/dist/shared/@outfitter/cli-1vy0vtga.js +0 -135
- package/dist/shared/@outfitter/cli-2g8bx1aq.d.ts +0 -50
- package/dist/shared/@outfitter/cli-33e97cjs.d.ts +0 -42
- package/dist/shared/@outfitter/cli-3b7ed3rm.d.ts +0 -97
- package/dist/shared/@outfitter/cli-3hk2xf3c.js +0 -82
- package/dist/shared/@outfitter/cli-3hp8qwx3.js +0 -11
- package/dist/shared/@outfitter/cli-47yw5h6a.js +0 -7
- package/dist/shared/@outfitter/cli-4b6tbp68.d.ts +0 -36
- package/dist/shared/@outfitter/cli-4fcz51qa.js +0 -70
- package/dist/shared/@outfitter/cli-4x6pqnez.js +0 -20
- package/dist/shared/@outfitter/cli-4zk2y4a2.d.ts +0 -61
- package/dist/shared/@outfitter/cli-60b5xh1r.js +0 -20
- package/dist/shared/@outfitter/cli-6bztk73z.d.ts +0 -51
- package/dist/shared/@outfitter/cli-6fxffp8k.js +0 -1
- package/dist/shared/@outfitter/cli-6hg0sg2d.d.ts +0 -93
- package/dist/shared/@outfitter/cli-6r3m2knf.js +0 -62
- package/dist/shared/@outfitter/cli-6ty1nvws.js +0 -179
- package/dist/shared/@outfitter/cli-7n610r63.js +0 -20
- package/dist/shared/@outfitter/cli-7na6p4fs.d.ts +0 -59
- package/dist/shared/@outfitter/cli-83jwvj1t.d.ts +0 -17
- package/dist/shared/@outfitter/cli-85fg2vr5.js +0 -123
- package/dist/shared/@outfitter/cli-8bwaw3pz.js +0 -7
- package/dist/shared/@outfitter/cli-8hngbjyr.d.ts +0 -164
- package/dist/shared/@outfitter/cli-8j5k6mr3.js +0 -71
- package/dist/shared/@outfitter/cli-8xsmsbbd.d.ts +0 -223
- package/dist/shared/@outfitter/cli-914d47mt.js +0 -20
- package/dist/shared/@outfitter/cli-9bcm4zhf.d.ts +0 -87
- package/dist/shared/@outfitter/cli-9khk3cbq.d.ts +0 -190
- package/dist/shared/@outfitter/cli-a4q87517.d.ts +0 -64
- package/dist/shared/@outfitter/cli-aem6v4c8.js +0 -146
- package/dist/shared/@outfitter/cli-b0tzqgnf.d.ts +0 -132
- package/dist/shared/@outfitter/cli-b5c2k0d7.js +0 -39
- package/dist/shared/@outfitter/cli-b5epywry.js +0 -1
- package/dist/shared/@outfitter/cli-bc17qeh2.js +0 -19
- package/dist/shared/@outfitter/cli-bcmcaz1b.js +0 -23
- package/dist/shared/@outfitter/cli-bv09nme3.d.ts +0 -56
- package/dist/shared/@outfitter/cli-c6pbxpw0.d.ts +0 -112
- package/dist/shared/@outfitter/cli-c8fqdaes.js +0 -117
- package/dist/shared/@outfitter/cli-c8q4f71g.js +0 -144
- package/dist/shared/@outfitter/cli-c9knfqn5.d.ts +0 -30
- package/dist/shared/@outfitter/cli-cf1xexgn.d.ts +0 -53
- package/dist/shared/@outfitter/cli-cf2s94s1.d.ts +0 -42
- package/dist/shared/@outfitter/cli-cwgj6mcs.js +0 -214
- package/dist/shared/@outfitter/cli-d8ahdd9d.js +0 -272
- package/dist/shared/@outfitter/cli-dbyteh27.d.ts +0 -24
- package/dist/shared/@outfitter/cli-e5ms1y0x.d.ts +0 -91
- package/dist/shared/@outfitter/cli-en6zn6sj.js +0 -1
- package/dist/shared/@outfitter/cli-evx7qcp1.d.ts +0 -300
- package/dist/shared/@outfitter/cli-f6fsaayd.js +0 -94
- package/dist/shared/@outfitter/cli-fakncnjp.d.ts +0 -106
- package/dist/shared/@outfitter/cli-ffa0jwb7.js +0 -122
- package/dist/shared/@outfitter/cli-h20jc0bs.d.ts +0 -66
- package/dist/shared/@outfitter/cli-h3jz0bxz.js +0 -48
- package/dist/shared/@outfitter/cli-h4wpzb3f.js +0 -67
- package/dist/shared/@outfitter/cli-hda6mc28.js +0 -126
- package/dist/shared/@outfitter/cli-hnpbqmc8.d.ts +0 -328
- package/dist/shared/@outfitter/cli-j19a91ck.js +0 -30
- package/dist/shared/@outfitter/cli-jejfypgf.js +0 -85
- package/dist/shared/@outfitter/cli-jp0k3qd9.js +0 -279
- package/dist/shared/@outfitter/cli-k76e7173.js +0 -128
- package/dist/shared/@outfitter/cli-kc3ffp1v.d.ts +0 -23
- package/dist/shared/@outfitter/cli-kk5hnndk.d.ts +0 -128
- package/dist/shared/@outfitter/cli-ktqme80d.js +0 -7
- package/dist/shared/@outfitter/cli-mq0jp15z.js +0 -1
- package/dist/shared/@outfitter/cli-n0c33vba.js +0 -25
- package/dist/shared/@outfitter/cli-n17gt1dz.js +0 -19
- package/dist/shared/@outfitter/cli-n9dbh0hp.js +0 -51
- package/dist/shared/@outfitter/cli-ndem6tz8.js +0 -63
- package/dist/shared/@outfitter/cli-nj4nqy1h.d.ts +0 -24
- package/dist/shared/@outfitter/cli-nkns8p4r.js +0 -61
- package/dist/shared/@outfitter/cli-p3dqm1vd.js +0 -22
- package/dist/shared/@outfitter/cli-pndwprz8.js +0 -118
- package/dist/shared/@outfitter/cli-pvrwv6rb.js +0 -352
- package/dist/shared/@outfitter/cli-py02m79x.d.ts +0 -20
- package/dist/shared/@outfitter/cli-qj83y5wj.d.ts +0 -71
- package/dist/shared/@outfitter/cli-regjbef6.d.ts +0 -26
- package/dist/shared/@outfitter/cli-s1tx5kha.d.ts +0 -59
- package/dist/shared/@outfitter/cli-sam2sq50.js +0 -37
- package/dist/shared/@outfitter/cli-snxj55n6.js +0 -43
- package/dist/shared/@outfitter/cli-symyxb0z.js +0 -20
- package/dist/shared/@outfitter/cli-tvw1xrdj.js +0 -20
- package/dist/shared/@outfitter/cli-v1tzwxkt.js +0 -32
- package/dist/shared/@outfitter/cli-vd60dj65.js +0 -1
- package/dist/shared/@outfitter/cli-vfcrskfj.d.ts +0 -41
- package/dist/shared/@outfitter/cli-vstbkzky.d.ts +0 -74
- package/dist/shared/@outfitter/cli-vtg0sqk2.d.ts +0 -54
- package/dist/shared/@outfitter/cli-x4cavvc0.js +0 -1
- package/dist/shared/@outfitter/cli-xep6v2c0.js +0 -52
- package/dist/shared/@outfitter/cli-xg5y5fhk.js +0 -86
- package/dist/shared/@outfitter/cli-y7k1t81k.js +0 -30
- package/dist/shared/@outfitter/cli-yfyzy95c.js +0 -67
- package/dist/shared/@outfitter/cli-z78mkrc7.js +0 -59
- package/dist/shared/@outfitter/cli-znc47004.js +0 -134
- package/dist/shared/@outfitter/cli-zx598p8q.d.ts +0 -26
- package/dist/streaming/ansi.d.ts +0 -2
- package/dist/streaming/ansi.js +0 -8
- package/dist/streaming/index.d.ts +0 -4
- package/dist/streaming/index.js +0 -17
- package/dist/streaming/spinner.d.ts +0 -3
- package/dist/streaming/spinner.js +0 -10
- package/dist/streaming/writer.d.ts +0 -2
- package/dist/streaming/writer.js +0 -9
- package/dist/table/index.d.ts +0 -4
- package/dist/table/index.js +0 -13
- package/dist/theme/context.d.ts +0 -9
- package/dist/theme/context.js +0 -14
- package/dist/theme/create.d.ts +0 -8
- package/dist/theme/create.js +0 -12
- package/dist/theme/index.d.ts +0 -17
- package/dist/theme/index.js +0 -42
- package/dist/theme/presets/bold.d.ts +0 -8
- package/dist/theme/presets/bold.js +0 -12
- package/dist/theme/presets/default.d.ts +0 -8
- package/dist/theme/presets/default.js +0 -11
- package/dist/theme/presets/index.d.ts +0 -12
- package/dist/theme/presets/index.js +0 -24
- package/dist/theme/presets/minimal.d.ts +0 -8
- package/dist/theme/presets/minimal.js +0 -12
- package/dist/theme/presets/rounded.d.ts +0 -8
- package/dist/theme/presets/rounded.js +0 -12
- package/dist/theme/resolve.d.ts +0 -8
- package/dist/theme/resolve.js +0 -11
- package/dist/theme/types.d.ts +0 -7
- package/dist/theme/types.js +0 -1
- package/dist/tree/index.d.ts +0 -3
- package/dist/tree/index.js +0 -11
- /package/dist/shared/@outfitter/{cli-ykxn7rb2.d.ts → cli-xppg982q.d.ts} +0 -0
- /package/dist/{render/types.js → shared/@outfitter/cli-zw75pdk8.js} +0 -0
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// packages/cli/src/render/indicators.ts
|
|
3
|
-
var INDICATORS = {
|
|
4
|
-
status: {
|
|
5
|
-
success: { unicode: "\u2714", fallback: "[ok]", color: "green" },
|
|
6
|
-
error: { unicode: "\u2716", fallback: "[x]", color: "red" },
|
|
7
|
-
warning: { unicode: "\u26A0", fallback: "[!]", color: "yellow" },
|
|
8
|
-
info: { unicode: "\u2139", fallback: "[i]", color: "blue" }
|
|
9
|
-
},
|
|
10
|
-
marker: {
|
|
11
|
-
circle: { unicode: "\u25CF", fallback: "*" },
|
|
12
|
-
circleOutline: { unicode: "\u25CB", fallback: "o" },
|
|
13
|
-
circleDotted: { unicode: "\u25CC", fallback: "o" },
|
|
14
|
-
circleSmall: { unicode: "\u2022", fallback: "\xB7" },
|
|
15
|
-
circleDot: { unicode: "\u25C9", fallback: "(*)" },
|
|
16
|
-
circleDotOutline: { unicode: "\u25EF", fallback: "( )" },
|
|
17
|
-
square: { unicode: "\u25A0", fallback: "[#]" },
|
|
18
|
-
squareOutline: { unicode: "\u25A1", fallback: "[ ]" },
|
|
19
|
-
squareSmall: { unicode: "\u25FC", fallback: "[#]" },
|
|
20
|
-
squareSmallOutline: { unicode: "\u25FB", fallback: "[ ]" },
|
|
21
|
-
lozenge: { unicode: "\u25C6", fallback: "\u2666" },
|
|
22
|
-
lozengeOutline: { unicode: "\u25C7", fallback: "\u25CA" },
|
|
23
|
-
lozengeDot: { unicode: "\u25C8", fallback: "\u2666\u2666" },
|
|
24
|
-
dash: { unicode: "\u2013", fallback: "-" },
|
|
25
|
-
pointer: { unicode: "\u276F", fallback: ">" },
|
|
26
|
-
pointerSmall: { unicode: "\u203A", fallback: ">" },
|
|
27
|
-
checkbox: { unicode: "\u2610", fallback: "[ ]" },
|
|
28
|
-
checkboxChecked: { unicode: "\u2611", fallback: "[x]" },
|
|
29
|
-
checkboxCross: { unicode: "\u2612", fallback: "[X]" }
|
|
30
|
-
},
|
|
31
|
-
progress: {
|
|
32
|
-
circleEmpty: { unicode: "\u25CB", fallback: "." },
|
|
33
|
-
circleQuarter: { unicode: "\u25D4", fallback: "o" },
|
|
34
|
-
circleHalf: { unicode: "\u25D1", fallback: "O" },
|
|
35
|
-
circleThree: { unicode: "\u25D5", fallback: "0" },
|
|
36
|
-
circleFull: { unicode: "\u25CF", fallback: "@" },
|
|
37
|
-
vertical1: { unicode: "\u2581", fallback: "_" },
|
|
38
|
-
vertical2: { unicode: "\u2582", fallback: "_" },
|
|
39
|
-
vertical3: { unicode: "\u2583", fallback: "=" },
|
|
40
|
-
vertical4: { unicode: "\u2584", fallback: "=" },
|
|
41
|
-
vertical5: { unicode: "\u2585", fallback: "#" },
|
|
42
|
-
vertical6: { unicode: "\u2586", fallback: "#" },
|
|
43
|
-
vertical7: { unicode: "\u2587", fallback: "#" },
|
|
44
|
-
verticalFull: { unicode: "\u2588", fallback: "#" },
|
|
45
|
-
horizontal1: { unicode: "\u258F", fallback: "|" },
|
|
46
|
-
horizontal2: { unicode: "\u258E", fallback: "|" },
|
|
47
|
-
horizontal3: { unicode: "\u258D", fallback: "|" },
|
|
48
|
-
horizontal4: { unicode: "\u258C", fallback: "|" },
|
|
49
|
-
horizontal5: { unicode: "\u258B", fallback: "|" },
|
|
50
|
-
horizontal6: { unicode: "\u258A", fallback: "|" },
|
|
51
|
-
horizontal7: { unicode: "\u2589", fallback: "|" },
|
|
52
|
-
horizontalFull: { unicode: "\u2588", fallback: "#" },
|
|
53
|
-
shadeLight: { unicode: "\u2591", fallback: "." },
|
|
54
|
-
shadeMedium: { unicode: "\u2592", fallback: ":" },
|
|
55
|
-
shadeDark: { unicode: "\u2593", fallback: "#" }
|
|
56
|
-
},
|
|
57
|
-
triangle: {
|
|
58
|
-
up: { unicode: "\u25B2", fallback: "^" },
|
|
59
|
-
upSmall: { unicode: "\u25B4", fallback: "^" },
|
|
60
|
-
upOutline: { unicode: "\u25B3", fallback: "^" },
|
|
61
|
-
down: { unicode: "\u25BC", fallback: "v" },
|
|
62
|
-
downSmall: { unicode: "\u25BE", fallback: "v" },
|
|
63
|
-
downOutline: { unicode: "\u25BD", fallback: "v" },
|
|
64
|
-
left: { unicode: "\u25C0", fallback: "<" },
|
|
65
|
-
leftSmall: { unicode: "\u25C2", fallback: "<" },
|
|
66
|
-
leftOutline: { unicode: "\u25C1", fallback: "<" },
|
|
67
|
-
right: { unicode: "\u25B6", fallback: ">" },
|
|
68
|
-
rightSmall: { unicode: "\u25B8", fallback: ">" },
|
|
69
|
-
rightOutline: { unicode: "\u25B7", fallback: ">" }
|
|
70
|
-
},
|
|
71
|
-
special: {
|
|
72
|
-
star: { unicode: "\u2605", fallback: "*" },
|
|
73
|
-
starOutline: { unicode: "\u2606", fallback: "*" },
|
|
74
|
-
heart: { unicode: "\u2665", fallback: "<3" },
|
|
75
|
-
heartOutline: { unicode: "\u2661", fallback: "<3" },
|
|
76
|
-
flag: { unicode: "\u2691", fallback: "[F]" },
|
|
77
|
-
flagOutline: { unicode: "\u2690", fallback: "[f]" },
|
|
78
|
-
gear: { unicode: "\u2699", fallback: "[*]" }
|
|
79
|
-
},
|
|
80
|
-
directional: {
|
|
81
|
-
arrowUp: { unicode: "\u2191", fallback: "^" },
|
|
82
|
-
arrowDown: { unicode: "\u2193", fallback: "v" },
|
|
83
|
-
arrowLeft: { unicode: "\u2190", fallback: "<-" },
|
|
84
|
-
arrowRight: { unicode: "\u2192", fallback: "->" },
|
|
85
|
-
arrowLeftRight: { unicode: "\u2194", fallback: "<->" },
|
|
86
|
-
arrowUpDown: { unicode: "\u2195", fallback: "^v" }
|
|
87
|
-
},
|
|
88
|
-
math: {
|
|
89
|
-
almostEqual: { unicode: "\u2248", fallback: "~=" },
|
|
90
|
-
notEqual: { unicode: "\u2260", fallback: "!=" },
|
|
91
|
-
lessOrEqual: { unicode: "\u2264", fallback: "<=" },
|
|
92
|
-
greaterOrEqual: { unicode: "\u2265", fallback: ">=" },
|
|
93
|
-
identical: { unicode: "\u2261", fallback: "===" },
|
|
94
|
-
infinity: { unicode: "\u221E", fallback: "inf" }
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
function isUnicodeSupported() {
|
|
98
|
-
if (process.env["CI"]) {
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
if (process.env["WT_SESSION"]) {
|
|
102
|
-
return true;
|
|
103
|
-
}
|
|
104
|
-
if (process.env["ConEmuTask"]) {
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
const term = process.env["TERM"] ?? "";
|
|
108
|
-
if (term === "xterm-256color" || term === "xterm" || term.includes("256color") || term.includes("truecolor")) {
|
|
109
|
-
return true;
|
|
110
|
-
}
|
|
111
|
-
const lang = process.env["LANG"] ?? process.env["LC_ALL"] ?? "";
|
|
112
|
-
if (lang.toLowerCase().includes("utf-8") || lang.toLowerCase().includes("utf8")) {
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
if (process.platform !== "win32") {
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
function getIndicator(category, name, forceUnicode) {
|
|
121
|
-
const indicator = INDICATORS[category][name];
|
|
122
|
-
if (!indicator) {
|
|
123
|
-
return "";
|
|
124
|
-
}
|
|
125
|
-
const useUnicode = forceUnicode ?? isUnicodeSupported();
|
|
126
|
-
return useUnicode ? indicator.unicode : indicator.fallback;
|
|
127
|
-
}
|
|
128
|
-
var PROGRESS_SEQUENCES = {
|
|
129
|
-
circle: [
|
|
130
|
-
"circleEmpty",
|
|
131
|
-
"circleQuarter",
|
|
132
|
-
"circleHalf",
|
|
133
|
-
"circleThree",
|
|
134
|
-
"circleFull"
|
|
135
|
-
],
|
|
136
|
-
vertical: [
|
|
137
|
-
"vertical1",
|
|
138
|
-
"vertical2",
|
|
139
|
-
"vertical3",
|
|
140
|
-
"vertical4",
|
|
141
|
-
"vertical5",
|
|
142
|
-
"vertical6",
|
|
143
|
-
"vertical7",
|
|
144
|
-
"verticalFull"
|
|
145
|
-
],
|
|
146
|
-
horizontal: [
|
|
147
|
-
"horizontal1",
|
|
148
|
-
"horizontal2",
|
|
149
|
-
"horizontal3",
|
|
150
|
-
"horizontal4",
|
|
151
|
-
"horizontal5",
|
|
152
|
-
"horizontal6",
|
|
153
|
-
"horizontal7",
|
|
154
|
-
"horizontalFull"
|
|
155
|
-
],
|
|
156
|
-
shade: ["shadeLight", "shadeMedium", "shadeDark"]
|
|
157
|
-
};
|
|
158
|
-
function getProgressIndicator(style, current, max, forceUnicode) {
|
|
159
|
-
const sequence = PROGRESS_SEQUENCES[style];
|
|
160
|
-
const steps = sequence.length;
|
|
161
|
-
const ratio = max <= 0 ? 0 : Math.max(0, Math.min(1, current / max));
|
|
162
|
-
const index = Math.round(ratio * (steps - 1));
|
|
163
|
-
const name = sequence[index];
|
|
164
|
-
if (name === undefined) {
|
|
165
|
-
return "";
|
|
166
|
-
}
|
|
167
|
-
return getIndicator("progress", name, forceUnicode);
|
|
168
|
-
}
|
|
169
|
-
var SEVERITY_MARKERS = {
|
|
170
|
-
minor: "lozengeOutline",
|
|
171
|
-
moderate: "lozenge",
|
|
172
|
-
severe: "lozengeDot"
|
|
173
|
-
};
|
|
174
|
-
function getSeverityIndicator(level, forceUnicode) {
|
|
175
|
-
const name = SEVERITY_MARKERS[level];
|
|
176
|
-
return getIndicator("marker", name, forceUnicode);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
export { INDICATORS, isUnicodeSupported, getIndicator, getProgressIndicator, getSeverityIndicator };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
defaultTheme
|
|
4
|
-
} from "./cli-z78mkrc7.js";
|
|
5
|
-
import {
|
|
6
|
-
BORDERS,
|
|
7
|
-
init_borders
|
|
8
|
-
} from "./cli-85fg2vr5.js";
|
|
9
|
-
|
|
10
|
-
// packages/cli/src/theme/presets/bold.ts
|
|
11
|
-
init_borders();
|
|
12
|
-
var boldTheme = {
|
|
13
|
-
...defaultTheme,
|
|
14
|
-
name: "bold",
|
|
15
|
-
border: "heavy",
|
|
16
|
-
borderChars: BORDERS.heavy,
|
|
17
|
-
treeGuide: "heavy"
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export { boldTheme };
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Progress bar rendering utilities.
|
|
3
|
-
*
|
|
4
|
-
* Renders progress bars with filled and empty segments.
|
|
5
|
-
*
|
|
6
|
-
* @packageDocumentation
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Configuration options for {@link renderProgress}.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* const options: ProgressOptions = {
|
|
14
|
-
* current: 75,
|
|
15
|
-
* total: 100,
|
|
16
|
-
* width: 20,
|
|
17
|
-
* showPercent: true,
|
|
18
|
-
* };
|
|
19
|
-
* // Renders: [###############.....] 75%
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
interface ProgressOptions {
|
|
23
|
-
/** Current progress value */
|
|
24
|
-
current: number;
|
|
25
|
-
/** Total value (100% when current equals total) */
|
|
26
|
-
total: number;
|
|
27
|
-
/** Width of the progress bar in characters (default: 20) */
|
|
28
|
-
width?: number;
|
|
29
|
-
/** Whether to show percentage after the bar (default: false) */
|
|
30
|
-
showPercent?: boolean;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Renders a progress bar with filled and empty segments.
|
|
34
|
-
*
|
|
35
|
-
* Uses unicode block characters: filled segments, empty segments.
|
|
36
|
-
* Optionally displays percentage after the bar.
|
|
37
|
-
*
|
|
38
|
-
* Handles edge cases:
|
|
39
|
-
* - `total <= 0`: Returns empty bar with 0%
|
|
40
|
-
* - `current > total`: Caps at 100%
|
|
41
|
-
* - `current < 0`: Floors at 0%
|
|
42
|
-
*
|
|
43
|
-
* @param options - Progress bar configuration
|
|
44
|
-
* @returns Formatted progress bar string
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```typescript
|
|
48
|
-
* renderProgress({ current: 50, total: 100 });
|
|
49
|
-
* // [##########..........]
|
|
50
|
-
*
|
|
51
|
-
* renderProgress({ current: 75, total: 100, showPercent: true });
|
|
52
|
-
* // [###############.....] 75%
|
|
53
|
-
*
|
|
54
|
-
* renderProgress({ current: 30, total: 100, width: 10 });
|
|
55
|
-
* // [###.......]
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
declare function renderProgress(options: ProgressOptions): string;
|
|
59
|
-
export { ProgressOptions, renderProgress };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ExampleTexts } from "./cli-c6pbxpw0";
|
|
2
|
-
/**
|
|
3
|
-
* Default example texts used when no custom examples are provided.
|
|
4
|
-
*
|
|
5
|
-
* These defaults are generic enough to work for any CLI while still
|
|
6
|
-
* being meaningful and demonstrative.
|
|
7
|
-
*/
|
|
8
|
-
declare const DEFAULT_EXAMPLES: ExampleTexts;
|
|
9
|
-
/**
|
|
10
|
-
* Resolves example text with custom overrides.
|
|
11
|
-
*
|
|
12
|
-
* @param key - The example text key
|
|
13
|
-
* @param custom - Optional custom examples
|
|
14
|
-
* @returns The example text (custom if provided, default otherwise)
|
|
15
|
-
*/
|
|
16
|
-
declare function getExample<K extends keyof ExampleTexts>(key: K, custom?: Partial<ExampleTexts>): ExampleTexts[K];
|
|
17
|
-
export { DEFAULT_EXAMPLES, getExample };
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
__esm
|
|
4
|
-
} from "./cli-v1tzwxkt.js";
|
|
5
|
-
|
|
6
|
-
// packages/cli/src/render/borders.ts
|
|
7
|
-
function getBorderCharacters(style) {
|
|
8
|
-
return BORDERS[style];
|
|
9
|
-
}
|
|
10
|
-
function drawHorizontalLine(width, chars, position, columnWidths) {
|
|
11
|
-
if (!chars.horizontal) {
|
|
12
|
-
return "";
|
|
13
|
-
}
|
|
14
|
-
const positionChars = {
|
|
15
|
-
top: { left: chars.topLeft, right: chars.topRight, cross: chars.topT },
|
|
16
|
-
middle: { left: chars.leftT, right: chars.rightT, cross: chars.cross },
|
|
17
|
-
bottom: {
|
|
18
|
-
left: chars.bottomLeft,
|
|
19
|
-
right: chars.bottomRight,
|
|
20
|
-
cross: chars.bottomT
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
const { left, right, cross: intersection } = positionChars[position];
|
|
24
|
-
if (!columnWidths || columnWidths.length <= 1) {
|
|
25
|
-
return `${left}${chars.horizontal.repeat(width)}${right}`;
|
|
26
|
-
}
|
|
27
|
-
const columnsWidth = columnWidths.reduce((sum, w) => sum + w, 0);
|
|
28
|
-
const intersectionsWidth = columnWidths.length - 1;
|
|
29
|
-
const actualWidth = columnsWidth + intersectionsWidth;
|
|
30
|
-
const adjustedWidths = [...columnWidths];
|
|
31
|
-
if (actualWidth !== width && adjustedWidths.length > 0) {
|
|
32
|
-
const lastIndex = adjustedWidths.length - 1;
|
|
33
|
-
const lastWidth = adjustedWidths[lastIndex] ?? 0;
|
|
34
|
-
adjustedWidths[lastIndex] = Math.max(0, lastWidth + (width - actualWidth));
|
|
35
|
-
}
|
|
36
|
-
const segments = adjustedWidths.map((colWidth) => chars.horizontal.repeat(colWidth));
|
|
37
|
-
return `${left}${segments.join(intersection)}${right}`;
|
|
38
|
-
}
|
|
39
|
-
var BORDERS;
|
|
40
|
-
var init_borders = __esm(() => {
|
|
41
|
-
BORDERS = {
|
|
42
|
-
single: {
|
|
43
|
-
topLeft: "\u250C",
|
|
44
|
-
topRight: "\u2510",
|
|
45
|
-
bottomLeft: "\u2514",
|
|
46
|
-
bottomRight: "\u2518",
|
|
47
|
-
horizontal: "\u2500",
|
|
48
|
-
vertical: "\u2502",
|
|
49
|
-
topT: "\u252C",
|
|
50
|
-
bottomT: "\u2534",
|
|
51
|
-
leftT: "\u251C",
|
|
52
|
-
rightT: "\u2524",
|
|
53
|
-
cross: "\u253C"
|
|
54
|
-
},
|
|
55
|
-
double: {
|
|
56
|
-
topLeft: "\u2554",
|
|
57
|
-
topRight: "\u2557",
|
|
58
|
-
bottomLeft: "\u255A",
|
|
59
|
-
bottomRight: "\u255D",
|
|
60
|
-
horizontal: "\u2550",
|
|
61
|
-
vertical: "\u2551",
|
|
62
|
-
topT: "\u2566",
|
|
63
|
-
bottomT: "\u2569",
|
|
64
|
-
leftT: "\u2560",
|
|
65
|
-
rightT: "\u2563",
|
|
66
|
-
cross: "\u256C"
|
|
67
|
-
},
|
|
68
|
-
rounded: {
|
|
69
|
-
topLeft: "\u256D",
|
|
70
|
-
topRight: "\u256E",
|
|
71
|
-
bottomLeft: "\u2570",
|
|
72
|
-
bottomRight: "\u256F",
|
|
73
|
-
horizontal: "\u2500",
|
|
74
|
-
vertical: "\u2502",
|
|
75
|
-
topT: "\u252C",
|
|
76
|
-
bottomT: "\u2534",
|
|
77
|
-
leftT: "\u251C",
|
|
78
|
-
rightT: "\u2524",
|
|
79
|
-
cross: "\u253C"
|
|
80
|
-
},
|
|
81
|
-
heavy: {
|
|
82
|
-
topLeft: "\u250F",
|
|
83
|
-
topRight: "\u2513",
|
|
84
|
-
bottomLeft: "\u2517",
|
|
85
|
-
bottomRight: "\u251B",
|
|
86
|
-
horizontal: "\u2501",
|
|
87
|
-
vertical: "\u2503",
|
|
88
|
-
topT: "\u2533",
|
|
89
|
-
bottomT: "\u253B",
|
|
90
|
-
leftT: "\u2523",
|
|
91
|
-
rightT: "\u252B",
|
|
92
|
-
cross: "\u254B"
|
|
93
|
-
},
|
|
94
|
-
ascii: {
|
|
95
|
-
topLeft: "+",
|
|
96
|
-
topRight: "+",
|
|
97
|
-
bottomLeft: "+",
|
|
98
|
-
bottomRight: "+",
|
|
99
|
-
horizontal: "-",
|
|
100
|
-
vertical: "|",
|
|
101
|
-
topT: "+",
|
|
102
|
-
bottomT: "+",
|
|
103
|
-
leftT: "+",
|
|
104
|
-
rightT: "+",
|
|
105
|
-
cross: "+"
|
|
106
|
-
},
|
|
107
|
-
none: {
|
|
108
|
-
topLeft: "",
|
|
109
|
-
topRight: "",
|
|
110
|
-
bottomLeft: "",
|
|
111
|
-
bottomRight: "",
|
|
112
|
-
horizontal: "",
|
|
113
|
-
vertical: "",
|
|
114
|
-
topT: "",
|
|
115
|
-
bottomT: "",
|
|
116
|
-
leftT: "",
|
|
117
|
-
rightT: "",
|
|
118
|
-
cross: ""
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
export { BORDERS, getBorderCharacters, drawHorizontalLine, init_borders };
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { IndicatorCategory } from "./cli-1g8tt31a";
|
|
2
|
-
import { DelimiterName } from "./cli-hnpbqmc8";
|
|
3
|
-
import { TreeGuideStyle } from "./cli-3b7ed3rm";
|
|
4
|
-
import { SpinnerStyle } from "./cli-e5ms1y0x";
|
|
5
|
-
import { BorderCharacters, BorderStyle } from "./cli-fakncnjp";
|
|
6
|
-
/**
|
|
7
|
-
* A glyph with unicode and ASCII fallback representations.
|
|
8
|
-
*
|
|
9
|
-
* Used for characters that may not be available in all terminals.
|
|
10
|
-
* The appropriate character is selected at runtime based on terminal capability.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* const bullet: GlyphPair = { unicode: "•", fallback: "*" };
|
|
15
|
-
* const checkbox: GlyphPair = { unicode: "☑", fallback: "[x]" };
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
interface GlyphPair {
|
|
19
|
-
/** Unicode character for modern terminals */
|
|
20
|
-
unicode: string;
|
|
21
|
-
/** ASCII fallback for limited terminals */
|
|
22
|
-
fallback: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Semantic states that can be mapped to visual markers.
|
|
26
|
-
*
|
|
27
|
-
* These represent the logical state of an item, which themes translate
|
|
28
|
-
* to specific visual representations.
|
|
29
|
-
*/
|
|
30
|
-
type SemanticState = "default" | "current" | "focused" | "checked" | "disabled" | "success" | "warning" | "error" | "info";
|
|
31
|
-
/**
|
|
32
|
-
* Specification for how to render a semantic state marker.
|
|
33
|
-
*
|
|
34
|
-
* Can either reference an existing indicator from the INDICATORS registry,
|
|
35
|
-
* or provide a custom glyph pair.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```typescript
|
|
39
|
-
* // Reference existing indicator
|
|
40
|
-
* const successMarker: MarkerSpec = {
|
|
41
|
-
* type: "indicator",
|
|
42
|
-
* category: "status",
|
|
43
|
-
* name: "success"
|
|
44
|
-
* };
|
|
45
|
-
*
|
|
46
|
-
* // Custom glyph
|
|
47
|
-
* const starMarker: MarkerSpec = {
|
|
48
|
-
* type: "custom",
|
|
49
|
-
* glyph: { unicode: "★", fallback: "*" }
|
|
50
|
-
* };
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
type MarkerSpec = {
|
|
54
|
-
type: "indicator";
|
|
55
|
-
category: IndicatorCategory;
|
|
56
|
-
name: string;
|
|
57
|
-
} | {
|
|
58
|
-
type: "custom";
|
|
59
|
-
glyph: GlyphPair;
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* Semantic color tokens as ANSI escape codes.
|
|
63
|
-
*
|
|
64
|
-
* Colors are stored as raw ANSI codes and can be empty strings
|
|
65
|
-
* when colors are disabled.
|
|
66
|
-
*/
|
|
67
|
-
interface ThemeColors {
|
|
68
|
-
/** Green - success messages, completed items */
|
|
69
|
-
success: string;
|
|
70
|
-
/** Yellow - warnings, caution */
|
|
71
|
-
warning: string;
|
|
72
|
-
/** Red - errors, failures */
|
|
73
|
-
error: string;
|
|
74
|
-
/** Blue - informational messages */
|
|
75
|
-
info: string;
|
|
76
|
-
/** Default text color (typically empty string) */
|
|
77
|
-
primary: string;
|
|
78
|
-
/** Gray - secondary text */
|
|
79
|
-
secondary: string;
|
|
80
|
-
/** Dim - de-emphasized text */
|
|
81
|
-
muted: string;
|
|
82
|
-
/** Cyan - interactive elements, highlights */
|
|
83
|
-
accent: string;
|
|
84
|
-
/** Bold - strong emphasis */
|
|
85
|
-
highlight: string;
|
|
86
|
-
/** Cyan + underline - URLs, clickable references */
|
|
87
|
-
link: string;
|
|
88
|
-
/** Bright red - dangerous actions */
|
|
89
|
-
destructive: string;
|
|
90
|
-
/** Dim gray - less prominent than muted */
|
|
91
|
-
subtle: string;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Default spacing values for various components.
|
|
95
|
-
*/
|
|
96
|
-
interface ThemeSpacing {
|
|
97
|
-
/** Default padding inside boxes (characters) */
|
|
98
|
-
boxPadding: number;
|
|
99
|
-
/** Indentation for nested list items (characters) */
|
|
100
|
-
listIndent: number;
|
|
101
|
-
/** Gap between items in vertical stacks (lines) */
|
|
102
|
-
stackGap: number;
|
|
103
|
-
/** Gap between items in horizontal stacks (characters) */
|
|
104
|
-
horizontalGap: number;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Complete visual theme configuration.
|
|
108
|
-
*
|
|
109
|
-
* Consolidates all visual primitives (borders, delimiters, markers, guides,
|
|
110
|
-
* colors) into a cohesive design system. Themes can be used as-is (presets)
|
|
111
|
-
* or customized via {@link createVisualTheme}.
|
|
112
|
-
*
|
|
113
|
-
* @example
|
|
114
|
-
* ```typescript
|
|
115
|
-
* import { defaultTheme, roundedTheme, createVisualTheme } from "@outfitter/cli/theme";
|
|
116
|
-
*
|
|
117
|
-
* // Use a preset
|
|
118
|
-
* const box = renderBox("Hello", { theme: roundedTheme });
|
|
119
|
-
*
|
|
120
|
-
* // Create a custom theme
|
|
121
|
-
* const brandTheme = createVisualTheme({
|
|
122
|
-
* extends: roundedTheme,
|
|
123
|
-
* overrides: {
|
|
124
|
-
* colors: { accent: "\x1b[38;5;39m" },
|
|
125
|
-
* spacing: { boxPadding: 2 }
|
|
126
|
-
* }
|
|
127
|
-
* });
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
interface VisualTheme {
|
|
131
|
-
/** Theme identifier */
|
|
132
|
-
name: string;
|
|
133
|
-
/** Border style preset name */
|
|
134
|
-
border: BorderStyle;
|
|
135
|
-
/** Derived border characters for the border style */
|
|
136
|
-
borderChars: BorderCharacters;
|
|
137
|
-
/** Tree guide style for hierarchical displays */
|
|
138
|
-
treeGuide: TreeGuideStyle;
|
|
139
|
-
/** Default delimiter for inline separators */
|
|
140
|
-
delimiter: DelimiterName;
|
|
141
|
-
/** Map of semantic states to marker specifications */
|
|
142
|
-
markers: Record<SemanticState, MarkerSpec>;
|
|
143
|
-
/** Default list bullet glyph */
|
|
144
|
-
listBullet: GlyphPair;
|
|
145
|
-
/** Checkbox glyphs for checked/unchecked states */
|
|
146
|
-
checkbox: {
|
|
147
|
-
checked: GlyphPair;
|
|
148
|
-
unchecked: GlyphPair;
|
|
149
|
-
};
|
|
150
|
-
/** Semantic color tokens */
|
|
151
|
-
colors: ThemeColors;
|
|
152
|
-
/** Default spacing values */
|
|
153
|
-
spacing: ThemeSpacing;
|
|
154
|
-
/** Default spinner animation style */
|
|
155
|
-
spinner: SpinnerStyle;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Partial theme for overriding specific properties.
|
|
159
|
-
*
|
|
160
|
-
* Used by {@link createVisualTheme} to allow partial customization
|
|
161
|
-
* while inheriting defaults.
|
|
162
|
-
*/
|
|
163
|
-
type PartialVisualTheme = { [K in keyof VisualTheme]? : K extends "colors" ? Partial<ThemeColors> : K extends "spacing" ? Partial<ThemeSpacing> : K extends "markers" ? Partial<Record<SemanticState, MarkerSpec>> : K extends "checkbox" ? Partial<VisualTheme["checkbox"]> : VisualTheme[K] };
|
|
164
|
-
export { GlyphPair, SemanticState, MarkerSpec, ThemeColors, ThemeSpacing, VisualTheme, PartialVisualTheme };
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// packages/cli/src/render/format-relative.ts
|
|
3
|
-
function formatRelative(date) {
|
|
4
|
-
let timestamp;
|
|
5
|
-
if (date instanceof Date) {
|
|
6
|
-
timestamp = date.getTime();
|
|
7
|
-
} else if (typeof date === "number") {
|
|
8
|
-
timestamp = date;
|
|
9
|
-
} else {
|
|
10
|
-
const parsed = Date.parse(date);
|
|
11
|
-
if (Number.isNaN(parsed)) {
|
|
12
|
-
return "invalid date";
|
|
13
|
-
}
|
|
14
|
-
timestamp = parsed;
|
|
15
|
-
}
|
|
16
|
-
if (!Number.isFinite(timestamp)) {
|
|
17
|
-
return "invalid date";
|
|
18
|
-
}
|
|
19
|
-
const now = Date.now();
|
|
20
|
-
const diffMs = now - timestamp;
|
|
21
|
-
const absDiffMs = Math.abs(diffMs);
|
|
22
|
-
const isFuture = diffMs < 0;
|
|
23
|
-
const SECOND = 1000;
|
|
24
|
-
const MINUTE = 60 * SECOND;
|
|
25
|
-
const HOUR = 60 * MINUTE;
|
|
26
|
-
const DAY = 24 * HOUR;
|
|
27
|
-
const MONTH = 30 * DAY;
|
|
28
|
-
const YEAR = 365 * DAY;
|
|
29
|
-
if (absDiffMs < 10 * SECOND) {
|
|
30
|
-
return "just now";
|
|
31
|
-
}
|
|
32
|
-
if (absDiffMs < MINUTE) {
|
|
33
|
-
const seconds = Math.floor(absDiffMs / SECOND);
|
|
34
|
-
return isFuture ? `in ${seconds} seconds` : `${seconds} seconds ago`;
|
|
35
|
-
}
|
|
36
|
-
if (absDiffMs < HOUR) {
|
|
37
|
-
const minutes = Math.floor(absDiffMs / MINUTE);
|
|
38
|
-
if (minutes === 1) {
|
|
39
|
-
return isFuture ? "in 1 minute" : "1 minute ago";
|
|
40
|
-
}
|
|
41
|
-
return isFuture ? `in ${minutes} minutes` : `${minutes} minutes ago`;
|
|
42
|
-
}
|
|
43
|
-
if (absDiffMs < DAY) {
|
|
44
|
-
const hours = Math.floor(absDiffMs / HOUR);
|
|
45
|
-
if (hours === 1) {
|
|
46
|
-
return isFuture ? "in 1 hour" : "1 hour ago";
|
|
47
|
-
}
|
|
48
|
-
return isFuture ? `in ${hours} hours` : `${hours} hours ago`;
|
|
49
|
-
}
|
|
50
|
-
if (absDiffMs < 2 * DAY) {
|
|
51
|
-
return isFuture ? "tomorrow" : "yesterday";
|
|
52
|
-
}
|
|
53
|
-
if (absDiffMs < MONTH) {
|
|
54
|
-
const days = Math.floor(absDiffMs / DAY);
|
|
55
|
-
return isFuture ? `in ${days} days` : `${days} days ago`;
|
|
56
|
-
}
|
|
57
|
-
if (absDiffMs < YEAR) {
|
|
58
|
-
const months = Math.floor(absDiffMs / MONTH);
|
|
59
|
-
if (months === 1) {
|
|
60
|
-
return isFuture ? "in 1 month" : "1 month ago";
|
|
61
|
-
}
|
|
62
|
-
return isFuture ? `in ${months} months` : `${months} months ago`;
|
|
63
|
-
}
|
|
64
|
-
const years = Math.floor(absDiffMs / YEAR);
|
|
65
|
-
if (years === 1) {
|
|
66
|
-
return isFuture ? "in 1 year" : "1 year ago";
|
|
67
|
-
}
|
|
68
|
-
return isFuture ? `in ${years} years` : `${years} years ago`;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export { formatRelative };
|