@silo-code/sdk 0.19.1 → 0.21.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 (40) hide show
  1. package/dist/context-keys.d.ts +18 -3
  2. package/dist/context-keys.d.ts.map +1 -1
  3. package/dist/domain-types.d.ts +8 -32
  4. package/dist/domain-types.d.ts.map +1 -1
  5. package/dist/extension-storage.d.ts +7 -3
  6. package/dist/extension-storage.d.ts.map +1 -1
  7. package/dist/file-service.d.ts +15 -2
  8. package/dist/file-service.d.ts.map +1 -1
  9. package/dist/index.d.ts +3 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +2 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/layout-service.d.ts +16 -4
  14. package/dist/layout-service.d.ts.map +1 -1
  15. package/dist/network-service.d.ts +24 -2
  16. package/dist/network-service.d.ts.map +1 -1
  17. package/dist/network-service.js +35 -1
  18. package/dist/network-service.js.map +1 -1
  19. package/dist/output-service.d.ts +42 -0
  20. package/dist/output-service.d.ts.map +1 -0
  21. package/dist/output-service.js +10 -0
  22. package/dist/output-service.js.map +1 -0
  23. package/dist/terminal-service.d.ts +29 -0
  24. package/dist/terminal-service.d.ts.map +1 -1
  25. package/dist/theme-service.d.ts +23 -7
  26. package/dist/theme-service.d.ts.map +1 -1
  27. package/dist/types.d.ts +124 -21
  28. package/dist/types.d.ts.map +1 -1
  29. package/package.json +2 -4
  30. package/src/context-keys.ts +18 -3
  31. package/src/domain-types.ts +8 -29
  32. package/src/extension-storage.ts +8 -3
  33. package/src/file-service.ts +16 -2
  34. package/src/index.ts +12 -1
  35. package/src/layout-service.ts +18 -4
  36. package/src/network-service.ts +34 -2
  37. package/src/output-service.ts +43 -0
  38. package/src/terminal-service.ts +31 -0
  39. package/src/theme-service.ts +23 -7
  40. package/src/types.ts +126 -22
@@ -15,11 +15,11 @@ export type {
15
15
  } from "./domain-types";
16
16
 
17
17
  /**
18
- * A selectable theme contributed via
19
- * {@link ExtensionContext.registerThemePreset}. Built-in presets (Tokyo Night,
20
- * Solarized Light, Gruvbox Dark, …) are registered by the `theme-presets`
21
- * extension; core ships only Dark and Light. A preset's {@link ThemePreset.vars}
22
- * are injected as CSS custom properties when it is the active theme.
18
+ * A selectable theme contributed via {@link ThemeService.registerPreset}.
19
+ * Built-in presets (Tokyo Night, Solarized Light, Gruvbox Dark, …) are
20
+ * registered by the `theme-presets` extension; core ships only Dark and Light.
21
+ * A preset's {@link ThemePreset.vars} are injected as CSS custom properties
22
+ * when it is the active theme.
23
23
  *
24
24
  * @category Registration
25
25
  * @public
@@ -74,8 +74,7 @@ export interface ThemeState {
74
74
  * Read via {@link ThemeService.getState | getState} /
75
75
  * {@link ThemeService.subscribe | subscribe} (e.g. with `useSyncExternalStore`);
76
76
  * drive via {@link ThemeService.setActive | setActive} and the custom-theme
77
- * methods. Contributing a *new* preset is a separate concern —
78
- * {@link ExtensionContext.registerThemePreset}.
77
+ * methods. Contribute a new preset via {@link ThemeService.registerPreset}.
79
78
  *
80
79
  * @category Consumer Services
81
80
  * @public
@@ -99,4 +98,21 @@ export interface ThemeService {
99
98
  exportTheme(theme: CustomTheme): ThemeExport;
100
99
  /** Validate/parse imported JSON into a custom theme (assigns a fresh id). */
101
100
  importTheme(data: unknown): CustomTheme;
