ee-bin 5.0.0-beta.1 → 5.0.0-beta.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/dist/cjs/config/bin_default.js +69 -29
- package/dist/cjs/config/bin_default.js.map +1 -1
- package/dist/cjs/index.js +125 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/extend.js +49 -15
- package/dist/cjs/lib/extend.js.map +1 -1
- package/dist/cjs/lib/helpers.js +71 -22
- package/dist/cjs/lib/helpers.js.map +1 -1
- package/dist/cjs/lib/utils.js +71 -30
- package/dist/cjs/lib/utils.js.map +1 -1
- package/dist/cjs/plugins/bundle_registry_plugin.js +156 -0
- package/dist/cjs/plugins/bundle_registry_plugin.js.map +1 -0
- package/dist/cjs/tools/encrypt.js +190 -29
- package/dist/cjs/tools/encrypt.js.map +1 -1
- package/dist/cjs/tools/iconGen.js +118 -30
- package/dist/cjs/tools/iconGen.js.map +1 -1
- package/dist/cjs/tools/incrUpdater.js +95 -33
- package/dist/cjs/tools/incrUpdater.js.map +1 -1
- package/dist/cjs/tools/move.js +71 -11
- package/dist/cjs/tools/move.js.map +1 -1
- package/dist/cjs/tools/serve.js +406 -81
- package/dist/cjs/tools/serve.js.map +1 -1
- package/dist/cjs/types/config.js +13 -0
- package/dist/cjs/types/config.js.map +1 -0
- package/dist/esm/config/bin_default.d.ts +19 -147
- package/dist/esm/config/bin_default.d.ts.map +1 -1
- package/dist/esm/config/bin_default.js +69 -29
- package/dist/esm/config/bin_default.js.map +1 -1
- package/dist/esm/index.d.ts +20 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +125 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/extend.d.ts +33 -0
- package/dist/esm/lib/extend.d.ts.map +1 -1
- package/dist/esm/lib/extend.js +49 -15
- package/dist/esm/lib/extend.js.map +1 -1
- package/dist/esm/lib/helpers.d.ts +44 -3
- package/dist/esm/lib/helpers.d.ts.map +1 -1
- package/dist/esm/lib/helpers.js +71 -22
- package/dist/esm/lib/helpers.js.map +1 -1
- package/dist/esm/lib/utils.d.ts +57 -3
- package/dist/esm/lib/utils.d.ts.map +1 -1
- package/dist/esm/lib/utils.js +71 -30
- package/dist/esm/lib/utils.js.map +1 -1
- package/dist/esm/plugins/bundle_registry_plugin.d.ts +33 -0
- package/dist/esm/plugins/bundle_registry_plugin.d.ts.map +1 -0
- package/dist/esm/plugins/bundle_registry_plugin.js +156 -0
- package/dist/esm/plugins/bundle_registry_plugin.js.map +1 -0
- package/dist/esm/tools/encrypt.d.ts +37 -1
- package/dist/esm/tools/encrypt.d.ts.map +1 -1
- package/dist/esm/tools/encrypt.js +190 -29
- package/dist/esm/tools/encrypt.js.map +1 -1
- package/dist/esm/tools/iconGen.d.ts +27 -1
- package/dist/esm/tools/iconGen.d.ts.map +1 -1
- package/dist/esm/tools/iconGen.js +118 -30
- package/dist/esm/tools/iconGen.js.map +1 -1
- package/dist/esm/tools/incrUpdater.d.ts +60 -13
- package/dist/esm/tools/incrUpdater.d.ts.map +1 -1
- package/dist/esm/tools/incrUpdater.js +95 -33
- package/dist/esm/tools/incrUpdater.js.map +1 -1
- package/dist/esm/tools/move.d.ts +41 -0
- package/dist/esm/tools/move.d.ts.map +1 -1
- package/dist/esm/tools/move.js +71 -11
- package/dist/esm/tools/move.js.map +1 -1
- package/dist/esm/tools/serve.d.ts +162 -25
- package/dist/esm/tools/serve.d.ts.map +1 -1
- package/dist/esm/tools/serve.js +406 -81
- package/dist/esm/tools/serve.js.map +1 -1
- package/dist/esm/types/config.d.ts +211 -0
- package/dist/esm/types/config.d.ts.map +1 -0
- package/dist/esm/types/config.js +13 -0
- package/dist/esm/types/config.js.map +1 -0
- package/package.json +16 -13
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Code Encryption Module — bytecode compilation + JS obfuscation
|
|
4
|
+
*
|
|
5
|
+
* Supports three encryption modes:
|
|
6
|
+
* - confusion: Obfuscation only (javascript-obfuscator), works for both frontend and Electron
|
|
7
|
+
* - bytecode: Bytecode only (bytenode), only for Electron (frontend renderer V8 version
|
|
8
|
+
* differs from compile-time V8, making bytecode incompatible)
|
|
9
|
+
* - strict: Obfuscation + bytecode combined; obfuscate first, then compile to bytecode
|
|
10
|
+
* for the strongest protection
|
|
11
|
+
* - none: No encryption (all processing skipped)
|
|
12
|
+
*
|
|
13
|
+
* Encryption flow:
|
|
14
|
+
* 1. Load config, determine encryption type and target file list (via globby scan)
|
|
15
|
+
* 2. Iterate target files; specificFiles entries are forced to use confusion
|
|
16
|
+
* (even when global config is bytecode)
|
|
17
|
+
* 3. Call generateJSConfuseFile or generateBytecodeFile based on encryption type
|
|
18
|
+
*
|
|
19
|
+
* Bytecode compilation safety mechanism:
|
|
20
|
+
* - After compilation, verify the .jsc file exists before deleting the source .js file
|
|
21
|
+
* - If .jsc was not generated, throw an error and keep the source file to prevent
|
|
22
|
+
* code loss from failed compilation
|
|
23
|
+
*/
|
|
2
24
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
26
|
};
|
|
@@ -10,54 +32,136 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
10
32
|
const helpers_js_1 = require("../lib/helpers.js");
|
|
11
33
|
const bytenode_1 = __importDefault(require("bytenode"));
|
|
12
34
|
const javascript_obfuscator_1 = __importDefault(require("javascript-obfuscator"));
|
|
13
|
-
const globby_1 =
|
|
35
|
+
const globby_1 = require("globby");
|
|
14
36
|
const utils_js_1 = require("../lib/utils.js");
|
|
15
|
-
|
|
37
|
+
/** Valid encryption type list (used for runtime includes validation) */
|
|
16
38
|
const EncryptTypes = ['bytecode', 'confusion', 'strict'];
|
|
39
|
+
/**
|
|
40
|
+
* Run a function while optionally suppressing javascript-obfuscator's "Pro" advertisement banner.
|
|
41
|
+
*
|
|
42
|
+
* javascript-obfuscator (v5.x) prints a promotional banner via console.log when stdout
|
|
43
|
+
* is a TTY and not in CI. There is no official option to disable it, so when `silent` is
|
|
44
|
+
* true we temporarily wrap console.log to drop only those advertisement lines, then restore
|
|
45
|
+
* it. When `silent` is false the function runs untouched.
|
|
46
|
+
*/
|
|
47
|
+
function withSuppressedObfuscatorAd(silent, fn) {
|
|
48
|
+
if (!silent)
|
|
49
|
+
return fn();
|
|
50
|
+
const original = console.log;
|
|
51
|
+
console.log = (...args) => {
|
|
52
|
+
const first = args[0];
|
|
53
|
+
if (typeof first === 'string' &&
|
|
54
|
+
(first.includes('JavaScript Obfuscator Pro') || first.includes('obfuscator.io'))) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
original.apply(console, args);
|
|
58
|
+
};
|
|
59
|
+
try {
|
|
60
|
+
return fn();
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
console.log = original;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** Default encryption config (type='none' means no encryption is performed) */
|
|
67
|
+
const DEFAULT_ENCRYPT_CONFIG = { type: 'none',
|
|
68
|
+
fileExt: ['.js'],
|
|
69
|
+
cleanFiles: [],
|
|
70
|
+
specificFiles: [],
|
|
71
|
+
encryptDir: './',
|
|
72
|
+
};
|
|
17
73
|
class Encrypt {
|
|
18
74
|
constructor(options = {}) {
|
|
19
75
|
const { config, out, target } = options;
|
|
20
76
|
this.basePath = process.cwd();
|
|
21
77
|
this.target = target || 'electron';
|
|
22
|
-
|
|
23
|
-
|
|
78
|
+
// Load config: get the config for the corresponding target from the encrypt section,
|
|
79
|
+
// fall back to default if not found
|
|
80
|
+
const conf = (0, utils_js_1.loadConfig)(config).encrypt;
|
|
81
|
+
this.config = conf[this.target] || DEFAULT_ENCRYPT_CONFIG;
|
|
24
82
|
const outputFolder = out || this.config.encryptDir || './';
|
|
25
83
|
this.encryptDir = path_1.default.join(this.basePath, outputFolder);
|
|
26
84
|
this.filesExt = this.config.fileExt || ['.js'];
|
|
27
85
|
this.type = this.config.type || 'none';
|
|
28
86
|
this.bOpt = this.config.bytecodeOptions || {};
|
|
29
87
|
this.cOpt = this.config.confusionOptions || {};
|
|
88
|
+
this.silent = this.config.silent ?? false;
|
|
30
89
|
this.patterns = this.config.files || null;
|
|
31
90
|
this.specFiles = this.config.specificFiles || [];
|
|
32
|
-
this.
|
|
91
|
+
this.entryFiles = this.config.entryFiles || [];
|
|
92
|
+
// codefiles is not initialized in the constructor (deferred until encrypt() is called
|
|
93
|
+
// to avoid wasting I/O when type='none')
|
|
33
94
|
}
|
|
34
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Lazily get the target file list
|
|
97
|
+
*
|
|
98
|
+
* On first call, uses globby to scan files matching the patterns.
|
|
99
|
+
* Results are cached in this.codefiles; subsequent calls return the cache.
|
|
100
|
+
* If patterns is null (no "files" field in config), returns undefined to indicate
|
|
101
|
+
* encryption cannot proceed.
|
|
102
|
+
*/
|
|
103
|
+
_getCodeFiles() {
|
|
104
|
+
if (this.codefiles !== undefined)
|
|
105
|
+
return this.codefiles;
|
|
35
106
|
if (!this.patterns)
|
|
36
107
|
return undefined;
|
|
37
|
-
|
|
38
|
-
return
|
|
108
|
+
this.codefiles = (0, globby_1.globbySync)(this.patterns, { cwd: this.basePath });
|
|
109
|
+
return this.codefiles;
|
|
39
110
|
}
|
|
40
|
-
|
|
111
|
+
/**
|
|
112
|
+
* Execute encryption — iterate target files and encrypt each one
|
|
113
|
+
*
|
|
114
|
+
* Frontend bytecode is skipped: the browser renderer process V8 version differs
|
|
115
|
+
* from the compile-time V8, so compiled bytecode cannot execute in the renderer.
|
|
116
|
+
*/
|
|
117
|
+
async encrypt() {
|
|
118
|
+
// Skip if type is 'none' or not in the valid EncryptTypes list
|
|
41
119
|
if (!EncryptTypes.includes(this.type))
|
|
42
120
|
return;
|
|
43
|
-
|
|
121
|
+
// Frontend does not support bytecode (renderer V8 version incompatibility)
|
|
122
|
+
if (this.target === 'frontend' && (this.type === 'bytecode' || this.type === 'strict')) {
|
|
123
|
+
console.log(helpers_js_1.chalk.blue('[ee-bin] [encrypt] ') + `Skipping frontend ${this.type} (bytecode not supported in renderer)`);
|
|
44
124
|
return;
|
|
45
|
-
|
|
46
|
-
|
|
125
|
+
}
|
|
126
|
+
console.log(helpers_js_1.chalk.blue('[ee-bin] [encrypt] ') + `start encrypting ${this.target}`);
|
|
127
|
+
const files = this._getCodeFiles();
|
|
128
|
+
if (!files)
|
|
47
129
|
return;
|
|
48
|
-
for (const file of
|
|
130
|
+
for (const file of files) {
|
|
49
131
|
const fullpath = path_1.default.join(this.encryptDir, file);
|
|
50
132
|
if (!fs_1.default.statSync(fullpath).isFile())
|
|
51
133
|
continue;
|
|
134
|
+
// Filter by file extension (fileExt config option)
|
|
135
|
+
const ext = path_1.default.extname(file);
|
|
136
|
+
if (!this.filesExt.includes(ext))
|
|
137
|
+
continue;
|
|
138
|
+
// Entry files (e.g. main.js) cannot be renamed to .jsc — the Electron/Node runtime
|
|
139
|
+
// requires a literal .js entry. In bytecode/strict mode, compile to .jsc and replace
|
|
140
|
+
// the source with a tiny bytenode loader shell. In confusion mode they behave normally.
|
|
141
|
+
if (this.entryFiles.includes(file)) {
|
|
142
|
+
await this.generateEntryLoader(fullpath);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
// Files in specificFiles are forced to use confusion (e.g. preload/bridge.js
|
|
146
|
+
// must remain in a readable format for BrowserWindow to load; bytecode won't work)
|
|
52
147
|
if (this.specFiles.includes(file)) {
|
|
53
|
-
this.generate(fullpath, 'confusion');
|
|
148
|
+
await this.generate(fullpath, 'confusion');
|
|
54
149
|
continue;
|
|
55
150
|
}
|
|
56
|
-
this.generate(fullpath);
|
|
151
|
+
await this.generate(fullpath);
|
|
57
152
|
}
|
|
58
|
-
console.log(helpers_js_1.chalk.blue('[ee-bin] [encrypt] ') + 'end
|
|
153
|
+
console.log(helpers_js_1.chalk.blue('[ee-bin] [encrypt] ') + 'end encrypting');
|
|
59
154
|
}
|
|
60
|
-
|
|
155
|
+
/**
|
|
156
|
+
* Encrypt a single file
|
|
157
|
+
*
|
|
158
|
+
* @param curPath - Absolute path to the file
|
|
159
|
+
* @param type - Encryption type override (used by specificFiles to force a specific type)
|
|
160
|
+
*
|
|
161
|
+
* strict mode = confusion + bytecode combined: obfuscate first, then compile to bytecode.
|
|
162
|
+
* The obfuscated code is compiled into bytecode for double protection.
|
|
163
|
+
*/
|
|
164
|
+
async generate(curPath, type) {
|
|
61
165
|
const encryptType = type || this.type;
|
|
62
166
|
const tips = helpers_js_1.chalk.blue('[ee-bin] [encrypt] ') +
|
|
63
167
|
'file: ' +
|
|
@@ -67,15 +171,42 @@ class Encrypt {
|
|
|
67
171
|
console.log(tips);
|
|
68
172
|
if (encryptType === 'strict') {
|
|
69
173
|
this.generateJSConfuseFile(curPath);
|
|
70
|
-
this.generateBytecodeFile(curPath);
|
|
174
|
+
await this.generateBytecodeFile(curPath);
|
|
71
175
|
}
|
|
72
176
|
else if (encryptType === 'bytecode') {
|
|
73
|
-
this.generateBytecodeFile(curPath);
|
|
177
|
+
await this.generateBytecodeFile(curPath);
|
|
74
178
|
}
|
|
75
179
|
else if (encryptType === 'confusion') {
|
|
76
180
|
this.generateJSConfuseFile(curPath);
|
|
77
181
|
}
|
|
78
182
|
}
|
|
183
|
+
async generateEntryLoader(curPath) {
|
|
184
|
+
const encryptType = this.type;
|
|
185
|
+
if (encryptType === 'strict') {
|
|
186
|
+
this.generateJSConfuseFile(curPath);
|
|
187
|
+
await this.generateBytecodeFile(curPath, false);
|
|
188
|
+
}
|
|
189
|
+
else if (encryptType === 'bytecode') {
|
|
190
|
+
await this.generateBytecodeFile(curPath, false);
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
await this.generate(curPath);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const jscName = path_1.default.basename(curPath, path_1.default.extname(curPath)) + '.jsc';
|
|
197
|
+
const loaderCode = [
|
|
198
|
+
"require('bytenode');",
|
|
199
|
+
`require('./${jscName}');`,
|
|
200
|
+
'',
|
|
201
|
+
].join('\n');
|
|
202
|
+
fs_1.default.writeFileSync(curPath, loaderCode, 'utf8');
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Obfuscate a single JS file (in-place write-back)
|
|
206
|
+
*
|
|
207
|
+
* Default options are merged with user config via Object.assign:
|
|
208
|
+
* User config overrides defaults; unset fields use defaults (compact=true, stringArray=true, etc.)
|
|
209
|
+
*/
|
|
79
210
|
generateJSConfuseFile(file) {
|
|
80
211
|
const opt = Object.assign({
|
|
81
212
|
compact: true,
|
|
@@ -83,10 +214,20 @@ class Encrypt {
|
|
|
83
214
|
stringArrayThreshold: 1,
|
|
84
215
|
}, this.cOpt);
|
|
85
216
|
const code = fs_1.default.readFileSync(file, 'utf8');
|
|
86
|
-
const result = javascript_obfuscator_1.default.obfuscate(code, opt);
|
|
217
|
+
const result = withSuppressedObfuscatorAd(this.silent, () => javascript_obfuscator_1.default.obfuscate(code, opt));
|
|
218
|
+
// Write obfuscated result back to the original file (in-place replacement)
|
|
87
219
|
fs_1.default.writeFileSync(file, result.getObfuscatedCode(), 'utf8');
|
|
88
220
|
}
|
|
89
|
-
|
|
221
|
+
/**
|
|
222
|
+
* Compile a single JS file to V8 bytecode (.jsc)
|
|
223
|
+
*
|
|
224
|
+
* Safety mechanism:
|
|
225
|
+
* 1. Only process .js files (skip .json and other extensions)
|
|
226
|
+
* 2. After compilation, verify the .jsc file exists before deleting the source .js file
|
|
227
|
+
* 3. If .jsc was not generated, throw an error and keep the source file (prevents code loss from failed compilation)
|
|
228
|
+
* 4. Use fs.unlinkSync to delete a single file instead of fs.rmSync (avoids recursive delete risk)
|
|
229
|
+
*/
|
|
230
|
+
async generateBytecodeFile(curPath, deleteSource = true) {
|
|
90
231
|
if (path_1.default.extname(curPath) !== '.js') {
|
|
91
232
|
return;
|
|
92
233
|
}
|
|
@@ -96,20 +237,40 @@ class Encrypt {
|
|
|
96
237
|
output: jscFile,
|
|
97
238
|
electron: true,
|
|
98
239
|
}, this.bOpt);
|
|
99
|
-
bytenode_1.default.compileFile(opt);
|
|
100
|
-
|
|
240
|
+
await bytenode_1.default.compileFile(opt);
|
|
241
|
+
// Verify .jsc output exists before deleting source file
|
|
242
|
+
if (fs_1.default.existsSync(jscFile)) {
|
|
243
|
+
if (deleteSource)
|
|
244
|
+
fs_1.default.unlinkSync(curPath);
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
throw new Error(`[ee-bin] [encrypt] Bytecode compilation failed: ${jscFile} was not created, keeping source ${curPath}`);
|
|
248
|
+
}
|
|
101
249
|
}
|
|
102
250
|
}
|
|
103
|
-
|
|
104
|
-
|
|
251
|
+
/**
|
|
252
|
+
* Encryption entry function — processes both electron and frontend targets
|
|
253
|
+
*
|
|
254
|
+
* Creates separate Encrypt instances for electron and frontend.
|
|
255
|
+
* Each instance independently determines whether to encrypt and which method to use,
|
|
256
|
+
* based on its own configuration.
|
|
257
|
+
*/
|
|
258
|
+
async function encrypt(options = {}) {
|
|
259
|
+
const electronOpt = { ...options, target: 'electron' };
|
|
105
260
|
const electronEpt = new Encrypt(electronOpt);
|
|
106
|
-
electronEpt.encrypt();
|
|
107
|
-
const frontendOpt =
|
|
261
|
+
await electronEpt.encrypt();
|
|
262
|
+
const frontendOpt = { ...options, target: 'frontend' };
|
|
108
263
|
const frontendEpt = new Encrypt(frontendOpt);
|
|
109
|
-
frontendEpt.encrypt();
|
|
264
|
+
await frontendEpt.encrypt();
|
|
110
265
|
}
|
|
266
|
+
/**
|
|
267
|
+
* Clean encrypted output — delete encryption artifacts from specified directories
|
|
268
|
+
*
|
|
269
|
+
* @param options.dir - Directory path(s) to clean (defaults to './public/electron').
|
|
270
|
+
* Accepts a string or string array for multiple directories.
|
|
271
|
+
*/
|
|
111
272
|
function cleanEncrypt(options = {}) {
|
|
112
|
-
const dirs = options.dir !== undefined ? (
|
|
273
|
+
const dirs = options.dir !== undefined ? (0, utils_js_1.toArray)(options.dir) : ['./public/electron'];
|
|
113
274
|
for (const dir of dirs) {
|
|
114
275
|
const tmpFile = path_1.default.join(process.cwd(), dir);
|
|
115
276
|
if (fs_1.default.existsSync(tmpFile)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encrypt.js","sourceRoot":"","sources":["../../../src/tools/encrypt.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"encrypt.js","sourceRoot":"","sources":["../../../src/tools/encrypt.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;;;AA2RH,0BAQC;AAQD,oCAYC;AArTD,gDAAwB;AACxB,4CAAoB;AACpB,kDAA0C;AAC1C,wDAAgC;AAChC,kFAAyD;AACzD,mCAAoC;AACpC,8CAAsD;AAGtD,wEAAwE;AACxE,MAAM,YAAY,GAAG,CAAC,UAAU,EAAE,WAAW,EAAE,QAAQ,CAAU,CAAC;AAWlE;;;;;;;GAOG;AACH,SAAS,0BAA0B,CAAI,MAAe,EAAE,EAAW;IACjE,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,EAAE,CAAC;IAEzB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAC7B,OAAO,CAAC,GAAG,GAAG,CAAC,GAAG,IAAe,EAAQ,EAAE;QACzC,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACtB,IACE,OAAO,KAAK,KAAK,QAAQ;YACzB,CAAC,KAAK,CAAC,QAAQ,CAAC,2BAA2B,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,EAChF,CAAC;YACD,OAAO;QACT,CAAC;QACD,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,IAAU,CAAC,CAAC;IACtC,CAAC,CAAC;IACF,IAAI,CAAC;QACH,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,GAAG,GAAG,QAAQ,CAAC;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,CAAC,CACzF,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Application Icon Generator — produces platform-specific icons from a source image
|
|
4
|
+
*
|
|
5
|
+
* This module generates all required icon formats for Electron applications:
|
|
6
|
+
* - .ico files for Windows (installer + taskbar)
|
|
7
|
+
* - .png files at various sizes for Linux, tray icons, and window icons
|
|
8
|
+
* - Renamed/copyed icons following electron-egg naming conventions
|
|
9
|
+
*
|
|
10
|
+
* Icon generation flow:
|
|
11
|
+
* 1. Load optional "icon-gen" dependency (graceful error if not installed)
|
|
12
|
+
* 2. Validate input image exists and prepare output directory
|
|
13
|
+
* 3. Generate icons via icon-gen library (ico + favicon/png sizes)
|
|
14
|
+
* 4. Post-process: rename and copy icons to match the framework's expected paths:
|
|
15
|
+
* - 16px → copied to public/images/ as "tray.png" (system tray icon)
|
|
16
|
+
* - 32px → copied to public/images/ with original name (window icon)
|
|
17
|
+
* - Other sizes → renamed to "NxN.png" format in build/icons/
|
|
18
|
+
*
|
|
19
|
+
* Dependencies:
|
|
20
|
+
* - icon-gen: Optional npm package for icon generation. If not installed,
|
|
21
|
+
* a helpful message is displayed with install instructions.
|
|
22
|
+
*/
|
|
2
23
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
24
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
25
|
};
|
|
@@ -6,6 +27,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
27
|
exports.run = run;
|
|
7
28
|
const fs_1 = __importDefault(require("fs"));
|
|
8
29
|
const path_1 = __importDefault(require("path"));
|
|
30
|
+
const helpers_js_1 = require("../lib/helpers.js");
|
|
31
|
+
/** Default parameter values when no CLI options are provided */
|
|
9
32
|
const DEFAULT_PARAMS = {
|
|
10
33
|
input: '/public/images/logo.png',
|
|
11
34
|
output: '/build/icons/',
|
|
@@ -14,27 +37,27 @@ const DEFAULT_PARAMS = {
|
|
|
14
37
|
imagesDir: '/public/images/',
|
|
15
38
|
};
|
|
16
39
|
class IconGen {
|
|
17
|
-
constructor(
|
|
18
|
-
const params = {
|
|
19
|
-
input: opts.input || DEFAULT_PARAMS.input,
|
|
20
|
-
output: opts.output || DEFAULT_PARAMS.output,
|
|
21
|
-
size: opts.size || DEFAULT_PARAMS.size,
|
|
22
|
-
clear: opts.clear === true,
|
|
23
|
-
imagesDir: opts.images || DEFAULT_PARAMS.imagesDir,
|
|
24
|
-
};
|
|
40
|
+
constructor(params) {
|
|
25
41
|
this.params = params;
|
|
42
|
+
// Attempt to load icon-gen as an optional dependency.
|
|
43
|
+
// If not installed, set to null and provide a helpful message later.
|
|
44
|
+
// If installed but fails to load (e.g. native module error), log the real error.
|
|
26
45
|
try {
|
|
27
46
|
// eslint-disable-next-line @typescript-eslint/no-require-imports -- optional dependency lazy load
|
|
28
47
|
const mod = require('icon-gen');
|
|
29
48
|
this.icongen = typeof mod.default === 'function' ? mod.default : mod;
|
|
30
49
|
}
|
|
31
|
-
catch {
|
|
50
|
+
catch (e) {
|
|
32
51
|
this.icongen = null;
|
|
52
|
+
if (e instanceof Error && !e.message.includes("Cannot find module")) {
|
|
53
|
+
console.log(helpers_js_1.chalk.yellow('[ee-bin] [icon-gen] ') + `icon-gen failed to load: ${e.message}`);
|
|
54
|
+
}
|
|
33
55
|
}
|
|
34
|
-
console.log('[ee-bin] [icon-gen]
|
|
56
|
+
console.log('[ee-bin] [icon-gen] Current working directory: ', process.cwd());
|
|
35
57
|
this.input = path_1.default.join(process.cwd(), params.input);
|
|
36
58
|
this.output = path_1.default.join(process.cwd(), params.output);
|
|
37
59
|
this.imagesDir = path_1.default.join(process.cwd(), params.imagesDir);
|
|
60
|
+
// Parse comma-separated size string into integer array for icon-gen
|
|
38
61
|
const sizeList = params.size.split(',').map((item) => parseInt(item, 10));
|
|
39
62
|
this.iconOptions = {
|
|
40
63
|
report: false,
|
|
@@ -48,39 +71,63 @@ class IconGen {
|
|
|
48
71
|
},
|
|
49
72
|
};
|
|
50
73
|
}
|
|
51
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Generate all icon files from the source image
|
|
76
|
+
*
|
|
77
|
+
* Steps:
|
|
78
|
+
* 1. Check icon-gen is available; if not, show install instructions
|
|
79
|
+
* 2. Validate input image exists
|
|
80
|
+
* 3. Prepare output directory (create if missing, optionally clear)
|
|
81
|
+
* 4. Run icon-gen to produce ico + png files
|
|
82
|
+
* 5. Post-process: rename and copy icons to framework-expected paths
|
|
83
|
+
*/
|
|
84
|
+
async generateIcons() {
|
|
52
85
|
if (!this.icongen) {
|
|
53
86
|
console.log('[ee-bin] [icon-gen] icon-gen is not installed.');
|
|
54
87
|
console.log('[ee-bin] [icon-gen] Please run: pnpm add icon-gen');
|
|
55
88
|
return;
|
|
56
89
|
}
|
|
57
|
-
console.log('[ee-bin] [icon-gen]
|
|
90
|
+
console.log('[ee-bin] [icon-gen] Start generating logo images');
|
|
91
|
+
// Validate that the source image file exists
|
|
58
92
|
if (!fs_1.default.existsSync(this.input)) {
|
|
59
|
-
console.error('[ee-bin] [icon-gen]
|
|
60
|
-
throw new Error('
|
|
93
|
+
console.error('[ee-bin] [icon-gen] Input: ', this.input);
|
|
94
|
+
throw new Error('Input image does not exist or path is invalid: ' + this.input);
|
|
61
95
|
}
|
|
96
|
+
// Ensure output directory exists
|
|
62
97
|
if (!fs_1.default.existsSync(this.output)) {
|
|
63
98
|
fs_1.default.mkdirSync(this.output, { recursive: true });
|
|
64
99
|
}
|
|
65
100
|
else {
|
|
101
|
+
// Optionally clear existing icons before generating new ones
|
|
66
102
|
if (this.params.clear) {
|
|
67
103
|
this.deleteGenFile(this.output);
|
|
68
104
|
}
|
|
69
105
|
}
|
|
106
|
+
// Ensure images directory exists (for tray/window icon copies)
|
|
70
107
|
if (!fs_1.default.existsSync(this.imagesDir)) {
|
|
71
108
|
fs_1.default.mkdirSync(this.imagesDir, { recursive: true });
|
|
72
109
|
}
|
|
73
|
-
|
|
74
|
-
.
|
|
75
|
-
console.log('[ee-bin] [icon-gen]
|
|
110
|
+
try {
|
|
111
|
+
const results = await this.icongen(this.input, this.output, this.iconOptions);
|
|
112
|
+
console.log('[ee-bin] [icon-gen] Generated image resources:');
|
|
76
113
|
console.log(results);
|
|
114
|
+
// Rename/copy icons to match electron-egg naming conventions
|
|
77
115
|
this._renameForEE(results);
|
|
78
|
-
}
|
|
79
|
-
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
80
118
|
console.error(err);
|
|
81
|
-
throw new Error('[ee-bin] [icon-gen]
|
|
82
|
-
}
|
|
119
|
+
throw new Error('[ee-bin] [icon-gen] Image generation failed!');
|
|
120
|
+
}
|
|
83
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Delete generated icon files (.ico, .png) from a directory recursively
|
|
124
|
+
*
|
|
125
|
+
* Only removes files with .ico or .png extensions; leaves other files and
|
|
126
|
+
* empty directories intact. This is used when --clear flag is set to start
|
|
127
|
+
* with a clean output directory.
|
|
128
|
+
*
|
|
129
|
+
* @param dirPath - Directory to scan for icon files to delete
|
|
130
|
+
*/
|
|
84
131
|
deleteGenFile(dirPath) {
|
|
85
132
|
if (fs_1.default.existsSync(dirPath)) {
|
|
86
133
|
const files = fs_1.default.readdirSync(dirPath);
|
|
@@ -90,6 +137,7 @@ class IconGen {
|
|
|
90
137
|
this.deleteGenFile(curPath);
|
|
91
138
|
}
|
|
92
139
|
else {
|
|
140
|
+
// Only delete icon files (.ico, .png), preserve other files
|
|
93
141
|
if (['.ico', '.png'].includes(path_1.default.extname(curPath))) {
|
|
94
142
|
fs_1.default.unlinkSync(curPath);
|
|
95
143
|
}
|
|
@@ -97,44 +145,84 @@ class IconGen {
|
|
|
97
145
|
}
|
|
98
146
|
}
|
|
99
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Post-process generated icons — rename and copy to framework-expected paths
|
|
150
|
+
*
|
|
151
|
+
* electron-egg naming conventions:
|
|
152
|
+
* - 16px icon → copy to public/images/ as "tray.png" (system tray icon)
|
|
153
|
+
* - 32px icon → copy to public/images/ with original name (window icon)
|
|
154
|
+
* - Other sizes → rename to "NxN.png" format in build/icons/ (e.g. "64x64.png")
|
|
155
|
+
*
|
|
156
|
+
* The icon-gen library generates files with a "logo-" prefix (from favicon.name config),
|
|
157
|
+
* e.g. "logo-16.png", "logo-32.png", "logo-256.png". This method transforms those
|
|
158
|
+
* names into the framework's expected format.
|
|
159
|
+
*
|
|
160
|
+
* @param filesPath - Array of file paths generated by icon-gen
|
|
161
|
+
*/
|
|
100
162
|
_renameForEE(filesPath) {
|
|
101
|
-
console.log('[ee-bin] [icon-gen]
|
|
163
|
+
console.log('[ee-bin] [icon-gen] Start renaming logo image resources');
|
|
102
164
|
try {
|
|
103
165
|
for (const filePath of filesPath) {
|
|
104
166
|
const extname = path_1.default.extname(filePath);
|
|
105
167
|
if (['.png'].includes(extname)) {
|
|
106
168
|
const filename = path_1.default.basename(filePath, extname);
|
|
169
|
+
// Extract the size number from the filename (e.g. "logo-16" → "16")
|
|
107
170
|
const basename = filename.split('-')[1];
|
|
108
171
|
const dirname = path_1.default.dirname(filePath);
|
|
109
172
|
if (basename === '16') {
|
|
173
|
+
// 16px icon → tray icon (used in system tray / notification area)
|
|
110
174
|
const newName = 'tray' + extname;
|
|
111
175
|
fs_1.default.copyFileSync(filePath, path_1.default.join(this.imagesDir, newName));
|
|
112
|
-
console.log(`${filename}${extname} --> ${this.params.imagesDir}/${newName}
|
|
176
|
+
console.log(`${filename}${extname} --> ${this.params.imagesDir}/${newName} copied successfully!`);
|
|
113
177
|
fs_1.default.unlinkSync(filePath);
|
|
114
178
|
continue;
|
|
115
179
|
}
|
|
116
180
|
if (basename === '32') {
|
|
181
|
+
// 32px icon → window icon (used for the app window title bar)
|
|
117
182
|
const newName = filename + extname;
|
|
118
183
|
fs_1.default.copyFileSync(filePath, path_1.default.join(this.imagesDir, newName));
|
|
119
|
-
console.log(`${filename}${extname} --> ${this.params.imagesDir}/${newName}
|
|
184
|
+
console.log(`${filename}${extname} --> ${this.params.imagesDir}/${newName} copied successfully!`);
|
|
120
185
|
continue;
|
|
121
186
|
}
|
|
187
|
+
// Other sizes → rename to "NxN.png" format (e.g. 64x64.png, 256x256.png)
|
|
188
|
+
// This is the standard naming convention for Electron icon sets
|
|
122
189
|
const newName = basename + 'x' + basename + extname;
|
|
123
190
|
const newPath = path_1.default.join(dirname, newName);
|
|
124
191
|
fs_1.default.renameSync(filePath, newPath);
|
|
125
|
-
console.log(`${filename}${extname} --> ${newName}
|
|
192
|
+
console.log(`${filename}${extname} --> ${newName} renamed successfully!`);
|
|
126
193
|
}
|
|
127
194
|
}
|
|
128
|
-
console.log('[ee-bin] [icon-gen]
|
|
195
|
+
console.log('[ee-bin] [icon-gen] Image resource processing completed!');
|
|
129
196
|
}
|
|
130
197
|
catch (e) {
|
|
131
198
|
console.error('[ee-bin] [icon-gen] ERROR: ', e);
|
|
132
|
-
throw new Error('
|
|
199
|
+
throw new Error('Renaming logo image resources failed!');
|
|
133
200
|
}
|
|
134
201
|
}
|
|
135
202
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
203
|
+
/**
|
|
204
|
+
* Extract IconGenParams from CLI options, applying defaults for missing values
|
|
205
|
+
*
|
|
206
|
+
* @param opts - Raw CLI options object from Commander
|
|
207
|
+
* @returns Fully resolved IconGenParams with defaults applied
|
|
208
|
+
*/
|
|
209
|
+
function extractParams(opts) {
|
|
210
|
+
return {
|
|
211
|
+
input: opts.input || DEFAULT_PARAMS.input,
|
|
212
|
+
output: opts.output || DEFAULT_PARAMS.output,
|
|
213
|
+
size: opts.size || DEFAULT_PARAMS.size,
|
|
214
|
+
clear: opts.clear === true,
|
|
215
|
+
imagesDir: opts.images || DEFAULT_PARAMS.imagesDir,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Icon generation entry function
|
|
220
|
+
*
|
|
221
|
+
* @param opts - CLI options (input, output, size, clear, images)
|
|
222
|
+
*/
|
|
223
|
+
async function run(opts) {
|
|
224
|
+
const params = extractParams(opts || {});
|
|
225
|
+
const i = new IconGen(params);
|
|
226
|
+
await i.generateIcons();
|
|
139
227
|
}
|
|
140
228
|
//# sourceMappingURL=iconGen.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iconGen.js","sourceRoot":"","sources":["../../../src/tools/iconGen.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"iconGen.js","sourceRoot":"","sources":["../../../src/tools/iconGen.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;AAyOH,kBAIC;AA3OD,4CAAoB;AACpB,gDAAwB;AACxB,kDAA0C;AAgB1C,gEAAgE;AAChE,MAAM,cAAc,GAAkB;IACpC,KAAK,EAAE,yBAAyB;IAChC,MAAM,EAAE,eAAe;IACvB,IAAI,EAAE,kBAAkB;IACxB,KAAK,EAAE,KAAK;IACZ,SAAS,EAAE,iBAAiB;CAC7B,CAAC;AAEF,MAAM,OAAO;IAcX,YAAY,MAAqB;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,sDAAsD;QACtD,qEAAqE;QACrE,iFAAiF;QACjF,IAAI,CAAC;YACH,kGAAkG;YAClG,MAAM,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;YAChC,IAAI,CAAC,OAAO,GAAG,OAAO,GAAG,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;QACvE,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;YACpB,IAAI,CAAC,YAAY,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,CAAC;gBACpE,OAAO,CAAC,GAAG,CAAC,kBAAK,CAAC,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