@inflatable-cookie/longhorn-poodle-svelte 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 (86) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +37 -0
  3. package/package.json +171 -0
  4. package/src/bindings/index.ts +4 -0
  5. package/src/bindings/layout.svelte.ts +143 -0
  6. package/src/bindings/lifecycle.svelte.ts +246 -0
  7. package/src/bindings/optimistic.svelte.ts +96 -0
  8. package/src/bindings/scheduler.ts +13 -0
  9. package/src/bindings/surface-transfer-actions.ts +281 -0
  10. package/src/bindings/surface-transfer.svelte.ts +230 -0
  11. package/src/bindings/surfaces.svelte.ts +179 -0
  12. package/src/bindings/transfer-actions.ts +240 -0
  13. package/src/bindings/transfer-model.ts +138 -0
  14. package/src/bindings/transfer.svelte.ts +388 -0
  15. package/src/bindings/window-chrome.ts +63 -0
  16. package/src/bindings/window-drag.ts +161 -0
  17. package/src/commands/poodle/CommandPaletteBinding.svelte +51 -0
  18. package/src/commands/poodle/KeybindingSettings.svelte +138 -0
  19. package/src/commands/poodle/projectors.ts +37 -0
  20. package/src/commands/poodle.ts +9 -0
  21. package/src/commands/svelte/lifecycle.ts +13 -0
  22. package/src/commands/svelte/session.svelte.ts +212 -0
  23. package/src/commands/svelte.ts +2 -0
  24. package/src/config/poodle/BackupSettingsPage.svelte +295 -0
  25. package/src/config/poodle/RestoreSettingsPage.svelte +535 -0
  26. package/src/config/poodle/StorageSettingsPage.svelte +361 -0
  27. package/src/config/poodle/restore-model.ts +63 -0
  28. package/src/config/poodle/types.ts +11 -0
  29. package/src/config/poodle.ts +8 -0
  30. package/src/history/svelte/lifecycle.ts +13 -0
  31. package/src/history/svelte/session.svelte.ts +97 -0
  32. package/src/history/svelte.ts +2 -0
  33. package/src/history-tree/svelte/lifecycle.ts +11 -0
  34. package/src/history-tree/svelte/session.svelte.ts +27 -0
  35. package/src/history-tree/svelte.ts +3 -0
  36. package/src/licence/poodle/LicenceActivation.svelte +62 -0
  37. package/src/licence/poodle/LicenceSeats.svelte +57 -0
  38. package/src/licence/poodle/LicenceStatus.svelte +34 -0
  39. package/src/licence/poodle/LicenceSurface.svelte.ts +43 -0
  40. package/src/licence/poodle.ts +3 -0
  41. package/src/native-content/index.ts +4 -0
  42. package/src/native-content/lifecycle.ts +13 -0
  43. package/src/native-content/session.svelte.ts +526 -0
  44. package/src/native-content/viewport.ts +27 -0
  45. package/src/native-content/visibility.ts +19 -0
  46. package/src/notifications/poodle/NotificationPanel.svelte +66 -0
  47. package/src/notifications/poodle/NotificationToastHost.svelte +40 -0
  48. package/src/notifications/poodle/NotificationToastStack.svelte +22 -0
  49. package/src/notifications/poodle/projectors.ts +30 -0
  50. package/src/notifications/poodle.ts +4 -0
  51. package/src/notifications/svelte/lifecycle.ts +11 -0
  52. package/src/notifications/svelte/session.svelte.ts +57 -0
  53. package/src/notifications/svelte.ts +2 -0
  54. package/src/operation/poodle/OperationPanel.svelte +200 -0
  55. package/src/operation/poodle/projectors.ts +78 -0
  56. package/src/operation/poodle.ts +2 -0
  57. package/src/operation/svelte/lifecycle.ts +13 -0
  58. package/src/operation/svelte/session.svelte.ts +80 -0
  59. package/src/operation/svelte.ts +2 -0
  60. package/src/poodle/LayoutDockRegion.svelte +148 -0
  61. package/src/poodle/LayoutSplitView.svelte +120 -0
  62. package/src/poodle/LayoutTabs.svelte +91 -0
  63. package/src/poodle/binding.ts +401 -0
  64. package/src/poodle/document.ts +117 -0
  65. package/src/poodle/index.ts +8 -0
  66. package/src/poodle/projectors.ts +125 -0
  67. package/src/poodle/transfer.ts +188 -0
  68. package/src/poodle/types.ts +89 -0
  69. package/src/settings/poodle/SettingsShell.svelte +382 -0
  70. package/src/settings/poodle.ts +2 -0
  71. package/src/settings/svelte/context.ts +61 -0
  72. package/src/settings/svelte/document.svelte.ts +202 -0
  73. package/src/settings/svelte/errors.ts +84 -0
  74. package/src/settings/svelte/lifecycle.ts +18 -0
  75. package/src/settings/svelte/page.svelte.ts +266 -0
  76. package/src/settings/svelte/runtime.svelte.ts +187 -0
  77. package/src/settings/svelte/scope.svelte.ts +123 -0
  78. package/src/settings/svelte/session.svelte.ts +288 -0
  79. package/src/settings/svelte/types.ts +90 -0
  80. package/src/settings/svelte.ts +6 -0
  81. package/src/svelte.d.ts +6 -0
  82. package/src/update/poodle/UpdateCentre.svelte +64 -0
  83. package/src/update/poodle/UpdateSettings.svelte +64 -0
  84. package/src/update/poodle/UpdateStatus.svelte +51 -0
  85. package/src/update/poodle/UpdateSurface.svelte.ts +88 -0
  86. package/src/update/poodle.ts +3 -0
@@ -0,0 +1,188 @@
1
+ import {
2
+ CROSS_WINDOW_DRAG_PROTOCOL_VERSION,
3
+ decodeDockPanelSubject,
4
+ type CrossWindowDragReceipt,
5
+ type CrossWindowDragSourceBridge,
6
+ type CrossWindowDragTargetBridge,
7
+ type CrossWindowDragTargetEvent,
8
+ type DragDropCommitResult,
9
+ } from "@inflatable-cookie/poodle-core";
10
+ import {
11
+ TRANSFER_PROTOCOL_VERSION,
12
+ type PanelSessionStartRequest,
13
+ type PanelTransferCommand,
14
+ type PanelTransferResponse,
15
+ type TransferCommitSelector,
16
+ type TransferSessionResponse,
17
+ } from "@inflatable-cookie/longhorn/transfer";
18
+ import type { TransferState } from "@inflatable-cookie/longhorn-poodle-svelte/transfer";
19
+
20
+ export type PanelDropSelector =
21
+ | {
22
+ readonly kind: "explicit_zone";
23
+ readonly dropZoneId: string;
24
+ }
25
+ | { readonly kind: "screen_point" };
26
+
27
+ export interface PanelTransferDragSourceOptions {
28
+ readonly state: TransferState;
29
+ readonly makeStartRequest: (
30
+ panelInstanceId: string,
31
+ ) => PanelSessionStartRequest;
32
+ readonly reportError: (error: unknown) => void;
33
+ readonly onPreparation?: (response: TransferSessionResponse) => void;
34
+ }
35
+
36
+ export interface PanelTransferDropTargetOptions {
37
+ readonly state: TransferState;
38
+ readonly selector: PanelDropSelector;
39
+ readonly nextRequestId: () => string;
40
+ readonly reportError: (error: unknown) => void;
41
+ readonly onResponse?: (response: PanelTransferResponse) => void;
42
+ readonly onTerminal?: () => void;
43
+ /** Required when `selector.kind` is `screen_point`. */
44
+ readonly screenPoint?: () => { readonly x: number; readonly y: number };
45
+ }
46
+
47
+ export function createPanelTransferDragSource(
48
+ options: PanelTransferDragSourceOptions,
49
+ ): CrossWindowDragSourceBridge {
50
+ return {
51
+ capabilities: {
52
+ pointer: true,
53
+ touch: false,
54
+ keyboardTargetPicker: false,
55
+ },
56
+ async prepare(request, signal) {
57
+ if (signal.aborted) return null;
58
+ const decoded = decodeDockPanelSubject(request.subject.id);
59
+ if (decoded === null) return null;
60
+
61
+ const startRequest = options.makeStartRequest(decoded.panelId);
62
+ const response = await options.state.preparePanel(startRequest);
63
+ notify(options.onPreparation, response, options.reportError);
64
+ if (response.status !== "started") return null;
65
+
66
+ return receiptFor(response.session.payload.session_id);
67
+ },
68
+ start() {
69
+ return () => undefined;
70
+ },
71
+ cancel() {
72
+ void options.state.cancelPreparation().catch((error) => {
73
+ report(options.reportError, error);
74
+ });
75
+ },
76
+ };
77
+ }
78
+
79
+ export function createPanelTransferDropTarget(
80
+ options: PanelTransferDropTargetOptions,
81
+ ): CrossWindowDragTargetBridge {
82
+ const listeners = new Set<(event: CrossWindowDragTargetEvent) => void>();
83
+ return {
84
+ capabilities: {
85
+ pointer: true,
86
+ touch: false,
87
+ keyboardTargetPicker: false,
88
+ },
89
+ subscribe(listener) {
90
+ listeners.add(listener);
91
+ return () => {
92
+ listeners.delete(listener);
93
+ };
94
+ },
95
+ async commit(request, signal) {
96
+ if (signal.aborted) {
97
+ return { status: "rejected", reason: "aborted" };
98
+ }
99
+ try {
100
+ const transferRequest: PanelTransferCommand = {
101
+ protocol_version: TRANSFER_PROTOCOL_VERSION,
102
+ request_id: options.nextRequestId(),
103
+ session_id: request.receipt.token,
104
+ selector: resolveSelector(options),
105
+ };
106
+ const response = await options.state.commitPanel(transferRequest);
107
+ notify(options.onResponse, response, options.reportError);
108
+ return commitResult(response);
109
+ } catch (error) {
110
+ report(options.reportError, error);
111
+ return {
112
+ status: "failed",
113
+ reason: error instanceof Error ? error.message : String(error),
114
+ };
115
+ } finally {
116
+ notifyTerminal(options.onTerminal, options.reportError);
117
+ }
118
+ },
119
+ };
120
+ }
121
+
122
+ function receiptFor(sessionId: string): CrossWindowDragReceipt {
123
+ return {
124
+ protocolVersion: CROSS_WINDOW_DRAG_PROTOCOL_VERSION,
125
+ token: sessionId,
126
+ };
127
+ }
128
+
129
+ function resolveSelector(
130
+ options: PanelTransferDropTargetOptions,
131
+ ): TransferCommitSelector {
132
+ if (options.selector.kind === "explicit_zone") {
133
+ return {
134
+ kind: "explicit_zone",
135
+ drop_zone_id: options.selector.dropZoneId,
136
+ };
137
+ }
138
+ const point = options.screenPoint?.();
139
+ if (
140
+ point === undefined ||
141
+ !Number.isSafeInteger(point.x) ||
142
+ !Number.isSafeInteger(point.y)
143
+ ) {
144
+ throw new RangeError("drop screen point must use integer screen DIPs");
145
+ }
146
+ return {
147
+ kind: "screen_point",
148
+ point: { x: point.x, y: point.y },
149
+ };
150
+ }
151
+
152
+ function commitResult(response: PanelTransferResponse): DragDropCommitResult {
153
+ if (response.status === "committed") return { status: "committed" };
154
+ return { status: "rejected", reason: response.abort.source.code };
155
+ }
156
+
157
+ function report(reporter: (error: unknown) => void, error: unknown): void {
158
+ try {
159
+ reporter(error);
160
+ } catch {
161
+ // Reporting failure must not escape an event callback.
162
+ }
163
+ }
164
+
165
+ function notify<T>(
166
+ listener: ((value: T) => void) | undefined,
167
+ value: T,
168
+ reporter: (error: unknown) => void,
169
+ ): void {
170
+ try {
171
+ listener?.(value);
172
+ } catch (error) {
173
+ report(reporter, error);
174
+ }
175
+ }
176
+
177
+ function notifyTerminal(
178
+ listener: (() => void) | undefined,
179
+ reporter: (error: unknown) => void,
180
+ ): void {
181
+ try {
182
+ listener?.();
183
+ } catch (error) {
184
+ report(reporter, error);
185
+ }
186
+ }
187
+
188
+ export type { CrossWindowDragReceipt };
@@ -0,0 +1,89 @@
1
+ import type {
2
+ LayoutMutationRequest,
3
+ LayoutSchemaDefinition,
4
+ PanelDefinition,
5
+ PanelInstance,
6
+ PanelInstanceId,
7
+ RegionDefinition,
8
+ RegionState,
9
+ SizingSlotDefinition,
10
+ } from "@inflatable-cookie/longhorn/layout";
11
+ import type {
12
+ SurfaceRecord,
13
+ SurfaceDocument,
14
+ } from "@inflatable-cookie/longhorn/surfaces";
15
+ import type { LayoutDispatchResult } from "@inflatable-cookie/longhorn-poodle-svelte/layout";
16
+ import type { IconProp, PanelTabItem } from "@inflatable-cookie/poodle-svelte";
17
+
18
+ export interface LayoutMutationState {
19
+ readonly projected: SurfaceDocument | undefined;
20
+ dispatch(
21
+ request: LayoutMutationRequest,
22
+ project: (document: SurfaceDocument) => SurfaceDocument,
23
+ ): Promise<LayoutDispatchResult>;
24
+ }
25
+
26
+ export interface PoodleLayoutDefinitions {
27
+ readonly schemas: readonly LayoutSchemaDefinition[];
28
+ readonly panels: readonly PanelDefinition[];
29
+ }
30
+
31
+ export interface PanelPresentation {
32
+ readonly label: string;
33
+ readonly icon?: IconProp | null;
34
+ }
35
+
36
+ export type PanelPresentationResolver = (
37
+ instance: PanelInstance,
38
+ ) => PanelPresentation | null;
39
+
40
+ export interface PanelRenderContext {
41
+ readonly instance: PanelInstance;
42
+ readonly definition: PanelDefinition;
43
+ readonly presentation: PanelPresentation;
44
+ }
45
+
46
+ export interface RegionProjection {
47
+ readonly container: SurfaceRecord;
48
+ readonly definition: RegionDefinition;
49
+ readonly state: RegionState;
50
+ readonly items: readonly PanelTabItem[];
51
+ readonly panels: ReadonlyMap<PanelInstanceId, PanelRenderContext>;
52
+ readonly active: PanelRenderContext | null;
53
+ }
54
+
55
+ export interface SizingSlotProjection {
56
+ readonly definition: SizingSlotDefinition;
57
+ readonly ratio: number;
58
+ }
59
+
60
+ export interface PoodleLayoutBindingOptions {
61
+ readonly state: LayoutMutationState;
62
+ readonly definitions: PoodleLayoutDefinitions;
63
+ readonly nextRequestId: () => string;
64
+ readonly onError: (error: unknown) => void;
65
+ readonly onResult?: (result: LayoutDispatchResult) => void;
66
+ }
67
+
68
+ export class MissingSurfaceDocumentError extends Error {
69
+ constructor() {
70
+ super("Poodle layout binding requires a projected layout document");
71
+ this.name = "MissingSurfaceDocumentError";
72
+ }
73
+ }
74
+
75
+ export class MissingLayoutMemberError extends Error {
76
+ constructor(kind: string, id: string) {
77
+ super(`Poodle layout binding cannot resolve ${kind}: ${id}`);
78
+ this.name = "MissingLayoutMemberError";
79
+ }
80
+ }
81
+
82
+ export class MissingPanelPresentationError extends Error {
83
+ constructor(panelInstanceId: PanelInstanceId) {
84
+ super(
85
+ `consumer supplied no presentation for panel instance ${panelInstanceId}`,
86
+ );
87
+ this.name = "MissingPanelPresentationError";
88
+ }
89
+ }
@@ -0,0 +1,382 @@
1
+ <script lang="ts">
2
+ import {
3
+ Button,
4
+ Callout,
5
+ Dialog,
6
+ FormActions,
7
+ SettingsShell as PoodleSettingsShell,
8
+ } from "@inflatable-cookie/poodle-svelte";
9
+ import { tick } from "svelte";
10
+
11
+ import {
12
+ useSettingsSession,
13
+ type SettingsRendererResolver,
14
+ type SettingsSession,
15
+ } from "../svelte.ts";
16
+
17
+ /**
18
+ * Binds a `SettingsSession` to Poodle's `SettingsShell`.
19
+ *
20
+ * Poodle owns the chrome: the dialog, the header and search field, the nav
21
+ * rail, the results list, the page region. It is presentational and takes
22
+ * `groups`, `searchResults` and a `page` snippet — it has no notion of a
23
+ * session, an apply unit, or a renderer, and it may not depend on Longhorn.
24
+ *
25
+ * This file is what closes that gap, and it is binding rather than design.
26
+ * Everything below is session-derived state Poodle cannot know about:
27
+ * connection status, recovery, activation requirements, apply-unit status,
28
+ * the staged apply actions, the unsaved-changes guard, and reset
29
+ * confirmation.
30
+ */
31
+ interface Props {
32
+ session: SettingsSession;
33
+ resolveRenderer: SettingsRendererResolver;
34
+ open?: boolean;
35
+ title?: string;
36
+ /**
37
+ * The dialog's accessible name, when it should differ from the title.
38
+ *
39
+ * "Settings" is the right visible title in every application and the
40
+ * wrong accessible name in all of them: a screen-reader user with three
41
+ * windows open hears it three times. Defaults to `title`.
42
+ */
43
+ ariaLabel?: string | null;
44
+ onOpenChange?: (open: boolean) => void;
45
+ }
46
+
47
+ let {
48
+ session,
49
+ resolveRenderer,
50
+ open = $bindable(true),
51
+ title = "Settings",
52
+ ariaLabel = null,
53
+ onOpenChange,
54
+ }: Props = $props();
55
+
56
+ let searchQuery = $state("");
57
+ let focusTarget = $state<HTMLElement | null>(null);
58
+
59
+ useSettingsSession(() => session, () => resolveRenderer);
60
+
61
+ /**
62
+ * Search narrows the nav rail; it does not replace the page.
63
+ *
64
+ * Poodle's shell used to render a separate results list over the page
65
+ * region. It duplicated the nav as a second list and hid the page you were
66
+ * working on behind the list you had just navigated from, so it is gone.
67
+ * Narrowing keeps one list of destinations and leaves the page alone, which
68
+ * is also why the query survives a navigation.
69
+ *
70
+ * Anchor matches become their own entries rather than collapsing into their
71
+ * page. Searching "Output" and landing on the Audio page with no idea which
72
+ * control matched is barely better than not searching.
73
+ */
74
+ const routes = new Map<string, { pageId: string; anchorId?: string }>();
75
+
76
+ const navigationGroups = $derived.by(() => {
77
+ routes.clear();
78
+ const query = searchQuery.trim();
79
+ const matches = query ? session.search(query) : undefined;
80
+ const anchorsByPage = new Map<string, { id: string; label: string }[]>();
81
+ if (matches) {
82
+ for (const { page, anchor } of matches) {
83
+ if (!anchor) continue;
84
+ const existing = anchorsByPage.get(page.id) ?? [];
85
+ if (!existing.some(({ id }) => id === anchor.id)) {
86
+ // An anchor may carry no label. It still matched -- on its id -- so
87
+ // it stays in the rail under the id rather than as a blank row.
88
+ existing.push({ id: anchor.id, label: anchor.label ?? anchor.id });
89
+ }
90
+ anchorsByPage.set(page.id, existing);
91
+ }
92
+ }
93
+ const matchedPages = matches && new Set(matches.map(({ page }) => page.id));
94
+
95
+ return (
96
+ session.navigation?.modules.flatMap(({ sections }) =>
97
+ sections
98
+ .map(({ section, pages }) => ({
99
+ id: section.id,
100
+ // The section's own label, always. This used to prefix the
101
+ // module's whenever more than one was registered, which reads as
102
+ // "STORAGE · STORAGE & BACKUPS" for a Storage module holding a
103
+ // Storage & Backups section. A host that wants its module named
104
+ // writes that into the section label.
105
+ label: section.label,
106
+ items: pages
107
+ .filter((page) => matchedPages === undefined || matchedPages.has(page.id))
108
+ .flatMap((page) => {
109
+ routes.set(page.id, { pageId: page.id });
110
+ const entry = { value: page.id, label: page.label };
111
+ const anchors = anchorsByPage.get(page.id) ?? [];
112
+ return [
113
+ entry,
114
+ ...anchors.map((anchor) => {
115
+ // A synthetic value rather than a composite string: ids
116
+ // are host-supplied and a separator could appear in one.
117
+ const value = `${page.id}\u0000${anchor.id}`;
118
+ routes.set(value, { pageId: page.id, anchorId: anchor.id });
119
+ return { value, label: `${page.label} · ${anchor.label}` };
120
+ }),
121
+ ];
122
+ }),
123
+ }))
124
+ // A section whose every page was filtered out is not a heading over
125
+ // nothing; it is absent.
126
+ .filter(({ items }) => items.length > 0),
127
+ ) ?? []
128
+ );
129
+ });
130
+
131
+ const currentPage = $derived(session.currentPage);
132
+ const renderer = $derived(session.currentRenderer);
133
+ const context = $derived(session.currentContext);
134
+ const pendingActivation = $derived(
135
+ session.activationRequirements.filter(({ state }) => state === "pending"),
136
+ );
137
+ const unitStatus = $derived(session.primaryUnitStatus);
138
+ const hasStagedUnit = $derived(
139
+ currentPage?.writableApplyUnitIds.some((unitId) =>
140
+ session.registry?.applyUnits.some(
141
+ (unit) => unit.id === unitId && unit.timing === "staged",
142
+ ),
143
+ ) ?? false,
144
+ );
145
+
146
+ // Poodle's shell refuses to close while this is set, and it reads it at the
147
+ // moment of the attempt. So this has to answer "would a close be refused",
148
+ // not "was one refused" -- a guard raised by our own handler arrives too
149
+ // late, after the shell has already decided.
150
+ const closeRefusedReason = $derived(
151
+ session.canLeaveCurrent ? null : "Apply or discard this page before leaving.",
152
+ );
153
+
154
+ $effect(() => {
155
+ session.focusRevision;
156
+ void tick().then(() => focusTarget?.focus());
157
+ });
158
+
159
+ // A default rather than an optional parameter: the packed artifact strips
160
+ // type annotations but leaves a bare `anchorId?`, which is not valid JS and
161
+ // fails the composition proof's bundler.
162
+ //
163
+ // The query is deliberately left alone. A narrowed rail is a filtered list
164
+ // of destinations, and clearing it on the first pick would throw away the
165
+ // filter the moment it became useful.
166
+ function navigate(value: string, _anchorId: string | null = null): void {
167
+ const route = routes.get(value) ?? { pageId: value };
168
+ void session.navigate(route).then(async (navigated) => {
169
+ if (!navigated) return;
170
+ await tick();
171
+ focusTarget?.focus();
172
+ });
173
+ }
174
+
175
+ // Poodle's shell holds itself open on `closeRefusedReason` and returns
176
+ // before it calls `onOpenChange`, so this is the only signal that a refused
177
+ // close was attempted. `requestClose` raises the guard dialog below and
178
+ // returns false; the shell has already refused to close.
179
+ function handleRequestClose(): void {
180
+ if (!session.canLeaveCurrent) session.requestClose();
181
+ }
182
+
183
+ function handleOpenChange(next: boolean): void {
184
+ if (next) {
185
+ open = true;
186
+ onOpenChange?.(true);
187
+ return;
188
+ }
189
+ // `handleRequestClose` has already raised the guard for a refused close,
190
+ // and Poodle's shell does not reach here in that case.
191
+ if (!session.requestClose()) return;
192
+ open = false;
193
+ onOpenChange?.(false);
194
+ }
195
+ </script>
196
+
197
+ <PoodleSettingsShell
198
+ bind:open
199
+ {title}
200
+ {ariaLabel}
201
+ groups={navigationGroups}
202
+ activePageId={session.route?.pageId ?? null}
203
+ pageTitle={currentPage?.label ?? null}
204
+ bind:searchQuery
205
+ {closeRefusedReason}
206
+ onNavigate={navigate}
207
+ onRequestClose={handleRequestClose}
208
+ onOpenChange={handleOpenChange}
209
+ >
210
+ {#snippet page()}
211
+ {#if session.status.kind === "loading"}
212
+ <Callout tone="pending" title="Loading settings" announceMode="polite" />
213
+ {:else if session.status.kind === "reconnecting"}
214
+ <Callout tone="pending" title="Reconnecting settings" announceMode="polite" />
215
+ {:else if session.status.kind === "unsupported"}
216
+ <Callout
217
+ tone="warning"
218
+ title="Settings unavailable"
219
+ message={session.status.reason}
220
+ announceMode="polite"
221
+ />
222
+ {:else if session.status.kind === "failed"}
223
+ <Callout
224
+ tone="danger"
225
+ title="Settings failed"
226
+ message={String(session.status.error)}
227
+ announceMode="assertive"
228
+ >
229
+ {#snippet actions()}
230
+ <Button
231
+ variant="secondary"
232
+ onClick={() => void session.reconnect().catch(() => undefined)}
233
+ >
234
+ Retry
235
+ </Button>
236
+ {/snippet}
237
+ </Callout>
238
+ {:else if currentPage && renderer && context}
239
+ <!-- No page heading. Poodle's nav rail already names the current page
240
+ and its page region carries the label as its accessible name, so a
241
+ second visible title was the duplication the redesign removed. No
242
+ close button either: the dialog has one. -->
243
+ <section
244
+ bind:this={focusTarget}
245
+ class="longhorn-settings-shell__page-focus"
246
+ tabindex="-1"
247
+ data-page-id={currentPage.id}
248
+ data-anchor-id={session.route?.anchorId}
249
+ >
250
+ {#if session.recovery}
251
+ <Callout
252
+ tone="danger"
253
+ title="Recovery required"
254
+ message={session.recovery.code}
255
+ announceMode="assertive"
256
+ />
257
+ {/if}
258
+
259
+ {#if pendingActivation.length > 0}
260
+ <Callout
261
+ tone="info"
262
+ title="Activation required"
263
+ message={pendingActivation.map(({ targetId }) => targetId).join(", ")}
264
+ announceMode="polite"
265
+ />
266
+ {/if}
267
+
268
+ {#if unitStatus.kind === "pending"}
269
+ <Callout tone="pending" title="Saving" announceMode="polite" />
270
+ {:else if unitStatus.kind === "saved"}
271
+ <Callout tone="success" title="Saved" announceMode="polite" />
272
+ {:else if unitStatus.kind === "conflict"}
273
+ <Callout
274
+ tone="warning"
275
+ title="Settings changed elsewhere"
276
+ message="Your draft is preserved. Review the current values before applying again."
277
+ announceMode="assertive"
278
+ />
279
+ {:else if unitStatus.kind === "rejected"}
280
+ <Callout
281
+ tone="danger"
282
+ title="Change rejected"
283
+ message={unitStatus.rejection.code}
284
+ announceMode="assertive"
285
+ />
286
+ {:else if unitStatus.kind === "failed"}
287
+ <Callout
288
+ tone="danger"
289
+ title="Save failed"
290
+ message={String(unitStatus.error)}
291
+ announceMode="assertive"
292
+ />
293
+ {/if}
294
+
295
+ <div class="longhorn-settings-shell__consumer-page">
296
+ {@render renderer(context)}
297
+ </div>
298
+
299
+ {#if hasStagedUnit}
300
+ <FormActions>
301
+ <Button
302
+ variant="secondary"
303
+ disabled={!session.dirty || session.busy}
304
+ onClick={() => session.cancelCurrent()}
305
+ >
306
+ Cancel
307
+ </Button>
308
+ <Button
309
+ variant="primary"
310
+ loading={session.busy}
311
+ disabled={!session.canApplyCurrent}
312
+ onClick={() => void session.applyCurrent().catch(() => undefined)}
313
+ >
314
+ Apply
315
+ </Button>
316
+ </FormActions>
317
+ {/if}
318
+ </section>
319
+ {/if}
320
+ {/snippet}
321
+ </PoodleSettingsShell>
322
+
323
+ <Dialog
324
+ open={session.guard !== undefined}
325
+ role="alertdialog"
326
+ title="Unsaved changes"
327
+ description="Apply or discard this page before leaving."
328
+ dismissOnBackdrop={false}
329
+ onOpenChange={(next) => {
330
+ if (!next) void session.resolveGuard("stay").catch(() => undefined);
331
+ }}
332
+ >
333
+ {#snippet actions()}
334
+ <Button
335
+ variant="ghost"
336
+ onClick={() => void session.resolveGuard("stay").catch(() => undefined)}
337
+ >
338
+ Stay
339
+ </Button>
340
+ <Button
341
+ variant="secondary"
342
+ disabled={session.busy}
343
+ onClick={() => void session.resolveGuard("discard").catch(() => undefined)}
344
+ >
345
+ Discard
346
+ </Button>
347
+ <Button
348
+ variant="primary"
349
+ loading={session.busy}
350
+ disabled={!session.canApplyCurrent}
351
+ onClick={() => void session.resolveGuard("apply").catch(() => undefined)}
352
+ >
353
+ Apply
354
+ </Button>
355
+ {/snippet}
356
+ </Dialog>
357
+
358
+ <Dialog
359
+ open={session.resetRequest !== undefined}
360
+ role="alertdialog"
361
+ title="Reset settings"
362
+ description="Remove the selected user overrides?"
363
+ dismissOnBackdrop={false}
364
+ onOpenChange={(next) => {
365
+ if (!next) void session.resolveReset(false).catch(() => undefined);
366
+ }}
367
+ >
368
+ {#snippet actions()}
369
+ <Button
370
+ variant="secondary"
371
+ onClick={() => void session.resolveReset(false).catch(() => undefined)}
372
+ >
373
+ Cancel
374
+ </Button>
375
+ <Button
376
+ variant="primary"
377
+ onClick={() => void session.resolveReset(true).catch(() => undefined)}
378
+ >
379
+ Reset
380
+ </Button>
381
+ {/snippet}
382
+ </Dialog>
@@ -0,0 +1,2 @@
1
+ export { default as SettingsShell } from "./poodle/SettingsShell.svelte";
2
+ export * from "./svelte.ts";