@phreshos/react 0.1.29 → 0.1.31
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.
|
@@ -2,6 +2,7 @@ import type { Process, Program } from "@phreshos/core";
|
|
|
2
2
|
/** Mutable runtime state derived from one Program's reads and live events. */
|
|
3
3
|
export type ProgramState = Readonly<{
|
|
4
4
|
installed: boolean;
|
|
5
|
+
pinned: boolean;
|
|
5
6
|
processes: readonly Process[];
|
|
6
7
|
}>;
|
|
7
8
|
/** Explicitly reads and follows one Program while this hook is mounted. */
|
|
@@ -3,12 +3,13 @@ import LiveState, { combineCleanups } from "./live-state.js";
|
|
|
3
3
|
/** Explicitly reads and follows one Program while this hook is mounted. */
|
|
4
4
|
export default function useProgramState(program) {
|
|
5
5
|
const state = useMemo(() => new LiveState(async () => {
|
|
6
|
-
const [installed, processes] = await Promise.all([
|
|
6
|
+
const [installed, pinned, processes] = await Promise.all([
|
|
7
7
|
program.installed(),
|
|
8
|
+
program.pinned(),
|
|
8
9
|
program.processes()
|
|
9
10
|
]);
|
|
10
|
-
return { installed, processes };
|
|
11
|
-
}, reduce => combineCleanups(program.subscribe("processCreate", process => reduce(current => addProcess(current, process))), program.subscribe("processExit", ({ process }) => reduce(current => removeProcess(current, process))), program.subscribe("uninstall", () => reduce(current => current.installed ? { ...current, installed: false } : current)))), [program]);
|
|
11
|
+
return { installed, pinned, processes };
|
|
12
|
+
}, reduce => combineCleanups(program.subscribe("processCreate", process => reduce(current => addProcess(current, process))), program.subscribe("processExit", ({ process }) => reduce(current => removeProcess(current, process))), program.subscribe("uninstall", () => reduce(current => current.installed ? { ...current, installed: false } : current)), program.subscribe("pinned", pinned => reduce(current => current.pinned === pinned ? current : { ...current, pinned })))), [program]);
|
|
12
13
|
return useSyncExternalStore(state.subscribe, state.snapshot, state.snapshot);
|
|
13
14
|
}
|
|
14
15
|
function addProcess(state, process) {
|
package/dist/use-window-state.js
CHANGED
|
@@ -3,11 +3,9 @@ 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, header,
|
|
6
|
+
const [title, header, position, size, minimized, maximized, front, layer] = await Promise.all([
|
|
7
7
|
window.title(),
|
|
8
8
|
window.header(),
|
|
9
|
-
window.frame(),
|
|
10
|
-
window.transaction(),
|
|
11
9
|
window.position(),
|
|
12
10
|
window.size(),
|
|
13
11
|
window.minimized(),
|
|
@@ -15,7 +13,7 @@ export default function useWindowState(window) {
|
|
|
15
13
|
window.front(),
|
|
16
14
|
window.layer()
|
|
17
15
|
]);
|
|
18
|
-
return { title, header,
|
|
19
|
-
}, 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("maximize", maximized => reduce(current => ({ ...current, maximized }))), window.subscribe("changeTitle", title => reduce(current => ({ ...current, title }))), window.subscribe("changeHeader", header => reduce(current => ({ ...current, header }))), window.subscribe("
|
|
16
|
+
return { title, header, position, size, minimized, maximized, front, layer };
|
|
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("maximize", maximized => reduce(current => ({ ...current, maximized }))), window.subscribe("changeTitle", title => reduce(current => ({ ...current, title }))), window.subscribe("changeHeader", header => reduce(current => ({ ...current, header }))), window.subscribe("front", front => reduce(current => ({ ...current, front }))))), [window]);
|
|
20
18
|
return useSyncExternalStore(state.subscribe, state.snapshot, state.snapshot);
|
|
21
19
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phreshos/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.31",
|
|
4
4
|
"description": "Runtime-neutral React adapters for PhreshOS contracts.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"prepack": "node --run build"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
|
|
49
|
+
"@phreshos/core": "^0.1.59",
|
|
50
50
|
"react": "^19.2.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
|
|
53
|
+
"@phreshos/core": "^0.1.59",
|
|
54
54
|
"@testing-library/dom": "^10.4.1",
|
|
55
55
|
"@testing-library/react": "^16.3.0",
|
|
56
56
|
"@types/react": "^19.2.18",
|