ee-bin 5.0.0-beta.2 → 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.
Files changed (73) hide show
  1. package/dist/cjs/config/bin_default.js +69 -29
  2. package/dist/cjs/config/bin_default.js.map +1 -1
  3. package/dist/cjs/index.js +125 -4
  4. package/dist/cjs/index.js.map +1 -1
  5. package/dist/cjs/lib/extend.js +49 -15
  6. package/dist/cjs/lib/extend.js.map +1 -1
  7. package/dist/cjs/lib/helpers.js +71 -22
  8. package/dist/cjs/lib/helpers.js.map +1 -1
  9. package/dist/cjs/lib/utils.js +71 -30
  10. package/dist/cjs/lib/utils.js.map +1 -1
  11. package/dist/cjs/plugins/bundle_registry_plugin.js +156 -0
  12. package/dist/cjs/plugins/bundle_registry_plugin.js.map +1 -0
  13. package/dist/cjs/tools/encrypt.js +190 -29
  14. package/dist/cjs/tools/encrypt.js.map +1 -1
  15. package/dist/cjs/tools/iconGen.js +118 -30
  16. package/dist/cjs/tools/iconGen.js.map +1 -1
  17. package/dist/cjs/tools/incrUpdater.js +95 -33
  18. package/dist/cjs/tools/incrUpdater.js.map +1 -1
  19. package/dist/cjs/tools/move.js +71 -11
  20. package/dist/cjs/tools/move.js.map +1 -1
  21. package/dist/cjs/tools/serve.js +406 -81
  22. package/dist/cjs/tools/serve.js.map +1 -1
  23. package/dist/cjs/types/config.js +13 -0
  24. package/dist/cjs/types/config.js.map +1 -0
  25. package/dist/esm/config/bin_default.d.ts +19 -147
  26. package/dist/esm/config/bin_default.d.ts.map +1 -1
  27. package/dist/esm/config/bin_default.js +69 -29
  28. package/dist/esm/config/bin_default.js.map +1 -1
  29. package/dist/esm/index.d.ts +20 -0
  30. package/dist/esm/index.d.ts.map +1 -1
  31. package/dist/esm/index.js +125 -4
  32. package/dist/esm/index.js.map +1 -1
  33. package/dist/esm/lib/extend.d.ts +33 -0
  34. package/dist/esm/lib/extend.d.ts.map +1 -1
  35. package/dist/esm/lib/extend.js +49 -15
  36. package/dist/esm/lib/extend.js.map +1 -1
  37. package/dist/esm/lib/helpers.d.ts +44 -3
  38. package/dist/esm/lib/helpers.d.ts.map +1 -1
  39. package/dist/esm/lib/helpers.js +71 -22
  40. package/dist/esm/lib/helpers.js.map +1 -1
  41. package/dist/esm/lib/utils.d.ts +57 -3
  42. package/dist/esm/lib/utils.d.ts.map +1 -1
  43. package/dist/esm/lib/utils.js +71 -30
  44. package/dist/esm/lib/utils.js.map +1 -1
  45. package/dist/esm/plugins/bundle_registry_plugin.d.ts +33 -0
  46. package/dist/esm/plugins/bundle_registry_plugin.d.ts.map +1 -0
  47. package/dist/esm/plugins/bundle_registry_plugin.js +156 -0
  48. package/dist/esm/plugins/bundle_registry_plugin.js.map +1 -0
  49. package/dist/esm/tools/encrypt.d.ts +37 -1
  50. package/dist/esm/tools/encrypt.d.ts.map +1 -1
  51. package/dist/esm/tools/encrypt.js +190 -29
  52. package/dist/esm/tools/encrypt.js.map +1 -1
  53. package/dist/esm/tools/iconGen.d.ts +27 -1
  54. package/dist/esm/tools/iconGen.d.ts.map +1 -1
  55. package/dist/esm/tools/iconGen.js +118 -30
  56. package/dist/esm/tools/iconGen.js.map +1 -1
  57. package/dist/esm/tools/incrUpdater.d.ts +60 -13
  58. package/dist/esm/tools/incrUpdater.d.ts.map +1 -1
  59. package/dist/esm/tools/incrUpdater.js +95 -33
  60. package/dist/esm/tools/incrUpdater.js.map +1 -1
  61. package/dist/esm/tools/move.d.ts +41 -0
  62. package/dist/esm/tools/move.d.ts.map +1 -1
  63. package/dist/esm/tools/move.js +71 -11
  64. package/dist/esm/tools/move.js.map +1 -1
  65. package/dist/esm/tools/serve.d.ts +162 -25
  66. package/dist/esm/tools/serve.d.ts.map +1 -1
  67. package/dist/esm/tools/serve.js +406 -81
  68. package/dist/esm/tools/serve.js.map +1 -1
  69. package/dist/esm/types/config.d.ts +211 -0
  70. package/dist/esm/types/config.d.ts.map +1 -0
  71. package/dist/esm/types/config.js +13 -0
  72. package/dist/esm/types/config.js.map +1 -0
  73. package/package.json +16 -13
