@vixoniccom/module-packager 2.12.0-dev.1 → 2.12.0-dev.10

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
@@ -12,7 +12,7 @@ const optionDefinitions = [
12
12
  { name: 'build', type: String, defaultValue: path.join(__dirname, 'build') },
13
13
  { name: 'config', type: String, defaultValue: './webpack.config.js' },
14
14
  { name: 'port', type: Number, defaultValue: 8080 },
15
- { name: 'mode', type: String, defaultValue: 'run' }
15
+ { name: 'mode', type: String, defaultValue: 'build' }
16
16
  ];
17
17
  const options = commandLineArgs(optionDefinitions);
18
18
  if (options.mode === 'watch') {
@@ -7,7 +7,8 @@
7
7
  </head>
8
8
 
9
9
  <body style="width: 100%; height: 100%; margin: 0; padding: 0;">
10
- <webview id="webview" style="width: 100%; height: 100%;" partition="persist:webview"></webview>
10
+ <!-- Remover el webview del HTML -->
11
+ <div id="webview-container" style="width: 100%; height: 100%;"></div>
11
12
 
12
13
  <script>
13
14
  const path = require('path')
@@ -22,11 +23,17 @@
22
23
  const remote = require('@electron/remote')
23
24
 
24
25
  ipcRenderer.on('init', (event, options) => {
25
- const webview = document.getElementById('webview')
26
- const win = remote.getCurrentWindow()
27
-
26
+ // Crear el webview dinámicamente
27
+ const webview = document.createElement('webview')
28
+ webview.id = 'webview'
29
+ webview.style.width = '100%'
30
+ webview.style.height = '100%'
31
+ webview.setAttribute('partition', 'persist:webview')
32
+
28
33
  webview.setAttribute('nodeintegration', '')
29
34
  webview.setAttribute('webpreferences', 'webSecurity=false, allowRunningInsecureContent=true, nodeIntegration=yes, contextIsolation=no')
35
+
36
+ const win = remote.getCurrentWindow()
30
37
 
31
38
  webview.addEventListener('did-finish-load', () => {
32
39
  win.show()
@@ -39,11 +46,14 @@
39
46
 
40
47
  webview.src = resolvedSrc
41
48
 
49
+ // Añadir el webview al DOM después de configurarlo
50
+ document.getElementById('webview-container').appendChild(webview)
51
+
42
52
  function getData() {
43
53
  const data = {}
44
54
 
45
55
  try {
46
- data.parameters = require(path.join(options.src, '/test/parameters.json')).parameters
56
+ data.parameters = require(path.join(options.src, 'test', 'parameters.json')).parameters
47
57
  } catch (err) {
48
58
  console.log('No parameters:', err.message)
49
59
  }
@@ -58,7 +68,7 @@
58
68
 
59
69
 
60
70
  try {
61
- data.services = require(path.join(options.src, '/test/services.json')).services
71
+ data.services = require(path.join(options.src, 'test','services.json')).services
62
72
  } catch (err) {
63
73
  console.log('No services:', err.message)
64
74
  }
package/dist/main.js CHANGED
@@ -16,7 +16,14 @@ import which from 'which';
16
16
  const __filename = fileURLToPath(import.meta.url);
17
17
  const __dirname = path.dirname(__filename);
18
18
  const electronPath = path.join(__dirname, 'electron.js');
19
- const npxPath = which.sync('npx');
19
+ let npxPath;
20
+ try {
21
+ npxPath = which.sync('npx');
22
+ }
23
+ catch (error) {
24
+ console.log(error);
25
+ console.error('Error: npx is not installed or not found in PATH.');
26
+ }
20
27
  const optionDefinitions = [
21
28
  { name: 'externals', type: String, defaultValue: [], multiple: true },
22
29
  { name: 'target', type: String, defaultValue: 'web' },
@@ -62,7 +69,7 @@ function createElectronArgs(mode) {
62
69
  '--port', String(options.port),
63
70
  '--mode', mode,
64
71
  '--config', options.config,
65
- '--externals', Array.isArray(options.externals) ? options.externals.join(',') : ''
72
+ ...options.externals.flatMap((pkg) => ['--externals', pkg])
66
73
  ];
67
74
  }
68
75
  // Función centralizada para manejar procesos Electron
@@ -77,7 +84,7 @@ function spawnElectronProcess(mode) {
77
84
  ELECTRON_DISABLE_SECURITY_WARNINGS: 'true',
78
85
  NODE_NO_WARNINGS: '1'
79
86
  },
80
- stdio: 'inherit'
87
+ stdio: ['inherit', 'pipe', 'pipe']
81
88
  });
82
89
  // Manejo centralizado de logs
83
90
  setupChildProcessLogging(child);
@@ -144,7 +151,6 @@ async function pack(callback) {
144
151
  console.log(clc.blue('Building module...'));
145
152
  validateConfiguration();
146
153
  const configPath = path.resolve(__dirname, options.config);
147
- console.log("🚀 ~ pack ~ configPath:", configPath);
148
154
  try {
149
155
  const webpackConfig = (await import(configPath)).default(options);
150
156
  function handleWebpackError(err) {
@@ -1,14 +1,10 @@
1
1
  import path from 'path';
2
- import { fileURLToPath } from 'url';
3
2
  import { createRequire } from 'module';
4
3
  import HtmlWebpackPlugin from 'html-webpack-plugin';
5
4
  import { CleanWebpackPlugin } from 'clean-webpack-plugin';
6
5
  import CopyWebpackPlugin from 'copy-webpack-plugin';
7
6
  import TerserPlugin from 'terser-webpack-plugin';
8
7
  import webpack from 'webpack';
9
- const __filename = fileURLToPath(import.meta.url);
10
- const __dirname = path.dirname(__filename);
11
- console.log("🚀 ~ __dirname:", __dirname);
12
8
  export default (env = {}, argv = {}) => {
13
9
  const require = createRequire(import.meta.url);
14
10
  const options = {
@@ -17,14 +13,17 @@ export default (env = {}, argv = {}) => {
17
13
  port: env.port ?? 8080,
18
14
  mode: argv.mode ?? 'production',
19
15
  };
20
- const isDev = options.mode === 'watch';
16
+ const isDev = options.mode === 'development' ||
17
+ argv.watch === true ||
18
+ process.env.NODE_ENV === 'development';
21
19
  const buildPath = path.resolve(options.build);
22
20
  const controllerHtmlPath = path.resolve(options.src, 'index.html');
23
21
  const controllerStaticPath = path.resolve(path.dirname(controllerHtmlPath), '../static');
24
22
  const controllerFontsPath = path.resolve(path.dirname(controllerHtmlPath), '../fonts');
23
+ const controllerTestPath = path.resolve(options.src, 'test');
25
24
  return {
26
25
  mode: isDev ? 'development' : 'production',
27
- target: 'electron-renderer',
26
+ target: options.target ?? 'electron-renderer',
28
27
  entry: isDev ? [
29
28
  `webpack-dev-server/client?http://localhost:${options.port}/`,
30
29
  'webpack/hot/dev-server',
@@ -35,6 +34,11 @@ export default (env = {}, argv = {}) => {
35
34
  filename: '[name].js',
36
35
  publicPath: isDev ? '/' : './'
37
36
  },
37
+ performance: {
38
+ maxAssetSize: 2000000, //2MB
39
+ maxEntrypointSize: 2000000,
40
+ hints: isDev ? false : 'warning'
41
+ },
38
42
  externals: {
39
43
  electron: 'commonjs electron',
40
44
  '@vixoniccom/module-controller': 'commonjs @vixoniccom/module-controller',
@@ -110,12 +114,13 @@ export default (env = {}, argv = {}) => {
110
114
  new CopyWebpackPlugin({
111
115
  patterns: [
112
116
  { from: controllerStaticPath, to: 'static', noErrorOnMissing: true },
113
- { from: controllerFontsPath, to: 'fonts', noErrorOnMissing: true }
117
+ { from: controllerFontsPath, to: 'fonts', noErrorOnMissing: true },
118
+ { from: controllerTestPath, to: 'test', noErrorOnMissing: true }
114
119
  ]
115
120
  })
116
121
  ],
117
- optimization: isDev ? undefined : {
118
- minimize: false,
122
+ optimization: {
123
+ minimize: !isDev,
119
124
  minimizer: [
120
125
  new TerserPlugin({
121
126
  minify: TerserPlugin.terserMinify,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vixoniccom/module-packager",
3
- "version": "2.12.0-dev.1",
3
+ "version": "2.12.0-dev.10",
4
4
  "type": "module",
5
5
  "license": "ISC",
6
6
  "bin": {
@@ -15,7 +15,7 @@
15
15
  "clean": "rimraf dist",
16
16
  "build:main": "tsc -p tsconfig.json --outDir dist",
17
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",
18
+ "copy:launcher": "cpy launcher.html dist",
19
19
  "build": "npm run clean && npm-run-all -p build:renderer build:main && npm run copy:launcher",
20
20
  "prerelease-dev": "standard-version --prerelease dev",
21
21
  "prerelease-rc": "standard-version --prerelease rc",
@@ -32,6 +32,7 @@
32
32
  "cli-color": "^1.2.0",
33
33
  "command-line-args": "^3.0.1",
34
34
  "copy-webpack-plugin": "^13.0.0",
35
+ "cpy-cli": "^5.0.0",
35
36
  "css-loader": "^7.1.2",
36
37
  "electron": "^36.1.0",
37
38
  "electron-debug": "^3.2.0",
@@ -40,7 +41,8 @@
40
41
  "html-webpack-plugin": "^4.5.2",
41
42
  "lodash": "^4.17.21",
42
43
  "process": "^0.11.10",
43
- "raw-loader": "^0.5.1",
44
+ "raw-loader": "^4.0.2",
45
+ "rimraf": "^6.0.1",
44
46
  "style-loader": "^4.0.0",
45
47
  "ts-loader": "^9.5.0",
46
48
  "ts-node": "^10.9.1",