Skip to content

Commit

Permalink
Support window sizing (#61)
Browse files Browse the repository at this point in the history
* `accept_first_mouse` -> `acceptFirstMouse`

* Add support for configuring webview size

* Prepare 0.0.12 (binary 0.1.10)

* Add ability to set window size after init

* Return scale factor with sizing

* Update changelog
  • Loading branch information
zephraph authored Sep 26, 2024
1 parent 0410eb0 commit 20af916
Show file tree
Hide file tree
Showing 13 changed files with 746 additions and 98 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Changelog

## 0.0.12 (binary 0.1.10) -- 2024-09-26

BREAKING CHANGES

- `WebViewOptions` `accept_first_mouse` is now `acceptFirstMouse`
- `WebViewOptions` `fullscreen` was removed in favor of `size`

Additions

- The webview size can be altered by providing `WebViewOptions` `size` as either `"maximized"`, `"fullscreen"`, or `{ width: number, height: number }`
- added `webview.maximize()`
- added `webview.minimize()`
- added `webview.fullscreen()`
- added `webview.getSize()`
- added `webview.setSize({ ... })`

Fixes

- `webview.on` and `webivew.once` had their types improved to actually return the result of their event payload

Misc

- Tao updated to v0.30.2
- Wry upgraded to v0.45.0

## 0.0.11 (binary 0.1.9) -- 2024-09-23

- Adds more doc comments
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "deno-webview"
version = "0.1.9"
version = "0.1.10"
edition = "2021"

[profile.release]
Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@justbe/webview",
"exports": "./src/lib.ts",
"version": "0.0.11",
"version": "0.0.12",
"tasks": {
"dev": "deno run --watch main.ts",
"gen": "deno task gen:rust && deno task gen:deno",
Expand Down
36 changes: 36 additions & 0 deletions examples/window-size.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { createWebView } from "../src/lib.ts";

using webview = await createWebView({
title: "Window Size",
html: `
<h1>Window Sizes</h1>
<div style="display: flex; gap: 10px;">
<button onclick="window.ipc.postMessage('maximize')">Maximize</button>
<button onclick="window.ipc.postMessage('minimize')">Minimize</button>
<button onclick="window.ipc.postMessage('fullscreen')">Fullscreen</button>
</div>
`,
size: {
height: 200,
width: 800,
},
ipc: true,
});

webview.on("ipc", ({ message }) => {
switch (message) {
case "maximize":
webview.maximize();
break;
case "minimize":
webview.minimize();
break;
case "fullscreen":
webview.fullscreen();
break;
default:
console.error("Unknown message", message);
}
});

await webview.waitUntilClosed();
47 changes: 43 additions & 4 deletions schemas/WebViewMessage.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 45 additions & 6 deletions schemas/WebViewOptions.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

140 changes: 139 additions & 1 deletion schemas/WebViewRequest.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 20af916

Please sign in to comment.