@@ -1,11 +1,65 @@
1
- export declare function loadConfig(binFile?: string): Record<string, unknown>;
1
+ /**
2
+ * Core Utility Functions — config loading, file I/O, path handling
3
+ *
4
+ * This module is the heart of the ee-bin configuration system. It implements the
5
+ * full configuration loading pipeline:
6
+ * loadConfig(binFile) → loads user ./cmd/bin.js
7
+ * → loadFile(binFile) → parses .js/.json/.json5 config files
8
+ * → extend(true, defaultConfig, userConfig) → deep merges with default config
9
+ *
10
+ * Also provides basic I/O utilities: JSON file read/write, directory deletion,
11
+ * and array normalization.
12
+ */
13
+ import type { BinConfig } from '../types/config.js';
14
+ /**
15
+ * Load and merge ee-bin configuration
16
+ *
17
+ * Two-phase merge strategy:
18
+ * 1. Load user config from ./cmd/bin.js (supports .js/.json/.json5 formats)
19
+ * 2. Deep merge user config on top of default config (user values override defaults)
20
+ *
21
+ * @param binFile - Custom config file path (defaults to './cmd/bin.js')
22
+ * @returns Fully merged BinConfig
23
+ */
24
+ export declare function loadConfig(binFile?: string): BinConfig;
25
+ /**
26
+ * Load a configuration file — supports .json5/.json/.js/.cjs formats
27
+ *
28
+ * Format-specific handling:
29
+ * - .json5/.json: Read text content and parse with the json5 parser
30
+ * (JSON5 supports comments, trailing commas, and other extended syntax)
31
+ * - .js/.cjs: Load the module via require() and extract the export value
32
+ * - If the export is a plain function (not a class), treat it as a config
33
+ * factory function and call it to obtain the config object
34
+ * - If the export is a class, use the class directly as config (do not call it)
35
+ * - If the export is an ESModule (has a default property), extract the .default value
36
+ *
37
+ * @param filepath - Config file path (relative to project root)
38
+ * @returns Config object (Record<string, unknown>)
39
+ * @throws Error with path hint if the file does not exist
40
+ */
2
41
  export declare function loadFile(filepath: string): Record<string, unknown>;
42
+ /** Recursively force-delete a directory or file (similar to rm -rf) */
3
43
  export declare function rm(name: string): void;
44
+ /**
45
+ * Synchronously read a JSON file and parse it into an object
46
+ * @throws Error if the file does not exist
47
+ */
4
48
  export declare function readJsonSync(filepath: string, encoding?: BufferEncoding): Record<string, unknown>;
49
+ /**
50
+ * Synchronously write a JSON file with auto-created directories and formatted output
51
+ *
52
+ * @param filepath - Target file path
53
+ * @param str - Data to write (objects are auto JSON.stringify'd; other types are converted to string)
54
+ * @param options - Optional parameters: space controls indentation (default 2), replacer controls serialization filtering
55
+ */
5
56
  export declare function writeJsonSync(filepath: string, str: unknown, options?: {
6
57
  space?: number;
7
58
  replacer?: (key: string, value: unknown) => unknown;
8
59
  }): void;
