Created
November 17, 2015 11:57
-
-
Save ghostoy/447d08051177fa3dc29c to your computer and use it in GitHub Desktop.
NW.js shim for providing backward compatible for NW13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
// detect `nw` object of NW13 | |
if (!(self.nw && self.nw.require)) return; | |
var realrequire = nw.require; | |
self.require = function() { | |
if (arguments[0] === 'nw.gui') { | |
return nw; | |
} else { | |
return realrequire.apply(self, [].slice.call(arguments, 0)); | |
} | |
}; | |
// Following items exist when running with `--mixed-context`. | |
// Copy them from `nw` to browser context | |
if (!self.process) self.process = self.nw.process; | |
if (!self.Buffer) self.Buffer = self.nw.Buffer; | |
if (!self.global) self.global = self.nw.global; | |
if (!self.root) self.root = self.nw.root; | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment