@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,361 @@
1
+ <script lang="ts">
2
+ import {
3
+ Button,
4
+ Callout,
5
+ ConfirmAction,
6
+ DetailItem,
7
+ Field,
8
+ FormActions,
9
+ Grid,
10
+ Select,
11
+ Stack,
12
+ Surface,
13
+ Table,
14
+ } from "@inflatable-cookie/poodle-svelte";
15
+ import type {
16
+ SelectOption,
17
+ TableColumn,
18
+ TableRow,
19
+ } from "@inflatable-cookie/poodle-svelte";
20
+ import { onMount } from "svelte";
21
+
22
+ import {
23
+ CONFIG_OPERATIONS_PROTOCOL_VERSION,
24
+ type ConfigOperationsSnapshot,
25
+ type StorageProfileId,
26
+ type StorageTransitionPreviewProjection,
27
+ type StorageTransitionReceiptProjection,
28
+ } from "@inflatable-cookie/longhorn/config";
29
+ import type { ConfigOperationsPageProps } from "./types.ts";
30
+
31
+ let {
32
+ client,
33
+ initialSnapshot = null,
34
+ nextRequestId = () => `config:${crypto.randomUUID()}`,
35
+ onSnapshot,
36
+ }: ConfigOperationsPageProps = $props();
37
+
38
+ const initialSnapshotValue = (() => initialSnapshot)();
39
+ const initialProfileValue = (() => initialSnapshot?.storage?.layout.profile ?? null)();
40
+ let snapshot = $state<ConfigOperationsSnapshot | null>(initialSnapshotValue);
41
+ let selectedProfile = $state<StorageProfileId | null>(initialProfileValue);
42
+ let preview = $state<StorageTransitionPreviewProjection | null>(null);
43
+ let receipt = $state<StorageTransitionReceiptProjection | null>(null);
44
+ let busy = $state(false);
45
+ let error = $state<string | null>(null);
46
+ let notice = $state<string | null>(null);
47
+
48
+ const storage = $derived(snapshot?.storage ?? null);
49
+ const canTransition = $derived(
50
+ snapshot?.capabilities.includes("storageTransition") === true,
51
+ );
52
+ const profileOptions = $derived<SelectOption[]>(
53
+ storage?.availableProfiles.map((value) => ({
54
+ value,
55
+ label: profileLabel(value),
56
+ })) ?? [],
57
+ );
58
+ const rootColumns: TableColumn[] = [
59
+ { id: "kind", label: "Purpose", isRowHeader: true },
60
+ { id: "path", label: "Resolved path" },
61
+ { id: "provenance", label: "Source" },
62
+ ];
63
+ const rootRows = $derived<TableRow[]>(
64
+ storage?.layout.roots.map((root) => ({
65
+ id: root.kind,
66
+ cells: {
67
+ kind: root.kind,
68
+ path: root.path,
69
+ provenance: root.provenance,
70
+ },
71
+ })) ?? [],
72
+ );
73
+
74
+ onMount(() => {
75
+ if (snapshot === null) void refresh();
76
+ });
77
+
78
+ async function refresh(): Promise<void> {
79
+ await run(async () => {
80
+ acceptSnapshot(
81
+ await client.snapshot({
82
+ protocolVersion: CONFIG_OPERATIONS_PROTOCOL_VERSION,
83
+ requestId: nextRequestId(),
84
+ }),
85
+ );
86
+ });
87
+ }
88
+
89
+ async function inspect(): Promise<void> {
90
+ const targetProfile = selectedProfile;
91
+ if (targetProfile === null) return;
92
+ await run(async () => {
93
+ receipt = null;
94
+ const outcome = await client.inspectStorageTransition({
95
+ protocolVersion: CONFIG_OPERATIONS_PROTOCOL_VERSION,
96
+ requestId: nextRequestId(),
97
+ targetProfile,
98
+ includeLogs: true,
99
+ });
100
+ if (outcome.status === "ready") {
101
+ preview = outcome.preview;
102
+ notice =
103
+ outcome.preview.conflicts.length === 0
104
+ ? "Transition inspected. Review the exact plan before confirming."
105
+ : "Transition has blocking conflicts and cannot be confirmed.";
106
+ } else {
107
+ reject(outcome.rejection.detail);
108
+ }
109
+ });
110
+ }
111
+
112
+ async function execute(): Promise<void> {
113
+ if (snapshot === null || preview === null) return;
114
+ await run(async () => {
115
+ const outcome = await client.executeStorageTransition({
116
+ protocolVersion: CONFIG_OPERATIONS_PROTOCOL_VERSION,
117
+ requestId: nextRequestId(),
118
+ generation: snapshot!.generation,
119
+ confirmationDigest: preview!.confirmationDigest,
120
+ });
121
+ if (outcome.status === "committed") {
122
+ receipt = outcome.receipt;
123
+ preview = null;
124
+ acceptSnapshot(outcome.snapshot);
125
+ notice = `Storage transition ${outcome.receipt.transitionId} committed.`;
126
+ } else {
127
+ reject(outcome.rejection.detail);
128
+ }
129
+ });
130
+ }
131
+
132
+ async function recover(): Promise<void> {
133
+ await run(async () => {
134
+ const outcome = await client.recoverStorage({
135
+ protocolVersion: CONFIG_OPERATIONS_PROTOCOL_VERSION,
136
+ requestId: nextRequestId(),
137
+ });
138
+ if (outcome.status === "recovered") {
139
+ acceptSnapshot(outcome.snapshot);
140
+ notice = outcome.receipt.detail;
141
+ } else {
142
+ reject(outcome.rejection.detail);
143
+ }
144
+ });
145
+ }
146
+
147
+ async function cleanup(): Promise<void> {
148
+ if (receipt === null) return;
149
+ await run(async () => {
150
+ const outcome = await client.cleanupStorage({
151
+ protocolVersion: CONFIG_OPERATIONS_PROTOCOL_VERSION,
152
+ requestId: nextRequestId(),
153
+ transitionId: receipt!.transitionId,
154
+ transitionReceiptDigest: receipt!.receiptDigest,
155
+ });
156
+ if (outcome.status === "applied") {
157
+ acceptSnapshot(outcome.snapshot);
158
+ notice = `${outcome.receipt.removedPaths.length} retained source path(s) removed.`;
159
+ receipt = null;
160
+ } else {
161
+ reject(outcome.rejection.detail);
162
+ }
163
+ });
164
+ }
165
+
166
+ async function run(action: () => Promise<void>): Promise<void> {
167
+ busy = true;
168
+ error = null;
169
+ notice = null;
170
+ try {
171
+ await action();
172
+ } catch (cause) {
173
+ error = cause instanceof Error ? cause.message : String(cause);
174
+ } finally {
175
+ busy = false;
176
+ }
177
+ }
178
+
179
+ function reject(detail: string): void {
180
+ error = detail;
181
+ }
182
+
183
+ function acceptSnapshot(value: ConfigOperationsSnapshot): void {
184
+ snapshot = value;
185
+ selectedProfile ??= value.storage?.layout.profile ?? null;
186
+ onSnapshot?.(value);
187
+ }
188
+
189
+ function profileLabel(profile: StorageProfileId): string {
190
+ switch (profile) {
191
+ case "platform-native-v1":
192
+ return "Platform native";
193
+ case "unified-app-root-v1":
194
+ return "Unified app root";
195
+ case "shared-product-root-v1":
196
+ return "Shared product root";
197
+ case "portable-v1":
198
+ return "Portable";
199
+ }
200
+ }
201
+ </script>
202
+
203
+ <div aria-busy={busy}>
204
+ <Stack gap="md">
205
+ {#if error}
206
+ <Callout tone="danger" title="Storage operation failed" message={error} announceMode="assertive" />
207
+ {/if}
208
+ {#if notice}
209
+ <Callout tone="success" title="Storage operation complete" message={notice} announceMode="polite" />
210
+ {/if}
211
+
212
+ <!-- Three different situations used to render this one warning: the first
213
+ read still in flight, a read that failed, and a host that genuinely
214
+ composed no storage diagnostics. Only the third is what the message claims, and a
215
+ Retry beside the other two is either pointless or premature. The load
216
+ is now its own state, so what a reader sees is what happened. -->
217
+ {#if storage === null && snapshot === null && busy}
218
+ <Callout tone="pending" title="Loading storage diagnostics" announceMode="polite" />
219
+ {:else if snapshot === null}
220
+ <Callout
221
+ tone="warning"
222
+ title="Settings could not be read"
223
+ message="No configuration snapshot arrived. The read did not fail, so the host answered with nothing."
224
+ >
225
+ {#snippet actions()}
226
+ <Button onClick={() => void refresh()}>Retry</Button>
227
+ {/snippet}
228
+ </Callout>
229
+ {:else if storage === null}
230
+ <Callout
231
+ tone="warning"
232
+ title="Storage diagnostics unavailable"
233
+ message="This host did not compose storage diagnostics for this window."
234
+ >
235
+ {#snippet actions()}
236
+ <Button onClick={() => void refresh()} loading={busy}>Retry</Button>
237
+ {/snippet}
238
+ </Callout>
239
+ {:else}
240
+ {#if storage.bootstrap.state === "recoveryRequired"}
241
+ <Callout
242
+ tone="danger"
243
+ title="Storage recovery required"
244
+ message={storage.bootstrap.detail}
245
+ announceMode="assertive"
246
+ >
247
+ {#snippet actions()}
248
+ <ConfirmAction
249
+ title="Recover storage selection?"
250
+ description="The host will inspect the journal and locator before choosing a safe terminal state."
251
+ tone="warning"
252
+ triggerLabel="Recover"
253
+ confirmLabel="Run recovery"
254
+ onConfirm={recover}
255
+ />
256
+ {/snippet}
257
+ </Callout>
258
+ {/if}
259
+
260
+ {#each storage.layout.warnings as warning (warning)}
261
+ <Callout tone="warning" title="Profile consequence" message={warning} />
262
+ {/each}
263
+
264
+ <Surface asRole="region" label="Active storage identity">
265
+ <Grid columns="repeat(auto-fit, minmax(14rem, 1fr))" gap="md">
266
+ <DetailItem label="Profile" value={profileLabel(storage.layout.profile)} />
267
+ <DetailItem label="Application identity" value={storage.layout.canonicalApplicationId} />
268
+ <DetailItem label="Directory leaf" value={storage.layout.effectiveLeaf} />
269
+ <DetailItem label="Leaf source" value={storage.layout.leafProvenance} />
270
+ <DetailItem label="Platform" value={storage.layout.platform} />
271
+ <DetailItem label="Layout digest" value={storage.layout.layoutDigest} truncateValue={true} />
272
+ </Grid>
273
+ </Surface>
274
+
275
+ <Table
276
+ columns={rootColumns}
277
+ rows={rootRows}
278
+ caption="Resolved storage roots"
279
+ ariaLabel="Resolved storage roots"
280
+ />
281
+
282
+ {#if canTransition}
283
+ <Surface asRole="region" label="Change storage profile">
284
+ <Field id="longhorn-storage-profile" label="Storage profile">
285
+ <Grid columns="minmax(12rem, 1fr) auto" gap="sm">
286
+ <Stack>
287
+ <Select
288
+ id="longhorn-storage-profile"
289
+ value={selectedProfile}
290
+ options={profileOptions}
291
+ native={true}
292
+ disabled={busy}
293
+ onValueChange={(value) => (selectedProfile = value as StorageProfileId)}
294
+ />
295
+ </Stack>
296
+ <Stack direction="row" align="end">
297
+ <Button
298
+ variant="secondary"
299
+ disabled={busy || selectedProfile === storage.layout.profile}
300
+ onClick={() => void inspect()}
301
+ >
302
+ Inspect change
303
+ </Button>
304
+ </Stack>
305
+ </Grid>
306
+ </Field>
307
+ </Surface>
308
+ {/if}
309
+
310
+ {#if preview}
311
+ <Surface asRole="region" label="Storage transition preview">
312
+ <h3>Transition preview</h3>
313
+ <p>{preview.domains.length} registered domain action(s).</p>
314
+ {#if preview.unknownSourcePaths.length > 0}
315
+ <Callout
316
+ tone="warning"
317
+ title="Unregistered files will be retained"
318
+ message={preview.unknownSourcePaths.join(", ")}
319
+ />
320
+ {/if}
321
+ {#each preview.conflicts as conflict (`${conflict.kind}:${conflict.path ?? ""}`)}
322
+ <Callout tone="danger" title={conflict.kind} message={conflict.detail} />
323
+ {/each}
324
+ <FormActions>
325
+ <Button variant="ghost" onClick={() => (preview = null)}>Cancel</Button>
326
+ {#if preview.conflicts.length === 0}
327
+ <ConfirmAction
328
+ title="Change storage profile?"
329
+ description="The host will recheck this exact evidence, journal the transition, and commit the locator last."
330
+ tone="warning"
331
+ triggerLabel="Confirm transition"
332
+ confirmLabel="Change profile"
333
+ onConfirm={execute}
334
+ >
335
+ <p>Confirmation digest: {preview.confirmationDigest}</p>
336
+ </ConfirmAction>
337
+ {/if}
338
+ </FormActions>
339
+ </Surface>
340
+ {/if}
341
+
342
+ {#if receipt && receipt.retainedSourcePaths.length > 0}
343
+ <Callout
344
+ tone="info"
345
+ title="Old storage retained"
346
+ message={`${receipt.retainedSourcePaths.length} source path(s) remain available for rollback.`}
347
+ >
348
+ {#snippet actions()}
349
+ <ConfirmAction
350
+ title="Remove retained old storage?"
351
+ description="Cleanup is authorized only by this committed transition receipt and cannot be undone."
352
+ triggerLabel="Clean up old storage"
353
+ confirmLabel="Remove exact paths"
354
+ onConfirm={cleanup}
355
+ />
356
+ {/snippet}
357
+ </Callout>
358
+ {/if}
359
+ {/if}
360
+ </Stack>
361
+ </div>
@@ -0,0 +1,63 @@
1
+ import {
2
+ RESTORE_COMPATIBILITY_LABEL_TEMPLATES,
3
+ renderLabelTemplate,
4
+ type RestoreDomainCompatibilityProjection,
5
+ type RestoreDomainInspectionProjection,
6
+ type RestoreIdentityStatusProjection,
7
+ } from "@inflatable-cookie/longhorn/config";
8
+
9
+ export type RestoreChoice = "" | "useArchive" | "keepCurrent";
10
+
11
+ export function canUseArchive(
12
+ domain: RestoreDomainInspectionProjection,
13
+ ): boolean {
14
+ return (
15
+ domain.compatibility.status === "ready" ||
16
+ domain.compatibility.status === "migrationRequired"
17
+ );
18
+ }
19
+
20
+ /**
21
+ * Renders a compatibility classification from the generated template table.
22
+ *
23
+ * The templates come from Rust, where the wording lives on the classification
24
+ * itself, and Rust renders from the same table — so the two backends cannot
25
+ * word a classification differently. Six of the thirteen interpolate their own
26
+ * fields, which is why this is a template table rather than a finished-string
27
+ * map. See memo 022, D2, and Card 170.
28
+ */
29
+ export function compatibilityLabel(
30
+ compatibility: RestoreDomainCompatibilityProjection,
31
+ ): string {
32
+ const template = RESTORE_COMPATIBILITY_LABEL_TEMPLATES[compatibility.status];
33
+ return renderLabelTemplate(template, fieldsOf(compatibility));
34
+ }
35
+
36
+ function fieldsOf(
37
+ compatibility: RestoreDomainCompatibilityProjection,
38
+ ): Record<string, string> {
39
+ const fields: Record<string, string> = {};
40
+ for (const [key, value] of Object.entries(compatibility)) {
41
+ if (key !== "status" && (typeof value === "string" || typeof value === "number")) {
42
+ fields[key] = String(value);
43
+ }
44
+ }
45
+ return fields;
46
+ }
47
+
48
+ /**
49
+ * Renders one identity comparison, naming both sides when they differ.
50
+ *
51
+ * Mirrors `longhorn_poodle::config::identity_label`. Not generated: the
52
+ * mismatch arm interpolates two fields into a sentence rather than a label,
53
+ * and a template table for two arms would be more machinery than it saves.
54
+ * Kept here so no surface renders `mismatch` — the serde wire form — at an
55
+ * operator. See memo 022, D1.
56
+ */
57
+ export function identityLabel(
58
+ status: RestoreIdentityStatusProjection,
59
+ ): string {
60
+ return status.status === "compatible"
61
+ ? "Compatible"
62
+ : `Mismatch: host expects ${status.expected}, archive declares ${status.archive}`;
63
+ }
@@ -0,0 +1,11 @@
1
+ import type {
2
+ ConfigOperationsClient,
3
+ ConfigOperationsSnapshot,
4
+ } from "@inflatable-cookie/longhorn/config";
5
+
6
+ export interface ConfigOperationsPageProps {
7
+ client: ConfigOperationsClient;
8
+ initialSnapshot?: ConfigOperationsSnapshot | null;
9
+ nextRequestId?: () => string;
10
+ onSnapshot?: (snapshot: ConfigOperationsSnapshot) => void;
11
+ }
@@ -0,0 +1,8 @@
1
+ export { default as StorageSettingsPage } from "./poodle/StorageSettingsPage.svelte";
2
+ export { default as BackupSettingsPage } from "./poodle/BackupSettingsPage.svelte";
3
+ export { default as RestoreSettingsPage } from "./poodle/RestoreSettingsPage.svelte";
4
+ export type { ConfigOperationsPageProps } from "./poodle/types.ts";
5
+
6
+ export const STORAGE_SETTINGS_RENDERER_ID = "longhorn:config.storage";
7
+ export const BACKUP_SETTINGS_RENDERER_ID = "longhorn:config.backup";
8
+ export const RESTORE_SETTINGS_RENDERER_ID = "longhorn:config.restore";
@@ -0,0 +1,13 @@
1
+ import { onMount } from "svelte";
2
+
3
+ import type { HistorySession } from "./session.svelte.ts";
4
+
5
+ export function useHistorySession(getSession: () => HistorySession): void {
6
+ onMount(() => {
7
+ const session = getSession();
8
+ void session.start().catch(() => undefined);
9
+ return () => {
10
+ void session.stop();
11
+ };
12
+ });
13
+ }
@@ -0,0 +1,97 @@
1
+ import {
2
+ HistoryController,
3
+ type HistoryControllerOptions,
4
+ type HistoryControllerStatus,
5
+ } from "@inflatable-cookie/longhorn/history";
6
+ import type {
7
+ HistoryEntryId,
8
+ HistoryEntryRecord,
9
+ HistoryNavigationRejectionProjection,
10
+ HistoryNavigationResult,
11
+ HistoryPageSnapshot,
12
+ HistorySnapshot,
13
+ } from "@inflatable-cookie/longhorn/history/protocol";
14
+
15
+ export class HistorySession {
16
+ readonly #controller: HistoryController;
17
+ readonly #unobserve: () => void;
18
+ status = $state<HistoryControllerStatus>({ kind: "idle" });
19
+ snapshot = $state<HistorySnapshot | undefined>();
20
+ pageSnapshot = $state<HistoryPageSnapshot | undefined>();
21
+ entries = $state<HistoryEntryRecord[]>([]);
22
+ rejection = $state<HistoryNavigationRejectionProjection | undefined>();
23
+ filter = $state("");
24
+ page = $state(1);
25
+ pageSize = $state(50);
26
+ totalEntries = $state(0);
27
+ navigationPending = $state(false);
28
+ canUndo = $state(false);
29
+ canRedo = $state(false);
30
+
31
+ constructor(options: HistoryControllerOptions) {
32
+ this.#controller = new HistoryController(options);
33
+ this.#unobserve = this.#controller.observe(() => this.#sync());
34
+ this.#sync();
35
+ }
36
+
37
+ start(): Promise<void> {
38
+ return this.#controller.start();
39
+ }
40
+
41
+ stop(): Promise<void> {
42
+ return this.#controller.stop();
43
+ }
44
+
45
+ refresh(): Promise<void> {
46
+ return this.#controller.refresh();
47
+ }
48
+
49
+ async dispose(): Promise<void> {
50
+ this.#unobserve();
51
+ await this.#controller.stop();
52
+ }
53
+
54
+ setFilter(value: string): void {
55
+ this.#controller.setFilter(value);
56
+ }
57
+
58
+ setPage(value: number): Promise<void> {
59
+ return this.#controller.setPage(value);
60
+ }
61
+
62
+ setPageSize(value: number): Promise<void> {
63
+ return this.#controller.setPageSize(value);
64
+ }
65
+
66
+ undo(): Promise<HistoryNavigationResult> {
67
+ return this.#controller.undo();
68
+ }
69
+
70
+ redo(): Promise<HistoryNavigationResult> {
71
+ return this.#controller.redo();
72
+ }
73
+
74
+ checkout(entryId: HistoryEntryId): Promise<HistoryNavigationResult> {
75
+ return this.#controller.checkout(entryId);
76
+ }
77
+
78
+ /** Card 191. The position before the oldest retained entry, in one step. */
79
+ checkoutRoot(): Promise<HistoryNavigationResult> {
80
+ return this.#controller.checkoutRoot();
81
+ }
82
+
83
+ #sync(): void {
84
+ this.status = this.#controller.status;
85
+ this.snapshot = this.#controller.snapshot;
86
+ this.pageSnapshot = this.#controller.pageSnapshot;
87
+ this.entries = [...this.#controller.entries];
88
+ this.rejection = this.#controller.rejection;
89
+ this.filter = this.#controller.filter;
90
+ this.page = this.#controller.page;
91
+ this.pageSize = this.#controller.pageSize;
92
+ this.totalEntries = this.#controller.totalEntries;
93
+ this.navigationPending = this.#controller.navigationPending;
94
+ this.canUndo = this.#controller.canUndo;
95
+ this.canRedo = this.#controller.canRedo;
96
+ }
97
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./svelte/session.svelte.ts";
2
+ export * from "./svelte/lifecycle.ts";
@@ -0,0 +1,11 @@
1
+ import { onMount } from "svelte";
2
+ import type { ForkHistorySession } from "./session.svelte.ts";
3
+ export function useForkHistorySession(getSession: () => ForkHistorySession): void {
4
+ onMount(() => {
5
+ const session = getSession();
6
+ void session.start().catch(() => undefined);
7
+ return () => {
8
+ void session.stop();
9
+ };
10
+ });
11
+ }
@@ -0,0 +1,27 @@
1
+ import { ForkHistoryController, type ForkHistoryControllerOptions, type ForkHistoryControllerStatus } from "@inflatable-cookie/longhorn/history-tree";
2
+ import type { ForkBranchId, ForkBranchPageSnapshot, ForkContinuationPageSnapshot, ForkEntryRecord, ForkPruneResult, ForkRemovalReceiptProjection, ForkNavigationResult, ForkPathPageSnapshot, ForkSnapshot } from "@inflatable-cookie/longhorn/history-tree/protocol";
3
+ export class ForkHistorySession {
4
+ readonly #controller: ForkHistoryController; readonly #unobserve: () => void;
5
+ status = $state<ForkHistoryControllerStatus>({ kind: "idle" }); snapshot = $state<ForkSnapshot>(); path = $state<ForkPathPageSnapshot>(); branches = $state<ForkBranchPageSnapshot>(); entries = $state<ForkEntryRecord[]>([]); navigationPending = $state(false); canUndo = $state(false); canRedo = $state(false);
6
+ constructor(options: ForkHistoryControllerOptions) { this.#controller = new ForkHistoryController(options); this.#unobserve = this.#controller.observe(() => this.#sync()); this.#sync(); }
7
+ start() { return this.#controller.start(); } stop() { return this.#controller.stop(); } refresh() { return this.#controller.refresh(); }
8
+ async dispose() { this.#unobserve(); await this.#controller.stop(); }
9
+ loadBranches(offset = 0) { return this.#controller.loadBranches(offset); }
10
+ selectDefaultPath() { return this.#controller.selectDefaultPath(); }
11
+ selectBranchPath(branchId: ForkBranchId) { return this.#controller.selectBranchPath(branchId); }
12
+ undo(): Promise<ForkNavigationResult> { return this.#controller.undo(); } redo(): Promise<ForkNavigationResult> { return this.#controller.redo(); }
13
+ checkout(branchId: ForkBranchId, entryId: string) { return this.#controller.checkout(branchId, entryId); }
14
+ /** Card 181. The position before a branch's first entry; a nascent branch sits here. */
15
+ checkoutBranchRoot(branchId: ForkBranchId) { return this.#controller.checkoutBranchRoot(branchId); }
16
+ /** Card 183. Every entry continuing from `anchorEntryId`, or from the root when null. */
17
+ loadContinuations(anchorEntryId: string | null, offset = 0): Promise<ForkContinuationPageSnapshot> { return this.#controller.loadContinuations(anchorEntryId, offset); }
18
+ /** Card 183. The flat run beginning at one entry, as the same page type as `path`. */
19
+ loadContinuationRun(fromEntryId: string, offset = 0): Promise<ForkPathPageSnapshot> { return this.#controller.loadContinuationRun(fromEntryId, offset); }
20
+ /** Card 186. Prune the unprotected share to a budget. */
21
+ prune(maximumEntries: number, maximumEncodedWeight: number): Promise<ForkPruneResult> { return this.#controller.prune(maximumEntries, maximumEncodedWeight); }
22
+ /** Card 185. Delete one continuation and everything below it. Irreversible. */
23
+ deleteContinuation(entryId: string): Promise<ForkRemovalReceiptProjection> { return this.#controller.deleteContinuation(entryId); }
24
+ /** Card 184. Check out the run beginning at one entry; applies none of it. */
25
+ checkoutContinuation(entryId: string): Promise<ForkNavigationResult> { return this.#controller.checkoutContinuation(entryId); }
26
+ #sync() { this.status = this.#controller.status; this.snapshot = this.#controller.snapshot; this.path = this.#controller.path; this.branches = this.#controller.branches; this.entries = [...this.#controller.entries]; this.navigationPending = this.#controller.navigationPending; this.canUndo = this.#controller.canUndo; this.canRedo = this.#controller.canRedo; }
27
+ }
@@ -0,0 +1,3 @@
1
+ export { ForkHistorySession } from "./svelte/session.svelte.ts";
2
+ export { useForkHistorySession } from "./svelte/lifecycle.ts";
3
+ export type { ForkHistoryControllerOptions, ForkHistoryControllerStatus } from "@inflatable-cookie/longhorn/history-tree";
@@ -0,0 +1,62 @@
1
+ <script lang="ts">
2
+ import { LicenceActivation as PoodleLicenceActivation } from "@inflatable-cookie/poodle-svelte";
3
+ import {
4
+ isProbablyATypo,
5
+ parseLicenceKey,
6
+ type LicenceController,
7
+ type LicenceCredentialProjection,
8
+ } from "@inflatable-cookie/longhorn/licence";
9
+
10
+ import { sampleLicenceController } from "./LicenceSurface.svelte.ts";
11
+
12
+ /**
13
+ * Binds a `LicenceController` to Poodle's `LicenceActivation`.
14
+ *
15
+ * The key format is injected rather than mirrored — Poodle's component takes
16
+ * a `LicenceKeyFormat` and this hands it Longhorn's, which is the design
17
+ * that lets a mistyped key fail locally without the format existing a third
18
+ * time. The conformance fixture binds the two implementations that do exist.
19
+ */
20
+ interface Props {
21
+ controller: LicenceController;
22
+ /** Poodle's `mode`: key entry, or the account flow with file import. */
23
+ mode?: "key" | "account";
24
+ title?: string;
25
+ }
26
+
27
+ let { controller, mode = "key", title = "Activate licence" }: Props = $props();
28
+
29
+ const licence = sampleLicenceController(() => controller);
30
+
31
+ function activate(detail: {
32
+ credential: LicenceCredentialProjection;
33
+ label: string | null;
34
+ }): void {
35
+ void controller.activate(detail.credential, detail.label);
36
+ }
37
+ </script>
38
+
39
+ {#if mode === "key"}
40
+ <PoodleLicenceActivation
41
+ mode="key"
42
+ keyFormat={{ parse: parseLicenceKey, isProbablyATypo }}
43
+ pending={licence.pending}
44
+ {title}
45
+ onActivate={activate}
46
+ />
47
+ {:else}
48
+ <PoodleLicenceActivation
49
+ mode="account"
50
+ accountTokenProvider={{
51
+ // The account flow needs a browser round trip the licence host owns.
52
+ // Card 159's licence half waits on the CredentialStore decision, and
53
+ // until then the account route reports itself unavailable rather than
54
+ // pretending: a button that silently does nothing is worse than one
55
+ // that says why.
56
+ acquire: () => Promise.reject(new Error("account sign-in is not composed yet")),
57
+ }}
58
+ pending={licence.pending}
59
+ {title}
60
+ onActivate={activate}
61
+ />
62
+ {/if}