9
- export declare function getArgumentByName(name: string, args?: string[]): string | undefined;
10
- export declare function getPlatform(delimiter?: string, isDiffArch?: boolean): string;
60
+ /**
61
+ * Normalize string | string[] | undefined to string[]
62
+ * Used to handle the "args" config field which accepts different input formats
63
+ */
64
+ export declare function toArray(value?: string[] | string): string[];
11
65
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils.ts"],"names":[],"mappings":"AAaA,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAOpE;AAED,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAqBlE;AAED,wBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAKrC;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAE,cAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAKzG;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,CAAA;CAAE,GAAG,IAAI,CAerJ;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAanF;AAED,wBAAgB,WAAW,CAAC,SAAS,SAAM,EAAE,UAAU,UAAQ,GAAG,MAAM,CAavE"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAUH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAMpD;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAOtD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA8BlE;AAED,uEAAuE;AACvE,wBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAKrC;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAE,cAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAKzG;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,CAAA;CAAE,GAAG,IAAI,CAgBrJ;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,EAAE,CAI3D"}
@@ -1,4 +1,16 @@
1
1
  "use strict";
2
+ /**
3
+ * Core Utility Functions — config loading, file I/O, path handling
4
+ *
5
+ * This module is the heart of the ee-bin configuration system. It implements the
6
+ * full configuration loading pipeline:
7
+ * loadConfig(binFile) → loads user ./cmd/bin.js
8
+ * → loadFile(binFile) → parses .js/.json/.json5 config files
9
+ * → extend(true, defaultConfig, userConfig) → deep merges with default config
10
+ *
11
+ * Also provides basic I/O utilities: JSON file read/write, directory deletion,
12
+ * and array normalization.
13
+ */
2
14
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
15
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
16
  };
@@ -8,8 +20,7 @@ exports.loadFile = loadFile;
8
20
  exports.rm = rm;
9
21
  exports.readJsonSync = readJsonSync;
10
22
  exports.writeJsonSync = writeJsonSync;
11
- exports.getArgumentByName = getArgumentByName;
12
- exports.getPlatform = getPlatform;
23
+ exports.toArray = toArray;
13
24
  const helpers_js_1 = require("./helpers.js");
14
25
  const path_1 = __importDefault(require("path"));
15
26
  const fs_1 = __importDefault(require("fs"));
@@ -21,6 +32,16 @@ const extend_js_1 = require("./extend.js");
21
32
  const log = (0, helpers_js_1.createDebug)('ee-bin:lib:utils');
22
33
  const _basePath = process.cwd();
23
34
  const userBin = './cmd/bin.js';
