win_webview2 1.0.3 → 1.0.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.
- package/README.md +26 -1
- package/argtype.ts +1 -0
- package/package.json +10 -2
- package/winWebview2.d.ts +18 -0
- package/winWebview2.mjs +3 -2
- package/win_lib/Win32/CmdWebview2.exe +0 -0
- package/win_lib/x64/CmdWebview2.exe +0 -0
- package/ww2_builder.mjs +1 -2
- package/ww2_builder_deploy.d.ts +3 -0
- package/index.js +0 -98
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Win Webview2
|
|
2
2
|
|
|
3
|
+
## npm install
|
|
4
|
+
|
|
5
|
+
```npm i win_webview2```
|
|
6
|
+
|
|
3
7
|
|
|
4
8
|
Win Webview2 is a GUI toolkit for building desktop applications with Node.js. It is similar to Electron but significantly smaller because Win Webview2 utilizes Microsoft WebView2, which is already installed on Windows 10 and later versions.
|
|
5
9
|
|
|
@@ -24,4 +28,25 @@ A menu will appear in the terminal with the following options:
|
|
|
24
28
|
"icon_path": "./icon.png",
|
|
25
29
|
"outdir": "./dist"
|
|
26
30
|
}
|
|
27
|
-
```
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Open Webview Frome Node
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
import { openDialogFile, openDialogFolder, openWeb } from 'win_webview2';
|
|
37
|
+
|
|
38
|
+
function openWebview(address) {
|
|
39
|
+
openWeb({
|
|
40
|
+
height : 400,
|
|
41
|
+
width: 800,
|
|
42
|
+
kiosk : false,
|
|
43
|
+
maximize : false,
|
|
44
|
+
title : "auto",
|
|
45
|
+
url : address,
|
|
46
|
+
isDebugMode : false
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
look at github examples folder for detail
|
package/argtype.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "win_webview2",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/nnttoo/win_webview2"
|
|
7
7
|
},
|
|
8
8
|
"description": "",
|
|
9
9
|
"main": "index.js",
|
|
10
|
-
"exports":
|
|
10
|
+
"exports":{
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./winWebview2.mjs",
|
|
13
|
+
"types": "./winWebview2.d.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
11
16
|
"bin": {
|
|
12
17
|
"win_webview2": "./ww2_builder.mjs"
|
|
13
18
|
},
|
|
@@ -18,5 +23,8 @@
|
|
|
18
23
|
"rcedit": "^4.0.1",
|
|
19
24
|
"sharp": "^0.33.5",
|
|
20
25
|
"sharp-ico": "^0.1.5"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^25.5.0"
|
|
21
29
|
}
|
|
22
30
|
}
|
package/winWebview2.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { OpenDialogFileArg, OpenWebArg } from "./argtype";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Open WebView window via IPC
|
|
6
|
+
*/
|
|
7
|
+
export function openWeb(arg: OpenWebArg): void;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Open file dialog and return selected file path
|
|
11
|
+
*/
|
|
12
|
+
export function openDialogFile(arg: OpenDialogFileArg): Promise<string>;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Open folder dialog and return selected folder path
|
|
16
|
+
*/
|
|
17
|
+
export function openDialogFolder(): Promise<string>;
|
|
18
|
+
|
package/winWebview2.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
|
|
3
2
|
import net from "net"
|
|
4
3
|
let isOncloseSetted = false;
|
|
5
4
|
const prefixWebview = "WINWEBVIEW_";
|
|
@@ -53,6 +52,8 @@ async function createPipe() {
|
|
|
53
52
|
console.log('Anak terhubung ke Named Pipe!');
|
|
54
53
|
});
|
|
55
54
|
|
|
55
|
+
|
|
56
|
+
|
|
56
57
|
client.on('data', (buff) => {
|
|
57
58
|
let data = buff.toString();
|
|
58
59
|
|
|
Binary file
|
|
Binary file
|
package/ww2_builder.mjs
CHANGED
package/index.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
var ffi = require('ffi-napi');
|
|
3
|
-
|
|
4
|
-
var arc = require('os').arch();
|
|
5
|
-
const path = require("path")
|
|
6
|
-
|
|
7
|
-
let libFilePath = "./bin/Win32/";
|
|
8
|
-
if (arc == "x64") {
|
|
9
|
-
console.log("using x64")
|
|
10
|
-
libFilePath = "./bin/x64/";
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
libFilePath = path.join(__dirname, libFilePath);
|
|
14
|
-
|
|
15
|
-
const mainDllPath = path.join(libFilePath, "win_webview2_lib.dll");
|
|
16
|
-
const webviewDllPath = path.join(libFilePath, "WebView2Loader.dll");
|
|
17
|
-
|
|
18
|
-
ffi.Library(webviewDllPath);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
module.exports = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// void OpenWebview(
|
|
28
|
-
// const char* url,
|
|
29
|
-
// int width,
|
|
30
|
-
// int height,
|
|
31
|
-
// bool maximize,
|
|
32
|
-
// bool kiosk,
|
|
33
|
-
// const char* title,
|
|
34
|
-
// const char* windowclassname,
|
|
35
|
-
// const char* windowParentclassname,
|
|
36
|
-
// CallbackType cb
|
|
37
|
-
|
|
38
|
-
// )
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @typedef OpenWebviewProp
|
|
42
|
-
* @property {string} url
|
|
43
|
-
* @property {int} width
|
|
44
|
-
* @property {int} height
|
|
45
|
-
* @property {bool} maximize
|
|
46
|
-
* @property {bool} kiosk
|
|
47
|
-
* @property {string} title
|
|
48
|
-
* @property {string} windowclassname
|
|
49
|
-
* @property {string} windowParentclassname
|
|
50
|
-
* @property {SimpleFFIcallback} ffiCallback
|
|
51
|
-
* @property {(string : str)=>void} callback
|
|
52
|
-
*
|
|
53
|
-
* @param {OpenWebviewProp} prop
|
|
54
|
-
*/
|
|
55
|
-
openWebview: (prop) => {
|
|
56
|
-
var libm = ffi.Library(mainDllPath, {
|
|
57
|
-
'OpenWebview': ['void',
|
|
58
|
-
[
|
|
59
|
-
'string', //url
|
|
60
|
-
'int', //width
|
|
61
|
-
'int', // height
|
|
62
|
-
'bool', // maximize
|
|
63
|
-
'bool', // kiosk
|
|
64
|
-
'string', // title.
|
|
65
|
-
'string', // windowclassname
|
|
66
|
-
'string', // windowParentclassname
|
|
67
|
-
'pointer', // CallbackType
|
|
68
|
-
]]
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
return new Promise((r,x)=>{
|
|
72
|
-
libm.OpenWebview.async(
|
|
73
|
-
prop.url,
|
|
74
|
-
prop.width,
|
|
75
|
-
prop.height,
|
|
76
|
-
prop.maximize,
|
|
77
|
-
prop.kiosk,
|
|
78
|
-
prop.title,
|
|
79
|
-
prop.windowclassname,
|
|
80
|
-
prop.windowParentclassname,
|
|
81
|
-
|
|
82
|
-
prop.ffiCallback,
|
|
83
|
-
(e, res) => {
|
|
84
|
-
if(e){
|
|
85
|
-
x(e);
|
|
86
|
-
} else {
|
|
87
|
-
r(res);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
)
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
}
|