Skip to content

Commit

Permalink
Use a custom protocol when loading HTML (#71)
Browse files Browse the repository at this point in the history
* Use a custom protocol when loading HTML

* Bump to 0.0.15 (Binary 0.1.12)

* Add ability to specify origin for html; improve docs

When using `html` as an option for constructing a webview, you may want to have a finer grained control over the origin. This change allows you to specify the origin both during creation of the webview and at `load_html` time.

* Update examples w/ origin usage; persistence

* Add changelog update
  • Loading branch information
zephraph authored Sep 29, 2024
1 parent 1100a45 commit dc31e5c
Show file tree
Hide file tree
Showing 14 changed files with 244 additions and 50 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 0.0.15 (binary 0.1.12) -- 2024-09-28

- Pages loaded with `html` are now considered to be in a secure context.
- When creating a webview with `html` or calling `webview.loadHtml()` the webview now has a default origin which can be changed via the `origin` parameter
- Improved type generation to output more doc strings and documented more code
- Update TLDraw example with a persistence key

## 0.0.14 (binary 0.1.11) -- 2024-09-26

- fix an issue where arm64 macs weren't downloading the correct binary
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.11"
version = "0.1.12"
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.14",
"version": "0.0.15",
"tasks": {
"dev": "deno run --watch main.ts",
"gen": "deno task gen:rust && deno task gen:deno",
Expand Down
7 changes: 7 additions & 0 deletions examples/load-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@ import { createWebView } from "../src/lib.ts";
using webview = await createWebView({
title: "Load Html Example",
html: "<h1>Initial html</h1>",
// Note: This origin is used with a custom protocol so it doesn't match
// https://example.com. This doesn't need to be set, but can be useful if
// you want to control resources that are scoped to a specific origin like
// local storage or indexeddb.
origin: "example.com",
devtools: true,
});

webview.on("started", async () => {
await webview.openDevTools();
await webview.loadHtml("<h1>Updated html!</h1>");
});

Expand Down
2 changes: 1 addition & 1 deletion examples/tldraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function App() {
return (
<>
<div style={{ position: "absolute", inset: 0 }}>
<Tldraw cameraOptions={{ wheelBehavior: "zoom" }} />
<Tldraw persistenceKey="tldraw-example" cameraOptions={{ wheelBehavior: "zoom" }} />
</div>
</>
);
Expand Down
4 changes: 4 additions & 0 deletions schemas/WebViewMessage.json

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

17 changes: 10 additions & 7 deletions schemas/WebViewOptions.json

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

35 changes: 34 additions & 1 deletion schemas/WebViewRequest.json

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

2 changes: 2 additions & 0 deletions schemas/WebViewResponse.json

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

Loading

0 comments on commit dc31e5c

Please sign in to comment.