win_webview2 1.1.23 → 1.1.25
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,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.
|
|
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");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "win_webview2",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.25",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/nnttoo/win_webview2"
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
"./node": {
|
|
17
17
|
"types": "./dist/node/tsExport/winwebview2.dt.ts",
|
|
18
18
|
"default": "./dist/node/tsExport/winwebview2.js"
|
|
19
|
+
},
|
|
20
|
+
"./builder": {
|
|
21
|
+
"types": "./dist/node/builderApi/builderApi.d.ts",
|
|
22
|
+
"default": "./dist/node/builderApi/builderApi.js"
|
|
19
23
|
}
|
|
20
24
|
},
|
|
21
25
|
"bin": {
|
|
@@ -39,7 +43,11 @@
|
|
|
39
43
|
"comment-json": "^4.6.2",
|
|
40
44
|
"degit": "^2.8.4",
|
|
41
45
|
"express": "^5.2.1",
|
|
46
|
+
"pe-library": "^2.0.1",
|
|
42
47
|
"prompts": "^2.4.2",
|
|
48
|
+
"resedit": "^3.0.2",
|
|
49
|
+
"sharp": "^0.34.5",
|
|
50
|
+
"sharp-ico": "^0.1.5",
|
|
43
51
|
"tsx": "^4.21.0"
|
|
44
52
|
},
|
|
45
53
|
"devDependencies": {
|