101
+ /**
102
+ * Register a {@link ThemePreset} (a selectable theme in the picker). The
103
+ * preset appears immediately and is removed when the returned
104
+ * {@link Disposable} is disposed (typically when the extension deactivates).
105
+ *
106
+ * @example
107
+ * ```ts
108
+ * ctx.theme.registerPreset({
109
+ * id: "my-theme",
110
+ * name: "My Theme",
111
+ * base: "dark",
112
+ * colorScheme: "dark",
113
+ * vars: { "--silo-color-bg": "#1a1a2e" },
114
+ * });
115
+ * ```
116
+ */
117
+ registerPreset(preset: ThemePreset): Disposable;
102
118
  }
package/src/types.ts CHANGED
@@ -18,7 +18,6 @@
18
18
  * @packageDocumentation
19
19
  */
20
20
  import type React from "react";
21
- import type { IDockviewPanelProps } from "dockview";
22
21
  import type { ContextKeys } from "./context-keys";
23
22
  import type { WorkspaceService } from "./workspace-service";
24
23
  import type { EditorService } from "./editor-service";
@@ -33,6 +32,7 @@ import type { DndService } from "./dnd-service";
33
32
  import type { UiService } from "./ui-service";
34
33
  import type { NetworkService } from "./network-service";
35
34
  import type { SystemService } from "./system-service";
35
+ import type { LogService } from "./output-service";
36
36
  import type {
37
37
  ExtensionStorage,
38
38
  ExtensionStorageScopes,
@@ -53,26 +53,70 @@ export interface Disposable {
53
53
  }
54
54
 
55
55
  /**
56
- * The dockview panel API handed to a {@link DockPanelKind} component used to
57
- * drive the panel's own tab (title, close, focus). Re-exported from `dockview`
58
- * so extensions don't take a direct dependency on it.
56
+ * The panel API handed to a {@link DockPanelKind} component. Use these methods
57
+ * to drive the panel's own tab (title, close, focus) and update its stored
58
+ * parameters. The host provides the implementation; extensions never construct
59
+ * this object directly.
59
60
  *
60
61
  * @category Core Types
61
62
  * @public
62
63
  */
63
- export type DockPanelApi = IDockviewPanelProps["api"];
64
+ export interface DockPanelApi {
65
+ /** Update the title shown in the panel's tab. */
66
+ setTitle(title: string): void;
67
+ /** Programmatically close this panel. */
68
+ close(): void;
69
+ /** Bring this panel to focus (make it the active panel in its group). */
70
+ setActive(): void;
71
+ /** `true` while this panel is the active one in its dock group. */
72
+ readonly isActive: boolean;
73
+ /**
74
+ * Subscribe to active-state transitions. The listener is called whenever
75
+ * the panel gains or loses active status, with an event carrying the new
76
+ * state. Returns a {@link Disposable} that cancels the subscription.
77
+ */
78
+ onDidActiveChange(
79
+ listener: (event: { readonly isActive: boolean }) => void,
80
+ ): Disposable;
81
+ /**
82
+ * `true` while this panel is visible — its tab is the selected one in its
83
+ * group. Distinct from {@link DockPanelApi.isActive | isActive}: with split
84
+ * groups, every group's selected tab is visible but only one panel in the
85
+ * whole dock is active.
86
+ */
87
+ readonly isVisible: boolean;
88
+ /**
89
+ * Subscribe to visibility transitions (the panel's tab being selected or
90
+ * deselected in its group). Use to pause expensive work while hidden, or to
91
+ * re-measure on reveal (e.g. the terminal refits xterm when its tab becomes
92
+ * visible again). Returns a {@link Disposable} that cancels the subscription.
93
+ */
94
+ onDidVisibilityChange(
95
+ listener: (event: { readonly isVisible: boolean }) => void,
96
+ ): Disposable;
97
+ /**
98
+ * Shallow-merge `params` into this panel's stored parameters. Keys absent
99
+ * from `params` are left unchanged. Useful for keeping tabs-serializable
100
+ * state (e.g. the open URL in a web-viewer panel) consistent with the UI.
101
+ */
102
+ updateParameters(params: object): void;
103
+ }
64
104
 
65
105
  /**
66
106
  * Props handed to a {@link DockPanelKind} component. Use this type to annotate
67
- * your component instead of importing `IDockviewPanelProps` from `dockview`
68
- * directly — the SDK wraps it so extensions remain insulated from dockview
69
- * version changes. The optional generic `T` narrows the shape of `params`.
107
+ * your component instead of importing from the underlying dock framework
108
+ * directly — the SDK owns this surface so extensions remain insulated from
109
+ * host implementation details. The optional generic `T` narrows `params`.
70
110
  *
71
111
  * @category Core Types
72
112
  * @public
73
113
  */
74
- export type DockPanelProps<T extends object = Record<string, unknown>> =
75
- IDockviewPanelProps<T>;
114
+ export interface DockPanelProps<T extends object = Record<string, unknown>> {
115
+ /** The panel API — drives the tab (title, close, focus, params). */
116
+ api: DockPanelApi;
117
+ /** Serializable parameters forwarded to the panel at open time. */
118
+ params: T;
119
+ }
76
120
 
77
121
  /**
78
122
  * Props passed to an {@link Editor} component. An editor renders the contents of
@@ -195,8 +239,15 @@ export interface Command {
195
239
  id: string;
196
240
  /** Human-readable label (shown where the command surfaces in UI). */
197
241
  label: string;
198
- /** The action. Runs synchronously; do async work inside if needed. */
199
- run: () => void;
242
+ /**
243
+ * The action. May accept arguments passed through from
244
+ * {@link ExtensionContext.executeCommand} and may return a value (sync or
245
+ * async); `executeCommand` resolves with whatever this returns.
246
+ *
247
+ * Zero-argument, void-returning commands are still valid — `() => void`
248
+ * satisfies this type, so existing registrations compile unchanged.
249
+ */
250
+ run: (...args: unknown[]) => unknown | Promise<unknown>;
200
251
  }
