@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
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
widget_default
|
|
5
|
+
} from "./chunk-wf0jtzhs.js";
|
|
6
|
+
|
|
7
|
+
// blocks/system/system-stats/index.tsx
|
|
8
|
+
import Sparkline from "@justanarthur/modo-ui/components/data-display/sparkline";
|
|
9
|
+
import Table from "@justanarthur/modo-ui/components/data-display/table";
|
|
10
|
+
import Meter from "@justanarthur/modo-ui/components/feedback/meter";
|
|
11
|
+
import { cn } from "@justanarthur/modo-ui/lib/utils";
|
|
12
|
+
import {
|
|
13
|
+
Activity,
|
|
14
|
+
ArrowDown,
|
|
15
|
+
ArrowUp,
|
|
16
|
+
BatteryCharging,
|
|
17
|
+
BatteryFull,
|
|
18
|
+
BatteryLow,
|
|
19
|
+
BatteryMedium,
|
|
20
|
+
Cpu,
|
|
21
|
+
HardDrive,
|
|
22
|
+
MemoryStick,
|
|
23
|
+
Network
|
|
24
|
+
} from "lucide-react";
|
|
25
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
26
|
+
/*!
|
|
27
|
+
* Local addition: a notch app's system load, the busiest figure as the hero
|
|
28
|
+
* with its trend, the rest as facts and the busiest processes beside it.
|
|
29
|
+
* Rebuilt from Just Notch's stats plugin (`System`, `Tile`, `Measuring`,
|
|
30
|
+
* `CpuLoad`) on the kit's Widget frame and modo-ui's Sparkline and Meter:
|
|
31
|
+
* the readings come in as props.
|
|
32
|
+
*/
|
|
33
|
+
var ROWS = 3;
|
|
34
|
+
var SHEET_ROWS = 8;
|
|
35
|
+
var percent = (v) => `${Math.round(v * 100)}%`;
|
|
36
|
+
var share = (v) => v < 0.1 ? `${(v * 100).toFixed(1)}%` : percent(v);
|
|
37
|
+
function bytes(n) {
|
|
38
|
+
if (n >= 100000000000)
|
|
39
|
+
return `${Math.round(n / 1e9)} GB`;
|
|
40
|
+
if (n >= 1e9)
|
|
41
|
+
return `${(n / 1e9).toFixed(1)} GB`;
|
|
42
|
+
return `${Math.round(n / 1e6)} MB`;
|
|
43
|
+
}
|
|
44
|
+
function rate(bps) {
|
|
45
|
+
if (bps >= 1e6)
|
|
46
|
+
return `${(bps / 1e6).toFixed(1)} MB/s`;
|
|
47
|
+
if (bps >= 1000)
|
|
48
|
+
return `${Math.round(bps / 1000)} KB/s`;
|
|
49
|
+
return `${Math.round(bps)} B/s`;
|
|
50
|
+
}
|
|
51
|
+
function span(seconds) {
|
|
52
|
+
const minutes = Math.floor(seconds / 60);
|
|
53
|
+
const hours = Math.floor(minutes / 60);
|
|
54
|
+
const days = Math.floor(hours / 24);
|
|
55
|
+
if (days)
|
|
56
|
+
return `${days} d ${hours % 24} h`;
|
|
57
|
+
if (hours)
|
|
58
|
+
return `${hours} h ${minutes % 60} min`;
|
|
59
|
+
return `${minutes} min`;
|
|
60
|
+
}
|
|
61
|
+
var clock = (minutes) => `${Math.floor(minutes / 60)}:${String(Math.round(minutes % 60)).padStart(2, "0")}`;
|
|
62
|
+
function toneOf(load) {
|
|
63
|
+
if (load >= 0.9)
|
|
64
|
+
return "error";
|
|
65
|
+
if (load >= 0.75)
|
|
66
|
+
return "warning";
|
|
67
|
+
return "current";
|
|
68
|
+
}
|
|
69
|
+
function verdict(load) {
|
|
70
|
+
if (load >= 0.9)
|
|
71
|
+
return "Under strain";
|
|
72
|
+
if (load >= 0.6)
|
|
73
|
+
return "Busy";
|
|
74
|
+
if (load >= 0.2)
|
|
75
|
+
return "Steady";
|
|
76
|
+
return "Idle";
|
|
77
|
+
}
|
|
78
|
+
var pressureOf = (sample) => sample.memoryPressure ?? sample.memoryUsed / sample.memoryTotal;
|
|
79
|
+
function batteryIcon({ level, charging }) {
|
|
80
|
+
if (charging)
|
|
81
|
+
return BatteryCharging;
|
|
82
|
+
if (level <= 20)
|
|
83
|
+
return BatteryLow;
|
|
84
|
+
if (level <= 70)
|
|
85
|
+
return BatteryMedium;
|
|
86
|
+
return BatteryFull;
|
|
87
|
+
}
|
|
88
|
+
function BatteryItem({ battery }) {
|
|
89
|
+
const left = battery.minutesLeft === undefined ? undefined : clock(battery.minutesLeft);
|
|
90
|
+
return /* @__PURE__ */ jsxs(widget_default.MetaItem, {
|
|
91
|
+
icon: batteryIcon(battery),
|
|
92
|
+
children: [
|
|
93
|
+
battery.level,
|
|
94
|
+
"%",
|
|
95
|
+
left && ` · ${left} ${battery.charging ? "to full" : "left"}`
|
|
96
|
+
]
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function Facts({ last, hero, battery, disk }) {
|
|
100
|
+
const dash = "–";
|
|
101
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
102
|
+
className: "flex min-w-0 flex-col gap-1",
|
|
103
|
+
children: [
|
|
104
|
+
/* @__PURE__ */ jsxs(widget_default.Meta, {
|
|
105
|
+
children: [
|
|
106
|
+
hero === "cpu" ? /* @__PURE__ */ jsx(widget_default.MetaItem, {
|
|
107
|
+
icon: MemoryStick,
|
|
108
|
+
children: last ? `${bytes(last.memoryUsed)} of ${bytes(last.memoryTotal)}` : dash
|
|
109
|
+
}) : /* @__PURE__ */ jsx(widget_default.MetaItem, {
|
|
110
|
+
icon: Cpu,
|
|
111
|
+
children: last ? `${percent(last.cpu)} CPU` : dash
|
|
112
|
+
}),
|
|
113
|
+
/* @__PURE__ */ jsx(widget_default.MetaItem, {
|
|
114
|
+
icon: ArrowDown,
|
|
115
|
+
children: last ? rate(last.netIn) : dash
|
|
116
|
+
}),
|
|
117
|
+
/* @__PURE__ */ jsx(widget_default.MetaItem, {
|
|
118
|
+
icon: ArrowUp,
|
|
119
|
+
children: last ? rate(last.netOut) : dash
|
|
120
|
+
})
|
|
121
|
+
]
|
|
122
|
+
}),
|
|
123
|
+
(battery || disk) && /* @__PURE__ */ jsxs(widget_default.Meta, {
|
|
124
|
+
children: [
|
|
125
|
+
battery && /* @__PURE__ */ jsx(BatteryItem, {
|
|
126
|
+
battery
|
|
127
|
+
}),
|
|
128
|
+
disk && /* @__PURE__ */ jsxs(widget_default.MetaItem, {
|
|
129
|
+
icon: HardDrive,
|
|
130
|
+
children: [
|
|
131
|
+
bytes(disk.free),
|
|
132
|
+
" free"
|
|
133
|
+
]
|
|
134
|
+
})
|
|
135
|
+
]
|
|
136
|
+
})
|
|
137
|
+
]
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function Processes({ processes }) {
|
|
141
|
+
const top = [...processes].sort((a, b) => b.cpu - a.cpu);
|
|
142
|
+
const more = top.length - ROWS;
|
|
143
|
+
return /* @__PURE__ */ jsxs(widget_default.Section, {
|
|
144
|
+
label: "Top processes",
|
|
145
|
+
trailing: /* @__PURE__ */ jsx("span", {
|
|
146
|
+
children: "CPU · memory"
|
|
147
|
+
}),
|
|
148
|
+
children: [
|
|
149
|
+
top.slice(0, ROWS).map((process) => /* @__PURE__ */ jsx(widget_default.Row, {
|
|
150
|
+
leading: share(process.cpu),
|
|
151
|
+
trailing: process.memory !== undefined && bytes(process.memory),
|
|
152
|
+
children: process.name
|
|
153
|
+
}, process.id)),
|
|
154
|
+
more > 0 && /* @__PURE__ */ jsxs("span", {
|
|
155
|
+
className: "flex h-6 items-center pl-17.5 text-caption text-muted-foreground",
|
|
156
|
+
children: [
|
|
157
|
+
more,
|
|
158
|
+
" more"
|
|
159
|
+
]
|
|
160
|
+
})
|
|
161
|
+
]
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
function Trend({ label, icon: Icon, value, unit, series, caption, className }) {
|
|
165
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
166
|
+
className: cn("flex min-w-0 flex-col gap-1", className),
|
|
167
|
+
"aria-busy": value === undefined,
|
|
168
|
+
children: [
|
|
169
|
+
/* @__PURE__ */ jsx(widget_default.Header, {
|
|
170
|
+
icon: Icon,
|
|
171
|
+
children: label
|
|
172
|
+
}),
|
|
173
|
+
/* @__PURE__ */ jsx(widget_default.Figure, {
|
|
174
|
+
value: value === undefined ? "–" : percent(value),
|
|
175
|
+
unit
|
|
176
|
+
}),
|
|
177
|
+
/* @__PURE__ */ jsx(Sparkline, {
|
|
178
|
+
values: series,
|
|
179
|
+
max: 1,
|
|
180
|
+
area: true,
|
|
181
|
+
tone: toneOf(value ?? 0),
|
|
182
|
+
label: value === undefined ? `${label}, measuring` : `${label}, ${percent(value)}`,
|
|
183
|
+
className: cn("my-1 h-14 w-full", value === undefined && "text-muted-foreground")
|
|
184
|
+
}),
|
|
185
|
+
/* @__PURE__ */ jsx(widget_default.Subtitle, {
|
|
186
|
+
children: caption
|
|
187
|
+
})
|
|
188
|
+
]
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
function batteryTone({ level, charging }) {
|
|
192
|
+
if (charging)
|
|
193
|
+
return "default";
|
|
194
|
+
if (level <= 10)
|
|
195
|
+
return "error";
|
|
196
|
+
if (level <= 20)
|
|
197
|
+
return "warning";
|
|
198
|
+
return "default";
|
|
199
|
+
}
|
|
200
|
+
function ProcessTable({ processes }) {
|
|
201
|
+
const top = [...processes].sort((a, b) => b.cpu - a.cpu).slice(0, SHEET_ROWS);
|
|
202
|
+
const head = "text-caption weight-normal text-muted-foreground";
|
|
203
|
+
return /* @__PURE__ */ jsx(widget_default.Section, {
|
|
204
|
+
label: "Top processes",
|
|
205
|
+
trailing: /* @__PURE__ */ jsx("span", {
|
|
206
|
+
children: "by CPU"
|
|
207
|
+
}),
|
|
208
|
+
children: /* @__PURE__ */ jsxs(Table, {
|
|
209
|
+
children: [
|
|
210
|
+
/* @__PURE__ */ jsx(Table.Header, {
|
|
211
|
+
children: /* @__PURE__ */ jsxs(Table.Row, {
|
|
212
|
+
children: [
|
|
213
|
+
/* @__PURE__ */ jsx(Table.Head, {
|
|
214
|
+
className: head,
|
|
215
|
+
children: "Name"
|
|
216
|
+
}),
|
|
217
|
+
/* @__PURE__ */ jsx(Table.Head, {
|
|
218
|
+
className: cn(head, "text-right"),
|
|
219
|
+
children: "CPU"
|
|
220
|
+
}),
|
|
221
|
+
/* @__PURE__ */ jsx(Table.Head, {
|
|
222
|
+
className: cn(head, "w-24 text-right"),
|
|
223
|
+
children: "Memory"
|
|
224
|
+
})
|
|
225
|
+
]
|
|
226
|
+
})
|
|
227
|
+
}),
|
|
228
|
+
/* @__PURE__ */ jsx(Table.Body, {
|
|
229
|
+
children: top.map((process) => /* @__PURE__ */ jsxs(Table.Row, {
|
|
230
|
+
children: [
|
|
231
|
+
/* @__PURE__ */ jsx(Table.Cell, {
|
|
232
|
+
className: "text-foreground",
|
|
233
|
+
children: process.name
|
|
234
|
+
}),
|
|
235
|
+
/* @__PURE__ */ jsx(Table.Cell, {
|
|
236
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
237
|
+
className: "flex items-center justify-end gap-3",
|
|
238
|
+
children: [
|
|
239
|
+
/* @__PURE__ */ jsx(Meter, {
|
|
240
|
+
variant: "line",
|
|
241
|
+
value: process.cpu,
|
|
242
|
+
label: `${process.name}, CPU`,
|
|
243
|
+
className: "w-24"
|
|
244
|
+
}),
|
|
245
|
+
/* @__PURE__ */ jsx("span", {
|
|
246
|
+
className: "w-12 text-right tabular-nums",
|
|
247
|
+
children: share(process.cpu)
|
|
248
|
+
})
|
|
249
|
+
]
|
|
250
|
+
})
|
|
251
|
+
}),
|
|
252
|
+
/* @__PURE__ */ jsx(Table.Cell, {
|
|
253
|
+
className: "text-right tabular-nums",
|
|
254
|
+
children: process.memory === undefined ? "–" : bytes(process.memory)
|
|
255
|
+
})
|
|
256
|
+
]
|
|
257
|
+
}, process.id))
|
|
258
|
+
})
|
|
259
|
+
]
|
|
260
|
+
})
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
function Sheet({ samples, hero, battery, disk, uptime, processes, size, className }) {
|
|
264
|
+
const last = samples.at(-1);
|
|
265
|
+
const busiest = processes?.length ? processes.reduce((a, b) => b.cpu > a.cpu ? b : a).name : undefined;
|
|
266
|
+
const cpu = /* @__PURE__ */ jsx(Trend, {
|
|
267
|
+
label: "CPU",
|
|
268
|
+
icon: Cpu,
|
|
269
|
+
value: last?.cpu,
|
|
270
|
+
unit: "load",
|
|
271
|
+
series: samples.map((s) => s.cpu),
|
|
272
|
+
caption: last ? [verdict(last.cpu), busiest && `${busiest} is busiest`].filter(Boolean).join(" · ") : "Measuring…"
|
|
273
|
+
}, "cpu");
|
|
274
|
+
const memory = /* @__PURE__ */ jsx(Trend, {
|
|
275
|
+
label: "Memory",
|
|
276
|
+
icon: MemoryStick,
|
|
277
|
+
value: last && pressureOf(last),
|
|
278
|
+
unit: "pressure",
|
|
279
|
+
series: samples.map(pressureOf),
|
|
280
|
+
caption: last ? `${bytes(last.memoryUsed)} of ${bytes(last.memoryTotal)} in use` : "Measuring…"
|
|
281
|
+
}, "memory");
|
|
282
|
+
const [first, second] = hero === "cpu" ? [cpu, memory] : [memory, cpu];
|
|
283
|
+
const left = battery?.minutesLeft === undefined ? undefined : clock(battery.minutesLeft);
|
|
284
|
+
return /* @__PURE__ */ jsxs(widget_default.Sheet, {
|
|
285
|
+
size,
|
|
286
|
+
className,
|
|
287
|
+
children: [
|
|
288
|
+
/* @__PURE__ */ jsxs("div", {
|
|
289
|
+
className: "flex min-w-0 flex-col gap-2",
|
|
290
|
+
children: [
|
|
291
|
+
/* @__PURE__ */ jsx(widget_default.Header, {
|
|
292
|
+
icon: Activity,
|
|
293
|
+
children: uptime === undefined ? "System" : `System · up ${span(uptime)}`
|
|
294
|
+
}),
|
|
295
|
+
/* @__PURE__ */ jsxs("div", {
|
|
296
|
+
className: "grid grid-cols-2 divide-x divide-border [&>*]:px-6 [&>*:first-child]:pl-0 [&>*:last-child]:pr-0",
|
|
297
|
+
children: [
|
|
298
|
+
first,
|
|
299
|
+
second
|
|
300
|
+
]
|
|
301
|
+
})
|
|
302
|
+
]
|
|
303
|
+
}),
|
|
304
|
+
/* @__PURE__ */ jsxs("div", {
|
|
305
|
+
className: "grid auto-cols-fr grid-flow-col divide-x divide-border [&>*]:px-6 [&>*:first-child]:pl-0 [&>*:last-child]:pr-0",
|
|
306
|
+
children: [
|
|
307
|
+
/* @__PURE__ */ jsxs("div", {
|
|
308
|
+
className: "flex min-w-0 flex-col gap-1",
|
|
309
|
+
"aria-busy": !last,
|
|
310
|
+
children: [
|
|
311
|
+
/* @__PURE__ */ jsx(widget_default.Header, {
|
|
312
|
+
icon: Network,
|
|
313
|
+
children: "Network"
|
|
314
|
+
}),
|
|
315
|
+
/* @__PURE__ */ jsxs("div", {
|
|
316
|
+
className: "flex min-w-0 items-baseline gap-5",
|
|
317
|
+
children: [
|
|
318
|
+
/* @__PURE__ */ jsxs("span", {
|
|
319
|
+
className: "flex items-center gap-1.5 whitespace-nowrap text-title weight-semibold tabular-nums text-foreground",
|
|
320
|
+
children: [
|
|
321
|
+
/* @__PURE__ */ jsx(ArrowDown, {
|
|
322
|
+
size: 16,
|
|
323
|
+
strokeWidth: 1.5,
|
|
324
|
+
"aria-label": "In",
|
|
325
|
+
className: "text-muted-foreground"
|
|
326
|
+
}),
|
|
327
|
+
last ? rate(last.netIn) : "–"
|
|
328
|
+
]
|
|
329
|
+
}),
|
|
330
|
+
/* @__PURE__ */ jsxs("span", {
|
|
331
|
+
className: "flex items-center gap-1.5 whitespace-nowrap text-title weight-semibold tabular-nums text-muted-foreground",
|
|
332
|
+
children: [
|
|
333
|
+
/* @__PURE__ */ jsx(ArrowUp, {
|
|
334
|
+
size: 16,
|
|
335
|
+
strokeWidth: 1.5,
|
|
336
|
+
"aria-label": "Out"
|
|
337
|
+
}),
|
|
338
|
+
last ? rate(last.netOut) : "–"
|
|
339
|
+
]
|
|
340
|
+
})
|
|
341
|
+
]
|
|
342
|
+
}),
|
|
343
|
+
/* @__PURE__ */ jsx(Sparkline, {
|
|
344
|
+
values: samples.map((s) => s.netIn),
|
|
345
|
+
secondary: samples.map((s) => s.netOut),
|
|
346
|
+
area: true,
|
|
347
|
+
label: last ? `Network, ${rate(last.netIn)} in, ${rate(last.netOut)} out` : "Network, measuring",
|
|
348
|
+
className: cn("my-1 h-12 w-full", !last && "text-muted-foreground")
|
|
349
|
+
})
|
|
350
|
+
]
|
|
351
|
+
}),
|
|
352
|
+
(battery || disk) && /* @__PURE__ */ jsxs("div", {
|
|
353
|
+
className: "flex min-w-0 flex-col justify-center gap-4",
|
|
354
|
+
children: [
|
|
355
|
+
battery && /* @__PURE__ */ jsx(Meter, {
|
|
356
|
+
label: battery.charging ? "Battery, charging" : "Battery",
|
|
357
|
+
value: battery.level,
|
|
358
|
+
max: 100,
|
|
359
|
+
tone: batteryTone(battery),
|
|
360
|
+
detail: `${battery.level}%${left ? ` · ${left} ${battery.charging ? "to full" : "left"}` : ""}`
|
|
361
|
+
}),
|
|
362
|
+
disk && /* @__PURE__ */ jsx(Meter, {
|
|
363
|
+
label: "Startup disk",
|
|
364
|
+
value: disk.total - disk.free,
|
|
365
|
+
max: disk.total,
|
|
366
|
+
detail: `${bytes(disk.free)} free of ${bytes(disk.total)}`
|
|
367
|
+
})
|
|
368
|
+
]
|
|
369
|
+
})
|
|
370
|
+
]
|
|
371
|
+
}),
|
|
372
|
+
processes?.length ? /* @__PURE__ */ jsx(ProcessTable, {
|
|
373
|
+
processes
|
|
374
|
+
}) : null
|
|
375
|
+
]
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
function SystemStatsLeading2() {
|
|
379
|
+
return /* @__PURE__ */ jsx(Cpu, {
|
|
380
|
+
size: 16,
|
|
381
|
+
strokeWidth: 1.5,
|
|
382
|
+
className: "text-muted-foreground"
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
function SystemStatsTrailing2({ sample }) {
|
|
386
|
+
if (!sample)
|
|
387
|
+
return /* @__PURE__ */ jsx("span", {
|
|
388
|
+
className: "text-caption weight-semibold text-muted-foreground",
|
|
389
|
+
children: "–"
|
|
390
|
+
});
|
|
391
|
+
return /* @__PURE__ */ jsx("span", {
|
|
392
|
+
className: "text-caption weight-semibold tabular-nums text-foreground",
|
|
393
|
+
children: percent(sample.cpu)
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
function SystemStatsMinimal2({ sample }) {
|
|
397
|
+
const load = sample?.cpu ?? 0;
|
|
398
|
+
return /* @__PURE__ */ jsx(Meter, {
|
|
399
|
+
variant: "ring",
|
|
400
|
+
className: "size-5.5",
|
|
401
|
+
size: "compact",
|
|
402
|
+
value: load,
|
|
403
|
+
label: sample ? `CPU, ${percent(load)}` : "CPU, measuring"
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
var SystemStats2 = Object.assign(function SystemStats({
|
|
407
|
+
samples,
|
|
408
|
+
hero = "cpu",
|
|
409
|
+
battery,
|
|
410
|
+
disk,
|
|
411
|
+
uptime,
|
|
412
|
+
processes,
|
|
413
|
+
size,
|
|
414
|
+
layout = "fit",
|
|
415
|
+
className
|
|
416
|
+
}) {
|
|
417
|
+
if (layout === "tall")
|
|
418
|
+
return /* @__PURE__ */ jsx(Sheet, {
|
|
419
|
+
size,
|
|
420
|
+
samples,
|
|
421
|
+
hero,
|
|
422
|
+
battery,
|
|
423
|
+
disk,
|
|
424
|
+
uptime,
|
|
425
|
+
processes,
|
|
426
|
+
className
|
|
427
|
+
});
|
|
428
|
+
const last = samples.at(-1);
|
|
429
|
+
const series = hero === "cpu" ? samples.map((s) => s.cpu) : samples.map(pressureOf);
|
|
430
|
+
const load = last ? hero === "cpu" ? last.cpu : pressureOf(last) : 0;
|
|
431
|
+
const name = hero === "cpu" ? "CPU" : "Memory pressure";
|
|
432
|
+
const busiest = processes?.length ? processes.reduce((a, b) => b.cpu > a.cpu ? b : a).name : undefined;
|
|
433
|
+
return /* @__PURE__ */ jsxs(widget_default, {
|
|
434
|
+
size,
|
|
435
|
+
className: cn("h-full", className),
|
|
436
|
+
aside: processes?.length ? /* @__PURE__ */ jsx(Processes, {
|
|
437
|
+
processes
|
|
438
|
+
}) : undefined,
|
|
439
|
+
children: [
|
|
440
|
+
/* @__PURE__ */ jsx(widget_default.Header, {
|
|
441
|
+
icon: Activity,
|
|
442
|
+
children: uptime === undefined ? "System" : `System · up ${span(uptime)}`
|
|
443
|
+
}),
|
|
444
|
+
/* @__PURE__ */ jsxs("div", {
|
|
445
|
+
className: "flex min-w-0 items-end gap-4",
|
|
446
|
+
"aria-busy": !last,
|
|
447
|
+
children: [
|
|
448
|
+
/* @__PURE__ */ jsx(widget_default.Figure, {
|
|
449
|
+
value: last ? percent(load) : "–",
|
|
450
|
+
unit: hero === "cpu" ? "CPU" : "pressure",
|
|
451
|
+
className: "shrink-0"
|
|
452
|
+
}),
|
|
453
|
+
/* @__PURE__ */ jsx(Sparkline, {
|
|
454
|
+
values: series,
|
|
455
|
+
max: 1,
|
|
456
|
+
area: true,
|
|
457
|
+
tone: toneOf(load),
|
|
458
|
+
label: last ? `${name}, ${percent(load)}` : `${name}, measuring`,
|
|
459
|
+
className: cn("mb-1.5 h-9 min-w-0 flex-1", !last && "text-muted-foreground")
|
|
460
|
+
})
|
|
461
|
+
]
|
|
462
|
+
}),
|
|
463
|
+
/* @__PURE__ */ jsx(widget_default.Subtitle, {
|
|
464
|
+
className: "mb-1",
|
|
465
|
+
children: last ? [verdict(load), busiest && `${busiest} is busiest`].filter(Boolean).join(" · ") : "Measuring…"
|
|
466
|
+
}),
|
|
467
|
+
/* @__PURE__ */ jsx(Facts, {
|
|
468
|
+
last,
|
|
469
|
+
hero,
|
|
470
|
+
battery,
|
|
471
|
+
disk
|
|
472
|
+
})
|
|
473
|
+
]
|
|
474
|
+
});
|
|
475
|
+
}, {
|
|
476
|
+
Leading: SystemStatsLeading2,
|
|
477
|
+
Trailing: SystemStatsTrailing2,
|
|
478
|
+
Minimal: SystemStatsMinimal2
|
|
479
|
+
});
|
|
480
|
+
var system_stats_default = SystemStats2;
|
|
481
|
+
export { SystemStatsLeading2, SystemStatsTrailing2, SystemStatsMinimal2, SystemStats2, system_stats_default };
|
|
@@ -126,6 +126,22 @@ interface WidgetChipProps2 {
|
|
|
126
126
|
}
|
|
127
127
|
/** A small label on a wash one surface up: an all-day event, a state. */
|
|
128
128
|
declare function WidgetChip2({ color, children }: WidgetChipProps2): Element_12xgc;
|
|
129
|
+
type WidgetLayout2 = "fit" | "tall";
|
|
130
|
+
interface WidgetSheetProps2 {
|
|
131
|
+
/** The bands, top to bottom: the hero first, then the lists and details. */
|
|
132
|
+
children: ReactNode;
|
|
133
|
+
/** Step on the size ladder for every part inside. Omitted, the widget follows the surrounding SizeProvider. */
|
|
134
|
+
size?: SizeVariant;
|
|
135
|
+
/** Classes for the column. */
|
|
136
|
+
className?: string;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* The frame of a widget at the open island's tall snap (a sheet about
|
|
140
|
+
* 692 × 476): bands stacked top to bottom, the hero first, set larger, then
|
|
141
|
+
* the lists and details the short island has no room for. Bands sit apart
|
|
142
|
+
* on space alone; a band of columns splits them with hairlines.
|
|
143
|
+
*/
|
|
144
|
+
declare function WidgetSheet2({ children, size, className }: WidgetSheetProps2): Element_12xgc;
|
|
129
145
|
interface WidgetProps2 {
|
|
130
146
|
/** The hero's picture at the start, as tall as the widget: artwork, a ring. */
|
|
131
147
|
media?: ReactNode;
|
|
@@ -154,6 +170,11 @@ interface WidgetProps2 {
|
|
|
154
170
|
* Empty and permission states are a `Widget.Message`, laid out across the
|
|
155
171
|
* wide, short island.
|
|
156
172
|
*
|
|
173
|
+
* At the island's tall snap a widget shows more, not the same layout
|
|
174
|
+
* stretched: each block takes `layout="tall"` and builds a `Widget.Sheet`,
|
|
175
|
+
* bands of fuller lists, larger pictures and the details the short island
|
|
176
|
+
* leaves out.
|
|
177
|
+
*
|
|
157
178
|
* The frame fills the island's content area. The aside folds away under
|
|
158
179
|
* 30rem of width, so a narrower panel keeps the hero.
|
|
159
180
|
*
|
|
@@ -171,5 +192,6 @@ declare const Widget2: (({ media, aside, children, size, className }: WidgetProp
|
|
|
171
192
|
Section: typeof WidgetSection2;
|
|
172
193
|
Row: typeof WidgetRow2;
|
|
173
194
|
Chip: typeof WidgetChip2;
|
|
195
|
+
Sheet: typeof WidgetSheet2;
|
|
174
196
|
};
|
|
175
|
-
export { WidgetHeaderProps2, WidgetHeader2, WidgetTitleProps2, WidgetTitle2, WidgetSubtitle2, WidgetFigureProps2, WidgetFigure2, WidgetMetaItemProps2, WidgetMetaItem2, WidgetMeta2, WidgetActionProps2, WidgetAction2, WidgetMessageProps2, WidgetMessage2, WidgetSectionProps2, WidgetSection2, WidgetRowProps2, WidgetRow2, WidgetChipProps2, WidgetChip2, WidgetProps2, Widget2 };
|
|
197
|
+
export { WidgetHeaderProps2, WidgetHeader2, WidgetTitleProps2, WidgetTitle2, WidgetSubtitle2, WidgetFigureProps2, WidgetFigure2, WidgetMetaItemProps2, WidgetMetaItem2, WidgetMeta2, WidgetActionProps2, WidgetAction2, WidgetMessageProps2, WidgetMessage2, WidgetSectionProps2, WidgetSection2, WidgetRowProps2, WidgetRow2, WidgetChipProps2, WidgetChip2, WidgetLayout2, WidgetSheetProps2, WidgetSheet2, WidgetProps2, Widget2 };
|
|
@@ -42,6 +42,8 @@ type Element_12xgc = JSX_1kxb["Element"];
|
|
|
42
42
|
* at 720 × 240): build each one on the kit's Widget frame, so every tab has
|
|
43
43
|
* one hero set large, a muted line, its facts and quiet actions in the same
|
|
44
44
|
* places.
|
|
45
|
+
* Pulled down to a 560 px sheet the area is about 692 × 476: pass each
|
|
46
|
+
* block `layout="tall"` there, for its fuller view.
|
|
45
47
|
*
|
|
46
48
|
* Pass it as the Island's `expanded`; it reads the notch from the Island.
|
|
47
49
|
* Selection runs through `value` / `onValueChange`, or is kept here from
|