win_webview2 1.1.16 → 1.1.17

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
- function getLibFilePath(libName, platform) {
14
- let modulePath = (0, dirnameTool_1.getWWVNodeModuleFolder)();
15
- modulePath = node_path_1.default.join(modulePath, "win_lib", platform, libName);
16
- return modulePath;
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
- const binFileVersion = "1.1.14";
19
- async function downloadModuleFile(libname, platform) {
20
- let filePath = getLibFilePath(libname, platform);
21
- let url = `https://github.com/nnttoo/win_webview2/releases/download/${binFileVersion}_${platform}/${libname}`;
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,25 @@ async function downloadModuleFile(libname, platform) {
29
39
  }
30
40
  await (0, downloader_1.downloadFile)(url, filePath);
31
41
  }
32
- async function downloadModule(platform) {
33
- await downloadModuleFile("ww2_addon.node", platform);
34
- await downloadModuleFile("WebView2Loader.dll", platform);
35
- await downloadModuleFile("exeOpenner.exe", platform);
36
- await downloadModuleFile("splash.png", platform);
42
+ async function downloadModuleAndExtract(platform) {
43
+ await downloadModuleFile(platform);
44
+ let modulePath = (0, dirnameTool_1.getWWVNodeModuleFolder)();
45
+ let winlibPath = node_path_1.default.join(modulePath, "win_lib");
46
+ let fileName = platform + ".zip";
47
+ let filePath = node_path_1.default.join(winlibPath, fileName);
48
+ extractZip(filePath, node_path_1.default.join(winlibPath, platform));
49
+ await (0, promises_1.unlink)(filePath);
50
+ }
51
+ function getCurrentPlatform() {
52
+ let result = "x64";
53
+ if (process.arch != 'x64') {
54
+ result = "x86";
55
+ }
56
+ return result;
37
57
  }
38
58
  async function getModule() {
39
59
  let addOnName = "ww2_addon.node";
40
- let config = await (0, ww2_config_1.readConfig)();
41
- if (config == null)
42
- throw "cannot read config";
60
+ let platform = getCurrentPlatform();
43
61
  let filepath = (() => {
44
62
  let userFolder = (0, dirnameTool_1.findUserProjectRoot)();
45
63
  if (userFolder == null)
@@ -53,13 +71,13 @@ async function getModule() {
53
71
  if (filepath != null)
54
72
  return filepath;
55
73
  let wwvModulePath = (0, dirnameTool_1.getWWVNodeModuleFolder)();
56
- let r = node_path_1.default.join(wwvModulePath, `win_lib/${config.platform}/ww2_addon.node`);
74
+ let r = node_path_1.default.join(wwvModulePath, `win_lib/${platform}/ww2_addon.node`);
57
75
  return r;
58
76
  })();
59
77
  if (filepath == null)
60
78
  throw "file path is null";
61
79
  if (!(0, node_fs_1.existsSync)(filepath)) {
62
- await downloadModule(config.platform);
80
+ await downloadModuleAndExtract(platform);
63
81
  }
64
82
  let myAddon = require(filepath);
65
83
  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.16",
3
+ "version": "1.1.17",
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" : "npm run build_node && npm run build_browser",
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",