win_webview2 1.0.13 → 1.1.3
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/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,71 @@
|
|
|
1
|
+
import { exec } from "node:child_process";
|
|
2
|
+
import { copyFile, mkdir } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
function debugDir(dirPath: string) {
|
|
6
|
+
exec("cd " + dirPath + "&& dir", (s, o) => {
|
|
7
|
+
console.log(o);
|
|
8
|
+
})
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
(async () => {
|
|
12
|
+
|
|
13
|
+
let result = "\n";
|
|
14
|
+
|
|
15
|
+
let rootPath = path.join(__dirname, "../../");
|
|
16
|
+
let copyFromRoot = async (src: string, target: string) => {
|
|
17
|
+
result += "\n" + target;
|
|
18
|
+
await copyFile(path.join(rootPath, src), path.join(rootPath, target));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
|
|
23
|
+
await mkdir(path.join(rootPath, "win_webview2/win_lib/Win32"));
|
|
24
|
+
await mkdir(path.join(rootPath, "win_webview2/win_lib/x64"));
|
|
25
|
+
} catch (error) {
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
await copyFromRoot(
|
|
30
|
+
"exeOpener/build/x64/exeOpenner.exe",
|
|
31
|
+
"win_webview2/win_lib/x64/exeOpenner.exe"
|
|
32
|
+
);
|
|
33
|
+
await copyFromRoot(
|
|
34
|
+
"exeOpener/build/x64/splash.png",
|
|
35
|
+
"win_webview2/win_lib/x64/splash.png"
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
await copyFromRoot(
|
|
39
|
+
"exeOpener/build/x86/exeOpenner.exe",
|
|
40
|
+
"win_webview2/win_lib/Win32/exeOpenner.exe"
|
|
41
|
+
);
|
|
42
|
+
await copyFromRoot(
|
|
43
|
+
"exeOpener/build/x86/splash.png",
|
|
44
|
+
"win_webview2/win_lib/Win32/splash.png"
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
console.log("copy webview2 32");
|
|
48
|
+
await copyFromRoot(
|
|
49
|
+
"nodeAddOn/build/ia32/Release/ww2_addon.node",
|
|
50
|
+
"win_webview2/win_lib/Win32/ww2_addon.node"
|
|
51
|
+
);
|
|
52
|
+
await copyFromRoot(
|
|
53
|
+
"nodeAddOn/build/ia32/Release/WebView2Loader.dll",
|
|
54
|
+
"win_webview2/win_lib/Win32/WebView2Loader.dll"
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
console.log("copy webview2 64");
|
|
58
|
+
await copyFromRoot(
|
|
59
|
+
"nodeAddOn/build/x64/Release/ww2_addon.node",
|
|
60
|
+
"win_webview2/win_lib/x64/ww2_addon.node"
|
|
61
|
+
);
|
|
62
|
+
await copyFromRoot(
|
|
63
|
+
"nodeAddOn/build/x64/Release/WebView2Loader.dll",
|
|
64
|
+
"win_webview2/win_lib/x64/WebView2Loader.dll"
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
console.log("copy done :" + result);
|
|
70
|
+
|
|
71
|
+
})();
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"module": "CommonJS",
|
|
5
|
-
"declaration": true,
|
|
6
|
-
"rootDir": "./
|
|
7
|
-
"outDir": "./tsDist",
|
|
8
|
-
"strict": true,
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"skipLibCheck": true
|
|
11
|
-
},
|
|
12
|
-
"include": ["
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "CommonJS",
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"rootDir": "./",
|
|
7
|
+
"outDir": "./tsDist",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true
|
|
11
|
+
},
|
|
12
|
+
"include": ["./"]
|
|
13
13
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
interface WW2FileDialogArg {
|
|
2
|
+
filter: string;
|
|
3
|
+
ownerClassName: string;
|
|
4
|
+
}
|
|
5
|
+
interface WW2ControlWindowsArg {
|
|
6
|
+
wndClassName: string;
|
|
7
|
+
controlcmd: "close" | "move" | "maximize" | "minimize" | "resize" | "check";
|
|
8
|
+
left?: number;
|
|
9
|
+
top?: number;
|
|
10
|
+
height?: number;
|
|
11
|
+
width?: number;
|
|
12
|
+
}
|
|
13
|
+
export type PostData = {
|
|
14
|
+
openWeb?: {
|
|
15
|
+
wclassname: string;
|
|
16
|
+
url: string;
|
|
17
|
+
title: string;
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
isKiosk: boolean;
|
|
21
|
+
isMaximize: boolean;
|
|
22
|
+
isDebug: boolean;
|
|
23
|
+
};
|
|
24
|
+
openFileDialog?: WW2FileDialogArg;
|
|
25
|
+
openFolderDialog?: WW2FileDialogArg;
|
|
26
|
+
controlWindow?: WW2ControlWindowsArg;
|
|
27
|
+
};
|
|
28
|
+
export declare function callWw2(arg: PostData): Promise<{
|
|
29
|
+
err: string;
|
|
30
|
+
result: string;
|
|
31
|
+
}>;
|
|
32
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function copyDir(source: string, destination: string): Promise<void>;
|
|
1
|
+
export declare function copyDir(source: string, destination: string): Promise<void>;
|
|
@@ -1,24 +1,24 @@
|
|
|
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.copyDir = copyDir;
|
|
7
|
-
const fs_1 = require("fs");
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
async function copyDir(source, destination) {
|
|
10
|
-
// pastikan folder tujuan ada
|
|
11
|
-
await fs_1.promises.mkdir(destination, { recursive: true });
|
|
12
|
-
const entries = await fs_1.promises.readdir(source, { withFileTypes: true });
|
|
13
|
-
for (const entry of entries) {
|
|
14
|
-
let srcPath = path_1.default.join(source, entry.name);
|
|
15
|
-
let destPath = path_1.default.join(destination, entry.name);
|
|
16
|
-
if (entry.isDirectory()) {
|
|
17
|
-
// rekursif ke subfolder
|
|
18
|
-
await copyDir(srcPath, destPath);
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
await fs_1.promises.copyFile(srcPath, destPath);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
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.copyDir = copyDir;
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
async function copyDir(source, destination) {
|
|
10
|
+
// pastikan folder tujuan ada
|
|
11
|
+
await fs_1.promises.mkdir(destination, { recursive: true });
|
|
12
|
+
const entries = await fs_1.promises.readdir(source, { withFileTypes: true });
|
|
13
|
+
for (const entry of entries) {
|
|
14
|
+
let srcPath = path_1.default.join(source, entry.name);
|
|
15
|
+
let destPath = path_1.default.join(destination, entry.name);
|
|
16
|
+
if (entry.isDirectory()) {
|
|
17
|
+
// rekursif ke subfolder
|
|
18
|
+
await copyDir(srcPath, destPath);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
await fs_1.promises.copyFile(srcPath, destPath);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,52 @@
|
|
|
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.ww2Init = ww2Init;
|
|
7
|
+
const dirnameTool_1 = require("../tsExport/dirnameTool");
|
|
8
|
+
const child_process_1 = require("child_process");
|
|
9
|
+
const prompts_1 = __importDefault(require("prompts"));
|
|
10
|
+
function runCommand(command) {
|
|
11
|
+
try {
|
|
12
|
+
const currentShell = process.platform === 'win32' ? 'cmd.exe' : '/bin/sh';
|
|
13
|
+
(0, child_process_1.execSync)(command, { stdio: 'inherit', shell: currentShell, killSignal: "SIGINT" });
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
console.error(`Command Error: ${command}`);
|
|
17
|
+
process.exit();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const jsonConfigFilePath = "./win_webview2.json";
|
|
21
|
+
let mdirname = (0, dirnameTool_1.getWw2Dirname)();
|
|
22
|
+
let ww2Choise = {
|
|
23
|
+
"ww2_typescript": {
|
|
24
|
+
description: "init win_webview2",
|
|
25
|
+
fun: async () => {
|
|
26
|
+
runCommand('npx degit nnttoo/win_webview2/example/ww2_typescript#master ww2_typescript');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
async function ww2Init() {
|
|
31
|
+
const response = await (0, prompts_1.default)({
|
|
32
|
+
type: 'select',
|
|
33
|
+
name: 'menu',
|
|
34
|
+
message: 'Pick one example',
|
|
35
|
+
instructions: '(Use arrow keys to navigate, press enter to select)',
|
|
36
|
+
choices: (() => {
|
|
37
|
+
let result = [];
|
|
38
|
+
for (let item in ww2Choise) {
|
|
39
|
+
let val = ww2Choise[item];
|
|
40
|
+
result.push({
|
|
41
|
+
title: item,
|
|
42
|
+
value: val.fun,
|
|
43
|
+
description: val.description,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
})(),
|
|
48
|
+
});
|
|
49
|
+
if (response && response.menu) {
|
|
50
|
+
await response.menu();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
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 builder_init_1 = require("./builder_init");
|
|
9
|
+
const userExec_1 = require("./userExec");
|
|
10
|
+
let ww2Choise = {
|
|
11
|
+
"init_win_webview2": {
|
|
12
|
+
description: "init win_webview2",
|
|
13
|
+
fun: async () => {
|
|
14
|
+
await (0, builder_init_1.ww2Init)();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
async function buildForServer() {
|
|
19
|
+
let userChoise = await (0, userExec_1.readUserScripts)();
|
|
20
|
+
if (userChoise != null) {
|
|
21
|
+
ww2Choise = {
|
|
22
|
+
...ww2Choise,
|
|
23
|
+
...userChoise
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const response = await (0, prompts_1.default)({
|
|
27
|
+
type: 'select',
|
|
28
|
+
name: 'menu',
|
|
29
|
+
message: 'Pick one',
|
|
30
|
+
instructions: '(Use arrow keys to navigate, press enter to select)',
|
|
31
|
+
choices: (() => {
|
|
32
|
+
let result = [];
|
|
33
|
+
for (let item in ww2Choise) {
|
|
34
|
+
let val = ww2Choise[item];
|
|
35
|
+
result.push({
|
|
36
|
+
title: item,
|
|
37
|
+
value: val.fun,
|
|
38
|
+
description: val.description,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
})(),
|
|
43
|
+
});
|
|
44
|
+
if (response && response.menu) {
|
|
45
|
+
await response.menu();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
console.log("ww2 version : v6 \n\n");
|
|
49
|
+
const args = process.argv.slice(2);
|
|
50
|
+
if (args.length > 0) {
|
|
51
|
+
let argument = args[0];
|
|
52
|
+
if (argument.startsWith("--")) {
|
|
53
|
+
argument = argument.substring(2);
|
|
54
|
+
}
|
|
55
|
+
console.log(argument);
|
|
56
|
+
if (ww2Choise[argument]) {
|
|
57
|
+
ww2Choise[argument].fun();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
buildForServer();
|
|
62
|
+
}
|
|
63
|
+
process.on('SIGINT', () => {
|
|
64
|
+
console.log('\n[Sinyal SIGINT Terdeteksi]');
|
|
65
|
+
console.log('User menekan Ctrl+C. Membersihkan data...');
|
|
66
|
+
// Anda harus memanggil exit secara manual jika menggunakan listener ini
|
|
67
|
+
process.exit(0);
|
|
68
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDirname = getDirname;
|
|
4
|
+
const node_url_1 = require("node:url");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
function getDirname() {
|
|
7
|
+
// Trik deteksi lingkungan
|
|
8
|
+
const _filename = typeof __filename !== 'undefined'
|
|
9
|
+
? __filename
|
|
10
|
+
// @ts-ignore:
|
|
11
|
+
: (0, node_url_1.fileURLToPath)(eval('import.meta.url'));
|
|
12
|
+
const _dirname = typeof __dirname !== 'undefined'
|
|
13
|
+
? __dirname
|
|
14
|
+
: (0, node_path_1.dirname)(_filename);
|
|
15
|
+
return { _dirname, _filename };
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDirname = getDirname;
|
|
4
|
+
const node_url_1 = require("node:url");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
function getDirname() {
|
|
7
|
+
// Trik deteksi lingkungan
|
|
8
|
+
const _filename = typeof __filename !== 'undefined'
|
|
9
|
+
? __filename
|
|
10
|
+
: (0, node_url_1.fileURLToPath)(import.meta.url);
|
|
11
|
+
const _dirname = typeof __dirname !== 'undefined'
|
|
12
|
+
? __dirname
|
|
13
|
+
: (0, node_path_1.dirname)(_filename);
|
|
14
|
+
return { _dirname, _filename };
|
|
15
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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.readUserScripts = readUserScripts;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const dirnameTool_1 = require("../tsExport/dirnameTool");
|
|
9
|
+
const promises_1 = require("node:fs/promises");
|
|
10
|
+
const comment_json_1 = require("comment-json");
|
|
11
|
+
const node_child_process_1 = require("node:child_process");
|
|
12
|
+
function runNpm(command) {
|
|
13
|
+
try {
|
|
14
|
+
const currentShell = process.platform === 'win32' ? 'cmd.exe' : '/bin/sh';
|
|
15
|
+
let cmd = `npm run ${command}`;
|
|
16
|
+
console.log(cmd);
|
|
17
|
+
(0, node_child_process_1.execSync)(cmd, { stdio: 'inherit', shell: currentShell, killSignal: "SIGINT" });
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
console.error(`Command Error: ${command}`);
|
|
21
|
+
process.exit();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async function readUserScripts() {
|
|
25
|
+
let dirUser = (0, dirnameTool_1.findUserProjectRoot)();
|
|
26
|
+
if (dirUser == null)
|
|
27
|
+
return;
|
|
28
|
+
let pkgJson = node_path_1.default.join(dirUser, "package.json");
|
|
29
|
+
let pkgTxt = await (0, promises_1.readFile)(pkgJson, "utf-8");
|
|
30
|
+
let obj = (0, comment_json_1.parse)(pkgTxt);
|
|
31
|
+
if (obj.scripts == null)
|
|
32
|
+
return;
|
|
33
|
+
let ww2Choise = {};
|
|
34
|
+
let name = obj.name ? obj.name : "";
|
|
35
|
+
for (let kscript in obj.scripts) {
|
|
36
|
+
let cmd = obj.scripts[kscript];
|
|
37
|
+
ww2Choise["--" + kscript] = {
|
|
38
|
+
description: name + " : " + cmd,
|
|
39
|
+
fun: () => {
|
|
40
|
+
runNpm(kscript);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return ww2Choise;
|
|
45
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export type ConfigWW2 = {
|
|
2
|
-
appname: string;
|
|
3
|
-
icon_path: string;
|
|
4
|
-
entry_point: string;
|
|
5
|
-
outdir: string;
|
|
6
|
-
platform: 'Win32' | 'x64';
|
|
7
|
-
};
|
|
1
|
+
export type ConfigWW2 = {
|
|
2
|
+
appname: string;
|
|
3
|
+
icon_path: string;
|
|
4
|
+
entry_point: string;
|
|
5
|
+
outdir: string;
|
|
6
|
+
platform: 'Win32' | 'x64';
|
|
7
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getWw2Dirname = getWw2Dirname;
|
|
37
|
+
exports.findUserProjectRoot = findUserProjectRoot;
|
|
38
|
+
const node_url_1 = require("node:url");
|
|
39
|
+
const node_path_1 = __importStar(require("node:path"));
|
|
40
|
+
const node_fs_1 = require("node:fs");
|
|
41
|
+
function getWw2Dirname() {
|
|
42
|
+
// Trik deteksi lingkungan
|
|
43
|
+
const _filename = typeof __filename !== 'undefined'
|
|
44
|
+
? __filename
|
|
45
|
+
// @ts-ignore:
|
|
46
|
+
: (0, node_url_1.fileURLToPath)(eval('import.meta.url'));
|
|
47
|
+
const _dirname = typeof __dirname !== 'undefined'
|
|
48
|
+
? __dirname
|
|
49
|
+
: (0, node_path_1.dirname)(_filename);
|
|
50
|
+
let ww2ModulePath = node_path_1.default.join(_dirname, "../../../");
|
|
51
|
+
return { _dirname, _filename, ww2ModulePath };
|
|
52
|
+
}
|
|
53
|
+
function findUserProjectRoot(currentDir = process.cwd()) {
|
|
54
|
+
const packagePath = node_path_1.default.join(currentDir, 'package.json');
|
|
55
|
+
if ((0, node_fs_1.existsSync)(packagePath)) {
|
|
56
|
+
return currentDir;
|
|
57
|
+
}
|
|
58
|
+
const parentDir = node_path_1.default.dirname(currentDir);
|
|
59
|
+
if (parentDir === currentDir) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
return findUserProjectRoot(parentDir);
|
|
63
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { getWw2Dirname } from "./dirnameTool";
|
|
2
|
+
import { readConfig } from "./ww2_config";
|
|
3
|
+
interface Ww2WebConfig {
|
|
4
|
+
callback: (err: any, data: any) => void;
|
|
5
|
+
wclassname: string;
|
|
6
|
+
url: string;
|
|
7
|
+
title: string;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
isKiosk: boolean;
|
|
11
|
+
isMaximize: boolean;
|
|
12
|
+
isDebug: boolean;
|
|
13
|
+
}
|
|
14
|
+
interface WW2FileDialogArg {
|
|
15
|
+
callback: (err: any, data: any) => void;
|
|
16
|
+
filter: string;
|
|
17
|
+
ownerClassName: string;
|
|
18
|
+
}
|
|
19
|
+
export interface WW2ControlWindowsArg {
|
|
20
|
+
wndClassName: string;
|
|
21
|
+
controlcmd: "close" | "move" | "maximize" | "minimize" | "resize" | "check";
|
|
22
|
+
left?: number;
|
|
23
|
+
top?: number;
|
|
24
|
+
height?: number;
|
|
25
|
+
width?: number;
|
|
26
|
+
}
|
|
27
|
+
interface Ww2Module {
|
|
28
|
+
openWeb: (arg: Ww2WebConfig) => void;
|
|
29
|
+
openFileDialog: (arg: WW2FileDialogArg) => void;
|
|
30
|
+
openFolderDialog: (arg: WW2FileDialogArg) => void;
|
|
31
|
+
controlWindow: (arg: WW2ControlWindowsArg) => void;
|
|
32
|
+
}
|
|
33
|
+
export declare function getModule(): Promise<Ww2Module>;
|
|
34
|
+
export declare function closeSplash(): Promise<void>;
|
|
35
|
+
export * from "./ww2_server";
|
|
36
|
+
export { findUserProjectRoot } from "./dirnameTool";
|
|
37
|
+
export { readConfig };
|
|
38
|
+
export { getWw2Dirname };
|
|
@@ -0,0 +1,51 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.getWw2Dirname = exports.readConfig = exports.findUserProjectRoot = void 0;
|
|
21
|
+
exports.getModule = getModule;
|
|
22
|
+
exports.closeSplash = closeSplash;
|
|
23
|
+
const node_fs_1 = require("node:fs");
|
|
24
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
25
|
+
const dirnameTool_1 = require("./dirnameTool");
|
|
26
|
+
Object.defineProperty(exports, "getWw2Dirname", { enumerable: true, get: function () { return dirnameTool_1.getWw2Dirname; } });
|
|
27
|
+
const ww2_config_1 = require("./ww2_config");
|
|
28
|
+
Object.defineProperty(exports, "readConfig", { enumerable: true, get: function () { return ww2_config_1.readConfig; } });
|
|
29
|
+
async function getModule() {
|
|
30
|
+
let dirname = (0, dirnameTool_1.getWw2Dirname)();
|
|
31
|
+
let filepath = node_path_1.default.join(dirname._dirname, "./ww2_addon.node");
|
|
32
|
+
if (!(0, node_fs_1.existsSync)(filepath)) {
|
|
33
|
+
let config = await (0, ww2_config_1.readConfig)();
|
|
34
|
+
if (config == null)
|
|
35
|
+
throw "user config null";
|
|
36
|
+
filepath = node_path_1.default.join(dirname._dirname, `../../../win_lib/${config.platform}/ww2_addon.node`);
|
|
37
|
+
}
|
|
38
|
+
let myAddon = require(filepath);
|
|
39
|
+
return myAddon;
|
|
40
|
+
}
|
|
41
|
+
function closeSplash() {
|
|
42
|
+
return getModule().then((module) => {
|
|
43
|
+
module.controlWindow({
|
|
44
|
+
controlcmd: "close",
|
|
45
|
+
wndClassName: "mysplashclassname"
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
__exportStar(require("./ww2_server"), exports);
|
|
50
|
+
var dirnameTool_2 = require("./dirnameTool");
|
|
51
|
+
Object.defineProperty(exports, "findUserProjectRoot", { enumerable: true, get: function () { return dirnameTool_2.findUserProjectRoot; } });
|
|
@@ -0,0 +1,18 @@
|
|
|
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.readConfig = readConfig;
|
|
7
|
+
const promises_1 = require("node:fs/promises");
|
|
8
|
+
const dirnameTool_1 = require("./dirnameTool");
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
const jsonConfigFilePath = "./win_webview2.json";
|
|
11
|
+
async function readConfig() {
|
|
12
|
+
let userDir = (0, dirnameTool_1.findUserProjectRoot)();
|
|
13
|
+
if (userDir == null)
|
|
14
|
+
return null;
|
|
15
|
+
let str = await (0, promises_1.readFile)(node_path_1.default.join(userDir, jsonConfigFilePath));
|
|
16
|
+
let jsonObj = JSON.parse(str.toString());
|
|
17
|
+
return jsonObj;
|
|
18
|
+
}
|