35
+ /**
36
+ * Load and merge ee-bin configuration
37
+ *
38
+ * Two-phase merge strategy:
39
+ * 1. Load user config from ./cmd/bin.js (supports .js/.json/.json5 formats)
40
+ * 2. Deep merge user config on top of default config (user values override defaults)
41
+ *
42
+ * @param binFile - Custom config file path (defaults to './cmd/bin.js')
43
+ * @returns Fully merged BinConfig
44
+ */
24
45
  function loadConfig(binFile) {
25
46
  const binPath = binFile || userBin;
26
47
  const userConfig = loadFile(binPath);
@@ -28,6 +49,22 @@ function loadConfig(binFile) {
28
49
  log('[loadConfig] bin:%j', result);
29
50
  return result;
30
51
  }
52
+ /**
53
+ * Load a configuration file — supports .json5/.json/.js/.cjs formats
54
+ *
55
+ * Format-specific handling:
56
+ * - .json5/.json: Read text content and parse with the json5 parser
57
+ * (JSON5 supports comments, trailing commas, and other extended syntax)
58
+ * - .js/.cjs: Load the module via require() and extract the export value
59
+ * - If the export is a plain function (not a class), treat it as a config
60
+ * factory function and call it to obtain the config object
61
+ * - If the export is a class, use the class directly as config (do not call it)
62
+ * - If the export is an ESModule (has a default property), extract the .default value
63
+ *
64
+ * @param filepath - Config file path (relative to project root)
65
+ * @returns Config object (Record<string, unknown>)
66
+ * @throws Error with path hint if the file does not exist
67
+ */
31
68
  function loadFile(filepath) {
32
69
  const configFile = path_1.default.join(_basePath, filepath);
33
70
  if (!fs_1.default.existsSync(configFile)) {
@@ -42,30 +79,52 @@ function loadFile(filepath) {
42
79
  if (configFile.endsWith('.js') || configFile.endsWith('.cjs')) {
43
80
  // eslint-disable-next-line @typescript-eslint/no-require-imports -- dynamic user config loading
44
81
  const mod = require(configFile);
82
+ // Handle ESM default export: require() on an ESM module returns { default: ... }
45
83
  result = mod.default != null ? mod.default : mod;
46
84
  }
85
+ // Config factory pattern: if the export is a plain function (not a class),
86
+ // call it to obtain the config object. Classes are used directly because
87
+ // a class export is itself the config class, not a factory function.
47
88
  if (helpers_js_3.is.function(result) && !helpers_js_3.is.class(result)) {
48
89
  result = result();
49
90
  }
91
+ // Warn if the config file exports an unrecognized value (null, undefined, primitive)
92
+ // that will be treated as empty config — the user's config is effectively ignored.
93
+ if (result === null || result === undefined) {
94
+ console.log(helpers_js_2.chalk.yellow('[ee-bin] [loadFile] ') + `Warning: ${configFile} exports ${result}, treating as empty config`);
95
+ }
50
96
  return result || {};
51
97
  }
98
+ /** Recursively force-delete a directory or file (similar to rm -rf) */
52
99
  function rm(name) {
53
100
  if (!fs_1.default.existsSync(name)) {
54
101
  return;
55
102
  }
56
103
  fs_1.default.rmSync(name, { recursive: true, force: true });
57
104
  }
105
+ /**
106
+ * Synchronously read a JSON file and parse it into an object
107
+ * @throws Error if the file does not exist
108
+ */
58
109
  function readJsonSync(filepath, encoding = 'utf8') {
59
110
  if (!fs_1.default.existsSync(filepath)) {
60
111
  throw new Error(filepath + ' is not found');
61
112
  }
62
113
  return JSON.parse(fs_1.default.readFileSync(filepath, { encoding }));
63
114
  }
115
+ /**
116
+ * Synchronously write a JSON file with auto-created directories and formatted output
117
+ *
118
+ * @param filepath - Target file path
119
+ * @param str - Data to write (objects are auto JSON.stringify'd; other types are converted to string)
120
+ * @param options - Optional parameters: space controls indentation (default 2), replacer controls serialization filtering
121
+ */
64
122
  function writeJsonSync(filepath, str, options) {
65
123
  const opt = options || {};
66
124
  if (!('space' in opt)) {
67
125
  opt.space = 2;
68
126
  }
127
+ // Auto-create target directory (prevents write failure from missing directory)
69
128
  fs_1.default.mkdirSync(path_1.default.dirname(filepath), { recursive: true });
70
129
  let data;
71
130
  if (typeof str === 'object') {
@@ -76,33 +135,15 @@ function writeJsonSync(filepath, str, options) {
76
135
  }
77
136
  fs_1.default.writeFileSync(filepath, data);
78
137
  }
79
- function getArgumentByName(name, args) {
80
- if (!args) {
81
- args = process.argv;
82
- }
83
- for (let i = 0; i < args.length; i++) {
84
- const item = args[i];
85
- if (!item)
86
- continue;
87
- const prefixKey = `--${name}=`;
88
- if (item.indexOf(prefixKey) !== -1) {
89
- return item.substring(prefixKey.length);
90
- }
91
- }
92
- return undefined;
93
- }
94
- function getPlatform(delimiter = '_', isDiffArch = false) {
95
- if (process.platform === 'win32') {
96
- let os = 'windows';
97
- if (isDiffArch) {
98
- os += delimiter + (process.arch === 'x64' ? '64' : '32');
99
- }
100
- return os;
101
- }
102
- if (process.platform === 'darwin') {
103
- const core = process.arch === 'arm64' ? 'apple' : 'intel';
104
- return 'macos' + delimiter + core;
105
- }
106
- return 'linux';
138
+ /**
139
+ * Normalize string | string[] | undefined to string[]
140
+ * Used to handle the "args" config field which accepts different input formats
141
+ */
142
+ function toArray(value) {
143
+ if (typeof value === 'string')
144
+ return [value];
145
+ if (Array.isArray(value))
146
+ return value;
147
+ return [];
107
148
  }
108
149
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources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A+E;IAC/E,YAAE,CAAC,SAAS,CAAC,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1D,IAAI,IAAY,CAAC;IACjB,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAC7D,CAAC;SAAM,CAAC;QACN,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IAED,YAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AACnC,CAAC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,KAAyB;IAC/C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAC9C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACvC,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * esbuild Bundle-Registry Plugin — generates controller and config registries at build time
3
+ *
4
+ * This plugin is the core mechanism for Electron main process bundling. It scans the
5
+ * electron/controller/ and electron/config/ directories at build time and generates
6
+ * virtual modules that register all controllers and config modules, ensuring the bundled
7
+ * code can correctly locate them. The lazy getter design avoids initialization order issues.
8
+ *
9
+ * Three virtual modules are generated:
10
+ * 1. app:controller-registry → Scans electron/controller/, generates global.__EE_CONTROLLER_REGISTRY__
11
+ * 2. app:config-registry → Scans electron/config/, generates global.__EE_CONFIG_REGISTRY__
12
+ * 3. app:bundle-entry → Virtual entry point that loads in order: config registry → controller registry → main.js
13
+ *
14
+ * Why config loads before controller:
15
+ * ee-core's ConfigLoader._loadConfig() needs __EE_CONFIG_REGISTRY__ to load configuration,
16
+ * and ControllerLoader.load() needs __EE_CONTROLLER_REGISTRY__ to load controllers.
17
+ * Config loading happens before controller loading (ElectronEgg lifecycle: loadConfig → loadController),
18
+ * so registries must be injected in this order as well.
19
+ *
20
+ * How it works with ee-core:
21
+ * - Bundle mode (global.__EE_CONTROLLER_REGISTRY__ exists) → FileLoader.parseFromRegistry() reads from the registry
22
+ * - Dev mode (registry absent) → FileLoader falls back to globby filesystem scanning + require()
23
+ */
24
+ import { Plugin } from 'esbuild';
25
+ /**
26
+ * Create the esbuild bundle-registry plugin
27
+ *
28
+ * @param controllerDir - Absolute path to the electron/controller/ directory
29
+ * @param mainJsPath - Absolute path to electron/main.js or main.ts (entry file)
30
+ * @param configDir - Absolute path to the electron/config/ directory
31
+ */
32
+ export declare function bundleRegistryPlugin(controllerDir: string, mainJsPath: string, configDir: string): Plugin;
33
+ //# sourceMappingURL=bundle_registry_plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle_registry_plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/bundle_registry_plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,MAAM,EAAe,MAAM,SAAS,CAAC;AAgD9C;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GAChB,MAAM,CAwGR"}
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ /**
3
+ * esbuild Bundle-Registry Plugin — generates controller and config registries at build time
4
+ *
5
+ * This plugin is the core mechanism for Electron main process bundling. It scans the
6
+ * electron/controller/ and electron/config/ directories at build time and generates
7
+ * virtual modules that register all controllers and config modules, ensuring the bundled
8
+ * code can correctly locate them. The lazy getter design avoids initialization order issues.
9
+ *
10
+ * Three virtual modules are generated:
11
+ * 1. app:controller-registry → Scans electron/controller/, generates global.__EE_CONTROLLER_REGISTRY__
12
+ * 2. app:config-registry → Scans electron/config/, generates global.__EE_CONFIG_REGISTRY__
13
+ * 3. app:bundle-entry → Virtual entry point that loads in order: config registry → controller registry → main.js
14
+ *
15
+ * Why config loads before controller:
16
+ * ee-core's ConfigLoader._loadConfig() needs __EE_CONFIG_REGISTRY__ to load configuration,
17
+ * and ControllerLoader.load() needs __EE_CONTROLLER_REGISTRY__ to load controllers.
18
+ * Config loading happens before controller loading (ElectronEgg lifecycle: loadConfig → loadController),
19
+ * so registries must be injected in this order as well.
20
+ *
21
+ * How it works with ee-core:
22
+ * - Bundle mode (global.__EE_CONTROLLER_REGISTRY__ exists) → FileLoader.parseFromRegistry() reads from the registry
23
+ * - Dev mode (registry absent) → FileLoader falls back to globby filesystem scanning + require()
24
+ */
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.bundleRegistryPlugin = bundleRegistryPlugin;
30
+ const globby_1 = require("globby");
31
+ const path_1 = __importDefault(require("path"));
32
+ /**
33
+ * Compute property paths from a file path, replicating ee-core's getProperties() + defaultCamelize(caseStyle: 'lower')
34
+ *
35
+ * Camelize rules (caseStyle: 'lower' means first character lowercase):
36
+ * - Remove file extension: 'foo/bar.js' → 'foo/bar'
37
+ * - Split by '/': 'foo/bar' → ['foo', 'bar']
38
+ * - Apply camelCase conversion per segment: letter after underscore/hyphen is uppercased ('foo-bar' → 'fooBar')
39
+ * - First character lowercase: 'FooBar' → 'fooBar'
40
+ *
41
+ * Example: 'foo_bar/my-controller.js' => ['fooBar', 'myController']
42
+ */
43
+ function computeProperties(filepath) {
44
+ const properties = filepath.substring(0, filepath.lastIndexOf('.')).split('/');
45
+ return properties.map((property) => {
46
+ if (!/^[a-z][a-z0-9_-]*$/i.test(property)) {
47
+ throw new Error(`${property} is not match 'a-z0-9_-' in ${filepath}`);
48
+ }
49
+ // Convert underscore/hyphen separators to camelCase
50
+ const normalized = property.replace(/[_-][a-z]/gi, (s) => s.substring(1).toUpperCase());
51
+ const first = normalized[0];
52
+ if (!first)
53
+ return normalized;
54
+ // Ensure first character is lowercase (caseStyle: 'lower')
55
+ return first.toLowerCase() + normalized.substring(1);
56
+ });
57
+ }
58
+ /**
59
+ * Create the esbuild bundle-registry plugin
60
+ *
61
+ * @param controllerDir - Absolute path to the electron/controller/ directory
62
+ * @param mainJsPath - Absolute path to electron/main.js or main.ts (entry file)
63
+ * @param configDir - Absolute path to the electron/config/ directory
64
+ */
65
+ function bundleRegistryPlugin(controllerDir, mainJsPath, configDir) {
66
+ return {
67
+ name: 'bundle-registry',
68
+ setup(build) {
69
+ let registryEntries = [];
70
+ let configEntries = [];
71
+ // Re-scan directories at the start of each build (supports file additions/deletions in rebuild/watch mode)
72
+ build.onStart(() => {
73
+ const controllerFiles = (0, globby_1.globbySync)(['**/*.js', '**/*.jsc', '**/*.ts'], { cwd: controllerDir });
74
+ registryEntries = controllerFiles.map((filepath) => ({
75
+ fullpath: 'controller/' + filepath.replace(/\\/g, '/'),
76
+ properties: computeProperties(filepath),
77
+ relPath: filepath,
78
+ }));
79
+ const configFiles = (0, globby_1.globbySync)(['**/*.js', '**/*.jsc', '**/*.ts'], { cwd: configDir });
80
+ configEntries = configFiles.map((filepath) => ({
81
+ // Remove extension from filename to match ee-core ConfigLoader's lookup logic:
82
+ // ConfigLoader finds config by name (e.g. 'default'), not including the '.js' extension
83
+ filename: filepath.replace(/\\/g, '/').substring(0, filepath.lastIndexOf('.')),
84
+ relPath: filepath,
85
+ }));
86
+ });
87
+ // ─── Virtual module: controller registry ──────────────────────
88
+ build.onResolve({ filter: /^app:controller-registry$/ }, (args) => {
89
+ return { path: args.path, namespace: 'controller-registry' };
90
+ });
91
+ build.onLoad({ filter: /.*/, namespace: 'controller-registry' }, () => {
92
+ const lines = ['// Auto-generated controller registry - do not edit'];
93
+ lines.push('global.__EE_CONTROLLER_REGISTRY__ = [');
94
+ for (const [i, entry] of registryEntries.entries()) {
95
+ const requirePath = JSON.stringify('./' + entry.relPath.replace(/\\/g, '/'));
96
+ const comma = i < registryEntries.length - 1 ? ',' : '';
97
+ // Use lazy getter (get module() { return require(...) }) instead of direct require()
98
+ // to avoid executing all controller modules at registry load time, which could cause
99
+ // initialization order issues. ee-core's FileLoader.parseFromRegistry() invokes the
100
+ // getter only when the module is actually needed.
101
+ lines.push(` { fullpath: ${JSON.stringify(entry.fullpath)}, properties: ${JSON.stringify(entry.properties)}, get module() { return require(${requirePath}); } }${comma}`);
102
+ }
103
+ lines.push('];');
104
+ return {
105
+ contents: lines.join('\n'),
106
+ loader: 'js',
107
+ // Set resolveDir to controllerDir so require() paths resolve relative to the controller directory
108
+ resolveDir: controllerDir,
109
+ };
110
+ });
111
+ // ─── Virtual module: config registry ──────────────────────────
112
+ build.onResolve({ filter: /^app:config-registry$/ }, (args) => {
113
+ return { path: args.path, namespace: 'config-registry' };
114
+ });
115
+ build.onLoad({ filter: /.*/, namespace: 'config-registry' }, () => {
116
+ const lines = ['// Auto-generated config registry - do not edit'];
117
+ lines.push('global.__EE_CONFIG_REGISTRY__ = [');
118
+ for (const [i, entry] of configEntries.entries()) {
119
+ const requirePath = JSON.stringify('./' + entry.relPath.replace(/\\/g, '/'));
120
+ const comma = i < configEntries.length - 1 ? ',' : '';
121
+ // Same as controller registry: use lazy getter to avoid loading config modules immediately
122
+ lines.push(` { filename: ${JSON.stringify(entry.filename)}, get module() { return require(${requirePath}); } }${comma}`);
123
+ }
124
+ lines.push('];');
125
+ return {
126
+ contents: lines.join('\n'),
127
+ loader: 'js',
128
+ resolveDir: configDir,
129
+ };
130
+ });
131
+ // ─── Virtual module: bundle entry point ───────────────────────
132
+ build.onResolve({ filter: /^app:bundle-entry$/ }, (args) => {
133
+ return { path: args.path, namespace: 'bundle-entry' };
134
+ });
135
+ build.onLoad({ filter: /.*/, namespace: 'bundle-entry' }, () => {
136
+ const mainRelative = JSON.stringify('./' + path_1.default.basename(mainJsPath));
137
+ // Load order is critical: config registry → controller registry → main.js
138
+ // Because ee-core's lifecycle is loadConfig → loadController → loadElectron,
139
+ // registries must be injected onto global before main.js executes
140
+ const contents = [
141
+ '// Auto-generated bundle entry - do not edit',
142
+ `require('app:config-registry');`,
143
+ `require('app:controller-registry');`,
144
+ `require(${mainRelative});`,
145
+ ].join('\n');
146
+ return {
147
+ contents,
148
+ loader: 'js',
149
+ // Set resolveDir to the directory containing main.js so require(main.js) resolves correctly
150
+ resolveDir: path_1.default.dirname(mainJsPath),
151
+ };
152
+ });
153
+ },
154
+ };
155
+ }
156
+ //# sourceMappingURL=bundle_registry_plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle_registry_plugin.js","sourceRoot":"","sources":["../../../src/plugins/bundle_registry_plugin.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;;AAyDH,oDA4GC;AAlKD,mCAAoC;AACpC,gDAAwB;AAoBxB;;;;;;;;;;GAUG;AACH,SAAS,iBAAiB,CAAC,QAAgB;IACzC,MAAM,UAAU,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/E,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;QACjC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC1C,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,+BAA+B,QAAQ,EAAE,CAAC,CAAC;QACxE,CAAC;QACD,oDAAoD;QACpD,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;QACxF,MAAM,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;QAC5B,IAAI,CAAC,KAAK;YA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ACJ,CAAC,CAAC,CAAC;YAEH,iEAAiE;YAEjE,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,oBAAoB,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE;gBACzD,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;YACxD,CAAC,CAAC,CAAC;YAEH,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,EAAE,GAAG,EAAE;gBAC7D,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,cAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;gBACtE,0EAA0E;gBAC1E,6EAA6E;gBAC7E,kEAAkE;gBAClE,MAAM,QAAQ,GAAG;oBACf,8CAA8C;oBAC9C,iCAAiC;oBACjC,qCAAqC;oBACrC,WAAW,YAAY,IAAI;iBAC5B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAEb,OAAO;oBACL,QAAQ;oBACR,MAAM,EAAE,IAAI;oBACZ,4FAA4F;oBAC5F,UAAU,EAAE,cAAI,CAAC,OAAO,CAAC,UAAU,CAAC;iBACrC,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1,9 +1,45 @@
1
+ /**
2
+ * Code Encryption Module — bytecode compilation + JS obfuscation
3
+ *
4
+ * Supports three encryption modes:
5
+ * - confusion: Obfuscation only (javascript-obfuscator), works for both frontend and Electron
6
+ * - bytecode: Bytecode only (bytenode), only for Electron (frontend renderer V8 version
7
+ * differs from compile-time V8, making bytecode incompatible)
8
+ * - strict: Obfuscation + bytecode combined; obfuscate first, then compile to bytecode
9
+ * for the strongest protection
10
+ * - none: No encryption (all processing skipped)
11
+ *
12
+ * Encryption flow:
13
+ * 1. Load config, determine encryption type and target file list (via globby scan)
14
+ * 2. Iterate target files; specificFiles entries are forced to use confusion
15
+ * (even when global config is bytecode)
16
+ * 3. Call generateJSConfuseFile or generateBytecodeFile based on encryption type
17
+ *
18
+ * Bytecode compilation safety mechanism:
19
+ * - After compilation, verify the .jsc file exists before deleting the source .js file
20
+ * - If .jsc was not generated, throw an error and keep the source file to prevent
21
+ * code loss from failed compilation
22
+ */
23
+ /** Encryption CLI options */
1
24
  interface EncryptOptions {
2
25
  config?: string;
3
26
  out?: string;
4
27
  target?: string;
5
28
  }
6
- export declare function encrypt(options?: EncryptOptions): void;
29
+ /**
30
+ * Encryption entry function — processes both electron and frontend targets
31
+ *
32
+ * Creates separate Encrypt instances for electron and frontend.
33
+ * Each instance independently determines whether to encrypt and which method to use,
34
+ * based on its own configuration.
35
+ */
36
+ export declare function encrypt(options?: EncryptOptions): Promise<void>;
37
+ /**
38
+ * Clean encrypted output — delete encryption artifacts from specified directories
39
+ *
40
+ * @param options.dir - Directory path(s) to clean (defaults to './public/electron').
41
+ * Accepts a string or string array for multiple directories.
42
+ */
7
43
  export declare function cleanEncrypt(options?: {
8
44
  dir?: string | string[];
9
45
  }): void;
@@ -1 +1 @@
1
- {"version":3,"file":"encrypt.d.ts","sourceRoot":"","sources":["../../../src/tools/encrypt.ts"],"names":[],"mappings":"AAqBA,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAoHD,wBAAgB,OAAO,CAAC,OAAO,GAAE,cAAmB,GAAG,IAAI,CAgB1D;AAED,wBAAgB,YAAY,CAAC,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAAO,GAAG,IAAI,CAY5E"}
1
+ {"version":3,"file":"encrypt.d.ts","sourceRoot":"","sources":["../../../src/tools/encrypt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAgBH,6BAA6B;AAC7B,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AA+PD;;;;;;GAMG;AACH,wBAAsB,OAAO,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAQzE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAAO,GAAG,IAAI,CAY5E"}