@phreshos/react 0.1.19 → 0.1.21

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
@@ -2,9 +2,20 @@
2
2
 
3
3
  Runtime-neutral React adapters for PhreshOS contracts.
4
4
 
5
- The React SDK receives explicit Core handles and live sources. It does not
6
- initialize transport, import the Client SDK, access the browser, or define
7
- domain state.
5
+ [Documentation](https://docs.phreshos.com/sdks/react) ·
6
+ [Runtime model](https://docs.phreshos.com/runtime) ·
7
+ [Source](https://github.com/PhreshOS/react)
8
+
9
+ ## Role
10
+
11
+ The React SDK adapts explicitly supplied Core contracts and live sources to
12
+ React providers and hooks. It does not initialize a transport, import the
13
+ Client SDK, access the browser, define domain state, or render visual language.
14
+
15
+ `SystemProvider`, `ContextProvider`, and `DesktopProvider` preserve the
16
+ separation between the global System, current Client Context, and containing
17
+ Desktop. State and subscription hooks preserve unresolved state and own only
18
+ their React lifecycle.
8
19
 
9
20
  ## Installation
10
21
 
@@ -17,54 +28,22 @@ domain state.
17
28
 
18
29
  `@phreshos/core` and React are peer dependencies.
19
30
 
20
- ## Providers
21
-
22
31
  ```tsx
23
- import { ContextProvider, DesktopProvider, SystemProvider } from "@phreshos/react"
32
+ import {
33
+ ContextProvider,
34
+ DesktopProvider,
35
+ SystemProvider,
36
+ } from "@phreshos/react"
24
37
 
25
38
  <SystemProvider system={system}>
26
39
  <DesktopProvider desktop={desktop}>
27
- <ContextProvider context={context}>
28
- {children}
29
- </ContextProvider>
40
+ <ContextProvider context={context}>{children}</ContextProvider>
30
41
  </DesktopProvider>
31
42
  </SystemProvider>
32
43
  ```
33
44
 
34
- Each provider receives one complete Core contract. The three roots remain
35
- separate: global System, current Client Context, and Client Desktop.
36
-
37
- ## Hooks
38
-
39
- Context hooks expose the supplied handles:
40
-
41
- - `useContext()`
42
- - `useProgram()`
43
- - `useProcess()`
44
- - `useParent()`
45
-
46
- System hooks expose the System and its live Appearance:
47
-
48
- - `useSystem()`
49
- - `useSystemAppearance()`
50
-
51
- Desktop hooks expose the Desktop and its live state:
52
-
53
- - `useDesktop()`
54
- - `useDesktopSurface()`
55
- - `useDesktopPreferences()`
56
-
57
- State hooks compose one explicit read with future events:
58
-
59
- - `useProgramState()`
60
- - `useProcessState()`
61
- - `useEndpointState()`
62
- - `useServiceState()`
63
- - `useWindowState()`
64
-
65
- `useSubscribe()`, `useSubscribeAsks()`, and `useSubscribeAnswers()` own
66
- their mounted registrations and clean them up on unmount. Unresolved initial
67
- reads remain `undefined`; the adapters do not invent fallback domain state.
45
+ See [React SDK](https://docs.phreshos.com/sdks/react) for providers, state
46
+ hooks, and subscription hooks.
68
47
 
69
48
  ## Development
70
49
 
@@ -73,13 +52,21 @@ bun install --frozen-lockfile
73
52
  bun run verify
74
53
  ```
75
54
 
76
- `verify` checks the contracts, tests the adapters in React, builds the package,
77
- and validates its public artifact.
55
+ `verify` checks the contracts, tests the adapters, builds the package, and
56
+ validates its published shape.
57
+
58
+ ## Related repositories
78
59
 
79
- ## Repository boundary
60
+ - [`@phreshos/core`](https://github.com/PhreshOS/core) owns every contract
61
+ accepted by these adapters.
62
+ - [`@phreshos/client`](https://github.com/PhreshOS/client) supplies Client
63
+ runtime values without becoming a dependency of this package.
64
+ - [`@phreshos/react-ui`](https://github.com/PhreshOS/react-ui) owns reusable
65
+ visual components and Appearance interpretation.
66
+ - [PhreshOS System](https://github.com/PhreshOS/system) composes these adapters
67
+ in the Desktop.
80
68
 
81
- This repository owns React lifecycle adaptation only. Core owns the contracts,
82
- runtime SDKs provide the sources, and React UI owns visual components.
69
+ ## Contributing
83
70
 
84
71
  See [CONTRIBUTING.md](CONTRIBUTING.md) for the repository workflow and
85
72
  [SECURITY.md](SECURITY.md) for private vulnerability reporting.
@@ -1,9 +1,7 @@
1
1
  import type { Process } from "@phreshos/core";
2
- /** Mutable lifecycle state of one Process and its Endpoint incarnations. */
2
+ /** Mutable lifecycle state of one Process. */
3
3
  export type ProcessState = Readonly<{
4
4
  exited: boolean;
5
- serverExists: boolean;
6
- clientExists: boolean;
7
5
  }>;
8
6
  /** Explicitly reads and follows one Process while this hook is mounted. */
9
7
  export default function useProcessState(process: Process): ProcessState | undefined;
@@ -1,14 +1,7 @@
1
1
  import { useMemo, useSyncExternalStore } from "react";
2
- import LiveState, { combineCleanups } from "./live-state.js";
2
+ import LiveState from "./live-state.js";
3
3
  /** Explicitly reads and follows one Process while this hook is mounted. */
4
4
  export default function useProcessState(process) {
5
- const state = useMemo(() => new LiveState(async () => {
6
- const [exited, serverExists, clientExists] = await Promise.all([
7
- process.exited(),
8
- process.server.exists(),
9
- process.client.exists()
10
- ]);
11
- return { exited, serverExists, clientExists };
12
- }, reduce => combineCleanups(process.server.lifecycle.subscribe("start", () => reduce(current => current.serverExists ? current : { ...current, serverExists: true })), process.server.lifecycle.subscribe("stop", () => reduce(current => current.serverExists ? { ...current, serverExists: false } : current)), process.client.lifecycle.subscribe("start", () => reduce(current => current.clientExists ? current : { ...current, clientExists: true })), process.client.lifecycle.subscribe("stop", () => reduce(current => current.clientExists ? { ...current, clientExists: false } : current)), process.subscribe("exit", () => reduce(current => ({ ...current, exited: true, serverExists: false, clientExists: false }))))), [process]);
5
+ const state = useMemo(() => new LiveState(async () => ({ exited: await process.exited() }), reduce => process.subscribe("exit", () => reduce(current => current.exited ? current : { exited: true }))), [process]);
13
6
  return useSyncExternalStore(state.subscribe, state.snapshot, state.snapshot);
14
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phreshos/react",
3
- "version": "0.1.19",
3
+ "version": "0.1.21",
4
4
  "description": "Runtime-neutral React adapters for PhreshOS contracts.",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
@@ -47,11 +47,12 @@
47
47
  "prepack": "node --run test && node --run build"
48
48
  },
49
49
  "peerDependencies": {
50
- "@phreshos/core": "^0.1.37",
50
+ "@phreshos/core": "^0.1.42",
51
51
  "react": "^19.2.0"
52
52
  },
53
53
  "devDependencies": {
54
- "@phreshos/core": "^0.1.37",
54
+ "@phreshos/core": "^0.1.42",
55
+ "@testing-library/dom": "^10.4.1",
55
56
  "@testing-library/react": "^16.3.0",
56
57
  "@types/react": "^19.2.18",
57
58
  "@types/react-dom": "^19.2.4",