fixing nw runtime compatibility...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2018-01-30 06:36:48 +03:00
parent 51b3f4eba3
commit e1615cc7df
5 changed files with 27 additions and 14 deletions

View File

@ -162,7 +162,7 @@ ELECTRON_DIST ?= electron-$(ELECTRON_VERSION)-$(TARGET_OS)-$(ARCH).zip
# NW...
#
# XXX get the version dynamically... (???)
NW_VERSION ?= v0.27.5
NW_VERSION ?= v0.28.0
NW_DIST ?= nwjs-sdk-$(NW_VERSION)-$(NW_OS)-$(ARCH).zip
NW_DOWNOAD_URL ?= https://dl.nwjs.io/$(NW_VERSION)
@ -554,13 +554,18 @@ $(TARGET_DIR)/$(ELECTRON_DIST):
# pack app.asar (electron-specific)...
# XXX should this update package.json -> set "main" to "e.js"...
.PRECIOUS: $(BUILD_DIR)/app.asar
# XXX do we need to track changes to pack-full or to build it only if
# app.asar is deleted?
# ...should we bakup the original package.json???
#$(BUILD_DIR)/app.asar:
# make check $(PACK_FULL)
$(BUILD_DIR)/app.asar: $(PACK_FULL)
cd $(BUILD_DIR) ; \
# update package.json to start electron...
cd "$(BUILD_DIR)/$(APP_NAME)/" ; \
cat package.json | sed 's/"index.html"/"e.js"/g' > package.json
cd "$(BUILD_DIR)" ; \
asar p "$(APP_NAME)" app.asar \
--exclude-hidden \
--unpack-dir node_modules/sharp
@ -641,12 +646,13 @@ $(TARGET_DIR)/$(NW_DIST):
# NOTE: this needs a clean app dir...
# XXX this is not runnable yet...
.PRECIOUS: $(BUILD_DIR)/package.nw
$(BUILD_DIR)/package.nw: INCLUDE_NODE_MODULES += $(INCLUDE_NW_NODE_MODULES)
$(BUILD_DIR)/package.nw: PACK_MINIMAL = $(BUILD_DIR)/$(APP_NAME)/ \
$(call includeNodeModules,$(INCLUDE_NODE_MODULES))
$(BUILD_DIR)/package.nw: $$(PACK_MINIMAL)
# update package.json...
# update package.json to start nw...
cd "$<" ; \
cat package.json | sed 's/"e.js"/"index.html"/g' > package.json
$(call zipFrom,$<,$@,*)

View File

@ -52,7 +52,8 @@ function createWindow(){
// and load the index.html of the app.
win.loadURL(url.format({
// XXX unify this with index.html
pathname: path.join(__dirname, 'electron.html'),
//pathname: path.join(__dirname, 'electron.html'),
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
}))

View File

@ -31,7 +31,7 @@
<script>
if(window.require && window.nw){
if(window.require){
window.__devtools_failsafe = setTimeout(function(){
// nw...
if(window.nw){
@ -48,7 +48,7 @@ if(window.require && window.nw){
</script>
<!-- Electron related fix -->
<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
<script>if(typeof module === 'object'){ window.module = module; module = undefined }</script>
@ -81,7 +81,7 @@ if(window.require && window.nw){
<!-- Electron related unfix -->
<script>if (window.module) module = window.module;</script>
<script>if(window.module){ module = window.module }</script>
<script>
require('./cfg/requirejs')

View File

@ -33,7 +33,7 @@
<script>
if(window.require && window.nw){
if(window.require){
window.__devtools_failsafe = setTimeout(function(){
// nw...
if(window.nw){
@ -50,7 +50,7 @@ if(window.require && window.nw){
</script>
<!-- Electron related fix -->
<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
<script>if(typeof module === 'object'){ window.module = module; module = undefined }</script>
@ -83,14 +83,18 @@ if(window.require && window.nw){
<!-- Electron related unfix -->
<script>if (window.module) module = window.module;</script>
<script>if(window.module){ module = window.module }</script>
<!--script data-main="ui" src="ext-lib/require.js"></script-->
<script src="ext-lib/require.js"></script>
<script src="cfg/requirejs.js"></script>
<script>
requirejs(['cfg/requirejs.js', 'ui'])
typeof(process) != 'undefined' ?
require('./cfg/requirejs')
: requirejs(['cfg/requirejs'])
requirejs(['ui'])
</script>
</head>

View File

@ -1,6 +1,6 @@
{
"name": "ImageGrid.Viewer.g4",
"main": "e.js",
"main": "index.html",
"version": "4.0.0a",
"author": "Alex A. Naanou <alex.nanou@gmail.com> (https://github.com/flynx)",
"contributors": [],
@ -54,7 +54,9 @@
"scripts": {
"build-css": "lessc css/layout.less css/layout.css",
"build-dist": "make dist",
"start": "electron e.js"
"start": "electron e.js",
"start-nw": "nw .",
"start-electron": "electron e.js ."
},
"vim-cfg": " vim:set ts=2 sw=2 expandtab : "
}