win_webview2 1.1.23 → 1.1.24

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.
@@ -0,0 +1,7 @@
1
+ export declare function createLauncher(arg: {
2
+ iconPath: string;
3
+ splashPath: string;
4
+ outPath: string;
5
+ platform: string;
6
+ script: string;
7
+ }): Promise<void>;
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.createLauncher = createLauncher;
40
+ const node_fs_1 = require("node:fs");
41
+ const promises_1 = require("node:fs/promises");
42
+ const node_path_1 = __importDefault(require("node:path"));
43
+ const dirnameTool_1 = require("../tsExport/dirnameTool");
44
+ const sharp_1 = __importDefault(require("sharp"));
45
+ const sharp_ico_1 = require("sharp-ico");
46
+ const PELibrary = __importStar(require("pe-library"));
47
+ const ResEdit = __importStar(require("resedit"));
48
+ async function createDir(dirpath) {
49
+ if (!(0, node_fs_1.existsSync)(dirpath)) {
50
+ try {
51
+ await (0, promises_1.mkdir)(dirpath, { recursive: true });
52
+ }
53
+ catch (error) {
54
+ }
55
+ }
56
+ }
57
+ async function createIcoFile(arg) {
58
+ let iconPath = arg.pngPath;
59
+ if (!(0, node_fs_1.existsSync)(iconPath)) {
60
+ console.log("icon not found");
61
+ return;
62
+ }
63
+ let outputIcon = arg.icoPath;
64
+ const sizes = [16, 32, 48, 256]; // Ukuran standar untuk rcedit
65
+ const images = await Promise.all(sizes.map(size => (0, sharp_1.default)(iconPath)
66
+ .resize(size, size)
67
+ .toFormat('png')));
68
+ await (0, sharp_ico_1.sharpsToIco)(images, outputIcon);
69
+ }
70
+ async function createLauncher(arg) {
71
+ if (arg.platform == null) {
72
+ arg.platform = "x64";
73
+ }
74
+ let exeTempPath = arg.outPath + '.temp.exe';
75
+ let exeReal = arg.outPath;
76
+ let outDirPath = node_path_1.default.dirname(arg.outPath);
77
+ await createDir(outDirPath);
78
+ let wwvPath = (0, dirnameTool_1.getWWVNodeModuleFolder)();
79
+ await (async () => {
80
+ console.log("copy launcer");
81
+ let launcerPath = node_path_1.default.join(wwvPath, "win_lib/" + arg.platform + "/appLauncher.exe");
82
+ await (0, promises_1.copyFile)(launcerPath, exeTempPath);
83
+ })();
84
+ console.log("copy splash file");
85
+ await (0, promises_1.copyFile)(arg.splashPath, node_path_1.default.join(outDirPath, "splash.png"));
86
+ await (async () => {
87
+ console.log("create ico file");
88
+ let icoPath = node_path_1.default.join(outDirPath, "icon.ico");
89
+ await createIcoFile({
90
+ pngPath: arg.iconPath,
91
+ icoPath: icoPath
92
+ });
93
+ console.log("edit file icon");
94
+ let iconBin = await (0, promises_1.readFile)(icoPath);
95
+ const iconFile = ResEdit.Data.IconFile.from(iconBin);
96
+ let exeData = await (0, promises_1.readFile)(exeTempPath);
97
+ let exe = PELibrary.NtExecutable.from(exeData);
98
+ let res = PELibrary.NtExecutableResource.from(exe);
99
+ ResEdit.Resource.IconGroupEntry.replaceIconsForResource(res.entries, 101, // ID Icon Group yang mau diganti (biasanya 101 atau 1)
100
+ 1033, // Language ID
101
+ iconFile.icons.map((item) => item.data) // Mengambil data biner dari tiap ukuran icon
102
+ );
103
+ const myScript = arg.script;
104
+ const scriptUint8 = new TextEncoder().encode(myScript);
105
+ const scriptEntry = {
106
+ type: 10, // RT_RCDATA
107
+ id: 'MY_SCRIPT', // Gunakan 'id' sesuai hasil print kamu
108
+ lang: 1033,
109
+ codepage: 0,
110
+ bin: scriptUint8.buffer // Ambil ArrayBuffer-nya
111
+ };
112
+ res.entries.push(scriptEntry);
113
+ res.outputResource(exe);
114
+ const newBinary = exe.generate();
115
+ await (0, promises_1.writeFile)(exeReal, Buffer.from(newBinary));
116
+ await (0, promises_1.rm)(exeTempPath);
117
+ })();
118
+ }
@@ -22,7 +22,7 @@ function extractZip(zipPath, targetDir) {
22
22
  }
