From 2854030a3f699188676f19ba16a5400c4976f23c Mon Sep 17 00:00:00 2001 From: Joe Wreschnig Date: Fri, 10 Apr 2015 23:39:16 +0200 Subject: [PATCH] Migrate from node-webkit to NW.js. --- .gitignore | 3 +- .projectile | 2 +- BUGS.org | 12 +++-- Makefile | 11 +++-- rules/node-webkit.mk | 99 ---------------------------------------- rules/nwjs.mk | 98 +++++++++++++++++++++++++++++++++++++++ src/yuu/core.js | 2 +- src/yuu/data/license.txt | 12 ++--- src/yuu/director.js | 4 +- tools/generate-nw | 4 +- tools/generate-osx-app | 4 +- tools/nw-linux-wrapper | 2 +- 12 files changed, 128 insertions(+), 125 deletions(-) delete mode 100644 rules/node-webkit.mk create mode 100644 rules/nwjs.mk diff --git a/.gitignore b/.gitignore index 17918bb..0ca1a89 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,4 @@ .DS_Store node_modules build -node-webkit - +nwjs diff --git a/.projectile b/.projectile index 7865c8b..b3aa348 100644 --- a/.projectile +++ b/.projectile @@ -1,2 +1,2 @@ -/node_modules --/node-webkit +-/nwjs diff --git a/BUGS.org b/BUGS.org index 735bf0b..ccdfe9d 100644 --- a/BUGS.org +++ b/BUGS.org @@ -4,11 +4,13 @@ performance. ** Use standard Unicode codepoints for icon fonts This is done via the [[https://korewanetadesu.com/pages/fontstandard.html][Font Standard]] icon font. -** Work around incorrect Safari JIT generation. +** Work around incorrect Safari JIT generation Some details of the symptoms / likely-but-unproven cause at https://korewanetadesu.com/safari-jit-bug.html. -** Sped up background and book noise animations. -** Cat paws. +** Sped up background and book noise animations +** Cat paws +** DONE Migrate to nw.js (from node-webkit) + * v1.2 ** DONE Override the GPU blacklist on GNU/Linux @@ -47,4 +49,6 @@ ** TODO Choppy / staticy audio on iOS Especially when backgrounding, e.g. switching tabs. There's probably no easy way to avoid this. -** TODO Upgrade from node-webkit to "nw". +** TODO Scrolling is broken in licensing window +This began when upgrading to nw.js 0.12 (from node-webkit 0.10.4). If +it's broken one place it's probably broken other places also. diff --git a/Makefile b/Makefile index 408a9c2..f2d4697 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,15 @@ #!/usr/bin/make -f -node-webkit-version := 0.10.4 +nwjs-version := 0.12.0 all: +print-%: ; @echo $*=$($*) .DELETE_ON_ERROR: include rules/programs.mk include rules/javascript.mk include rules/icons.mk include rules/git.mk -include rules/node-webkit.mk +include rules/nwjs.mk include rules/pngcrush.mk .PHONY: all check distclean lint test dist clean serve @@ -70,7 +71,7 @@ clean: distclean: clean $(RM) -r node_modules - $(RM) $(node-webkit-archives) + $(RM) $(nwjs-archives) $(DISTROOT)-src.zip $(DISTROOT)-src.tar.gz: | .git mkdir -p $(@D) @@ -92,8 +93,8 @@ $(DISTROOT).bare.zip: | .git tools/generate-appcache $@.tmp mv $@.tmp $@ -# Python's zipfile module generates zipfiles that node-webkit cannot -# read, so delegate to a real zip tool. +# Python's zipfile module generates zipfiles that NW.js cannot read, +# so delegate to a real zip tool. %.nw: %.bare.zip tools/generate-nw $(RM) -r $@ $@.tmp $(UNZIP) -d $@.tmp $< diff --git a/rules/node-webkit.mk b/rules/node-webkit.mk deleted file mode 100644 index dd46e17..0000000 --- a/rules/node-webkit.mk +++ /dev/null @@ -1,99 +0,0 @@ -# This is free and unencumbered software released into the public -# domain. To the extent possible under law, the author of this file -# waives all copyright and related or neighboring rights to it. - -.DELETE_ON_ERROR: - -include $(dir $(realpath $(lastword $(MAKEFILE_LIST))))programs.mk - -node-webkit-platforms := \ - osx-x64.zip osx-ia32.zip \ - linux-x64.tar.gz linux-ia32.tar.gz \ - win-ia32.zip - -node-webkit-pattern := \ - $(addprefix node-webkit-v%-,$(node-webkit-platforms)) - -# These are like 30MB, don't download them every time. -.PRECIOUS: $(node-webkit-pattern) - -$(node-webkit-pattern): - mkdir -p $(@D) - wget -O $@ http://dl.node-webkit.org/v$(*F)/$(@F) || ($(RM) $@ && exit 1) - -node-webkit-version ?= 0.10.2 -node-webkit-prefix ?= node-webkit/ -node-webkit-directx = $(addprefix $(node-webkit-prefix),d3dcompiler_43.dll d3dcompiler_46.dll) - -node-webkit = $(node-webkit-prefix)node-webkit-v$(firstword $(value node-webkit-version-$1) $(node-webkit-version))-$1 - -node-webkit-archives = \ - $(foreach p,$(node-webkit-platforms),$(call node-webkit,$(p))) - -define node-webkit-package-osx - $(RM) $@ - $(RM) -r $(@:.zip=) - $(UNZIP) -d $(@D) $2 - mv $(@D)/$(notdir $(2:.zip=)) $(@:.zip=) - tools/generate-osx-app $(@:.zip=) $1 - $(RM) $(@:.zip=)/nwsnapshot - mv $(@:.zip=)/credits.html $(@:.zip=)/node-webkit\ credits.html - cd $(@D) && $(ZIP) -r $(@F) $(@F:.zip=) - $(RM) -r $(@:.zip=) -endef - -%-osx-ia32.zip: %.nw $(call node-webkit,osx-ia32.zip) - $(call node-webkit-package-osx,$<,$(word 2,$^)) - -%-osx-x64.zip: %.nw $(call node-webkit,osx-x64.zip) - $(call node-webkit-package-osx,$<,$(word 2,$^)) - -define node-webkit-package-linux - $(RM) $@ - $(RM) -r $(@:.tar.gz=) - tar -C $(@D) -xzf $2 - mkdir -p $(@:.tar.gz=) - mv $(@D)/$(notdir $(2:.tar.gz=)) $(@:.tar.gz=)/nw - cp -a $1 $(@:.tar.gz=)/nw/package.nw - cp -a tools/nw-linux-wrapper $(@:.tar.gz=)/`echo $(notdir $1) | sed -E 's/_.+//'` - $(RM) $(@:.tar.gz=)/nw/nwsnapshot - mv $(@:.tar.gz=)/nw/credits.html $(@:.tar.gz=)/nw/node-webkit\ credits.html - tar -czf $@ -C $(@D) $(@F:.tar.gz=) - $(RM) -r $(@:.tar.gz=) -endef - -%-linux-ia32.tar.gz: %.nw $(call node-webkit,linux-ia32.tar.gz) - $(call node-webkit-package-linux,$<,$(word 2,$^)) - -%-linux-x64.tar.gz: %.nw $(call node-webkit,linux-x64.tar.gz) - $(call node-webkit-package-linux,$<,$(word 2,$^)) - -WINE ?= wine - -node-webkit-icon = $(shell $(UNZIP) -p $1 package.json | grep -Eo '"[^"]+.ico"' -m 1) - -define node-webkit-package-win - $(RM) $@ - $(RM) -r $(@:.zip=) - if $(UNZIP) -l $2 credits.html > /dev/null; then $(UNZIP) -d $(@D)/$(notdir $(2:.zip=)) $2; else $(UNZIP) -d $(@D) $2; fi - mv $(@D)/$(notdir $(2:.zip=)) $(@:.zip=) - $(RM) $(@:.zip=)/nwsnapshot.exe - $(UNZIP) -p $< $(call node-webkit-icon,$<) > $(@D)/icon.ico - $(WINE) tools/rcedit.exe $(@:.zip=)/nw.exe --set-icon $(@D)/icon.ico - $(RM) $(@D)/icon.ico - mv $(@:.zip=)/credits.html $(@:.zip=)/node-webkit\ credits.html - cp -a $< $(@:.zip=)/package.nw - cp -a $(node-webkit-directx) $(@:.zip=) - mv $(@:.zip=)/nw.exe $(@:.zip=)/`echo $(notdir $1) | sed -E 's/_.+/.exe/'` - cd $(@D) && $(ZIP) -r $(@F) $(@F:.zip=) - $(RM) -r $(@:.zip=) -endef - -%-win-ia32.zip: %.nw $(call node-webkit,win-ia32.zip) $(node-webkit-directx) - $(call node-webkit-package-win,$<,$(word 2,$^)) - -$(node-webkit-directx): - wget -O $@ 'https://github.com/cefsharp/cef-binary/raw/1e51255cf77d267899bf7834768b8774affaad2d/cef_binary_3.y.z_windows32/Release/'$(notdir $@) - -$(node-webkit-prefix)dxwebsetup.exe: - wget -O $@ http://download.microsoft.com/download/1/7/1/1718CCC4-6315-4D8E-9543-8E28A4E18C4C/dxwebsetup.exe diff --git a/rules/nwjs.mk b/rules/nwjs.mk new file mode 100644 index 0000000..42bbf79 --- /dev/null +++ b/rules/nwjs.mk @@ -0,0 +1,98 @@ +# This is free and unencumbered software released into the public +# domain. To the extent possible under law, the author of this file +# waives all copyright and related or neighboring rights to it. + +.DELETE_ON_ERROR: + +include $(dir $(realpath $(lastword $(MAKEFILE_LIST))))programs.mk + +nwjs-platforms := \ + osx-x64.zip osx-ia32.zip \ + linux-x64.tar.gz linux-ia32.tar.gz \ + win-ia32.zip + +nwjs-pattern := \ + $(addprefix nwjs-v%-,$(nwjs-platforms)) + +# These are like 30MB, don't download them every time. +.PRECIOUS: $(nwjs-pattern) + +$(nwjs-pattern): + mkdir -p $(@D) + wget -O $@ http://dl.nwjs.io/v$(*F)/$(@F) || ($(RM) $@ && exit 1) + +nwjs-version ?= 0.10.2 +nwjs-prefix ?= nwjs/ +nwjs-directx = $(addprefix $(nwjs-prefix),d3dcompiler_43.dll d3dcompiler_46.dll) + +nwjs = $(nwjs-prefix)nwjs-v$(firstword $(value nwjs-version-$1) $(nwjs-version))-$1 + +nwjs-archives = $(foreach p,$(nwjs-platforms),$(call nwjs,$(p))) + +define nwjs-package-osx + $(RM) $@ + $(RM) -r $(@:.zip=) + $(UNZIP) -d $(@D) $2 + mv $(@D)/$(notdir $(2:.zip=)) $(@:.zip=) + tools/generate-osx-app $(@:.zip=) $1 + $(RM) $(@:.zip=)/nwjc + mv $(@:.zip=)/credits.html $(@:.zip=)/nwjs\ credits.html + cd $(@D) && $(ZIP) -r $(@F) $(@F:.zip=) + $(RM) -r $(@:.zip=) +endef + +%-osx-ia32.zip: %.nw $(call nwjs,osx-ia32.zip) + $(call nwjs-package-osx,$<,$(word 2,$^)) + +%-osx-x64.zip: %.nw $(call nwjs,osx-x64.zip) + $(call nwjs-package-osx,$<,$(word 2,$^)) + +define nwjs-package-linux + $(RM) $@ + $(RM) -r $(@:.tar.gz=) + tar -C $(@D) -xzf $2 + mkdir -p $(@:.tar.gz=) + mv $(@D)/$(notdir $(2:.tar.gz=)) $(@:.tar.gz=)/nw + cp -a $1 $(@:.tar.gz=)/nw/package.nw + cp -a tools/nw-linux-wrapper $(@:.tar.gz=)/`echo $(notdir $1) | sed -E 's/_.+//'` + $(RM) $(@:.tar.gz=)/nw/nwjc + mv $(@:.tar.gz=)/nw/credits.html $(@:.tar.gz=)/nw/nwjs\ credits.html + tar -czf $@ -C $(@D) $(@F:.tar.gz=) + $(RM) -r $(@:.tar.gz=) +endef + +%-linux-ia32.tar.gz: %.nw $(call nwjs,linux-ia32.tar.gz) + $(call nwjs-package-linux,$<,$(word 2,$^)) + +%-linux-x64.tar.gz: %.nw $(call nwjs,linux-x64.tar.gz) + $(call nwjs-package-linux,$<,$(word 2,$^)) + +WINE ?= wine + +nwjs-icon = $(shell $(UNZIP) -p $1 package.json | grep -Eo '"[^"]+.ico"' -m 1) + +define nwjs-package-win + $(RM) $@ + $(RM) -r $(@:.zip=) + if $(UNZIP) -l $2 credits.html > /dev/null; then $(UNZIP) -d $(@D)/$(notdir $(2:.zip=)) $2; else $(UNZIP) -d $(@D) $2; fi + mv $(@D)/$(notdir $(2:.zip=)) $(@:.zip=) + $(RM) $(@:.zip=)/nwjc.exe + $(UNZIP) -p $< $(call nwjs-icon,$<) > $(@D)/icon.ico + $(WINE) tools/rcedit.exe $(@:.zip=)/nw.exe --set-icon $(@D)/icon.ico + $(RM) $(@D)/icon.ico + mv $(@:.zip=)/credits.html $(@:.zip=)/nwjs\ credits.html + cp -a $< $(@:.zip=)/package.nw + cp -a $(nwjs-directx) $(@:.zip=) + mv $(@:.zip=)/nw.exe $(@:.zip=)/`echo $(notdir $1) | sed -E 's/_.+/.exe/'` + cd $(@D) && $(ZIP) -r $(@F) $(@F:.zip=) + $(RM) -r $(@:.zip=) +endef + +%-win-ia32.zip: %.nw $(call nwjs,win-ia32.zip) $(nwjs-directx) + $(call nwjs-package-win,$<,$(word 2,$^)) + +$(nwjs-directx): + wget -O $@ 'https://github.com/cefsharp/cef-binary/raw/1e51255cf77d267899bf7834768b8774affaad2d/cef_binary_3.y.z_windows32/Release/'$(notdir $@) + +$(nwjs-prefix)dxwebsetup.exe: + wget -O $@ http://download.microsoft.com/download/1/7/1/1718CCC4-6315-4D8E-9543-8E28A4E18C4C/dxwebsetup.exe diff --git a/src/yuu/core.js b/src/yuu/core.js index 1d64e98..e770f86 100644 --- a/src/yuu/core.js +++ b/src/yuu/core.js @@ -160,7 +160,7 @@ req[k] = params[k]; req.onload = function () { var status = this.status; - // status === 0 is given by node-webkit for success. + // status === 0 is given by NW.js for success. if ((status >= 200 && status < 300) || status === 0) resolve(this.response); else diff --git a/src/yuu/data/license.txt b/src/yuu/data/license.txt index 6c2b4e7..062800f 100644 --- a/src/yuu/data/license.txt +++ b/src/yuu/data/license.txt @@ -497,11 +497,11 @@ OTHER DEALINGS IN THE FONT SOFTWARE. -- -This program may be distributed along with node-webkit, a wrapper for +This program may be distributed along with NW.js, a wrapper for packaging web applications for standalone use. If so, the accompanying -`node-webkit credits.html' contains its licensing information. +`nw credits.html' contains its licensing information. -This program is not a derivative work of node-webkit but rather "mere -aggregation." You do not need to account for node-webkit's licensing -terms to modify and/or redistribute parts of this program unless you -also modify and/or redistribute node-webkit. +This program is not a derivative work of NW.js but rather "mere +aggregation." You do not need to account for NW.js's licensing terms +to modify and/or redistribute parts of this program unless you also +modify and/or redistribute NW.js. diff --git a/src/yuu/director.js b/src/yuu/director.js index 051eb53..83103b3 100644 --- a/src/yuu/director.js +++ b/src/yuu/director.js @@ -140,7 +140,7 @@ // Aside from the performance considerations, deferring // resizing by multiple frames fixes mis-sizing during startup - // and fullscreen transition in node-webkit on Windows. (And + // and fullscreen transition in NW.js on Windows. (And // probably similar bugs in other configurations.) _doresize: yf.debounce(function () { this._resized = true; @@ -305,7 +305,7 @@ return; this._tickCount = 0; this._timerStart = 0; - // GNU/Linux with node-webkit sizes things incorrectly on + // GNU/Linux with NW.js sizes things incorrectly on // startup, so force a recalculating as soon as the render // loop runs. this._resized = true; diff --git a/tools/generate-nw b/tools/generate-nw index a249232..62b535c 100755 --- a/tools/generate-nw +++ b/tools/generate-nw @@ -1,8 +1,8 @@ #!/usr/bin/env python -# Generate a node-webkit package.json file for a website. +# Generate an NW.js package.json file for a website. # -# https://github.com/rogerwang/node-webkit/wiki/Manifest-format +# https://github.com/nwjs/nw.js/wiki/Manifest-format import os import re diff --git a/tools/generate-osx-app b/tools/generate-osx-app index dd05cdd..57d80a0 100755 --- a/tools/generate-osx-app +++ b/tools/generate-osx-app @@ -25,7 +25,7 @@ def main(nwdir, nwpackage): icnss = filter(lambda f: f.lower().endswith(".icns"), nwzip.namelist()) package = json.load(nwzip.open("package.json")) - app = join(nwdir, "node-webkit.app") + app = join(nwdir, "nwjs.app") title = package["window"]["title"] exe = package["name"].split(".")[-1] plist = dict( @@ -49,7 +49,7 @@ def main(nwdir, nwpackage): plist["CFBundleIconFile"] = icnss[0] plistlib.writePlist(plist, join(app, "Contents/Info.plist")) exedir = join(app, "Contents", "MacOS") - shutil.move(join(exedir, "node-webkit"), join(exedir, exe)) + shutil.move(join(exedir, "nwjs"), join(exedir, exe)) shutil.copy(nwpackage, join(app, "Contents", "Resources", "app.nw")) shutil.move(app, join(app, "..", xp_filename(title) + ".app")) diff --git a/tools/nw-linux-wrapper b/tools/nw-linux-wrapper index e195611..9e229f8 100755 --- a/tools/nw-linux-wrapper +++ b/tools/nw-linux-wrapper @@ -14,7 +14,7 @@ NWFLAGS="--enable-webgl --ignore-gpu-blacklist" PACKAGE="$NWDIR/package.nw" if [ ! -x "$NWBIN" ]; then - echo "node-webkit (nw) executable could not be found." >&2 + echo "NW.js (nw) executable could not be found." >&2 exit 127 fi -- 2.30.2