@justanarthur/modo-ui-notch 0.3.0 → 0.4.1
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 +38 -4
- 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-7fvnrtz4.d.ts → chunk-1v35ck2y.d.ts} +12 -2
- package/dist/shared/{chunk-wkg17nxs.d.ts → chunk-2bqmmfg9.d.ts} +13 -2
- package/dist/shared/{chunk-mt0k6v8x.js → chunk-2nxwdn5s.js} +147 -39
- package/dist/shared/{chunk-pfhy5e4q.d.ts → chunk-6tnq6p89.d.ts} +2 -0
- package/dist/shared/{chunk-bvtyjcce.d.ts → chunk-72s4sqwh.d.ts} +16 -1
- package/dist/shared/{chunk-t0hcxh89.d.ts → chunk-9b8b7fw6.d.ts} +12 -0
- package/dist/shared/{chunk-xq5hc5gv.js → chunk-a059ccj0.js} +177 -66
- package/dist/shared/{chunk-qdzemt2v.js → chunk-cry81asr.js} +401 -89
- package/dist/shared/{chunk-da177e8r.d.ts → chunk-fr9jf804.d.ts} +16 -1
- package/dist/shared/{chunk-9c7ewvkk.js → chunk-kbk4bp6p.js} +162 -19
- package/dist/shared/{chunk-3thgcfcq.d.ts → chunk-kv0w8vhq.d.ts} +18 -1
- package/dist/shared/{chunk-416tsgbc.d.ts → chunk-nqjermbr.d.ts} +25 -3
- package/dist/shared/chunk-p3nezxvx.js +481 -0
- package/dist/shared/{chunk-2818esrq.d.ts → chunk-sen170mz.d.ts} +10 -1
- package/dist/shared/{chunk-9m0xbg5v.js → chunk-wayv5rhr.js} +1 -1
- package/dist/shared/{chunk-ym0xbses.js → chunk-ygnrrqta.js} +274 -18
- package/dist/shared/{chunk-j77cx8dp.js → chunk-yw478nmj.js} +325 -58
- package/dist/shared/{chunk-cc9nwbtf.js → chunk-z3tj1ydg.js} +3 -0
- package/dist/shared/{chunk-x7f3g82r.js → chunk-zxsw11dr.js} +14 -4
- package/dist/styles.css +61 -1
- 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 +2 -2
- package/dist/shared/chunk-s2jeqqan.js +0 -243
|
@@ -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 };
|