forked from LeenkxTeam/LNXSDK
Update Files
This commit is contained in:
58
Kha/Tools/khamake/Data/debug-html5/electron.js
Normal file
58
Kha/Tools/khamake/Data/debug-html5/electron.js
Normal file
@ -0,0 +1,58 @@
|
||||
'use strict';
|
||||
|
||||
const electron = require('electron');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const app = electron.app;
|
||||
const BrowserWindow = electron.BrowserWindow;
|
||||
|
||||
var mainWindow = null;
|
||||
|
||||
electron.ipcMain.on('show-window', (event, arg) => {
|
||||
if (arg.width && arg.height) mainWindow.setContentSize(arg.width, arg.height);
|
||||
if (arg.title) mainWindow.setTitle(arg.title);
|
||||
if (arg.x != -1 && arg.y != -1) {
|
||||
mainWindow.setPosition(arg.x, arg.y);
|
||||
}
|
||||
else {
|
||||
mainWindow.center();
|
||||
}
|
||||
mainWindow.show();
|
||||
});
|
||||
|
||||
electron.ipcMain.on('load-blob', (event, arg) => {
|
||||
let url = null;
|
||||
if (path.isAbsolute(arg.file)) {
|
||||
url = arg.file;
|
||||
}
|
||||
else {
|
||||
url = path.join(__dirname, arg.file);
|
||||
}
|
||||
try {
|
||||
const data = fs.readFileSync(url);
|
||||
mainWindow.webContents.send('blob-loaded', {id: arg.id, data: data});
|
||||
}
|
||||
catch (err) {
|
||||
mainWindow.webContents.send('blob-failed', {id: arg.id, url: url, error: err});
|
||||
}
|
||||
});
|
||||
|
||||
app.on('window-all-closed', function () {
|
||||
app.quit();
|
||||
});
|
||||
|
||||
app.on('ready', function () {
|
||||
mainWindow = new BrowserWindow({
|
||||
width: {Width}, height: {Height},
|
||||
show: false, useContentSize: true, autoHideMenuBar: true,
|
||||
icon: app.getAppPath() + '/favicon' + {ext},
|
||||
webPreferences: {
|
||||
contextIsolation: true,
|
||||
preload: path.join(app.getAppPath(), 'preload.js')
|
||||
}
|
||||
});
|
||||
mainWindow.loadURL('file://' + app.getAppPath() + '/index.html');
|
||||
mainWindow.on('closed', function() {
|
||||
mainWindow = null;
|
||||
});
|
||||
});
|
26
Kha/Tools/khamake/Data/debug-html5/index.html
Normal file
26
Kha/Tools/khamake/Data/debug-html5/index.html
Normal file
@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Content-Security-Policy" content="script-src 'self' {UnsafeEval};">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
|
||||
<title>{Name}</title>
|
||||
<style>
|
||||
html, body, canvas, div {
|
||||
margin:0;
|
||||
padding: 0;
|
||||
width:100%;
|
||||
height:100%;
|
||||
}
|
||||
#khanvas {
|
||||
display:block;
|
||||
border:none;
|
||||
outline:none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="khanvas" width="0" height="0" tabindex="-1"></canvas>
|
||||
<script src="kha.js"></script>
|
||||
</body>
|
||||
</html>
|
5
Kha/Tools/khamake/Data/debug-html5/package.json
Normal file
5
Kha/Tools/khamake/Data/debug-html5/package.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"name" : "kodestudio-debug",
|
||||
"version" : "0.1.0",
|
||||
"main" : "electron.js"
|
||||
}
|
48
Kha/Tools/khamake/Data/debug-html5/preload.js
Normal file
48
Kha/Tools/khamake/Data/debug-html5/preload.js
Normal file
@ -0,0 +1,48 @@
|
||||
const electron = require('electron');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
let blobId = 0;
|
||||
let blobRequests = {};
|
||||
|
||||
electron.ipcRenderer.on('blob-loaded', (event, args) => {
|
||||
const blobRequest = blobRequests[args.id];
|
||||
delete blobRequests[args.id];
|
||||
blobRequest.done(new Uint8Array(args.data));
|
||||
});
|
||||
|
||||
electron.ipcRenderer.on('blob-failed', (event, args) => {
|
||||
const blobRequest = blobRequests[args.id];
|
||||
delete blobRequests[args.id];
|
||||
blobRequest.failed({url: args.url, error: args.error});
|
||||
});
|
||||
|
||||
electron.contextBridge.exposeInMainWorld(
|
||||
'electron', {
|
||||
{Expose}
|
||||
showWindow: (title, x, y, width, height) => {
|
||||
if (electron.webFrame.setZoomLevelLimits != null) { // TODO: Figure out why this check is sometimes required
|
||||
electron.webFrame.setZoomLevelLimits(1, 1);
|
||||
}
|
||||
const options = {
|
||||
title: title,
|
||||
x: x,
|
||||
y: y,
|
||||
width: width,
|
||||
height: height,
|
||||
};
|
||||
electron.ipcRenderer.send('show-window', options);
|
||||
},
|
||||
loadBlob: (desc, done, failed) => {
|
||||
const options = {
|
||||
file: desc.files[0],
|
||||
id: blobId++
|
||||
};
|
||||
blobRequests[options.id] = {
|
||||
done: done,
|
||||
failed: failed
|
||||
};
|
||||
electron.ipcRenderer.send('load-blob', options);
|
||||
}
|
||||
}
|
||||
);
|
Reference in New Issue
Block a user