@vixoniccom/module-packager 2.10.3-dev.5 → 2.10.3-dev.7

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 CHANGED
@@ -41,14 +41,12 @@ function createWindow() {
41
41
  mainWindow.loadURL(launcherURL);
42
42
  // mainWindow.webContents.openDevTools({ mode: 'detach' })
43
43
  mainWindow.webContents.once('did-finish-load', () => {
44
- console.log('[ELECTRON] did-finish-load → show()');
45
44
  mainWindow?.show();
46
45
  mainWindow?.webContents.send('init', options);
47
46
  });
48
47
  mainWindow.on('closed', () => (mainWindow = null));
49
48
  }
50
49
  app.whenReady().then(() => {
51
- console.log('[ELECTRON] App is ready');
52
50
  createWindow();
53
51
  app.on('activate', () => {
54
52
  if (BrowserWindow.getAllWindows().length === 0) {
@@ -1,5 +1,5 @@
1
1
  <!DOCTYPE html>
2
- <html style="width: 100%; height: 100%; margin: 0; padding: 0;">
2
+ <html lang="en" xml:lang="en" style="width: 100%; height: 100%; margin: 0; padding: 0;">
3
3
 
4
4
  <head>
5
5
  <meta charset="UTF-8" />
@@ -13,43 +13,30 @@
13
13
  const path = require('path')
14
14
  let ModuleController;
15
15
  try {
16
- ModuleController = require('@vixoniccom/module-controller')
17
- console.log('[WEBVIEW] ModuleController cargado OK');
18
- } catch (err) {
16
+ const moduleControllerModule = require('@vixoniccom/module-controller');
17
+ ModuleController = moduleControllerModule.default;
18
+ } catch (err) {
19
19
  console.error('[WEBVIEW] NO se pudo cargar ModuleController', err);
20
20
  }
21
21
  const { ipcRenderer } = require('electron')
22
22
  const remote = require('@electron/remote')
23
23
 
24
24
  ipcRenderer.on('init', (event, options) => {
25
- console.log('[WEBVIEW] init', options)
26
-
27
25
  const webview = document.getElementById('webview')
28
26
  const win = remote.getCurrentWindow()
29
27
 
30
28
  webview.setAttribute('nodeintegration', '')
31
29
  webview.setAttribute('webpreferences', 'contextIsolation=no, nodeIntegration=yes')
32
30
 
33
- // webview.addEventListener('dom-ready', () => {
34
- // webview.openDevTools() // opcional
35
- // })
36
-
37
31
  webview.addEventListener('did-finish-load', () => {
38
- console.log('[WEBVIEW] did-finish-load fired')
39
32
  win.show()
40
33
  win.focus()
41
34
  })
42
35
 
43
- webview.addEventListener('did-fail-load', (e) => {
44
- console.error('[WEBVIEW] did-fail-load', e)
45
- })
46
-
47
36
  const resolvedSrc = options.mode === 'watch'
48
37
  ? `http://localhost:${options.port}/index.html`
49
38
  : `file://${path.join(options.build, 'index.html')}`
50
39
 
51
- console.log('[WEBVIEW] Resolved src:', resolvedSrc)
52
-
53
40
  webview.src = resolvedSrc
54
41
 
55
42
  function getData() {
@@ -87,9 +74,6 @@
87
74
  const data = getData()
88
75
  const schema = getSchema()
89
76
 
90
- console.log('[WEBVIEW] Data entregada a ModuleController:', data)
91
- console.log('[WEBVIEW] Schema entregado a ModuleController:', schema)
92
-
93
77
  ModuleController.init(win, webview, data, schema, options.mode === 'watch')
94
78
  })
95
79
  </script>
package/dist/main.js CHANGED
@@ -4,18 +4,17 @@ import commandLineArgs from 'command-line-args';
4
4
  import path from 'path';
5
5
  import webpack from 'webpack';
6
6
  import WebpackDevServer from 'webpack-dev-server';
7
- import { spawn, exec } from 'child_process';
7
+ import { exec } from 'child_process';
8
8
  import { fileURLToPath } from 'url';
9
9
  import fs from 'fs';
10
10
  import archiver from 'archiver';
11
11
  import clc from 'cli-color';
12
12
  import { Configuration } from '@vixoniccom/modules';
13
13
  import tsNode from 'ts-node';
14
+ import { createRequire } from 'module';
14
15
  const __filename = fileURLToPath(import.meta.url);
15
16
  const __dirname = path.dirname(__filename);
16
17
  const electronPath = path.join(__dirname, 'electron.js');
17
- // import pjson from '../package.json' assert { type: 'json' }
18
- // console.log(`VIXONIC PACKAGER: Version ${pjson.version}`)
19
18
  const optionDefinitions = [
20
19
  { name: 'externals', type: String, defaultValue: [], multiple: true },
21
20
  { name: 'target', type: String, defaultValue: 'web' },
@@ -45,77 +44,58 @@ if (options.mode === 'build') {
45
44
  });
46
45
  }
47
46
  else if (options.mode === 'watch') {
48
- console.log('[DEBUG] Entrando a watch()');
49
47
  watch();
50
48
  }
51
49
  else if (options.mode === 'run') {
52
50
  run();
53
51
  }
54
52
  else if (options.mode === 'generate-configuration') {
55
- generateConfiguration();
53
+ await generateConfiguration();
56
54
  }
57
55
  else if (options.mode === 'validate-configuration') {
58
56
  validateConfiguration();
59
57
  }
60
- function runElectron() {
61
- const electronProcess = spawn('npx', [
62
- 'electron',
63
- electronPath,
64
- '--src', path.resolve(options.src),
65
- '--build', path.resolve(options.build),
66
- '--port', `${options.port}`,
67
- '--mode', options.mode,
68
- '--config', options.config,
69
- '--externals', options.externals.join(',')
70
- ], {
71
- cwd: __dirname,
72
- env: { ...process.env, NODE_ENV: 'development' },
73
- stdio: 'inherit'
74
- });
75
- electronProcess.on('close', (code) => {
76
- console.log(`Electron process exited with code ${code}`);
77
- if (code !== 0) {
78
- console.error('Electron process exited with an error.');
79
- }
80
- });
81
- }
82
58
  async function pack(callback) {
83
- console.log(path.resolve(__dirname, './dist', options.config));
84
59
  console.log(clc.blue('Building module...'));
85
60
  validateConfiguration();
86
61
  const configPath = path.resolve(__dirname, options.config);
87
- console.log("🚀 ~ pack ~ configPath:", configPath);
88
62
  try {
89
63
  const webpackConfig = (await import(configPath)).default(options);
90
- webpack(webpackConfig, function (err, stats) {
91
- if (err) {
92
- console.error('Build error:', err);
93
- if (err.details) {
94
- console.error('Details:', err.details);
95
- }
96
- if (err.errors) {
97
- console.error('TS Errors:', JSON.stringify(err.errors, null, 2));
98
- }
99
- throw err;
64
+ function handleWebpackError(err) {
65
+ console.error('Build error:', err);
66
+ if (err.details) {
67
+ console.error('Details:', err.details);
100
68
  }
101
- else {
102
- if (stats.hasErrors()) {
103
- const info = stats.toJson('errors-only');
104
- console.error(clc.red('Webpack errors:'));
105
- if (info.errors && info.errors.length) {
106
- info.errors.forEach((e) => {
107
- console.error(clc.red(typeof e === 'object' ? JSON.stringify(e, null, 2) : e));
108
- });
109
- }
110
- else {
111
- console.error(clc.red(JSON.stringify(info, null, 2)));
112
- }
113
- callback && callback(stats);
69
+ if (err.errors) {
70
+ console.error('TS Errors:', JSON.stringify(err.errors, null, 2));
71
+ }
72
+ throw err;
73
+ }
74
+ function handleWebpackStats(stats, callback) {
75
+ if (stats.hasErrors()) {
76
+ const info = stats.toJson('errors-only');
77
+ console.error(clc.red('Webpack errors:'));
78
+ if (info.errors?.length) {
79
+ info.errors.forEach((e) => {
80
+ console.error(clc.red(typeof e === 'object' ? JSON.stringify(e, null, 2) : e));
81
+ });
114
82
  }
115
83
  else {
116
- console.log(clc.green('Build OK.'));
117
- callback && callback(null);
84
+ console.error(clc.red(JSON.stringify(info, null, 2)));
118
85
  }
86
+ callback?.(stats);
87
+ }
88
+ else {
89
+ console.log(clc.green('Build OK.'));
90
+ callback?.(null);
91
+ }
92
+ }
93
+ webpack(webpackConfig, function (err, stats) {
94
+ if (err) {
95
+ handleWebpackError(err);
96
+ }
97
+ else {
98
+ handleWebpackStats(stats, callback);
119
99
  }
120
100
  });
121
101
  }
@@ -137,11 +117,11 @@ function installExternals(callback) {
137
117
  if (err)
138
118
  throw err;
139
119
  console.log(clc.green('Externals installed.'));
140
- callback && callback(null);
120
+ callback?.(null);
141
121
  });
142
122
  }
143
123
  else {
144
- callback && callback(null);
124
+ callback?.(null);
145
125
  }
146
126
  }
147
127
  function zip() {
@@ -162,10 +142,8 @@ function zip() {
162
142
  clc.move(-2, 0);
163
143
  }
164
144
  async function watch() {
165
- console.log('[VMP] ▸ starting dev-server & electron in watch mode…');
166
145
  const cfgPath = path.resolve(__dirname, '..', 'dist/webpack.config.js');
167
146
  const webpackConfigFactory = (await import(cfgPath)).default;
168
- console.log('[VMP] ▸ webpack config loaded from', cfgPath);
169
147
  const compiler = webpack(webpackConfigFactory(options));
170
148
  const server = new WebpackDevServer({
171
149
  static: false,
@@ -174,7 +152,6 @@ async function watch() {
174
152
  historyApiFallback: true
175
153
  }, compiler);
176
154
  await server.start();
177
- console.log(`[VMP] ▸ dev-server listening on http://localhost:${options.port}`);
178
155
  const cmd = [
179
156
  'npx', 'electron', electronPath,
180
157
  '--src', path.resolve(options.src),
@@ -184,14 +161,31 @@ async function watch() {
184
161
  '--config', options.config,
185
162
  '--externals', options.externals.join(',')
186
163
  ].join(' ');
187
- console.log(`[VMP] ▸ ${cmd}`);
188
- const child = exec(cmd, { cwd: __dirname, env: { ...process.env, NODE_ENV: 'development' } });
189
- child.stdout?.pipe(process.stdout);
190
- child.stderr?.pipe(process.stderr);
164
+ const child = exec(cmd, {
165
+ cwd: __dirname,
166
+ env: {
167
+ ...process.env,
168
+ NODE_ENV: 'development',
169
+ ELECTRON_DISABLE_SECURITY_WARNINGS: 'true',
170
+ NODE_NO_WARNINGS: '1'
171
+ }
172
+ });
173
+ // Filtrar logs no deseados
174
+ child.stdout?.on('data', (data) => {
175
+ const output = data.toString();
176
+ if (!shouldFilterLog(output)) {
177
+ process.stdout.write(output);
178
+ }
179
+ });
180
+ child.stderr?.on('data', (data) => {
181
+ const output = data.toString();
182
+ if (!shouldFilterLog(output)) {
183
+ process.stderr.write(output);
184
+ }
185
+ });
191
186
  }
192
187
  async function run() {
193
188
  await new Promise((resolve, reject) => pack((err) => (err ? reject(err) : resolve())));
194
- console.log('[VMP] ▸ building renderer…');
195
189
  const cfgPath = path.resolve(__dirname, '..', 'dist/webpack.config.js');
196
190
  const webpackConfigFactory = (await import(cfgPath)).default;
197
191
  const compiler = webpack(webpackConfigFactory(options));
@@ -202,8 +196,6 @@ async function run() {
202
196
  if (stats?.hasErrors()) {
203
197
  return reject(new Error(stats.toString({ all: false, errors: true, colors: true })));
204
198
  }
205
- console.log(stats?.toString({ colors: true, chunks: false, modules: false }) ??
206
- '[VMP] ▸ renderer built');
207
199
  compiler.close(closeErr => (closeErr ? reject(closeErr) : resolve()));
208
200
  });
209
201
  });
@@ -226,12 +218,30 @@ async function run() {
226
218
  ].join(' ');
227
219
  const child = exec(cmd, {
228
220
  cwd: __dirname,
229
- env: { ...process.env, NODE_ENV: 'production' },
221
+ env: {
222
+ ...process.env,
223
+ NODE_ENV: 'production',
224
+ // Suprimir warnings en producción también
225
+ ELECTRON_DISABLE_SECURITY_WARNINGS: 'true',
226
+ NODE_NO_WARNINGS: '1'
227
+ },
228
+ });
229
+ // Aplicar el mismo filtrado
230
+ child.stdout?.on('data', (data) => {
231
+ const output = data.toString();
232
+ if (!shouldFilterLog(output)) {
233
+ process.stdout.write(output);
234
+ }
235
+ });
236
+ child.stderr?.on('data', (data) => {
237
+ const output = data.toString();
238
+ if (!shouldFilterLog(output)) {
239
+ process.stderr.write(output);
240
+ }
230
241
  });
231
- child.stdout?.pipe(process.stdout);
232
- child.stderr?.pipe(process.stderr);
233
242
  }
234
- function loadConfiguration() {
243
+ async function loadConfiguration() {
244
+ const require = createRequire(import.meta.url);
235
245
  tsNode.register({
236
246
  compilerOptions: {
237
247
  moduleResolution: 'node',
@@ -240,11 +250,12 @@ function loadConfiguration() {
240
250
  checkJs: false
241
251
  }
242
252
  });
243
- return require(path.resolve(options.confDefinition, 'index.ts')).configuration;
253
+ const configPath = path.resolve(options.confDefinition, 'index.ts');
254
+ return require(configPath).configuration;
244
255
  }
245
- function generateConfiguration() {
256
+ async function generateConfiguration() {
246
257
  try {
247
- let configuration = loadConfiguration();
258
+ let configuration = await loadConfiguration();
248
259
  fs.writeFileSync(path.resolve(options.src, 'parameters.d.ts'), configuration.declarationFileString);
249
260
  fs.writeFileSync(path.resolve(options.src, '..', 'configuration.json'), JSON.stringify(configuration, undefined, 2));
250
261
  console.log(clc.green(`Configuration generated`));
@@ -273,3 +284,22 @@ function validateConfiguration() {
273
284
  throw e;
274
285
  }
275
286
  }
287
+ function shouldFilterLog(output) {
288
+ const filtersToRemove = [
289
+ "'session.getAllExtensions' is deprecated",
290
+ "DeprecationWarning: Compilation.assets will be frozen",
291
+ "BREAKING CHANGE: No more changes should happen to Compilation.assets",
292
+ "[DEP_WEBPACK_COMPILATION_ASSETS] DeprecationWarning",
293
+ "Compilation.assets will be frozen in future",
294
+ "Request Autofill.enable failed",
295
+ "Request Autofill.setAddresses failed",
296
+ "Uncaught (in promise) SyntaxError",
297
+ "wasn't found",
298
+ "asset main.js",
299
+ "runtime modules",
300
+ "orphan modules",
301
+ "cacheable modules",
302
+ "webpack compiled successfully"
303
+ ];
304
+ return filtersToRemove.some(filter => output.includes(filter));
305
+ }
package/package.json CHANGED
@@ -1,51 +1,7 @@
1
1
  {
2
- "_args": [
3
- [
4
- {
5
- "raw": "@vixoniccom/module-packager@^1.2.0",
6
- "scope": "@vixoniccom",
7
- "escapedName": "@vixoniccom%2fmodule-packager",
8
- "name": "@vixoniccom/module-packager",
9
- "rawSpec": "^1.2.0",
10
- "spec": ">=1.2.0 <2.0.0",
11
- "type": "range"
12
- }
13
- ]
14
- ],
15
- "_from": "@vixoniccom/module-packager@>=1.2.0 <2.0.0",
16
- "_inCache": true,
17
- "_location": "/@vixoniccom/module-packager",
18
- "_nodeVersion": "7.6.0",
19
- "_npmOperationalInternal": {
20
- "host": "packages-12-west.internal.npmjs.com",
21
- "tmp": "tmp/module-packager-1.2.0.tgz_1487918846893_0.5388180573936552"
22
- },
23
- "_npmUser": {
24
- "name": "vixonic",
25
- "email": "tdadone@vixonic.net"
26
- },
27
- "_npmVersion": "2.15.9",
28
- "_phantomChildren": {},
29
- "_requested": {
30
- "raw": "@vixoniccom/module-packager@^1.2.0",
31
- "scope": "@vixonic",
32
- "escapedName": "@vixonic%2fmodule-packager",
33
- "name": "@vixoniccom/module-packager",
34
- "rawSpec": "^1.2.0",
35
- "spec": ">=1.2.0 <2.0.0",
36
- "type": "range"
37
- },
38
- "_requiredBy": [
39
- "#DEV:/"
40
- ],
41
- "_resolved": "https://registry.npmjs.org/@vixoniccom/module-packager/-/module-packager-1.2.0.tgz",
42
- "_shasum": "9735f3bcbf2101d404d7bb058cb8337b0a87c503",
43
- "_shrinkwrap": null,
44
- "_spec": "@vixoniccom/module-packager@^1.2.0",
45
- "_where": "c:\\Development\\menuboard",
46
- "author": {
47
- "name": "tdadone"
48
- },
2
+ "name": "@vixoniccom/module-packager",
3
+ "version": "2.10.3-dev.7",
4
+ "type": "module",
49
5
  "bin": {
50
6
  "vixonic-module-packager": "./dist/main.js"
51
7
  },
@@ -53,9 +9,25 @@
53
9
  "dist",
54
10
  "index.html"
55
11
  ],
12
+ "main": "dist/main.js",
13
+ "scripts": {
14
+ "start": "electron dist/electron.js --mode run --build ./dist/build",
15
+ "clean": "rimraf dist",
16
+ "build:main": "tsc -p tsconfig.json --outDir dist",
17
+ "build:renderer": "webpack --config webpack.config.js --env src=./ --env build=./dist/build --mode production",
18
+ "copy:launcher": "cp launcher.html dist/launcher.html",
19
+ "build": "npm run clean && npm-run-all -p build:renderer build:main && npm run copy:launcher",
20
+ "watch:renderer": "webpack --config webpack.config.js --env src=./ --env build=./dist/build --mode=development --watch",
21
+ "watch:main": "tsc -p tsconfig.json --outDir dist --watch",
22
+ "dev:watch": "npm run clean && npm-run-all -p watch:renderer watch:main",
23
+ "prerelease-dev": "standard-version --prerelease dev",
24
+ "prerelease-rc": "standard-version --prerelease rc",
25
+ "prerelease-test": "standard-version --prerelease test",
26
+ "release": "standard-version"
27
+ },
56
28
  "dependencies": {
57
29
  "@electron/remote": "^2.1.2",
58
- "@vixoniccom/module-controller": "^2.0.0-dev.1",
30
+ "@vixoniccom/module-controller": "^2.0.0-dev.2",
59
31
  "@vixoniccom/modules": "^2.20.0",
60
32
  "archiver": "^5.3.0",
61
33
  "clean-webpack-plugin": "^4.0.0",
@@ -64,9 +36,8 @@
64
36
  "copy-webpack-plugin": "^13.0.0",
65
37
  "electron": "^36.1.0",
66
38
  "electron-debug": "^3.2.0",
67
- "file-loader": "^0.9.0",
68
39
  "global": "^4.4.0",
69
- "html-loader": "^0.4.5",
40
+ "html-loader": "^5.1.0",
70
41
  "html-webpack-plugin": "^4.5.2",
71
42
  "lodash": "^4.17.21",
72
43
  "process": "^0.11.10",
@@ -78,38 +49,6 @@
78
49
  "webpack-cli": "^6.0.1",
79
50
  "webpack-dev-server": "^5.2.1"
80
51
  },
81
- "directories": {},
82
- "dist": {
83
- "shasum": "9735f3bcbf2101d404d7bb058cb8337b0a87c503",
84
- "tarball": "https://registry.npmjs.org/@vixoniccom/module-packager/-/module-packager-1.2.0.tgz"
85
- },
86
- "main": "dist/main.js",
87
- "maintainers": [
88
- {
89
- "name": "vixonic",
90
- "email": "tdadone@vixonic.net"
91
- }
92
- ],
93
- "name": "@vixoniccom/module-packager",
94
- "readme": "ERROR: No README data found!",
95
- "scripts": {
96
- "start": "electron dist/electron.js --mode run --build ./dist/build",
97
- "clean": "rimraf dist",
98
- "build:main": "tsc -p tsconfig.json --outDir dist",
99
- "build:renderer": "webpack --config webpack.config.js --env src=./ --env build=./dist/build --mode production",
100
- "copy:launcher": "cp launcher.html dist/launcher.html",
101
- "build": "npm run clean && npm-run-all -p build:renderer build:main && npm run copy:launcher",
102
- "watch:renderer": "webpack --config webpack.config.js --env src=./ --env build=./dist/build --mode=development --watch",
103
- "watch:main": "tsc -p tsconfig.json --outDir dist --watch",
104
- "dev:watch": "npm run clean && npm-run-all -p watch:renderer watch:main",
105
- "prerelease-dev": "standard-version --prerelease dev",
106
- "prerelease-rc": "standard-version --prerelease rc",
107
- "prerelease-test": "standard-version --prerelease test",
108
- "release": "standard-version"
109
- },
110
- "type": "module",
111
- "version": "2.10.3-dev.5",
112
- "license": "ISC",
113
52
  "devDependencies": {
114
53
  "@types/archiver": "^6.0.3",
115
54
  "@types/cli-color": "^2.0.6",