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