201
252
 
202
253
  /**
@@ -233,7 +284,13 @@ export interface MenuItemContribution {
233
284
  * Defaults to "9_default" so unspecified items land at the bottom.
234
285
  */
235
286
  group?: string;
236
- /** Sort order within a group. Defaults to 0. */
287
+ /**
288
+ * Sort order within a group. Defaults to 0.
289
+ *
290
+ * **Convention:** built-in (core) items use negative values; extensions
291
+ * should use `0` or greater so they appear after built-in items within
292
+ * the same group by default.
293
+ */
237
294
  order?: number;
238
295
  /**
239
296
  * Optional predicate against current context keys. Items whose `when`
@@ -318,16 +375,19 @@ export interface SidePanel {
318
375
 
319
376
  /**
320
377
  * Registers a kind of dock panel (a tab that can live in the center dock area,
321
- * e.g. the terminal). Workspaces open panels of registered kinds by id.
378
+ * e.g. the terminal). Workspaces open panels of registered kinds by id. The
379
+ * optional generic `T` is the shape of the params this kind's panels are
380
+ * opened with — annotate your component with `DockPanelProps<T>` and
381
+ * {@link ExtensionContext.registerDockPanelKind} infers it, no casts needed.
322
382
  *
323
383
  * @category Registration
324
384
  * @public
325
385
  */
