Merge branch 'master' of gitea.iwm-tuebingen.de:IWMBrowser/iwmlib

This commit is contained in:
Uwe Oestermeier 2019-05-24 11:00:38 +02:00
commit d615158cf9
6 changed files with 116 additions and 13 deletions

33
dist/iwmlib.js vendored
View File

@ -1545,6 +1545,12 @@
} }
const ipc = null;
try {
ipc = require('electron').ipcRenderer;
} catch (e) {}
/** Basic class for app specific logging requirements. /** Basic class for app specific logging requirements.
* Can be used to implement persistent logging in electron apps. * Can be used to implement persistent logging in electron apps.
*/ */
@ -1553,10 +1559,15 @@
/** Static log function. /** Static log function.
* @param {*} message * @param {*} message
*/ */
log(message) { static log(message) {
if (ipc) {
ipc.send('log', message);
} else {
console.log(message); console.log(message);
} }
} }
}
/* globals Hammer, propagating */ /* globals Hammer, propagating */
@ -2684,10 +2695,26 @@
/** /**
* Distincts if the app is running inside electron or not. * Distincts if the app is running inside electron or not.
* *
* source: https://discuss.atom.io/t/detect-electron-or-web-page-running/33180/3 * source: https://github.com/cheton/is-electron
*/ */
static get isElectron() { static get isElectron() {
return typeof process != 'undefined' && process.versions && process.versions.electron !== undefined
// Renderer process
if (typeof window !== 'undefined' && typeof window.process === 'object' && window.process.type === 'renderer') {
return true
}
// Main process
if (typeof process !== 'undefined' && typeof process.versions === 'object' && !!process.versions.electron) {
return true
}
// Detect the user agent when the `nodeIntegration` option is set to true
if (typeof navigator === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent.indexOf('Electron') >= 0) {
return true
}
return false
} }
/** Returns the display resolution. Necessary for retina displays. /** Returns the display resolution. Necessary for retina displays.

33
dist/iwmlib.pixi.js vendored
View File

@ -4709,6 +4709,12 @@
// } // }
} }
const ipc = null;
try {
ipc = require('electron').ipcRenderer;
} catch (e) {}
/** Basic class for app specific logging requirements. /** Basic class for app specific logging requirements.
* Can be used to implement persistent logging in electron apps. * Can be used to implement persistent logging in electron apps.
*/ */
@ -4717,10 +4723,15 @@
/** Static log function. /** Static log function.
* @param {*} message * @param {*} message
*/ */
log(message) { static log(message) {
if (ipc) {
ipc.send('log', message);
} else {
console.log(message); console.log(message);
} }
} }
}
/* globals Hammer, propagating */ /* globals Hammer, propagating */
@ -5848,10 +5859,26 @@
/** /**
* Distincts if the app is running inside electron or not. * Distincts if the app is running inside electron or not.
* *
* source: https://discuss.atom.io/t/detect-electron-or-web-page-running/33180/3 * source: https://github.com/cheton/is-electron
*/ */
static get isElectron() { static get isElectron() {
return typeof process != 'undefined' && process.versions && process.versions.electron !== undefined
// Renderer process
if (typeof window !== 'undefined' && typeof window.process === 'object' && window.process.type === 'renderer') {
return true
}
// Main process
if (typeof process !== 'undefined' && typeof process.versions === 'object' && !!process.versions.electron) {
return true
}
// Detect the user agent when the `nodeIntegration` option is set to true
if (typeof navigator === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent.indexOf('Electron') >= 0) {
return true
}
return false
} }
/** Returns the display resolution. Necessary for retina displays. /** Returns the display resolution. Necessary for retina displays.

View File

@ -37,10 +37,26 @@ export class Capabilities {
/** /**
* Distincts if the app is running inside electron or not. * Distincts if the app is running inside electron or not.
* *
* source: https://discuss.atom.io/t/detect-electron-or-web-page-running/33180/3 * source: https://github.com/cheton/is-electron
*/ */
static get isElectron() { static get isElectron() {
return typeof process != 'undefined' && process.versions && process.versions.electron !== undefined
// Renderer process
if (typeof window !== 'undefined' && typeof window.process === 'object' && window.process.type === 'renderer') {
return true
}
// Main process
if (typeof process !== 'undefined' && typeof process.versions === 'object' && !!process.versions.electron) {
return true
}
// Detect the user agent when the `nodeIntegration` option is set to true
if (typeof navigator === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent.indexOf('Electron') >= 0) {
return true
}
return false
} }
/** Returns the display resolution. Necessary for retina displays. /** Returns the display resolution. Necessary for retina displays.

22
lib/logging.html Normal file
View File

@ -0,0 +1,22 @@
<!doctype html>
<html lang="en">
<head>
<title>Logging Doctest</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="./3rdparty/highlight/styles/default.css">
<link rel="stylesheet" href="../css/doctest.css">
<script src="./3rdparty/highlight/highlight.pack.js"></script>
<script src="../dist/iwmlib.3rdparty.js"></script>
<script src="../dist/iwmlib.js"></script>
</head>
<body id="page" onload="Doctest.run()">
<h1>
Logging
</h1>
<p>Store informations of your app permanently.</p>
<script class="doctest">
Logging.log('app started')
</script>
</body>

View File

@ -1,3 +1,9 @@
const ipc = null
try {
ipc = require('electron').ipcRenderer
} catch (e) {}
/** Basic class for app specific logging requirements. /** Basic class for app specific logging requirements.
* Can be used to implement persistent logging in electron apps. * Can be used to implement persistent logging in electron apps.
*/ */
@ -6,7 +12,12 @@ export default class Logging {
/** Static log function. /** Static log function.
* @param {*} message * @param {*} message
*/ */
log(message) { static log(message) {
if (ipc) {
ipc.send('log', message)
} else {
console.log(message) console.log(message)
} }
} }
}

View File

@ -1,6 +1,6 @@
{ {
"name": "iwmlib", "name": "iwmlib",
"version": "1.0.4", "version": "1.0.7",
"description": "An Open Source library for multi-touch, WebGL powered applications.", "description": "An Open Source library for multi-touch, WebGL powered applications.",
"main": "index.js", "main": "index.js",
"directories": { "directories": {