@snap-rail/ui 0.0.0-stage → 0.1.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.
Files changed (60) hide show
  1. package/LICENSE +202 -0
  2. package/lib/charts.js +142 -0
  3. package/lib/contract.js +543 -0
  4. package/lib/fallback.js +400 -0
  5. package/lib/index.js +3345 -0
  6. package/lib/pages.js +68 -0
  7. package/lib/runtime.js +2064 -0
  8. package/lib/settings.js +1195 -0
  9. package/lib/skins.js +284 -0
  10. package/lib/slots.js +267 -0
  11. package/lib/types/charts.d.ts +62 -0
  12. package/lib/types/charts.js +41 -0
  13. package/lib/types/components/button.d.ts +39 -0
  14. package/lib/types/components/button.js +27 -0
  15. package/lib/types/components/controls.d.ts +66 -0
  16. package/lib/types/components/controls.js +66 -0
  17. package/lib/types/components/dialog.d.ts +58 -0
  18. package/lib/types/components/dialog.js +46 -0
  19. package/lib/types/components/feedback.d.ts +46 -0
  20. package/lib/types/components/feedback.js +20 -0
  21. package/lib/types/components/form.d.ts +31 -0
  22. package/lib/types/components/form.js +13 -0
  23. package/lib/types/components/index.d.ts +15 -0
  24. package/lib/types/components/index.js +15 -0
  25. package/lib/types/components/input.d.ts +37 -0
  26. package/lib/types/components/input.js +15 -0
  27. package/lib/types/components/layout.d.ts +100 -0
  28. package/lib/types/components/layout.js +80 -0
  29. package/lib/types/components/schema-form.d.ts +34 -0
  30. package/lib/types/components/schema-form.js +61 -0
  31. package/lib/types/components/surface.d.ts +49 -0
  32. package/lib/types/components/surface.js +59 -0
  33. package/lib/types/contract.d.ts +358 -0
  34. package/lib/types/contract.js +235 -0
  35. package/lib/types/fallback.d.ts +14 -0
  36. package/lib/types/fallback.js +50 -0
  37. package/lib/types/index.d.ts +19 -0
  38. package/lib/types/index.js +19 -0
  39. package/lib/types/pages.d.ts +40 -0
  40. package/lib/types/pages.js +69 -0
  41. package/lib/types/runtime.d.ts +71 -0
  42. package/lib/types/runtime.js +177 -0
  43. package/lib/types/settings-pages/appearance.d.ts +13 -0
  44. package/lib/types/settings-pages/appearance.js +131 -0
  45. package/lib/types/settings-pages/index.d.ts +3 -0
  46. package/lib/types/settings-pages/index.js +3 -0
  47. package/lib/types/settings-pages/plugins.d.ts +16 -0
  48. package/lib/types/settings-pages/plugins.js +109 -0
  49. package/lib/types/settings.d.ts +58 -0
  50. package/lib/types/settings.js +170 -0
  51. package/lib/types/skins.d.ts +143 -0
  52. package/lib/types/skins.js +268 -0
  53. package/lib/types/slots.d.ts +69 -0
  54. package/lib/types/slots.js +210 -0
  55. package/lib/types/utils.d.ts +15 -0
  56. package/lib/types/utils.js +26 -0
  57. package/package.json +105 -3
  58. package/src/styles/base.css +321 -0
  59. package/src/styles/default.css +734 -0
  60. package/README.md +0 -3