326
- export interface DockPanelKind {
386
+ export interface DockPanelKind<T extends object = Record<string, unknown>> {
327
387
  /** Unique id for this panel kind. */
328
388
  id: string;
329
- /** The React component; receives the raw dockview panel props. */
330
- component: React.ComponentType<IDockviewPanelProps>;
389
+ /** The React component that renders this panel; receives {@link DockPanelProps}. */
390
+ component: React.ComponentType<DockPanelProps<T>>;
331
391
  /**
332
392
  * When set, this kind appears as an entry in the center dock's **+** add
333
393
  * menu (the per-group header button). Omit to keep the kind internal.
@@ -364,7 +424,19 @@ export interface StatusItem {
364
424
  id: string;
365
425
  /** Which end of the status bar this item sits at. */
366
426
  alignment: "left" | "right";
367
- /** Sort order within its alignment group. Lower sorts first. Defaults to 0. */
427
+ /**
428
+ * Sort order within its alignment group. Defaults to 0.
429
+ *
430
+ * The sort direction mirrors the alignment so that **negative values always
431
+ * anchor an item toward the nearest edge**:
432
+ * - **Left items** sort ascending — lower priority = closer to the left edge.
433
+ * - **Right items** sort descending — lower priority = closer to the right edge.
434
+ *
435
+ * **Convention:** built-in (core) items use negative values so they are
436
+ * anchored to their respective edges. Extensions should use `0` or greater,
437
+ * which places them between the two built-in zones by default. An extension
438
+ * may still choose a negative value intentionally to interleave with built-ins.
439
+ */
368
440
  priority?: number;
369
441
  /**
370
442
  * Tooltip shown on hover over the entire status item. The host renders a
@@ -445,20 +517,39 @@ export interface ExtensionContext {
445
517
  registerKeybinding(binding: Keybinding): Disposable;
446
518
  /** Register a {@link SidePanel} (a left/right column panel). */
447
519
  registerSidePanel(panel: SidePanel): Disposable;
448
- /** Register a {@link DockPanelKind} (a center-dock tab kind). */
449
- registerDockPanelKind(kind: DockPanelKind): Disposable;
520
+ /**
521
+ * Register a {@link DockPanelKind} (a center-dock tab kind). The params
522
+ * generic `T` is inferred from the component's {@link DockPanelProps}
523
+ * annotation, so kinds with typed params register without casts.
524
+ */
525
+ registerDockPanelKind<T extends object = Record<string, unknown>>(
526
+ kind: DockPanelKind<T>,
527
+ ): Disposable;
450
528
  /** Register a {@link StatusItem} (a status-bar widget). */
451
529
  registerStatusItem(item: StatusItem): Disposable;
452
530
  /** Register a {@link SettingsPage} (a page in the Settings dialog). */
453
531
  registerSettingsPage(page: SettingsPage): Disposable;
454
- /** Register a {@link ThemePreset} (a selectable theme in the picker). */
532
+ /**
533
+ * Register a {@link ThemePreset} (a selectable theme in the picker).
534
+ * @deprecated Use {@link ThemeService.registerPreset | ctx.theme.registerPreset()} instead.
535
+ * This method will be removed in a future release.
536
+ */
455
537
  registerThemePreset(preset: ThemePreset): Disposable;
456
538
  /**
457
539
  * Invoke a registered command by id — including commands contributed by
458
540
  * other extensions. The minimal "operate" primitive; pairs with the typed
459
541
  * services for read access.
542
+ *
543
+ * Optional positional `args` are forwarded to the command's
544
+ * {@link Command.run} function. The returned `Promise` resolves with the
545
+ * command's return value, or rejects if the command throws, is async and
546
+ * rejects, or the id is not registered. Sync commands dispatch synchronously
547
+ * before the promise settles, so callers that read state the command mutates
548
+ * immediately after `await executeCommand(…)` see the updated state.
549
+ *
550
+ * @typeParam T - Expected return type of the command (defaults to `unknown`).
460
551
  */
461
- executeCommand(id: string): void;
552
+ executeCommand<T = unknown>(id: string, ...args: unknown[]): Promise<T>;
462
553
  /**
463
554
  * Consumer API for driving workspace state — create, rename, reorder,
464
555
  * activate, soft close/reopen, and hard delete. Subscribe to a frozen
@@ -549,6 +640,19 @@ export interface ExtensionContext {
549
640
  * See {@link SystemService} for the full API.
550
641
  */
551
642
  readonly system: SystemService;
643
+ /**
644
+ * Write-only structured logger scoped to this extension. Entries appear in
645
+ * the **Output** panel under the extension's display name. A channel is
646
+ * created automatically at activation and removed at deactivation — no setup
647
+ * required.
648
+ *
649
+ * ```ts
650
+ * ctx.log.info("Extension activated");
651
+ * ctx.log.warn("Unexpected state", { detail: 42 });
652
+ * ctx.log.show(); // open the Output panel, select this extension's channel
653
+ * ```
654
+ */
655
+ readonly log: LogService;
552
656
  /**
553
657
  * Resolve a handle to another extension in order to consume the API it
554
658
  * published (the value its {@link Extension.activate} returned). This is how