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

View File

@ -52,7 +52,8 @@ function createWindow(){
// and load the index.html of the app. // and load the index.html of the app.
win.loadURL(url.format({ win.loadURL(url.format({
// XXX unify this with index.html // 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:', protocol: 'file:',
slashes: true slashes: true
})) }))

View File

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

View File

@ -33,7 +33,7 @@
<script> <script>
if(window.require && window.nw){ if(window.require){
window.__devtools_failsafe = setTimeout(function(){ window.__devtools_failsafe = setTimeout(function(){
// nw... // nw...
if(window.nw){ if(window.nw){
@ -50,7 +50,7 @@ if(window.require && window.nw){
</script> </script>
<!-- Electron related fix --> <!-- 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 --> <!-- 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="ext-lib/require.js"></script>
<script src="cfg/requirejs.js"></script> <script src="cfg/requirejs.js"></script>
<script> <script>
requirejs(['cfg/requirejs.js', 'ui'])
typeof(process) != 'undefined' ?
require('./cfg/requirejs')
: requirejs(['cfg/requirejs'])
requirejs(['ui'])
</script> </script>
</head> </head>

View File

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