win_webview2 1.1.16 → 1.1.18
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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WwvPlatFrom } from "./ww2_config";
|
|
1
2
|
interface Ww2WebConfig {
|
|
2
3
|
callback: (err: any, data: any) => void;
|
|
3
4
|
wclassname: string;
|
|
@@ -28,5 +29,6 @@ interface Ww2Module {
|
|
|
28
29
|
openFolderDialog: (arg: WW2FileDialogArg) => void;
|
|
29
30
|
controlWindow: (arg: WW2ControlWindowsArg) => void;
|
|
30
31
|
}
|
|
32
|
+
export declare function downloadModuleAndExtract(platform: WwvPlatFrom): Promise<void>;
|
|
31
33
|
export declare function getModule(): Promise<Ww2Module>;
|
|
32
34
|
export {};
|
|
@@ -3,22 +3,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.downloadModuleAndExtract = downloadModuleAndExtract;
|
|
6
7
|
exports.getModule = getModule;
|
|
7
8
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
9
|
const dirnameTool_1 = require("./dirnameTool");
|
|
9
|
-
const ww2_config_1 = require("./ww2_config");
|
|
10
10
|
const node_fs_1 = require("node:fs");
|
|
11
11
|
const downloader_1 = require("./downloader");
|
|
12
12
|
const promises_1 = require("node:fs/promises");
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const adm_zip_1 = __importDefault(require("adm-zip"));
|
|
14
|
+
function extractZip(zipPath, targetDir) {
|
|
15
|
+
try {
|
|
16
|
+
const zip = new adm_zip_1.default(zipPath);
|
|
17
|
+
zip.extractAllTo(targetDir, true);
|
|
18
|
+
console.log(`✅ Extract done to: ${targetDir}`);
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
console.error("❌ Error extract:", err);
|
|
22
|
+
}
|
|
17
23
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
let
|
|
24
|
+
;
|
|
25
|
+
const binFileVersion = "1.1.16";
|
|
26
|
+
async function downloadModuleFile(platform) {
|
|
27
|
+
let modulePath = (0, dirnameTool_1.getWWVNodeModuleFolder)();
|
|
28
|
+
let winlibPath = node_path_1.default.join(modulePath, "win_lib");
|
|
29
|
+
let fileName = platform + ".zip";
|
|
30
|
+
let filePath = node_path_1.default.join(winlibPath, fileName);
|
|
31
|
+
let url = `https://github.com/nnttoo/win_webview2/releases/download/${binFileVersion}/${fileName}`;
|
|
22
32
|
console.log("Bin File Version : " + binFileVersion);
|
|
23
33
|
console.log("downloading :\n", url);
|
|
24
34
|
try {
|
|
@@ -29,17 +39,32 @@ async function downloadModuleFile(libname, platform) {
|
|
|
29
39
|
}
|
|
30
40
|
await (0, downloader_1.downloadFile)(url, filePath);
|
|
31
41
|
}
|
|
32
|
-
async function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
async function sleep(n) {
|
|
43
|
+
return new Promise((r, x) => {
|
|
44
|
+
setTimeout(() => {
|
|
45
|
+
r(null);
|
|
46
|
+
}, n);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async function downloadModuleAndExtract(platform) {
|
|
50
|
+
await downloadModuleFile(platform);
|
|
51
|
+
let modulePath = (0, dirnameTool_1.getWWVNodeModuleFolder)();
|
|
52
|
+
let winlibPath = node_path_1.default.join(modulePath, "win_lib");
|
|
53
|
+
let fileName = platform + ".zip";
|
|
54
|
+
let filePath = node_path_1.default.join(winlibPath, fileName);
|
|
55
|
+
extractZip(filePath, node_path_1.default.join(winlibPath, platform));
|
|
56
|
+
await sleep(1000);
|
|
57
|
+
}
|
|
58
|
+
function getCurrentPlatform() {
|
|
59
|
+
let result = "x64";
|
|
60
|
+
if (process.arch != 'x64') {
|
|
61
|
+
result = "x86";
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
37
64
|
}
|
|
38
65
|
async function getModule() {
|
|
39
66
|
let addOnName = "ww2_addon.node";
|
|
40
|
-
let
|
|
41
|
-
if (config == null)
|
|
42
|
-
throw "cannot read config";
|
|
67
|
+
let platform = getCurrentPlatform();
|
|
43
68
|
let filepath = (() => {
|
|
44
69
|
let userFolder = (0, dirnameTool_1.findUserProjectRoot)();
|
|
45
70
|
if (userFolder == null)
|
|
@@ -53,13 +78,13 @@ async function getModule() {
|
|
|
53
78
|
if (filepath != null)
|
|
54
79
|
return filepath;
|
|
55
80
|
let wwvModulePath = (0, dirnameTool_1.getWWVNodeModuleFolder)();
|
|
56
|
-
let r = node_path_1.default.join(wwvModulePath, `win_lib/${
|
|
81
|
+
let r = node_path_1.default.join(wwvModulePath, `win_lib/${platform}/ww2_addon.node`);
|
|
57
82
|
return r;
|
|
58
83
|
})();
|
|
59
84
|
if (filepath == null)
|
|
60
85
|
throw "file path is null";
|
|
61
86
|
if (!(0, node_fs_1.existsSync)(filepath)) {
|
|
62
|
-
await
|
|
87
|
+
await downloadModuleAndExtract(platform);
|
|
63
88
|
}
|
|
64
89
|
let myAddon = require(filepath);
|
|
65
90
|
return myAddon;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { getWWVNodeModuleFolder } from "./dirnameTool";
|
|
2
2
|
import { readConfig } from "./ww2_config";
|
|
3
|
+
import { downloadModuleAndExtract } from "./downloadModule";
|
|
3
4
|
export declare function closeSplash(): Promise<void>;
|
|
4
5
|
export * from "./downloadModule";
|
|
5
6
|
export * from "./ww2_server";
|
|
6
7
|
export { findUserProjectRoot } from "./dirnameTool";
|
|
7
8
|
export { readConfig };
|
|
8
|
-
export { getWWVNodeModuleFolder };
|
|
9
|
+
export { getWWVNodeModuleFolder, downloadModuleAndExtract };
|
|
@@ -14,13 +14,14 @@ 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.getWWVNodeModuleFolder = exports.readConfig = exports.findUserProjectRoot = void 0;
|
|
17
|
+
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; } });
|
|
21
21
|
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
|
+
Object.defineProperty(exports, "downloadModuleAndExtract", { enumerable: true, get: function () { return downloadModule_1.downloadModuleAndExtract; } });
|
|
24
25
|
function closeSplash() {
|
|
25
26
|
return (0, downloadModule_1.getModule)().then((module) => {
|
|
26
27
|
module.controlWindow({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "win_webview2",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.18",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/nnttoo/win_webview2"
|
|
@@ -28,12 +28,14 @@
|
|
|
28
28
|
"build_node_watch": "npm run build_node -- --watch",
|
|
29
29
|
"build_browser": "tsc -p ./src/srcBrowser/tsconfig.json",
|
|
30
30
|
"build_browser_watch": "npm run build_browser -- --watch",
|
|
31
|
-
"build_all"
|
|
32
|
-
"copy_dll": "tsx ./srcInternal/copyDll.ts"
|
|
31
|
+
"build_all": "npm run build_node && npm run build_browser",
|
|
32
|
+
"copy_dll": "tsx ./srcInternal/copyDll.ts",
|
|
33
|
+
"Clean_WinLib": "rm -rf ./win_lib"
|
|
33
34
|
},
|
|
34
35
|
"author": "",
|
|
35
36
|
"license": "ISC",
|
|
36
37
|
"dependencies": {
|
|
38
|
+
"adm-zip": "^0.5.17",
|
|
37
39
|
"comment-json": "^4.6.2",
|
|
38
40
|
"degit": "^2.8.4",
|
|
39
41
|
"express": "^5.2.1",
|
|
@@ -41,6 +43,7 @@
|
|
|
41
43
|
"tsx": "^4.21.0"
|
|
42
44
|
},
|
|
43
45
|
"devDependencies": {
|
|
46
|
+
"@types/adm-zip": "^0.5.8",
|
|
44
47
|
"@types/express": "^5.0.6",
|
|
45
48
|
"@types/node": "^25.5.2",
|
|
46
49
|
"@types/prompts": "^2.4.9",
|