@omercnet/paseo-connected-hosts 0.1.0-next.303.1 → 0.1.0-next.305.1

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.
package/client/hosts.ts CHANGED
@@ -1,7 +1,21 @@
1
- import type { HostAdd, HostDirectory, HostSummary, HostUpdate, PaseoApi } from "@getpaseo/client";
1
+ import type { HostAdd, HostDirectory, HostSummary, HostUpdate } from "@getpaseo/protocol/hosts";
2
2
  import type { SessionOutboundMessage } from "@getpaseo/protocol/messages";
3
3
  import { useCallback, useEffect, useState } from "react";
4
4
 
5
+ /** The slice of the plugin's `usePaseo()` client that follows the saved hosts. */
6
+ export interface HostsApi {
7
+ hosts: {
8
+ observe(): {
9
+ subscribe(observer: {
10
+ snapshot(directory: HostDirectory): void;
11
+ update(message: SessionOutboundMessage): void;
12
+ error(cause: unknown): void;
13
+ }): () => void;
14
+ release(): Promise<void>;
15
+ };
16
+ };
17
+ }
18
+
5
19
  export type Built<T> = { ok: true; value: T } | { ok: false; error: string };
6
20
 
7
21
  /** Prefers the daemon's `userMessage` over the transport message, which appends request details. */
@@ -103,7 +117,7 @@ export interface DirectoryHandlers {
103
117
  * Follows the selected daemon's saved hosts and returns the cleanup. `observe()` throws
104
118
  * synchronously when the daemon is offline or too old, so that is reported like any other failure.
105
119
  */
106
- export function observeDirectory(paseo: PaseoApi, handlers: DirectoryHandlers): () => void {
120
+ export function observeDirectory(paseo: HostsApi, handlers: DirectoryHandlers): () => void {
107
121
  try {
108
122
  const subscription = paseo.hosts.observe();
109
123
  const stop = subscription.subscribe({
@@ -132,7 +146,7 @@ export interface HostDirectoryState {
132
146
  }
133
147
 
134
148
  /** Live view of the selected daemon's saved hosts. Resets when the selected host changes. */
135
- export function useHostDirectory(paseo: PaseoApi): HostDirectoryState {
149
+ export function useHostDirectory(paseo: HostsApi): HostDirectoryState {
136
150
  const [directory, setDirectory] = useState<HostDirectory | null>(null);
137
151
  const [error, setError] = useState<string | null>(null);
138
152
  const [attempt, setAttempt] = useState(0);
package/client/screen.tsx CHANGED
@@ -1,7 +1,7 @@
1
- import type { HostSummary } from "@getpaseo/client";
2
1
  import type { PluginTheme } from "@getpaseo/plugin";
3
2
  import { type PluginScreenProps, usePaseo } from "@getpaseo/plugin/client";
4
3
  import { Icon, Modal, ScrollView, TextInput, useToast } from "@getpaseo/plugin/client/ui";
4
+ import type { HostSummary } from "@getpaseo/protocol/hosts";
5
5
  import { useMemo, useState } from "react";
6
6
  import { Pressable, Text, type TextStyle, View, type ViewStyle } from "react-native";
7
7
  import {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omercnet/paseo-connected-hosts",
3
- "version": "0.1.0-next.303.1",
3
+ "version": "0.1.0-next.305.1",
4
4
  "type": "module",
5
5
  "description": "A Paseo plugin that manages the daemon's connected hosts from the UI.",
6
6
  "license": "MIT",