@phreshos/react 0.1.10 → 0.1.11
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 +9 -6
- package/dist/current-provider.d.ts +1 -1
- package/dist/current-provider.js +1 -1
- package/dist/main.d.ts +1 -1
- package/dist/main.js +1 -1
- package/dist/system-provider.d.ts +5 -5
- package/dist/system-provider.js +8 -8
- package/package.json +5 -5
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()`, `
|
|
24
|
-
`usePointerPosition()` expose those values synchronously
|
|
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
|
|
92
|
+
import { SystemProvider, useDesktopPreferences, useDesktopSize, useSystemAppearance } from "@phreshos/react"
|
|
92
93
|
|
|
93
94
|
function Content() {
|
|
94
|
-
const theme =
|
|
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", "
|
|
103
|
+
return <SystemProvider provide={["appearance", "desktopPreferences", "desktopSize"]} fallback={<p>Loading…</p>}>
|
|
103
104
|
<Content />
|
|
104
105
|
</SystemProvider>
|
|
105
106
|
}
|
|
@@ -109,7 +110,9 @@ 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
|
|
113
|
+
The provider renders its optional fallback, or `null`, until every selected
|
|
114
|
+
value resolves. `useDesktopPreferences()` is a pure state adapter; document
|
|
115
|
+
presentation remains an explicit concern of the consuming interface.
|
|
113
116
|
|
|
114
117
|
```tsx
|
|
115
118
|
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
|
|
21
|
+
readonly fallback?: ReactNode;
|
|
22
22
|
/** Exact current values made available to descendant hooks. */
|
|
23
23
|
readonly provide: CurrentProvision;
|
|
24
24
|
/**
|
package/dist/current-provider.js
CHANGED
|
@@ -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,
|
|
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,
|
|
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
|
|
3
|
-
declare const provisionNames: readonly ["appearance", "
|
|
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
|
|
9
|
-
export declare function
|
|
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
|
|
23
|
+
readonly fallback?: ReactNode;
|
|
24
24
|
/** Exact system values requested and followed for mounted descendants. */
|
|
25
25
|
readonly provide: SystemProvision;
|
|
26
26
|
}
|
package/dist/system-provider.js
CHANGED
|
@@ -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", "
|
|
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
|
|
45
|
-
export function
|
|
46
|
-
return useProvided("
|
|
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 "
|
|
73
|
-
stores.
|
|
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
|
-
|
|
100
|
+
desktopPreferences: "useDesktopPreferences",
|
|
101
101
|
desktopSize: "useDesktopSize",
|
|
102
102
|
pointerPosition: "usePointerPosition"
|
|
103
103
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phreshos/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
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.
|
|
51
|
-
"@phreshos/core": "^0.1.
|
|
50
|
+
"@phreshos/client": "^0.1.23",
|
|
51
|
+
"@phreshos/core": "^0.1.22",
|
|
52
52
|
"react": "^19.2.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@phreshos/client": "^0.1.
|
|
56
|
-
"@phreshos/core": "^0.1.
|
|
55
|
+
"@phreshos/client": "^0.1.23",
|
|
56
|
+
"@phreshos/core": "^0.1.22",
|
|
57
57
|
"@testing-library/react": "^16.3.0",
|
|
58
58
|
"@types/react": "^19.2.18",
|
|
59
59
|
"@types/react-dom": "^19.2.4",
|