@nativewindow/webview 0.1.1 → 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 +31 -16
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="
|
|
2
|
+
<img src="https://fcannizzaro.com/_astro/native-window.IZZgO9dh.webp" alt="native-window" />
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
# @nativewindow/webview
|
|
6
6
|
|
|
7
7
|
[](https://github.com/nativewindow/webview/actions/workflows/ci.yml)
|
|
8
|
-
[](https://www.npmjs.com/package/@nativewindow/webview)
|
|
9
|
-
[](https://www.npmjs.com/package/@nativewindow/webview)
|
|
9
|
+
[](https://www.npmjs.com/package/@nativewindow/ipc)
|
|
10
|
+
[](https://www.npmjs.com/package/@nativewindow/react)
|
|
11
|
+
[](https://www.npmjs.com/package/@nativewindow/tsdb)
|
|
12
12
|
|
|
13
|
-
> [!
|
|
14
|
-
> This project is in **
|
|
13
|
+
> [!NOTE]
|
|
14
|
+
> This project is in **beta**. APIs may change without notice and some features may be incomplete or unstable.
|
|
15
15
|
|
|
16
16
|
Native OS webviews for Bun, Deno & Node.js. Create real desktop windows with embedded web content using [wry](https://github.com/tauri-apps/wry) + [tao](https://github.com/tauri-apps/tao) — providing WebKit on macOS and Linux, and WebView2 on Windows.
|
|
17
17
|
|
|
@@ -74,19 +74,26 @@ Use `native-window-ipc` for compile-time checked messaging between Bun/Deno/Node
|
|
|
74
74
|
|
|
75
75
|
```ts
|
|
76
76
|
import { z } from "zod";
|
|
77
|
-
import { createWindow } from "
|
|
77
|
+
import { createWindow } from "@nativewindow/ipc";
|
|
78
78
|
|
|
79
79
|
const ch = createWindow(
|
|
80
80
|
{ title: "Typed IPC" },
|
|
81
81
|
{
|
|
82
82
|
schemas: {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
// host -> webview
|
|
84
|
+
host: {
|
|
85
|
+
"update-title": z.string(),
|
|
86
|
+
},
|
|
87
|
+
// webview -> host
|
|
88
|
+
client: {
|
|
89
|
+
"user-click": z.object({ x: z.number(), y: z.number() }),
|
|
90
|
+
counter: z.number(),
|
|
91
|
+
},
|
|
86
92
|
},
|
|
87
93
|
},
|
|
88
94
|
);
|
|
89
95
|
|
|
96
|
+
// Receive typed messages from the webview (client events)
|
|
90
97
|
ch.on("user-click", (pos) => {
|
|
91
98
|
// pos: { x: number; y: number }
|
|
92
99
|
console.log(`Click at ${pos.x}, ${pos.y}`);
|
|
@@ -97,8 +104,8 @@ ch.on("counter", (n) => {
|
|
|
97
104
|
ch.send("update-title", `Count: ${n}`);
|
|
98
105
|
});
|
|
99
106
|
|
|
100
|
-
// ch.send("counter", "wrong"); // Type error
|
|
101
|
-
// ch.send("typo", 123); // Type error
|
|
107
|
+
// ch.send("counter", "wrong"); // Type error: "counter" is a client event
|
|
108
|
+
// ch.send("typo", 123); // Type error: "typo" does not exist
|
|
102
109
|
|
|
103
110
|
ch.window.loadHtml(`<html>...</html>`);
|
|
104
111
|
```
|
|
@@ -122,15 +129,23 @@ For webview apps bundled with their own build step, import the client directly:
|
|
|
122
129
|
|
|
123
130
|
```ts
|
|
124
131
|
import { z } from "zod";
|
|
125
|
-
import { createChannelClient } from "
|
|
132
|
+
import { createChannelClient } from "@nativewindow/ipc/client";
|
|
126
133
|
|
|
127
134
|
const ch = createChannelClient({
|
|
128
135
|
schemas: {
|
|
129
|
-
|
|
130
|
-
|
|
136
|
+
host: {
|
|
137
|
+
"update-title": z.string(),
|
|
138
|
+
},
|
|
139
|
+
client: {
|
|
140
|
+
counter: z.number(),
|
|
141
|
+
},
|
|
131
142
|
},
|
|
132
143
|
});
|
|
144
|
+
|
|
145
|
+
// Send client events to the host
|
|
133
146
|
ch.send("counter", 42); // Typed!
|
|
147
|
+
|
|
148
|
+
// Receive host events from the host
|
|
134
149
|
ch.on("update-title", (t) => {
|
|
135
150
|
// t: string
|
|
136
151
|
document.title = t;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nativewindow/webview",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "Native OS webview windows for Bun & Node.js (
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Native OS webview windows for Bun & Node.js (beta)",
|
|
5
5
|
"homepage": "https://nativewindow.fcannizzaro.com",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/nativewindow/webview/issues"
|
|
@@ -56,12 +56,12 @@
|
|
|
56
56
|
"typescript": "^5"
|
|
57
57
|
},
|
|
58
58
|
"optionalDependencies": {
|
|
59
|
-
"@nativewindow/webview-darwin-arm64": "0.1
|
|
60
|
-
"@nativewindow/webview-darwin-x64": "0.1
|
|
61
|
-
"@nativewindow/webview-linux-arm64-gnu": "0.1
|
|
62
|
-
"@nativewindow/webview-linux-x64-gnu": "0.1
|
|
63
|
-
"@nativewindow/webview-win32-arm64-msvc": "0.1
|
|
64
|
-
"@nativewindow/webview-win32-x64-msvc": "0.1
|
|
59
|
+
"@nativewindow/webview-darwin-arm64": "1.0.1",
|
|
60
|
+
"@nativewindow/webview-darwin-x64": "1.0.1",
|
|
61
|
+
"@nativewindow/webview-linux-arm64-gnu": "1.0.1",
|
|
62
|
+
"@nativewindow/webview-linux-x64-gnu": "1.0.1",
|
|
63
|
+
"@nativewindow/webview-win32-arm64-msvc": "1.0.1",
|
|
64
|
+
"@nativewindow/webview-win32-x64-msvc": "1.0.1"
|
|
65
65
|
},
|
|
66
66
|
"napi": {
|
|
67
67
|
"binaryName": "native-window",
|