fixed loading in electron, still need to merge the requirejs config (ui.js, cfg/..) and html...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-11-01 04:53:36 +03:00
parent 47066f5da0
commit d456103823
6 changed files with 186 additions and 41 deletions

View File

@ -0,0 +1,45 @@
/**********************************************************************
*
*
*
**********************************************************************/
global.requirejs = global.requirejs || require('requirejs')
requirejs.config({
nodeRequire: require,
//baseUrl: __dirname,
// XXX this does not work on direct filesystem access...
//urlArgs: 'bust='+Date.now(),
paths: {
//text: 'node_modules/requirejs-plugins/lib/text',
//json: 'node_modules/requirejs-plugins/src/json',
//react: 'node_modules/react/dist/react-with-addons.min.js',
//'react-dom': 'node_modules/react-dom/dist/react-dom.min.js',
//'ext-lib/preact': './node_modules/preact/dist/preact.dev',
'lib/object': 'node_modules/ig-object/object',
'lib/actions': 'node_modules/ig-actions/actions',
'lib/features': 'node_modules/ig-features/features',
//'lib/keyboard': './node_modules/ig-keyboard/keyboard',
},
map: {
'*': {
// back-refs
// ...these enable the npm modules reference each other in
// a cross-platform manner....
'ig-object': 'lib/object',
'ig-actions': 'lib/actions',
'ig-features': 'lib/features',
//'ig-keyboard': 'lib/keyboard',
},
},
})
/**********************************************************************
* vim:set ts=4 sw=4 : */

View File

