@vixoniccom/module-packager 2.14.1-dev.5 → 2.14.2-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 +2 -6
- package/dist/launcher.html +0 -79
- package/dist/scripts/preload.js +59 -0
- package/dist/scripts/webview-preload.js +13 -0
- package/package.json +2 -2
package/dist/electron.js
CHANGED
|
@@ -28,12 +28,8 @@ function createWindow() {
|
|
|
28
28
|
width: 1024,
|
|
29
29
|
height: 768,
|
|
30
30
|
webPreferences: {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
nodeIntegration: true,
|
|
34
|
-
contextIsolation: false,
|
|
35
|
-
webSecurity: false,
|
|
36
|
-
webviewTag: true
|
|
31
|
+
webviewTag: true,
|
|
32
|
+
preload: path.join(__dirname, 'scripts', 'preload.js'),
|
|
37
33
|
}
|
|
38
34
|
});
|
|
39
35
|
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>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// preload.ts
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { ipcRenderer } from 'electron';
|
|
4
|
+
import remote from '@electron/remote';
|
|
5
|
+
let ModuleController;
|
|
6
|
+
try {
|
|
7
|
+
const m = require('@vixoniccom/module-controller');
|
|
8
|
+
ModuleController = m.default;
|
|
9
|
+
}
|
|
10
|
+
catch (err) {
|
|
11
|
+
console.error('[PRELOAD] No se pudo cargar ModuleController', err);
|
|
12
|
+
}
|
|
13
|
+
ipcRenderer.on('init', (_event, options) => {
|
|
14
|
+
const webview = document.createElement('webview');
|
|
15
|
+
webview.id = 'webview';
|
|
16
|
+
webview.style.width = '100%';
|
|
17
|
+
webview.style.height = '100%';
|
|
18
|
+
webview.setAttribute('partition', 'persist:webview');
|
|
19
|
+
webview.setAttribute('preload', `file://${path.join(__dirname, 'webview-preload.js')}`);
|
|
20
|
+
const win = remote.getCurrentWindow();
|
|
21
|
+
webview.addEventListener('did-finish-load', () => {
|
|
22
|
+
win.show();
|
|
23
|
+
win.focus();
|
|
24
|
+
});
|
|
25
|
+
const resolvedSrc = options.mode === 'watch'
|
|
26
|
+
? `http://localhost:${options.port}/index.html`
|
|
27
|
+
: `file://${path.join(options.build, 'index.html')}`;
|
|
28
|
+
webview.src = resolvedSrc;
|
|
29
|
+
document.getElementById('webview-container')?.appendChild(webview);
|
|
30
|
+
function getData() {
|
|
31
|
+
const data = {};
|
|
32
|
+
try {
|
|
33
|
+
data.parameters = require(path.join(options.src, 'test', 'parameters.json')).parameters;
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
console.log('No parameters:', err.message);
|
|
37
|
+
}
|
|
38
|
+
let escaped = path.join(options.mode === 'watch' ? options.src : options.build, 'test', 'downloads');
|
|
39
|
+
if (options.mode === 'watch')
|
|
40
|
+
escaped = `file://${escaped}`;
|
|
41
|
+
data.downloadsPath = escaped.replace(/\\/g, '/');
|
|
42
|
+
try {
|
|
43
|
+
data.services = require(path.join(options.src, 'test', 'services.json')).services;
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
console.log('No services:', err.message);
|
|
47
|
+
}
|
|
48
|
+
return data;
|
|
49
|
+
}
|
|
50
|
+
function getSchema() {
|
|
51
|
+
try {
|
|
52
|
+
return require(path.join(options.src, '../configuration.json')).schema;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return {};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
ModuleController?.init(win, webview, getData(), getSchema(), options.mode === 'watch');
|
|
59
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ipcRenderer } from 'electron';
|
|
2
|
+
ipcRenderer.on('preload', (_event, data) => {
|
|
3
|
+
window.postMessage({ channel: 'preload', data }, location.origin);
|
|
4
|
+
});
|
|
5
|
+
ipcRenderer.on('start', (_event, data) => {
|
|
6
|
+
window.postMessage({ channel: 'start', data }, location.origin);
|
|
7
|
+
});
|
|
8
|
+
ipcRenderer.on('update', (_event, data) => {
|
|
9
|
+
window.postMessage({ channel: 'update', data }, location.origin);
|
|
10
|
+
});
|
|
11
|
+
ipcRenderer.on('finish', () => {
|
|
12
|
+
window.postMessage({ channel: 'finish', data: null }, location.origin);
|
|
13
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vixoniccom/module-packager",
|
|
3
|
-
"version": "2.14.
|
|
3
|
+
"version": "2.14.2-dev.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"bin": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@electron/remote": "^2.1.2",
|
|
28
28
|
"@types/which": "^3.0.4",
|
|
29
29
|
"@vixoniccom/module-controller": "2.0.1-dev.2",
|
|
30
|
-
"@vixoniccom/modules": "
|
|
30
|
+
"@vixoniccom/modules": "2.26.0-dev.1",
|
|
31
31
|
"archiver": "^5.3.0",
|
|
32
32
|
"clean-webpack-plugin": "^4.0.0",
|
|
33
33
|
"cli-color": "^1.2.0",
|