@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,295 @@
1
+ <script lang="ts">
2
+ import {
3
+ Button,
4
+ Callout,
5
+ ConfirmAction,
6
+ DetailItem,
7
+ FormActions,
8
+ Grid,
9
+ Stack,
10
+ Surface,
11
+ Table,
12
+ } from "@inflatable-cookie/poodle-svelte";
13
+ import type { TableColumn, TableRow } from "@inflatable-cookie/poodle-svelte";
14
+ import { onMount } from "svelte";
15
+
16
+ import {
17
+ CONFIG_OPERATIONS_PROTOCOL_VERSION,
18
+ type BackupArchiveProjection,
19
+ type ConfigOperationsSnapshot,
20
+ } from "@inflatable-cookie/longhorn/config";
21
+ import type { ConfigOperationsPageProps } from "./types.ts";
22
+
23
+ let {
24
+ client,
25
+ initialSnapshot = null,
26
+ nextRequestId = () => `config:${crypto.randomUUID()}`,
27
+ onSnapshot,
28
+ }: ConfigOperationsPageProps = $props();
29
+
30
+ const initialSnapshotValue = (() => initialSnapshot)();
31
+ let snapshot = $state<ConfigOperationsSnapshot | null>(initialSnapshotValue);
32
+ let busy = $state(false);
33
+ let error = $state<string | null>(null);
34
+ let notice = $state<string | null>(null);
35
+
36
+ const backup = $derived(snapshot?.backup ?? null);
37
+ const canCreate = $derived(snapshot?.capabilities.includes("backupCreate") === true);
38
+ const canExport = $derived(snapshot?.capabilities.includes("backupExport") === true);
39
+ const canRetain = $derived(snapshot?.capabilities.includes("backupRetention") === true);
40
+ const inventoryColumns: TableColumn[] = [
41
+ { id: "state", label: "State", isRowHeader: true },
42
+ { id: "path", label: "Path" },
43
+ { id: "detail", label: "Evidence" },
44
+ ];
45
+ const inventoryRows = $derived<TableRow[]>(
46
+ backup?.inventory.entries.map((entry, index) => ({
47
+ id: `${index}:${entry.path ?? entry.diagnosticKind}`,
48
+ cells: {
49
+ state: entry.state,
50
+ path: entry.path ?? "Operational root",
51
+ detail: entry.detail,
52
+ },
53
+ })) ?? [],
54
+ );
55
+
56
+ onMount(() => {
57
+ if (snapshot === null) void refresh();
58
+ });
59
+
60
+ async function refresh(): Promise<void> {
61
+ await run(async () => {
62
+ acceptSnapshot(
63
+ await client.snapshot({
64
+ protocolVersion: CONFIG_OPERATIONS_PROTOCOL_VERSION,
65
+ requestId: nextRequestId(),
66
+ }),
67
+ );
68
+ });
69
+ }
70
+
71
+ async function create(pendingPolicy: "refuse" | "flush"): Promise<void> {
72
+ await run(async () => {
73
+ const outcome = await client.createBackup({
74
+ protocolVersion: CONFIG_OPERATIONS_PROTOCOL_VERSION,
75
+ requestId: nextRequestId(),
76
+ pendingPolicy,
77
+ });
78
+ if (outcome.status === "published") {
79
+ acceptSnapshot(outcome.snapshot);
80
+ notice = `Backup published to ${outcome.publication.path}.`;
81
+ } else {
82
+ reject(outcome.rejection.detail);
83
+ }
84
+ });
85
+ }
86
+
87
+ async function exportArchive(archive: BackupArchiveProjection): Promise<void> {
88
+ await run(async () => {
89
+ const outcome = await client.exportBackup({
90
+ protocolVersion: CONFIG_OPERATIONS_PROTOCOL_VERSION,
91
+ requestId: nextRequestId(),
92
+ archiveSha256: archive.archiveSha256,
93
+ });
94
+ if (outcome.status === "published") {
95
+ acceptSnapshot(outcome.snapshot);
96
+ notice = `Backup exported to ${outcome.publication.path}.`;
97
+ } else {
98
+ reject(outcome.rejection.detail);
99
+ }
100
+ });
101
+ }
102
+
103
+ async function applyRetention(): Promise<void> {
104
+ if (snapshot === null || backup?.retention === null) return;
105
+ await run(async () => {
106
+ const outcome = await client.applyBackupRetention({
107
+ protocolVersion: CONFIG_OPERATIONS_PROTOCOL_VERSION,
108
+ requestId: nextRequestId(),
109
+ generation: snapshot!.generation,
110
+ confirmationDigest: backup!.retention!.confirmationDigest,
111
+ });
112
+ if (outcome.status === "applied") {
113
+ acceptSnapshot(outcome.snapshot);
114
+ notice = `${outcome.deletedPaths.length} proven archive(s) removed.`;
115
+ } else {
116
+ reject(outcome.rejection.detail);
117
+ }
118
+ });
119
+ }
120
+
121
+ async function run(action: () => Promise<void>): Promise<void> {
122
+ busy = true;
123
+ error = null;
124
+ notice = null;
125
+ try {
126
+ await action();
127
+ } catch (cause) {
128
+ error = cause instanceof Error ? cause.message : String(cause);
129
+ } finally {
130
+ busy = false;
131
+ }
132
+ }
133
+
134
+ function reject(detail: string): void {
135
+ error = detail;
136
+ }
137
+
138
+ function acceptSnapshot(value: ConfigOperationsSnapshot): void {
139
+ snapshot = value;
140
+ onSnapshot?.(value);
141
+ }
142
+ </script>
143
+
144
+ <div aria-busy={busy}>
145
+ <Stack gap="md">
146
+ {#if error}
147
+ <Callout tone="danger" title="Backup operation failed" message={error} announceMode="assertive" />
148
+ {/if}
149
+ {#if notice}
150
+ <Callout tone="success" title="Backup operation complete" message={notice} announceMode="polite" />
151
+ {/if}
152
+
153
+ <!-- Three different situations used to render this one warning: the first
154
+ read still in flight, a read that failed, and a host that genuinely
155
+ composed no backup inventory. Only the third is what the message claims, and a
156
+ Retry beside the other two is either pointless or premature. The load
157
+ is now its own state, so what a reader sees is what happened. -->
158
+ {#if backup === null && snapshot === null && busy}
159
+ <Callout tone="pending" title="Loading backup inventory" announceMode="polite" />
160
+ {:else if snapshot === null}
161
+ <Callout
162
+ tone="warning"
163
+ title="Settings could not be read"
164
+ message="No configuration snapshot arrived. The read did not fail, so the host answered with nothing."
165
+ >
166
+ {#snippet actions()}
167
+ <Button onClick={() => void refresh()}>Retry</Button>
168
+ {/snippet}
169
+ </Callout>
170
+ {:else if backup === null}
171
+ <Callout
172
+ tone="warning"
173
+ title="Backup inventory unavailable"
174
+ message="This host did not compose backup inventory for this window."
175
+ >
176
+ {#snippet actions()}
177
+ <Button onClick={() => void refresh()} loading={busy}>Retry</Button>
178
+ {/snippet}
179
+ </Callout>
180
+ {:else}
181
+ {#if backup.pending.state === "pending"}
182
+ <Callout
183
+ tone="warning"
184
+ title="Unpublished configuration changes"
185
+ message={`${backup.pending.domainCount} domain(s) must be refused or explicitly flushed before capture.`}
186
+ />
187
+ {/if}
188
+
189
+ {#if backup.encryption.state === "interactionRequired"}
190
+ <Callout
191
+ tone="warning"
192
+ title="Encryption interaction required"
193
+ message="Encryption identity stays in the host provider. Complete host interaction before retrying."
194
+ />
195
+ {:else if backup.encryption.state === "failed"}
196
+ <Callout tone="danger" title="Encryption unavailable" message={backup.encryption.detail} />
197
+ {/if}
198
+
199
+ <Surface asRole="region" label="Backup status">
200
+ <Grid columns="repeat(auto-fit, minmax(14rem, 1fr))" gap="md">
201
+ <DetailItem label="Operational root" value={backup.inventory.root} />
202
+ <DetailItem label="Inventory complete" value={backup.inventory.complete ? "Yes" : "No"} />
203
+ <DetailItem label="Valid archives" value={backup.inventory.archives.length} />
204
+ <DetailItem label="Encryption" value={backup.encryption.state} />
205
+ </Grid>
206
+ </Surface>
207
+
208
+ <section aria-label="Operational backups">
209
+ <h3>Operational backups</h3>
210
+ {#if backup.inventory.archives.length === 0}
211
+ <p>No valid same-app backups found.</p>
212
+ {:else}
213
+ <Stack gap="md" asRole="list">
214
+ {#each backup.inventory.archives as archive (archive.archiveSha256)}
215
+ <div role="listitem">
216
+ <Surface asRole="group" label={`Backup ${archive.archiveId}`}>
217
+ <Stack direction="row" justify="between" align="center" gap="md">
218
+ <Stack gap="sm">
219
+ <strong>{archive.createdAt}</strong>
220
+ <p>{archive.path}</p>
221
+ <small>{archive.archiveSha256}</small>
222
+ </Stack>
223
+ {#if canExport}
224
+ <Button
225
+ variant="secondary"
226
+ disabled={busy}
227
+ onClick={() => void exportArchive(archive)}
228
+ >
229
+ Export…
230
+ </Button>
231
+ {/if}
232
+ </Stack>
233
+ </Surface>
234
+ </div>
235
+ {/each}
236
+ </Stack>
237
+ {/if}
238
+ </section>
239
+
240
+ {#if backup.inventory.entries.length > 0}
241
+ <Callout
242
+ tone="info"
243
+ title="Preserved inventory"
244
+ message="Locked, corrupt, foreign, unknown, unreadable, and unmanaged entries are excluded from automatic retention."
245
+ />
246
+ <Table
247
+ columns={inventoryColumns}
248
+ rows={inventoryRows}
249
+ caption="Preserved backup inventory"
250
+ ariaLabel="Preserved backup inventory"
251
+ />
252
+ {/if}
253
+
254
+ <FormActions>
255
+ <Button variant="ghost" onClick={() => void refresh()} loading={busy}>Refresh</Button>
256
+ {#if canCreate}
257
+ {#if backup.pending.state === "pending"}
258
+ <ConfirmAction
259
+ title="Flush and create backup?"
260
+ description="The host will durably publish pending configuration before capture."
261
+ tone="warning"
262
+ triggerLabel="Flush and create"
263
+ confirmLabel="Flush and create backup"
264
+ onConfirm={() => create("flush")}
265
+ />
266
+ {:else}
267
+ <Button variant="primary" loading={busy} onClick={() => void create("refuse")}>
268
+ Create backup
269
+ </Button>
270
+ {/if}
271
+ {/if}
272
+ </FormActions>
273
+
274
+ {#if canRetain && backup.retention}
275
+ <Surface asRole="region" label="Backup retention">
276
+ <h3>Retention plan</h3>
277
+ <p>{backup.retention.deletionPaths.length} proven archive(s) are eligible for deletion.</p>
278
+ <ConfirmAction
279
+ title="Apply backup retention?"
280
+ description="The host will recheck every exact path and archive digest. Protected or uninspectable entries remain untouched."
281
+ triggerLabel="Apply retention"
282
+ confirmLabel="Delete proven archives"
283
+ onConfirm={applyRetention}
284
+ >
285
+ <Stack gap="sm" asRole="list">
286
+ {#each backup.retention.deletionPaths as path (path)}
287
+ <span role="listitem">{path}</span>
288
+ {/each}
289
+ </Stack>
290
+ </ConfirmAction>
291
+ </Surface>
292
+ {/if}
293
+ {/if}
294
+ </Stack>
295
+ </div>