23
23
  }
24
24
  ;
25
- const binFileVersion = "1.1.21";
25
+ const binFileVersion = "1.1.24";
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");
@@ -2,9 +2,11 @@ import { getWWVNodeModuleFolder } from "./dirnameTool";
2
2
  import { readConfig } from "./ww2_config";
3
3
  import { downloadModuleAndExtract } from "./downloadModule";
4
4
  import { runVirtualDir } from "./runVirtualDir/runVirtualDir";
5
+ import * as builderApi from "../builderApi/builderApi";
5
6
  export declare function closeSplash(): Promise<void>;
6
7
  export * from "./downloadModule";
7
8
  export * from "./ww2_server";
8
9
  export { findUserProjectRoot } from "./dirnameTool";
9
10
  export { readConfig };
10
11
  export { getWWVNodeModuleFolder, downloadModuleAndExtract, runVirtualDir };
12
+ export { builderApi };
@@ -10,11 +10,33 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
12
  }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
13
35
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
36
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
37
  };
16
38
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.runVirtualDir = exports.downloadModuleAndExtract = exports.getWWVNodeModuleFolder = exports.readConfig = exports.findUserProjectRoot = void 0;
39
+ exports.builderApi = exports.runVirtualDir = exports.downloadModuleAndExtract = exports.getWWVNodeModuleFolder = exports.readConfig = exports.findUserProjectRoot = void 0;
18
40
  exports.closeSplash = closeSplash;
19
41
  const dirnameTool_1 = require("./dirnameTool");
20
42
  Object.defineProperty(exports, "getWWVNodeModuleFolder", { enumerable: true, get: function () { return dirnameTool_1.getWWVNodeModuleFolder; } });
@@ -24,6 +46,8 @@ const downloadModule_1 = require("./downloadModule");
24
46
  Object.defineProperty(exports, "downloadModuleAndExtract", { enumerable: true, get: function () { return downloadModule_1.downloadModuleAndExtract; } });
25
47
  const runVirtualDir_1 = require("./runVirtualDir/runVirtualDir");
26
48
  Object.defineProperty(exports, "runVirtualDir", { enumerable: true, get: function () { return runVirtualDir_1.runVirtualDir; } });
49
+ const builderApi = __importStar(require("../builderApi/builderApi"));
50
+ exports.builderApi = builderApi;
27
51
  function closeSplash() {
28
52
  return (0, downloadModule_1.getModule)().then((module) => {
29
53
  module.controlWindow({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "win_webview2",
3
- "version": "1.1.23",
3
+ "version": "1.1.24",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/nnttoo/win_webview2"
@@ -39,7 +39,11 @@
39
39
  "comment-json": "^4.6.2",
40
40
  "degit": "^2.8.4",
41
41
  "express": "^5.2.1",
42
+ "pe-library": "^2.0.1",
42
43
  "prompts": "^2.4.2",
44
+ "resedit": "^3.0.2",
45
+ "sharp": "^0.34.5",
46
+ "sharp-ico": "^0.1.5",
43
47
  "tsx": "^4.21.0"
44
48
  },
45
49
  "devDependencies": {