@phreshos/react 0.1.15 → 0.1.16

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
@@ -48,7 +48,7 @@ useProcessState(process)
48
48
  // { exited, serverExists, clientExists } | undefined
49
49
 
50
50
  useServiceState(service)
51
- // { enabled } | undefined
51
+ // { exists } | undefined
52
52
 
53
53
  useWindowState(window)
54
54
  // WindowState | undefined
@@ -1,7 +1,7 @@
1
1
  import type { Service } from "@phreshos/client";
2
- /** Live availability of one exact service identity. */
2
+ /** Live existence of one configured Endpoint service. */
3
3
  export type ServiceState = Readonly<{
4
- enabled: boolean;
4
+ exists: boolean;
5
5
  }>;
6
6
  /** Explicitly reads and follows one service while this hook is mounted. */
7
7
  export default function useServiceState(service: Service): 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 () => ({ enabled: await service.enabled() }), reduce => combineCleanups(service.lifecycle.subscribe("enable", () => reduce(current => setEnabled(current, true))), service.lifecycle.subscribe("disable", () => reduce(current => setEnabled(current, false))))), [service]);
5
+ const state = useMemo(() => new LiveState(async () => ({ exists: await service.exists() }), reduce => combineCleanups(service.lifecycle.subscribe("start", () => reduce(current => setExists(current, true))), service.lifecycle.subscribe("stop", () => reduce(current => setExists(current, false))))), [service]);
6
6
  return useSyncExternalStore(state.subscribe, state.snapshot, state.snapshot);
7
7
  }
8
- function setEnabled(state, enabled) {
9
- return state.enabled === enabled ? state : { enabled };
8
+ function setExists(state, exists) {
9
+ return state.exists === exists ? state : { exists };
10
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phreshos/react",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
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.27",
51
- "@phreshos/core": "^0.1.27",
50
+ "@phreshos/client": "^0.1.28",
51
+ "@phreshos/core": "^0.1.29",
52
52
  "react": "^19.2.0"
53
53
  },
54
54
  "devDependencies": {
55
- "@phreshos/client": "^0.1.27",
56
- "@phreshos/core": "^0.1.27",
55
+ "@phreshos/client": "^0.1.28",
56
+ "@phreshos/core": "^0.1.29",
57
57
  "@testing-library/react": "^16.3.0",
58
58
  "@types/react": "^19.2.18",
59
59
  "@types/react-dom": "^19.2.4",