@justanarthur/modo-ui-notch 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/blocks/activities/agenda/examples.mdx +8 -0
- package/blocks/activities/agenda/index.tsx +164 -16
- package/blocks/activities/clock/examples.mdx +16 -0
- package/blocks/activities/clock/index.tsx +357 -59
- package/blocks/activities/now-playing/examples.mdx +8 -0
- package/blocks/activities/now-playing/index.tsx +140 -54
- package/blocks/activities/weather/examples.mdx +9 -1
- package/blocks/activities/weather/index.tsx +241 -12
- package/blocks/app/expanded-island/index.tsx +3 -1
- package/blocks/app/settings-window/examples.mdx +8 -0
- package/blocks/app/settings-window/index.tsx +8 -3
- package/blocks/system/clipboard/examples.mdx +8 -0
- package/blocks/system/clipboard/index.tsx +262 -52
- package/blocks/system/recent-files/examples.mdx +14 -0
- package/blocks/system/recent-files/index.tsx +110 -25
- package/blocks/system/system-stats/examples.mdx +8 -0
- package/blocks/system/system-stats/index.tsx +211 -4
- package/components/island/widget/index.tsx +34 -0
- package/dist/blocks/activities/agenda/index.d.ts +2 -1
- package/dist/blocks/activities/agenda/index.js +2 -2
- package/dist/blocks/activities/clock/index.d.ts +2 -1
- package/dist/blocks/activities/clock/index.js +2 -2
- package/dist/blocks/activities/now-playing/index.d.ts +2 -1
- package/dist/blocks/activities/now-playing/index.js +2 -2
- package/dist/blocks/activities/weather/index.d.ts +2 -1
- package/dist/blocks/activities/weather/index.js +2 -2
- package/dist/blocks/app/expanded-island/index.d.ts +1 -1
- package/dist/blocks/app/expanded-island/index.js +1 -1
- package/dist/blocks/app/settings-window/index.d.ts +1 -1
- package/dist/blocks/app/settings-window/index.js +1 -1
- package/dist/blocks/system/clipboard/index.d.ts +2 -1
- package/dist/blocks/system/clipboard/index.js +2 -2
- package/dist/blocks/system/recent-files/index.d.ts +2 -1
- package/dist/blocks/system/recent-files/index.js +2 -2
- package/dist/blocks/system/system-stats/index.d.ts +2 -1
- package/dist/blocks/system/system-stats/index.js +2 -2
- package/dist/components/island/widget/index.d.ts +2 -2
- package/dist/components/island/widget/index.js +3 -1
- package/dist/index.d.ts +11 -11
- package/dist/index.js +12 -10
- package/dist/shared/{chunk-2m5dz8nf.d.ts → chunk-0ym9mcqc.d.ts} +6 -2
- package/dist/shared/{chunk-xq5hc5gv.js → chunk-2b6gpn8k.js} +177 -66
- package/dist/shared/chunk-3hcnf4yx.js +481 -0
- package/dist/shared/{chunk-416tsgbc.d.ts → chunk-42wab62s.d.ts} +23 -1
- package/dist/shared/{chunk-pfhy5e4q.d.ts → chunk-6tnq6p89.d.ts} +2 -0
- package/dist/shared/{chunk-qdzemt2v.js → chunk-93dtpjz7.js} +401 -89
- package/dist/shared/{chunk-da177e8r.d.ts → chunk-a6njb8db.d.ts} +16 -1
- package/dist/shared/{chunk-2818esrq.d.ts → chunk-ab8mdg0n.d.ts} +10 -1
- package/dist/shared/{chunk-3thgcfcq.d.ts → chunk-evqpf92s.d.ts} +18 -1
- package/dist/shared/{chunk-mt0k6v8x.js → chunk-gcyspvgr.js} +147 -39
- package/dist/shared/{chunk-t0hcxh89.d.ts → chunk-gkj0hjrn.d.ts} +12 -0
- package/dist/shared/{chunk-wkg17nxs.d.ts → chunk-n739am8j.d.ts} +13 -2
- package/dist/shared/{chunk-ym0xbses.js → chunk-nwzpekvy.js} +274 -18
- package/dist/shared/{chunk-bvtyjcce.d.ts → chunk-sbrtesdg.d.ts} +16 -1
- package/dist/shared/{chunk-7fvnrtz4.d.ts → chunk-swc7dqpw.d.ts} +12 -2
- package/dist/shared/{chunk-j77cx8dp.js → chunk-t9wqhgzt.js} +325 -58
- package/dist/shared/{chunk-9m0xbg5v.js → chunk-wayv5rhr.js} +1 -1
- package/dist/shared/{chunk-x7f3g82r.js → chunk-wf0jtzhs.js} +12 -2
- package/dist/shared/{chunk-9c7ewvkk.js → chunk-yq5svpk7.js} +162 -19
- package/dist/shared/{chunk-cc9nwbtf.js → chunk-z3tj1ydg.js} +3 -0
- package/dist/styles.css +60 -0
- package/mock/clipboard.tsx +34 -0
- package/mock/clock.tsx +3 -3
- package/mock/data.ts +48 -0
- package/mock/files.tsx +14 -1
- package/mock/island-content.tsx +47 -15
- package/mock/system.ts +3 -0
- package/mock/weather.tsx +42 -12
- package/package.json +1 -1
- package/dist/shared/chunk-s2jeqqan.js +0 -243
package/mock/island-content.tsx
CHANGED
|
@@ -19,6 +19,7 @@ import ClipboardHistory from '../blocks/system/clipboard'
|
|
|
19
19
|
import RecentFiles from '../blocks/system/recent-files'
|
|
20
20
|
import SystemStats from '../blocks/system/system-stats'
|
|
21
21
|
import Island from '../components/island/island'
|
|
22
|
+
import type { WidgetLayout } from '../components/island/widget'
|
|
22
23
|
import { ISLAND_STATES, type IslandState } from '../lib/geometry'
|
|
23
24
|
import { PLAYING } from './artwork'
|
|
24
25
|
import { CLIP_NOW, CLIPS, PINNED } from './clipboard'
|
|
@@ -50,28 +51,48 @@ export function DownloadedFlash() {
|
|
|
50
51
|
const noop = () => {}
|
|
51
52
|
|
|
52
53
|
/** Every widget of the open island, by tab value. */
|
|
53
|
-
export function widgetFor(tab: string): ReactNode {
|
|
54
|
+
export function widgetFor(tab: string, layout: WidgetLayout = 'fit'): ReactNode {
|
|
54
55
|
if (tab === 'now-playing')
|
|
55
|
-
return <NowPlaying track={PLAYING} defaultShuffle={false} defaultRepeat="all" defaultLiked />
|
|
56
|
-
if (tab === 'calendar') return <Agenda events={EVENTS} now={AGENDA_NOW} />
|
|
57
|
-
if (tab === 'weather') return <Weather {...FORECAST} onRefresh={noop} />
|
|
58
|
-
if (tab === 'clock') return <Clock zones={ZONES} />
|
|
56
|
+
return <NowPlaying track={PLAYING} defaultShuffle={false} defaultRepeat="all" defaultLiked layout={layout} />
|
|
57
|
+
if (tab === 'calendar') return <Agenda events={EVENTS} now={AGENDA_NOW} layout={layout} />
|
|
58
|
+
if (tab === 'weather') return <Weather {...FORECAST} onRefresh={noop} layout={layout} />
|
|
59
|
+
if (tab === 'clock') return <Clock zones={ZONES} completedToday={3} layout={layout} />
|
|
59
60
|
if (tab === 'system')
|
|
60
|
-
return
|
|
61
|
+
return (
|
|
62
|
+
<SystemStats
|
|
63
|
+
samples={READINGS}
|
|
64
|
+
battery={BATTERY}
|
|
65
|
+
disk={DISK}
|
|
66
|
+
uptime={UPTIME}
|
|
67
|
+
processes={PROCESSES}
|
|
68
|
+
layout={layout}
|
|
69
|
+
/>
|
|
70
|
+
)
|
|
61
71
|
if (tab === 'clipboard')
|
|
62
|
-
return <ClipboardHistory clips={CLIPS} defaultPinned={PINNED} now={CLIP_NOW} onDelete={noop} />
|
|
72
|
+
return <ClipboardHistory clips={CLIPS} defaultPinned={PINNED} now={CLIP_NOW} onDelete={noop} layout={layout} />
|
|
63
73
|
if (tab === 'files')
|
|
64
74
|
return (
|
|
65
|
-
<RecentFiles
|
|
75
|
+
<RecentFiles
|
|
76
|
+
files={RECENT_FILES}
|
|
77
|
+
now={FILES_NOW}
|
|
78
|
+
onReveal={noop}
|
|
79
|
+
onCopy={noop}
|
|
80
|
+
onDelete={noop}
|
|
81
|
+
onClear={noop}
|
|
82
|
+
layout={layout}
|
|
83
|
+
/>
|
|
66
84
|
)
|
|
67
85
|
return null
|
|
68
86
|
}
|
|
69
87
|
|
|
70
88
|
const WIDGET_TABS: ExpandedIslandTab[] = TABS.map(tab => ({ ...tab, content: widgetFor(tab.value) }))
|
|
89
|
+
const TALL_TABS: ExpandedIslandTab[] = TABS.map(tab => ({ ...tab, content: widgetFor(tab.value, 'tall') }))
|
|
71
90
|
|
|
72
|
-
/** The open island's tabs, a view per widget
|
|
73
|
-
export function panelTabs(views: Record<string, ReactNode> = {}): ExpandedIslandTab[] {
|
|
74
|
-
return
|
|
91
|
+
/** The open island's tabs, a view per widget at `layout`, with `views` in place of the mock ones. */
|
|
92
|
+
export function panelTabs(views: Record<string, ReactNode> = {}, layout: WidgetLayout = 'fit'): ExpandedIslandTab[] {
|
|
93
|
+
return (layout === 'tall' ? TALL_TABS : WIDGET_TABS).map(tab =>
|
|
94
|
+
tab.value in views ? { ...tab, content: views[tab.value] } : tab,
|
|
95
|
+
)
|
|
75
96
|
}
|
|
76
97
|
|
|
77
98
|
/** The open island: a tab per widget in the wings, settings at the far right. */
|
|
@@ -127,14 +148,25 @@ export function IslandPlayground({ defaultState = 'compact' }: { defaultState?:
|
|
|
127
148
|
)
|
|
128
149
|
}
|
|
129
150
|
|
|
130
|
-
/** The open island on a strip of screen, on `tab`, its view replaced by `children` when given. */
|
|
131
|
-
export function WidgetIsland({
|
|
132
|
-
|
|
151
|
+
/** The open island on a strip of screen, on `tab`, its view replaced by `children` when given; `tall` pulls it down to the 560 px sheet. */
|
|
152
|
+
export function WidgetIsland({
|
|
153
|
+
tab,
|
|
154
|
+
children,
|
|
155
|
+
height,
|
|
156
|
+
tall = false,
|
|
157
|
+
}: {
|
|
158
|
+
tab: string
|
|
159
|
+
children?: ReactNode
|
|
160
|
+
height?: number
|
|
161
|
+
tall?: boolean
|
|
162
|
+
}) {
|
|
163
|
+
const tabs = panelTabs(children ? { [tab]: children } : {}, tall ? 'tall' : 'fit')
|
|
133
164
|
return (
|
|
134
|
-
<ScreenEdge height={height}>
|
|
165
|
+
<ScreenEdge height={height ?? (tall ? 580 : 260)}>
|
|
135
166
|
<Island
|
|
136
167
|
defaultState="expanded"
|
|
137
168
|
collapsedState="idle"
|
|
169
|
+
panelHeight={tall ? 560 : undefined}
|
|
138
170
|
expanded={<ExpandedIsland tabs={tabs} defaultValue={tab} onSettings={() => {}} />}
|
|
139
171
|
/>
|
|
140
172
|
</ScreenEdge>
|
package/mock/system.ts
CHANGED
|
@@ -43,4 +43,7 @@ export const PROCESSES: StatsProcess[] = [
|
|
|
43
43
|
{ id: '1043', name: 'WindowServer', cpu: 0.052, memory: 0.6e9 },
|
|
44
44
|
{ id: '97', name: 'Figma', cpu: 0.031, memory: 1.1e9 },
|
|
45
45
|
{ id: '1520', name: 'Music', cpu: 0.012, memory: 0.3e9 },
|
|
46
|
+
{ id: '644', name: 'Slack', cpu: 0.019, memory: 0.8e9 },
|
|
47
|
+
{ id: '388', name: 'mds_stores', cpu: 0.024, memory: 0.2e9 },
|
|
48
|
+
{ id: '0', name: 'kernel_task', cpu: 0.041, memory: 2.1e9 },
|
|
46
49
|
]
|
package/mock/weather.tsx
CHANGED
|
@@ -31,8 +31,9 @@ export const CURRENT: WeatherNow = {
|
|
|
31
31
|
uv: 4,
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
// Temperature, condition and chance of rain from 14:00 on: a dry afternoon that turns wet by
|
|
35
|
-
|
|
34
|
+
// Temperature, condition and chance of rain for a day from 14:00 on: a dry afternoon that turns wet by
|
|
35
|
+
// evening, clears overnight and comes up bright.
|
|
36
|
+
const DAY_AHEAD: [number, WeatherHour['condition'], number][] = [
|
|
36
37
|
[18.4, 'partly-cloudy', 5],
|
|
37
38
|
[19.1, 'partly-cloudy', 10],
|
|
38
39
|
[18.6, 'cloudy', 20],
|
|
@@ -41,15 +42,28 @@ const AFTERNOON: [number, WeatherHour['condition'], number][] = [
|
|
|
41
42
|
[14.9, 'rain', 80],
|
|
42
43
|
[14.1, 'drizzle', 40],
|
|
43
44
|
[13.5, 'cloudy', 20],
|
|
45
|
+
[13.0, 'cloudy', 15],
|
|
46
|
+
[12.6, 'partly-cloudy', 10],
|
|
47
|
+
[12.1, 'partly-cloudy', 5],
|
|
48
|
+
[11.7, 'clear', 0],
|
|
49
|
+
[11.4, 'clear', 0],
|
|
50
|
+
[11.0, 'clear', 0],
|
|
51
|
+
[10.6, 'clear', 0],
|
|
52
|
+
[10.3, 'clear', 0],
|
|
53
|
+
[10.1, 'partly-cloudy', 0],
|
|
54
|
+
[10.4, 'partly-cloudy', 5],
|
|
55
|
+
[11.6, 'partly-cloudy', 5],
|
|
56
|
+
[13.0, 'clear', 0],
|
|
57
|
+
[14.3, 'clear', 0],
|
|
58
|
+
[15.2, 'partly-cloudy', 5],
|
|
59
|
+
[15.9, 'partly-cloudy', 10],
|
|
60
|
+
[16.1, 'cloudy', 20],
|
|
44
61
|
]
|
|
45
62
|
|
|
46
|
-
export const HOURS: WeatherHour[] =
|
|
47
|
-
|
|
48
|
-
temperature,
|
|
49
|
-
|
|
50
|
-
isDay: 14 + i < 17,
|
|
51
|
-
precipitation,
|
|
52
|
-
}))
|
|
63
|
+
export const HOURS: WeatherHour[] = DAY_AHEAD.map(([temperature, condition, precipitation], i) => {
|
|
64
|
+
const hour = (14 + i) % 24
|
|
65
|
+
return { time: today(14) + i * HOUR, temperature, condition, isDay: hour >= 7 && hour < 17, precipitation }
|
|
66
|
+
})
|
|
53
67
|
|
|
54
68
|
/** A clear night: the same strip, read at 22:00. */
|
|
55
69
|
export const NIGHT: { current: WeatherNow; hours: WeatherHour[] } = {
|
|
@@ -63,11 +77,27 @@ export const NIGHT: { current: WeatherNow; hours: WeatherHour[] } = {
|
|
|
63
77
|
})),
|
|
64
78
|
}
|
|
65
79
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
80
|
+
// The week ahead, today first.
|
|
81
|
+
const WEEK: [WeatherDay['condition'], number, number, number][] = [
|
|
82
|
+
['rain', 19.6, 11.2, 80],
|
|
83
|
+
['drizzle', 16.1, 9.4, 40],
|
|
84
|
+
['partly-cloudy', 17.3, 8.1, 10],
|
|
85
|
+
['clear', 19.8, 7.6, 0],
|
|
86
|
+
['cloudy', 15.4, 9.9, 25],
|
|
87
|
+
['heavy-rain', 12.2, 8.4, 90],
|
|
88
|
+
['partly-cloudy', 14.6, 6.3, 15],
|
|
69
89
|
]
|
|
70
90
|
|
|
91
|
+
export const DAYS: WeatherDay[] = WEEK.map(([condition, high, low, precipitation], i) => ({
|
|
92
|
+
date: today(i * 24),
|
|
93
|
+
condition,
|
|
94
|
+
high,
|
|
95
|
+
low,
|
|
96
|
+
precipitation,
|
|
97
|
+
sunrise: today(i * 24 + 6, 58 + i),
|
|
98
|
+
sunset: today(i * 24 + 16, 12 - i),
|
|
99
|
+
}))
|
|
100
|
+
|
|
71
101
|
/** The forecast for `Weather`'s props. */
|
|
72
102
|
export const FORECAST = { location: WEATHER_LOCATION, current: CURRENT, hours: HOURS, days: DAYS, now: WEATHER_NOW }
|
|
73
103
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justanarthur/modo-ui-notch",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"description": "A macOS notch app kit on modo-ui: the island that grows out of the notch (idle, compact, split, expanded, flash), its tabs across the wings and the pieces its activities show. Documented with modo.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
widget_default
|
|
5
|
-
} from "./chunk-x7f3g82r.js";
|
|
6
|
-
|
|
7
|
-
// blocks/system/system-stats/index.tsx
|
|
8
|
-
import Sparkline from "@justanarthur/modo-ui/components/data-display/sparkline";
|
|
9
|
-
import Meter from "@justanarthur/modo-ui/components/feedback/meter";
|
|
10
|
-
import { cn } from "@justanarthur/modo-ui/lib/utils";
|
|
11
|
-
import {
|
|
12
|
-
Activity,
|
|
13
|
-
ArrowDown,
|
|
14
|
-
ArrowUp,
|
|
15
|
-
BatteryCharging,
|
|
16
|
-
BatteryFull,
|
|
17
|
-
BatteryLow,
|
|
18
|
-
BatteryMedium,
|
|
19
|
-
Cpu,
|
|
20
|
-
HardDrive,
|
|
21
|
-
MemoryStick
|
|
22
|
-
} from "lucide-react";
|
|
23
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
24
|
-
/*!
|
|
25
|
-
* Local addition: a notch app's system load, the busiest figure as the hero
|
|
26
|
-
* with its trend, the rest as facts and the busiest processes beside it.
|
|
27
|
-
* Rebuilt from Just Notch's stats plugin (`System`, `Tile`, `Measuring`,
|
|
28
|
-
* `CpuLoad`) on the kit's Widget frame and modo-ui's Sparkline and Meter:
|
|
29
|
-
* the readings come in as props.
|
|
30
|
-
*/
|
|
31
|
-
var ROWS = 3;
|
|
32
|
-
var percent = (v) => `${Math.round(v * 100)}%`;
|
|
33
|
-
var share = (v) => v < 0.1 ? `${(v * 100).toFixed(1)}%` : percent(v);
|
|
34
|
-
function bytes(n) {
|
|
35
|
-
if (n >= 100000000000)
|
|
36
|
-
return `${Math.round(n / 1e9)} GB`;
|
|
37
|
-
if (n >= 1e9)
|
|
38
|
-
return `${(n / 1e9).toFixed(1)} GB`;
|
|
39
|
-
return `${Math.round(n / 1e6)} MB`;
|
|
40
|
-
}
|
|
41
|
-
function rate(bps) {
|
|
42
|
-
if (bps >= 1e6)
|
|
43
|
-
return `${(bps / 1e6).toFixed(1)} MB/s`;
|
|
44
|
-
if (bps >= 1000)
|
|
45
|
-
return `${Math.round(bps / 1000)} KB/s`;
|
|
46
|
-
return `${Math.round(bps)} B/s`;
|
|
47
|
-
}
|
|
48
|
-
function span(seconds) {
|
|
49
|
-
const minutes = Math.floor(seconds / 60);
|
|
50
|
-
const hours = Math.floor(minutes / 60);
|
|
51
|
-
const days = Math.floor(hours / 24);
|
|
52
|
-
if (days)
|
|
53
|
-
return `${days} d ${hours % 24} h`;
|
|
54
|
-
if (hours)
|
|
55
|
-
return `${hours} h ${minutes % 60} min`;
|
|
56
|
-
return `${minutes} min`;
|
|
57
|
-
}
|
|
58
|
-
var clock = (minutes) => `${Math.floor(minutes / 60)}:${String(Math.round(minutes % 60)).padStart(2, "0")}`;
|
|
59
|
-
function toneOf(load) {
|
|
60
|
-
if (load >= 0.9)
|
|
61
|
-
return "error";
|
|
62
|
-
if (load >= 0.75)
|
|
63
|
-
return "warning";
|
|
64
|
-
return "current";
|
|
65
|
-
}
|
|
66
|
-
function verdict(load) {
|
|
67
|
-
if (load >= 0.9)
|
|
68
|
-
return "Under strain";
|
|
69
|
-
if (load >= 0.6)
|
|
70
|
-
return "Busy";
|
|
71
|
-
if (load >= 0.2)
|
|
72
|
-
return "Steady";
|
|
73
|
-
return "Idle";
|
|
74
|
-
}
|
|
75
|
-
var pressureOf = (sample) => sample.memoryPressure ?? sample.memoryUsed / sample.memoryTotal;
|
|
76
|
-
function batteryIcon({ level, charging }) {
|
|
77
|
-
if (charging)
|
|
78
|
-
return BatteryCharging;
|
|
79
|
-
if (level <= 20)
|
|
80
|
-
return BatteryLow;
|
|
81
|
-
if (level <= 70)
|
|
82
|
-
return BatteryMedium;
|
|
83
|
-
return BatteryFull;
|
|
84
|
-
}
|
|
85
|
-
function BatteryItem({ battery }) {
|
|
86
|
-
const left = battery.minutesLeft === undefined ? undefined : clock(battery.minutesLeft);
|
|
87
|
-
return /* @__PURE__ */ jsxs(widget_default.MetaItem, {
|
|
88
|
-
icon: batteryIcon(battery),
|
|
89
|
-
children: [
|
|
90
|
-
battery.level,
|
|
91
|
-
"%",
|
|
92
|
-
left && ` · ${left} ${battery.charging ? "to full" : "left"}`
|
|
93
|
-
]
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
function Facts({ last, hero, battery, disk }) {
|
|
97
|
-
const dash = "–";
|
|
98
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
99
|
-
className: "flex min-w-0 flex-col gap-1",
|
|
100
|
-
children: [
|
|
101
|
-
/* @__PURE__ */ jsxs(widget_default.Meta, {
|
|
102
|
-
children: [
|
|
103
|
-
hero === "cpu" ? /* @__PURE__ */ jsx(widget_default.MetaItem, {
|
|
104
|
-
icon: MemoryStick,
|
|
105
|
-
children: last ? `${bytes(last.memoryUsed)} of ${bytes(last.memoryTotal)}` : dash
|
|
106
|
-
}) : /* @__PURE__ */ jsx(widget_default.MetaItem, {
|
|
107
|
-
icon: Cpu,
|
|
108
|
-
children: last ? `${percent(last.cpu)} CPU` : dash
|
|
109
|
-
}),
|
|
110
|
-
/* @__PURE__ */ jsx(widget_default.MetaItem, {
|
|
111
|
-
icon: ArrowDown,
|
|
112
|
-
children: last ? rate(last.netIn) : dash
|
|
113
|
-
}),
|
|
114
|
-
/* @__PURE__ */ jsx(widget_default.MetaItem, {
|
|
115
|
-
icon: ArrowUp,
|
|
116
|
-
children: last ? rate(last.netOut) : dash
|
|
117
|
-
})
|
|
118
|
-
]
|
|
119
|
-
}),
|
|
120
|
-
(battery || disk) && /* @__PURE__ */ jsxs(widget_default.Meta, {
|
|
121
|
-
children: [
|
|
122
|
-
battery && /* @__PURE__ */ jsx(BatteryItem, {
|
|
123
|
-
battery
|
|
124
|
-
}),
|
|
125
|
-
disk && /* @__PURE__ */ jsxs(widget_default.MetaItem, {
|
|
126
|
-
icon: HardDrive,
|
|
127
|
-
children: [
|
|
128
|
-
bytes(disk.free),
|
|
129
|
-
" free"
|
|
130
|
-
]
|
|
131
|
-
})
|
|
132
|
-
]
|
|
133
|
-
})
|
|
134
|
-
]
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
function Processes({ processes }) {
|
|
138
|
-
const top = [...processes].sort((a, b) => b.cpu - a.cpu);
|
|
139
|
-
const more = top.length - ROWS;
|
|
140
|
-
return /* @__PURE__ */ jsxs(widget_default.Section, {
|
|
141
|
-
label: "Top processes",
|
|
142
|
-
trailing: /* @__PURE__ */ jsx("span", {
|
|
143
|
-
children: "CPU · memory"
|
|
144
|
-
}),
|
|
145
|
-
children: [
|
|
146
|
-
top.slice(0, ROWS).map((process) => /* @__PURE__ */ jsx(widget_default.Row, {
|
|
147
|
-
leading: share(process.cpu),
|
|
148
|
-
trailing: process.memory !== undefined && bytes(process.memory),
|
|
149
|
-
children: process.name
|
|
150
|
-
}, process.id)),
|
|
151
|
-
more > 0 && /* @__PURE__ */ jsxs("span", {
|
|
152
|
-
className: "flex h-6 items-center pl-17.5 text-caption text-muted-foreground",
|
|
153
|
-
children: [
|
|
154
|
-
more,
|
|
155
|
-
" more"
|
|
156
|
-
]
|
|
157
|
-
})
|
|
158
|
-
]
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
function SystemStatsLeading2() {
|
|
162
|
-
return /* @__PURE__ */ jsx(Cpu, {
|
|
163
|
-
size: 16,
|
|
164
|
-
strokeWidth: 1.5,
|
|
165
|
-
className: "text-muted-foreground"
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
function SystemStatsTrailing2({ sample }) {
|
|
169
|
-
if (!sample)
|
|
170
|
-
return /* @__PURE__ */ jsx("span", {
|
|
171
|
-
className: "text-caption weight-semibold text-muted-foreground",
|
|
172
|
-
children: "–"
|
|
173
|
-
});
|
|
174
|
-
return /* @__PURE__ */ jsx("span", {
|
|
175
|
-
className: "text-caption weight-semibold tabular-nums text-foreground",
|
|
176
|
-
children: percent(sample.cpu)
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
function SystemStatsMinimal2({ sample }) {
|
|
180
|
-
const load = sample?.cpu ?? 0;
|
|
181
|
-
return /* @__PURE__ */ jsx(Meter, {
|
|
182
|
-
variant: "ring",
|
|
183
|
-
className: "size-5.5",
|
|
184
|
-
size: "compact",
|
|
185
|
-
value: load,
|
|
186
|
-
label: sample ? `CPU, ${percent(load)}` : "CPU, measuring"
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
var SystemStats2 = Object.assign(function SystemStats({ samples, hero = "cpu", battery, disk, uptime, processes, size, className }) {
|
|
190
|
-
const last = samples.at(-1);
|
|
191
|
-
const series = hero === "cpu" ? samples.map((s) => s.cpu) : samples.map(pressureOf);
|
|
192
|
-
const load = last ? hero === "cpu" ? last.cpu : pressureOf(last) : 0;
|
|
193
|
-
const name = hero === "cpu" ? "CPU" : "Memory pressure";
|
|
194
|
-
const busiest = processes?.length ? processes.reduce((a, b) => b.cpu > a.cpu ? b : a).name : undefined;
|
|
195
|
-
return /* @__PURE__ */ jsxs(widget_default, {
|
|
196
|
-
size,
|
|
197
|
-
className: cn("h-full", className),
|
|
198
|
-
aside: processes?.length ? /* @__PURE__ */ jsx(Processes, {
|
|
199
|
-
processes
|
|
200
|
-
}) : undefined,
|
|
201
|
-
children: [
|
|
202
|
-
/* @__PURE__ */ jsx(widget_default.Header, {
|
|
203
|
-
icon: Activity,
|
|
204
|
-
children: uptime === undefined ? "System" : `System · up ${span(uptime)}`
|
|
205
|
-
}),
|
|
206
|
-
/* @__PURE__ */ jsxs("div", {
|
|
207
|
-
className: "flex min-w-0 items-end gap-4",
|
|
208
|
-
"aria-busy": !last,
|
|
209
|
-
children: [
|
|
210
|
-
/* @__PURE__ */ jsx(widget_default.Figure, {
|
|
211
|
-
value: last ? percent(load) : "–",
|
|
212
|
-
unit: hero === "cpu" ? "CPU" : "pressure",
|
|
213
|
-
className: "shrink-0"
|
|
214
|
-
}),
|
|
215
|
-
/* @__PURE__ */ jsx(Sparkline, {
|
|
216
|
-
values: series,
|
|
217
|
-
max: 1,
|
|
218
|
-
area: true,
|
|
219
|
-
tone: toneOf(load),
|
|
220
|
-
label: last ? `${name}, ${percent(load)}` : `${name}, measuring`,
|
|
221
|
-
className: cn("mb-1.5 h-9 min-w-0 flex-1", !last && "text-muted-foreground")
|
|
222
|
-
})
|
|
223
|
-
]
|
|
224
|
-
}),
|
|
225
|
-
/* @__PURE__ */ jsx(widget_default.Subtitle, {
|
|
226
|
-
className: "mb-1",
|
|
227
|
-
children: last ? [verdict(load), busiest && `${busiest} is busiest`].filter(Boolean).join(" · ") : "Measuring…"
|
|
228
|
-
}),
|
|
229
|
-
/* @__PURE__ */ jsx(Facts, {
|
|
230
|
-
last,
|
|
231
|
-
hero,
|
|
232
|
-
battery,
|
|
233
|
-
disk
|
|
234
|
-
})
|
|
235
|
-
]
|
|
236
|
-
});
|
|
237
|
-
}, {
|
|
238
|
-
Leading: SystemStatsLeading2,
|
|
239
|
-
Trailing: SystemStatsTrailing2,
|
|
240
|
-
Minimal: SystemStatsMinimal2
|
|
241
|
-
});
|
|
242
|
-
var system_stats_default = SystemStats2;
|
|
243
|
-
export { SystemStatsLeading2, SystemStatsTrailing2, SystemStatsMinimal2, SystemStats2, system_stats_default };
|