@phreshos/react 0.1.10 → 0.1.12

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
@@ -20,8 +20,9 @@ It provides two kinds of adapter:
20
20
  `provide` prop, then exposes them synchronously through `useProgram()`,
21
21
  `useProcess()`, and `useParent()`.
22
22
  - `SystemProvider` subscribes before reading exactly the system values named by its
23
- required `provide` prop. `useSystemAppearance()`, `useSystemTheme()`, `useDesktopSize()`, and
24
- `usePointerPosition()` expose those values synchronously after resolution.
23
+ required `provide` prop. `useSystemAppearance()`, `useDesktopPreferences()`,
24
+ `useDesktopSize()`, and `usePointerPosition()` expose those values synchronously
25
+ after resolution.
25
26
  - `useSubscribe()` and `useObserve()` own persistent ordinary-event
26
27
  registrations for one mounted React consumer.
27
28
  - `useProgramState(program)`, `useProcessState(process)`,
@@ -88,10 +89,10 @@ subscribes before requesting each selected snapshot and prevents an older read
88
89
  from overwriting a newer event:
89
90
 
90
91
  ```tsx
91
- import { SystemProvider, useDesktopSize, useSystemAppearance, useSystemTheme } from "@phreshos/react"
92
+ import { SystemProvider, useDesktopPreferences, useDesktopSize, useSystemAppearance } from "@phreshos/react"
92
93
 
93
94
  function Content() {
94
- const theme = useSystemTheme()
95
+ const { theme } = useDesktopPreferences()
95
96
  const appearance = useSystemAppearance()
96
97
  const desktop = useDesktopSize()
97
98
 
@@ -99,7 +100,7 @@ function Content() {
99
100
  }
100
101
 
101
102
  function App() {
102
- return <SystemProvider provide={["appearance", "theme", "desktopSize"]} fallback={<p>Loading…</p>}>
103
+ return <SystemProvider provide={["appearance", "desktopPreferences", "desktopSize"]} fallback={<p>Loading…</p>}>
103
104
  <Content />
104
105
  </SystemProvider>
105
106
  }
@@ -109,7 +110,10 @@ The selection is required and non-empty. Nothing is read or subscribed merely
109
110
  because either SDK was imported, and an unselected system value never enters the
110
111
  Client. `pointerPosition` is permission-guarded: selecting it does not request
111
112
  permission, and resolution fails unless the Program already holds `pointer`.
112
- The provider renders its fallback until every selected value resolves.
113
+ The provider renders its optional fallback, or `null`, until every selected
114
+ value resolves. `useDesktopPreferences()` is a pure state adapter. The System
115
+ communicates its effective scheme through the Client iframe, while each Client
116
+ HTML document declares which schemes it supports.
113
117
 
114
118
  ```tsx
115
119
  import { current } from "@phreshos/client"
