@phreshos/react 0.1.1 → 0.1.2
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 +4 -0
- package/dist/use-window-state.js +4 -5
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -52,6 +52,10 @@ useWindowState(window)
|
|
|
52
52
|
// WindowState | undefined
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
+
`WindowState` contains the observable Window properties only. The command-only
|
|
56
|
+
`window.surface` capability is intentionally absent: Program code may replace
|
|
57
|
+
or remove its target but cannot read or subscribe to it.
|
|
58
|
+
|
|
55
59
|
`undefined` means only that the initial explicit reads are pending. Each hook
|
|
56
60
|
opens its live subscriptions before those reads, then applies any intervening
|
|
57
61
|
events so an older result cannot overwrite newer state. If an initial read
|
package/dist/use-window-state.js
CHANGED
|
@@ -3,17 +3,16 @@ import LiveState, { combineCleanups } from "./live-state.js";
|
|
|
3
3
|
/** Explicitly reads and follows one live Client Window while mounted. */
|
|
4
4
|
export default function useWindowState(window) {
|
|
5
5
|
const state = useMemo(() => new LiveState(async () => {
|
|
6
|
-
const [title, position, size, minimized, front, layer, location
|
|
6
|
+
const [title, position, size, minimized, front, layer, location] = await Promise.all([
|
|
7
7
|
window.title(),
|
|
8
8
|
window.position(),
|
|
9
9
|
window.size(),
|
|
10
10
|
window.minimized(),
|
|
11
11
|
window.front(),
|
|
12
12
|
window.layer(),
|
|
13
|
-
window.location()
|
|
14
|
-
window.surface.snapshot()
|
|
13
|
+
window.location()
|
|
15
14
|
]);
|
|
16
|
-
return { title, position, size, minimized, front, layer, location
|
|
17
|
-
}, reduce => combineCleanups(window.subscribe("move", position => reduce(current => ({ ...current, position }))), window.subscribe("resize", size => reduce(current => ({ ...current, size }))), window.subscribe("minimize", minimized => reduce(current => ({ ...current, minimized }))), window.subscribe("changeTitle", title => reduce(current => ({ ...current, title }))), window.subscribe("front", front => reduce(current => ({ ...current, front })))
|
|
15
|
+
return { title, position, size, minimized, front, layer, location };
|
|
16
|
+
}, reduce => combineCleanups(window.subscribe("move", position => reduce(current => ({ ...current, position }))), window.subscribe("resize", size => reduce(current => ({ ...current, size }))), window.subscribe("minimize", minimized => reduce(current => ({ ...current, minimized }))), window.subscribe("changeTitle", title => reduce(current => ({ ...current, title }))), window.subscribe("front", front => reduce(current => ({ ...current, front }))))), [window]);
|
|
18
17
|
return useSyncExternalStore(state.subscribe, state.snapshot, state.snapshot);
|
|
19
18
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phreshos/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
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.2",
|
|
51
|
+
"@phreshos/core": "^0.1.2",
|
|
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.2",
|
|
56
|
+
"@phreshos/core": "^0.1.2",
|
|
57
57
|
"@testing-library/react": "^16.3.0",
|
|
58
58
|
"@types/react": "^19.2.18",
|
|
59
59
|
"@types/react-dom": "^19.2.4",
|