@vixoniccom/module-packager 2.12.0-dev.9 → 2.12.1-test.0
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/electron.js +0 -1
- package/dist/launcher.html +0 -4
- package/dist/main.js +10 -17
- package/dist/webpack.config.js +1 -1
- package/package.json +3 -3
package/dist/electron.js
CHANGED
|
@@ -40,7 +40,6 @@ function createWindow() {
|
|
|
40
40
|
const launcherPath = path.join(__dirname, 'launcher.html');
|
|
41
41
|
const launcherURL = `file://${launcherPath}`;
|
|
42
42
|
mainWindow.loadURL(launcherURL);
|
|
43
|
-
// mainWindow.webContents.openDevTools({ mode: 'detach' })
|
|
44
43
|
mainWindow.webContents.once('did-finish-load', () => {
|
|
45
44
|
mainWindow?.show();
|
|
46
45
|
mainWindow?.webContents.send('init', options);
|
package/dist/launcher.html
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
</head>
|
|
8
8
|
|
|
9
9
|
<body style="width: 100%; height: 100%; margin: 0; padding: 0;">
|
|
10
|
-
<!-- Remover el webview del HTML -->
|
|
11
10
|
<div id="webview-container" style="width: 100%; height: 100%;"></div>
|
|
12
11
|
|
|
13
12
|
<script>
|
|
@@ -23,7 +22,6 @@
|
|
|
23
22
|
const remote = require('@electron/remote')
|
|
24
23
|
|
|
25
24
|
ipcRenderer.on('init', (event, options) => {
|
|
26
|
-
// Crear el webview dinámicamente
|
|
27
25
|
const webview = document.createElement('webview')
|
|
28
26
|
webview.id = 'webview'
|
|
29
27
|
webview.style.width = '100%'
|
|
@@ -46,7 +44,6 @@
|
|
|
46
44
|
|
|
47
45
|
webview.src = resolvedSrc
|
|
48
46
|
|
|
49
|
-
// Añadir el webview al DOM después de configurarlo
|
|
50
47
|
document.getElementById('webview-container').appendChild(webview)
|
|
51
48
|
|
|
52
49
|
function getData() {
|
|
@@ -60,7 +57,6 @@
|
|
|
60
57
|
|
|
61
58
|
let escaped = path.join(options.mode === 'watch' ? options.src : options.build, 'test', 'downloads')
|
|
62
59
|
|
|
63
|
-
// Add file:// to watch because in this mode the app will be in a localhost hosted environment.
|
|
64
60
|
if (options.mode === 'watch') escaped = `file://${escaped}`
|
|
65
61
|
escaped = escaped.replace(/\\/g, '/')
|
|
66
62
|
|
package/dist/main.js
CHANGED
|
@@ -37,30 +37,24 @@ const optionDefinitions = [
|
|
|
37
37
|
{ name: 'tsOverride', type: Boolean }
|
|
38
38
|
];
|
|
39
39
|
const options = commandLineArgs(optionDefinitions);
|
|
40
|
-
// Validación de entrada mejorada
|
|
41
40
|
function validateOptions(options) {
|
|
42
41
|
if (options.target !== 'electron-renderer' && options.externals.length > 0) {
|
|
43
42
|
throw new Error(`Can't use external dependencies if target is not electron-renderer.`);
|
|
44
43
|
}
|
|
45
|
-
// Validar puerto
|
|
46
44
|
if (options.port < 1 || options.port > 65535) {
|
|
47
45
|
throw new Error('Port must be between 1 and 65535');
|
|
48
46
|
}
|
|
49
|
-
// Validar modo
|
|
50
47
|
const validModes = ['build', 'watch', 'run', 'generate-configuration', 'validate-configuration'];
|
|
51
48
|
if (!validModes.includes(options.mode)) {
|
|
52
49
|
throw new Error(`Invalid mode. Must be one of: ${validModes.join(', ')}`);
|
|
53
50
|
}
|
|
54
51
|
}
|
|
55
|
-
// Función para sanitizar rutas
|
|
56
52
|
function sanitizePath(inputPath) {
|
|
57
|
-
// Prevenir path traversal
|
|
58
53
|
if (inputPath.includes('..') || inputPath.includes('~')) {
|
|
59
54
|
throw new Error('Invalid path: path traversal detected');
|
|
60
55
|
}
|
|
61
56
|
return path.resolve(inputPath);
|
|
62
57
|
}
|
|
63
|
-
// Función centralizada para crear argumentos de Electron
|
|
64
58
|
function createElectronArgs(mode) {
|
|
65
59
|
return [
|
|
66
60
|
electronPath,
|
|
@@ -72,7 +66,6 @@ function createElectronArgs(mode) {
|
|
|
72
66
|
...options.externals.flatMap((pkg) => ['--externals', pkg])
|
|
73
67
|
];
|
|
74
68
|
}
|
|
75
|
-
// Función centralizada para manejar procesos Electron
|
|
76
69
|
function spawnElectronProcess(mode) {
|
|
77
70
|
const args = createElectronArgs(mode);
|
|
78
71
|
const nodeEnv = mode === 'run' ? 'production' : 'development';
|
|
@@ -86,11 +79,9 @@ function spawnElectronProcess(mode) {
|
|
|
86
79
|
},
|
|
87
80
|
stdio: ['inherit', 'pipe', 'pipe']
|
|
88
81
|
});
|
|
89
|
-
// Manejo centralizado de logs
|
|
90
82
|
setupChildProcessLogging(child);
|
|
91
83
|
return child;
|
|
92
84
|
}
|
|
93
|
-
// Función para manejar logging de procesos hijo
|
|
94
85
|
function setupChildProcessLogging(child) {
|
|
95
86
|
child.stdout?.on('data', (data) => {
|
|
96
87
|
const output = data.toString();
|
|
@@ -105,20 +96,19 @@ function setupChildProcessLogging(child) {
|
|
|
105
96
|
}
|
|
106
97
|
});
|
|
107
98
|
}
|
|
108
|
-
// Función centralizada para compilar webpack
|
|
109
99
|
async function compileWebpack() {
|
|
110
|
-
// CORREGIDO: Usar __dirname para el webpack.config.js del module-packager
|
|
111
100
|
const cfgPath = path.resolve(__dirname, 'webpack.config.js');
|
|
112
101
|
const webpackConfigFactory = (await import(cfgPath)).default;
|
|
113
102
|
const compiler = webpack(webpackConfigFactory(options));
|
|
114
103
|
return new Promise((resolve, reject) => {
|
|
115
|
-
compiler
|
|
104
|
+
compiler?.run((err, stats) => {
|
|
116
105
|
if (err)
|
|
117
|
-
return reject(err);
|
|
106
|
+
return reject(new Error(`Webpack compilation error: ${err.message}`));
|
|
118
107
|
if (stats?.hasErrors()) {
|
|
119
|
-
|
|
108
|
+
const errorMessage = stats.toString({ all: false, errors: true, colors: true });
|
|
109
|
+
return reject(new Error(`Webpack compilation failed: ${errorMessage}`));
|
|
120
110
|
}
|
|
121
|
-
compiler.close(closeErr => (closeErr ? reject(closeErr) : resolve()));
|
|
111
|
+
compiler.close(closeErr => (closeErr ? reject(new Error(`Webpack compilation error: ${closeErr}`)) : resolve()));
|
|
122
112
|
});
|
|
123
113
|
});
|
|
124
114
|
}
|
|
@@ -175,7 +165,11 @@ async function pack(callback) {
|
|
|
175
165
|
else {
|
|
176
166
|
console.error(clc.red(JSON.stringify(info, null, 2)));
|
|
177
167
|
}
|
|
178
|
-
|
|
168
|
+
// CORREGIDO: Pasar un objeto Error en lugar de stats
|
|
169
|
+
const errorMessage = info.errors?.length
|
|
170
|
+
? info.errors.map((e) => typeof e === 'object' ? JSON.stringify(e) : e).join('\n')
|
|
171
|
+
: 'Webpack compilation failed with errors';
|
|
172
|
+
callback?.(new Error(errorMessage));
|
|
179
173
|
}
|
|
180
174
|
else {
|
|
181
175
|
console.log(clc.green('Build OK.'));
|
|
@@ -244,7 +238,6 @@ function zip() {
|
|
|
244
238
|
clc.move(-2, 0);
|
|
245
239
|
}
|
|
246
240
|
async function watch() {
|
|
247
|
-
// CORREGIDO: Usar __dirname para el webpack.config.js del module-packager
|
|
248
241
|
const cfgPath = path.resolve(__dirname, 'webpack.config.js');
|
|
249
242
|
const webpackConfigFactory = (await import(cfgPath)).default;
|
|
250
243
|
const compiler = webpack(webpackConfigFactory(options));
|
package/dist/webpack.config.js
CHANGED
|
@@ -23,7 +23,7 @@ export default (env = {}, argv = {}) => {
|
|
|
23
23
|
const controllerTestPath = path.resolve(options.src, 'test');
|
|
24
24
|
return {
|
|
25
25
|
mode: isDev ? 'development' : 'production',
|
|
26
|
-
target: options.target,
|
|
26
|
+
target: options.target ?? 'electron-renderer',
|
|
27
27
|
entry: isDev ? [
|
|
28
28
|
`webpack-dev-server/client?http://localhost:${options.port}/`,
|
|
29
29
|
'webpack/hot/dev-server',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vixoniccom/module-packager",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.1-test.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"bin": {
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@electron/remote": "^2.1.2",
|
|
27
27
|
"@types/which": "^3.0.4",
|
|
28
|
-
"@vixoniccom/module-controller": "2.0.0
|
|
29
|
-
"@vixoniccom/modules": "2.20.
|
|
28
|
+
"@vixoniccom/module-controller": "^2.0.0",
|
|
29
|
+
"@vixoniccom/modules": "^2.20.4",
|
|
30
30
|
"archiver": "^5.3.0",
|
|
31
31
|
"clean-webpack-plugin": "^4.0.0",
|
|
32
32
|
"cli-color": "^1.2.0",
|