@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,138 @@
1
+ <script lang="ts">
2
+ import { Button, Callout, FormActions, Grid, Stack, TextInput } from "@inflatable-cookie/poodle-svelte";
3
+
4
+ import type {
5
+ CommandKeymapConflict,
6
+ } from "@inflatable-cookie/longhorn/commands/protocol";
7
+ import type { CommandSettingsRecord } from "@inflatable-cookie/longhorn/commands";
8
+
9
+ interface Props {
10
+ records: readonly CommandSettingsRecord[];
11
+ conflicts?: readonly CommandKeymapConflict[];
12
+ query?: string;
13
+ captureBindingId?: string;
14
+ capturedLabel?: string | null;
15
+ dirty?: boolean;
16
+ busy?: boolean;
17
+ onQueryChange?: (query: string) => void;
18
+ onCapture?: (bindingId: string) => void;
19
+ onCancelCapture?: () => void;
20
+ onApply?: () => void;
21
+ onCancel?: () => void;
22
+ onReset?: () => void;
23
+ }
24
+
25
+ let {
26
+ records,
27
+ conflicts = [],
28
+ query = "",
29
+ captureBindingId = undefined,
30
+ capturedLabel = null,
31
+ dirty = false,
32
+ busy = false,
33
+ onQueryChange = undefined,
34
+ onCapture = undefined,
35
+ onCancelCapture = undefined,
36
+ onApply = undefined,
37
+ onCancel = undefined,
38
+ onReset = undefined,
39
+ }: Props = $props();
40
+
41
+ let visible = $derived(
42
+ query.trim().length === 0
43
+ ? records
44
+ : records.filter((record) => {
45
+ const needle = query.toLowerCase();
46
+ return (
47
+ record.label.toLowerCase().includes(needle) ||
48
+ record.id.includes(needle) ||
49
+ record.keywords.some((keyword) =>
50
+ keyword.toLowerCase().includes(needle),
51
+ )
52
+ );
53
+ }),
54
+ );
55
+ </script>
56
+
57
+ <section aria-label="Keybindings">
58
+ <Stack gap="sm">
59
+ <TextInput
60
+ type="search"
61
+ value={query}
62
+ ariaLabel="Search keybindings"
63
+ placeholder="Search commands"
64
+ onValueChange={(value) => onQueryChange?.(value)}
65
+ onClear={() => onQueryChange?.("")}
66
+ />
67
+
68
+ {#if conflicts.length > 0}
69
+ <Callout tone="warning">
70
+ {conflicts.length} unresolved keybinding
71
+ {conflicts.length === 1 ? " conflict" : " conflicts"}
72
+ </Callout>
73
+ {/if}
74
+
75
+ {#if captureBindingId !== undefined}
76
+ <Callout tone="info">
77
+ {capturedLabel ?? "Press a shortcut"}
78
+ <Button variant="ghost" onClick={() => onCancelCapture?.()}>
79
+ Cancel capture
80
+ </Button>
81
+ </Callout>
82
+ {/if}
83
+
84
+ <Stack gap="md" asRole="list">
85
+ {#each visible as record (record.id)}
86
+ <div data-command-id={record.id} role="listitem">
87
+ <Grid columns="minmax(0, 1fr) auto auto" gap="sm">
88
+ <Stack direction="row" align="center">
89
+ <Stack gap="sm">
90
+ <strong>{record.label}</strong>
91
+ {#if record.description}
92
+ <small>{record.description}</small>
93
+ {/if}
94
+ </Stack>
95
+ </Stack>
96
+ <Stack direction="row" align="center">
97
+ <span>
98
+ {record.shortcuts.map(({ label }) => label).join(", ") || "Unbound"}
99
+ </span>
100
+ </Stack>
101
+ <Stack direction="row" gap="sm" wrap={true}>
102
+ {#each record.bindings as binding (binding.id)}
103
+ <Button
104
+ variant="secondary"
105
+ disabled={busy}
106
+ onClick={() => onCapture?.(binding.id)}
107
+ >
108
+ Change {binding.id}
109
+ </Button>
110
+ {/each}
111
+ </Stack>
112
+ </Grid>
113
+ </div>
114
+ {/each}
115
+ </Stack>
116
+
117
+ <FormActions>
118
+ <Button variant="ghost" disabled={busy} onClick={() => onReset?.()}>
119
+ Reset
120
+ </Button>
121
+ <Button
122
+ variant="secondary"
123
+ disabled={!dirty || busy}
124
+ onClick={() => onCancel?.()}
125
+ >
126
+ Cancel
127
+ </Button>
128
+ <Button
129
+ variant="primary"
130
+ loading={busy}
131
+ disabled={!dirty}
132
+ onClick={() => onApply?.()}
133
+ >
134
+ Apply
135
+ </Button>
136
+ </FormActions>
137
+ </Stack>
138
+ </section>
@@ -0,0 +1,37 @@
1
+ import type {
2
+ CommandActionItem,
3
+ DiscoveryState,
4
+ } from "@inflatable-cookie/poodle-svelte";
5
+
6
+ import type {
7
+ CommandControllerStatus,
8
+ } from "@inflatable-cookie/longhorn/commands";
9
+ import type { CommandProjectionRecord } from "@inflatable-cookie/longhorn/commands";
10
+
11
+ export function toPoodleCommandItems(
12
+ records: readonly CommandProjectionRecord[],
13
+ categoryLabel: (categoryPath: readonly string[]) => string | null = (
14
+ _categoryPath,
15
+ ) => null,
16
+ ): CommandActionItem[] {
17
+ return records.map((record) => ({
18
+ id: record.id,
19
+ title: record.label,
20
+ description: record.description,
21
+ group: categoryLabel(record.categoryPath),
22
+ shortcut: record.shortcuts[0]?.label ?? null,
23
+ keywords: [...record.keywords],
24
+ disabled: record.availability.state !== "available",
25
+ }));
26
+ }
27
+
28
+ export function toPoodleDiscoveryState(
29
+ status: CommandControllerStatus,
30
+ query: string,
31
+ itemCount: number,
32
+ ): DiscoveryState {
33
+ if (status.kind === "idle" || status.kind === "loading") return "loading";
34
+ if (status.kind !== "ready") return "error";
35
+ if (itemCount === 0) return query.length === 0 ? "empty" : "no-results";
36
+ return "ready";
37
+ }
@@ -0,0 +1,9 @@
1
+ export * from "./svelte.ts";
2
+ export * from "./poodle/projectors.ts";
3
+ export type {
4
+ CommandProjectionRecord,
5
+ CommandSettingsRecord,
6
+ CommandSurfaceProjection,
7
+ } from "@inflatable-cookie/longhorn/commands";
8
+ export { default as CommandPaletteBinding } from "./poodle/CommandPaletteBinding.svelte";
9
+ export { default as KeybindingSettings } from "./poodle/KeybindingSettings.svelte";
@@ -0,0 +1,13 @@
1
+ import { onMount } from "svelte";
2
+
3
+ import type { CommandSession } from "./session.svelte.ts";
4
+
5
+ export function useCommandSession(getSession: () => CommandSession): 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,212 @@
1
+ import {
2
+ routeCommandKeyboardEvent,
3
+ type KeyboardEventLike,
4
+ } from "@inflatable-cookie/longhorn/commands";
5
+ import type {
6
+ CommandKeyChord,
7
+ CommandKeymapPatch,
8
+ CommandPlatform,
9
+ } from "@inflatable-cookie/longhorn/commands/protocol";
10
+ import type {
11
+ CommandControllerStatus,
12
+ CommandMutationStatus,
13
+ } from "@inflatable-cookie/longhorn/commands";
14
+ import { CommandController } from "@inflatable-cookie/longhorn/commands";
15
+ import type {
16
+ CommandProjectionRecord,
17
+ CommandSettingsRecord,
18
+ } from "@inflatable-cookie/longhorn/commands";
19
+
20
+ export interface CommandKeyboardTarget {
21
+ addEventListener(
22
+ type: "keydown",
23
+ listener: (event: KeyboardEventLike) => void,
24
+ ): void;
25
+ removeEventListener(
26
+ type: "keydown",
27
+ listener: (event: KeyboardEventLike) => void,
28
+ ): void;
29
+ }
30
+
31
+ export interface CommandSessionOptions {
32
+ readonly controller: CommandController;
33
+ readonly platform: CommandPlatform;
34
+ readonly contextPath: () => readonly string[];
35
+ readonly keyboardTarget?: CommandKeyboardTarget;
36
+ readonly reserved?: (
37
+ platform: CommandPlatform,
38
+ chord: CommandKeyChord,
39
+ ) => boolean;
40
+ }
41
+
42
+ export interface CapturedCommandChord {
43
+ readonly bindingId: string;
44
+ readonly chord: CommandKeyChord;
45
+ readonly label: string;
46
+ }
47
+
48
+ export class CommandSession {
49
+ readonly #controller: CommandController;
50
+ readonly #options: CommandSessionOptions;
51
+ #revision = $state(0);
52
+ #open = $state(false);
53
+ #query = $state("");
54
+ #captureBindingId = $state<string | undefined>(undefined);
55
+ #captured = $state.raw<CapturedCommandChord | undefined>(undefined);
56
+ #removeObserver: (() => void) | undefined;
57
+ #listening = false;
58
+
59
+ readonly #keydown = (event: KeyboardEventLike): void => {
60
+ this.handleKeyboard(event);
61
+ };
62
+
63
+ constructor(options: CommandSessionOptions) {
64
+ this.#controller = options.controller;
65
+ this.#options = options;
66
+ }
67
+
68
+ get status(): CommandControllerStatus {
69
+ this.#revision;
70
+ return this.#controller.status;
71
+ }
72
+
73
+ get mutation(): CommandMutationStatus {
74
+ this.#revision;
75
+ return this.#controller.mutation;
76
+ }
77
+
78
+ get projection() {
79
+ this.#revision;
80
+ return this.#controller.projection;
81
+ }
82
+
83
+ get paletteRecords(): readonly CommandProjectionRecord[] {
84
+ const records = this.projection?.palette ?? [];
85
+ if (this.#query.length === 0) return records;
86
+ const hits = new Set(
87
+ this.#controller.searchHits.map(({ record }) => record.id),
88
+ );
89
+ return records.filter(({ id }) => hits.has(id));
90
+ }
91
+
92
+ get settingsRecords(): readonly CommandSettingsRecord[] {
93
+ return this.projection?.settings ?? [];
94
+ }
95
+
96
+ get open(): boolean {
97
+ return this.#open;
98
+ }
99
+
100
+ set open(value: boolean) {
101
+ this.#open = value;
102
+ }
103
+
104
+ get query(): string {
105
+ return this.#query;
106
+ }
107
+
108
+ get captureBindingId(): string | undefined {
109
+ return this.#captureBindingId;
110
+ }
111
+
112
+ get captured(): CapturedCommandChord | undefined {
113
+ return this.#captured;
114
+ }
115
+
116
+ get dirty(): boolean {
117
+ this.#revision;
118
+ return this.#controller.dirty;
119
+ }
120
+
121
+ async start(): Promise<void> {
122
+ if (this.#removeObserver === undefined) {
123
+ this.#removeObserver = this.#controller.observe(() => {
124
+ this.#revision += 1;
125
+ });
126
+ }
127
+ if (!this.#listening && this.#options.keyboardTarget !== undefined) {
128
+ this.#options.keyboardTarget.addEventListener("keydown", this.#keydown);
129
+ this.#listening = true;
130
+ }
131
+ await this.#controller.start();
132
+ }
133
+
134
+ async stop(): Promise<void> {
135
+ if (this.#listening && this.#options.keyboardTarget !== undefined) {
136
+ this.#options.keyboardTarget.removeEventListener(
137
+ "keydown",
138
+ this.#keydown,
139
+ );
140
+ this.#listening = false;
141
+ }
142
+ this.#removeObserver?.();
143
+ this.#removeObserver = undefined;
144
+ this.#captureBindingId = undefined;
145
+ this.#captured = undefined;
146
+ this.#open = false;
147
+ this.#query = "";
148
+ await this.#controller.stop();
149
+ }
150
+
151
+ setOpen(open: boolean): void {
152
+ this.#open = open;
153
+ }
154
+
155
+ async setQuery(query: string): Promise<void> {
156
+ this.#query = query;
157
+ await this.#controller.search(query);
158
+ }
159
+
160
+ select(commandId: string): Promise<unknown> {
161
+ return this.#controller.dispatch({
162
+ commandId,
163
+ source: "palette",
164
+ });
165
+ }
166
+
167
+ beginCapture(bindingId: string): void {
168
+ this.#captureBindingId = bindingId;
169
+ this.#captured = undefined;
170
+ }
171
+
172
+ cancelCapture(): void {
173
+ this.#captureBindingId = undefined;
174
+ this.#captured = undefined;
175
+ }
176
+
177
+ stagePatch(patch: CommandKeymapPatch): void {
178
+ this.#controller.stageKeymapPatch(patch);
179
+ }
180
+
181
+ applyDraft(): Promise<boolean> {
182
+ return this.#controller.applyKeymapDraft();
183
+ }
184
+
185
+ cancelDraft(): void {
186
+ this.#controller.cancelKeymapDraft();
187
+ }
188
+
189
+ resetKeymap(): Promise<boolean> {
190
+ return this.#controller.resetKeymap();
191
+ }
192
+
193
+ handleKeyboard(event: KeyboardEventLike): void {
194
+ const model = this.#controller.model;
195
+ if (model === undefined) return;
196
+ routeCommandKeyboardEvent(event, {
197
+ platform: this.#options.platform,
198
+ contextPath: this.#options.contextPath(),
199
+ mode: this.#captureBindingId === undefined ? "dispatch" : "capture",
200
+ bindings: model.keymap.bindings,
201
+ commands: model.catalogue.commands,
202
+ reserved: this.#options.reserved,
203
+ dispatcher: this.#controller,
204
+ onCapture: (chord, label) => {
205
+ const bindingId = this.#captureBindingId;
206
+ if (bindingId === undefined) return;
207
+ this.#captured = { bindingId, chord, label };
208
+ this.#captureBindingId = undefined;
209
+ },
210
+ });
211
+ }
212
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./svelte/session.svelte.ts";
2
+ export * from "./svelte/lifecycle.ts";