@softvisio/webview 1.2.5
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.
Potentially problematic release.
This version of @softvisio/webview might be problematic. Click here for more details.
- package/.editorconfig +16 -0
- package/CHANGELOG.md +67 -0
- package/README.md +52 -0
- package/docs/.docs.config.yaml +5 -0
- package/docs/.nojekyll +0 -0
- package/docs/README.md +48 -0
- package/docs/_sidebar.md +11 -0
- package/docs/index.html +37 -0
- package/lib/binaries/darwin/webview +0 -0
- package/lib/binaries/linux/webview +0 -0
- package/lib/binaries/win32/WebView2Loader.dll +0 -0
- package/lib/binaries/win32/elevation-required.html +22 -0
- package/lib/binaries/win32/hstart.exe +0 -0
- package/lib/binaries/win32/webview.dll +0 -0
- package/lib/binaries/win32/webview.exe +0 -0
- package/lib/index.js +91 -0
- package/package.json +27 -0
package/.editorconfig
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
root = true
|
|
2
|
+
|
|
3
|
+
[*]
|
|
4
|
+
indent_style = space
|
|
5
|
+
indent_size = 4
|
|
6
|
+
end_of_line = lf
|
|
7
|
+
charset = utf-8
|
|
8
|
+
trim_trailing_whitespace = true
|
|
9
|
+
insert_final_newline = true
|
|
10
|
+
max_line_length = 99999999
|
|
11
|
+
|
|
12
|
+
[*.{yml,yaml}]
|
|
13
|
+
indent_size = 2
|
|
14
|
+
|
|
15
|
+
[Makefile]
|
|
16
|
+
indent_style = tab
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
### 1.2.5 (2022-05-19)
|
|
4
|
+
|
|
5
|
+
Fixes:
|
|
6
|
+
|
|
7
|
+
- fix: windows elevation error handle
|
|
8
|
+
|
|
9
|
+
### 1.2.4 (2022-05-19)
|
|
10
|
+
|
|
11
|
+
Fixes:
|
|
12
|
+
|
|
13
|
+
- fix: error message on windows
|
|
14
|
+
|
|
15
|
+
### 1.2.3 (2022-05-19)
|
|
16
|
+
|
|
17
|
+
Fixes:
|
|
18
|
+
|
|
19
|
+
- fix: use laucher under windows
|
|
20
|
+
|
|
21
|
+
### 1.2.2 (2022-05-18)
|
|
22
|
+
|
|
23
|
+
Fixes:
|
|
24
|
+
|
|
25
|
+
- fix: windows launcher
|
|
26
|
+
|
|
27
|
+
### 1.2.1 (2022-04-23)
|
|
28
|
+
|
|
29
|
+
Fixes:
|
|
30
|
+
|
|
31
|
+
- fix: windows isolation patch removed
|
|
32
|
+
|
|
33
|
+
### 1.2.0 (2022-04-21)
|
|
34
|
+
|
|
35
|
+
Features:
|
|
36
|
+
|
|
37
|
+
- feat: abort signal support
|
|
38
|
+
|
|
39
|
+
Fixes:
|
|
40
|
+
|
|
41
|
+
- fix: spawn typo
|
|
42
|
+
|
|
43
|
+
### 1.1.2 (2022-04-16)
|
|
44
|
+
|
|
45
|
+
Fixes:
|
|
46
|
+
|
|
47
|
+
- fix: win32 loopback
|
|
48
|
+
|
|
49
|
+
### 1.1.1 (2022-04-16)
|
|
50
|
+
|
|
51
|
+
Fixes:
|
|
52
|
+
|
|
53
|
+
- fix: docs
|
|
54
|
+
|
|
55
|
+
### 1.1.0 (2022-04-16)
|
|
56
|
+
|
|
57
|
+
Features:
|
|
58
|
+
|
|
59
|
+
- feat: close events
|
|
60
|
+
|
|
61
|
+
### 1.0.0 (2022-04-16)
|
|
62
|
+
|
|
63
|
+
Fixes:
|
|
64
|
+
|
|
65
|
+
- fix: build
|
|
66
|
+
|
|
67
|
+
Migration:
|
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<!-- !!! DO NOT EDIT, THIS FILE IS GENERATED AUTOMATICALLY !!! -->
|
|
2
|
+
|
|
3
|
+
> :information_source: Please, see the full project documentation here: [https://softvisio.github.io/webview/](https://softvisio.github.io/webview/).
|
|
4
|
+
|
|
5
|
+
# Introduction
|
|
6
|
+
|
|
7
|
+
`NodeJS` wrapper for [webview](https://github.com/webview/webview).
|
|
8
|
+
|
|
9
|
+
Compiled binaries: [suchipi/webview](https://github.com/suchipi/webview).
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```shell
|
|
14
|
+
npm i @softvisio/webview
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```javascript
|
|
20
|
+
import WebView from "@softvisio/webview";
|
|
21
|
+
|
|
22
|
+
const webView = new WebView("https://example.com/", { title: "Example", width: 400, height: 400 });
|
|
23
|
+
|
|
24
|
+
webView.on("close", () => {});
|
|
25
|
+
|
|
26
|
+
webView.close();
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Notes
|
|
30
|
+
|
|
31
|
+
### Windows
|
|
32
|
+
|
|
33
|
+
On windows, the webview will not be able to access localhost unless the following command has been run as administrator at least once before:
|
|
34
|
+
|
|
35
|
+
```shell
|
|
36
|
+
checknetisolation.exe LoopbackExempt -a -n=Microsoft.Win32WebViewHost_cw5n1h2txyewy
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```shell
|
|
40
|
+
curl -sSLO https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
|
|
41
|
+
nuget.exe install Microsoft.Web.Webview2 -OutputDirectory script
|
|
42
|
+
|
|
43
|
+
cl -DSFML_STATIC /std:c++17 /EHsc /I script\Microsoft.Web.WebView2.1.0.1185.39\build\native\include script\Microsoft.Web.WebView2.1.0.1185.39\build\native\x64\WebView2Loader.dll.lib main.cc /link /out:webview.exe
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Linux
|
|
47
|
+
|
|
48
|
+
On Linux, you need to install GTK3 and GtkWebkit2.
|
|
49
|
+
|
|
50
|
+
```shell
|
|
51
|
+
sudo apt-get install libwebkit2gtk-4.0-dev
|
|
52
|
+
```
|
package/docs/.nojekyll
ADDED
|
File without changes
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Introduction
|
|
2
|
+
|
|
3
|
+
`NodeJS` wrapper for [webview](https://github.com/webview/webview).
|
|
4
|
+
|
|
5
|
+
Compiled binaries: [suchipi/webview](https://github.com/suchipi/webview).
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```shell
|
|
10
|
+
npm i @softvisio/webview
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
import WebView from "@softvisio/webview";
|
|
17
|
+
|
|
18
|
+
const webView = new WebView("https://example.com/", { title: "Example", width: 400, height: 400 });
|
|
19
|
+
|
|
20
|
+
webView.on("close", () => {});
|
|
21
|
+
|
|
22
|
+
webView.close();
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Notes
|
|
26
|
+
|
|
27
|
+
### Windows
|
|
28
|
+
|
|
29
|
+
On windows, the webview will not be able to access localhost unless the following command has been run as administrator at least once before:
|
|
30
|
+
|
|
31
|
+
```shell
|
|
32
|
+
checknetisolation.exe LoopbackExempt -a -n=Microsoft.Win32WebViewHost_cw5n1h2txyewy
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```shell
|
|
36
|
+
curl -sSLO https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
|
|
37
|
+
nuget.exe install Microsoft.Web.Webview2 -OutputDirectory script
|
|
38
|
+
|
|
39
|
+
cl -DSFML_STATIC /std:c++17 /EHsc /I script\Microsoft.Web.WebView2.1.0.1185.39\build\native\include script\Microsoft.Web.WebView2.1.0.1185.39\build\native\x64\WebView2Loader.dll.lib main.cc /link /out:webview.exe
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Linux
|
|
43
|
+
|
|
44
|
+
On Linux, you need to install GTK3 and GtkWebkit2.
|
|
45
|
+
|
|
46
|
+
```shell
|
|
47
|
+
sudo apt-get install libwebkit2gtk-4.0-dev
|
|
48
|
+
```
|
package/docs/_sidebar.md
ADDED
package/docs/index.html
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
|
|
3
|
+
<!-- !!! DO NOT EDIT, THIS FILE IS GENERATED AUTOMATICALLY !!! -->
|
|
4
|
+
|
|
5
|
+
<html>
|
|
6
|
+
<head>
|
|
7
|
+
<meta charset="UTF-8" />
|
|
8
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
|
9
|
+
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
|
10
|
+
|
|
11
|
+
<link rel="stylesheet" id="lightTheme" href="https://cdn.jsdelivr.net/npm/docsify-themeable/dist/css/theme-simple.css" />
|
|
12
|
+
<link rel="stylesheet" id="darkTheme" href="https://cdn.jsdelivr.net/npm/docsify-themeable/dist/css/theme-simple-dark.css" />
|
|
13
|
+
<link rel="stylesheet" href="https://softvisio.github.io/cli/assets/theme/theme.css" />
|
|
14
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" />
|
|
15
|
+
</head>
|
|
16
|
+
<body>
|
|
17
|
+
<nav>
|
|
18
|
+
<a href="#/changelog">Changelog</a> • <a href="https://github.com/softvisio/webview/discussions" title="Discussions"><i class="fa-regular fa-comments"></i></a> • <a href="https://github.com/softvisio/webview/issues" title="Issues"><i class="fa-solid fa-bug"></i></a> • <a href="https://www.npmjs.com/package/@softvisio/webview" title="NPM package"><i class="fa-brands fa-npm"></i></a> • <a href="#toggleTheme"><i class="fa-solid fa-adjust"></i> Theme</a>
|
|
19
|
+
</nav>
|
|
20
|
+
<div id="app"></div>
|
|
21
|
+
<div id="gotoTop"><a href="#gotoTop">🡡 Top</a></div>
|
|
22
|
+
|
|
23
|
+
<script>
|
|
24
|
+
window.$docsify = { alias: { "/changelog": "https://raw.githubusercontent.com/softvisio/webview/master/CHANGELOG.md" }, auto2top: true, externalLinkTarget: "_self", loadSidebar: true, maxLevel: 2, name: "@softvisio/webview", relativePath: true, repo: "https://github.com/softvisio/webview", search: { depth: 3 }, subMaxLevel: 2, tabs: {} };
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<script src="https://softvisio.github.io/cli/assets/theme/theme.js"></script>
|
|
28
|
+
<script src="https://cdn.jsdelivr.net/npm/docsify"></script>
|
|
29
|
+
<script src="https://cdn.jsdelivr.net/npm/prismjs/components/prism-bash.min.js"></script>
|
|
30
|
+
<script src="https://cdn.jsdelivr.net/npm/docsify/lib/plugins/search.min.js"></script>
|
|
31
|
+
<script src="https://cdn.jsdelivr.net/npm/docsify/lib/plugins/zoom-image.min.js"></script>
|
|
32
|
+
<script src="https://cdn.jsdelivr.net/npm/docsify-tabs"></script>
|
|
33
|
+
<script src="https://cdn.jsdelivr.net/npm/docsify-copy-code"></script>
|
|
34
|
+
<script src="https://cdn.jsdelivr.net/npm/docsify-pagination/dist/docsify-pagination.min.js"></script>
|
|
35
|
+
<script src="https://cdn.jsdelivr.net/npm/docsify/lib/plugins/external-script.min.js"></script>
|
|
36
|
+
</body>
|
|
37
|
+
</html>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Elevated permissions required</title>
|
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
6
|
+
<meta name="title" content="" />
|
|
7
|
+
<meta name="keywords" content="" />
|
|
8
|
+
<meta name="description" content="" />
|
|
9
|
+
<meta name="robots" content="" />
|
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
|
11
|
+
<meta http-equiv="Content-Style-Type" content="text/css" />
|
|
12
|
+
</head>
|
|
13
|
+
<body>
|
|
14
|
+
<h2>Elevated permissions required</h2>
|
|
15
|
+
<p>
|
|
16
|
+
Microsoft webview requires elevated permissions to access localhost.
|
|
17
|
+
<br />
|
|
18
|
+
Please, run it with the evevates permissions or run following command manually as administrator to allow access to the localhost for webview (this is required one time only):
|
|
19
|
+
</p>
|
|
20
|
+
<code>CheckNetIsolation.exe LoopbackExempt -a -n="Microsoft.Win32WebViewHost_cw5n1h2txyewy"</code>
|
|
21
|
+
</body>
|
|
22
|
+
</html>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import Events from "events";
|
|
2
|
+
import childProcess from "child_process";
|
|
3
|
+
|
|
4
|
+
const BINARIES = {
|
|
5
|
+
"win32": "webview.exe",
|
|
6
|
+
"linux": "webview",
|
|
7
|
+
"darwin": "webview",
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
var WIN32_ISOLATION;
|
|
11
|
+
|
|
12
|
+
export default class WebView extends Events {
|
|
13
|
+
#name;
|
|
14
|
+
#proc;
|
|
15
|
+
|
|
16
|
+
constructor ( url, { name, title, width, height, signal } = {} ) {
|
|
17
|
+
super();
|
|
18
|
+
|
|
19
|
+
if ( this.#proc ) return;
|
|
20
|
+
|
|
21
|
+
this.#name = name || "webview";
|
|
22
|
+
|
|
23
|
+
if ( process.platform === "win32" && !WIN32_ISOLATION ) {
|
|
24
|
+
const stdout = childProcess.execFileSync( "checknetisolation.exe", ["LoopbackExempt", "-s"], {
|
|
25
|
+
"windowsHide": true,
|
|
26
|
+
"encoding": "utf8",
|
|
27
|
+
} );
|
|
28
|
+
|
|
29
|
+
if ( !stdout.includes( "microsoft.win32webviewhost_cw5n1h2txyewy" ) ) {
|
|
30
|
+
childProcess.execFileSync( "hstart.exe", ["/ELEVATE", "/NOCONSOLE", "checknetisolation.exe LoopbackExempt -a -n=Microsoft.Win32WebViewHost_cw5n1h2txyewy"], {
|
|
31
|
+
"cwd": new URL( `binaries/${process.platform}`, import.meta.url ),
|
|
32
|
+
"windowsHide": true,
|
|
33
|
+
"encoding": "utf8",
|
|
34
|
+
} );
|
|
35
|
+
|
|
36
|
+
const stdout = childProcess.execFileSync( "checknetisolation.exe", ["LoopbackExempt", "-s"], {
|
|
37
|
+
"windowsHide": true,
|
|
38
|
+
"encoding": "utf8",
|
|
39
|
+
} );
|
|
40
|
+
|
|
41
|
+
if ( !stdout.includes( "microsoft.win32webviewhost_cw5n1h2txyewy" ) ) {
|
|
42
|
+
console.log( `Unable to start webview, elevated permissions required (https://github.com/webview/webview/issues/599)` );
|
|
43
|
+
|
|
44
|
+
url = new URL( `binaries/${process.platform}/elevation-required.html`, import.meta.url );
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
WIN32_ISOLATION = true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
WIN32_ISOLATION = true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const args = ["--url", url];
|
|
56
|
+
if ( title ) args.push( "--title", title );
|
|
57
|
+
if ( width ) args.push( "--width", width );
|
|
58
|
+
if ( height ) args.push( "--height", height );
|
|
59
|
+
|
|
60
|
+
this.#proc = childProcess
|
|
61
|
+
.spawn( BINARIES[process.platform], args, {
|
|
62
|
+
"cwd": new URL( `binaries/${process.platform}`, import.meta.url ),
|
|
63
|
+
"stdio": "ignore",
|
|
64
|
+
signal,
|
|
65
|
+
} )
|
|
66
|
+
.once( "error", e => {
|
|
67
|
+
if ( e.code !== "ABORT_ERR" ) throw e;
|
|
68
|
+
} )
|
|
69
|
+
.once( "close", () => {
|
|
70
|
+
this.#proc = null;
|
|
71
|
+
|
|
72
|
+
this.emit( "close" );
|
|
73
|
+
} );
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// properties
|
|
77
|
+
get name () {
|
|
78
|
+
return this.#name;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
isStarted () {
|
|
82
|
+
return !!this.#proc;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
close () {
|
|
86
|
+
if ( !this.#proc ) return;
|
|
87
|
+
this.#proc.kill();
|
|
88
|
+
|
|
89
|
+
this.#proc = null;
|
|
90
|
+
}
|
|
91
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@softvisio/webview",
|
|
3
|
+
"version": "1.2.5",
|
|
4
|
+
"description": "Webview bindings",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"softvisio",
|
|
7
|
+
"webview"
|
|
8
|
+
],
|
|
9
|
+
"homepage": "https://softvisio.github.io/webview/",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/softvisio/webview/issues",
|
|
12
|
+
"email": "zdm <zdm@softvisio.net>"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/softvisio/webview.git"
|
|
17
|
+
},
|
|
18
|
+
"license": "ISC",
|
|
19
|
+
"author": "zdm <zdm@softvisio.net>",
|
|
20
|
+
"type": "module",
|
|
21
|
+
"imports": {
|
|
22
|
+
"#lib/*": "./lib/*.js"
|
|
23
|
+
},
|
|
24
|
+
"exports": {
|
|
25
|
+
".": "./lib/index.js"
|
|
26
|
+
}
|
|
27
|
+
}
|