@phreshos/react 0.1.5 → 0.1.7

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/README.md CHANGED
@@ -50,7 +50,7 @@ useProcessState(process)
50
50
  // { exited, serverExists, clientExists } | undefined
51
51
 
52
52
  useServiceState(service)
53
- // { disabled } | undefined
53
+ // { enabled } | undefined
54
54
 
55
55
  useWindowState(window)
56
56
  // WindowState | undefined
@@ -5,10 +5,10 @@ export default function useProgramState(program) {
5
5
  const state = useMemo(() => new LiveState(async () => {
6
6
  const [installed, processes] = await Promise.all([
7
7
  program.installed(),
8
- program.processes()
8
+ program.process.list()
9
9
  ]);
10
10
  return { installed, processes };
11
- }, reduce => combineCleanups(program.subscribe("processCreate", process => reduce(current => addProcess(current, process))), program.subscribe("processExit", ({ process }) => reduce(current => removeProcess(current, process))), program.subscribe("uninstall", () => reduce(current => current.installed ? { ...current, installed: false } : current)))), [program]);
11
+ }, reduce => combineCleanups(program.process.subscribe("create", process => reduce(current => addProcess(current, process))), program.process.subscribe("exit", ({ process }) => reduce(current => removeProcess(current, process))), program.subscribe("uninstall", () => reduce(current => current.installed ? { ...current, installed: false } : current)))), [program]);
12
12
  return useSyncExternalStore(state.subscribe, state.snapshot, state.snapshot);
13
13
  }
14
14
  function addProcess(state, process) {
@@ -1,7 +1,7 @@
1
1
  import type { ServiceHandler } from "@phreshos/client";
2
2
  /** Live availability of one exact service identity. */
3
3
  export type ServiceState = Readonly<{
4
- disabled: boolean;
4
+ enabled: boolean;
5
5
  }>;
6
6
  /** Explicitly reads and follows one service while this hook is mounted. */
7
7
  export default function useServiceState(service: ServiceHandler): ServiceState | undefined;
@@ -2,9 +2,9 @@ import { useMemo, useSyncExternalStore } from "react";
2
2
  import LiveState, { combineCleanups } from "./live-state.js";
3
3
  /** Explicitly reads and follows one service while this hook is mounted. */
4
4
  export default function useServiceState(service) {
5
- const state = useMemo(() => new LiveState(async () => ({ disabled: await service.disabled() }), reduce => combineCleanups(service.subscribe("enable", () => reduce(current => setDisabled(current, false))), service.subscribe("disable", () => reduce(current => setDisabled(current, true))))), [service]);
5
+ const state = useMemo(() => new LiveState(async () => ({ enabled: await service.enabled() }), reduce => combineCleanups(service.subscribe("enable", () => reduce(current => setEnabled(current, true))), service.subscribe("disable", () => reduce(current => setEnabled(current, false))))), [service]);
6
6
  return useSyncExternalStore(state.subscribe, state.snapshot, state.snapshot);
7
7
  }
8
- function setDisabled(state, disabled) {
9
- return state.disabled === disabled ? state : { disabled };
8
+ function setEnabled(state, enabled) {
9
+ return state.enabled === enabled ? state : { enabled };
10
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phreshos/react",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "React adapters for the Client SDK.",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
@@ -47,13 +47,13 @@
47
47
  "prepack": "node --run test && node --run build"
48
48
  },
49
49
  "peerDependencies": {
50
- "@phreshos/client": "^0.1.9",
51
- "@phreshos/core": "^0.1.6",
50
+ "@phreshos/client": "^0.1.13",
51
+ "@phreshos/core": "^0.1.9",
52
52
  "react": "^19.2.0"
53
53
  },
54
54
  "devDependencies": {
55
- "@phreshos/client": "^0.1.9",
56
- "@phreshos/core": "^0.1.6",
55
+ "@phreshos/client": "^0.1.13",
56
+ "@phreshos/core": "^0.1.9",
57
57
  "@testing-library/react": "^16.3.0",
58
58
  "@types/react": "^19.2.18",
59
59
  "@types/react-dom": "^19.2.4",