Skip to content

Commit

Permalink
Fixed #3 & #4. Added edge support. More readme
Browse files Browse the repository at this point in the history
  • Loading branch information
eliassjogreen committed Mar 17, 2020
1 parent 4dfd47c commit 85bc1e6
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[target.x86_64-pc-windows-msvc]
rustflags = ["-Ctarget-feature=+crt-static"]
6 changes: 3 additions & 3 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "deno_webview"
version = "0.2.0"
version = "0.2.2"
authors = ["Elias Sjögreen <eliassjogreen1@gmail.com>"]
edition = "2018"

Expand All @@ -14,4 +14,4 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

[features]
edge = ["webview-sys/edge"]
default = ["webview-sys/edge"]
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,19 @@ cargo build --release --locked
```

optionally with edge (does not work yet
[#3](https://github.com/eliassjogreen/deno_webview/issues/3))
optionally with mshtml

```
deno -A scripts/build.ts edge
deno -A scripts/build.ts mshtml
```

or

```
cargo build --release --locked --features edge
cargo build --release --locked --no-default-features
```

Expand All @@ -174,6 +173,15 @@ using local binaries can be easier to do using the
deno -A scripts/dev.ts example.ts
```

## Environment variables

- `DEV` - When developing locally `DEV` should be set to the local release
path, usually `file://./target/release`
- `MSHTML` - Due to MSHTML (ie) no longer being enabled by default the only
way to enable it is to set the `MSHTML` variable to the path of a binary
build built with the `--no-default-features` flag or using
`deno -A scripts/build.ts mshtml`

## Contributing

Contributions either in the form of pull requests or issues are always welcome.
Expand Down Expand Up @@ -201,7 +209,7 @@ Just remember to format using `deno fmt` and `cargo fmt`. Thx <3
`*mut CWebView`)~~ Used solution found
[here](https://github.com/crabmusket/deno_sqlite_plugin/blob/2df9e495f34d246881de0b48c9c79cc9e271abeb/src/lib.rs#L18)
- [x] Better errors and responses from rust land
- [ ] Update ci so building with Edge works
- [x] Update ci so building with Edge works
[#3](https://github.com/eliassjogreen/deno_webview/issues/3)
- [ ] Two-way deno bindings (to call deno from javascript)
- [ ] More examples
Expand Down
18 changes: 18 additions & 0 deletions examples/user_agent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { WebView } from "../mod.ts";

new WebView({
title: "User agent deno_webview example",
url: `data:text/html,
<html>
<body>
<h1 id="h1">2 Nav</h1>
<script>document.body.innerHTML = window.navigator.userAgent;</script>
</body>
</html>
`,
width: 800,
height: 600,
resizable: true,
debug: false,
frameless: false
}).run();
7 changes: 4 additions & 3 deletions plugin.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { prepare } from "https://deno.land/x/plugin_prepare@v0.3.0/mod.ts";

const DEV = Deno.env("DEV");
const MSHTML = Deno.env("MSHTML");

const pluginPath = DEV !== undefined
? DEV
: "https://github.com/eliassjogreen/deno_webview/releases/download/0.2.0";
: "https://github.com/eliassjogreen/deno_webview/releases/download/0.2.2";

const plugin = await prepare({
name: "deno_webview",
checkCache: DEV !== undefined,
checkCache: DEV === undefined,
urls: {
mac: `${pluginPath}/libdeno_webview.dylib`,
win: `${pluginPath}/deno_webview.dll`,
win: MSHTML === undefined ? `${pluginPath}/deno_webview.dll` : MSHTML,
linux: `${pluginPath}/libdeno_webview.so`
}
});
Expand Down
7 changes: 3 additions & 4 deletions scripts/build.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
export async function build(edge: boolean = Deno.args[0] === "edge") {
export async function build(mshtml: boolean = Deno.args.includes("mshtml")) {
const command = ["cargo", "build", "--release", "--locked"];

// TODO (#3) fix
if (edge) {
command.push("--features", "edge");
if (mshtml) {
command.push("--no-default-features");
}

const cargo = Deno.run({
Expand Down
27 changes: 19 additions & 8 deletions scripts/dev.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
import { build } from "./build.ts";

export async function dev(file: string = Deno.args[0]) {
await build();
export async function dev(
file: string = Deno.args[0],
mshtml: boolean = Deno.args.includes("mshtml")
) {
await build();

Deno.run({
args: ["deno", "run", "-A", file],
env: {
"DEV": "file://./target/release"
const env: {
[key: string]: string;
} = {
DEV: "file://./target/release"
};

if (mshtml) {
env["MSHTML"] = "file://./target/release/deno_webview.dll";
}
});

Deno.run({
args: ["deno", "run", "-A", "-r", file],
env
});
}

if (import.meta.main) {
dev();
await dev();
}

0 comments on commit 85bc1e6

Please sign in to comment.