@vixoniccom/module-packager 2.10.2-test.6 → 2.10.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 +10 -13
- package/dist/launcher.html +98 -0
- package/dist/main.js +15 -9
- package/dist/webpack.config.js +28 -9
- package/package.json +14 -13
- package/dist/build/371.bundle.js +0 -433
- package/dist/build/676.bundle.js +0 -693
- package/dist/build/index.html +0 -73
- package/dist/build/main.bundle.js +0 -419359
- package/index.html +0 -88
package/dist/electron.js
CHANGED
|
@@ -4,7 +4,6 @@ import remoteMain from '@electron/remote/main/index.js';
|
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
6
6
|
import commandLineArgs from 'command-line-args';
|
|
7
|
-
import fs from 'fs';
|
|
8
7
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
8
|
const __dirname = path.dirname(__filename);
|
|
10
9
|
const optionDefinitions = [
|
|
@@ -16,14 +15,12 @@ const optionDefinitions = [
|
|
|
16
15
|
{ name: 'mode', type: String, defaultValue: 'run' }
|
|
17
16
|
];
|
|
18
17
|
const options = commandLineArgs(optionDefinitions);
|
|
19
|
-
console.log('🚀 [ELECTRON] options:', options);
|
|
20
18
|
if (options.mode === 'watch') {
|
|
21
19
|
(await import('electron-debug')).default({ showDevTools: true });
|
|
22
20
|
}
|
|
23
21
|
remoteMain.initialize();
|
|
24
22
|
let mainWindow = null;
|
|
25
23
|
function createWindow() {
|
|
26
|
-
console.log('[ELECTRON] Creating BrowserWindow…');
|
|
27
24
|
mainWindow = new BrowserWindow({
|
|
28
25
|
show: false,
|
|
29
26
|
x: 100,
|
|
@@ -31,7 +28,6 @@ function createWindow() {
|
|
|
31
28
|
width: 1024,
|
|
32
29
|
height: 768,
|
|
33
30
|
webPreferences: {
|
|
34
|
-
preload: path.join(__dirname, 'preload.js'),
|
|
35
31
|
nodeIntegrationInSubFrames: true,
|
|
36
32
|
nodeIntegration: true,
|
|
37
33
|
contextIsolation: false,
|
|
@@ -40,21 +36,22 @@ function createWindow() {
|
|
|
40
36
|
}
|
|
41
37
|
});
|
|
42
38
|
remoteMain.enable(mainWindow.webContents);
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
39
|
+
const launcherPath = path.join(__dirname, 'launcher.html');
|
|
40
|
+
const launcherURL = `file://${launcherPath}`;
|
|
41
|
+
// const devUrl = `http://localhost:${options.port}/index.html`;
|
|
42
|
+
// const fileUrl = `file://${path.join(options.build, 'index.html')}`;
|
|
43
|
+
console.log('🚀 cargando launcher:', launcherURL);
|
|
44
|
+
mainWindow.loadURL(launcherURL);
|
|
45
|
+
// const url = options.mode === 'watch' ? devUrl : fileUrl;
|
|
46
|
+
// console.log("🚀 ~ createWindow ~ url:", url)
|
|
47
|
+
mainWindow.webContents.openDevTools({ mode: 'detach' });
|
|
48
|
+
// mainWindow.loadURL(url);
|
|
51
49
|
mainWindow.webContents.once('did-finish-load', () => {
|
|
52
50
|
console.log('[ELECTRON] did-finish-load → show()');
|
|
53
51
|
mainWindow?.show();
|
|
54
52
|
mainWindow?.webContents.send('init', options);
|
|
55
53
|
});
|
|
56
54
|
mainWindow.on('closed', () => (mainWindow = null));
|
|
57
|
-
// mainWindow.webContents.openDevTools({ mode: 'detach' });
|
|
58
55
|
}
|
|
59
56
|
app.whenReady().then(() => {
|
|
60
57
|
console.log('[ELECTRON] App is ready');
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html style="width: 100%; height: 100%; margin: 0; padding: 0;">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8" />
|
|
6
|
+
<title></title>
|
|
7
|
+
</head>
|
|
8
|
+
|
|
9
|
+
<body style="width: 100%; height: 100%; margin: 0; padding: 0;">
|
|
10
|
+
<webview id="webview" style="width: 100%; height: 100%;" partition="persist:webview"></webview>
|
|
11
|
+
|
|
12
|
+
<script>
|
|
13
|
+
const path = require('path')
|
|
14
|
+
let ModuleController;
|
|
15
|
+
try {
|
|
16
|
+
ModuleController = require('@vixoniccom/module-controller');
|
|
17
|
+
console.log('[WEBVIEW] ModuleController cargado OK');
|
|
18
|
+
} catch (err) {
|
|
19
|
+
console.error('[WEBVIEW] NO se pudo cargar ModuleController', err);
|
|
20
|
+
}
|
|
21
|
+
const { ipcRenderer } = require('electron')
|
|
22
|
+
const remote = require('@electron/remote')
|
|
23
|
+
|
|
24
|
+
ipcRenderer.on('init', (event, options) => {
|
|
25
|
+
console.log('[WEBVIEW] init', options)
|
|
26
|
+
|
|
27
|
+
const webview = document.getElementById('webview')
|
|
28
|
+
const win = remote.getCurrentWindow()
|
|
29
|
+
|
|
30
|
+
webview.setAttribute('nodeintegration', '')
|
|
31
|
+
webview.setAttribute('webpreferences', 'contextIsolation=no, nodeIntegration=yes')
|
|
32
|
+
|
|
33
|
+
webview.addEventListener('dom-ready', () => {
|
|
34
|
+
webview.openDevTools() // opcional
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
webview.addEventListener('did-finish-load', () => {
|
|
38
|
+
console.log('[WEBVIEW] did-finish-load fired')
|
|
39
|
+
win.show()
|
|
40
|
+
win.focus()
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
webview.addEventListener('did-fail-load', (e) => {
|
|
44
|
+
console.error('[WEBVIEW] did-fail-load', e)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
const resolvedSrc = options.mode === 'watch'
|
|
48
|
+
? `http://localhost:${options.port}/index.html`
|
|
49
|
+
: `file://${path.join(options.build, 'index.html')}`
|
|
50
|
+
|
|
51
|
+
console.log('[WEBVIEW] Resolved src:', resolvedSrc)
|
|
52
|
+
|
|
53
|
+
webview.src = resolvedSrc
|
|
54
|
+
|
|
55
|
+
function getData() {
|
|
56
|
+
const data = {}
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
data.parameters = require(path.join(options.src, '/test/parameters.json')).parameters
|
|
60
|
+
} catch (err) {
|
|
61
|
+
console.log('No parameters:', err.message)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let escaped = path.join(options.mode === 'watch' ? options.src : options.build, 'test', 'downloads')
|
|
65
|
+
if (options.mode === 'watch') escaped = `file://${escaped}`
|
|
66
|
+
escaped = escaped.replace(/\\/g, '/')
|
|
67
|
+
data.downloadsPath = escaped
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
data.services = require(path.join(options.src, '/test/services.json')).services
|
|
71
|
+
} catch (err) {
|
|
72
|
+
console.log('No services:', err.message)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return data
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function getSchema() {
|
|
79
|
+
try {
|
|
80
|
+
return require(path.join(options.src, '../configuration.json')).schema
|
|
81
|
+
} catch (err) {
|
|
82
|
+
console.log('No schema:', err.message)
|
|
83
|
+
return {}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const data = getData()
|
|
88
|
+
const schema = getSchema()
|
|
89
|
+
|
|
90
|
+
console.log('[WEBVIEW] Data entregada a ModuleController:', data)
|
|
91
|
+
console.log('[WEBVIEW] Schema entregado a ModuleController:', schema)
|
|
92
|
+
|
|
93
|
+
ModuleController.init(win, webview, data, schema, options.mode === 'watch')
|
|
94
|
+
})
|
|
95
|
+
</script>
|
|
96
|
+
</body>
|
|
97
|
+
|
|
98
|
+
</html>
|
package/dist/main.js
CHANGED
|
@@ -80,9 +80,11 @@ function runElectron() {
|
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
async function pack(callback) {
|
|
83
|
+
console.log(path.resolve(__dirname, './dist', options.config));
|
|
83
84
|
console.log(clc.blue('Building module...'));
|
|
84
85
|
validateConfiguration();
|
|
85
|
-
const configPath = path.resolve(__dirname,
|
|
86
|
+
const configPath = path.resolve(__dirname, options.config);
|
|
87
|
+
console.log("🚀 ~ pack ~ configPath:", configPath);
|
|
86
88
|
try {
|
|
87
89
|
const webpackConfig = (await import(configPath)).default(options);
|
|
88
90
|
webpack(webpackConfig, function (err, stats) {
|
|
@@ -144,6 +146,8 @@ function installExternals(callback) {
|
|
|
144
146
|
}
|
|
145
147
|
function zip() {
|
|
146
148
|
console.log(clc.blue('Archiving...'));
|
|
149
|
+
console.log(clc.blue('Cleaning build...'));
|
|
150
|
+
console.log("[DEBUG] Cleaning build folder", path.resolve(options.build, '../', 'build.zip'));
|
|
147
151
|
let output = fs.createWriteStream(path.resolve(options.build, '../', 'build.zip'));
|
|
148
152
|
let archive = archiver('zip');
|
|
149
153
|
archive.pipe(output);
|
|
@@ -159,15 +163,18 @@ function zip() {
|
|
|
159
163
|
}
|
|
160
164
|
async function watch() {
|
|
161
165
|
console.log('[VMP] ▸ starting dev-server & electron in watch mode…');
|
|
162
|
-
|
|
163
|
-
const cfgPath = path.resolve(__dirname, '..', 'webpack.config.js');
|
|
166
|
+
const cfgPath = path.resolve(__dirname, '..', 'dist/webpack.config.js');
|
|
164
167
|
const webpackConfigFactory = (await import(cfgPath)).default;
|
|
165
|
-
|
|
168
|
+
console.log('[VMP] ▸ webpack config loaded from', cfgPath);
|
|
166
169
|
const compiler = webpack(webpackConfigFactory(options));
|
|
167
|
-
const server = new WebpackDevServer({
|
|
170
|
+
const server = new WebpackDevServer({
|
|
171
|
+
static: false,
|
|
172
|
+
port: options.port,
|
|
173
|
+
devMiddleware: { publicPath: '/' },
|
|
174
|
+
historyApiFallback: true
|
|
175
|
+
}, compiler);
|
|
168
176
|
await server.start();
|
|
169
177
|
console.log(`[VMP] ▸ dev-server listening on http://localhost:${options.port}`);
|
|
170
|
-
// 3 Lanza Electron con npx (igual que antes)
|
|
171
178
|
const cmd = [
|
|
172
179
|
'npx', 'electron', electronPath,
|
|
173
180
|
'--src', path.resolve(options.src),
|
|
@@ -179,7 +186,6 @@ async function watch() {
|
|
|
179
186
|
].join(' ');
|
|
180
187
|
console.log(`[VMP] ▸ ${cmd}`);
|
|
181
188
|
const child = exec(cmd, { cwd: __dirname, env: { ...process.env, NODE_ENV: 'development' } });
|
|
182
|
-
// redirige STDOUT/STDERR a la consola del packager
|
|
183
189
|
child.stdout?.pipe(process.stdout);
|
|
184
190
|
child.stderr?.pipe(process.stderr);
|
|
185
191
|
}
|
|
@@ -219,11 +225,11 @@ function generateConfiguration() {
|
|
|
219
225
|
function validateConfiguration() {
|
|
220
226
|
try {
|
|
221
227
|
const jsonPath = path.resolve(options.src, '../', 'configuration.json');
|
|
222
|
-
const json = JSON.parse(fs.readFileSync(jsonPath, 'utf8'));
|
|
228
|
+
const json = JSON.parse(fs.readFileSync(jsonPath, 'utf8'));
|
|
223
229
|
const conf = Configuration.fromJSON(json);
|
|
224
230
|
if (conf.durationFormula) {
|
|
225
231
|
const valuesPath = path.resolve(options.src, 'test', 'parameters.json');
|
|
226
|
-
const values = JSON.parse(fs.readFileSync(valuesPath, 'utf8'));
|
|
232
|
+
const values = JSON.parse(fs.readFileSync(valuesPath, 'utf8'));
|
|
227
233
|
console.log('Validate duration');
|
|
228
234
|
console.log('Duration on undefined:', conf.getDuration({}), 'seconds');
|
|
229
235
|
console.log('Duration:', conf.getDuration(values.parameters), 'seconds');
|
package/dist/webpack.config.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
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';
|
|
8
|
+
import webpack from 'webpack';
|
|
7
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
-
const __dirname = path.dirname(__filename)
|
|
10
|
+
// const __dirname = path.dirname(__filename)
|
|
9
11
|
export default (env = {}, argv = {}) => {
|
|
12
|
+
const require = createRequire(import.meta.url);
|
|
10
13
|
const options = {
|
|
11
14
|
src: env.src ?? './src',
|
|
12
15
|
build: env.build ?? './build',
|
|
@@ -29,6 +32,7 @@ export default (env = {}, argv = {}) => {
|
|
|
29
32
|
publicPath: '/'
|
|
30
33
|
},
|
|
31
34
|
externals: {
|
|
35
|
+
electron: 'commonjs electron',
|
|
32
36
|
'@vixoniccom/module-controller': 'commonjs @vixoniccom/module-controller',
|
|
33
37
|
webpack: 'commonjs webpack',
|
|
34
38
|
'terser-webpack-plugin': 'commonjs terser-webpack-plugin',
|
|
@@ -40,10 +44,11 @@ export default (env = {}, argv = {}) => {
|
|
|
40
44
|
extensions: ['.tsx', '.ts', '.js', '.jsx', '.mjs'],
|
|
41
45
|
mainFields: ['module', 'browser', 'main'],
|
|
42
46
|
fullySpecified: false,
|
|
43
|
-
|
|
44
|
-
'
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
fallback: {
|
|
48
|
+
process: require.resolve('process/browser.js'),
|
|
49
|
+
global: require.resolve('global')
|
|
50
|
+
},
|
|
51
|
+
modules: ['node_modules']
|
|
47
52
|
},
|
|
48
53
|
module: {
|
|
49
54
|
rules: [
|
|
@@ -91,10 +96,26 @@ export default (env = {}, argv = {}) => {
|
|
|
91
96
|
sources: false,
|
|
92
97
|
}
|
|
93
98
|
}
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
test: /\.(ts|tsx)$/,
|
|
102
|
+
exclude: /node_modules/,
|
|
103
|
+
use: {
|
|
104
|
+
loader: 'ts-loader',
|
|
105
|
+
options: {
|
|
106
|
+
transpileOnly: true
|
|
107
|
+
}
|
|
108
|
+
}
|
|
94
109
|
}
|
|
95
110
|
]
|
|
96
111
|
},
|
|
97
112
|
plugins: [
|
|
113
|
+
new webpack.DefinePlugin({
|
|
114
|
+
global: 'globalThis'
|
|
115
|
+
}),
|
|
116
|
+
new webpack.ProvidePlugin({
|
|
117
|
+
process: 'process/browser.js'
|
|
118
|
+
}),
|
|
98
119
|
new CleanWebpackPlugin(),
|
|
99
120
|
new HtmlWebpackPlugin({
|
|
100
121
|
template: controllerHtmlPath,
|
|
@@ -123,11 +144,9 @@ export default (env = {}, argv = {}) => {
|
|
|
123
144
|
})
|
|
124
145
|
]
|
|
125
146
|
},
|
|
126
|
-
devtool: isDev ? '
|
|
147
|
+
devtool: isDev ? 'eval' : false,
|
|
127
148
|
devServer: isDev ? {
|
|
128
|
-
static:
|
|
129
|
-
directory: path.resolve(options.src)
|
|
130
|
-
},
|
|
149
|
+
static: false,
|
|
131
150
|
open: false,
|
|
132
151
|
client: {
|
|
133
152
|
overlay: true
|
package/package.json
CHANGED
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
],
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@electron/remote": "^2.1.2",
|
|
59
|
-
"@vixoniccom/module-controller": "
|
|
59
|
+
"@vixoniccom/module-controller": "2.0.0-dev.0",
|
|
60
60
|
"@vixoniccom/modules": "^2.20.0",
|
|
61
61
|
"archiver": "^5.3.0",
|
|
62
62
|
"clean-webpack-plugin": "^4.0.0",
|
|
@@ -66,13 +66,18 @@
|
|
|
66
66
|
"electron": "^36.1.0",
|
|
67
67
|
"electron-debug": "^3.2.0",
|
|
68
68
|
"file-loader": "^0.9.0",
|
|
69
|
+
"global": "^4.4.0",
|
|
69
70
|
"html-loader": "^0.4.5",
|
|
70
71
|
"html-webpack-plugin": "^4.5.2",
|
|
71
72
|
"lodash": "^4.17.21",
|
|
73
|
+
"process": "^0.11.10",
|
|
72
74
|
"raw-loader": "^0.5.1",
|
|
73
75
|
"ts-loader": "^9.5.0",
|
|
74
76
|
"ts-node": "^10.9.1",
|
|
75
|
-
"typescript": "^5.8.3"
|
|
77
|
+
"typescript": "^5.8.3",
|
|
78
|
+
"webpack": "^5.99.8",
|
|
79
|
+
"webpack-cli": "^6.0.1",
|
|
80
|
+
"webpack-dev-server": "^5.2.1"
|
|
76
81
|
},
|
|
77
82
|
"directories": {},
|
|
78
83
|
"dist": {
|
|
@@ -90,19 +95,18 @@
|
|
|
90
95
|
"readme": "ERROR: No README data found!",
|
|
91
96
|
"scripts": {
|
|
92
97
|
"start": "electron dist/electron.js --mode run --build ./dist/build",
|
|
93
|
-
"
|
|
94
|
-
"build:main": "tsc -p tsconfig.json",
|
|
95
|
-
"build": "
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"dev": "npm-run-all -p dev:renderer dev:electron",
|
|
98
|
+
"clean": "rimraf dist",
|
|
99
|
+
"build:main": "tsc -p tsconfig.json --outDir dist",
|
|
100
|
+
"build:renderer": "webpack --config webpack.config.js --env src=./ --env build=./dist/build --mode production",
|
|
101
|
+
"copy:launcher": "cp launcher.html dist/launcher.html",
|
|
102
|
+
"build": "npm run clean && npm-run-all -p build:renderer build:main && npm run copy:launcher",
|
|
99
103
|
"prerelease-dev": "standard-version --prerelease dev",
|
|
100
104
|
"prerelease-rc": "standard-version --prerelease rc",
|
|
101
105
|
"prerelease-test": "standard-version --prerelease test",
|
|
102
106
|
"release": "standard-version"
|
|
103
107
|
},
|
|
104
108
|
"type": "module",
|
|
105
|
-
"version": "2.10.2
|
|
109
|
+
"version": "2.10.2",
|
|
106
110
|
"license": "ISC",
|
|
107
111
|
"devDependencies": {
|
|
108
112
|
"@types/archiver": "^6.0.3",
|
|
@@ -116,9 +120,6 @@
|
|
|
116
120
|
"sass-loader": "^16.0.5",
|
|
117
121
|
"standard-version": "^9.3.1",
|
|
118
122
|
"style-loader": "^4.0.0",
|
|
119
|
-
"wait-on": "^8.0.3"
|
|
120
|
-
"webpack": "^5.99.8",
|
|
121
|
-
"webpack-cli": "^6.0.1",
|
|
122
|
-
"webpack-dev-server": "^5.2.1"
|
|
123
|
+
"wait-on": "^8.0.3"
|
|
123
124
|
}
|
|
124
125
|
}
|