win_webview2 1.0.0 → 1.0.2
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 +1 -1
- package/index.js +1 -13
- package/package.json +3 -3
- package/winWebview2.mjs +77 -61
- package/win_lib/Win32/CmdWebview2.exe +0 -0
- package/win_lib/x64/CmdWebview2.exe +0 -0
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -22,19 +22,7 @@ ffi.Library(webviewDllPath);
|
|
|
22
22
|
|
|
23
23
|
module.exports = {
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @typedef SimpleFFIcallback
|
|
28
|
-
*
|
|
29
|
-
* @param {(string : str)=>void} jscallback
|
|
30
|
-
* @return {SimpleFFIcallback}
|
|
31
|
-
*/
|
|
32
|
-
createFFIcallback : (jscallback)=>{
|
|
33
|
-
return ffi.Callback('void', ['string'], (g) => {
|
|
34
|
-
jscallback(g);
|
|
35
|
-
})
|
|
36
|
-
},
|
|
37
|
-
|
|
25
|
+
|
|
38
26
|
|
|
39
27
|
// void OpenWebview(
|
|
40
28
|
// const char* url,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "win_webview2",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/nnttoo/win_webview2"
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
"main": "index.js",
|
|
10
10
|
"exports": "./winWebview2.mjs",
|
|
11
11
|
"bin": {
|
|
12
|
-
"
|
|
12
|
+
"win_webview2": "./ww2_builder.mjs"
|
|
13
13
|
},
|
|
14
14
|
"author": "",
|
|
15
15
|
"license": "ISC",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"prompts": "^2.4.
|
|
17
|
+
"prompts": "^2.4.3",
|
|
18
18
|
"rcedit": "^4.0.1",
|
|
19
19
|
"sharp": "^0.33.5",
|
|
20
20
|
"sharp-ico": "^0.1.5"
|
package/winWebview2.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
+
|
|
3
|
+
import net from "net"
|
|
2
4
|
let isOncloseSetted = false;
|
|
3
5
|
const prefixWebview = "WINWEBVIEW_";
|
|
4
6
|
const prefixWebviewResult = "WIN_WEBVIEW2_RESULT";
|
|
@@ -7,15 +9,10 @@ const prefixWebviewResult = "WIN_WEBVIEW2_RESULT";
|
|
|
7
9
|
let resultDataFromWebview2 = "";
|
|
8
10
|
let resultInUse = false;
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*/
|
|
15
|
-
function sleep(n){
|
|
16
|
-
return new Promise((r,x)=>{
|
|
17
|
-
setTimeout(r,n);
|
|
18
|
-
})
|
|
12
|
+
function sleep(n = 1000) {
|
|
13
|
+
return new Promise((r, x) => {
|
|
14
|
+
setTimeout(r, n);
|
|
15
|
+
})
|
|
19
16
|
}
|
|
20
17
|
|
|
21
18
|
|
|
@@ -23,63 +20,82 @@ function sleep(n){
|
|
|
23
20
|
*
|
|
24
21
|
* @param {object } arg
|
|
25
22
|
*/
|
|
26
|
-
async function waitingResult(arg){
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
resultDataFromWebview2 = null;
|
|
31
|
-
|
|
32
|
-
var objstr = JSON.stringify(arg);
|
|
33
|
-
console.log(`${prefixWebview}JSON` + objstr);
|
|
34
|
-
|
|
35
|
-
while(resultDataFromWebview2 == null){
|
|
36
|
-
await sleep(200);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
resultInUse = false;
|
|
40
|
-
return resultDataFromWebview2;
|
|
23
|
+
async function waitingResult(arg) {
|
|
24
|
+
if (resultInUse) return "";
|
|
25
|
+
resultInUse = true;
|
|
41
26
|
|
|
42
|
-
|
|
27
|
+
resultDataFromWebview2 = null;
|
|
43
28
|
|
|
29
|
+
var objstr = JSON.stringify(arg);
|
|
30
|
+
sendToPipe(`${prefixWebview}JSON` + objstr);
|
|
31
|
+
|
|
32
|
+
while (resultDataFromWebview2 == null) {
|
|
33
|
+
await sleep(200);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
resultInUse = false;
|
|
37
|
+
return resultDataFromWebview2;
|
|
44
38
|
|
|
45
|
-
/**
|
|
46
|
-
*
|
|
47
|
-
* @param {string} data
|
|
48
|
-
*/
|
|
49
|
-
function setToResult(data){
|
|
50
|
-
if(!data.startsWith(prefixWebviewResult)) return false;
|
|
51
|
-
let result = data.substring(prefixWebviewResult.length);
|
|
52
|
-
resultDataFromWebview2 = result;
|
|
53
|
-
return true;
|
|
54
39
|
}
|
|
55
40
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
async function createPipe() {
|
|
44
|
+
|
|
45
|
+
// ini akan terhubung terus menerus
|
|
46
|
+
|
|
47
|
+
/** @type {string} */
|
|
48
|
+
// @ts-ignore
|
|
49
|
+
let PIPE_CPLUS_SENDER = process.env.PIPE_PATH + "Sender";
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
let client = net.createConnection(PIPE_CPLUS_SENDER, () => {
|
|
53
|
+
console.log('Anak terhubung ke Named Pipe!');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
client.on('data', (buff) => {
|
|
57
|
+
let data = buff.toString();
|
|
58
|
+
|
|
59
|
+
if (!data.startsWith(prefixWebviewResult)) return false;
|
|
60
|
+
let result = data.substring(prefixWebviewResult.length);
|
|
61
|
+
resultDataFromWebview2 = result;
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// while(true){
|
|
65
|
+
// await sleep();
|
|
66
|
+
// sendToPipe("ping");
|
|
67
|
+
// }
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
/**
|
|
71
|
+
* @param {string} msg
|
|
72
|
+
*/
|
|
73
|
+
function sendToPipe(msg) {
|
|
74
|
+
|
|
75
|
+
/** @type {any} */
|
|
76
|
+
var PIPE_CPLUS_Reader = process.env.PIPE_PATH;
|
|
77
|
+
let client = net.createConnection(PIPE_CPLUS_Reader, () => {
|
|
78
|
+
console.log("PIPE_CPLUS_Reader terhubung")
|
|
79
|
+
client.write(msg);
|
|
80
|
+
});
|
|
81
|
+
client.on("error",(e)=>{
|
|
82
|
+
console.log("errornya apa : ", e );
|
|
83
|
+
})
|
|
84
|
+
}
|
|
69
85
|
|
|
70
86
|
/**
|
|
71
87
|
*
|
|
72
88
|
* @param {import("./argtype").OpenWebArg } arg
|
|
73
89
|
*/
|
|
74
90
|
export function openWeb(arg) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
91
|
+
if (!isOncloseSetted) {
|
|
92
|
+
isOncloseSetted = true;
|
|
93
|
+
createPipe();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
arg["fun"] = "OpenWeb";
|
|
97
|
+
var objstr = JSON.stringify(arg);
|
|
98
|
+
sendToPipe(`${prefixWebview}JSON` + objstr);
|
|
83
99
|
}
|
|
84
100
|
|
|
85
101
|
/**
|
|
@@ -87,14 +103,14 @@ export function openWeb(arg) {
|
|
|
87
103
|
* @param {import("./argtype").OpenDialogFileArg} arg
|
|
88
104
|
* @returns {Promise<string>}
|
|
89
105
|
*/
|
|
90
|
-
export
|
|
91
|
-
|
|
92
|
-
|
|
106
|
+
export function openDialogFile(arg) {
|
|
107
|
+
arg["fun"] = "OpenDialogFIle";
|
|
108
|
+
return waitingResult(arg);
|
|
93
109
|
}
|
|
94
110
|
|
|
95
|
-
export async function openDialogFolder(){
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
111
|
+
export async function openDialogFolder() {
|
|
112
|
+
let obj = {
|
|
113
|
+
fun: "OpenDialogFolder"
|
|
114
|
+
};
|
|
115
|
+
return waitingResult(obj);
|
|
100
116
|
}
|
|
Binary file
|
|
Binary file
|