win_webview2 1.0.13 → 1.1.5
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/README.md +164 -31
- package/buildtools/copyDll.ts +71 -0
- package/{tsconfig.json → buildtools/tsconfig.json} +12 -12
- package/dist/browser/ww2_browser.d.ts +32 -0
- package/dist/browser/ww2_browser.js +11 -0
- package/{tsDist/srcBuilder → dist/node/builder}/build_copyDir.d.ts +1 -1
- package/{tsDist/srcBuilder → dist/node/builder}/build_copyDir.js +24 -24
- package/dist/node/builder/builder_deploy.d.ts +2 -0
- package/{tsDist/srcBuilder/builder_tp.js → dist/node/builder/builder_deploy.js} +2 -2
- package/dist/node/builder/builder_init.d.ts +9 -0
- package/dist/node/builder/builder_init.js +52 -0
- package/dist/node/builder/builder_promps.d.ts +9 -0
- package/dist/node/builder/builder_promps.js +68 -0
- package/dist/node/builder/dirnameTool.d.ts +4 -0
- package/dist/node/builder/dirnameTool.js +16 -0
- package/dist/node/builder/tools.d.ts +4 -0
- package/dist/node/builder/tools.js +15 -0
- package/dist/node/builder/userExec.d.ts +2 -0
- package/dist/node/builder/userExec.js +45 -0
- package/{tsDist/srcBuilder/builder_tp.d.ts → dist/node/tsExport/config.d.ts} +7 -7
- package/dist/node/tsExport/config.js +2 -0
- package/dist/node/tsExport/dirnameTool.d.ts +6 -0
- package/dist/node/tsExport/dirnameTool.js +63 -0
- package/dist/node/tsExport/winwebview2.d.ts +38 -0
- package/dist/node/tsExport/winwebview2.js +51 -0
- package/dist/node/tsExport/ww2_config.d.ts +7 -0
- package/dist/node/tsExport/ww2_config.js +18 -0
- package/dist/node/tsExport/ww2_server.d.ts +36 -0
- package/dist/node/tsExport/ww2_server.js +100 -0
- package/package.json +21 -7
- package/srcBrowser/tsconfig.json +13 -0
- package/srcBrowser/ww2_browser.ts +47 -0
- package/srcNode/builder/builder_init.ts +78 -0
- package/srcNode/builder/builder_promps.ts +93 -0
- package/srcNode/builder/userExec.ts +54 -0
- package/srcNode/tsExport/dirnameTool.ts +34 -0
- package/srcNode/tsExport/winwebview2.ts +78 -0
- package/srcNode/tsExport/ww2_config.ts +24 -0
- package/srcNode/tsExport/ww2_server.ts +157 -0
- package/srcNode/tsconfig.json +13 -0
- package/tsDistRun.js +5 -5
- package/win_lib/Win32/WebView2Loader.dll +0 -0
- package/win_lib/Win32/exeOpenner.exe +0 -0
- package/win_lib/Win32/ww2_addon.node +0 -0
- package/win_lib/x64/WebView2Loader.dll +0 -0
- package/win_lib/x64/exeOpenner.exe +0 -0
- package/win_lib/x64/ww2_addon.node +0 -0
- package/tsDist/logprint.d.ts +0 -1
- package/tsDist/logprint.js +0 -6
- package/tsDist/srcBuilder/ww2_build_promp.d.ts +0 -1
- package/tsDist/srcBuilder/ww2_build_promp.js +0 -31
- package/tsDist/srcBuilder/ww2_buildercore.d.ts +0 -14
- package/tsDist/srcBuilder/ww2_buildercore.js +0 -124
- package/tsDist/tsExport/winwebview2.d.ts +0 -28
- package/tsDist/tsExport/winwebview2.js +0 -105
- package/tsSrc/logprint.ts +0 -3
- package/tsSrc/srcBuilder/build_copyDir.ts +0 -32
- package/tsSrc/srcBuilder/builder_tp.ts +0 -7
- package/tsSrc/srcBuilder/ww2_build_promp.ts +0 -30
- package/tsSrc/srcBuilder/ww2_buildercore.ts +0 -182
- package/tsSrc/tsExport/winwebview2.ts +0 -160
- package/win_lib/Win32/CmdWebview2.exe +0 -0
- package/win_lib/Win32/icon.ico +0 -0
- package/win_lib/Win32/index.bat +0 -3
- package/win_lib/x64/CmdWebview2.exe +0 -0
- package/win_lib/x64/icon.ico +0 -0
- package/win_lib/x64/index.bat +0 -3
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import path, { dirname } from 'node:path';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export function getWw2Dirname() {
|
|
7
|
+
// Trik deteksi lingkungan
|
|
8
|
+
const _filename = typeof __filename !== 'undefined'
|
|
9
|
+
? __filename
|
|
10
|
+
// @ts-ignore:
|
|
11
|
+
: fileURLToPath(eval('import.meta.url'));
|
|
12
|
+
|
|
13
|
+
const _dirname = typeof __dirname !== 'undefined'
|
|
14
|
+
? __dirname
|
|
15
|
+
: dirname(_filename);
|
|
16
|
+
|
|
17
|
+
let ww2ModulePath = path.join(_dirname,"../../../")
|
|
18
|
+
|
|
19
|
+
return { _dirname, _filename , ww2ModulePath};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function findUserProjectRoot(currentDir : string = process.cwd()) {
|
|
23
|
+
|
|
24
|
+
const packagePath = path.join(currentDir, 'package.json');
|
|
25
|
+
if (existsSync(packagePath)) {
|
|
26
|
+
return currentDir;
|
|
27
|
+
}
|
|
28
|
+
const parentDir = path.dirname(currentDir);
|
|
29
|
+
if (parentDir === currentDir) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return findUserProjectRoot(parentDir);
|
|
33
|
+
}
|
|
34
|
+
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { readFile } from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { getWw2Dirname } from "./dirnameTool";
|
|
6
|
+
import { ConfigWW2, readConfig } from "./ww2_config";
|
|
7
|
+
|
|
8
|
+
interface Ww2WebConfig {
|
|
9
|
+
callback: (err: any, data: any) => void;
|
|
10
|
+
wclassname: string;
|
|
11
|
+
url: string;
|
|
12
|
+
title: string;
|
|
13
|
+
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
isKiosk: boolean;
|
|
17
|
+
isMaximize: boolean;
|
|
18
|
+
isDebug: boolean;
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface WW2FileDialogArg {
|
|
23
|
+
callback: (err: any, data: any) => void;
|
|
24
|
+
filter: string;
|
|
25
|
+
ownerClassName: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface WW2ControlWindowsArg {
|
|
29
|
+
wndClassName: string;
|
|
30
|
+
controlcmd: "close" | "move" | "maximize" | "minimize" | "resize" | "check",
|
|
31
|
+
left?: number;
|
|
32
|
+
top?: number;
|
|
33
|
+
height?: number;
|
|
34
|
+
width?: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface Ww2Module {
|
|
38
|
+
openWeb: (arg: Ww2WebConfig) => void;
|
|
39
|
+
openFileDialog: (arg: WW2FileDialogArg) => void;
|
|
40
|
+
openFolderDialog: (arg: WW2FileDialogArg) => void;
|
|
41
|
+
controlWindow: (arg: WW2ControlWindowsArg) => void;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
export async function getModule() {
|
|
47
|
+
let dirname = getWw2Dirname();
|
|
48
|
+
|
|
49
|
+
let filepath = path.join(
|
|
50
|
+
dirname._dirname,
|
|
51
|
+
"./ww2_addon.node"
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
if (!existsSync(filepath)) {
|
|
55
|
+
|
|
56
|
+
let config = await readConfig();
|
|
57
|
+
if(config == null) throw "user config null";
|
|
58
|
+
filepath = path.join(dirname._dirname, `../../../win_lib/${config.platform}/ww2_addon.node`);
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
let myAddon = require(filepath) as Ww2Module;
|
|
63
|
+
return myAddon;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function closeSplash(){
|
|
67
|
+
return getModule().then((module)=>{
|
|
68
|
+
module.controlWindow({
|
|
69
|
+
controlcmd : "close",
|
|
70
|
+
wndClassName : "mysplashclassname"
|
|
71
|
+
})
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export * from "./ww2_server"
|
|
76
|
+
export {findUserProjectRoot } from "./dirnameTool"
|
|
77
|
+
export {readConfig} ;
|
|
78
|
+
export {getWw2Dirname}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { findUserProjectRoot } from "./dirnameTool";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
export type ConfigWW2 = {
|
|
6
|
+
appname: string;
|
|
7
|
+
entry_point: string;
|
|
8
|
+
outdir: string;
|
|
9
|
+
platform: 'Win32' | 'x64'
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
const jsonConfigFilePath = "./win_webview2.json";
|
|
14
|
+
export async function readConfig() {
|
|
15
|
+
let userDir = findUserProjectRoot();
|
|
16
|
+
if (userDir == null) return null;
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
let str = await readFile(path.join(userDir, jsonConfigFilePath));
|
|
21
|
+
let jsonObj = JSON.parse(str.toString());
|
|
22
|
+
|
|
23
|
+
return jsonObj as ConfigWW2;
|
|
24
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
|
|
2
|
+
import express from 'express';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { Server } from 'http';
|
|
5
|
+
import { AddressInfo } from 'net';
|
|
6
|
+
import { getModule, WW2ControlWindowsArg } from './winwebview2';
|
|
7
|
+
|
|
8
|
+
interface WW2FileDialogArg {
|
|
9
|
+
filter: string;
|
|
10
|
+
ownerClassName: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export type PostData = {
|
|
15
|
+
openWeb?: {
|
|
16
|
+
wclassname: string,
|
|
17
|
+
url: string,
|
|
18
|
+
title: string,
|
|
19
|
+
|
|
20
|
+
width: number,
|
|
21
|
+
height: number,
|
|
22
|
+
isKiosk: boolean,
|
|
23
|
+
isMaximize: boolean,
|
|
24
|
+
isDebug: boolean,
|
|
25
|
+
},
|
|
26
|
+
openFileDialog?: WW2FileDialogArg,
|
|
27
|
+
openFolderDialog?: WW2FileDialogArg,
|
|
28
|
+
controlWindow?: WW2ControlWindowsArg,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export async function ww2_CreateServer(arg: {
|
|
32
|
+
port: number,
|
|
33
|
+
onExpressCreate: (app: express.Express) => void,
|
|
34
|
+
uiConfig: {
|
|
35
|
+
|
|
36
|
+
wclassname: string,
|
|
37
|
+
title: string,
|
|
38
|
+
width: number,
|
|
39
|
+
height: number,
|
|
40
|
+
isKiosk: boolean,
|
|
41
|
+
isMaximize: boolean,
|
|
42
|
+
isDebug: boolean,
|
|
43
|
+
},
|
|
44
|
+
htmlfolder : string
|
|
45
|
+
}) {
|
|
46
|
+
let port = arg.port ? arg.port : 0;
|
|
47
|
+
|
|
48
|
+
let app = express();
|
|
49
|
+
app.use(express.json());
|
|
50
|
+
app.use(express.static(arg.htmlfolder));
|
|
51
|
+
arg.onExpressCreate(app);
|
|
52
|
+
|
|
53
|
+
app.post("/ww2_post", async (req, res) => {
|
|
54
|
+
|
|
55
|
+
let body = req.body as PostData;
|
|
56
|
+
console.log("ww2_post", body);
|
|
57
|
+
let result = "";
|
|
58
|
+
let err = "";
|
|
59
|
+
try {
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
if (body.openWeb) {
|
|
64
|
+
let openWebArg = body.openWeb;
|
|
65
|
+
ww2Module.openWeb({
|
|
66
|
+
callback: () => {
|
|
67
|
+
|
|
68
|
+
},
|
|
69
|
+
height: openWebArg.height,
|
|
70
|
+
wclassname: openWebArg.wclassname,
|
|
71
|
+
isDebug: openWebArg.isDebug,
|
|
72
|
+
isKiosk: openWebArg.isKiosk,
|
|
73
|
+
isMaximize: openWebArg.isMaximize,
|
|
74
|
+
title: openWebArg.title,
|
|
75
|
+
url: openWebArg.url,
|
|
76
|
+
width: openWebArg.width
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
result = openWebArg.url;
|
|
80
|
+
|
|
81
|
+
} else if (body.controlWindow) {
|
|
82
|
+
ww2Module.controlWindow(body.controlWindow);
|
|
83
|
+
} else if (body.openFileDialog) {
|
|
84
|
+
let openFileDialogArg = body.openFileDialog;
|
|
85
|
+
result = await new Promise((r, x) => {
|
|
86
|
+
ww2Module.openFileDialog({
|
|
87
|
+
callback: (err, d) => {
|
|
88
|
+
r(d);
|
|
89
|
+
},
|
|
90
|
+
filter: openFileDialogArg.filter,
|
|
91
|
+
ownerClassName: openFileDialogArg.ownerClassName
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
} else if(body.openFolderDialog){
|
|
95
|
+
|
|
96
|
+
let ofArg = body.openFolderDialog;
|
|
97
|
+
result = await new Promise((r,x)=>{
|
|
98
|
+
ww2Module.openFolderDialog({
|
|
99
|
+
callback : (err,data)=>{
|
|
100
|
+
r(data);
|
|
101
|
+
},
|
|
102
|
+
filter : ofArg.filter,
|
|
103
|
+
ownerClassName : ofArg.ownerClassName
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
} catch (error) {
|
|
109
|
+
err = error + "";
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
res.json({
|
|
113
|
+
error : err,
|
|
114
|
+
result : result
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
let ww2Module = await getModule();
|
|
120
|
+
|
|
121
|
+
let server = app.listen(port, async (err) => {
|
|
122
|
+
let add = server.address();
|
|
123
|
+
if (add == null) {
|
|
124
|
+
console.log("build server failed : " + err);
|
|
125
|
+
process.exit();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
let addr = add as AddressInfo;
|
|
129
|
+
|
|
130
|
+
let resultPort = addr.port;
|
|
131
|
+
let url = `http://localhost:${resultPort}`;
|
|
132
|
+
|
|
133
|
+
console.log(url);
|
|
134
|
+
|
|
135
|
+
console.log("open UI");
|
|
136
|
+
|
|
137
|
+
let uiConfig = arg.uiConfig;
|
|
138
|
+
|
|
139
|
+
ww2Module.openWeb({
|
|
140
|
+
callback: (err, data) => {
|
|
141
|
+
process.exit();
|
|
142
|
+
},
|
|
143
|
+
wclassname: uiConfig.wclassname,
|
|
144
|
+
height: uiConfig.height,
|
|
145
|
+
isDebug: uiConfig.isDebug,
|
|
146
|
+
isKiosk: uiConfig.isKiosk,
|
|
147
|
+
isMaximize: uiConfig.isMaximize,
|
|
148
|
+
title: uiConfig.title,
|
|
149
|
+
width: uiConfig.width,
|
|
150
|
+
url: url,
|
|
151
|
+
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
}
|
package/tsDistRun.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const path = require("path");
|
|
4
|
-
|
|
5
|
-
const entry = path.resolve(__dirname, "./
|
|
6
|
-
|
|
2
|
+
|
|
3
|
+
const path = require("path");
|
|
4
|
+
|
|
5
|
+
const entry = path.resolve(__dirname, "./dist/node/builder/builder_promps.js");
|
|
6
|
+
|
|
7
7
|
require(entry);
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/tsDist/logprint.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function logPrint(msg: any): void;
|
package/tsDist/logprint.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function buildForServer(): Promise<void>;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.buildForServer = buildForServer;
|
|
7
|
-
const prompts_1 = __importDefault(require("prompts"));
|
|
8
|
-
const ww2_buildercore_1 = require("./ww2_buildercore");
|
|
9
|
-
async function buildForServer() {
|
|
10
|
-
const response = await (0, prompts_1.default)({
|
|
11
|
-
type: 'select',
|
|
12
|
-
name: 'menu',
|
|
13
|
-
message: 'Pilih menu',
|
|
14
|
-
choices: [
|
|
15
|
-
{
|
|
16
|
-
title: 'init_webview2', value: async () => {
|
|
17
|
-
await ww2_buildercore_1.WW2Deploy.initWW2();
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
title: 'deploy', value: async () => {
|
|
22
|
-
await ww2_buildercore_1.WW2Deploy.startDeploy();
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
]
|
|
26
|
-
});
|
|
27
|
-
if (response && response.menu) {
|
|
28
|
-
response.menu();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
buildForServer();
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ConfigWW2 } from './builder_tp';
|
|
2
|
-
export declare class WW2Deploy {
|
|
3
|
-
configObjec?: ConfigWW2;
|
|
4
|
-
outputExeFile?: string;
|
|
5
|
-
makeDistFolder(): Promise<void>;
|
|
6
|
-
buildIcon(): Promise<void>;
|
|
7
|
-
copyExe(): Promise<void>;
|
|
8
|
-
editIcon(): Promise<void>;
|
|
9
|
-
readConfig(): Promise<void>;
|
|
10
|
-
copyNodeExe(): Promise<void>;
|
|
11
|
-
createIndexConf(): Promise<void>;
|
|
12
|
-
static initWW2(): Promise<void>;
|
|
13
|
-
static startDeploy(): Promise<void>;
|
|
14
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.WW2Deploy = void 0;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
|
-
const sharp_1 = __importDefault(require("sharp"));
|
|
10
|
-
const path_1 = __importDefault(require("path"));
|
|
11
|
-
const rcedit_1 = __importDefault(require("rcedit"));
|
|
12
|
-
const sharp_ico_1 = __importDefault(require("sharp-ico"));
|
|
13
|
-
const logprint_1 = require("../logprint");
|
|
14
|
-
const build_copyDir_1 = require("./build_copyDir");
|
|
15
|
-
const jsonConfigFilePath = "./win_webview2.json";
|
|
16
|
-
class WW2Deploy {
|
|
17
|
-
async makeDistFolder() {
|
|
18
|
-
if (this.configObjec == null)
|
|
19
|
-
return;
|
|
20
|
-
let config = this.configObjec;
|
|
21
|
-
let folderDist = config.outdir;
|
|
22
|
-
if (!fs_1.default.existsSync(folderDist)) {
|
|
23
|
-
await fs_1.default.promises.mkdir(folderDist);
|
|
24
|
-
}
|
|
25
|
-
let libFolder = path_1.default.join(folderDist, "lib");
|
|
26
|
-
if (!fs_1.default.existsSync(libFolder)) {
|
|
27
|
-
await fs_1.default.promises.mkdir(libFolder);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
async buildIcon() {
|
|
31
|
-
if (this.configObjec == null)
|
|
32
|
-
return;
|
|
33
|
-
let config = this.configObjec;
|
|
34
|
-
let iconPath = config.icon_path;
|
|
35
|
-
if (!fs_1.default.existsSync(iconPath)) {
|
|
36
|
-
(0, logprint_1.logPrint)("icon notfound");
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
let outputIcon = path_1.default.join(config.outdir, "icon.ico");
|
|
40
|
-
const sizes = [16, 32, 48, 256]; // Ukuran standar untuk rcedit
|
|
41
|
-
const images = await Promise.all(sizes.map(size => (0, sharp_1.default)(iconPath)
|
|
42
|
-
.resize(size, size)
|
|
43
|
-
.toFormat('png')));
|
|
44
|
-
await sharp_ico_1.default.sharpsToIco(images, outputIcon);
|
|
45
|
-
console.log('✅ Berhasil membuat icon.ico yang valid untuk rcedit!');
|
|
46
|
-
}
|
|
47
|
-
async copyExe() {
|
|
48
|
-
let currentDir = path_1.default.join(__dirname, "../../");
|
|
49
|
-
if (this.configObjec == null)
|
|
50
|
-
return;
|
|
51
|
-
let config = this.configObjec;
|
|
52
|
-
let platform = config.platform;
|
|
53
|
-
let inputDir = path_1.default.join(currentDir, "win_lib", platform);
|
|
54
|
-
this.outputExeFile = path_1.default.join(config.outdir, config.appname + ".exe");
|
|
55
|
-
await (0, build_copyDir_1.copyDir)(inputDir, config.outdir);
|
|
56
|
-
await promises_1.default.rename(path_1.default.join(config.outdir, "CmdWebview2.exe"), this.outputExeFile);
|
|
57
|
-
await (async () => {
|
|
58
|
-
let inputFileDll = jsonConfigFilePath;
|
|
59
|
-
let outFileDll = path_1.default.join(config.outdir, "win_webview2.json");
|
|
60
|
-
await fs_1.default.promises.copyFile(inputFileDll, outFileDll);
|
|
61
|
-
})();
|
|
62
|
-
(0, logprint_1.logPrint)("copy file success");
|
|
63
|
-
}
|
|
64
|
-
async editIcon() {
|
|
65
|
-
if (this.outputExeFile == null)
|
|
66
|
-
return;
|
|
67
|
-
if (this.configObjec == null)
|
|
68
|
-
return;
|
|
69
|
-
let object = this.configObjec;
|
|
70
|
-
let iconPath = path_1.default.join(object.outdir, "icon.ico");
|
|
71
|
-
iconPath = path_1.default.resolve(iconPath);
|
|
72
|
-
await (0, rcedit_1.default)(this.outputExeFile, {
|
|
73
|
-
icon: iconPath,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
async readConfig() {
|
|
77
|
-
let str = await fs_1.default.promises.readFile(jsonConfigFilePath);
|
|
78
|
-
let jsonObj = JSON.parse(str.toString());
|
|
79
|
-
this.configObjec = jsonObj;
|
|
80
|
-
}
|
|
81
|
-
async copyNodeExe() {
|
|
82
|
-
if (this.configObjec == null)
|
|
83
|
-
return;
|
|
84
|
-
let obj = this.configObjec;
|
|
85
|
-
let inputNodeExe = process.execPath;
|
|
86
|
-
let outNodeExe = path_1.default.join(obj.outdir, "lib", "node.exe");
|
|
87
|
-
await fs_1.default.promises.copyFile(inputNodeExe, outNodeExe);
|
|
88
|
-
}
|
|
89
|
-
async createIndexConf() {
|
|
90
|
-
if (this.configObjec == null)
|
|
91
|
-
return;
|
|
92
|
-
let obj = this.configObjec;
|
|
93
|
-
let oututFileConf = path_1.default.join(obj.outdir, "index.bat");
|
|
94
|
-
let configCtn = `.\\\\lib\\\\node.exe ./${obj.entry_point}`;
|
|
95
|
-
await fs_1.default.promises.writeFile(oututFileConf, configCtn);
|
|
96
|
-
}
|
|
97
|
-
static async initWW2() {
|
|
98
|
-
let objConfig = {
|
|
99
|
-
entry_point: "app.js",
|
|
100
|
-
appname: "openweb",
|
|
101
|
-
icon_path: "./icon.png",
|
|
102
|
-
outdir: "./dist",
|
|
103
|
-
platform: 'Win32'
|
|
104
|
-
};
|
|
105
|
-
let objstr = JSON.stringify(objConfig, null, 2);
|
|
106
|
-
if (fs_1.default.existsSync(jsonConfigFilePath)) {
|
|
107
|
-
(0, logprint_1.logPrint)("file config is exits");
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
await fs_1.default.promises.writeFile(jsonConfigFilePath, objstr);
|
|
111
|
-
}
|
|
112
|
-
static async startDeploy() {
|
|
113
|
-
(0, logprint_1.logPrint)("Start Deploy win_webview2");
|
|
114
|
-
let c = new WW2Deploy();
|
|
115
|
-
await c.readConfig();
|
|
116
|
-
await c.makeDistFolder();
|
|
117
|
-
await c.buildIcon();
|
|
118
|
-
await c.copyExe();
|
|
119
|
-
await c.editIcon();
|
|
120
|
-
await c.copyNodeExe();
|
|
121
|
-
await c.createIndexConf();
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
exports.WW2Deploy = WW2Deploy;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export type OpenWebArg = {
|
|
2
|
-
url: string;
|
|
3
|
-
width: number;
|
|
4
|
-
height: number;
|
|
5
|
-
kiosk: boolean;
|
|
6
|
-
maximize: boolean;
|
|
7
|
-
title: string;
|
|
8
|
-
isDebugMode: boolean;
|
|
9
|
-
winClassName: string;
|
|
10
|
-
};
|
|
11
|
-
export type OpenDialogFileArg = {
|
|
12
|
-
winClassName: string;
|
|
13
|
-
filter: string;
|
|
14
|
-
};
|
|
15
|
-
export type OpenDialogArg = {
|
|
16
|
-
winClassName: string;
|
|
17
|
-
};
|
|
18
|
-
export declare function openWeb(arg: OpenWebArg): Promise<void>;
|
|
19
|
-
export declare function openDialogFile(arg: OpenDialogFileArg): Promise<unknown>;
|
|
20
|
-
export declare function openDialogFolder(arg: OpenDialogArg): Promise<unknown>;
|
|
21
|
-
export declare function controlWindow(arg: {
|
|
22
|
-
winClassName: string;
|
|
23
|
-
controlcmd: "close" | "maximize" | "minimize" | "move" | "resize";
|
|
24
|
-
left: number;
|
|
25
|
-
top: number;
|
|
26
|
-
width: number;
|
|
27
|
-
height: number;
|
|
28
|
-
}): Promise<unknown>;
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.openWeb = openWeb;
|
|
4
|
-
exports.openDialogFile = openDialogFile;
|
|
5
|
-
exports.openDialogFolder = openDialogFolder;
|
|
6
|
-
exports.controlWindow = controlWindow;
|
|
7
|
-
const node_child_process_1 = require("node:child_process");
|
|
8
|
-
const promises_1 = require("node:fs/promises");
|
|
9
|
-
const jsonConfigFilePath = "./win_webview2.json";
|
|
10
|
-
async function readConfig() {
|
|
11
|
-
let str = await (0, promises_1.readFile)(jsonConfigFilePath);
|
|
12
|
-
let jsonObj = JSON.parse(str.toString());
|
|
13
|
-
return jsonObj;
|
|
14
|
-
}
|
|
15
|
-
async function getExecPath() {
|
|
16
|
-
let jsonConfig = await readConfig();
|
|
17
|
-
let exeFilePath = jsonConfig.appname + ".exe";
|
|
18
|
-
return exeFilePath;
|
|
19
|
-
}
|
|
20
|
-
async function openWeb(arg) {
|
|
21
|
-
let jsonConfig = await readConfig();
|
|
22
|
-
let exeFilePath = jsonConfig.appname + ".exe";
|
|
23
|
-
let arrOpen = [
|
|
24
|
-
"fun=openwebview",
|
|
25
|
-
"wndClassName=" + arg.winClassName,
|
|
26
|
-
"url=" + arg.url,
|
|
27
|
-
"width=" + arg.width,
|
|
28
|
-
"height=" + arg.height,
|
|
29
|
-
//"kiosk=true",
|
|
30
|
-
//"maximize=true",
|
|
31
|
-
"title=auto",
|
|
32
|
-
//"isDebugMode=true"
|
|
33
|
-
];
|
|
34
|
-
if (arg.maximize) {
|
|
35
|
-
arrOpen.push("maximize=true");
|
|
36
|
-
}
|
|
37
|
-
if (arg.kiosk) {
|
|
38
|
-
arrOpen.push("kiosk=true");
|
|
39
|
-
}
|
|
40
|
-
if (arg.isDebugMode) {
|
|
41
|
-
arrOpen.push("isDebugMode=true");
|
|
42
|
-
}
|
|
43
|
-
(0, node_child_process_1.execFile)(exeFilePath, arrOpen, (err, data) => {
|
|
44
|
-
console.log(err);
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
async function openDialogFile(arg) {
|
|
48
|
-
let exeFilePath = await getExecPath();
|
|
49
|
-
return new Promise((r, x) => {
|
|
50
|
-
(0, node_child_process_1.execFile)(exeFilePath, [
|
|
51
|
-
"fun=openFileDialog",
|
|
52
|
-
"wndClassName=" + arg.winClassName,
|
|
53
|
-
"filter=" + arg.filter,
|
|
54
|
-
], (/** @type {any} */ err, /** @type {string} */ data) => {
|
|
55
|
-
let filepath = "";
|
|
56
|
-
for (let l of data.split("\r\n")) {
|
|
57
|
-
if (l.startsWith("result:")) {
|
|
58
|
-
filepath = l.substring(7, l.length);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
r(filepath);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
async function openDialogFolder(arg) {
|
|
66
|
-
let exeFilePath = await getExecPath();
|
|
67
|
-
return new Promise((r, x) => {
|
|
68
|
-
(0, node_child_process_1.execFile)(exeFilePath, [
|
|
69
|
-
"fun=openFolderDialog",
|
|
70
|
-
"wndClassName=" + arg.winClassName,
|
|
71
|
-
], (
|
|
72
|
-
/** @type {any} */
|
|
73
|
-
err,
|
|
74
|
-
/** @type {string} */
|
|
75
|
-
data) => {
|
|
76
|
-
let filepath = "";
|
|
77
|
-
for (let l of data.split("\r\n")) {
|
|
78
|
-
if (l.startsWith("result:")) {
|
|
79
|
-
filepath = l.substring(7, l.length);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
r(filepath);
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
async function controlWindow(arg) {
|
|
87
|
-
let exeFilePath = await getExecPath();
|
|
88
|
-
return new Promise((r, x) => {
|
|
89
|
-
(0, node_child_process_1.execFile)(exeFilePath, [
|
|
90
|
-
"fun=controlwindow",
|
|
91
|
-
"wndClassName=" + arg.winClassName,
|
|
92
|
-
"controlcmd=" + arg.controlcmd,
|
|
93
|
-
"left=" + arg.left,
|
|
94
|
-
"top=" + arg.top,
|
|
95
|
-
"width=" + arg.width,
|
|
96
|
-
"height=" + arg.height,
|
|
97
|
-
], (
|
|
98
|
-
/** @type {any} */
|
|
99
|
-
err,
|
|
100
|
-
/** @type {string} */
|
|
101
|
-
data) => {
|
|
102
|
-
r(data);
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
}
|
package/tsSrc/logprint.ts
DELETED