@nativewindow/react 1.0.0 → 1.0.1
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 +10 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@nativewindow/react)
|
|
4
4
|
|
|
5
|
-
> [!
|
|
6
|
-
> This project is in **
|
|
5
|
+
> [!NOTE]
|
|
6
|
+
> This project is in **beta**. APIs may change without notice.
|
|
7
7
|
|
|
8
8
|
React hooks for [native-window-ipc](https://github.com/nativewindow/webview/tree/main/packages/ipc). Provides type-safe React bindings for the webview side of the IPC channel.
|
|
9
9
|
|
|
@@ -32,10 +32,12 @@ import { z } from "zod";
|
|
|
32
32
|
import { createChannelHooks } from "@nativewindow/react";
|
|
33
33
|
|
|
34
34
|
export const { ChannelProvider, useChannel, useChannelEvent, useSend } = createChannelHooks({
|
|
35
|
-
|
|
36
|
-
counter: z.number(),
|
|
35
|
+
host: {
|
|
37
36
|
"update-title": z.string(),
|
|
38
37
|
},
|
|
38
|
+
client: {
|
|
39
|
+
counter: z.number(),
|
|
40
|
+
},
|
|
39
41
|
});
|
|
40
42
|
```
|
|
41
43
|
|
|
@@ -64,11 +66,12 @@ function Counter() {
|
|
|
64
66
|
const [count, setCount] = useState(0);
|
|
65
67
|
const send = useSend();
|
|
66
68
|
|
|
67
|
-
// Subscribe to events with automatic cleanup
|
|
68
|
-
useChannelEvent("
|
|
69
|
-
|
|
69
|
+
// Subscribe to host events with automatic cleanup
|
|
70
|
+
useChannelEvent("update-title", (title) => {
|
|
71
|
+
document.title = title;
|
|
70
72
|
});
|
|
71
73
|
|
|
74
|
+
// Send client events to the host
|
|
72
75
|
return <button onClick={() => send("counter", count + 1)}>Count: {count}</button>;
|
|
73
76
|
}
|
|
74
77
|
```
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nativewindow/react",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "React bindings for native-window IPC (
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "React bindings for native-window IPC (beta)",
|
|
5
5
|
"homepage": "https://nativewindow.fcannizzaro.com",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/nativewindow/webview/issues"
|