@@ -18,7 +18,7 @@ export interface CurrentProviderProperties {
18
18
  /** Content rendered after every selected current handle has resolved. */
19
19
  readonly children: ReactNode;
20
20
  /** Content rendered while selected handles or optional Server readiness resolve. */
21
- readonly fallback: ReactNode;
21
+ readonly fallback?: ReactNode;
22
22
  /** Exact current values made available to descendant hooks. */
23
23
  readonly provide: CurrentProvision;
24
24
  /**
@@ -3,7 +3,7 @@ import { current } from "@phreshos/client";
3
3
  const provisionNames = ["program", "process", "parent"];
4
4
  const CurrentContext = createContext(null);
5
5
  /** Resolves only the current handles explicitly selected by the program. */
6
- export default function CurrentProvider({ children, fallback, provide, waitServer = false }) {
6
+ export default function CurrentProvider({ children, fallback = null, provide, waitServer = false }) {
7
7
  const normalized = normalizeProvision(provide);
8
8
  const selectionKey = normalized.join("\0");
9
9
  const selection = useMemo(() => normalized, [selectionKey]);
package/dist/main.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { default as CurrentProvider, useParent, useProcess, useProgram, type CurrentProvision, type CurrentProvisionName, type CurrentProviderProperties } from "./current-provider.js";
2
- export { default as SystemProvider, usePointerPosition, useDesktopSize, useSystemAppearance, useSystemTheme, type SystemProvision, type SystemProvisionName, type SystemProviderProperties } from "./system-provider.js";
2
+ export { default as SystemProvider, usePointerPosition, useDesktopSize, useDesktopPreferences, useSystemAppearance, type SystemProvision, type SystemProvisionName, type SystemProviderProperties } from "./system-provider.js";
3
3
  export { default as useSubscribe } from "./use-subscribe.js";
4
4
  export { default as useObserve } from "./use-observe.js";
5
5
  export { default as useProgramState, type ProgramState } from "./use-program-state.js";
package/dist/main.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { default as CurrentProvider, useParent, useProcess, useProgram } from "./current-provider.js";
2
- export { default as SystemProvider, usePointerPosition, useDesktopSize, useSystemAppearance, useSystemTheme } from "./system-provider.js";
2
+ export { default as SystemProvider, usePointerPosition, useDesktopSize, useDesktopPreferences, useSystemAppearance } from "./system-provider.js";
3
3
  export { default as useSubscribe } from "./use-subscribe.js";
4
4
  export { default as useObserve } from "./use-observe.js";
5
5
  export { default as useProgramState } from "./use-program-state.js";
@@ -1,12 +1,12 @@
1
1
  import { type ReactNode } from "react";
2
- import { type Appearance, type DesktopSize, type PointerPosition, type Theme } from "@phreshos/client";
3
- declare const provisionNames: readonly ["appearance", "theme", "desktopSize", "pointerPosition"];
2
+ import { type Appearance, type DesktopPreferences, type DesktopSize, type PointerPosition } from "@phreshos/client";
3
+ declare const provisionNames: readonly ["appearance", "desktopPreferences", "desktopSize", "pointerPosition"];
4
4
  /** Requests and follows only the system values explicitly selected by the program. */
5
5
  export default function SystemProvider(properties: SystemProviderProperties): import("react").FunctionComponentElement<SelectedSystemProviderProperties>;
6
6
  /** Returns the complete unresolved Appearance and follows authoritative updates. */
7
7
  export declare function useSystemAppearance(): Appearance;
8
- /** Returns the effective local Desktop Theme and follows future changes. */
9
- export declare function useSystemTheme(): Theme;
8
+ /** Returns all effective Desktop preferences and follows authoritative updates. */
9
+ export declare function useDesktopPreferences(): DesktopPreferences;
10
10
  /** Returns the selected desktop size and follows future resize events. */
11
11
  export declare function useDesktopSize(): DesktopSize;
12
12
  /** Returns the selected Pointer position and follows future move events. */
@@ -20,7 +20,7 @@ export interface SystemProviderProperties {
20
20
  /** Content rendered after every selected system value has resolved. */
21
21
  readonly children: ReactNode;
22
22
  /** Content rendered while selected system values resolve. */
23
- readonly fallback: ReactNode;
23
+ readonly fallback?: ReactNode;
24
24
  /** Exact system values requested and followed for mounted descendants. */
25
25
  readonly provide: SystemProvision;
26
26
  }
@@ -1,14 +1,14 @@
1
1
  import { createContext, createElement, useContext, useEffect, useMemo, useState, useSyncExternalStore } from "react";
2
2
  import { system } from "@phreshos/client";
3
3
  import LiveSnapshot from "./live-snapshot.js";
4
- const provisionNames = ["appearance", "theme", "desktopSize", "pointerPosition"];
4
+ const provisionNames = ["appearance", "desktopPreferences", "desktopSize", "pointerPosition"];
5
5
  const SystemContext = createContext(null);
6
6
  /** Requests and follows only the system values explicitly selected by the program. */
7
7
  export default function SystemProvider(properties) {
8
8
  const normalized = normalizeProvision(properties.provide);
9
9
  const selectionKey = normalized.join("\0");
10
10
  const selection = useMemo(() => normalized, [selectionKey]);
11
- return createElement(SelectedSystemProvider, { ...properties, key: selectionKey, selection });
11
+ return createElement(SelectedSystemProvider, { ...properties, fallback: properties.fallback ?? null, key: selectionKey, selection });
12
12
  }
13
13
  function SelectedSystemProvider({ children, fallback, selection }) {
14
14
  const stores = useMemo(() => createStores(selection), [selection]);
@@ -41,9 +41,9 @@ function SelectedSystemProvider({ children, fallback, selection }) {
41
41
  export function useSystemAppearance() {
42
42
  return useProvided("appearance");
43
43
  }
44
- /** Returns the effective local Desktop Theme and follows future changes. */
45
- export function useSystemTheme() {
46
- return useProvided("theme");
44
+ /** Returns all effective Desktop preferences and follows authoritative updates. */
45
+ export function useDesktopPreferences() {
46
+ return useProvided("desktopPreferences");
47
47
  }
48
48
  /** Returns the selected desktop size and follows future resize events. */
49
49
  export function useDesktopSize() {
@@ -69,8 +69,8 @@ function createStores(selection) {
69
69
  case "appearance":
70
70
  stores.appearance = new LiveSnapshot(() => system.appearance.snapshot(), subscriber => system.appearance.subscribe("change", subscriber));
71
71
  break;
72
- case "theme":
73
- stores.theme = new LiveSnapshot(() => system.theme.snapshot(), subscriber => system.theme.subscribe("change", subscriber));
72
+ case "desktopPreferences":
73
+ stores.desktopPreferences = new LiveSnapshot(() => system.desktopPreferences.snapshot(), subscriber => system.desktopPreferences.subscribe("change", subscriber));
74
74
  break;
75
75
  case "desktopSize":
76
76
  stores.desktopSize = new LiveSnapshot(() => system.desktop.size(), subscriber => system.desktop.subscribe("resize", subscriber));
@@ -97,7 +97,7 @@ function normalizeProvision(provide) {
97
97
  }
98
98
  const hookNames = {
99
99
  appearance: "useSystemAppearance",
100
- theme: "useSystemTheme",
100
+ desktopPreferences: "useDesktopPreferences",
101
101
  desktopSize: "useDesktopSize",
102
102
  pointerPosition: "usePointerPosition"
103
103
  };
@@ -1,7 +1,7 @@
1
- import type { ServiceHandler } from "@phreshos/client";
1
+ import type { Service } from "@phreshos/client";
2
2
  /** Live availability of one exact service identity. */
3
3
  export type ServiceState = Readonly<{
4
4
  enabled: boolean;
5
5
  }>;
6
6
  /** Explicitly reads and follows one service while this hook is mounted. */
7
- export default function useServiceState(service: ServiceHandler): ServiceState | undefined;
7
+ export default function useServiceState(service: Service): ServiceState | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phreshos/react",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
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.22",
51
- "@phreshos/core": "^0.1.19",
50
+ "@phreshos/client": "^0.1.24",
51
+ "@phreshos/core": "^0.1.24",
52
52
  "react": "^19.2.0"
53
53
  },
54
54
  "devDependencies": {
55
- "@phreshos/client": "^0.1.22",
56
- "@phreshos/core": "^0.1.19",
55
+ "@phreshos/client": "^0.1.24",
56
+ "@phreshos/core": "^0.1.24",
57
57
  "@testing-library/react": "^16.3.0",
58
58
  "@types/react": "^19.2.18",
59
59
  "@types/react-dom": "^19.2.4",