@@ -0,0 +1,1195 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { Component, createContext, useContext, useEffect, useState, useSyncExternalStore } from "react";
3
+ import { Slot } from "@radix-ui/react-slot";
4
+ import "@radix-ui/react-checkbox";
5
+ import "@radix-ui/react-label";
6
+ import "@radix-ui/react-radio-group";
7
+ import "@radix-ui/react-select";
8
+ import * as SwitchPrimitive from "@radix-ui/react-switch";
9
+ import * as TabsPrimitive from "@radix-ui/react-tabs";
10
+ import * as DialogPrimitive from "@radix-ui/react-dialog";
11
+ import { rpcErrorText, subscribeFrame } from "@snap-rail/connection";
12
+ import { settingsChangedSchema } from "@snap-rail/station-rpc/contract";
13
+ import "@snap-rail/cordis";
14
+ import "@snap-rail/cordis-plugin-timer";
15
+ import "@snap-rail/shell/contract";
16
+ import "react-dom/client";
17
+ import "@snap-rail/app-boot/contract";
18
+ //#region lib/types/utils.js
19
+ /**
20
+ * Small helpers shared by the headless semantic components: class merging and
21
+ * the stable `data-snap-*` anatomy that skins target.
22
+ *
23
+ * @module @snap-rail/ui/utils
24
+ */
25
+ /** Join truthy class names. */
26
+ function cn(...values) {
27
+ return values.filter((value) => typeof value === "string" && value.length > 0).join(" ");
28
+ }
29
+ /** The anatomy attributes every semantic component renders. */
30
+ function part(component, name) {
31
+ return {
32
+ "data-snap-component": component,
33
+ "data-snap-part": `${component}.${name}`
34
+ };
35
+ }
36
+ /** Map a semantic spacing token to a CSS variable. */
37
+ function space(token) {
38
+ return `var(--snap-space-${token})`;
39
+ }
40
+ //#endregion
41
+ //#region lib/types/components/button.js
42
+ /**
43
+ * Semantic buttons: one behaviour, skin-owned visuals. The DOM exposes
44
+ * `button.root`, `button.label`, `button.icon`, and `button.spinner` parts;
45
+ * intent/emphasis/size are data attributes a skin styles.
46
+ *
47
+ * @module @snap-rail/ui/components/button
48
+ */
49
+ /** A spinner that inherits the current text colour. */
50
+ function Spinner(props) {
51
+ return jsxs("svg", {
52
+ ...part("button", "spinner"),
53
+ className: cn("snap-spinner", props.className),
54
+ viewBox: "0 0 24 24",
55
+ "aria-hidden": "true",
56
+ children: [jsx("circle", {
57
+ cx: "12",
58
+ cy: "12",
59
+ r: "9",
60
+ fill: "none",
61
+ stroke: "currentColor",
62
+ strokeWidth: "3",
63
+ opacity: "0.25"
64
+ }), jsx("path", {
65
+ d: "M21 12a9 9 0 0 0-9-9",
66
+ fill: "none",
67
+ stroke: "currentColor",
68
+ strokeWidth: "3",
69
+ strokeLinecap: "round"
70
+ })]
71
+ });
72
+ }
73
+ /** A themed button; `asChild` composes the behaviour onto a child element. */
74
+ function Button({ intent = "neutral", emphasis = "solid", size = "md", loading = false, icon, iconPosition = "start", asChild = false, disabled, className, children, type, ...props }) {
75
+ const Component = asChild ? Slot : "button";
76
+ const content = asChild ? children : jsxs(Fragment, { children: [
77
+ icon !== void 0 && iconPosition === "start" && jsx("span", {
78
+ ...part("button", "icon"),
79
+ children: icon
80
+ }),
81
+ children !== void 0 && jsx("span", {
82
+ ...part("button", "label"),
83
+ children
84
+ }),
85
+ icon !== void 0 && iconPosition === "end" && jsx("span", {
86
+ ...part("button", "icon"),
87
+ children: icon
88
+ }),
89
+ loading && jsx(Spinner, {})
90
+ ] });
91
+ return jsx(Component, {
92
+ ...part("button", "root"),
93
+ ...type !== void 0 ? { type } : !asChild ? { type: "button" } : {},
94
+ className: cn("snap-button", className),
95
+ "data-intent": intent,
96
+ "data-emphasis": emphasis,
97
+ "data-size": size,
98
+ "data-loading": loading || void 0,
99
+ "data-disabled": disabled === true || void 0,
100
+ "aria-busy": loading || void 0,
101
+ disabled: !asChild ? disabled === true || loading : void 0,
102
+ ...props,
103
+ children: content
104
+ });
105
+ }
106
+ /** A square glyph button with a mandatory accessible label. */
107
+ function IconButton({ icon, label, active = false, intent = "neutral", emphasis = "ghost", size = "md", className, ...props }) {
108
+ return jsx("button", {
109
+ ...part("icon-button", "root"),
110
+ type: "button",
111
+ className: cn("snap-icon-button", className),
112
+ "data-intent": intent,
113
+ "data-emphasis": emphasis,
114
+ "data-size": size,
115
+ "data-active": active || void 0,
116
+ "aria-label": label,
117
+ "aria-pressed": active || void 0,
118
+ ...props,
119
+ children: jsx("span", {
120
+ ...part("icon-button", "icon"),
121
+ "aria-hidden": "true",
122
+ children: icon
123
+ })
124
+ });
125
+ }
126
+ //#endregion
127
+ //#region lib/types/components/dialog.js
128
+ /**
129
+ * Dialog/sheet semantics over Radix's focus trap and portal. The skin chooses
130
+ * the presentation (modal, sheet, fullscreen) through the `presentation`
131
+ * attribute; the core owns dismissal and focus behaviour.
132
+ *
133
+ * @module @snap-rail/ui/components/dialog
134
+ */
135
+ /** The dialog root. */
136
+ const Dialog = DialogPrimitive.Root;
137
+ /** The portalled dialog content. */
138
+ function DialogContent({ children, className, presentation = "auto", size = "md", showClose = true }) {
139
+ const resolved = presentation === "auto" ? "modal" : presentation;
140
+ return jsxs(DialogPrimitive.Portal, { children: [jsx(DialogPrimitive.Overlay, {
141
+ ...part("dialog", "overlay"),
142
+ className: "snap-dialog-overlay"
143
+ }), jsxs(DialogPrimitive.Content, {
144
+ ...part("dialog", "panel"),
145
+ className: cn("snap-dialog-panel", className),
146
+ "data-presentation": resolved,
147
+ "data-size": size,
148
+ children: [children, showClose && jsx(DialogPrimitive.Close, {
149
+ ...part("dialog", "close"),
150
+ className: "snap-dialog-close",
151
+ "aria-label": "关闭",
152
+ children: "×"
153
+ })]
154
+ })] });
155
+ }
156
+ /** The dialog title. */
157
+ function DialogTitle({ children, className }) {
158
+ return jsx(DialogPrimitive.Title, {
159
+ ...part("dialog", "title"),
160
+ className: cn("snap-dialog-title", className),
161
+ children
162
+ });
163
+ }
164
+ //#endregion
165
+ //#region lib/types/components/controls.js
166
+ /** The tabs root. */
167
+ const Tabs = TabsPrimitive.Root;
168
+ /** The tabs list. */
169
+ function TabsList({ className, children, ...props }) {
170
+ return jsx(TabsPrimitive.List, {
171
+ ...part("tabs", "list"),
172
+ className: cn("snap-tabs-list", className),
173
+ ...props,
174
+ children
175
+ });
176
+ }
177
+ /** A tab trigger. */
178
+ function TabsTrigger({ className, children, ...props }) {
179
+ return jsx(TabsPrimitive.Trigger, {
180
+ ...part("tabs", "trigger"),
181
+ className: cn("snap-tabs-trigger", className),
182
+ ...props,
183
+ children
184
+ });
185
+ }
186
+ /** A boolean switch. */
187
+ function Switch({ className, label, ...props }) {
188
+ return jsxs("label", {
189
+ className: "snap-switch-label",
190
+ children: [jsx(SwitchPrimitive.Root, {
191
+ ...part("switch", "root"),
192
+ className: cn("snap-switch", className),
193
+ ...props,
194
+ children: jsx(SwitchPrimitive.Thumb, {
195
+ ...part("switch", "thumb"),
196
+ className: "snap-switch-thumb"
197
+ })
198
+ }), label !== void 0 && jsx("span", {
199
+ ...part("switch", "label"),
200
+ children: label
201
+ })]
202
+ });
203
+ }
204
+ //#endregion
205
+ //#region lib/types/components/feedback.js
206
+ /** A compact status/count label. */
207
+ function Badge({ children, intent = "neutral", className }) {
208
+ return jsx("span", {
209
+ ...part("badge", "root"),
210
+ className: cn("snap-badge", className),
211
+ "data-intent": intent,
212
+ children
213
+ });
214
+ }
215
+ /** A centered empty/zero-state block. */
216
+ function EmptyState({ title, description, icon, action, className }) {
217
+ return jsxs("div", {
218
+ ...part("empty-state", "root"),
219
+ className: cn("snap-empty-state", className),
220
+ children: [
221
+ icon !== void 0 && jsx("div", {
222
+ ...part("empty-state", "icon"),
223
+ children: icon
224
+ }),
225
+ jsx("div", {
226
+ ...part("empty-state", "title"),
227
+ children: title
228
+ }),
229
+ description !== void 0 && jsx("div", {
230
+ ...part("empty-state", "description"),
231
+ children: description
232
+ }),
233
+ action !== void 0 && jsx("div", {
234
+ ...part("empty-state", "action"),
235
+ children: action
236
+ })
237
+ ]
238
+ });
239
+ }
240
+ //#endregion
241
+ //#region lib/types/components/layout.js
242
+ /** A vertical flow. */
243
+ function Stack({ gap = "md", padding, align, className, style, children }) {
244
+ return jsx("div", {
245
+ ...part("stack", "root"),
246
+ className: cn("snap-stack", className),
247
+ style: {
248
+ display: "flex",
249
+ flexDirection: "column",
250
+ gap: space(gap),
251
+ ...padding !== void 0 ? { padding: space(padding) } : {},
252
+ ...align !== void 0 ? { alignItems: align } : {},
253
+ ...style
254
+ },
255
+ children
256
+ });
257
+ }
258
+ /** A horizontal flow. */
259
+ function Row({ gap = "sm", padding, align, justify, wrap = false, className, style, children }) {
260
+ return jsx("div", {
261
+ ...part("row", "root"),
262
+ className: cn("snap-row", className),
263
+ style: {
264
+ display: "flex",
265
+ flexDirection: "row",
266
+ gap: space(gap),
267
+ ...padding !== void 0 ? { padding: space(padding) } : {},
268
+ ...align !== void 0 ? { alignItems: align } : {},
269
+ ...justify !== void 0 ? { justifyContent: justify } : {},
270
+ ...wrap ? { flexWrap: "wrap" } : {},
271
+ ...style
272
+ },
273
+ children
274
+ });
275
+ }
276
+ /** A page body with its own header/actions anatomy. */
277
+ function Page({ header, actions, title, description, className, style, children }) {
278
+ return jsxs("div", {
279
+ ...part("page", "root"),
280
+ className: cn("snap-page", className),
281
+ style: {
282
+ display: "flex",
283
+ flexDirection: "column",
284
+ minHeight: 0,
285
+ ...style
286
+ },
287
+ children: [(header !== void 0 || title !== void 0 || description !== void 0 || actions !== void 0) && jsxs("div", {
288
+ ...part("page", "header"),
289
+ style: {
290
+ display: "flex",
291
+ flexDirection: "column",
292
+ gap: space("sm"),
293
+ flexShrink: 0
294
+ },
295
+ children: [
296
+ jsxs("div", {
297
+ style: {
298
+ display: "flex",
299
+ alignItems: "flex-start",
300
+ justifyContent: "space-between",
301
+ gap: space("md")
302
+ },
303
+ children: [title !== void 0 && jsx("div", {
304
+ ...part("page", "title"),
305
+ children: title
306
+ }), actions !== void 0 && jsx("div", {
307
+ ...part("page", "actions"),
308
+ children: actions
309
+ })]
310
+ }),
311
+ description !== void 0 && jsx("div", {
312
+ ...part("page", "description"),
313
+ children: description
314
+ }),
315
+ header
316
+ ]
317
+ }), jsx("div", {
318
+ ...part("page", "body"),
319
+ style: {
320
+ display: "flex",
321
+ flexDirection: "column",
322
+ flex: 1,
323
+ minHeight: 0
324
+ },
325
+ children
326
+ })]
327
+ });
328
+ }
329
+ /** A titled content section. */
330
+ function Section({ title, description, actions, className, style, children }) {
331
+ return jsxs("section", {
332
+ ...part("section", "root"),
333
+ className: cn("snap-section", className),
334
+ style: {
335
+ display: "flex",
336
+ flexDirection: "column",
337
+ gap: space("sm"),
338
+ ...style
339
+ },
340
+ children: [(title !== void 0 || actions !== void 0) && jsxs("div", {
341
+ ...part("section", "header"),
342
+ style: {
343
+ display: "flex",
344
+ alignItems: "center",
345
+ justifyContent: "space-between",
346
+ gap: space("md")
347
+ },
348
+ children: [jsxs("div", { children: [title !== void 0 && jsx("div", {
349
+ ...part("section", "title"),
350
+ children: title
351
+ }), description !== void 0 && jsx("div", { children: description })] }), actions !== void 0 && jsx("div", {
352
+ ...part("section", "actions"),
353
+ children: actions
354
+ })]
355
+ }), jsx("div", {
356
+ ...part("section", "body"),
357
+ children
358
+ })]
359
+ });
360
+ }
361
+ //#endregion
362
+ //#region lib/types/components/surface.js
363
+ /** A semantic table. */
364
+ function Table({ className, children, ...props }) {
365
+ return jsx("div", {
366
+ ...part("table", "root"),
367
+ className: cn("snap-table", className),
368
+ children: jsx("table", {
369
+ ...props,
370
+ children
371
+ })
372
+ });
373
+ }
374
+ /** The table head. */
375
+ function TableHeader({ className, children, ...props }) {
376
+ return jsx("thead", {
377
+ ...part("table", "header"),
378
+ className: cn("snap-table-header", className),
379
+ ...props,
380
+ children
381
+ });
382
+ }
383
+ /** The table body. */
384
+ function TableBody({ className, children, ...props }) {
385
+ return jsx("tbody", {
386
+ ...part("table", "body"),
387
+ className: cn("snap-table-body", className),
388
+ ...props,
389
+ children
390
+ });
391
+ }
392
+ /** A table row. */
393
+ function TableRow({ className, children, ...props }) {
394
+ return jsx("tr", {
395
+ ...part("table", "row"),
396
+ className: cn("snap-table-row", className),
397
+ ...props,
398
+ children
399
+ });
400
+ }
401
+ /** A table header cell. */
402
+ function TableHead({ className, children, ...props }) {
403
+ return jsx("th", {
404
+ ...part("table", "head"),
405
+ className: cn("snap-table-head", className),
406
+ ...props,
407
+ children
408
+ });
409
+ }
410
+ /** A table body cell. */
411
+ function TableCell({ className, children, ...props }) {
412
+ return jsx("td", {
413
+ ...part("table", "cell"),
414
+ className: cn("snap-table-cell", className),
415
+ ...props,
416
+ children
417
+ });
418
+ }
419
+ //#endregion
420
+ //#region lib/types/contract.js
421
+ /** The stable region slots every layout may provide. */
422
+ const UI_SLOT_IDS = {
423
+ /** The one active layout of the operator window. */
424
+ layout: "shell.layout",
425
+ /** The operator titlebar. */
426
+ titlebar: "shell.titlebar",
427
+ /** Contributed titlebar actions. */
428
+ titlebarActions: "shell.titlebar.actions",
429
+ /** Sidebar extension area. */
430
+ sidebar: "shell.sidebar",
431
+ /** Statusbar extension area. */
432
+ statusbar: "shell.statusbar",
433
+ /** The global overlay stack (dialogs, confirms). */
434
+ overlay: "shell.overlay",
435
+ /** The floating ball surface face. */
436
+ ball: "shell.ball",
437
+ /** The settings trigger. */
438
+ settingsEntry: "settings.entry",
439
+ /** The settings surface itself. */
440
+ settingsSurface: "settings.surface"
441
+ };
442
+ UI_SLOT_IDS.layout, UI_SLOT_IDS.titlebar, UI_SLOT_IDS.titlebarActions, UI_SLOT_IDS.sidebar, UI_SLOT_IDS.statusbar, UI_SLOT_IDS.overlay, UI_SLOT_IDS.ball, UI_SLOT_IDS.settingsEntry, UI_SLOT_IDS.settingsSurface;
443
+ createContext(null);
444
+ createContext(null);
445
+ //#endregion
446
+ //#region lib/types/runtime.js
447
+ /** The React context carrying the host link/surface into builtin pages. */
448
+ const ClientContext = createContext(null);
449
+ /** Read the client services (host link + surface) from a builtin page. */
450
+ function useClient() {
451
+ const service = useContext(ClientContext);
452
+ if (service === null) throw new Error("useClient: no ClientProvider in the tree");
453
+ return service;
454
+ }
455
+ //#endregion
456
+ //#region lib/types/settings-pages/appearance.js
457
+ const THEME_KEY = "ui.theme";
458
+ const WINDOW_KEY = "ui.window";
459
+ const BALL_KEY = "ui.ball";
460
+ const WINDOW_PRESETS = [
461
+ {
462
+ label: "1280 × 800",
463
+ width: 1280,
464
+ height: 800
465
+ },
466
+ {
467
+ label: "1440 × 900",
468
+ width: 1440,
469
+ height: 900
470
+ },
471
+ {
472
+ label: "1600 × 900",
473
+ width: 1600,
474
+ height: 900
475
+ },
476
+ {
477
+ label: "1920 × 1080",
478
+ width: 1920,
479
+ height: 1080
480
+ }
481
+ ];
482
+ const BALL_SIZES = [
483
+ 96,
484
+ 112,
485
+ 128,
486
+ 160,
487
+ 192
488
+ ];
489
+ /** Read a settings value through the host link. */
490
+ async function readSetting(link, key) {
491
+ const result = await link.call("settings.get", { key });
492
+ return result.ok ? result.value.value : void 0;
493
+ }
494
+ /** Write a settings value; `null` clears the row. */
495
+ async function writeSetting(link, key, value) {
496
+ await link.call("settings.set", {
497
+ key,
498
+ value
499
+ });
500
+ }
501
+ /** The appearance/display page. */
502
+ function AppearancePage() {
503
+ const { link } = useClient();
504
+ const [mode, setMode] = useState("dark");
505
+ const [windowPreset, setWindowPreset] = useState(void 0);
506
+ const [ballSize, setBallSize] = useState(128);
507
+ const [ballEnabled, setBallEnabled] = useState(true);
508
+ const [ballDockable, setBallDockable] = useState(true);
509
+ const [ballCollapse, setBallCollapse] = useState(true);
510
+ const [skins, setSkins] = useState([]);
511
+ const [error, setError] = useState(void 0);
512
+ const [busy, setBusy] = useState(false);
513
+ useEffect(() => {
514
+ Promise.all([
515
+ readSetting(link, THEME_KEY),
516
+ readSetting(link, WINDOW_KEY),
517
+ readSetting(link, BALL_KEY),
518
+ link.call("plugins.list", {})
519
+ ]).then(([theme, windowRow, ballRow, plugins]) => {
520
+ const themeMode = theme?.mode;
521
+ if (themeMode === "system" || themeMode === "light" || themeMode === "dark") setMode(themeMode);
522
+ const windowProfile = windowRow;
523
+ if (windowProfile !== null && windowProfile !== void 0 && typeof windowProfile.width === "number" && typeof windowProfile.height === "number") {
524
+ const preset = WINDOW_PRESETS.find((item) => item.width === windowProfile.width && item.height === windowProfile.height);
525
+ setWindowPreset(preset?.label);
526
+ }
527
+ const ballProfile = ballRow;
528
+ if (ballProfile !== null && ballProfile !== void 0 && typeof ballProfile.size === "number") setBallSize(ballProfile.size);
529
+ if (ballProfile !== null && ballProfile !== void 0 && typeof ballProfile.enabled === "boolean") setBallEnabled(ballProfile.enabled);
530
+ if (ballProfile !== null && ballProfile !== void 0 && typeof ballProfile.dockable === "boolean") setBallDockable(ballProfile.dockable);
531
+ if (ballProfile !== null && ballProfile !== void 0 && typeof ballProfile.collapse === "boolean") setBallCollapse(ballProfile.collapse);
532
+ if (plugins.ok) setSkins(plugins.value.plugins.filter((plugin) => plugin.kind === "skin" && plugin.source !== "builtin").map((plugin) => ({
533
+ name: plugin.packageName,
534
+ title: plugin.title ?? plugin.packageName,
535
+ enabled: plugin.enabled
536
+ })));
537
+ }).catch((cause) => {
538
+ setError(cause instanceof Error ? cause.message : String(cause));
539
+ });
540
+ return subscribeFrame(link, "settings/changed", settingsChangedSchema, (change) => {
541
+ if (change.key === THEME_KEY) {
542
+ const next = change.value?.mode;
543
+ if (next === "system" || next === "light" || next === "dark") setMode(next);
544
+ }
545
+ });
546
+ }, [link]);
547
+ const saveTheme = (next) => {
548
+ setMode(next);
549
+ writeSetting(link, THEME_KEY, { mode: next }).catch((cause) => {
550
+ setError(cause instanceof Error ? cause.message : String(cause));
551
+ });
552
+ };
553
+ const saveWindow = (width, height, label) => {
554
+ setWindowPreset(label);
555
+ writeSetting(link, WINDOW_KEY, {
556
+ width,
557
+ height,
558
+ minWidth: 960,
559
+ minHeight: 600
560
+ }).catch((cause) => {
561
+ setError(cause instanceof Error ? cause.message : String(cause));
562
+ });
563
+ };
564
+ const resetWindow = () => {
565
+ setWindowPreset(void 0);
566
+ writeSetting(link, WINDOW_KEY, null).catch((cause) => {
567
+ setError(cause instanceof Error ? cause.message : String(cause));
568
+ });
569
+ };
570
+ const saveBall = (patch) => {
571
+ const next = {
572
+ size: patch.size ?? ballSize,
573
+ enabled: patch.enabled ?? ballEnabled,
574
+ dockable: patch.dockable ?? ballDockable,
575
+ collapse: patch.collapse ?? ballCollapse
576
+ };
577
+ if (patch.size !== void 0) setBallSize(patch.size);
578
+ if (patch.enabled !== void 0) setBallEnabled(patch.enabled);
579
+ if (patch.dockable !== void 0) setBallDockable(patch.dockable);
580
+ if (patch.collapse !== void 0) setBallCollapse(patch.collapse);
581
+ writeSetting(link, BALL_KEY, next).catch((cause) => {
582
+ setError(cause instanceof Error ? cause.message : String(cause));
583
+ });
584
+ };
585
+ const toggleSkin = (skin) => {
586
+ setBusy(true);
587
+ link.call("plugins.set-enabled", {
588
+ name: skin.name,
589
+ enabled: !skin.enabled
590
+ }).then((result) => {
591
+ if (!result.ok) {
592
+ setError(rpcErrorText(result.error));
593
+ return;
594
+ }
595
+ setSkins((current) => current.map((item) => item.name === skin.name ? {
596
+ ...item,
597
+ enabled: !item.enabled
598
+ } : item));
599
+ }).catch((cause) => {
600
+ setError(cause instanceof Error ? cause.message : String(cause));
601
+ }).finally(() => {
602
+ setBusy(false);
603
+ });
604
+ };
605
+ return jsx(Page, {
606
+ title: "外观与显示",
607
+ description: "主题、皮肤、主窗口尺寸和悬浮球外观;保存后立即生效。",
608
+ children: jsxs(Stack, {
609
+ gap: "lg",
610
+ children: [
611
+ error !== void 0 && jsx("div", {
612
+ role: "alert",
613
+ style: { color: "var(--snap-color-danger)" },
614
+ children: error
615
+ }),
616
+ jsx(Section, {
617
+ title: "主题模式",
618
+ children: jsx(Tabs, {
619
+ value: mode,
620
+ onValueChange: (value) => saveTheme(value),
621
+ children: jsxs(TabsList, {
622
+ "aria-label": "主题模式",
623
+ children: [
624
+ jsx(TabsTrigger, {
625
+ value: "system",
626
+ children: "跟随系统"
627
+ }),
628
+ jsx(TabsTrigger, {
629
+ value: "light",
630
+ children: "白天"
631
+ }),
632
+ jsx(TabsTrigger, {
633
+ value: "dark",
634
+ children: "黑夜"
635
+ })
636
+ ]
637
+ })
638
+ })
639
+ }),
640
+ jsx(Section, {
641
+ title: "界面皮肤",
642
+ description: "皮肤由独立插件提供;启用后需要重启终端。",
643
+ children: jsxs(Stack, {
644
+ gap: "sm",
645
+ children: [jsxs(Row, {
646
+ gap: "sm",
647
+ align: "center",
648
+ children: [jsx(Badge, {
649
+ intent: "success",
650
+ children: "默认(内置)"
651
+ }), jsx("span", {
652
+ style: {
653
+ color: "var(--snap-color-muted)",
654
+ fontSize: "var(--snap-text-sm)"
655
+ },
656
+ children: "工业钴蓝,始终可用"
657
+ })]
658
+ }), skins.length === 0 ? jsx("span", {
659
+ style: { color: "var(--snap-color-muted)" },
660
+ children: "尚未安装其他皮肤插件。"
661
+ }) : skins.map((skin) => jsxs(Row, {
662
+ gap: "sm",
663
+ align: "center",
664
+ children: [
665
+ jsx("span", { children: skin.title }),
666
+ jsx(Badge, {
667
+ intent: skin.enabled ? "success" : "neutral",
668
+ children: skin.enabled ? "已启用" : "未启用"
669
+ }),
670
+ jsx(Button, {
671
+ size: "sm",
672
+ emphasis: "outline",
673
+ disabled: busy,
674
+ onClick: () => toggleSkin(skin),
675
+ children: skin.enabled ? "停用" : "启用"
676
+ })
677
+ ]
678
+ }, skin.name))]
679
+ })
680
+ }),
681
+ jsx(Section, {
682
+ title: "主窗口",
683
+ description: "布局/套件会声明推荐尺寸;这里的选择会覆盖布局推荐。",
684
+ children: jsxs(Stack, {
685
+ gap: "sm",
686
+ children: [jsxs(Row, {
687
+ gap: "sm",
688
+ wrap: true,
689
+ children: [WINDOW_PRESETS.map((preset) => jsx(Button, {
690
+ size: "sm",
691
+ intent: windowPreset === preset.label ? "primary" : "neutral",
692
+ emphasis: windowPreset === preset.label ? "solid" : "outline",
693
+ onClick: () => saveWindow(preset.width, preset.height, preset.label),
694
+ children: preset.label
695
+ }, preset.label)), jsx(Button, {
696
+ size: "sm",
697
+ emphasis: "ghost",
698
+ onClick: resetWindow,
699
+ children: "跟随布局"
700
+ })]
701
+ }), jsxs("span", {
702
+ style: {
703
+ color: "var(--snap-color-muted)",
704
+ fontSize: "var(--snap-text-sm)"
705
+ },
706
+ children: ["当前:", windowPreset ?? "跟随布局推荐 / 默认 1280 × 800"]
707
+ })]
708
+ })
709
+ }),
710
+ jsx(Section, {
711
+ title: "悬浮球",
712
+ description: "球面尺寸与停泊行为;球内显示内容由业务套件决定。",
713
+ children: jsxs(Stack, {
714
+ gap: "md",
715
+ children: [jsx(Row, {
716
+ gap: "sm",
717
+ wrap: true,
718
+ align: "center",
719
+ children: BALL_SIZES.map((size) => jsxs(Button, {
720
+ size: "sm",
721
+ intent: ballSize === size ? "primary" : "neutral",
722
+ emphasis: ballSize === size ? "solid" : "outline",
723
+ onClick: () => saveBall({ size }),
724
+ children: [size, "px"]
725
+ }, size))
726
+ }), jsxs(Row, {
727
+ gap: "lg",
728
+ wrap: true,
729
+ align: "center",
730
+ children: [
731
+ jsx(Switch, {
732
+ label: "启用悬浮球",
733
+ checked: ballEnabled,
734
+ onCheckedChange: (enabled) => saveBall({ enabled })
735
+ }),
736
+ jsx(Switch, {
737
+ label: "允许贴边",
738
+ checked: ballDockable,
739
+ onCheckedChange: (dockable) => saveBall({ dockable })
740
+ }),
741
+ jsx(Switch, {
742
+ label: "贴边后收起",
743
+ checked: ballCollapse,
744
+ onCheckedChange: (collapse) => saveBall({ collapse })
745
+ })
746
+ ]
747
+ })]
748
+ })
749
+ })
750
+ ]
751
+ })
752
+ });
753
+ }
754
+ //#endregion
755
+ //#region lib/types/settings-pages/plugins.js
756
+ /** Human labels for the package kinds. */
757
+ const KIND_LABELS = {
758
+ skin: "界面风格",
759
+ driver: "通讯驱动",
760
+ suite: "业务套件",
761
+ plugin: "插件"
762
+ };
763
+ const PROFILE_LABELS = {
764
+ native: "皮肤原生",
765
+ integrated: "图表桥接",
766
+ custom: "自定义界面"
767
+ };
768
+ /** Collapse entry rows into package rows (one master switch per package). */
769
+ function packageRows(plugins) {
770
+ const byPackage = /* @__PURE__ */ new Map();
771
+ for (const plugin of plugins) {
772
+ if (plugin.source === "builtin") continue;
773
+ const existing = byPackage.get(plugin.packageName);
774
+ if (existing !== void 0) {
775
+ existing.enabled = existing.enabled || plugin.enabled;
776
+ continue;
777
+ }
778
+ byPackage.set(plugin.packageName, {
779
+ packageName: plugin.packageName,
780
+ title: plugin.title ?? plugin.packageName,
781
+ category: plugin.category ?? "其他",
782
+ kind: plugin.kind ?? "plugin",
783
+ ...plugin.version !== void 0 ? { version: plugin.version } : {},
784
+ enabled: plugin.enabled,
785
+ source: plugin.source,
786
+ builtinDefault: plugin.source === "builtin-default",
787
+ clientOnly: plugin.clientOnly === true,
788
+ ...plugin.uiProfile !== void 0 ? { uiProfile: plugin.uiProfile } : {}
789
+ });
790
+ }
791
+ return [...byPackage.values()].sort((a, b) => a.category.localeCompare(b.category) || a.title.localeCompare(b.title));
792
+ }
793
+ /** The plugin management page. */
794
+ function PluginsPage({ ctx }) {
795
+ const [rows, setRows] = useState([]);
796
+ const [error, setError] = useState(void 0);
797
+ const [busy, setBusy] = useState(void 0);
798
+ const [touched, setTouched] = useState(/* @__PURE__ */ new Set());
799
+ const load = () => {
800
+ setError(void 0);
801
+ ctx.client.link.call("plugins.list", {}).then((result) => {
802
+ if (!result.ok) {
803
+ setError(rpcErrorText(result.error));
804
+ return;
805
+ }
806
+ setRows(packageRows(result.value.plugins));
807
+ }).catch((cause) => {
808
+ setError(cause instanceof Error ? cause.message : String(cause));
809
+ });
810
+ };
811
+ useEffect(load, []);
812
+ const toggle = (row, enabled) => {
813
+ setBusy(row.packageName);
814
+ ctx.client.link.call("plugins.set-enabled", {
815
+ name: row.packageName,
816
+ enabled
817
+ }).then((result) => {
818
+ if (!result.ok) {
819
+ setError(rpcErrorText(result.error));
820
+ return;
821
+ }
822
+ setRows((current) => current.map((item) => item.packageName === row.packageName ? {
823
+ ...item,
824
+ enabled
825
+ } : item));
826
+ setTouched((current) => new Set(current).add(row.packageName));
827
+ }).catch((cause) => {
828
+ setError(cause instanceof Error ? cause.message : String(cause));
829
+ }).finally(() => {
830
+ setBusy(void 0);
831
+ });
832
+ };
833
+ const uninstall = (row) => {
834
+ if (!window.confirm(`卸载 ${row.title}?该包的数据也会一起删除。`)) return;
835
+ setBusy(row.packageName);
836
+ ctx.client.link.call("plugins.uninstall", { name: row.packageName }).then((result) => {
837
+ if (!result.ok) {
838
+ setError(rpcErrorText(result.error));
839
+ return;
840
+ }
841
+ setTouched((current) => new Set(current).add(row.packageName));
842
+ load();
843
+ }).catch((cause) => {
844
+ setError(cause instanceof Error ? cause.message : String(cause));
845
+ }).finally(() => {
846
+ setBusy(void 0);
847
+ });
848
+ };
849
+ const groups = /* @__PURE__ */ new Map();
850
+ for (const row of rows) {
851
+ const bucket = groups.get(row.category);
852
+ if (bucket === void 0) groups.set(row.category, [row]);
853
+ else bucket.push(row);
854
+ }
855
+ return jsx(Page, {
856
+ title: "插件管理",
857
+ description: "安装驱动、业务页面和界面风格。启用/停用写入 plugins.yml,渲染端在下一次重启后生效。",
858
+ actions: jsx(Button, {
859
+ intent: "neutral",
860
+ emphasis: "outline",
861
+ onClick: load,
862
+ children: "刷新"
863
+ }),
864
+ children: jsxs(Stack, {
865
+ gap: "lg",
866
+ children: [error !== void 0 && jsx("div", {
867
+ role: "alert",
868
+ style: { color: "var(--snap-color-danger)" },
869
+ children: error
870
+ }), rows.length === 0 ? jsx(EmptyState, {
871
+ title: "还没有安装插件",
872
+ description: "把插件 zip 拖入插件安装入口,或从插件源搜索安装。"
873
+ }) : [...groups.entries()].map(([category, entries]) => jsx(Section, {
874
+ title: category,
875
+ children: jsxs(Table, { children: [jsx(TableHeader, { children: jsxs(TableRow, { children: [
876
+ jsx(TableHead, { children: "名称" }),
877
+ jsx(TableHead, { children: "类型" }),
878
+ jsx(TableHead, { children: "版本" }),
879
+ jsx(TableHead, { children: "状态" }),
880
+ jsx(TableHead, { children: "操作" })
881
+ ] }) }), jsx(TableBody, { children: entries.map((row) => jsxs(TableRow, { children: [
882
+ jsx(TableCell, { children: jsxs("div", {
883
+ style: {
884
+ display: "flex",
885
+ flexDirection: "column"
886
+ },
887
+ children: [jsxs("span", {
888
+ style: {
889
+ display: "flex",
890
+ alignItems: "center",
891
+ gap: "var(--snap-space-sm)"
892
+ },
893
+ children: [row.title, row.builtinDefault && jsx(Badge, {
894
+ intent: "neutral",
895
+ children: "内置默认"
896
+ })]
897
+ }), jsx("span", {
898
+ style: {
899
+ color: "var(--snap-color-muted)",
900
+ fontSize: "var(--snap-text-xs)"
901
+ },
902
+ children: row.packageName
903
+ })]
904
+ }) }),
905
+ jsxs(TableCell, { children: [KIND_LABELS[row.kind] ?? row.kind, row.uiProfile !== void 0 && jsx(Badge, {
906
+ intent: "neutral",
907
+ children: PROFILE_LABELS[row.uiProfile] ?? row.uiProfile
908
+ })] }),
909
+ jsx(TableCell, { children: row.version ?? "—" }),
910
+ jsx(TableCell, { children: row.builtinDefault ? jsx(Badge, {
911
+ intent: "success",
912
+ children: "始终随底座"
913
+ }) : jsxs("div", {
914
+ style: {
915
+ display: "flex",
916
+ alignItems: "center",
917
+ gap: "var(--snap-space-sm)"
918
+ },
919
+ children: [jsx(Switch, {
920
+ checked: row.enabled,
921
+ disabled: busy === row.packageName,
922
+ onCheckedChange: (next) => toggle(row, next),
923
+ "aria-label": `启用 ${row.title}`
924
+ }), touched.has(row.packageName) && jsx(Badge, {
925
+ intent: "warning",
926
+ children: "待重启"
927
+ })]
928
+ }) }),
929
+ jsx(TableCell, { children: row.builtinDefault ? jsx("span", {
930
+ style: { color: "var(--snap-color-muted)" },
931
+ children: "内置默认不可卸载"
932
+ }) : jsx(Button, {
933
+ intent: "danger",
934
+ emphasis: "ghost",
935
+ size: "sm",
936
+ disabled: busy === row.packageName,
937
+ onClick: () => uninstall(row),
938
+ children: "卸载"
939
+ }) })
940
+ ] }, row.packageName)) })] })
941
+ }, category))]
942
+ })
943
+ });
944
+ }
945
+ //#endregion
946
+ //#region lib/types/settings.js
947
+ /** Sort pages by order, then registration time. */
948
+ function orderedPages(pages) {
949
+ return [...pages].sort((a, b) => a.page.order - b.page.order || a.seq - b.seq).map((entry) => entry.page);
950
+ }
951
+ /** A page-level boundary: one broken settings page must not take down the shell. */
952
+ var SettingsPageBoundary = class extends Component {
953
+ state = { failed: false };
954
+ static getDerivedStateFromError() {
955
+ return { failed: true };
956
+ }
957
+ componentDidCatch(error) {
958
+ console.error(`[snap-rail ui] settings page ${this.props.page} failed`, error);
959
+ }
960
+ render() {
961
+ return this.state.failed ? jsx(EmptyState, {
962
+ title: "设置页加载失败",
963
+ description: "该页面抛出了异常,其他设置页仍可使用。"
964
+ }) : this.props.children;
965
+ }
966
+ };
967
+ /** The gear glyph used by the default trigger. */
968
+ function GearIcon() {
969
+ return jsxs("svg", {
970
+ viewBox: "0 0 24 24",
971
+ width: "18",
972
+ height: "18",
973
+ fill: "none",
974
+ stroke: "currentColor",
975
+ strokeWidth: "1.8",
976
+ "aria-hidden": "true",
977
+ children: [jsx("circle", {
978
+ cx: "12",
979
+ cy: "12",
980
+ r: "3"
981
+ }), jsx("path", { d: "M19.4 15a1.7 1.7 0 0 0 .34 1.87l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.7 1.7 0 0 0-1.87-.34 1.7 1.7 0 0 0-1 1.55V21a2 2 0 1 1-4 0v-.09a1.7 1.7 0 0 0-1-1.55 1.7 1.7 0 0 0-1.87.34l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.7 1.7 0 0 0 .34-1.87 1.7 1.7 0 0 0-1.55-1H3a2 2 0 1 1 0-4h.09a1.7 1.7 0 0 0 1.55-1 1.7 1.7 0 0 0-.34-1.87l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.7 1.7 0 0 0 1.87.34h0a1.7 1.7 0 0 0 1-1.55V3a2 2 0 1 1 4 0v.09a1.7 1.7 0 0 0 1 1.55h0a1.7 1.7 0 0 0 1.87-.34l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.7 1.7 0 0 0-.34 1.87v0a1.7 1.7 0 0 0 1.55 1H21a2 2 0 1 1 0 4h-.09a1.7 1.7 0 0 0-1.55 1Z" })]
982
+ });
983
+ }
984
+ /** The default settings trigger; the layout decides placement/presentation. */
985
+ function SettingsEntry(props) {
986
+ if (props.presentation === "label") return jsx(Button, {
987
+ intent: "neutral",
988
+ emphasis: "ghost",
989
+ icon: jsx(GearIcon, {}),
990
+ onClick: props.open,
991
+ children: "设置"
992
+ });
993
+ return jsx(IconButton, {
994
+ icon: jsx(GearIcon, {}),
995
+ label: "设置",
996
+ active: props.isOpen,
997
+ onClick: props.open
998
+ });
999
+ }
1000
+ /** The default settings surface. */
1001
+ function SettingsSurface(props) {
1002
+ const { service } = props;
1003
+ useSyncExternalStore(service.subscribe, service.version, service.version);
1004
+ const open = service.isOpen();
1005
+ const pages = service.listPages();
1006
+ const activeId = service.activePage();
1007
+ const active = pages.find((page) => page.id === activeId);
1008
+ const groups = /* @__PURE__ */ new Map();
1009
+ for (const page of pages) {
1010
+ const group = page.group ?? "其他";
1011
+ const bucket = groups.get(group);
1012
+ if (bucket === void 0) groups.set(group, [page]);
1013
+ else bucket.push(page);
1014
+ }
1015
+ return jsx(Dialog, {
1016
+ open,
1017
+ onOpenChange: (next) => {
1018
+ if (!next) service.close();
1019
+ },
1020
+ children: jsx(DialogContent, {
1021
+ presentation: "fullscreen",
1022
+ showClose: false,
1023
+ children: jsxs("div", {
1024
+ ...part("settings", "root"),
1025
+ className: "snap-settings",
1026
+ children: [jsxs("header", {
1027
+ ...part("settings", "header"),
1028
+ className: "snap-settings-header",
1029
+ children: [jsx(DialogTitle, { children: "设置" }), jsx(Button, {
1030
+ intent: "neutral",
1031
+ emphasis: "ghost",
1032
+ onClick: () => service.close(),
1033
+ children: "关闭"
1034
+ })]
1035
+ }), jsxs("div", {
1036
+ ...part("settings", "body"),
1037
+ className: "snap-settings-body",
1038
+ children: [jsx("nav", {
1039
+ ...part("settings", "nav"),
1040
+ className: "snap-settings-nav",
1041
+ "aria-label": "设置页",
1042
+ children: [...groups.entries()].map(([group, entries]) => jsxs("div", {
1043
+ ...part("settings", "group"),
1044
+ className: "snap-settings-group",
1045
+ children: [jsx("div", {
1046
+ ...part("settings", "group-title"),
1047
+ className: "snap-settings-group-title",
1048
+ children: group
1049
+ }), entries.map((page) => jsxs("button", {
1050
+ type: "button",
1051
+ ...part("settings", "nav-item"),
1052
+ className: cn("snap-settings-nav-item", page.id === activeId && "is-active"),
1053
+ "data-active": page.id === activeId || void 0,
1054
+ "aria-current": page.id === activeId ? "page" : void 0,
1055
+ onClick: () => service.open(page.id),
1056
+ children: [page.icon !== void 0 && jsx("span", {
1057
+ ...part("settings", "nav-icon"),
1058
+ children: page.icon
1059
+ }), jsx("span", { children: page.title })]
1060
+ }, page.id))]
1061
+ }, group))
1062
+ }), jsx("main", {
1063
+ ...part("settings", "content"),
1064
+ className: "snap-settings-content",
1065
+ "data-active-page": activeId,
1066
+ children: active === void 0 ? jsx(EmptyState, {
1067
+ title: "暂无设置页",
1068
+ description: "安装或启用一个带设置页的插件后,它会出现在这里。"
1069
+ }) : jsx(SettingsPageBoundary, {
1070
+ page: active.id,
1071
+ children: active.render()
1072
+ })
1073
+ })]
1074
+ })]
1075
+ })
1076
+ })
1077
+ });
1078
+ }
1079
+ /** Mount the settings registry and its default slot contributions. */
1080
+ const settingsPlugin = {
1081
+ name: "snap-rail settings",
1082
+ inject: ["ui"],
1083
+ apply(ctx) {
1084
+ const pages = /* @__PURE__ */ new Map();
1085
+ const listeners = /* @__PURE__ */ new Set();
1086
+ let open = false;
1087
+ let requestedId;
1088
+ let revision = 0;
1089
+ let seq = 0;
1090
+ const notify = (kind) => {
1091
+ revision += 1;
1092
+ for (const listener of listeners) listener();
1093
+ ctx.emit(kind === "pages" ? "settings/pages-changed" : "settings/open-changed");
1094
+ };
1095
+ const firstId = () => orderedPages(pages.values())[0]?.id;
1096
+ const activeId = () => {
1097
+ if (!open) return void 0;
1098
+ if (requestedId !== void 0 && pages.has(requestedId)) return requestedId;
1099
+ return firstId();
1100
+ };
1101
+ const service = {
1102
+ registerPage(caller, page) {
1103
+ pages.set(page.id, {
1104
+ page,
1105
+ seq: seq++
1106
+ });
1107
+ notify("pages");
1108
+ const remove = () => {
1109
+ if (pages.delete(page.id)) notify("pages");
1110
+ };
1111
+ caller.effect(() => remove);
1112
+ return remove;
1113
+ },
1114
+ listPages: () => orderedPages(pages.values()),
1115
+ open(pageId) {
1116
+ if (pageId !== void 0) requestedId = pageId;
1117
+ if (open && pageId === void 0) return;
1118
+ open = true;
1119
+ notify("open");
1120
+ },
1121
+ close() {
1122
+ if (!open) return;
1123
+ open = false;
1124
+ notify("open");
1125
+ },
1126
+ toggle() {
1127
+ if (open) service.close();
1128
+ else service.open();
1129
+ },
1130
+ isOpen: () => open,
1131
+ activePage: activeId,
1132
+ subscribe(listener) {
1133
+ listeners.add(listener);
1134
+ return () => {
1135
+ listeners.delete(listener);
1136
+ };
1137
+ },
1138
+ version: () => revision
1139
+ };
1140
+ ctx.provide("settings", service);
1141
+ ctx.settings.registerPage(ctx, {
1142
+ id: "plugins",
1143
+ title: "插件管理",
1144
+ group: "系统",
1145
+ order: 0,
1146
+ keywords: [
1147
+ "安装",
1148
+ "启用",
1149
+ "卸载",
1150
+ "驱动",
1151
+ "皮肤"
1152
+ ],
1153
+ render: () => jsx(PluginsPage, { ctx })
1154
+ });
1155
+ ctx.settings.registerPage(ctx, {
1156
+ id: "appearance",
1157
+ title: "外观与显示",
1158
+ group: "系统",
1159
+ order: 1,
1160
+ keywords: [
1161
+ "主题",
1162
+ "皮肤",
1163
+ "窗口",
1164
+ "悬浮球",
1165
+ "尺寸"
1166
+ ],
1167
+ render: () => jsx(AppearancePage, {})
1168
+ });
1169
+ ctx.ui.contribute(ctx, UI_SLOT_IDS.settingsEntry, {
1170
+ id: "settings.default-entry",
1171
+ order: 0,
1172
+ render: (context) => jsx(SettingsEntry, {
1173
+ presentation: context.presentation,
1174
+ open: context.open,
1175
+ isOpen: context.isOpen
1176
+ })
1177
+ });
1178
+ ctx.ui.contribute(ctx, UI_SLOT_IDS.settingsSurface, {
1179
+ id: "settings.default-surface",
1180
+ order: 0,
1181
+ render: () => jsx(SettingsSurface, { service })
1182
+ });
1183
+ }
1184
+ };
1185
+ /** The settings page info the slot context exposes. */
1186
+ function settingsPageInfo(page) {
1187
+ return {
1188
+ id: page.id,
1189
+ title: page.title,
1190
+ ...page.group !== void 0 ? { group: page.group } : {},
1191
+ order: page.order
1192
+ };
1193
+ }
1194
+ //#endregion
1195
+ export { SettingsEntry, SettingsSurface, settingsPlugin as default, settingsPageInfo };