win_webview2 1.1.19 → 1.1.20
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/dist/browser/runVirtualDirBrowser.d.ts +1 -0
- package/dist/browser/runVirtualDirBrowser.js +36 -0
- package/dist/browser/ww2_browser.d.ts +2 -1
- package/dist/browser/ww2_browser.js +2 -0
- package/dist/node/tsExport/downloadModule.d.ts +3 -1
- package/dist/node/tsExport/downloadModule.js +1 -1
- package/dist/node/tsExport/runVirtualDir.d.ts +12 -0
- package/dist/node/tsExport/runVirtualDir.js +38 -0
- package/dist/node/tsExport/winwebview2.d.ts +2 -1
- package/dist/node/tsExport/winwebview2.js +3 -1
- package/dist/node/tsExport/ww2_server.js +4 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function callVirtualDirFunction(funName: string, param: string): Promise<unknown>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
let registerListenerReady = false;
|
|
2
|
+
let funRegistred = {};
|
|
3
|
+
function registerListener() {
|
|
4
|
+
if (registerListenerReady)
|
|
5
|
+
return;
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
window.chrome.webview.addEventListener('message', function (event) {
|
|
8
|
+
let data = event.data;
|
|
9
|
+
try {
|
|
10
|
+
let jobj = JSON.parse(data);
|
|
11
|
+
funRegistred[jobj.replyFun](jobj.data);
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
console.log("messageError ", error);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
registerListenerReady = true;
|
|
18
|
+
}
|
|
19
|
+
export function callVirtualDirFunction(funName, param) {
|
|
20
|
+
let ranNumber = Date.now();
|
|
21
|
+
let replyFun = funName + ranNumber;
|
|
22
|
+
registerListener();
|
|
23
|
+
let jsonPost = {
|
|
24
|
+
funName: funName,
|
|
25
|
+
data: param,
|
|
26
|
+
replyFun: replyFun
|
|
27
|
+
};
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
window.chrome.webview.postMessage(JSON.stringify(jsonPost));
|
|
30
|
+
return new Promise((r, x) => {
|
|
31
|
+
funRegistred[replyFun] = (msg) => {
|
|
32
|
+
delete funRegistred[replyFun];
|
|
33
|
+
r(msg);
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { callVirtualDirFunction } from "./runVirtualDirBrowser";
|
|
1
2
|
interface WW2FileDialogArg {
|
|
2
3
|
filter: string;
|
|
3
4
|
ownerClassName: string;
|
|
@@ -29,4 +30,4 @@ export declare function callWw2(arg: PostData): Promise<{
|
|
|
29
30
|
err: string;
|
|
30
31
|
result: string;
|
|
31
32
|
}>;
|
|
32
|
-
export {};
|
|
33
|
+
export { callVirtualDirFunction };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { callVirtualDirFunction } from "./runVirtualDirBrowser";
|
|
1
2
|
export async function callWw2(arg) {
|
|
2
3
|
let response = await fetch("/ww2_post", {
|
|
3
4
|
method: "POST",
|
|
@@ -9,3 +10,4 @@ export async function callWw2(arg) {
|
|
|
9
10
|
let result = await response.json();
|
|
10
11
|
return result;
|
|
11
12
|
}
|
|
13
|
+
export { callVirtualDirFunction };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WwvPlatFrom } from "./ww2_config";
|
|
2
|
-
interface Ww2WebConfig {
|
|
2
|
+
export interface Ww2WebConfig {
|
|
3
3
|
callback: (err: any, data: any) => void;
|
|
4
4
|
wclassname: string;
|
|
5
5
|
url: string;
|
|
@@ -9,6 +9,8 @@ interface Ww2WebConfig {
|
|
|
9
9
|
isKiosk: boolean;
|
|
10
10
|
isMaximize: boolean;
|
|
11
11
|
isDebug: boolean;
|
|
12
|
+
virtualHostNameToFolderMapping?: string;
|
|
13
|
+
onPostMessage: (msg: string, reply: (msg: string) => void) => void;
|
|
12
14
|
}
|
|
13
15
|
interface WW2FileDialogArg {
|
|
14
16
|
callback: (err: any, data: any) => void;
|
|
@@ -22,7 +22,7 @@ function extractZip(zipPath, targetDir) {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
;
|
|
25
|
-
const binFileVersion = "1.1.
|
|
25
|
+
const binFileVersion = "1.1.19";
|
|
26
26
|
async function downloadModuleFile(platform) {
|
|
27
27
|
let modulePath = (0, dirnameTool_1.getWWVNodeModuleFolder)();
|
|
28
28
|
let winlibPath = node_path_1.default.join(modulePath, "win_lib");
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Ww2WebConfig } from "./downloadModule";
|
|
2
|
+
export interface JsonMsg {
|
|
3
|
+
funName: string;
|
|
4
|
+
data: string;
|
|
5
|
+
replyFun: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function runVirtualDir(config: Omit<Ww2WebConfig, "onPostMessage" | "url" | "virtualHostNameToFolderMapping"> & {
|
|
8
|
+
mapFunction: {
|
|
9
|
+
[key: string]: (msg: string) => Promise<string>;
|
|
10
|
+
};
|
|
11
|
+
virtualHostNameToFolderMapping: string;
|
|
12
|
+
}): void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runVirtualDir = runVirtualDir;
|
|
4
|
+
const downloadModule_1 = require("./downloadModule");
|
|
5
|
+
const winwebview2_1 = require("./winwebview2");
|
|
6
|
+
function runVirtualDir(config) {
|
|
7
|
+
(0, downloadModule_1.getModule)().then((wwv) => {
|
|
8
|
+
(0, winwebview2_1.closeSplash)();
|
|
9
|
+
wwv.openWeb({
|
|
10
|
+
callback: config.callback,
|
|
11
|
+
height: config.height,
|
|
12
|
+
width: config.width,
|
|
13
|
+
wclassname: config.wclassname,
|
|
14
|
+
isDebug: config.isDebug,
|
|
15
|
+
isKiosk: config.isKiosk,
|
|
16
|
+
isMaximize: config.isMaximize,
|
|
17
|
+
onPostMessage: async (msg, r) => {
|
|
18
|
+
try {
|
|
19
|
+
let jobj = JSON.parse(msg);
|
|
20
|
+
if (jobj.funName == null)
|
|
21
|
+
throw "onPostMessage no funName";
|
|
22
|
+
let result = await config.mapFunction[jobj.funName](jobj.data);
|
|
23
|
+
let replyObj = {
|
|
24
|
+
funName: jobj.funName,
|
|
25
|
+
data: result,
|
|
26
|
+
replyFun: jobj.replyFun
|
|
27
|
+
};
|
|
28
|
+
r(JSON.stringify(replyObj));
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
title: config.title,
|
|
34
|
+
url: "",
|
|
35
|
+
virtualHostNameToFolderMapping: config.virtualHostNameToFolderMapping
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { getWWVNodeModuleFolder } from "./dirnameTool";
|
|
2
2
|
import { readConfig } from "./ww2_config";
|
|
3
3
|
import { downloadModuleAndExtract } from "./downloadModule";
|
|
4
|
+
import { runVirtualDir } from "./runVirtualDir";
|
|
4
5
|
export declare function closeSplash(): Promise<void>;
|
|
5
6
|
export * from "./downloadModule";
|
|
6
7
|
export * from "./ww2_server";
|
|
7
8
|
export { findUserProjectRoot } from "./dirnameTool";
|
|
8
9
|
export { readConfig };
|
|
9
|
-
export { getWWVNodeModuleFolder, downloadModuleAndExtract };
|
|
10
|
+
export { getWWVNodeModuleFolder, downloadModuleAndExtract, runVirtualDir };
|
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.downloadModuleAndExtract = exports.getWWVNodeModuleFolder = exports.readConfig = exports.findUserProjectRoot = void 0;
|
|
17
|
+
exports.runVirtualDir = exports.downloadModuleAndExtract = exports.getWWVNodeModuleFolder = exports.readConfig = exports.findUserProjectRoot = void 0;
|
|
18
18
|
exports.closeSplash = closeSplash;
|
|
19
19
|
const dirnameTool_1 = require("./dirnameTool");
|
|
20
20
|
Object.defineProperty(exports, "getWWVNodeModuleFolder", { enumerable: true, get: function () { return dirnameTool_1.getWWVNodeModuleFolder; } });
|
|
@@ -22,6 +22,8 @@ const ww2_config_1 = require("./ww2_config");
|
|
|
22
22
|
Object.defineProperty(exports, "readConfig", { enumerable: true, get: function () { return ww2_config_1.readConfig; } });
|
|
23
23
|
const downloadModule_1 = require("./downloadModule");
|
|
24
24
|
Object.defineProperty(exports, "downloadModuleAndExtract", { enumerable: true, get: function () { return downloadModule_1.downloadModuleAndExtract; } });
|
|
25
|
+
const runVirtualDir_1 = require("./runVirtualDir");
|
|
26
|
+
Object.defineProperty(exports, "runVirtualDir", { enumerable: true, get: function () { return runVirtualDir_1.runVirtualDir; } });
|
|
25
27
|
function closeSplash() {
|
|
26
28
|
return (0, downloadModule_1.getModule)().then((module) => {
|
|
27
29
|
module.controlWindow({
|
|
@@ -30,7 +30,8 @@ async function ww2_CreateServer(arg) {
|
|
|
30
30
|
isMaximize: openWebArg.isMaximize,
|
|
31
31
|
title: openWebArg.title,
|
|
32
32
|
url: openWebArg.url,
|
|
33
|
-
width: openWebArg.width
|
|
33
|
+
width: openWebArg.width,
|
|
34
|
+
onPostMessage: (m, r) => { }
|
|
34
35
|
});
|
|
35
36
|
result = openWebArg.url;
|
|
36
37
|
}
|
|
@@ -95,6 +96,8 @@ async function ww2_CreateServer(arg) {
|
|
|
95
96
|
title: uiConfig.title,
|
|
96
97
|
width: uiConfig.width,
|
|
97
98
|
url: url,
|
|
99
|
+
onPostMessage: (msg, r) => {
|
|
100
|
+
},
|
|
98
101
|
});
|
|
99
102
|
});
|
|
100
103
|
}
|