@ -14,6 +14,13 @@ var path = require('path')
var url = require('url')
//---------------------------------------------------------------------
//require('./cfg/requirejs')
//var _require = require
//require = requirejs
/*********************************************************************/
@ -37,7 +44,7 @@ function createWindow() {
// and load the index.html of the app.
win.loadURL(url.format({
// XXX for some reason the system is loaded twice...
pathname: path.join(__dirname, 'index.html'),
pathname: path.join(__dirname, 'electron.html'),
protocol: 'file:',
slashes: true
}))

124
ui (gen4)/electron.html Executable file
View File

@ -0,0 +1,124 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="msapplication-tap-highlight" content="no" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-Bold.ttf" />
<link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-BoldItalic.ttf" />
<link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-ExtraBold.ttf" />
<link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-ExtraBoldItalic.ttf" />
<link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-Italic.ttf" />
<link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-Light.ttf" />
<link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-LightItalic.ttf" />
<link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-Regular.ttf" />
<link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-Semibold.ttf" />
<link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-SemiboldItalic.ttf" />
<link rel="stylesheet" href="css/fonts.css" />
<link rel="stylesheet" href="css/layout.css" />
<link rel="stylesheet" href="css/editor.css" />
<link rel="stylesheet" href="css/widget/browse.css" />
<link rel="stylesheet" href="css/widget/overlay.css" />
<link rel="stylesheet" href="css/widget/drawer.css" />
<link rel="stylesheet" href="css/loader.css" />
<link rel="stylesheet" href="css/experimenting.css" />
<script>
if(window.require && window.nw){
window.__devtools_failsafe = setTimeout(function(){
// nw...
if(window.nw){
nw.Window.get().showDevTools()
// electron...
} else {
try{
require('electron').remote.getCurrentWindow().openDevTools()
} catch(err){ }
}
}, 5000)
}
</script>
<!-- Electron related fix -->
<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
<!-- jQuery -->
<script src="ext-lib/jquery.js"></script>
<!--script src="ext-lib\jquery-1.9.1.js"></script-->
<!-- migrating to jQuery 1.9.x -->
<!--script src="ext-lib/jquery-migrate-1.4.1.js"></script-->
<!-- migrating to jQuery 3.x -->
<!--script src="ext-lib/jquery-migrate-3.0.0.js"></script-->
<script src="ext-lib/jquery-ui.js"></script>
<script src="ext-lib/jquery.ui.touch-punch.min.js"></script>
<!-- preact.js -->
<script src="node_modules/preact/dist/preact.min.js"></script>
<!-- velocity.js -->
<script src="ext-lib/velocity.min.js"></script>
<script src="ext-lib/virtual-dom.js"></script>
<!-- hammer.js -->
<script src="ext-lib/hammer.min.js"></script>
<script src="ext-lib/jquery.hammer.js"></script>
<script src="lib/jli.js"></script>
<!-- Electron related unfix -->
<script>if (window.module) module = window.module;</script>
<script>
require('./cfg/requirejs')
requirejs('./ui')
</script>
</head>
<body>
<!-- for viewer structure doc see: ribbons.js... -->
<!--div class="viewer gray marks-visible" empty-help="Press 'O' to load, 'F1' for help or '?' for keyboard mappings."-->
<!--div class="ribbon-set"-->
<!-- DEBUG: remove when not needed... -->
<!--div class="point" title="current origin point"> </div-->
<!-- DEBUG: end -->
<!--/div-->
<!-- XXX should these be here???
<div class="overlay-block">
<div class="background"></div>
<div class="content"></div>
</div>
-->
<!-- DEBUG: remove when not needed... -->
<!--div class="container-center"> </div-->
<!-- DEBUG: end -->
<!--/div-->
<div class="viewer gray marks-visible" tabindex="0"></div>
<!-- vim:set ts=4 sw=4 spell : -->
</body>
</html>

View File

@ -151,11 +151,11 @@ var ElectronHostActions = actions.Actions({
get size(){
return electron.remote.getCurrentWindow().getSize() },
set size(value){
electron.remote.getCurrentWindow().setSize(value) },
value && electron.remote.getCurrentWindow().setSize(value[0], value[1]) },
get position(){
return electron.remote.getCurrentWindow().getPosition() },
set position(value){
electron.remote.getCurrentWindow().setPosition(value) },
value && electron.remote.getCurrentWindow().setPosition(value[0], value[1]) },
show: ['- Window/',
function(){
@ -372,8 +372,8 @@ module.AppControl = core.ImageGridFeatures.Feature({
// - ready protocol breaks -- need to call .ready() to unstall
// the viewer
// ...does this all have anything to do with double init???
//isApplicable: function(){ return this.runtime.desktop },
isApplicable: function(){ return this.runtime.desktop && !this.runtime.electron },
isApplicable: function(){ return this.runtime.desktop },
//isApplicable: function(){ return this.runtime.desktop && !this.runtime.electron },
// XXX show main window...
handlers: [

View File

@ -8,42 +8,13 @@
//var DEBUG = DEBUG != null ? DEBUG : true
global.requirejs = global.requirejs || require('requirejs')
requirejs.config({
nodeRequire: require,
//baseUrl: __dirname,
require('./cfg/requirejs')
// XXX this does not work on direct filesystem access...
//urlArgs: 'bust='+Date.now(),
paths: {
//text: 'node_modules/requirejs-plugins/lib/text',
//json: 'node_modules/requirejs-plugins/src/json',
//react: 'node_modules/react/dist/react-with-addons.min.js',
//'react-dom': 'node_modules/react-dom/dist/react-dom.min.js',
'lib/object': 'node_modules/ig-object/object',
'lib/actions': 'node_modules/ig-actions/actions',
'lib/features': 'node_modules/ig-features/features',
},
map: {
'*': {
// back-refs
// ...these enable the npm modules reference each other in
// a cross-platform manner....
'ig-object': 'lib/object',
'ig-actions': 'lib/actions',
'ig-features': 'lib/features',
//'ig-keyboard': 'lib/keyboard',
},
},
})
var _require = require
require = requirejs
//---------------------------------------------------------------------
// XXX need to automate this...

View File

@ -15,6 +15,9 @@ if((typeof(process) != 'undefined' ? process : {}).__nwjs){
.addPath(path.dirname(process.execPath) + '/node_modules/')
}
//require('./cfg/requirejs')
//*
// Setup modules loaded from npm...
//
@ -34,9 +37,6 @@ var requirejs_cfg = {
'lib/actions': './node_modules/ig-actions/actions',
'lib/features': './node_modules/ig-features/features',
//'lib/keyboard': './node_modules/ig-keyboard/keyboard',
//'ext-lib/preact': './node_modules/preact/dist/preact.dev',
},
map: {
'*': {
@ -46,8 +46,6 @@ var requirejs_cfg = {
'ig-object': 'lib/object',
'ig-actions': 'lib/actions',
'ig-features': 'lib/features',
//'ig-keyboard': 'lib/keyboard',
},
},
}