@vixoniccom/module-packager 2.13.0 → 2.13.1-dev.1
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 +3 -6
- package/dist/launcher.html +0 -79
- package/dist/main.js +6 -2
- package/dist/scripts/preload.cjs +68 -0
- package/dist/scripts/webview-preload.cjs +15 -0
- package/package.json +3 -2
package/dist/electron.js
CHANGED
|
@@ -28,12 +28,9 @@ function createWindow() {
|
|
|
28
28
|
width: 1024,
|
|
29
29
|
height: 768,
|
|
30
30
|
webPreferences: {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
contextIsolation: false,
|
|
35
|
-
webSecurity: false,
|
|
36
|
-
webviewTag: true
|
|
31
|
+
webviewTag: true,
|
|
32
|
+
sandbox: false,
|
|
33
|
+
preload: path.join(__dirname, 'scripts', 'preload.cjs'),
|
|
37
34
|
}
|
|
38
35
|
});
|
|
39
36
|
remoteMain.enable(mainWindow.webContents);
|
package/dist/launcher.html
CHANGED
|
@@ -8,85 +8,6 @@
|
|
|
8
8
|
|
|
9
9
|
<body style="width: 100%; height: 100%; margin: 0; padding: 0;">
|
|
10
10
|
<div id="webview-container" style="width: 100%; height: 100%;"></div>
|
|
11
|
-
|
|
12
|
-
<script>
|
|
13
|
-
const path = require('path')
|
|
14
|
-
let ModuleController;
|
|
15
|
-
try {
|
|
16
|
-
const moduleControllerModule = require('@vixoniccom/module-controller');
|
|
17
|
-
ModuleController = moduleControllerModule.default;
|
|
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
|
-
const webview = document.createElement('webview')
|
|
26
|
-
webview.id = 'webview'
|
|
27
|
-
webview.style.width = '100%'
|
|
28
|
-
webview.style.height = '100%'
|
|
29
|
-
webview.setAttribute('partition', 'persist:webview')
|
|
30
|
-
|
|
31
|
-
webview.setAttribute('nodeintegration', '')
|
|
32
|
-
webview.setAttribute('webpreferences', 'webSecurity=false, allowRunningInsecureContent=true, nodeIntegration=yes, contextIsolation=no')
|
|
33
|
-
|
|
34
|
-
const win = remote.getCurrentWindow()
|
|
35
|
-
|
|
36
|
-
webview.addEventListener('did-finish-load', () => {
|
|
37
|
-
win.show()
|
|
38
|
-
win.focus()
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
const resolvedSrc = options.mode === 'watch'
|
|
42
|
-
? `http://localhost:${options.port}/index.html`
|
|
43
|
-
: `file://${path.join(options.build, 'index.html')}`
|
|
44
|
-
|
|
45
|
-
webview.src = resolvedSrc
|
|
46
|
-
|
|
47
|
-
document.getElementById('webview-container').appendChild(webview)
|
|
48
|
-
|
|
49
|
-
function getData() {
|
|
50
|
-
const data = {}
|
|
51
|
-
|
|
52
|
-
try {
|
|
53
|
-
data.parameters = require(path.join(options.src, 'test', 'parameters.json')).parameters
|
|
54
|
-
} catch (err) {
|
|
55
|
-
console.log('No parameters:', err.message)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
let escaped = path.join(options.mode === 'watch' ? options.src : options.build, 'test', 'downloads')
|
|
59
|
-
|
|
60
|
-
if (options.mode === 'watch') escaped = `file://${escaped}`
|
|
61
|
-
escaped = escaped.replace(/\\/g, '/')
|
|
62
|
-
|
|
63
|
-
data.downloadsPath = escaped
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
data.services = require(path.join(options.src, 'test','services.json')).services
|
|
68
|
-
} catch (err) {
|
|
69
|
-
console.log('No services:', err.message)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return data
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function getSchema() {
|
|
76
|
-
try {
|
|
77
|
-
return require(path.join(options.src, '../configuration.json')).schema
|
|
78
|
-
} catch (err) {
|
|
79
|
-
console.log('No schema:', err.message)
|
|
80
|
-
return {}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const data = getData()
|
|
85
|
-
const schema = getSchema()
|
|
86
|
-
|
|
87
|
-
ModuleController.init(win, webview, data, schema, options.mode === 'watch')
|
|
88
|
-
})
|
|
89
|
-
</script>
|
|
90
11
|
</body>
|
|
91
12
|
|
|
92
13
|
</html>
|
package/dist/main.js
CHANGED
|
@@ -194,10 +194,14 @@ async function pack(callback) {
|
|
|
194
194
|
function installExternals(callback) {
|
|
195
195
|
let externals = options.externals.map((x) => {
|
|
196
196
|
// Validar nombre del paquete
|
|
197
|
-
if (!/^[
|
|
197
|
+
if (!/^(?:@[a-z0-9-_.]+\/)?[a-z0-9-_.]+$/i.test(x)) {
|
|
198
198
|
throw new Error(`Invalid package name: ${x}`);
|
|
199
199
|
}
|
|
200
|
-
const
|
|
200
|
+
const nodeModulesBase = path.resolve(options.src, '..', 'node_modules');
|
|
201
|
+
const packageJsonPath = path.resolve(nodeModulesBase, x, 'package.json');
|
|
202
|
+
if (!packageJsonPath.startsWith(nodeModulesBase + path.sep)) {
|
|
203
|
+
throw new Error(`Invalid package path: path traversal detected for package ${x}`);
|
|
204
|
+
}
|
|
201
205
|
return `${x}@${JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')).version}`;
|
|
202
206
|
});
|
|
203
207
|
if (externals.length) {
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const { ipcRenderer } = require('electron');
|
|
5
|
+
const remote = require('@electron/remote');
|
|
6
|
+
let ModuleController;
|
|
7
|
+
try {
|
|
8
|
+
const m = require('@vixoniccom/module-controller');
|
|
9
|
+
ModuleController = m.default;
|
|
10
|
+
}
|
|
11
|
+
catch (err) {
|
|
12
|
+
console.error('[PRELOAD] No se pudo cargar ModuleController', err);
|
|
13
|
+
}
|
|
14
|
+
ipcRenderer.once('init', (_event, options) => {
|
|
15
|
+
const webview = document.createElement('webview');
|
|
16
|
+
webview.id = 'webview';
|
|
17
|
+
webview.style.width = '100%';
|
|
18
|
+
webview.style.height = '100%';
|
|
19
|
+
webview.setAttribute('partition', 'persist:webview');
|
|
20
|
+
webview.setAttribute('preload', `file://${path.join(__dirname, 'webview-preload.cjs')}`);
|
|
21
|
+
const win = remote.getCurrentWindow();
|
|
22
|
+
webview.addEventListener('did-finish-load', () => {
|
|
23
|
+
win.show();
|
|
24
|
+
win.focus();
|
|
25
|
+
if (options.mode === 'watch') {
|
|
26
|
+
webview.openDevTools();
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
const resolvedSrc = options.mode === 'watch'
|
|
30
|
+
? `http://localhost:${options.port}/index.html`
|
|
31
|
+
: `file://${path.join(options.build, 'index.html')}`;
|
|
32
|
+
webview.src = resolvedSrc;
|
|
33
|
+
const container = document.getElementById('webview-container');
|
|
34
|
+
if (!container) {
|
|
35
|
+
console.error('[PRELOAD] webview-container not found in DOM');
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
container.appendChild(webview);
|
|
39
|
+
function getData() {
|
|
40
|
+
const data = {};
|
|
41
|
+
try {
|
|
42
|
+
data.parameters = require(path.join(options.src, 'test', 'parameters.json')).parameters;
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
console.log('No parameters:', err.message);
|
|
46
|
+
}
|
|
47
|
+
let escaped = path.join(options.mode === 'watch' ? options.src : options.build, 'test', 'downloads');
|
|
48
|
+
if (options.mode === 'watch')
|
|
49
|
+
escaped = `file://${escaped}`;
|
|
50
|
+
data.downloadsPath = escaped.replaceAll('\\', '/');
|
|
51
|
+
try {
|
|
52
|
+
data.services = require(path.join(options.src, 'test', 'services.json')).services;
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
console.log('No services:', err.message);
|
|
56
|
+
}
|
|
57
|
+
return data;
|
|
58
|
+
}
|
|
59
|
+
function getSchema() {
|
|
60
|
+
try {
|
|
61
|
+
return require(path.join(options.src, '../configuration.json')).schema;
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return {};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
ModuleController?.init(win, webview, getData(), getSchema(), options.mode === 'watch');
|
|
68
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const electron_1 = require("electron");
|
|
4
|
+
electron_1.ipcRenderer.on('preload', (_event, data) => {
|
|
5
|
+
window.postMessage({ channel: 'preload', data }, location.origin);
|
|
6
|
+
});
|
|
7
|
+
electron_1.ipcRenderer.on('start', (_event, data) => {
|
|
8
|
+
window.postMessage({ channel: 'start', data }, location.origin);
|
|
9
|
+
});
|
|
10
|
+
electron_1.ipcRenderer.on('update', (_event, data) => {
|
|
11
|
+
window.postMessage({ channel: 'update', data }, location.origin);
|
|
12
|
+
});
|
|
13
|
+
electron_1.ipcRenderer.on('finish', () => {
|
|
14
|
+
window.postMessage({ channel: 'finish', data: null }, location.origin);
|
|
15
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vixoniccom/module-packager",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.1-dev.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"bin": {
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"build:main": "tsc -p tsconfig.json --outDir dist",
|
|
18
18
|
"build:renderer": "webpack --config webpack.config.js --env src=./ --env build=./dist/build --mode production",
|
|
19
19
|
"copy:launcher": "cpy launcher.html dist",
|
|
20
|
-
"build": "
|
|
20
|
+
"build:preload": "tsc -p tsconfig.preload.json --outDir dist",
|
|
21
|
+
"build": "npm run clean && npm-run-all -p build:renderer build:main build:preload && npm run copy:launcher",
|
|
21
22
|
"prerelease-dev": "standard-version --prerelease dev",
|
|
22
23
|
"prerelease-rc": "standard-version --prerelease rc",
|
|
23
24
|
"prerelease-test": "standard-version --prerelease test",
|